$(document).ready(function() {
	$('.gridLinks a:nth-child(3n+1)').css('border-left','0');
	
	$('#comments input, #comments textarea').focus(function() {
		if ($(this).val()==$(this).attr('originalValue')) $(this).val('');
	}).blur(function () {
		if ($(this).val()=='') $(this).val($(this).attr('originalValue'));
	});
	
	$('#newCommentSubmit').click(function(event) {
		if ($('.newCommentName').val()==$('.newCommentName').attr('originalValue') || $('.newCommentName').val().length<2) {
			alert('Please enter your name.');
			event.preventDefault();
			$('.newCommentName').focus();
		}
		else if ($('.newCommentEmail').val()==$('.newCommentEmail').attr('originalValue') || $('.newCommentEmail').val().length<2 || !$('.newCommentEmail').val().match(/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/)) {
			alert('Please enter a valid email address.');
			event.preventDefault();
			$('.newCommentEmail').focus();
		}
		else if ($('[name=comment]').val()==$('[name=comment]').attr('originalValue') || $('[name=comment]').val().length<2) {
			alert('Please enter your comment.');
			event.preventDefault();
			$('[name=comment]').focus();
		}
		else if ($('.newCommentWebsite').val()==$('.newCommentWebsite').attr('originalValue')) $('.newCommentWebsite').val('');
		else $('#commentForm').submit();
	});
});
