function comments_post() {

	var f = $(this);

	var url = f.attr("action");

	var post = {}
	f.find("input").each(function(){
		post[$(this).attr("name")] = $(this).val();
	});
	f.find("textarea").each(function(){
		post[$(this).attr("name")] = $(this).val();
	});

	var id = Math.round(Math.random() * 10000);

	$.ajax({
		"type": "POST",
		"url": url,
		"data": post,
		"dataType": "html",
		"beforeSend": function(){
			f.find("input.submit-post").val("Please wait...").attr("disabled","disabled");
			f.find("textarea").attr("disabled","disabled");
		},
		"success": function(){
		
			var thingy = checkForLink(post["comment"]);

			var re = new RegExp("\n", "g");
			var commentblock = $("#commentblock").html().replace("[[comment]]", thingy.replace(re, "<br />"));
			f.siblings(".stream").append("<div id=\"newcomment_" + id + "\" style=\"display: none;\">" + "<div style=\"padding: 0.5em;\"><em>This comment is being held in moderation and will appear soon.</em></div>" + commentblock + "</div>")
			$("#newcomment_" + id).slideDown(400);

			f.find("input.submit-post").val("Comment").removeAttr("disabled");
			f.find("textarea").removeAttr("disabled").val("");

			/*
			//  For updating comment number....not working
			var numComments = f.parent().find('.comment').size();

			alert(numComments);
			var str = f.parent().parent().find('p.CommentMenu').html();
			var newstr = str.replace((numComments-1),numComments);

			alert(newstr);

			f.parent().parent().find('p.CommentMenu').replaceWith(newstr);
			*/

		}
	});

	return false;

}


function comments_show(ev) {
	$(this).parent().parent().siblings(".comments").slideDown(fadetime).fadeIn(fadetime);
	return false;
}


function comments_min() {
	$('.comments .stream').each(function() {

		var numComments = $(this).find('.comment').size();

		if(numComments > 5) {

			var x = 0;

			$(this).find('.comment').each(function() {
				if(x < (numComments-2)) {
					$(this).hide(0);
					x = x + 1;
				}
			});

			$(this).prepend("<div id=\"newcomment_min\"><a class=\"more_comments\" href=\"#\">View " + (numComments-2) + " More Comments</a></div>");

		}
	});
}


function comments_max(this1) {
	$(this1).parent().parent().find('.comment').slideDown(400);
	$(this1).parent().remove();
}

