/* --- Featured Comments Post Comment --- */

( function($) {

	$(document).ready(function() {
	
	$('#submit').click(function () {		
		
		var name = $('input[name=author]');
		var email = $('input[name=email]');
		var website = $('input[name=url]');
		var comment = $('textarea[name=comment]');
		var comment_post_id = $('input[name=comment_post_ID]');
		var comment_parent = $('input[name=comment_parent]');
		
		if (name.val()=='') {
			$('.featured-comment-required').fadeIn('slow');
			$('.featured-comment-success').fadeOut('slow');
			$('.featured-comment-fail').fadeOut('slow');
		}
		
		else if (email.val()=='') {
			$('.featured-comment-required').fadeIn('slow');
			$('.featured-comment-success').fadeOut('slow');
			$('.featured-comment-fail').fadeOut('slow');
		}
		
		else if (comment.val()=='') {
			$('.featured-comment-required').fadeIn('slow');
			$('.featured-comment-success').fadeOut('slow');
			$('.featured-comment-fail').fadeOut('slow');
		}
		
		var data = 'author=' + name.val() + '&email=' + email.val() + '&url=' + 
		website.val() + '&comment='  + encodeURIComponent(comment.val()) + '&comment_post_ID=' + comment_post_id.val() + '&comment_parent=' + comment_parent.val();
		
		$('.featured-comment-loading').show();
		
		$.ajax({
			url: "/wordpress/wp-comments-post-featured.php",	
			type: "POST",
			data: data,		
			cache: false,
			success: function (html) {				
				if (html==1) {					
					$('.featured-comment-add').fadeOut('slow');					
					$('.featured-comment-success').fadeIn('slow');
					$('.featured-comment-required').fadeOut('slow');
					$('.featured-comment-fail').fadeOut('slow');
				} else $('.featured-comment-fail').fadeIn('slow'); $('.featured-comment-required').fadeOut('slow');				
			}		
		});
		return false;
	});	
});	
	 } ) ( jQuery );
