	function initStrValidate () {
	  txtWait = "Please wait while I validate your input value";
	  txtBadDate = "Your date is incorrect";
	  txtBadNNight = "Please re-enter the length of your stay";
	}
	function initStrCal () {
	  txtCalendar = "Calendar";
	  txtSelectDate = "Select a check-in date";
	  txtClose = "close";
	  	txtNext="Next";  
		txtPrevious="Previous";
		isSecure = 0;

	  monthName = new Array(12);
	  monthName[1] = "January";
	  monthName[2] = "February";
	  monthName[3] = "March";
	  monthName[4] = "April";
	  monthName[5] = "May";
	  monthName[6] = "June";
	  monthName[7] = "July";
	  monthName[8] = "August";
	  monthName[9] = "September";
	  monthName[10] = "October";
	  monthName[11] = "November";
	  monthName[12] = "December";

	  dayName = new Array(7);
	  dayName[1] = "Sun";
	  dayName[2] = "Mon";
	  dayName[3] = "Tue";
	  dayName[4] = "Wed";
	  dayName[5] = "Thu";
	  dayName[6] = "Fri";
	  dayName[7] = "Sat";
	}
	function isNumofnights(NN){
	  var digits="0123456789";
	  var s = NN.value;
	  var isaNumber = true;
	  var i = 0;
	  for(i=0;i<NN.value.length;i++)
	    if (digits.indexOf(s.charAt(i))==-1) {
	      isaNumber = false;
	      break;
	  }
	  if (s < 1) isaNumber = false;
	  return isaNumber;
	}
	function validate_form(Fsearch){
	  var dayIndex;
	  var monthIndex;
	  var yearIndex;
	  initStrValidate();
	  dayIndex = Fsearch.CD.selectedIndex;
	  monthIndex = Fsearch.CM.selectedIndex;
	  yearIndex = Fsearch.CY.selectedIndex;
	  window.status=txtWait;
	  if (dayIndex==0 || monthIndex==0 || yearIndex==0){
	    alert(txtBadDate);
	    if (dayIndex==0) Fsearch.CD.focus();
	    else if (monthIndex==0) Fsearch.CM.focus();
	    else Fsearch.CY.focus();
	    window.status="";
	    return false;
	  }
	  if (!isNumofnights(Fsearch.NN)){
	    alert(txtBadNNight);
	    Fsearch.NN.focus();
	    window.status="";
	    return false;
	  }
	  window.status="";
	  return true;
	}
	// Calendar global declarations and initialization
	function init () {
	    initStrCal();
	    today 	    = new Date();
	    currDay         = today.getDate();
	    currMonth       = today.getMonth();
	    currYear	    = today.getYear();
	    if (currYear < 1000) currYear += 1900;
	    today = new Date(currYear, currMonth, currDay);
	    nextYear	    = new Date(currYear, currMonth, currDay);
		nextYear.setDate (nextYear.getDate() + 365);

	    // Get the date that is selected on the pull down menus if any.
	    var d;
	    var m;
	    var y;
	    eval("d=document.forms['" + formName + "']." + dayFld  + ".selectedIndex");
	    eval("m=document.forms['" + formName + "']." + monthFld  + ".selectedIndex");
	    eval("y=document.forms['" + formName + "']." + yearFld  + ".selectedIndex");
	    if (d == 0 && m == 0 && y == 0) displayMonth = currMonth;
	    else {
		if (d == 0) d = 1;		// set defaults
		if (m == 0) m = 1;
		if (y == 0) y = currYear;
		else y = currYear + y - 1;	// translate year index */
		var tempDate = new Date (y, m - 1, d);
		if (tempDate.getTime() < today.getTime()) {
			tempDate.setDate(today.getDate());
		}
		else if (tempDate.getTime() >= nextYear.getTime()) {
			tempDate.setDate(nextYear.getDate() - 1);
		}
		displayMonth = tempDate.getMonth();
		var displayYear = tempDate.getYear();
		if (displayYear < 1000) displayYear += 1900;
		tempDate = new Date(displayYear, displayMonth + 1, 1);
		if (tempDate.getTime() >= nextYear.getTime()) {
			displayMonth -= 1;
		}
		if (displayYear > currYear) displayMonth += 12;
	    }
	}
		var calendarWinOpen = false;
		var calendarWindow = null;
		function openCalendarWin() {
	    var windowOptions  = "toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=yes,width=525,height=300";
	    calendarWindow = this.open("","calendarWindow",windowOptions);
	    calendarWindow.callingForm = this;    
	    calendarWinOpen = true;
	}
	function closeCalendarWindow() {
	    if (calendarWinOpen) {
	        calendarWinOpen = false;
	        calendarWindow.close();
	    }
	}
	// Calendar main entry point
	function popUpCalendar (dayFldName, monthFldName, yearFldName, formFldName) {
	    dayFld  = dayFldName;
	    monthFld = monthFldName;
	    yearFld = yearFldName;
	    formName  = formFldName;
	    init();
	    openCalendarWin();
	    redrawCalendar();
	}
	// repaint the calendar
	function redrawCalendar() {
	    calendarWindow.callingForm = this;
	    calendarWindow.document.open();
	    calendarTitle = "<TITLE>" + txtCalendar + "</TITLE>";
	    calendarWindow.document.write(calendarTitle);
	    var firstOfMonth = new Date(currYear, displayMonth, 1);
	    drawCalendar(firstOfMonth);
	    calendarWindow.document.write(htmlBuffer);
	    calendarWindow.document.close();
	    calendarWindow.callingForm = this;
	    calendarWindow.focus();
	}
	// fill the calling forms date and month
	function fillDate(returnDay, returnMonth, returnYear) {
	    var d = returnDay;
	    var m = returnMonth;
	    var y = returnYear;
	    eval("document.forms['" + formName + "']." + dayFld  + ".selectedIndex=" + d);
	    eval("document.forms['" + formName + "']." + monthFld + ".selectedIndex=" + m);
	    eval("document.forms['" + formName + "']." + yearFld + ".selectedIndex=" + y);
	    closeCalendarWindow();
	}
	// set the month
	function changeMonth (increment) {
	    var nextMonth = displayMonth;
	    if (increment == 1) nextMonth++ ;
	    else nextMonth-- ;
	    if ((nextMonth - currMonth >= 13) || (nextMonth < currMonth))  {
	        nextMonth = currMonth;
	    }
	    displayMonth = nextMonth;
	    redrawCalendar();
	}
	// generate the calendar document
	function drawCalendar (theDate) {
	    var y = theDate.getYear();
	    if (y < 1000) y += 1900;
	    var monthNum = theDate.getMonth();
	    var nextDate = new Date(y, monthNum + 1, 1);
	    htmlBuffer  = "<HTML>";
	    htmlBuffer += "<BODY BGCOLOR=#FFFFFF>";
	    htmlBuffer += "<TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0><TR><TD><FONT FACE=ARIAL SIZE=-1><B>"
	    htmlBuffer += txtSelectDate;
	    htmlBuffer += "</B></FONT></TD><TD ALIGN=RIGHT>";

		 // Get the last day of the month before the first month we drew.
	    var tempDate = new Date (y, monthNum, 1);
	     tempDate.setDate(tempDate.getDate() - 1);
	    if (tempDate.getTime() >= today.getTime()) {
	        htmlBuffer += "<A HREF='javascript:callingForm.changeMonth(-1)'><FONT FACE=ARIAL SIZE=-2>";
		htmlBuffer += txtPrevious;
		htmlBuffer += "</FONT></A>";
	    }
		 // Get the first day of the month after the last month we drew.
	    tempDate = new Date (y, monthNum + 2, 1);
	    if (tempDate.getTime() < nextYear.getTime()) {
	        htmlBuffer += "&nbsp;&nbsp;&nbsp;<A HREF='javascript:callingForm.changeMonth(1)'><FONT FACE=ARIAL SIZE=-2>";
		htmlBuffer += txtNext;
		htmlBuffer += "</FONT></A>";
	    }
		htmlBuffer += "</TD></TR><TR><TD COLSPAN=2 BGCOLOR=#CCCCCC>";
		if (isSecure == 1) htmlBuffer += "s";
		htmlBuffer += "</TD></TR></TABLE><P>";
	    htmlBuffer += "<TABLE BORDER=0 WIDTH=100%><TR><TD WIDTH=50% ALIGN=MIDDLE>";
	    drawOneMonth(theDate);
	    htmlBuffer += "</TD>";

	    htmlBuffer += "<TD ALIGN=MIDDLE WIDTH=50%>";
	    drawOneMonth(nextDate);
	    htmlBuffer += "</TD></TR>";
	    htmlBuffer += "<TR><TD COLSPAN=3 ALIGN=RIGHT VALIGN=BOTTOM>";
	    htmlBuffer += "&nbsp;<BR><FONT FACE=ARIAL SIZE=-2><a href='javascript:callingForm.closeCalendarWindow();'>";
	    htmlBuffer += txtClose;
	    htmlBuffer += "</a></FONT></TD></TR>"
	    htmlBuffer += "</TABLE></BODY></HTML>";
	}

	function drawOneMonth(theDate) {
	    var d;
	    var monthNum = theDate.getMonth();
		htmlBuffer += "<P ALIGN=LEFT><FONT COLOR=#0066CC FACE=ARIAL SIZE=-1><B>&nbsp;&nbsp;";
	    htmlBuffer += monthName[monthNum+1];
	    var dispYear = theDate.getYear();
	    if (dispYear < 1000) dispYear += 1900;
	    htmlBuffer += " " + dispYear;
	    htmlBuffer += "</B></FONT></P>";
	    htmlBuffer += "<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR=#CCCCCC width=95%><TR><TD>";
		htmlBuffer += "<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=3 width=100%>";
	    htmlBuffer += "<TR>";
	    for (d = 1; d <= 7; d++) {

	        htmlBuffer += "<TD BGCOLOR=FFFFFF><FONT SIZE=-1 FACE=ARIAL>"
			   + dayName[d]
			   + "</FONT></TD>";
	    }
	    htmlBuffer += "</TR>";

	    drawBody(theDate);
	    htmlBuffer += "</TABLE></TD></TR></TABLE>";
	}
	// generate the calendar body

	function drawBody (theDate) {
	    var w;
	    var d;
	    var y = theDate.getYear();
	    if (y < 1000) y += 1900;

	    var myDate = new Date (y, theDate.getMonth(), 1);
	    var monthNum = myDate.getMonth();
	    firstSunday (myDate);

	    for (w=0; w<6; w++) {
		htmlBuffer += "<TR>";
	        for (d=0; d<7; d++) {
	            htmlBuffer += "<TD ALIGN=CENTER BGCOLOR=FFFFFF><FONT FACE=ARIAL SIZE=-1>&nbsp;";
		    if (myDate.getMonth() != monthNum) {

			// this square on the calendar is not part of the month
		    }
		    else {
	                var date = myDate.getDate();
			var date_str;
			if (date < 10) date_str = "0" + date;
			else date_str = "" + date;
	        htmlBuffer += "&nbsp;";

			if (myDate.getTime() >= today.getTime()
				&& myDate.getTime() < nextYear.getTime())
			{
			    // create a link
			    y = (myDate.getYear() - today.getYear()) + 1;

			    var m = myDate.getMonth() + 1;
	                    htmlBuffer += "<A HREF='javascript:callingForm.fillDate(";

			    		htmlBuffer += date + "," + m + ", " + y + ")'";
	                    htmlBuffer += ">";
	                    htmlBuffer += date_str;
	                    htmlBuffer += "</A>";
	                }
			else {
			    htmlBuffer += date_str;
			}
	                htmlBuffer += "&nbsp;";
		    }
	            htmlBuffer   += "</FONT></TD>";
		    // increment the date
		    myDate.setDate(myDate.getDate() + 1);
	        }
	        htmlBuffer += "</TR>";
	    }
	}
	function firstSunday (fromDate) {
	    while (fromDate.getDay() != 0) {
		fromDate.setDate(fromDate.getDate() - 1);
	    }
	}
	function thisWindowOnFocus() {

	    closeCalendarWindow();
	}