$(“a.load-comments”).livequery(function() {

$(this).click(function(){ // when you click on the link

var $this = $(this);

var $grandpa = $this.parent(“div”).parent(“div”);

var commentsWrapper = $grandpa.find(“.comments-wrapper”); // find the right comments wrapper

var commentsFormWrapper = $grandpa.find(“.comments-form-wrapper”); // find the right comments form wrapper

var commentsLoader = $grandpa.find(“.comments-loader”); // find the right loader image

commentsFormWrapper.fadeOut(“fast”, function() { // hide the comments form wrapper

if(!$this.hasClass(“current”)) { // check if link is currently opened

$(“a.load-comments, a.load-comments-form”).removeClass(“current”); // remove the ‘current’ class from all other links

$this.addClass(“current”); // add current class to this link

commentsLoader.fadeIn(“fast”, function() { // fade in the loader icon

commentsWrapper.load($this.attr(“href”), function() { // load the comments

commentsLoader.fadeOut(“fast”, function() { // fade out the loader image

commentsWrapper.fadeIn(“fast”); // fade in the comments

});

});

});

} else { // we know that this has class “current”

$this.removeClass(“current”); // remove the class ‘current’

commentsWrapper.fadeOut(“fast”); // fade out comments

}

});

return false; // prevent following the link

});

});