// Esperia

// Desativar "Ativar controle do flash"
function ActiveX() {
	theObjects = document.getElementsByTagName("object");
	for (var i = 0; i < theObjects.length; i++) {
		theObjects[i].outerHTML = theObjects[i].outerHTML;
	}
}

function validar(form1){
 if (document.form1.nome.value.length < 1){
  alert("O campo Nome não pode ficar em branco.");
  form1.nome.focus();
  return false;
 }
  if (document.form1.ddd.value.length < 1){
  alert("O campo DDD não pode ficar em branco.");
  form1.ddd.focus();
  return false;
  }
  if (document.form1.telefone.value.length < 1){
  alert("O campo Telefone não pode ficar em branco.");
  form1.telefone.focus();
  return false;
 }
  if (document.form1.email.value.length < 1){
  alert("O campo Email não pode ficar em branco.");
  form1.email.focus();
  return false;
 }
 if ((document.form1.email.value.indexOf('@')==-1) || (document.form1.email.value.indexOf('.')== -1)) { 	
 	alert("Campo de Email inválido."); 
	form1.email.focus(); 
	return false; 
}
	return true;
}

function mudarImagem(novaimagem, galeria, leg) {

     var imggaleria = document.getElementById(galeria);
								
     imggaleria.src = novaimagem;
	 
	 //document.getElementById("leg_sel").innerHTML = leg;

     return false;
}

function ActiveX(){
theObjects = document.getElementsByTagName("object");
for (var i = 0; i < theObjects.length; i++) {
theObjects[i].outerHTML = theObjects[i].outerHTML;
}}

function validaForm(form){
 if (document.form.nome.value.length < 1){
  alert("O campo Nome não pode ficar em branco.");
  form.nome.focus();
  return false;
 }
  if (document.form.telefone.value.length < 1){
  alert("O campo Telefone não pode ficar em branco.");
  form.telefone.focus();
  return false;
 }
 if (isNaN(document.form.telefone.value)){
	alert ("O campo Telefone deve conter apenas numeros!");
	document.form.telefone.focus();
	return false;
	}
  if (document.form.email.value.length < 1){
  alert("O campo Email não pode ficar em branco.");
  form.email.focus();
  return false;
 }
 if (document.form.email.value.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1) {
	alert("Campo de E-mail inválido!");
	document.form.email.focus();
	return false;
	}
return true;
}

function EnviarPorEmail(){
	window.open('../enviarporemail/form.asp','EnviarPorEmail',"width=450,height=260, left=" + screen.width/3 + ", top="+screen.height/3);
}

function AgendarTeste(atividade,checked){
	window.open('../atividades/agendeseuteste.asp?atividade='+atividade+'&checked='+checked+'','AgendarTeste',"width=510,height=670, left=" + screen.width/4 + ", top="+screen.height/6+",scrollbars=yes");
}

function AlugarSalao(salao){
	window.open('../saloes/alugarsalao.asp?salao='+salao+'','AlugarSalao',"width=530,height=720,scrollbars=yes,menubar=no,status=no,toolbar=no,fullscreen=no, left=" + screen.width/4 + ", top="+screen.height/6);
}

function Enquete(){
	window.open('../enquete.asp','Enquete',"width=520,height=680,scrollbars=yes,menubar=no,status=no,toolbar=no,fullscreen=no, left=" + screen.width/4 + ", top="+screen.height/6);
}

function Oportunidades(){
	window.open('../oportunidades/oportunidades.asp','Oportunidade',"width=520,height=520,scrollbars=yes,menubar=no,status=no,toolbar=no,fullscreen=no, left=" + screen.width/4 + ", top="+screen.height/6);
}

//Valida se selecionou algum horario
function validarAgendaHorario() {
	var cont = -1;
	var selecionou = false;
	if (document.getElementById("TotalHorario"))
		cont = document.getElementById("TotalHorario").value;

	//Valida Horario
	for (i=0; i<=cont; i++) {
		if (document.getElementById("Horario" + i).checked)	{
			selecionou	= true;
			break;
		}
	}
	
	if (selecionou==false) {
		alert("Selecione o horário desejado!");
	}
	
	return selecionou;
}

function validarAgenda(form3) {
	if (document.form3.socio[0].checked == true && document.form3.socio[1].checked == false){
		if (document.form3.rm.value.length < 1){
			alert("O campo Matrícula não pode ficar em branco.");
			form3.rm.focus();
			return false;
		}
		if (document.form3.nome.value.length < 1){
			alert("O campo Nome não pode ficar em branco.");
			form3.nome.focus();
			return false;
		}
		if (document.form3.telefone.value.length < 1){
			alert("O campo Telefone não pode ficar em branco.");
			form3.telefone.focus();
			return false;
		}
		if (document.form3.email.value.length < 1){
			alert("O campo Email não pode ficar em branco.");
			form3.email.focus();
			return false;
		}
		if ((document.form3.email.value.indexOf('@')==-1) || (document.form3.email.value.indexOf('.')== -1)) { 	
			alert("Campo de Email inválido."); 
			form3.email.focus(); 
			return false; 
		}
		if (document.form3.observacoes.value.length < 1){
			alert("O campo Observações não pode ficar em branco.");
			form3.observacoes.focus();
			return false;
		}
		
		//Valida horario
		return validarAgendaHorario();
	} else {
		if (document.form3.nome.value.length < 1){
			alert("O campo Nome não pode ficar em branco.");
			 form3.nome.focus();
		  return false;
		}
		if (document.form3.rg.value.length < 1){
			alert("O campo RG não pode ficar em branco.");
			form3.rg.focus();
			return false;
		}
		if (document.form3.cpf.value.length < 1){
			alert("O campo CPF não pode ficar em branco.");
			form3.cpf.focus();
			return false;
		}
		if (document.form3.cep.value.length < 1){
			alert("O campo CEP não pode ficar em branco.");
			form3.cep.focus();
			return false;
		}
		if (document.form3.endereco.value.length < 1){
			alert("O campo Endereço não pode ficar em branco.");
			form3.nome.focus();
			return false;
		}
		if (document.form3.numero.value.length < 1){
			alert("O campo Número não pode ficar em branco.");
			form3.numero.focus();
			return false;
		}
		if (document.form3.cidade.value.length < 1){
			alert("O campo Cidade não pode ficar em branco.");
			form3.cidade.focus();
			return false;
		}
		if (document.form3.uf.value.length < 1){
			alert("O campo UF não pode ficar em branco.");
			form3.uf.focus();
			return false;
		}
		if (document.form3.telefone.value.length < 1){
			alert("O campo Telefone não pode ficar em branco.");
			form3.telefone.focus();
			return false;
		}
		if (document.form3.email.value.length < 1){
			alert("O campo Email não pode ficar em branco.");
			form3.email.focus();
			return false;
		}
		if ((document.form3.email.value.indexOf('@')==-1) || (document.form3.email.value.indexOf('.')== -1)) { 	
			alert("Campo de Email inválido."); 
			form3.email.focus(); 
			return false; 
		}
		if (document.form3.observacoes.value.length < 1){
			alert("O campo Observações não pode ficar em branco.");
			form3.observacoes.focus();
			return false;
		}
		
		//Valida horario
		return validarAgendaHorario();
	}
}

function insereEmail(e) {
	fnAjax("GET", "divEmail", "ajax.asp", "operacao=insereEmail&e="+e, "", "");
}

function validarSalao(form2){
	 if (document.form2.socio[0].checked == true && document.form2.socio[1].checked == false){
		 
			if (document.form2.rm.value.length < 1){
				alert("O campo Matrícula não pode ficar em branco.");
				form2.rm.focus();
				return false;
			}
			if (document.form2.nome.value.length < 1){
				alert("O campo Nome não pode ficar em branco.");
				 form2.nome.focus();
			  return false;
			}
			if (document.form2.telefone.value.length < 1){
				alert("O campo Telefone não pode ficar em branco.");
				form2.telefone.focus();
				return false;
			}
			if (document.form2.email.value.length < 1){
				alert("O campo Email não pode ficar em branco.");
				form2.email.focus();
				return false;
			}
			if ((document.form2.email.value.indexOf('@')==-1) || (document.form2.email.value.indexOf('.')== -1)) { 	
				alert("Campo de Email inválido."); 
				form2.email.focus(); 
				return false; 
			}
			if (document.form2.tipoevento[0].checked == false && document.form2.tipoevento[1].checked == false && document.form2.tipoevento[2].checked == false){
				alert("O campo Tipo de evento não pode ficar em branco.");
				return false;
			}
			return true;
			
	}else {
			if (document.form2.nome.value.length < 1){
				alert("O campo Nome não pode ficar em branco.");
				 form2.nome.focus();
			 	 return false;
			}
			if (document.form2.rg.value.length < 1){
				alert("O campo RG não pode ficar em branco.");
				form2.rg.focus();
				return false;
			}
			if (document.form2.cpf.value.length < 1){
				alert("O campo CPF não pode ficar em branco.");
				form2.cpf.focus();
				return false;
			}
			if (document.form2.cep.value.length < 1){
				alert("O campo CEP não pode ficar em branco.");
				form2.cep.focus();
				return false;
			}
			if (document.form2.endereco.value.length < 1){
				alert("O campo Endereço não pode ficar em branco.");
				form2.endereco.focus();
				return false;
			}
			if (document.form2.numero.value.length < 1){
				alert("O campo Número não pode ficar em branco.");
				form2.numero.focus();
				return false;
			}
			if (document.form2.cidade.value.length < 1){
				alert("O campo Cidade não pode ficar em branco.");
				form2.cidade.focus();
				return false;
			}
			if (document.form2.uf.value.length < 1){
				alert("O campo UF não pode ficar em branco.");
				form2.uf.focus();
				return false;
			}
			if (document.form2.telefone.value.length < 1){
				alert("O campo Telefone não pode ficar em branco.");
				form2.telefone.focus();
				return false;
			}
			if (document.form2.email.value.length < 1){
				alert("O campo Email não pode ficar em branco.");
				form2.email.focus();
				return false;
			}
			if ((document.form2.email.value.indexOf('@')==-1) || (document.form2.email.value.indexOf('.')== -1)) { 	
				alert("Campo de Email inválido."); 
				form2.email.focus(); 
				return false; 
			}
			if (document.form2.tipoevento[0].checked == false && document.form2.tipoevento[1].checked == false && document.form2.tipoevento[2].checked == false){
				alert("O campo Tipo de evento não pode ficar em branco.");
				return false;
			}
			return true;
			}
		
}

function validarEnquete(form5){
	if (document.form5.visual[0].checked == false && document.form5.visual[1].checked == false && document.form5.visual[2].checked == false && document.form5.visual[3].checked == false){
		alert("Selecione uma opção sobre a parte visual do site.");
		return false;
	}
	if (document.form5.navegacao[0].checked == false && document.form5.navegacao[1].checked == false && document.form5.navegacao[2].checked == false && document.form5.navegacao[3].checked == false){
		alert("Selecione uma opção sobre a navegação do site.");
		return false;
	}
	if (document.form5.conteudo[0].checked == false && document.form5.conteudo[1].checked == false && document.form5.conteudo[2].checked == false && document.form5.conteudo[3].checked == false){
		alert("Selecione uma opção sobre os conteúdos do site.");
		return false;
	}
	if (document.form5.procurou[0].checked == false && document.form5.procurou[1].checked == false){
		alert("Selecione uma opção sobre se você não encontrou algo no site.");
		return false;
	}
	if (document.form5.procurou[0].checked == true && document.form5.procurou[1].checked == false){
		if (document.form5.oque.value.length < 1){
				alert("O campo O que não pode ficar em branco.");
				form5.oque.focus();
				return false;
			}
	}
	if (document.form5.nome.value.length < 1){
		alert("O campo Nome não pode ficar em branco.");
		form5.nome.focus();
		return false;
	}
	if (document.form5.email.value.length < 1){
		alert("O campo Email não pode ficar em branco.");
		form5.email.focus();
		return false;
	}
	if ((document.form5.email.value.indexOf('@')==-1) || (document.form5.email.value.indexOf('.')== -1)) { 	
		alert("Campo de Email inválido."); 
		form5.email.focus(); 
		return false; 
	}
		return true;
}

function validarOportunidade(form6) {
	if (document.form6.socio[0].checked == true && document.form6.socio[1].checked == false){
		
	if (document.form6.rm.value.length < 1){
		alert("O campo Matrícula não pode ficar em branco.");
		form6.rm.focus();
		return false;
	}
	if (document.form6.nome.value.length < 1){
		alert("O campo Nome não pode ficar em branco.");
		form6.nome.focus();
		return false;
	}
	if (document.form6.telefone.value.length < 1){
		alert("O campo Telefone não pode ficar em branco.");
		form6.telefone.focus();
		return false;
	}
	if (document.form6.email.value.length < 1){
		alert("O campo Email não pode ficar em branco.");
		form6.email.focus();
		return false;
	}
	if ((document.form6.email.value.indexOf('@')==-1) || (document.form6.email.value.indexOf('.')== -1)) { 	
		alert("Campo de Email inválido."); 
		form6.email.focus(); 
		return false; 
	}
} else {
	if (document.form6.nome.value.length < 1){
		alert("O campo Nome não pode ficar em branco.");
		form6.nome.focus();
		return false;
	}
	if (document.form6.telefone.value.length < 1){
		alert("O campo Telefone não pode ficar em branco.");
		form6.telefone.focus();
		return false;
	}
	if (document.form6.email.value.length < 1){
		alert("O campo Email não pode ficar em branco.");
		form6.email.focus();
		return false;
	}
	if ((document.form6.email.value.indexOf('@')==-1) || (document.form6.email.value.indexOf('.')== -1)) { 	
		alert("Campo de Email inválido."); 
		form6.email.focus(); 
		return false; 
	}
}
}

function validaOuvidoria(form7){
 if (document.form7.nome.value.length < 1){
  alert("O campo Nome não pode ficar em branco.");
  form7.nome.focus();
  return false;
 }
  if (document.form7.ddd.value.length < 1){
  	alert("O campo DDD não pode ficar em branco.");
  	form7.ddd.focus();
  	return false;
  }
  if (document.form7.telefone.value.length < 1){
  alert("O campo Telefone não pode ficar em branco.");
  form7.telefone.focus();
  return false;
 }
 if (isNaN(document.form7.telefone.value)){
	alert ("O campo Telefone deve conter apenas numeros!");
	document.form7.telefone.focus();
	return false;
	}
  if (document.form7.email.value.length < 1){
  alert("O campo Email não pode ficar em branco.");
  form7.email.focus();
  return false;
 }
 if (document.form7.email.value.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1) {
	alert("Campo de E-mail inválido!");
	document.form7.email.focus();
	return false;
	}
return true;
}


//Banners Clicks
function fnBannersClicks(c) {
	fnAjax("GET", "id_sav", apl_Url + "ajax.asp", "operacao=setBannerClick&CodBanner="+c, "", "");
}

function Eventos(codigo, mes, ano) {
	var parametros = "operacao=MudaEvento&codigo="+codigo+"&mes="+mes+"&ano="+ano;
	fnAjax("GET", "dados", "../inc/ajax.asp", parametros, "", "");
}

function Eventos2(codigo) {
	var parametros = "operacao=MudaEvento2&codigo="+codigo;
	fnAjax("GET", "dados", "../inc/ajax.asp", parametros, "", "");
}

function Eventos3() {
	var parametros = "operacao=MudaEvento3";
	fnAjax("GET", "dados", "../inc/ajax.asp", parametros, "", "");
}

function Eventos4() {
	var parametros = "operacao=MudaEvento4";
	fnAjax("GET", "dados", "../inc/ajax.asp", parametros, "", "");
}

function Eventos5(codigo) {
	var parametros = "operacao=MudaEvento5&codigo="+codigo;
	fnAjax("GET", "dados", "../inc/ajax.asp", parametros, "", "");
}

function Eventos6(codigo) {
	var parametros = "operacao=MudaEvento6&codigo="+codigo;
	fnAjax("GET", "dados", "../inc/ajax.asp", parametros, "", "");
}

function Eventos7(codigo) {
	var parametros = "operacao=MudaEvento7&codigo="+codigo;
	fnAjax("GET", "dados", "../inc/ajax.asp", parametros, "", "");
}

function Time(){
	Banner1();
	var x = window.setInterval(Banner1,20000);	
}

function Banner1() {
	var parametros = "operacao=Banner1";
	fnAjaxPrototype("GET", "divBanner1", "../inc/ajax.asp", parametros, "", "");
}

function Time2(){
	Banner2();
	var x = window.setInterval(Banner2,20000);
}

function Banner2() {
	var parametros = "operacao=Banner2";
	fnAjaxPrototype("GET", "divBanner2", "../inc/ajax.asp", parametros, "", "");
}


function Time3(){
	if(!document.getElementById("codb1")){
		Banner3();
	}
	var x = window.setInterval(Banner3,20000);	
}

function Banner3() {
	var parametros = "operacao=Banner3";
	if(document.getElementById("codb1")){
		parametros = parametros + "&codbanner="+ document.getElementById("codb1").value;
	}
	fnAjax("GET", "divBanner3", "../inc/ajax.asp", parametros, "", "");
}

function Time4(){
	if(!document.getElementById("codb2")){
		Banner4();
	}
	var x = window.setInterval(Banner4,2000);
}

function Banner4() {
	var parametros = "operacao=Banner4";
	if(document.getElementById("codb2")){
		parametros = parametros + "&codbanner="+ document.getElementById("codb2").value;
	}
	fnAjax("GET", "divBanner4", "../inc/ajax.asp", parametros, "", "");
}

function BannerTopo() {
	var parametros = "operacao=BannerTopo";
	fnAjax("GET", "divBannerTopo", "../inc/ajax.asp", parametros, "", "");
}

function fnEncaminhe() {
	var obj;
	var rtn = true;
	
	obj = document.getElementById("NomeDes");
	if (obj.value == "") {
		alert('Informe o nome do destinatário!');
		rtn = false;
		obj.focus();
	}
	
	obj = document.getElementById("EmailDes");
	if (rtn && obj.value == "") {
		alert('Informe o e-mail do destinatário!');
		rtn = false;
		obj.focus();
	} else {
		if (rtn && !isEmail(obj.value)) {
			alert('E-mail do destinatário inválido!!');
			rtn = false;
			obj.focus();
		}
	}
	
	obj = document.getElementById("NomeSeu");
	if (rtn && obj.value == "") {
		alert('Informe o seu nome!');
		rtn = false;
		obj.focus();
	}
	
	if (rtn) {
		document.getElementById("frmEncaminhe").submit();
	}
}

//Verifica se eh Email Valido
function isEmail(v) {
	var a=0
	var p=0
	
	if (v.length==0)
		return(true);
	
	for(var i=1;i<v.length;i++) {
		if(!v.charAt(i))
			return false
		else 
			if(v.charAt(i)=='@'){
				a++;
				if(v.charAt(i+1)=='')
					return false
			}
		else
			if(v.charAt(i)=='.'){
				p++;
				if(v.charAt(i+1)==''||v.charAt(i+1)=='@'||v.charAt(i-1)=='@')
					return false
			}
	}
	
	if(a==1&&p)
		return true
}

// hide vivendo
function fnHide(n){
	
	var v;
	
	if (n == 1) {
		v = "hidePalestras";
	}
	if (n == 2) {
		v = "hideOficinas";
	}
	if (n == 3) {
		v = "hideDocumentarios";
	}
	if (n == 4) {
		v = "hideEncerramento";
	}
	
	if(document.getElementById(v).style.display == "none"){
		document.getElementById(v).style.display = "";
		if(v == "hidePalestras") {
			document.getElementById("hideOficinas").style.display = "none";
			document.getElementById("hideDocumentarios").style.display = "none";
			document.getElementById("hideEncerramento").style.display = "none";
		}
		if(v == "hideOficinas") {
			document.getElementById("hidePalestras").style.display = "none";
			document.getElementById("hideDocumentarios").style.display = "none";
			document.getElementById("hideEncerramento").style.display = "none";
		}
		if(v == "hideDocumentarios") {
			document.getElementById("hidePalestras").style.display = "none";
			document.getElementById("hideOficinas").style.display = "none";
			document.getElementById("hideEncerramento").style.display = "none";
		}
		if(v == "hideEncerramento") {
			document.getElementById("hidePalestras").style.display = "none";
			document.getElementById("hideOficinas").style.display = "none";
			document.getElementById("hideDocumentarios").style.display = "none";
		}
	} else {
		document.getElementById(v).style.display = "none";
	}
}
