<!-- alerts, quick and dirty - final checks server based

var phrase = new RegExp("\\W?");
var state = new RegExp("[a-zA-Z]{2}");
var zipcode = new RegExp("\\d{5}");
var zipcode9 = new RegExp("\\d{5}-\\d{4}");
var phone = new RegExp("\\d{3}-?\\d{4}");
var phonedot = new RegExp("\\d{3}.?\\d{4}");
var phonearea = new RegExp("(\\d{3})\\d{3}-?\\d{4}");
var phoneareadot = new RegExp("\\d{3}.?\\d{3}.?\\d{4}");

function isblank(s) {
  for (var i = 0; i < s.length; i++) {
	var c = s.charAt(i);
		if ((c != ' ') && (c != '/n') && (c != '\t')) return false;
	}
	return true;
}
function empty_fields (f) {
  var msg;
  var empty_fields = "";
  var errors = "";
  
  for (var i = 0; i < f.length; i++) {
  	var e = f.elements[i];
  	if (((e.type == "text") || (e.type == "textarea")) && !e.optional) {
  		// empty ?
  		if ((e.value == null) || (e.value == "") || isblank(e.value)) {
  			empty_fields += "\n " + e.name;
  			continue;
  		}
  	
  	
  	}
  }
  if (!empty_fields) return true;
  alert(empty_fields);
  return false;
  
}
function textCheck(s,t) {
		
	if (isblank(s.value) || !phrase.test(s.value,"g")) {
		t.style.color = "red";
		t.style.fontWeight = "bold";
	}
	else {
		t.style.color = "";
		t.style.fontWeight = "";
	}
}
function stateCheck(s,t) {
	if (isblank(s.value) || s.value.length != 2 || !state.test(s.value,"i")) {
		t.style.color = "red";
		t.style.fontWeight = "bold";
	}
	else {
		t.style.color = "";
		t.style.fontWeight = "";
	}
}
function zipCheck(s,t) {
	if (isblank(s.value)) {
		t.style.color = "red";
		t.style.fontWeight = "bold";
	}
	else if ((s.value.length == 5) && (zipcode.test(s.value))) {
		t.style.color = "";
		t.style.fontWeight = "";
	}
	else if ((s.value.length == 10) && (zipcode9.test(s.value))) {
		t.style.color = "";
		t.style.fontWeight = "";
	}
	else {
  		t.style.color = "red";
		t.style.fontWeight = "bold";
	}
}
function phoneCheck(s,t) {
	if (isblank(s.value)) {
		t.style.color = "red";
		t.style.fontWeight = "bold";
	}
	else if ((s.value.length == 7 || s.value.length == 8) && (phone.test(s.value) || phonedot.test(s.value))) {
		t.style.color = "";
		t.style.fontWeight = "";
	}
	else if ((s.value.length == 10 || s.value.length == 12 || s.value.length == 13) && (phonearea.test(s.value) || phoneareadot.test(s.value))) {
		t.style.color = "";
		t.style.fontWeight = "";
	}
	
	else {
  		t.style.color = "red";
		t.style.fontWeight = "bold";
	}
}
function guestCheck(s,t) {
	if (isblank(s.value)) {
		t.style.color = "red";
		t.style.fontWeight = "bold";
	}
	else if (!(s.value > 0 && s.value < 101)) {
		t.style.color = "red";
		t.style.fontWeight = "bold";
	}
	else {
		t.style.color = "";
		t.style.fontWeight = "";	}
}

function check (f) {
  var msg = "";
  var today = new Date();
  var arrival = new Date();
  var departure = new Date();
  
  var phonect = 0;
  for (var i = 0; i < f.length; i++) {
  	var e = f.elements[i];
  	switch(e.name) {
  		case "Name":
  			if (isblank(e.value)) {
  				msg += "Please enter your Name:\n";
				obj = document.getElementById("nameTag");
  				obj.style.color = "red";
				obj.style.fontWeight = "bold";
			}
  			break;
  		case "CompanyName":
  			if (isblank(e.value)) {
  				msg += "Please enter your Company's Name:\n";
  				obj = document.getElementById("cnameTag");
  				obj.style.color = "red";
				obj.style.fontWeight = "bold";
				// cnameTag.style.color = "red";
				// cnameTag.style.fontWeight = "bold";
			}
  			break;
		case "MailAddress":
  			if (isblank(e.value)) {
  				msg += "Please enter your Address:\n";
				obj = document.getElementById("addrTag");
  				obj.style.color = "red";
				obj.style.fontWeight = "bold";
  				// addrTag.style.color = "red";
				// addrTag.style.fontWeight = "bold";
			}
  			break;
		case "City":
  			if (isblank(e.value)) {
  				msg += "Please enter your City:\n";
  				obj = document.getElementById("cityTag");
  				obj.style.color = "red";
				obj.style.fontWeight = "bold";
				// cityTag.style.color = "red";
				// cityTag.style.fontWeight = "bold";
			}
  			break;
		case "State":
  			if (isblank(e.value)) {
  				msg += "Please enter your State:\n";
  				obj = document.getElementById("stateTag");
  				obj.style.color = "red";
				obj.style.fontWeight = "bold";
				// stateTag.style.color = "red";
				// stateTag.style.fontWeight = "bold";
			}
  			break;
		case "ZipCode":
  			if (isblank(e.value)) {
  				msg += "Please enter your Zip Code:\n";
  				obj = document.getElementById("zipTag");
  				obj.style.color = "red";
				obj.style.fontWeight = "bold";
				// zipTag.style.color = "red";
				// zipTag.style.fontWeight = "bold";
				break;
			}
			if ((e.value.length == 5) && (zipcode.test(e.value))) {
				break;
			}
			if ((e.value.length == 10) && (zipcode9.test(e.value))) {
				break;
			}
			msg += "Please enter either a 5 or 9 digit Zip Code:\n";
  				obj = document.getElementById("zipTag");
  				obj.style.color = "red";
				obj.style.fontWeight = "bold";
				// zipTag.style.color = "red";
			// zipTag.style.fontWeight = "bold";
			break;
  		case "Email":
  			if (isblank(e.value)) {
  				msg += "Please enter your Email Address:\n";
				obj = document.getElementById("emailTag");
  				obj.style.color = "red";
				obj.style.fontWeight = "bold";
  				// emailTag.style.color = "red";
				// emailTag.style.fontWeight = "bold";
			}
  			break;
		case "PhoneNumber":
  			if (isblank(e.value)) {
  				msg += "Please enter your Phone Number:\n";
  				obj = document.getElementById("phoneTag");
  				obj.style.color = "red";
				obj.style.fontWeight = "bold";
				// phoneTag.style.color = "red";
				// phoneTag.style.fontWeight = "bold";
			}
			else if ((e.value.length == 7 || e.value.length == 8) && (phone.test(e.value) || phonedot.test(e.value))) {
				obj = document.getElementById("phoneTag");
  				obj.style.color = "red";
				obj.style.fontWeight = "bold";
				// phoneTag.style.color = "";
				// phoneTag.style.fontWeight = "";
			}
			else if ((e.value.length == 10 || e.value.length == 12 || e.value.length == 13) && (phonearea.test(e.value) || phoneareadot.test(e.value))) {
				obj = document.getElementById("phoneTag");
  				obj.style.color = "red";
				obj.style.fontWeight = "bold";
				// phoneTag.style.color = "";
				// phoneTag.style.fontWeight = "";
			}
			else {
				msg += "Please enter either a 7 or 10 digit Phone Number:\n";
  				obj = document.getElementById("phoneTag");
  				obj.style.color = "red";
				obj.style.fontWeight = "bold";
				// phoneTag.style.color = "red";
				// phoneTag.style.fontWeight = "bold";
			}
  			break;
  		case "Arrival_Month":
  			if (isblank(e.value)) {
  				msg += "Please enter an arrival month:\n";
  			}
  			arrival.setMonth(e.value - 1);
  			break;
		case "Arrival_Day":
  			if (isblank(e.value)) {
  				msg += "Please enter an arrival day:\n";
  			}
  			arrival.setDate(e.value);
  			break;

		case "Arrival_Year":
  			if (isblank(e.value)) {
  				msg += "Please enter an arrival year:\n";
  			}
  			arrival.setFullYear(e.value);
  			break;

		case "Departure_Month":
  			if (isblank(e.value)) {
  				msg += "Please enter an departure month:\n";
  			}
  			departure.setMonth(e.value - 1);
  			break;
		case "Departure_Day":
  			if (isblank(e.value)) {
  				msg += "Please enter an departure day:\n";
  			}
  			departure.setDate(e.value);
  			break;

		case "Departure_Year":
  			if (isblank(e.value)) {
  				msg += "Please enter an departure year:\n";
  			}
  			departure.setFullYear(e.value);
  			break;
		case "Guests":
  			if (isblank(e.value)) {
  				msg += "Please enter the number of guests:\n";
  				obj = document.getElementById("guestTag");
  				obj.style.color = "red";
				obj.style.fontWeight = "bold";
				// guestTag.style.color = "red";
				// guestTag.style.fontWeight = "bold";
			}
  			break;
		case "property":
			break;
		case "Please_Contact_Me":
			break;
		case "Send_Property_Literature":
			break;
  		default:
  			if ((!e.optional) && (e.name)) {
  				msg += "Please enter a value for " + e.name + "\n";
  			}
  			break;
  	}
  }
  
  if (!msg) return true;
  alert(msg);
  return false;
  
}
// -->