// JavaScript Document

 /* function validate
 * Validate non null on desired fields and do a little 
 * more for fields which should have some structure 
 * such as zip and email
 */
function validate(form) {
		var strMsg = "";
		if (form.name.value == "") {
			strMsg += "Please enter your name. \n";
		}
		
		if (form.email.value == "") {
			strMsg += "Please enter your email. \n";
		}	
		
		
		if (form.email.value != "" && (!validateEmail(form.email.value))) {
			strMsg += "Email address is not valid. \n";
		}
		
		if (form.message.value == "") {
			strMsg += "Please type a message. \n";
		
		}
		if (strMsg.length > 0) {
			alert(strMsg);
		}
		
		return (strMsg.length == 0);
}

/*
 * function validateEmail
 * A very simple function to determine if an email address is 
 * completely wrong or at least has all the functional parts - 
 * that is, a '.' and an '@'.
 */
function validateEmail(emailAddress) {
	if (emailAddress.indexOf('@') == -1 || emailAddress.indexOf('.') == -1) {
		return false;
	}
	return true;
}

