 (function($){
	$.fn.videoGallery = function(options){

		var defaults = {
            w: 300,
            h: 300,
            holderDiv: '#video-holder',
            src: 'rel',
			showTitle: true,
            title: 'title',
            titleLoc: '#video-title'
		};

		var options = $.extend(defaults, options);

		var element = this;

		return this.each(function(){
         src = $(options.holderDiv).attr(options.src);
         title = $(options.holderDiv).attr(options.title);

         if (options.showTitle === true){
            $(options.titleLoc)
               .text(title);
         }

         $(options.holderDiv)
            .html('<object width="'+options.w+'px" height="'+options.h+'px" wmode="transparent" ><param name="wmode" value="transparent" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="'+src+'.swf" /><embed src="'+src+'.swf" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="'+options.w+'px" height="'+options.h+'px" wmode="transparent" ></embed></object>');

         $(this).
            click(
               function(){
                  src = $(this).attr(options.src);
                  title = $(this).attr(options.title);

                  $(options.holderDiv)
                     .html('<object width="'+options.w+'px" height="'+options.h+'px" wmode="transparent" ><param name="wmode" value="transparent" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="'+src+'.swf" /><embed src="'+src+'.swf" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="'+options.w+'px" height="'+options.h+'px" wmode="transparent" ></embed></object>');

                  if (options.showTitle === true){
                     $(options.titleLoc)
                        .text(title);
                  }
               }
            )
		}); // end this.each

	}; // end fn.videoGallery

})(jQuery);
