// JavaScript Document

//script para abrir popup
function OpenWindow(FileNameToOpen,janela,largura,altura)
{
newWindow = window.open(FileNameToOpen,janela, 'width='+largura+', height='+altura+', toolbar=no, scrollbars=yes, location=no, left=100, top=100')
if (newWindow.open)
{
newWindow.focus()
}
}

// Início do código de Aumentar/ Diminuir a letra
 
// Para usar coloque o comando: "javascript:mudaTamanho('tag_ou_id_alvo', -1);" para diminuir
// e o comando "javascript:mudaTamanho('tag_ou_id_alvo', +1);" para aumentar
 
var tagAlvo = new Array('p'); //pega todas as tags p//
 
// Especificando os possíveis tamanhos de fontes, poderia ser: x-small, small...
var tamanhos = new Array( '9px','10px','11px','12px','13px','14px','15px' );
var tamanhoInicial = 2;
 
function mudaTamanho( idAlvo,acao ){
  if (!document.getElementById) return
  var selecionados = null,tamanho = tamanhoInicial,i,j,tagsAlvo;
  tamanho += acao;
  if ( tamanho < 0 ) tamanho = 0;
  if ( tamanho > 6 ) tamanho = 6;
  tamanhoInicial = tamanho;
  if ( !( selecionados = document.getElementById( idAlvo ) ) ) selecionados = document.getElementsByTagName( idAlvo )[ 0 ];
  
  selecionados.style.fontSize = tamanhos[ tamanho ];
  
  for ( i = 0; i < tagAlvo.length; i++ ){
    tagsAlvo = selecionados.getElementsByTagName( tagAlvo[ i ] );
    for ( j = 0; j < tagsAlvo.length; j++ ) tagsAlvo[ j ].style.fontSize = tamanhos[ tamanho ];
  }
}

//script que rediciona as caixas de artigos
// Funcao que redireciona 
function navegaBoxGeral(url){
        if(url != ""){
        window.location.assign(url);
        } else {
        return false;
        }
}

function navegaBoxGeralBlank(url) {
	if(url != ""){
	window.open(url); 
    } else {
        return false;
    }	
}

function deleta(){
	if(confirm("Tem certeza que deseja excluir esta registro do banco de dados?")){
		return true;
	} else {
		return false;
	}
}

// funcao de redirecionamento
function redirect(URLStr) { 

	var location = URLStr; 
	
	document.location.href=location;

}

// FORMULARIO PARA CADASTRO
function Formatar_Telefone(objeto,tammax,teclapres){

    var tecla = teclapres.keyCode;
    vr = objeto.value;
    vr = vr.replace( "(", "" );
    vr = vr.replace( ")", "" );
    vr = vr.replace( " ", "" );
    vr = vr.replace( "-", "" );
    tam = vr.length;

    if (tam < tammax && tecla != 8) {
            tam = vr.length + 1 ;
    }

    if (tecla == 8 ) {
            tam = tam - 1 ;
    }

    if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ) {
            if ( tam <= 4 ) {
                     objeto.value = vr ;
            }
             if ( (tam > 4) && (tam <= 8) ) {
                     objeto.value = vr.substr(0,tam-4) + '-' + vr.substr( tam - 4, tam ) ;
            }
             if ( (tam >= 9) && (tam <= 10) ) {
                    objeto.value = '(' + vr.substr(0,2) + ') ' + vr.substr(2,tam-6) + '-' + vr.substr(tam-4,tam) ;
            }
    }
}

function Validar_Email(email){

    if(email.length < 6) {
            return false;
    }

    var x = 0;
    for (var c=0;c<email.length;c++) {
            if (email.substring(c,c+1) == '@') {
                    x = c;
            }
    }
    var y = 0;
    if (x > 0) {
            for (c=x;c<email.length;c++) {
                    if (email.substring(c,c+1)=='.') {
                            y = c;
                            var valida = 1;
                    }
            }
            if (y > 0) {
                    var dominio = '';
                    for (c=x;c<y;c++) {
                            dominio = dominio + email.substring(1,c);
                    }
            }
    }
    else {
            return false;
    }
    if (y <= x+2){
            return false;
    }
    if (valida == 1){
            return true;
    }
}

function validarLogin(){
    
	if (document.formLogin.userLogin.value=="") {
            document.formLogin.userLogin.focus();
            alert("Digite seu email!");
            return false;
	} else {
        if (!Validar_Email(document.formLogin.userLogin.value)) {
                document.formLogin.userLogin.focus();
                alert("Digite um e-mail válido!");
                return false;
        }
	}
	
	if (document.formLogin.passLogin.value=="") {
        document.formLogin.passLogin.focus();
        alert("Digite sua senha!");
        return false;
}
	
}

function Validar_Cadastro(){
    
	if (document.formCad.nome.value=="") {
            document.formCad.nome.focus();
            alert("Digite seu nome!");
            return false;
    }	
	
    if (document.formCad.email.value=="") {
            document.formCad.email.focus();
            alert("Informe o seu e-mail!");
            return false;
    } else {
            if (!Validar_Email(document.formCad.email.value)) {
                    document.formCad.email.focus();
                    alert("Digite um e-mail válido!");
                    return false;
            }
    }	        
	
	if (document.formCad.endereco.value=="") {
            document.formCad.endereco.focus();
            alert("Digite o nome da sua rua!");
            return false;
    }	
	
	if (document.formCad.n.value=="") {
            document.formCad.n.focus();
            alert("Digite o número da sua casa!");
            return false;
    }	
	          
	if (document.formCad.bairro.value=="") {
            document.formCad.bairro.focus();
            alert("Digite o nome do seu bairro!");
            return false;
    }	
			
	if (document.formCad.cidade.value=="") {
            document.formCad.cidade.focus();
            alert("Digite o nome da sua cidade!");
            return false;
    }	        		  
    
	if (document.formCad.senha01.value=="") {
            document.formCad.senha01.focus();
            alert("Digite a sua senha!");
            return false;
    }        
        
    
	if (document.formCad.senha02.value=="") {
            document.formCad.senha02.focus();
            alert("Confirme a sua senha!");
            return false;
    }  

	if (document.formCad.senha01.value!="" && document.formCad.senha02.value!="") {
        
		var senha01 = document.formCad.senha01.value;    
		var senha02 = document.formCad.senha02.value;
		
		if(senha01 != senha02) {
			document.formCad.senha01.focus();
            alert("As senhas não são iguais!");
            return false;
		}
    }                 
            
}


function Validar_EditCadastro(){
    
	if (document.formCad.nome.value=="") {
            document.formCad.nome.focus();
            alert("Digite seu nome!");
            return false;
    }	
	
    if (document.formCad.email.value=="") {
            document.formCad.email.focus();
            alert("Informe o seu e-mail!");
            return false;
    } else {
            if (!Validar_Email(document.formCad.email.value)) {
                    document.formCad.email.focus();
                    alert("Digite um e-mail válido!");
                    return false;
            }
    }	        
	
	if (document.formCad.endereco.value=="") {
            document.formCad.endereco.focus();
            alert("Digite o nome da sua rua!");
            return false;
    }	
	
	if (document.formCad.n.value=="") {
            document.formCad.n.focus();
            alert("Digite o número da sua casa!");
            return false;
    }	
            
	if (document.formCad.bairro.value=="") {
            document.formCad.bairro.focus();
            alert("Digite o nome do seu bairro!");
            return false;
    }	
			
	if (document.formCad.cidade.value=="") {
            document.formCad.cidade.focus();
            alert("Digite o nome da sua cidade!");
            return false;
    }	        		          
        
    if (document.formCad.senha01.value!="" || document.formCad.senha02.value!="") {
        
		var senha01 = document.formCad.senha01.value;    
		var senha02 = document.formCad.senha02.value;
		
		if(senha01 != senha02) {
			document.formCad.senha01.focus();
            alert("As senhas não são iguais!");
            return false;
		}
    }                 
            
}	

function Validar_CadAnuncioGratis(){
    
	if (document.cadAnuncio.titulo.value=="") {
            document.cadAnuncio.titulo.focus();
            alert("Digite o que você deseja anunciar!");
            return false;
    }
	
	if (document.cadAnuncio.texto.value=="") {
        document.cadAnuncio.texto.focus();
        alert("Digite a descrição do anúncio!");
        return false;
	}	

	if (document.cadAnuncio.autor.value=="") {
        document.cadAnuncio.autor.focus();
        alert("Digite seu nome!");
        return false;
	}	
	
    if (document.cadAnuncio.email.value!="") {
        if (!Validar_Email(document.cadAnuncio.email.value)) {
                document.cadAnuncio.email.focus();
                alert("Digite um e-mail válido!");
                return false;
        }
    }
}
//---> BUSCA - INICIO
function ajaxValidator() {
	  //verifica se o browser tem suporte a ajax
	  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;
			}
		 }
	  }

		return ajax;	
	}

	// FUNCAO QUE EXIBE AS SUB-CATEGORIAS
	function Dados(valor) {
	   
	  var ajax = ajaxValidator();
	   
	  //se tiver suporte ajax
	  if(ajax) {
		 //deixa apenas o elemento 1 no option, os outros são excluídos
		 document.forms[3].Marca.options.length = 1;
		 
		 idOpcao  = document.getElementById("opcoes");
		 
		 ajax.open("POST", "componentes/institucional/classificados/sispro_selcmarca.php", true);
		 ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		 
		 ajax.onreadystatechange = function() {
			//enquanto estiver processando...emite a msg de carregando
			if(ajax.readyState == 1) {
			   idOpcao.innerHTML = "Carregando...!";   
			}
			//após ser processado - chama função processXML que vai varrer os dados
			if(ajax.readyState == 4 ) {
			   if(ajax.responseXML) {
				  processXML(ajax.responseXML);
			   }
			   else {
				   //caso não seja um arquivo XML emite a mensagem abaixo
				   idOpcao.innerHTML = "SELECIONE O TIPO";
			   }
			}
		 }
		 //passa o código da categoria escolhida
		 var params = "tipo="+valor;
		 ajax.send(params);
	  }
	}

	// FUNCAO QUE EXIBE OS PRODUTOS
	function Dados2(valor) {
	   
	  var ajax = ajaxValidator();
	   
	  //se tiver suporte ajax
	  if(ajax) {
		 //deixa apenas o elemento 1 no option, os outros são excluídos
		 document.forms[3].Modelo.options.length = 1;
		 
		 idOpcao  = document.getElementById("opcoesM");
		 tipo = document.forms[3].Tipo.value;
		 
		 ajax.open("POST", "componentes/institucional/classificados/sispro_selcmodelo.php", true);
		 ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		 
		 ajax.onreadystatechange = function() {
			//enquanto estiver processando...emite a msg de carregando
			if(ajax.readyState == 1) {
			   idOpcao.innerHTML = "Carregando...!";   
			}
			//após ser processado - chama função processXML que vai varrer os dados
			if(ajax.readyState == 4 ) {
			   if(ajax.responseXML) {
				  processXML2(ajax.responseXML);
			   }
			   else {
				   //caso não seja um arquivo XML emite a mensagem abaixo
				   idOpcao.innerHTML = "SELECIONE A MARCA";
			   }
			}
		 }
		 //passa o código da subcategoria escolhida
		 var params = "tipo="+tipo+"&marca="+valor;
		 ajax.send(params);
	  }
	}

	// FUNCAO QUE EXIBE AS CIDADES
	function Dados3(valor) {
	   
	  var ajax = ajaxValidator();
	   
	  //se tiver suporte ajax
	  if(ajax) {
		 //deixa apenas o elemento 1 no option, os outros são excluídos
		 document.forms[3].Cidade.options.length = 1;
		 
		 idOpcao  = document.getElementById("opcoesC");
		 
		 ajax.open("POST", "componentes/institucional/classificados/sispro_selccidade.php", true);
		 ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		 
		 ajax.onreadystatechange = function() {
			//enquanto estiver processando...emite a msg de carregando
			if(ajax.readyState == 1) {
			   idOpcao.innerHTML = "Carregando...!";   
			}
			//após ser processado - chama função processXML que vai varrer os dados
			if(ajax.readyState == 4 ) {
			   if(ajax.responseXML) {
				  processXML3(ajax.responseXML);
			   }
			   else {
				   //caso não seja um arquivo XML emite a mensagem abaixo
				   idOpcao.innerHTML = "SELECIONE A CIDADE";
			   }
			}
		 }
		 //passa o código da categoria escolhida
		 var params = "estado="+valor;
		 ajax.send(params);
	  }
	}

	// FUNCAO QUE EXIBE OS BAIRROS
	function Dados4(valor) {
	   
	  var ajax = ajaxValidator();
	   
	  //se tiver suporte ajax
	  if(ajax) {
		 //deixa apenas o elemento 1 no option, os outros são excluídos
		 document.forms[3].Bairro.options.length = 1;
		 
		 idOpcao  = document.getElementById("opcoesB");
		 
		 ajax.open("POST", "componentes/institucional/classificados/sispro_selcbairro.php", true);
		 ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		 
		 ajax.onreadystatechange = function() {
			//enquanto estiver processando...emite a msg de carregando
			if(ajax.readyState == 1) {
			   idOpcao.innerHTML = "Carregando...!";   
			}
			//após ser processado - chama função processXML que vai varrer os dados
			if(ajax.readyState == 4 ) {
			   if(ajax.responseXML) {
				  processXML4(ajax.responseXML);
			   }
			   else {
				   //caso não seja um arquivo XML emite a mensagem abaixo
				   idOpcao.innerHTML = "SELECIONE O BAIRRO";
			   }
			}
		 }
		 //passa o código da categoria escolhida
		 var params = "cidade="+valor;
		 ajax.send(params);
	  }
	}
	
	// FUNCAO QUE EXIBE AS CIDADES
	function Dados5(valor) {
	   
	  var ajax = ajaxValidator();
	   
	  //se tiver suporte ajax
	  if(ajax) {
		 //deixa apenas o elemento 1 no option, os outros são excluídos
		 document.forms[3].guiaCidade.options.length = 1;
		 
		 idOpcao  = document.getElementById("opcoesC");
		 
		 ajax.open("POST", "componentes/institucional/guia_comercial/selccidade.php", true);
		 ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		 
		 ajax.onreadystatechange = function() {
			//enquanto estiver processando...emite a msg de carregando
			if(ajax.readyState == 1) {
			   idOpcao.innerHTML = "Carregando...!";   
			}
			//após ser processado - chama função processXML que vai varrer os dados
			if(ajax.readyState == 4 ) {
			   if(ajax.responseXML) {
				  processXML5(ajax.responseXML);
			   }
			   else {
				   //caso não seja um arquivo XML emite a mensagem abaixo
				   idOpcao.innerHTML = "SELECIONE O ESTADO";
			   }
			}
		 }
		 //passa o código da categoria escolhida
		 var params = "Estado="+valor;
		 ajax.send(params);
	  }
	}	
	
	// FUNCAO QUE EXIBE AS CIDADES
	function Dados6(valor) {
	   
	  var ajax = ajaxValidator();
	   
	  //se tiver suporte ajax
	  if(ajax) {
		 //deixa apenas o elemento 1 no option, os outros são excluídos
		 document.buscaGuia.guiaCidade.options.length = 1;
		 
		 idOpcao  = document.getElementById("opcoesC");
		 
		 ajax.open("POST", "componentes/institucional/guia_comercial/selccidade.php", true);
		 ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		 
		 ajax.onreadystatechange = function() {
			//enquanto estiver processando...emite a msg de carregando
			if(ajax.readyState == 1) {
			   idOpcao.innerHTML = "Carregando...!";   
			}
			//após ser processado - chama função processXML que vai varrer os dados
			if(ajax.readyState == 4 ) {
			   if(ajax.responseXML) {
				  processXML6(ajax.responseXML);
			   }
			   else {
				   //caso não seja um arquivo XML emite a mensagem abaixo
				   idOpcao.innerHTML = "SELECIONE O ESTADO";
			   }
			}
		 }
		 //passa o código da categoria escolhida
		 var params = "Estado="+valor;
		 ajax.send(params);
	  }
	}	

	function processXML(obj){
	  //pega a tag subcategoria
	  var dataArray   = obj.getElementsByTagName("marca");
	  
	  //total de elementos contidos na tag subcategoria
	  if(dataArray.length > 0) {
		 //percorre o arquivo XML para extrair os dados
		 for(var i = 0 ; i < dataArray.length ; i++) {
			var item = dataArray[i];
			//contéudo dos campos no arquivo XML
			var codigo    =  item.getElementsByTagName("id")[0].firstChild.nodeValue;
			var descricao =  item.getElementsByTagName("nome")[0].firstChild.nodeValue;
			
			idOpcao.innerHTML = "CLIQUE AQUI!";
			
			//cria um novo option dinamicamente  
			var novo = document.createElement("option");
				//atribui um ID a esse elemento
				novo.setAttribute("id", "opcoes");
				//atribui um valor
				novo.value = codigo;
				//atribui um texto
				novo.text  = descricao;
				//finalmente adiciona o novo elemento
				document.forms[3].Marca.options.add(novo);
		 }
	  }
	  else {
		//caso o XML volte vazio, printa a mensagem abaixo
		idOpcao.innerHTML = "SELECIONE O TIPO";
	  }	  
	}

	function processXML2(obj){
	  //pega a tag subcategoria
	  var dataArray   = obj.getElementsByTagName("modelo");
	  
	  //total de elementos contidos na tag subcategoria
	  if(dataArray.length > 0) {
		 //percorre o arquivo XML para extrair os dados
		 for(var i = 0 ; i < dataArray.length ; i++) {
			var item = dataArray[i];
			//contéudo dos campos no arquivo XML
			var codigo    =  item.getElementsByTagName("id")[0].firstChild.nodeValue;
			var descricao =  item.getElementsByTagName("nome")[0].firstChild.nodeValue;
			
			idOpcao.innerHTML = "CLIQUE AQUI!";
			
			//cria um novo option dinamicamente  
			var novo = document.createElement("option");
				//atribui um ID a esse elemento
				novo.setAttribute("id", "opcoesM");
				//atribui um valor
				novo.value = codigo;
				//atribui um texto
				novo.text  = descricao;
				//finalmente adiciona o novo elemento
				document.forms[3].Modelo.options.add(novo);
		 }
	  }
	  else {
		//caso o XML volte vazio, printa a mensagem abaixo
		idOpcao.innerHTML = "SELECIONE A MARCA";
	  }	  
	}

	function processXML3(obj){
	  //pega a tag subcategoria
	  var dataArray   = obj.getElementsByTagName("cidade");
	  
	  //total de elementos contidos na tag subcategoria
	  if(dataArray.length > 0) {
		 //percorre o arquivo XML para extrair os dados
		 for(var i = 0 ; i < dataArray.length ; i++) {
			var item = dataArray[i];
			//contéudo dos campos no arquivo XML
			var codigo    =  item.getElementsByTagName("id")[0].firstChild.nodeValue;
			var descricao =  item.getElementsByTagName("nome")[0].firstChild.nodeValue;
			
			idOpcao.innerHTML = "CLIQUE AQUI!";
			
			//cria um novo option dinamicamente  
			var novo = document.createElement("option");
				//atribui um ID a esse elemento
				novo.setAttribute("id", "opcoesC");
				//atribui um valor
				novo.value = descricao;
				//atribui um texto
				novo.text  = descricao;
				//finalmente adiciona o novo elemento
				document.forms[3].Cidade.options.add(novo);
		 }
	  }
	  else {
		//caso o XML volte vazio, printa a mensagem abaixo
		idOpcao.innerHTML = "SELECIONE A CIDADE";
	  }	  
	}

	function processXML4(obj){
	  //pega a tag subcategoria
	  var dataArray   = obj.getElementsByTagName("bairro");
	  
	  //total de elementos contidos na tag subcategoria
	  if(dataArray.length > 0) {
		 //percorre o arquivo XML para extrair os dados
		 for(var i = 0 ; i < dataArray.length ; i++) {
			var item = dataArray[i];
			//contéudo dos campos no arquivo XML
			var codigo    =  item.getElementsByTagName("id")[0].firstChild.nodeValue;
			var descricao =  item.getElementsByTagName("nome")[0].firstChild.nodeValue;
			
			idOpcao.innerHTML = "CLIQUE AQUI!";
			
			//cria um novo option dinamicamente  
			var novo = document.createElement("option");
				//atribui um ID a esse elemento
				novo.setAttribute("id", "opcoesB");
				//atribui um valor
				novo.value = descricao;
				//atribui um texto
				novo.text  = descricao;
				//finalmente adiciona o novo elemento
				document.forms[3].Bairro.options.add(novo);
		 }
	  }
	  else {
		//caso o XML volte vazio, printa a mensagem abaixo
		idOpcao.innerHTML = "SELECIONE O BAIRRO";
	  }	  
	}
	
	function processXML5(obj){
		  //pega a tag subcategoria
		  var dataArray   = obj.getElementsByTagName("subcategoria");
		  
		  //total de elementos contidos na tag subcategoria
		  if(dataArray.length > 0) {
			 //percorre o arquivo XML para extrair os dados
			 for(var i = 0 ; i < dataArray.length ; i++) {
				var item = dataArray[i];
				//contéudo dos campos no arquivo XML
				var codigo    =  item.getElementsByTagName("id")[0].firstChild.nodeValue;
				var descricao =  item.getElementsByTagName("nome")[0].firstChild.nodeValue;
				
				idOpcao.innerHTML = "CLIQUE AQUI!";
				
				//cria um novo option dinamicamente  
				var novo = document.createElement("option");
					//atribui um ID a esse elemento
					novo.setAttribute("id", "opcoesC");
					//atribui um valor
					novo.value = descricao;
					//atribui um texto
					novo.text  = descricao;
					//finalmente adiciona o novo elemento
					document.forms[3].guiaCidade.options.add(novo);
			 }
		  }
		  else {
			//caso o XML volte vazio, printa a mensagem abaixo
			idOpcao.innerHTML = "SELECIONE A CIDADE";
		  }	  
		}	
	
	function processXML6(obj){
		  //pega a tag subcategoria
		  var dataArray   = obj.getElementsByTagName("subcategoria");
		  
		  //total de elementos contidos na tag subcategoria
		  if(dataArray.length > 0) {
			 //percorre o arquivo XML para extrair os dados
			 for(var i = 0 ; i < dataArray.length ; i++) {
				var item = dataArray[i];
				//contéudo dos campos no arquivo XML
				var codigo    =  item.getElementsByTagName("id")[0].firstChild.nodeValue;
				var descricao =  item.getElementsByTagName("nome")[0].firstChild.nodeValue;
				
				idOpcao.innerHTML = "CLIQUE AQUI!";
				
				//cria um novo option dinamicamente  
				var novo = document.createElement("option");
					//atribui um ID a esse elemento
					novo.setAttribute("id", "opcoesC");
					//atribui um valor
					novo.value = descricao;
					//atribui um texto
					novo.text  = descricao;
					//finalmente adiciona o novo elemento
					document.buscaGuia.guiaCidade.options.add(novo);
			 }
		  }
		  else {
			//caso o XML volte vazio, printa a mensagem abaixo
			idOpcao.innerHTML = "SELECIONE A CIDADE";
		  }	  
		}		
	
//--> FIM

// Conta caracteres
function ContaCaracteres(){
   intCaracteres = 1000 - document.FormProposta.Mensagem.value.length;
   if (intCaracteres > 0){
      document.FormProposta.caracteres.value = intCaracteres;
      return true;
   }
   else {
      document.FormProposta.caracteres.value = 0;
      document.FormProposta.Mensagem.value = document.FormProposta.Mensagem.value.substr(0,1000)
      return false;
   }
}

function validaProposta() {
	
	// NOME
	if (document.FormProposta.Nome.value=="") {
			document.FormProposta.Nome.focus();
			alert("Digite seu nome!");
			return false;
	}
	
	// EMAIL
    if (document.FormProposta.Email.value=="") {
        document.FormProposta.Email.focus();
        alert("Informe o seu e-mail!");
        return false;
    } else {
        if (!Validar_Email(document.FormProposta.Email.value)) {
                document.FormProposta.Email.focus();
                alert("Digite um e-mail válido!");
                return false;
        }
    }
	
	// MENSAGEM
	if (document.FormProposta.Mensagem.value=="") {
			document.FormProposta.Mensagem.focus();
			alert("Digite a mensagem!");
			return false;
	}	
	
}

function validaBusca() {
	// categorias
	if (document.formBusca.categoria.value=="") {
			document.formBusca.categoria.focus();
			alert("Escolha uma das categorias!");
			return false;
	}	
}

function ContaCaracteres2(){
	   intCaracteres = 400 - document.cadAnuncio.texto.value.length;
	   if (intCaracteres > 0){
	      document.cadAnuncio.caracteres.value = intCaracteres;
	      return true;
	   }
	   else {
	      document.cadAnuncio.caracteres.value = 0;
	      document.cadAnuncio.texto.value = document.cadAnuncio.texto.value.substr(0,400)
	      return false;
	   }
	}
	
function limpa_campo(qual, texto, tipo){
		var element = document.getElementById(qual);
	if(element.value=='' && tipo=='out'){
		element.value=texto;
	}else if(element.value==texto && tipo=='in'){
		element.value='';
	}
}	
