﻿(function(){if(typeof Spry=="undefined"||!Spry.Widget||!Spry.Widget.PanelSet){alert("SpryFadingPanels.js requires SpryPanelSet.js!");return}Spry.Widget.FadingPanels=function(b,c){var a=this.setOptions(this.setOptions({},Spry.Widget.FadingPanels.config),c);Spry.Widget.PanelSet.call(this,Spry.$$(b),a)};Spry.Widget.FadingPanels.prototype=new Spry.Widget.PanelSet;Spry.Widget.FadingPanels.prototype.constructor=Spry.Widget.FadingPanels;Spry.Widget.FadingPanels.config={defaultPanel:0,minOpacity:0,maxOpacity:1,minDuration:500,maxDuration:500,stoppedMinDuration:200,stoppedMaxDuration:200,visibleClass:"FadingPanelVisible",hiddenClass:"FadingPanelHidden",autoPlay:false,displayInterval:4e3,parallelTransition:true};Spry.Widget.FadingPanels.prototype.initialize=function(){var a=new Spry.Widget.Event(this);this.notifyObservers("onPreInitialize",a);if(!a.performDefaultAction)return;this.disableNotifications();Spry.Widget.PanelSet.prototype.initialize.call(this);var c=this.getPanels(),e=this.currentPanel;for(var b=0;b<c.length;b++){var d=c[b];this.setOpacity(d,d==e?this.maxOpacity:this.minOpacity)}this.enableNotifications();this.notifyObservers("onPostInitialize",a)};Spry.Widget.FadingPanels.prototype.showPanel=function(f){var b=this.indexToElement(f);if(b&&b!=this.currentPanel){var c=this.createEvent(b,{currentPanel:this.currentPanel});this.notifyObservers("onPreShowPanel",c);if(!c.performDefaultAction)return;if(this.showEffect&&!this.parallelTransition)this.showEffect.stop();if(this.hideEffect&&!this.parallelTransition)this.hideEffect.stop();var e=this.currentPanel;this.currentPanel=b;var a=this,d=function(){a.currentPanel=b;a.addClassName(b,a.visibleClass);a.removeClassName(b,a.hiddenClass);a.notifyObservers("onPreShowPanelEffect",c);a.showEffect=new Spry.Effect.CSSAnimator(b,"opacity: "+a.maxOpacity,{duration:a.isPlaying()?a.maxDuration:a.stoppedMaxDuration});a.showEffect.addObserver({onAnimationComplete:function(){a.showEffect=null;a.notifyObservers("onPostShowPanelEffect",c)}});a.showEffect.start();a.notifyObservers("onPostShowPanel",c)};if(e)this.hidePanel(e,d);else d()}};Spry.Widget.FadingPanels.prototype.hidePanel=function(f,e){var b=this.indexToElement(f);if(b){var c=this.createEvent(b);this.notifyObservers("onPreHidePanel",c);if(!c.performDefaultAction)return;this.currentPanel=null;var a=this,d=function(){a.addClassName(b,a.hiddenClass);a.removeClassName(b,a.visibleClass);a.notifyObservers("onPostHidePanel",c);if(e)e()};this.notifyObservers("onPreHidePanelEffect",c);this.hideEffect=new Spry.Effect.CSSAnimator(b,"opacity: "+this.minOpacity,{duration:this.isPlaying()?this.minDuration:this.stoppedMinDuration});this.hideEffect.addObserver({onAnimationComplete:function(){a.hideEffect=null;a.notifyObservers("onPostHidePanelEffect",c);if(!a.parallelTransition)d()}});this.hideEffect.start();if(this.parallelTransition)d()}}})()
