function populateCitySelect( country ) {
  countryArrayName = country.replace(/ /g,'');
  if ( countryArrayName.length == 0 ) 
  {
    document.theForm.FABChoice.length = 1;
    document.theForm.FABChoice.options[0] = new Option('Choose a city');
    document.theForm.FABChoice.options[0].value = '';
    return;
  }
  
  if ( country == 'Holland' ) 
  {
    country = 'Netherlands';
    countryArrayName = country;
  }
  if ( country == 'Britain' ) 
  {
    country = 'UK';
    countryArrayName = country;
  }
  newOptions = eval(countryArrayName+'Array');
  document.theForm.FABChoice.length = 1;
  document.theForm.FABChoice.options[0] = new Option('Choose a city');
  document.theForm.FABChoice.options[0].value = '';
  document.theForm.FABChoice.options[0].selected = true;
  var citylength = newOptions.length + 1;
  for ( i=0; i<newOptions.length; i++ ) {
    document.theForm.FABChoice.length++;
    thisEntry = newOptions[i];
    newOption = new Option( thisEntry );
    // MK - changed the last variable to newcountry so the FABChoice value 
    // will be correct when submitted to the search engine.  It was broken
    // for the special cases of Holland and Britain handled above.
    newOption.value =  thisEntry + ';' + country;
    document.theForm.FABChoice.options[i+1] = newOption;
  }
  document.theForm.FABChoice.length = citylength;
  if(newOptions.length == 1) document.theForm.FABChoice.options[1].selected = true;
}

function makeValidDate() 
{   
    document.theForm.datePicked.value = "true";
    year = document.theForm.selYear.options[ document.theForm.selYear.selectedIndex ].value;
    month = document.theForm.selMonth.options[ document.theForm.selMonth.selectedIndex ].value;
    day = document.theForm.selDay.options[ document.theForm.selDay.selectedIndex ].value;

    maxDay = 31;
    if ( month == 4 || month == 6 || month == 9 || month == 11 ) 
    {
        maxDay = 30;
    } 
    else if ( month == 2 ) 
    {
        if ( year%100 != 0 && year%4 == 0 ) 
        {
            maxDay = 29;
        } 
        else  
        {
            maxDay = 28;
        }
    }
    //alert("func:" + ( Math.min(day, maxDay) - 1));
    document.theForm.selDay.selectedIndex = ( Math.min(day, maxDay) - 1);
}

function validateDate(frm){

    if(frm.FABCountryChoice.value=='' || frm.FABChoice.value==''){
        alert('Please select a destination');
        return false;
    }

    var DateStart = frm.selYear.value + '-' + frm.selMonth.value + '-' + frm.selDay.value;

    var nowDate=new Date();
    if(Date.UTC(frm.selYear.value,frm.selMonth.value-1,frm.selDay.value) < Date.UTC(nowDate.getUTCFullYear(),nowDate.getUTCMonth(),nowDate.getUTCDate())){
        alert('The date you\'ve chosen is in the past');
        return false;
    }

    return true;
}

/*MK - I made some changes here to make it work in both prepopulation cases.*/
function onInit()
{

	if (typeof(Country) != 'undefined')
	{
	    if (!document.theForm.FABCountryChoice.value && Country)
	    {
		document.theForm.FABCountryChoice.value = Country ;
	    }
	    populateCitySelect(document.theForm.FABCountryChoice.value);
	    if (document.theForm.tmpChoice.value)
		{
		    document.theForm.FABChoice.value = document.theForm.tmpChoice.value;
		}
	    else if (City)
		{
		    country = document.theForm.FABCountryChoice.value;
		    //strippedCountry = country.replace(/ /g,'');
		    strippedCountry = country;
			CChoice = City + ';' + strippedCountry;
			//alert(CChoice);
			document.theForm.FABChoice.value = CChoice;
		}
	}
	
	
	if (document.theForm.datePicked.value == "false")
    {
	    Today = new Date();
        ThreeDays = new Date();
        ThreeDays.setTime(Today.getTime() + (60*60*24*3*1000));
        Day = ThreeDays.getDate();
        if(Day > 0) Day = Day - 1;
        Month = ThreeDays.getMonth();
        Year = ThreeDays.getYear();
        document.theForm.selDay.options[Day].selected = true;
        document.theForm.selMonth.options[Month].selected = true;
        x = document.theForm.selYear.length;
        for(i=0;i<x;i++) 
        {
            if(document.theForm.selYear.options[i].value == Year) 
            {
                document.theForm.selYear.options[i].selected = true;
            }
        }
    }// end if
}