// JavaScript Document

$(function(){
	$('.rss').hide();
});
		
function mudaRss(idHidden, idView, quantNoticias, tempo){
	var li = $('#'+idHidden+' ul').children().get(0);
	$("#"+idView+" ul").html($(li).html()).fadeOut().fadeIn(1000);
	var index = 1;
	mudaSlideRss(tempo, idView, idHidden, index, quantNoticias)
}

function mudaSlideRss(tempo, idView, idHidden, index, quantNoticias){
	setTimeout(function(){
		$("#"+idView+" ul li").remove().fadeOut();
		if(index > (quantNoticias-1)){ index = 0; }
		var li = $('#'+idHidden+' ul').children().get(index);
		$("#"+idView+" ul").html($(li).html());
		$("#"+idView+" ul").effect();
		index++;
		mudaSlideRss(tempo, idView, idHidden, index, quantNoticias);
	}, tempo);
}
	
function callback(id) {
	setTimeout(function() {
		$("#" + id).removeAttr("style").hide().fadeIn();
	}, 1000 );
}

function startBanner(){
	var slides = $('#carouseldiv').clone(true).children();
	$('#carouseldiv').html("<div>" + $(slides[0]).html() + "</div>");
	var index = 1;
	mudaSlide(slides, index);
}

function mudaSlide(slides, index){
	setTimeout(function(){
		index = (index > 3 ? 0 : index);
		var li = $("<div>" + $(slides[index]).html() + "</div>");
		$('#carouseldiv').fadeOut('slow', function(){ $('#carouseldiv').html(li).fadeIn(1000); });
		index++;
		mudaSlide(slides, index);
	}, 5000);
}