
    jQuery.fn.mtCommentPaginate = function(options) {

	settings = jQuery.extend({
		blockSelector: 'ol.commentlist'
	}, options);

	blocks = jQuery(settings.blockSelector);
	currentBlock = 0;
	currentLink = null;

	numberOfBlocks = blocks.length;
	if (numberOfBlocks == 1)
	{
		numberOfComments = jQuery(blocks[0]).children().length;
		if (numberOfComments == 0)
			return this;
	}

        pager = jQuery(this);
	current = jQuery('<span class="page-numbers current"/>');

	//Build the links
	jQuery('<a href="#comments">&laquo; Previous</a>').appendTo(pager);

	links = [];
	for (x = 0; x < numberOfBlocks; x++) {
		links.push(
			jQuery('<a href="#comments" class="page-numbers"/>')
				.text( x+1 )
				.click(function() {
					currentLink.show();
					id = jQuery(this).text() - 1;
					current.text(jQuery(this).text());
					current.insertAfter(this);
					jQuery(this).hide();

					jQuery(blocks[currentBlock]).hide();
					jQuery(blocks[id]).css('display', 'inline');
					
					currentLink = jQuery(this);
					return false;
				})
		);
	}
	currentLink = links[0];

	for (x = 0; x < links.length; x++)
		links[x].appendTo(pager);

	jQuery('<a href="#comments">Next &raquo;</a>').appendTo(pager);

	current.text('1');
	current.insertAfter(currentLink);
	currentLink.hide();

	return this;
    };


