
var posicao = 2;
var total;
var tempo;


function iniciar(){
	total = $("div.box_botoes > a").length;	
	
	for(c=2; c<=total; c++){
		nomeBOXF = "box"+c;		
		document.getElementById(nomeBOXF).style.display = 'none';			 
	}
	
	tempo = window.setInterval("trocaBOX()",10000);	
}

function atualiza(pos){
	clearInterval(tempo);
	posicao = pos;	
	trocaBOX();
	tempo = window.setInterval("trocaBOX()",10000);
}

function trocaBOX(){	

	if(posicao > total){
		posicao = 1;
	}
	
	//fecha todas divs
	for(c=1; c<=total; c++){
		nomeBOXF = "box"+c;		
		nomeBOTAO = "Botao"+c;
		
		if(c == posicao){
			document.getElementById(nomeBOTAO).src = 'http://www.eunoenem.com.br/mod/enem_custom_index/graphics/bto'+c+'_1.gif';	
		}
		else{
			document.getElementById(nomeBOTAO).src = 'http://www.eunoenem.com.br/mod/enem_custom_index/graphics/bto'+c+'_0.gif';	
		}
		
		document.getElementById(nomeBOXF).style.display = 'none';	
			
	}	
	
	nomeBOX = "#box" + posicao;		
	$(nomeBOX).fadeIn("slow");	
	//document.getElementById("atual").innerHTML = posicao;
	
	posicao++;	
}




function trocaAba(id){
	
	if(id == 1){
		document.getElementById('Botao1').src = 'http://www.eunoenem.com.br/mod/enem_custom_index/graphics/btConteudoPremium_1.gif';
		document.getElementById('Botao2').src = 'http://www.eunoenem.com.br/mod/enem_custom_index/graphics/btAcesso_0.gif';			
		
		$('#Conteudo2').fadeOut("fast", function(){
			$('#Conteudo1').fadeIn("fast");
		});		
	}
	else if (id == 2){
		document.getElementById('Botao1').src = 'http://www.eunoenem.com.br/mod/enem_custom_index/graphics/btConteudoPremium_0.gif';
		document.getElementById('Botao2').src = 'http://www.eunoenem.com.br/mod/enem_custom_index/graphics/btAcesso_1.gif';	
		
		$('#Conteudo1').fadeOut("fast", function(){
			$('#Conteudo2').fadeIn("fast");
		});		
	}	
}
/*
function startTroca(max){
	total = max;
	var tempo = window.setInterval(function(){trocaBOX(i, max)}, 9500);
}

function Anterior(){
	clearInterval(tempo);
	
	if (posicao <= 2){
		posicao = total;		
	}
	else{
		posicao = posicao - 2;
	}
	
	trocaBOX();
	tempo = window.setInterval("trocaBOX()",10000);
}

function Proximo(){	
	clearInterval(tempo);
	trocaBOX();
	tempo = window.setInterval("trocaBOX()",10000);	
}*/

