(function($) {
    $.fn.extend({
        imageGallery: function(options) {

            var defaults = {
            	images: [],
            	title: 'Default'
            };

            var config = $.extend(true, {}, defaults, options);

            this.each(function() {
                var tElement = $(this);
                
		tElement.click(function() {
			return false;
		})
		.dialog({
			lang: {
				header: 'Image Gallery - ' + config.title
			},
			onContentLoad: function(obj, dialog) {
				$.each(config.images, function() {
					var tDiv = $('<div />');
					var tImg = $('<img />').attr({
							src: this.Source,
							alt: this.AltText
					});
					tDiv.append(tImg);
					var tDescr = $('<h3 />').text(this.AltText);
					dialog.append(tDescr).append(tDiv);
				});
			}
		});
                
            });

        }
    });
})(jQuery);
