// JavaScript Document
 (function($){
	$.fn.videoGallery = function(options){
	
		var defaults = {
            w: 413,
            h: 240,
            holderDiv: '#video-holder',
            src: 'rel',
			showTitle: true,
            title: 'title',
            titleLoc: '#video-title'
		};
		
		var options = $.extend(defaults, options);

		var element = this;
		i = 0;
		var href1 = '';
		return this.each(function(){
         src = $(options.holderDiv).attr(options.src);
         title = $(options.holderDiv).attr(options.title);
		 if(i == 0)
         href1 = $(this).find('a').attr('rel');
         if (options.showTitle === true){
            $(options.titleLoc)
               .text(title);  
         }
             $(options.holderDiv)
            .html('<a href="'+href1+'"><img src="'+src+'" border="0" width="'+options.w+'px" height="'+options.h+'px" /><img class="play_button" src="http://www.isssource.com/video_play_btn.png"></a>');
			
                  
         $(this).
            click(
               function(){
                  src = $(this).attr(options.src);
                  title = $(this).attr(options.title);
				  var ahref = $(this).find('a').attr('rel');
                  $(options.holderDiv)
                     .html('<a href="'+ahref+'"><img src="'+src+'" border="0" width="'+options.w+'px" height="'+options.h+'px" /><img class="play_button" src="http://www.isssource.com/video_play_btn.png"></a>');
					 
				  var description = $(this).find('input').attr('value');	 
				  $("#message").html('<p>'+description+'</p>');	 
				  $("#descriptionToShow").attr('value',description);
                 $(options.holderDiv).attr('title',title);
                  if (options.showTitle === true){
                     $(options.titleLoc)
                        .text(title);  
                  }
               }
            )
			i++;
		}); // end this.each
	
	}; // end fn.videoGallery
	
})(jQuery);
