var SlideShow=new Class({Implements:[Options,Events,Loop,Chain],options:{delay:7000,transition:"crossFade",duration:"2000",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.ptr=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");var c=a;a=(typeof a=="number")?this.slides[a]:a;if(a!=this.current){var f=this.getTransition(a);var e=this.getDuration(a);var d=this.current.setStyle("z-index",1);var b=this.reset(a);this.transitions[f](d,b,e,this);(function(){d.setStyle("z-index",0);this.fireEvent("showComplete")}).bind(this).delay(e);this.current=b}this.ptr=c;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(){this.ptr=(this.slides[this.ptr+1])?this.ptr+1:0;return this.ptr},previousSlide:function(){this.ptr=(this.slides[this.ptr-1])?this.ptr-1:this.slides.length;return this.ptr},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)}]]);
