if(!window.isEmpty){window.isEmpty=function(val){var re=/^\s{1,}$/g;if((val.length==0)||(val==null)||((val.search(re))>-1)){return true;}else{return false;}}}
if(!window.isCPF){window.isCPF=function(arg){var pri=arg.substring(0,3);var seg=arg.substring(4,7);var ter=arg.substring(8,11);var qua=arg.substring(12,14);var i;var numero=(pri+seg+ter+qua);var s=numero;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);var result;if(d1==0)result="falso";d1=11-(d1%11);if(d1>9)d1=0;if(dv.charAt(0)!=d1)result="falso";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)result="falso";return!(result=="falso");}}
if(!window.isCNPJ){window.isCNPJ=function(str){if(!(str=/^\d?(\d{2})\.?(\d{3})\.?(\d{3})\/?(\d{4})\-?(\d{2})/.exec(str)))
return false;var sum1=0,sum2=0,sum3=0,calc1=5,calc2=6;str.shift();str=str.join("");for(var i=0;i<=12;i++){calc1=(calc1<2)?9:calc1;calc2=(calc2<2)?9:calc2;if(i<=11)
sum1+=str[i]*calc1;sum2+=str[i]*calc2;sum3+=str[i];calc1--;calc2--;}
sum1%=11;sum2%=11;return(sum3&&str[12]==(sum1<2?0:11-sum1)&&str[13]==(sum2<2?0:11-sum2))?str:false;}}
if(!window.isEmail){function isEmail(str){var apos=str.indexOf("@");return!(apos<1||str.lastIndexOf(".")-apos<2);}}
if(!$.fn.validar){(function(){$.fn.validar=function(_opts){var opts=$.extend({},$.fn.validar.options,_opts);this.submit(function(){var $this=$(this);return $this.validar.me.call($this,opts);});}
$.fn.validar.me=function(o){var r=true;try{r=o.before();}catch(e){r=false;}
try{this.find("input, select, textarea").filter("[req=true], [req=text], [req=email], [req=cpf], [req=equals], [req=cnpj]").filter(":visible").each(function(){var $this=$(this),val=$.trim($this.val()),label='',req=$this.attr("req");if(typeof $("label[for="+$this.attr("id")+"]")[0]=="object"){label=$.trim($("label[for="+$this.attr("id")+"]").text());}else{label=$.trim($this.attr("label"));}
try{if(r){if(isEmpty(val)){throw"Por favor, preencha o campo "+label+".";}else if(req=="email"){if(!isEmail(val)){throw"Por favor, preencha o corretamente o campo "+label+".";}}else if(req=="cpf"){if(!isCPF(val)){throw"Por favor, preencha o corretamente o campo "+label+".";}}else if(req=="cnpj"){if(!isCNPJ(val)){throw"Por favor, preencha o corretamente o campo "+label+".";}}else if(req=="equals"){if(val!=$($this.attr("equals")).val()){throw"Por favor, preencha o corretamente o campo "+label+".";}}}}catch(e){r=false;o.alert(e);setTimeout(function(){$this.focus();},10);}})}catch(e){alert(e);r=false;}
if(r&&typeof o.end=="function"){try{r=o.end();}catch(e){r=false;}}
return r;}
$.fn.validar.options={before:function(){return true;},end:function(){return true;},alert:(function(){if(window.Notify){return function(msg){new Notify(msg);}}else{return function(msg){alert(msg);}}})()}})()}
