


function validateCommentForm(){
	
	var commentform = document.forms['commentform'];
	var authorObj = 	commentform.author;
	var authorError = 	document.getElementById("authorError"); 
	if (authorError && !((typeof authorError) == 'undefined')) authorError.innerHTML = "&nbsp;";
	var emailObj = 		commentform.email;
	var emailError = 	document.getElementById("emailError");
	if (emailError && !((typeof emailError) == 'undefined')) emailError.innerHTML = "&nbsp;";
	var commentObj = 	commentform.comment;
	var commentError = 	document.getElementById("commentError"); 
	if (commentError && !((typeof commentError) == 'undefined')) commentError.innerHTML = "&nbsp;";
	
	var cleanForm = true;

	
	if (authorObj && (authorObj.value == '' || (typeof authorObj.value) == 'undefined' )) {
		authorError.innerHTML = "Author name is required."
		cleanForm = false;
	}
	if (emailObj && (emailObj.value == '' || (typeof emailObj.value) == 'undefined' )) {
		emailError.innerHTML = "Email is required."
		cleanForm = false;
	}
	if (emailObj && !IsValidEmailAddress(emailObj.value)) {
		emailError.innerHTML = "Please enter a valid Email address."
		cleanForm = false;
	}
	if (commentObj && (commentObj.value == '' || (typeof commentObj.value) == 'undefined')) {
		commentError.innerHTML = "Please enter a comment."
		cleanForm = false;
	}

	return cleanForm;

	
	
}


//if the value is a valid email address
function IsValidEmailAddress(value)
{
    if (value == "")
        return true;
    var regExpr = "^[a-zA-Z0-9\-\._]+\@([a-zA-Z0-9\-]+\.)+([a-zA-Z0-9]{2,4})$";
    return IsValidRegularExpression(value, regExpr)
}

//if the value matched the regular expression
function IsValidRegularExpression(value, regExpr)
{
    var rexp = new RegExp(regExpr);
    return rexp.test(value);
}