

$(document).ready(function(){

	$("li.view_com a").click(function () {

		if($(this).hasClass("hide"))

		{

			$(this).parents('.main_post:first').find('.comment').show({ width: "auto"}, 2500 );

			$(this).html('Hide '+ $(this).parents('.main_post:first').find('.comment .text-box p').length + ' Comments');

			//$(this).parent().parent().parent().animate({height: "100%;"}, 500 );

			$(this).removeClass("hide");

		}else

		{

			$(this).parents('.main_post:first').find('.comment').hide({ width: "0px"}, 2500 );

			$(this).html('View '+ $(this).parents('.main_post:first').find('.comment .text-box p').length + ' Comments ');

			//$(this).parent().parent().parent().animate({height: "60px;"}, 500 );

			$(this).addClass("hide");

		}

	});

	$("li.comment_add a").click(function () {

		if($(this).hasClass("hide_add_comment"))

		{

			$(this).parents('.main_post:first').find('.commentform').show({ width: "auto"}, 2500 );

			//$(this).parent().parent().parent().animate({height: "100%;"}, 500 );

			$(this).removeClass("hide_add_comment");

		}else

		{

			$(this).parents('.main_post:first').find('.commentform').hide({ width: "0px"}, 2500 );

			//$(this).parent().parent().parent().animate({height: "60px;"}, 500 );

			$(this).addClass("hide_add_comment");

		}

	});

	$("span.cancel_add_comment a").click(function () {

		$(this).parent().parent().parent().parent().parent().parent().parent().parent().find('.commentform').hide({ width: "auto"}, 2500 );

		$("li.comment_add a").addClass("hide_add_comment");

	});

	$("li.add_single_comment a").click(function () {

		$(this).parent().parent().parent().parent().parent().find('.commentform').show({ width: "auto"}, 2500 );

	});

	

	$(".form form").submit(function (){

		$(this).parents('.main_post:first').find('.view_com a').html('Hide '+ ($(this).parents('.main_post:first').find('.comment .text-box p').length + 1) + ' Comments');

	});

});

