Understanding basic jQuery structure
===

I'm learning jQuery, and am attempting to understand the following code structure.


    if(jQuery) (function($){
    	$.extend($.fn, {
    		MyPlugin: function(a, b) {
    		....		
    		}
    	});
    })(jQuery);

From what I can tell, this first checks to see if the jQuery object exists.  If it does, it defines an inline function, which extends the jQuery object using the 'fn' attribute.  

I've seen this question asked in a couple other places, [for example here][1], but the points I'm not understanding haven't been addressed.  Where I'm getting confused...

-why is the special jquery "$" object passed to the initial function?

-why is the inline function passed the jQuery object (on the last line)?  ie: (function($) {...})(jQuery);

Thanks.


  [1]: http://stackoverflow.com/questions/6576498/understanding-jquery-plugin-development-pattern