/* 
############################################################
# -------------------------------------------------------- #
# SOUDADO.COM © Todos os direitos reservados               #
# -------------------------------------------------------- #
############################################################
*/

var atual= 1;
var prox = 2;
var t1   = 100;
var t2   = 0;
var timer;

function produtos(pid,acao)
{
	switch(acao)
	{
		case "over":
			document.getElementById(pid).style.backgroundPosition='right bottom';
			document.getElementById(pid).style.border = "#117198 solid 1px";
			document.getElementById(pid).style.color = "#117198";
		break;
		
		case "out":
			document.getElementById(pid).style.backgroundPosition='left bottom';
			document.getElementById(pid).style.border = "#CCC solid 1px";
			document.getElementById(pid).style.color = "#000";
		break;
		
	}
	
}


function destaque(acao)
{
	switch(acao)
	{
		case 1:
		   document.getElementById("destaque").style.position = "relative";
		   document.getElementById("destaque").style.top = "0";
		   document.getElementById("destaque").style.left = "0";
		break;
		
		case 2:
		   document.getElementById("destaque").style.position = "absolute";
		   document.getElementById("destaque").style.top = "-10000px";
		   document.getElementById("destaque").style.left = "-10000px";
		break;
	}
}


// Vai deixando ele transparente e o outro revelando
function transp(atual,prox)
{
	t1 = t1 - 1;
	t2 = t2 + 1;
	
	//for(x=1;x<=qtdd;x++)
	//{
		//if(x != prox)
		//{
			document.getElementById('p'+atual).style.filter = "alpha(opacity="+ t1 +")";
			document.getElementById('p'+atual).style.opacity = t1/100;
		//}
	//}
		
	document.getElementById('p'+prox).style.filter = "alpha(opacity="+ t2 +")";
	document.getElementById('p'+prox).style.opacity = t2/100;
	
	if(t1 > 0) { setTimeout("transp("+atual+","+prox+")",10); }
	else
	{
		for(x=1;x<=qtdd;x++)
		{
			if(x != prox)
			{
				document.getElementById('p'+x).style.position = "absolute";
				document.getElementById('p'+x).style.top = "-15000px";
			}
		}
	}
	
}

function mudar_boxe(manual)
{	
	clearTimeout(timer);
	
	t1 = 100;
	t2 = 0;	
	
	// Verifica qual será o próximo
	if(manual == 0) { if(atual != qtdd) { prox=atual+1; } else { prox = 1; } }
	
	// Habilita todos
	for(x=1;x<=qtdd;x++)
	{
		if(x != prox)
		{
			document.getElementById('p'+x).style.filter = "alpha(opacity=0)";
			document.getElementById('p'+x).style.opacity = 0;
		}
		
		document.getElementById('p'+x).style.position = "absolute";
		document.getElementById('p'+x).style.top = "";
	}
		
	// Deixa todos os quadradinhos pretos e ativa o próximo
	for(x=1;x<=qtdd;x++) document.getElementById('pp'+x).style.background = "black";
	document.getElementById('pp'+prox).style.background = "#117198";
	
	// Inicia a fazer a transparencia
	transp(atual,prox);
		
	// Muda nas variaveis
	atual = prox;
	
	// Chama novamente daqui 7 segundos
	timer = setTimeout("mudar_boxe(0)",6000);
}

if (navigator.appName == "Microsoft Internet Explorer")
{
	for(x=1;x<=qtdd;x++) document.getElementById('p'+x).style.left = "0";
}

function mudar_agora(id)
{	
	if(t1 == 100 || t1 == 0)
	{
		prox=id;	
		mudar_boxe(1);
	}
}

timer = setInterval("mudar_boxe(0)",6000);

