<!-- Begin
//  TB 20040414:	I ripped off most of this, but added the functionality to have multiple pull down dates
//					in the same form.  There is a second variable now in two of the functions that is named
//					fieldNumber.  In the function SetToToday() that is called from the body in onLoad, fieldNumber
//					Should be the number of pull down dates in the form.  Month, Day, and Year make one pull down
//					date.  The fieldNumber variable in the function ChangeOptionDays() that is called from the 
//					SELECT field onChange is the number reperesenting which date pull down menu group it belongs 
//					to.  The first Pull down date menu would have a value of 1 in the second field of the function
//					and 1 at the end of the name, as in this example:
//					<SELECT name="FirstSelectMonth1" onchange="ChangeOptionDays('FirstSelect','1')">
//					The second group would be like this example:
//					<SELECT name="FirstSelectMonth2" onchange="ChangeOptionDays('FirstSelect','2')">


//set todays date
Now = new Date();
NowDay = Now.getDate();
NowMonth = Now.getMonth();
NowYear = Now.getYear();
if (NowYear < 200) 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" && (WhichYear/4) != Math.floor(WhichYear/4))	DaysInMonth = 28;
  if (WhichMonth == "Feb" && (WhichYear/4) == Math.floor(WhichYear/4))	DaysInMonth = 29;
  return DaysInMonth;
}

//function to change the available days in a months
function ChangeOptionDays(FormName, Which, fieldNumber)
{
  DaysObject = eval("document." + FormName + "." + Which + "Day" + fieldNumber);
  MonthObject = eval("document." + FormName + "." + Which + "Month" + fieldNumber);
  YearObject = eval("document." + FormName + "." + Which + "Year" + fieldNumber);

  Month = MonthObject[MonthObject.selectedIndex].text;
  Year = YearObject[YearObject.selectedIndex].text;

  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++)
    {
	  //var OldOption = DaysObject.options.length; 
      NewOption = new Option(DaysObject.options.length + 1);
	  //alert(NewOption);
	  try {
        DaysObject.add(NewOption, null);
	  }catch(ex){
	    DaysObject.add(NewOption);
	  }
    }
  }
    if (DaysObject.selectedIndex < 0) DaysObject.selectedIndex == 0;
}

//function to set options to today
function SetToToday(FormName, Which, fieldNumber)
{
	for (i = 1; i <= fieldNumber; i++) {
		DaysObject = eval("document." + FormName + "." + Which + "Day" +i);
		MonthObject = eval("document." + FormName + "." + Which + "Month" +i);
		YearObject = eval("document." + FormName + "." + Which + "Year" +i);

		YearObject[0].selected = true;
		MonthObject[NowMonth].selected = true;

		ChangeOptionDays(FormName, Which, i);

		DaysObject[NowDay-1].selected = true;
	}
}

//function to write option years plus x
/*function WriteYearOptions(YearsAhead)
{
  line = "";
  for (i=0; i<YearsAhead; i++)
  {
    line += "<OPTION>";
    line += NowYear + i;
  }
  return line;
}
*/
function WriteYearOptions(StartYear,YearsAhead,DisplayYear)
{
  line = '<option value="' + DisplayYear + '">' + DisplayYear + '</option>';
  for (i=0; i<YearsAhead; i++)
  {
    var newYear = StartYear + i;
    line += '<option value="' + newYear + '">' + newYear + '</option>';
    //line += StartYear + i;
  }
  return line;
}
//  End -->
