﻿var public_ja_consta = "#_public_ja_consta";
var public_erro = "#_public_erro";
var public_nao_consta = "#_public_nao_consta";
var vazio = "#_empty";
function AbrirAjax() {
	
	var xmlhttp;
	try {
		//Para o Internet Explorer
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	catch(e) {
	 try {
	  //Para o Internet Explorer
	  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	 }
	 catch(ex) {
	  try {
	   //Para todos os outros Browsers (FireFox,Opera, etc ...)
	   xmlhttp = new XMLHttpRequest();
	  }
	  catch(exc) {
	   alert("Seu navegador não tem recursos para uso de Ajax");
	   xmlhttp = null;
	  }
	 }
	}
	return xmlhttp;
}

function loadLeft(arquivo, vidro, foco){
		
	var Ajax = new AbrirAjax();
	Ajax.open('post', "/", true);
	Ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	Ajax.setRequestHeader('encoding','UTF-8');
	if (!vidro){
		
		Ajax.onreadystatechange = function(){
			if (Ajax.readyState == 1){
			document.getElementById('left').innerHTML = "<p><p><p><p><center><img src='/images/gerais/loading.gif' width='32' height='32' /></center>";	
			}
			if(Ajax.readyState == 4) {
				
				document.getElementById('left').innerHTML = Ajax.responseText;
				if (foco) document.getElementById(foco).focus();
			}
		
		}
	}
	else{
		
		AbrirVidro();
		Ajax.onreadystatechange = function(){
			if(Ajax.readyState == 4) VidroConteudo(Ajax.responseText);
		}		
	}
	
	var dados =	"acao=request" + 
				"&request=view" + 
				"&arquivo=" + arquivo;
		
	Ajax.send(dados);
}

function loadCenter(arquivo, vidro, foco){
		
	var Ajax = new AbrirAjax();
	Ajax.open('post', "/", true);
	Ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	Ajax.setRequestHeader('encoding','UTF-8');
	if (!vidro){
		
		Ajax.onreadystatechange = function(){
			if (Ajax.readyState == 1){
			document.getElementById('center').innerHTML = "<p><p><p><p><center><img src='/images/gerais/loading.gif' width='32' height='32' /></center>";	
			}
			if(Ajax.readyState == 4) {
				
				document.getElementById('center').innerHTML = Ajax.responseText;
				if (foco) document.getElementById(foco).focus();
			}
		
		}
	}
	else{
		
		AbrirVidro();
		Ajax.onreadystatechange = function(){
			if(Ajax.readyState == 4) VidroConteudo(Ajax.responseText);
		}		
	}
	
	var dados =	"acao=request" + 
				"&request=view" + 
				"&arquivo=" + arquivo;
		
	Ajax.send(dados);
}

function loadRight(arquivo, vidro, foco){
		
	var Ajax = new AbrirAjax();
	Ajax.open('post', "/", true);
	Ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	Ajax.setRequestHeader('encoding','UTF-8');
	if (!vidro){
		
		Ajax.onreadystatechange = function(){
			if (Ajax.readyState == 1){
			document.getElementById('right').innerHTML = "<p><p><p><p><center><img src='/images/gerais/loading.gif' width='32' height='32' /></center>";	
			}
			if(Ajax.readyState == 4) {
				
				document.getElementById('right').innerHTML = Ajax.responseText;
				if (foco) document.getElementById(foco).focus();
			}
		
		}
	}
	else{
		
		AbrirVidro();
		Ajax.onreadystatechange = function(){
			if(Ajax.readyState == 4) VidroConteudo(Ajax.responseText);
		}		
	}
	
	var dados =	"acao=request" + 
				"&request=view" + 
				"&arquivo=" + arquivo;
		
	Ajax.send(dados);
}

function loadView(arquivo, elemento_destino_id, vidro){
		
	var Ajax = new AbrirAjax();
	Ajax.open('post', "/", true);
	Ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	Ajax.setRequestHeader('encoding','UTF-8');
	if (!vidro){
		
		Ajax.onreadystatechange = function(){
			if (Ajax.readyState == 1){
			document.getElementById(elemento_destino_id).innerHTML = "<p><p><p><p><center><img src='/images/gerais/loading.gif' width='32' height='32' /></center>";	
			}
			if(Ajax.readyState == 4) document.getElementById(elemento_destino_id).innerHTML = Ajax.responseText;		}
	}
	else{
		
		AbrirVidro();
		Ajax.onreadystatechange = function(){
			if(Ajax.readyState == 4) VidroConteudo(Ajax.responseText);
		}		
	}
	
	var dados =	"acao=request" + 
				"&request=view" + 
				"&arquivo=" + arquivo;
		
	Ajax.send(dados);
}

function loadFoto(arquivo_news, vidro_news, foco_news){
		
	var Ajax = new AbrirAjax();
	Ajax.open('post', "/", true);
	Ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	Ajax.setRequestHeader('encoding','UTF-8');
	if (!vidro_news){
		
		Ajax.onreadystatechange = function(){
			if (Ajax.readyState == 1){
			document.getElementById('center').innerHTML = "<p><p><p><p><center><img src='/images/gerais/loading.gif' width='32' height='32' /></center>";	
			}
			if(Ajax.readyState == 4) {
				
				document.getElementById('center').innerHTML = Ajax.responseText;
				if (foco_news) document.getElementById(foco_news).focus();
			}
		
		}
	}
	else{
		
		AbrirVidroFoto();
		Ajax.onreadystatechange = function(){
			if(Ajax.readyState == 4) VidroConteudoFoto(Ajax.responseText);
		}		
	}
	
	var dados =	"acao=request" + 
				"&request=view" + 
				"&arquivo=" + arquivo_news;
		
	Ajax.send(dados);
}

function AbrirVidro(){
	
	var vidro = document.createElement("div");
	vidro.setAttribute('class', 'vidro');
	vidro.setAttribute('id', 'vidro');
	vidro.ondblclick = function (){ FecharVidro();};
	document.body.appendChild(vidro);
	
	var folha_moldura = document.createElement("div");
	folha_moldura.setAttribute('class', 'folha_moldura');
	folha_moldura.setAttribute('id', 'folha_moldura');
	folha_moldura.ondblclick = function (){ FecharVidro();};
	var folha_moldura = document.body.appendChild(folha_moldura);
	
	var folha_estrutura = document.createElement("div");
	folha_estrutura.setAttribute('class', 'folha_estrutura');
	folha_estrutura.setAttribute('id', 'folha_estrutura');
	folha_estrutura.ondblclick = function (){ FecharVidro();};
	var folha_estrutura = folha_moldura.appendChild(folha_estrutura);
	
	var folha_barra = document.createElement("div");
	folha_barra.setAttribute('class', 'folha_barra');
	folha_barra.setAttribute('id', 'folha_barra');
	folha_barra.innerHTML="<a onClick='FecharVidro()' style='cursor:pointer' title='Fechar'>[x]</a>";
	folha_estrutura.appendChild(folha_barra);
	
	var folha_conteudo = document.createElement("div");
	folha_conteudo.setAttribute('class', 'folha_conteudo');
	folha_conteudo.setAttribute('id', 'folha_conteudo');
	var folha_conteudo = folha_estrutura.appendChild(folha_conteudo);
	
	document.getElementById('folha_conteudo').innerHTML="<h3>processando...</h3>";
	var Imagem = document.createElement("img");
	Imagem.setAttribute("src", "/images/gerais/loading.gif");		
	document.getElementById('folha_conteudo').appendChild(Imagem);	
}

function AbrirVidroFoto(){
	
	var vidro_news = document.createElement("div");
	vidro_news.setAttribute('class', 'vidro_news');
	vidro_news.setAttribute('id', 'vidro_news');
	vidro_news.ondblclick = function (){ FecharVidroFoto();};
	document.body.appendChild(vidro_news);
	
	var folha_moldura_news = document.createElement("div");
	folha_moldura_news.setAttribute('class', 'folha_moldura_news');
	folha_moldura_news.setAttribute('id', 'folha_moldura_news');
	folha_moldura_news.ondblclick = function (){ FecharVidroFoto();};
	var folha_moldura_news = document.body.appendChild(folha_moldura_news);
	
	var folha_estrutura_news = document.createElement("div");
	folha_estrutura_news.setAttribute('class', 'folha_estrutura_news');
	folha_estrutura_news.setAttribute('id', 'folha_estrutura_news');
	folha_estrutura_news.ondblclick = function (){ FecharVidroFoto();};
	var folha_estrutura_news = folha_moldura_news.appendChild(folha_estrutura_news);
	
	var folha_barra_news = document.createElement("div");
	folha_barra_news.setAttribute('class', 'folha_barra_news');
	folha_barra_news.setAttribute('id', 'folha_barra_news');
	folha_barra_news.innerHTML="<a onClick='FecharVidroFoto()' style='cursor:pointer' title='Fechar'>[x]</a>";
	folha_estrutura_news.appendChild(folha_barra_news);
	
	var folha_conteudo_news = document.createElement("div");
	folha_conteudo_news.setAttribute('class', 'folha_conteudo_news');
	folha_conteudo_news.setAttribute('id', 'folha_conteudo_news');
	var folha_conteudo_news = folha_estrutura_news.appendChild(folha_conteudo_news);
	
	document.getElementById('folha_conteudo_news').innerHTML="<h3>processando...</h3>";
	var Imagem = document.createElement("img");
	Imagem.setAttribute("src", "/images/gerais/loading.gif");		
	document.getElementById('folha_conteudo_news').appendChild(Imagem);	
}

function VidroConteudo(conteudo){
	
	if (document.getElementById('folha_conteudo')){
		document.getElementById('folha_conteudo').innerHTML=conteudo;
	}
	else alert('Erro. Vidro não encontrado.');
}

function VidroConteudoFoto(conteudo_news){
	
	if (document.getElementById('folha_conteudo_news')){
		document.getElementById('folha_conteudo_news').innerHTML=conteudo_news;
	}
	else alert('Erro. Vidro não encontrado.');
}

function FecharVidro(){
	
	document.body.removeChild(document.getElementById('vidro'));
	document.body.removeChild(document.getElementById('folha_moldura'));
}

function FecharVidroFoto(){
	
	document.body.removeChild(document.getElementById('vidro_news'));
	document.body.removeChild(document.getElementById('folha_moldura_news'));
}

function processar_length(field, countfield, maxlimit) {
	
	if (field.value.length > maxlimit) 
		field.value = field.value.substring(0, maxlimit);
	else 
	countfield.value = maxlimit - field.value.length;
}

function submit_msg(unidade){
	
	if (!document.getElementById('nome').value){
		alert('Informe seu nome');
		document.getElementById('nome').focus();
		return;
	}
	if (!document.getElementById('telefone').value){
		alert('Informe seu telefone');
		document.getElementById('telefone').focus();
		return;
	}
	if (!document.getElementById('email').value){
		alert('Informe seu e-mail');
		document.getElementById('email').focus();
		return;
	}
	if(!IsEmail(document.getElementById('email').value)){
		alert('Informe um e-mail válido');
		document.getElementById('email').focus();
		return;
	}
	if (!document.getElementById('assunto').value){
		alert('Informe o assunto');
		document.getElementById('assunto').focus();
		return;
	}
	if (!document.getElementById('setor').value){
		alert('Selecione o setor');
		document.getElementById('setor').focus();
		return;
	}
	if (document.getElementById('texto').length > 500){
		alert('A mensagem não pode possuir mais de 500 caracteres');
		return;
	}
	if (document.getElementById('texto').value < 1){
		alert('Sem mensagem');
		document.getElementById('texto').focus();
		return;
	}
	
	var nome 	= document.getElementById('nome').value;
	var telefone = document.getElementById('telefone').value;
	var email 	= document.getElementById('email').value;
	var assunto = document.getElementById('assunto').value;
	var msg		= document.getElementById('texto').value;
	var setor	= document.getElementById('setor').value;
	
	var Ajax = new AbrirAjax();
	Ajax.open('post', '/', true);
	Ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	Ajax.setRequestHeader('encoding','UTF-8');
	Ajax.onreadystatechange = function () {
		
		if (Ajax.readyState == 1){
			
			AbrirVidro();
		}
		
		if (Ajax.readyState == 4){
						
			if(Ajax.responseText == public_erro){
				alert("Houve um erro na requisição. Mensagem não enviada. Contacte o suporte.");
				FecharVidro();
				return;
			}
			
			alert('Mensagem enviada com sucesso');
			loadCenter('unidades/feap/faleconosco.php', false);
			FecharVidro();
			return;
		}
	}
	
	var info =  "acao=save" +
				"&controller=controllerFaleConosco.php" +
				"&target=mensagem" +
				"&dado=mensagem" +
				"&nome=" + nome +
				"&telefone=" + telefone +
				"&email=" + email +
				"&assunto=" + assunto +
				"&msg=" + msg +
				"&setor=" + setor;
	
	Ajax.send(info);
}

function IsEmail(email){
    var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
    var check=/@[\w\-]+\./;
    var checkend=/\.[a-zA-Z]{2,3}$/;
    if(((email.search(exclude) != -1)||(email.search(check)) == -1)||(email.search(checkend) == -1)){return false;}
    else {return true;}
}

function tratar_duplo_clique(){
	
	if(document.getElementById('clicked')){
	
		if (document.getElementById('clicked').value == '1'){
			setTimeout("document.getElementById('clicked').value = '0'", 1500);
			return false;
		}
		else {
			document.getElementById('clicked').value = '1';
			setTimeout("document.getElementById('clicked').value = '0'", 1500);
			return true;
		}
	}
}


function loadUnidade(arquivo, vidro, foco){
		
	var Ajax = new AbrirAjax();
	Ajax.open('post', "/", true);
	Ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	Ajax.setRequestHeader('encoding','UTF-8');
	if (!vidro){
		
		Ajax.onreadystatechange = function(){
			if (Ajax.readyState == 1){
			document.getElementById('unidade_table').innerHTML = "<p><p><p><p><center><img src='/images/gerais/loading.gif' width='32' height='32' /></center>";	
			}
			if(Ajax.readyState == 4) {
				
				document.getElementById('unidade_table').innerHTML = Ajax.responseText;
				if (foco) document.getElementById(foco).focus();
			}
		}
	}
	else{
		
		AbrirVidro();
		Ajax.onreadystatechange = function(){
			if(Ajax.readyState == 4) VidroConteudo(Ajax.responseText);
		}		
	}
	
	var dados =	"acao=request" + 
				"&request=view" + 
				"&arquivo=" + arquivo;
		
	Ajax.send(dados);
}

//////////////////////////////////////////////////
////////////////  VESTIBULAR  ////////////////////
//////////////////////////////////////////////////

function vest_zerar_status_opcao(elemento, opcao_selecionada){
	
	var child_lenght = elemento.childNodes.length;
	var count = 0;	
	
	if (elemento.value == opcao_selecionada) elemento.selectedIndex = 0;
	
	while (count <= child_lenght){
		
		if(elemento.childNodes[count].value){
			
			if((elemento.childNodes[count].value == opcao_selecionada) && (elemento.childNodes[count].value > 0))
				elemento.childNodes[count].style.display='none';				
			
			else
				elemento.childNodes[count].style.display='block';
		}
		count++;
	}
}

function processar_opcao(elemento){
	
	var opcao_selecionada = elemento.value;
	
	var elemento_opcao_1 = document.getElementById('curso_opcao_1');
	var elemento_opcao_2 = document.getElementById('curso_opcao_2');
	var elemento_opcao_3 = document.getElementById('curso_opcao_3');
	
	if(elemento == elemento_opcao_1) vest_zerar_status_opcao(elemento_opcao_2, opcao_selecionada);
	
	if(elemento == elemento_opcao_2) vest_zerar_status_opcao(elemento_opcao_3, opcao_selecionada);
	
	if(elemento == elemento_opcao_3) vest_zerar_status_opcao(elemento_opcao_1, opcao_selecionada);
}

function save_vest_inscricao(){
	
	if(!document.getElementById('lingua').value || document.getElementById('lingua').value == null){
		alert('Selecione a opção de Língua Estrangeira!');
		document.getElementById('lingua').focus();
		return;
	}
	
	if(document.getElementById('prenome').value == '' || document.getElementById('prenome').value == null){
		document.getElementById('prenome').focus();
		alert('O campo Prenome é obrigatório!');
		return;
	}
	
	if(document.getElementById('sobrenome').value == ''  || document.getElementById('sobrenome').value == null){
		document.getElementById('sobrenome').focus();
		alert('O campo Sobrenome é obrigatório!');
		return;
	}
	
	if(document.getElementById('cpf').value == ''  || document.getElementById('cpf').value == null){
		document.getElementById('cpf').focus();	
		alert('O campo CPF é obrigatório!');
		return;
	}
	
	if(document.getElementById('cpf').value.length != 11){
		document.getElementById('cpf').focus();	
		alert('O campo CPF deve conter 11 dígitos!');
		return;
	}	
	
	if(document.getElementById('naturalidade').value == '' || document.getElementById('naturalidade').value == null){
		document.getElementById('naturalidade').focus();	
		alert('O campo Naturalidade é obrigatório!');
		return;
	}
	
	if(document.getElementById('nascimento_dia').value == '' || document.getElementById('nascimento_dia').value == null){
		document.getElementById('nascimento_dia').focus();
		alert('O campo Dia de Nascimento é obrigatório!');
		return;
	}
	
	if(document.getElementById('nascimento_dia').value.length != 2){
		document.getElementById('nascimento_dia').focus();
		alert('O campo Dia de Nascimento deve conter 2 dígitos!');
		return;
	}
	
	if(document.getElementById('nascimento_mes').value == ''  || document.getElementById('nascimento_mes').value == null){
		document.getElementById('nascimento_mes').focus();
		alert('O campo Mês de Nascimento é obrigatório!');
	return;
	}

	if(document.getElementById('nascimento_mes').value.length != 2){
		document.getElementById('nascimento_mes').focus();
		alert('O campo Mês de Nascimento deve conter 2 dígitos!');
		return;
	}
	
	if(document.getElementById('nascimento_ano').value == ''  || document.getElementById('nascimento_ano').value == null){
		document.getElementById('nascimento_ano').focus();
		alert('O campo Ano de Nascimento é obrigatório!');
		return;
	}

	if(document.getElementById('nascimento_ano').value.length != 4){
		document.getElementById('nascimento_ano').focus();
		alert('O campo Ano de Nascimento deve conter 4 dígitos!');
		return;
	}

	if(document.getElementById('profissao').value == '' || document.getElementById('profissao').value == null){
		document.getElementById('profissao').focus();
		alert('O campo Profissão é obrigatório!');
		return;
	}
	
	if(document.getElementById('nacionalidade').value == '' || document.getElementById('nacionalidade').value == null){
		document.getElementById('nacionalidade').focus();
		alert('O campo Nacionalidade é obrigatório!');
		return;
	}
	
	if(document.getElementById('renda').value == '' || document.getElementById('renda').value == null){
		document.getElementById('renda').focus();
		alert('O campo Renda Familiar é obrigatório!');
		return;
	}
	
	if(document.getElementById('mae').value == '' || document.getElementById('mae').value == null){
		document.getElementById('mae').focus();
		alert('O campo Nome da Mãe é obrigatório!');
		return;
	}
	
	if(document.getElementById('rg_numero').value == '' || document.getElementById('rg_numero').value == null){
		document.getElementById('rg_numero').focus();
		alert('O campo RG(Número) é obrigatório!');
		return;
	}
	
	if(document.getElementById('rg_emissor').value == '' || document.getElementById('rg_emissor').value == null){
		document.getElementById('rg_emissor').focus();
		alert('O campo RG(Órgão Emissor) é obrigatório!');
		return;
	}
	
	if(document.getElementById('rg_emissao_dia').value == '' || document.getElementById('rg_emissao_dia').value == null){
		document.getElementById('rg_emissao_dia').focus();
		alert('O campo RG(Data de Emissão) é obrigatório!');
		return;
	}

	if(document.getElementById('rg_emissao_dia').value.length != 2){
		document.getElementById('rg_emissao_dia').focus();
		alert('O campo RG (Data de Emissão) deve conter 2 dígitos!');
		return;
	}
	
	if(document.getElementById('rg_emissao_dia').value > 31){
		document.getElementById('rg_emissao_dia').focus();
		alert('O campo RG (Data de Emissão) não pode conter valores acima de 31!');
		return;
	}	

	if(document.getElementById('rg_emissao_mes').value == '' || document.getElementById('rg_emissao_mes').value == null){
		document.getElementById('rg_emissao_mes').focus();
		alert('O campo RG(Data de Emissão) é obrigatório!');
		document.getElementById('rg_emissao_mes').focus();
		return;
	}

	if(document.getElementById('rg_emissao_mes').value.length != 2){
		document.getElementById('rg_emissao_mes').focus();
		alert('O campo RG (Data de Emissão) deve conter 2 dígitos!');
		return;
	}
	
	if(document.getElementById('rg_emissao_mes').value.length != 2){
		document.getElementById('rg_emissao_mes').focus();
		alert('O campo RG (emissão) deve conter 2 dígitos!');
		return;
	}	

	if(document.getElementById('rg_emissao_ano').value == '' || document.getElementById('rg_emissao_ano').value == null){
		document.getElementById('rg_emissao_ano').focus();
		alert('O campo RG(Data de Emissão) é obrigatório!');
		return;
	}

	if(document.getElementById('rg_emissao_ano').value.length != 4){
		document.getElementById('rg_emissao_ano').focus();
		alert('O campo RG (Data de Emissão) deve conter 4 dígitos!');
		return;
	}
	
	if(document.getElementById('logradouro').value == '' || document.getElementById('logradouro').value == null){
		document.getElementById('logradouro').focus();
		alert('O campo Logradouro é obrigatório!');
		return;
	}
	
	if(document.getElementById('numero').value == '' || document.getElementById('numero').value == null){
		document.getElementById('numero').focus();
		alert('O campo Número é obrigatório!');
		return;
	}
	
	if(document.getElementById('bairro').value == '' || document.getElementById('bairro').value == null){
		document.getElementById('bairro').focus();
		alert('O campo Bairro é obrigatório!');
		return;
	}
	
	if(document.getElementById('cidade').value == '' || document.getElementById('cidade').value == null){
		document.getElementById('cidade').focus();
		alert('O campo Cidade é obrigatório!');
		return;
	}
	
	if(document.getElementById('cep').value == ''  || document.getElementById('cep').value == null){
		document.getElementById('cep').focus();
		alert('O campo CEP é obrigatório!');
		return;
	}
	
	if(document.getElementById('cep').value.length != 8){
		document.getElementById('cep').focus();
		alert('O campo CEP deve conter 8 dígitos!');
		return;
	}	
	
	if(document.getElementById('estado').value == '' || document.getElementById('estado').value == null){
		document.getElementById('estado').focus();
		alert('O campo Estado é obrigatório!');
		return;
	}
	
	if(document.getElementById('pais').value == '' || document.getElementById('pais').value == null){
		document.getElementById('pais').focus();
		alert('O campo País é obrigatório!');
		return;
	}
	if(document.getElementById('email').value == '' ||
		document.getElementById('email').value == null  ||
		document.getElementById('email').value == 'undefined'){
		
		document.getElementById('email').focus();
		alert('O campo E-Mail é obrigatório!');
		return;
	}
	
	if( document.getElementById('email').value.indexOf('@') == -1){
		
		document.getElementById('email').focus();
		alert('Informe um e-mail válido!');
		return;
	}	
	
	if(document.getElementById('telefone').value == '' || document.getElementById('telefone').value == null){
		document.getElementById('telefone').focus();
		alert('O campo Telefone é obrigatório!');
		return;
	}
	
	if(document.getElementById('midia').value == '' || document.getElementById('midia').value == null){
		document.getElementById('midia').focus();
		alert('O campo, Como soube do Vestibular?, é obrigatório!');
		return;
	}
	
	var pai = document.getElementById('pai').value;
	var complemento = document.getElementById('complemento').value;
	var rg_validade_dia = document.getElementById('rg_validade_dia').value;
	var rg_validade_mes = document.getElementById('rg_validade_mes').value;	
	var rg_validade_ano = document.getElementById('rg_validade_ano').value;
	var curso_opcao_2 = document.getElementById('curso_opcao_2').value;
	var curso_opcao_3 = document.getElementById('curso_opcao_3').value;
	
	if(rg_validade_dia){
		
		if(document.getElementById('rg_validade_dia').value.length != 2){
			document.getElementById('rg_validade_dia').focus();
			alert('O campo RG (validade) deve conter 2 dígitos!');
			return;
		}
		
		if(document.getElementById('rg_validade_dia').value > 31){
			document.getElementById('rg_validade_dia').focus();
			alert('O campo RG (validade) não pode ter valor acima de 31!');
			return;
		}
		
		if(document.getElementById('rg_validade_mes').value.length != 2){
			document.getElementById('rg_validade_mes').focus();
			alert('O campo RG (validade) deve conter 2 dígitos!');
			return;
		}
		
		if(document.getElementById('rg_validade_mes').value > 12){
			document.getElementById('rg_validade_mes').focus();
			alert('O campo RG (validade) não pode conter valor acima de 12!');
			return;
		}
		
		if(document.getElementById('rg_validade_ano').value.length != 4){
			document.getElementById('rg_validade_ano').focus();
			alert('O campo RG (validade) deve conter 4 dígitos!');
			return;
		}
		
	}
					
	var Ajax = new AbrirAjax();
	Ajax.open('post', '/', true);
	Ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	Ajax.setRequestHeader('encoding','UTF-8');
	Ajax.onreadystatechange = function () {
		
		if (Ajax.readyState == 1){
			
			AbrirVidro();
		}
		
		if (Ajax.readyState == 4){
			
			if(Ajax.responseText == public_erro){
				alert("Houve um erro na requisição. Inscrição não realizada. Contacte o suporte.");
				FecharVidro();
				return;
			}
			
			if(Ajax.responseText == public_ja_consta){
				alert("Inscrição deste CPF já realizada.");
				FecharVidro();
				return;
			}
			
			FecharVidro();
			document.getElementById('body').innerHTML = Ajax.responseText;
			return;
		}
	}
	
	var info =  "acao=save" +
				"&controller=controllerVestibular.php" +
				"&target=vestibular" +
				"&dado=inscricao" +
				"&curso_1=" + document.getElementById('curso_opcao_1').value +
				"&lingua=" + document.getElementById('lingua').value +
				"&prenome=" + document.getElementById('prenome').value +
				"&sobrenome=" + document.getElementById('sobrenome').value +
				"&sexo=" + document.getElementById('sexo').value +
				"&estado_civil=" + document.getElementById('estado_civil').value +
				"&cpf=" + document.getElementById('cpf').value +
				"&naturalidade=" + document.getElementById('naturalidade').value +
				"&nascimento_dia=" + document.getElementById('nascimento_dia').value +
				"&nascimento_mes=" + document.getElementById('nascimento_mes').value +
				"&nascimento_ano=" + document.getElementById('nascimento_ano').value +
				"&profissao=" + document.getElementById('profissao').value +
				"&mae=" + document.getElementById('mae').value +
				"&rg_numero=" + document.getElementById('rg_numero').value +
				"&rg_emissor=" + document.getElementById('rg_emissor').value +
				"&rg_emissao_dia=" + document.getElementById('rg_emissao_dia').value +
				"&rg_emissao_mes=" + document.getElementById('rg_emissao_mes').value +
				"&rg_emissao_ano=" + document.getElementById('rg_emissao_ano').value +
				"&logradouro=" + document.getElementById('logradouro').value +
				"&numero=" + document.getElementById('numero').value +
				"&bairro=" + document.getElementById('bairro').value +
				"&cidade=" + document.getElementById('cidade').value +
				"&cep=" + document.getElementById('cep').value +
				"&estado=" + document.getElementById('estado').value +
				"&pais=" + document.getElementById('pais').value +
				"&renda=" + document.getElementById('renda').value +
				"&nacionalidade=" + document.getElementById('nacionalidade').value +
				"&email=" + document.getElementById('email').value +
				"&telefone=" + document.getElementById('telefone').value +
				"&midia=" + document.getElementById('midia').value;

	if(pai) info +="&pai=" + pai;
	if(complemento) info +="&complemento=" + complemento;
	if(rg_validade_dia) info +="&rg_validade_dia=" + rg_validade_dia;
	if(rg_validade_mes) info +="&rg_validade_mes=" + rg_validade_mes;
	if(rg_validade_ano) info +="&rg_validade_ano=" + rg_validade_ano;
	if(curso_opcao_2) info +="&curso_2=" + curso_opcao_2;
	if(curso_opcao_3) info +="&curso_3=" + curso_opcao_3;
	
	Ajax.send(info);
}

function formata_int(elemento){
	
	string = elemento.value
	tamanho = string.length;
	novaString = "";
	
	for (count = 0; count<tamanho; count++){
		
		if ((string.substring(count, count+1) == '0') ||
		   (string.substring(count, count+1) == '1') ||
		   (string.substring(count, count+1) == '2') ||
		   (string.substring(count, count+1) == '3') ||
		   (string.substring(count, count+1) == '4') ||
		   (string.substring(count, count+1) == '5') ||
		   (string.substring(count, count+1) == '6') ||
		   (string.substring(count, count+1) == '7') ||
		   (string.substring(count, count+1) == '8') ||
		   (string.substring(count, count+1) == '9')){
			
			novaString += string.substring(count, count+1);
		}
	}
	
	elemento.value = novaString;
}

function requestComprovanteInscrição(){

	// CPF //////////////////////////////
	
	if(document.getElementById('cpf').value == ''){
		document.getElementById('cpf').focus();
		alert('O campo CPF é obrigatório');
		return;
	}
	
	if(document.getElementById('cpf').value.length != 11){
		document.getElementById('cpf').focus();
		alert('O campo CPF deve conter 11 dígitos');
		return;
	}

	// DIA //////////////////////////////
	
	if(document.getElementById('nascimento_dia').value == ''){
		document.getElementById('nascimento_dia').focus();
		alert('O campo DIA é obrigatório');
		return;
	}

	if(document.getElementById('nascimento_dia').value.length != 2){
		document.getElementById('nascimento_dia').focus();
		alert('O campo DIA deve conter 2 dígitos!');
		return;
	}
	
	if(document.getElementById('nascimento_dia').value > 31){
		document.getElementById('nascimento_dia').focus();
		alert('O campo DIA não pode conter valores acima de 31!');
		return;
	}	

	// MÊS //////////////////////////////

	if(document.getElementById('nascimento_mes').value == ''){
		document.getElementById('nascimento_mes').focus();
		alert('O campo MÊS é obrigatório!');
		return;
	}

	if(document.getElementById('nascimento_mes').value > 12){
		document.getElementById('nascimento_mes').focus();
		alert('O campo MÊS não suporta valores acima de 12!');
		return;
	}
	
	if(document.getElementById('nascimento_mes').value.length != 2){
		document.getElementById('nascimento_mes').focus();
		alert('O campo MÊS deve conter 2 dígitos!');
		return;
	}	

	// ANO //////////////////////////////

	if(document.getElementById('nascimento_ano').value.length != 4){
		document.getElementById('nascimento_ano').focus();
		alert('O campo ANO deve conter 4 dígitos!');
		return;
	}

	if(document.getElementById('nascimento_ano').value == ''){
		document.getElementById('nascimento_ano').focus();
		alert('O campo ANO é obrigatório');
		return;
	}
	
	//////////////////////////////////////////
	
	var cpf = document.getElementById('cpf').value;
	var nascimento_dia = document.getElementById('nascimento_dia').value;
	var nascimento_mes = document.getElementById('nascimento_mes').value;
	var nascimento_ano = document.getElementById('nascimento_ano').value;
	
	var nascimento = nascimento_ano + nascimento_mes + nascimento_dia;
	
	var Ajax = new AbrirAjax();
	Ajax.open('post', '/', true);
	Ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	Ajax.setRequestHeader('encoding','UTF-8');
	Ajax.onreadystatechange = function () {
		
		if (Ajax.readyState == 1){
			
			AbrirVidro();
		}
		
		if (Ajax.readyState == 4){
			
			if(Ajax.responseText == public_erro){
				alert("Houve um erro na requisição. Inscrição não realizada. Contacte o suporte.");
				FecharVidro();
				return;
			}
			
			if(Ajax.responseText == vazio){
				alert("Nenhuma inscição encontrada");
				FecharVidro();
				return;
			}
			
			if(Ajax.responseText == '#_inconsistente'){
				alert("Dados inconsistentes. Favor contactar o suporte.");
				FecharVidro();
				return;
			}
			
			FecharVidro();
			document.getElementById('body').innerHTML = Ajax.responseText;
			return;
		}
	}
	
	var info =  "acao=load" +
				"&controller=controllerVestibular.php" +
				"&target=vestibular" +
				"&dado=comprovante" +
				"&cpf=" + cpf +
				"&nascimento=" + nascimento;
				
	Ajax.send(info);
}

function vest_acesso_restrito(){
	
	if(document.getElementById('login').value == ''){
		document.getElementById('login').focus();
		alert('Informe seu login');
		return;
	}

	if(document.getElementById('pass').value == ''){
		document.getElementById('pass').focus();
		alert('Informe sua senha');
		return;
	}	 
	
	var Ajax = new AbrirAjax();
	Ajax.open('post', '/', true);
	Ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	Ajax.setRequestHeader('encoding','UTF-8');
	Ajax.onreadystatechange = function () {
		
		if (Ajax.readyState == 1){
			
			AbrirVidro();
		}
		
		if (Ajax.readyState == 4){
			
			if(Ajax.responseText == public_erro){
				FecharVidro();
				alert("Houve um erro na requisição. Contacte o suporte.");
				return;
			}
			
			if(Ajax.responseText == public_nao_consta){
				FecharVidro();
				alert("Dados não conferem. Cetifique-se que digitou corretamente.");
				return;
			}

			FecharVidro();
			
			window.location = "";
			return;
		}
	}
	
	var info =  "controller=controllerVestibular.php" +
				"&acao=login" +
				"&login=" + document.getElementById('login').value +
				"&pass=" + document.getElementById('pass').value;
				
	Ajax.send(info);	
}

function sair(){
	
	var Ajax = new AbrirAjax();
	Ajax.open('post', '#', true);
	Ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	Ajax.setRequestHeader('encoding','UTF-8');
	Ajax.onreadystatechange = function () {
		
		if (Ajax.readyState == 4){
						
			if(Ajax.responseText == public_erro){
				alert("Houve um erro na requisição. Mensagem não enviada. Contacte o suporte.");
				FecharVidro();
				return;
			}
			
			window.location=window.location;
			return;
		}
	}
	
	var info =  "acao=logout";
	
	Ajax.send(info);	
	
}

function send_mail(){

	if(document.getElementById('inscricao_id').innerHTML == ''){
		alert('Um erro ocorreu! Contacte o TI!');
		return;
	}
	
	var inscricao_id = document.getElementById('inscricao_id').innerHTML;
	
	var Ajax = new AbrirAjax();
	Ajax.open('post', '#', true);
	Ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	Ajax.setRequestHeader('encoding','UTF-8');
	Ajax.onreadystatechange = function () {
		
		if (Ajax.readyState == 1){
			
			AbrirVidro();
			
		}
		
		if (Ajax.readyState == 4){
		
			if(Ajax.responseText == 0){
				FecharVidro();
				alert("Houve um erro na requisição. Email não enviado. Contacte o suporte.");
				return;
			}
			
			FecharVidro();
			alert('Email enviado com sucesso!');
			return;
		}
	
	}
	
	var info =  "acao=sendmail" +
				"&controller=controllerVestibular.php" +
				"&target=comprovante" +
				"&comprovante_id="+ inscricao_id;
	
	Ajax.send(info);
}

//////////////////////////////////////////////////
/////////////  TRABALHE CONOSCO  /////////////////
//////////////////////////////////////////////////

function save_curriculo(){
	
	
	if(document.getElementById('nome').value == '' || document.getElementById('nome').value == null){
		document.getElementById('nome').focus();
		alert('O campo Nome Completo é obrigatório!');
		return;
	}


	if(document.getElementById('nascimento_dia').value == '' || document.getElementById('nascimento_dia').value == null){
		document.getElementById('nascimento_dia').focus();
		alert('O campo Dia de Nascimento é obrigatório!');
		return;
	}
	
	if(document.getElementById('nascimento_dia').value.length != 2){
		document.getElementById('nascimento_dia').focus();
		alert('O campo Dia de Nascimento deve conter 2 dígitos!');
		return;
	}
	
	if(document.getElementById('nascimento_mes').value == ''  || document.getElementById('nascimento_mes').value == null){
		document.getElementById('nascimento_mes').focus();
		alert('O campo Mês de Nascimento é obrigatório!');
		return;
	}

	if(document.getElementById('nascimento_mes').value.length != 2){
		document.getElementById('nascimento_mes').focus();
		alert('O campo Mês de Nascimento deve conter 2 dígitos!');
		return;
	}
	
	if(document.getElementById('nascimento_ano').value == ''  || document.getElementById('nascimento_ano').value == null){
		document.getElementById('nascimento_ano').focus();
		alert('O campo Ano de Nascimento é obrigatório!');
		return;
	}

	if(document.getElementById('nascimento_ano').value.length != 4){
		document.getElementById('nascimento_ano').focus();
		alert('O campo Ano de Nascimento deve conter 4 dígitos!');
		return;
	}
	
	if(document.getElementById('nacionalidade').value == '' || document.getElementById('nacionalidade').value == null){
		document.getElementById('nacionalidade').focus();
		alert('O campo Nacionalidade é obrigatório!');
		return;
	}

	if(document.getElementById('filhos').value == '' || document.getElementById('filhos').value == null){
		document.getElementById('filhos').focus();
		alert('Por favor selecione quantos filhos possui!');
		return;
	}

	if(document.getElementById('endereco').value == '' || document.getElementById('endereco').value == null){
		document.getElementById('endereco').focus();
		alert('O campo Endereço é obrigatório!');
		return;
	}

	if(document.getElementById('numero').value == '' || document.getElementById('numero').value == null){
		document.getElementById('numero').focus();
		alert('O campo Número é obrigatório!');
		return;
	}

	if(document.getElementById('bairro').value == '' || document.getElementById('bairro').value == null){
		document.getElementById('bairro').focus();
		alert('O campo Bairro é obrigatório!');
		return;
	}

	if(document.getElementById('cep').value == '' || document.getElementById('cep').value == null){
		document.getElementById('cep').focus();
		alert('O campo CEP é obrigatório!');
		return;
	}

	if(document.getElementById('cidade').value == '' || document.getElementById('cidade').value == null){
		document.getElementById('cidade').focus();
		alert('O campo Cidade é obrigatório!');
		return;
	}

	if(document.getElementById('estado').value == '' || document.getElementById('estado').value == null){
		document.getElementById('estado').focus();
		alert('O campo Estado é obrigatório!');
		return;
	}

	if(document.getElementById('pais').value == '' || document.getElementById('pais').value == null){
		document.getElementById('pais').focus();
		alert('O campo País é obrigatório!');
		return;
	}

	if(document.getElementById('email').value == '' || document.getElementById('email').value == null){
		document.getElementById('email').focus();
		alert('O campo E-mail é obrigatório!');
		return;
	}

	if(document.getElementById('telefone').value == '' || document.getElementById('telefone').value == null){
		document.getElementById('telefone').focus();
		alert('O campo Telefone é obrigatório!');
		return;
	}

	if(document.getElementById('cargo').value == '' || document.getElementById('cargo').value == null){
		document.getElementById('cargo').focus();
		alert('O campo Cargo Pretendido é obrigatório!');
		return;
	}

	if(document.getElementById('salario').value == '' || document.getElementById('salario').value == null){
		document.getElementById('salario').focus();
		alert('O campo Pretensão Salarial é obrigatório!');
		return;
	}

	if(document.getElementById('perfil').value == '' || document.getElementById('perfil').value == null){
		document.getElementById('perfil').focus();
		alert('O campo Perfil Profissional é obrigatório!');
		return;
	}

	if(document.getElementById('escolaridade').value == '' || document.getElementById('escolaridade').value == null){
		document.getElementById('escolaridade').focus();
		alert('O campo Escolaridade é obrigatório!');
		return;
	}

	if(document.getElementById('esc_situacao').value == '' || document.getElementById('esc_situacao').value == null){
		document.getElementById('esc_situacao').focus();
		alert('O campo Situação é obrigatório!');
		return;
	}

	if(document.getElementById('idiomas').value == '' || document.getElementById('idiomas').value == null){
		document.getElementById('idiomas').focus();
		alert('O campo Idiomas é obrigatório!');
		return;
	}


}
/*



	var Ajax = new AbrirAjax();
	Ajax.open('post', '/', true);
	Ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	Ajax.setRequestHeader('encoding','UTF-8');
	Ajax.onreadystatechange = function () {
		
		if (Ajax.readyState == 1){
			
			AbrirVidro();
		}
		
		if (Ajax.readyState == 4){
			
			if(Ajax.responseText == public_erro){
				alert("Houve um erro na requisição. Curriculo não cadastrado. Contacte o suporte.");
				FecharVidro();
				return;
			}
			
			alert("Curriculo cadastrado com sucesso!");
			FecharVidro();
			loadconteudo('../../home/conteudoHome.php, false');
			return;
		}
	}
	
	var info =  "acao=save" +
				"&controller=controllerTrabalheConosco.php" +
				"&target=curriculo" +
				"&dado=cadastramento" +
				"&nome=" + document.getElementById('nome').value +
				"&nascimento_dia=" + document.getElementById('nascimento_dia').value +
				"&nascimento_mes=" + document.getElementById('nascimento_mes').value +
				"&nascimento_ano=" + document.getElementById('nascimento_ano').value +
				"&nacionalidade=" + document.getElementById('nacionalidade').value +
				"&estado_civil=" + document.getElementById('estado_civil').value +
				"&sexo=" + document.getElementById('sexo').value +
				"&filhos=" + document.getElementById('filhos').value +
				"&empregado=" + document.getElementById('empregado').value +
				"&endereco=" + document.getElementById('endereco').value +
				"&numero=" + document.getElementById('numero').value +
				"&bairro=" + document.getElementById('bairro').value +
				"&cep=" + document.getElementById('cep').value +
				"&cidade=" + document.getElementById('cidade').value +
				"&estado=" + document.getElementById('estado').value +
				"&pais=" + document.getElementById('pais').value +
				"&email=" + document.getElementById('email').value +
				"&telefone=" + document.getElementById('telefone').value +
				"&cargo=" + document.getElementById('cargo').value +
				"&salario=" + document.getElementById('salario').value +
				"&perfil=" + document.getElementById('perfil').value +
				"&escolaridade=" + document.getElementById('escolaridade').value +
				"&esc_situacao=" + document.getElementById('esc_situacao').value +
				"&idiomas=" + document.getElementById('idiomas').value +



	if(complemento) info +="&complemento=" + document.getElementById('complemento').value;
	if(empresa_1) info +="&empresa_1=" + document.getElementById('empresa_1').value;
	if(segmento_1) info +="&segmento_1=" + document.getElementById('segmento_1').value;
	if(cargo_1) info +="&cargo_1=" + document.getElementById('cargo_1').value;
	if(descricao_1) info +="&descricao_1=" + document.getElementById('descricao_1').value;
	if(porte_1) info +="&porte_1=" + document.getElementById('porte_1').value;
	if(desligamento_1) info +="&desligamento_1=" + document.getElementById('desligamento_1').value;
	if(dia_inicio_1) info +="&dia_inicio_1=" + document.getElementById('dia_inicio_1').value;
	if(mes_inicio_1) info +="&mes_inicio_1=" + document.getElementById('mes_inicio_1').value;
	if(ano_inicio_1) info +="&ano_inicio_1=" + document.getElementById('ano_inicio_1').value;
	if(dia_termino_1) info +="&dia_termino_1=" + document.getElementById('dia_termino_1').value;
	if(mes_termino_1) info +="&mes_termino_1=" + document.getElementById('mes_termino_1').value;
	if(ano_termino_1) info +="&ano_termino_1=" + document.getElementById('ano_termino_1').value;

	if(empresa_2) info +="&empresa_2=" + document.getElementById('empresa_2').value;
	if(segmento_2) info +="&segmento_2=" + document.getElementById('segmento_2').value;
	if(cargo_2) info +="&cargo_2=" + document.getElementById('cargo_2').value;
	if(descricao_2) info +="&descricao_2=" + document.getElementById('descricao_2').value;
	if(porte_2) info +="&porte_2=" + document.getElementById('porte_2').value;
	if(desligamento_2) info +="&desligamento_2=" + document.getElementById('desligamento_2').value;
	if(dia_inicio_2) info +="&dia_inicio_2=" + document.getElementById('dia_inicio_2').value;
	if(mes_inicio_2) info +="&mes_inicio_2=" + document.getElementById('mes_inicio_2').value;
	if(ano_inicio_2) info +="&ano_inicio_2=" + document.getElementById('ano_inicio_2').value;
	if(dia_termino_2) info +="&dia_termino_2=" + document.getElementById('dia_termino_2').value;
	if(mes_termino_2) info +="&mes_termino_2=" + document.getElementById('mes_termino_2').value;
	if(ano_termino_2) info +="&ano_termino_2=" + document.getElementById('ano_termino_2').value;

	if(empresa_3) info +="&empresa_3=" + document.getElementById('empresa_3').value;
	if(segmento_3) info +="&segmento_3=" + document.getElementById('segmento_3').value;
	if(cargo_3) info +="&cargo_3=" + document.getElementById('cargo_3').value;
	if(descricao_3) info +="&descricao_3=" + document.getElementById('descricao_3').value;
	if(porte_3) info +="&porte_3=" + document.getElementById('porte_3').value;
	if(desligamento_3) info +="&desligamento_3=" + document.getElementById('desligamento_3').value;
	if(dia_inicio_3) info +="&dia_inicio_3=" + document.getElementById('dia_inicio_3').value;
	if(mes_inicio_3) info +="&mes_inicio_3=" + document.getElementById('mes_inicio_3').value;
	if(ano_inicio_3) info +="&ano_inicio_3=" + document.getElementById('ano_inicio_3').value;
	if(dia_termino_3) info +="&dia_termino_3=" + document.getElementById('dia_termino_3').value;
	if(mes_termino_3) info +="&mes_termino_3=" + document.getElementById('mes_termino_3').value;
	if(ano_termino_3) info +="&ano_termino_3=" + document.getElementById('ano_termino_3').value;
	
	Ajax.send(info);

}

*/
