/*-------------------------------------------

A SIMPLE FORM VALIDATION SCRIPT
  (2nd minor revision)

  This simple form validation script is
	made freely	available for use or modification
	to anyone who finds it useful.

	It is provided as is without any warranty
	or implied suitability to any purpose.

	Thank you for your interest.
	Support OpenSource!
-------------------------------------------*/



function getValue(field) {
  var address = location.search.substring(1);
  var startExtract = address.indexOf(field + "=");
  if (startExtract > -1) {
    startExtract = startExtract + field.length + 1;
    var endExtract = address.indexOf("&",startExtract);
    if (endExtract == -1)
      endExtract = address.length;
    return unescape(address.substring(startExtract,endExtract));
  }
  return '';
}



function validate() {

	if (document.onlineform.realname.value=="") {
		alert("Please provide your name.");
		document.onlineform.realname.focus();
		return false;
	}

	if (document.onlineform.nationality.value=="") {
		alert("Please indicate your nationality.");
		document.onlineform.nationality.focus();
		return false;
	}

	if (document.onlineform.email.value=="") {
		alert("Please provide your e-mail address.");
		document.onlineform.email.focus();
		return false;
	}


/*	if (document.onlineform.submission(0).checked) { */

		if (document.onlineform.phone.value=="") {
			alert("Please provide your phone number.");
			document.onlineform.phone.focus();
			return false;
		}

		if (document.onlineform.occupancy.value=="") {
			alert("Please indicate the number of occupants.");
			document.onlineform.occupancy.focus();
			return false;
		}
		else if (isNaN(document.onlineform.occupancy.value)==true) {
			alert("Please enter a NUMERIC value for OCCUPANCY field.");
			document.onlineform.occupancy.focus();
			return false;
		}

		if (document.onlineform.rooms_required.value=="") {
			alert("Please enter number of rooms.");
			document.onlineform.rooms_required.focus();
			return false;
		}
		else if (isNaN(document.onlineform.rooms_required.value)==true) {
			alert("Please enter a NUMERIC value for NO. OF ROOMS field.");
			document.onlineform.rooms_required.focus();
			return false;
		}

		/* ------ validate check-in date ----- */

		var inMonth = document.onlineform.check_in_month.options[document.onlineform.check_in_month.selectedIndex].value;
		if (inMonth=="") {
			alert("Please indicate your Check-In Month.");
			document.onlineform.check_in_month.focus();
			return false;
		}

		var inDay = document.onlineform.check_in_day.options[document.onlineform.check_in_day.selectedIndex].value;
		if (inDay=="") {
			alert("Please indicate your Check-In Day.");
			document.onlineform.check_in_day.focus();
			return false;
		}

		var inYear = document.onlineform.check_in_year.options[document.onlineform.check_in_year.selectedIndex].value;
		if (inYear=="") {
			alert("Please indicate your Check-In Year.");
			document.onlineform.check_in_year.focus();
			return false;
		}


		/* ------ validate check-out date ----- */

		var outMonth = document.onlineform.check_out_month.options[document.onlineform.check_out_month.selectedIndex].value;
		if (outMonth=="") {
			alert("Please indicate your Check-Out Month.");
			document.onlineform.check_out_month.focus();
			return false;
		}

		var outDay = document.onlineform.check_out_day.options[document.onlineform.check_out_day.selectedIndex].value;
		if (outDay=="") {
			alert("Please indicate your Check-Out Day.");
			document.onlineform.check_out_day.focus();
			return false;
		}

		var outYear = document.onlineform.check_out_year.options[document.onlineform.check_out_year.selectedIndex].value;
		if (outYear=="") {
			alert("Please indicate your Check-Out Year.");
			document.onlineform.check_out_year.focus();
			return false;
		}

}


