/*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Função: getObjectAjax
 Parâmetros: 
 Descrição: 
 Retorna:  
 Desenvolvedor: Andrea
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
	function getObjectAjax(){
		var xmlObj;

		if (window.ActiveXObject){ // Código para o IE
			xmlObj = xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		else if (window.XMLHttpRequest){ // Código para o FF
			xmlObj = new XMLHttpRequest();
		}

		return xmlObj;
	}
	
/*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Função: prosseguirInscricao, fncAbrirDiv e fncFecharDiv
 Parâmetros: 
 Descrição: Abrir ou Fechar POP quando ex-aluno logado
 Retorna:  
 Desenvolvedor: Andre
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
function fncFecharDiv(){
	document.getElementById('janela').style.display = 'none';
}
function fncAbrirDiv(){
		var tipo = document.getElementById('vlrTipExAluno').value, pag;
		var matricula = document.getElementById('vlrMatExAluno').value;
		if (tipo == 1) {
			pag = "ex_brasil.asp?alet="+Aleatorio();
		} else if (tipo == 2) {
			pag = "ex_japao.asp?alet="+Aleatorio();
		} else {
			pag = "ex_angola.asp?alet="+Aleatorio();
		}

	ajaxPadrao(pag,"popup");
	ajaxPadrao("inscricao_exaluno.asp?nmLogin="+matricula+"","conteudo");
	document.getElementById('janela').style.display = '';
}

function prosseguirInscricao() {
	fncFecharDiv();
}

/*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Função: Aleatorio
 Parâmetros: 
 Descrição: Gera Número Randômico
 Retorna:  
 Desenvolvedor: Andre
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
function Aleatorio(){ // Função para carregar toda vez que for jamado um ajax (para IE)
	aleat = Math.random() * 5000;
	aleat = Math.round(aleat);
	return aleat;
}

/*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Função: retirarAcento
 Parâmetros: 
 Descrição: Retira Acentos
 Retorna: valor sem acentos
 Desenvolvedor: Andre
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
function retirarAcento(valor) {  
	var varString = new String(valor);  
	var stringAcentos = new String('àâêôûãõáéíóúçüÀÂÊÔÛÃÕÁÉÍÓÚÇÜ');  
	var stringSemAcento = new String('aaeouaoaeioucuAAEOUAOAEIOUCU');  
  
	var i = new Number();  
	var j = new Number();  
	var cString = new String();  
	var varRes = '';  
  
	for (i = 0; i < varString.length; i++) {  
		cString = varString.substring(i, i + 1);  
		for (j = 0; j < stringAcentos.length; j++) {  
			if (stringAcentos.substring(j, j + 1) == cString){  
				cString = stringSemAcento.substring(j, j + 1);  
			}  
		}  
		varRes += cString;  
	}  

	return varRes;  
}

/*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Função: ajaxPadrao
 Parâmetros: 
 Descrição: Principal função de Ajax do MBA
 Retorna: valor sem acentos
 Desenvolvedor: Andre
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

function ajaxPadrao(url,local) {

	var variacao = url.split(".");

	if(url != '') {
		var XMLHTTP = getObjectAjax();

		XMLHTTP.onreadystatechange=function()	{
			if(XMLHTTP.readyState==4)  {
				document.getElementById(""+local+"").innerHTML = XMLHTTP.responseText;

				if(document.getElementById("vlrTipExAluno") && local != "popup") {
					fncAbrirDiv();
				}

				if(variacao[0] == "valida_login" || variacao[0] == "logado") {
					document.getElementById("centro").className = 'centroAlternativo';
				} else {
					document.getElementById("centro").className = 'centro';
				}

				if(document.getElementById("txa")) {
					preencheCampos();
				}

				alteraTitulo(); // Altera título da página

			} else {

				document.getElementById(""+local+"").innerHTML = "<strong>Carregando...</strong>";

			}
		}

		XMLHTTP.open("GET",url,true);
		XMLHTTP.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
        XMLHTTP.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
        XMLHTTP.setRequestHeader("Pragma", "no-cache");
		XMLHTTP.send(null);
	}
}

/*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Função: ajaxValida
 Parâmetros: Tipo a ser validado 
		//1 = Verifica Nome
		//2 = Verifica CPF
		//3 = Verifica Passaporte
 Descrição: Função para verificar se o usuário já está cadastrado no MBA
 Retorna: Alert de erro quando é encontrado
 Desenvolvedor: Andre
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

function ajaxValida(tipo) {
		var XMLHTTP = getObjectAjax();
		var dado, local, url;

		//1 = Verifica Nome
		//2 = Verifica CPF
		//3 = Verifica Passaporte
		if(tipo == 1) {
			dado = document.getElementById("cpf_numero").value;
			dado=dado.replace(".","");
			dado=dado.replace(".","");
			dado=dado.replace("-","");
			local = document.getElementById("cpfAjaxVerifCad").innerHTML;
		} else if (tipo == 2) {
			dado = document.getElementById("txidpassAA").value;
			local = document.getElementById("passAjaxVerifCad").innerHTML;
		} else {
			dado = document.getElementById("nome").value;
			local = document.getElementById("nomeAjaxVerifCad").innerHTML;
			dado = retirarAcento(dado);
		}

		if(tipo == 1) {
			if (validaCPF(dado) == false) {
				alert("CPF inválido. Digite um CPF Válido");
				document.getElementById("cpf_numero").focus();
				return false;
			}
		}

		url = "valida_dados.asp?tipo="+tipo+"&var="+dado;
		//alert(""+tipo+"\n\n"+dado+"");

		XMLHTTP.onreadystatechange=function()	{
			if(XMLHTTP.readyState==4)  {
				//alert(XMLHTTP.responseText);
				if(XMLHTTP.responseText == '1') {
					alert('Você já possui um cadastro no MBA ou já está matriculado.\nEm caso de dúvidas, entre em contato pelo atendimento@aiec.br.');
					desabilitaBotao('1');
				} else {
					desabilitaBotao('0');
				}
				local = "*";
			} else {
				local = "--";
			}
		}

		XMLHTTP.open("GET",url,true);
		XMLHTTP.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
        XMLHTTP.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
        XMLHTTP.setRequestHeader("Pragma", "no-cache");
		XMLHTTP.send(null);
}

/*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Função: desabilitaBotao
 Parâmetros: Desabilita ou Habiilitar
 Descrição: Habilita ou desabilita o botão de enviar
 Retorna:
 Desenvolvedor: Andre
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
function desabilitaBotao(t) {
	if (t == 1) {
		document.getElementById("botaDeEnviar").innerHTML = '<img src="imagens/bt_enviar.png" class="clButton" />';
	} else {
		document.getElementById("botaDeEnviar").innerHTML = '<img src="imagens/bt_enviar.png" class="clButton" onClick="insCasos();" />';
	}
}

/*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Função: validaCampo
 Parâmetros: String
 Descrição: Retira Caracteres inválidos
 Retorna: Caracteres válidos
 Desenvolvedor: Andre
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
function validaCampo(str){
	var texto = new String(str);
	texto = texto.replace(/&nbsp;\s*|\s*$/g,"");
	texto = texto.replace("'", ""); 
    return texto;
}
/*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Função: ApenasNumeros
 Parâmetros: Valor
 Descrição: Retira tudo qu enão for número
 Retorna: Numeros
 Desenvolvedor: Andre
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
function ApenasNumeros(pVal) {
	var reTipo = /^\d+$/;
	return reTipo.test(pVal);
}

/*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Função: 
 Parâmetros: 
 Descrição: 
 Retorna: 
 Desenvolvedor: 
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

function doDigits(pStr){
	var reDigits = /^\d+$/;
	if (reDigits.test(pStr)) {
		alert(pStr + " contém apenas dígitos.");
	} else if (pStr != null && pStr != "") {
		alert(pStr + " NÃO contém apenas dígitos.");
	}
}


/*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Função: execmascara, execFuncao
 Parâmetros: 
 Descrição: validação através de expressões regulares;
 Retorna: os caracteres permitidos
 Desenvolvedor: Andre
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

function execFuncao(o,f){
    v_obj=o
    v_fun=f
    setTimeout("execmascara()",1)
}

function execmascara(){
    v_obj.value=v_fun(v_obj.value)
}

/*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Função: 
 Parâmetros:
 Descrição: Funções utilizados com a funão execmascara
 Retorna: 
 Desenvolvedor: Andre
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

function soEmail(v){
    return v.replace(/[^a-z0-9-_.@]/g,"");
}

function cpf(v){
    v=v.replace(/\D/g,"")
    v=v.replace(/(\d{3})(\d)/,"$1.$2")
    v=v.replace(/(\d{3})(\d)/,"$1.$2")
    v=v.replace(/(\d{3})(\d{1,2})$/,"$1-$2")
    return v
}

function soNumeros(v){
    return v.replace(/\D/g,"")
}

function telefone(v){
    v=v.replace(/\D/g,"")
    v=v.replace(/^(\d{4})(\d)/g,"$1-$2")
    return v
}

function cep(v){
    v=v.replace(/D/g,"")
    v=v.replace(/^(\d{5})(\d)/,"$1-$2")
    return v
}

/*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Função: insCasos
 Parâmetros:
 Descrição: Funções de validação do formulário
 Retorna: 
 Desenvolvedor: Andre
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

function insCasos(){

	var form = document.getElementById('form');
			
	var nome = form.txNome;
	var email = form.txemail;
	var centro = form.centro;
	var endereco = form.txendereco;
	var bairro = form.txbairro;
	var cidade = form.txcidade;
	var estado = form.slcEstado;
	var txemail_conf = form.txemail_conf;
	var outros = form.ufOutros;
	var sexo = form.slcSexo;
	var como_soube = form.como_soube;
	var txa_questao_outros = form.txa_questao_outros;
	var cep = form.txcep;
	var convite = form.convite;

	nome.value = validaCampo(nome.value);
	email.value = validaCampo(form.txemail.value);
	txemail_conf.value = validaCampo(form.txemail_conf.value);
	centro.value = validaCampo(form.centro.value);
	endereco.value = validaCampo(form.txendereco.value);
	bairro.value = validaCampo(form.txbairro.value);
	cidade.value = validaCampo(form.txcidade.value);
	estado.value = validaCampo(form.slcEstado.value);
	como_soube.value = validaCampo(form.como_soube.value);
	txa_questao_outros.value = validaCampo(form.txa_questao_outros.value);

	if (document.getElementById("tipoInscVal").value == "") {
		if (document.getElementById("txn").value == 3) {
			if(document.getElementById("txidpassAA").value == '') {
			alert('Preencha os campos indicados com (*) corretamente!');
				document.getElementById("txidpassAA").value = '';
				document.getElementById("txidpassAA").focus();
				return false;
			}
		} else {
			if(validaCPF(document.getElementById("cpf_numero").value) == false) {
				alert("O CPF Digitado é inválido! Por favor, digite um CPF válido");
				document.getElementById("cpf_numero").value = '';
				document.getElementById("cpf_numero").focus();
				return false;
			}

		}
	} else {
		if (document.getElementById("tipoInscVal").value == 3) {
			if(document.getElementById("txidpassAA").value == '') {
			alert('Preencha os campos indicados com (*) corretamente!');
				document.getElementById("txidpassAA").value = '';
				document.getElementById("txidpassAA").focus();
				return false;
			}
		} else {
			if(validaCPF(document.getElementById("cpf_numero").value) == false) {
				alert("O CPF Digitado é inválido! Por favor, digite um CPF válido");
				document.getElementById("cpf_numero").value = '';
				document.getElementById("cpf_numero").focus();
				return false;
			}

		}
	}

	if (nome.value == '') {
		alert('O campo NOME deve ser preenchido!');
		nome.focus();
		return false;
	}

	if (email.value == '') {
		alert('O campo E-MAIL deve ser preenchido!');
		email.focus();
		return false;
	} else {
		if(validaEmailApenasUm(email.value) == false) {
			alert('O campo E-MAIL deve conter apenas um endereço eletrônico.');
			email.focus();
			return false;
		}
	}

	if (txemail_conf.value == '') {
		alert('O campo E-MAIL CONFIRMAÇÃO deve ser preenchido!');
		txemail_conf.focus();
		return false;
	}

	if (centro.value == '0') {
		alert('O campo POLO deve ser selecionado!');
		centro.focus();
		return false;
	}

	if (sexo.value == '0') {
		alert('O campo SEXO deve ser selecionado!');
		sexo.focus();
		return false;
	}

	if (endereco.value == '') {
		alert('O campo ENDEREÇO deve ser preenchido!');
		endereco.focus();
		return false;
	}

	if (cidade.value == '') {
		if (document.getElementById("tipoInscVal").value == "") {
			if (document.getElementById("txn").value == 3 || document.getElementById("txn").value == 2) {
				alert('O campo CIDADE deve ser preenchido!');
			}
		} else {
			if (document.getElementById("tipoInscVal").value == 3 || document.getElementById("tipoInscVal").value == 2) {
					alert('O campo PROVÍNCIA deve ser preenchido!');
				}
		}
		cidade.focus();
		return false;
	}

	if (estado.value == '0') {
		alert('O campo ESTADO deve ser selecionado!');
		estado.focus();
		return false;
	}

	if (validate_email(email,"E-mail inválido!") != true){
		email.focus();
		return false;
	}
	
	if (como_soube.value == '0') {
		alert('Informe a opção de como soube do MBA!');
		como_soube.focus();
		return false;
	}
	
	if (como_soube.value == 'Outros') {
		if(txa_questao_outros.value == '') {
			alert('Digite como soube do MBA.');
			txa_questao_outros.focus();
			return false;
		}
		if(txa_questao_outros.length >= '50') {
			alert('O Campo está muito grande são permitidos apenas 50 caracteres.');
			txa_questao_outros.focus();
			return false;
		}
	}

	if(validaTelefones() != true) {
		return false;
	}
	desabilitaBotao('1');
	form.submit();
}

/*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Função: verificaTamanhoDoCampo
 Parâmetros:
 Descrição: Funções que valida o máximo permitido no campo "outros"
 Retorna: 
 Desenvolvedor: Andre
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
	function verificaTamanhoDoCampo() {
		if (document.getElementById("txa_questao_outros").value.length > 50) {
			//alert("O campo ESPECIFICAR COMO SOUBE DO PROCESSO SELETIVO deve conter no m&aacute;ximo 140 caracteres.");
			document.getElementById("txa_questao_outros").value = document.getElementById("txa_questao_outros").value.substring(0,50);
			document.getElementById("txa_questao_outros").focus();
		}
	}

/*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Função: validaTelefones
 Parâmetros:
 Descrição: Função que verifica se pelo menos um dos campos de telefones foram preenchidos
 Retorna: 
 Desenvolvedor: Andre
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
function validaTelefones() {
	var form = document.getElementById('form');
	var contador = 0;
	var telcomercial = form.txtelcomercial;
	var txtelcelular = form.txtelcelular;
	var telresidencial = form.txtelresidencial;
	var dddcomercial = form.dddcomercial;
	var dddcelular = form.dddcelular;
	var dddresidencial = form.dddresidencial;

	if(dddcomercial.value == '' && telcomercial.value == '') {
		contador++;
	} else {
		if((dddcomercial.value != '' && telcomercial.value == '') ||
		(dddcomercial.value == '' && telcomercial.value != '')){
			alert('Telefone comercial preenchido incorretamente');
			return false;
		}
	}

	if(dddcelular.value == '' && txtelcelular.value == '') {
		contador++;
	} else {
		if((dddcelular.value != '' && txtelcelular.value == '') ||
			(dddcelular.value == '' && txtelcelular.value != '')){
			alert('Telefone celular preenchido incorretamente');
			return false;
		}
	}

	if(dddresidencial.value == '' && telresidencial.value == '') {
		contador++;
	} else {
		if((dddresidencial.value != '' && telresidencial.value == '') ||
			(dddresidencial.value == '' && telresidencial.value != '')){
			alert('Telefone celular preenchido incorretamente');
			return false;
		}
	}

	if(contador == 3){
		alert('Preencha pelo menos um número de telefone');
		return false;
	} else {
		return true;
	}
}
/*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Função: validaEmailApenasUm
 Parâmetros:
 Descrição: Função que verifica se existe somente 1 Email cadastrado
 Retorna: 
 Desenvolvedor: Andre
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
function validaEmailApenasUm(str) {
	if(str.indexOf("@") == str.lastIndexOf("@")) {
		return true;
	} else {
		return false;
	}
}
/*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Função: validaTelefones
 Parâmetros:
 Descrição: Função que verifica se pelo menos um dos campos de telefones foram preenchidos
 Retorna: 
 Desenvolvedor: Andre
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
function validate_email(field,alerttxt){
	with (field){
		var apos=value.indexOf("@");
		var dotpos=value.lastIndexOf(".");

		if (apos<1||dotpos-apos<2){
		  alert(alerttxt);
		  return false;
		}else{
		  return true;
		}

	}
}

function validaEmailConf(){

	var d = document.form;
	var email = d.txemail.value; 
	var email_conf = d.txemail_conf.value; 
		
	if (email != '' || email_conf != ''){

		if (email != email_conf){
			d.txemail.value = ''; 
			d.txemail_conf.value = '';
			alert('Atenção! O e-mail digitado não confere com a confirmação!');
			return false;
		}else{
			return true;
		}

	} else {
		alert('É obrigatório o preenchimento do campo e-mail!');
		return false;
	}
}

function validaPass(objeto){
	var testePass = /[^\w+\x2D*]/;
	
	if (testePass.test(objeto.value) == true){
		window.alert("Preencha o campo passaporte corretamente!");
		objeto.focus();
	}
}

function CPForPASSPri(valor){
	document.getElementById("tipoInscVal").value = valor;

	if(valor == 3) {
		ajaxPadrao("inscricao_ficha.asp?tipo=3","conteudo");
	} else if(valor == 2) {
		ajaxPadrao("inscricao_ficha.asp?tipo=2","conteudo");
	} else {
		ajaxPadrao("inscricao_ficha.asp?tipo=1","conteudo");
	}
}

function campo_outros() {

	var x = document.getElementById('como_soube').value;
		
	if(x == "Outros"){
			document.getElementById("ParagradoCampoOutros").style.display = '';
	} else {
			document.getElementById("ParagradoCampoOutros").style.display = 'none';
			document.getElementById("txa_questao_outros").value = '';
	}
	setTimeout("campo_outros();",1);
}

	function preencheCampos() {

		document.getElementById("nome").value = document.getElementById("txa").value;
		document.getElementById("empresa").value = document.getElementById("txh").value;
//		document.getElementById("txtelcomercial").value = document.getElementById("txf").value; //Não trazer pois não existe um formato correto
//		document.getElementById("txtelresidencial").value = document.getElementById("txi").value; //Não trazer pois não existe um formato correto
		document.getElementById("txendereco").value = document.getElementById("txb").value;
		document.getElementById("bairro").value = document.getElementById("txc").value;
		document.getElementById("cidade").value = document.getElementById("txd").value;
		document.getElementById("txcep").value = document.getElementById("txj").value;
		document.getElementById("cpf_numero").value = document.getElementById("txm").value;
		document.getElementById("txidpassAA").value = document.getElementById("txl").value;
		document.getElementById("txemail").value = document.getElementById("txo").value;
		document.getElementById("txemail_conf").value = document.getElementById("txo").value;

		if(document.getElementById("NomeDesabilitado") != null && document.getElementById("NomeDesabilitado") != 'undefined') {
			document.getElementById("NomeDesabilitado").value = document.getElementById("txa").value;
			document.getElementById("CpfDesabilitado").value = document.getElementById("txm").value;
			document.getElementById("RgDesabilitado").value = document.getElementById("txl").value;
			if (document.getElementById("CpfDesabilitado").value.length > 10){
				execFuncao(document.getElementById("CpfDesabilitado"), cpf);
			}
		}

		if (document.getElementById("cpf_numero").value.length > 10){
			execFuncao(document.getElementById("cpf_numero"), cpf);
		}

		for (i=0; i < document.getElementById("slcEstado").length ; i++){
			if( document.getElementById("slcEstado").options[i].value == document.getElementById("txe").value ){
				document.getElementById("slcEstado").options[i].selected = true;
			}
		}

		for (i=0; i < document.getElementById("como_soube").length ; i++){
			if( document.getElementById("como_soube").options[i].value == 'Ex-Aluno' ){
				document.getElementById("como_soube").options[i].selected = true;
			}
		}
		
		if (document.getElementById("txg").value != 1 && document.getElementById("txg").value != 2){
			document.getElementById("htmlSexo").innerHTML = '<select name="slcSexo" id="slcSexo" class="campos"><option value="0">Selecione</option><option value="1">Feminino</option><option value="2">Masculino</option></select> <span class="cl_colorRed"> * </span>'
		} else {
			if (document.getElementById("txg").value == 1) {
				var sexo = "Feminino"
			} else {
				var sexo = "Masculino"
			}
			document.getElementById("htmlSexo").innerHTML = '<input type="text" value="'+sexo+'" name="SexoDesabilitado" id="SexoDesabilitado" maxlength="35" size="35" class="camposInativo" disabled="true"><input type="hidden" name="slcSexo" id="slcSexo" maxlength="1" value="'+document.getElementById("txg").value+'">'
		}

		
	}

	function Verificar(e){ // Desabilita Copiar e Colar de Um botão!
			var key;
			if(window.event) { //IE
				key = window.event;
				var ctrl=key.ctrlKey;
				var tecla=key.keyCode;
			} else { //FireFox
				key = e.which;
				var ctrl=e.ctrlKey;
				var tecla=e.keyCode;
			}

			if ((ctrl && tecla == 67) || (ctrl && tecla == 86) || tecla == 45){
				tecla = 0; 
				if(window.event) // IE
					key.returnValue = false;
				else  // FireFox
					e.preventDefault();
			}

		}
		//Valida CPF
function validaCPF(num){

		num=num.replace(".","")
		num=num.replace(".","")
		num=num.replace("-","")
		//alert(num);
		//padrao para apenas 11 ocorrencias de numeros
		var padraoCPF = /\d{11}/;
		
		//testa o padrao
		if (padraoCPF.test(num) == false){
			return false;
		}
		
		//cria um array para armazenar cada algarismo do CPF
		var vetorCPF = new Array();
	
		//atribui os algarismos ao vetor
		for (i=0 ; i<11 ; i++){
			vetorCPF[i] = num.substring(i,i+1);
		}
		
		//declaracao de variaveis para uso futuro
		var J = 0;
		var K = 0;
		var somaJ = 0;
		var somaK = 0;
		var validaCont = 0;
		
		//verifica quantos numeros repetidos contem no CPF
		for (i=1 ; i<11 ; i++){
			if(vetorCPF[i] == vetorCPF[i-1]){
				validaCont++;
			}
		}
		
		//se todos os numeros forem iguais, o CPF e invalido
		if(validaCont == 10){
			return false;
		}
		
		//faz a primeira conta matematica para descobrir o primeiro algarismo verificador
		for (i=0 ; i<9 ; i++){
			somaJ += (10-i)*vetorCPF[i];
		}
		
		if(somaJ%11 == 0 || somaJ%11 == 1){
			J = 0;
		}else{
			J = 11 - (somaJ%11);
		}
		
		//faz a segunda conta matematica para descobrir o segundo algarismo verificador
		for (i=0 ; i<10 ; i++){
			somaK += (11-i)*vetorCPF[i];
		}
		
		if(somaK%11 == 0 || somaK%11 == 1){
			K = 0;
		}else{
			K = 11 - (somaK%11);
		}
		
		//compara o CPF aos algarismos verificadores 
		if (vetorCPF[9] != J || vetorCPF[10] != K){
			return false;
		}
		return true;
	}

	function fazerPagamento() {
		var pla = document.getElementById("idPlano").value;
		var mat = document.getElementById("idMatricula").value;

		if(pla == 0) {
			alert("Selecione um plano de pagamento");
			document.getElementById("idPlano").focus();
		} else {
			window.open("inscricao_libera_pagamento.asp?c="+pla+"&m="+mat+"","_blank","toolbar=no, location=no, directories=no, status=yes, menubar=yes, scrollbars=yes, resizable=no, width=600, height=400",true);
		}
	}

function validaLoginExAluno(){
		padraoLogin = /\d{9}/;
		
		login = document.getElementById("iptLogin").value;
		senha = document.getElementById("iptSenha").value;
		
		if (padraoLogin.test(login) == false){
			alert("Preencha o campo login corretamente!");
			return false;
		} 
		
		if (senha==""){
			alert("Preencha o campo senha!");
			return false;
		}
		
		ajaxPadrao("valida_exaluno.asp?nmLogin="+login+"&nmSenha="+senha+"","conteudo");
}

	
function validaLogin(){
		padraoLogin = /\d{9}/;
		
		login = document.getElementById("iptLogin").value;
		senha = document.getElementById("iptSenha").value;
		
		if (padraoLogin.test(login) == false){
			alert("Preencha o campo login corretamente!");
			return false;
		} 
		
		if (senha==""){
			alert("Preencha o campo senha!");
			return false;
		}
		
		ajaxPadrao("valida_login.asp?nmLogin="+login+"&nmSenha="+senha+"","conteudo");
	}
	
	function recuperaSenha(ex){
		padraoLogin = /\d{9}/;
		
		login = document.getElementById("iptLogin").value;
		
		if (padraoLogin.test(login) == false){
			alert("Preencha o campo login corretamente!");
			return false;
		} 
		
		ajaxPadrao("recupera_senha.asp?nmLogin="+login+"&ex="+ex+"","conteudo");
	}
	
	/*fora de uso*/function abrirLembreteSenha(){
		window.open("/site/cursos_senha_confirma.asp","_blank","toolbar=no, location=no, directories=no, status=yes, menubar=yes, scrollbars=yes, resizable=yes, fullscreen=yes",true);
	}
	
	/*fora de uso*/function abrirPagamento(){
		window.open("/alunos/srv/financeiro/pagamento/formas_pagamento.asp","_blank","toolbar=no, location=no, directories=no, status=yes, menubar=yes, scrollbars=yes, resizable=no, width=600, height=400",true);
	}
	
	function abrirContrato(tipoAluno,paisAluno){
		if(paisAluno == 'Japão') {
			paisAluno = 'japao';
		}
		if(paisAluno == 'Angola') {
			paisAluno = 'angola';
		}
		if(paisAluno == 'Brasil') {
			paisAluno = 'brasil';
		}
		window.open("/documentos/contratos/contrato_mba/"+tipoAluno+""+paisAluno+".pdf","_blank","toolbar=no, location=no, directories=no, status=yes, menubar=yes, scrollbars=yes, resizable=yes, width=600, height=400",true);
	}
	
	function instrucaoLogado(){
		document.getElementById("divLogado").innerHTML = "<span onclick=ajaxPadrao('logado.asp','conteudo')> Voltar </span>";
		document.getElementById("divLogado").className = "clVoltar";
	}
	
function abreOutros(){
		if(document.getElementById("slcEstado").value == "outros"){
			document.getElementById("iptUfOutros").style.display = "";
		}else{
			document.getElementById("iptUfOutros").style.display = "none";
		}
}

function alteraTitulo() {
	var campoBaseA = document.getElementById("tipoInscVal");
	var campoBaseB = document.getElementById("txn");
	var cmpTituloP = document.getElementById("tituloPagina");
	var inscricoes = new Array();
	inscricoes[0] = "MBA em Captação de Financiamento - Faculdade AIEC";
	inscricoes[1] = "Inscrição para residentes no Brasil";
	inscricoes[2] = "Inscrição para brasileiros no exterior";
	inscricoes[3] = "Inscrição para estrangeiros no exterior";

	if (campoBaseA.value != '') {
		window.parent.document.title = inscricoes[0] + " - " + inscricoes[campoBaseA.value];
		cmpTituloP.innerHTML = inscricoes[campoBaseA.value];	
		return false;
	}
	
	if (campoBaseB != null) {
		window.parent.document.title = inscricoes[0] + " - " + inscricoes[campoBaseB.value];	
		cmpTituloP.innerHTML = inscricoes[campoBaseB.value];	
		return false;
	}
	window.parent.document.title = inscricoes[0];
		cmpTituloP.innerHTML = "INSCRIÇÃO";	

}

function abrirDivPagamento(){
	if (document.getElementById("idPlano").value == "0") {
		document.getElementById("divCaixaLogin").style.display = "none";
	} else {
		document.getElementById("divCaixaLogin").style.display = "";
	}
}

function redirLogin() {
	var variaveis = document.location.href.split("?");

	if(variaveis[1] == "login-inscrito") {
		ajaxPadrao("valida_login.asp","conteudo");
	} else {
		ajaxPadrao("valida_exaluno.asp","conteudo");
	}
}

function clickIE() {if (document.all) {return false;}}
function clickNS(e) {if 
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {return false;}}}
if (document.layers) 
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
document.oncontextmenu=new Function("return false")
