 /*
 * Copyright (c) 2008 John McMullen (http://www.smple.com)
 * This is licensed under GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * For a copy of the GNU General Public License, see <http://www.gnu.org/licenses/>.
 *
*/

 (function($){
	$.fn.videoGallery = function(options){

		var defaults = {
            w: 320,
            h: 240,
            holderDiv: '#video-holder',
            src: 'rel',
			showTitle: true,
			showDescrizione: true,
            title: 'title',
			descrizione: 'descrizione',
            titleLoc: '#video-title',
			descLoc: '#video-descrizione'
		};

		var options = $.extend(defaults, options);

		var element = this;

		return this.each(function(){
         src = $(options.holderDiv).attr(options.src);
         title = $(options.holderDiv).attr(options.title);
	     descrizione = $(options.holderDiv).attr(options.descrizione);


         if (options.showTitle === true){
            $(options.titleLoc)
               .text(title);
         }
		 if (options.showDescrizione=== true){
					$(options.descLoc)
					   .text(descrizione);
				 }

         $(options.holderDiv).
            html('<object width="504" height="289" id="pano"><param name="wmode" value="transparent" name="movie" value="http://vimeo.com/moogaloop.swf?clip_id='+ src +'&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><embed src="http://vimeo.com/moogaloop.swf?clip_id='+ src +'&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" wmode="transparent" allowscriptaccess="always" width="504" height="289"></embed></object> ');

         $(this).
            click(
               function(){
                  src = $(this).attr(options.src);
                  title = $(this).attr(options.title);
			      descrizione = $(this).attr(options.descrizione);

                  $(options.holderDiv).
                     html('<object width="504" height="289" id="pano"><param name="wmode" value="transparent"  name="movie" value="http://vimeo.com/moogaloop.swf?clip_id='+ src +'&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><embed src="http://vimeo.com/moogaloop.swf?clip_id='+ src +'&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" type="application/x-shockwave-flash" wmode="transparent" allowfullscreen="true" allowscriptaccess="always" width="504" height="289"></embed></object> ');

                  if (options.showTitle === true){
                     $(options.titleLoc)
                        .text(title);
                  }
				  if (options.showDescrizione=== true){
									 $(options.descLoc)
										.text(descrizione);
								  }
               }
            )
		}); // end this.each

	}; // end fn.videoGallery

})(jQuery);
