if(typeof AC==="undefined"){var AC={}}AC.AutoGallery={};AC.AutoGallery={views:{},slideshows:{},defaultOptions:{silentTriggers:true,showFirstOnStopMovie:true,stickyHeight:true,imageLinkAutoCaptions:true,imageLinkClasses:true,useHTML5Tags:true},defaultSlideshowOptions:{autoplay:2000,delay:7000,stopAfterReturnToSection:0,discontinuousPreviousNext:false,stopOnContentTriggerClick:true},initializeAutoGalleries:function(){if(typeof this.options==="undefined"){this.options={}
}if(typeof this.slideshowOptions==="undefined"){this.slideshowOptions={}}this.options=Object.extend(this.defaultOptions,this.options);
this.slideshowOptions=Object.extend(this.defaultSlideshowOptions,this.slideshowOptions);
var p,r,j,n,l,o,q,i,m=$$(".gallery");for(p=m.length-1;p>=0;p--){if(!m[p].hasClassName("noautogallery")){i=Object.clone(this.options);
i.toEnsureInView=i.ensureInView||false;i.ensureInView=false;j=m[p].down(".gallery-view");
n=this.getContent(m[p].select("a."+j.id));for(var r=n.length-1;r>=0;r--){if(n[r].href.search("#next")>0||n[r].href.search("#previous")>0){n=n.without(n[r])
}}if(l=m[p].down("a."+j.id+'[href^="#"]')){if((o=m[p].down(".gallery-content"))||(o=m[p].down("figure"))){n.shift();
n.unshift(o);i.initialId=n.id}else{i.initialId=l.href.replace(/.*#/,"")}i=this.setOption(i,"useKeyboardNav",true);
i=this.setOption(i,"discontinuousPreviousNext",true)}else{n.unshift(j.down(".gallery-content"));
i.toEnsureInView=true}this.stick(n,j);if(m[p].hasClassName("slide-gallery")){i=this.setOption(i,"slideGallery",true);
i=this.setOption(i,"useTouchEvents",true);this.views[j.id]=new AC.ViewMaster.SlideViewer(n,j,j.id,i)
}else{this.views[j.id]=new AC.ViewMaster.Viewer(n,j,j.id,i)}this.views[j.id].setDelegate(AC.AutoGallery);
if(m[p].hasClassName("slideshow")){this.slideshows[j.id]=new AC.ViewMaster.Slideshow(this.views[j.id],"ac-autogallery-slideshow-trigger",this.slideshowOptions);
this.views[j.id].options.toEnsureInView=false}}}for(j in this.views){if(this.views[j].options.toEnsureInView){this.views[j].options.ensureInView=true
}if(q=document.location.hash.toString().replace(/^#/,"")){if(this.views[j].orderedSections.indexOf(q)!==-1){this.views[j].show(this.views[j].sectionWithId(q))
}}}},getContent:function(f){var h,g,j=[],i=[];for(g=0;g<f.length;g++){h=f[g].getAttribute("href").split("#")[1];
if(h!=="next"&&h!=="previous"&&h!=="SwapViewPreviousSelection"&&h!=="SwapViewFirstSection"){if(i.indexOf(h)===-1){i.push(h);
j.push(f[g])}}}return j},setOption:function(e,d,f){if(!e||!d||!f){return null}if(!(d in this.options)){e[d]=f
}return e},stick:function(k,n){var h,i,j,m,l=0;if(k[0].tagName.toLowerCase()!="a"){h=k[0]
}if(!h){h=n}if(h&&(i=h.getHeight())){n.style.height=i+"px";if((j=n.up(".slide-gallery"))&&(l=j.getWidth())){if(n.getWidth()<=l){n.style.width=(l*k.length)+"px"
}j.style.width=l+"px";j.style.height=i+"px"}}},bringGalleryTo:function(k,n,h,j){var i,m,l;
if(k){if(i=k.up(".gallery")){i.style.zIndex=j}if(l=i.up(".section")){l.style.zIndex=j;
if(m=l.next(".section")){m.style.zIndex=1}}if(n&&n.content){n.content.style.zIndex=j
}if(h&&h.content){h.content.style.zIndex=j}}},willShow:function(e,h,f){var g=e.view.view();
if((f.hasMovie()||f.content.down("a.movieLink"))&&e.options.showFirstOnStopMovie){for(e in this.views){if(this.views[e].currentSection.hasMovie()||this.views[e].currentSection.content.down("a.movieLink")){this.views[e].showFirst()
}}}if((f.hasMovie()||f.content.down("a.movieLink"))||(h&&(h.hasMovie()||h.content.down("a.movieLink")))){this.bringGalleryTo(g,h,f,f.content.getAttribute("data-z")||"10")
}if(h&&h.caption&&e.options.slideGallery){h.caption.setOpacity("0")}},didShow:function(o,n,p){var l=o.view.view(),i,j,m,k;
if(n&&n.hasMovie()){this.bringGalleryTo(l,n,p,"1")}if(p&&p.caption&&o.options.slideGallery){p.caption.setOpacity("1")
}}};Event.onDOMReady(AC.AutoGallery.initializeAutoGalleries.bind(AC.AutoGallery));
