Return to tutorial on Moving image across screen

Moving image horizontally within two boundaries Moving image randomly within four boundaries Moving image by using up, down, left & right keys

JavaScript

<script language='JavaScript' type='text/JavaScript'>
<!--
var dir='down';

function reset1(){
clearTimeout(my_time);
document.getElementById('i1').style.left= "500px";
document.getElementById('i1').style.top= "100px";
document.getElementById("msg").innerHTML="";
}

function disp(){
var step=5; // Change this step value
//alert(dir);

var y=document.getElementById('i1').offsetTop;
var x=document.getElementById('i1').offsetLeft;
if(y >= 500 ){
dir = 'up';
}
if(y <= 100 ){
dir = 'down';
}

if(dir=='down'){y= y +step;}
else{y=y - step;}
document.getElementById('i1').style.top= y + "px"; // vertical movment

//////////////////////
}

function timer(){
disp();
var y=document.getElementById('i1').offsetTop;
var x=document.getElementById('i1').offsetLeft;
document.getElementById("msg").innerHTML="X: " + x  + " Y : " + y
my_time=setTimeout('timer()',10);
}

//-->
</script>
HTML
<img src=images/help.jpg id='i1' style="position:absolute; left: 500; top: 100;">
<br><br><br><br>
<input type=button onClick=timer() value='Start'>
<input type=button onClick=reset1() value='Reset'>
<div id='msg'></div>