
 
 (function($){
	$.fn.videoGallery = function(options){
	
		var defaults = {
            w: 320,
            h: 240,
            holderDiv: '#video-holder',
            src: 'rel',
			namei: 'name',
			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);
         namei = $(options.holderDiv).attr(options.namei);
		 
         if (options.showTitle === true){
            $(options.titleLoc)
               .text(title);
         }
         
         $(options.holderDiv)
            .html('<div  style="background:url(\'images/player.png\') no-repeat #000;width:457px;height:205px;padding-left:6px;padding-top:6px;"></div><br>');
          
		  
		  
         $(this).
            click(
               function(){
                  src = $(this).attr(options.src);
                  title = $(this).attr(options.title);
                  namei = $(this).attr(options.namei);
				  
				$(options.titleLoc).fadeOut('slow', function(){
					$(options.holderDiv).fadeOut('slow', function(){
                  $(options.holderDiv)
                     .html('<iframe style="background:url(\'images/player.png\') no-repeat #000;width:457px;height:205px;padding-left:6px;padding-top:6px;" title="YouTube video player" width="640" height="390" src="'+namei+'" frameborder="0" allowfullscreen></iframe><br>');
                  if (options.showTitle === true){
                     $(options.titleLoc)
                        .text(title);  
                  }
					$(options.titleLoc).fadeIn(1500);
					$(options.holderDiv).fadeIn(1000);
					});
				  });
			  }
            )
			
		}); // end this.each
	
	}; // end fn.videoGallery
	
})(jQuery);
