﻿function getTopTenOffers(language,country){

//alert(language+country);
    var content = "";
    var thisRequest = iets();
    if (thisRequest != null) {
        var url = "/xmlMod/module_1716/xml/"+language.toLowerCase()+"/offers.xml"
        thisRequest.open("GET", url, true);
        thisRequest.send(null);
        thisRequest.onreadystatechange = function() {
            if (thisRequest.readyState == 4) {
                thisRequestXML = thisRequest.responseXML;
              //alert(thisRequest.responseText);
                var getInfoFrom = thisRequestXML.getElementsByTagName('offers');
                // document.getElementById('top10head').innerHTML = getTagContent(getInfoFrom[0],'title');
                if(language.toLowerCase()=='nl' || language.toLowerCase()=='vl') document.getElementById('top10head').innerHTML ="Top 5 autohuur bestemmingen";
                else document.getElementById('top10head').innerHTML ="Location Voiture : Top 5";
                
                var theseOffers = thisRequestXML.getElementsByTagName(country.toUpperCase());  
                if (theseOffers.length==0)theseOffers = thisRequestXML.getElementsByTagName('WW');
                var theseOffers = theseOffers[0].getElementsByTagName('offer');
                for (var i = 0; i < theseOffers.length; i++) {
                    var location = getTagContent(theseOffers[i],'location');

                  
                  
                  
                  
                  
                //  content+="<div onclick='window.open(\""+getTagContent(theseOffers[i],'link')+"\",\"_self\")' style='cursor:pointer;padding:10px 10px 10px 30px;border-bottom:1px dotted #CCCCCC;background:transparent url(\"xmlMod/module_2122/library/media/icon_Auto_sm.gif\") no-repeat 3px 10px'>";
                    content+="<div onclick='window.open(\""+getTagContent(theseOffers[i],'link')+"\",\"_self\")' style='cursor:pointer;padding:10px 10px 10px 30px;border-bottom:1px dotted #CCCCCC;'>";
                  
                  content +="<div style='font-weight:bold;'>"+getTagContent(theseOffers[i],'location')+"</div>";
                   content +="<div style='font-weight:bold;text-align:right;color:#F45000'>"+vanaf+currencyChar+" "+(getTagContent(theseOffers[i],'amount')*currencyRate).toFixed(2)+" "+getTagContent(theseOffers[i],'description')+"</div>";
                  content+="<div style='clear:both'> </div></div>";
                  
 
                  
                }
                //alert(newsmenu);
              content += "<div style='clear:both;font-style:italic;padding-top:5px;padding:10px'>" + getTagContent(getInfoFrom[0], 'description').replace(/all-inclusive/i, "all inclusive").replace(/basé/i, "basée") + "</div>";
                document.getElementById('top10').innerHTML = content;     
             
            }
        }
        
    
    }
}





















function getTagContent(a,b){

   var thisname = a.getElementsByTagName(b);
   if (thisname[0]) thisname = thisname[0].childNodes[0].nodeValue;
   else thisname="";
   return thisname;
}

function iets(){
  try {
        thisRequest = new XMLHttpRequest()
    }
    catch (tryMS) {
        try {
            thisRequest = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (otherMS) {
            try {
                thisRequest = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (failed) {
                thisRequest = null;
            }
        }
    }
return thisRequest;

}


