﻿function Init()
{
InitDDL();
}
function Cadastrar()
{
document.location.href = "../../gadget/curriculo/dadospessoais/default.aspx" + document.location.search;
}
function Limpar()
{
document.location.href = document.location.href;
}
function Lembrar()
{
document.location.href = "../lembrarsenha/default.aspx" + document.location.search;
}
function AlteraFocoDocumento(obj,chk)
{
if (chk)
{
if (obj.value.length == 14)
{
document.Form1.txtSenha.focus();
}
}
else
{
if (obj.value.length == 24)
{
document.Form1.txtSenha.focus();
}
}
}
function AlteraFocoSenha(obj)
{
if ((obj.value.length == 12) && (logLogin < 2))
{
document.Form1.txtPessoaCodigo.focus();
logLogin++;
}
}
function MascaraCPF(obj,chk)
{
if (chk)
{
obj.maxLength = 14;
campo = obj.value;
if (campo.length == 3)
{
obj.value = campo + ".";
}
else if (campo.length == 7)
{
obj.value = campo + ".";
}
else if (campo.length == 11)
{
obj.value = campo + "-";
}
}
}
function ExibirPais(obj)
{
myObj = document.getElementById(obj.id)
if (myObj.value=="rdbCPF")
{
document.getElementById("pais").style.display = "none";
}
else
{
document.getElementById("pais").style.display = "block";
}
document.getElementById("txtPessoaCodigo").value = "";
}
function ChangeValue(objddl,strtxt)
{
objtxt = document.getElementById(strtxt);
objtxt.value = objddl.options[objddl.selectedIndex].value;
}
function InitDDL()
{
document.getElementById("imgEnviar").src = document.getElementById("imgLimpar").src;
try
{
strSufixo = document.getElementById("txtDataCache").value;
includeHTML("tdSourceddlPais",location.href.substring(0,location.href.indexOf("/pub/"))+"/website/software/cache/cachePais"+strSufixo+".html");
objSourceddlPais = document.getElementById("SourceddlPais");
objddlPaisPassaporte = document.getElementById("ddlPaisPassaporte");
objtxtPaisPassaporte = document.getElementById("txtPaisPassaporte");
for (i=0; i<objSourceddlPais.length; i++)
{
objddlPaisPassaporte.options[i] = new Option(objSourceddlPais.options[i].text,objSourceddlPais.options[i].value);
if (objddlPaisPassaporte.options[i].value == objtxtPaisPassaporte.value)
{
objddlPaisPassaporte.selectedIndex = i;
}
}
}
catch(e){}
}
function ltrim(str)
{
for (var i = 0; (i < str.length) && (str.charAt(i) == " "); i++)
{
}
if (i == str.length)
{
return "";
}
else
{
return str.substring(i, str.length);
}
}
function rtrim(str)
{
for (var i = str.length; (i > 0) && (str.charAt(i - 1) == " "); i--)
{
}
return str.substring(0, i);
}
function trim(str)
{
for (var i = 0; (i < str.length) && (str.charAt(i) == " "); i++)
{
}
for (var j = str.length; (j > 0) && (str.charAt(j - 1) == " "); j--)
{
}
if (i == str.length)
{
return "";
}
else
{
return str.substring(i, j);
}
}
function alltrim(str)
{
for (var i = 0; (i < str.length) && (str.charAt(i) == " "); i++)
{
}
for (var j = str.length; (j > 0) && (str.charAt(j - 1) == " "); j--)
{
}
if (i == str.length)
{
str = "";
}
else
{
str = str.substring(i, j);
}
while (str.length > 0 && str.indexOf("\t") != -1)
{
str = str.substring(0,str.indexOf("\t")) + str.substring(str.indexOf("\t")+1,str.length)
}
return str;
}
function validarCPF(pCPF)
{
try
{
strCPF = pCPF.replace(".","").replace(".","").replace("-","");
if (strCPF.length != 11 || isNaN(strCPF) || strCPF.indexOf(",") != -1 || strCPF.indexOf(".") != -1 || strCPF.indexOf("-") != -1) //if (strCPF.length != 11 || isNaN(strCPF) || strCPF.indexOf(",") != -1 || pCPF.charAt(3) != "." || pCPF.charAt(7) != "." || pCPF.charAt(11) != "-" || pCPF.indexOf(".") != 3 || pCPF.lastIndexOf(".") != 7 || pCPF.indexOf(".",4) != 7 || pCPF.indexOf("-") != 11 || pCPF.lastIndexOf("-") != 11)
{
return false;
}
firstSum = 0;
firstDigit = 0;
for (var i = 0; i <= 8; i++)
{
firstSum += parseInt(strCPF.substring(i,i+1))*(10 - i);
}
firstRemResult = firstSum % 11;
if (firstRemResult > 1)
{
firstDigit = 11 - firstRemResult;
}
if (parseInt(strCPF.substring(9,10)) != firstDigit)
{
return false;
}
secondSum = 0;
secondDigit = 0;
for (var i = 0; i <= 9; i++)
{
secondSum += parseInt(strCPF.substring(i,i+1))*(11 - i);
}
secondRemResult = secondSum % 11;
if (secondRemResult > 1)
{
secondDigit = 11 - secondRemResult;
}
if (parseInt(strCPF.substring(10,11)) != secondDigit)
{
return false;
}
return true;
}
catch (e)
{
return false;
}
}
function cvLogin_ClientValidate()
{
objrdbCPF = document.getElementById("rdbCPF");
objrdbPassaporte = document.getElementById("rdbPassaporte");
objtxtPessoaCodigo = document.getElementById("txtPessoaCodigo");
objtxtPaisPassaporte = document.getElementById("txtPaisPassaporte");
objtxtSenha = document.getElementById("txtSenha");
objlblPais = document.getElementById("lblPais");
objlblNumeroDocumento = document.getElementById("lblNumeroDocumento");
objlblSenha = document.getElementById("lblSenha");
objimgPais = document.getElementById("imgPais");
objimgNumeroDocumento = document.getElementById("imgNumeroDocumento");
objimgSenha = document.getElementById("imgSenha");
objtxtPessoaCodigo.value = alltrim(objtxtPessoaCodigo.value);
objtxtPaisPassaporte.value = alltrim(objtxtPaisPassaporte.value);
objtxtSenha.value = alltrim(objtxtSenha.value);
objlblPais.style.color = "";
objlblNumeroDocumento.style.color = "";
objlblSenha.style.color = "";
objimgPais.style.display = "none";
objimgNumeroDocumento.style.display = "none";
objimgSenha.style.display = "none";
objimgPais.title = "";
objimgNumeroDocumento.title = "";
objimgSenha.title = "";
strRtn = true;
if ((objrdbCPF.checked && objtxtPessoaCodigo.value.length == 0) || (objrdbPassaporte.checked && (objtxtPaisPassaporte.value.length == 0 || objtxtPessoaCodigo.value.length == 0)) || objtxtSenha.value.length == 0)
{
if (objrdbPassaporte.checked && objtxtPaisPassaporte.value.length == 0)
{
objlblPais.style.color = "Red";
objimgPais.title = "O campo país é obrigatório quando se seleciona um documento do tipo passaporte."; //GetErroMessage("3")
objimgPais.style.display = "";
}
if (objtxtPessoaCodigo.value.length == 0)
{
objlblNumeroDocumento.style.color = "Red";
objimgNumeroDocumento.title = "O campo número do documento é obrigatório."; //GetErroMessage("1")
objimgNumeroDocumento.style.display = "";
}
if (objtxtSenha.value.length == 0)
{
objlblSenha.style.color = "Red";
objimgSenha.title = "O campo senha é obrigatório."; //GetErroMessage("4")
objimgSenha.style.display = "";
}
strRtn = false;
}
if (objrdbCPF.checked && objtxtPessoaCodigo.value.length > 0 && !validarCPF(objtxtPessoaCodigo.value))
{
objlblNumeroDocumento.style.color = "Red";
objimgNumeroDocumento.title = "O campo número do documento é um CPF inválido."; //GetErroMessage("11")
objimgNumeroDocumento.style.display = "";
strRtn = false;
}
return strRtn;
}

