// Calendar Script

	var ie4 = navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) >= 4 ? 1 : 0;
	var ns5 = navigator.appName == "Netscape" && parseInt(navigator.appVersion) >= 5 ? 1 : 0;

    var thisMonth = (new Date().getFullYear()*12) + new Date().getMonth();
    var thisMonth_b = (new Date().getFullYear()*12) + new Date().getMonth();
    var monthsArray = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
    var fullMonthsArray = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
    var fullMonthsArrayda = ["januar", "februar", "marts", "april", "maj", "juni", "juli", "august", "september", "oktober", "november", "december"];
    var fullMonthsArrayse = ["Januari", "Februari", "Maart", "April", "Mei", "Juni", "Juli", "Augustus", "September", "Oktober", "November", "December"];
var fullMonthsArrayde = ["Januari", "Februari", "Mars", "April", "Maj", "Juni", "Juli", "Augusti", "September", "Oktober", "November", "December"];
    var daysArray = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
    var stndrdArray = ["","st","nd","rd","th","th","th","th","th","th","th","th","th","th","th","th","th","th","th","th","th","st","nd","rd","th","th","th","th","th","th","th","st"];
    var whichFields = "start";
    var fieldsToHide = new Array();
    var targetDay;
    var targetMonth;
    var targetYear;
    
    

	function PopulateCalendar( monthOffset, calendarId, defaultday, defaultmonth, defaultyear, datetype, language) {
		thisMonth += monthOffset;
		theDate = new Date( Math.floor( thisMonth / 12), thisMonth % 12);
		if ( defaultday > 0 )
			{
//			theDate.setDate(defaultday);
			theDate.setMonth(defaultmonth);
			theDate.setYear(defaultyear)
			thisMonth = ( defaultyear * 12 ) + defaultmonth;
			}
		
		targetMonth = theDate.getMonth( );
		targetYear = theDate.getFullYear( );

		daysInMonth = GetDaysInMonth( theDate);

		outHtml = '<table class="doublecal">';
		outHtml += '<tr>' + "\n";

		if (calendarId == 'calendar_a')
			{
			outHtml += '<td colspan="3" class="calhead" onclick="toggleCalendar();">' + "\n";
			}
		else
			{
			if (calendarId == 'calendar_a_ins')
				{
				outHtml += '<td colspan="3" class="calhead" onclick="toggleCalendar_ins();">' + "\n";
				}
			else
				{
				if (calendarId == 'calendar_b_ins')
					{
					outHtml += '<td colspan="3" class="calhead" onclick="toggleCalendar_b_ins();">' + "\n";
					}
				else
					{
					outHtml += '<td colspan="3" class="calhead" onclick="toggleCalendar_b();">' + "\n";
					}
				}				
			}

		
		if (language == 'da')
			outHtml += 'x Luk' + "\n";
		else
			if (language == 'de')
				outHtml += 'x Sluit' + "\n";
			else
				if (language == 'se')
					outHtml += 'x Nära' + "\n";
				else
					outHtml += 'x Close' + "\n";

		outHtml += '</td>' + "\n";
		outHtml += '</tr>' + "\n";

		
		outHtml += '<tr><td valign="top" align="center">'; 
		outHtml += '<table class="contents" border="0px" cellspacing="0px" cellpadding="0px">';
		
		
		outHtml += '<tr>' + "\n";
		outHtml += '<td class="cell">' + "\n";
		outHtml += '<a class="chevrons" href="Javascript: PopulateCalendar( -2, \'' + calendarId + '\',0,0,0, \'' + datetype + '\',  \'' + language + '\');"><<</a>' + "\n";
		outHtml += '</td>' + "\n";
		outHtml += '<td colspan="6" class="month">' + "\n"; // Start outputting the header
		


		if (language == 'da')
			{
			outHtml += fullMonthsArrayda[theDate.getMonth()] + " " + theDate.getFullYear();
			}
		else
			{
			if (language == 'de')
				{
				outHtml += fullMonthsArrayde[theDate.getMonth()] + " " + theDate.getFullYear();
				}
			else
				{
				if (language == 'se')
					outHtml += fullMonthsArrayse[theDate.getMonth()] + " " + theDate.getFullYear();
				else
					outHtml += fullMonthsArray[theDate.getMonth()] + " " + theDate.getFullYear();
				}
			}

		
		outHtml += '</td>' + "\n";
		outHtml += '</tr>' + "\n";
		outHtml += '<tr class="weekdays">' + "\n";
		

		if (language == 'da') 
			outHtml += '<td>S</td><td>M</td><td>T</td><td>O</td><td>T</td><td>F</td><td>L</td>' + "\n";
		else
			if (language == 'de')
 				outHtml += '<td>Z</td><td>M</td><td>D</td><td>W</td><td>D</td><td>V</td><td>Z</td>' + "\n";
			else
				if (language == 'se')
					outHtml += '<td>S</td><td>M</td><td>T</td><td>O</td><td>T</td><td>F</td><td>L</td>' + "\n";
				else
					outHtml += '<td>S</td><td>M</td><td>T</td><td>W</td><td>T</td><td>F</td><td>S</td>' + "\n";


		

		outHtml += '</tr>' + "\n";

		// Now output the dates
		
		outHtml += '<tr>' + "\n"; //Start the first new row!


//		LastDateAllowed = new Date("2007","11","31","23","59","59");
		LastDateAllowed = new Date
//		LastDateAllowed.setYear(LastDateAllowed.getFullYear() + 1);
		LastDateAllowed.setDate(1);
		LastDateAllowed.setMonth(LastDateAllowed.getMonth() + 14);	
		
		FirstDateAllowed = new Date();
		FirstDateAllowed.setHours(23);
		FirstDateAllowed.setMinutes(59);
		FirstDateAllowed.setSeconds(59);

		
		for( idx = 0; idx < 42; idx++) {
			currentdate = (idx - new Date(Math.floor(thisMonth/12), thisMonth%12).getDay()) + 1;

			if( (idx % 7) == 0) 
				outHtml += '</tr><tr>' + "\n";
			
			if( currentdate > 0 && currentdate <= daysInMonth) 
                        {
				currDate = new Date(targetYear, targetMonth, currentdate,"23","59","59");
				
				
				if (currDate <= FirstDateAllowed)
				{
					outHtml += '<td class="dayx">' + currentdate + '</td>' + "\n";
				}
				else
				{
					if (currDate > LastDateAllowed)
					{
						outHtml += '<td class="dayx">' + currentdate + '</td>' + "\n";
					}
					else
					{
					
					if (defaultday == currDate.getDate() && defaultmonth == currDate.getMonth() && defaultyear == currDate.getFullYear() )
						{
						outHtml += '<td class="defday" onclick="SelectDate( '+currentdate+", "+targetMonth +", "+targetYear+", '"+calendarId+"'"+');">' + currentdate + '</td>' + "\n";
						}
					else
						{
						outHtml += '<td class="day" onclick="SelectDate( '+currentdate+", "+targetMonth +", "+targetYear+", '"+calendarId+"'"+');">' + currentdate + '</td>' + "\n";
						}
												
					}
				}
			} 
                        else
                        {
				outHtml += '<td>&nbsp;</td>' + "\n";
			}
		}
		outHtml += '</tr>' + "\n";
		
		outHtml += '</table>' + "\n";
		outHtml += '</td>'
//	divider
				
		outHtml += '<td class="monthdivider">';
//		outHtml += '<img src="assets/calendar/divider.gif" border="0">';
		outHtml += '</td>' + "\n";
//	Start of second month
		outHtml += '<td valign="top" align="center">';
		

		thisMonth += 1;
		theDate = new Date( Math.floor( thisMonth / 12), thisMonth % 12);
				
		targetMonth = theDate.getMonth( );
		targetYear = theDate.getFullYear( );

		daysInMonth = GetDaysInMonth( theDate);



		outHtml += '<table class="contents" border="0px" cellspacing="0px" cellpadding="0px">';
		outHtml += '<tr>' + "\n";
		outHtml += '<td colspan="6" class="month">' + "\n"; // Start outputting the header
		

		
		if (language == 'da')
			{
			outHtml += fullMonthsArrayda[theDate.getMonth()] + " " + theDate.getFullYear();
			}
		else
			{
			if (language == 'de')
				{
				outHtml += fullMonthsArrayde[theDate.getMonth()] + " " + theDate.getFullYear();
				}
			else
				{
				if (language == 'se')
					outHtml += fullMonthsArrayse[theDate.getMonth()] + " " + theDate.getFullYear();
				else
					outHtml += fullMonthsArray[theDate.getMonth()] + " " + theDate.getFullYear();
				}
			}
		

		outHtml += '</td>' + "\n";
		

		outHtml += '<td class="cell">' + "\n";
		outHtml += '<a class="chevrons" href="Javascript: PopulateCalendar( 0, \'' + calendarId + '\',0,0,0, \'' + datetype + '\',  \'' + language + '\');">>></a>' + "\n";
		outHtml += '</td>' + "\n";
		outHtml += '</tr>' + "\n";
		outHtml += '<tr class="weekdays">' + "\n";
		if (language == 'da') 
			outHtml += '<td>S</td><td>M</td><td>T</td><td>O</td><td>T</td><td>F</td><td>L</td>' + "\n";
		else
			if (language == 'de')
 				outHtml += '<td>Z</td><td>M</td><td>D</td><td>W</td><td>D</td><td>V</td><td>Z</td>' + "\n";
			else
				if (language == 'se')
					outHtml += '<td>S</td><td>M</td><td>T</td><td>O</td><td>T</td><td>F</td><td>L</td>' + "\n";
				else
					outHtml += '<td>S</td><td>M</td><td>T</td><td>W</td><td>T</td><td>F</td><td>S</td>' + "\n";
		outHtml += '</tr>' + "\n";

		// Now output the dates
		
		outHtml += '<tr>' + "\n"; //Start the first new row!


//		LastDateAllowed = new Date("2007","11","31","23","59","59");
		LastDateAllowed = new Date
//		LastDateAllowed.setYear(LastDateAllowed.getFullYear() + 1);
		LastDateAllowed.setDate(1);
		LastDateAllowed.setMonth(LastDateAllowed.getMonth() + 14);	

		FirstDateAllowed = new Date();
		FirstDateAllowed.setHours(23);
		FirstDateAllowed.setMinutes(59);
		FirstDateAllowed.setSeconds(59);
		for( idx = 0; idx < 42; idx++) {
			currentdate = (idx - new Date(Math.floor(thisMonth/12), thisMonth%12).getDay()) + 1;

			if( (idx % 7) == 0) 
				outHtml += '</tr><tr>' + "\n";
			
			if( currentdate > 0 && currentdate <= daysInMonth) 
                        {
				currDate = new Date(targetYear, targetMonth, currentdate,"23","59","59");
				
				
				if (currDate <= FirstDateAllowed)
				{
					outHtml += '<td class="dayx">' + currentdate + '</td>' + "\n";
				}
				else
				{
					if (currDate > LastDateAllowed)
					{
						outHtml += '<td class="dayx">' + currentdate + '</td>' + "\n";
					}
					else
					{

					if (defaultday == currDate.getDate() && defaultmonth == currDate.getMonth() && defaultyear == currDate.getFullYear() )
						{
						outHtml += '<td class="defday" onclick="SelectDate( '+currentdate+", "+targetMonth +", "+targetYear+", '"+calendarId+"'"+');">' + currentdate + '</td>' + "\n";
						}
					else
						{
						outHtml += '<td class="day" onclick="SelectDate( '+currentdate+", "+targetMonth +", "+targetYear+", '"+calendarId+"'"+');">' + currentdate + '</td>' + "\n";
						}
												
					}
				}
			} 
                        else
                        {
				outHtml += '<td>&nbsp;</td>' + "\n";
			}
		}
		outHtml += '</tr>' + "\n";
		
		outHtml += '</table>' + "\n";
		outHtml += '</td></tr></table>';
		if( document.getElementById) 
			document.getElementById( calendarId).innerHTML = outHtml;
		else
			document.all[ calendarId].innerHTML = outHtml;
	}
	
	
	
	
function PopulateCalendarlong( monthOffset, calendarId, defaultday, defaultmonth, defaultyear, datetype, language, rangetype) {
		thisMonth += monthOffset;
		theDate = new Date( Math.floor( thisMonth / 12), thisMonth % 12);
		if ( defaultday > 0 )
			{
//			theDate.setDate(defaultday);
			theDate.setMonth(defaultmonth);
			theDate.setYear(defaultyear)
			thisMonth = ( defaultyear * 12 ) + defaultmonth;
			}
		
		targetMonth = theDate.getMonth( );
		targetYear = theDate.getFullYear( );

		daysInMonth = GetDaysInMonth( theDate);
		outHtml = '<table class="doublecal" cellspacing="1px">';		
		


		outHtml += '<tr>' + "\n";

		if (calendarId == 'calendar_a')
			{
			outHtml += '<td colspan="3" class="calhead" onclick="toggleCalendar();">' + "\n";
			}
		else
			{
			if (calendarId == 'calendar_a_ins')
				{
				outHtml += '<td colspan="3" class="calhead" onclick="toggleCalendar_ins();">' + "\n";
				}
			else
				{
				if (calendarId == 'calendar_b_ins')
					{
					outHtml += '<td colspan="3" class="calhead" onclick="toggleCalendar_b_ins();">' + "\n";
					}
				else
					{
					outHtml += '<td colspan="3" class="calhead" onclick="toggleCalendar_b();">' + "\n";
					}
				}				
			}

		if (language == 'da')
			{
			outHtml += 'x Luk' + "\n";
			}
		else
			{
			if (language == 'de')
				{
				outHtml += 'x Sluit' + "\n";
				}
			else
				{
				outHtml += 'x Close' + "\n";
				}
			}
		outHtml += '</td>' + "\n";
		outHtml += '</tr>' + "\n";




		outHtml += '<tr><td valign="top" align="center">'; 
		outHtml += '<table class="contents" border="0px" cellspacing="0px" cellpadding="0px">';
		outHtml += '<tr>' + "\n";
		outHtml += '<td class="cell">' + "\n";
		outHtml += '<a class="chevrons" href="Javascript: PopulateCalendarlong( -2, \'' + calendarId + '\',0,0,0, \'' + datetype + '\',  \'' + language + '\',  \'' + rangetype + '\' );"><<</a>' + "\n";
		outHtml += '</td>' + "\n";
		outHtml += '<td colspan="6" class="month">' + "\n"; // Start outputting the header
		
		
		if (language == 'da')
			outHtml += fullMonthsArrayda[theDate.getMonth()] + " " + theDate.getFullYear();
		else
			outHtml += fullMonthsArray[theDate.getMonth()] + " " + theDate.getFullYear();
		
		outHtml += '</td>' + "\n";
		outHtml += '</tr>' + "\n";
		outHtml += '<tr class="weekdays">' + "\n";
		if (language == 'da') 
			outHtml += '<td>S</td><td>M</td><td>T</td><td>O</td><td>T</td><td>F</td><td>L</td>' + "\n";
		else
			outHtml += '<td>S</td><td>M</td><td>T</td><td>W</td><td>T</td><td>F</td><td>S</td>' + "\n";
		outHtml += '</tr>' + "\n";

		// Now output the dates
		
		outHtml += '<tr>' + "\n"; //Start the first new row!

		// LastDateAllowed = new Date("2009","07","31","23","59","59");
		FirstDateAllowed = new Date();
		FirstDateAllowed.setHours(23);
		FirstDateAllowed.setMinutes(59);
		FirstDateAllowed.setSeconds(59);
		FirstDateAllowed.setMilliseconds(0);
		LastDateAllowed = new Date();
		LastDateAllowed = new Date(FirstDateAllowed);
		if (rangetype.substring(0,1) == '1')
			FirstDateAllowed.setDate(FirstDateAllowed.getDate() + 1);
		

		if (rangetype.substring(1,2) == '2' || rangetype.substring(1,2) == '3' ) 
			{
			
			if (rangetype.substring(1,2) == '2')
				LastDateAllowed.setYear(LastDateAllowed.getFullYear() + 2);
			else
			
				LastDateAllowed.setYear(LastDateAllowed.getFullYear() + 3);
			
			LastDateAllowed.setMonth(0);
			
			LastDateAllowed.setDate(1);
			
			LastDateAllowed.setDate(LastDateAllowed.getDate() - 1);
			}
		else
			{
			LastDateAllowed.setYear(LastDateAllowed.getFullYear() + 3);
			LastDateAllowed.setDate(1);
			LastDateAllowed.setDate(LastDateAllowed.getDate() - 1);
			}
		
			

	
		for( idx = 0; idx < 42; idx++) {
			currentdate = (idx - new Date(Math.floor(thisMonth/12), thisMonth%12).getDay()) + 1;

			if( (idx % 7) == 0) 
				outHtml += '</tr><tr>' + "\n";
			
			if( currentdate > 0 && currentdate <= daysInMonth) 
                        {
				currDate = new Date(targetYear, targetMonth, currentdate,"23","59","59","00");
			

				if (currDate < FirstDateAllowed)
				{
					outHtml += '<td class="dayx">' + currentdate + '</td>' + "\n";
				}
				else
				{
					if (currDate > LastDateAllowed)
					{
						outHtml += '<td class="dayx">' + currentdate + '</td>' + "\n";
					}
					else
					{

					
					if (defaultday == currDate.getDate() && defaultmonth == currDate.getMonth() && defaultyear == currDate.getFullYear() )
						{
						outHtml += '<td class="defday" onclick="SelectDatelong( '+currentdate+", "+targetMonth +", "+targetYear+", '"+calendarId+"'"+", '"+datetype+"'"+", '"+rangetype+"'"+');">' + currentdate + '</td>' + "\n";
						}
					else
						{
						outHtml += '<td class="day" onclick="SelectDatelong( '+currentdate+", "+targetMonth +", "+targetYear+", '"+calendarId+"'"+", '"+datetype+"'"+", '"+rangetype+"'"+');">' + currentdate + '</td>' + "\n";
						}
												
					}
				}
			} 
                        else
                        {
				outHtml += '<td>&nbsp;</td>' + "\n";
			}
		}
		outHtml += '</tr>' + "\n";
		
		outHtml += '</table>' + "\n";
		outHtml += '</td>'
//	divider
				
		outHtml += '<td valign="middle" align="center">';
		
		outHtml += '</td>' + "\n";
//	Start of second month
		outHtml += '<td valign="top" align="center">';
		

		thisMonth += 1;
		theDate = new Date( Math.floor( thisMonth / 12), thisMonth % 12);
				
		targetMonth = theDate.getMonth( );
		targetYear = theDate.getFullYear( );

		daysInMonth = GetDaysInMonth( theDate);

		

		outHtml += '<table class="contents" border="0px" cellspacing="0px" cellpadding="0px">';
		outHtml += '<tr>' + "\n";
		outHtml += '<td colspan="6" class="month">' + "\n"; // Start outputting the header
		if (language == 'da')
			outHtml += fullMonthsArrayda[theDate.getMonth()] + " " + theDate.getFullYear();
		else
			outHtml += fullMonthsArray[theDate.getMonth()] + " " + theDate.getFullYear();
		outHtml += '</td>' + "\n";
		

		outHtml += '<td class="cell">' + "\n";
		outHtml += '<a class="chevrons" href="Javascript: PopulateCalendarlong( 0, \'' + calendarId + '\',0,0,0, \'' + datetype + '\',  \'' + language + '\',  \'' + rangetype + '\');">>></a>' + "\n";
		outHtml += '</td>' + "\n";
		outHtml += '</tr>' + "\n";
		outHtml += '<tr class="weekdays">' + "\n";
		if (language == 'da') 
			outHtml += '<td>S</td><td>M</td><td>T</td><td>O</td><td>T</td><td>F</td><td>L</td>' + "\n";
		else
			outHtml += '<td>S</td><td>M</td><td>T</td><td>W</td><td>T</td><td>F</td><td>S</td>' + "\n";
		outHtml += '</tr>' + "\n";

		// Now output the dates
		
		outHtml += '<tr>' + "\n"; //Start the first new row!


		// LastDateAllowed = new Date("2009","07","31","23","59","59");
		FirstDateAllowed = new Date();
		FirstDateAllowed.setHours(23);
		FirstDateAllowed.setMinutes(59);
		FirstDateAllowed.setSeconds(59);
		FirstDateAllowed.setMilliseconds(0);
		LastDateAllowed = new Date();
		LastDateAllowed = new Date(FirstDateAllowed);
		if (rangetype.substring(0,1) == '1')
			FirstDateAllowed = FirstDateAllowed.setDate(FirstDateAllowed.getDate() + 1);
		if (rangetype.substring(1,2) == '2' || rangetype.substring(1,2) == '3' ) 
			{
			
			if (rangetype.substring(1,2) == '2')
				LastDateAllowed.setYear(LastDateAllowed.getFullYear() + 2);
			else
			
				LastDateAllowed.setYear(LastDateAllowed.getFullYear() + 3);
			
			LastDateAllowed.setMonth(0);
			
			LastDateAllowed.setDate(1);
			
			LastDateAllowed.setDate(LastDateAllowed.getDate() - 1);
			}
		else
			{
			LastDateAllowed.setYear(LastDateAllowed.getFullYear() + 3);
			LastDateAllowed.setDate(1);
			LastDateAllowed.setDate(LastDateAllowed.getDate() - 1);
			}
		for( idx = 0; idx < 42; idx++) {
			currentdate = (idx - new Date(Math.floor(thisMonth/12), thisMonth%12).getDay()) + 1;

			if( (idx % 7) == 0) 
				outHtml += '</tr><tr>' + "\n";
			
			if( currentdate > 0 && currentdate <= daysInMonth) 
                        {
				currDate = new Date(targetYear, targetMonth, currentdate,"23","59","59","00");
				
				
				if (currDate < FirstDateAllowed)
				{
					outHtml += '<td class="dayx">' + currentdate + '</td>' + "\n";
				}
				else
				{
					if (currDate > LastDateAllowed)
					{
						outHtml += '<td class="dayx">' + currentdate + '</td>' + "\n";
					}
					else
					{

					if (defaultday == currDate.getDate() && defaultmonth == currDate.getMonth() && defaultyear == currDate.getFullYear() )
						{
						outHtml += '<td class="defday" onclick="SelectDatelong( '+currentdate+", "+targetMonth +", "+targetYear+", '"+calendarId+"'"+", '"+datetype+"'"+');">' + currentdate + '</td>' + "\n";
						}
					else
						{
						outHtml += '<td class="day" onclick="SelectDatelong( '+currentdate+", "+targetMonth +", "+targetYear+", '"+calendarId+"'"+", '"+datetype+"'"+');">' + currentdate + '</td>' + "\n";
						}
												
					}
				}
			} 
                        else
                        {
				outHtml += '<td>&nbsp;</td>' + "\n";
			}
		}
		outHtml += '</tr>' + "\n";
		
		outHtml += '</table>' + "\n";
		outHtml += '</td></tr></table>';
		if( document.getElementById) 
			document.getElementById( calendarId).innerHTML = outHtml;
		else
			document.all[ calendarId].innerHTML = outHtml;
	}








	
	
	function SelectDate( theDay, theMonth, theYear, calId) {
	
	if (calId == "calendar_a")
		{
                document.amendproduct.dispstartday.options[(theDay-1)].selected = true;
		
		changethemonthyeardropdown((monthsArray[ theMonth].toUpperCase()) + ("" + theYear).substring(2,4),document.amendproduct.dispstartmonth);
		
		if (document.amendproduct.dispendmonth)
			{
			changethemonthyeardropdown((monthsArray[ theMonth].toUpperCase()) + ("" + theYear).substring(0,4),document.amendproduct.dispendmonth);
                	}
		toggleCalendar( ); // Hide the calendar!
		}
	else
		{
		if (calId == "calendar_a_ins")
			{
                	document.amendproduct.dispstartday.options[(theDay-1)].selected = true;
			changethemonthyeardropdown((monthsArray[ theMonth].toUpperCase()) + ("" + theYear).substring(0,4),document.amendproduct.dispstartmonth);
			changethemonthyeardropdown((monthsArray[ theMonth].toUpperCase()) + ("" + theYear).substring(0,4),document.amendproduct.dispendmonth);
                	toggleCalendar_ins( ); // Hide the calendar!
			}
		else
			{
			if (calId == "calendar_b_ins")
				{
				document.amendproduct.dispendday.options[(theDay-1)].selected = true;
				changethemonthyeardropdown((monthsArray[ theMonth].toUpperCase()) + ("" + theYear).substring(0,4),document.amendproduct.dispendmonth);
				toggleCalendar_b_ins( ); // Hide the calendar!	
				}
			else
				{		
				document.amendproduct.dispendday.options[(theDay-1)].selected = true;
				changethemonthyeardropdown((monthsArray[ theMonth].toUpperCase()) + ("" + theYear).substring(2,4),document.amendproduct.dispendmonth);
				toggleCalendar_b( ); // Hide the calendar!	
				}

			}
	
		}
	
}


	function SelectDatelong( theDay, theMonth, theYear, calId, datetype, rangetype) {
	
	if (datetype == "display")
		{
		if (calId == "calendar_a")
			{
                	document.amendproduct.dispstartday.options[(theDay-1)].selected = true;
			changethemonthyeardropdown((monthsArray[ theMonth].toUpperCase()),document.amendproduct.dispstartmonth);
			changethemonthyeardropdown(("" + theYear).substring(2,4),document.amendproduct.dispstartyear);
			toggleCalendar( ); // Hide the calendar!
			}
		else
			{
			document.amendproduct.dispendday.options[(theDay-1)].selected = true;
			changethemonthyeardropdown((monthsArray[ theMonth].toUpperCase()),document.amendproduct.dispendmonth);
			changethemonthyeardropdown(("" + theYear).substring(2,4),document.amendproduct.dispendyear);
			toggleCalendar_b( ); // Hide the calendar!
			}
		}
	else
		{
		if (calId == "calendar_a")
			{
                	document.login.BkDay.options[(theDay-1)].selected = true;
			changethemonthyeardropdown((monthsArray[ theMonth].toUpperCase()),document.login.BkMonth);
			changethemonthyeardropdown(("" + theYear).substring(2,4),document.login.BkYear);
			changethemonthyeardropdown((monthsArray[ theMonth].toUpperCase()),document.login.retMonth);
			changethemonthyeardropdown(("" + theYear).substring(2,4),document.login.retYear);
			toggleCalendar( ); // Hide the calendar!
			}
		else
			{
			document.login.retDay.options[(theDay-1)].selected = true;
			changethemonthyeardropdown((monthsArray[ theMonth].toUpperCase()),document.login.retMonth);
			changethemonthyeardropdown(("" + theYear).substring(2,4),document.login.retYear);
			toggleCalendar_b( ); // Hide the calendar!
			}
		}
	}






	function GetDaysInMonth(date)
    {
       temp = new Date(date.valueOf());

       return new Date(temp.setMonth(temp.getMonth()+1).valueOf() - (24*60*60*1000)).getDate();
    }





    
    function toggleCalendar( ) {
	    if( document.getElementById) 
	    	document.getElementById( "calendar_a").style.display = document.getElementById( "calendar_a").style.display == "none" ? "" : "none";
	    else
	    	document.all[ "calendar_a"].style.display = document.all[ "calendar_a"].style.display == "none" ? "" : "none";
	    	
	    return true;
    }


    function toggleCalendar_b( ) {
	    if( document.getElementById) 
	    	document.getElementById( "calendar_b").style.display = document.getElementById( "calendar_b").style.display == "none" ? "" : "none";
	    else
	    	document.all[ "calendar_b"].style.display = document.all[ "calendar_b"].style.display == "none" ? "" : "none";
	    	
	    return true;
    }
    function toggleCalendar_ins( ) {
	    if( document.getElementById) 
	    	document.getElementById( "calendar_a_ins").style.display = document.getElementById( "calendar_a_ins").style.display == "none" ? "" : "none";
	    else
	    	document.all[ "calendar_a_ins"].style.display = document.all[ "calendar_a_ins"].style.display == "none" ? "" : "none";
	    	
	    return true;
    }


    function toggleCalendar_b_ins( ) {
	    if( document.getElementById) 
	    	document.getElementById( "calendar_b_ins").style.display = document.getElementById( "calendar_b_ins").style.display == "none" ? "" : "none";
	    else
	    	document.all[ "calendar_b_ins"].style.display = document.all[ "calendar_b_ins"].style.display == "none" ? "" : "none";
	    	
	    return true;
    }



	function toggleCalendarlong( ) {
		
	    if( document.getElementById) 
	    	document.getElementById( "calendar_a").style.display = document.getElementById( "calendar_a").style.display == "none" ? "" : "none";
	    else
	    	document.all[ "calendar_a"].style.display = document.all[ "calendar_a"].style.display == "none" ? "" : "none";
	    	
	    return true;
    }


	function toggleCalendarlong_b( ) {
		
	    if( document.getElementById) 
	    	document.getElementById( "calendar_b").style.display = document.getElementById( "calendar_b").style.display == "none" ? "" : "none";
	    else
	    	document.all[ "calendar_b"].style.display = document.all[ "calendar_b"].style.display == "none" ? "" : "none";
	    	
	    return true;
    }




    function PadLeft(str)
    {
       while(str.length < 2)
          str = "0" + str;

       return str;
    }






function changethemonthyeardropdown(mycode,listname){
i = 0
      var itemFound = false
      while ((i < listname.options.length) && (!itemFound)) {
         if (listname.options[i].value == mycode) {
            listname.options[i].selected = true
            itemFound = true
         }
         i++
      }
   }






function togcal(datetype, language)
{
var months = "JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC";
var monthpos;
monthpos = months.indexOf(document.forms[0].dispstartmonth.value.substring(0,3));
monthpos = (( monthpos + 3 ) / 3 ) - 1;
PopulateCalendar( 0, "calendar_a",document.forms[0].dispstartday.value, monthpos, '20' + document.forms[0].dispstartmonth.value.substring(3,5),datetype, language);
toggleCalendar( );
}

function togcal_b(datetype, language)
{
var months = "JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC";
var monthpos;
monthpos = months.indexOf(document.forms[0].dispendmonth.value.substring(0,3));
monthpos = (( monthpos + 3 ) / 3 ) - 1;
PopulateCalendar( 0, "calendar_b",document.forms[0].dispendday.value, monthpos, '20' + document.forms[0].dispendmonth.value.substring(3,5),datetype, language);
toggleCalendar_b( );
}


function togcal_ins()
{
var months = "JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC";
var monthpos;
monthpos = months.indexOf(document.forms[0].dispstartmonth.value.substring(0,3));
monthpos = (( monthpos + 3 ) / 3 ) - 1;
PopulateCalendar( 0, "calendar_a_ins",document.forms[0].dispstartday.value, monthpos, document.forms[0].dispstartmonth.value.substring(3,7));
toggleCalendar_ins( );
}

function togcal_b_ins()
{
var months = "JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC";
var monthpos;
monthpos = months.indexOf(document.forms[0].dispendmonth.value.substring(0,3));
monthpos = (( monthpos + 3 ) / 3 ) - 1;
PopulateCalendar( 0, "calendar_b_ins",document.forms[0].dispendday.value, monthpos, parseInt(document.forms[0].dispendmonth.value.substring(3,7)));
toggleCalendar_b_ins( );
}



function togcallong(datetype, language, rangetype)
{
var months = "JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC";
var monthpos;
if (datetype == "display")
	{
	monthpos = months.indexOf(document.forms.amendproduct.dispstartmonth.value);

	}  
else
	{
	monthpos = months.indexOf(document.forms.login.BkMonth.value);

	}    
monthpos = (( monthpos + 3 ) / 3 ) - 1;
if (datetype == "display")
	{
	PopulateCalendarlong( 0, "calendar_a",document.forms.amendproduct.dispstartday.value, monthpos, 2000 + parseInt(document.forms.amendproduct.dispstartyear.value,10),datetype, language, rangetype);

	}
else
	{
	PopulateCalendarlong( 0, "calendar_a",document.forms.login.BkDay.value, monthpos, 2000 + parseInt(document.forms.login.BkYear.value,10),datetype, language, rangetype);

	}
toggleCalendarlong( );
}

function togcallong_b(datetype, language, rangetype)
{
var months = "JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC";
var monthpos;
if (datetype == "display")
	{	
	monthpos = months.indexOf(document.forms.amendproduct.dispendmonth.value);

	}
else
	{	
	monthpos = months.indexOf(document.forms.login.retMonth.value);

	}
monthpos = (( monthpos + 3 ) / 3 ) - 1;
if (datetype == "display")
	{
	PopulateCalendarlong( 0, "calendar_b",document.forms.amendproduct.dispendday.value, monthpos, 2000 + parseInt(document.forms.amendproduct.dispendyear.value,10),datetype,language, rangetype);

	}
else
	{
	PopulateCalendarlong( 0, "calendar_b",document.forms.login.retDay.value, monthpos, 2000 + parseInt(document.forms.login.retYear.value,10),datetype,language, rangetype);

	}

toggleCalendarlong_b( );
}


















 










