$(document).ready(function(){
  if ( $('a#next').length > 0 ) {    
    $('a#next').click(function(e) {
      e.preventDefault();
      $('.thumbs .selected').next().find('a').click();
    });

    $('a#prev').click(function(e) {
      e.preventDefault();
      $('.thumbs .selected').prev().find('a').click();
    });
  }

  if ( $('#gallery-thumbs').length > 0 ) {
    $('#gallery-thumbs').galleriffic({
      delay:                     0, // in milliseconds
      numThumbs:                 15, // The number of thumbnails to show page
      preloadAhead:              -1, // Set to -1 to preload all images
      enableTopPager:            false,
      enableBottomPager:         true,
      maxPagesToShow:            20,  // The maximum number of pages to display in either the top or bottom pager
      imageContainerSel:         '#gallery-slideshow', // The CSS selector for the element within which the main slideshow image should be rendered
      captionContainerSel:       '#gallery-caption', // The CSS selector for the element within which the captions should be rendered
      loadingContainerSel:       '#gallery-loading', // The CSS selector for the element within which should be shown when an image is loading
      loadingContainerSel:       '#gallery-controls', // The CSS selector for the element within which should be shown when an image is loading
      renderSSControls:          false, // Specifies whether the slideshow's Play and Pause links should be rendered
      renderNavControls:         false, // Specifies whether the slideshow's Next and Previous links should be rendered
      playLinkText:              'Play',
      pauseLinkText:             'Pause',
      prevLinkText:              'Previous',
      nextLinkText:              'Next',
      nextPageLinkText:          'Next &rsaquo;',
      prevPageLinkText:          '&lsaquo; Prev',
      defaultTransitionDuration: 0
    });
    $('#gallery a').dblclick(function(e){
      return false;
    });
  }
});

