	function ajax(){
		try{
			xmlhttp = new XMLHttpRequest();
		}catch(ee){
			try{
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
			}catch(e){
				try{
					xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
				}catch(E){
					alert("Este navegador não aceita o AJAX");
					xmlhttp = false;
				}
			}
		}
	}
//////////////////////////////////////  Carregando  Cidades   /////////////////////////////////////////////////////////////////////////////////////////////
	function carregaCombo(idEstado){
			
		var combo = document.getElementById("txtCidade"); // resgatando os dados do combo		
		var	itemCombo = document.createElement('option'); // criando a tag option
		var novoTexto = document.createTextNode("--- AGUARDE CARREGANDO ---"); // adicionando um texto na tag
		itemCombo.appendChild(novoTexto);
		ajax(); // chamando a função ajax
		
		xmlhttp.open("POST","cidades.asp", true);
		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); /// quando envio for método post inserir esta linha 
		
		xmlhttp.onreadystatechange = function(){
			if(xmlhttp.readyState == 1){
				combo.appendChild(itemCombo);
				combo.disabled = true;
				
			}
			if(xmlhttp.readyState == 4){
				combo.remove(combo.selectedIndex);
				texto = xmlhttp.responseText;
				//alert(texto); // mostrando um alert com o que está sendo enviado para a páginas asp
				combo.disabled = false;
				innerSelect("txtCidade",texto);
				carregaestado(idCidade); //chamar as funções aqui
			}
		}
		xmlhttp.send("id="+idEstado.value);	
		//alert (idEstado.value) //exibindo  a consulta da página as  o retono qua paarecerá no combo
	}
//////////////////////////////////////  Carregando  Bairro   /////////////////////////////////////////////////////////////////////////////////////////////
		function carregaestado(idCidade){
		var combo1 = document.getElementById("bairro"); // resgatando os dados do combo
		var	itemCombo1 = document.createElement('option'); // criando a tag option
		var novoTexto1 = document.createTextNode("--- AGUARDE CARREGANDO ---"); // adicionando um texto na tag
		itemCombo1.appendChild(novoTexto1);
		ajax();
		
		xmlhttp.open("POST","bairros.asp", true);
		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		
		
		xmlhttp.onreadystatechange = function(){
			if(xmlhttp.readyState == 1){
				combo1.appendChild(itemCombo1);
				combo1.disabled = true;
				
			}
			if(xmlhttp.readyState == 4){
				combo1.remove(combo1.selectedIndex);
				texto1 = xmlhttp.responseText;
				combo1.disabled = false;
				innerSelect1("bairro",texto1);
				//alert(texto1);
				carregatipo(idTipo);
			}
		}
		xmlhttp.send("idcid="+idCidade.value);	
		//alert (idCidade.value)
	}
    function innerSelect(id,html)
	{
	var sel = document.getElementById(id);
	html = html = '<select name=\"txtCidade\" class=\"cid\" id=\"txtCidade\" onchange=\"carregaestado(this)\" >'+html+'</select>';;
	var temp = document.createElement('div');
	temp.innerHTML = html;
	sel.innerHTML = '';
	var options = temp.getElementsByTagName('option');
	i = 0;
	while (i < options.length)
		{
		sel.appendChild(options[i]);
	//i++;
		}
	} 

    function innerSelect1(id,html)
	{
	var sel = document.getElementById(id);
	html = html = '<select name=\"bairro\" class=\"cid\" id=\"bairro\" onchange=\"carregaestado(this)\" >'+html+'</select>';;
	var temp = document.createElement('div');
	temp.innerHTML = html;
	sel.innerHTML = '';
	var options = temp.getElementsByTagName('option');
	i = 0;
	while (i < options.length)
		{
		sel.appendChild(options[i]);
	//i++;
		}
	} 

	function mostraValor(){
		var valorCombo = document.getElementById("txtCidade");
		//alert(valorCombo.value);
	}
//////////////////////////////////////  Carregando  tipo   /////////////////////////////////////////////////////////////////////////////////////////////
	
		function carregatipo(idTipo){
		var combotipo = document.getElementById("tipo"); // resgatando os dados do combo
		var	itemCombotipo = document.createElement('option'); // criando a tag option
		var novoTextotipo = document.createTextNode("--- AGUARDE CARREGANDO ---"); // adicionando um texto na tag
		itemCombotipo.appendChild(novoTextotipo);
		
		ajax();
		
		xmlhttp.open("POST","tipos.asp", true);
		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		
		
		xmlhttp.onreadystatechange = function(){
			if(xmlhttp.readyState == 1){
				combotipo.appendChild(itemCombotipo);
				combotipo.disabled = true;
				
			}
			if(xmlhttp.readyState == 4){
				combotipo.remove(combotipo.selectedIndex);
				textotipo = xmlhttp.responseText;
				combotipo.disabled = false;
				innerSelecttipo("tipo",textotipo);
				//alert (textotipo)
				carregaFinalidade(idFinalidade);
			}
		}
		xmlhttp.send("idtipo="+idTipo.value);	
		//alert (idTipo.value)
	}
    function innerSelecttipo(id,html)
	{
	var sel = document.getElementById(id);
	html = html = '<select name=\"tipo\" class=\"cid\" id=\"txtCidade\" onchange=\"carregaestado(this)\" >'+html+'</select>';;
	var temp = document.createElement('div');
	temp.innerHTML = html;
	sel.innerHTML = '';
	var options = temp.getElementsByTagName('option');
	i = 0;
	while (i < options.length)
		{
		sel.appendChild(options[i]);
	//i++;
		}
	} 


//////////////////////////////////////  Carregando  Finalidade   /////////////////////////////////////////////////////////////////////////////////////////////
	
		function carregaFinalidade(idFinalidade){
		var combofinalidade = document.getElementById("finalidade"); // resgatando os dados do combo
		var	itemCombofinalidade = document.createElement('option'); // criando a tag option
		var novoTextofinalidade = document.createTextNode("--- AGUARDE CARREGANDO ---"); // adicionando um texto na tag
		itemCombofinalidade.appendChild(novoTextofinalidade);
		
		ajax();
		
		xmlhttp.open("POST","finalidades.asp", true);
		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		
		
		xmlhttp.onreadystatechange = function(){
			if(xmlhttp.readyState == 1){
				combofinalidade.appendChild(itemCombofinalidade);
				combofinalidade.disabled = true;
				
			}
			if(xmlhttp.readyState == 4){
				combofinalidade.remove(combofinalidade.selectedIndex);
				textofinalidade = xmlhttp.responseText;
				combofinalidade.disabled = false;
				innerSelectfinalidade("finalidade",textofinalidade);
				//alert(textofinalidade)
				carregaTransacao(idTransacao);
			}
		}
		xmlhttp.send("idfinalidade="+idFinalidade.value);	
		//alert (idFinalidade.value)
	}
    function innerSelectfinalidade(id,html)
	{
	var sel = document.getElementById(id);
	html = html = '<select name=\"finalidade\" class=\"cid\" id=\"finalidade\" onchange=\"carregaestado(this)\" >'+html+'</select>';;
	var temp = document.createElement('div');
	temp.innerHTML = html;
	sel.innerHTML = '';
	var options = temp.getElementsByTagName('option');
	i = 0;
	while (i < options.length)
		{
		sel.appendChild(options[i]);
	//i++;
		}
	} 

//////////////////////////////////////  Carregando  transacao   /////////////////////////////////////////////////////////////////////////////////////////////
	
		function carregaTransacao(idTransacao){
		var combotransacao = document.getElementById("transacao"); // resgatando os dados do combo
		var	itemCombotransacao = document.createElement('option'); // criando a tag option
		var novoTextotransacao = document.createTextNode("--- AGUARDE CARREGANDO ---"); // adicionando um texto na tag
		itemCombotransacao.appendChild(novoTextotransacao);
		
		ajax();
		
		xmlhttp.open("POST","transacaos.asp", true);
		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		
		
		xmlhttp.onreadystatechange = function(){
			if(xmlhttp.readyState == 1){
				combotransacao.appendChild(itemCombotransacao);
				combotransacao.disabled = true;
				
			}
			if(xmlhttp.readyState == 4){
				combotransacao.remove(combotransacao.selectedIndex);
				textotransacao = xmlhttp.responseText;
				combotransacao.disabled = false;
				innerSelecttransacao("transacao",textotransacao);
				//alert (textotransacao)
				carregaValorInicial(idValorinicial);
			}
		}
		xmlhttp.send("idtransacao="+idTransacao.value);	
		//alert (idTransacao.value)
	}
    function innerSelecttransacao(id,html)
	{
	var sel = document.getElementById(id);
	html = html = '<select name=\"transacao\" class=\"cid\" id=\"transacao\" onchange=\"carregaestado(this)\" >'+html+'</select>';;
	var temp = document.createElement('div');
	temp.innerHTML = html;
	sel.innerHTML = '';
	var options = temp.getElementsByTagName('option');
	i = 0;
	while (i < options.length)
		{
		sel.appendChild(options[i]);
	//i++;
		}
	} 


//////////////////////////////////////  Carregando  valor Inicial   /////////////////////////////////////////////////////////////////////////////////////////

		function carregaValorInicial(idValorinicial){
		var combovalorinicial = document.getElementById("valor_inicial"); // resgatando os dados do combo
		var	itemCombovalorinicial = document.createElement('option'); // criando a tag option
		var novoTextovalorinicial = document.createTextNode("--- AGUARDE CARREGANDO ---"); // adicionando um texto na tag
		itemCombovalorinicial.appendChild(novoTextovalorinicial);
		
		ajax();
		
		xmlhttp.open("POST","valorinicials.asp", true);
		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		
		
		xmlhttp.onreadystatechange = function(){
			if(xmlhttp.readyState == 1){
				combovalorinicial.appendChild(itemCombovalorinicial);
				combovalorinicial.disabled = true;
				
			}
			if(xmlhttp.readyState == 4){
				combovalorinicial.remove(combovalorinicial.selectedIndex);
				textovalorinicial = xmlhttp.responseText;
				combovalorinicial.disabled = false;
				innerSelectvalorinicial("valor_inicial",textovalorinicial);
				//alert(textovalorinicial)
				carregaValorFinal(idValorfinal);
			}
		}
		xmlhttp.send("idvalorinicial="+idValorinicial.value);	
		//alert (idValorinicial.value)
	}
    function innerSelectvalorinicial(id,html)
	{
	var sel = document.getElementById(id);
	html = html = '<select name=\"valor_inicial\" class=\"cid\" id=\"valor_inicial\" onchange=\"carregaestado(this)\" >'+html+'</select>';;
	var temp = document.createElement('div');
	temp.innerHTML = html;
	sel.innerHTML = '';
	var options = temp.getElementsByTagName('option');
	i = 0;
	while (i < options.length)
		{
		sel.appendChild(options[i]);
	//i++;
		}
	} 
//////////////////////////////////////  Carregando  Valor FINAL     //////////////////////////////////////////////////////////////////////////////////////////
	
		function carregaValorFinal(idValorfinal){
		var combovalorfinal = document.getElementById("valor_final"); // resgatando os dados do combo
		var	itemCombovalorfinal = document.createElement('option'); // criando a tag option
		var novoTextovalorfinal = document.createTextNode("--- AGUARDE CARREGANDO ---"); // adicionando um texto na tag
		itemCombovalorfinal.appendChild(novoTextovalorfinal);
		
		ajax();
		
		xmlhttp.open("POST","valorfinals.asp", true);
		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		
		
		xmlhttp.onreadystatechange = function(){
			if(xmlhttp.readyState == 1){
				combovalorfinal.appendChild(itemCombovalorfinal);
				combovalorfinal.disabled = true;
				
			}
			if(xmlhttp.readyState == 4){
				combovalorfinal.remove(combovalorfinal.selectedIndex);
				textovalorfinal = xmlhttp.responseText;
				combovalorfinal.disabled = false;
				innerSelectvalorfinal("valor_final",textovalorfinal);
				//alert (textovalorfinal)
			}
		}
		xmlhttp.send("idvalorfinal="+idValorfinal.value);	
		//alert (idValorfinal.value)
	}
    function innerSelectvalorfinal(id,html)
	{
	var sel = document.getElementById(id);
	html = html = '<select name=\"valor_final\" class=\"cid\" id=\"valor_final\" onchange=\"carregaestado(this)\" >'+html+'</select>';;
	var temp = document.createElement('div');
	temp.innerHTML = html;
	sel.innerHTML = '';
	var options = temp.getElementsByTagName('option');
	i = 0;
	while (i < options.length)
		{
		sel.appendChild(options[i]);
	//i++;
		}
	} 


///  fim da função para o valor Inicial
