function ajax(url,funcao)
{
    req = null;
    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest)
    {
        req = new XMLHttpRequest();
        if (funcao != "")
            req.onreadystatechange =  eval(funcao);
        req.open("GET", url, true);
        req.send(null);

    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        isIE = true;
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req)
        {
              if (funcao != "")
                req.onreadystatechange = eval(funcao);
            req.open("GET", url, true);
            req.send();
        }
    }
}

var flag_marca  = 0;
function CarregaCaminho(origem, destino, classe){
    document.getElementById("espera").className = "show";
    document.getElementById("dcaminho").innerHTML = "";

    ajax("remote_simulador.php?origem="+origem+"&destino="+destino+"&classe="+classe, "MostraCaminho");
    if (flag_marca==0){
        flag_marca = 1;
        window.location.href = "#resultado";
    }
}

function MostraCaminho(){
        if (req.readyState == 4){
            if (req.status == 200){
                document.getElementById("espera").className = "hide";
                document.getElementById("dcaminho").innerHTML = req.responseText;
            }
        }

}


