function anim(ob, x, dx, t,callback){ if(t<0) callback(); document.getElementById(ob).style['top']=x+dx; setTimeout(function(){anim(ob, x, dx, t-1)}, 10);} anim('div',1,1,25,function(){alert('алерт')});