function Bairros_Busca(id_cidade){
	
	transacao = document.getElementById("transacao").value;
	
	xmlHttp = GetXmlHttpObject();
	url = "bairros_busca.asp";	
	url = url + "?sid=" + Math.random();
	url = url + "&cidade="+ id_cidade;
	url = url + "&transacao="+ transacao;
	
	xmlHttp.onreadystatechange = Achou;
	
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);

	if (xmlHttp.readyState == 1) {
		
		document.getElementById("Bairros").innerHTML = "...Buscando dados....";  
		if(id_cidade != ''){
			
			if(id_cidade.indexOf(",") > 0){
				texto = id_cidade.split(",")
				cidade = texto[1];
			}
			else{
				cidade = id_cidade;
			}
			
			document.getElementById("txt_cidade").innerHTML = cidade;
		}else{
			document.getElementById("txt_cidade").innerHTML = "Cidade";
		}
	
	}
}

function Achou() { 
	if (xmlHttp.readyState == 4){ 
		document.getElementById("Bairros").innerHTML=xmlHttp.responseText;
	}
}

function GetXmlHttpObject(){
	
	 if (window.XMLHttpRequest) {   
			   a=new XMLHttpRequest(); } //Objeto nativo (FF/Safari/Opera7.6+)  
	   else {  
		 try {   
			a=new ActiveXObject("Msxml2.XMLHTTP");  //activeX (IE5.5+/MSXML2+)  
		 }	 
		 catch(e) {  
		   try {   
			  a=new ActiveXObject("Microsoft.XMLHTTP"); //activeX (IE5+/MSXML1)  
		   }	 
		   catch(e) { /* O navegador não tem suporte */   
			  a=false;   
		   }  
		 }  
	   }   
	   return a;  
}
