function Mask(o,f,t){v_obj=o;v_fun=f;v_tip=t;setTimeout("execmascara()",1);}function execmascara(){if(v_tip!=""){v_obj.value=v_fun(v_obj.value,v_tip);}else{v_obj.value=v_fun(v_obj.value,"");}}function Site(v){v=v.replace(/^http:\/\/?/,"");dominio=v;caminho="";if(v.indexOf("/")>-1){dominio=v.split("/")[0];}caminho=v.replace(/[^\/]*/,"");dominio=dominio.replace(/[^\w\.\+-:@]/g,"");caminho=caminho.replace(/[^\w\d\+-@:\?&=%\(\)\.]/g,"");caminho=caminho.replace(/([\?&])=/,"$1");if(caminho!=""){dominio=dominio.replace(/\.+$/,"");}v="http://"+dominio+caminho;return v;}function confir_campo(campo1,campo2,campo3){if(campo1==campo3){document.getElementById(campo2).style.background="#ff0000";}else{if(campo1==""){document.getElementById(campo2).style.background="#ff0000";}else{document.getElementById(campo2).style.background="#D0E0DD";}}}function display(id,dsp){var disp=document.getElementById(id);if(dsp!=""){document.getElementById(id).style.display="none";document.getElementById(id).style.display=dsp;}else{if(disp.style.display=="none"){document.getElementById(id).style.display="none";document.getElementById(id).style.display="block";}else{document.getElementById(id).style.display="none";}}}function confirma_senha(senha1,senha2,senha3,senha4){if(senha1!=senha2){alert("Senhas não conferem");document.getElementById(senha3).style.background="#ff0000";document.getElementById(senha4).style.background="#ff0000";}else{if(senha1==""){alert("Preencha o campo senha");document.getElementById(senha3).style.background="#ff0000";document.getElementById(senha4).style.background="#ff0000";}else{document.getElementById(senha3).style.background="#D0E0DD";document.getElementById(senha4).style.background="#D0E0DD";}}}function numero(v,t){v=v.replace(/\D/g,"");if(t=="1"){v=v.replace(/(\d{4})(\d)/,"$1-$2");}return v;}function mostrar(mostra,item,valor){if(mostra=="mostrar"){if(valor=="0"){document.getElementById(item).disabled=true;}else{document.getElementById(item).disabled=false;}}else{if(mostra=="esconder"){document.getElementById(item).disabled=true;}}}var checkCount=0;function setChecks(obj,maxChecks){var checks=document.getElementsByName(obj);var total=checks.length;var checkados=0;for(var x=0;x<total;++x){if(checks[x].checked==true){++checkados;}if(checkados>maxChecks){checks[x].checked=false;}}if(checkados>maxChecks){alert("Você pode escolher no máximo até "+maxChecks+" opções");}}function pula_campo(campo,max,prox_campo){if(campo.value.length==max){prox_campo.focus();}}function copiaEmail(email,id,id2){document.getElementById(id).value=email.value;if(id2!=""){document.getElementById(id2).value=email.value;}}function ValidaMinLeng(vId,divId,tdId,minNum){var cvalue=vId.value;if(cvalue.length<minNum){if(divId=="login_error"){document.getElementById("login_error").innerHTML="<span id='l_error' class='obg'>Utilize um login com no mínimo 5 caracteres</span>";}else{document.getElementById("divId").innerHTML="<span id='l_error' class='obg'>Utilize um login com no mínimo 5 caracteres</span>";}}else{document.getElementById(divId).innerHTML="";}}function busca(id,acao,id_select){$.ajax({type:"POST",url:"/ajax.php",data:"acao="+acao+"&codig_id="+id,beforeSend:function(){},success:function(txt){$("#"+id_select).html(txt);},error:function(txt){}});}function Dados(valor){try{ajax=new ActiveXObject("Microsoft.XMLHTTP");}catch(e){try{ajax=new ActiveXObject("Msxml2.XMLHTTP");}catch(ex){try{ajax=new XMLHttpRequest();}catch(exc){alert("Esse browser não tem recursos para uso do Ajax");ajax=null;}}}if(ajax){document.forms[0].cidade_emp.options.length=1;idOpcao=document.getElementById("opcoes");ajax.open("POST","busca.php",true);ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");ajax.onreadystatechange=function(){if(ajax.readyState==1){idOpcao.innerHTML="Carregando...!";}if(ajax.readyState==4){if(ajax.responseXML){processXML(ajax.responseXML);}else{idOpcao.innerHTML="-------------------";}}};var params="estado="+valor;ajax.send(params);}}function processXML(obj){var dataArray=obj.getElementsByTagName("cidade");if(dataArray.length>0){for(var i=0;i<dataArray.length;i++){var item=dataArray[i];var codigo=item.getElementsByTagName("codigo")[0].firstChild.nodeValue;var descricao=item.getElementsByTagName("descricao")[0].firstChild.nodeValue;idOpcao.innerHTML="Escolha a cidade";var novo=document.createElement("option");novo.setAttribute("id","opcoes");novo.value=codigo;novo.text=descricao;document.forms[0].cidade_emp.options.add(novo);}}else{idOpcao.innerHTML="";}}function VerQtde(nomeobj,max){if(max==0){return 1;}var lista=document.getElementById(nomeobj);var sel=lista.selectedIndex;var total=0;for(i=0;i<lista.length;i++){if(lista.options[i].selected==true){if(total>=max){lista.options[i].selected=false;}total++;}}}function maxlength(id,max){if(document.getElementById(id).value.length>=max){document.getElementById(id).value=document.getElementById(id).value.substring(0,max);}}function buscaCombo(valor,obj){var objeto=document.getElementById(obj);tam_objeto=objeto.options.length;for(i=0;i<tam_objeto;i++){valor_valor=valor.value.toLowerCase();tam_valor=valor_valor.length;valor_objeto=objeto.options[i].text.toLowerCase();if(valor_objeto.substring(0,tam_valor)==valor_valor){objeto.options[i].selected=true;return true;}}return false;}function popup(url){window.open(url,"","width=550,height=550,top=0,resizable=no,scrollbars=yes,location=no");}function ValidaEmail(mail){if((mail.length!=0)&&((mail.indexOf("@")<1)||(mail.indexOf(".")<7))){return false;}return true;}function telefone(obj){if((obj.value.length==2)){obj.value="("+obj.value+") ";}if((obj.value.length==9)){obj.value=obj.value+"-";}}function limpa(){document.forms["cadastro"].email.value="";document.forms["cadastro"].senha1.value="";document.forms["cadastro"].senha2.value="";document.forms["cadastro"].nome.value="";document.forms["cadastro"].ender.value="";document.forms["cadastro"].telef.value="";document.forms["cadastro"].celul.value="";}function checkform(theform){for(i=0;i<theform.elements.length;i++){if(theform.elements[i].name=="senha"){if(theform.elements[i].value!=""){if(theform.elements[i+1].value!=""){if(theform.elements[i+2].value!=""){if(theform.elements[i+1].value!=theform.elements[i+2].value){alert('O campo "Nova senha" e "Confirmação de senha" não conferem');theform.elements[i].focus();return false;}}else{alert('Por favor preencha o campo "'+theform.elements[i+2].title+'"');theform.elements[i+2].focus();return false;}}else{if(!theform.elements[i+1].value){alert('Por favor preencha o campo "'+theform.elements[i+1].title+'"');theform.elements[i+1].focus();return false;}else{return false;}}}}if(theform.elements[i].title.substr(0,1)=="*"){if(theform.elements[i]=="[object HTMLSelectElement]"){if(!theform.elements[i].selectedIndex){alert('O campo "'+theform.elements[i].title.substr(1,(theform.elements[i].title.length))+'" é obrigatorio');theform.elements[i].focus();return false;}}else{if(!theform.elements[i].value){alert('O campo "'+theform.elements[i].title.substr(1,(theform.elements[i].title.length))+'" é obrigatorio');theform.elements[i].focus();return false;}if(theform.elements[i].name=="email"){if(ValidaEmail(theform.elements[i].value)==false){alert("Por favor, utilize um E-mail válido");theform.elements[i].focus();return false;}}}}}return true;}