function startTicker(){
	var intervalo = 0;
	var lastWidth = 0;
	var spaceBetween = 120;
	var startPosition = 600;
	var andamento = 50;
	var totalItems = 0;
	var count = 0;

	$("#ticker div").each(function(){
		totalItems++;
		$(this).addClass("tickerItem");
		$(this).css("left", (lastWidth + startPosition) + "px");
		$(this).hover(function(){ stopTicker(); }, function(){intervalo = window.setInterval(scrollTicker, 500);});
		lastWidth = lastWidth + $(this).width() + spaceBetween + andamento;
	});
	
	intervalo = window.setInterval(scrollTicker, 500);

	function scrollTicker(){
		count = 0;
		$("#ticker div").each(function(){
			count++;
			posAtual = parseInt($(this).css('left'));
			posFinal = parseInt($(this).width());
			$(this).animate({left: (posAtual - andamento)}, 450, "linear");
			if(posAtual < -posFinal){
				novaPos = getNewPos(count);
				$(this).stop();
				$(this).css('left', novaPos);
			}
			
		});
	}
	
	function stopTicker(){
		clearInterval(intervalo);
		$("#ticker div").each(function(){ $(this).stop(); });
	}
	
	function getNewPos(pCount){
		var xCount = 0;
		var nPos = 0;
		var xPos = pCount - 1;
		if(xPos < 1) xPos = totalItems;
		$("#ticker div").each(function(){
			xCount++;
			if(xPos == xCount){
				nPos = parseInt($(this).css('left'));
				nPos += $(this).width() + spaceBetween;
			}
		});
		if(nPos < startPosition) nPos = startPosition;
		return nPos;
	}
}

