// Add the following text to the page that wants to call 
// <SCRIPT src="verifyinfo.js"></SCRIPT>
// End of text to add.

function Echeck(str){
	if (str.length < 5) return(0)
	if (str.indexOf(" ") >= 0) return(0)
	if (str.indexOf(".") < 1) return(0)
	if (str.indexOf("@") < 1) return(0)
	if (str.indexOf("@") != str.lastIndexOf("@")) return(0)
	if (str.indexOf("..") >= 0) return(0)

	for (k=0; k<str.length; k++){
		chr=str.charCodeAt(k)
		if (chr<=39 || chr>=127 || chr==44 || chr==59)	return(0)
		}
	
	return(1)
	}

function VerifyEmail(forminfo) {
	missinginfo="";

	if (Echeck(forminfo.email.value) == true) {
		return true;
		}
		
	missinginfo ="_____________________________\nWe had a problem processing your information:\n";

	if(forminfo.email.value.length == 0) {
		missinginfo += "- Your Email address is missing.";
	}
	else {
		missinginfo += "- The Email address doesn't appear to be valid.";
		}
	
	missinginfo += "\n- Format: user@home.com";
	missinginfo += "\n_____________________________\nPlease re-enter the information and submit your request again.";
	alert(missinginfo);
	forminfo.email.focus();
	return false;
	}

// Contact Us, Reservation Request

function VerifyContactUs(forminfo) {
	missinginfo="";
	document.images['Telephone'].src = "";
	document.images['email'].src = "";

	<!-- We need either a phone number or email address. -->
	if ((forminfo.Telephone.value.length == 0) && (forminfo.email.value.length == 0)) {
		missinginfo  = "_____________________________\n";
		missinginfo += " We need either your phone number or your email address\nso that we can contact you.";
		missinginfo += "\n_____________________________\nPlease re-enter the information and submit your request again.";
		alert(missinginfo);
		forminfo.Telephone.focus();
		
		document.images['Telephone'].src = "images/redflag.gif";
		document.images['email'].src = "images/redflag.gif";

		return false;
		}

	<!-- If they gave us a phone number we don't check the email values. -->
	if(forminfo.Telephone.value.length != 0) {
 		return true;
		}

	if (VerifyEmail(forminfo) == true) {
		return true;
		}

	document.images['email'].src = "images/redflag.gif";
	return false;
	}

// Gift Certificate Request

function VerifyGiftCertificate(forminfo) {
	givefocus = ""
	missinginfo="_____________________________\n";

  	if (forminfo.Giver_Name.value.length == 0) {
		missinginfo += "- We would like your name.\n";
		givefocus = "Giver_Name"
	}

	if (forminfo.Giver_Phone.value.length == 0) {
		missinginfo += "- We need a phone number so we can contact you if we have any questions.\n"
		if (givefocus == "") {
			givefocus = "Giver_Phone"
		}
	}

	if (givefocus == "") {
  		return true;
	}
	
	missinginfo += "\n_____________________________\nPlease re-enter the information and submit your request again.";
	alert(missinginfo);
	forminfo.elements[givefocus].focus();
	return false
}

