
var locais_mundo = new Array('brasil','australia','europa','hawaii','tahiti','afsul','argentina','indonesia','amcentral','california','fiji','japao','amsul');

var op = new Array("mundo","brasilMapa","brSul","brSe","brNe","brNo");

var estados = new Array("rs","sc","pr","sp","rj","es","ba","se","al","pe","pb","fn","rn","ce","pi","ma","pa","ap");
var estadoRegiao = new Array(1,1,1,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4);

//----- tipos: todos, forum, trips
var idTipoCom = new Array(0,'f','t');
var nrTipoCom = new Array(0,3,3);

function esconde_tudo(){

	for(var m=0;m<1;m++){
		switch( m ){
		
			case 0:
			for( var c=0; c<=12; c++ ){
				esconde(locais_mundo[c]);
			}
	
		}
	}
	
}


function esconde(id)
{
  var el = document.getElementById(id);
  if(el!=null){ el.style.display = "none"; }
}

function mostra(id)
{
  var el = document.getElementById(id);
  if(el!=null){ el.style.display = "block"; }
}



function selec( idAba, nrAbas, tipo ){
	
	var c,t;
	
	for( c = 0; c <= nrAbas; c++ ){			
		if( c == idAba ){
			document.getElementById('b'+tipo+c).className='ativa';
		}
		else{
			document.getElementById('b'+tipo+c).className='normal';
		}
	}
	
	switch(tipo){
		
		case 'p':
		
			for( c = 0; c<=nrAbas; c++ ){ 
				esconde(op[c]);
				esconde_tudo();
				}
  			if( idAba <= nrAbas ){ mostra(op[idAba]) }
					
			break;
		
		case 'c':
		
			for(t=1;t<=2;t++){
				for( c = 1; c<=nrTipoCom[t]; c++ ){ 
					if(idAba==0||idAba==t){	mostra('c'+idTipoCom[t]+c) }
					else{	esconde('c'+idTipoCom[t]+c) }
				}
			}
			break;
		
	}
}


function mostra_select(id){
	
	esconde_tudo();
	mostra(id);
	
}

var idAtual = 1;

function  mostraTv(id,total){
	
	for(var c = 1; c<= total; c++){
		if(id==c){
			document.getElementById('foto'+id).style.opacity = 100;
			mostra('foto'+c);
			document.getElementById('botao'+c).className='selected';
			mostra('textoFoto'+c);
		}
		else{
			esconde('foto'+c);
			document.getElementById('botao'+c).className='';
			esconde('textoFoto'+c);
		}
	}
	
	idAtual = id;
}


var tempo = 0.5;

function  fadeTv(id,total){

	var el = 0;
	var idAntigo = 	idAtual;

	if(idAntigo==id){
		id++;
		if(id>total){id=1}
	}

	for(var c = 1; c<= total; c++){
		
		if(c!=idAntigo){
			$('#foto'+c).hide();
		}
		
		el = document.getElementById('botao'+c);
		if(el!=null){
			if(c!=id){
				el.className='';
				$('#textoFoto'+c).hide();
			}
			else{
				el.className='selected';
				if(id!=1){	
					$('#textoFoto'+c).show().attr("style","bottom:-64px;z-index:30;").animate( { bottom:"0"}, 700);
				}
			}
		}
	}

	
	if(id>idAtual){ 
			el = document.getElementById('foto'+id);
			if(el!=null){
				$('#foto'+id).hide();
				$('#foto'+id).fadeIn(tempo*1000,function(){
					$('#foto'+idAntigo).hide();
				});
			}
	}		
	else{ 
		$('#foto'+id).show();
		$('#foto'+idAntigo).fadeOut(tempo*1000,function(){
			$('#foto'+idAntigo).hide();
		});
	}

	idAtual = id;
	
}

var totalBotoes = 0;
var contaBotao = 1;
var intervalo = 0;
var duracao = 5000;
var timerOn = false;

function ativaTimer(total){
	if(total>1){
		intervalo = window.setTimeout("avancaSlide()", duracao);
		timerOn = true;
	}
	totalBotoes = total;
}

function reativaTimer(){
  	if(timerOn){
		clearInterval(intervalo);
		intervalo =0;
		intervalo = window.setTimeout("avancaSlide()", duracao);
  	}
}

function desativaTimer(){
	window.clearTimeout(intervalo);
}

function avancaSlide() {
	contaBotao = idAtual+1;
	if(contaBotao>totalBotoes){contaBotao=1}
	fadeTv(contaBotao,totalBotoes);
	intervalo = window.setTimeout("avancaSlide()", duracao);
}

function fadeOut(id, time) {
	target = document.getElementById(id);
	alpha = 100;
	timer = (time*1000)/50;
	var i = setInterval(
			function() {
				if (alpha <= 0){
					clearInterval(i);
					el = document.getElementById(id);
					if(el!=null){
						el.style.display = "none";
					}
				}
				setAlpha(target, alpha);
				alpha -= 5;
			}, timer);
}

function fadeIn(id, time, id2) {
	target = document.getElementById(id);
	alpha = 0;
	timer = (time*1000)/50;
	var i = setInterval(
			function() {
				if (alpha >= 100){
					clearInterval(i);
					document.getElementById(id2).style.display = "none";
					setAlpha(target, 100);
				}
				setAlpha(target, alpha);
				alpha += 5;
			}, timer);
}

function setAlpha(target, alpha) {
	if(target!=null){
		target.style.filter = "alpha(opacity="+ alpha +")";
		target.style.opacity = alpha/100;
	}
}

function escolheDia(dia){
	
	for(var c = 1; c<= 3; c++){
		if(c!=dia){
			document.getElementById('botaoDia'+c).className='';
			
		}
		else{
			document.getElementById('botaoDia'+c).className='selected';			
			document.getElementById('mapa_brasil_hoje').style.left= (1-dia)*266+'px';
		}
	}
	
}

function mudaTipo(tipo){

	posi = new Array('','0px','-267px','-535px')
	for(var c = 1; c<= 3; c++){
		if(c!=tipo){
			document.getElementById('botaoTipo'+c).className='';
			document.getElementById('escala'+c).style.display='none';			
		}
		else{
			document.getElementById('botaoTipo'+c).className='selected';			
			document.getElementById('mapa_brasil_hoje').style.top= posi[tipo];
			document.getElementById('escala'+c).style.display='block';			
		}
	}

}


var UnicoLit = new Array(0,3,8,11,14,18,21,25,26,29,30,34,35,36,40,47,50,53,54);
var idLit =   new Array(0,8,26,30,37,47,79,69,70,74,73,64,66,67,72,71,63,65,68);

function mostraMenu() {
	
		 var el = 0;
		 var ct = document.form.ponto.value;
		 var achou = false;
		 
		 for(var c=1;c<=UnicoLit.length;c++){
	 		if(UnicoLit[c]==ct){
				document.location.href='/previsao/previsao.asp?lit='+idLit[c];
				achou = true;
			}
		 }
		 if( !achou ){
			 for(c=0;c<=42;c++){
    		 	if(c == 3){c = 4}
    		 	if(c == 8){c = 9}
    		 	if(c == 11){c = 12}
    		 	if(c == 14){c = 15}
    		 	if(c == 18){c = 22}
    		 	if(c == 23){c = 24}
    		 	if(c == 25){c = 27}
    	 		if(c == 29){c = 38 }
    		 	if(c == 39){c = 42 }
				el = document.getElementById("E"+c);
				if(el!=null){ el.style.display = "none"; }
			 }
			 
			 el = document.getElementById("E"+ct);
			 if(el!=null){ 
			 	el.style.display = "block"; 
			 	el = eval("document.form" + ct).lit;
			 	if(el!=null){el.selectedIndex = 0;}
			}
		 }
		 
	 	document.getElementById("E00").style.display = "none";

}
	  
	  

function mostraMenuInter() {
	
		 var el = 0;
		 var ct = document.formM.ponto.value;
		 var achou = false;
		 
		 for(var c=1;c<=UnicoLit.length;c++){
	 		if(UnicoLit[c]==ct){
				document.location.href='/previsao/previsao.asp?lit='+idLit[c];
				achou = true;
			}
		 }
		 if( !achou ){
			 for(c=0;c<=42;c++){
    		 	if(c == 3){c = 4}
    		 	if(c == 8){c = 9}
    		 	if(c == 11){c = 12}
    		 	if(c == 14){c = 15}
    		 	if(c == 18){c = 22}
    		 	if(c == 23){c = 24}
    		 	if(c == 25){c = 27}
    	 		if(c == 29){c = 38 }
    		 	if(c == 39){c = 42 }
				el = document.getElementById("E"+c);
				if(el!=null){ el.style.display = "none"; }
			 }
			 
			 el = document.getElementById("E"+ct);
			 if(el!=null){ 
			 	el.style.display = "block"; 
			 	el = eval("document.form" + ct).lit;
			 	if(el!=null){el.selectedIndex = 0;}
			}
		 }
		 

}
	  
	  	  
function fazLogin(){
	var email = document.login.email.value;
	var senha = document.login.senha.value;

	if(email.length > 0 && senha.length > 0 ){document.login.submit()}
	
}

function mostraLogin(){
	document.getElementById("usuario_visitante").style.display = "none";
	document.getElementById("login_usuario").style.display = "block";
}



$(function(){
	if(alturaBannerTopo>90){
		$('#interno_bannerTopo').hover(
    	     function () { $(this).height(alturaBannerTopo);}, function () { $(this).height(90); }
    	 );
	 }
});


function checaOpniao(){
	var nome = document.opniao.nome.value;
	var email = document.opniao.email.value;
	var op = document.opniao.op.value;
	var erro = false;
		
	if(op.length<2){
		alert("escreva a sua opnião antes de enviar.");
		erro = true;
	}

	if(!erro&&nome.length<2){
		alert("escreva o seu nome.");
		erro = true;
	}

	if(!erro&&op.length<2){
		alert("escreva o seu email.");
		erro = true;
	}

	if(!erro&&!valida(email)){
		alert("escreva um email válido para que possamos responder a sua mensagem.");
		erro = true;
	}
		
	if(!erro){
		$('#opniao').hide();
		$('#opniao_aguarde').show();
		$('#arrudeia_opniao').animate({height:"100px"},1000);
		
		$.post("/news/enviaOpniao.asp", $('#opniao').serialize() , function(resp){

		   		resp = jQuery.trim(resp);
  
		   		if(resp.substr(5,4)=='true'){ 
		   			$('#opniao_aguarde').html("<b>Sua mensagem foi enviada.</b><br/><br/>Obrigado por opinar!");
				}							
		 });
	}
	
}

function setHoraVerao(v){
	$('#data_relogio').load("/cadastro/setHoraVerao.asp?set=" + v);
}