/************************************************************
© by Markus C. Unterleitner
Last updated: 20.05.2003
All rights reserved
*************************************************************/

Now = new Date();
NowDay = Now.getDate();
NowMonth = Now.getMonth();
NowYear = Now.getYear();
if (NowYear < 2000) NowYear += 1900; //for Netscape


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 ChangeOptionDays(Which)
{
	var msg="document.Form." + Which + "Tag";
	msg2="document.Form." + Which + "Monat";
	msg3="document.Form." + Which + "Jahr";
	
	DaysObject = eval(msg);
	MonthObject = eval(msg2);
	YearObject = eval(msg3);

	Month = MonthObject[MonthObject.selectedIndex].text;
	Year = YearObject[YearObject.selectedIndex].text;

	DaysForThisSelection = DaysInMonth(Month, Year);
	CurrentDaysInSelection = DaysObject.length-1;
	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 );
			DaysObject.options[DaysObject.options.length]=NewOption;
		}
	}

	if (DaysObject.selectedIndex < 0) DaysObject.selectedIndex == 0;
}


function WriteYearOptions(YearsAhead)
{
	line = "";

	for (i=0; i<YearsAhead+2; i++)
	{
		line += "<OPTION>";
		line += NowYear-2 + i;
	}

	return line;
}

function WriteYearOptionsBack(YearsFrom, YearTo)
{
	line = "";
	if (YearTo==0)
		YearTo=NowYear;

	for (i=YearsFrom; i<=YearTo; i++)
	{
		line += "<OPTION value="+i+">";
		line += ""+i;
	}

	return line;
}
