//This script has been made by Paul van Grieken (p.van.grieken@xs4all.nl), june 2000.
// adjusted to make it work in firefox


var iStep = 0;
var nSteps = 500;    //number of steps used ('distance')
var v = 100;       //swimming velocity (ms per step)
var dw
var dh
var x = new Array(5);
var y = new Array(5);
var theObj

function shiftTo(obj, x, y) {
	obj.left = x;
	obj.top  = y;
}

function fx(stepnr,r){
	with (Math){
		t = stepnr*PI/nSteps
		x[0] = -0.95*dw*sin(t) + 0.95*dw;
		x[1] = 0.43*dw*cos(t+PI)+0.5*dw;
		x[2] = dw/2-dw/2.25*cos(t);
		x[3] = dw/2+dw/2.25*sin(3*t+1.5*PI);
		x[4] = dw/2+dw/2.25*sin(3*t+1.5*PI);
	}
	return x[r]
}
function fy(stepnr,r){
	with (Math){
		t = stepnr*PI/nSteps;
		y[0] = (dh-50)/-2*cos(t+PI) + (dh-50)/2;
		y[1] = 0.95*dh-20-0.95*dh*t/PI;
		y[2] = dh/2.25+dh/2.25*sin(2*t);
		y[3] = dh-dh*t/PI*sin(1.6*2*t+1.6*PI)*sin(1.6*2*t+1.6*PI)-40;
		y[4] = dh/2-dh*0.8*t/PI*sin(t+1.5*PI)+130;
	}
	return y[r]
}
function swim(mm,r){
	iStep++
	shiftTo(mm,fx(iStep,r),fy(iStep,r))
	if(iStep==nSteps){clearInterval(tid)};
}
function init(){
	{
		dw = document.body.clientWidth;
		dh = document.body.clientHeight;
		mm = document.getElementById('swmm').style;
		r = Math.floor(Math.random()*5);
		tid=setInterval('swim(mm,r)',v);
		mm.visibility = 'visible';
	}
}

onload=init;

