
//sarissa
var xmlhttp = new XMLHttpRequest();
function GetTop10(number, rate, curr)
{
 var firstcontent = document.getElementById("firstcontent").innerHTML;
 var bottomcontent = document.getElementById("destination_info").innerHTML;
	// bepaal de locatie van het xml bestand
	//var Language = document.getElementById("languagecode").value;

	if (document.getElementById("accountId")) var account = document.getElementById("accountId").value;
	else var account = '10686';

	if (account == '10686' || account == '10680' || account == '13348') var filePath = "xmlmod/exports/populairdestinations_account"+account+".xml";
    else var filePath = "xmlmod/exports/populairdestinations_account10686.xml";

    xmlhttp.open("GET", filePath, true);

	xmlhttp.onreadystatechange = function()
    	{
        	if(xmlhttp.readyState == 4)
        	{
           		try
           		{
               			// lees het hele xml bestand uit
               			var xTest = (new DOMParser()).parseFromString(xmlhttp.responseText, "text/xml");
                
				// Get all location nodes
				var locations = xTest.selectNodes("//Location");
				
				var Content = "";
				if (!number) number = "8";
				var test="true";
				var numberSoFar = 1;
				var i=0;
				while ( test == 'true') 
				{
					// Get each Location Data
					var LocationInList = locations[i];
					if(LocationInList)
					{
						var ID = "";
						ID = LocationInList.selectSingleNode("ID/text()");
						ID = new XMLSerializer().serializeToString(ID);
						//alert(ID);
						var Name = "";
						Name = LocationInList.selectSingleNode("Name/text()");
						Name = new XMLSerializer().serializeToString(Name);
						// if (Name.length > 15 )alert (Name);
						/*
						var tot = "";
						tot = Name.indexOf(" ");
						var next = "";
						next = Name.indexOf(" ");
						if (next=="-1")
						{
						Name = Name.substring(0,tot);
						}
						else
						{
						    nextnew = Name.indexOf(" ");
						    if (nextnew=="-1")
						    {
						    Name = Name.substring(0,next);
						    }
						    else
						    {
						    Name = Name.substring(0,nextnew);
						    }
						}
						*/
						if (Name.indexOf(",")!=-1) Name = Name.substring(0,Name.indexOf(','));
						if (Name.indexOf("(")!=-1) Name = Name.substring(0,Name.indexOf('('));
						if (Name.indexOf("airport")!=-1) Name = Name.substring(0,Name.indexOf('airport'));
						if (Name.length < 12 )
						{
						var Price = "";
						Price = LocationInList.selectSingleNode("MinPrice/text()");
						Price = new XMLSerializer().serializeToString(Price);
						Price = Price / 7;
						Price = Price * rate;
						Price = Price.toFixed(0);
						Content += "";
						if (numberSoFar == 1) Content += "<li class='li_top'>";
						if (numberSoFar == 2 || numberSoFar == 4 || numberSoFar == 6 || numberSoFar == 8 ) Content += "<li class='li_2'>";
						if (numberSoFar == 3 || numberSoFar == 5 || numberSoFar == 7 ) Content += "<li class='li_1'>";
						Content += "<span class='name'><a href='select_car.aspx?locationid=" + ID + "'>" + (numberSoFar)+". " + Name+"</a></span><a href='select_car.aspx?locationid=" + ID + "' ><b class='nb'>" + curr + " " + Price + "</b></a></li>";
						numberSoFar = numberSoFar + 1;
						}
						
					}
					else
					{
				
					}
					if (numberSoFar > 8 || i > 19) test = 'false';
					i+=1; 
				}
				var towrite = "<li style='font-size:13px; font-weight:bold; font-family:Arial, Helvetica, sans-serif; height:30px; width:100%; padding-top:5px; padding-left:5px; '>"+ firstcontent +"</li>"; 
				towrite += Content;
				towrite += "<div id='destination_info'>"+ bottomcontent +"</div>";
				document.getElementById("top8").innerHTML = towrite;
	            		             
	    		}
			catch(er)
           		{
            		
            		}
            
        	}
    	}
    	xmlhttp.send('');
}
