function SetDateOptions(Which, dateValue)
{
  var currentDate = (dateValue == null || dateValue == "") ? new Date() : FormatDate(dateValue);

  var DaysObject = eval("document.selectForm." + Which + "Day");
  var MonthObject = eval("document.selectForm." + Which + "Month");

  var year = currentDate.getYear() % 100;
  var Date1 = (currentDate.getMonth() + 1) + "/" + currentDate.getDate() + "/" + (year<10?"0":"") + year;

  var xx = Date1.split('/');

  MonthObject.selectedIndex = xx[0] - 1;
  DaysObject.selectedIndex = xx[1] - 1;
}

function MakeDepartureDates()
{
    //alert("MakeDepartureDates1");

    var dayInteger1 = document.selectForm.FirstDay.selectedIndex + 1;
    var monthInteger1 = document.selectForm.FirstMonth.selectedIndex + 1;

    //alert("MakeDepartureDates2");

    var dayInteger2 = document.selectForm.SecondDay.selectedIndex + 1;
    var monthInteger2 = document.selectForm.SecondMonth.selectedIndex + 1;

    //alert("MakeDepartureDates3");

    today = new Date();
    var year1 = today.getYear() % 100;
    var year2 = today.getYear() % 100;

    //alert("MakeDepartureDates4");

    if ((monthInteger1 < today.getMonth()+1) || ((monthInteger1 == today.getMonth()+1) && (dayInteger1 < today.getDate())))
    {
        year1++;
    }

    //alert("MakeDepartureDates5");

    if ((monthInteger2 < today.getMonth()+1) || ((monthInteger2 == today.getMonth()+1) && (dayInteger2 < today.getDate())))
    {
        year2++;
    }

    //alert("MakeDepartureDates6");

    document.selectForm.departuredate1.value = (monthInteger1<10?"0":"") + monthInteger1 + "/" + (dayInteger1<10?"0":"") + dayInteger1 + "/" + (year1<10?"0":"") + year1 % 100;
    document.selectForm.departuredate2.value = (monthInteger2<10?"0":"") + monthInteger2 + "/" + (dayInteger2<10?"0":"") + dayInteger2 + "/" + (year2<10?"0":"") + year2 % 100;

    //alert("MakeDepartureDates7");

    //alert("DDATE1=" + document.selectForm.departuredate1.value);
    //alert("DDATE2=" + document.selectForm.departuredate2.value);

    return true;
}

//set todays date
Now = new Date();
NowDay = Now.getDate();
NowMonth = Now.getMonth();
NowYear = Now.getYear();
if (NowYear < 2000) NowYear += 1900; //for Netscape

//function for returning how many days there are in a month including leap years
function DaysInMonth(WhichMonth, WhichYear)
{
  var DaysInMonth = 31;
  if (WhichMonth == "Apr" || WhichMonth == "Jun" || WhichMonth == "Sep" || WhichMonth == "Nov") DaysInMonth = 30;
  if (WhichMonth == "Feb")
  {
  	if ((WhichYear % 4 == 0 && WhichYear % 100 != 0) || WhichYear % 400 == 0 || WhichYear == 0)
  		DaysInMonth = 29;
  	else
  		DaysInMonth = 28;
  }
  return DaysInMonth;
}

//function to change the available days in a months
function ChangeOptionDays(Which)
{
  var today = new Date()

  DaysObject = eval("document.selectForm." + Which + "Day");
  MonthObject = eval("document.selectForm." + Which + "Month");

  Month = MonthObject[MonthObject.selectedIndex].text;
  var Year = today.getYear() % 100

  DaysForThisSelection = DaysInMonth(Month, Year);
  CurrentDaysInSelection = DaysObject.length;
  if (CurrentDaysInSelection > DaysForThisSelection)
  {
    for (i=0; i<(CurrentDaysInSelection-DaysForThisSelection); i++)
    {
      DaysObject.options[DaysObject.options.length - 1] = null
    }
  }
  if (DaysForThisSelection > CurrentDaysInSelection)
  {
    for (i=0; i<(DaysForThisSelection-CurrentDaysInSelection); i++)
    {
      NewOption = new Option(DaysObject.options.length + 1);
      DaysObject.add(NewOption);
    }
  }
    if (DaysObject.selectedIndex < 0) DaysObject.selectedIndex == 0;
}

//function to set options to today
function SetToToday(Which)
{
  DaysObject = eval("document.selectForm." + Which + "Day");
  MonthObject = eval("document.selectForm." + Which + "Month");

  YearObject[0].selected = true;
  MonthObject[NowMonth].selected = true;

  ChangeOptionDays(Which);

  DaysObject[NowDay-1].selected = true;
}