var acao_pesquisa = "";
var id_pesquisa = "";

function valor_tipo(){
	
	if(document.getElementById('busca_tipo0') != undefined){
		if(document.getElementById('busca_tipo0').checked)
			return "";
		if(document.getElementById('busca_tipo1').checked)
			return "N";
		if(document.getElementById('busca_tipo2').checked)
			return "U";
	}else{
		return "";	
	}
	return "";
}		
var xmldoc;
try{
    xmldoc = new xmlDocument();
}
catch(eee){
    try{
        xmldoc = new ActiveXObject("Msxml2.DOMDocument");
    }catch(eeee){
        try{
            xmldoc = new ActiveXObject("Microsoft.XMLDOM");
        }catch(EE){
            xmldoc = null
            
        }
    }
}
var	objRegiao = null; 
function Carrega_Mapa(pais,estado,cidade,cidade_regiao,bairro,bairro_subregiao,categoria,subcategoria,tipo,marca,modelo,negociacao){
	var strConsulta = "";
	if(pais != ""){
		strConsulta = strConsulta + "pais=" + pais;
		if(estado != ""){
			strConsulta = strConsulta + "&estado=" + estado;
			if(cidade != ""){
				strConsulta = strConsulta + "&cidade=" + cidade;
				if(cidade_regiao != ""){
					strConsulta = strConsulta + "&cidade_regiao=" + cidade_regiao;
					if(bairro != ""){
						strConsulta = strConsulta + "&bairro=" + bairro;
						if(bairro_subregiao != ""){
							strConsulta = strConsulta + "&bairro_subregiao=" + bairro_subregiao;
						}
					}
				}
			}
		}
	}else{
		strConsulta = "pais=00000000001";
	}
	
	
	if(categoria != ""){
		strConsulta = strConsulta + "&categoria=" + categoria;
		if(subcategoria != ""){
			strConsulta = strConsulta + "&subcategoria=" + subcategoria;
			if(marca != ""){
				strConsulta = strConsulta + "&marca=" + marca;
				if(modelo != ""){
					strConsulta = strConsulta + "&modelo=" + modelo;
				}
			}
		}
	}

	if(negociacao != ""){
		strConsulta = strConsulta + "&negociacao=" + negociacao;
	}
	
 
	if(tipo != ""){
		strConsulta = strConsulta + "&tipo=" + tipo;
	}

	objRegiao = null; 

	// Procura por um objeto nativo (Mozilla/Safari) 
    if (window.XMLHttpRequest) {
		objRegiao = new XMLHttpRequest(); 
        objRegiao.open("GET","gera_mapa.php?" + strConsulta  + "&tmpdatahora=" + pega_datahora(), true); 		
		objRegiao.onreadystatechange = ProcessCarrega_Mapa; 		
        objRegiao.send(null); 

    // Procura por uma versao ActiveX (IE) 
    } else if (window.ActiveXObject) { 
        objRegiao = new ActiveXObject("Microsoft.XMLHTTP"); 
        if (objRegiao) { 
			objRegiao.onreadystatechange = ProcessCarrega_Mapa; 
			objRegiao.open("POST","gera_mapa.php?" + strConsulta  + "&tmpdatahora=" + pega_datahora(), true);
			objRegiao.setRequestHeader('Content-Type','text/xml');
			objRegiao.setRequestHeader('encoding','ISO-8859-1');
			objRegiao.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			objRegiao.setRequestHeader('Content-length', strConsulta.length ); 
			
			objRegiao.send(strConsulta);

        } 
    } 
}

function ProcessCarrega_Mapa(){ 
	document.getElementById('carregando').style.display = '';
	document.getElementById('filtros_busca').style.display = 'none';
//	document.getElementById('filtros_busca').style.display = '';

	if (objRegiao.readyState == 4){
		if (objRegiao.status == 200) { 
			//alert(objRegiao.responseText)
			/*x = window.open('','','');
			x.document.write(objRegiao.responseText);*/

			if (window.ActiveXObject){
				ret = xmldoc.loadXML(objRegiao.responseText);
				if (ret!=true){
					alert("Não foi possvel ler o documento");
					return(0);
				}
			}else{
				var xmlParser = new DOMParser();
				xmldoc = xmlParser.parseFromString(objRegiao.responseText,"text/xml");
			}		
			
			xmldoc.resolveExternals=false;
			xmldoc.async=false;
			var root = xmldoc.documentElement;
			/*##########################
			#COMBO DE PAIS (busca_pais)#
			###########################*/
			c_busca_pais = document.getElementById('busca_pais');
			if(c_busca_pais){
				while (c_busca_pais.length > 0) {
				    c_busca_pais.remove(0);
				}

				for(i = 0; i < root.childNodes.item(0).childNodes.length; i++){
					var newElem = document.createElement("option");
					newElem.text = root.childNodes.item(0).childNodes.item(i).attributes.getNamedItem('text').value;
					newElem.value = root.childNodes.item(0).childNodes.item(i).attributes.getNamedItem('value').value;
					c_busca_pais.options.add(newElem);
					if(root.childNodes.item(0).childNodes.item(i).attributes.getNamedItem('selected').value == 'true'){
						c_busca_pais.value = root.childNodes.item(0).childNodes.item(i).attributes.getNamedItem('value').value;
					}
				} 
			}
			/*###############################
			#COMBO DE ESTADOS (busca_estado)#
			###############################*/
			c_busca_estado = document.getElementById('busca_estado');
			if(c_busca_estado){
				while (c_busca_estado.length > 0) {
				    c_busca_estado.remove(0);
				}
	
				var newElem = document.createElement("option");
				newElem.text = "todos os estados";
				newElem.value = "";
				c_busca_estado.options.add(newElem);
				c_busca_estado.value = "";

				for(i = 0; i < root.childNodes.item(1).childNodes.length; i++){
					var newElem = document.createElement("option");
					newElem.text = root.childNodes.item(1).childNodes.item(i).attributes.getNamedItem('text').value;
					newElem.value = root.childNodes.item(1).childNodes.item(i).attributes.getNamedItem('value').value;
					c_busca_estado.options.add(newElem);
					if(root.childNodes.item(1).childNodes.item(i).attributes.getNamedItem('selected').value == 'true'){
						c_busca_estado.value = root.childNodes.item(1).childNodes.item(i).attributes.getNamedItem('value').value;
					}
				} 
				if(c_busca_estado.options.length < 2){
					c_busca_estado.style.display = 'none';
					document.getElementById('apontador1').style.display = 'none';
				}else{
					c_busca_estado.style.display = '';
					document.getElementById('apontador1').style.display = '';				
				}
			}
			/*###############################
			#COMBO DE CIDADE  (busca_cidade)#
			###############################*/

			c_busca_cidade = document.getElementById('busca_cidade');
			if(c_busca_cidade){
				while (c_busca_cidade.length > 0) {
					c_busca_cidade.remove(0);
				}
	
	
				if(root.childNodes.item(2).attributes.getNamedItem('value') != null){
					var newElem = document.createElement("option");
					newElem.text = "todas as  cidades";
					newElem.value = "";
					c_busca_cidade.options.add(newElem);
	
					var newElem = document.createElement("option");
					newElem.text = "Regiao de " + root.childNodes.item(2).attributes.getNamedItem('text').value;
					newElem.value = root.childNodes.item(2).attributes.getNamedItem('value').value;
					c_busca_cidade.options.add(newElem);
					
				}else{
					var newElem = document.createElement("option");
					newElem.text = "todas as cidades";
					newElem.value = "";
					c_busca_cidade.options.add(newElem);
				}
	//			c_busca_cidade.value = "";
				for(i = 0; i < root.childNodes.item(2).childNodes.length; i++){
					var newElem = document.createElement("option");
					newElem.text = root.childNodes.item(2).childNodes.item(i).attributes.getNamedItem('text').value;
					newElem.value = root.childNodes.item(2).childNodes.item(i).attributes.getNamedItem('value').value;
					c_busca_cidade.options.add(newElem);
					if(root.childNodes.item(2).attributes.getNamedItem('value') == null){
						if(root.childNodes.item(2).childNodes.item(i).attributes.getNamedItem('selected').value == 'true'){
							c_busca_cidade.value = root.childNodes.item(2).childNodes.item(i).attributes.getNamedItem('value').value;
						}
					}else{
						c_busca_cidade.value = root.childNodes.item(2).attributes.getNamedItem('value').value;
					}
				} 
				if(c_busca_cidade.options.length < 2){
					c_busca_cidade.style.display = 'none';
				}else{
					c_busca_cidade.style.display = '';
				}
			}
			/*######################################
			#COMBO DE CIDADE  (busca_cidade_regiao)#
			######################################*/
			c_busca_cidade_regiao = document.getElementById('busca_cidade_regiao');
			if(c_busca_cidade_regiao){
				while (c_busca_cidade_regiao.length > 0) {
					c_busca_cidade_regiao.remove(0);
				}
	
				var newElem = document.createElement("option");
				newElem.text = "todas as cidades da região";
				newElem.value = "";
				c_busca_cidade_regiao.options.add(newElem);
				c_busca_cidade_regiao.value = "";
				
				for(i = 0; i < root.childNodes.item(3).childNodes.length; i++){
					var newElem = document.createElement("option");
					newElem.text = root.childNodes.item(3).childNodes.item(i).attributes.getNamedItem('text').value;
					newElem.value = root.childNodes.item(3).childNodes.item(i).attributes.getNamedItem('value').value;
					c_busca_cidade_regiao.options.add(newElem);
					if(root.childNodes.item(3).childNodes.item(i).attributes.getNamedItem('selected').value == 'true'){
						c_busca_cidade_regiao.value = root.childNodes.item(3).childNodes.item(i).attributes.getNamedItem('value').value;
					}
				} 
				if(c_busca_cidade_regiao.options.length < 2){
					c_busca_cidade_regiao.style.display = 'none';
					document.getElementById('apontador2').style.display = 'none';
				}else{
					if(c_busca_cidade_regiao.options.length == 2){
						c_busca_cidade_regiao.options[1].selected = true;
					}
					c_busca_cidade_regiao.style.display = '';
					document.getElementById('apontador2').style.display = '';
				}
			}
			
			/*######################################
			#COMBO DE BAIRRO  (busca_bairro)       #
			######################################*/
			c_busca_bairro = document.getElementById('busca_bairro');
			if(c_busca_bairro){
				while (c_busca_bairro.length > 0) {
					c_busca_bairro.remove(0);
				}
				if(root.childNodes.item(4).attributes.getNamedItem('value') != null){
					
					var newElem = document.createElement("option");
					newElem.text = "todos os bairros";
					newElem.value = "";
					c_busca_bairro.options.add(newElem);
					
					var newElem = document.createElement("option");
					newElem.text = "SubRegião de " + root.childNodes.item(4).attributes.getNamedItem('text').value;
					newElem.value = root.childNodes.item(4).attributes.getNamedItem('value').value;
					c_busca_bairro.options.add(newElem);
				}else{
					var newElem = document.createElement("option");
					newElem.text = "todos os bairros";
					newElem.value = "";
					c_busca_bairro.options.add(newElem);
				}
				
				c_busca_bairro.value = "";
	
				for(i = 1; i < root.childNodes.item(4).childNodes.length; i++){
					var newElem = document.createElement("option");
					newElem.text = root.childNodes.item(4).childNodes.item(i).attributes.getNamedItem('text').value;
					newElem.value = root.childNodes.item(4).childNodes.item(i).attributes.getNamedItem('value').value;
					c_busca_bairro.options.add(newElem);
					if(root.childNodes.item(4).childNodes.item(i).attributes.getNamedItem('selected').value == 'true'){
						c_busca_bairro.value = root.childNodes.item(4).childNodes.item(i).attributes.getNamedItem('value').value;
					}
				} 
				if(c_busca_bairro.options.length < 2){
					c_busca_bairro.style.display = 'none';
	
				}else{
					c_busca_bairro.style.display = '';
				}
			}
			/*######################################
			#COMBO DE BAIRRO  (busca_bairro_subregiao)#
			######################################*/
			c_busca_bairro_subregiao = document.getElementById('busca_bairro_subregiao');
			if(c_busca_bairro_subregiao){
				while (c_busca_bairro_subregiao.length > 0) {
					c_busca_bairro_subregiao.remove(0);
				}
	
				var newElem = document.createElement("option");
				newElem.text = "todos os bairros da sub-regiao";
				newElem.value = "";
				c_busca_bairro_subregiao.options.add(newElem);
				c_busca_bairro_subregiao.value = "";
	
				for(i = 1; i < root.childNodes.item(5).childNodes.length; i++){
					var newElem = document.createElement("option");
					newElem.text = root.childNodes.item(5).childNodes.item(i).attributes.getNamedItem('text').value;
					newElem.value = root.childNodes.item(5).childNodes.item(i).attributes.getNamedItem('value').value;
					c_busca_bairro_subregiao.options.add(newElem);
					if(root.childNodes.item(5).childNodes.item(i).attributes.getNamedItem('selected').value == 'true'){
						c_busca_bairro_subregiao.value = root.childNodes.item(5).childNodes.item(i).attributes.getNamedItem('value').value;
					}
				} 
				if(root.childNodes.item(5).childNodes.length < 2){
					c_busca_bairro_subregiao.style.display = 'none';
					document.getElementById('apontador3').style.display = 'none';
				}else{
					c_busca_bairro_subregiao.style.display = '';
					document.getElementById('apontador3').style.display = '';
				}
			}
			/*############################################
			# MAPA                                       #
			#############################################*/
			if(root.childNodes.item(6).childNodes.item(0).attributes.getNamedItem('src').value != ""){
				divmapa = root.childNodes.item(6).childNodes.item(1).text;
				divmapa = divmapa + "<img src=\"" +  root.childNodes.item(6).childNodes.item(0).attributes.getNamedItem('src').value + "\" usemap=\"#mapa\" border=\"0\" > ";
				for(x=0; x <= (divmapa.length / 14); x++ ){
					divmapa = divmapa.replace('[menor]',"<");
					divmapa = divmapa.replace('[maior]',">");
				}	
				//alert(divmapa)
				//x= document.open('','','');
				//x.document.write(divmapa);
				
				
				
				document.getElementById('mapa').innerHTML = divmapa;
			}
			/*#############################################
			#COMBO DE CATEGORIAS  (busca_bairro_subregiao)#
			#############################################*/
			if(document.getElementById('busca_categoria') != undefined){
				c_busca_categoria = document.getElementById('busca_categoria');
				while (c_busca_categoria.length > 0) {
					c_busca_categoria.remove(0);
				}
	
/*				var newElem = document.createElement("option");
				newElem.text = "todas as categorias";
				newElem.value = "";
				c_busca_categoria.options.add(newElem);*/
				c_busca_categoria.value = "";
	
				for(i = 0; i < root.childNodes.item(7).childNodes.length; i++){
					var newElem = document.createElement("option");
					newElem.text = root.childNodes.item(7).childNodes.item(i).attributes.getNamedItem('text').value;
					newElem.value = root.childNodes.item(7).childNodes.item(i).attributes.getNamedItem('value').value;
					c_busca_categoria.options.add(newElem);
					if(root.childNodes.item(7).childNodes.item(i).attributes.getNamedItem('selected').value == 'true'){
						
						strLocation = location.href.split("/");
						switch(root.childNodes.item(7).childNodes.item(i).attributes.getNamedItem('value').value){
							case "00000000001":
								if(strLocation[strLocation.length-1].substr(0,12) != "veiculos.php"){
									window.location.href='veiculos.php';
								}
							break;
							case "00000000002":
								if(strLocation[strLocation.length-1].substr(0,11) != "imoveis.php"){
									window.location.href='imoveis.php';
								}
							break;
							case "00000000003":
								if(strLocation[strLocation.length-1].substr(0,16) != "sites_regiao.php"){
									window.location.href='sites_regiao.php';
								}
							break;
							case "00000000004":
								if(strLocation[strLocation.length-1].substr(0,12) != "empregos.php"){
									window.location.href='empregos.php';
								}
							break;
							default:
								if(strLocation[strLocation.length-1].substr(0,17) != "classificados.php"){
									window.location.href='classificados.php';
								}
								
							break;
						}
						
						c_busca_categoria.value = root.childNodes.item(7).childNodes.item(i).attributes.getNamedItem('value').value;							

					}
				} 
	
				if(root.childNodes.item(7).childNodes.length < 1){
					c_busca_categoria.style.display = 'none';
					document.getElementById('apontador4').style.display = 'none';
				}else{
					c_busca_categoria.style.display = '';
					document.getElementById('apontador4').style.display = '';
				}
				/*################################################
				#COMBO DE SUBCATEGORIAS  (busca_bairro_subregiao)#
				################################################*/
				c_busca_subcategoria = document.getElementById('busca_subcategoria');
				while (c_busca_subcategoria.length > 0) {
					c_busca_subcategoria.remove(0);
				}
	
				var newElem = document.createElement("option");
				newElem.text = "todas as subcategorias";
				newElem.value = "";
				c_busca_subcategoria.options.add(newElem);
				c_busca_subcategoria.value = "";
	
				for(i = 0; i < root.childNodes.item(8).childNodes.length; i++){
				var newElem = document.createElement("option");
					newElem.text = root.childNodes.item(8).childNodes.item(i).attributes.getNamedItem('text').value;
					newElem.value = root.childNodes.item(8).childNodes.item(i).attributes.getNamedItem('value').value;
					c_busca_subcategoria.options.add(newElem);
					if(root.childNodes.item(8).childNodes.item(i).attributes.getNamedItem('selected').value == 'true'){
						c_busca_subcategoria.value = root.childNodes.item(8).childNodes.item(i).attributes.getNamedItem('value').value;
					}
				} 
	
				if(root.childNodes.item(8).childNodes.length < 1){
					c_busca_subcategoria.style.display = 'none';
					document.getElementById('apontador4').style.display = 'none';
				}else{
					c_busca_subcategoria.style.display = '';
					document.getElementById('apontador4').style.display = '';
				}
				
				//SELECIONA O TIPO
				switch(root.childNodes.item(9).text){
					case 'N':
						document.getElementById('busca_tipo1').checked = true;
					break;
					case 'U':
						document.getElementById('busca_tipo2').checked = true;
					break;
					default:
						document.getElementById('busca_tipo0').checked = true;
					break;					
					
				}
				/*################################################
				#COMBO DE MARCAS  (busca_bairro_subregiao)#
				################################################*/

				
				c_busca_marca = document.getElementById('busca_marca');
				if(c_busca_marca != undefined){
					while (c_busca_marca.length > 0) {
						c_busca_marca.remove(0);
					}
		
					var newElem = document.createElement("option");
					newElem.text = "todas as marcas";
					newElem.value = "";
					c_busca_marca.options.add(newElem);
					c_busca_marca.value = "";
		
					for(i = 0; i < root.childNodes.item(10).childNodes.length; i++){
						var newElem = document.createElement("option");
						newElem.text = root.childNodes.item(10).childNodes.item(i).attributes.getNamedItem('text').value;
						newElem.value = root.childNodes.item(10).childNodes.item(i).attributes.getNamedItem('value').value;
						c_busca_marca.options.add(newElem);
//						alert(root.childNodes.item(10).childNodes.item(i).attributes.getNamedItem('selected').value);	
						if(root.childNodes.item(10).childNodes.item(i).attributes.getNamedItem('selected').value == 'true'){
							c_busca_marca.value = root.childNodes.item(10).childNodes.item(i).attributes.getNamedItem('value').value;
						}
					} 
		
					if(root.childNodes.item(10).childNodes.length < 1){
						c_busca_marca.style.display = 'none';
						document.getElementById('apontador5').style.display = 'none';
					}else{
						c_busca_marca.style.display = '';
						document.getElementById('apontador5').style.display = '';
					}
				}
				
				/*################################################
				#COMBO DE MODELOS  (busca_bairro_subregiao)#
				################################################*/

				
				c_busca_modelo = document.getElementById('busca_modelo');
				if(c_busca_modelo != undefined){
					while (c_busca_modelo.length > 0) {
						c_busca_modelo.remove(0);
					}
		
					var newElem = document.createElement("option");
					newElem.text = "todos os modelos";
					newElem.value = "";
					c_busca_modelo.options.add(newElem);
					c_busca_modelo.value = "";
		
					for(i = 0; i < root.childNodes.item(11).childNodes.length; i++){
						var newElem = document.createElement("option");
						newElem.text = root.childNodes.item(11).childNodes.item(i).attributes.getNamedItem('text').value;
						newElem.value = root.childNodes.item(11).childNodes.item(i).attributes.getNamedItem('value').value;
						c_busca_modelo.options.add(newElem);
//						alert(root.childNodes.item(10).childNodes.item(i).attributes.getNamedItem('selected').value);	
						if(root.childNodes.item(11).childNodes.item(i).attributes.getNamedItem('selected').value == 'true'){
							c_busca_modelo.value = root.childNodes.item(11).childNodes.item(i).attributes.getNamedItem('value').value;
						}
					} 
		
					if(root.childNodes.item(11).childNodes.length < 1){
						c_busca_modelo.style.display = 'none';
					}else{
						c_busca_modelo.style.display = '';
					}
				}
				
				
				/*################################################
				#COMBO DE NEGOCIACAO     (busca_bairro_subregiao)#
				################################################*/
		
				c_busca_negociacao = document.getElementById('busca_negociacao');
				if(c_busca_negociacao != undefined){
					while (c_busca_negociacao.length > 0) {
						c_busca_negociacao.remove(0);
					}
		
					var newElem = document.createElement("option");
					newElem.text = "selecione uma negociação";
					newElem.value = "";
					c_busca_negociacao.options.add(newElem);
					c_busca_negociacao.value = "";
		
					for(i = 0; i < root.childNodes.item(12).childNodes.length; i++){
						var newElem = document.createElement("option");
						newElem.text = root.childNodes.item(12).childNodes.item(i).attributes.getNamedItem('text').value;
						newElem.value = root.childNodes.item(12).childNodes.item(i).attributes.getNamedItem('value').value;
						c_busca_negociacao.options.add(newElem);
//						alert(root.childNodes.item(10).childNodes.item(i).attributes.getNamedItem('selected').value);	
						if(root.childNodes.item(12).childNodes.item(i).attributes.getNamedItem('selected').value == 'true'){
							c_busca_negociacao.value = root.childNodes.item(12).childNodes.item(i).attributes.getNamedItem('value').value;
						}
					} 
		
					/*if(root.childNodes.item(12).childNodes.length < 1){
						c_busca_negociacao.style.display = 'none';
					}else{
						c_busca_negociacao.style.display = '';
					}*/
				}
				
			}
			document.getElementById('carregando').style.display = 'none';
			document.getElementById('filtros_busca').style.display = '';

			if(acao_pesquisa == "A"){
				Carrega_Registros('','','','');
			}else if(global_auto_procurar == '1'){
				Carrega_Registros(valor_tipo(),document.getElementById('busca_ordem').value,'1','pesquisar')
			}
			
		}else{ 
			alert("Houve um problema ao obter os dados:\n" + objRegiao.statusText); 
			//document.getElementById('prepage').style.display = 'none';
		} 	
	}
	return true;
}

function Hoje(){
	
	var objData = new Date();
	var dia = new String(objData.getDate());
	var mes = new String(objData.getMonth() +1);
	var ano = new String(objData.getFullYear());
	var seg = new String(objData.getSeconds());
	
	if(parseInt(dia.length) == 1){
		dia = "0" + dia;
	}
	if(parseInt(mes.length) == 1){

		mes = "0" + mes;
	}

	return dia + "" + mes + "" + ano + "" + seg;

	
}

function efetua_busca_filtros(){
	
	var categoria = "";
	if(document.getElementById('busca_categoria') != undefined){
		categoria = document.getElementById('busca_categoria').options[(document.getElementById('busca_categoria').selectedIndex)].value;
	}
	/*strLocation = location.href.split("/");
    /*#############################################################################################################################*/
	/*antes de fazer isso enviar a informação para que o arquivo possa saber em qual categoria estou: PROBLEMA COMO FAZER ISSO ????*/
	/*#############################################################################################################################*/
/*
	switch(categoria){
		case "00000000001":
			if(strLocation[strLocation.length-1].substr(0,12) != "veiculos.php"){
				window.location.href='veiculos.php';
			}
		break;
		case "00000000002":
			if(strLocation[strLocation.length-1].substr(0,11) != "imoveis.php"){
				window.location.href='imoveis.php';
			}
		break;
		case "00000000003":
			if(strLocation[strLocation.length-1].substr(0,16) != "sites_regiao.php"){
				window.location.href='sites_regiao.php';
			}
		break;
		case "00000000004":
			if(strLocation[strLocation.length-1].substr(0,12) != "empregos.php"){
				window.location.href='empregos.php';
			}
		break;
		default:
			if(strLocation[strLocation.length-1].substr(0,17) != "classificados.php"){
				window.location.href='classificados.php';
			}
			
		break;
	}
	*/
	var pais, estado, cidade, cidade_regiao, bairro, bairro_subregiao, subcategoria, negociacao, modelo, marca;
	pais = document.getElementById('busca_pais').options[(document.getElementById('busca_pais').selectedIndex)].value;
	estado = document.getElementById('busca_estado').options[(document.getElementById('busca_estado').selectedIndex)].value;
	cidade = document.getElementById('busca_cidade').options[(document.getElementById('busca_cidade').selectedIndex)].value;
	cidade_regiao = document.getElementById('busca_cidade_regiao').options[(document.getElementById('busca_cidade_regiao').selectedIndex)].value;
	bairro = document.getElementById('busca_bairro').options[(document.getElementById('busca_bairro').selectedIndex)].value;
	bairro_subregiao = document.getElementById('busca_bairro_subregiao').options[(document.getElementById('busca_bairro_subregiao').selectedIndex)].value;


	if(trim(pais) == ""){
		pais = "";
		estado = "";
		cidade = "";
		cidade_regiao = "";
		bairro = "";
		bairro_subregiao = "";
	}else{
		if(trim(estado) == ""){
			estado = "";
			cidade = "";
			cidade_regiao = "";
			bairro = "";
			bairro_subregiao = "";
		}else{
			if(trim(cidade) == ""){
				cidade = "";
				cidade_regiao = "";
				bairro = "";
				bairro_subregiao = "";
			}else{
				if(trim(cidade_regiao) == ""){
					cidade_regiao = "";
					bairro = "";
					bairro_subregiao = "";
				}else{
					if(trim(bairro) == ""){
						bairro = "";
						bairro_subregiao = "";
					}else{
						if(trim(bairro_subregiao) == ""){
							bairro_subregiao = "";
						}
					}
				}
			}
		}
	}
	subcategoria = "";
	if(document.getElementById('busca_subcategoria') != undefined){
		subcategoria = document.getElementById('busca_subcategoria').options[(document.getElementById('busca_subcategoria').selectedIndex)].value;
	}
	
	marca = "";
	if(document.getElementById('busca_marca') != undefined){
		marca = document.getElementById('busca_marca').options[(document.getElementById('busca_marca').selectedIndex)].value;
	}
	modelo = "";
	if(document.getElementById('busca_modelo') != undefined){
		modelo = document.getElementById('busca_modelo').options[(document.getElementById('busca_modelo').selectedIndex)].value;
	}
	negociacao = "";
	if(document.getElementById('busca_negociacao') != undefined){
		negociacao = document.getElementById('busca_negociacao').options[(document.getElementById('busca_negociacao').selectedIndex)].value;
	}
	//alert("pais=" + pais +",estado="+ estado +",cidade="+ cidade +",cidade_regiao="+ cidade_regiao +",bairro="+ bairro +",bairro_subregiao"+ bairro_subregiao +",subcategoria="+ subcategoria +",negociacao="+ negociacao +",modelo="+ modelo +",marca="+ marca)
//	return false;

	Carrega_Mapa(pais,estado,cidade,cidade_regiao,bairro,bairro_subregiao,categoria,subcategoria,valor_tipo(),marca,modelo,negociacao);
	//alert(pais+","+estado+","+cidade+","+cidade_regiao+","+bairro+","+bairro_subregiao+","+categoria+","+subcategoria+","+valor_tipo()+","+marca+","+modelo+","+negociacao)
}	 
function abreestados(cod){

	pais = document.getElementById('busca_pais').options[(document.getElementById('busca_pais').selectedIndex)].value;
	estado = document.getElementById('busca_estado').options[(document.getElementById('busca_estado').selectedIndex)].value;
	cidade = document.getElementById('busca_cidade').options[(document.getElementById('busca_cidade').selectedIndex)].value;
	cidade_regiao = document.getElementById('busca_cidade_regiao').options[(document.getElementById('busca_cidade_regiao').selectedIndex)].value;
	bairro = document.getElementById('busca_bairro').options[(document.getElementById('busca_bairro').selectedIndex)].value;
	bairro_subregiao = document.getElementById('busca_bairro_subregiao').options[(document.getElementById('busca_bairro_subregiao').selectedIndex)].value;

	categoria = "";
	if(document.getElementById('busca_categoria') != undefined){
		categoria = document.getElementById('busca_categoria').options[(document.getElementById('busca_categoria').selectedIndex)].value;
	}
	subcategoria = "";
	if(document.getElementById('busca_subcategoria') != undefined){
		subcategoria = document.getElementById('busca_subcategoria').options[(document.getElementById('busca_subcategoria').selectedIndex)].value;
	}
	
	marca = "";
	if(document.getElementById('busca_marca') != undefined){
		marca = document.getElementById('busca_marca').options[(document.getElementById('busca_marca').selectedIndex)].value;
	}
	modelo = "";
	if(document.getElementById('busca_modelo') != undefined){
		modelo = document.getElementById('busca_modelo').options[(document.getElementById('busca_modelo').selectedIndex)].value;
	}
	negociacao = "";
	if(document.getElementById('busca_negociacao') != undefined){
		negociacao = document.getElementById('busca_negociacao').options[(document.getElementById('busca_negociacao').selectedIndex)].value;
	}
	Carrega_Mapa(pais,cod,cidade,cidade_regiao,bairro,bairro_subregiao,categoria,subcategoria,valor_tipo(),marca,modelo,negociacao)
}
function abrecidades(cod){

	pais = document.getElementById('busca_pais').options[(document.getElementById('busca_pais').selectedIndex)].value;
	estado = document.getElementById('busca_estado').options[(document.getElementById('busca_estado').selectedIndex)].value;
	cidade = document.getElementById('busca_cidade').options[(document.getElementById('busca_cidade').selectedIndex)].value;
	cidade_regiao = document.getElementById('busca_cidade_regiao').options[(document.getElementById('busca_cidade_regiao').selectedIndex)].value;
	bairro = document.getElementById('busca_bairro').options[(document.getElementById('busca_bairro').selectedIndex)].value;
	bairro_subregiao = document.getElementById('busca_bairro_subregiao').options[(document.getElementById('busca_bairro_subregiao').selectedIndex)].value;

	categoria = "";
	if(document.getElementById('busca_categoria') != undefined){
		categoria = document.getElementById('busca_categoria').options[(document.getElementById('busca_categoria').selectedIndex)].value;
	}
	subcategoria = "";
	if(document.getElementById('busca_subcategoria') != undefined){
		subcategoria = document.getElementById('busca_subcategoria').options[(document.getElementById('busca_subcategoria').selectedIndex)].value;
	}
	
	marca = "";
	if(document.getElementById('busca_marca') != undefined){
		marca = document.getElementById('busca_marca').options[(document.getElementById('busca_marca').selectedIndex)].value;
	}
	modelo = "";
	if(document.getElementById('busca_modelo') != undefined){
		modelo = document.getElementById('busca_modelo').options[(document.getElementById('busca_modelo').selectedIndex)].value;
	}
	
	negociacao = "";
	if(document.getElementById('busca_negociacao') != undefined){
		negociacao = document.getElementById('busca_negociacao').options[(document.getElementById('busca_negociacao').selectedIndex)].value;
	}
	
	Carrega_Mapa(pais,estado,cod,cidade_regiao,bairro,bairro_subregiao,categoria,subcategoria,valor_tipo(),marca,modelo,negociacao)
}
function abrecidades_regiao(cod){
	pais = document.getElementById('busca_pais').options[(document.getElementById('busca_pais').selectedIndex)].value;
	estado = document.getElementById('busca_estado').options[(document.getElementById('busca_estado').selectedIndex)].value;
	cidade = document.getElementById('busca_cidade').options[(document.getElementById('busca_cidade').selectedIndex)].value;
	cidade_regiao = document.getElementById('busca_cidade_regiao').options[(document.getElementById('busca_cidade_regiao').selectedIndex)].value;
	bairro = document.getElementById('busca_bairro').options[(document.getElementById('busca_bairro').selectedIndex)].value;
	bairro_subregiao = document.getElementById('busca_bairro_subregiao').options[(document.getElementById('busca_bairro_subregiao').selectedIndex)].value;

	categoria = "";
	if(document.getElementById('busca_categoria') != undefined){
		categoria = document.getElementById('busca_categoria').options[(document.getElementById('busca_categoria').selectedIndex)].value;
	}
	subcategoria = "";
	if(document.getElementById('busca_subcategoria') != undefined){
		subcategoria = document.getElementById('busca_subcategoria').options[(document.getElementById('busca_subcategoria').selectedIndex)].value;
	}
	
	marca = "";
	if(document.getElementById('busca_marca') != undefined){
		marca = document.getElementById('busca_marca').options[(document.getElementById('busca_marca').selectedIndex)].value;
	}
	modelo = "";
	if(document.getElementById('busca_modelo') != undefined){
		modelo = document.getElementById('busca_modelo').options[(document.getElementById('busca_modelo').selectedIndex)].value;
	}
	negociacao = "";
	if(document.getElementById('busca_negociacao') != undefined){
		negociacao = document.getElementById('busca_negociacao').options[(document.getElementById('busca_negociacao').selectedIndex)].value;
	}
	Carrega_Mapa(pais,estado,cidade,cod,bairro,bairro_subregiao,categoria,subcategoria,valor_tipo(),marca,modelo,negociacao)

}
function abrebairros(cod){
	pais = document.getElementById('busca_pais').options[(document.getElementById('busca_pais').selectedIndex)].value;
	estado = document.getElementById('busca_estado').options[(document.getElementById('busca_estado').selectedIndex)].value;
	cidade = document.getElementById('busca_cidade').options[(document.getElementById('busca_cidade').selectedIndex)].value;
	cidade_regiao = document.getElementById('busca_cidade_regiao').options[(document.getElementById('busca_cidade_regiao').selectedIndex)].value;
	bairro = cod
	bairro_subregiao = document.getElementById('busca_bairro_subregiao').options[(document.getElementById('busca_bairro_subregiao').selectedIndex)].value;

	categoria = "";
	if(document.getElementById('busca_categoria') != undefined){
		categoria = document.getElementById('busca_categoria').options[(document.getElementById('busca_categoria').selectedIndex)].value;
	}
	subcategoria = "";
	if(document.getElementById('busca_subcategoria') != undefined){
		subcategoria = document.getElementById('busca_subcategoria').options[(document.getElementById('busca_subcategoria').selectedIndex)].value;
	}
	
	marca = "";
	if(document.getElementById('busca_marca') != undefined){
		marca = document.getElementById('busca_marca').options[(document.getElementById('busca_marca').selectedIndex)].value;
	}
	modelo = "";
	if(document.getElementById('busca_modelo') != undefined){
		modelo = document.getElementById('busca_modelo').options[(document.getElementById('busca_modelo').selectedIndex)].value;
	}
	
	negociacao = "";
	if(document.getElementById('busca_negociacao') != undefined){
		negociacao = document.getElementById('busca_negociacao').options[(document.getElementById('busca_negociacao').selectedIndex)].value;
	}
	
	Carrega_Mapa(pais,estado,cidade,cod,bairro,bairro_subregiao,categoria,subcategoria,valor_tipo(),marca,modelo,negociacao)

}	
function abrebairros_subregiao(cod){
	pais = document.getElementById('busca_pais').options[(document.getElementById('busca_pais').selectedIndex)].value;
	estado = document.getElementById('busca_estado').options[(document.getElementById('busca_estado').selectedIndex)].value;
	cidade = document.getElementById('busca_cidade').options[(document.getElementById('busca_cidade').selectedIndex)].value;
	cidade_regiao = document.getElementById('busca_cidade_regiao').options[(document.getElementById('busca_cidade_regiao').selectedIndex)].value;
	bairro = document.getElementById('busca_bairro').options[(document.getElementById('busca_bairro').selectedIndex)].value;
	bairro_subregiao = cod

	categoria = "";
	if(document.getElementById('busca_categoria') != undefined){
		categoria = document.getElementById('busca_categoria').options[(document.getElementById('busca_categoria').selectedIndex)].value;
	}
	subcategoria = "";
	if(document.getElementById('busca_subcategoria') != undefined){
		subcategoria = document.getElementById('busca_subcategoria').options[(document.getElementById('busca_subcategoria').selectedIndex)].value;
	}
	
	marca = "";
	if(document.getElementById('busca_marca') != undefined){
		marca = document.getElementById('busca_marca').options[(document.getElementById('busca_marca').selectedIndex)].value;
	}
	modelo = "";
	if(document.getElementById('busca_modelo') != undefined){
		modelo = document.getElementById('busca_modelo').options[(document.getElementById('busca_modelo').selectedIndex)].value;
	}
	
	negociacao = "";
	if(document.getElementById('busca_negociacao') != undefined){
		negociacao = document.getElementById('busca_negociacao').options[(document.getElementById('busca_negociacao').selectedIndex)].value;
	}
	Carrega_Mapa(pais,estado,cidade,cod,bairro,bairro_subregiao,categoria,subcategoria,valor_tipo(),marca,modelo,negociacao)
}	
function pesquisa_palavra_chave(valor){
		
}