/*
 ADOBE CONFIDENTIAL
 ___________________

 Copyright 2011 Adobe Systems Incorporated
 All Rights Reserved.

 NOTICE:  All information contained herein is, and remains
 the property of Adobe Systems Incorporated and its suppliers,
 if any.  The intellectual and technical concepts contained
 herein are proprietary to Adobe Systems Incorporated and its
 suppliers and may be covered by U.S. and Foreign Patents,
 patents in process, and are protected by trade secret or copyright law.
 Dissemination of this information or reproduction of this material
 is strictly forbidden unless prior written permission is obtained
 from Adobe Systems Incorporated.
*/
Muse.Plugins.SlideShow=function(){};Muse.Plugins.SlideShow.prototype.initialize=function(a){a.observers.push(this)};
Muse.Plugins.SlideShow.prototype.onPreTransformMarkup=function(a,b){if(Spry.Utils.hasClassName(a.element,"SlideShowWidget")){b.preventDefault();Spry.$$("."+a.countClass,a.element).forEach(function(a){a.contentContainer=Muse.Utils.firstDescendant(a,Muse.Utils.Match.byNodeName("p"));if(!a.contentContainer)a.contentContainer=Muse.Utils.firstDescendant(a,Muse.Utils.Match.byNodeName("span"))});var c=Spry.$$("."+a.slideClass,a.element);if(a.plugIns.indexOf(Spry.Widget.ContentSlideShow.slideTransitionPlugin)!=
-1){var d=Spry.$$(".SlideShowContentPanel",a.element),e=document.createElement("div");e.className=a.clipClass;Muse.Utils.wrapElement(d[0],e);var f=Spry.$$(e),g=void 0;Muse.Utils.getStyleValue(d[0],"position")=="absolute"&&(e=Muse.Utils.getStyleValue(d[0],"top"),g=Muse.Utils.getStyleValue(d[0],"left"),g="position:absolute; top:"+e+"px; left:"+g+"px;");var e=Muse.Utils.getStyleValue(c[0],"width")+Muse.Utils.getStyleValue(c[0],"border-left-width")+Muse.Utils.getStyleValue(c[0],"border-right-width"),
h=Muse.Utils.getStyleValue(c[0],"height")+Muse.Utils.getStyleValue(c[0],"border-top-width")+Muse.Utils.getStyleValue(c[0],"border-bottom-width"),i=e*c.length;f.setStyle((g!=void 0?g:"")+"overflow:hidden; width:"+e+"px; height:"+h+"px;");d.setStyle("position:relative; left:0px; top:0px; margin:0px; overflow:hidden; width: "+i+"px; height: "+h*c.length+"px;");for(g=0;g<c.length;g++)d=e*g,f=0*g,Spry.$$(c[g]).setStyle("left:"+d+"px; top:"+f+"px; position:absolute; margin:0px")}a.element.parentNode.className.match(/mu-query/)&&
Muse.Plugins.SlideShow.layoutThumbnails(a)}};
Muse.Plugins.SlideShow.layoutThumbnails=function(a){Spry.$$("."+a.slideLinksClass,a.element).forEach(function(b){var c=Muse.Utils.descendants(b,Muse.Utils.Match.byClass(a.slideLinkClass)),d=c[0],e=Muse.Utils.getStyleValue(d,"width"),f=Muse.Utils.getStyleValue(d,"height"),g=Muse.Utils.getStyleValue(d,"margin-right"),h=Muse.Utils.getStyleValue(d,"margin-bottom"),i=Muse.Utils.getStyleValue(d,"border-left-width"),j=Muse.Utils.getStyleValue(d,"border-right-width"),k=Muse.Utils.getStyleValue(d,"border-top-width"),
l=Muse.Utils.getStyleValue(d,"border-bottom-width"),d=Muse.Utils.getStyleValue(b,"width"),o=Muse.Utils.getStyleValue(b,"padding-left"),m=Muse.Utils.getStyleValue(b,"padding-top"),p=Math.floor((d+g)/(e+i+j+g)),r=Math.ceil(c.length/p);(b.runtimeStyle?b.runtimeStyle:b.style).height=(f+k+l)*r+h*(r-1)+"px";var q=c.length<p?c.length:p,s=Muse.Utils.pixelRound((d-(e+i+j)*q-g*(q-1))/2)+o,t=s,v=m,u=1;c.forEach(function(a){u>q&&(u=1,t=s,v+=f+k+l+h);u++>1&&(t+=e+i+j+g);a=a.runtimeStyle?a.runtimeStyle:a.style;
a.marginRight="0px";a.marginBottom="0px";a.left=t+"px";a.top=v+"px"})})};
Muse.Plugins.SlideShow.positionImage=function(a,b,c){var b=a.width,d=a.height,e=Muse.Utils.getNaturalWidth(a),f=Muse.Utils.getNaturalHeight(a);if(!(b==e&&d==f)){var g=e,h=f;if(c=="fillFrameProportionally")e>b&&f>d&&(c=e/b,g=f/d,c<g?(h=f/c,g=b):(h=d,g=e/g));else if(c=="fitContentProportionally"&&(e>b||f>d))c=e/b,g=f/d,c>g?(h=f/c,g=e/c):(h=f/g,g=e/g);a=a.runtimeStyle?a.runtimeStyle:a.style;a.width=Muse.Utils.pixelRound(g)+"px";a.height=Muse.Utils.pixelRound(h)+"px";a.marginTop=Muse.Utils.pixelRound((d-
h)/2)+"px";a.marginLeft=Muse.Utils.pixelRound((b-g)/2)+"px"}};Muse.Plugins.SlideShow.handleImageEventChange=function(a,b,c){a&&Muse.Plugins.SlideShow.positionImage(a,b,c)};
Muse.Plugins.SlideShow.handleImagePositioning=function(a,b,c){Spry.$$("."+b,a.element).forEach(function(a){Spry.$$("img",a).forEach(function(b){b&&!b.complete?(Spry.$$(b).addEventListener("load",function(b){Muse.Plugins.SlideShow.handleImageEventChange(b.target||b.srcElement,a,c)},!1),Spry.$$(b).addEventListener("error",function(b){Muse.Plugins.SlideShow.handleImageEventChange(b.target||b.srcElement,a,c)},!1)):Muse.Plugins.SlideShow.positionImage(b,a,c)})})};
Muse.Plugins.SlideShow.prototype.onPreAttachViewBehaviors=function(a){a.element.parentNode.className.match(/mu-query/)&&(Muse.Plugins.SlideShow.handleImagePositioning(a,a.slideClass,a.heroFitting),Muse.Plugins.SlideShow.handleImagePositioning(a,a.slideLinkClass,a.thumbFitting))};
Muse.Plugins.SlideShow.prototype.onPostAttachBehaviors=function(a){a.captionsSet=new Spry.Widget.PanelSet(Spry.$$(".SSSlideCaption",a.element),{dropFrames:a.dropFrames,displayInterval:a.displayInterval});for(var b=a.captionsSet.getPanels(),c=0;c<b.length;c++){var d=b[c];d.style.display=d!=a.captionsSet.getCurrentPanel()?"none":""}a.panelSet.addObserver({onPostShowPanel:function(b,c){Muse.Plugins.SlideShow.handlePostShowSlide(a,c)},onPostHidePanel:function(b,c){Muse.Plugins.SlideShow.handlePostHideSlide(a,
c)}})};Muse.Plugins.SlideShow.handlePostShowSlide=function(a,b){var c=a.captionsSet.getPanel(b.targetIndex);if(c)c.style.display="block",a.captionsSet.showPanel(c)};Muse.Plugins.SlideShow.handlePostHideSlide=function(a,b){var c=a.captionsSet.getPanel(b.targetIndex);if(c)c.style.display="none"};Muse.Plugins.SlideShow.prototype.onPostStartSlideShow=function(a){Spry.Utils.removeClassName(a.element,a.stoppedClass)};
Muse.Plugins.SlideShow.prototype.onPostStop=function(a){Spry.Utils.addClassName(a.element,a.stoppedClass)};Spry.Widget.ContentSlideShow.config.plugIns.push(new Muse.Plugins.SlideShow);Spry.Widget.ContentSlideShow.config.transitionDuration=1E3;Muse.Plugins.SlideShowLightbox=function(){};Muse.Plugins.SlideShowLightbox.prototype.initialize=function(a){a.lightboxEnabled_runtime===!0&&a.observers.push(this)};
Muse.Plugins.SlideShowLightbox.prototype.onPreInitialize=function(a){var a=$(a.element),b=a.find(".SlideShowCaptionPanel, .SSFirstButton, .SSPreviousButton, .SSNextButton, .SSLastButton, .SlideShowLabel, .SSCloseButton"),c=a.find(".SSSlide").offset();b.each(function(a,b){var f=$(b),g=f.offset();f.css({left:g.left-c.left,top:g.top-c.top})})};
Muse.Plugins.SlideShowLightbox.prototype.onPostAttachBehaviors=function(a){if(Spry.Utils.hasClassName(a.element,"SlideShowWidget")){var b=$(a.element),c=b.find(".SSClip"),d=b.find(".SlideShowContentPanel"),e=c.length>0?c:d,f=e.find(".SSSlide"),g=b.find(".SSSlideLink"),h=b.find(".SlideShowCaptionPanel, .SSFirstButton, .SSPreviousButton, .SSNextButton, .SSLastButton, .SlideShowLabel, .SSCloseButton"),b=b.find(".SSCloseButton"),i=f.outerWidth(),j=f.outerHeight(),d=d.clone().css({position:"absolute",
left:0,top:0,width:"auto",height:"auto",padding:0,margin:0}),k=$("<div class='overlayWedge'></div>"),l=d.find(".SSSlide").parent();l.append(k);l.css({height:"auto"});d.find(".SSSlide").remove();d.css({visibility:"hidden"}).appendTo("body");var l=d.outerWidth(),o=d.outerHeight();d.detach().css({visibility:""});e.css({padding:0,left:0,top:0,width:i,height:j});c.length==0&&(f.css({left:0,top:0,position:"absolute"}),e.append(f).children(":not(.SSSlide)").remove());var m=$("<div class='LightboxContent'></div>").css({position:"absolute"}).append(e).append(h.addClass("popup_element")).museOverlay({autoOpen:!1,
offsetLeft:-i/2,offsetTop:-j/2,overlayExtraWidth:l,overlayExtraHeight:o,$overlaySlice:d,$overlayWedge:k});a.lightboxContent=m.get(0);g.bind("click",function(){m.museOverlay("open");c.length>0&&a.panelSet.scrollToPage($(this).index())});b.bind("click",function(){m.museOverlay("close")})}};
Muse.Plugins.SlideShowLightbox.prototype.onPostShowSlide=function(a){var b=a.panelSet;if(b){var c=b.getPanelCount(),d=c?b.getCurrentPanelIndex()+1:0,e=[d,c];Spry.$$("."+a.countClass,a.lightboxContent).forEach(function(a){if(a.contentContainer){var b=0;Spry.Utils.preorderTraversal(a.contentContainer,function(a){if(a.nodeType==3){var c=a.nodeValue.replace(/\d+/g,function(a){if(b<e.length)return e[b++];return a});if(c!=a.nodeValue)a.nodeValue=c;if(b==e.length)return!0}return!1});if(b==0)a.contentContainer.innerHTML=
d+" of "+c}})}};Spry.Widget.ContentSlideShow.config.plugIns.push(new Muse.Plugins.SlideShowLightbox);

