x_loc = 0;
y_loc = 0;
isMS = false;
isNN4 = false;
isGecko = false;
isKonqueror = false;
isNN6 = false;
isMac = false;
isSafari = false;
doMouse = false;
doLatLon = false;
debug = false;
// remember when this page started (so we can kill the loops later).
start_time = new Date();
start_seconds = start_time.getTime() / 1000;
loop_limit_seconds = 300+60;
//check if the latitude and longitude are defined
if(typeof(lat) != "undefined" && typeof(lon) != "undefined") { doLatLon = true; }
if (debug) {
document.writeln ("
Browser = " + navigator.appName );
document.writeln ("
Version = " + navigator.appVersion);
}
browser_version = parseFloat(navigator.appVersion)
if (!browser_version) browser_version = 0.
//browser_version = 0. // only do this during testing.
if (debug) {
document.writeln ("
extracted Browser version = " + browser_version );
}
if (navigator.appName.indexOf("Microsoft") != -1) {
if ( browser_version >= 4.) isMS = true;
// IE on Mac has different Mouse calculations.
if ( navigator.appVersion.indexOf("Mac") != -1) isMac = true;
}
if (navigator.userAgent.indexOf("Safari") >= 0) {isSafari = true;}
if (navigator.userAgent.toLowerCase().indexOf("konqueror") != -1) isKonqueror = true;
if (navigator.appName.indexOf("Netscape") != -1) {
// Netscape 6 reports v5 !!!
if ( (browser_version >= 4.) && (browser_version < 5.) ) isNN4 = true;
if ( navigator.userAgent.toLowerCase().indexOf("netscape6") != -1 ) isNN6 = true;
if ( browser_version >= 5. ) isGecko = true;
}
if (navigator.appName.indexOf("Opera") != -1) {
// Opera v7 is MS compatible for mouse distances.
if ( browser_version >= 7. ) isMS = true;
}
if (isMS || isNN4 || isGecko) doMouse = true;
if (isKonqueror) doMouse = false;
// Do not show mouse if Km is not defined.
if (Km<1) { doMouse = false }
if (debug) {
document.writeln ("
isNN4 = " + isNN4 + ", isNN6=" + isNN6)
document.writeln ("
isMS = " + isMS + ", isMac=" + isMac)
document.writeln ("
Km = " + Km);
document.writeln ("
doMouse = " + doMouse);
document.writeln ("
")
}
if (nImages>0) {
var doc; // Holds a pointer to MS or NN document (see launch).
image_href = "";
first_image = 0;
last_image = nImages-1;
animation_height = 524;
animation_width = 564;
//**************************************************************************
//=== THE CODE STARTS HERE - no need to change anything below ===
//=== global variables ====
theImages = new Array(); //holds the images
imageNum = new Array(); //keeps track of which images to omit from loop
normal_delay = 300;
delay = normal_delay; //delay between frames in 1/100 seconds
delay_step = 50;
delay_max = 4000;
delay_min = 50;
dwell_multipler = 3;
dwell_step = 1;
end_dwell_multipler = dwell_multipler;
start_dwell_multipler = dwell_multipler - 1;
current_image = first_image; //number of the current image
timeID = null;
looping = 0; // 0-stopped, 1-playing
play_mode = 0; // 0-normal, 1-loop, 2-sweep
size_valid = 0;
} // (end of if there are images to loop)
//==============================================================
//== All previous statements are performed as the page loads. ==
//== The following functions are also defined at this time. ==
//==============================================================
//===> Load and initialize everything once page is downloaded
// (called from 'onLoad' in
)
function launch()
{
doc = document;
if (isNN4) doc = document.animationlayer.document;
if (nImages==0) {
doc.animation.src = "IDR.no.images.gif" // Scrub the 'Please wait' image.
return;
}
if (doMouse) startxy (); // Start pointer-origin code.
// If there is only 1 image, show it, but dont start the loop.
if (nImages==1) {
current_image = 0;
theImages[current_image] = new Image();
theImages[current_image].src = image_href + theImageNames[current_image];
imageNum[current_image] = true; // pretend it is ready.
display_current_image();
return;
}
//
// step 5: construct filenames for all images
//
for (var i = first_image; i <= last_image; i++)
{
current_image = i;
theImages[current_image] = new Image();
theImages[current_image].src = image_href + theImageNames[current_image];
imageNum[current_image] = false; // image is not ready yet.
}
current_image = first_image;
imageNum[current_image] = true; // pretend it is ready.
// this needs to be done to set the right mode when the page is manually reloaded
change_mode (1);
fwd();
}
function loop_time_OK ()
{
// This whole web page should auto-refresh itself every nnn seconds
// e.g. every 300 seconds (5 minutes).
// If we see that the loops have been running for more than nnn seconds,
// then assume that the browser has been iconised, which prevents html
// refreshes, but does not stop the loop. The loop maybe uselessly
// trying to fetch out of date images and generating a lot of 404's
// swamping the web server.
// So we stop the loop ourselves, and stop useless web traffic.
// When the browser is un-iconised, the page-refresh kicks in an restarts it.
// Usage:
// if (loop_time_OK ()) { continue looping }
// else { stop(); }
now_time = new Date();
now_seconds = now_time.getTime() / 1000;
elaspsed_seconds = now_seconds - start_seconds;
if (elaspsed_seconds < loop_limit_seconds) { return 1;}
else { return 0;}
}
//==> Display the 'current_image'.
function display_current_image()
{
//display image onto screen
doc.animation.src = theImages[current_image].src;
//display image number
document.control_form.frame_nr.value = current_image+1;
}
//===> Stop the animation
function stop()
{
//== cancel animation (timeID holds the expression which calls the fwd or bkwd function) ==
if (looping == 1) {
clearTimeout (timeID);
}
looping = 0;
return;
}
//===> Display animation in fwd direction in either loop or sweep mode
function animate_fwd()
{
if (nImages<=1) return;
current_image++; //increment image number
//== check if current image has exceeded loop bound ==
if (current_image > last_image) {
if (play_mode == 1) { //fwd loop mode - skip to first image
current_image = first_image;
}
if (play_mode == 2) { //sweep mode - change directions (go bkwd)
current_image = last_image;
animate_rev();
return;
}
}
//== check to ensure that current image has not been deselected from the loop ==
//== if it has, then find the next image that hasn't been ==
while (imageNum[current_image] == false) {
if (theImages[current_image].complete) {
imageNum[current_image] = true;
break;
}
current_image++;
if (current_image > last_image) {
if (play_mode == 1)
current_image = first_image;
if (play_mode == 2) {
current_image = last_image;
animate_rev();
return;
}
}
}
display_current_image();
delay_time = delay;
if (current_image == first_image) delay_time = start_dwell_multipler*delay;
if (current_image == last_image) delay_time = end_dwell_multipler*delay;
//== call "animate_fwd()" again after a set time (delay_time) has elapsed ==
// (Maybe stop the loops if we are iconised).
if (loop_time_OK()) { timeID = setTimeout("animate_fwd()", delay_time); }
else { stop(); }
}
//===> Display animation in reverse direction
function animate_rev()
{
if (nImages<=1) return;
current_image--; //decrement image number
//== check if image number is before lower loop bound ==
if (current_image < first_image) {
if (play_mode == 1) { //rev loop mode - skip to last image
current_image = last_image;
}
if (play_mode == 2) {
current_image = first_image; //sweep mode - change directions (go fwd)
animate_fwd();
return;
}
}
//== check to ensure that current image has not been deselected from the loop ==
//== if it has, then find the next image that hasn't been ==
while (imageNum[current_image] == false) {
if (theImages[current_image].complete) {
imageNum[current_image] = true;
break;
}
current_image--;
if (current_image < first_image) {
if (play_mode == 1)
current_image = last_image;
if (play_mode == 2) {
current_image = first_image;
animate_fwd();
return;
}
}
}
display_current_image();
delay_time = delay;
if (current_image == first_image) delay_time = start_dwell_multipler*delay;
if (current_image == last_image) delay_time = end_dwell_multipler*delay;
//== call "animate_rev()" again after a set amount of time (delay_time) has elapsed ==
// (Maybe stop the loops if we are iconised).
if (loop_time_OK()) { timeID = setTimeout("animate_rev()", delay_time); }
else { stop(); }
}
//===> Changes playing speed by adding to or substracting from the delay between frames
function change_speed(dv)
{
delay+=dv;
//== check to ensure max and min delay constraints have not been crossed ==
if(delay > delay_max) delay = delay_max;
if(delay < delay_min) delay = delay_min;
}
//===> functions that changed the dwell rates.
function change_end_dwell(dv) {
end_dwell_multipler+=dv;
if ( end_dwell_multipler < 1 ) end_dwell_multipler = 0;
}
function change_start_dwell(dv) {
start_dwell_multipler+=dv;
if ( start_dwell_multipler < 1 ) start_dwell_multipler = 0;
}
//===> Increment to next image
function incrementImage()
{
var number;
if (nImages<=1) return;
stop();
current_image++;
number = current_image;
//== if image is last in loop, increment to first image ==
if (number > last_image) number = first_image;
//== check to ensure that image has not been deselected from loop ==
while (imageNum[number] == false) {
if (theImages[number].complete) {
imageNum[number] = true;
break;
}
number++;
if (number > last_image) number = first_image;
}
current_image = number;
display_current_image();
}
//===> Decrement to next image
function decrementImage()
{
var number;
if (nImages<=1) return;
stop();
current_image--;
number = current_image;
if (number < first_image) number = last_image;
while (imageNum[number] == false) {
if (theImages[number].complete) {
imageNum[number] = true;
break;
}
number--;
if (number < first_image) number = last_image;
}
current_image = number;
display_current_image();
}
function fwd()
{
stop();
looping = 1;
play_mode = 1;
animate_fwd();
}
function rrev()
{
stop();
looping = 1;
play_mode = 1;
animate_rev();
}
function sweep() {
stop();
looping = 1;
play_mode = 2;
animate_fwd();
}
function change_mode(mode)
{
play_mode = mode;
}
function func()
{
}
if (nImages>0) {
// Compute some internal globals.
var maxKm = Km-1;
// 128km is .5 KmPerPixel, 512km is 2 KmPerPixel
var KmPerPixel = Km/256;
// Internal Global variables.
var xx=0;
var yy=0;
var zz=0;
var aa=0;
var xKm=0;
var yKm=0;
var mapx=0;
var mapy=0;
var xKmOrigin=0;
var yKmOrigin=0;
}
function startxy ()
{
// Setup mouse-move & mouse-click(down) callbacks.
if (isMS) {
document.body.onmousemove=move;
document.body.onmousedown=down;
//document.animation.src = GifFileName;
}
if (isNN4) {
document.captureEvents(Event.MOUSEMOVE);
document.onMouseMove=move;
document.captureEvents(Event.MOUSEDOWN);
document.onMouseDown=down;
}
if (isGecko)
{
loopArea = document.getElementById("animation");
loopArea.addEventListener("mousemove", move, true);
loopArea.addEventListener("mousedown", down, true);
}
resetOrigin ();
}
function resize () {
document.animationlayer.document.animation.src = GifFileName;
}
function move(e) // When the mouse moves, update the pointer boxes.
{
if (isMS) {
e = window.event;
xKm=9999
yKm=9999
if (e.srcElement && e.srcElement.name) {
if (e.srcElement.name == "animation") {
xPixels = window.event.offsetX-262+1
yPixels = window.event.offsetY-262+1
x_loc = window.event.offsetX
y_loc = window.event.offsetY
// Mac IE forgets to adjust for the scroll bars.
if (isMac) {
xPixels += document.body.scrollLeft
yPixels += document.body.scrollTop
}
xKm= xPixels*KmPerPixel
yKm=-yPixels*KmPerPixel
}
}
}
if(isGecko)
{
xKm=9999
yKm=9999
var element = document.getElementById("animation");
var distanceX = 0;
var distanceY = 0;
while(element != null)
{
distanceX += element.offsetLeft;
distanceY += element.offsetTop;
element = element.offsetParent;
}
if (e.target.id == "animation")
{
xKm= (e.pageX-distanceX-262)*KmPerPixel
yKm=-(e.pageY-distanceY-262)*KmPerPixel
x_loc = e.pageX-distanceX
y_loc = e.pageY-distanceY
}
}
if (isNN4) {
xKm=9999
yKm=9999
if (e.target.name) {
if (e.target.name == "animation") {
xKm= (e.pageX-document.animationlayer.pageX-262+1)*KmPerPixel
yKm=-(e.pageY-document.animationlayer.pageY-262+1)*KmPerPixel
x_loc = e.pageX-document.animationlayer.pageX
y_loc = e.pageY-document.animationlayer.pageY
}
}
}
if (Math.abs(xKm)>maxKm || Math.abs(yKm)>maxKm) {
document.myForm.x.value=""
document.myForm.y.value=""
document.myForm.z.value=""
document.myForm.a.value=""
if(doLatLon)
{
}
}
else {
xx=xKm-xKmOrigin
yy=yKm-yKmOrigin
zz=Math.round(Math.sqrt(xx*xx+yy*yy)-.01)
aa=450-Math.round(Math.atan2(yy,xx)*57.29)
if (aa>359) { aa=aa-360 }
if (zz<1) { aa="0" }
xx=Math.round(xx)
yy=Math.round(yy)
if (xx == 0) { xx=0; }
if (yy == 0) { yy=0; }
if (zz == 0) { zz=0; }
if (xx>=0) document.myForm.x.value = xx + ' km East'
else document.myForm.x.value =-xx + ' km West'
if (yy>=0) document.myForm.y.value = yy + ' km North'
else document.myForm.y.value =-yy + ' km South'
document.myForm.z.value = zz + ' km Away'
document.myForm.a.value = aa + ' Degrees'
}
}
function down() // A left-click (mouse-down) to move the Origin.
{
if (Math.abs(xKm)=0) document.offsets.xo.value = Math.round(xKmOrigin) + ' km East'
else document.offsets.xo.value = -Math.round(xKmOrigin) + ' km West'
if (yKmOrigin>=0) document.offsets.yo.value = Math.round(yKmOrigin) + ' km North'
else document.offsets.yo.value = -Math.round(yKmOrigin) + ' km South'
window.frames['dataframe'].window.location.replace('http://bsch.com.au/stormtracker.code.php?radar=radars/67/3/IDR673200810141426.gif&radarnumber=1&x=' + x_loc + '&y=' + y_loc);
}
function resetOrigin ()
{
xKm = 0;
yKm = 0;
down ();
}
function xynullfunc()
{
}