
function callMe()
		{
			var dDate;
			var iYear;
			var iMonth;
			var iDay;

			dDate = new Date();
			iDay = dDate.getDate();
			iMonth = dDate.getMonth();
			iYear = dDate.getFullYear();

			for(var i=0;i<=document.frmBook.checkInDate.length-1; i++)
			{
				if(document.frmBook.checkInDate[i].value == iDay)
				{
					document.frmBook.checkInDate[i].selected=true;
				}
			}

			for(var i=0;i<=document.frmBook.checkInMonth.length-1; i++)
			{
				if(document.frmBook.checkInMonth[i].value == iMonth + 1)
				{
					document.frmBook.checkInMonth[i].selected=true;
				}
			}

			for(var i=0;i<=document.frmBook.checkInYear.length-1; i++)
			{
				if(document.frmBook.checkInYear[i].value == iYear)
				{
					document.frmBook.checkInYear[i].selected=true;
				}
			}

		}


function init(){

var sysdate = new Date();
//alert("System Date ------- "+ sysdate);
var date = sysdate.getDate();
var month = sysdate.getMonth();
var year = sysdate.getFullYear();

//alert("date === "+date +"Month ======== "+ month +"Year ======= "+ year);
document.frmBook.checkInDate.value=date;
document.frmBook.checkInMonth.value=month+1;
document.frmBook.checkInYear.value=year;
}


function openWin(URL)
		{
			aWindow=window.open(URL, "terms", "top=20,left=20,toolbar=no,width=520,height=400,status=no,scrollbars=yes,resize=no,menubar=no");
		}

		function getTerms()
		{
			var s = checkDate(document.frmBook);
			if (s)
			{
				var sDate ;
				var nNights ;
				sDate = document.frmBook.ArrivalDay.options[document.frmBook.ArrivalDay.selectedIndex].value + '/'+
							 document.frmBook.ArrivalMonth.options[document.frmBook.ArrivalMonth.selectedIndex].value + '/' +
							 document.frmBook.ArrivalYear.options[document.frmBook.ArrivalYear.selectedIndex].value;

				nNights = document.frmBook.Nights.options[document.frmBook.Nights.selectedIndex].value;
				openWin("terms.asp?date=" + sDate + "&nNights=" + nNights);
			}
		}

		function checkDate(frm)
		{
				var dDate;
				var iYear;
				var iMonth;
				var iDay;
				var aMonthDays = [ 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ];

				dDate = new Date();
				iDay = dDate.getDate();
				iMonth = dDate.getMonth();
				iYear = dDate.getFullYear();

				// now, check if the year is OK
				if ( frm.ArrivalYear.options[frm.ArrivalYear.selectedIndex].value == iYear)
				{
					if ( frm.ArrivalMonth.options[frm.ArrivalMonth.selectedIndex].value < iMonth + 1)
					{
						alert( "Please select the Arrival Date greater than or equal to Today.");
						return false;
					}
					else if ( frm.ArrivalMonth.options[frm.ArrivalMonth.selectedIndex].value == iMonth + 1)
					{
						if ( frm.ArrivalDay.options[frm.ArrivalDay.selectedIndex].value < iDay)
						{
							alert( "Please select the Arrival Date greater than or equal to Today.");
							return false;
						}
					}
				}

				// check that the upper date limit is OK
				if ( frm.ArrivalMonth.options[frm.ArrivalMonth.selectedIndex].value != 2)
				{
					if (frm.ArrivalDay.options[frm.ArrivalDay.selectedIndex].value > aMonthDays[ frm.ArrivalMonth.options[frm.ArrivalMonth.selectedIndex].value])
					{
						alert( "Please select an Valid Date of the selected Month.");
						return false;
					}
				}

				// check the date in february is correct
				if ( frm.ArrivalMonth.options[frm.ArrivalMonth.selectedIndex].value == 2)
				{
					if (frm.ArrivalDay.options[frm.ArrivalDay.selectedIndex].value > daysInFebruary( frm.ArrivalYear.options[frm.ArrivalYear.selectedIndex].value))
					{
						alert( "Please select an Valid Date in month of February.");
						return false;
					}
				}
			return true;
		}


		function validate(frm)
		{
			var s = checkDate(frm);
			if (!s)
			{
				return s;
			}

			if ( parseInt(frm.Rooms.options[frm.Rooms.selectedIndex].value) > parseInt(frm.Adults.options[frm.Adults.selectedIndex].value) )
			{
				alert("There should be one Adult Per Room.");
				frm.Adults.focus();
				return false;
			}
		}

		function daysInFebruary (year)
		{
			// February has 29 days in any year evenly divisible by four,
		  // EXCEPT for centurial years which are not also divisible by 400.
		  return (  ((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0) ) ) ? 29 : 28 );

		}
