function displayCommentForm() {
	// get the url from the original link
	var commentFormURL = $("h3.commentTitle a").eq(0).attr("href")+"&fragment=true";
	
	// create container div
	if ($("#ajax-comment-form").length == 0) {
		$("h3.commentTitle").after('<div id="ajax-comment-form" style="display:none;"></div>');
	}
	
	// hide the "add comment" buttons
	$(".addCommentButton").hide();
	
	// load the comment form into the container
	$("#ajax-comment-form").addClass("loading").load(commentFormURL,{fragment:true}, function() {
		// callback
		// replace cancel btn action
		$("#cancelCommentButton").click(function() {
			removeCommentForm();
			return false;
		});
		
		$(this).removeClass("loading").slideDown();
	});	
}

function removeCommentForm() {
	$("#ajax-comment-form").slideUp(function(){
		$(this).remove();
	});
	$(".addCommentButton").show();
}

// initalize ajax-enabled comments
$(document).ready(function(){
	// replace click events on "add comment" buttons
	$(".addCommentButton").click(function() {
		displayCommentForm();
		return false;
	});
});

