try{
    xmlhttp = new XMLHttpRequest();
}catch(ee){
    try{
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    }catch(e){
        try{
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }catch(E){
            xmlhttp = false;
        }
    }
}

function carrega(uf)
{
	
	//document.getElementById("icone").style.display = "block";
	document.getElementById("text_car").style.display = "block";
	

    //Abre a url
    xmlhttp.open("GET", "/idiomas/_includes/inc_busca_cidades.asp?uf="+uf,true);


    //Executada quando o navegador obtiver o código
    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4)
		{
            //Lę o texto
            var texto=xmlhttp.responseText;

            //Desfaz o urlencode
			texto = texto.split("/");
			
			document.getElementById("municipio").options.length = 0;

			for(x=0;x<texto.length;x++)

				document.getElementById("municipio").options[x] = new Option(texto[x].substr(texto[x].indexOf("@")+1, texto[x].length),texto[x]);

			//document.getElementById("icone").style.display = "none";
			document.getElementById("text_car").style.display = "none";
        }
    }
    xmlhttp.send(null)
}

function carrega_dir(uf)
{
	
	//document.getElementById("icone").style.display = "block";
	document.getElementById("text_car_dir").style.display = "block";
	

    //Abre a url
    xmlhttp.open("GET", "/idiomas/_includes/inc_busca_cidades.asp?uf="+uf,true);


    //Executada quando o navegador obtiver o código
    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4)
		{
            //Lę o texto
            var texto=xmlhttp.responseText;

            //Desfaz o urlencode
			texto = texto.split("/");
			
			document.getElementById("municipio_dir").options.length = 0;

			for(x=0;x<texto.length;x++)

				document.getElementById("municipio_dir").options[x] = new Option(texto[x].substr(texto[x].indexOf("@")+1, texto[x].length),texto[x]);

			//document.getElementById("icone").style.display = "none";
			document.getElementById("text_car_dir").style.display = "none";
        }
    }
    xmlhttp.send(null)
}


function faltaPreencher(obj, msg)
{
	alert(msg);
	obj.focus();
	return false;
}

function submete()
{
	document.frmPortal.action='/idiomas/ingles/advanced_search_res.asp';
	document.frmPortal.submit();
}

function carregaMunicipio()
{
	document.frmPortal.submit();
}

function Pesquisa()
{
	if(document.getElementById("uf").value == 0)
	{
		alert("Preenchimento do campo UF é obrigatório");
		document.getElementById("uf").focus();
		return;
	}
	
	if(document.getElementById("no_municipio").value == 0)
	{
		alert("Preenchimento do campo Cidade é obrigatório");
		document.getElementById("no_municipio").focus();
		return;
	}
	document.getElementById("frmPortal").submit();
}

function enter(event){
 
	Tecla = event.which;
	if (Tecla == null)
	   Tecla = event.keyCode;
	if (Tecla == 13)
	   Pesquisa();
	return false;
}