
var scrollSpeed = 50; // screen pixels per second
var scrollWidth;

function scrollBanner(time)
{
	$('#scroll-inner').css('left', 0);
	$('#scroll-inner').animate({ left: -scrollWidth }, time, 'linear', function(){
		scrollBanner(time);
	});
}

$(function(){
	// setup scrolling content
	var scroll = $('.scroll-contents').clone();
	var height = $('.scroll-contents').outerHeight();
	scrollWidth = 0;
	
	$('.scroll-contents').each(function(){
		scrollWidth += $(this).outerWidth();
	});
	
	if (height < 100) height = 100;
	$('#scroll-outer').css('height', height);
	
	// append clone of .scroll-contents
	$('#scroll-inner').css('width', scrollWidth*2);
	$('#scroll-inner').append(scroll);

	// calculate length of time to scroll over
	var scrollTime = (scrollWidth / scrollSpeed) * 1000;
	
	// start scrolling
	scrollBanner(scrollTime);
});
