
//This function will Reload the MonthYear fields and the days fields
	function LoadDates(thefield, ddlDepartureMonthYear, ddlDepartureDay, ddlReturnMonthYear, ddlReturnDay)
	{
		switch(thefield)
		{
			case "ddlDepartureMonthYear":
				//if (window.document.frmBookNow.Dept_MonthYear.selectedIndex == -1)
				if (ddlDepartureMonthYear.selectedIndex == -1)
				{	
					//LoadDays(window.document.frmBookNow.Dept_Day, window.document.frmBookNow.Dept_MonthYear.options[1].value);
					LoadDays(ddlDepartureDay, ddlDepartureMonthYear.options[1].value);
					if (ddlDepartureDay.value> ddlReturnDay.value)
					{
						ddlReturnDay.value=ddlDepartureDay.value
					}
				}
				else
				{
					//LoadDays(window.document.frmBookNow.Dept_Day, window.document.frmBookNow.Dept_MonthYear.options[window.document.frmBookNow.Dept_MonthYear.selectedIndex].value);  //window.document.frmBookNow.Dept_Year.selectedIndex
					LoadDays(ddlDepartureDay, ddlDepartureMonthYear.options[ddlDepartureMonthYear.selectedIndex].value);  //window.document.frmBookNow.Dept_Year.selectedIndex
					if (ddlDepartureDay.value> ddlReturnDay.value)
					{
						ddlReturnDay.value=ddlDepartureDay.value
					}
				}
				//if (window.document.frmBookNow.Rtrn_MonthYear.selectedIndex<window.document.frmBookNow.Dept_MonthYear.selectedIndex)
				if (ddlReturnMonthYear.selectedIndex < ddlDepartureMonthYear.selectedIndex)
				{
					//Reset RMY
					//window.document.frmBookNow.Rtrn_MonthYear.selectedIndex = window.document.frmBookNow.Dept_MonthYear.selectedIndex;
					ddlReturnMonthYear.selectedIndex = ddlDepartureMonthYear.selectedIndex;
					//Reset RD
					//if (window.document.frmBookNow.Rtrn_MonthYear.selectedIndex == -1){
					if (ddlReturnMonthYear.selectedIndex == -1){
						//LoadDays(window.document.frmBookNow.Rtrn_Day, window.document.frmBookNow.Rtrn_MonthYear.options[1].value);
						LoadDays(ddlReturnDay, ddlReturnMonthYear.options[1].value);
					}
					else
					{	
						//LoadDays(window.document.frmBookNow.Rtrn_Day, window.document.frmBookNow.Rtrn_MonthYear.options[window.document.frmBookNow.Rtrn_MonthYear.selectedIndex].value);
						LoadDays(ddlReturnDay, ddlReturnMonthYear.options[ddlReturnMonthYear.selectedIndex].value);
					}				
				}
				break;
			case "ddlReturnMonthYear":
				//if (window.document.frmBookNow.Rtrn_MonthYear.selectedIndex == -1){
				if (ddlReturnMonthYear.selectedIndex == -1){
					//LoadDays(window.document.frmBookNow.Rtrn_Day, window.document.frmBookNow.Rtrn_MonthYear.options[1].value);
					LoadDays(ddlReturnDay, ddlReturnMonthYear.options[1].value);
				}
				else{	
					//LoadDays(window.document.frmBookNow.Rtrn_Day, window.document.frmBookNow.Rtrn_MonthYear.options[window.document.frmBookNow.Rtrn_MonthYear.selectedIndex].value);
					LoadDays(ddlReturnDay, ddlReturnMonthYear.options[ddlReturnMonthYear.selectedIndex].value);
				}
				break;
		}		
	}
			
	//Days function
	function LoadDays(myDay, myMonthYear)
	{
		var today = new Date();
		var theYear = myMonthYear.substr(3,4);
		var theMonth = myMonthYear.substr(0,2);
		var howMany = getDaysInMonth(theMonth, theYear);
		var DaysIndex	= eval(myDay.selectedIndex);
		//var Days = myDay.options[ DaysIndex ].value;
		var usrDay = '';
		if (usrDay <= ' ') usrDay = today.getDate();
		// clean drop down
		myDay.length = 0
		// if (myMonth.name == "fbnOutMonth" )
		{
			for (var i = 1; i <= howMany; i+=1)
			{
				// enter date number
				myDay.length += 1
				myDay.options[(myDay.length - 1)].text = i;
				if (i<10)
				{
					myDay.options[(myDay.length - 1)].value = '0' + i;
				}
				else
				{
					myDay.options[(myDay.length - 1)].value = i;
				}
		
			}
			
			if (DaysIndex >= myDay.length)
			{
				myDay.selectedIndex =0;
			}
			else
			{
				myDay.selectedIndex = DaysIndex;
			}
		
		}
		
	}
	
	// number of days in the month
	function getDaysInMonth(month,year)
	{
		var days;
		if (month==1 || month==3 || month==5 || month==7 || month==8 || month==10 || month==12)  days=31;
		else if (month==4 || month==6 || month==9 || month==11) days=30;
		else if (month==2)
		{
			if (isLeapYear(year))
			{
				days=29;
			}
			else
			{
				days=28;
			}
		}
		return (days);
	}

	function isLeapYear (Year)
	{
		if (((Year % 4)==0) && ((Year % 100)!=0) || ((Year % 400)==0))
		{
			return (true);
		}
		else
		{
			return (false);
		}
	}


	<!--//

	function CheckParams(pM,opt,rbRoundTrip,ddlDepartureMonthYear,ddlDepartureDay,ddlReturnMonthYear,ddlReturnDay,ddlDepartureCity,ddlArrivalCity)
	{
	//alert ("Inside CheckParams");
	//alert (ddlPassengerCount.selectedIndex);
	var strMsg='';
	
		if (pM==0)
		{
			
			if ((ddlDepartureCity.selectedIndex == 0) && (ddlArrivalCity.selectedIndex != 0))
			{
				strMsg = "Please select your departure city." 
			}
			if ((ddlDepartureCity.selectedIndex != 0) && (ddlArrivalCity.selectedIndex == 0))
			{
				strMsg = "Please select your arrival city."
			}
			if ((ddlDepartureCity.selectedIndex == 0) && (ddlArrivalCity.selectedIndex == 0))
			{
				strMsg = "Please select your departure and arrival cities."
			}
			if (opt == 0)
			{
			if (ddlDepartureMonthYear.selectedIndex == -1)
			{
				var ddDepartureMY = ddlDepartureMonthYear.options[1].value;
			}
			else
			{
				var ddDepartureMY = ddlDepartureMonthYear.options[ddlDepartureMonthYear.selectedIndex].value;  
			}
			if (ddlDepartureDay.selectedIndex == -1)
			{
				var ddDepartureDay = ddlDepartureDay.options[1].value;
			}
			else
			{
				var ddDepartureDay = ddlDepartureDay.options[ddlDepartureDay.selectedIndex].value;  
			}

			if (ddlReturnMonthYear.selectedIndex == -1)
			{
				var ddReturnMY = ddlReturnMonthYear.options[1].value;
			}
			else
			{
				var ddReturnMY = ddlReturnMonthYear.options[ddlReturnMonthYear.selectedIndex].value;  
			}
			
			if (ddlReturnDay.selectedIndex == -1)
			{
				var ddReturnDay = ddlReturnDay.options[1].value;
			}
			else
			{
				var ddReturnDay = ddlReturnDay.options[ddlReturnDay.selectedIndex].value;  
			}							
				var bGood = dateCompare(rbRoundTrip, ddDepartureMY, ddDepartureDay, ddReturnMY, ddReturnDay);
				//var bGood = true;
			}
			else
			{
				var bGood = true;
			}
		}
		else
		{
			var bGood = true;
		}
		if (bGood) 
		{
			if (strMsg.length == 0 )
			{
				if (window.document.forms[0].Manager.value=="bkgModManager")
					window.document.forms[0].action="welcome.aspx?pg=bkgmodmanager";
				else
					window.document.forms[0].action="welcome.aspx?pg=bkgmanager";
				//alert(ddlDepartureCity.value);
				window.document.forms[0].submit();							
			}
		}
		else
		{
			//alert("Your Return Date is before your Departure Date. Please check your Dates.");
			if (opt == 0)
			{
			strMsg =  strMsg + " Your arrival date is before your departure date. Please check your dates and try again.";
			}
			
			
		}
	
			if (strMsg.length != 0 )
			{
				alert( strMsg);
				return false;
			}	
	
	}
	
	//This function compare Departure Date Return Date
	function dateCompare(rbRoundTrip, ddlDepartureMonthYear, ddlDepartureDay, ddlArrivalMonthYear, ddlArrivalDay)
	{
		var bGood = true;
		//var frm = window.document.frmBookNow;
		var frm = window.document.forms[0];
		var dDay = ddlDepartureDay;
		var dMY = ddlDepartureMonthYear;
		var rDay = ddlArrivalDay;
		var rMY = ddlArrivalMonthYear;
		if(rbRoundTrip.checked)
		{
			//alert("Year check "+dMY.substr(3,4)+"<="+rMY.substr(3,4));
			if(dMY.substr(3,4)<=rMY.substr(3,4))
			{
				if (dMY.substr(3,4)==rMY.substr(3,4))
				{
					//alert("Month check "+dMY.substr(0,2)+"<="+rMY.substr(0,2));
					if(dMY.substr(0,2)<=rMY.substr(0,2))
					{
						//alert("1st step = "+dMY.substr(0,2)+"<="+rMY.substr(0,2));
						if(dMY.substr(0,2)==rMY.substr(0,2))
						{
							//alert("Day check "+dDay+"<="+rDay);
							//alert(eval(dDay)<=eval(rDay));
							if(eval(dDay)<=eval(rDay))
							{
								//alert("Final");
								bGood=true;
							}
							else
							{
								//alert("Final NO");
								bGood=false;
							}
						}
						else
						{
							//alert("Hi againe!");
							bGood=true;
						}
					}
					else
					{
						bGood= false;
					}
				}
				else
				{
					bGood= true;
				}
			}
			else
			{
				bGood= false;
			}
		//alert(bGood+" That is it.");
		}
		return bGood;
	}
	//?
	function DateSetter(seg)
	{
		if (seg == 1)
		{
			//var MY1 = window.document.forms['frmBookNow'].elements['Dept_MonthYear'].options[window.document.forms['frmBookNow'].elements['Dept_MonthYear'].selectedIndex].value;
			var MY1 = window.document.forms['frmBookNow'].elements['Dept_MonthYear'].options[window.document.forms['frmBookNow'].elements['Dept_MonthYear'].selectedIndex].value;
			//var DT1 = window.document.forms['frmBookNow'].elements['Dept_Day'].options[window.document.forms['frmBookNow'].elements['Dept_Day'].selectedIndex].value;
			var DT1 = window.document.forms['frmBookNow'].elements['Dept_Day'].options[window.document.forms['frmBookNow'].elements['Dept_Day'].selectedIndex].value;
		}
		else
		{
			//var MY1 = window.document.forms['frmBookNow'].elements['Rtrn_MonthYear'].options[window.document.forms['frmBookNow'].elements['Rtrn_MonthYear'].selectedIndex].value;
			var MY1 = window.document.forms['frmBookNow'].elements['Rtrn_MonthYear'].options[window.document.forms['frmBookNow'].elements['Rtrn_MonthYear'].selectedIndex].value;
			//var DT1 = window.document.forms['frmBookNow'].elements['Rtrn_Day'].options[window.document.forms['frmBookNow'].elements['Rtrn_Day'].selectedIndex].value;
			var DT1 = window.document.forms['frmBookNow'].elements['Rtrn_Day'].options[window.document.forms['frmBookNow'].elements['Rtrn_Day'].selectedIndex].value;
		}
		var dt = DT1+"/"+MY1.replace(". ","/");
		return dt;
	}
	//-->

	function EnableReturn(ddlArrivalMonthYear, ddlArrivalDay)
	{
		ddlArrivalMonthYear.disabled = false;
		ddlArrivalDay.disabled = false;
	}
	function DisableReturn(ddlArrivalMonthYear, ddlArrivalDay)
	{
		ddlArrivalMonthYear.options[0].selected = true;
		ddlArrivalMonthYear.disabled = true;
		ddlArrivalDay.options[0].selected = true;
		ddlArrivalDay.disabled = true;
	}