setInterval example
 

<script type="text/javascript">

var testIntervalId = 0;

var argh = 0;

function testClickHandler( ) {
if ( document.getElementById("testButton").value == "START" ) {
document.getElementById("testButton").value = "STOP";
testIntervalId = setInterval ( "testPlus()", 0.1 );
}
else {
document.getElementById("testMessage").innerHTML = "";
document.getElementById("testButton").value = "START";
testIntervalId = setInterval ( "testMinus()", 0.1 );
}
}

function testPlus( ) {

argh+=10;
newHeight = argh * 1.25;
document.getElementById("testMessage").innerHTML = argh + " / " + newHeight;
document.getElementById("container").style.opacity = argh / 400;
document.getElementById("container").style.width = argh + "px";
document.getElementById("container").style.height = newHeight + "px";

if (argh > 390) {

clearInterval ( testIntervalId );
argh = 400;

}

}

function testMinus( ) {

argh-=10;
newHeight = argh * 1.25;
document.getElementById("testMessage").innerHTML = argh + " / " + newHeight;
document.getElementById("container").style.opacity = argh / 400;
document.getElementById("container").style.width = argh + "px";
document.getElementById("container").style.height = newHeight + "px";

if (argh < 10) {

clearInterval ( testIntervalId );
argh = 0;

}

}

</script>