I use prototype.js.
var retleft = 0;
var rettop = 120;
function mytimer(){
var itemfld = $('fld');
var retfld = Element.getDimensions(itemfld);
var elements = $$('div.z');
for(var i=0;i<elements.length;i++){
if(elements[i].id=='Obj0'){
retleft -= 5;
rettop += 5;
if(retleft < 0){retleft = retfld.width;}
if(rettop > retfld.height){rettop = 0;}
elements[i].setStyle({'left': retleft + 'px', 'top': rettop + 'px'});
}
}
setTimeout("mytimer()", 50);
}
Element.observe(window, "load", function() {
setTimeout("mytimer()", 50);
});