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.setup();if(this.options.autoplay){this.startLoop()}},setup:function(){this.setupElement();this.setupSlides();return this},setupElement:function(){var A=this.element;if(A.getStyle("position")!="absolute"&&A!=document.body){A.setStyle("position","relative")}return this},setupSlides:function(){this.slides.each(function(A,B){this.storeTransition(A).reset(A);if(B!=0){A.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);A.store("ssDuration",D);return this},getTransition:function(A){return A.retrieve("ssTransition")},getDuration:function(A){return A.retrieve("ssDuration")},show:function(A){this.fireEvent("show");A=(typeof A=="number")?this.slides[A]:A;if(A!=this.current){var E=this.getTransition(A);var D=this.getDuration(A);var C=this.current.setStyle("z-index",1);var B=this.reset(A);this.transitions[E](C,B,D,this);(function(){C.setStyle("display","none");this.fireEvent("showComplete")}).bind(this).delay(D);this.current=B}return this},reset:function(A){return A.setStyles({position:"absolute","z-index":0,display:"block",left:0,top:0}).fade("show");return this},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(){this.show(this.nextSlide());return this},showPrevious:function(){this.show(this.previousSlide());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}});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.getStyle("width").toInt();B.setStyle("left",E);[B,C].each(function(F){var G=F.getStyle("left").toInt()-E;F.set("tween",{duration:D}).tween("left",G)});return this}],["pushRight",function(C,B,D,A){var E=A.element.getStyle("width").toInt();B.setStyle("left",-E);[B,C].each(function(F){var G=F.getStyle("left").toInt()+E;F.set("tween",{duration:D}).tween("left",G)});return this}],["pushDown",function(C,B,D,A){var E=A.element.getStyle("height").toInt();B.setStyle("top",-E);[B,C].each(function(F){var G=F.getStyle("top").toInt()+E;F.set("tween",{duration:D}).tween("top",G)});return this}],["pushUp",function(C,B,D,A){var E=A.element.getStyle("height").toInt();B.setStyle("top",E);[B,C].each(function(F){var G=F.getStyle("top").toInt()-E;F.set("tween",{duration:D}).tween("top",G)});return this}],["blindLeft",function(C,B,D,A){var E=A.element.getStyle("width").toInt();B.setStyles({left:E,"z-index":1}).set("tween",{duration:D}).tween("left",0);return this}],["blindRight",function(C,B,D,A){var E=A.element.getStyle("width").toInt();B.setStyles({left:-E,"z-index":1}).set("tween",{duration:D}).tween("left",0);return this}],["blindUp",function(C,B,D,A){var E=A.element.getStyle("height").toInt();B.setStyles({top:E,"z-index":1}).set("tween",{duration:D}).tween("top",0);return this}],["blindDown",function(C,B,D,A){var E=A.element.getStyle("height").toInt();B.setStyles({top:-E,"z-index":1}).set("tween",{duration:D}).tween("top",0);return this}],["blindDownFade",function(C,B,D,A){this.blindDown(C,B,D,A).fade(C,B,D,A)}],["blindUpFade",function(C,B,D,A){this.blindUp(C,B,D,A).fade(C,B,D,A)}],["blindLeftFade",function(C,B,D,A){this.blindLeft(C,B,D,A).fade(C,B,D,A)}],["blindRightFade",function(C,B,D,A){this.blindRight(C,B,D,A).fade(C,B,D,A)}]]);
