try{
    xmlhttp = new XMLHttpRequest();
}catch(ee){
    try{
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    }catch(e){
        try{
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }catch(E){
            xmlhttp = false;
        }
    }
}
//aqui começa o ajax dos modelos
function doBuscaModelo(tmarca){

    //limpa o select
    var c=document.getElementById("modelo")
    while(c.options.length>0)c.options[0]=null
    c.options[0]=new Option("Carregando Dados ...","Carregando Dados ...")

    //Monta a url com a marca
    xmlhttp.open("GET", "html/buscamodelos.php?marca="+tmarca,true);

    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4){
            //limpa o select
            var c=document.getElementById("modelo")
            while(c.options.length>0)c.options[0]=null
            //Transforma a lista de modelos JSON em Javascript
            var aModelos=eval((xmlhttp.responseText))
            //popula o select com a lista de modelos obtida
            for(var i=0;i<aModelos.length;i++){
                aModelos[i]=unescape(aModelos[i])
				var id = aModelos[i];
				i++;
				var label = aModelos[i];
                c.options[c.options.length]=new Option(label,id)
            }
        }
    }
    xmlhttp.send(null)
}
//aqui começa o ajax dos modelos
function doBuscaVersao(tmodelo){

    //limpa o select
    var c=document.getElementById("versao")
    while(c.options.length>0)c.options[0]=null
    c.options[0]=new Option("Carregando Dados ...","Carregando Dados ...")

    //Monta a url com a marca
    xmlhttp.open("GET", "html/buscaversoes.php?modelo="+tmodelo,true);

    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4){
            //limpa o select
            var c=document.getElementById("versao")
            while(c.options.length>0)c.options[0]=null
            //Transforma a lista de modelos JSON em Javascript
            var aVersao=eval((xmlhttp.responseText))
            //popula o select com a lista de modelos obtida
            for(var i=0;i<aVersao.length;i++){
                aVersao[i]=unescape(aVersao[i])
				var id = aVersao[i];
				i++;
				var label = aVersao[i];
                c.options[c.options.length]=new Option(label,id)
            }
        }
    }
    xmlhttp.send(null)
}