jQuery(document).ready(function(jQuery){

  var imgArray = jQuery.makeArray(jQuery("#thumbs .thumb"));
  if (imgArray.length <= 1){ jQuery("#controls").hide(); }      // hide controls if only one photo
  
  // Initialize Minimal Galleriffic Gallery
  if (imgArray.length){
    jQuery('#gallery').galleriffic('#thumbs', {                // id for div that has thumbnails
      imageContainerSel:      '#slideshow',               // id for div that has slideshow
      captionContainerSel:    '#caption',                 // id for div that has caption
      autoStart:              true,                       // set to false if you don't want slideshow to start automatically
      delay:                  4000,                       // time for each image in a slideshow, in milliseconds
      numThumbs:              12,                         // number of thumbnails shown at one time (i.e., size of page when paginated)
      playLinkText:           'Play',                     // labels for slideshow controls
      pauseLinkText:          'Pause',
      prevLinkText:           '&laquo; Previous',
      nextLinkText:           'Next &raquo;',
      controlsContainerSel:   '#controls',                 // id for div that has slideshow controls
      enableBottomPager:      true,                        // show thumbnail pagination controls at bottom
      onTransitionOut:        function(callback) {         // fade out
          if (imgArray.length > 1){
            jQuery('#caption').fadeOut('fast');
            jQuery('#slideshow').fadeOut('fast', callback);
          } else {
            jQuery('#caption').fadeOut(0);
            jQuery('#slideshow').fadeOut(0, callback);
          }
      },
      onTransitionIn:         function() {                 // fade in
          if (imgArray.length > 1){
            jQuery('#slideshow, #caption').fadeIn('fast');
          } else {
            jQuery('#slideshow, #caption').fadeIn(0);
          }
      }
    });
  }
  else {
     jQuery('#empty_gallery').show();                           // if there are no images, show "empty gallery" text
  }
});