var scrollerStep = 1;
var scrollerIntervalMs = 200;

function initScroller()
{
	$('.autoscroll').each( function() {
		$(this).mouseover(function() { doPause(this); });
		$(this).mouseout(function() { doPause(this); });
		//$(this).css('overflow', 'hidden');
	});
	setInterval("doScroll()", scrollerIntervalMs);	
}

function doScroll()
{
	$('.autoscroll').filter(':not(".paused")').each( function() {
		var x = this.scrollTop;
		// The height of the div, as defined by CSS
		var divHeight = parseInt($(this).css('height'));
		// The height of the div's contents
		var contentHeight = this.scrollHeight;
		// Increment the position we're scrolling to by 1px
		x += scrollerStep;
		// Start over if we've scrolled too far
		if(x > (contentHeight - divHeight)) x = 0;
		// Scroll!
		this.scrollTop = x;

	});
}

function doPause(el)
{
	$(el).toggleClass('paused');
}

$(document).ready(function() {
   initScroller();
});
