// AJAX do Google Maps


function GetXMLHttp() {
        var xmlHttp;
        try {
                xmlHttp = new XMLHttpRequest();
        }
        catch(ee) {
                try {
                        xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
                }
                catch(e) {
                        try {
                                xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
                        }
                        catch(e) {
                                xmlHttp = false;
                        }
                }
        }
        return xmlHttp;
}

var xmlRequest = GetXMLHttp();
var div;

function abrirPag(valor,n_div){
        var url = valor;
		div = n_div;
        xmlRequest.onreadystatechange = mudancaEstado;
        xmlRequest.open("GET",url,true);
        xmlRequest.send(null);

                if (xmlRequest.readyState == 1) {
                        document.getElementById(div).innerHTML = "<img src='../../public/imgs/loader.gif'>";
                }

        return url;
}

function mudancaEstado(){
        if (xmlRequest.readyState == 4){
                document.getElementById(div).innerHTML = xmlRequest.responseText;
        }
}

var num,cont=0,cidade_destino,cidade_origem,i;

function abrirMapa(num,cidade_origem)
	{
		
		cidade_destino = document.getElementById("input_mapa"+num).value;
		
		abrirPag('google-maps.php?CIDADEDESTINO='+cidade_destino+'&CIDADEORIGEM='+cidade_origem,'mapateste');
		
						
	}
