function vazio(a,b){document.getElementById(a).style.border="solid 1px #afcf30";if(document.getElementById(a).value==""){document.getElementById(a).style.border="solid 1px #afcf30";msgBox(" O campo "+b+" deve ser preenchido corretamente!");document.getElementById(a).focus();return true}document.getElementById(a).style.border="solid 1px #afcf30";return false}function limpa_mask(a){sValue=a.value;while(sValue.indexOf("-")>=0){sValue=sValue.toString().replace("-","")}while(sValue.indexOf(":")>=0){sValue=sValue.toString().replace(":","")}while(sValue.indexOf(".")>=0){sValue=sValue.toString().replace(".","")}while(sValue.indexOf("/")>=0){sValue=sValue.toString().replace("/","")}while(sValue.indexOf("(")>=0){sValue=sValue.toString().replace("(","")}while(sValue.indexOf(")")>=0){sValue=sValue.toString().replace(")","")}while(sValue.indexOf(" ")>=0){sValue=sValue.toString().replace(" ","")}return sValue}function mask(h,d,l){var e,a,k,f,b,c,g,j;if(document.all){j=l.keyCode}else{j=l.which}if(navigator.appName!="Microsoft Internet Explorer"){if(j==8){return true}}k=limpa_mask(document.getElementById(h));f=k.length;b=d.length;e=0;a=0;g="";b=f;while(e<=b){c=((d.charAt(e)=="-")||(d.charAt(e)==".")||(d.charAt(e)=="/"));c=c||((d.charAt(e)=="(")||(d.charAt(e)==")")||(d.charAt(e)==" "));if(c){g+=d.charAt(e);b++}else{g+=k.charAt(a);a++}e++}document.getElementById(h).value=g;if(j!=8){if(d.charAt(e-1)=="9"){return((j>47)&&(j<58))}}return true}function Limpar(e,c){var b="";var a;for(var d=0;d<e.length;d++){a=c.indexOf(e.substring(d,d+1));if(a>=0){b+=a}}return b}function Formata(b,e,d,a){var c=d.keyCode;vr=Limpar(b.value,"0123456789");tam=vr.length;dec=a;if(tam<e&&c!=8){tam=vr.length+1}if(c==8){tam=tam-1}if(c==8||c>=48&&c<=57||c>=96&&c<=105){if(tam<=dec){b.value=vr}if((tam>dec)&&(tam<=5)){b.value=vr.substr(0,tam-2)+","+vr.substr(tam-dec,tam)}if((tam>=6)&&(tam<=8)){b.value=vr.substr(0,tam-5)+vr.substr(tam-5,3)+","+vr.substr(tam-dec,tam)}if((tam>=9)&&(tam<=11)){b.value=vr.substr(0,tam-8)+""+vr.substr(tam-8,3)+""+vr.substr(tam-5,3)+","+vr.substr(tam-dec,tam)}if((tam>=12)&&(tam<=14)){b.value=vr.substr(0,tam-11)+""+vr.substr(tam-11,3)+"."+vr.substr(tam-8,3)+""+vr.substr(tam-5,3)+","+vr.substr(tam-dec,tam)}if((tam>=15)&&(tam<=17)){b.value=vr.substr(0,tam-14)+""+vr.substr(tam-14,3)+""+vr.substr(tam-11,3)+""+vr.substr(tam-8,3)+""+vr.substr(tam-5,3)+","+vr.substr(tam-2,tam)}}};
