var margin = 0; // margin around the items. var speed = 15; // milliseconds it will take for items to move 1 pixel. var stopspeed = 5000; // milliseconds that the news item will stop for, example: 2000 : 2seconds. var scroller; function begin() { scroller = document.getElementById("scroller"); if(scroller.hasChildNodes()) { for(var i = 0; i < scroller.childNodes.length; i++) { if(scroller.childNodes[i].nodeType == 1) { scroller.childNodes[i].style.margin = margin + 'px'; } else if(scroller.childNodes[i].nodeType == 3) { scroller.removeChild(scroller.childNodes[i]); i--; } } setTimeout("count(" + margin + ")", stopspeed); } } function count(counter) { counter--; setTimeout("move(" + counter + ")", speed); } function move(counter) { scroller.firstChild.style.marginTop = counter + 'px'; if(counter > -(scroller.firstChild.offsetHeight)) { count(counter); } else { setTimeout("stack(" + counter + ")", stopspeed); } } function stack(counter) { var thischild = scroller.firstChild; scroller.removeChild(thischild); scroller.appendChild(thischild); scroller.lastChild.style.margin = margin + 'px'; count(margin); }