jQuery(document).ready(function($) {
	var tickerWidth = 0;
	var intervalID;
	var tickerList = $("#header-ticker ul");
	var maxWidth = $('#header-ticker').outerWidth(true);
	var maxHeight = $('#header-ticker').outerHeight(true);
	
	tickerList.find("li").each(function(item) {
		tickerWidth += $(this, item).outerWidth(true);
	});
	
	tickerWidth += tickerList.children("lh").outerWidth(true);
	
	tickerList.css("min-width", tickerWidth + "px");
	
	//console.log($('#header-ticker').css("display"));
	//tickerList.show();
	
	//var tickerListCopy = tickerList.clone().appendTo("#header-ticker");
	
	setTimeout(tickerDelay, 3000);
	
	function tickerDelay() {
		intervalID = setInterval(tick, 60);
	}
	
	function tick() {
		var currentLeft = tickerList.position().left;
		
		tickerList.css("left", currentLeft - 2);	
		
		if (currentLeft <= -tickerWidth) tickerList.css("left", maxWidth);
	}
});
