JQuery Plugins/Classes - Which one to use?

Hi,

I’m making a custom gallery in JavaScript using the jQuery framework. However, I am a little stuck on the best method.

Basically, I need to be able to reference each gallery once they have been instantiated (to manually trigger next/previous image etc). I originally looked at the jcarousel method, whereby you save an object to the data attribute of the selected element. From this, I came up with:

;(function($)
{
    $.fn.test = function(opts)
    {
        var options = $.extend({}, $.test.defaults, opts);
        return $(this).each(function()
        {
            $(this).data('test', new $.test(this, options));
        });
    }
    
    $.test = function(e, opts){
        this.options = opts;
        this.instance = e;
    };
    
    $.test.defaults = {
        'sound'      : "TRA LA"
    }
    
    $.test.prototype.sing = sing;
    
    function sing()
    {
       alert(this.options.sound);
    }

})(jQuery);

$("#item").test({'sound' : "LAAAAA"});
$item = $("#item").data('test');
$item.sing();     // LAAAAA

This works fine with multiple instances. However, then I came across this article by John Resig.

Now I’m not sure which would be the best one to use. I’m leaning towards my first example, and if that is the best, what can I do to improve it?

Thanks in advance!