(function(a){var b={},c=0;a.galleriffic={version:"2.0.1",normalizeHash:function(a){return a.replace(/^.*#/,"").replace(/\?.*$/,"")},getImage:function(c){return c?(c=a.galleriffic.normalizeHash(c),b[c]):void 0},gotoImage:function(b){var c=a.galleriffic.getImage(b);if(!c)return!1;var d=c.gallery;return d.gotoImage(c),!0},removeImageByHash:function(b,c){var d=a.galleriffic.getImage(b);if(!d)return!1;var e=d.gallery;return c&&c!=e?!1:e.removeImageByIndex(d.index)}};var d={delay:3e3,numThumbs:20,preloadAhead:40,enableTopPager:!1,enableBottomPager:!0,maxPagesToShow:7,imageContainerSel:"",captionContainerSel:"",controlsContainerSel:"",loadingContainerSel:"",renderSSControls:!0,renderNavControls:!0,playLinkText:"Play",pauseLinkText:"Pause",prevLinkText:"Previous",nextLinkText:"Next",nextPageLinkText:"Next ›",prevPageLinkText:"‹ Prev",enableHistory:!1,enableKeyboardNavigation:!0,autoStart:!1,syncTransitions:!1,defaultTransitionDuration:1e3,onSlideChange:void 0,onTransitionOut:void 0,onTransitionIn:void 0,onPageTransitionOut:void 0,onPageTransitionIn:void 0,onImageAdded:void 0,onImageRemoved:void 0};a.fn.galleriffic=function(e){a.extend(this,{version:a.galleriffic.version,isSlideshowRunning:!1,slideshowTimeout:void 0,clickHandler:function(b,c){if(this.pause(),!this.enableHistory){var d=a.galleriffic.normalizeHash(a(c).attr("href"));a.galleriffic.gotoImage(d),b.preventDefault()}},appendImage:function(a){return this.addImage(a,!1,!1),this},insertImage:function(a,b){return this.addImage(a,!1,!0,b),this},addImage:function(d,e,f,g){var h="string"==typeof d?a(d):d,i=h.find("a.thumb"),j=i.attr("href"),k=i.attr("title"),l=h.find(".caption").remove(),m=i.attr("name");c++,(!m||b[""+m])&&(m=c),f||(g=this.data.length);var n={title:k,slideUrl:j,caption:l,hash:m,gallery:this,index:g};f?(this.data.splice(g,0,n),this.updateIndices(g)):this.data.push(n);var o=this;return e||this.updateThumbs(function(){var a=o.find("ul.thumbs");f?a.children(":eq("+g+")").before(h):a.append(h),o.onImageAdded&&o.onImageAdded(n,h)}),b[""+m]=n,i.attr("rel","history").attr("href","#"+m).removeAttr("name").click(function(a){o.clickHandler(a,this)}),this},removeImageByIndex:function(a){if(0>a||a>=this.data.length)return!1;var b=this.data[a];return b?(this.removeImage(b),!0):!1},removeImageByHash:function(b){return a.galleriffic.removeImageByHash(b,this)},removeImage:function(a){var c=a.index;return this.data.splice(c,1),delete b[""+a.hash],this.updateThumbs(function(){var b=f.find("ul.thumbs").children(":eq("+c+")").remove();f.onImageRemoved&&f.onImageRemoved(a,b)}),this.updateIndices(c),this},updateIndices:function(a){for(i=a;this.data.length>i;i++)this.data[i].index=i;return this},initializeThumbs:function(){this.data=[];var b=this;return this.find("ul.thumbs > li").each(function(){b.addImage(a(this),!0,!1)}),this},isPreloadComplete:!1,preloadInit:function(){if(0==this.preloadAhead)return this;this.preloadStartIndex=this.currentImage.index;var a=this.getNextIndex(this.preloadStartIndex);return this.preloadRecursive(this.preloadStartIndex,a)},preloadRelocate:function(a){return this.preloadStartIndex=a,this},preloadRecursive:function(a,b){if(a!=this.preloadStartIndex){var c=this.getNextIndex(this.preloadStartIndex);return this.preloadRecursive(this.preloadStartIndex,c)}var d=this,e=b-a;if(0>e&&(e=this.data.length-1-a+b),this.preloadAhead>=0&&e>this.preloadAhead)return setTimeout(function(){d.preloadRecursive(a,b)},500),this;var f=this.data[b];if(!f)return this;if(f.image)return this.preloadNext(a,b);var g=new Image;return g.onload=function(){f.image=this,d.preloadNext(a,b)},g.alt=f.title,g.src=f.slideUrl,this},preloadNext:function(a,b){var c=this.getNextIndex(b);if(c==a)this.isPreloadComplete=!0;else{var d=this;setTimeout(function(){d.preloadRecursive(a,c)},100)}return this},getNextIndex:function(a){var b=a+1;return b>=this.data.length&&(b=0),b},getPrevIndex:function(a){var b=a-1;return 0>b&&(b=this.data.length-1),b},pause:function(){return this.isSlideshowRunning=!1,this.slideshowTimeout&&(clearTimeout(this.slideshowTimeout),this.slideshowTimeout=void 0),this.$controlsContainer&&this.$controlsContainer.find("div.ss-controls a").removeClass().addClass("play").attr("title",this.playLinkText).attr("href","#play").html(this.playLinkText),this},play:function(){if(this.isSlideshowRunning=!0,this.$controlsContainer&&this.$controlsContainer.find("div.ss-controls a").removeClass().addClass("pause").attr("title",this.pauseLinkText).attr("href","#pause").html(this.pauseLinkText),!this.slideshowTimeout){var a=this;this.slideshowTimeout=setTimeout(function(){a.ssAdvance()},this.delay)}return this},toggleSlideshow:function(){return this.isSlideshowRunning?this.pause():this.play(),this},ssAdvance:function(){return this.isSlideshowRunning&&this.next(!0),this},next:function(a,b){return this.gotoIndex(this.getNextIndex(this.currentImage.index),a,b),this},previous:function(a,b){return this.gotoIndex(this.getPrevIndex(this.currentImage.index),a,b),this},nextPage:function(a,b){var c=this.getCurrentPage(),d=this.getNumPages()-1;if(d>c){var e=c*this.numThumbs,f=e+this.numThumbs;this.gotoIndex(f,a,b)}return this},previousPage:function(a,b){var c=this.getCurrentPage();if(c>0){var d=c*this.numThumbs,e=d-this.numThumbs;this.gotoIndex(e,a,b)}return this},gotoIndex:function(b,c,d){c||this.pause(),0>b?b=0:b>=this.data.length&&(b=this.data.length-1);var e=this.data[b];return!d&&this.enableHistory?a.historyLoad(e.hash+""):this.gotoImage(e),this},gotoImage:function(a){var b=a.index;return this.onSlideChange&&this.onSlideChange(this.currentImage.index,b),this.currentImage=a,this.preloadRelocate(b),this.refresh(),this},getDefaultTransitionDuration:function(a){return a?this.defaultTransitionDuration:this.defaultTransitionDuration/2},refresh:function(){var a=this.currentImage;if(!a)return this;var b=a.index;this.$controlsContainer&&this.$controlsContainer.find("div.nav-controls a.prev").attr("href","#"+this.data[this.getPrevIndex(b)].hash).end().find("div.nav-controls a.next").attr("href","#"+this.data[this.getNextIndex(b)].hash);var c=this.$imageContainer.find("span.current").addClass("previous").removeClass("current"),d=0;this.$captionContainer&&(d=this.$captionContainer.find("span.current").addClass("previous").removeClass("current"));var e=this.syncTransitions&&a.image,f=!0,g=this,h=function(){f=!1,c.remove(),d&&d.remove(),e||(a.image&&a.hash==g.data[g.currentImage.index].hash?g.buildImage(a,e):g.$loadingContainer&&g.$loadingContainer.show())};if(0==c.length?h():this.onTransitionOut?this.onTransitionOut(c,d,e,h):(c.fadeTo(this.getDefaultTransitionDuration(e),0,h),d&&d.fadeTo(this.getDefaultTransitionDuration(e),0)),e&&this.buildImage(a,e),!a.image){var i=new Image;i.onload=function(){a.image=this,f||a.hash!=g.data[g.currentImage.index].hash||g.buildImage(a,e)},i.alt=a.title,i.src=a.slideUrl}return this.relocatePreload=!0,this.syncThumbs()},buildImage:function(a,b){var c=this,d=this.getNextIndex(a.index),e=this.$imageContainer.append(' ').find("span.current").css("opacity","0");e.find("a").append(a.image).click(function(a){c.clickHandler(a,this)});var f=0;return this.$captionContainer&&(f=this.$captionContainer.append('').find("span.current").css("opacity","0").append(a.caption)),this.$loadingContainer&&this.$loadingContainer.hide(),this.onTransitionIn?this.onTransitionIn(e,f,b):(e.fadeTo(this.getDefaultTransitionDuration(b),1),f&&f.fadeTo(this.getDefaultTransitionDuration(b),1)),this.isSlideshowRunning&&(this.slideshowTimeout&&clearTimeout(this.slideshowTimeout),this.slideshowTimeout=setTimeout(function(){c.ssAdvance()},this.delay)),this},getCurrentPage:function(){return Math.floor(this.currentImage.index/this.numThumbs)},syncThumbs:function(){var a=this.getCurrentPage();a!=this.displayedPage&&this.updateThumbs();var b=this.find("ul.thumbs").children();return b.filter(".selected").removeClass("selected"),b.eq(this.currentImage.index).addClass("selected"),this},updateThumbs:function(a){var b=this,c=function(){a&&a(),b.rebuildThumbs(),b.onPageTransitionIn?b.onPageTransitionIn():b.show()};return this.onPageTransitionOut?this.onPageTransitionOut(c):(this.hide(),c()),this},rebuildThumbs:function(){var b=this.data.length>this.numThumbs;if(this.enableTopPager){var c=this.find("div.top");0==c.length?c=this.prepend('
').find("div.top"):c.empty(),b&&this.buildPager(c)}if(this.enableBottomPager){var d=this.find("div.bottom");0==d.length?d=this.append('').find("div.bottom"):d.empty(),b&&this.buildPager(d)}var e=this.getCurrentPage(),f=e*this.numThumbs,g=f+this.numThumbs-1;g>=this.data.length&&(g=this.data.length-1);var h=this.find("ul.thumbs");return h.find("li").each(function(b){var c=a(this);b>=f&&g>=b?c.show():c.hide()}),this.displayedPage=e,h.removeClass("noscript"),this},getNumPages:function(){return Math.ceil(this.data.length/this.numThumbs)},buildPager:function(a){var b=this,c=this.getNumPages(),d=this.getCurrentPage(),e=d*this.numThumbs,f=this.maxPagesToShow-1,g=d-Math.floor((this.maxPagesToShow-1)/2)+1;if(g>0){var h=c-g;f>h&&(g-=f-h)}if(0>g&&(g=0),d>0){var i=e-this.numThumbs;a.append(''+this.prevPageLinkText+"")}for(g>0&&(this.buildPageLink(a,0,c),g>1&&a.append('…'),f--);f>0;)this.buildPageLink(a,g,c),f--,g++;if(c>g){var j=c-1;j>g&&a.append('…'),this.buildPageLink(a,j,c)}var k=e+this.numThumbs;return this.data.length>k&&a.append(''+this.nextPageLinkText+""),a.find("a").click(function(a){b.clickHandler(a,this)}),this},buildPageLink:function(a,b,c){var d=b+1,e=this.getCurrentPage();if(b==e)a.append(''+d+"");else if(c>b){var f=b*this.numThumbs;a.append(''+d+"")}return this}}),a.extend(this,d,e),this.enableHistory&&!a.historyInit&&(this.enableHistory=!1),this.imageContainerSel&&(this.$imageContainer=a(this.imageContainerSel)),this.captionContainerSel&&(this.$captionContainer=a(this.captionContainerSel)),this.loadingContainerSel&&(this.$loadingContainer=a(this.loadingContainerSel)),this.initializeThumbs(),3>this.maxPagesToShow&&(this.maxPagesToShow=3),this.displayedPage=-1,this.currentImage=this.data[0];var f=this;this.$loadingContainer&&this.$loadingContainer.hide(),this.controlsContainerSel&&(this.$controlsContainer=a(this.controlsContainerSel).empty(),this.renderSSControls&&(this.autoStart?this.$controlsContainer.append('"):this.$controlsContainer.append('"),this.$controlsContainer.find("div.ss-controls a").click(function(a){return f.toggleSlideshow(),a.preventDefault(),!1})),this.renderNavControls&&this.$controlsContainer.append(' ").find("div.nav-controls a").click(function(a){f.clickHandler(a,this)}));var g=!this.enableHistory||!location.hash;if(this.enableHistory&&location.hash){var h=a.galleriffic.normalizeHash(location.hash),j=b[h];j||(g=!0)}return g&&this.gotoIndex(0,!1,!0),this.enableKeyboardNavigation&&a(document).keydown(function(a){var b=a.charCode?a.charCode:a.keyCode?a.keyCode:0;switch(b){case 32:f.next(),a.preventDefault();break;case 33:f.previousPage(),a.preventDefault();break;case 34:f.nextPage(),a.preventDefault();break;case 35:f.gotoIndex(f.data.length-1),a.preventDefault();break;case 36:f.gotoIndex(0),a.preventDefault();break;case 37:f.previous(),a.preventDefault();break;case 39:f.next(),a.preventDefault()}}),this.autoStart&&this.play(),setTimeout(function(){f.preloadInit()},1e3),this}})(jQuery);