// JavaScript Document

function abrir(param, h, w) {
    novaJanela = window.open(param, 'janela', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,height='+h+',width='+w);
} 

function abrirgirl(nome) {
	url = "clickgirl/" + nome +  "/index.html"
	clickgirl = window.open(url, nome, 'maximized=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,top=20,left=0,width=790,height=520');
}

function overMenu(cel,secao){
		cel.style.cursor='hand';		
		cel.style.color = '#fae713';
		try {
			obj = eval("secao_" + secao)
		}
		catch(e){
			obj = null
		}
		if (!(obj == null)){
			cel.background = 'images/new/fundo_barra_on.gif';
			barra_info.style.display = 'none';
			obj.style.display='block';
		}
}

function outMenu(cel,secao){		
		cel.style.cursor='auto';
		window.status = event.clientY;
		if ((event.clientY < 190) || (event.clientY > 209)){						
			cel.style.color = '';
			try{
				obj = eval("secao_" + secao)
			}
			catch(e){
				obj = null
			}
			if (!(obj == null)){
				cel.background = '';
				barra_info.style.display = 'block';
				obj.style.display='none';
			}
		}
}

function showList(sigla){
	clearList();
	eval("link_" + state + ".className='linkEstado';");
	//eval("seta_" + state + ".src='images/new/transp.gif';");
	eval("link_" + sigla + ".className='current_state';");
	//eval("seta_" + sigla + ".src='images/new/ico_seta.gif';");	
	eval("lista_praia_" + sigla + ".style.display='block';");
	eval("altura = tabela_praia_" + sigla + ".clientHeight");
	if (altura > 80){
		eval("lista_praia_" + sigla + ".style.height = 80");
	}
	else {
		eval("lista_praia_" + sigla + ".style.height = tabela_praia_" + sigla + ".clientHeight");
	}	
	state = sigla;	
	
}

hoje = new Date()
dia = hoje.getDate()
dias = hoje.getDay()
mes = hoje.getMonth()
ano = hoje.getYear()
if (dia < 10)
		dia = "0" + dia
if (ano < 2000)
		ano = "19" + ano

var NomeDia = new Array(7)
NomeDia[0] = "Domingo"
NomeDia[1] = "Segunda-feira"
NomeDia[2] = "Terça-feira"
NomeDia[3] = "Quarta-feira"
NomeDia[4] = "Quinta-feira"
NomeDia[5] = "Sexta-feira"
NomeDia[6] = "Sábado"

var NomeMes = new Array(11);
NomeMes[0] = "Janeiro"
NomeMes[1] = "Fevereiro"
NomeMes[2] = "Março"
NomeMes[3] = "Abril"
NomeMes[4] = "Maio"
NomeMes[5] = "Junho"
NomeMes[6] = "Julho"
NomeMes[7] = "Agosto"
NomeMes[8] = "Setembro"
NomeMes[9] = "Outubro"
NomeMes[10] = "Novembro"
NomeMes[11] = "Dezembro"

function WriteDate() {
        document.write (dia + " de " + NomeMes[mes] + " de " + ano)
}

function validacao() {
		msg = ""
        		
		if (isEmpty(document.Cadastro.nome.value) || !checkField(document.Cadastro.nome.value)) {
		    msg += "Ocorreram irregularidades no campo NOME(Preenchimento Obrigatório).\n";
		}
		if (isEmpty(document.Cadastro.email.value) || !Emailverify(document.Cadastro.email.value)) {
		    msg += "Ocorreram irregularidades no campo E-MAIL(Preenchimento Obrigatório).\n";
		}
		if (isEmpty(document.Cadastro.cidade.value) || !checkField(document.Cadastro.cidade.value)) {
		    msg += "Ocorreram irregularidades no campo CIDADE(Preenchimento Obrigatório).\n";
		}
		if (document.Cadastro.estado.value == 0) {
		    msg += "Ocorreram irregularidades no campo ESTADO(Preenchimento Obrigatório).\n";
		}
		if (isEmpty(document.Cadastro.assunto.value) || !checkField(document.Cadastro.assunto.value)) {
		    msg += "Ocorreram irregularidades no campo ASSUNTO(Preenchimento Obrigatório).\n";
		}
		if (isEmpty(document.Cadastro.comenta.value)) {
		    msg += "Ocorreram irregularidades no campo DESCRIÇÃO(Preenchimento Obrigatório).\n";
		}
		
		if (msg != "") {
			alert(msg);
			return false;
		} else {
			return true;
		}
	}
	
function check_mail(strmail) {
	//alert ("oi")	
	if(strmail == '') 
		return;
	chartosplit = ',;';
	protectchar = '"';
	temp = '';
	armail = new Array();
	inthechar = false; 
	lt = '<';
	gt = '>'; 
	isclosed = true;

	for(i=0;i<strmail.length;i++) {
		thischar = strmail.charAt(i);
		if(thischar == lt && isclosed) isclosed = false;
		if(thischar == gt && !isclosed) isclosed = true;
		if(thischar == protectchar) inthechar =	(inthechar)?0:1;
		if(chartosplit.indexOf(thischar) != -1 && !inthechar && isclosed) {
			armail[armail.length] = temp; temp = '';
		} 
		else
		  temp += thischar;
	}
	armail[armail.length] = temp; 

	for(i=0;i<armail.length;i++) {
		thismail = armail[i]; strPat = /(.*)<(.*)>/;
		matchArray = thismail.match(strPat); 
		if (matchArray != null) 
			strEmail = matchArray[2];
		else {
			strPat = /([-a-zA-Z0-9_$+.]+@[-a-zA-Z0-9_.]+[-a-zA-Z0-9_]+)((.*))/; 
			matchArray = thismail.match(strPat); 
			if (matchArray != null) 
				strEmail = matchArray[1]; 
			else 
				strEmail = thismail;
		}
		if (strEmail.charAt(0) == '"' && strEmail.charAt(strEmail.length-1) == '"')
			 strEmail = strEmail.substring(1,strEmail.length-1) 
		if(strEmail.charAt(0) == '<' && strEmail.charAt(strEmail.length-1) == '>') 
			strEmail = strEmail.substring(1,strEmail.length-1)
		strPat = /([-a-zA-Z0-9_$+.]+@[-a-zA-Z0-9_.]+[-a-zA-Z0-9_]+)((.*))/;
		matchArray = strEmail.match(strPat); 
		if(matchArray == null){					
			return false;}
		else {
			return true;
		}
	}
}

function doNumber() {
	var whichcode = window.event.keyCode;
	if(whichcode < chr('0')) whichcode = 0;
	if(whichcode > chr('9')) whichcode = 0;
	window.event.keyCode = whichcode; 
}


function chr(which) {
return(which.charCodeAt(0)); }

function validata(obj){
	if (obj.value.length==2) obj.value = obj.value + "/";
	if (obj.value.length==5) obj.value = obj.value + "/";
}

function getPrevisao(estado) {		
	try {
		var Resposta;
		var oXmlhttp = new ActiveXObject('MSXML2.XMLHTTP');
		oXmlhttp.open('GET', "remote_previsao.asp?estado=" + estado, false);
		oXmlhttp.send();
		Resposta = oXmlhttp.responseText;
		if (Resposta != ""){
			previsao_informe.innerHTML = Resposta;
		}
	}
	catch (err){
		alert("Seu navegador não suporta esta função!");
	}
}