function ValidateHomeCheckAvailabilityForm(theForm){
	var from_dd = theForm.rsv_arrival_dd.value;
  var from_mm = theForm.rsv_arrival_mm.value;
  var from_yy = theForm.rsv_arrival_yy.value;
  var to_dd = theForm.rsv_departure_dd.value;
  var to_mm = theForm.rsv_departure_mm.value;
  var to_yy = theForm.rsv_departure_yy.value;
	
	var destination = theForm.rsv_res_id.value;
	var adults = theForm.rsv_adults.value;
	var children = theForm.rsv_children.value;
	
	var fromdate1 = new Date(from_yy,(from_mm-1),from_dd);
	var todate1 = new Date(to_yy,(to_mm-1),to_dd);
	
	var today = new Date();

	fromdate=from_dd+from_mm+from_yy;
	todate=to_dd+to_mm+to_yy;

	if (!destination) {
		alert("You must select destination");
		return false;
	} else if (!adults) {
		alert("You must enter number of adult number");
		return false;
	} else if (!children) {
		alert("You must enter children number");
		return false;
	} else if ( (fromdate1.getFullYear() < today.getFullYear())
		|| ((fromdate1.getFullYear() == today.getFullYear()) && (fromdate1.getMonth()+1 < today.getMonth()+1))
		|| ((fromdate1.getFullYear() == today.getFullYear()) && (fromdate1.getMonth()+1 == today.getMonth()+1) && (fromdate1.getDate() < today.getDate())) ) {
		alert("Arrival Date cannot be in the past.");
		return false;
	} else if ( (todate1.getFullYear() < today.getFullYear())
		|| ((todate1.getFullYear() == today.getFullYear()) && (todate1.getMonth()+1 < today.getMonth()+1))
		|| ((todate1.getFullYear() == today.getFullYear()) && (todate1.getMonth()+1 == today.getMonth()+1) && (todate1.getDate() < today.getDate())) ) {
		alert("Departure Date cannot be in the past.");
		return false;
	} else if ( ((from_dd != fromdate1.getDate()) || (from_mm != fromdate1.getMonth()+1) || (from_yy != fromdate1.getFullYear())) && (fromdate != '') ) {
		alert("Invalid Arrival Date.");
		return false;
	} else if ( ((to_dd != todate1.getDate()) || (to_mm != todate1.getMonth()+1) || (to_yy != todate1.getFullYear())) && (todate != '') ) {
		alert("Invalid Departure Date.");
		return false;
	} else if (((fromdate1 > todate1) && (todate != '')) || (fromdate == todate)) {
		alert("Arrival Date must be before Departure Date.");
		return false;
	} else {
		return true;
	}
	
}
function goToCheckAvailability(theform,thePageId) {

  lochref = 'index.php?pageid='+thePageId+'&pageaction=hrs&modid=CheckAvailability';

	location = lochref;
}
