$(document).ready(function() {

  $("a[rel=lightbox]").fancybox({
  	'transitionIn'		: 'none',
  	'transitionOut'		: 'none',
  	'titlePosition' 	: 'over',
  	'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
  		return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
  	}
  });
  
  $('.slideshow').cycle({
		fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		timeout: 6000,
		speed: 2000
	});
	
  // Load theme
  Galleria.loadTheme('/_/javascripts/galleria/classic/galleria.classic.js');

  // intiialize flickr plugin
  var api_key = 'cf67c18436081a3855c7e6119bb530d6'; // get your API key at Flickr
  var flickr = new Galleria.Flickr(api_key);

  // inject a user's photostrem photset into galleria
  flickr.getUser('53787743@N08', { 
      size: 'big',
      description: true // set this to true to fetch flickr descriptions
  }, function(data) {
      $('#galleria').galleria({
          data_source: data, // add the flickr data
          show_imagenav: false, // remove the prev/next arrows
          extend: function() {
              var gallery = this; // save the scope
              $('#nav a').click(function(e) {
                  e.preventDefault(); // prevent default actions on the links
              })
              // attach gallery methods to links:
              $('#g_prev').click(function() {
                  gallery.prev();
              });
              $('#g_next').click(function() {
                  gallery.next();
              });
              $('#g_play').click(function() {
                  gallery.play();
              });
              $('#g_pause').click(function() {
                  gallery.pause();
              });
              $('#g_fullscreen').click(function() {
                  gallery.enterFullscreen();
              });
          }
      });
  });	

});

