// Variable
var URLservidor = "http://" + document.domain + '/data/';
//var URLservidor = 'http://localhost:3999/DAT_2/data/';

var archivoXML = 'rates.xml';

// Creación del ObjectoXMLHttpRequest
try{
   ObjectoXMLHttpRequest = new ActiveXObject("MSXML2.XMLHTTP");
}catch(exception1){
   try{
      ObjectoXMLHttpRequest = new ActiveXObject("Microsoft.XMLHTTP");
   }catch(exception2){
      ObjectoXMLHttpRequest = false;
   }
}
if(!ObjectoXMLHttpRequest && window.XMLHttpRequest){
   ObjectoXMLHttpRequest = new XMLHttpRequest();
}

function BuscarTarifa()
{
   if (ObjectoXMLHttpRequest)
     {
      // Llamada del documento XML
//        document.getElementById("pleasewaitScreen").style.visibility="visible";
        ObjectoXMLHttpRequest.open('GET',URLservidor + archivoXML, true);
     }
     ObjectoXMLHttpRequest.onreadystatechange = function() {
         if (ObjectoXMLHttpRequest.readyState == 4 && ObjectoXMLHttpRequest.status == 200) {
             var documentoXML = ObjectoXMLHttpRequest.responseXML;
             options = documentoXML.getElementsByTagName('rate');
             for (i = 0; i < options.length; i++) {
                 if ((document.getElementById("hdffrom").value == options[i].attributes.getNamedItem('origenid').nodeValue) && (document.getElementById("hdfto").value == options[i].attributes.getNamedItem('destinoid').nodeValue)) {
                     CalcularTarifa(options[i].attributes.getNamedItem('tarifa').nodeValue, options[i].attributes.getNamedItem('tarifaextra').nodeValue, options[i].attributes.getNamedItem('tarifacompartido').nodeValue, options[i].attributes.getNamedItem('tarifaextracomp').nodeValue, options[i].attributes.getNamedItem('cargo').nodeValue, options[i].attributes.getNamedItem('tarifagb').nodeValue, options[i].attributes.getNamedItem('tarifaextragb').nodeValue, options[i].attributes.getNamedItem('tiemviaje').nodeValue);
                     //                     CalcularTarifa(options[i].attributes.getNamedItem('tarifa').nodeValue, options[i].attributes.getNamedItem('tarifaextra').nodeValue, options[i].attributes.getNamedItem('cargo').nodeValue, options[i].attributes.getNamedItem('tarifagb').nodeValue, options[i].attributes.getNamedItem('tarifaextragb').nodeValue, options[i].attributes.getNamedItem('tiemviaje').nodeValue)
//                     document.getElementById("pleasewaitScreen").style.visibility = "hidden";
                     break;
                 }
             }
             if (i == 0) {
                 BuscarTarifa();
             }
             if (i == options.length) {
                 document.getElementById("spanBloque15").innerHTML = "Rate not found!";
                 document.getElementById("spanBloque15").style.display = "block";
                 document.getElementById("btnQuote").disabled = "";
//                 document.getElementById("pleasewaitScreen").style.visibility = "hidden";
                 document.getElementById("tblPasajeroDetalle1").style.display = "none";
                 document.getElementById("tblPasajeroDetalle2").style.display = "none";
                 document.getElementById("tblSubmit").style.display = "none";
             }
         }
     }
   ObjectoXMLHttpRequest.send(null);
   return false;
}

