//Edited By HIT2Go
var ordenado = '';
var dt = '';
function $(id){
	return document.getElementById(id);
}

function ordenar(prd,query){
	url = query.split("_");
	for(i=0;i<10;i++){
		if(i == 3){ 
			dt = prd;
		}else if(url[i] == undefined){
			dt = '';
		}else{ 
			dt = url[i];
		}
		ordenado += dt+'_';
	}
	window.location=ordenado+'.html';	
}
function GetXmlHttpRequest(){
	var ajax=false;
	//para MZ
    if(window.XMLHttpRequest) {
    	try {
			ajax = new XMLHttpRequest();
        } catch(e) {
			ajax = false;
        }
    // para IE
    } else if(window.ActiveXObject) {
       	try {
        	ajax = new ActiveXObject("Msxml2.XMLHTTP");
      	} catch(e) {
        	try {
          		ajax = new ActiveXObject("Microsoft.XMLHTTP");
        	} catch(e) {
          		ajax = false;
        	}
		}
    }
	return ajax;
}

	

function mostraImovel(categ,pais)
{	
		var neg=document.getElementById("negImovel");
		while(neg.options.length>0)neg.options[0]=null;
		neg.options[0]=new Option("Cargando...","");
		
	   var monta = GetXmlHttpRequest();
	   monta.open("post", "engine/combo.php?categ="+categ, true);
	   monta.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	   monta.onreadystatechange=function(){
		     if (monta.readyState==4){
				 if(monta.responseXML) {
                  processXML(monta.responseXML);
               }
               else {
                  alert("Nenhum resultado encontrado");
               }

			 }}
	   monta.send("c="+categ+"&pais="+pais);
}

function processXML(obj){
      
      var dataArray   = obj.getElementsByTagName("listing");
      
	  var neg=document.getElementById("negImovel");
	  while(neg.options.length>0)neg.options[0]=null;
	  neg.options[0]=new Option("Todas","");
      if(dataArray.length > 0) {

         for(var i = 1; i < dataArray.length; i++) {
           
            var idx = dataArray.item(i).getAttribute("categ");
            var nome = dataArray.item(i).getAttribute("nome");

		 var novo = document.createElement("option");
          novo.setAttribute("id", "opcoes");
	      novo.value = idx;
          novo.text  = nome;
          document.getElementById("negImovel").options.add(novo);
         }
      }
      else {
       alert("Nenhum resultado encontrado");
      }      
  }
