﻿// JScript File


var XmlHttp;
var AjaxServerPageName;

var leadDays =3; //This is to adjust the lead days
var topCountry=new Array("1","4","3","5","13","7","12","37");
var isTopLocationIncluded;
var selCountryID;

AjaxServerPageName = "Locations.aspx";
//Creating and setting the instance of appropriate XMLHTTP Request object to a “XmlHttp” variable  
function CreateXmlHttp()
{
	//Creating object of XMLHTTP in IE
	try
	{
		XmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch(oc)
		{
			XmlHttp = null;
		}
	}
	//Creating object of XMLHTTP in Mozilla and Safari 
	if(!XmlHttp && typeof XMLHttpRequest != "undefined") 
	{
		XmlHttp = new XMLHttpRequest();
	}
}
//Check For US Resident
function USResident()
    {
        var value=document.getElementById("selCountryList").value;
         var fromLocationList = document.getElementById("selFromLocations");
         var toLocationList = document.getElementById("selToLocations");
         var optionItem;
        if (value==13)
            {
             if(confirm('Are you a US or Canadian driving license holder? If NO please click "OK". If YES click "Cancel".')==false) 
                {
                 alert("We are sorry, the facility to book for US Resident will be available soon.");
                    document.getElementById("selCountryList").selectedIndex=0;
                    fromLocationList.options.length=0;
                    toLocationList.options.length=0;
                     
                    fromLocationList.innerHTML="";
                    toLocationList.innerHTML="";
                    
                    optionItem = new Option( "---- SELECT LOCATION ----", "0",  false, false);
					fromLocationList.options[fromLocationList.length] = optionItem;
	
					optionItem = new Option( "---- SAME AS ABOVE ----", "0",  false, false);
					toLocationList.options[toLocationList.length] = optionItem;
                    return false;
                 } 
                 else
                 {
                    return true; 
                 }
            }
           return true; 
    }
//Gets called when country combo box selection changes
function CountryListOnChange() 
{
	var countryList = document.getElementById("selCountryList");
	var hidcountryName = document.getElementById("hidCtryName");
	if(!USResident())
	{
	    return false;
	}

 var fromLocationList = document.getElementById("selFromLocations");

 if(fromLocationList.selectedIndex==-1)
    location.href("Index.html");
	if(countryList.selectedIndex==0) 
	{
	   return false;
    }
	else
	hidcountryName.value=countryList.options[countryList.selectedIndex].text;
	
	var selectedCountry = countryList.options[countryList.selectedIndex].value;
	selCountryID=selectedCountry;
	topCountry.sort(sortNumber);
	isTopLocationIncluded=false;
	checkForTopLocation(selectedCountry);
	var requestUrl = AjaxServerPageName + "?SelectedCountry=" + encodeURIComponent(selectedCountry)+"&isTopLocation="+encodeURIComponent(isTopLocationIncluded);
	
	CreateXmlHttp();
	
	// If browser supports XMLHTTPRequest object
	if(XmlHttp)
	{
		//Setting the event handler for the response
		XmlHttp.onreadystatechange = HandleResponse;
		
		//Initializes the request object with GET (METHOD of posting), 
		//Request URL and sets the request as asynchronous.
		XmlHttp.open("GET", requestUrl,  true);
		
		//Sends the request to server
		XmlHttp.send(null);		
	}
}


//Called when response comes back from server
function HandleResponse()
{
	// To make sure receiving response data from server is completed
	if(XmlHttp.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		var fromLocationList = document.getElementById("selFromLocations");
	    fromLocationList.disabled=false;
	    var toLocationList = document.getElementById("selToLocations");
	    toLocationList.disabled=false;
		if(XmlHttp.status == 200)
		{
			ClearAndSetStateListItems(XmlHttp.responseXML.documentElement);
		}
		else
		{
			alert("There was a problem retrieving data from the server." );
		}
	}
	else
	{	
	 var fromLocationList = document.getElementById("selFromLocations");
	 fromLocationList.options.length=0;
	 optionItem = new Option( "Please wait....", "0",  false, false);
	 fromLocationList.options[fromLocationList.length] = optionItem;
	 fromLocationList.disabled=true;
	 var toLocationList = document.getElementById("selToLocations");
	 toLocationList.options.length=0;
	 optionItem = new Option( "Please wait....", "0",  false, false);
	 toLocationList.options[toLocationList.length] = optionItem;
	 toLocationList.disabled=true;
	}
}

//Clears the contents of state combo box and adds the states of currently selected country
function ClearAndSetStateListItems(countryNode)
{
   
    var fromLocationList = document.getElementById("selFromLocations");
    var toLocationList = document.getElementById("selToLocations");
    var padd="    ";
    fromLocationList.innerHTML="";
    toLocationList.innerHTML="";
    fromLocationList.options.length=0;
    toLocationList.options.length=0;
    
    
	var stateNodes = countryNode.getElementsByTagName('LocationName');
	var stateNodes1 = countryNode.getElementsByTagName('pk_LocationID');
	
	var textValue; 
	var optionItem;
	
	optionItem = new Option( "---- SELECT LOCATION ----", "0",  false, false);
	fromLocationList.options[fromLocationList.length] = optionItem;
	
	optionItem = new Option( "---- SAME AS ABOVE ----", "0",  false, false);
	toLocationList.options[toLocationList.length] = optionItem;
	
	if(isTopLocationIncluded)
	{
	    InsertTopLocations(fromLocationList);
	    InsertTopLocations(toLocationList);
	}
	var hidIdFrom = document.getElementById("hidIdFrom");
	var hidIdTo = document.getElementById("hidIdTo");

    var flagFrom=0;
    var flagTo=0;
    if(isTopLocationIncluded)
    {
        
        var optGroup4 = document.createElement('optgroup');
        optGroup4.label = "Alphabetical List";
        
        var optGroup5 = document.createElement('optgroup');
        optGroup5.label = "Alphabetical List";   
       
       
       
        if (window.ActiveXObject)
        {
            fromLocationList.appendChild(optGroup4); 
            toLocationList.appendChild(optGroup5);
            for (var count = 0; count < stateNodes.length; count++)
	        {
   		        textValue = GetInnerText(stateNodes[count]);
            
   		        if(flagFrom==1){
   		        optionItem = new Option(padd+textValue, GetInnerText(stateNodes1[count]),  true, true);
   		        flagFrom=0;
   		        }
   		        else
		        optionItem = new Option(padd+textValue, GetInnerText(stateNodes1[count]),  false, false);
		         if(GetInnerText(stateNodes1[count])==hidIdFrom.value)
                    flagFrom=1;
                    fromLocationList.options[fromLocationList.length] = optionItem;
                    
                    if(flagTo==1){
   		        optionItem = new Option(padd+textValue, GetInnerText(stateNodes1[count]),  true, true);
   		        flagTo=0;
   		        }
   		        else
		        optionItem = new Option(padd+textValue, GetInnerText(stateNodes1[count]),  false, false);
		         if(GetInnerText(stateNodes1[count])==hidIdTo.value)
                    flagTo=1;
		        toLocationList.options[toLocationList.length] = optionItem;
	        }
        }
        else
        {
            for (var count = 0; count < stateNodes.length; count++)
	        {
   		        textValue = GetInnerText(stateNodes[count]);
            
   		        if(flagFrom==1){
   		        optionItem = new Option(padd+textValue, GetInnerText(stateNodes1[count]),  true, true);
   		        flagFrom=0;
   		        }
   		        else
		        optionItem = new Option(padd+textValue, GetInnerText(stateNodes1[count]),  false, false);
		         if(GetInnerText(stateNodes1[count])==hidIdFrom.value)
                    flagFrom=1;
                    //fromLocationList.options[fromLocationList.length] = optionItem;
                    optGroup4.appendChild(optionItem);
                    if(flagTo==1){
   		        optionItem = new Option(padd+textValue, GetInnerText(stateNodes1[count]),  true, true);
   		        flagTo=0;
   		        }
   		        else
		        optionItem = new Option(padd+textValue, GetInnerText(stateNodes1[count]),  false, false);
		         if(GetInnerText(stateNodes1[count])==hidIdTo.value)
                    flagTo=1;
		        //toLocationList.options[toLocationList.length] = optionItem;
		        optGroup5.appendChild(optionItem);
	        }
	        fromLocationList.appendChild(optGroup4); 
            toLocationList.appendChild(optGroup5);
        }
    }
    else
    {
        for (var count = 0; count < stateNodes.length; count++)
	    {
   		    textValue = GetInnerText(stateNodes[count]);
        
   		    if(flagFrom==1){
   		    optionItem = new Option(textValue, GetInnerText(stateNodes1[count]),  true, true);
   		    flagFrom=0;
   		    }
   		    else
		    optionItem = new Option(textValue, GetInnerText(stateNodes1[count]),  false, false);
		     if(GetInnerText(stateNodes1[count])==hidIdFrom.value)
                flagFrom=1;
                fromLocationList.options[fromLocationList.length] = optionItem;
                
                if(flagTo==1){
   		    optionItem = new Option(textValue, GetInnerText(stateNodes1[count]),  true, true);
   		    flagTo=0;
   		    }
   		    else
		    optionItem = new Option(textValue, GetInnerText(stateNodes1[count]),  false, false);
		     if(GetInnerText(stateNodes1[count])==hidIdTo.value)
                flagTo=1;
		    toLocationList.options[toLocationList.length] = optionItem;
	    }
    }
	
	   fromLocationList.focus();
  
}

//Added By WSPL 20071218
//*********This is code for getting LeadDays from Server
//This Function get the Lead Days using AJAX
function GetLeadDays()
{
    try
    {
 	    var requestUrl = AjaxServerPageName + "?GetLeadDays=true";
	    CreateXmlHttp();
	    // If browser supports XMLHTTPRequest object
	    if(XmlHttp)
	    {
		    //Setting the event handler for the response
		    XmlHttp.onreadystatechange = GetResponse;
		    //Initializes the request object with GET (METHOD of posting), 
		    //Request URL and sets the request as asynchronous.
		    XmlHttp.open("GET", requestUrl,  true);
		    //Sends the request to server
		    XmlHttp.send(null);		
	    }
	}
	catch(err)
	{
	}
	setDates();
}

function GetResponse()
{
	// To make sure receiving response data from server is completed
	if(XmlHttp.readyState == 4)
	{
		if(XmlHttp.status == 200)
		{			
			leadDays=XmlHttp.responseText;
			alert(leadDays);
		}
	}
}
//*********End of Lead Days from Server*****************


//Returns the node text value 
function GetInnerText (node)
{
	 return (node.textContent || node.innerText || node.text) ;
}

function fillFrom()
{
    var fromLocationList = document.getElementById("selFromLocations");
    var hidIdFrom = document.getElementById("hidIdFrom");
    var hidNameFrom = document.getElementById("hidNameFrom");
	hidIdFrom.value=fromLocationList.options[fromLocationList.selectedIndex].value;
	hidNameFrom.value=fromLocationList.options[fromLocationList.selectedIndex].text;
}

function fillTo()
{
    var toLocationList = document.getElementById("selToLocations");
    var hidIdTo = document.getElementById("hidIdTo");
    var hidNameTo = document.getElementById("hidNameTo");
	hidIdTo.value=toLocationList.options[toLocationList.selectedIndex].value;
	hidNameTo.value=toLocationList.options[toLocationList.selectedIndex].text;
}

function fillCarTypeName()
{
    //	var selCarType = document.getElementById("selCarType");
    //    var hidCarTypeName = document.getElementById("hidCarTypeName");
    //    hidCarTypeName.value=selCarType.options[selCarType.selectedIndex].text;
}

function fillCurrencyName()
{
    //	var selCurrency = document.getElementById("selCurrency");
    //    var hidCurrecyName = document.getElementById("hidCarTypeName");
    //    hidCurrecyName.value=selCurrency.options[selCurrency.selectedIndex].text;
}


    var Today=new Date();
    Today.setDate(Today.getDate()-1);   //this is set Today date less than one 
    var cal15 = new CalendarPopup('divCalender1');
    var Date1=formatDate(Today,"MM/dd/yyyy");
    cal15.addDisabledDates(null, Date1);
    cal15.setCssPrefix("TEST");
    cal15.setReturnFunction("setMultipleValues4");
    
function setMultipleValues4(y,m,d) 
{
    var selDay=document.getElementById("selFromDay");
    var selMon=document.getElementById("selFromMonth");
    var selYear=document.getElementById("selFromYear");
     selYear.value=y;
     selMon.selectedIndex=m-1;
     for (var i=0; i<selDay.options.length; i++)
     {
          if (selDay.options[i].value==d) 
          {
               selDay.selectedIndex=i;
          }
     }  
     validateFromDate();  	
}

    var cal16 = new CalendarPopup('divCalender2');
    cal16.addDisabledDates(null, Date1);
    cal16.setReturnFunction("setMultipleValues5");
    cal16.setCssPrefix("TEST");

function setMultipleValues5(y,m,d) {
var selToDay=document.getElementById("selToDay");
var selToMon=document.getElementById("selToMonth");
var selToYear=document.getElementById("selToYear");
selToYear.value=y;
selToMon.selectedIndex=m-1;
for (var i=0; i<selToDay.options.length; i++)
 {
      if (selToDay.options[i].value==d) 
      {
           selToDay.selectedIndex=i;
      }
 }
      validateToDate(); 
}
function setDates()
{
    //var leadDays =4; //This is to adjust the lead days
    var Today=new Date();
    Today.setDate(Today.getDate()+leadDays); 
    document.getElementById("selFromYear").value=Today.getYear();
    var month=Today.getMonth()+1;
    document.getElementById("selFromMonth").value=month;
    document.getElementById("selFromDay").value=Today.getDate(); 
    Today.setDate(Today.getDate()+7);
    document.getElementById("selToYear").value=Today.getYear();
    var month=Today.getMonth()+1;
    document.getElementById("selToMonth").value=month;
    document.getElementById("selToDay").value=Today.getDate(); 
    var countryList = document.getElementById("selCountryList");
    countryList.selectedIndex=0;
}

function getDayOfWeek()
{
	var intDay = this.getDay();
	var aryDays = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
	return aryDays[intDay];
}

function getWeekDay(DayVal)
{
	var intDay = DayVal;
	var aryDays = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
	return aryDays[intDay];
}

function getFullMonth()
{
	var intMonth = this.getMonth();
	var aryMonths = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
	return aryMonths[intMonth];
}

function getMilitaryFormat()
{
	var sReturn;
	var intYear = this.getFullYear();
	var intMonth = this.getMonth() + 1;
	var intDate = this.getDate();
	sReturn = intYear.toString() + '/';
	if (intMonth.toString().length==1) sReturn += '0';
	sReturn += intMonth.toString() + '/';
	if (intDate.toString().length==1) sReturn += '0';
	sReturn += intDate.toString();
	return sReturn;
}

function validateFromDate()
{
	var iDay = parseInt(document.getElementById("selFromDay").value, 10);
	var iMonth = parseInt(document.getElementById("selFromMonth").value, 10) - 1;  // Month is zero based
	var iYear = parseInt(document.getElementById("selFromYear").value, 10);
	var dCollection = new Date(iYear,iMonth,iDay);
	if (dCollection.getMonth() != iMonth)
	{
	    alert("Date invalid, please select a different date");
		document.getElementById("selFromDay").selectedIndex = 0;  // Set to first entry (day=1)
		document.getElementById("selFromMonth").selectedIndex = dCollection.getMonth();  // Set to new month
	}
	//var intDay = dCollection.getDay(); 
	//document.forms[0].FromDay.value = getWeekDay(intDay);
	return dCollection;
}

function validateToDate()
{
	var iDay = parseInt(document.getElementById("selToDay").value, 10);
	var iMonth = parseInt(document.getElementById("selToMonth").value, 10) - 1;  // Month is zero based
	var iYear = parseInt(document.getElementById("selToYear").value, 10);
	// If date has rolled over onto following month (i.e. 31-Apr was entered, correct date...
	var dReturn = new Date(iYear,iMonth,iDay);
	if (dReturn.getMonth() != iMonth)
	{
		alert("Date invalid, please select a different date");
		document.getElementById("selToDay").selectedIndex = 0; // Set to first entry (day=1)
		document.getElementById("selToMonth").selectedIndex = dReturn.getMonth();  // Set to new month
	   }
	//var intDay = dReturn.getDay(); 
	//document.forms[0].ToDay.value = getWeekDay(intDay);
	return dReturn;
}

function validateDate()
{
 	var dCollection = validateFromDate();
	var dReturn = validateToDate();
	if(dCollection.getTime() != dReturn.getTime())
	{
   		iTimeDiff = (document.getElementById("selToTime").selectedIndex - document.getElementById("selFromTime").selectedIndex);
   		if(iTimeDiff >= 1 )
   		{  
   			alert("When a vehicle is returned later than the collection time an addional days rental applies");
   		}
   }
}

function ValidateUserInput()
{

    var selCurrency = document.getElementById("selCurrency");
    var hidCurrecyName = document.getElementById("hidCurrecyName");
    hidCurrecyName.value=selCurrency.options[selCurrency.selectedIndex].text;
    
    var selCarType = document.getElementById("selCarType");
    var hidCarTypeName = document.getElementById("hidCarTypeName");
    hidCarTypeName.value=selCarType.options[selCarType.selectedIndex].text;
    
	var _txtBoxId = document.getElementById("txtDriverAge");
	var _ddlCountryList = document.getElementById("selCountryList") ;
	var _ddlFromLocation = document.getElementById("selFromLocations");
	var _ddlToLocation = document.getElementById("selToLocations") ;
	var _ddlCurrency = document.getElementById("selCurrency"); 
    var age = _txtBoxId.value;
	if(_ddlCountryList.selectedIndex == 0)
	{
		alert("Please select Country");
		_ddlCountryList.focus();
		return false;
	}
	if(_ddlFromLocation.selectedIndex == 0)
	{
		alert("Please select collection location");
		_ddlFromLocation.focus();
		return false;
	}
	if (document.getElementById("selCarType") != null)
	{
		if (document.getElementById("selCarType").selectedIndex == 0 )
		{
			alert("Please select car type.");
			document.getElementById("selCarType").focus();
			return false;
		}
	}
	 if ( age == "")
	{
		alert("Please Enter Driver Age"); 
		_txtBoxId.focus();
		return false;
	}
	if(isNaN(parseInt(age)))
	{
		alert("Driver age can only be in numeric value! ");
		_txtBoxId.focus();
		return false;
	}
	 if (age > 75 || age < 21)
	{
		alert("If aged under 21 or over 75, please contact our call centre. Please check the suppliers terms for age restrictions."); 
		_txtBoxId.focus();
		return false;
	}
	dtFromDate = new Date(document.getElementById("selFromYear").value, document.getElementById("selFromMonth").selectedIndex, document.getElementById("selFromDay").value);
	dtToDate = new Date(document.getElementById("selToYear").value, document.getElementById("selToMonth").selectedIndex, document.getElementById("selToDay").value);
	dtFromDate.setHours(document.getElementById("selFromTime").value.substring(0,2));
	dtToDate.setHours(document.getElementById("selToTime").value.substring(0,2));
	if( dtToDate <= dtFromDate )
	{
		alert("Return date/time must be 'After' collection date/time");
		document.getElementById("selFromDay").focus();
		return false;
	 }
    ///------------- this is to validate the date (collection date should not be less than that of the default one)------------///
	dtFromDate = document.getElementById("selFromDay").value + "/" + document.getElementById("selFromMonth").value + "/" + document.getElementById("selFromYear").value;
	dtToDate =  document.getElementById("selToDay").value + "/" + document.getElementById("selToMonth").value + "/" + document.getElementById("selToYear").value;
	var dNow = new Date();
	dNow.setDate(dNow.getDate()+leadDays);
	var arrDate=dtFromDate.split("/");
	var Month = dNow.getMonth() +1;
	var Day1 = parseInt(arrDate[0]);
	var Month1 = parseInt(arrDate[1]);
	var Year1 = parseInt(arrDate[2]);
	var vday ="";
	if (leadDays == 1)
	{
		vday = "day";
	}
	else
	{
		vday = "days";
	}
	var Message = "Our website can only process a reservation when your travel dates exceeds " + leadDays + " " + vday +
					" from today's date. If a rental vehicle is required prior to this please contact our reservation dept by telephone or email (see contact us)." ;
	if(arrDate[0]< (dNow.getDate()) && arrDate[1]<=Month && arrDate[2]<= dNow.getYear())
	{
		alert(Message);
		document.getElementById("selFromDay").focus();
		return false;
	}
	if(arrDate[0]>= (dNow.getDate()) && arrDate[1]< Month && arrDate[2]<= dNow.getYear())
	{
		alert(Message);
		document.getElementById("selFromDay").focus();
		return false;
	}
	arrDate=dtToDate.split("/");
	Month=dNow.getMonth() +1;
	var Day2 = parseInt(arrDate[0]);
	var Month2 = parseInt(arrDate[1]);
	var Year2 = parseInt(arrDate[2]);
	if(arrDate[0]< dNow.getDate() && arrDate[1]<=Month && arrDate[2]<= dNow.getYear())
	{	
		alert(Message);
		document.getElementById("selToDay").focus();
		return false;
	}
	if(arrDate[0]>= dNow.getDate() && arrDate[1]< Month && arrDate[2]<= dNow.getYear())
	{	
		alert(Message);
		document.getElementById("selToDay").focus();
		return false;
	}
	if (Year1< dNow.getFullYear())
	{
		alert("Collection Date is not valid!!");
		document.getElementById("selFromDay").focus();
		return false;
	}
	///-------------validation end here ---------------------///
	if(_ddlToLocation.selectedIndex == 0)
	{
	    _ddlToLocation.selectedIndex = _ddlFromLocation.selectedIndex;
	     var hidIdFrom = document.getElementById("hidIdFrom");
    var hidNameFrom = document.getElementById("hidNameFrom");
    var hidIdTo = document.getElementById("hidIdTo");
    var hidNameTo = document.getElementById("hidNameTo");
    hidIdTo.value=hidIdFrom.value;
    hidNameTo.value=hidNameFrom.value;
	}
}

function message()
{
	alert("If aged under 21 or over 75, please contact our call centre. Please check the suppliers terms for age restrictions.");
}

function ViewCarGroup()
{
	window.open(carDetailUrl,'cardetail','width=675,height=650,scrollbars=1');
}
  
function sortNumber(a, b)
{
return a - b;
}

function checkForTopLocation(selectedCountry)
{
for(var i=0;i<topCountry.length;i++)
{
    if(topCountry[i].toString()==selectedCountry)
    {
        isTopLocationIncluded=true;
    }
}
//isTopLocationIncluded=false;
}

function InsertTopLocations(LocationList)
{
 var TopLocations;
 if (selCountryID == 1)
    {
     TopLocations = new Array(
                   '8,ALICANTE AIRPORT','9,ALMERIA AIRPORT','1,MALAGA AIRPORT','7,BARCELONA  AIRPORT',
                   '779,GIBRALTAR AIRPORT (SPANISH SIDE)','22,SEVILLE AIRPORT','2,MADRID AIRPORT',
                   '13,MAHON AIRPORT MENORCA','14,MURCIA (SAN JAVIER) AIRPORT','12,PALMA AIRPORT MALLORCA',
                   '16,VALENCIA AIRPORT');
    }
 if (selCountryID == 3)
    {
     TopLocations = new Array(
                   '4,FARO AIRPORT','5,LISBON AIRPORT','6,OPORTO AIRPORT');
    }
 if (selCountryID == 4)
    {
     TopLocations = new Array(
                   '433,BERGAMO AIRPORT','865,BRESCIA AIRPORT','343,CAGLIARI AIRPORT (SARDINIA)',
                   '307,FLORENCE AIRPORT (TUSCANY)','312,MILAN LINATE AIRPORT','313,MILAN MALPENSA AIRPORT',
                   '316,NAPLES AIRPORT','349,PALERMO AIRPORT (SICILY)','6669,PARMA AIRPORT',
                   '327,ROME  CIAMPINO AIRPORT','321,ROME  FIUMICINO AIRPORT');
    }
 if (selCountryID == 5)
    {
     TopLocations = new Array(
                   '502,BORDEAUX AIRPORT','654,PARIS CDG ROISSY AIRPORT','622,GENEVA AIRPORT FRENCH SIDE',
                   '741,LYON ST EXUPERY AIRPORT*','516,CARCASSONE AIRPORT','631,MARSEILLE AIRPORT',
                   '803,NANTES AIRPORT','740,NICE AIRPORT','640,PERPIGNAN AIRPORT','649,TOULOUSE AIRPORT');
    }
 if (selCountryID == 7)
    {
     TopLocations = new Array(
                   '5395,BERLIN-SCHOENEFELD AIRPORT','518,BERLIN-TEGEL AIRPORT','519,BERLIN-TEMPLEHOF AIRPORT',
                   '522,BREMEN AIRPORT','528,DUSSELDORF AIRPORT','530,FRANKFURT INTERNATIONAL AIRPORT',
                   '533,HAMBURG AIRPORT','535,HANOVER INTERNATIONAL AIRPORT','540,MUNICH INTERNATIONAL AIRPORT',
                   '544,STUTTGART AIRPORT');
    }
 if (selCountryID == 12)
    {
     TopLocations = new Array(
                   '567,CALGARY AIRPORT (AL)','569,EDMONTON AIRPORT (AL)','582,HALIFAX AIRPORT (NS)',
                   '7072,MONTREAL PIERRE ELLIOTT TRUDEAU AIRPORT',
                   '574,TORONTO PEARSON INTERNATIONAL  AIRPORT (OT)','565,VANCOUVER AIRPORT (BC)');
    }
 if (selCountryID == 13)
    {
     TopLocations = new Array(
                   '270,DALLAS FORT WORTH AIRPORT (TX)','148,DENVER AIRPORT (CO)','125,LOS ANGELES AIRPORT (CA)',
                   '222,LAS VEGAS AIRPORT (NV)','171,MIAMI AIRPORT (FL)','175,ORLANDO INTL. AIRPORT (FL)',
                   '106,PHOENIX AIRPORT (AZ)','141,SAN FRANCISCO AIRPORT (CA)','294,SANFORD AIRPORT (FL) *',
                   '185,TAMPA AIRPORT (FL)','155,WASHINGTON DC DULLES INT.AIRPORT');
    }
 if (selCountryID == 37)
    {
     TopLocations = new Array(
                   '727,ADELAIDE AIRPORT  (SA)','725,BRISBANE AIRPORT (SQ)','726,CAIRNS AIRPORT ( NQ)',
                   '730,MELBOURNE AIRPORT (VA)','729,SYDNEY AIRPORT (NSW)');
    }
 
 var optGroup = document.createElement('optgroup')
     optGroup.label = "Top Locations";
 
 if (navigator.appName == "Microsoft Internet Explorer")
    {
     LocationList.appendChild(optGroup);
     for (i=0; i<TopLocations.length; i++)
         {
          optionItem = new Option(TopLocations[i].substring((TopLocations[i].indexOf(",") + 1),(TopLocations[i].length)), TopLocations[i].substring(0,(TopLocations[i].indexOf(","))),  false, false);
          LocationList.options[LocationList.length] = optionItem;
         }
    }
 else
    {
     for (i=0; i<TopLocations.length; i++)
         {
          optionItem = new Option(TopLocations[i].substring((TopLocations[i].indexOf(",") + 1),(TopLocations[i].length)), TopLocations[i].substring(0,(TopLocations[i].indexOf(","))),  false, false);
          optGroup.appendChild(optionItem);
         }
     LocationList.appendChild(optGroup);
    }
     
 var optGroup2 = document.createElement('optgroup');
     optGroup2.lable="&nbsp;";
     LocationList.appendChild(optGroup2);
}