﻿String.prototype.rspace=function(){return this.replace(/(\s*)|(\s*$)/g,"")};String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")};function isEmail(a){var b=/^[\w!#$%&'*+\/=?^`{|}~-]+(\.[\w!#$%&'*+\/=?^`{|}~-]+)*@(([\w-]+\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;return b.test(a)}function isCep(a){var b=/^\d{5}-\d{3}$/;return b.test(a)}
function isDate(a){var b="0123456789",c="",d="";c="/";var e=c=0,f;for(f=e=0;f<a.length;f++)if(b.indexOf(a.substr(f,1))>=0)d+=a.substr(f,1);a=d;if(a.length==6)a=a.substr(0,4)+"20"+a.substr(4,2);if(a.length!=8)e=19;d=a.substr(4,4);if(d==0)e=20;if(d<=1900)e=20;b=a.substr(2,2);if(b<1||b>12)e=21;a=a.substr(0,2);if(a<1)e=22;if(d%4==0||d%100==0||d%400==0)c=1;if(b==2&&c==1&&a>29)e=23;if(b==2&&c!=1&&a>28)e=24;if(a>31&&(b=="01"||b=="03"||b=="05"||b=="07"||b=="08"||b=="10"||b=="12"))e=25;if(a>30&&(b=="04"||
b=="06"||b=="09"||b=="11"))e=26;if(a==0&&b==0&&d==0)e=0;return e==0?true:false}
function isCpf(a){dig2=dig1=soma=x=0;numcpf1=texto="";len=a.length;x=len-1;for(var b=0;b<=len-3;b++){y=a.substring(b,b+1);soma+=y*x;x-=1;texto+=y}dig1=11-soma%11;if(dig1==10)dig1=0;if(dig1==11)dig1=0;numcpf1=a.substring(0,len-2)+dig1;x=11;for(b=soma=0;b<=len-2;b++){soma+=numcpf1.substring(b,b+1)*x;x-=1}dig2=11-soma%11;if(dig2==10)dig2=0;if(dig2==11)dig2=0;if(dig1+""+dig2==a.substring(len,len-2))return true;return false}
function isCnpj(a){value=a.replace(/[^\d]/gi,"");if(value=="00000000000000"||value=="11111111111111"||value=="22222222222222"||value=="33333333333333"||value=="44444444444444"||value=="55555555555555"||value=="66666666666666"||value=="77777777777777"||value=="88888888888888"||value=="99999999999999")return false;a=[];var b=new Number,c=[6,5,4,3,2,9,8,7,6,5,4,3,2];for(i=0;i<12;i++){a[i]=value.charAt(i);b+=a[i]*c[i+1]}a[12]=(x=b%11)<2?0:11-x;for(y=b=0;y<13;y++)b+=a[y]*c[y];a[13]=(x=b%11)<2?0:11-x;if(value.charAt(12)!=
a[12]||value.charAt(13)!=a[13])return false;return true}function DateFuture(a){var b,c,d,e=new Date;c=new Date;b=e.getDate();c=c.getMonth()+1;d=e.getFullYear();e=new Date(d,c-1,b);b=a.toString().split("/")[0];c=a.toString().split("/")[1];d=a.toString().split("/")[2];a=new Date(d,c-1,b);return a-e>0?false:true}function ValidarCNPJ(a,b){b.IsValid=isCnpj(b.Value)?true:false}function ValidarCPFCNPJ(a,b){a=b.Value;b.IsValid=document.length==11?isCpf(a)?true:false:isCnpj(a)?true:false}
function ValidarCPF(a,b){a=b.Value;a=clearString(a,"0123456789");b.IsValid=CaracIguais(a)?a.length<11?false:isCpf(a)?true:false:false}function validaCPF(a){a=clearString(a,"0123456789");if(!CaracIguais(a))return false;if(a.length<11)return false;if(!isCpf(a))return false;return true}function validarSobreNome(a){a=a;a=a.split(" ");return a[1].length<2?false:true}function verificaDependente(a){if(a.value!="")a.style.background=a.value>9?"yellow":"#ffffff"}
function validarTempoResidencia(a,b){if(b.val()==""){Alert(b,"O tempo de resid\u00eancia (em anos) deve ser preenchido.");return false}if(a.val()==""){Alert(a,"O tempo de resid\u00eancia (em meses) deve ser preenchido.");return false}if(a.val()<0||a.val()>11){a.val()==12?Alert(a,"O tempo em meses deve ser convertido em anos. 12 meses = 1 ano"):Alert(a,"O tempo de resid\u00eancia deve ser preenchido corretamente.");return false}if(b.val()==0&&a.val()<6){Alert(a,"O tempo de resid\u00eancia deve ser superior a 5 meses.");
return false}return true}function validarString(a){if(a.indexOf("  ")>0)return false;if(!CaracRepetidos(a))return false;return true}function CaracRepetidos(a){for(var b="",c="",d="",e=1;e<a.length-1;e++){b=a.substr(e-1,1);c=a.substr(e,1);d=a.substr(e+1,1);if(b==c&&c==d)return false}return true}function CaracIguais(a){for(var b=0;b<a.length-1;b++)if(a.substr(b,1)!=a.substr(b+1,1))return true;return false}
function ValidarTelefone(a){if(a.length<8)return false;a=a.substr(0,1);if(a==1||a==0||a==7||a==8||a==9)return false;return true}
function ValidarDDD(a,b){if(a.length<2)return false;switch(b){case "AC":if(a=="68")return true;break;case "AL":if(a=="82")return true;break;case "AP":if(a=="96")return true;break;case "AM":if(a=="92"||a=="97")return true;break;case "BA":if(a=="71"||a=="73"||a=="74"||a=="75"||a=="77")return true;break;case "CE":if(a=="85"||a=="88")return true;break;case "DF":if(a=="61")return true;break;case "ES":if(a=="27"||a=="28")return true;break;case "GO":if(a=="62"||a=="64")return true;break;case "MA":if(a==
"98"||a=="99")return true;break;case "MT":if(a=="65"||a=="66")return true;break;case "MS":if(a=="67")return true;break;case "MG":if(a=="31"||a=="32"||a=="33"||a=="34"||a=="35"||a=="37"||a=="38")return true;break;case "PA":if(a=="91"||a=="93"||a=="94")return true;break;case "PB":if(a=="83")return true;break;case "PR":if(a=="41"||a=="42"||a=="43"||a=="44"||a=="45"||a=="46")return true;break;case "PE":if(a=="81"||a=="87")return true;break;case "PI":if(a=="86"||a=="89")return true;break;case "RJ":if(a==
"21"||a=="24"||a=="22")return true;break;case "RN":if(a=="84")return true;break;case "RS":if(a=="51"||a=="53"||a=="54"||a=="55")return true;break;case "RO":if(a=="69")return true;break;case "RR":if(a=="95")return true;break;case "SC":if(a=="47"||a=="48"||a=="49")return true;break;case "SP":if(a=="11"||a=="12"||a=="13"||a=="14"||a=="15"||a=="16"||a=="17"||a=="18"||a=="19")return true;break;case "SE":if(a=="79")return true;break;case "TO":if(a=="63")return true;break}return false}
function ValidarCEP(a,b){var c=false;value=a.replace("-","");if(value.length<8)return false;for(a=0;a<value.length-1;a++)if(value.substr(a,1)!=value.substr(a+1,1))c=true;if(!c)return false;if(b!="")switch(b){case "AC":if(value<69900000||value>69999999)return false;break;case "AL":if(value<57000000||value>57999999)return false;break;case "AP":if(value<68900000||value>68999999)return false;break;case "AM":if(value<69000000||value>69299999)if(value<69400000||value>69899999)return false;break;case "BA":if(value<
40000000||value>48999999)return false;break;case "CE":if(value<60000000||value>63999999)return false;break;case "DF":if(value<70000000||value>72799999)if(value<73000000||value>73699999)return false;break;case "ES":if(value<29000000||value>29999999)return false;break;case "GO":if(value<72800000||value>72999999)if(value<73700000||value>76999999)return false;break;case "MA":if(value<65000000||value>65999999)return false;break;case "MT":if(value<78000000||value>78899999)return false;break;case "MS":if(value<
79000000||value>79999999)return false;break;case "MG":if(value<30000000||value>39999999)return false;break;case "PA":if(value<66000000||value>68899999)return false;break;case "PB":if(value<58000000||value>58999999)return false;break;case "PR":if(value<80000000||value>87999999)return false;break;case "PE":if(value<50000000||value>56999999)return false;break;case "PI":if(value<64000000||value>64999999)return false;break;case "RJ":if(value<20000000||value>28999999)return false;break;case "RN":if(value<
59000000||value>59999999)return false;break;case "RS":if(value<90000000||value>99999999)return false;break;case "RO":if(value<78900000||value>78999999)return false;break;case "RR":if(value<69300000||value>69399999)return false;break;case "SC":if(value<88000000||value>89999999)return false;break;case "SP":if(value<262144||value>19999999)return false;break;case "SE":if(value<49000000||value>49999999)return false;break;case "TO":if(value<77000000||value>77999999)return false;break}return true}
function DateDiff(a,b){var c,d,e;c=a.toString().split("/")[0];d=a.toString().split("/")[1];e=a.toString().split("/")[2];a=new Date(e,d-1,c);c=b.toString().split("/")[0];d=b.toString().split("/")[1];e=b.toString().split("/")[2];b=new Date(e,d-1,c);return b-a}function TextoNormalBlur(a,b){var c,d="";for(c=0;c<a.value.length;c++)d+=TextoNormalValidaCaracter(a.value.charAt(c),b);a.value=d}
function TextoNormalValidaCaracter(a,b){a=a;var c="";if(a>="0"&&a<="9")c=a;if(a>="A"&&a<="Z")c=a;if(a>="a"&&a<="z")c=a;if(a==" ")c=a;if(a=="\u00c3\u0081")c="A";if(a=="\u00c3\u00a1")c="a";if(a=="\u00c3\u20ac")c="a";if(a=="\u00c3 ")c="a";if(a=="\u00c3\u0192")c="A";if(a=="\u00c3\u00a3")c="a";if(a=="\u00c3\u201a")c="A";if(a=="\u00c3\u00a2")c="a";if(a=="\u00c3\u2030")c="E";if(a=="\u00c3\u00a9")c="e";if(a=="\u00c3\u0160")c="E";if(a=="\u00c3\u00aa")c="e";if(a=="\u00c3\u008d")c="I";if(a=="\u00c3")c="i";if(a==
"\u00c3\u201c")c="O";if(a=="\u00c3\u00b3")c="o";if(a=="\u00c3\u201d")c="O";if(a=="\u00c3\u00b4")c="o";if(a=="\u00c3\u2022")c="O";if(a=="\u00c3\u00b5")c="o";if(a=="\u00c3\u0161")c="U";if(a=="\u00c3\u00ba")c="u";if(a=="\u00c3\u2021")c="C";if(a=="\u00c3\u00a7")c="c";if(b){if(a=="-")c=a;if(a==".")c=a;if(a=="_")c=a;if(a=="@")c=a}else if(a=="_")c=" ";return c}
function TextoNormal(a,b,c){if(window.event)key=window.event.keyCode;else if(a)key=a.which;else return true;a=false;if(key>=48&&key<=57)a=true;if(key>=65&&key<=90)a=true;if(key>=97&&key<=122)a=true;if(key==32)a=true;if(key==8)a=true;if(key==13)a=true;if(key==0)a=true;var d="";if(key==193)a=true;if(key==225)a=true;if(key==195)a=true;if(key==227)a=true;if(key==201)a=true;if(key==233)a=true;if(key==202)a=true;if(key==234)a=true;if(key==205)a=true;if(key==237)a=true;if(key==211)a=true;if(key==243)a=true;
if(key==212)a=true;if(key==244)a=true;if(key==213)a=true;if(key==245)a=true;if(key==218)a=true;if(key==250)a=true;if(key==199)a=true;if(key==231)a=true;if(c){if(key==45)a=true;if(key==46)a=true;if(key==95)a=true;if(key==64)a=true}if(d!=""){b.value+=d;a=false}return a}function isNumber(a){var b=false;if(a.trim()!=""){b=/\D/;b=!b.test(a)}return b}
function getEndByCep(a,b,c,d,e,f,g){var j=document.getElementById(a);j=j.value.trim();j=j.replace("-","");if(j!="")if(isNumber(j))a=getCep("../../inc/getCep.asp?cep="+j,a,b,c,d,e,f,g);else CepInvalido(a,b,c,d,e,f,g)}function selEstado(a,b){for(i=0;a.length;i++)if(a[i]==b){a.selectedIndex=i;return}}
function getCep(a,b,c,d,e,f,g,j){AjaxRequest.get({url:a,onError:function(k){CepInvalido(b,c,d,e,f,g,j)},onSuccess:function(k){k=new String(k.responseText);if(k=="vazio")CepInvalido(b,c,d,e,f,g,j);else{k=k.split("|");if(k.length>0){var l=document.getElementById(b);l=document.getElementById(c);var m=document.getElementById(d),o=document.getElementById(e),p=document.getElementById(f),n=document.getElementById(g);n=document.getElementById(j);l.value=k[1];p.value=k[2];m.value=k[3];o.value=k[4];n.value=
k[5]}else CepInvalido(b,c,d,e,f,g,j)}}})}function CepInvalido(a,b,c,d,e,f,g){a=document.getElementById(a);b=document.getElementById(b);c=document.getElementById(c);d=document.getElementById(d);e=document.getElementById(e);f=document.getElementById(f);g=document.getElementById(g);if(!confirm("Cep n\u00c3\u00a3o encontrado. Deseja confirmar este Cep?")){a.value="";b.value="";c.value="";d.selectedIndex=0;e.value="";f.value="";a.focus();a.select();g.value=""}}
function customNome(a,b){a=b.Value;b.IsValid=validarNome(a)?true:false}function ValidarTelefone(a){if(a.length<8)return false;a=a.substr(0,1);if(a==1||a==0||a==7||a==8||a==9)return false;return true}function validarNome(a,b){a=a.trim();if(b!=1){b=a.indexOf(" ");if(b<2)return false}if(a.length<5)return false;if(!validarString(a))return false;return true}function validarSobreNome(a){a=a;a=a.split(" ");return a[a.length-1].length<2?false:true}
function onKeyPressInputCpf(a,b){return onlyNumbers(a,b)}function onKeyUpInputCpf(a,b){var c;if(window.event)a=window.event.keyCode;else if(a)a=a.which;else return;c=String.fromCharCode(a);if(a==8||a==46||a>=96&&a<=105||"0123456789".indexOf(c)>-1)b.value=cpfFormatted(b.value)}function onBlurInputCpf(a,b){b.value=cpfFormatted(b.value)}function clearString(a,b){var c="",d=-1,e=0;for(e=0;e<a.length;e++){d=b.indexOf(a.charAt(e));if(d>-1)c+=b.charAt(d)}return c}
function cpfFormatted(a){a=a;var b="",c="";b="";var d=[],e=0,f=0,g=0;a=clearString(a,"0123456789");if(a.length>2){b=a.substr(0,9);c=a.substr(9,2);if(b.length>3){d=[];e=0;f=1;for(g=0;e<b.length&&e<12;e++,f++)if(f%3==0){d.push(b.substr(e-2,3));g++}b=b.substr(3*g,b.length-3*g);b=b.length>0?d.join(".")+"."+b:d.join(".")}a=c.length>0?b+"-"+c:b}return a}
function FormataCampo(a,b,c,d){if(d=="S"&&consistente=="N"){if(obrigatorio=="N"&&a.value.length>0){obrig_fixo="S";Consist(a.maxLength,a);obrig_fixo="N"}if(obrigatorio=="S"||a.value.length>0)if(d=="S"){if(a.value.length!=c.length){Alert("O campo precisa estar neste formato:\n\n       "+c);a.value=""}erro="S";return false}}if(d=="S"&&obrigatorio=="N"&&a.value.length>0){obrig_fixo="S";Consist(a.maxLength,a);obrig_fixo="N";consistente=="N"&&Alert("O campo precisa estar neste formato:\n\n       "+c)}strtext=
a.value;tamtext=strtext.length;tammask=c.length;arrmask=new Array(tammask);for(d=0;d<tammask;d++)arrmask[d]=c.slice(d,d+1);if(arrmask[tamtext]=="#"||arrmask[tamtext]=="9"||arrmask[tamtext+1]!="#"||arrmask[tamtext+1]!="9")b.keyCode>=35&&b.keyCode<=40||b.keyCode>=48&&b.keyCode<=57||b.keyCode>=96&&b.keyCode<=105||b.keyCode==8||b.keyCode==9||b.keyCode==46||b.keyCode==13||b.keyCode==16?Organiza_Casa(a,arrmask[tamtext],b.keyCode,strtext):Detona_Event(a,strtext);else if(arrmask[tamtext]=="A"){charupper=
event.valueOf();Detona_Event(a,strtext);masktext=strtext+charupper;a.value=masktext}}function Organiza_Casa(a,b,c,d){if((b=="/"||b=="."||b==","||b==":"||b==" "||b=="-")&&c!=8){separador=b;masktext=d+separador;a.value=masktext}}function Detona_Event(a,b){event.returnValue=false;if(b!="")a.value=b}
function formatCurrency(a){a=a.toString().replace(/\$|\,/g,"");if(isNaN(a))a="0";sign=a==(a=Math.abs(a));a=Math.floor(a*100+0.50000000001);cents=a%100;a=Math.floor(a/100).toString();if(cents<10)cents="0"+cents;for(var b=0;b<Math.floor((a.length-(1+b))/3);b++)a=a.substring(0,a.length-(4*b+3))+"."+a.substring(a.length-(4*b+3));return(sign?"":"-")+""+a+","+cents}
function float2moeda(a){x=0;if(a<0){a=Math.abs(a);x=1}if(isNaN(a))a="0";cents=Math.floor((a*100+0.5)%100);a=Math.floor((a*100+0.5)/100).toString();if(cents<10)cents="0"+cents;for(var b=0;b<Math.floor((a.length-(1+b))/3);b++)a=a.substring(0,a.length-(4*b+3))+"."+a.substring(a.length-(4*b+3));ret=a+","+cents;if(x==1)ret=" - "+ret;return ret}
function validaFormVsContrate(){var a=$(".idCPFText"),b=$(".idDataText"),c=$(".idUF"),d=$(".idSexo"),e=$(".idCivil"),f=$(".idProdutoDDL");a=a.val();b=b.val();var g=b.split("/");g=new Date(g[1]+"/"+g[0]+"/"+g[2]);var j=new Date,k="",l=false;if(f.val()==""){k+="Selecione o produto de interesse\n";l=true}if(!isCpf(a)){k+="CPF inv\u00c3\u00a1lido\n";l=true}if(b==""){k+="Preencha a data de nascimento.\n";l=true}if(!isDate(g)){k+="Data de nascimento incorreta.\n";l=true}if(g>j){k+="Data de nascimento n\u00c3\u00a3o pode ser maior que data atual.\n";
l=true}if(c.val()==""){k+="Selecione a UF.\n";l=true}if(d.val()==""){k+="Selecione o sexo.\n";l=true}if(e.val()==""){k+="Selecione o estado civil.\n";l=true}if(l){Alert(k);return false}else return true}function getEndByCep(a,b,c,d,e,f,g){var j=$j("."+a);j=j.val().trim();j=j.replace("-","");if(j!="")if(isNumber(j))a=getCep("getCep.aspx?cep="+j,a,b,c,d,e,f,g);else CepInvalido(a,b,c,d,e,f,g)}
function CepInvalido(a,b,c,d,e,f,g){a=$j("."+a);b=$j("."+b);c=$j("."+c);d=$j("."+d);e=$j("."+e);f=$j("."+f);g=$j("."+g);if(!confirm("Cep n\u00e3o encontrado. Deseja confirmar este Cep?")){a.attr({value:""});b.attr({value:""});c.attr({value:""});d.attr({value:""});e.attr({value:""});f.attr({value:""});g.attr({value:""});a.focus()}}
function getCep(a,b,c,d,e,f,g,j){a=$.ajax({url:a,async:false}).responseText;if(a=="vazio"||a=="")CepInvalido(b,c,d,e,f,g,j);else{a=a.split("|");if(a.length>0){$j("."+c).attr({value:a[1]});$j("."+f).attr({value:a[2]});$j("."+d).attr({value:a[3]});$j("."+e).attr({value:a[4]});$j("."+j).attr({value:a[5]})}else CepInvalido(b,c,d,e,f,g,j)}}
function validarTempoAdmissao(){var a=$j(".dataNascimento").val();a=a.substr(3,2)+"/"+a.substr(0,2)+"/"+a.substr(6,4);a=new Date(a);var b="6/8/2008";b=b.substr(3,1)+"/"+b.substr(0,2)+"/"+b.substr(5,4);b=new Date(b);var c=$j(".unidadeTempoAtividade").val(),d=$j(".tempoAtividade").val();if(c=="a"){b=new Date(b.getFullYear()-d,b.getMonth(),b.getDate());if(a.getFullYear()>b.getFullYear()){Alert($j(".dataNascimento"),"A data de admiss\u00e3o informada est\u00e1 incorreta. A data n\u00e3o pode ser inferior a sua data de nascimento.");
return false}if(a.getFullYear()+14>=b.getFullYear()){Alert($j(".tempoAtividade"),"O tempo de atividade informado est\u00e1 incorreto. Voc\u00ea n\u00e3o pode exercer atividade remunerada antes dos 14 anos.");return false}}return true}
function verificaPreenchimentoTempoAdmissao(){var a=$j(".unidadeTempoAtividade").val(),b=$j(".tempoAtividade").val();if(a=="m")if(b<0||b>11){b==12?Alert($j(".tempoAtividade"),"O tempo em meses deve ser convertido em anos. 12 meses = 1 ano"):Alert($j(".tempoAtividade"),"O tempo de atividade deve ser preenchido corretamente.");return false}return true}
function NaturezaOcupacao_Change(){var a=$j(this);switch(a.val()){case "1":case "2":case "4":case "6":case "10":case "13":case "14":case "15":case "16":case "17":setRequireds(1);break;case "3":setRequireds(2);break;case "5":case "7":case "8":case "9":case "11":case "12":setRequireds(3);break}}function toogleRequiredClass(a,b){b?a.addClass("required").parent().find("em").show():a.removeClass("required").parent().find("em").hide()}
function setRequireds(a){var b=$j(".cepEmpresa"),c=$j(".nomeEmpresa"),d=$j(".cnpj"),e=$j(".enderecoEmpresa"),f=$j(".numeroEmpresa"),g=$j(".bairroEmpresa"),j=$j(".cidadeEmpresa"),k=$j(".estadoEmpresa"),l=$j(".dddEmpresa"),m=$j(".telefoneEmpresa");switch(a){case 1:toogleRequiredClass(b,true);toogleRequiredClass(c,true);toogleRequiredClass(d,false);toogleRequiredClass(e,true);toogleRequiredClass(f,true);toogleRequiredClass(g,true);toogleRequiredClass(j,true);toogleRequiredClass(k,true);toogleRequiredClass(l,
true);toogleRequiredClass(m,true);break;case 2:toogleRequiredClass(b,false);toogleRequiredClass(c,true);toogleRequiredClass(d,true);toogleRequiredClass(e,false);toogleRequiredClass(f,false);toogleRequiredClass(g,false);toogleRequiredClass(j,false);toogleRequiredClass(k,false);toogleRequiredClass(l,true);toogleRequiredClass(m,true);break;case 3:toogleRequiredClass(b,false);toogleRequiredClass(c,false);toogleRequiredClass(d,false);toogleRequiredClass(e,false);toogleRequiredClass(f,false);toogleRequiredClass(g,
false);toogleRequiredClass(j,false);toogleRequiredClass(k,false);toogleRequiredClass(l,false);toogleRequiredClass(m,false);break}}function objDisabled(a,b){if(b){strCor="#F7F7F7";a.attr({value:""})}else strCor="#FFFFFF";a.css({background:strCor});a.attr({disabled:b})}
function calculaIdade(a,b){var c=null;c=b==""?new Date("6/8/2008"):new Date(b);b=0;c=c.getDate()+"/"+c.getMonth()+"/"+c.getFullYear();x=a.split("/");h=c.split("/");if(x[0]>31||x[1]>12||x[2]>h[2])return 0;b=h[2]-x[2];if(h[1]<x[1])b-=1;else if(h[1]==x[1])if(h[0]<x[0])b-=1;return b}
function Menor18Anos(a){a=new Date(a);var b=new Date("6/8/2008");return a.getFullYear()>b.getFullYear()-PROPOSAL_MIN_AGE?true:a.getFullYear()==b.getFullYear()-PROPOSAL_MIN_AGE&&a.getMonth()>b.getMonth()?true:a.getFullYear()==b.getFullYear()-PROPOSAL_MIN_AGE&&a.getMonth()==b.getMonth()&&a.getDate()>b.getDate()?true:false}function verificaDependente(){var a=$j(".numeroDependentes");if(a.val()!="")a.val()>9?a.css({background:"yellow"}):a.css({background:"#ffffff"})}
function Menor14Anos(a,b){a=calculaIdade(b,a);return parseInt(a)<15}function Maior75Anos(a){return calculaIdade(a,"")<=PROPOSAL_MAX_AGE?false:true}function ConsistDataNascimento(a,b){var c=new Date(b),d=new Date(a);return DateDiff(a,b)<0||d.getFullYear()>c.getFullYear()?false:true}
function VerificarTextoNormalNosCampos(a){switch(a){case 2:TextoNormalBlur($j(".cidadeResidencia")[0],false);TextoNormalBlur($j(".bairroResidencia")[0],false);TextoNormalBlur($j(".enderecoResidencia")[0],false);break;case 3:TextoNormalBlur($j(".cidadeEmpresa")[0],false);TextoNormalBlur($j(".bairroEmpresa")[0],false);TextoNormalBlur($j(".enderecoEmpresa")[0],false);break}}
function Validar(){ConfigurarCampos();var a=$j("#proposal_product_id");if(a.val()=="0"){a.focus();Alert(a,"Voc\u00ea deve escolher um tipo de Cart\u00e3o.");return false}a=$j(".nomeCompleto");if(a.val()==""){a.focus();Alert(a,"Voc\u00ea deve preencher o campo Nome Completo.");return false}else{if(!validarNome(a.val())){a.focus();Alert(a,"Voc\u00ea deve preencher corretamente o campo Nome Completo.");return false}if(!validarSobreNome(a.val())){a.focus();Alert(a,"Voc\u00ea deve informar um Nome com Sobrenome com mais de 2 d\u00edgitos.");
return false}}a=$j(".email");if(a.val()==""){a.focus();Alert(a,"Voc\u00ea deve preencher o campo Email.");return false}if(!isEmail(a.val())){a.focus();Alert(a,"Email inv\u00e1lido.");return false}a=$j(".sexo");if(a.val()=="0"){a.focus();Alert(a,"Voc\u00ea deve escolher uma op\u00e7\u00e3o no campo Sexo.");return false}a=$j(".estadoCivil");if(a.val()=="0"){a.focus();Alert(a,"Voc\u00ea deve escolher uma op\u00e7\u00e3o no campo Estado civil.");return false}if(a.val()=="2"){a=$j(".nomeConjuge");if(a.val()==
""){a.focus();Alert(a,"Voc\u00ea deve preencher o campo Nome do C\u00f4njuge.");return false}else{if(!validarNome(a.val())){a.focus();Alert(a,"Voc\u00ea deve preencher corretamente o campo Nome do C\u00f4njuge.");return false}if(!validarSobreNome(a.val())){a.focus();Alert(a,"Voc\u00ea deve informar o Nome do C\u00f4njuge com um sobrenome com mais de 2 d\u00edgitos.");return false}}}a=$j(".dataNascimento");if(a.val()==""||a.val()=="dd/mm/aaaa"){a.focus();Alert(a,"Data de nascimento n\u00e3o informada.");
return false}if(!isDate(a.val())){a.focus();Alert(a,"Data de nascimento inv\u00e1lida.");return false}if(Menor18Anos(a.val())){a.focus();Alert(a,"\u00c9 necess\u00e1rio ter no m\u00ednimo "+PROPOSAL_MIN_AGE+" anos.");return false}if(Maior75Anos(a.val())){a.focus();Alert(a,"\u00c9 necess\u00e1rio ter no m\u00e1ximo "+PROPOSAL_MAX_AGE+" anos.");return false}var b=$j(".nacionalidade");if(b.val()=="0"){b.focus();Alert(b,"Voc\u00ea deve preencher o campo Nacionalidade.");return false}b=$j(".naturalUf");
if(b.val()=="0"){b.focus();Alert(b,"Selecione o estado de que voc\u00ea \u00e9 natural.");return false}b=$j(".naturalidade");if(b.val()==""){b.focus();Alert(b,"Voc\u00ea deve preencher o campo Naturalidade.");return false}if(!validarString(b.val())||b.val().length<3){b.focus();Alert(b,"Voc\u00ea deve preencher corretamente o campo Naturalidade.");return false}b=$j(".nomeMae");if(b.val()==""){b.focus();Alert(b,"Voc\u00ea deve preencher o campo Nome da m\u00e3e.");return false}else{if(!validarNome(b.val())){b.focus();
Alert(b,"Voc\u00ea deve preencher corretamente o campo Nome da m\u00e3e.");return false}if(!validarSobreNome(b.val())){b.focus();Alert(b,"Voc\u00ea deve informar o campo Nome da M\u00e3e com um sobrenome com mais de 2 d\u00edgitos.");return false}}b=$j(".nomePai");if(b.val()!=""){if(!validarNome(b.val())){b.focus();Alert(b,"O campo Nome do Pai n\u00e3o foi preenchido corretamente, informe seu nome completo.");return false}if(!validarSobreNome(b.val())){b.focus();Alert(b,"Voc\u00ea deve informar o campo Nome do Pai com um sobrenome com mais de 2 d\u00edgitos.");
return false}}b=$j(".identidade");if(b.val()==""){b.focus();Alert(b,"Voc\u00ea deve preencher o campo Identidade.");return false}else if(b.val().length<6||b.val()<1){b.focus();Alert(b,"Voc\u00ea deve preencher corretamente o campo Identidade.");return false}b=$j(".orgaoEmissor");if(b.val()==""){b.focus();Alert(b,"Voc\u00ea deve preencher o campo \u00d3rg\u00e3o emissor.");return false}b=$j(".orgaoEmissorUf");if(b.val()=="0"){b.focus();Alert(b,"Selecione o estado do \u00d3rg\u00e3o emissor.");return false}b=
$j(".dataExpedicao");var c=new Date(b.val()),d=new Date(a.val());if(b.val()==""||b.val()=="dd/mm/aaaa"){b.focus();Alert(b,"Data de expedi\u00e7\u00e3o n\u00e3o informada.");return false}if(!isDate(b.val())){b.focus();Alert(b,"Data de expedi\u00e7\u00e3o inv\u00e1lida.");return false}if(ConsistDataNascimento(b.val(),a.val())||c>Date()||c<d){b.focus();Alert(b,"Data de expedi\u00e7\u00e3o inv\u00e1lida.");return false}a=$j(".cpf");if(a.val()==""){a.focus();Alert(a,"Voc\u00ea deve preencher o campo CPF.");
return false}else if(!validaCPF(a.val())){a.focus();Alert(a,"CPF informado \u00e9 inv\u00e1lido.");return false}a=$j(".exposicaoPolitica");if(a.val()=="-1"){a.focus();Alert(a,"Exposi\u00e7\u00e3o pol\u00edtica n\u00e3o informada.");return false}b=$j(".cepResidencia");a=$j(".estadoResidencia");if(b.val().length<=0){b.focus();Alert(b,"Voc\u00ea deve preencher o CEP.");return false}else if(!ValidarCEP(b.val(),a.val())){b.focus();Alert(b,"Voc\u00ea deve preencher um CEP v\u00e1lido para o Estado selecionado.");
return false}c=$j(".enderecoResidencia");if(c.val().trim()==""){b.focus();Alert(b,"Voc\u00ea deve informar um CEP v\u00e1lido!");return false}else if(!validarNome(c.val().trim())){b.focus();Alert(b,"Voc\u00ea deve informar um CEP v\u00e1lido!");return false}c=$j(".numeroResidencia");if(c.val()==""){c.focus();Alert(c,"Voc\u00ea deve preencher o N\u00famero do endere\u00e7o.");return false}c=$j(".bairroResidencia");if(c.val()==""){b.focus();Alert(b,"Voc\u00ea deve informar um CEP v\u00e1lido!");return false}if(a.val()==
"0"){b.focus();Alert(b,"Voc\u00ea deve informar um CEP v\u00e1lido!");return false}c=$j(".cidadeResidencia");if(c.val()==""){b.focus();Alert(b,"Voc\u00ea deve informar um CEP v\u00e1lido!");return false}else if(!validarString(c.val())){b.focus();Alert(b,"Voc\u00ea deve informar um CEP v\u00e1lido!");return false}c=$j(".dddResidencia");d=$j(".telefoneResidencia");b="option[value="+a.val()+"]";if(c.val()==""){c.focus();Alert(c,"Voc\u00ea deve preencher o DDD.");return false}else if(d.val()==""){d.focus();
Alert(d,"Voc\u00ea deve preencher o Telefone.");return false}else if(!ValidarDDD(c.val(),a.find(b).text())){c.focus();Alert(c,"Voc\u00ea deve preencher um DDD v\u00e1lido para o Estado selecionado.");return false}c=$j(".dddCelular");d=$j(".celular");if(c.val()!=""||d.val()!="")if(c.val()==""){c.focus();Alert(c,"Voc\u00ea deve preencher o DDD do Celular.");return false}else if(ValidarDDD(c.val(),a.find(b).text())){if(d.val()==""){d.focus();Alert(d,"Voc\u00ea deve preencher o Celular.");return false}}else{c.focus();
Alert(c,"Voc\u00ea deve preencher um DDD de celular v\u00e1lido para o Estado selecionado.");return false}d=$j(".telefoneResidencia");if(d.val()!="")if(!ValidarTelefone(d.val())){d.focus();Alert(d,"Voc\u00ea deve preencher corretamente o campo Telefone.");return false}a=$j(".dataNascimento");a=new Date(a.val());b=new Date("6/8/2008");a=a.getFullYear();c=$j(".tempoResidencia");c=$j(".tempoAnosResidencia");d=$j(".tempoMesesResidencia");b=b.getFullYear()-c.val();if(!validarTempoResidencia(d,c))return false;
if(Number(b)<new Number(a)){c.focus();Alert(c,"O Tempo de resid\u00eancia deve ser menor ou igual sua idade.");return false}c=$j(".tipoResidencia");if(c.val()=="0"){c.focus();Alert(c,"Voc\u00ea deve escolher o Tipo de resid\u00eancia.");return false}c=$j(".tempoAnteriorResidencia");d=$j(".unidateTempoAnteriorResidencia");if(c.val()!=""){if(d.val()=="1"){b-=parseInt(c.val());if(Number(b)<Number(a)){c.focus();Alert(c,"O Tempo de resid\u00eancia total deve ser menor ou igual sua idade.");return false}}if(d.val()==
"0"){d.focus();Alert(d,"Voc\u00ea deve escolher entre M\u00eas e Ano o per\u00edodo de resid\u00eancia anterior.");return false}}a=$j(".naturezaOcupacao");if(a.val()=="0"){a.focus();Alert(a,"Voc\u00ea deve preencher o campo Natureza da Ocupa\u00e7\u00e3o.");return false}b=$j(".cepEmpresa");a=$j(".estadoEmpresa");if(b.is(".required")&&a.is(".required"))if(b.val()==""){b.focus();Alert(b,"Voc\u00ea deve preencher o CEP correto da empresa em que trabalha.");return false}else if(!ValidarCEP(b.val(),a.find("option:selected").text())){b.focus();
Alert(b,"Voc\u00ea deve preencher um CEP v\u00e1lido para o Estado selecionado.");return false}c=$j(".nomeEmpresa");if(c.is(".required"))if(c.val()==""){c.focus();Alert(c,"Voc\u00ea deve preencher o Nome da empresa.");return false}else if(!validarNome(c.val(),1)){c.focus();Alert(c,"Voc\u00ea deve preencher corretamente o Nome da empresa.");return false}c=$j(".cnpj");if(c.is(".required"))if(c.val()==""){c.focus();Alert(c,"Voc\u00ea deve preencher o campo Cnpj.");return false}else if(!isCnpj(c.val())){c.focus();
Alert(c,"Voc\u00ea deve corretamente o campo Cnpj.");return false}c=$j(".enderecoEmpresa");if(c.is(".required"))if(c.val()==""){b.focus();Alert(b,"Voc\u00ea deve preencher o CEP correto da empresa em que trabalha.");return false}else if(!validarNome(c.val(),1)){b.focus();Alert(b,"Voc\u00ea deve preencher o CEP correto da empresa em que trabalha.");return false}c=$j(".numeroEmpresa");if(c.is(".required"))if(c.val()==""){c.focus();Alert(c,"Voc\u00ea deve preencher o N\u00famero do endere\u00e7o da empresa em que trabalha.");
return false}c=$j(".bairroEmpresa");if(c.is(".required"))if(c.val()==""){b.focus();Alert(b,"Voc\u00ea deve preencher o CEP correto da empresa em que trabalha.");return false}if(a.is(".required"))if(a.val()=="0"){b.focus();Alert(b,"Voc\u00ea deve preencher o CEP correto da empresa em que trabalha.");return false}c=$j(".cidadeEmpresa");if(c.is(".required"))if(c.val()==""){b.focus();Alert(b,"Voc\u00ea deve preencher o CEP correto da empresa em que trabalha.");return false}else if(!validarString(c.val())){b.focus();
Alert(b,"Voc\u00ea deve preencher o CEP correto da empresa em que trabalha.");return false}b=$j(".dddEmpresa");if(b.is(".required"))if(b.val()==""){b.focus();Alert(b,"Voc\u00ea deve preencher o DDD da empresa em que trabalha.");return false}else if(a.is(".required"))if(!ValidarDDD(b.val(),a.find("option:selected").text())){b.focus();Alert(b,"Voc\u00ea deve preencher um DDD v\u00e1lido para o Estado selecionado.");return false}a=$j(".telefoneEmpresa");if(a.is(".required"))if(a.val()==""){a.focus();
Alert(a,"Voc\u00ea deve preencher o Telefone da empresa em que trabalha.");return false}else if(!ValidarTelefone(a.val())){a.focus();Alert(a,"Voc\u00ea deve preencher corretamente o campo Telefone da empresa em que trabalha.");return false}a=$j(".tempoAtividade");b=$j(".unidadeTempoAtividade");if(a.val()==""&&b.val()=="0"){a.focus();Alert(a,"Voc\u00ea deve preencher o campo Tempo de Atividade.");return false}if(a.val()!="")if(b.val()=="0"){b.focus();Alert(b,"Selecione o per\u00edodo a que se refere o tempo de atividade.");
return false}if(b.val()!="0")if(a.val()==""){a.focus();Alert(a,"Informe o tempo de atividade.");return false}if(!verificaPreenchimentoTempoAdmissao()){a.focus();return false}if(!validarTempoAdmissao()){a.focus();return false}a=$j(".profissaoEmpresa");if(a.find("option:selected").val()==0){a.focus();Alert(a,"Voc\u00ea deve preencher o campo Profiss\u00e3o.");return false}a=$j(".rendaEmpresa");if(a.val()==""){a.focus();Alert(a,"Voc\u00ea deve preencher a Renda que recebe na empresa em que trabalha atualmente.");
return false}c=a.val();c=c.split(".").join("");c=c.split(",").join(".");b=a=PROPOSAL_MAINREVENUE;a=a.split(".").join("");a=a.split(",").join(".");if(parseFloat(c)<a){d=$j(".valorOutraRendaEmpresa").val();if(d==""){Alert($j(".valorOutraRendaEmpresa"),"Voc\u00ea deve informar um valor maior ou igual que a renda m\u00ednima (R$ "+b+").");return false}else{d=d.split(".").join("");d=d.split(",").join(".");c=parseFloat(c)+parseFloat(d);if(c<a){Alert($j(".valorOutraRendaEmpresa"),"Voc\u00ea deve informar um valor maior ou igual que a renda m\u00ednima (R$ "+
b+").");return false}}}a=$j(".tempoTrabalhoAnteriorEmpresa");b=$j(".unidadeTempoTrabalhoAnteriorEmpresa");if(a.val()!="")if(b.val()=="0"){b.focus();Alert(b,"Selecione o per\u00edodo a que se refere o tempo trabalhado anteriormente.");return false}if(b.val()!="0")if(a.val()==""){Alert(a,"Informe o tempo de trabalho na empresa anteriormente.");return false}a=$j(".nomeReferencia");if(a.val()==""){a.focus();Alert(a,"Voc\u00ea deve preencher o nome da Refer\u00eancia Pessoal.");return false}else{if(!validarNome(a.val())){a.focus();
Alert(a,"Voc\u00ea deve preencher corretamente o campo Nome da Refer\u00eancia Pessoal.");return false}if(!validarSobreNome(a.val())){a.focus();Alert(a,"Voc\u00ea deve informar o Nome da Refer\u00eancia Pessoal com sobrenome com mais de 2 d\u00edgitos.");return false}}a=$j(".parentescoReferencia");if(a.val()=="0"){a.focus();Alert(a,"Voc\u00ea deve preencher o grau de parentesco.");return false}a=$j(".dddReferencia");if(a.val()==""){a.focus();Alert(a,"Voc\u00ea deve preencher o DDD da refer\u00eancia pessoal.");
return false}a=$j(".telefoneReferencia");if(a.val()==""){a.focus();Alert(a,"Voc\u00ea deve preencher o Telefone da refer\u00eancia pessoal.");return false}else if(!ValidarTelefone(a.val())){a.focus();Alert(a,"Voc\u00ea deve preencher corretamente o Telefone da refer\u00eancia pessoal.");return false}a=$j(".nomeReferencia2");if(a.val()!=""){if(!validarNome(a.val())){a.focus();Alert(a,"Voc\u00ea deve preencher corretamente o campo Nome da Refer\u00eancia Pessoal.");return false}if(!validarSobreNome(a.val())){a.focus();
Alert(a,"Voc\u00ea deve informar o Nome da Refer\u00eancia Pessoal com sobrenome com mais de 2 d\u00edgitos.");return false}a=$j(".parentescoReferencia2");if(a.val()=="0"){a.focus();Alert(a,"Voc\u00ea deve preencher o grau de parentesco.");return false}else{a=$j(".dddReferencia2");if(a.val()==""){a.focus();Alert(a,"Voc\u00ea deve preencher o DDD da refer\u00eancia pessoal.");return false}a=$j(".telefoneReferencia2");if(a.val()==""){a.focus();Alert(a,"Voc\u00ea deve preencher o Telefone da refer\u00eancia pessoal.");
return false}else if(!ValidarTelefone(a.val())){a.focus();Alert(a,"Voc\u00ea deve preencher corretamente o Telefone da refer\u00eancia pessoal.");return false}}}a=$j("input.chequeEspecial:checked");if(a.length<=0){a.focus();Alert(a,"Responda se voc\u00ea possui cheque especial.");return false}a=$j("input[name=proposal.prospect.billinginfo.duedate.id]:checked");b=$j("input[name=proposal.prospect.billinginfo.duedate.id]");if(a.length<=0){b.focus();Alert(b,"Voc\u00ea deve escolher entre uma das Datas de vencimento de extrato.");
return false}$j(".cep, .cpf, .cnpj, .telefone, .numeroAgencia, .ramalEmpresa, .ramalResidencia").each(function(){this.value=this.value.replace(/[^\d]/gi,"")});$j(".view-only").attr("disabled",false);$j(".btnSim").attr("disabled","disabled");return true};
