$(document).ready(function(){
	$("#twitter-update-list").load("/content/badge.php");
	$("#commentform").submit(function() {
 		var valid = true;
		if ( $.trim($("#author").val()) == "" ) {
			$("#author-error").html("&nbsp;You must enter a name.");
			valid = false;
		}
		else {
			$("#author-error").html("");
		}
		if ( $.trim($("#email").val()) == "" || !isEmail($("#email").val())) {
			$("#email-error").html("&nbsp;You must enter a valid email address.");
			valid = false;
		}
		else {
			$("#email-error").html("");
		}
		if ( $.trim($("#comment").val()) == "" ) {
			$("#comment-error").html("You must enter a comment.<br />");
			valid = false;
		}
		else {
			$("#comment-error").html("");
		}
		return valid;
	});
});

function isEmail(string) {
	return (string.search(/[\S]+@[\w-]+(.[\w-]+)+/) != -1);
}
