var Loop=new Class({loopCount:0,isLooping:false,loopMethod:function(){},setLoop:function(b,a){wasLooping=this.isLooping;if(wasLooping){this.stopLoop()}this.loopMethod=b;this.loopDelay=a||3000;if(wasLooping){this.startLoop()}return this},stopLoop:function(){this.isLooping=false;clearInterval(this.periodical);return this},startLoop:function(b,a){if(!this.isLooping){this.isLooping=true;if(a){this.looper()}this.periodical=this.looper.periodical(b||this.loopDelay,this)}return this},resetLoop:function(){this.loopCount=0;return this},looper:function(){this.loopCount++;this.loopMethod(this.loopCount);return this}});(function(){var a=this.SlideShow=new Class({Implements:[Options,Events,Loop],options:{delay:7000,transition:"crossFade",duration:500,autoplay:false,dataAttribute:"data-slideshow",selector:"> *",initialSlideIndex:0},transitioning:false,reversed:false,initialize:function(c,b,d){this.element=document.id(c);this.setOptions(b);if(!d){this.setup()}},setup:function(b){if(b){this.setOptions(b)}this.slides=this.element.getElements(this.options.selector);this.setupElement().setupSlides();this.current=this.current||this.slides[this.options.initialSlideIndex];this.index=this.current.retrieve("slideshow-index");this.setLoop(this.show.pass(this.reversed?"previous":"next",this),this.options.delay);if(this.options.autoplay){this.play()}return this},show:function(c,d){if(c=="next"||c=="previous"){c=this[c+"Slide"]()}if(typeof c=="number"){c=this.slides[c]}if(c==this.current||this.transitioning){return this}this.transitioning=true;this.current.store("slideshow:oldStyles",this.current.get("style"));var h=(d&&d.transition)?d.transition:c.retrieve("slideshow-transition"),g=(d&&d.duration)?d.duration:c.retrieve("slideshow-duration"),f=this.current.setStyle("z-index",1),e=this.reset(c).setStyle("z-index",0),b=this.index=e.retrieve("slideshow-index");slideData={previous:{element:f,index:f.retrieve("slideshow-index")},next:{element:e,index:b}};this.fireEvent("show",slideData);a.transitions[h]({previous:f,next:e,duration:g,instance:this});(function(){f.setStyle("display","none");this.fireEvent("showComplete",slideData);this.transitioning=false}).bind(this).delay(g);this.current=e;return this},play:function(){this.startLoop();this.fireEvent("play");return this},pause:function(){this.stopLoop();this.fireEvent("pause");return this},reverse:function(){this.setLoop(this.show.pass(this.reversed?"next":"previous",this),this.options.delay);this.reversed=!this.reversed;this.fireEvent("reverse");return this},setupElement:function(){this.storeData(this.element);this.options.duration=this.element.retrieve("slideshow-duration");this.options.transition=this.element.retrieve("slideshow-transition");this.options.delay=this.element.retrieve("slideshow-delay");if(this.element.getStyle("position")=="static"){this.element.setStyle("position","relative")}return this},setupSlides:function(){this.slides.each(function(b,c){b.store("slideshow-index",c).store("slideshow:oldStyles",b.get("style"));this.storeData(b);b.setStyle("display",(this.current||c==this.options.initialSlideIndex)?"":"none")},this);return this},storeData:function(b){var c=this.options;b.store("slideshow-transition",c.transition);b.store("slideshow-duration",c.duration);if(b==this.element){b.store("slideshow-delay",c.delay)}var d=b.get(this.options.dataAttribute);if(!d){return this}Slick.parse(d).expressions[0].each(function(e){b.store("slideshow-"+e.tag,e.pseudos[0].key)});return this},reset:function(b){return b.set("style",b.retrieve("slideshow:oldStyles"))},nextSlide:function(){return this.slides[this.index+1]||this.slides[0]},previousSlide:function(){return this.slides[this.index-1]||this.slides.getLast()},toElement:function(){return this.element}});a.transitions={};a.defineTransition=function(b,c){a.transitions[b]=c};a.defineTransitions=function(b){Object.each(b,function(d,c){a.defineTransition(c,d)})}})();Element.Properties.slideshow={set:function(a){this.get("slideshow").setup(a);return this},get:function(){var a=this.retrieve("slideshow");if(!a){a=new SlideShow(this,{},true);this.store("slideshow",a)}return a}};Element.implement({playSlideShow:function(a){this.get("slideshow").setup(a).play();return this},pauseSlideShow:function(){this.get("slideshow").pause();return this}});SlideShow.defineTransitions({none:function(a){a.previous.setStyle("display","none");return this},fade:function(a){a.previous.set("tween",{duration:a.duration}).fade("out");return this},crossFade:function(a){a.previous.set("tween",{duration:a.duration}).fade("out");a.next.set("tween",{duration:a.duration}).fade("in");return this},fadeThroughBackground:function(b){var a=b.duration/2;b.next.set("tween",{duration:a}).fade("hide");b.previous.set("tween",{duration:a,onComplete:function(){b.next.fade("in")}}).fade("out");return this}});(function(){function a(c){return{property:(c=="left"||c=="right")?"left":"top",inverted:(c=="left"||c=="up")?1:-1}}function b(c,d,e){var f={duration:e.duration,unit:"%"};if(c=="blind"){e.next.setStyle("z-index",2)}if(c!="slide"){e.next.set("tween",f).setStyle(d.property,100*d.inverted+"%");e.next.tween(d.property,0)}if(c!="blind"){e.previous.set("tween",f).tween(d.property,-(100*d.inverted))}}["left","right","up","down"].each(function(e){var f=e.capitalize(),c="blind"+f,d="slide"+f;[["push"+f,(function(){var g=a(e);return function(h){b("push",g,h)}}())],[c,(function(){var g=a(e);return function(h){b("blind",g,h)}}())],[d,(function(){var g=a(e);return function(h){b("slide",g,h)}}())],[c+"Fade",function(g){this.fade(g)[c](g);return this}]].each(function(g){SlideShow.defineTransition(g[0],g[1])})})})();
