//bouncing DIV block
var myID;
var lastHeight;
var bounceCount;
var maxDrop;

//April 2004 - preload images to cater for slow(er) links
var preloadImage_1 = new Image;
var preloadImage_2 = new Image;
preloadImage_1 = "BounceNoCookies.gif";
preloadImage_2 = "Bounce.gif";

function startBounce()
{
//set initial height
document.all.flyer.style.top = -20;
bounceCount = 0;
maxDrop = 200;
lastHeight = maxDrop;

myID = setInterval("MoveDown(5,"+maxDrop+")",3);
}

function MoveDown(ByPix,DownTo)
{
	flyer.style.top = parseInt(flyer.style.top) + ByPix;

	flyer.style.display="block";

	if (parseInt(flyer.style.top) > DownTo)
	{
		stopBounce();
		if (lastHeight > 20) {
			lastHeight = parseInt(lastHeight * .1);
		}else {
			lastHeight = parseInt(lastHeight * .8);
		}
		thisHeight = maxDrop - lastHeight;
		
		if (thisHeight < maxDrop + 1 && bounceCount < 15)
		{
			if (bounceCount == 0)
			//Set off noise on first bounce only
			{	
				//switched off because it causes the bouncing block to stutter and also seems to cause the entire screen to flicker
				//document.all.myDiv.innerHTML='<embed id="myboing" src="Sounds/cartoon056.wav" autostart="true" hidden="true" loop="false" width=145 height=60></embed>'
			}
			bounceCount ++
			// Debug: flyer.innerText = "Bounce=" + bounceCount + " Height=" + thisHeight;
			temp="MoveUp(2," + thisHeight + ")";
			myID= setInterval(temp,1);
			
		}else{
		myID= setTimeout("goAway()",3000)
		}
	}
}

function MoveUp(ByPix,UpTo)
{
	flyer.style.top = parseInt(flyer.style.top) - ByPix;

	if (parseInt(flyer.style.top) < UpTo)
	{
		stopBounce();
		temp="MoveDown(2," + maxDrop + ")";
		myID = setInterval(temp,1);
	}
}

function stopBounce()
{
    clearInterval(myID);
}

function goAway()
{
    flyer.style.display="none";
	clearTimeout(myID);
}
