// variable for timer
var timer;

function soar()
{
	var obj = document.getElementById("lyr");


// stop if top of page
	// alert(parseInt(obj.style.top))
	if (parseInt(obj.style.top) >= 10)
	{
	obj.style.top = (parseInt(obj.style.top)-1)+"px";
	}
	timer = window.setTimeout("soar()", 50);
}

function sink()
{
	var obj = document.getElementById("lyr");
// stop if top of page
	// alert(parseInt(obj.style.top))
	if (parseInt(obj.style.top) <= 400)
	{
	obj.style.top = (parseInt(obj.style.top)+1)+"px";
	}
	timer = window.setTimeout("sink()", 50);
}


function left()
{
	var obj = document.getElementById("lyr");

// stop if top of page
	// alert(parseInt(obj.style.top))
	if (parseInt(obj.style.left) >= 10)
	{
	obj.style.left = (parseInt(obj.style.left)-1)+"px";
	}
	timer = window.setTimeout("left()", 50);
}

function right()
{
	var obj = document.getElementById("lyr");
// stop if top of page
	// alert(parseInt(obj.style.top))
	if (parseInt(obj.style.left) <= 400)
	{
	obj.style.left = (parseInt(obj.style.left)+1)+"px";
	}
	timer = window.setTimeout("right()", 50);
}



// for the square routine


function soarq()
{
	var i=0;
	do
	{
	
		var obj = document.getElementById("lyr");

		obj.style.top = (parseInt(obj.style.top)-1)+"px";

		i++;
	}
	while (i<=20);
	return;		
}

function sinkq()
{
	var i=0;
	do
	{
	
		var obj = document.getElementById("lyr");

		obj.style.top = (parseInt(obj.style.top)+1)+"px";

		i++;
	}
	while (i<=20);
	return;		
}


function leftq()
{
	var i=0;
	do
	{
	
		var obj = document.getElementById("lyr");

		obj.style.left = (parseInt(obj.style.left)-1)+"px";

		i++;
	}
	while (i<=20);
	return;		
}

function rightq()
{
	var i=0;
	do
	{
	
		var obj = document.getElementById("lyr");

		obj.style.left = (parseInt(obj.style.left)+1)+"px";

		i++;
	}
	while (i<=20);
	return;		
}


function square()
{
	// move around in a square
	window.setTimeout("sinkq()", 1000);
	window.setTimeout("sinkq()", 2000);
	window.setTimeout("sinkq()", 3000);
	
	window.setTimeout("rightq()", 4000);
	window.setTimeout("rightq()", 5000);
	window.setTimeout("rightq()", 6000);
	
	window.setTimeout("soarq()", 7000);
	window.setTimeout("soarq()", 8000);
	window.setTimeout("soarq()", 9000);

	window.setTimeout("leftq()", 10000);
	window.setTimeout("leftq()", 11000);
	window.setTimeout("leftq()", 12000);


	timer=window.setTimeout("square()", 13000);
		return;
}

function diagonal()
{
	var obj = document.getElementById("lyr");
// stop if top of page
	// alert(parseInt(obj.style.top))
	
	obj.style.left = (parseInt(obj.style.left)+1)+"px";
	obj.style.top = (parseInt(obj.style.top)+1)+"px";
	timer = window.setTimeout("diagonal()", 50);
}

function stop()
{	
	clearTimeout(timer);
}