//Requires jQuery

$(document).ready(function(){
	var elements = $(".scroller");
	//Pad the tops and bottoms of each element so seems smooth
	elements.each(function(i){
		this.style.overflow="hidden";
		this.style.padding = 5;
		this.style.margin = 0;
		var padding = "<div style='height: " + this.clientHeight + "px;'></div>\n";
		$(this).html(padding + $(this).html() + padding);
		this.keepscrolling=true;
		$(this).mouseover(function(){this.keepscrolling=false;});
		$(this).mouseout(function(){this.keepscrolling=true;});
	});
	//Then set the scroller
	setInterval(function(){
		$(elements).each(function(i){
			if (this.keepscrolling){
				if (this.scrollTop + this.clientHeight == this.scrollHeight){
					this.scrollTop = 0;
				} else {
					var oldScrollTop = this.scrollTop;
					this.scrollTop = this.scrollTop + 1;
				}
			}
		});
	}, 30);
});

