	var xmlhttp = getXmlHttpRequest();
	
	function getXmlHttpRequest() {
		if (window.XMLHttpRequest) {
			return new XMLHttpRequest();
		} else if (window.ActiveXObject) {
			return new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	
	
function Cidades(url,ID){
  document.getElementById("cidade").innerHTML = '<select disabled="disabled" style="width:88px;"><option>Carregando...</option></select>';
  xmlhttp.open("GET", url + '?uf=' + ID, true);
  xmlhttp.onreadystatechange = function(){
  
   if (xmlhttp.readyState == 4){
   
   var texto = xmlhttp.responseText;
   texto = texto.replace(/\+/g," ");
   texto = unescape(texto);
	document.getElementById("cidade").innerHTML = xmlhttp.responseText;
   }
  } 
  xmlhttp.send(null);
 }
 
 function Cidades2(url,ID){
  document.getElementById("cidade").innerHTML = '<select disabled="disabled" style="width:128px; height:20px; font-size:12px;"><option>Carregando...</option></select>';
  xmlhttp.open("GET", url + '?uf=' + ID, true);
  xmlhttp.onreadystatechange = function(){
  
   if (xmlhttp.readyState == 4){
   
   var texto = xmlhttp.responseText;
   texto = texto.replace(/\+/g," ");
   texto = unescape(texto);
	document.getElementById("cidade").innerHTML = xmlhttp.responseText;
   }
  } 
  xmlhttp.send(null);
 }

function Bairros(url,ID){
  document.getElementById("bairros").innerHTML = '<select disabled="disabled" style="width:88px;"><option>Carregando...</option></select>';
  xmlhttp.open("GET", url + '?cidade=' + ID, true);
  xmlhttp.onreadystatechange = function(){
  
   if (xmlhttp.readyState == 4){
   var texto = xmlhttp.responseText;
   texto = texto.replace(/\+/g," ");
   texto = unescape(texto);
	document.getElementById("bairros").innerHTML = xmlhttp.responseText;
   }
  } 
  xmlhttp.send(null);
 }

function BuscaCodigoImovel() {
	var codigo_imovel = document.getElementById("codigo_imovel").value;
	window.location = 'imoveis.php?id='+codigo_imovel;
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function Inserir(url,id_imovel){
	  xmlhttp.open("GET", url + '?id_imovel=' + id_imovel, true);
	  xmlhttp.onreadystatechange = function(){
	  
		   if (xmlhttp.readyState == 4){
			}
	  } 
	  xmlhttp.send(null);
 }


function PainelCidades(ID){
	
  document.getElementById("cidade").innerHTML = '<select disabled="disabled" style="width:129px;"><option>Carregando...</option></select>';
  xmlhttp.open("GET", 'ajax_cidades.php?uf=' + ID, true);
  xmlhttp.onreadystatechange = function(){
   if (xmlhttp.readyState == 4){
   
   var texto = xmlhttp.responseText;
   texto = texto.replace(/\+/g," ");
   texto = unescape(texto);
	document.getElementById("cidade").innerHTML = xmlhttp.responseText;
	PainelCategorias(ID);
   }
  } 
  xmlhttp.send(null);
 }
  
  
function PainelCategorias(ID){
	
  document.getElementById("categorias").innerHTML = '<select disabled="disabled" style="width:124px;"><option>Carregando...</option></select>';
  xmlhttp.open("GET", 'ajax_categorias.php?uf=' + ID, true);
  xmlhttp.onreadystatechange = function(){
   if (xmlhttp.readyState == 4){
   
   var texto = xmlhttp.responseText;
   texto = texto.replace(/\+/g," ");
   texto = unescape(texto);
	document.getElementById("categorias").innerHTML = xmlhttp.responseText;
   }
  } 
  xmlhttp.send(null);
 }