// Comments error checking and toggling trackback visibility

$(document).ready(function(){

	$("#commentform").submit(function(){
		$(".error").hide();
		var hasError = false;
		
		var nameVal = $("#author").val();
		if(nameVal == '') {
			$("#author").after('<span class="error">You forgot to enter your name.</span>');
			hasError = true;
		}
		
		var emailVal = $("#email").val();
		if(emailVal == '') {
			$("#email").after('<span class="error">You forgot to enter your email address.</span>');
			hasError = true;
		}
		
		var commentVal = $("#comment").val();
		if(commentVal == '') {
			$("#comment").after('<span class="error">You forgot to enter your comments.</span>');
			hasError = true;
		}
		
		if(hasError == true) {
			return false;	
		} else {
			
			/*$(this).hide();
			$("#comments_form li.buttons").append('<img src="/images/template/loading.gif" alt="Loading" id="loading" />');
			
			
			var urlVal = $("#url").val();
			var commentVal = $("#comment").val();
			var comment_post_IDVal = $("#comment_post_ID").val();
			
			$.post("/blog/wp-comments-post.php",
   				{ author: nameVal, email: emailVal, url: urlVal, comment: commentVal, comment_post_ID: comment_post_IDVal },
   					function(data){						
						//$(".commentlist").append('<li id="inserted"><div class="commentInner">'+commentVal+'</div><div class="commentData"><p class="commentmetadata"><cite><a href="'+urlVal+'" rel="external nofollow">'+nameVal+'</a></cite></li>');
						$("#respond").after('<p class="thanks">Your comment was added. I intend to have this show the comment without you having to refresh the page, but I haven&rsquo;t had time. So in the meantime, reload the page to see your comment.</p>').slideDown("normal");
						
						$("input#submit").show();
						$("#loading").remove();
						
						//alert('comment added, reload the page for the time being');
   					}
				 );
			return false;*/
			
			
			
		}
		
		
	});										   
});