//-------------------------
//from reservationForm.asp
//-------------------------
function makeReservation(destination){
	var f = document.reservationForm;
	var alertString = "";
	
	if(f.clientName.value == ""){
		alertString = alertString + "Name must be filled in\n";
	}
	
	if(f.clientAddress.value == ""){
		alertString = alertString + "Address must be filled in\n";
	}
	
	if(f.clientCity.value == ""){
		alertString = alertString + "City/town must be filled in\n";
	}
	
	if(f.clientState.value == ""){
		alertString = alertString + "Province/state must be filled in\n";
	}
	
	if(f.clientZipcode.value == ""){
		alertString = alertString + "Postal/zip code must be filled in\n";
	}
	
	if(f.clientCountry.value == ""){
		alertString = alertString + "Country must be filled in\n";
	}	
	
	if(f.clientTelephoneDay.value == ""){
		alertString = alertString + "Daytime telephone number must be filled in\n";
	}
	
	if(f.clientTelephoneEvening.value == ""){
		alertString = alertString + "Evening telephone number must be filled in\n";
	}
	
	if(f.clientEmail.value != ""){
		var field = f.clientEmail; // email field
  		var str = field.value; // email string
  		var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
  		var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid
  		if (!reg1.test(str) && reg2.test(str)){ 
		// syntax is valid
  		}
		else{
  			alertString = alertString + "A valid email address must be filled in\n"; // this is also optional
		}
	}
	else{
		alertString = alertString + "An email address must be filled in\n";
	}
	
	if(f.numberOfAdults.options[f.numberOfAdults.selectedIndex].value == "0"){
		alertString = alertString + "Number of adults must be filled in\n";
	}
	
	//booking conditions checkbox
	if(f.bookingConditions.checked == false){
		alertString = alertString + "\n********************************************************\nYou must tick the box to say that you have read\nand understood our Booking Conditions\n********************************************************";
	}	
	
	if(alertString == ""){
		if(destination == "online"){
			f.action = "https://www.stylusnet-ssl.com/florida/reservationPayment.asp";
		}
		else{
			f.action = "reservationPrint.asp";
		}
		f.submit();
	}
	else{
		alert(alertString);
	}

}

//-------------------------
//from reservationPayment.asp
//-------------------------
function confirmOnlineReservation(){
	var f = document.reservationForm;
	var blnSubmit = true;
	
	if(f.paymentMethod.options[f.paymentMethod.selectedIndex].value == "x"){
		alert("Please choose a payment method from the list");
		blnSubmit = false;
		return false;
	}
	
	if(f.cardNumber.value == ""){
		alert("Please enter your card number");
		blnSubmit = false;
		return false;
	}
	
	if(f.cardName.value == ""){
		alert("Please enter the card holder's name");
		blnSubmit = false;
		return false;
	}
	
	if(f.expiryMonth.options[f.expiryMonth.selectedIndex].value == "x" || f.expiryYear.options[f.expiryYear.selectedIndex].value == "x"){
		alert("Please enter the full expiry date from the dropdown lists");
		blnSubmit = false;
		return false;
	}
	
	if(f.paymentMethod.options[f.paymentMethod.selectedIndex].value == "Switch" && f.issueNumber.value == ""){
		alert("Please enter the issue number of your Switch card");
		blnSubmit = false;
		return false;
	}
	
	if(blnSubmit){
		f.action = "reservationConfirmation.asp";
		f.submit();
	}	
}



//-------------------------
//from contact.asp
//-------------------------
function validateContact(){
	var f = document.contactForm;
	var blnSubmit = true;
	
	if(f.clientName.value == ""){
		alert("Please fill in your name");
		f.clientName.focus();
		blnSubmit = false;
		return false;
	}
	
	if(f.clientCountry.value == ""){
		alert("Please fill in your country of residence");
		f.clientCountry.focus();
		blnSubmit = false;
		return false;
	}	
	
	if(f.clientTelephoneDay.value == ""){
		alert("Please give us a daytime telephone number");
		f.clientTelephoneDay.focus();
		blnSubmit = false;
		return false;
	}
	
	if(f.clientEmail.value != ""){
		var field = f.clientEmail; // email field
  		var str = field.value; // email string
  		var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
  		var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid
  		if (!reg1.test(str) && reg2.test(str)){ 
			// syntax is valid
			blnSubmit = true;
  		}
		else{
  			alert("A valid email address must be filled in"); // this is also optional
			f.clientEmail.focus();
			blnSubmit = false;
			return false;
		}
	}
	else{
		alert("Please enter your email address");
		f.clientEmail.focus();
		blnSubmit = false;
		return false;
	}
	
	if(f.comments.value == ""){
		alert("Please enter any comments or enquiries you may have.");
		f.comments.focus();
		blnSubmit = false;
		return false;
	}
	
	if(blnSubmit){
		f.action = "sendmail.asp";
		f.submit();
	}

}
