var scrollerWidth = 0;
var containerWidth = 0;
var scrollDistance = 0;
var scrollDistanceIncrement = 2;
var scrollTimeIncrement = 80;

jQuery(document).ready(function(){
	if(jQuery('#ticker-content-scroll').length > 0)
	{
		containerWidth = parseInt(jQuery('#ticker-container').css('width'));
		jQuery('#ticker-content-scroll>div').each(
			function()
			{
				var w = parseInt(jQuery(this).outerWidth())+5;
				//jQuery(this).css('width', w+'px');
				scrollerWidth += w;
			}
		);
		jQuery('#ticker-content-scroll').css('width', scrollerWidth+'px');
		
		if(containerWidth < scrollerWidth)
		{
			setTimeout(function() { shiftScrollLeft() }, 3000);
		}
	}
});

function shiftScrollLeft()
{
	var currentLeft = parseInt(jQuery('#ticker-content-scroll').css('left'));
	if((currentLeft * -1) > scrollerWidth)
	{
		jQuery('#ticker-content-scroll').css('left', containerWidth+'px')
	}
	else
	{
		currentLeft = currentLeft - scrollDistanceIncrement;
		jQuery('#ticker-content-scroll').css('left', currentLeft+'px')
	}
	setTimeout(function(){ shiftScrollLeft() }, scrollTimeIncrement);
}
