<!--
// New calendar script

	var Lx=0
	var	Months = new Array(" JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC",
	 					" JAN FEB MAR APR MAI JUN JUL AUG SEP OKT NOV DEZ")
	var	Suf = new Array("(st|nd|rd|th)", "(te|ste)")
	var Ln = new Array('English', 'German') // optional paragraph, see *
	var	MonthNames = new Array("January","February","March","April","May","June","July","August","September","October","November","December")

	var strHTML = ""
	var todaysDate = new Date()
	var thisDate = new Date()
	var thisMonth = thisDate.getMonth();
	var thisYear = thisDate.getYear();
	var returnControl;
	var returnType = "long";
	var dateSelected = false;
	
	// function to show calendar
	function calShowCalendar(object_id, type,framed, currentValue)
	{
	
		var return_array;

		if (object_id == "")					
			return_array = calDateVal(currentValue,'2');
		else
		{
			if (framed)
				returnControl = parent.document.all.item(object_id);
			else
				returnControl = parent.parent.document.all.item(object_id);
		
			return_array = calDateVal(returnControl.value,'2');	
		}
		
		if (type)
			returnType = type;

		if (!return_array[0])		
			thisDate = new Date();
		else
		{
			thisDate = return_array[1];
			dateSelected = true;
		}
			
		thisMonth = thisDate.getMonth();
		thisYear = thisDate.getYear();			
		
		calLoadCalendar();
	}
	
	
	// load the calendar into div
	function calLoadCalendar()
	{
		strHTML = ""
		
		calDoCalendarHeader()
		calDoCalendarBody()
		calDoCalendarFooter()
		document.getElementById("calendar_div").innerHTML = strHTML;
	}
	
	// add the calendar header to the string
	function calDoCalendarHeader()
	{		
	

		strHTML += "<table cellpadding=\"0\" cellpacing=\"0\" border=\"0\" class=\"collapsed\">";
		strHTML += "<tr>";
		strHTML += "<td valign=\"top\" colspan=\"3\">";
		strHTML += "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">";
		strHTML += "<tr>";
		
		var thisMonth = thisDate.getMonth();
		var thisYear = thisDate.getFullYear() < 100 ? thisDate.getFullYear() + 1900 : thisDate.getFullYear();
		
		strHTML += "<td class=\"font11\" height=\"20\" align=\"center\">";
		strHTML += "<select style=\"margin-bottom:10px\" name=\"calendarMonth\" id=\"calendarMonth\" onchange=\"calCalendarMonth(this.value)\">";
		strHTML += "<option " + (thisMonth == 0 ? " selected " : "") + "value=\"0\")>January</option>";
		strHTML += "<option " + (thisMonth == 1 ? " selected " : "") + "value=\"1\")>February</option>";
		strHTML += "<option " + (thisMonth == 2 ? " selected " : "") + "value=\"2\")>March</option>";
		strHTML += "<option " + (thisMonth == 3 ? " selected " : "") + "value=\"3\")>April</option>";
		strHTML += "<option " + (thisMonth == 4 ? " selected " : "") + "value=\"4\")>May</option>";
		strHTML += "<option " + (thisMonth == 5 ? " selected " : "") + "value=\"5\")>June</option>";
		strHTML += "<option " + (thisMonth == 6 ? " selected " : "") + "value=\"6\")>July</option>";
		strHTML += "<option " + (thisMonth == 7 ? " selected " : "") + "value=\"7\")>August</option>";
		strHTML += "<option " + (thisMonth == 8 ? " selected " : "") + "value=\"8\")>September</option>";
		strHTML += "<option " + (thisMonth == 9 ? " selected " : "") + "value=\"9\")>October</option>";
		strHTML += "<option " + (thisMonth == 10 ? " selected " : "") + "value=\"10\")>November</option>";
		strHTML += "<option " + (thisMonth == 11 ? " selected " : "") + "value=\"11\")>December</option>";
		strHTML += "</select>";
		strHTML += "</td>";

		strHTML += "<td class=\"font11\" height=\"20\" align=\"center\">";
		strHTML += "<select style=\"margin-bottom:10px\" name=\"calendarYear\" id=\"calendarYear\" onchange=\"calCalendarYear(this.value)\" >";
		for (var i=1960; i<2060; i++)		
			strHTML += "<option " + (thisYear == i ? " selected " : "") + " value=\"" + i + "\">" + i + "</option>";		
		strHTML += "</select>"
		strHTML += "</td>"
		strHTML += "</tr>"
		strHTML += "</table>"
		strHTML += "</td>"
		strHTML += "</tr>"		
		strHTML += "<tr>";
		strHTML += "<td colspan=\"3\" align=\"center\">";
		strHTML += "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">";
		strHTML += "<tr>";
		strHTML += "<td align=\"center\" class=\"calDayHeadClass\">Mon</td>";
		strHTML += "<td align=\"center\" class=\"calDayHeadClass\">Tue</td>";
		strHTML += "<td align=\"center\" class=\"calDayHeadClass\">Wed</td>";
		strHTML += "<td align=\"center\" class=\"calDayHeadClass\">Thu</td>";
		strHTML += "<td align=\"center\" class=\"calDayHeadClass\">Fri</td>";
		strHTML += "<td align=\"center\" class=\"calDayHeadClass\">Sat</td>";				
		strHTML += "<td align=\"center\" class=\"calDayHeadClass\">Sun</td>";
		strHTML += "<tr>";
	}

	// add the calendar body
	function calDoCalendarBody()
	{
	
		var lastDate = new Date((new Date(thisDate.getYear(), thisDate.getMonth() + 1,1))-1);
		var lastDay = lastDate.getDate();
		var toDay = todaysDate.getDate();
		var setDay = thisDate.getDate();
		var toMonth = todaysDate.getMonth();
		var toYear = todaysDate.getYear();
		var firstDay = new Date((new Date(thisDate.getYear(), thisDate.getMonth(),1))-1).getDay()+1;			

		for (var i=1; i < 43; i++)
		{			
			strHTML += i % 7 == 1 ? "<tr>" : "";
			if (i - firstDay + 1 == toDay && thisDate.getMonth() == toMonth && thisDate.getYear() == toYear)			
				strHTML += "<td align=\"center\" onmouseover=\"calDayOver(this)\" onmouseout=\"calDayOut(this,'calCurrentDayClass')\" onclick=\"calSelectDate(" + (i - firstDay + 1) + ")\" class=\"calCurrentDayClass\">" + (i - firstDay + 1) + "</td>";
			else if (i - firstDay + 1 == setDay && dateSelected)			
				strHTML += "<td align=\"center\" onmouseover=\"calDayOver(this)\" onmouseout=\"calDayOut(this,'calSelectedDayClass')\" onclick=\"calSelectDate(" + (i - firstDay + 1) + ")\" class=\"calSelectedDayClass\">" + (i - firstDay + 1) + "</td>";
			else if (i - firstDay < lastDay && i - firstDay >= 0)
				strHTML += "<td align=\"center\" onmouseover=\"calDayOver(this)\" onmouseout=\"calDayOut(this,'calDayClass')\" onclick=\"calSelectDate(" + (i - firstDay + 1) + ")\" class=\"calDayClass\">" + (i - firstDay + 1) + "</td>";
			else
				strHTML += "<td align=\"center\" class=\"calNoDayClass\">&nbsp;</td>"
			strHTML += i % 7 == 0 ? "</tr>" : "";
		}

	}
	
	// add the calendar footer to the string
	function calDoCalendarFooter()
	{		
		strHTML += "</table>";
		strHTML += "</td colspan=\"3\" align=\"center\">";
		strHTML += "</tr>";
		strHTML += "</table>";
	}
	
	// function to change month
	function calCalendarMonth(month)
	{
		thisDate = new Date(thisYear, month, 1);
		thisMonth = thisDate.getMonth();
		thisYear = thisDate.getYear();		
		calLoadCalendar();
	}
	
	// function to change year
	function calCalendarYear(year)
	{
		thisDate = new Date(year, thisMonth, 1);
		thisMonth = thisDate.getMonth();
		thisYear = thisDate.getYear();		
		calLoadCalendar();
	}	
	
	// function to change class of highlighted day
	function calDayOver(daycell)
	{
		daycell.className = "calDayOverClass";
	}

	// function to reset class of highlighted day
	function calDayOut(daycell,className)
	{
		daycell.className = className;
	}
	
	// function to select date
	function calSelectDate(selectedDay)
	{
		var returnDate = 
			returnType == "long" ? (selectedDay  + " " + calGetMonthName(thisMonth) + " " + thisYear):(selectedDay + "/" + calGetMonthShortName(thisMonth) + "/" + thisYear);

		if (returnControl)
			returnControl.value = returnDate;
			
			
		hideFrame(frameElement)
		if (frameElement.return_function)
			if (returnControl)
				parent.setTimeout(frameElement.return_function,100);
			else
				parent.setTimeout(frameElement.return_function + "('" + returnDate + "')",100);
			
	}
	
	function calDateVal(Q, F) 
	{ 

		var Mon, x, Rex, B, Y, ND=0;
	 
	 	//Q = Q.trim() // optional line
	
	 	if (F==0) 
		{
			 Rex = /(\d+)(\d{2})(\d{2})$/     // D5+ as Y+MMDD
	  		 Q = (Q.search(Rex)==-1 ? '' : Q.replace(Rex, '$1 $2 $3') ) // split
	  	} // optional paragraph
	
	// 	Rex = new RegExp(Suf[Lx], "i") // Remove suffix, see * below
	// 	Q = Q.replace(Rex, '')  // optional paragraph	
	
		Rex = /([^A-Z]+)([IVX]{1,4})(.*)/i // Seek Roman (month) : viii IX
	 	if (Rex.test(Q)) 
		{
	  		Mon = Q.replace(Rex, '$2').toUpperCase() // 1-4 Chars of month
	  		x = " I    II   III  IV   V    VI   VII  VIII IX   X    XI   XII ".indexOf(' '+Mon)
	  		Q = Q.replace(Rex, '$1 '+(1+x/5)+' $3') // make numeric
	 	} // optional paragraph
	
	 	Rex = /([^A-Z]*)([A-Z]{1,3})(.*)/i // Seek month letters : Au / Aug.  Or {3}.
	 	if (Rex.test(Q)) 
		{
	  		Mon = Q.replace(Rex, '$2').toUpperCase() // 1-3 Letters of month
	  		x = Months[Lx].indexOf(' '+Mon)  // or next line for English only, *
	  		// x = " JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC".indexOf(' '+Mon)
	 		Q = Q.replace(Rex, '$1 '+(1+x/4)+' $3')//.trim(); // make sufficiently numeric
	  	} // optional paragraph
	
	 	Rex = /^(\d+)\D+(\d+)\D+(\d+)$/ // three digit fields
	 	// if (F==1) Q = Q                       // ISO
	 	if (F==2) Q = Q.replace(Rex, '$3 $2 $1') // EU
	 	if (F==3) Q = Q.replace(Rex, '$3 $1 $2') // NA
	 	B = Rex.test(Q) // Split into $1 $2 $3
		if (B) with (RegExp) { Y = +$1
	  	if (Y<100) Y += (Y<60?2000:1900)      // optional century line
	  	with (ND = new Date(Y, $2-1, $3))
	  	B = ((getMonth()==$2-1) && (getDate()==$3))  } // test Y M D valid
	 	// To allow true years 00..99, enter as >2 digits, check $1.length;
	 	// then increase year by 100 & decrease month by 1200.
	 	return [B, ND] // [Valid, DateObject]
	 } // end DatVal	
	
	// get the month name
	function calGetMonthName(month)
	{
		return MonthNames[month];
	}
	
	// get the month short name
	function calGetMonthShortName(month)
	{
		return (MonthNames[month]).substring(0,3);
	}	
	
//-->