var intervalo;
var posY;
var indice = 0;
var totalItems;

$(document).ready( function () {		     
	//posY = $("#tickerIndex ul").position().top;
	totalItems = $("#tickerIndex li").length+1;
	
	// REPETIMOS EL ÚLTIMO
	$("#tickerIndex ul").append("<li></li>");
	$("#tickerIndex li:last").text($("#tickerIndex li:first").text());
	
	// ELEGIMOS ALEATORIO
	var aleatorio = Math.floor(Math.random()*(totalItems-1));
	indice = aleatorio
	posY = -30*(aleatorio);
	$("#tickerIndex ul").css({ top:posY });
	
	// LANZAMOS SCROLL
	intervalo = setInterval(tickerIndex,3000);
	// PNG FIX
	$(document).pngFix(); 
})

function tickerIndex(){
	posY-=30;
	if ( indice < totalItems-1){
		indice++;
	} else {
		indice= 1;
		posY = 0;
		$("#tickerIndex ul").css({ top:posY })
		posY-=30;
	}
	$("#tickerIndex ul").animate({ top:posY }, 900);
}