// JavaScript Document

/* ALERTA */
function alerta(titulo,mensagem){
	document.getElementById('popup_container').style.display = "block";
	document.getElementById('popup_title').innerHTML = titulo;
	document.getElementById('mensagem').innerHTML = mensagem;
}
function fecharAlerta(){
	document.getElementById('popup_container').style.display = "none";
}

/* EFEITO MouseOver DOS ICONES DE SERVIÇOS E PRODUTOS - Todas as páginas */
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

/* EFEITO DO CAMPO DE CEP - Todas as páginas */
function validaCep(){
	estado_cep = document.getElementById("cidade_cep");
	estado_cep.value = "";
	estado_cep.style.borderColor = "#024271";
	estado_cep.style.backgroundColor = "#eff6f9";
	estado_cep.style.borderStyle = "solid";
	estado_cep.style.color = "#024271";
}

/*TROCA IMAGEM DO BOX MAPAS - previsao.php
function trocaImagem(regiao, mapa){
	document.getElementById("mapa_regiao1").src = "http://www4.climatempo.com.br/climatempo/images/mapas/" + mapa + "/mapa" + mapa + regiao + "1.gif";
	alert("http://www4.climatempo.com.br/climatempo/images/mapas/" + mapa + "/mapa" + mapa + regiao + "1.gif");
}
*/

/* SETA CIDADE PADRAO */
function setCookie(name, value,days){      
	var expireDate = new Date()
	var expstring=(typeof days!="undefined")? expireDate.setDate(expireDate.getDate()+parseInt(days)) : expireDate.setDate(expireDate.getDate()-5)          
	var curCookie = name + "=" + escape(value) +"; expires=" + expireDate.toGMTString() + "; path=/";
	document.cookie = curCookie;
	alert("Ciudad agregado!");
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return false;
}
//TROCA IMAGEM BOX LITORAL - brasil.php
n = 1;
function auto(){
fotos = new Array()
fotos[1] = "http://www4.climatempo.com.br/climatempo/ondas/imagens/br901.jpg";
fotos[2] = "http://www4.climatempo.com.br/climatempo/ondas/imagens/br902.jpg";
fotos[3] = "http://www4.climatempo.com.br/climatempo/ondas/imagens/br903.jpg";
fotos[4] = "http://www4.climatempo.com.br/climatempo/ondas/imagens/br904.jpg";
fotos[5] = "http://www4.climatempo.com.br/climatempo/ondas/imagens/br905.jpg";
fotos[6] = "http://www4.climatempo.com.br/climatempo/ondas/imagens/br906.jpg";
fotos[7] = "http://www4.climatempo.com.br/climatempo/ondas/imagens/br907.jpg";
fotos[8] = "http://www4.climatempo.com.br/climatempo/ondas/imagens/br908.jpg";
fotos[9] = "http://www4.climatempo.com.br/climatempo/ondas/imagens/br909.jpg";
fotos[10] = "http://www4.climatempo.com.br/climatempo/ondas/imagens/br910.jpg";
document.getElementById("foto").src = fotos[n];
setTimeout("auto()",1000)
n = n + 1;
	if(n  == fotos.length){
		n = 1
	}
}

//Troca video do box Videos
function muda_video(video){
document.getElementById('video').innerHTML = "<embed src='http://www.truetech.com.br/webtvconsole/usuario/embed.swf' quality='high' bgcolor='#ffffff' width='320' height='270' name='AdobeTVPlayer' play='true' loop='false' quality='high' allowScriptAccess='sameDomain' allowFullScreen='true' type='application/x-shockwave-flash' pluginspage='http://www.adobe.com/go/getflashplayer' flashVars='console=57&video="+video+"'></embed>";
}

//VALIDAÇÃO DE INTERATIVO FOTO
function valida_foto(){
	if (document.frmPesquisa2.cmbCidade.options[document.frmPesquisa2.cmbCidade.selectedIndex].value == "" || document.frmPesquisa2.cmbCidade.options[document.frmPesquisa2.cmbCidade.selectedIndex].value == 0){ 
		alerta("Erro!","Cidade Inválida");
		return false;
	}
	if (document.frmPesquisa2.txtNome.value == ''){
		alerta("Erro!","Preencha o nome");
		return false;
	}
	if (document.frmPesquisa2.txtEmail.value == ''){
		alerta("Erro!","Preencha o email");
		return false;
	}
	if (document.frmPesquisa2.txtTitulo.value == ''){
		alerta("Erro!","Preencha o título");
		return false;
	}
	if (document.frmPesquisa2.txtComentario.value == ''){
		alerta("Erro!","Escreva seu comentário");
		return false;
	}
	if (document.frmPesquisa2.txtfoto.value == ''){
		alerta("Erro!","Selecione sua foto");
		return false;
	}
}

//MOSTRA O FORMULARIO DA PAGINA INTERATIVO FOTO
ativado = 0;
function foto_interativo(){
	if(ativado == 1){
		document.getElementById('interativo').style.display = "none";
		ativado = 0;
	}else if(ativado == 0){
		document.getElementById('interativo').style.display = "block";
		ativado = 1;
	}
	
}

//VALIDA FORMULARIO DA PAGINA RADIO
function valida_radio(){
	if (document.forms[0].nome.value < 1){ 
		alerta("Erro!","Digite um nome");
		return false;
	}
	if (document.forms[0].sobrenome.value < 1){ 
		alerta("Erro!","Digite um sobrenome");
		return false;
	}
	if (document.forms[0].nome_radio.value < 1){ 
		alerta("Erro!","Digite o nome da rádio");
		return false;
	}
	if (document.forms[0].estado.value < 1){ 
		alerta("Erro!","Digite um estado");
		return false;
	}
	if (document.forms[0].cidade.value < 1){ 
		alerta("Erro!","Digite uma cidade");
		return false;
	}
	if (document.forms[0].frequencia.value < 1){ 
		alerta("Erro!","Digite uma frequência");
		return false;
	}
	if (document.forms[0].numero_ouvintes.value < 1){ 
		alerta("Erro!","Digite o número de ouvintes");
		return false;
	}
	if (document.forms[0].insercoes.value < 1){ 
		alerta("Erro!","Digite a quantidade de inserções");
		return false;
	}
	if (document.forms[0].abrangencia.value < 1){ 
		alerta("Erro!","Digite a área de abrangência");
		return false;
	}
}

//VALIDA FORMULARIO DA CONSULTORIA
function valida_form(){
	if (document.forms[0].nome.value < 1){ 
		alerta("Erro!","Digite um nome");
		return false;
	}
	if (document.forms[0].telefone.value < 1){ 
		alerta("Erro!","Digite um telefone");
		return false;
	}
	if (document.forms[0].empresa.value < 1){ 
		alerta("Erro!","Digite uma empresa");
		return false;
	}
	if (document.forms[0].email.value < 1){ 
		alerta("Erro!","Digite uma email");
		return false;
	}
	if (document.forms[0].empresa.value < 1){ 
		alerta("Erro!","Digite uma empresa");
		return false;
	}
	if (document.forms[0].pais.options[document.forms[0].pais.selectedIndex].value == "" || document.forms[0].pais.options[document.forms[0].pais.selectedIndex].value == 0){ 
		alerta("Erro!","País Inválido");
		return false;
	}
	if (document.forms[0].estado.value < 1){ 
		alerta("Erro!","Digite um estado");
		return false;
	}
	if (document.forms[0].cidade.value < 1){ 
		alerta("Erro!","Digite uma cidade");
		return false;
	}
}

//AUMENTAR/DIMNUIR AS FONTES
var tagAlvo = new Array('p'); //pega todas as tags p//
 
// Especificando os possíveis tamanhos de fontes, poderia ser: x-small, small...
var tamanhos = new Array('11px','12px','13px','14px','16px');
var tamanhoInicial = 1;
 
function changecss( idAlvo,acao ){
  if (!document.getElementById) return
  var selecionados = null,tamanho = tamanhoInicial,i,j,tagsAlvo;
  tamanho += acao;
  if ( tamanho < 0 ) tamanho = 0;
  if ( tamanho > 4 ) tamanho = 4;
  tamanhoInicial = tamanho;
  if ( !( selecionados = document.getElementById( idAlvo ) ) ) selecionados = document.getElementsByTagName( idAlvo )[ 0 ];
  
  selecionados.style.fontSize = tamanhos[ tamanho ];
  
  for ( i = 0; i < tagAlvo.length; i++ ){
    tagsAlvo = selecionados.getElementsByTagName( tagAlvo[ i ] );
    for ( j = 0; j < tagsAlvo.length; j++ ) tagsAlvo[ j ].style.fontSize = tamanhos[ tamanho ];
  }
}

