/**
 * If called after window.onload - the return value is the gallery object.
 * If called before window.onload - the return value is the jQuery object (gallery container), and
 * the gallery creation will be triggered onlod... 
 */
jQuery.fn.thumbnailGallery = function() {
    if (jQuery(this).attr("id")) {
    var args = Array.prototype.slice.call(arguments, 0);
    args.unshift(jQuery(this));
    if (!DMX.DOM_READY) {
      jQuery(function() {
        DMX.include("/dmx/widgets/ThumbnailGallery/thumbnail_gallery_core.js");
        DMX.ThumbnailGallery.apply(DMX, args);
      });
    } else {
      return DMX.ThumbnailGallery.apply(DMX, args);
    }
  }
  return this;
};

