	function ValidateEmail ( form, field ) {
		var Email = document[form][field].value;
		var validEmail=0;
			// check invalid charecter
		if ( Email != "" ) {
			var invalidChars="/:,;";
			var msg="Oops! This is an invalid e-mail address";
				// check lenth a@b.com should be the shortest e-mail adress
			if (Email.length<5) {validEmail+=1;}
						
				// check invalid characters
			for (i=0; i<invalidChars.length; i++) {
				badChar=invalidChars.charAt(i);
				if (Email.indexOf(badChar,0)>-1) {
					validEmail+=1;
				}
			}	
				// check @ and "."
			var atPos = Email.indexOf("@",1);
			if ( atPos == -1 ) {
				validEmail+=1;
			} 
			else {
				if (atPos != Email.lastIndexOf("@")){
					validEmail+=1;
				}
				else {				
					periodPos=Email.indexOf(".",atPos);
					if ((periodPos-atPos)<2) {
						validEmail+=1;
					}
				}
			}
				// check no _ after @
			if (atPos<Email.lastIndexOf("_")){
				validEmail+=1;
			}		
				//output the check result
			if (validEmail != 0) {
				alert(msg);
				document[form][field].value = "";
				document[form][field].focus();
			}
		}
	}


function submitFeedback(){
	var msg = "";
	var variableArray = ["Subject", "Name", "Email", "Category", "Comment"];
	var missFields = "NO";
	for(i=0; i<5; i++){
		var field = variableArray[i]; 
		if (document.feedback[field].value == ""){
			msg += "\t";
			msg += variableArray[i];
			msg += "\n";
			missFields = "YES";
		}
	}
	if (missFields == "YES"){
		msg = "Please enter information into these fields:\n" + msg;
		alert (msg);
	}
	else{
		document.feedback.submit();
	}
}



