function selectByGuide() {
  alert("Please select a guide below.");
}

/*
  Make external links open in new window/tab
*/
function externalLinks() {
	if (!document.getElementsByTagName) return;
		var anchors = document.getElementsByTagName("a");
		for (var i=0; i<anchors.length; i++) {
		  var anchor = anchors[i];
		  if (anchor.getAttribute("href")) {
		 	if (anchor.getAttribute("rel") == "external" || anchor.getAttribute("rel") == "help") {
				anchor.target = "_blank";
			}
	  	}
	}
}

/*
  Event loading: functions to fire on window load
*/
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			if (oldonload) {
				oldonload();
			}
			func();
		}
	}
}

function validateAddForm() {

	var el = document.getElementById("ReservationReservationDatesString");
	if (el.value == "") {
		alert("Please select dates before continuing.");
		return false;
	}
  
  // gather required fields
  var fields = [
    document.forms[0].ReservationFirstName, //first name
    document.forms[0].ReservationLastName, //last name
    document.forms[0].ReservationEmail, //email
    document.forms[0].ReservationPrimaryPhone // phone number
  ];

  var out = '';

  // check for empty fields and collect error messages
  for (var i=0; i < fields.length; i++) {
    if (!fields[i].value) {
       out += fields[i].title + '\n';
    }
  };
  
  if (out != '') {
    alert(out);
    return false;    
  } else {
    return validateWaiverCheck();
  }
}

function validateWaiverCheck() {
	// See if 'Waiver Accepted' checkbox is checked
	var waiver_checked = '';
	if (document.forms[0].ReservationWaiverAccepted.checked) {
		waiver_checked = 'Yes';
	}	
	// Give an error if it isn't checked Yes
	if (waiver_checked != 'Yes') {
		alert('Please acknowledge that you have read and printed the Waiver before continuing.');
		return false;
	} else {
	  return;
	}
}

function loadMonthNav(form, option){
	form.action = form.action + "/" + option;
	form.submit();
}

addLoadEvent(externalLinks);