
function clear_selected() {
	document.Availability.selected_date.value = "";
	document.Availability.addBooking.value = "";
	document.Availability.submit();
}

function checkOtherNights() {
	if (document.Availability.form_nights.value=="Other" && document.Availability.otherNightsNumber.value=="")
	{
		otherNightsDiv.style.visibility='visible';
	}
	else if (document.Availability.otherNightsNumber.value < 1 || document.Availability.otherNightsNumber.value >70)
	{
		alert("Please note the maximum stay allowed using this booking screen is 10 weeks (70 days)\n\nIf you wish to assign a period longer than this, make sure the dates are available, make any length of booking at the correct start date and edit the booking to change the finsh date.");
	}
	else
	{
		document.Availability.submit();
	}
}

function checkOtherNightsMY(number) {
	if (document.Availability.form_nights.value=="Other")
	{
		document.Availability.otherNightsNumber = number;
		document.Availability.submit();
}
	else
	{
		document.Availability.submit();
	}
}

function editedit(bookingRef) {
	document.Availability.editBooking.value = "yes";
	document.Availability.bookingRef.value = bookingRef;
	document.Availability.submit();
}

function confirmDelete(delUrl) {
  if (confirm("WARNING\n\nAre you sure you wish to delete this booking and all it's associated information")) {
    document.location = delUrl;
  }
}

function selectDate(dDate, formmonth, formnights) {
	document.Availability.selected_date.value = dDate;

	if (dDate.length<10)
	{
		var selectedday = dDate.substring(0,1); 
		var selectedmonth = dDate.substring(2,4);
	}
	else 
	{
		var selectedday = dDate.substring(0,2);
		var selectedmonth = dDate.substring(3,5);
	}
	if (selectedmonth.substring(0,1)==0)
	{
		selectedmonth = selectedmonth.substring(1);
	}
	if (formmonth+2==selectedmonth || formmonth-selectedmonth==10)
	{
		if (parseInt(selectedday,10)+parseInt(formnights,10)>=28)
		{
			document.Availability.form_month.value = selectedmonth;
		}
	}
	document.Availability.checkNow.value = "check";
	document.Availability.form_nights.value = formnights;
	document.Availability.otherNightsNumber.value = formnights;
	document.Availability.submit();
}

function book_selected () {
	if (document.Availability.selected_date.value!="")
	{
	document.Availability.addBooking.value = "add";
	document.Availability.bookingRef.value = "";
	document.Availability.editBooking.value = "";
	document.Availability.submit();
	}
}

function bookedDetails(bookingRef) {
	document.Availability.bookingRef.value = bookingRef;
	document.Availability.editBooking.value = "";
	document.Availability.addBooking.value = "";
	document.Availability.submit();
}

function clearBookingRef() {
	document.Availability.editBooking.value = "";
	document.Availability.bookingRef.value = "";
	document.Availability.addBooking.value = "";
	document.Availability.submit();
}

function clearEditEdit() {
	document.Availability.editBooking.value = "";
	document.Availability.bookingRef.value = "";
	document.Availability.addBooking.value = "";
	document.Availability.submit();
}

function checkAvailability (selected_date, form_nights) {
	if (selected_date!="")
	{
		document.Availability.checkNow.value = "check";
		document.Availability.submit();
	}
}

