function submit(theform) {
if (document.getElementById) {
	window.external.AutoCompleteSaveForm(theform);
}
theform.submit();
}

function DaysInMonth(Mon, Year)
{
  var DaysInMonth = 31;
  if (Mon == "Apr" || Mon == "Jun" || Mon == "Sep" || Mon == "Nov") DaysInMonth = 30;
  if (Mon == "Feb" && (Year/4) != Math.floor(Year/4))	DaysInMonth = 28;
  if (Mon == "Feb" && (Year/4) == Math.floor(Year/4))	DaysInMonth = 29;
  return DaysInMonth;
}

function ChangeOptionDays(dob,mob,yob)
{
  Day = dob[dob.selectedIndex].text;
  Month = mob[mob.selectedIndex].text;
  Year = yob[yob.selectedIndex].text;
  DaysForThisSelection = DaysInMonth(Month, Year);
  CurrentDaysInSelection = dob.length;
 // if (CurrentDaysInSelection > DaysForThisSelection)
 // {
  //  for (i=0; i<(CurrentDaysInSelection-DaysForThisSelection); i++)
 //   {
 //     dob.options[dob.options.length - 1] = null
//    }

//  }
  if (DaysForThisSelection > CurrentDaysInSelection)
  {
//    for (i=0; i<(DaysForThisSelection-CurrentDaysInSelection); i++)
//    {
//      NewOption = new Option(dob.options.length + 1);
//      dob.add(NewOption);
//    }
  }
  if (Day > DaysForThisSelection) 
	{
	dob[(dob.options.length)-1].selected=true;
	}
	 else 
	 {
	dob[Day-1].selected=true;
	}
}

function SetToToday(dob,mob,yob)
{
 Now = new Date();
 NowDay = Now.getDate();
 NowMonth = Now.getMonth();
 NowYear = Now.getYear();
 if (NowYear < 2000) NowYear += 1900; 
 yob[0].selected = true;
 mob[NowMonth].selected = true;
 ChangeOptionDays(dob,mob,yob);
 dob[NowDay-1].selected = true;
}

function WriteYearOptions(YearsAhead,selyear)
{
 Now = new Date();
 NowDay = Now.getDate();
 NowMonth = Now.getMonth();
 NowYear = Now.getYear();
 if (NowYear<2000) NowYear+=1900;
  line = "";
  for (i=0; i<YearsAhead; i++)
  {
    if (selyear==(NowYear+i)) 
		{
		line += "<OPTION SELECTED>";
		} 
		else 
		 {
		line += "<OPTION>";
		}
    line += NowYear + i;
  }
  return line;
}
