var indiceCarrousel = 5;
var pararCicloCarrousel = false;
function rotaNoticiaCarrousel()
{
	if(pararCicloCarrousel)
		return;
		
	var indiceAnt = indiceCarrousel;
	if((indiceCarrousel+1)>=$(".carrousel_portada>.noticia").size())
		indiceCarrousel = 0;
	else
		indiceCarrousel++;
	$(".carrousel_portada>.noticia:eq(" + indiceAnt + ")").fadeOut(1,function(){
		$(this).hide();
		$(".selector_noticia > .boton:eq(" + indiceAnt + ")").css("background-color","#000000");
		$(".selector_noticia > .boton:eq(" + indiceCarrousel + ")").css("background-color","#05759A");
		$(".carrousel_portada>.noticia:eq(" + indiceCarrousel + ")").show();
		$(".carrousel_portada>.noticia:eq(" + indiceCarrousel + ")").fadeIn(1);
	});
	
	setTimeout("rotaNoticiaCarrousel()", 8000);
}

function inicializarCarrouselEIndice(valorIndice)
{
	indiceCarrousel = valorIndice;
	inicializarCarrousel();
}

function inicializarCarrousel()
{
	rotaNoticiaCarrousel();
	$(".selector_noticia > .boton").click(function(){
		var indiceAnt = indiceCarrousel;
		indiceCarrousel = $(".selector_noticia > .boton").index(this);
		$(".carrousel_portada>.noticia:eq(" + indiceAnt + ")").fadeOut(1,function(){
			$(this).hide();
			$(".selector_noticia > .boton:eq(" + indiceAnt + ")").css("background-color","#000000");
			$(".selector_noticia > .boton:eq(" + indiceCarrousel + ")").css("background-color","#05759A");
			$(".carrousel_portada>.noticia:eq(" + indiceCarrousel + ")").fadeIn(1);
		});
		
		pararCicloCarrousel = true;
	});
}
