var timeout;
jQuery( document ).ready(function()
{
	var content = jQuery( '.bannerPlace' );
	var inner = jQuery( '.bannerPlace .inner' );

	if( content.length > 0 && inner.length > 0 )
	{
		var scrollWidth = content[0].scrollWidth;
		var contentWidth = content.width();
		
		//content.css( 'position', 'relative' );
		//inner.css( 'position', 'absolute' );
		
		//console.log( content[0].scrollLeft = 0 );
		
		//console.log(scrollWidth);
		//console.log(contentWidth);
		
		if( scrollWidth == contentWidth )
		{
			//console.log('asd');
			// double the width of inner
			//inner.width( contentWidth * 2 );
			// double the content
			var html = inner.html();
			inner.html( html + html );
			
			inner.width( (scrollWidth * 2) + 0 );
			
			var scrollLeft = 0;
			var step = 1;
			var interval = 20;
			
			var scroll = function()
			{
				scrollLeft += step;
				if( scrollLeft > contentWidth )
				{
					scrollLeft = scrollLeft - contentWidth;
				}
				//console.log( scrollLeft );
				inner.css( 'margin-left', scrollLeft * ( -1 ) + 'px' );
				//inner.css( 'left', scrollLeft * ( -1 ) + 'px' );
				//content[0].scrollLeft = scrollLeft;
				//inner[0].style.marginLeft =  scrollLeft * ( -1 ) + 'px';
				timeout = setTimeout( function(){ scroll(); }, interval );
			}
			//setInterval( function(){ scroll(); }, interval );
			scroll();
		}
	}
	
	
	
});
function s(){ clearTimeout( timeout ); }
