
function limpa_campo(campo){if(campo==1){document.tipo_veiculo.tipo_preco0.checked=true;document.tipo_veiculo.valor_preco2.value='';}
if(campo==2){document.tipo_veiculo.tipo_preco1.checked=true;document.tipo_veiculo.valor_preco1.value='';}}
function FormataValor(valorvariavel,valorcampo,teclapres,tammax)
{var tecla=teclapres.keyCode;if(!(tecla==8||(tecla>=48&&tecla<=57)||(tecla>=96&&tecla<=105||tecla==188||tecla==9||tecla==190||tecla==194||tecla==110)))
{valorcampo.value='';teclapres.keyCode=46;}
if(valorvariavel=='')
{var trava="";trava=valorcampo.value;if(trava.length>=tammax)
{return false;}}
if(valorvariavel!=''){var Decimal=false;var ValorDecimal=valorvariavel;for(i=0;i<ValorDecimal.length;i++){if(isNaN(ValorDecimal.substring(i,i+1))){if(ValorDecimal.substring(i,i+1)=='.'||ValorDecimal.substring(i,i+1)==',')
{var Decimal=true;}}}
if(!(Decimal))
{valorvariavel+='00'}}
if(valorvariavel==''){vr=LimparValor(valorcampo.value,"0123456789");var retorno=valorcampo.value
tam=vr.length;if(tam<tammax&&tecla!=8){tam=vr.length+1;}
if(tecla==8){tam=tam-1;}}
else{vr=LimparValor(valorvariavel,"0123456789");var retorno=valorvariavel
tam=vr.length;}
if(tam>(tammax-2)||valorvariavel!=''||tecla==8||tecla>=48&&tecla<=57||tecla>=96&&tecla<=105){if(tam<=2){retorno=vr;}
if((tam>=2)&&(tam<=5)){retorno=vr.substr(0,tam-2)+','+vr.substr(tam-2,tam);}
if((tam>=6)&&(tam<=8)){retorno=vr.substr(0,tam-5)+'.'+vr.substr(tam-5,3)+','+vr.substr(tam-2,tam);}
if((tam>=9)&&(tam<=11)){retorno=vr.substr(0,tam-8)+'.'+vr.substr(tam-8,3)+'.'+vr.substr(tam-5,3)+','+vr.substr(tam-2,tam);}
if((tam>=12)&&(tam<=14)){retorno=vr.substr(0,tam-11)+'.'+vr.substr(tam-11,3)+'.'+vr.substr(tam-8,3)+'.'+vr.substr(tam-5,3)+','+vr.substr(tam-2,tam);}
if((tam>=15)&&(tam<=17)){retorno=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);}}
if(valorvariavel==''){valorcampo.value=retorno;}
else{return retorno;}}
function LimparValor(valor,validos){var result="";var aux;for(var i=0;i<valor.length;i++){aux=validos.indexOf(valor.substring(i,i+1));if(aux>=0){result+=aux;}}
return result;}
function teste(valorvariavel,valorcampo,teclapres,tammax)
{var tecla=teclapres.keyCode;if(!(tecla==8||(tecla>=48&&tecla<=57)||(tecla>=96&&tecla<=105||tecla==188||tecla==9||tecla==190||tecla==194||tecla==110)))
{valorcampo.value='';teclapres.keyCode=46;}
if(valorvariavel=='')
{var trava="";trava=valorcampo.value;if(trava.length>=tammax)
{return false;}}}
function txtBoxFormat(objForm,strField,sMask,evtKeyPress){var i,nCount,sValue,fldLen,mskLen,bolMask,sCod,nTecla;if(navigator.appVersion.indexOf("MSIE")!=-1)
nTecla=evtKeyPress.keyCode;else
nTecla=evtKeyPress.which;sValue=objForm[strField].value;sValue=sValue.toString().replace("-","");sValue=sValue.toString().replace("-","");sValue=sValue.toString().replace(".","");sValue=sValue.toString().replace(".","");sValue=sValue.toString().replace("/","");sValue=sValue.toString().replace("/","");sValue=sValue.toString().replace("(","");sValue=sValue.toString().replace("(","");sValue=sValue.toString().replace(")","");sValue=sValue.toString().replace(")","");sValue=sValue.toString().replace(" ","");sValue=sValue.toString().replace(" ","");fldLen=sValue.length;mskLen=sMask.length;i=0;nCount=0;sCod="";mskLen=fldLen;while(i<=mskLen){bolMask=((sMask.charAt(i)=="-")||(sMask.charAt(i)==".")||(sMask.charAt(i)=="/"))
bolMask=bolMask||((sMask.charAt(i)=="(")||(sMask.charAt(i)==")")||(sMask.charAt(i)==" "))
if(bolMask){sCod+=sMask.charAt(i);mskLen++;}
else{sCod+=sValue.charAt(nCount);nCount++;}
i++;}
objForm[strField].value=sCod;if(nTecla!=8){if(sMask.charAt(i-1)=="9"){return((nTecla>47)&&(nTecla<58));}
else{return true;}}
else{return true;}}
function teste_email(str){var strAlfa="ABCDEFGHIJKLMNOPQRSTUWVXYZ";var strNum="0123456789";var strSpecial="_.-@";var strValid=strAlfa+strNum+strSpecial;if(str!=null){var email=str.toUpperCase();for(i=0;i<email.length;i++){if(strValid.indexOf(email.charAt(i))<0){return false;}}
var strC="@.";for(i=0;i<strC.length;i++){if(email.indexOf(strC.charAt(i))<0)
return false;}
if(email.indexOf("@")!=email.lastIndexOf("@"))
return false;if(email.indexOf("@")>email.lastIndexOf("."))
return false;if(email.charAt(email.indexOf("@")+1)==".")
return false;if(!(email.indexOf("@")!=0&&email.lastIndexOf(".")!=email.length-1))
return false;}
return true;}