function MM_jumpMenu(targ,selObj,restore){ 
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
	 function SoNumeros() 
	 { 
	  var carCode = event.keyCode; 
	  if ((carCode < 48) || (carCode > 57)) 
	  { 
	   event.cancelBubble = true 
	   event.returnValue = false; 
	  } 
	 } 
	 
    function Mascara(o,f){
        v_obj=o
        v_fun=f
        setTimeout("execmascara()",1)
    }
    
    /*Função que Executa os objetos*/
    function execmascara(){
        v_obj.value=v_fun(v_obj.value)
    }
    
    /*Função que Determina as expressões regulares dos objetos*/
    function leech(v){
        v=v.replace(/o/gi,"0")
        v=v.replace(/i/gi,"1")
        v=v.replace(/z/gi,"2")
        v=v.replace(/e/gi,"3")
        v=v.replace(/a/gi,"4")
        v=v.replace(/s/gi,"5")
        v=v.replace(/t/gi,"7")
        return v
    }
    
    /*Função que permite apenas numeros*/
    function Integer(v){
        return v.replace(/\D/g,"")
    }
    
    /*Função que padroniza telefone (11) 4184-1241*/
    function Telefone(v){
        v=v.replace(/\D/g,"")                 
        //v=v.replace(/^(\d\d)(\d)/g,"($1)$2") 
        v=v.replace(/(\d{4})(\d)/,"$1-$2")    
        return v
    }
    
    /*Função que padroniza telefone (11) 41841241*/
    function TelefoneCall(v){
        v=v.replace(/\D/g,"")                 
        v=v.replace(/^(\d\d)(\d)/g,"($1) $2")    
        return v
    }
    
    /*Função que padroniza CPF*/
    function Cpf(v){
        v=v.replace(/\D/g,"")                    
        v=v.replace(/(\d{3})(\d)/,"$1.$2")       
        v=v.replace(/(\d{3})(\d)/,"$1.$2")       
                                                 
        v=v.replace(/(\d{3})(\d{1,2})$/,"$1-$2") 
        return v
    }
	    /*Função que padroniza CEP*/
    function Cep(v){
        v=v.replace(/D/g,"")                
        v=v.replace(/^(\d{5})(\d)/,"$1-$2") 
        return v
    }
    
    /*Função que padroniza CNPJ*/
    function Cnpj(v){
        v=v.replace(/\D/g,"")                   
        v=v.replace(/^(\d{2})(\d)/,"$1.$2")     
        v=v.replace(/^(\d{2})\.(\d{3})(\d)/,"$1.$2.$3") 
        v=v.replace(/\.(\d{3})(\d)/,".$1/$2")           
        v=v.replace(/(\d{4})(\d)/,"$1-$2")              
        return v
    }
    

    /*Função que padroniza o Site*/
    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
    }

    /*Função que padroniza DATA*/
    function Data(v){
        v=v.replace(/\D/g,"") 
        v=v.replace(/(\d{2})(\d)/,"$1/$2") 
        v=v.replace(/(\d{2})(\d)/,"$1/$2") 
        return v
    }

function ValEmail(field) { // validar campo email
	 if (field.value.length != 0)
	 {
		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(field.value)){
		return (true)
		}
		alert("O e-mail informado é inválido!")
		field.value = '';
		field.focus();
		field.select();
		return (false)
	 }
	}
	
function ValNextel() 
	 { 
	  var carCode = event.keyCode; 
	  if (((carCode < 48)&&(carCode!=42)) || (carCode > 57) ) 
	  { 
	   event.cancelBubble = true 
	   event.returnValue = false; 
	  } 
} 
	 
	

function verContato(codigo, tipo, root)
{
	   div=codigo; 
	   var pesquisa = createXMLHTTP();
	   document.getElementById(div).innerHTML="<span class='load'>Pesquisando...</span>";
	   pesquisa.open("post", root+"obj/objcontato.asp", true);
	   pesquisa.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	   pesquisa.onreadystatechange=function(){
				if (pesquisa.readyState==4){
			     document.getElementById(div).innerHTML = pesquisa.responseText;
			     }}
			      pesquisa.send("codigo="+codigo+"&tipo="+tipo+"&root="+root);
}

function validaAcesso(root)
{
	   var email=document.getElementById("loginAcesso").value;
	   var senha=document.getElementById("senhaAcesso").value;
	   var pesquisa = createXMLHTTP();
	   pesquisa.open("post", root+"obj/objvalidaAcesso.asp", true);
	   pesquisa.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	   pesquisa.onreadystatechange=function(){
				 if (pesquisa.readyState==4){
					 if(pesquisa.responseText==''){
						 alert("Email ou Senha Inválida!!!")
					 }else{
						 str=pesquisa.responseText
						 vStr=str.split('||');
						 document.getElementById("idAnuncio").value=vStr[0];
						 document.getElementById("nome").value=vStr[1];
						 document.getElementById("empresa").value=vStr[2];
						 document.getElementById("ramos").value=vStr[16];
						 carregaLista(vStr[16],'categoria', 290, root)
						 self.setTimeout("document.getElementById('categoria').value=vStr[3]", 200);
						 document.getElementById("cep").value=vStr[12].substr(0,5)+"-"+vStr[12].substr(5,3);
						 buscaCep(vStr[12], '', root)
						 document.getElementById("numero").value=vStr[10];
						 document.getElementById("comp").value=vStr[11];
						 document.getElementById("ddd1").value=vStr[5];
						 document.getElementById("telefone1").value=vStr[6].substr(0,4)+"-"+vStr[6].substr(4,4); 
						 document.getElementById("ddd2").value=vStr[7];
						 document.getElementById("telefone2").value=vStr[8].substr(0,4)+"-"+vStr[8].substr(4,4); 
						 document.getElementById("nextel").value=vStr[9];
						 document.getElementById("site").value=vStr[13];
						 document.getElementById("email").value=vStr[14];	
						 document.getElementById("senha").value=vStr[15];
						 }
			     }}
			     pesquisa.send("email="+email+"&senha="+senha);

}

function validaBusca()
{
	if(document.getElementById('busca_pchaves').value==''  || document.getElementById('busca_pchaves').value=='palavra-chave'){
		return false;	
	}
}

function Problema(codigo, root)
{
if(document.getElementById("op1"+codigo).checked==true) 
{
opcao=1;	
}
else if(document.getElementById("op2"+codigo).checked==true) 
{
opcao=2;	
}
else if(document.getElementById("op3"+codigo).checked==true) 
{
opcao=3;	
}
else if(document.getElementById("op4"+codigo).checked==true) 
{
opcao=4;	
}
else
{
opcao=0;	
}
	   var problem = createXMLHTTP();
	   problem.open("post", root+"obj/objproblema.asp", true);
	   problem.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	   problem.onreadystatechange=function(){
				if (problem.readyState==4){
				 alert(problem.responseText)
				 document.getElementById(codigo).innerHTML = "<br /><strong>Agradecemos a colaboração...</strong><br /><br />";
			     }}
			      problem.send("codigo="+codigo+"&opcao="+opcao);
}

function buscaCep(cep, complemento, root)
{	   
		   document.getElementById("logradouro"+complemento).value="Aguarde..."
		   
		   var xmlhttp = createXMLHTTP();
		   xmlhttp.open("post", root+"obj/objBuscaCep.asp", true);
		   xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		   xmlhttp.onreadystatechange=function(){
		   if (xmlhttp.readyState==4){
			   //alert(complemento);
			   var strEndereco=xmlhttp.responseText;
			   if (strEndereco!='null' && strEndereco!='undefined'){
				   vEndereco=strEndereco.split('||')
				   document.getElementById("logradouro"+complemento).value=vEndereco[0];
				   document.getElementById("bairro"+complemento).value=vEndereco[1];
				   document.getElementById("cidade"+complemento).value=vEndereco[2];
				   document.getElementById("ddd1"+complemento).value=vEndereco[3];
			   }else{
				   if(strEndereco=='null'){
					   alert("CEP Inválido ou não pertence a Região!!!")
					   document.getElementById("cep"+complemento).focus();
					   document.getElementById("cep"+complemento).select();
				   }
				   	   document.getElementById("logradouro"+complemento).value='';
					   document.getElementById("bairro"+complemento).value='';
					   document.getElementById("cidade"+complemento).value='';
					   document.getElementById("cep"+complemento).value='';
					   document.getElementById("ddd1"+complemento).value='';
			   }
			 }}
			 xmlhttp.send("cep="+cep);

}

function carregaLista(id, nome, tamanho, root)
{
	   var xmlhttp = createXMLHTTP();
	   xmlhttp.open("post", root+"obj/objCarregaLista.asp", true);
	   xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	   xmlhttp.onreadystatechange=function(){
				if (xmlhttp.readyState==4){
				 document.getElementById("div_"+nome).innerHTML = xmlhttp.responseText;
			     }}
			      xmlhttp.send("id="+id+"&nome="+nome+"&tamanho="+tamanho+"&root="+root);
	
}

function valida_cadastro() {
     var Form; 
     Form = document.form_cadastro;
     if (Form.nome.value.length == 0){
	alert("Digite seu Nome !");
        Form.nome.focus();
        return false;
     }
     if (Form.empresa.value.length == 0) {
	alert("Digite o nome da Empresa !");
        Form.empresa.focus();
        return false;
     }
	 
	 if (Form.ramos.value == 0) {
	 alert("Escolha o Ramo !");
        Form.ramos.focus();
        return false;
     }
	 
	 if (Form.categoria.value == 0) {
	alert("Escolha a categoria !");
        Form.categoria.focus();
        return false;
     }
	 if (Form.cep.value.length == 0) {
	alert("Digite o cep !");
        Form.cep.focus();
     return false;
     }
	if (Form.numero.value.length == 0) {
	alert("Digite o numero !");
        Form.numero.focus();
     return false;
     }	
     if (Form.telefone1.value.length == 0) {
	alert("Digite seu telefone !");
        Form.telefone1.focus();
        return false;
     }
     if (Form.email.value.length == 0) {
	alert("Digite seu e-mail !");
        Form.email.focus();
        return false;
     }
     if (Form.senha.value.length <= 3) {
	alert("Digite uma senha de 4 a 8 digitos !");
        Form.senha.focus();
        return false;
     }
}

function valida_contato() {
     var Form; 
     Form = document.form_contato;
     if (Form.nome.value.length == 0){
	alert("Digite seu Nome !");
        Form.nome.focus();
        return false;
     }
     if (Form.email.value.length == 0) {
	alert("Digite seu e-mail !");
        Form.email.focus();
        return false;
     }
     if (Form.assunto.value.length <= 3) {
	 alert("Digite o assunto!");
        Form.assunto.focus();
        return false;
     }
     if (Form.mensagem.value.length <= 10) {
	 alert("Digite uma mensagem válida!");
        Form.mensagem.focus();
        return false;
     }
}

function showDiv(nome) 
{
		document.getElementById(nome).style.display="none";
	}
	function escondeDiv(nome) 
	{
		document.getElementById(nome).style.display="none";
}

function mostraDiv(nome) 
{
	if(document.getElementById(nome).style.display=="none"){ 
	document.getElementById(nome).style.display = "block";
	}else{
	document.getElementById(nome).style.display = "none";
	}
}



