window.addEvent('domready', function(){
	$('comments_load_form').sendPhpr('onLoadCommentsForm', {update: 'comments_form_container'})
})

function validate_comment()
{
	if (!$('author_name').value.trim().length)
	{
		alert('Please enter your name.');
		$('author_name').focus();
		return false;
	}
	
	if ($('author_email').value.trim().length)
	{
		var re = new RegExp("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", "i");

		if (!re.test($('author_email').value.trim()))
		{
			alert('Please specify a valid email address.');
			$('author_email').focus();
			return false;
		}
	}
	
	if (!$('comment').value.trim().length)
	{
		alert('Please enter comment text.');
		$('comment').focus();
		return false;
	}
	
	$('comment_form').sendPhpr('onPostComment', {update: 'comment_form', onFailure: function(){
		$('comment_btn').removeClass('hidden');
		$('comment_send_indicator').addClass('hidden');
	}})
	
	$('comment_btn').addClass('hidden');
	$('comment_send_indicator').removeClass('hidden');
	
	return false;
}