/*Function contact_email()
 * No Paramaters expected
 * Function: Validate the feedback form
 * Author: 	 Joseph Zanotelli
 * Created:  07/06/2010

-Revisions-
07/06/2010 - Created
*/
 
function validateFeedback() {
	//Define form fields into local variables
	var name	 = document.feedbackform.name.value;
	var email 	 = document.feedbackform.email.value;
	var feedback = document.feedbackform.feedback.value;
	
	//Verify that the name is filled in
	if (name ==""){
		alert("Name is a required field");
		document.feedbackform.name.focus();
		return false;
	}
	
	//Verify that the from address is filled in and valid
	if (email == "" || isValidEmail(email) == false){
		alert("A valid E-Mail address is required");
		document.feedbackform.email.focus();
		return false;
	}
	
	//Verify that the message box contains text
	if (feedback ==""){
		alert("The feedback box can not be empty");
		document.feedbackform.feedback.focus();
		return false;
	}

}

/*Function isValidEmail()
 * 1 Paramaters expected (Email address - String)
 * Function: Validates that the string conformes to a email address
 * Author: 	 Joseph Zanotelli
 * Created:  10/16/2005

-Revisions-
10/16/2005 - Created
*/
function isValidEmail(str) {
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){return false}
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){return false}
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){return false}
		if (str.indexOf(at,(lat+1))!=-1){return false}
		if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){return false}
		if (str.indexOf(dot,(lat+2))==-1){return false}
		if (str.indexOf(" ")!=-1){return false}
 		return true					
	}