var x = 0; var y = 0; var y2 = 0; onload=function(){ document.getElementById("bm0").style.backgroundPosition = "left top"; } function smove(a){ y2 = a * -330; document.getElementById("bm"+x).style.backgroundPosition = "left bottom"; document.getElementById("bm"+a).style.backgroundPosition = "left top"; x = a; setTimeout("clkset()",10); } function clkset(){ if(y > y2){ y -= 30; }else if(y2 > y){ y += 30; } document.getElementById("move").style.top = y + "px"; if(y2 != y) setTimeout("clkset()",10); }