function ajax() {
};
ajax.prototype.iniciar = function() {

    try{
        this.xmlhttp = new XMLHttpRequest();
    }catch(ee){
        try{
            this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        }catch(e){
            try{
                this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            }catch(E){
                this.xmlhttp = false;
            }
        }
    }
    return true;
}

ajax.prototype.ocupado = function() {
    estadoAtual = this.xmlhttp.readyState;
    return (estadoAtual && (estadoAtual < 4));
}

ajax.prototype.processa = function() {
    if (this.xmlhttp.readyState == 4 && this.xmlhttp.status == 200) {
        return true;
    }
}

ajax.prototype.enviar = function(url, metodo, modo) {
    if (!this.xmlhttp) {
        this.iniciar();
    }
    if (!this.ocupado()) {
        if(metodo == "GET") {
            this.xmlhttp.open("GET", url, modo);
            this.xmlhttp.send(null);
        } else {        
            this.xmlhttp.open("POST", url, modo);
            this.xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
            this.xmlhttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
            this.xmlhttp.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
            this.xmlhttp.setRequestHeader("Pragma", "no-cache");
            this.xmlhttp.send(url);
        }    

        if (this.processa) {
            return unescape(this.xmlhttp.responseText.replace(/\+/g," "));
        }
    }
    return false;
}

  function troca(esconde,mostra){
	  document.getElementById(esconde).style.display='none';
	  document.getElementById(mostra).style.display='';
	  if(mostra == "formnovo")
	  document.cpform.cpf.focus();
	  if(mostra == "formalterar")
	  document.cpform2.cpf2.focus();
  }
function testacpf(cpf,pass,formulario,tipo,metodo,modo)
{ 
if(tipo == "cadastrar")
{
    remoto  = new ajax();
	document.getElementById("erros").className='';
	document.getElementById("erros").style.display='';
	document.getElementById("erros").innerHTML="Verifcando autenticidade do CPF";
    xmlhttp = remoto.enviar("v.php?cpf="+cpf+"&tipo="+tipo, metodo, modo );
	
	if(xmlhttp=="falso"){
			document.getElementById("erros").className='erro';
			document.getElementById("erros").style.display='';
			document.getElementById("erros").innerHTML="CPF inv&aacute;lido! Favor verificar sua autenticidade.";
	}else{
		 if(xmlhttp=="ok3"){
			document.getElementById("erros").className='erro';
			document.getElementById("erros").style.display='';
			document.getElementById("erros").innerHTML="CPF j&aacute; cadastrado no sistema! Digite abaixo o CPF e Senha para edit&aacute;-lo";
			troca('formnovo','formalterar');
			
		}else if(xmlhttp=="ok4"){
			//alert(formulario);
			document.getElementById(formulario).submit();
		}
	}
}
else if(tipo == "alterar") {
    remoto  = new ajax();
	document.getElementById("erros").className='';
	document.getElementById("erros").style.display='';
	document.getElementById("erros").innerHTML="Verifcando autenticidade do Cadastro";
    xmlhttp = remoto.enviar("v.php?cpf="+cpf+"&s="+pass+"&tipo="+tipo, metodo, modo );
	if(xmlhttp=="falso"){
		
			document.getElementById("erros").className='erro';
			document.getElementById("erros").style.display='';
			document.getElementById("erros").innerHTML="CPF inv&aacute;lido! Favor verificar sua autenticidade.";
	}else{
		if(xmlhttp=="ok2"){
			document.getElementById("erros").className='erro';
			document.getElementById("erros").style.display='';
			document.getElementById("erros").innerHTML="CPF e/ou Senha inv&aacute;lidos!";
		}else if(xmlhttp=="ok1")
			document.getElementById(formulario).submit();
	}
}
}



//trocar os campos da pagina de curriculos

  
  //mascara de cpf dos curriculos
  function mascara(o,f){
    v_obj=o
    v_fun=f
    setTimeout("execmascara()",1)
}

function execmascara(){
    v_obj.value=v_fun(v_obj.value)
}

function maskcpf(v){
    v=v.replace(/\D/g,"")                    
    v=v.replace(/(\d{3})(\d)/,"$1.$2")      
    v=v.replace(/(\d{3})(\d)/,"$1.$2")     
                                             
    v=v.replace(/(\d{3})(\d{1,2})$/,"$1-$2") 
    return v
}


function soNumeros(v){
    return v.replace(/\D/g,"")
}

function masktelefone(v){
	v=v.replace(/\D/g,"")               
    v=v.replace(/^(\d\d)(\d)/g,"($1) $2") 
    v=v.replace(/(\d{4})(\d)/,"$1-$2") 
    return v
}

function masknascimento(v){
    v=v.replace(/\D/g,"")    
	v=v.replace(/(\d{2})(\d)/,"$1/$2") 
	v=v.replace(/(\d{2})(\d)/,"$1/$2")
    return v
}

function maskcep(v){
    v=v.replace(/\D/g,"")
    v=v.replace(/^(\d{5})(\d)/,"$1-$2")
    return v
}
function validar(){		
		if(document.getElementById("email").value == ""){
			alert("Informe seu e-mail !");
			email.focus();
			return false;}
	with(document.frm){

		if(nome.value == ""){
			alert("Informe o campo nome !");
			nome.focus();
			return false;}
		if(endereco.value == ""){
			alert("Informe o campo Endereco !");
			endereco.focus();
			return false;}
		if(bairro.value == ""){
			alert("Informe o campo bairro !");
			bairro.focus();
			return false;}
		if(cidade.value == ""){
			alert("Informe o campo cidade !");
			cidade.focus();
			return false;}
		if(estado.value == 0){
			alert("Escolha um estado !");
			estado.focus();
			return false;}
		if(cep.value.length < 8){
			alert("Informe o campo CEP !");
			cep.focus();	
			return false;}
		if(dtanasc.value.length != 10){
			alert("Informe a Data Nascimento !");
			dtanasc.focus();
			return false;}
		if(nacionalidade.value == 0){
			alert("Escolha uma nacionalidade !");
			nacionalidade.focus();
			return false;}
		if(estadocivil.value == 0){
			alert("Escolha um estado civil !");
			estadocivil.focus();
			return false;}
		if(escolaridade.value == 0){
			alert("Escolha uma escolaridade !");
			escolaridade.focus();
			return false;}
		if(CargoPretendido.value == ""){
			alert("Informe o cargo pretendido !");
			CargoPretendido.focus();
			return false;}
		if(sexo.value == 0){
			alert("Escolha uma opção !");
			sexo.focus();
			return false;}

	
						}
				}
				
function nome(){
	alert("oba");
			//if(quantidade.lenght < 2) 
		//		document.getElementById("nomev").innerHTML="<img src='chili/img/stop-trans.png'>";
			//else 
			//	document.getElementById("nomev").innerHTML="<img src='chili/img/okform-trans.png'>";
			
}