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 doBusca(tuf){

    //limpa o select
    var c=document.getElementById("cidade")
	var achou=false

    while(c.options.length>0)c.options[0]=null
    c.options[0]=new Option(" -- Aguarde ... -- "," -- Aguarde ... -- ")

    //Monta a url com a uf
    xmlhttp.open("GET", "cidades.asp?uf="+tuf,true);

    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4 && xmlhttp.status == 200){
            //limpa o select
            var c=document.getElementById("cidade")
            while(c.options.length>0)c.options[0]=null
            //Transforma a lista de cidades JSON em Javascript

            var str=xmlhttp.responseText

            var aCidades=eval((str))

            //popula o select com a lista de cidades obtida
            c.options[0]=new Option("Selecione","Selecione")

            for(var i=0;i<aCidades.length;i++){
				achou=true
                aCidades[i]=unescape(aCidades[i])
                c.options[c.options.length]=new Option(aCidades[i],aCidades[i])
				
            }
        }
    }

    xmlhttp.send(null)
	
	if (achou==false) {c.options[0]=new Option("Selecione","Selecione")	}
	
}

function doBuscaAtiv(tarea){

    //limpa o select
    var c=document.getElementById("atividade")
	var achou=false

    while(c.options.length>0)c.options[0]=null
    c.options[0]=new Option(" -- Aguarde ... -- "," -- Aguarde ... -- ")

    //Monta a url com a uf
    xmlhttp.open("GET", "atividades.asp?area="+tarea,true);

    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4 && xmlhttp.status == 200){
            //limpa o select
            var c=document.getElementById("atividade")
            while(c.options.length>0)c.options[0]=null
            //Transforma a lista de cidades JSON em Javascript
            var aAtividades=eval((xmlhttp.responseText))

            //popula o select com a lista de cidades obtida
            c.options[0]=new Option("Selecione","Selecione")

            for(var i=0;i<aAtividades.length;i++){
				achou=true
                aAtividades[i]=unescape(aAtividades[i])
                c.options[c.options.length]=new Option(aAtividades[i],aAtividades[i])
				
            }
        }
    }

    xmlhttp.send(null)
	
	if (achou==false) {c.options[0]=new Option("Selecione","Selecione")	}
	
}

function doBuscaTodasAtivs(tarea){

    //limpa o select
    var c=document.getElementById("atividade")
	var achou=false

    while(c.options.length>0)c.options[0]=null
    c.options[0]=new Option(" -- Aguarde ... -- "," -- Aguarde ... -- ")

    //Monta a url com a uf
    xmlhttp.open("GET", "todasatividades.asp?area="+tarea,true);

    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4 && xmlhttp.status == 200){
            //limpa o select
            var c=document.getElementById("atividade")
            while(c.options.length>0)c.options[0]=null
            //Transforma a lista de cidades JSON em Javascript
            var aAtividades=eval((xmlhttp.responseText))

            //popula o select com a lista de cidades obtida
            c.options[0]=new Option("Selecione","Selecione")

            for(var i=0;i<aAtividades.length;i++){
				achou=true
                aAtividades[i]=unescape(aAtividades[i])
                c.options[c.options.length]=new Option(aAtividades[i],aAtividades[i])
				
            }
        }
    }

    xmlhttp.send(null)
	
	if (achou==false) {c.options[0]=new Option("Selecione","Selecione")	}
	
}


