The code in the stop count function is what I have tried so far, but it is not working since the object keeps on moving down the page. There are no error messages, I just don't get the desired behavior. I think it has something to do with the way I am trying to determine the position of the object on the page, but I am stuck.

script type="text/javascript">
//note setTimeout is a rather misleading name; setTimeIn would have been more appropriate;
var foo = null; // object
var t;
var t=setTimeout(doMove,20); //create a variable to hold the timeout so we can reference it later with clear clearTimeout(t);

function doMove() {


foo.style.top = parseInt(foo.style.top)+1+'px';
setTimeout(doMove,20); // call doMove in 20msec
stopCount();
}


function stopCount() //stop the animatiion when the top of foo is at 0, even with top of screen
{
if (document.foo.top='0')

clearTimeout(t);
}


function init() {
foo = document.getElementById('fooObject'); // get the "foo" object
foo.style.top = '-650px'; //
doMove(); // start animating
}


window.onload = init;

</script>

Thanks