/* Seleção do Cidade por Estado */

var cidade;

function listaCidadesCadastro(id,selecionado) {
	cidade = selecionado;
	
	listBox = document.getElementById('cidade');
	if (id != 0) {
		listBox.options[0].text = 'Aguarde...';
		listBox.disabled = true;
		executar('bd.get.cidades.php','id='+id,listaCidadesReturn);
	}
	else {
		document.getElementById('cidade').value = '';
		limparCombo(listBox,1);
		listBox.options[0].text = 'Selecione um estado primeiro';
		listBox.disabled = true;
	
	}
}

function listaCidades(id,selecionado) {
	cidade = selecionado;
	listBox = document.getElementById('cidade');
	if (id != 0) {
		listBox.options[0].text = 'Aguarde...';
		listBox.disabled = true;
		executar('modulos/candidatos/bd.get.cidades.php','id='+id,listaCidadesReturn);
	}
	else {
		document.getElementById('cidade').value = '';
		limparCombo(listBox,1);
		listBox.options[0].text = 'Selecione um estado primeiro';
		listBox.disabled = true;
	
	}
}

function listaCidadesReturn() {
	if (xhReq.readyState == 4) {
		listBox = document.getElementById('cidade');
//		alert(xhReq.responseText);
		if (xhReq.responseXML) {
			listBox.disabled = true;
			resposta = xhReq.responseXML;
			obj = resposta.getElementsByTagName('cidade');
			limparCombo(listBox,1);
			for (i = 0; i < obj.length; i++) {
				valor = obj[i].getElementsByTagName('id')[0].firstChild.nodeValue;
				texto = unescape(obj[i].getElementsByTagName('nome')[0].firstChild.nodeValue);
				addCombo(valor,texto,listBox);
				listBox.options[0].text = 'Selecione a cidade...';
				listBox.disabled = false;
			}
			listBox.value = cidade;
			cidade = '';
		}
		else {
			listBox.value = 0;
			listBox.options[0].text = 'Estado sem cidade cadastrada.';
			listBox.disabled = true;
		}
	}
}

/*************************/
function listaCidadesComercial(id,selecionado) {
	cidade = selecionado;
	
	listBox = document.getElementById('cidade_comercial');
	if (id != 0) {
		listBox.options[0].text = 'Aguarde...';
		listBox.disabled = true;
		executar('bd.get.cidades.php','id='+id,listaCidadesComercialReturn);
	}
	else {
		document.getElementById('cidade').value = '';
		limparCombo(listBox,1);
		listBox.options[0].text = 'Selecione um estado primeiro';
		listBox.disabled = true;
	
	}
}

function listaCidadesComercialReturn() {
	if (xhReq.readyState == 4) {
		listBox = document.getElementById('cidade_comercial');
//		alert(xhReq.responseText);
		if (xhReq.responseXML) {
			listBox.disabled = true;
			resposta = xhReq.responseXML;
			obj = resposta.getElementsByTagName('cidade');
			limparCombo(listBox,1);
			for (i = 0; i < obj.length; i++) {
				valor = obj[i].getElementsByTagName('id')[0].firstChild.nodeValue;
				texto = unescape(obj[i].getElementsByTagName('nome')[0].firstChild.nodeValue);
				addCombo(valor,texto,listBox);
				listBox.options[0].text = 'Selecione a cidade...';
				listBox.disabled = false;
			}
			listBox.value = cidade;
			cidade = '';
		}
		else {
			listBox.value = 0;
			listBox.options[0].text = 'Estado sem cidade cadastrada.';
			listBox.disabled = true;
		}
	}
}


function abre(pag,nome) {
	document.getElementById('lista').innerHTML = '<div align="center"><br><img src="../imagens/icones/black_preload.gif" width="16" height="16" align="absmiddle">Carregando dados... Aguarde!<br></div>';
	if (!nome){
		nome = ""
	}
	include("modulos/candidatos/lista.candidato.php",'pagina='+pag+'&nome='+nome,'lista');
}

var mensagem; 
var statusmodify;

function novo() {
	mensagem = '';
	executar("modulos/candidatos/bd.new.candidato.php",'id='+id,deletaRetorno);	
}

function edita(id) {
	executar("modulos/candidatos/bd.get.php",'id='+id,editaOpen);
}

function mudaStatus(id) {
	statusmodify = id;
	document.getElementById('imgAguarde').style.display = '';
	executar("modulos/candidatos/bd.mudastatus.php",'id='+id,mudaImagemStatus);
}

function mudaImagemStatus() {
	if(xhReq.readyState==4){
		document.getElementById('imgAguarde').style.display = 'none';
		document.getElementById('img'+statusmodify).src = xhReq.responseText;
	}
}

function deleta(id) {
	if (confirm('Tem certeza que deseja excluir este candidato do cadastro?')) {
		mensagem = 'Candidato excluído com sucesso';
		executar("modulos/candidatos/bd.apaga.candidato.php",'id='+id,deletaRetorno);
	}
}

function deletaRetorno() {
	if(xhReq.readyState==4){
		retorno = parseInt(xhReq.responseText);
//		alert(xhReq.responseText);
		if (retorno > 0) {
			if (mensagem) {
				alert(mensagem);
			}
			document.getElementById('nome').value 				= '';
			document.getElementById('nomeMae').value 			= '';
			document.getElementById('cpf').value 				= '';
			document.getElementById('rg').value 				= '';
			document.getElementById('tipoIdentidade').value 	= '';
			document.getElementById('orgaoEmissor').value 		= '';
			document.getElementById('ufEmissor').value 			= '';
			document.getElementById('envelope').value 			= '';
			document.getElementById('data_nascimento').value 	= '';
			document.getElementById('sexo').value			 	= '-';
			document.getElementById('ecivil').value			 	= '-';
			document.getElementById('escolaridade').value		= '-';
			document.getElementById('experiencia').value		= '-';
			document.getElementById('endereco').value 			= '';
			document.getElementById('complemento').value 		= '';
			document.getElementById('cep').value 				= '';
			document.getElementById('bairro').value 			= '';
			document.getElementById('cidade').value				= '0';
			document.getElementById('cidade').disabled			= false;
			document.getElementById('estado').value 			= '0';
			document.getElementById('ddd').value 				= '';
			document.getElementById('fone').value 				= '';
			document.getElementById('celular').value 			= '';
			document.getElementById('email').value 				= '';
			document.getElementById('deficiencia').checked 		= false;
			document.getElementById('data_inscricao').value 	= '';
			document.getElementById('cid').value 				= '';
			document.getElementById('obs_deficiencia').value 	= '';
			document.getElementById('botao').value				= 'Cadastrar';
			document.getElementById('botao').disabled			= false;
			document.getElementById('ativo').checked 			= true;
			document.getElementById('id').value 				= xhReq.responseText;
			setTimeout('abre(1,"")',500);
		}
		else 
		{
			alert('Ocorreu um erro durante a remoção deste candidato.\nPor favor tente novamente.');	
			abre(1);
		}
	}
	else return;
}

function editaOpen() {
	if(xhReq.readyState==4){ 
		resposta 		= xhReq.responseXML;
		obj 			= resposta.getElementsByTagName('candidato');
		id 				= obj[0].getElementsByTagName('id')[0].firstChild.nodeValue;
		nome			= unescape(obj[0].getElementsByTagName('nome')[0].firstChild.nodeValue);
		nomeMae			= unescape(obj[0].getElementsByTagName('nomeMae')[0].firstChild.nodeValue);
		cpf				= obj[0].getElementsByTagName('cpf')[0].firstChild.nodeValue;
		rg				= obj[0].getElementsByTagName('rg')[0].firstChild.nodeValue;
		tipoIdentidade	= obj[0].getElementsByTagName('tipoIdentidade')[0].firstChild.nodeValue;
		if(obj[0].getElementsByTagName('orgaoEmissor')[0].firstChild != null) {
			var	orgaoEmissor		= obj[0].getElementsByTagName('orgaoEmissor')[0].firstChild.nodeValue;
		}
		else {
			var orgaoEmissor = '';	
		}
		if(obj[0].getElementsByTagName('ufEmissor')[0].firstChild != null) {
			var	ufEmissor		= obj[0].getElementsByTagName('ufEmissor')[0].firstChild.nodeValue;
		}
		else {
			var ufEmissor = '';	
		}
		if(obj[0].getElementsByTagName('envelope')[0].firstChild != null) {
			var	envelope		= obj[0].getElementsByTagName('envelope')[0].firstChild.nodeValue;
		}
		else {
			var envelope = '';	
		}
		data_nascimento	= obj[0].getElementsByTagName('data_nascimento')[0].firstChild.nodeValue;
		sexo			= obj[0].getElementsByTagName('sexo')[0].firstChild.nodeValue;
		ecivil			= obj[0].getElementsByTagName('ecivil')[0].firstChild.nodeValue;
		escolaridade	= obj[0].getElementsByTagName('escolaridade')[0].firstChild.nodeValue;
		if(obj[0].getElementsByTagName('experiencia')[0].firstChild != null) {
			var	experiencia		= obj[0].getElementsByTagName('experiencia')[0].firstChild.nodeValue;
		}
		else {
			var experiencia = '';	
		}
		endereco		= unescape(obj[0].getElementsByTagName('endereco')[0].firstChild.nodeValue);
		if(obj[0].getElementsByTagName('complemento')[0].firstChild != null) {
			var	complemento		= unescape(obj[0].getElementsByTagName('complemento')[0].firstChild.nodeValue);
		}
		else {
			var complemento = '';	
		}
		cep		= obj[0].getElementsByTagName('cep')[0].firstChild.nodeValue;
		if(obj[0].getElementsByTagName('bairro')[0].firstChild != null) {
			var	bairro		= unescape(obj[0].getElementsByTagName('bairro')[0].firstChild.nodeValue);
		}
		else {
			var bairro = '';	
		}
		cidade			= obj[0].getElementsByTagName('cidade')[0].firstChild.nodeValue;
		estado			= obj[0].getElementsByTagName('estado')[0].firstChild.nodeValue;
		if(obj[0].getElementsByTagName('ddd')[0].firstChild != null) {
			var	ddd		= obj[0].getElementsByTagName('ddd')[0].firstChild.nodeValue;
		}
		else {
			var ddd = '';	
		}
		if(obj[0].getElementsByTagName('fone')[0].firstChild != null) {
			var	fone		= obj[0].getElementsByTagName('fone')[0].firstChild.nodeValue;
		}
		else {
			var fone = '';	
		}
		if(obj[0].getElementsByTagName('celular')[0].firstChild != null) {
			var	celular		= obj[0].getElementsByTagName('celular')[0].firstChild.nodeValue;
		}
		else {
			var celular = '';	
		}
		if(obj[0].getElementsByTagName('email')[0].firstChild != null) {
			var	email		= obj[0].getElementsByTagName('email')[0].firstChild.nodeValue;
		}
		else {
			var email = '';	
		}
		nacionalidade	= obj[0].getElementsByTagName('nacionalidade')[0].firstChild.nodeValue;
		deficiencia		= obj[0].getElementsByTagName('deficiencia')[0].firstChild.nodeValue;
		data_inscricao	= obj[0].getElementsByTagName('data_inscricao')[0].firstChild.nodeValue;
		cid				= obj[0].getElementsByTagName('cid')[0].firstChild.nodeValue;
		obs_deficiencia	= obj[0].getElementsByTagName('obs_deficiencia')[0].firstChild.nodeValue;
		ativo		 	= obj[0].getElementsByTagName('ativo')[0].firstChild.nodeValue;
	
		listaCidades(estado,cidade);
	
		document.getElementById('nome').value 				= nome;
		document.getElementById('nomeMae').value 			= nomeMae;
		document.getElementById('cpf').value 				= cpf;
		document.getElementById('rg').value 				= rg;
		document.getElementById('tipoIdentidade').value 	= tipoIdentidade;
		document.getElementById('orgaoEmissor').value 		= orgaoEmissor;
		document.getElementById('ufEmissor').value 			= ufEmissor;
		document.getElementById('envelope').value 			= envelope;
		document.getElementById('data_nascimento').value 	= data_nascimento;
		document.getElementById('sexo').value 				= sexo;
		document.getElementById('ecivil').value 			= ecivil;
		document.getElementById('escolaridade').value 		= escolaridade;
		document.getElementById('experiencia').value 		= experiencia;
		document.getElementById('endereco').value 			= endereco;
		document.getElementById('complemento').value 		= complemento;
		document.getElementById('cep').value 				= cep;
		document.getElementById('bairro').value 			= bairro;
		document.getElementById('estado').value 			= estado;
		document.getElementById('ddd').value 				= ddd;
		document.getElementById('fone').value 				= fone;
		document.getElementById('celular').value 			= celular;
		document.getElementById('email').value 				= email;
		document.getElementById('nacionalidade').value 		= nacionalidade;
		document.getElementById('data_inscricao').value 	= data_inscricao;
		document.getElementById('cid').value 				= cid;
		document.getElementById('obs_deficiencia').value	= obs_deficiencia;
		document.getElementById('id').value					= id;
		document.getElementById('botao').value				= 'Salvar';
		if (ativo == 1) {
			document.getElementById('ativo').checked = true;
		}
		else {
			document.getElementById('ativo').checked = false;
		}
		if (deficiencia == 1) {
			document.getElementById('deficiencia').checked = true;
		}
		else {
			document.getElementById('deficiencia').checked = false;
		}
	}
	if(xhReq.readyState!=4){ 
		return;
	}
}


function verificaCpfCadastro(cpf)
{
	executar('bd.verificaCpf.php','cpf='+cpf,verificaCpfReturn);
}



function verificaCpfReturn() {
	if (xhReq.readyState == 4) {
		if (xhReq.responseText == 'existe') {
			alert ("Cpf Já Cadastrado");
			document.getElementById('cpf').focus();
		}
		
	}
}


function verificaDocumentoReturn() {
	if (xhReq.readyState == 4) {
		if (xhReq.responseText == 'existe') {
			alert ("Documento Já Cadastrado");
			document.getElementById('envelope').focus();
		}
		
	}
}


function verificaDocumentoCadastro(documento)
{
	executar('bd.verificaDocumento.php','envelope='+documento,verificaDocumentoReturn);
}


function ImprimiBoletoBB()
{
	var cargos_id		= document.getElementById('cargos_id');
	var nome			= document.getElementById('nome');
	var nomeMae			= document.getElementById('nomeMae');
	var cpf				= document.getElementById('cpf');
	var rg				= document.getElementById('rg');
	var fone			= document.getElementById('fone');
	var tipoIdentidade	= document.getElementById('tipoIdentidade');
	var data_nascimento	= document.getElementById('data_nascimento');
	var sexo			= document.getElementById('sexo');
	var ecivil			= document.getElementById('ecivil');
	var escolaridade	= document.getElementById('escolaridade');
	var experiencia		= document.getElementById('experiencia');
	var endereco		= document.getElementById('endereco');
	var cidade			= document.getElementById('cidade');
	var estado			= document.getElementById('estado');
	var celular			= document.getElementById('celular');
	var email			= document.getElementById('email');
	var nacionalidade	= document.getElementById('nacionalidade');
	var deficiencia		= document.getElementById('deficiencia');
	var ativo			= document.getElementById('ativo');
	var id				= document.getElementById('id');
	var usuarios_id		= document.getElementById('usuarios_id');
	var cep				= document.getElementById('cep');
	var verifica		= document.getElementById('verifica');
	var data_inscricao	= document.getElementById('data_inscricao');
	var cid				= document.getElementById('cid');
	var obs_deficiencia	= document.getElementById('obs_deficiencia');
	var localidade_id	= document.getElementById('localidade_id');
	var local_prova		= document.getElementById('local_prova');
	var contato_nome1	= document.getElementById('contato_nome1');
	var contato_fone1	= document.getElementById('contato_fone1');
	var contato_nome2	= document.getElementById('contato_nome2');
	var contato_fone2	= document.getElementById('contato_fone2');

	//verificação do cpf
	var i;
 	s = document.cad.cpf.value;
	var c = s.substr(0,9);
	var dv = s.substr(9,2);
	var d1 = 0;
	var v = 0;
	
	for (i = 0; i < 9; i++)
	{
		d1 += c.charAt(i)*(10-i);
	}
	if (d1 == 0){
 		v = 1;	
	}
 	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(0) != d1)
	{
 		v = 1;
	}
	d1 *= 2;
	for (i = 0; i < 9; i++)
	{
		d1 += c.charAt(i)*(11-i);
	}
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(1) != d1)
	{
		v = 1;	
	}
	
	
	if (nome.value == '' ){
		alert('Por favor preencha o campo Nome.');
		nome.focus();
		return false;
	} else if (localidade_id.value == '-' ){
		alert('Por favor preencha o campo Localidade.');
		nome.focus();
		return false;
	} else if (local_prova.value == '-' ){
		alert('Por favor preencha o campo Local Prova.');
		local_prova.focus();
		return false;
	} else if (cpf.value == '' ){
		alert('Por favor preencha o campo CPF.');
		cpf.focus();
		return false;
	} else if (cargos_id.value == '-' ){
		alert('Por favor selecione o cargo.');
		cargos_id.focus();
		return false;
	} else if (fone.value == '' ){
		alert('Por favor informe o telefone.');
		fone.focus();
		return false;
	} else if (rg.value == '' ){
		alert('Por favor preencha o campo Identidade.');
		rg.focus();
		return false;
	} else if (tipoIdentidade.value	== '-' ){
		alert('Por favor selecione o Tipo de Documento.');
		tipoIdentidade.focus();
		return false;
	} else if (data_nascimento.value == '' ){
		alert('Por favor preencha a Data de Nascimento.');
		data_nascimento.focus();
		return false;
	} else if (escolaridade.value == '-' ){
		alert('Por favor selecione a Escolaridade.');
		escolaridade.focus();
		return false;
	} else if (endereco.value == '' ){
		alert('Por favor preencha o campo Endereço.');
		endereco.focus();
		return false;
	} else if (cidade.value == '' ){
		alert('Por favor selecione a Cidade.');
		cidade.focus();
		return false;
	} else if (estado.value == '-' ){
		alert('Por favor selecione o Estado.');
		estado.focus();
		return false;	
	} else if (cep.value == '' ){
		alert('Por favor selecione o Cep.');
		estado.focus();
		return false;	
	} else if (!verifica.checked) {
		alert('Você deve declarar que as informações são verdadeiras.');
		estado.focus();
		return false;	
	} else if (cid.value == '' ){
		alert('Especificação do CID é obrigatoria.');
		estado.focus();
		return false;	
	} else if (contato_nome1.value == '' ){
		alert('Informe o nome do contato.');
		contato_nome1.focus();
		return false;
	} else if (contato_nome2.value == '' ){
		alert('Informe o nome do contato.');
		contato_nome2.focus();
		return false;
	} else if (contato_fone1 == '' ){
		alert('Informe o telefone do contato.');
		contato_fone1.focus();
		return false;
	} else if (contato_fone2.value == '' ){
		alert('Informe o telefone do contato.');
		contato_fone2.focus();
		return false;
	} else if (ecivil.value == '-' ){
		alert('Por favor selecione o Estado Civil.');
		estado.focus();
		return false;	
	} else if (data_nascimento.value.length < 10){
		alert('A data de Nascimento deve ser no formato dd/mm/aaaa.');
		data_nascimento.focus();
		return false;		
	} else {
		document.getElementById('botao').value = 'Aguarde...';
		document.getElementById('botao').disabled = true;
		xhSend('bd.altera.candidato.php','cad',ImprimiBoletoBB_retorno);
	}
}

function alteraCadastro()
{
	var cargos_id		= document.getElementById('cargos_id');
	var nome			= document.getElementById('nome');
	var nomeMae			= document.getElementById('nomeMae');
	var cpf				= document.getElementById('cpf');
	var rg				= document.getElementById('rg');
	var fone			= document.getElementById('fone');
	var tipoIdentidade	= document.getElementById('tipoIdentidade');
	var data_nascimento	= document.getElementById('data_nascimento');
	var sexo			= document.getElementById('sexo');
	var ecivil			= document.getElementById('ecivil');
	var escolaridade	= document.getElementById('escolaridade');
	var experiencia		= document.getElementById('experiencia');
	var endereco		= document.getElementById('endereco');
	var cidade			= document.getElementById('cidade');
	var estado			= document.getElementById('estado');
	var celular			= document.getElementById('celular');
	var email			= document.getElementById('email');
	var nacionalidade	= document.getElementById('nacionalidade');
	var deficiencia		= document.getElementById('deficiencia');
	var ativo			= document.getElementById('ativo');
	var id				= document.getElementById('id');
	var usuarios_id		= document.getElementById('usuarios_id');
	var cep				= document.getElementById('cep');
	var verifica		= document.getElementById('verifica');
	var data_inscricao	= document.getElementById('data_inscricao');
	var cid				= document.getElementById('cid');
	var obs_deficiencia	= document.getElementById('obs_deficiencia');
	var localidade_id	= document.getElementById('localidade_id');
	var local_prova		= document.getElementById('local_prova');
	var contato_nome1	= document.getElementById('contato_nome1');
	var contato_fone1	= document.getElementById('contato_fone1');
	var contato_nome2	= document.getElementById('contato_nome2');
	var contato_fone2	= document.getElementById('contato_fone2');

	//verificação do cpf
	var i;
 	s = document.cad.cpf.value;
	var c = s.substr(0,9);
	var dv = s.substr(9,2);
	var d1 = 0;
	var v = 0;
	
	for (i = 0; i < 9; i++)
	{
		d1 += c.charAt(i)*(10-i);
	}
	if (d1 == 0){
 		v = 1;	
	}
 	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(0) != d1)
	{
 		v = 1;
	}
	d1 *= 2;
	for (i = 0; i < 9; i++)
	{
		d1 += c.charAt(i)*(11-i);
	}
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(1) != d1)
	{
		v = 1;	
	}
	
	
	if (nome.value == '' ){
		alert('Por favor preencha o campo Nome.');
		nome.focus();
		return false;
	} else if (localidade_id.value == '-' ){
		alert('Por favor preencha o campo Localidade.');
		nome.focus();
		return false;
	} else if (local_prova.value == '-' ){
		alert('Por favor preencha o campo Local Prova.');
		local_prova.focus();
		return false;
	} else if (cpf.value == '' ){
		alert('Por favor preencha o campo CPF.');
		cpf.focus();
		return false;
	} else if (cargos_id.value == '-' ){
		alert('Por favor selecione o cargo.');
		cargos_id.focus();
		return false;
	} else if (fone.value == '' ){
		alert('Por favor informe o telefone.');
		fone.focus();
		return false;
	} else if (rg.value == '' ){
		alert('Por favor preencha o campo Identidade.');
		rg.focus();
		return false;
	} else if (tipoIdentidade.value	== '-' ){
		alert('Por favor selecione o Tipo de Documento.');
		tipoIdentidade.focus();
		return false;
	} else if (data_nascimento.value == '' ){
		alert('Por favor preencha a Data de Nascimento.');
		data_nascimento.focus();
		return false;
	} else if (escolaridade.value == '-' ){
		alert('Por favor selecione a Escolaridade.');
		escolaridade.focus();
		return false;
	} else if (endereco.value == '' ){
		alert('Por favor preencha o campo Endereço.');
		endereco.focus();
		return false;
	} else if (cidade.value == '' ){
		alert('Por favor selecione a Cidade.');
		cidade.focus();
		return false;
	} else if (estado.value == '-' ){
		alert('Por favor selecione o Estado.');
		estado.focus();
		return false;	
	} else if (cep.value == '' ){
		alert('Por favor selecione o Cep.');
		estado.focus();
		return false;	
	} else if (!verifica.checked) {
		alert('Você deve declarar que as informações são verdadeiras.');
		estado.focus();
		return false;	
	} else if (cid.value == '' ){
		alert('Especificação do CID é obrigatoria.');
		estado.focus();
		return false;	
	} else if (contato_nome1.value == '' ){
		alert('Informe o nome do contato.');
		contato_nome1.focus();
		return false;
	} else if (contato_nome2.value == '' ){
		alert('Informe o nome do contato.');
		contato_nome2.focus();
		return false;
	} else if (contato_fone1 == '' ){
		alert('Informe o telefone do contato.');
		contato_fone1.focus();
		return false;
	} else if (contato_fone2.value == '' ){
		alert('Informe o telefone do contato.');
		contato_fone2.focus();
		return false;
	} else if (ecivil.value == '-' ){
		alert('Por favor selecione o Estado Civil.');
		estado.focus();
		return false;	
	} else if (data_nascimento.value.length < 10){
		alert('A data de Nascimento deve ser no formato dd/mm/aaaa.');
		data_nascimento.focus();
		return false;		
	} else {
		document.getElementById('botao').value = 'Aguarde...';
		document.getElementById('botao').disabled = true;
		xhSend('bd.altera.candidato.php','cad',alteraFimCadastro);
	}
}

function alteraCadastroGo()
{
	var cargos_id		= document.getElementById('cargos_id');
	var nome			= document.getElementById('nome');
	var nomeMae			= document.getElementById('nomeMae');
	var cpf				= document.getElementById('cpf');
	var rg				= document.getElementById('rg');
	var fone			= document.getElementById('fone');
	var tipoIdentidade	= document.getElementById('tipoIdentidade');
	var data_nascimento	= document.getElementById('data_nascimento');
	var sexo			= document.getElementById('sexo');
	var ecivil			= document.getElementById('ecivil');
	var escolaridade	= document.getElementById('escolaridade');
	var experiencia		= document.getElementById('experiencia');
	var endereco		= document.getElementById('endereco');
	var cidade			= document.getElementById('cidade');
	var estado			= document.getElementById('estado');
	var celular			= document.getElementById('celular');
	var email			= document.getElementById('email');
	var nacionalidade	= document.getElementById('nacionalidade');
	var deficiencia		= document.getElementById('deficiencia');
	var ativo			= document.getElementById('ativo');
	var id				= document.getElementById('id');
	var usuarios_id		= document.getElementById('usuarios_id');
	var cep				= document.getElementById('cep');
	var verifica		= document.getElementById('verifica');
	var data_inscricao	= document.getElementById('data_inscricao');
	var cid				= document.getElementById('cid');
	var obs_deficiencia	= document.getElementById('obs_deficiencia');
	var localidade_id	= document.getElementById('localidade_id');
	var local_prova		= document.getElementById('local_prova');
	var contato_nome1	= document.getElementById('contato_nome1');
	var contato_fone1	= document.getElementById('contato_fone1');
	var contato_nome2	= document.getElementById('contato_nome2');
	var contato_fone2	= document.getElementById('contato_fone2');

	//verificação do cpf
	var i;
 	s = document.cad.cpf.value;
	var c = s.substr(0,9);
	var dv = s.substr(9,2);
	var d1 = 0;
	var v = 0;
	
	for (i = 0; i < 9; i++)
	{
		d1 += c.charAt(i)*(10-i);
	}
	if (d1 == 0){
 		v = 1;	
	}
 	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(0) != d1)
	{
 		v = 1;
	}
	d1 *= 2;
	for (i = 0; i < 9; i++)
	{
		d1 += c.charAt(i)*(11-i);
	}
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(1) != d1)
	{
		v = 1;	
	}
	
	
	if (nome.value == '' ){
		alert('Por favor preencha o campo Nome.');
		nome.focus();
		return false;
	} else if (localidade_id.value == '-' ){
		alert('Por favor preencha o campo Localidade.');
		nome.focus();
		return false;
	} else if (local_prova.value == '-' ){
		alert('Por favor preencha o campo Local Prova.');
		local_prova.focus();
		return false;
	} else if (cpf.value == '' ){
		alert('Por favor preencha o campo CPF.');
		cpf.focus();
		return false;
	} else if (cargos_id.value == '-' ){
		alert('Por favor selecione o cargo.');
		cargos_id.focus();
		return false;
	} else if (fone.value == '' ){
		alert('Por favor informe o telefone.');
		fone.focus();
		return false;
	} else if (rg.value == '' ){
		alert('Por favor preencha o campo Identidade.');
		rg.focus();
		return false;
	} else if (tipoIdentidade.value	== '-' ){
		alert('Por favor selecione o Tipo de Documento.');
		tipoIdentidade.focus();
		return false;
	} else if (data_nascimento.value == '' ){
		alert('Por favor preencha a Data de Nascimento.');
		data_nascimento.focus();
		return false;
	} else if (escolaridade.value == '-' ){
		alert('Por favor selecione a Escolaridade.');
		escolaridade.focus();
		return false;
	} else if (endereco.value == '' ){
		alert('Por favor preencha o campo Endereço.');
		endereco.focus();
		return false;
	} else if (cidade.value == '' ){
		alert('Por favor selecione a Cidade.');
		cidade.focus();
		return false;
	} else if (estado.value == '-' ){
		alert('Por favor selecione o Estado.');
		estado.focus();
		return false;	
	} else if (cep.value == '' ){
		alert('Por favor selecione o Cep.');
		estado.focus();
		return false;	
	} else if (!verifica.checked) {
		alert('Você deve declarar que as informações são verdadeiras.');
		estado.focus();
		return false;	
	} else if (cid.value == '' ){
		alert('Especificação do CID é obrigatoria.');
		estado.focus();
		return false;	
	} else if (contato_nome1.value == '' ){
		alert('Informe o nome do contato.');
		contato_nome1.focus();
		return false;
	} else if (contato_nome2.value == '' ){
		alert('Informe o nome do contato.');
		contato_nome2.focus();
		return false;
	} else if (contato_fone1 == '' ){
		alert('Informe o telefone do contato.');
		contato_fone1.focus();
		return false;
	} else if (contato_fone2.value == '' ){
		alert('Informe o telefone do contato.');
		contato_fone2.focus();
		return false;
	} else if (ecivil.value == '-' ){
		alert('Por favor selecione o Estado Civil.');
		estado.focus();
		return false;	
	} else if (data_nascimento.value.length < 10){
		alert('A data de Nascimento deve ser no formato dd/mm/aaaa.');
		data_nascimento.focus();
		return false;		
	} else {
		document.getElementById('botao').value = 'Aguarde...';
		document.getElementById('botao').disabled = true;
		xhSend('bd.altera.candidato.php','cad',alteraFimCadastroGo);
	}
}

function alteraFimCadastroGo() {
	if(xhReq.readyState==4)
	{
		var retorno = xhReq.responseXML;
		var id 		= retorno.getElementsByTagName('id')[0].firstChild.nodeValue;
		var insc 	= retorno.getElementsByTagName('inscricao')[0].firstChild.nodeValue;
		var nome 	= retorno.getElementsByTagName('nome')[0].firstChild.nodeValue;
		var cpf 	= retorno.getElementsByTagName('cpf')[0].firstChild.nodeValue;
		var dia 	= retorno.getElementsByTagName('dia')[0].firstChild.nodeValue;
		var valor 	= retorno.getElementsByTagName('valor')[0].firstChild.nodeValue;
		var cargo 	= retorno.getElementsByTagName('cargo')[0].firstChild.nodeValue;

		if (id != null)
		{
			//id = id.nodeValue;
			cargo = cargo.nodeValue;
			
			//window.location.replace ('../boleto/boleto_itau.php?cargos_id='+cargo+'&inscricao='+insc.nodeValue+'&bo='+id);
			//if (!urlBoleto)
			urlBoleto = 'http://www.sefaz.go.gov.br/netaccess/dare/goref/EmitDoc.asp?doc_origem='+id+'&cpf_cnpj='+cpf+'&razao_social='+nome+'&endereco=&municipio=&data_venc='+dia+'&data_pgto='+dia+'&valor_total=&info=&servico=16&codg_orgao=3051&valor_Original='+valor+'&valor_Multa=&valor_Juros=&valor_Atualiz=&Numr_parc=&Uf=GO&Desc_municipio=GOIANIA';
				window.location.replace(urlBoleto);

		}

	}
}


//cadastro bahia


function alteraCadastroBahia()
{
	var cargos_id		= document.getElementById('cargos_id');
	var nome			= document.getElementById('nome');
	var nomeMae			= document.getElementById('nomeMae');
	var cpf				= document.getElementById('cpf');
	var rg				= document.getElementById('rg');
	var fone			= document.getElementById('fone');
	var tipoIdentidade	= document.getElementById('tipoIdentidade');
	var data_nascimento	= document.getElementById('data_nascimento');
	var sexo			= document.getElementById('sexo');
	var ecivil			= document.getElementById('ecivil');
	var escolaridade	= document.getElementById('escolaridade');
	var experiencia		= document.getElementById('experiencia');
	var endereco		= document.getElementById('endereco');
	var cidade			= document.getElementById('cidade');
	var estado			= document.getElementById('estado');
	var celular			= document.getElementById('celular');
	var email			= document.getElementById('email');
	var nacionalidade	= document.getElementById('nacionalidade');
	var deficiencia		= document.getElementById('deficiencia');
	var ativo			= document.getElementById('ativo');
	var id				= document.getElementById('id');
	var usuarios_id		= document.getElementById('usuarios_id');
	var cep				= document.getElementById('cep');
	var verifica		= document.getElementById('verifica');
	var data_inscricao	= document.getElementById('data_inscricao');
	var cid				= document.getElementById('cid');
	var obs_deficiencia	= document.getElementById('obs_deficiencia');
	var localidade_id	= document.getElementById('localidade_id');
	var local_prova		= document.getElementById('local_prova');
	var contato_nome1	= document.getElementById('contato_nome1');
	var contato_fone1	= document.getElementById('contato_fone1');
	var contato_nome2	= document.getElementById('contato_nome2');
	var contato_fone2	= document.getElementById('contato_fone2');
	var turno       	= document.getElementById('turno');
	
	//verificação do cpf
	var i;
 	s = document.cad.cpf.value;
	var c = s.substr(0,9);
	var dv = s.substr(9,2);
	var d1 = 0;
	var v = 0;
	
	for (i = 0; i < 9; i++)
	{
		d1 += c.charAt(i)*(10-i);
	}
	if (d1 == 0){
 		v = 1;	
	}
 	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(0) != d1)
	{
 		v = 1;
	}
	d1 *= 2;
	for (i = 0; i < 9; i++)
	{
		d1 += c.charAt(i)*(11-i);
	}
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(1) != d1)
	{
		v = 1;	
	}
	
	
	if (nome.value == '' ){
		alert('Por favor preencha o campo Nome.');
		nome.focus();
		return false;
	} else if (localidade_id.value == '-' ){
		alert('Por favor preencha o campo Localidade.');
		nome.focus();
		return false;
	} else if (turno.value == '-' ){
		alert('Por favor preencha o campo Turno.');
		turno.focus();
		return false;
	} else if (local_prova.value == '-' ){
		alert('Por favor preencha o campo Local Prova.');
		local_prova.focus();
		return false;
	} else if (cpf.value == '' ){
		alert('Por favor preencha o campo CPF.');
		cpf.focus();
		return false;
	} else if (cargos_id.value == '-' ){
		alert('Por favor selecione o cargo.');
		cargos_id.focus();
		return false;
	} else if (fone.value == '' ){
		alert('Por favor informe o telefone.');
		fone.focus();
		return false;
	} else if (rg.value == '' ){
		alert('Por favor preencha o campo Identidade.');
		rg.focus();
		return false;
	} else if (tipoIdentidade.value	== '-' ){
		alert('Por favor selecione o Tipo de Documento.');
		tipoIdentidade.focus();
		return false;
	} else if (data_nascimento.value == '' ){
		alert('Por favor preencha a Data de Nascimento.');
		data_nascimento.focus();
		return false;
	} else if (escolaridade.value == '-' ){
		alert('Por favor selecione a Escolaridade.');
		escolaridade.focus();
		return false;
	} else if (endereco.value == '' ){
		alert('Por favor preencha o campo Endereço.');
		endereco.focus();
		return false;
	} else if (cidade.value == '' ){
		alert('Por favor selecione a Cidade.');
		cidade.focus();
		return false;
	} else if (estado.value == '-' ){
		alert('Por favor selecione o Estado.');
		estado.focus();
		return false;	
	} else if (cep.value == '' ){
		alert('Por favor selecione o Cep.');
		estado.focus();
		return false;	
	} else if (!verifica.checked) {
		alert('Você deve declarar que as informações são verdadeiras.');
		estado.focus();
		return false;	
	} else if (cid.value == '' ){
		alert('Especificação do CID é obrigatoria.');
		estado.focus();
		return false;	
	} else if (contato_nome1.value == '' ){
		alert('Informe o nome do contato.');
		contato_nome1.focus();
		return false;
	} else if (contato_nome2.value == '' ){
		alert('Informe o nome do contato.');
		contato_nome2.focus();
		return false;
	} else if (contato_fone1 == '' ){
		alert('Informe o telefone do contato.');
		contato_fone1.focus();
		return false;
	} else if (contato_fone2.value == '' ){
		alert('Informe o telefone do contato.');
		contato_fone2.focus();
		return false;
	} else if (ecivil.value == '-' ){
		alert('Por favor selecione o Estado Civil.');
		estado.focus();
		return false;	
	} else if (data_nascimento.value.length < 10){
		alert('A data de Nascimento deve ser no formato dd/mm/aaaa.');
		data_nascimento.focus();
		return false;		
	} else {
		document.getElementById('botao').value = 'Aguarde...';
		document.getElementById('botao').disabled = true;
		xhSend('bd.altera.candidato.php','cad',alteraFimCadastroBahia);
	}
}



function alteraCadastroCaixa()
{
	var cargos_id		= document.getElementById('cargos_id');
	var nome			= document.getElementById('nome');
	var nomeMae			= document.getElementById('nomeMae');
	var cpf				= document.getElementById('cpf');
	var rg				= document.getElementById('rg');
	var fone			= document.getElementById('fone');
	var tipoIdentidade	= document.getElementById('tipoIdentidade');
	var data_nascimento	= document.getElementById('data_nascimento');
	var sexo			= document.getElementById('sexo');
	var ecivil			= document.getElementById('ecivil');
	var escolaridade	= document.getElementById('escolaridade');
	var experiencia		= document.getElementById('experiencia');
	var endereco		= document.getElementById('endereco');
	var cidade			= document.getElementById('cidade');
	var estado			= document.getElementById('estado');
	var celular			= document.getElementById('celular');
	var email			= document.getElementById('email');
	var nacionalidade	= document.getElementById('nacionalidade');
	var deficiencia		= document.getElementById('deficiencia');
	var ativo			= document.getElementById('ativo');
	var id				= document.getElementById('id');
	var usuarios_id		= document.getElementById('usuarios_id');
	var cep				= document.getElementById('cep');
	var verifica		= document.getElementById('verifica');
	var data_inscricao	= document.getElementById('data_inscricao');
	var cid				= document.getElementById('cid');
	var obs_deficiencia	= document.getElementById('obs_deficiencia');
	var localidade_id	= document.getElementById('localidade_id');
	var local_prova	= document.getElementById('local_prova');

	//verificação do cpf
	var i;
 	s = document.cad.cpf.value;
	var c = s.substr(0,9);
	var dv = s.substr(9,2);
	var d1 = 0;
	var v = 0;
	
	for (i = 0; i < 9; i++)
	{
		d1 += c.charAt(i)*(10-i);
	}
	if (d1 == 0){
 		v = 1;	
	}
 	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(0) != d1)
	{
 		v = 1;
	}
	d1 *= 2;
	for (i = 0; i < 9; i++)
	{
		d1 += c.charAt(i)*(11-i);
	}
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(1) != d1)
	{
		v = 1;	
	}
	
	
	if (nome.value == '' ){
		alert('Por favor preencha o campo Nome.');
		nome.focus();
		return false;
	} else if (localidade_id.value == '-' ){
		alert('Por favor preencha o campo Localidade.');
		nome.focus();
		return false;
	} else if (local_prova.value == '-' ){
		alert('Por favor preencha o campo Local Prova.');
		local_prova.focus();
		return false;
	} else if (cpf.value == '' ){
		alert('Por favor preencha o campo CPF.');
		cpf.focus();
		return false;
	} else if (cargos_id.value == '-' ){
		alert('Por favor selecione o cargo.');
		cargos_id.focus();
		return false;
	} else if (fone.value == '' ){
		alert('Por favor informe o telefone.');
		fone.focus();
		return false;
	} else if (rg.value == '' ){
		alert('Por favor preencha o campo Identidade.');
		rg.focus();
		return false;
	} else if (tipoIdentidade.value	== '-' ){
		alert('Por favor selecione o Tipo de Documento.');
		tipoIdentidade.focus();
		return false;
	} else if (data_nascimento.value == '' ){
		alert('Por favor preencha a Data de Nascimento.');
		data_nascimento.focus();
		return false;
	} else if (escolaridade.value == '-' ){
		alert('Por favor selecione a Escolaridade.');
		escolaridade.focus();
		return false;
	} else if (endereco.value == '' ){
		alert('Por favor preencha o campo Endereço.');
		endereco.focus();
		return false;
	} else if (cidade.value == '' ){
		alert('Por favor selecione a Cidade.');
		cidade.focus();
		return false;
	} else if (estado.value == '-' ){
		alert('Por favor selecione o Estado.');
		estado.focus();
		return false;	
	} else if (cep.value == '' ){
		alert('Por favor selecione o Cep.');
		estado.focus();
		return false;	
	} else if (!verifica.checked){
		alert('Você deve declarar que as informações são verdadeiras.');
		estado.focus();
		return false;	
	} else if (cid.value == '' ){
		alert('Especificação do CID é obrigatoria.');
		estado.focus();
		return false;	
	} else if (ecivil.value == '-' ){
		alert('Por favor selecione o Estado Civil.');
		estado.focus();
		return false;	
	} else if (data_nascimento.value.length < 10){
		alert('A data de Nascimento deve ser no formato dd/mm/aaaa.');
		data_nascimento.focus();
		return false;		
	} else {
		document.getElementById('botao').value = 'Aguarde...';
		document.getElementById('botao').disabled = true;
		xhSend('bd.altera.candidato.php','cad',alteraFimCadastroCaixa);
	}
}


function alteraCadastroNatal()
{
	var cargos_id		= document.getElementById('cargos_id');
	var nome			= document.getElementById('nome');
	var nomeMae			= document.getElementById('nomeMae');
	var cpf				= document.getElementById('cpf');
	var rg				= document.getElementById('rg');
	var fone			= document.getElementById('fone');
	var tipoIdentidade	= document.getElementById('tipoIdentidade');
	var data_nascimento	= document.getElementById('data_nascimento');
	var sexo			= document.getElementById('sexo');
	var ecivil			= document.getElementById('ecivil');
	var escolaridade	= document.getElementById('escolaridade');
	var experiencia		= document.getElementById('experiencia');
	var endereco		= document.getElementById('endereco');
	var cidade			= document.getElementById('cidade');
	var estado			= document.getElementById('estado');
	var celular			= document.getElementById('celular');
	var email			= document.getElementById('email');
	var nacionalidade	= document.getElementById('nacionalidade');
	var deficiencia		= document.getElementById('deficiencia');
	var ativo			= document.getElementById('ativo');
	var id				= document.getElementById('id');
	var usuarios_id		= document.getElementById('usuarios_id');
	var cep				= document.getElementById('cep');
	var verifica		= document.getElementById('verifica');
	var data_inscricao	= document.getElementById('data_inscricao');
	var cid				= document.getElementById('cid');
	var obs_deficiencia	= document.getElementById('obs_deficiencia');
	var localidade_id	= document.getElementById('localidade_id');
	var local_prova	= document.getElementById('local_prova');

	//verificação do cpf
	var i;
 	s = document.cad.cpf.value;
	var c = s.substr(0,9);
	var dv = s.substr(9,2);
	var d1 = 0;
	var v = 0;
	
	for (i = 0; i < 9; i++)
	{
		d1 += c.charAt(i)*(10-i);
	}
	if (d1 == 0){
 		v = 1;	
	}
 	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(0) != d1)
	{
 		v = 1;
	}
	d1 *= 2;
	for (i = 0; i < 9; i++)
	{
		d1 += c.charAt(i)*(11-i);
	}
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(1) != d1)
	{
		v = 1;	
	}
	
	
	if (nome.value == '' ){
		alert('Por favor preencha o campo Nome.');
		nome.focus();
		return false;
	} else if (localidade_id.value == '-' ){
		alert('Por favor preencha o campo Localidade.');
		nome.focus();
		return false;
	} else if (local_prova.value == '-' ){
		alert('Por favor preencha o campo Local Prova.');
		local_prova.focus();
		return false;
	} else if (cpf.value == '' ){
		alert('Por favor preencha o campo CPF.');
		cpf.focus();
		return false;
	} else if (cargos_id.value == '-' ){
		alert('Por favor selecione o cargo.');
		cargos_id.focus();
		return false;
	} else if (fone.value == '' ){
		alert('Por favor informe o telefone.');
		fone.focus();
		return false;
	} else if (rg.value == '' ){
		alert('Por favor preencha o campo Identidade.');
		rg.focus();
		return false;
	} else if (tipoIdentidade.value	== '-' ){
		alert('Por favor selecione o Tipo de Documento.');
		tipoIdentidade.focus();
		return false;
	} else if (data_nascimento.value == '' ){
		alert('Por favor preencha a Data de Nascimento.');
		data_nascimento.focus();
		return false;
	} else if (escolaridade.value == '-' ){
		alert('Por favor selecione a Escolaridade.');
		escolaridade.focus();
		return false;
	} else if (endereco.value == '' ){
		alert('Por favor preencha o campo Endereço.');
		endereco.focus();
		return false;
	} else if (cidade.value == '' ){
		alert('Por favor selecione a Cidade.');
		cidade.focus();
		return false;
	} else if (estado.value == '-' ){
		alert('Por favor selecione o Estado.');
		estado.focus();
		return false;	
	} else if (cep.value == '' ){
		alert('Por favor selecione o Cep.');
		estado.focus();
		return false;	
	} else if (!verifica.checked){
		alert('Você deve declarar que as informações são verdadeiras.');
		estado.focus();
		return false;	
	} else if (cid.value == '' ){
		alert('Especificação do CID é obrigatoria.');
		estado.focus();
		return false;	
	} else if (ecivil.value == '-' ){
		alert('Por favor selecione o Estado Civil.');
		estado.focus();
		return false;	
	} else if (data_nascimento.value.length < 10){
		alert('A data de Nascimento deve ser no formato dd/mm/aaaa.');
		data_nascimento.focus();
		return false;		
	} else {
		document.getElementById('botao').value = 'Aguarde...';
		document.getElementById('botao').disabled = true;
		xhSend('bd.altera.candidato.php','cad',alteraFimCadastroNatal);
	}
}

function alteraCadastroSuperior()
{
	var cargos_id		= document.getElementById('cargos_id');
	var nome			= document.getElementById('nome');
	var nomeMae			= document.getElementById('nomeMae');
	var cpf				= document.getElementById('cpf');
	var rg				= document.getElementById('rg');
	var fone			= document.getElementById('fone');
	var tipoIdentidade	= document.getElementById('tipoIdentidade');
	var data_nascimento	= document.getElementById('data_nascimento');
	var sexo			= document.getElementById('sexo');
	var ecivil			= document.getElementById('ecivil');
	var escolaridade	= document.getElementById('escolaridade');
	var experiencia		= document.getElementById('experiencia');
	var endereco		= document.getElementById('endereco');
	var cidade			= document.getElementById('cidade');
	var estado			= document.getElementById('estado');
	var celular			= document.getElementById('celular');
	var email			= document.getElementById('email');
	var nacionalidade	= document.getElementById('nacionalidade');
	var deficiencia		= document.getElementById('deficiencia');
	var ativo			= document.getElementById('ativo');
	var id				= document.getElementById('id');
	var usuarios_id		= document.getElementById('usuarios_id');
	var cep				= document.getElementById('cep');
	var verifica		= document.getElementById('verifica');
	var data_inscricao	= document.getElementById('data_inscricao');
	var cid				= document.getElementById('cid');
	var obs_deficiencia	= document.getElementById('obs_deficiencia');
	var localidade_id	= document.getElementById('localidade_id');
	var local_prova		= document.getElementById('local_prova');
	var contato_nome1	= document.getElementById('contato_nome1');
	var contato_fone1	= document.getElementById('contato_fone1');
	var contato_nome2	= document.getElementById('contato_nome2');
	var contato_fone2	= document.getElementById('contato_fone2');
	
	var universidade	= document.getElementById('universidade');
	var curso			= document.getElementById('curso');
	var semestre		= document.getElementById('semestre');
	var matricula		= document.getElementById('matricula');
	
	
	//verificação do cpf
	var i;
 	s = document.cad.cpf.value;
	var c = s.substr(0,9);
	var dv = s.substr(9,2);
	var d1 = 0;
	var v = 0;
	
	for (i = 0; i < 9; i++)
	{
		d1 += c.charAt(i)*(10-i);
	}
	if (d1 == 0){
 		v = 1;	
	}
 	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(0) != d1)
	{
 		v = 1;
	}
	d1 *= 2;
	for (i = 0; i < 9; i++)
	{
		d1 += c.charAt(i)*(11-i);
	}
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(1) != d1)
	{
		v = 1;	
	}
	
	if (nome.value == '' ){
		alert('Por favor preencha o campo Nome.');
		nome.focus();
		return false;
	} else if (cpf.value == '' ){
		alert('Por favor preencha o campo CPF.');
		cpf.focus();
		return false;
	} else if (fone.value == '' ){
		alert('Por favor informe o telefone.');
		fone.focus();
		return false;
	} else if (rg.value == '' ){
		alert('Por favor preencha o campo Identidade.');
		rg.focus();
		return false;
	} else if (tipoIdentidade.value	== '-' ){
		alert('Por favor selecione o Tipo de Documento.');
		tipoIdentidade.focus();
		return false;
	} else if (data_nascimento.value == '' ){
		alert('Por favor preencha a Data de Nascimento.');
		data_nascimento.focus();
		return false;
	} else if (escolaridade.value == '-' ){
		alert('Por favor selecione a Escolaridade.');
		escolaridade.focus();
		return false;
	} else if (endereco.value == '' ){
		alert('Por favor preencha o campo Endereço.');
		endereco.focus();
		return false;
	} else if (cidade.value == '' ){
		alert('Por favor selecione a Cidade.');
		cidade.focus();
		return false;
	} else if (estado.value == '-' ){
		alert('Por favor selecione o Estado.');
		estado.focus();
		return false;	
	} else if (cep.value == '' ){
		alert('Por favor selecione o Cep.');
		estado.focus();
		return false;	
	} else if (!verifica.checked){
		alert('Você deve declarar que as informações são verdadeiras.');
		estado.focus();
		return false;	
	} else if (cid.value == '' ){
		alert('Especificação do CID é obrigatoria.');
		estado.focus();
		return false;	
	} else if (contato_nome1.value == '' ){
		alert('Informe o nome do contato.');
		contato_nome1.focus();
		return false;
	} else if (contato_nome2.value == '' ){
		alert('Informe o nome do contato.');
		contato_nome2.focus();
		return false;
	} else if (contato_fone1 == '' ){
		alert('Informe o telefone do contato.');
		contato_fone1.focus();
		return false;
	} else if (contato_fone2.value == '' ){
		alert('Informe o telefone do contato.');
		contato_fone2.focus();
		return false;
	} else if (ecivil.value == '-' ){
		alert('Por favor selecione o Estado Civil.');
		estado.focus();
		return false;	
	} else if (data_nascimento.value.length < 10){
		alert('A data de Nascimento deve ser no formato dd/mm/aaaa.');
		data_nascimento.focus();
		return false;
	} else if (!universidade.value){
		alert('Informe a universidade.');
		universidade.focus();
		return false;
	} else if (!curso.value){
		alert('Informe o curso.');
		curso.focus();
		return false;
	} else if (semestre.value == ""){
		alert('Informe o semestre.');
		semestre.focus();
		return false;
	} else if (matricula.value == ""){
		alert('Informe o número de matrícula.');
		matricula.focus();
		return false;
	} else {
		document.getElementById('botao').value = 'Aguarde...';
		document.getElementById('botao').disabled = true;
		xhSend('bd.altera.candidato.superior.php','cad',alteraFimCadastroSuperior);
	}
}

function verificaRadio(obj)
	{
	for(var i = 0; i < obj.length; i++)
	if (obj[i].checked)  return obj[i].value;
	}

function ImprimiBoletoBB_retorno() {
	if(xhReq.readyState==4)
	{
		var retorno = xhReq.responseXML;
		var id 		= retorno.getElementsByTagName('id')[0].firstChild;
		var insc 	= retorno.getElementsByTagName('inscricao')[0].firstChild;
		var cargo 	= retorno.getElementsByTagName('cargo')[0].firstChild;

		if (id != null)
		{
			id = id.nodeValue;
			cargo = cargo.nodeValue;

			window.location.replace ('../boleto/boleto_bb_caucaia.php?cargos_id='+cargo+'&inscricao='+insc.nodeValue+'&bo='+id);

		}

	}
}

var urlBoleto;
function alteraFimCadastro() {
	if(xhReq.readyState==4)
	{
		var retorno = xhReq.responseXML;
		var id 		= retorno.getElementsByTagName('id')[0].firstChild;
		var insc 	= retorno.getElementsByTagName('inscricao')[0].firstChild;
		var cargo 	= retorno.getElementsByTagName('cargo')[0].firstChild;

		if (id != null)
		{
			id = id.nodeValue;
			cargo = cargo.nodeValue;

			//window.location.replace ('../boleto/boleto_itau.php?cargos_id='+cargo+'&inscricao='+insc.nodeValue+'&bo='+id);
			if (!urlBoleto)
				urlBoleto = '../boleto/boleto_itau.php';
			window.location.replace (urlBoleto+'?cargos_id='+cargo+'&inscricao='+insc.nodeValue+'&bo='+id);

		}

	}
}
function alteraFimCadastroBahia() {

	if(xhReq.readyState==4)
	{	
		var retorno 	= xhReq.responseXML;
		var id 			= retorno.getElementsByTagName('id')[0].firstChild;
		var insc 		= retorno.getElementsByTagName('inscricao')[0].firstChild;
		var cargo 		= retorno.getElementsByTagName('cargo')[0].firstChild;
		var cad_unico	= retorno.getElementsByTagName('cad_unico')[0].firstChild;
		//var nome 		= unescape(retorno.getElementsByTagName('nome')[0].firstChild);
		var cpf 		= retorno.getElementsByTagName('cpf')[0].firstChild;
		var telefone 	= retorno.getElementsByTagName('telefone')[0].firstChild;

		if (id != null)
		{
			id = id.nodeValue;
			cargo = cargo.nodeValue;
			if (cad_unico.nodeValue == "nenhum"){
				window.location.replace ('../boleto/boleto_bb_bahia.php?cargos_id='+cargo+'&inscricao='+insc.nodeValue+'&bo='+id);	
			}else{
				window.location.replace ('../recibo/index.php?telefone='+telefone.nodeValue+'&cpf='+cpf.nodeValue+'&nome='+nome.nodeValue+'&cargos_id='+cargo+'&inscricao='+insc.nodeValue+'&bo='+id+'&cad_unico='+cad_unico.nodeValue);
			}			

		}

	}
}

function alteraFimCadastroCaixa() {
	if(xhReq.readyState==4)
	{
		var retorno = xhReq.responseXML;
		var id 		= retorno.getElementsByTagName('id')[0].firstChild;
		var insc 	= retorno.getElementsByTagName('inscricao')[0].firstChild;
		var cargo 	= retorno.getElementsByTagName('cargo')[0].firstChild;
		
		if (id != null)
		{
			id = id.nodeValue;
			cargo = cargo.nodeValue;

			window.location.replace ('../boleto/boleto_caixa.php?cargos_id='+cargo+'&inscricao='+insc.nodeValue+'&bo='+id);

		}

	}
}


function alteraFimCadastroNatal() {
	if(xhReq.readyState==4)
	{
		var retorno = xhReq.responseXML;
		var id 		= retorno.getElementsByTagName('id')[0].firstChild;
		var insc 	= retorno.getElementsByTagName('inscricao')[0].firstChild;
		var cargo 	= retorno.getElementsByTagName('cargo')[0].firstChild;
		
		if (id != null)
		{
			id = id.nodeValue;
			cargo = cargo.nodeValue;
			
			window.location.replace ('../boleto/boleto_caixa_natal.php?cargos_id='+cargo+'&inscricao='+insc.nodeValue+'&bo='+id);
			
		}
		
	}
}

function alteraFimCadastroSuperior() {
	if(xhReq.readyState==4)
	{
		var retorno  = xhReq.responseXML;
		var id 		 = retorno.getElementsByTagName('id')[0].firstChild;
		var concurso = retorno.getElementsByTagName('concurso')[0].firstChild;

		if (id != null)
		{
			id 			= id.nodeValue;
			concurso 	= concurso.nodeValue;

			window.location.replace ('comprovante_completo.php?concurso='+concurso+'&id='+id);
		}

	}
}

function alteraCadastroTST()
{
	var cargos_id		= document.getElementById('cargos_id');
	var nome			= document.getElementById('nome');
	var nomeMae			= document.getElementById('nomeMae');
	var naturalidade	= document.getElementById('naturalidade');
	var estado_nasc		= document.getElementById('estado_nasc');
	var cpf				= document.getElementById('cpf');
	var rg				= document.getElementById('rg');
	var fone			= document.getElementById('fone');
	var tipoIdentidade	= document.getElementById('tipoIdentidade');
	var data_nascimento	= document.getElementById('data_nascimento');
	var sexo			= document.getElementById('sexo');
	var ecivil			= document.getElementById('ecivil');
	var escolaridade	= document.getElementById('escolaridade');
	var experiencia		= document.getElementById('experiencia');
	var endereco		= document.getElementById('endereco');
	var cidade			= document.getElementById('cidade');
	var estado			= document.getElementById('estado');
	var celular			= document.getElementById('celular');
	var email			= document.getElementById('email');
	var nacionalidade	= document.getElementById('nacionalidade');
	var deficiencia		= document.getElementById('deficiencia');
	var ativo			= document.getElementById('ativo');
	var id				= document.getElementById('id');
	var usuarios_id		= document.getElementById('usuarios_id');
	var cep				= document.getElementById('cep');
	var verifica		= document.getElementById('verifica');
	var data_inscricao	= document.getElementById('data_inscricao');
	var cid				= document.getElementById('cid');
	var obs_deficiencia	= document.getElementById('obs_deficiencia');
	var localidade_id	= document.getElementById('localidade_id');
	var local_prova		= document.getElementById('local_prova');
	var contato_nome1	= document.getElementById('contato_nome1');
	var contato_fone1	= document.getElementById('contato_fone1');
	var contato_nome2	= document.getElementById('contato_nome2');
	var contato_fone2	= document.getElementById('contato_fone2');
	
	var universidade	= document.getElementById('universidade');
	var curso			= document.getElementById('curso');
	var semestre		= document.getElementById('semestre');
	var matricula		= document.getElementById('matricula');
	
	var condicao_1		= document.getElementById('condicao_1');
	var especificar		= document.getElementById('especificar');
	
	var nome_referencia_1 		= document.getElementById('nome_referencia_1');
	var profissao_referencia_1	= document.getElementById('profissao_referencia_1');
	var endereco_referencia_1	= document.getElementById('endereco_referencia_1');
	var cidade_referencia_1		= document.getElementById('cidade_referencia_1');
	var telefone_referencia_1	= document.getElementById('telefone_referencia_1');
	
	var orgao_trabalho_1		= document.getElementById('orgao_trabalho_1');
	var funcao_trabalho_1		= document.getElementById('funcao_trabalho_1');
	var periodo_trabalho_ini_1	= document.getElementById('periodo_trabalho_fim_1');
	var periodo_trabalho_fim_1	= document.getElementById('periodo_trabalho_fim_1');
	var endereco_trabalho_1		= document.getElementById('endereco_trabalho_1');
	var cidade_trabalho_1		= document.getElementById('cidade_trabalho_1');
	var telefone_trabalho_1		= document.getElementById('telefone_trabalho_1');

	//verificação do cpf
	var i;
 	s = document.cad.cpf.value;
	var c = s.substr(0,9);
	var dv = s.substr(9,2);
	var d1 = 0;
	var v = 0;
	
	for (i = 0; i < 9; i++)
	{
		d1 += c.charAt(i)*(10-i);
	}
	if (d1 == 0){
 		v = 1;	
	}
 	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(0) != d1)
	{
 		v = 1;
	}
	d1 *= 2;
	for (i = 0; i < 9; i++)
	{
		d1 += c.charAt(i)*(11-i);
	}
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(1) != d1)
	{
		v = 1;	
	}
	
	
	if (nome.value == '' ){
		alert('Por favor preencha o campo Nome.');
		nome.focus();
		return false;
	} else if (nomeMae.value == '' ){
		alert('Por favor preencha o campo Filiação.');
		nomeMae.focus();
		return false;
	} else if (data_nascimento.value == '' ){
		alert('Por favor preencha a Data de Nascimento.');
		data_nascimento.focus();
		return false;
	} else if (data_nascimento.value.length < 10){
		alert('A data de Nascimento deve ser no formato dd/mm/aaaa.');
		data_nascimento.focus();
		return false;		
	} else if (cpf.value == '' ){
		alert('Por favor preencha o campo CPF.');
		cpf.focus();
		return false;
	} else if (naturalidade.value == '' ){
		alert('Por favor preencha o campo Naturalidade.');
		naturalidade.focus();
		return false;
	} else if (estado_nasc.value == '' ){
		alert('Por favor preencha o campo UF de nascimento.');
		estado_nasc.focus();
		return false;
	} else if (ecivil.value == '-' ){
		alert('Por favor selecione o Estado Civil.');
		ecivil.focus();
		return false;	
	} else if (sexo.value == '-' ){
		alert('Por favor selecione o Sexo.');
		sexo.focus();
		return false;	
	} else if (fone.value == '' ){
		alert('Por favor informe o telefone.');
		fone.focus();
		return false;
	} else if (rg.value == '' ){
		alert('Por favor preencha o campo Identidade.');
		rg.focus();
		return false;
	} else if (endereco.value == '' ){
		alert('Por favor preencha o campo Endereço.');
		endereco.focus();
		return false;
	} else if (cidade.value == '' ){
		alert('Por favor selecione a Cidade.');
		cidade.focus();
		return false;
	} else if (estado.value == '-' ){
		alert('Por favor selecione o Estado.');
		estado.focus();
		return false;	
	} else if (cep.value == '' ){
		alert('Por favor selecione o Cep.');
		cep.focus();
		return false;	
	} else if ((condicao_1.checked==true) && (especificar.value=='')) {
		alert('Você deve especificar a condição especial.');
		especificar.focus();
		return false;			
	} else if (!verifica.checked){
		alert('Você deve declarar que as informações são verdadeiras.');
		verifica.focus();
		return false;
	} else {
		document.getElementById('botao').value = 'Aguarde...';
		document.getElementById('botao').disabled = true;
		xhSend('bd.altera.candidato.TST.php','cad',alteraFimCadastroTST);
	}
}


function alteraFimCadastroTST() {

	document.getElementById('botao').value = 'Imprimir Comprovante';
	document.getElementById('botao').disabled = false;

	if(xhReq.readyState==4)
	{
		var retorno  = xhReq.responseXML;
		var id 		 = retorno.getElementsByTagName('id')[0].firstChild;
		var concurso = retorno.getElementsByTagName('concurso')[0].firstChild;

		if (id != null)
		{
			id 			= id.nodeValue;
			concurso 	= concurso.nodeValue;

			window.location.replace ('comprovante_completoTST.php?concurso='+concurso+'&id='+id);
		}

	}
}


/* Seleção do Cargo */

var cargo;

function listaCargos(id,selecionado) {
	cargo = selecionado;
	listBox = document.getElementById('cargos_id');
	if (id > 0) {
		listBox.options[0].text = 'Aguarde...';
		listBox.disabled = true;
		executar('modulos/cartoes/bd.get.cargos.php','id='+id,listaCargosReturn);
	}
	else {
		document.getElementById('inscricao').value = '';
		limparCombo(listBox,1);
		listBox.options[0].text = 'Selecione uma opção...';
		listBox.disabled = true;
		listaLocaisProva(0,0);
		listaLocaisVagas(0,0);
	}
}

function listaLocalidadeCadastro(id,selecionado) {
	localidade = selecionado;
	listBox = document.getElementById('localidade_id');
	if (id > 0) {
		listBox.options[0].text = 'Aguarde...';
		listBox.disabled = true;
		executar('bd.get.localidade.php','id='+id,listaLocalidadesReturn);
	}
	else {
		document.getElementById('inscricao').value = '';
		limparCombo(listBox,1);
		listBox.options[0].text = 'Selecione uma opção...';
		listBox.disabled = true;
		listaLocaisProva(0,0);
		listaLocaisVagas(0,0);
	}
}



function listaLocalidadesReturn() {
	if (xhReq.readyState == 4) {
		listBox = document.getElementById('localidade_id');
		if (xhReq.responseXML) {
			listBox.disabled = true;
			resposta = xhReq.responseXML;
			obj = resposta.getElementsByTagName('localidade');
			limparCombo(listBox,1);
			for (i = 0; i < obj.length; i++) {
				valor = obj[i].getElementsByTagName('id')[0].firstChild.nodeValue;
				texto = unescape(obj[i].getElementsByTagName('local')[0].firstChild.nodeValue);
				
				addCombo(valor,texto,listBox);
				listBox.options[0].text = 'Selecione uma opção...';
				listBox.disabled = false;
			}
			listBox.value = localidade;
			localidade = '';
		}
		else {
			listBox.value = 0;
			listBox.options[0].text = 'Concurso sem localidade cadastrada.';
			listBox.disabled = true;
		}
	}
}



