function validateSurveyEmail() {

	var msg = ""; var msgComplete = ""; var email = document.surveyForm.textEmailAddress.value;

	if ( (document.surveyForm.textAreaWhy.value == "") && (document.surveyForm.textAreaNotCompleteReason.value == "") && (document.surveyForm.radioAbleComplete.checked = "undefined") && (document.surveyForm.textEmailAddress.value == "") ) {
		msgComplete = "Please complete the Survey form before submitting\n";
	}
	
	if (!check_email(email)) {
		msg = "Please enter a valid email address";
		document.surveyForm.textEmailAddress.select();
	}

	if ((msg.length == 0) && (msgComplete.length == 0)) {
		document.surveyForm.submit();
	} else { 
		if (msgComplete.length != 0) { alert(msgComplete); }
		else { alert(msg); }
	}

}

function check_email(e) {
	ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";
	for(i=0; i < e.length ;i++) {
		if(ok.indexOf(e.charAt(i))<0) {
			return (false);
		}	
	}	 

	if (document.images) {
		re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
		re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
		if (!e.match(re) && e.match(re_two)) {
			return (-1);		
		} 
	}
}
