// JavaScript Document
$(document).ready(function(){

var qual = new Array ("um", "dois" , "tres" , "quatro" , "cinco"  );
var tempo = new Array ( 0 , 150 , 300 , 450 , 600 );
var a = 0;
var b = 4;
var c = 5;


$('#carrossel .proximo').click(function (){
	incrementa(a,b);
	if(c>=20){
	$('#carrossel .proximo').hide();
	}else{
	$('#carrossel .proximo').show();
	};
	$('#carrossel .antes').show();
});

$('#carrossel .antes').click(function (){
	c-=10;
	decrementa(a,b);
	$('#carrossel .proximo').show();
	if(c<=0){
	$('#carrossel .antes').hide();
	}else{
	$('#carrossel .antes').show();
	};
});

function incrementa(a, b ){
	for ( i=a ;i<=b;i++)
	{
	$("." + qual[i]).delay(tempo[i]).fadeOut(300 , function (){
	c++;
	$(this).css("background","url(externos/logomarca/" + c +".png)");
	$(this).fadeIn(300);
	});
	}
}

function decrementa(a, b){
	for ( i=a ;i<=b;i++)
	{
	$("." + qual[i]).delay(tempo[i]).fadeOut(300 , function (){
	c++;
	$(this).css("background","url(externos/logomarca/" + c +".png)");
	$(this).fadeIn(300);});
	}
}



$('#carrossel .antes').hide();
$('#ruan_carrossel li').css("opacity", 0.5);
$('#ruan_carrossel li').mouseover(function(){
	$(this).animate({opacity:1}, 300);
});
$('#ruan_carrossel li').mouseout(function(){
	$(this).animate({opacity:0.5}, 300);
});

});

