$.fn.pagination = function(options) {
    var defaults = {
	loadClass: 'ajax-load',
	controllerClass : 'paginationControl'
    };
    var options = $.extend(defaults, options);
    
    var elem = $(this);
    var height = elem.height();
    var controller;
    var items;
    init();
    
    function init() {
	controller = elem.find('.'+options.controllerClass+':first');
	items = controller.find('ul li a');
	items.each(function() {
	    var item = $(this);
	    item.click(function() {
		clear();
		elem.html('');
		elem.css('height', height);
		elem.addClass(options.loadClass);
		$.get(item.attr('href'), function(responseText) {
			elem.css('height', 'auto');
			elem.removeClass(options.loadClass);
			elem.html($(responseText).html());
			init();
		    }
		);
		return false;
	    });
	});
    }
    
    function clear() {
	items.each(function() {
	    $(this).unbind('click');
	});
    }

};
