var NOME_IMGS = Array();
NOME_IMGS['faleconosco'] = 'fale';
NOME_IMGS['store'] = 'store';
NOME_IMGS['ead'] = 'ead';
NOME_IMGS['jornal'] = 'jornal';
NOME_IMGS['links'] = 'links';
NOME_IMGS['resgate'] = 'resgate';
NOME_IMGS['noticias'] = 'noticias';
NOME_IMGS['entrevista'] = 'entrevista';
NOME_IMGS['eventos'] = 'eventos';
NOME_IMGS['sociedade'] = 'sociedade';
NOME_IMGS['home'] = 'home';
var urlAtiva="";
var expositor="";

function include(url) {
  window.document.write('<script src="'+url+'" language="Javascript" type="text/javascript"></script>');
}

function mudarImgMenu(objImg,imgNome){
	var ver = document.getElementById('variavelVer').value;
	if(ver!='cadastro'){
		if(objImg.src.indexOf('2')==-1){
			objImg.src='imagens/'+imgNome+"2.png";
		}else if(ver!=imgNome){
			objImg.src='imagens/'+imgNome+".png";
		}
	}
}
function reEnvioAtivacao(){
	var email= document.getElementById('email').value;
	if(estaVazio(email)){
		alert('Preencha o email!');
		return;
	}
	document.getElementById('loginForm').action='process/email-ativacao.cfm';
	document.getElementById('loginForm').submit();
}
function lembrarsenha(){
	var email= document.getElementById('email').value;
	if(email==null || email==""){
		alert('Preencha o email!');
		return;
	}
	$.ajax({
	  url: 'process/lembrarsenha.cfm?email='+email,
	  success: function() {
		myAlert('<center>Sua senha foi enviada para o e-mail.<br><br>'+email+'</center>','Fechar');
	  }
	});
}
function submitToInc(form,inc){
	document.getElementById(form).action="index.cfm?ver="+inc;
	document.getElementById(form).submit();
}
function locationToInc(inc){
	window.location="index.cfm?ver="+inc;
}
function cadastrar(cadastroForm){
	var form = document.getElementById(cadastroForm);
	var erro = "";
	
	if(estaVazio(document.getElementById('nome').value)){
		erro = "- nome\n";
	}
	if(document.getElementById('estado') &&
		document.getElementById('estado').selectedIndex==0){
		erro += "- estado\n";
	}
	if(estaVazio(document.getElementById('cidade').value)){
		erro += "- cidade\n";
	}
	if(estaVazio(document.getElementById('email').value) 
		//|| !emailValido(document.getElementById('email').value)
		){
		erro += "- e-mail\n";
	}
	if(estaVazio(document.getElementById('senha').value)
		|| document.getElementById('senha').value != document.getElementById('senha2').value){
		erro += "- senha";
	}
	
	if(erro==""){
		form.action='process/cadastro.cfm';
		form.submit();
	} else {
		//alert("Foram encontrados erros nos seguintes campos:\n"+erro+".");
	}
}

function estaVazio(campo){
	if(campo==null || campo==""){
		return true;
	}
	return false;
}
function abilitarMenuAmbientesVirtuais(abilitar){
	//if(!abilitar){div.style.display="none";}
	//else{
		//div.style.display="block";
		$.ajax({
	  		url: 'controles/m-user-region.cfc?method=getQtdeUsuariosPorRegiao',
	 		 success: function(retorno) {
				retorno = retorno.split(",");
				document.getElementById('qtdeMP1').innerHTML=retorno[0];
				document.getElementById('qtdeMP2').innerHTML=retorno[1];
				document.getElementById('qtdeMP3').innerHTML=retorno[2];
				document.getElementById('qtdeCC1').innerHTML=retorno[3];
				document.getElementById('qtdeCC2').innerHTML=retorno[4];
				document.getElementById('qtdeCC3').innerHTML=retorno[5];
				document.getElementById('qtdeTL').innerHTML=retorno[6];
				document.getElementById('qtdeA').innerHTML=retorno[7];
				document.getElementById('qtdeMR').innerHTML=retorno[8];
				document.getElementById('qtdeP').innerHTML=retorno[9];
				document.getElementById('qtdeB').innerHTML=retorno[10];
				document.getElementById('qtdeTD').innerHTML=retorno[11];
				document.getElementById('qtdeE').innerHTML=retorno[12];
				document.getElementById('qtdeCT').innerHTML=retorno[13];
	  		}
		});	
	//}
}
function filtrarConsultorio(valor){
	var itens = document.getElementsByName('item');
	for(var i=0;i<itens.length;i++){
		//alert(itens[i].innerHTML);
		if(itens[i].innerHTML.toUpperCase().indexOf(valor.toUpperCase())==-1){
			itens[i].style.display='none';
		}else{
			itens[i].style.display='block';
		}
	}
}
function gravarLogNavegacao(acessoFinal,tipoAcesso){
	$.ajax({
	  url: 'controles/m-log.cfc?method=LogPlataforma&acessoInicial='+urlAtiva+'&acessoFinal='+acessoFinal+'&tipoAcesso='+tipoAcesso+'&expositor='+expositor,
	  success: function() {}
	});		
}
function selecionarTipoLogin(categoria){
	var tiposCadastro = document.getElementsByName('tipocadastro');
	for(var i=0;i<tiposCadastro.length;i++){
		tiposCadastro[i].checked=false;
	}
	
	document.getElementById("tipoLoginR").style.display='none';
	document.getElementById("tipoLoginO").style.display='none';
	document.getElementById("tipoLoginS").style.display='none';
	document.getElementById("tipoLoginM").style.display='none';
	document.getElementById("tipoLoginMR").style.display='none';
	document.getElementById("tipoLoginCat").style.display='none';
	document.getElementById("tipoLogin"+categoria).style.display='block';	
}
function validaSenha(){
	if(document.cadastroForm.senha.value.valTrim() != document.cadastroForm.senha2.value.valTrim()){
		return "Confirme sua senha corretamente.";	
	}else if(document.cadastroForm.senha.value.valTrim() == document.cadastroForm.teot.value.valTrim()){
		return "Ao mudar sua senha USE algo diferente de seu TEOT.";
	}
	return false;
}
function validaLength(campo){
	return campo.value;	
}
function abrirTermoPrivacidade(){
	window.open('termos-compromisso.cfm','Termos','width=1024, height=720')
}
function cancelarMinhaInscricao(id){
	if(confirm("Ao efetuar o cancelamento, todos os dados referentes a última tentativa de pagamento no PagSeguro serão perdidos.\n\nDeseja prosseguir? ") && 
		confirm("Esta operacão não poderá ser desfeita!\n\nCaso concorde com esta condição, aperte o botão [OK].\n\nDesta forma o botão vermelho para pagar a anuidade, ficará disponível na secretaria.")){
		$.ajax({
		  url: 'controles/m-inscricao.cfc?method=cancelar&id='+id,
		  success: function() {
				alert("Último pagamento cancelado com sucesso!");
				window.location='index.cfm?ver=secretaria';
			}
		});
	}
}
include('js/formulario.js');

function PopUp(url) 
{
 params  = 'width='+(screen.width-20);
 params += ', height='+(screen.height-100);
 params += ', top=0, left=0';
 params += ', fullscreen=yes';
 params += ', scrollbars=yes';

 newwin=window.open(url,'WindowName', params);
 if (window.focus) {newwin.focus()}
 return false;
}
