	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 AtivaValor(tabela){
  xmlhttp.open("GET",'ativavalor.php?tabela='+tabela, true);
  xmlhttp.onreadystatechange = function(){
  
   if (xmlhttp.readyState == 4){
   }
  } 
  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 = 'empresas.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 CarregaSubcategorias(url,ID){
  document.getElementById("subcategorias").innerHTML = 'Carregando...';
  xmlhttp.open("GET", url + '?id_categoria=' + ID, true);
  xmlhttp.onreadystatechange = function(){
  
   if (xmlhttp.readyState == 4){
   var texto = xmlhttp.responseText;
   texto = texto.replace(/\+/g," ");
   texto = unescape(texto);
	document.getElementById("subcategorias").innerHTML = xmlhttp.responseText;
   }
  } 
  xmlhttp.send(null);
 }

function CarregaSubcategorias2(url,id_empresa,ID){
  document.getElementById("subcategorias").innerHTML = 'Carregando...';
  xmlhttp.open("GET", url + '?id=' + id_empresa + '&id_categoria=' + ID, true);
  xmlhttp.onreadystatechange = function(){
  
   if (xmlhttp.readyState == 4){
   var texto = xmlhttp.responseText;
   texto = texto.replace(/\+/g," ");
   texto = unescape(texto);
	document.getElementById("subcategorias").innerHTML = xmlhttp.responseText;
   }
  } 
  xmlhttp.send(null);
 }
 
var xmlhttp = getXmlHttpRequest();
	
	function getXmlHttpRequest() {
		if (window.XMLHttpRequest) {
			return new XMLHttpRequest();
		} else if (window.ActiveXObject) {
			return new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	
function Inserir(url,subcategoria,itens){
	  xmlhttp.open("GET", url + '?item=' + itens + '&subcategoria=' + subcategoria, true);
	  xmlhttp.onreadystatechange = function(){
		   if (xmlhttp.readyState == 4){
			}
	  } 
	  xmlhttp.send(null);
 }
 
 function BuscaCodigoImovel() {
	var codigo_imovel = document.getElementById("codigo_imovel").value;
	window.location = 'empresas.php?id='+codigo_imovel;
}
 	
function Editar(url,empresa,subcategoria,itens){
	  xmlhttp.open("GET", url + '?id_empresa=' + empresa + '&id_item=' + itens + '&id_subcategoria=' + subcategoria, true);
	  xmlhttp.onreadystatechange = function(){
		   if (xmlhttp.readyState == 4){
			}
	  } 
	  xmlhttp.send(null);
 }
 
 function BuscaCodigoImovel() {
	var codigo_imovel = document.getElementById("codigo_imovel").value;
	window.location = 'empresas.php?id='+codigo_imovel;
}
 	
	
function InserirAcrescentarItem(){
	  var acrescentar_item = document.getElementById("acrescentar_item").value;
	  xmlhttp.open("GET", 'acrescentar_item.php?acrescentar_item='+acrescentar_item, true);
	  xmlhttp.onreadystatechange = function(){
		   if (xmlhttp.readyState == 4){
			   document.getElementById("acrescentar_item").value = '';
			   alert('Sua sugestão foi enviada com sucesso!');
			}
	  } 
	  xmlhttp.send(null);
 }