function checkEmail(theEmail) {
		var regex = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
		
		if (!regex.test(theEmail)) {
			return false;
		} else {
			return true;
		}
	}

	// trim() function to strip whitespace
	String.prototype.trim = function() 
	{
	  return( this.replace(/^\s*([\s\S]*\S+)\s*$|^\s*$/,'$1') ); 
	}

	function validate() {
		var f = document.orderdocs;
		
		// Check the user has typed in their name
		if (f.firstname.value.trim().length == 0) {
			alert("Please enter your first name.");
			f.firstname.focus();
			return false;
		}
		
		// Check the user has typed in their name
		if (f.lastname.value.trim().length == 0) {
			alert("Please enter your last name.");
			f.lastname.focus();
			return false;
		}
		
		// Check for comments
		if (f.address.value.trim() == 0) {
			alert("Please enter your address.");
			f.address.focus();
			return false;
		}
		
		// Check for a valid email address
		if (f.email.value.trim().length == 0) {
			alert("Please enter your email address.");
			f.email.focus();
			return false;
		}
		
		if (!checkEmail(f.email.value)) {
			alert("Please enter a valid email address.");
			f.email.focus();
			return false;
		}
		
		// Check for comments
		//if (f.comments.value.trim() == 0) {
		//	alert("Please enter your comments.");
		//	f.comments.focus();
		//	return false;
		//}
		
		return true;
	}
	
		function validateFB() {
		var f = document.feedback;
		
		// Check the user has typed in their name
		if (f.firstname.value.trim().length == 0) {
			alert("Please enter your first name.");
			f.firstname.focus();
			return false;
		}
		
		// Check the user has typed in their name
		if (f.lastname.value.trim().length == 0) {
			alert("Please enter your last name.");
			f.lastname.focus();
			return false;
		}
		
		// Check for comments
		if (f.address1.value.trim() == 0) {
			alert("Please enter the first line of your address.");
			f.address1.focus();
			return false;
		}
		
		// Check for a valid email address
		if (f.email.value.trim().length == 0) {
			alert("Please enter your email address.");
			f.email.focus();
			return false;
		}
		
		if (!checkEmail(f.email.value)) {
			alert("Please enter a valid email address.");
			f.email.focus();
			return false;
		}
		
		// Check for comments
		if (f.comments.value.trim() == 0) {
			alert("Please enter your comments.");
			f.comments.focus();
			return false;
		}
		
		return true;
	}
	
	
	
	