		function sendToReservation()
		{
			if ( validateForm() )
			{

				if(document.chkAvailabilityForm.openInNewWindow.value == "1")
				{
					if (document.chkAvailabilityForm.adults.value != null)
						
						 mine = window.open("http://clients.innroad.com/"+document.chkAvailabilityForm.clientCode.value+"/logon.aspx?adults="+document.chkAvailabilityForm.adults.value +"&children="+document.chkAvailabilityForm.children.value+"&dateStart="+document.chkAvailabilityForm.dateStart.value+"&dateEnd="+document.chkAvailabilityForm.dateEnd.value+"&propertyID="+document.chkAvailabilityForm.propertyID.value+"&promoCode="+document.chkAvailabilityForm.promoCode.value);
					else
						mine = window.open("http://clients.innroad.com/"+ document.chkAvailabilityForm.clientCode.value);

					window.document.location.replace("index.html");
				}
				else
				{
				  if (document.chkAvailabilityForm.useIFrame.value == "1")
				  {
					document.chkAvailabilityForm.submit();
				  }
				  else
				  {
					// If iFrame is not exist than opening in the same window.
					var mine;

					if (document.chkAvailabilityForm.adults.value != null)
						window.top.location.replace("http://clients.innroad.com/"+document.chkAvailabilityForm.clientCode.value+"/logon.aspx?adults="+document.chkAvailabilityForm.adults.value +"&children="+document.chkAvailabilityForm.children.value+"&dateStart="+document.chkAvailabilityForm.dateStart.value+"&dateEnd="+document.chkAvailabilityForm.dateEnd.value+"&propertyID="+document.chkAvailabilityForm.propertyID.value+"&promoCode="+document.chkAvailabilityForm.promoCode.value);
					else
						window.top.location.replace("http://clients.innroad.com/"+document.chkAvailabilityForm.clientCode.value);

				  }
				}
			}
		}

		function validateForm()
		{		  

		  if ( !validateNotEmpty(trim(document.chkAvailabilityForm.dateStart.value)) )
		  {
		    alert("Please enter Checkin Date");
		    document.chkAvailabilityForm.dateStart.focus();
		    return false;
		  }

		  if ( !validateNotEmpty(trim(document.chkAvailabilityForm.dateEnd.value)) )
		  {
		    alert("Please enter Checkout Date");
		    document.chkAvailabilityForm.dateEnd.focus();
		    return false;
		  }

		  if ( validateDateOffset() )
		  {
			if ( document.chkAvailabilityForm.adults.value == '0' )
			{
			    alert("Please select adults");
			    document.chkAvailabilityForm.adults.focus();
			    return false;
			}
			else
			    return true;
		  }
		  else
			return false;
		}

		function validateDateOffset()
		{
		  var returnVal = true;
		  var startDateTime = new Date(document.chkAvailabilityForm.dateStart.value).getTime();
		  var endDateTime = new Date(document.chkAvailabilityForm.dateEnd.value).getTime();
		  var curDate = new Date();

		  var y = curDate.getYear();

		  if(navigator.appName=='Netscape')
		  {
			y = y + 1900;
		  }
		  curDate = new Date(y, curDate.getMonth(), parseInt(curDate.getDate()) );
		  var curDateTime = curDate.getTime();

		  var one_day = 1000*60*60*24;

		  if (startDateTime >= endDateTime )
		  {
			    alert("Please enter valid Check Out date");
			    returnVal = false;
		  }
		  else
		  {
			   if (document.chkAvailabilityForm.daysOffset.value > 0)
			   {
				    if (startDateTime > curDateTime)
				    {
					     if ( Math.ceil((startDateTime - curDateTime)/(one_day)) < document.chkAvailabilityForm.daysOffset.value )
					     {
						alert("Please enter Check In date which is greater than " + document.chkAvailabilityForm.daysOffset.value + " from now");
						returnVal = false;
					     }
				    }
				    else
				    {
					alert("Please enter Check In date which is greater than " + document.chkAvailabilityForm.daysOffset.value + " from now");
					returnVal = false;
				    }
			   }
		  }
		  return returnVal;
		}

		function populateDates()
		{
		  var curDate = new Date();
		  var y = curDate.getYear();

		  if(navigator.appName == 'Netscape')
		  {
			y = y + 1900;
		  }

		  curDate = new Date(y, curDate.getMonth(), parseInt(curDate.getDate())+parseInt(document.chkAvailabilityForm.daysOffset.value) );
		  document.chkAvailabilityForm.dateStart.value = formatDate(curDate, "MM/dd/yyyy");
		  curDate = new Date(y, curDate.getMonth(), parseInt(curDate.getDate())+1 );
		  document.chkAvailabilityForm.dateEnd.value = formatDate(curDate, "MM/dd/yyyy");
		  setNights();
		}

		function setCheckoutDate()
		{
			setCheckoutDateParams(document.chkAvailabilityForm.dateStart,document.chkAvailabilityForm.noOfNights,document.chkAvailabilityForm.dateEnd);
		}

		function setCheckoutDateParams(checkinDate, noOfNights, checkOutDate)
		{
			if (checkinDate.value != '' && isNumericVal(noOfNights.value, 0) && noOfNights.value != '')
			{
				var m_names = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug",
										"Sep", "Oct", "Nov", "Dec");

				var myDate=new Date(checkinDate.value)
				var nights = noOfNights.value;
				myDate.setDate(myDate.getDate()+parseInt(nights))
				checkOutDate.value = (myDate.getMonth()+1) + "/" + myDate.getDate() + "/" + myDate.getFullYear();
			}
		}

		function isNumericVal(c, varTest)
		{
			//allows alhabetic and space characters
			var letters="-0123456789";
			var LETTERS="-0123456789";

			var index1 = c.indexOf("-");
			var index2 = c.indexOf("-", index1 + 1);
			var index3 = c.indexOf("-", index2 + 1);

			if (varTest == 1)
			{
				if (!((index1 == 3) && (index2 == 7) && (index3 == -1)))
				{
					return false;
				}
			}

			if(c.length>1)
			{
				for(j=0;j<c.length;j++)
				{
				// call isAlphaCell recursively for each character
				alpha=isNumericVal(c.substring(j,j+1), 2);	// 2nd time entry
				if(!alpha) return alpha;
				}
				return alpha;
			}
			else
			{
				// if c is alpha return true
				if(letters.indexOf(c)>=0 || LETTERS.indexOf(c)>=0) return true;
				return false;
			}
		}

		function setNights()
		{
			return setNightsParams(document.chkAvailabilityForm.dateStart,document.chkAvailabilityForm.noOfNights,document.chkAvailabilityForm.dateEnd);
		}

		function setNightsParams(checkinDate, noOfNights, checkOutDate)
		{
			var one_day=1000*60*60*24
			if (checkinDate.value != '' && checkOutDate.value != '')
			{

				var totNights = new Number();
				var zero = 0;

				var stDate = new Date(checkinDate.value);
				var endDate = new Date(checkOutDate.value);

				stDate.setHours(0);
				stDate.setMinutes(0);
				stDate.setSeconds(0);

				stDate.setHours(0);
				endDate.setMinutes(0);
				endDate.setSeconds(0);

				totNights=Math.round((endDate.getTime() - stDate.getTime())/one_day);

				if(totNights < zero)
				{
					alert('Arrival Date must be earlier than Departure Date');
					return false;
				}
				else
				{
					noOfNights.value = totNights ;
					return true;
				}
			}
		}

		function fillForm()
		{
			if (document.chkAvailabilityForm.beFilterConfig.value == 'town')
			{
				document.chkAvailabilityForm.beFilterName.value="townID";
				document.getElementById("beFilterLabel").innerHTML="Town:";
			}

			if (document.chkAvailabilityForm.beFilterConfig.value == 'property')
			{

				document.chkAvailabilityForm.beFilterName.value="propertyID";
				document.getElementById("beFilterLabel").innerHTML="Property:";
			}

			if (document.chkAvailabilityForm.beFilterConfig.value == 'roomClass')
			{
				document.chkAvailabilityForm.beFilterName.value="roomClassID";
				document.getElementById("beFilterLabel").innerHTML="Room Class:";
			}

			if (document.chkAvailabilityForm.showHideBEFilter.value == 'hide')
			{
				document.getElementById("beFilterTR").style.display = 'none';
			}

			if (document.chkAvailabilityForm.showHideBEFilter.value == 'show')
			{
				document.getElementById("beFilterTR").style.display = '';
			}

			if (document.chkAvailabilityForm.showHideChildren.value == 'hide')
			{
				document.getElementById("beChildrenTD").style.display = 'none';
				document.getElementById("beChildrenHelpTD").style.display = 'none';
			}
			if (document.chkAvailabilityForm.showHideChildren.value == 'show')
			{
				document.getElementById("beChildrenTD").style.display = '';
				document.getElementById("beChildrenHelpTD").style.display = '';
			}

			if (document.chkAvailabilityForm.showHideNights.value == 'hide')
			{
				document.getElementById("beNightsTR").style.display = 'none';
			}
			if (document.chkAvailabilityForm.showHideNights.value == 'show')
			{
				document.getElementById("beNightsTR").style.display = '';
			}

			if (document.chkAvailabilityForm.showHidePromoCode.value == 'hide')
			{
				document.getElementById("bePromoCodeTR").style.display = 'none';
			}
			if (document.chkAvailabilityForm.showHidePromoCode.value == 'show')
			{
				document.getElementById("bePromoCodeTR").style.display = '';
			}
		}
