// Função para validar o cpf digitado no currículo
function validaCpf() {
  with ( document.curriculo ) {
    if ( curriculoCpf.value == "" ) {
      alert("O campo CPF é obrigatório ");
      curriculoCpf.focus();
      return false;
    } else {
  		var i; 
	  	s = curriculoCpf.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) { 
  			alert("CPF inválido !!")
        curriculoCpf.focus();
  		  return false; 
		  } 
		  d1 = 11 - (d1 % 11); 
		  if (d1 > 9) d1 = 0; 
		  if (dv.charAt(0) != d1) { 
  			alert("CPF inválido !!")
	      curriculoCpf.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) { 
  			alert("CPF inválido !!")
        curriculoCpf.focus();
			  return false; 
		  } 
		  return true; 
	  } 

    if ( curriculoCpf.value == "" ){
      alert("O campo " + curriculoCpf.name + " é obrigatório !!");
      curriculoCpf.focus();
      return false;
    }
    return true;
  }
}
// Função exigindo obrigatoriedade dos campos
function validaCampo() {
	with ( document.curriculo2 ) {
		if ( curriculoNome.value == "" ) {
			alert("O campo nome é obrigatório !!");
			curriculoNome.focus();
			return false;
		}

    //validar Nacionalidade
		if ( curriculoNacionalidade.value == "" ) {
			alert("O campo nacionalidade é obrigatório !!");
			curriculoNacionalidade.focus();
			return false;
		}
    //validar Data de nascimento
		if ( curriculoDataNascimento.value == "" ) {
			alert("O campo Data de nascimento é obrigatório !!");
			curriculoDataNascimento.focus();
			return false;
		}
    //validar Prefixo
		if ( curriculoTelefonePrefixo.value == "" ) {
			alert("O campo Prefixo é obrigatório !!");
			curriculoTelefonePrefixo.focus();
			return false;
		}

    //validar Telefone
		if ( curriculoTelefone.value == "" ) {
			alert("O campo Telefone é obrigatório !!");
			curriculoTelefone.focus();
			return false;
		}

    //validar email
		if ( curriculoEmail.value == "" ) {
			alert("O campo E-Mail é obrigatório !!");
			curriculoEmail.focus();
			return false;
		}
    arroba = curriculoEmail.value.indexOf("@");
    if ( arroba == -1 ) {
      alert("E-mail inválido !!");
        curriculoEmail.focus();
        return false;
    }		

    //validar Endereco
		if ( curriculoEndereco.value == "" ) {
			alert("O campo Endereco é obrigatório !!");
			curriculoEndereco.focus();
			return false;
		}

    //validar Número
		if ( curriculoEnderecoNumero.value == "" ) {
			alert("O campo Número é obrigatório !!");
			curriculoEnderecoNumero.focus();
			return false;
		}

    //validar Estado
		if ( curriculoEnderecoUf.value == "" ) {
			alert("O campo Estado é obrigatório !!");
			curriculoEnderecoUf.focus();
			return false;
		}
		
    //validar Cidade
		if ( cidadeID.value == "" ) {
			alert("O campo Cidade é obrigatório !!");
			cidadeID.focus();
			return false;
		}
			
    //validar Último local de trabalho
		if ( curriculoUltimoLocalTrabalho.value == "" ) {
			alert("O campo Ultimo local de trabalho é obrigatório !!");
			curriculoUltimoLocalTrabalho.focus();
			return false;
		}
		return true;
	}
}

// Funções de ajuste de entrada dos campos

// Só números
function ajustar_num(input)
{ if ((event.keyCode<48)||(event.keyCode>57)){
		event.returnValue = false; }
	}
//-------------------------------
function ajustar_data(input)
{ if ((event.keyCode<48)||(event.keyCode>57)){
		event.returnValue = false; 
		} else { 
		if ((input.value.length==2)||(input.value.length==5))
			input.value=input.value + "/" ; } }
//-------------------------------			
function ajustar_cep(input)
{ if ((event.keyCode<48)||(event.keyCode>57)){
		event.returnValue = false; 
		} else { 
		if ((input.value.length==5))
			input.value=input.value + "-" ; } }
//-------------------------------			
function ajustar_tel(input)
{ if ((event.keyCode<48)||(event.keyCode>57)){
		event.returnValue = false; 
		} else { 
		if ((input.value.length==4))
			input.value=input.value + "-" ; } }
//-----------------------------------
function max(txarea) { 
	total = 10; 
	tam = txarea.value.length; 
	str=""; 
	str=str+tam; 
	Digitado.innerHTML = str; 
	Restante.innerHTML = total - str; 

	if (tam > total){ 
		aux = txarea.value; 
		txarea.value = aux.substring(0,total); 
		Digitado.innerHTML = total 
		Restante.innerHTML = 0 
	} 
} 