/* EMAIL FORM VALIDATIONS
*******************************************************************/

/* FORM: CONTACT US
*******************************************************************/

function validCUForm(contact_us){
	
	var problem = false;  // Flag variable
	var invalidChars = " /:,;"; //The characters don't belong in a valid email address
			
		// Validate the first name
		if (contact_us.first_name.value == ""){
			alert ("Please enter your first name.");
			contact_us.first_name.value = "*** FIRST NAME";
			contact_us.first_name.focus();
			problem = true;
		}
		
		// Validate the last name
		if (contact_us.last_name.value == ""){
			alert ("Please enter your last name.");
			contact_us.last_name.value = "*** LAST NAME";
			contact_us.last_name.focus();
			problem = true;
		}
		
		// Validate the email address
			
			//You must enter something
			if (contact_us.email.value == ""){
				alert("Please enter your email address!");
				contact_us.email.value = "*** EMAIL ADDRESS";
				contact_us.email.focus();
				problem = true;
			}
			
			// There must be something BEFORE the at sign 
			if (contact_us.email.value.indexOf("@", 0) == 0){
				alert("No username in email address!");
				problem = true;
			}
			
			// There must be an at sign at, or after, the second character
			if (contact_us.email.value.indexOf("@", 1) == -1){
				alert("No @ sign in email address!");
				problem = true;
			}
			
			// There must be a period somewhere 
			if (contact_us.email.value.indexOf(".", 0) == -1){
				alert("No period in email address!");
				problem = true;
			}
			
			// Check for invalid characters
			for (i=0; i<invalidChars.length; i++){
				if (contact_us.email.value.indexOf(invalidChars.charAt(i), 0) > -1){
					alert("Bad character(s) in email address!", invalidChars.charAt(i), i); 
					problem = true;
				}
			} 
					
		
		// return true/false based upon problem
		if(problem){
			return false;
		} else{
			return true;
		}	

};// end of function request showing definition

