function frame() {
top=(top>rest)?rest:(top+1);
left=(left>resl)?resl:(left+1);
document.getElementById("ger").style.top = top + "px";
document.getElementById("ger").style.left = left + "px";
if ( (top >= rest) && (left>=resl) ) {
clearInterval(timer);
}
}
var timer = setInterval(frame, 10);
вроде того