function buscaTipoImovel(cidade, tc){
	
	var tiposdeimovel = document.getElementById('TipoImovelInput');	
	tiposdeimovel.innerHTML = '';
	
	var op = document.createElement('option');    
	op.setAttribute('value', '');    
	op.appendChild(document.createTextNode("Carregando..."));    
	tiposdeimovel.appendChild(op);
	
	//cidade = cidade.replace(/ /g, '+');	
		
	var url = 'xml/TICidadeContratoXML.php?tn=' + tc + '&cidade=' + cidade;
	
	//alert(url);
		
	var ajax = openAjax();
	
	ajax.open('GET', url, true);
	ajax.onreadystatechange = function(){
		
		if (ajax.readyState == 4){
			
			if (ajax.status == 200){
				
				//Novamente limpa o ComboBox
				tiposdeimovel.innerHTML = '';
				
				var xml = ajax.responseXML;
				// Aqui é criada uma variavel que receberá o equivalente a um NÓ no arquivo XML.
				var tipoimovel = xml.getElementsByTagName('tipoimovel');
				
				var bairros = document.getElementById('BairroInput');	
				bairros.setAttribute('disabled', 'disabled');
				
				//var buscar = document.getElementById('BuscarInput');
				//buscar.setAttribute('disabled', 'disabled');
				
				if(tipoimovel.length == 0){					
					
					//Aqui irá desativar o ComboBox de Cidades		
					tiposdeimovel.setAttribute('disabled', 'disabled');
					var intro = document.createElement('option');
					intro.setAttribute('value', '');
					intro.appendChild(document.createTextNode("- Tipo de Imovel"));					
					tiposdeimovel.appendChild(intro);	
					
				}else{
					
					tiposdeimovel.removeAttribute('disabled');
					
					var intro1 = document.createElement('option');
					intro1.setAttribute('value', '');
					intro1.appendChild(document.createTextNode("- Tipo de Imovel"));					
					tiposdeimovel.appendChild(intro1);	
					
					var intro2 = document.createElement('option');
					intro2.setAttribute('value', '');
					intro2.appendChild(document.createTextNode("---------------------------"));					
					tiposdeimovel.appendChild(intro2);
					
					//alert(tipoimovel.length);
					
					for (var i = 0; i < tipoimovel.length; i++){
						
						//alert(i);
												
						var nomeTipo = tipoimovel[i].getElementsByTagName('nome')[0].firstChild.nodeValue;
						//alert(nomeTipo);
						
						var nomeTipoFormat = tipoimovel[i].getElementsByTagName('nomeformat')[0].firstChild.nodeValue;
						//alert(nomeTipoFormat);
						
						var opcao = document.createElement('option');
						opcao.setAttribute('value', nomeTipoFormat);
						opcao.appendChild(document.createTextNode(nomeTipo));
						tiposdeimovel.appendChild(opcao);
					}
				}
			}
		}
	}
	
	ajax.send(null);
	
}

function seoString(palavra){
	
	var string = palavra.toLowerCase();	

	for(var x = 0; x < string.length; x++){
		string = string.replace(/[âáàã]/,"a");
		string = string.replace(/[éèê]/,"e");
		string = string.replace(/[íìî]/,"i");
		string = string.replace(/[ôõóò]/,"o");
		string = string.replace(/[úùû]/,"u");
		string = string.replace("ç","c");
		//string = string.replace(" ","-");
	}
	
	return string;

}
