// JavaScript Document

var reDate1 = /^\d{1,2}\/\d{1,2}\/\d{1,4}$/;
var reDate2 = /^[0-3]?\d\/[01]?\d\/(\d{2}|\d{4})$/;
var reDate3 = /^(0?[1-9]|[12]\d|3[01])\/(0?[1-9]|1[0-2])\/(19|20)?\d{2}$/;
var reDate4 = /^((0?[1-9]|[12]\d)\/(0?[1-9]|1[0-2])|30\/(0?[13-9]|1[0-2])|31\/(0?[13578]|1[02]))\/(19|20)?\d{2}$/;
var reDate5 = /^((0[1-9]|[12]\d)\/(0[1-9]|1[0-2])|30\/(0[13-9]|1[0-2])|31\/(0[13578]|1[02]))\/\d{4}$/;
var reDate = reDate4;
var testeMatricula = /^\d{9,11}$/;
var testeSenha = /^\w{6,20}$/;
//var testeAtivacao = /^\([A-Za-z]|[0-9])|([0-9]|[A-Za-z])$/;
var testeEmail = /^[\w-]+(\.[\w-]+)*@(([A-Za-z\d][A-Za-z\d-]{0,61}[A-Za-z\d]\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;
var testeCarBlock = /[&'\\\"%]/;
var testeNumero = /^\d+$/;

/*
	Consulta de Vaga
*/

function atualizarSenha() {
	// senha em branco
	document.form1.f_senha.value = Trim(document.form1.f_senha.value);		
	if ( document.form1.f_senha.value == '' ) {
		document.getElementById('l_senha').style.backgroundColor = '#FFFFCC';		
		alert("Senha em branco.");
		document.form1.f_senha.focus();
		return false;
	}
	else {
		document.getElementById('l_senha').style.backgroundColor = '#f0f0f0';
	}
	// senha menor que 6 digitos
	if ( testeSenha.test(document.form1.f_senha.value) == false ) {
		document.getElementById('l_senha').style.backgroundColor = '#FFFFCC';
		alert("Senha inválida.\nFormato: até 6-20 caracteres alfanumericos");
		document.form1.f_senha.value = '';
		document.form1.f_senha.focus();
		return false;
	}
	else {
		document.getElementById('l_senha').style.backgroundColor = '#f0f0f0';
	}
	
	// senha caracteres bloqueados
	if ( testeCarBlock.test(document.form1.f_senha.value) ) {
		document.getElementById('l_senha').style.backgroundColor = '#FFFFCC';		
		alert("Senha inválida.\nCaracteres digitados não podem ser utilizados. [& ' \\ \" %]");
		document.form1.f_senha.focus();
		return false;
	}
	else {
		document.getElementById('l_senha').style.backgroundColor = '#f0f0f0';
	}
	
	
	document.form1.f_nsenha.value = Trim(document.form1.f_nsenha.value);		
	if ( document.form1.f_nsenha.value == '' ) {
		document.getElementById('l_nsenha').style.backgroundColor = '#FFFFCC';		
		alert("Nova senha em branco.");
		document.form1.f_nsenha.focus();
		return false;
	}
	else {
		document.getElementById('l_nsenha').style.backgroundColor = '#f0f0f0';
	}
	
	if ( testeSenha.test(document.form1.f_nsenha.value) == false ) {
		document.getElementById('l_nsenha').style.backgroundColor = '#FFFFCC';
		alert("Nova senha inválida.\nFormato: até 6-20 caracteres alfanumericos");
		document.form1.f_nsenha.value = '';
		document.form1.f_nsenha.focus();
		return false;
	}
	else {
		document.getElementById('l_nsenha').style.backgroundColor = '#f0f0f0';
	}
	
	if ( testeCarBlock.test(document.form1.f_nsenha.value) ) {
		document.getElementById('l_nsenha').style.backgroundColor = '#FFFFCC';		
		alert("Nova senha inválida.\nCaracteres digitados não podem ser utilizados. [& ' \\ \" %]");
		document.form1.f_nsenha.focus();
		return false;
	}
	else {
		document.getElementById('l_nsenha').style.backgroundColor = '#f0f0f0';
	}
	

	document.form1.f_cnsenha.value = Trim(document.form1.f_cnsenha.value);		
	if ( document.form1.f_cnsenha.value == '' ) {
		document.getElementById('l_cnsenha').style.backgroundColor = '#FFFFCC';		
		alert("Confirmação de senha em branco.");
		document.form1.f_cnsenha.focus();
		return false;
	}
	else {
		document.getElementById('l_cnsenha').style.backgroundColor = '#f0f0f0';
	}
	if ( testeSenha.test(document.form1.f_cnsenha.value) == false ) {
		document.getElementById('l_cnsenha').style.backgroundColor = '#FFFFCC';
		alert("Confirmação de nova senha inválida.\nFormato: até 6-20 caracteres alfanumericos");
		document.form1.f_cnsenha.value = '';
		document.form1.f_cnsenha.focus();
		return false;
	}
	else {
		document.getElementById('l_cnsenha').style.backgroundColor = '#f0f0f0';
	}	
	
	if ( testeCarBlock.test(document.form1.f_cnsenha.value) ) {
		document.getElementById('l_cnsenha').style.backgroundColor = '#FFFFCC';		
		alert("Confirmação de senha inválida.\nCaracteres digitados não podem ser utilizados. [& ' \\ \" %]");
		document.form1.f_cnsenha.focus();
		return false;
	}
	else {
		document.getElementById('l_cnsenha').style.backgroundColor = '#f0f0f0';
	}
	
	// COMPARAR SENHA ATUAL COM NOVA SENHA
	if ( document.form1.f_senha.value == document.form1.f_nsenha.value ) {
		document.getElementById('l_nsenha').style.backgroundColor = '#FFFFCC';	
		alert("Nova senha é igual a senha anterior.\nEscolha outra senha.");
		document.form1.f_nsenha.value = '';
		document.form1.f_cnsenha.value = '';
		document.form1.f_nsenha.focus();
		return false;		
	}
	else {
		document.getElementById('l_nsenha').style.backgroundColor = '#f0f0f0';
	}

// COMPARAR SENHA ATUAL COM NOVA SENHA
	if ( document.form1.f_nsenha.value != document.form1.f_cnsenha.value ) {
		document.getElementById('l_nsenha').style.backgroundColor = '#FFFFCC';	
		alert("Nova senha não confere com a confirmação.\nDigite novamente.");
		document.form1.f_nsenha.value = '';
		document.form1.f_cnsenha.value = '';
		document.form1.f_nsenha.focus();
		return false;		
	}	
	else {
		document.getElementById('l_nsenha').style.backgroundColor = '#f0f0f0';
	}
	
	document.form1.submit();
}

function candidatarAluno() {
	if ( confirm('Você deseja ser um candidato desta vaga?') ) {
		document.form1.submit();
	}
	else {
		return false;
	}
	
}

function abrirVaga(num) {
	document.form1.idVaga.value = num;
	document.form1.target = "_blank";
	document.form1.action = "fsm_login.php?action=detalhe_vaga&chave="+num;
	document.form1.submit();
}

function atualizarListagemVaga(num) {
	document.form1.begin.value = num;
	document.form1.submit();
}

function validarBuscaVaga() {
		if ( testeCarBlock.test(document.form1.f_empresa.value) ) {
			document.getElementById('l_empresa').style.backgroundColor = '#FFFFCC';		
			alert("Empresa inválida.\nCaracteres digitados não podem ser utilizados. [& ' \\ \" %]");
			document.form1.f_empresa.focus();
			return false;
		}
		else {
			document.getElementById('l_empresa').style.backgroundColor = '#f0f0f0';
		}
		
		document.form1.f_ramo.value = Trim(document.form1.f_ramo.value);		
		if ( document.form1.f_ramo.value == '' ) {
			document.getElementById('l_ramo').style.backgroundColor = '#FFFFCC';		
			alert("Ramo de atuação em branco.");
			document.form1.f_ramo.focus();
			return false;
		}
		else {
			document.getElementById('l_ramo').style.backgroundColor = '#f0f0f0';
		}		
		
		if ( testeCarBlock.test(document.form1.f_chave.value) ) {
			document.getElementById('l_chave').style.backgroundColor = '#FFFFCC';		
			alert("Chave inválida.\nCaracteres digitados não podem ser utilizados. [& ' \\ \" %]");
			document.form1.f_chave.focus();
			return false;
		}
		else {
			document.getElementById('l_chave').style.backgroundColor = '#f0f0f0';
		}		
		
		document.form1.f_jornada.value = Trim(document.form1.f_jornada.value);
		if ( document.form1.f_jornada.value != '' && testeNumero.test(document.form1.f_jornada.value) == false ) {
			document.getElementById('l_jornada').style.backgroundColor = '#FFFFCC';		
			alert("Jornada inválida.\nApenas números são permitidos.");
			document.form1.f_jornada.focus();
			return false;
		}
		else {
			document.getElementById('l_jornada').style.backgroundColor = '#f0f0f0';
		}				
		document.form1.submit();
}

function doDate(pStr, pFmt)
{
	eval("reDate = reDate" + pFmt);
	if (!reDate.test(pStr) || pStr == "" || pStr == " ") {
		alert(pStr + " não é uma data válida.");
		document.form1.f_curric_data_nasc.value = '';
		document.form1.f_curric_data_nasc.focus();
		return false;
	}
} // doDate


  function desabilitarDataFinal() {
	  if ( document.form1.f_curric_exp_empregoAtual.checked ) {
	  	  document.getElementById('f_curric_exp_periodoF').style.background = "#999999";
		  document.getElementById('f_curric_exp_periodoF').disabled = "disabled";
	  }
	  else {
	  	  document.getElementById('f_curric_exp_periodoF').style.background = "#FFFFFF";
		  document.getElementById('f_curric_exp_periodoF').disabled = "";		  
	  }
  }

  function mascaraData(data){ 
	  var mydata = ''; 
	  mydata = mydata + data.value; 
	  if ( mydata.length >= 10 ) {
		  data.value = mydata.slice(0,10);
		  return;
	  }
	  if (mydata.length == 2){ 
		  mydata = mydata + '/';
		  data.value = mydata;
		  return;
	  } 
	  if (mydata.length == 5){ 
		  mydata = mydata + '/';
		  data.value = mydata;
		  return;
	  }	  
  } 

function doDate1(pStr, pFmt)
{
	eval("reDate = reDate" + pFmt);
	if (!reDate.test(pStr) || pStr == "" || pStr == " ") {
		return false;
	}
} // doDate

function doDate3(pStr, pFmt)
	{
	eval("reDate = reDate" + pFmt);
	if (!reDate.test(pStr) || pStr == "" || pStr == " ") {
		return false;
	}
} // doDate	

function doDate4(pStr, pFmt)
	{
	eval("reDate = reDate" + pFmt);
	if (!reDate.test(pStr) || pStr == "" || pStr == " ") {
		alert(pStr + " não é uma data válida.");
		document.form1.f_curric_exp_periodoF.value = '';
		document.form1.f_curric_exp_periodoF.focus();
		return false;
	}
} // doDate	

function validarFormAtivacao() {
	document.form1.f_ativacao.value = Trim(document.form1.f_ativacao.value);
	if ( document.form1.f_ativacao.value == '' ) {
		alert("Código de ativação em branco.");
		document.form1.f_ativacao.focus();
		return false;
	}
/*
	if ( testeAtivacao.test(document.form1.f_ativacao.value) == false ) {
		alert("Código de ativação inválido.\nFormato: apenas caracteres alfanumericos.");
		document.form1.f_ativacao.value = '';
		document.form1.f_ativacao.focus();
		return false;
	}
*/
	document.form1.submit();
}

function validarFormNovaAtivacao() {
	document.form1.f_emailA.value = Trim(document.form1.f_emailA.value);
	document.form1.f_matriculaA.value = Trim(document.form1.f_matriculaA.value);
	if ( document.form1.f_matriculaA.value == '' ) {
		alert("Matrícula em branco.");
		document.form1.f_matriculaA.focus();
		return false;
	}	
	if ( testeMatricula.test(document.form1.f_matriculaA.value) == false ) {
		alert("Matrícula inválida.\nExemplo: 200110100 [Nº MAT]");
		document.form1.f_matriculaA.value = '';
		document.form1.f_matriculaA.focus();
		return false;
	}
	if ( document.form1.f_emailA.value == '' ) {
		alert("E-mail em branco.");
		document.form1.f_emailA.focus();
		return false;
	}
	if ( testeEmail.test(document.form1.f_emailA.value) == false ) {
		alert("E-mail inválido.\nExemplo: nome@dominio");
		document.form1.f_emailA.value = '';
		document.form1.f_emailA.focus();
		return false;
	}
	document.form1.submit();
}

function validarFormNovaSenha() {
	document.form2.f_matriculaR.value = Trim(document.form2.f_matriculaR.value);
	document.form2.f_emailR.value = Trim(document.form2.f_emailR.value);
	
	if ( document.form2.f_matriculaR.value == '' ) {
		alert("Matrícula em branco.");
		document.form2.f_matriculaR.focus();
		return false;
	}	
	if ( testeMatricula.test(document.form2.f_matriculaR.value) == false ) {
		alert("Matrícula inválida.\nExemplo: 200110100 [Nº MAT]");
		document.form2.f_matriculaR.value = '';
		document.form2.f_matriculaR.focus();
		return false;
	}
	if ( document.form2.f_emailR.value == '' ) {
		alert("E-mail em branco.");
		document.form2.f_emailR.focus();
		return false;
	}
	if ( testeEmail.test(document.form2.f_emailR.value) == false ) {
		alert("E-mail inválido.\nExemplo: nome@dominio");
		document.form2.f_emailR.value = '';
		document.form2.f_emailR.focus();
		return false;
	}
	document.form2.submit();
}

function validarEnter(evt) {
		evt = (evt) ? evt : event;
		var c = (evt.which) ? evt.which : evt.keyCode;
		if (c == 13) {
			validarFormAutenticacao();
			return false;
		}
		else {
			return true;
		}
}

function validarFormAutenticacao() {
	if ( document.form1.f_login.value == '' ) {
		alert("Login em branco.");
		document.form1.f_login.focus();
		return false;
	}
	if ( testeMatricula.test(document.form1.f_login.value) == false ) {
		alert("Login inválido.\nExemplo: 200110100 [Nº MAT]");
		document.form1.f_login.value = '';
		document.form1.f_login.focus();
		return false;
	}
	if ( document.form1.f_senha.value == '' ) {
		alert("Senha em branco.");
		document.form1.f_senha.focus();
		return false;
	}
	if ( testeSenha.test(document.form1.f_senha.value) == false ) {
		alert("Senha inválida.\nFormato: até 6-20 caracteres alfanumericos");
		document.form1.f_senha.value = '';
		document.form1.f_senha.focus();
		return false;
	}
	document.form1.submit();	
}

function validarFormContato() {
	if ( document.form1.f_nome.value == '' ) {
		alert("Nome em branco.");
		document.form1.f_nome.focus();
		return false;
	}
	if ( document.form1.f_email.value == '' ) {
		alert("E-mail em branco.");
		document.form1.f_email.focus();
		return false;
	}
	if ( testeEmail.test(document.form1.f_email.value) == false ) {
		alert("E-mail inválido.\nExemplo: nome@dominio");
		document.form1.f_cemail.value = '';
		document.form1.f_email.value = '';
		document.form1.f_email.focus();
		return false;
	}
	if ( document.form1.f_mensagem.value == '' ) {
		alert("Mensagem em branco.");
		document.form1.f_mensagem.focus();
		return false;
	}
	if ( document.form1.f_palavra.value == '' ) {
		alert("Palavra em branco.");
		document.form1.f_palavra.focus();
		return false;
	}	
	document.form1.submit();	
}

function validarFormCadastro() {
	document.form1.f_matricula.value = Trim(document.form1.f_matricula.value);
	document.form1.f_email.value = Trim(document.form1.f_email.value);
	document.form1.f_cemail.value = Trim(document.form1.f_cemail.value);
	
	if ( document.form1.f_matricula.value == '' ) {
		alert("Matricula em branco.");
		document.form1.f_matricula.focus();
		return false;
	}
	if ( testeMatricula.test(document.form1.f_matricula.value) == false ) {
		alert("Matricula inválida.\nExemplo: 200110100");
		document.form1.f_matricula.value = '';
		document.form1.f_matricula.focus();
		return false;
	}
	if ( document.form1.f_senha.value == '' ) {
		alert("Senha em branco.");
		document.form1.f_senha.focus();
		return false;
	}
	if ( testeSenha.test(document.form1.f_senha.value) == false ) {
		alert("Senha inválida.\nFormato: até 6-20 caracteres alfanumericos");
		document.form1.f_csenha.value = '';
		document.form1.f_senha.value = '';
		document.form1.f_senha.focus();
		return false;
	}	
	if ( document.form1.f_csenha.value == '' ) {
		alert("Confirmação de Senha em branco.");
		document.form1.f_csenha.focus();
		return false;
	}
	if ( document.form1.f_csenha.value != document.form1.f_senha.value ) {
		alert("As senhas digitadas não são iguais.");
		document.form1.f_csenha.value = '';
		document.form1.f_senha.value = '';
		document.form1.f_senha.focus();
		return false;		
	}
	if ( document.form1.f_email.value == '' ) {
		alert("E-mail em branco.");
		document.form1.f_email.focus();
		return false;
	}
	if ( testeEmail.test(document.form1.f_email.value) == false ) {
		alert("E-mail inválido.\nExemplo: nome@dominio");
		document.form1.f_cemail.value = '';
		document.form1.f_email.value = '';
		document.form1.f_email.focus();
		return false;
	}
	if ( document.form1.f_email.value != document.form1.f_cemail.value ) {
		alert("Os e-mails digitados não são iguais.");
		document.form1.f_cemail.value = '';
		document.form1.f_email.value = '';
		document.form1.f_email.focus();
		return false;		
	}
	document.form1.submit();
}

function verificarCursoEscolhidoP1() {
 	var tamanhoSelect = document.form1.f_curso.length;
    var indiceEscolhido = document.form1.f_curso.selectedIndex;
    var valorEscolhido = document.form1.f_curso.options[indiceEscolhido].value;
    var textoEscolhido = document.form1.f_curso.options[indiceEscolhido].text;
	//
	if ( valorEscolhido == 'Sistemas de Informação' || valorEscolhido == 'Administração' ) {
		document.getElementById('periodoL01').style.visibility = 'visible';
		document.getElementById('periodoL01').style.display = '';	
		document.getElementById('periodoL02').style.visibility = 'visible';
		document.getElementById('periodoL02').style.display = '';			
	}
	else {
		document.getElementById('periodoL01').style.visibility = 'hidden';
		document.getElementById('periodoL01').style.display = 'none';	
		document.getElementById('periodoL02').style.visibility = 'hidden';
		document.getElementById('periodoL02').style.display = 'none';
	}
}

function mostrarTipoDeficiencia() {
		document.getElementById('tipod01').style.visibility = 'visible';
		document.getElementById('tipod01').style.display = '';
}

function ocultarTipoDeficiencia() {
		document.getElementById('tipod01').style.visibility = 'hidden';
		document.getElementById('tipod01').style.display = 'none';
}

function mostrarQtdFilho() {
		document.getElementById('qf01').style.visibility = 'visible';
		document.getElementById('qf01').style.display = '';
}

function ocultarQtdFilho() {
		document.getElementById('qf01').style.visibility = 'hidden';
		document.getElementById('qf01').style.display = 'none';
}


	/*
	
		PASSO 1
	
	*/

function validarFormulario(num) {
	
	if ( confirm('Você deseja salvar seus dados?\n') ) {
	
		if ( document.form1.f_curso.options[document.form1.f_curso.selectedIndex].value == '' || document.form1.f_curso.options[document.form1.f_curso.selectedIndex].value == ' ' ) {
			document.getElementById('l_curso').style.backgroundColor = '#FFFFCC';		
			alert("Selecione um curso.");
			document.form1.f_curso.focus();
			return false;		
		}
		else {
			document.getElementById('l_curso').style.backgroundColor = '#dfdfdf';
		}
		
		
		if ( document.form1.f_curso.options[document.form1.f_curso.selectedIndex].value == 'Administração' || document.form1.f_curso.options[document.form1.f_curso.selectedIndex].value == 'Sistemas de Informação' ) {
			if ( document.form1.f_curso_periodo.options[document.form1.f_curso_periodo.selectedIndex].value == '' || document.form1.f_curso_periodo.options[document.form1.f_curso_periodo.selectedIndex].value == ' ' ) {
				document.getElementById('periodoL02').style.backgroundColor = '#FFFFCC';
				alert("Período em branco.\nFavor selecione em qual período você encontra-se matriculado.");
				document.form1.f_curso_periodo.focus();
				return false;
			}
			else {
				document.getElementById('periodoL02').style.backgroundColor = '#dfdfdf';
			}
		}
		else {
			document.form1.f_curso_periodo.options[document.form1.f_curso_periodo.selectedIndex].value = '';
		}
		
		if ( document.form1.f_curric_cpf.value == '' ) {
			document.getElementById('l_cpf').style.backgroundColor = '#FFFFCC';
			alert("CPF em branco.");
			document.form1.f_curric_cpf.focus();
			return false;
		}
		else {
			document.getElementById('l_cpf').style.backgroundColor = '#dfdfdf';
		}	
		
		if ( document.form1.f_curric_cpf.value.search('^\\d{11}')) {
			document.getElementById('l_cpf').style.backgroundColor = '#FFFFCC';		
			alert("CPF invalido.");
			document.form1.f_curric_cpf.focus();
			return false;
		}
		else {
			document.getElementById('l_cpf').style.backgroundColor = '#f0f0f0';
		}		
		
		if ( document.form1.f_curric_rg.value == '' ) {
			document.getElementById('l_rg').style.backgroundColor = '#FFFFCC';
			alert("RG em branco.");
			document.form1.f_curric_rg.focus();
			return false;
		}
		else {
			document.getElementById('l_rg').style.backgroundColor = '#dfdfdf';
		}			
		
		if ( document.form1.f_curric_nome.value == '' || document.form1.f_curric_nome.value == ' ' ) {
			document.getElementById('l_nome').style.backgroundColor = '#FFFFCC';		
			alert("Nome em branco.");
			document.form1.f_curric_nome.focus();
			return false;
		}
		else {
			document.getElementById('l_nome').style.backgroundColor = '#dfdfdf';				
		}
		
		if ( document.form1.f_curric_data_nasc.value == '' ) {
			document.getElementById('l_dtNascimento').style.backgroundColor = '#FFFFCC';
			alert("data de nascimento em branco.");
			document.form1.f_curric_data_nasc.focus();
			return false;
		}
		else {
			document.getElementById('l_dtNascimento').style.backgroundColor = '#f0f0f0';
		}
		
		if ( reDate5.test(document.form1.f_curric_data_nasc.value) == false ) {
			document.getElementById('l_dtNascimento').style.backgroundColor = '#FFFFCC';
			alert("Data de nascimento inválida.");
			document.form1.f_curric_data_nasc.focus();
			return false;
		}
		else {
			document.getElementById('l_dtNascimento').style.backgroundColor = '#f0f0f0';
		}
		
		//	
		if ( document.form1.f_curric_sexo.value == '' ) {
			alert("sexo em branco.");
			document.form1.sexo.focus();
			return false;
		}
		
		if ( document.form1.f_curric_pais.value == '' ) {
			document.getElementById('l_pais').style.backgroundColor = '#FFFFCC';
			alert("país em branco.");
			document.form1.f_curric_pais.focus();
			return false;
		}
		else {
			document.getElementById('l_pais').style.backgroundColor = '#dfdfdf';				
		}
		
		if ( document.form1.f_curric_estado.value == '' ) {
			document.getElementById('l_estado').style.backgroundColor = '#FFFFCC';		
			alert("estado em branco.");
			document.form1.f_curric_estado.focus();
			return false;
		}
		else {
			document.getElementById('l_estado').style.backgroundColor = '#f0f0f0';
		}
		
		if ( document.form1.f_curric_cidade.value == '' ) {
			document.getElementById('l_cidade').style.backgroundColor = '#FFFFCC';		
			alert("cidade em branco.");
			document.form1.f_curric_cidade.focus();
			return false;
		}
		else {
			document.getElementById('l_cidade').style.backgroundColor = '#dfdfdf';				
		}
		
		if ( document.form1.f_curric_bairro.value == '' ) {
			document.getElementById('l_bairro').style.backgroundColor = '#FFFFCC';		
			alert("bairro em branco.");
			document.form1.f_curric_bairro.focus();
			return false;
		}
		else {
			document.getElementById('l_bairro').style.backgroundColor = '#f0f0f0';
		}	
		
		
		if ( document.form1.f_curric_estadocivil.value == '' ) {
			document.getElementById('l_curric_estadocivil').style.backgroundColor = '#FFFFCC';		
			alert("Estado civil em branco.");
			document.form1.f_curric_estadocivil.focus();
			return false;
		}
		else {
			document.getElementById('f_curric_estadocivil').style.backgroundColor = '#f0f0f0';
		}	
		
		if ( document.form1.f_curric_endereco.value == '' ) {
			document.getElementById('l_endereco').style.backgroundColor = '#FFFFCC';		
			alert("endereço em branco.");
			document.form1.f_curric_endereco.focus();
			return false;
		}
		else {
			document.getElementById('l_endereco').style.backgroundColor = '#dfdfdf';				
		}
		
		if ( document.form1.f_curric_cep.value == '' ) {
			document.getElementById('l_cep').style.backgroundColor = '#FFFFCC';		
			alert("cep em branco.");
			document.form1.f_curric_cep.focus();
			return false;
		}
		else {
			document.getElementById('l_cep').style.backgroundColor = '#f0f0f0';
		}	
		
		if ( document.form1.f_curric_cep.value.search('^\\d{8}')) {
			document.getElementById('l_cep').style.backgroundColor = '#FFFFCC';		
			alert("CEP invalido.");
			document.form1.f_curric_cep.focus();
			return false;
		}
		else {
			document.getElementById('l_cep').style.backgroundColor = '#f0f0f0';
		}	
		//			
		if ( document.form1.f_curric_mail.value == '' ) {
			alert("E-mail em branco.");
			document.form1.f_curric_mail.focus();
			return false;
		}
		if (!(/^[\w-]+(\.[\w-]+)*@(([A-Za-z\d][A-Za-z\d-]{0,61}[A-Za-z\d]\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/.test(document.form1.f_curric_mail.value)))
		{ 
			alert("E-mail válido.");
			document.form1.f_curric_mail.focus() 
			return false;
		}
		if ( document.form1.f_curric_mail.value != document.form1.f_curric_mail1.value ) {
			alert("E-mail não são iguais.");
			document.form1.f_curric_mail.value = '';
			document.form1.f_curric_mail1.value = '';
			document.form1.f_curric_mail.focus() 
			return false;		
		}
		document.form1.pagdest.value = num;
		document.form1.submit();
	}
	else {
		document.form1.pagdest.value = num;
		document.location.href = "verPasso"+num+".php";
	}
}

	/*
	
		PASSO 2
	
	*/


function validarFormulario2(num) {
	if ( confirm('Você deseja salvar seus dados?\n') ) {
		
		if ( document.form1.f_curric_objProf.value == '' || document.form1.f_curric_objProf.value.length <= 1 ) {
			alert("Objetivos em branco.");
			document.form1.f_curric_objProf.focus();
			return false;
		}
		if ( document.form1.f_curric_qualiProf.value == '' || document.form1.f_curric_qualiProf.value.length <= 1 ) {
			alert("Qualificações em branco.");
			document.form1.f_curric_qualiProf.focus();
			return false;
		}	
		document.form1.pagdest.value = num;
		document.form1.submit();
	}
	else {
		document.form1.pagdest.value = num;
		document.location.href = "verPasso"+num+".php";
	}
}


	/*
	
		PASSO 3
	
	*/


function validarFormulario3(num) {
	
	if ( confirm('Você deseja salvar seus dados?\n') ) {
	
		if ( document.form1.f_curric_exp_empresa.value == '' || document.form1.f_curric_exp_empresa.value.length <= 1 ) {
			document.getElementById('l_empresa').style.backgroundColor = '#FFFFCC';
			alert("Empresa em branco.");
			document.form1.f_curric_exp_empresa.focus();
			return false;
		}
		else {
			document.getElementById('l_empresa').style.backgroundColor = '#dfdfdf';
		}	
		
		if ( document.form1.f_curric_exp_estado.value == '' || document.form1.f_curric_exp_estado.value.length <= 1 ) {
			document.getElementById('l_estado').style.backgroundColor = '#FFFFCC';
			alert("Estado em branco.");
			document.form1.f_curric_exp_estado.focus();
			return false;
		}
		else {
			document.getElementById('l_estado').style.backgroundColor = '#f0f0f0';
		}
		
		if ( document.form1.f_curric_exp_cidade.value == '' ) {
			document.getElementById('l_cidade').style.backgroundColor = '#FFFFCC';
			alert("Cidade em branco.");
			document.form1.f_curric_exp_cidade.focus();
			return false;
		}
		else {
			document.getElementById('l_cidade').style.backgroundColor = '#dfdfdf';
		}	
		
		if ( document.form1.f_curric_exp_periodoI.value == '' || document.form1.f_curric_exp_periodoI.value.length <= 1 ) {
			document.getElementById('l_periodo').style.backgroundColor = '#FFFFCC';
			alert("Período inicial em branco.");
			document.form1.f_curric_exp_periodoI.focus();
			return false;
		}
		else {
			document.getElementById('l_periodo').style.backgroundColor = '#f0f0f0';
		}
		
		if ( doDate3(document.form1.f_curric_exp_periodoI.value,5) == false ) {
			document.getElementById('l_periodo').style.backgroundColor = '#FFFFCC';
			alert(document.form1.f_curric_exp_periodoI.value + " não é uma data válida.");
			document.form1.f_curric_exp_periodoI.value = '';
			document.form1.f_curric_exp_periodoI.focus();
			return false;
		}
		else {
			document.getElementById('l_periodo').style.backgroundColor = '#f0f0f0';
		}	
		
		if ( document.form1.f_curric_exp_periodoF.value == '' || document.form1.f_curric_exp_periodoF.value == ' ' ) {
			if ( document.form1.f_curric_exp_empregoAtual.checked == false ) {
				alert("Preencha o campo período final ou marque a opção Emprego Atual.");
				document.form1.f_curric_exp_periodoF.focus();
				return false;
			}
		}
		else {
			if ( doDate1(document.form1.f_curric_exp_periodoF.value,5) == false ) {
				document.getElementById('l_periodo').style.backgroundColor = '#FFFFCC';
				alert(document.form1.f_curric_exp_periodoF.value + " não é uma data válida.");
				document.form1.f_curric_exp_periodoF.value = '';
				document.form1.f_curric_exp_periodoF.focus();
				return false;
			}		
			else {
				document.getElementById('l_periodo').style.backgroundColor = '#f0f0f0';
			}		
			
			if ( document.form1.f_curric_exp_empregoAtual.checked && document.form1.f_curric_exp_empregoAtual.value == 'Sim' ) {
				alert("O campo período final esta preenchido. Desmarque a opção Emprego Atual.");
				document.form1.f_curric_exp_periodoF.focus();
				return false;
			}
		}
		
		if ( document.form1.f_curric_exp_descricao.value == '' || document.form1.f_curric_exp_descricao.value.length <= 1 ) {
			document.getElementById('l_descricao').style.backgroundColor = '#FFFFCC';
			alert("Descrição em branco.");
			document.form1.f_curric_exp_descricao.focus();
			return false;
		}
		else {
			document.getElementById('l_descricao').style.backgroundColor = '#dfdfdf';
		}	
		
		document.form1.pagdest.value = num;	
		document.form1.submit();
	}
	else {
		document.form1.pagdest.value = num;
		document.location.href = "verPasso"+num+".php";		
	}
}

function validarFormulario4(num) {
	
	if ( confirm('Você deseja salvar seus dados?\n') ) {
		
		if ( document.form1.f_curric_exp_tipo.value == '' || document.form1.f_curric_exp_tipo.value.length <= 1 ) {
			document.getElementById('l_tipo').style.backgroundColor = '#FFFFCC';
			alert("Tipo em branco.");
			document.form1.f_curric_exp_tipo.focus();
			return false;
		}
		else {
			document.getElementById('l_tipo').style.backgroundColor = '#dfdfdf';
		}	


		if ( document.form1.f_curric_exp_instituicao.value == '' || document.form1.f_curric_exp_instituicao.value.length <= 1 ) {
			document.getElementById('l_inst').style.backgroundColor = '#FFFFCC';
			alert("Instituição em branco.");
			document.form1.f_curric_exp_instituicao.focus();
			return false;
		}
		else {
			document.getElementById('l_inst').style.backgroundColor = '#f0f0f0';
		}	
		
		if ( document.form1.f_curric_exp_curso.value == '' || document.form1.f_curric_exp_curso.value.length <= 1 ) {
			document.getElementById('l_curso').style.backgroundColor = '#FFFFCC';
			alert("Curso em branco.");
			document.form1.f_curric_exp_curso.focus();
			return false;
		}
		else {
			document.getElementById('l_curso').style.backgroundColor = '#dfdfdf';
		}		
	
		if ( document.form1.f_curric_exp_periodoI.value == '' || document.form1.f_curric_exp_periodoI.value.length <= 1 ) {
			document.getElementById('l_periodo').style.backgroundColor = '#FFFFCC';
			alert("Período inicial em branco.");
			document.form1.f_curric_exp_periodoI.focus();
			return false;
		}
		else {
			document.getElementById('l_periodo').style.backgroundColor = '#f0f0f0';
		}	
		
		if ( document.form1.f_curric_exp_periodoF.value == '' || document.form1.f_curric_exp_periodoF.value.length <= 1 ) {
			document.getElementById('l_periodo').style.backgroundColor = '#FFFFCC';
			alert("Período final em branco.\nCaso ainda esteja curso indique a data de termino.");
			document.form1.f_curric_exp_periodoF.focus();
			return false;
		}
		else {
			document.getElementById('l_periodo').style.backgroundColor = '#f0f0f0';
		}			
		
		if ( doDate3(document.form1.f_curric_exp_periodoI.value,5) == false ) {
			document.getElementById('l_periodo').style.backgroundColor = '#FFFFCC';
			alert(document.form1.f_curric_exp_periodoI.value + " não é uma data válida.");
			document.form1.f_curric_exp_periodoI.value = '';
			document.form1.f_curric_exp_periodoI.focus();
			return false;
		}
		else {
			document.getElementById('l_periodo').style.backgroundColor = '#f0f0f0';
		}	
		
		if ( doDate3(document.form1.f_curric_exp_periodoF.value,5) == false ) {
			document.getElementById('l_periodo').style.backgroundColor = '#FFFFCC';
			alert(document.form1.f_curric_exp_periodoF.value + " não é uma data válida.");
			document.form1.f_curric_exp_periodoF.value = '';
			document.form1.f_curric_exp_periodoF.focus();
			return false;
		}	
		else {
			document.getElementById('l_periodo').style.backgroundColor = '#f0f0f0';
		}	
		
		if ( document.form1.f_curric_exp_descricao.value == '' || document.form1.f_curric_exp_descricao.value.length <= 1 ) {
			document.getElementById('l_descricao').style.backgroundColor = '#FFFFCC';
			alert("Descrição em branco.");
			document.form1.f_curric_exp_descricao.focus();
			return false;
		}
		else {
			document.getElementById('l_descricao').style.backgroundColor = '#dfdfdf';
		}		
		
		document.form1.pagdest.value = num;
		document.form1.submit();
	}
	else {
		document.form1.pagdest.value = num;
		document.location.href = "verPasso"+num+".php";		
	}
}

function validarFormulario5(num) {
	if ( confirm('Você deseja salvar seus dados?\n') ) {
		if ( document.form1.f_curric_idioma.value == '' || document.form1.f_curric_idioma.value.length <= 1 ) {
			document.getElementById('l_idioma').style.backgroundColor = '#FFFFCC';
			alert("Idioma em branco.");
			document.form1.f_curric_idioma.focus();
			return false;
		}
		else {
			document.getElementById('l_idioma').style.backgroundColor = '#dfdfdf';
		}		
		if ( document.form1.f_curric_nivel.value == '' || document.form1.f_curric_nivel.value.length <= 1 ) {
			document.getElementById('l_nivel').style.backgroundColor = '#FFFFCC';
			alert("Nível em branco.");
			document.form1.f_curric_nivel.focus();
			return false;
		}
		else {
			document.getElementById('l_nivel').style.backgroundColor = '#f0f0f0';
		}			
	/*
		if ( document.form1.f_curric_descricao.value == '' || document.form1.f_curric_descricao.value.length <= 1 ) {
			alert("Descrição em branco.");
			document.form1.f_curric_descricao.focus();
			return false;
		}
	*/
		document.form1.pagdest.value = num;	
		document.form1.submit();
	}
	else {
		document.form1.pagdest.value = num;
		document.location.href = "verPasso"+num+".php";		
	}	
	
}

function validarFormulario6(num) {
	if ( confirm('Você deseja salvar seus dados?\n') ) {	
		if ( document.form1.f_curriculo_foto.value == '' || document.form1.f_curriculo_foto.value.length <= 1 ) {
			alert("arquivo em branco.");
			document.form1.f_curriculo_foto.focus();
			return false;
		}
		document.form1.pagdest.value = num;	
		document.form1.submit();
	}
	else {
		document.form1.pagdest.value = num;
		document.location.href = "verPasso"+num+".php";
	}	
}

function finalizarCadastro() {
	if ( confirm('Você tem certeza que deseja finalizar?') ) {
		document.form1.pagina.value = 6;		
		document.form1.submit();
	}
	else {
		return false;
	}
}

function validacpf(){
 
var i;
 
s = document.form1.f_curric_cpf.value;
 
var c = s.substr(0,9);
 
var dv = s.substr(9,2);
 
var d1 = 0;
 
for (i = 0; i < 9; i++)
 
{
 
d1 += c.charAt(i)*(10-i);
 
}
 
if (d1 == 0){
document.getElementById('l_cpf').style.backgroundColor = '#FFFFCC'; 
alert("CPF Invalido")
document.form1.f_curric_cpf.value = ''; 
document.form1.f_curric_cpf.focus();
return false;
 
}
 
d1 = 11 - (d1 % 11);
 
if (d1 > 9) d1 = 0;
 
if (dv.charAt(0) != d1)
 
{
document.getElementById('l_cpf').style.backgroundColor = '#FFFFCC';  
alert("CPF Invalido")
document.form1.f_curric_cpf.value = ''; 
document.form1.f_curric_cpf.focus();
return false;
 
}
 
 
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)
 
{
document.getElementById('l_cpf').style.backgroundColor = '#FFFFCC';  
alert("CPF Invalido")
document.form1.f_curric_cpf.value = ''; 
document.form1.f_curric_cpf.focus(); 
return false; 
}
document.getElementById('l_cpf').style.backgroundColor = '#dfdfdf'; 
return true;
}

// fim validação de cpf

// MAIUSCULA
function toUppercase() {
	document.form1.outstring.value = document.form1.instring.value.toUpperCase();
}

// DATA NASCIMENTO
  function mascara_datadeNascimento(data){ 
	  var mydata = ''; 
	  mydata = mydata + data; 
	  if (mydata.length == 2){ 
		  mydata = mydata + '/'; 
		  document.forms[0].f_curric_data_nasc.value = mydata; 
	  } 
	  if (mydata.length == 5){ 
		  mydata = mydata + '/'; 
		  document.forms[0].f_curric_data_nasc.value = mydata; 
	  } 
	  if (mydata.length == 10){ 
		  verifica_datadeNascimento(); 
	  } 
  } 
   
  function verifica_datadeNascimento () { 

	dia = (document.forms[0].f_curric_data_nasc.value.substring(0,2)); 
	mes = (document.forms[0].f_curric_data_nasc.value.substring(3,5)); 
	ano = (document.forms[0].f_curric_data_nasc.value.substring(6,10)); 

	situacao = ""; 
	// verifica o dia valido para cada mes 
	if ((dia < 01)||(dia < 01 || dia > 30) && (  mes == 04 || mes == 06 || mes == 09 || mes == 11 ) || dia > 31) { 
		situacao = "falsa"; 
	} 

	// verifica se o mes e valido 
	if (mes < 01 || mes > 12 ) { 
		situacao = "falsa"; 
	} 

	// verifica se e ano bissexto 
	if (mes == 2 && ( dia < 01 || dia > 29 || ( dia > 28 && (parseInt(ano / 4) != ano / 4)))) { 
		situacao = "falsa"; 
	} 

	if (document.forms[0].f_curric_data_nasc.value == "") { 
		situacao = "falsa"; 
	} 

	if (situacao == "falsa") { 
		alert("Data Nascimento inválida!"); 
		document.forms[0].f_curric_data_nasc.focus(); 
	} 
  }
  
  function contarChar(id,num){
		if ( num == 1 ) {
			document.getElementById('qtd1').innerHTML = 1000-id.value.length;
			if((1000-id.value.length)==0)
			alert('Atenção, você atingiu o limite máximo de caracteres!');
		}
		else {
			if ( num == 2 ) {			
				document.getElementById('qtd2').innerHTML = 1000-id.value.length;
				if((1000-id.value.length)==0)
				alert('Atenção, você atingiu o limite máximo de caracteres!');
			}
		}
  }  
  
  function procurar(tipo) {
	  document.form1.pesquisa.value = tipo;
	  document.form1.submit();
  }
  
  function macaraData1(data){ 
	  var mydata = ''; 
	  mydata = mydata + data; 
	  if (mydata.length == 2){ 
		  mydata = mydata + '/'; 
		  document.forms[0].f_curric_exp_periodoI.value = mydata; 
	  } 
	  if (mydata.length == 5){ 
		  mydata = mydata + '/'; 
		  document.forms[0].f_curric_exp_periodoI.value = mydata; 
	  }
  } 
  
  function macaraData2(data){ 
	  var mydata = ''; 
	  mydata = mydata + data; 
	  if (mydata.length == 2){ 
		  mydata = mydata + '/'; 
		  document.forms[0].f_curric_exp_periodoF.value = mydata; 
	  } 
	  if (mydata.length == 5){ 
		  mydata = mydata + '/'; 
		  document.forms[0].f_curric_exp_periodoF.value = mydata; 
	  }
  }   
  
	function Trim(str){
		return str.replace(/^\s+|\s+$/g,"");
	}
