function ajaxFunction(metodo, arquivo, divElem){
document.getElementById(divElem).innerHTML="<p align='center'><img src='_images/ajax-loader.gif'></p>";
var xmlHttp;
try{  // Firefox, Opera 8.0+, Safari  
	xmlHttp=new XMLHttpRequest();  
}
catch (e){  // Internet Explorer  
	try{
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    
	}
	catch (e){
		try{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch (e){
			alert("Your browser does not support AJAX!");
			return false;      
			}    
		}
	}
	xmlHttp.onreadystatechange=function(){
		if(xmlHttp.readyState==4){
//		document.myForm.time.value=xmlHttp.responseText;
		document.getElementById(divElem).innerHTML=xmlHttp.responseText;
		}
	}
	xmlHttp.open(metodo, arquivo, true);
	xmlHttp.send(null);  
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// FUNÇÃO PARA HABILITAR DIV AO CLICAR EM COMENTAR 
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function FunMostraDiv(theId){
var theArray= new Array(theId);
w=document.getElementById(theId)
if(w.style.display=="block"){w.style.display='none';}else{ 
       for(i=0; i<theArray.length; i++){
            if(theArray[i] == theId){
                w.style.display='block';
            }else{
                document.getElementById(theArray[i]).style.display='none';
				return false;      
			}
		  }
	   }
	}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// FUNÇÃO PARA VALIDAÇÃO DO FORMULARIO DE COMENTARIOS
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function ValidaComentario(frm) {
	
    if (frm.txtNome.value == ""){
		alert("O campo Nome não foi preenchido.");
		frm.txtNome.focus();
		return false;
    }
   
   	if (frm.txtCidade.value == ""){
		alert("O campo Cidade não foi preenchido.");
		frm.txtCidade.focus();
    return false;
    }
  
  	if (frm.txtComentarios.value == ""){
		alert("O campo Comentário não foi preenchido.");
		frm.txtComentarios.focus();
    return false;
    }

    if (frm.strCaptcha.value == ""){
		alert("O campo Caracteres não foi preenchido.");
		frm.strCaptcha.focus();
    return false;
    }

    if (frm.txtEmail.value == ""){
		alert("E-mail Invalido, verifique-o e tente novamente.")
		frm.txtEmail.focus();
		return false;
	}
	/*if(frm.txtUF.options[frm.txtUF.selectedIndex].value == "")
	{
		alert("Selecione um estado.");
		return false;
    }*/
	return true;
}

function validaUF(frm)
{
	if(frm.txtUF.options[frm.txtUF.selectedIndex].value == "")
	{
		alert("Selecione um estado.");
		return false;
    }
	return true;
}


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function ValidaNewsletter(){
	if (document.form_newsletter.nome.value == ""){
		alert("O campo Nome não foi preenchido");
		document.form_newsletter.nome.focus();
	return false;
	}
	if (document.form_newsletter.email.value == ""){
		alert("O campo Email não foi preenchido");
		document.form_newsletter.email.focus();
	return false;
	}
	//validar email(verificao de endereco eletrônico)
	parte1 = document.form_newsletter.email.value.indexOf("@");
	//parte2 = document.form_newsletter.email.value.indexOf(".");
	parte3 = document.form_newsletter.email.value.length;
	if (!(parte1 >= 3 && parte3 >= 9)) {
			alert ("O campo E-mail deve ser conter um endereco eletronico!");
			document.form_newsletter.email.focus();
			return false;
	}
return true;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


function enviarNewsletter(objNome, objEmail, objIp){
	
	var endereco = "actions.asp?a=n&nome=" + objNome.value + "&email=" + objEmail.value + "&ip=" + objIp;
	
	if (ValidaNewsletter())
		{
				ajaxFunction("GET", endereco, "newsletter");
		}
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function janela_center(mypage, myname, w, h, scroll) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function abre_janela(sCampo)
{
	eval("window.open('foto.asp?c=<%=id%>&o='+sCampo+'','banner','toolbar=no,status=no,height=230,width=400,left=10,top=20,scrollbars=0')");
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function checa_mail() {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.insc.email.value)){
return true
}
alert("E-mail inválido, verifique-o e tente novamente")
document.insc.email.focus();
return false;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function fcnValidacao(){
if (document.insc.nome.value == ""){
alert("O campo Nome não foi preenchido");
document.insc.nome.focus();
return false;
}
if (document.insc.dia_n.value == ""){
alert("Preencha corretamente sua data de nascimento");
document.insc.dia_n.focus();
return false;
}
if (document.insc.mes_n.value == ""){
alert("Preencha corretamente sua data de nascimento");
document.insc.mes_n.focus();
return false;
}
if (document.insc.ano_n.value == ""){
alert("Preencha corretamente sua data de nascimento");
document.insc.ano_n.focus();
return false;
}
if (document.insc.sexo.value == ""){
alert("O campo Sexo não foi preenchido");
document.insc.sexo.focus();
return false;
}

if (document.insc.profissao.value == ""){
	alert("O campo profissao não foi preenchido");
	document.insc.profissao.focus();
return false;
}
	
	if (document.insc.ddd_tel_residencial.value == "" && document.insc.ddd_tel_celular.value == "" ){
		alert("Preencha pelo menos um telefone para contato!");
		//document.insc.ddd_tel_residencial.focus();
	return false;
	}
	if (document.insc.tel_residencial.value == "" && document.insc.tel_celular.value == ""){
		alert("Preencha pelo menos um telefone para contato!");
		//document.insc.tel_residencial.focus();
	return false;
	}
	
if (document.insc.email.value == ""){
alert("O campo E-mail não foi preenchido");
document.insc.email.focus();
return false;
}
if (document.insc.endereco.value == ""){
alert("O campo Endereco não foi preenchido");
document.insc.endereco.focus();
return false;
}
if (document.insc.numero.value == ""){
alert("O campo Numero não foi preenchido");
document.insc.numero.focus();
return false;
}
if (document.insc.bairro.value == ""){
alert("O campo Bairro não foi preenchido");
document.insc.bairro.focus();
return false;
}
if (document.insc.cidade.value == ""){
alert("O campo Cidade não foi preenchido");
document.insc.cidade.focus();
return false;
}
if (document.insc.cep.value == ""){
alert("O campo CEP não foi preenchido corretamente");
document.insc.cep.focus();
return false;
}
if (document.insc.cep_c.value == ""){
alert("O campo CEP não foi preenchido corretamente");
document.insc.cep_c.focus();
return false;
}
if (document.insc.estado.value == ""){
alert("O campo Estado não foi preenchido");
document.insc.estado.focus();
return false;
}
if (document.insc.o_p.value == ""){
alert("O campo de descrição do quadro não foi preenchido corretamente");
document.insc.o_p.focus();
return false;
}
return true;
}









//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function fcnValidacaoDancas(){
if (document.insc.nome.value == ""){
alert("O campo Nome não foi preenchido");
document.insc.nome.focus();
return false;
}
if (document.insc.dia_n.value == ""){
alert("Preencha corretamente sua data de nascimento");
document.insc.dia_n.focus();
return false;
}
if (document.insc.mes_n.value == ""){
alert("Preencha corretamente sua data de nascimento");
document.insc.mes_n.focus();
return false;
}
if (document.insc.ano_n.value == ""){
alert("Preencha corretamente sua data de nascimento");
document.insc.ano_n.focus();
return false;
}
if (document.insc.sexo.value == ""){
alert("O campo Sexo não foi preenchido");
document.insc.sexo.focus();
return false;
}

	if (document.insc.profissao.value == ""){
		alert("O campo profissao não foi preenchido");
		document.insc.profissao.focus();
	return false;
	}
	if (document.insc.tempo_profissao.value == ""){
		alert("O campo tempo de profissão não foi preenchido");
		document.insc.tempo_profissao.focus();
	return false;
	}
	
	if (document.insc.ddd_tel_residencial.value == "" && document.insc.ddd_tel_celular.value == "" ){
		alert("Preencha pelo menos um telefone para contato!");
		//document.insc.ddd_tel_residencial.focus();
	return false;
	}
	if (document.insc.tel_residencial.value == "" && document.insc.tel_celular.value == ""){
		alert("Preencha pelo menos um telefone para contato!");
		//document.insc.tel_residencial.focus();
	return false;
	}
	
if (document.insc.email.value == ""){
alert("O campo E-mail não foi preenchido");
document.insc.email.focus();
return false;
}
if (document.insc.endereco.value == ""){
alert("O campo Endereco não foi preenchido");
document.insc.endereco.focus();
return false;
}
if (document.insc.numero.value == ""){
alert("O campo Numero não foi preenchido");
document.insc.numero.focus();
return false;
}
if (document.insc.bairro.value == ""){
alert("O campo Bairro não foi preenchido");
document.insc.bairro.focus();
return false;
}
if (document.insc.cidade.value == ""){
alert("O campo Cidade não foi preenchido");
document.insc.cidade.focus();
return false;
}
if (document.insc.cep.value == ""){
alert("O campo CEP não foi preenchido corretamente");
document.insc.cep.focus();
return false;
}
if (document.insc.cep_c.value == ""){
alert("O campo CEP não foi preenchido corretamente");
document.insc.cep_c.focus();
return false;
}
if (document.insc.estado.value == ""){
alert("O campo Estado não foi preenchido");
document.insc.estado.focus();
return false;
}
if (document.insc.o_p.value == ""){
alert("O campo de descrição do quadro não foi preenchido corretamente");
document.insc.o_p.focus();
return false;
}
return true;
}










function fcnValidacaoFORM2(){
if (document.insc.nome.value == ""){
alert("O campo Nome não foi preenchido");
document.insc.nome.focus();
return false;
}
if (document.insc.dia_n.value == ""){
alert("Preencha corretamente sua data de nascimento");
document.insc.dia_n.focus();
return false;
}
if (document.insc.mes_n.value == ""){
alert("Preencha corretamente sua data de nascimento");
document.insc.mes_n.focus();
return false;
}
if (document.insc.ano_n.value == ""){
alert("Preencha corretamente sua data de nascimento");
document.insc.ano_n.focus();
return false;
}

if (!document.insc.sexo[0].checked && !document.insc.sexo[1].checked) {
	alert("Escolha o sexo!")
	return false;
}



	
	if (document.insc.ddd_tel_residencial.value == "" && document.insc.ddd_tel_celular.value == "" ){
		alert("Preencha pelo menos um telefone para contato!");
		//document.insc.ddd_tel_residencial.focus();
	return false;
	}
	if (document.insc.tel_residencial.value == "" && document.insc.tel_celular.value == ""){
		alert("Preencha pelo menos um telefone para contato!");
		//document.insc.tel_residencial.focus();
	return false;
	}
	
	
	
	if (document.insc.email.value == ""){
		alert("O campo Email não foi preenchido");
		document.insc.email.focus();
	return false;
	}
	//validar email(verificao de endereco eletrônico)
	parte1 = document.insc.email.value.indexOf("@");
	//parte2 = document.form_newsletter.email.value.indexOf(".");
	parte3 = document.insc.email.value.length;
	if (!(parte1 >= 3 && parte3 >= 9)) {
			alert ("O campo E-mail deve ser conter um endereco eletronico!");
			document.insc.email.focus();
			return false;
	}
	
if (document.insc.endereco.value == ""){
alert("O campo Endereco não foi preenchido");
document.insc.endereco.focus();
return false;
}
if (document.insc.numero.value == ""){
alert("O campo Numero não foi preenchido");
document.insc.numero.focus();
return false;
}
if (document.insc.bairro.value == ""){
alert("O campo Bairro não foi preenchido");
document.insc.bairro.focus();
return false;
}
if (document.insc.cidade.value == ""){
alert("O campo Cidade não foi preenchido");
document.insc.cidade.focus();
return false;
}
if (document.insc.cep.value == ""){
alert("O campo CEP não foi preenchido corretamente");
document.insc.cep.focus();
return false;
}
if (document.insc.cep_c.value == ""){
alert("O campo CEP não foi preenchido corretamente");
document.insc.cep_c.focus();
return false;
}
if (document.insc.estado.value == ""){
alert("O campo Estado não foi preenchido");
document.insc.estado.focus();
return false;
}
if (document.insc.o_p.value == ""){
alert("O campo Fale um pouco sobre você não foi preenchido corretamente");
document.insc.o_p.focus();
return false;
}

if (document.insc.peso.value == ""){
alert("O campo peso não foi preenchido corretamente");
document.insc.peso.focus();
return false;
}

if (document.insc.altura.value == ""){
alert("O campo altura não foi preenchido corretamente");
document.insc.altura.focus();
return false;
}

if (document.insc.blusa.value == ""){
alert("O campo blusa não foi preenchido corretamente");
document.insc.blusa.focus();
return false;
}

if (document.insc.calca.value == ""){
alert("O campo Calça não foi preenchido corretamente");
document.insc.calca.focus();
return false;
}
if (document.insc.sapato.value == ""){
alert("O campo sapato não foi preenchido corretamente");
document.insc.sapato.focus();
return false;
}

if (document.insc.participou_programa_tv.value == 0 && document.insc.participou_programa_tv.value == ""){
		alert("Selecione o campo Já participou de programa tv?");
		document.insc.participou_programa_tv.focus();
	return false;
}
	
if(document.insc.participou_programa_tv.options[document.insc.participou_programa_tv.selectedIndex].value == "Sim"){
		if (document.insc.qual_programa_tv.value == ""){
			alert("O campo Qual programa de tv? não foi preenchido corretamente");
			document.insc.qual_programa_tv.focus();
			return false;
		}
		document.insc.qual_programa_tv.focus();
}



if (document.insc.restricoes_biquini.value == 0 && document.insc.restricoes_biquini.value == ""){
		alert("Selecione o campo Tem restricões a biquini?");
		document.insc.restricoes_biquini.focus();
	return false;
}

if (document.insc.foto.value == ""){
alert("O campo Foto não foi preenchido corretamente");
document.insc.foto.focus();
return false;
}


return true;
}