This function only implement image move from left to right. You can modify the code to fulfill your function.
<SCRIPT LANGUAGE=javascript>
<!--
var pos = -95;
var speed = Math.floor(Math.random () * 10) + 2;
function movet()
{
pos += speed;
if (pos > 795) pos = -95;
document.getElementById("mouse").style.left = pos;
window.setTimeout("next();", 30);
}
<BODY onLoad = "move();">
<div ID = "mouse" style = "HEIGHT: 100px; LEFT:
0px; POSITION: absolute; TOP: 170px; WIDTH: 100px">
<a href = "http://www.mouse.com" target = "nnn">
<IMG alt = "click me" border = 0 height = 100 src = "mouse.gif" width=100 onMouseOver="showWord();" onMouseOut="hideWord()">
</a>
</div>
<SCRIPT LANGUAGE=javascript>
<!--
var pos = -95;
var speed = Math.floor(Math.random () * 10) + 2;
function movet()
{
pos += speed;
if (pos > 795) pos = -95;
document.getElementById("mouse").style.left = pos;
window.setTimeout("next();", 30);
}
<BODY onLoad = "move();">
<div ID = "mouse" style = "HEIGHT: 100px; LEFT:
0px; POSITION: absolute; TOP: 170px; WIDTH: 100px">
<a href = "http://www.mouse.com" target = "nnn">
<IMG alt = "click me" border = 0 height = 100 src = "mouse.gif" width=100 onMouseOver="showWord();" onMouseOut="hideWord()">
</a>
</div>