function validate(theForm) {
    var why = "";
    why += checkEmail(theForm.email.value);
    why += isEmpty(theForm.message.value,"Please enter a message");
    if (why != "") {
		alert(why);
		return false;
    }
	return true;
}

function checkEmail (strng) {
	var error="";
	if (strng == "") {
	   error = "Please enter an email address.\n";
	}

	var emailFilter=/^.+@.+\..{2,3}$/;
	if (!(emailFilter.test(strng))) { 
	   error = "Please enter a valid email address.\n";
	} else {
	//test email for illegal characters
		var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
		if (strng.match(illegalChars)) {
			error = "The email address contains invalid characters.\n";
	   }
	}
	return error;    
}

function isEmpty (str,err) {
	var error = "";
	if (str.length == 0) {
		error = err+"\n";
	}
	return error;	  
}