function updateDayFrom() 
{
var today=new Date();
var currDay = today.getDate();
var mnthSelectedIndex;
var mnthSelected;
var yrSelectedIndex;
var yrSelected;

mnthSelectedIndex = document.F1.MnthFrom.selectedIndex;
yrSelectedIndex = document.F1.YrFrom.selectedIndex;

if (mnthSelectedIndex != 0 && yrSelectedIndex != 0)
  {
  mnthSelected = document.F1.MnthFrom[mnthSelectedIndex].value;
  yrSelected = document.F1.YrFrom[yrSelectedIndex].value;

  if (mnthSelected == "02")
    {
    document.F1.DayFrom.options[31] = null;
    document.F1.DayFrom.options[30] = null;

    //check for leap year
    //if leap year
    if ( ((yrSelected%400)==0) || (((yrSelected%100)!=0) && ((yrSelected%4)==0)) )
      {
      //if there is currently not a 29th day then add it
      if (document.F1.DayFrom.options[29] == null) 
        {
        document.F1.DayFrom.options[29] = new Option("29");
        document.F1.DayFrom.options[29].value = "29";
        }
      } 
    //else not leap year so make 29th day null
    else 
      {
      document.F1.DayFrom.options[29] = null;
      }
    }

  //initialise drop-down list of days to 31 for certain months
  else if (mnthSelected == "01" ||
     mnthSelected == "03" ||
     mnthSelected == "05" ||
     mnthSelected == "07" ||
     mnthSelected == "08" ||
     mnthSelected == "10" ||
     mnthSelected == "12")
    {
    if (document.F1.DayFrom.options[29] == null) 
      {
      document.F1.DayFrom.options[29] = new Option("29");
      document.F1.DayFrom.options[29].value = "29";
      }
    if (document.F1.DayFrom.options[30] == null) 
      {
      document.F1.DayFrom.options[30] = new Option("30");
      document.F1.DayFrom.options[30].value = "30";
      }
    if (document.F1.DayFrom.options[31] == null) 
      {
      document.F1.DayFrom.options[31] = new Option("31");
      document.F1.DayFrom.options[31].value = "31";
      }
    }

  //initialise drop-down list of days to 30 for certain months
  else 
    {
    if (document.F1.DayFrom.options[29] == null) 
      {
      document.F1.DayFrom.options[29] = new Option("29");
      document.F1.DayFrom.options[29].value = "29";
      }
    if (document.F1.DayFrom.options[30] == null) 
      {
      document.F1.DayFrom.options[30] = new Option("30");
      document.F1.DayFrom.options[30].value = "30";
      }
    document.F1.DayFrom.options[31] = null;
    }
  }
//document.F1.DayFrom.options[currDay].selected = true;
}


function updateDayTo() 
{
var today=new Date();
var currDay = today.getDate();
var mnthSelectedIndex;
var mnthSelected;
var yrSelectedIndex;
var yrSelected;

mnthSelectedIndex = document.F1.MnthTo.selectedIndex;
yrSelectedIndex = document.F1.YrTo.selectedIndex;

if (mnthSelectedIndex != 0 && yrSelectedIndex != 0)
  {
  mnthSelected = document.F1.MnthTo[mnthSelectedIndex].value;
  yrSelected = document.F1.YrTo[yrSelectedIndex].value;

  if (mnthSelected == "02")
    {
    document.F1.DayTo.options[31] = null;
    document.F1.DayTo.options[30] = null;

    //check for leap year
    //if leap year
    if ( ((yrSelected%400)==0) || (((yrSelected%100)!=0) && ((yrSelected%4)==0)) )
      {
      //if there is currently not a 29th day then add it
      if (document.F1.DayTo.options[29] == null) 
        {
        document.F1.DayTo.options[29] = new Option("29");
        document.F1.DayTo.options[29].value = "29";
        }
      } 
    //else not leap year so make 29th day null
    else 
      {
      document.F1.DayTo.options[29] = null;
      }
    }

  //initialise drop-down list of days to 31 for certain months
  else if (mnthSelected == "01" ||
     mnthSelected == "03" ||
     mnthSelected == "05" ||
     mnthSelected == "07" ||
     mnthSelected == "08" ||
     mnthSelected == "10" ||
     mnthSelected == "12")
    {
    if (document.F1.DayTo.options[29] == null) 
      {
      document.F1.DayTo.options[29] = new Option("29");
      document.F1.DayTo.options[29].value = "29";
      }
    if (document.F1.DayTo.options[30] == null) 
      {
      document.F1.DayTo.options[30] = new Option("30");
      document.F1.DayTo.options[30].value = "30";
      }
    if (document.F1.DayTo.options[31] == null) 
      {
      document.F1.DayTo.options[31] = new Option("31");
      document.F1.DayTo.options[31].value = "31";
      }
    }

  //initialise drop-down list of days to 30 for certain months
  else 
    {
    if (document.F1.DayTo.options[29] == null) 
      {
      document.F1.DayTo.options[29] = new Option("29");
      document.F1.DayTo.options[29].value = "29";
      }
    if (document.F1.DayTo.options[30] == null) 
      {
      document.F1.DayTo.options[30] = new Option("30");
      document.F1.DayTo.options[30].value = "30";
      }
    document.F1.DayTo.options[31] = null;
    }
  }
//document.F1.DayTo.options[currDay].selected = true;
}


//** CODE BELOW NOT USED **
function populateDays(year,month,todayDate) 
{

timeA = new Date(year, month,1);
timeDifference = timeA - 86400000;
timeB = new Date(timeDifference);

var currDay = Date.getDay()
  
var daysInMonth = timeB.getDate();

for (var i = 0; i < daysInMonth; i++) 
  {
  F1.day.options[i] = new Option(i+1);
  }
document.F1.day.options[currDay-1].selected = true;
}


function populateDates() {

// You can easily customize what years can be used
var years = new Array(2002,2003,2004,2005);

for (var i = 0; i < document.F1.YrTo.length; i++) 
  {
  document.F1.YrTo.options[0] = null;
  }
var currDate = new Date();
var currYear = currDate.getFullYear();
var currMonth = currDate.getMonth();

for (var i = 0; i < document.F1.YrTo.length; i++) 
  {
  document.F1.YrTo.options[i] = new Option(years[i]);
  if (document.F1.YrTo.options[i].text == currYear)
    document.F1.YrTo.options[i].selected=true;
  }

//make selected month the current month
//for (var i = 0; i < document.F1.MnthTo.length; i++) 
  //{
  //if (i == currMonth)
    //{
    //document.F1.MnthTo.options[i].selected=true;
    //break;
    //}
  //}
updateDay()
}

//  End -->