function validString(str, validChars) {

	for (var i=0; i<str.length; i++)
		if ( validChars.indexOf(str.substr(i,1)) == -1 )
			return false;
	
	return true;
}

function echeck(str) {
	var at = "@";
	var dot = ".";

	// check wikipedia, valid emails according to RFC standard can be alphanumeric, ., and the following
	var validAlpha = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
	var validNumeric = "0123456789";
	var validSpecial = "!#$%&'*+-/=?^_`{|}~.";

	//method: must be an @ (it need be unique but its not a valid character so will be filtered out anyway), not at the beginning. (needs to not be at the end, but well check the rest of the string soon)
	//preceding the @ must be valid characters only, with . neither beginning nor the character before the @
	//following the @ must be alphanumeric only, followed by at least 1 .
	//after the last . there must be at least 2 CHARACTERS

	if (str.indexOf(at)==-1 || str.indexOf(at)==0)
		return false;

	var atPos = str.indexOf(at);
	var emailName = str.substr(0, atPos);
	if ( !validString(emailName, validAlpha + validNumeric + validSpecial) || emailName.indexOf(dot)==0 || emailName.lastIndexOf(dot)==emailName.length-1)
		return false;

	//checks <=0 for it not being there at all, or if its the first
	var emailDomain = str.substr(atPos+1, str.length-emailName.length)
	if ( !validString(emailDomain, validAlpha + validNumeric + dot) || emailDomain.indexOf(dot)<=0 || emailDomain.lastIndexOf(dot)>=emailDomain.length-2)
		return false;

  return true;			
}

function ValidateForm(){

	var emailID=document.feedback.email;
	
	// strip leading and trailing whitespace
	// for reference, refer to w3schools replace function
	// and this site for special character explanation
	// http://www.devguru.com/Technologies/ecmascript/quickref/regexp_special_characters.html
	emailID.value = emailID.value.replace(/^\s+|\s+$/g,"");

	if (!echeck(emailID.value)){
    alert("Please Enter a Valid E-mail Address");
		emailID.focus();
		return false;
	}
	
	return true;
 }