


function makeArray(n) 
{
	this.length = n;
	return this;
}
//
// global declarations and initialization
//
function init(visibleYr, MonthName) 
{
	visibleYear		= visibleYr;
	//selDate			= eval("document.forms[" + formNum + "]." + dateFld + ".value");
	//selMonth		= eval("document.forms[" + formNum + "]." + monthFld + ".value");
	//selYear			= eval("document.forms[" + formNum + "]." + yearFld + ".value");
	selDate			= eval("document." + formName + "." + dateFld + ".value");
	selMonth		= eval("document." + formName + "." + monthFld + ".value");
	selYear			= eval("document." + formName + "." + yearFld + ".value");
	if (!visibleYr)
		selYear		= CalcTheYearByMonthDay(selYear, selMonth-1, selDate);
	theDate         = new Date(selYear, selMonth-1, 1);
	today			= new Date();
	if (selYear == 0)
		theDate = today;
	msPerDay        = 24*60*60*1000;
	dispMonth		= selMonth;
	 
	monthName = new makeArray(12);
	eval(MonthName);
}
//
// entry point
//
function openCalendar(monthFldName, dateFldName, yearFldName, frmName, theMinYear, theMaxYear, startOrEndFld, servTypeFld, monthNames, startOnSundayFld) 
{
	startOnSunday = startOnSundayFld;
	if (frmName == "" || frmName == 0)
		formName = "form";
	else
		formName = frmName;
	monthFld = monthFldName;
	dateFld	= dateFldName;
	yearFld = yearFldName;
	minYear	= theMinYear;
	maxYear	= theMaxYear;
	startOrEnd = startOrEndFld;
	servType = servTypeFld;
	allowSelectPast = false;
	init(false, monthNames);
	windowOptions  = "toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=yes,width=200,height=220";
	calendarWindow = this.open("","calendarWindow",windowOptions);
	calendarWindow.callingForm = this;
	redraw();
	if (window.event) window.event.returnValue = false;
}
//
// entry point
//
function openCalendarWithYear(monthFldName, dateFldName, yearFldName, frmName, theMinYear, theMaxYear, startOrEndFld, servTypeFld, allowSelPast, monthNames, startOnSundayFld)
{
	startOnSunday = startOnSundayFld
	if (frmName == "" || frmName == 0)
		formName = "form";
	else
		formName = frmName;
	monthFld = monthFldName;
	dateFld	= dateFldName;
	yearFld = yearFldName;
	var now = new Date();
	minYear	= theMinYear;
	maxYear	= theMaxYear;
	startOrEnd = startOrEndFld;
	servType = servTypeFld;
	allowSelectPast = allowSelPast;
	init(true, monthNames);
	windowOptions  = "toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=yes,width=200,height=220";
	calendarWindow = this.open("","calendarWindow",windowOptions);
	calendarWindow.callingForm = this;
	redraw();
	if (window.event) window.event.returnValue = false;
}
//
// repaint the calendar
//
function redraw() 
{
	calendarWindow.callingForm = this;
	var firstOfMonth = new Date(theDate.getFullYear(),theDate.getMonth(),1);
	calendarWindow.document.open();
	calTitle = "<TITLE>Calendar</TITLE>";
	calendarWindow.document.write(calTitle);
	drawCalendar(firstOfMonth);
	calendarWindow.document.write(htmlBuffer);
	calendarWindow.document.close();
	calendarWindow.callingForm = this;
	calendarWindow.focus();
}
//
// fill the calling forms date and month
//
function fillDate(filler) 
{
	var d = filler;
	var m = theDate.getMonth();
	var y = theDate.getFullYear();
	if (!visibleYear)
		y = CalcTheYearByMonthDay(y, m, d);
	//eval("document.forms[" + formNum + "]." + monthFld + ".selectedIndex=" + (m+1));
	//eval("document.forms[" + formNum + "]." + dateFld  + ".selectedIndex=" + d);
	//eval("document.forms[" + formNum + "]." + yearFld  + ".selectedIndex=" + (y-minYear+1));	
	eval("document." + formName + "." + monthFld + ".selectedIndex=" + (m+1));
	eval("document." + formName + "." + dateFld  + ".selectedIndex=" + d);
	eval("document." + formName + "." + yearFld  + ".selectedIndex=" + (y-minYear+1));	
	eval("updateDaysDesc()");
	if (startOrEnd == "Start")
		OnNumDaysChange(servType);
	else if (startOrEnd == "End")
		OnEndDateChange(servType);
	if (calendarWindow.callingForm.OnCalendarChange)
		calendarWindow.callingForm.OnCalendarChange();
	if(calendarWindow.callingForm.UpdateNewMonthYearCombo)
	{
		//alert("found UpdateNewMonthYearCombo");
		var TmpStr	=	new String();
		TmpStr		=	monthFld;
		
		//alert(TmpStr);
		
		if(TmpStr.substr(0,3) == "end")
		{
			//alert(TmpStr.substr(0,3));
			UpdateNewMonthYearCombo('end_dt_yr','end_dt_mn','SelectEndMonthYear');
			if(calendarWindow.callingForm.SyncAllCombos)
			{
				SyncAllCombos();
				
			}
			
		}
		else if(TmpStr.substr(0,3) == "htl" || TmpStr.substr(0,3) == "car")
		{
			var TmpArray = TmpStr.split("_");
			SyncAllCombosComplex(TmpArray[0]+'_'+ TmpArray[1]+'_dt_yr' ,TmpArray[0]+'_'+ TmpArray[1]+'_dt_mn' ,TmpArray[0]+'_'+ TmpArray[1]+'_dt_dy' ,TmpArray[0] + '_Select'+ TmpArray[1] + 'MonthYear' ,TmpArray[0] + '_Select'+ TmpArray[1] + 'Day');
		
		}		
		else if(TmpStr.substr(0,3) == "sta" && !(TmpStr.substr(TmpStr.lastIndexOf("_")+1) == "mn0"))
		{
			
			var IndexStr	= new String();
			IndexStr	= TmpStr.substr(TmpStr.lastIndexOf("_")+1)	;
			IndexStr	=	IndexStr.substr(2);
		
			
			if(calendarWindow.callingForm.document.getElementById("SelectStartMonthYear_" + IndexStr))
			{
				
				//alert(calendarWindow.callingForm.document.getElementById("SelectStartMonthYear_" + IndexStr));
				SyncAllCombosComplex('start_dt_yr'+ IndexStr,'start_dt_mn'+ IndexStr,'start_dt_dy'+ IndexStr,'SelectStartMonthYear_'+IndexStr,'SelectStartDay_'+IndexStr)
				//UpdateNewMonthYearCombo('start_dt_yr'+ IndexStr,'start_dt_mn'+IndexStr,'SelectStartMonthYear_'+IndexStr);
			}
			else
			{
				
				//alert(calendarWindow.callingForm.document.getElementById("SelectStartMonthYear_" + IndexStr));
				UpdateNewMonthYearCombo('start_dt_yr','start_dt_mn','SelectStartMonthYear');
			}
		
			if(calendarWindow.callingForm.SyncAllCombos)
			{
				SyncAllCombos();
				
			}
			
			updateDaysDesc();
		}
		else if(TmpStr.substr(0,3) == "dep" && isNaN(TmpStr.substr(TmpStr.length-1)))
		{
			
			UpdateNewMonthYearCombo('dep_dt_yr','dep_dt_mn','SelectEndMonthYear');
			AutoSelectOldDayCombo('dep_dt_dy','SelectStartDay');
			
		}
		else if(!isNaN(TmpStr.substr(TmpStr.length-1)))
		{
			
			var TmpArray = TmpStr.split("_");
			//TmpArray[3]	is the number of the combo box - if multiple instances have been created
		
			if(calendarWindow.callingForm.SyncAllCombosComplex)
			{
				
				if(calendarWindow.callingForm.document.getElementById("SelectStartDay_0") && !isNaN(TmpArray[3]))
				{
					
					UpdateNewMonthYearCombo(TmpArray[0]+'_dt_yr_' + TmpArray[3],TmpArray[0]+'_dt_mn_' + TmpArray[3],'SelectStartMonthYear_'+TmpArray[3]);
					SyncAllCombosComplex(TmpArray[0]+'_dt_yr_' + TmpArray[3],TmpArray[0]+'_dt_mn_' + TmpArray[3],TmpArray[0]+'_dt_dy_' + TmpArray[3],'SelectStartMonthYear_' + TmpArray[3],'SelectStartDay_' + TmpArray[3]);	
					
					
					//OnStartDateChange(IDS_SERVTYPE_FLIGHT, segmentCount);
					// OnNumDaysChangeGeneral(IDS_SERVTYPE_FLIGHT," & GetConfigServTypeTime("FLIGHT", "startTime") & "," & GetConfigServTypeTime("FLIGHT", "endTime") &", " &" form.dep_dt_yr_" & i & ".value, form.dep_dt_mn_" & i &".value, form.dep_dt_dy_"& i &".value, form.dep_dt_yr_" & i+1 &", form.dep_dt_mn_" & i+1 &", form.dep_dt_dy_" & i+1 &");updateDaysDesc()" %>
					
					if(calendarWindow.callingForm.document.getElementById("numDays"))
					{
						
						//alert();
						if(TmpArray[3] == 0)
						{
							StartOrEnd	=	"Start";
						}
						else if(TmpArray[3] == 1)
						{
							StartOrEnd	=	"End";
						}
						calendarWindow.callingForm.UpdateDateFromCalendar(StartOrEnd);
						
						
					}
				}
				else if(isNaN(TmpArray[3]))
				{
					var ObjIndex	=	new String();
					ObjIndex	= TmpArray[2];
					ObjIndex	= ObjIndex.substr(2);
					//alert(TmpArray[0]+'_dt_yr'+ObjIndex+","+TmpArray[0]+'_dt_mn'+ObjIndex+","+TmpArray[0]+'_dt_dy'+ObjIndex+","+'SelectStartMonthYear_' + ObjIndex+","+'SelectStartDay_' + ObjIndex);
				
					UpdateNewMonthYearCombo(TmpArray[0]+'_dt_'+TmpArray[2],TmpArray[0]+'_dt_'+TmpArray[2],'SelectStartMonthYear_'+ObjIndex);
					//AutoSelectOldDayCombo(TmpArray[0]+'_dt_'+TmpArray[2],'SelectStartDay_'+ ObjIndex);
					SyncAllCombosComplex(TmpArray[0]+'_dt_yr' + ObjIndex,TmpArray[0]+'_dt_mn' + ObjIndex,TmpArray[0]+'_dt_dy' + ObjIndex,'SelectStartMonthYear_' + ObjIndex,'SelectStartDay_' + ObjIndex);	
			
				}				
				else
				{
					//alert("doesnt exist");
					if(TmpArray[3] == 2 )
					{
						UpdateNewMonthYearCombo(TmpArray[0]+'_dt_yr_' + TmpArray[3],TmpArray[0]+'_dt_mn_' + TmpArray[3],'SelectEndMonthYear');
						SyncAllCombosComplex(TmpArray[0]+'_dt_yr_' + TmpArray[3],TmpArray[0]+'_dt_mn_' + TmpArray[3],TmpArray[0]+'_dt_dy_' + TmpArray[3],'SelectEndMonthYear','SelectEndDay');	
	
					}
					else if(TmpArray[3] == 1)
					{
						//alert("mashehu");
						UpdateNewMonthYearCombo(TmpArray[0]+'_dt_yr_' + TmpArray[3],TmpArray[0]+'_dt_mn_' + TmpArray[3],'SelectStartMonthYear');
						SyncAllCombosComplex(TmpArray[0]+'_dt_yr_' + TmpArray[3],TmpArray[0]+'_dt_mn_' + TmpArray[3],TmpArray[0]+'_dt_dy_' + TmpArray[3],'SelectStartMonthYear','SelectStartDay');	
					
					}
					
				}
				
			}
			
			
		}
		else if(TmpStr.substr(0,6) == "cheque") 
		{
			UpdateNewMonthYearCombo('cheque_value_dt_yr','cheque_value_dt_mn','cheque_SelectStartMonthYear');
			SyncAllCombos();
		}
		else if(TmpStr.substr(0,5) == "trans") 
		{
			UpdateNewMonthYearCombo('trans_value_dt_yr','trans_value_dt_mn','trans_SelectStartMonthYear');
			SyncAllCombos();
		}
	}
	
	calendarWindow.close();
}
//
// set the month
//
function changeMonth (increment) 
{
	var dispMonth = theDate.getMonth();
	var dispYear = theDate.getFullYear();
	var saveMonth = dispMonth;
	var saveYear = dispYear;
	if (increment == 1)
		dispMonth++ ;
	else 
		dispMonth-- ;
	if (dispMonth > 11) {
		dispMonth = 0;
		dispYear++;
	}	
	else if (dispMonth < 0) {
		dispMonth = 11;
		dispYear--;
	}
	var validDate = true;
	if (dispYear < minYear) {
		dispYear = minYear;
		validDate = false;
	}	
	if (dispYear > maxYear) {
		dispYear = maxYear;
		validDate = false;
	}	
	if (validDate) {
		theDate = new Date(dispYear, dispMonth, 1);
		redraw();
	}
	else {
		dispMonth = saveMonth;
		dispYear = saveYear;
	}	
}
//
// generate the calendar document
//
function drawCalendar (theDate) 
{
	monthNum = theDate.getMonth() + 1;
	htmlBuffer  = "<HTML>";
	htmlBuffer += "<HEAD>";
	//alert(monthName[''+monthNum]);

    htmlBuffer += "<link REL='STYLESHEET' TYPE='text/css' HREF='" + jsPath + "'>";
	htmlBuffer += "</HEAD>";
	htmlBuffer += "<BODY BGCOLOR=#FFFFFF>";
	htmlBuffer += "<FORM>";
	htmlBuffer += "<TABLE ALIGN=CENTER CELLSPACING=1 CELLPADDING=1  border=0>";
	htmlBuffer += "<tr><TD VALIGN=TOP>";
	htmlBuffer += "<A HREF='' onClick='callingForm.changeMonth(-1);return false;'>" + "<<" + "</A>";
	htmlBuffer += "</TD><TD  class='calendar-table'>";
	htmlBuffer += "<TABLE ALIGN=CENTER BORDER=0 CELLSPACING=2 CELLPADDING=2 WIDTH='100%' class='calendar-table' height=100%>";
	htmlBuffer += "<tr><Td COLSPAN=7 class=calend-bg-td>";
	htmlBuffer += monthName[monthNum];
	htmlBuffer += " " + theDate.getFullYear();
	htmlBuffer += "</td></tr><TR  class=calend-bg-td>";
	if (startOnSunday == "True")
		htmlBuffer += "<Td class=calend-bg-td>S</td><Td class=calend-bg-td>M</td><Td class=calend-bg-td>T</td><Td class=calend-bg-td>W</td><Td class=calend-bg-td>T</td><Td class=calend-bg-td>F</td><Td class=calend-bg-td>S</td></TR>";
	else
		htmlBuffer += "<Td class=calend-bg-td>M</td><Td class=calend-bg-td>T</td><Td class=calend-bg-td>W</td><Td class=calend-bg-td>T</td><Td class=calend-bg-td>F</td><Td class=calend-bg-td>S</td><Td class=calend-bg-td>S</td></TR>";	
	drawBody(theDate);
	htmlBuffer += "</tr></TABLE>";
	htmlBuffer += "</TD><TD VALIGN=TOP>";
	htmlBuffer += "<A HREF='#' onClick='callingForm.changeMonth(1);return false;'>" + ">>" + "</A>";
	htmlBuffer += "</TD></tr>";
	htmlBuffer += "</TABLE>";
	htmlBuffer += "</BODY></HTML>";
}
//
// generate the calendar body
//
function drawBody (theDate) 
{
	thisMonth = theDate.getMonth();
	thisDate  = theDate.getDate();
	if (startOnSunday == "True")
		firstSunday(theDate);
	else
		firstMonday(theDate);	
	for (w=0; w<6; w++) {
		for (d=0; d<7; d++) {
			date = theDate.getDate();
			htmlBuffer   += "<TD ALIGN=CENTER bgcolor=white>";
			// skip previous month
			if (theDate.getMonth() != thisMonth) {
				htmlBuffer += "<BR>";
			} else {
				htmlBuffer += "<A HREF='#' class='calend-days'";
				if (theDate.getDate() == today.getDate() &&
				    theDate.getMonth() == today.getMonth()&&
				    theDate.getFullYear() == today.getFullYear()) {
					htmlBuffer += " style='{color:Red}' ";
					htmlBuffer += " onClick='callingForm.fillDate(" + date + ");return false;'";
				}
				else if (theDate.valueOf() < today.valueOf() && !allowSelectPast)  {
					htmlBuffer += " style='{text-decoration:line-through}'";
					htmlBuffer += " onmouseover='style.cursor=\"default\"'";
				}
				else
					htmlBuffer += " onClick='callingForm.fillDate(" + date + ");return false;'";
				htmlBuffer += ">";
				htmlBuffer += date;
				htmlBuffer += "</A>";
			}
			// increment the date
			theDate.setDate(theDate.getDate()+1);
		}
		htmlBuffer += "<TR bgcolor=white>";
	}
	htmlBuffer += "</FORM>";
}
//
// reset the startdate to get the
// previous sunday before the current date
// so that the drawing can begin from a sunday
//
function firstSunday (fromDate) 
{
	while (fromDate.getDay() != 0) {
		fromDate.setDate(fromDate.getDate()-1);
	}
}

//The same as firstSunday fbut finds the first Monday
function firstMonday (fromDate) 
{
	while (fromDate.getDay() != 1) {
		fromDate.setDate(fromDate.getDate()-1);
	}
}


//
// take day and month and return year for month+day comboboxes (no year combo)
// if the month+day is in the past, assume next year, else current year.
//
function CalcTheYearByMonthDay(year, month, day)
{
	var now = new Date();
	if (((now.getMonth() > month) || (now.getMonth() == month && now.getDate() > day)) && now.getFullYear() >= year) {
		year = now.getFullYear();	
		year++;
	}		
	return year;
}

//The function appearing after this one is a more general version of this function. 
function OnEndDateChange(servType)
{
	if (form.numDays) {
		var dd,mm,yy;
		var start_dt, end_dt, start_tm, end_tm;
		yy = form.start_dt_yr.value;
		mm = form.start_dt_mn.value;
		dd = form.start_dt_dy.value;
		yy = CalcTheYearByMonthDay(yy, mm, dd)
		start_dt = new Date(yy,mm-1,dd);
		yy = form.end_dt_yr.value;
		mm = form.end_dt_mn.value;
		dd = form.end_dt_dy.value;
		yy = CalcTheYearByMonthDay(yy, mm, dd)
		end_dt = new Date(yy,mm-1,dd);
		var	msPerDay = 24*60*60*1000;
		var numDays = Math.round((end_dt - start_dt) / msPerDay);
		//In car rent take acctual pickup & drop off time
		switch (servType) {
			case IDS_SERVTYPE_CARRNT :
				start_tm = form.dep_tm.value;
				end_tm   = form.arr_tm.value;				
				break;
			default:
				start_tm = startTime;
				end_tm   = endTime;
				break;
		}
		numDays += ExtraDays(servType, start_tm, end_tm, start_dt, end_dt);
		form.numDays.value = numDays;
	}
}

/*
General function to set the difference value between the start and end dates.
This function should be called when the end date is changed.
servType - the type of the service (like : IDS_SERVTYPE_FLIGHT)
startTime, endTime - Values got from the vb function GetConfigServTypeTime
start_yy, start_mn, start_dy - values of start year, month, day
end_yy, end_mn, end_dy - values of end year, month, day
res - reference to the updated combo box
*/
function setNumDaysChange(servType, startTime, endTime,start_yy, start_mn, start_dy, end_yy, end_mn, end_dy, res)
{
	var start_dt, end_dt,res_dt;
	var d = new Date();
	start_dt = new Date(start_yy,start_mn-1,start_dy,d.getUTCHours(),d.getUTCMinutes(),d.getUTCMilliseconds());
	end_dt = new Date(end_yy,end_mn-1,end_dy,d.getUTCHours(),d.getUTCMinutes(),d.getUTCMilliseconds());
	
	var	msPerDay = 24*60*60*1000;
	var numDays = Math.round((end_dt - start_dt) / msPerDay);
	numDays += ExtraDays(servType, startTime, endTime, start_dt, end_dt);
	res.value = numDays;
}

//The function appearing after this one is a more general version of this function. 
//dontAutoCalcYear - set this optional var to true if you dont want to call the function
//CalcTheYearByMonthDay (if no parameter is passed it's value is undefined and the 
//CalcTheYearByMonthDay function is executed)
function OnNumDaysChange(servType, dontAutoCalcYear)
{
	if (form == null || form.start_dt_yr == null) //prevent run time error - happens when there is session timeout
		return false;
	var numDays = 1;	// Default 1 day
	var dd,mm,yy, rc;
	var start_dt, end_dt;
	var startTime = 0, endTime = 0;  //Has no affect since we want the start or end date only without relative ref to the service
	yy = form.start_dt_yr.value;
	if (!dontAutoCalcYear)
		yy = CalcTheYearByMonthDay(yy, mm, dd);
	mm = form.start_dt_mn.value;
	dd = form.start_dt_dy.value;
	var d = new Date();
	start_dt = new Date(yy,mm-1,dd,d.getUTCHours(),d.getUTCMinutes(),d.getUTCMilliseconds());
	var	msPerDay = 24*60*60*1000;
	if (form.numDays) {
		if (form.numDays.value == "") {
			yy = form.end_dt_yr.value;
			if (!dontAutoCalcYear)
				yy = CalcTheYearByMonthDay(yy, mm, dd);
			mm = form.end_dt_mn.value;
			dd = form.end_dt_dy.value;
			end_dt = new Date(yy,mm-1,dd,d.getUTCHours(),d.getUTCMinutes(),d.getUTCMilliseconds());
			numDays = (end_dt.valueOf()-start_dt.valueOf())/msPerDay;
			if (numDays <= form.numDays.length)
				form.numDays.value = numDays;				
			else
				return false;
		}
		else
			numDays = parseInt(form.numDays.value,10);
	}
	if(servType == IDS_SERVTYPE_CARRNT)
	{		
		startTime = form.dep_tm.value;
		endTime   = form.arr_tm.value;
	}
	end_dt = new Date(start_dt.getTime() + msPerDay * (numDays-ExtraDays(servType, startTime, endTime, start_dt, end_dt)));
	rc = SetSaveComboIndex(form.end_dt_yr, end_dt.getFullYear()-startYear+1); 
	if (rc) 
		rc = SetSaveComboIndex(form.end_dt_mn, end_dt.getMonth()+1); 
	if (rc)
		rc = SetSaveComboIndex(form.end_dt_dy, end_dt.getDate()); 				
	if (rc)
		eval("updateDaysDesc()");
}

//The selected index will be set only if it there is an item to set it to it.
function SetSaveComboIndex(combo, newSelectedIndex)
{
	if (combo.length < newSelectedIndex) {
		return false;
	}

	combo.selectedIndex = newSelectedIndex;
	return true;
}

function OnNumDaysChangeGeneral(servType, startTime, endTime, yy , mm, dd, res_yy, res_mn, res_dy,dontAutoCalcYear)
{
	if (form.numDays) {
		var dd,mm,yy;
		var start_dt, end_dt;
		
		if (!dontAutoCalcYear)
			yy = CalcTheYearByMonthDay(yy, mm, dd);
		var d = new Date();
		start_dt = new Date(yy,mm-1,dd,d.getUTCHours(),d.getUTCMinutes(),d.getUTCMilliseconds());
		var	msPerDay = 24*60*60*1000;
		end_dt = new Date(start_dt.getTime() + msPerDay * (parseInt(form.numDays.value,10)-ExtraDays(servType, startTime, endTime, start_dt, end_dt)));
		res_yy.selectedIndex = (end_dt.getFullYear()-startYear+1);
		res_mn.selectedIndex = (end_dt.getMonth()+1);
		res_dy.selectedIndex = end_dt.getDate();
		updateDaysDesc();
	}
}

function OnStartDateChange(servType, segmentCount)
{
	var dd,mm,yy;
	var start_dt,end_dt;
	
	switch (servType)	{
		case IDS_SERVTYPE_FLIGHT:
		case IDS_SERVTYPE_FERRY:
		case IDS_SERVTYPE_TRAIN:
		case IDS_SERVTYPE_TRANSFER_ALLOC:
		{	
			if (segmentCount.value==2)	{		
				yy = form.dep_dt_yr_0.value;
				mm = form.dep_dt_mn_0.value;
				dd = form.dep_dt_dy_0.value;
				yy = CalcTheYearByMonthDay(yy, mm, dd)
				start_dt = new Date(yy,mm-1,dd);
				var	msPerDay = 24*60*60*1000;
				end_dt = new Date(start_dt.getTime() + msPerDay * 1);
				form.dep_dt_yr_1.selectedIndex = (end_dt.getFullYear()-startYear+1);
				form.dep_dt_mn_1.selectedIndex = (end_dt.getMonth()+1);
				form.dep_dt_dy_1.selectedIndex = end_dt.getDate();
			}
			break;
		}		
		case IDS_SERVTYPE_CRUISE:		
		{
			
			yy = form.start_dt_yr.value;
			mm = form.start_dt_mn.value;
			dd = form.start_dt_dy.value;
			yy = CalcTheYearByMonthDay(yy, mm, dd)
			
			form.end_dt_yr.value = yy;
			form.end_dt_mn.selectedIndex = mm;
			form.end_dt_dy.selectedIndex = dd;
			break;
		}
	}
}

//function to return the day's number according to a specific date
function getDayDesc(year, month, day)
{
	var date = new Date(year, month-1 , day);
	return date.getDay();
}

//update end day
function updateEndDay(YrMnCombo1,YrMnCombo2,DayCombo1,DayCombo2)

{
	if ((document.getElementById(DayCombo2).selectedIndex < document.getElementById(DayCombo1).selectedIndex) && (document.getElementById(YrMnCombo2).selectedIndex == document.getElementById(YrMnCombo1).selectedIndex))
	{
		document.getElementById(DayCombo2).selectedIndex=document.getElementById(DayCombo1).selectedIndex;
		AutoSelectOldDayCombo('dep_dt_dy_1',DayCombo2);
		//document.getElementById('dep_dt_dy_1').selectedIndex=document.getElementById(DayCombo1).selectedIndex;
	}
	
}
