$(document).ready(function(){

var captions = $(".caption");

jQuery.each(captions, function() {
      var arr = $(this).html().split('.');
      var htmlStr = arr[0].replace('/', '');
      $(this).html(htmlStr);
});


var imgArray = jQuery.makeArray($("#thumbs .thumb"));
  if (imgArray.length <= 1){ $("#controls").hide(); }


// Initialize Minimal Galleriffic Gallery
if (imgArray.length){
  $('#gallery').galleriffic('#thumbs', {
    imageContainerSel:      '#slideshow',
                captionContainerSel:    '#caption',
                autoStart:              true,
                delay:                  4000,
                numThumbs:              8,
                playLinkText:           'Play',
          pauseLinkText:          'Pause',
    prevLinkText:           '&laquo; Previous',
    nextLinkText:           'Next &raquo;',
    controlsContainerSel:   '#controls',
    enableBottomPager:      true,
    onTransitionOut:        function(callback) {
                    if (imgArray.length > 1){
      $('#caption').fadeOut('fast');
      $('#slideshow').fadeOut('fast', callback);
                    } else {
      $('#caption').fadeOut(0);
      $('#slideshow').fadeOut(0, callback);
                    }
    },
    onTransitionIn:         function() {
                    if (imgArray.length > 1){
      $('#slideshow, #caption').fadeIn('fast');
                    } else {
      $('#slideshow, #caption').fadeIn(0);
                    }
    }
    
  });
}
  
});
