// JavaScript Document move the body
var delay=100;
var steps=3;
var animationInProgress=false;
var timeoutInProgress=false;
var animationDone = false;
var xs = new Array(); //x apexes
var ys = new Array(); //y apexes
var ns = new Array(); //steps before next apex
var apexMeter = 0;
var apexMeterStop = 7;
var stepMeter = 1;
var DELAY = 100; // milliseconds between steps
var RIGHT = screen.width;
var BOTTOM = screen.height;
var thisX = 0; // current window X
var thisY = 0; // current window Y

function move(x,y) {
// utility function
window.moveTo(x,y);
}
function initAnimation() {
// set up scrolling arrays
if (!animationInProgress) {
animationInProgress=true;
xs[0]=0;ys[0]=0;ns[0]=4;
xs[1]=Math.floor((RIGHT-720)/2);ys[1]=0;ns[1]=4;
xs[2]=Math.floor(RIGHT-720);ys[2]=Math.floor((BOTTOM-300)/2);ns[2]=4;
xs[3]=Math.floor((RIGHT-720)/2);ys[3]=Math.floor(BOTTOM-300);ns[3]=3;
xs[4]=Math.floor((RIGHT-720)/4);ys[4]=Math.floor((BOTTOM-300)/2);ns[4]=3;
xs[5]=Math.floor((RIGHT-720)/2);ys[5]=Math.floor((BOTTOM-300)/4);ns[5]=3;
xs[6]=Math.floor((RIGHT-720)/16)*10;ys[6]=Math.floor((BOTTOM-300)/2);ns[6]=3;
xs[7]=Math.floor((RIGHT-720)/2);ys[7]=Math.floor((BOTTOM-300)/2);
animate(xs[0],ys[0]);
}
}
function animate(targetX,targetY) {
// move window if appropriate, wait a bit
if (!timeoutInProgress) {
timeoutInProgress=true;
thisX=targetX;
thisY=targetY;
move(thisX,thisY);
stepMeter++;
if (!animationDone) {
setTimeout("continueAnimation()",DELAY);
}
}
}
function continueAnimation() {
// step through arrays, call animate
timeoutInProgress=false;
if (stepMeter >= ns[apexMeter]) {
// on to next apex
stepMeter = 0;
apexMeter++;
//alert(apexMeter);
}
if (apexMeter < apexMeterStop) {
// only continue if still within legal apex range
tempX=xs[apexMeter+1]-xs[apexMeter]; // distance between apexes
tempX=Math.floor(tempX/ns[apexMeter]); // distance between steps
tempY=ys[apexMeter+1]-ys[apexMeter]; // distance between apexes
tempY=Math.floor(tempY/ns[apexMeter]); // distance between steps
if (stepMeter > 0) {
tempX=thisX+tempX;
tempY=thisY+tempY;
} else {
tempX=xs[apexMeter];
tempY=ys[apexMeter];
}
animate(tempX,tempY);
} else {
// last step
animationDone = true;
animate(xs[apexMeter],ys[apexMeter]);
}
}
move(0,0);


