var SlideShow=new Class({Implements:[Options,Events,Loop],options:{delay:7000,transition:"crossFade",duration:"500",autoplay:false},initialize:function(b,a){this.setOptions(a);this.setLoop(this.showNext,this.options.delay);this.element=document.id(b);this.slides=this.element.getChildren();this.current=this.slides[0];this.transitioning=false;this.setup();if(this.options.autoplay){this.play()}},setup:function(){this.setupElement().setupSlides(true);return this},setupElement:function(){var a=this.element;if(a.getStyle("position")!="absolute"&&a!=document.body){a.setStyle("position","relative")}return this},setupSlides:function(a){this.slides.each(function(b,c){this.storeTransition(b).reset(b);if(a&&c!=0){b.setStyle("display","none")}},this);return this},storeTransition:function(a){var c=a.get("class");var b=/transition:[a-zA-Z]+/;var e=/duration:[0-9]+/;var f=(c.match(b))?c.match(b)[0].split(":")[1]:this.options.transition;var d=(c.match(e))?c.match(e)[0].split(":")[1]:this.options.duration;a.store("ssTransition",f).store("ssDuration",d);return this},resetOptions:function(a){this.options=$merge(this.options,a);this.setupSlides(false);return this},getTransition:function(a){return a.retrieve("ssTransition")},getDuration:function(a){return a.retrieve("ssDuration")},show:function(a,b){a=(typeof a=="number")?this.slides[a]:a;if(a!=this.current&&!this.transitioning){this.transitioning=true;var g=(b&&b.transition)?b.transition:this.getTransition(a),f=(b&&b.duration)?b.duration:this.getDuration(a),d=this.current.setStyle("z-index",1),c=this.reset(a);var e={previous:{element:d,index:this.slides.indexOf(d)},next:{element:c,index:this.slides.indexOf(c)}};this.fireEvent("show",e);this.transitions[g](d,c,f,this);(function(){d.setStyle("display","none");this.fireEvent("showComplete",e);this.transitioning=false}).bind(this).delay(f);this.current=c}return this},reset:function(a){return a.setStyles({position:"absolute","z-index":0,display:"block",left:0,top:0}).fade("show")},nextSlide:function(){var a=this.current.getNext();return(a)?a:this.slides[0]},previousSlide:function(){var a=this.current.getPrevious();return(a)?a:this.slides.getLast()},showNext:function(a){this.show(this.nextSlide(),a);return this},showPrevious:function(a){this.show(this.previousSlide(),a);return this},play:function(){this.startLoop();this.fireEvent("play");return this},pause:function(){this.stopLoop();this.fireEvent("pause");return this},reverse:function(){var a=(this.loopMethod==this.showNext)?this.showPrevious:this.showNext;this.setLoop(a,this.options.delay);this.fireEvent("reverse");return this},toElement:function(){return this.element}});Element.Properties.slideshow={set:function(a){var b=this.retrieve("slideshow");if(b){b.pause()}return this.eliminate("slideshow").store("slideshow:options",a)},get:function(a){if(a||!this.retrieve("slideshow")){if(a||!this.retrieve("slideshow:options")){this.set("slideshow",a)}this.store("slideshow",new SlideShow(this,this.retrieve("slideshow:options")))}return this.retrieve("slideshow")}};Element.implement({playSlideShow:function(a){this.get("slideshow",a).play();return this},pauseSlideShow:function(a){this.get("slideshow",a).pause();return this}});SlideShow.adders={transitions:{},add:function(b,a){this.transitions[b]=a;this.implement({transitions:this.transitions})},addAllThese:function(a){$A(a).each(function(b){this.add(b[0],b[1])},this)}};$extend(SlideShow,SlideShow.adders);SlideShow.implement(SlideShow.adders);SlideShow.add("fade",function(c,b,d,a){c.set("tween",{duration:d}).fade("out");return this});SlideShow.addAllThese([["none",function(c,b,d,a){c.setStyle("display","none");return this}],["crossFade",function(c,b,d,a){c.set("tween",{duration:d}).fade("out");b.set("tween",{duration:d}).fade("in");return this}],["fadeThroughBackground",function(c,b,e,a){var d=e/2;b.set("tween",{duration:d}).fade("hide");c.set("tween",{duration:d,onComplete:function(){b.fade("in")}}).fade("out")}],["pushLeft",function(c,b,d,a){var e=a.element.getSize().x;b.setStyle("left",e);new Fx.Elements([c,b],{duration:d}).start({0:{left:[-e]},1:{left:[0]}});return this}],["pushRight",function(b,f,c,a){var e=a.element.getSize().x;f.setStyle("left",-e);new Fx.Elements([b,f],{duration:c}).start({0:{left:[e]},1:{left:[0]}});return this}],["pushUp",function(b,f,c,a){var e=a.element.getSize().y;f.setStyle("top",e);new Fx.Elements([b,f],{duration:c}).start({0:{top:[-e]},1:{top:[0]}});return this}],["pushDown",function(b,f,c,a){var e=a.element.getSize().y;f.setStyle("top",-e);new Fx.Elements([b,f],{duration:c}).start({0:{top:[e]},1:{top:[0]}});return this}],["blindRight",function(b,f,c,a){var e=a.element.getSize().x;f.setStyles({left:-e,"z-index":2}).set("tween",{duration:c}).tween("left",0);return this}],["blindLeft",function(b,f,c,a){var e=a.element.getSize().x;f.setStyles({left:e,"z-index":2}).set("tween",{duration:c}).tween("left",0);return this}],["blindUp",function(b,f,c,a){var e=a.element.getSize().y;f.setStyles({top:e,"z-index":2}).set("tween",{duration:c}).tween("top",0);return this}],["blindDown",function(b,f,c,a){var e=a.element.getSize().y;f.setStyles({top:-e,"z-index":2}).set("tween",{duration:c}).tween("top",0);return this}],["blindDownFade",function(b,e,c,a){this.blindDown(b,e,c,a).fade(b,e,c,a)}],["blindUpFade",function(b,e,c,a){this.blindUp(b,e,c,a).fade(b,e,c,a)}],["blindLeftFade",function(b,e,c,a){this.blindLeft(b,e,c,a).fade(b,e,c,a)}],["blindRightFade",function(b,e,c,a){this.blindRight(b,e,c,a).fade(b,e,c,a)}]]);

