var Slide=new Class({Implements:Options,options:{container:"gallery",delay:5000,duration:1500},initialize:function(b,a){this.element=this.subject=$A(b);this.setOptions(a);this.options.container=$(this.options.container);this.period=null;this.images=null;this.currentImage=0;this.preloadSlide()},showImage:function(a){if(a>=0&&a<this.images.length){$clear(this.period);if(this.currentImage!=a){this.images[this.currentImage].tween("opacity",0);this.currentImage=a;this.images[this.currentImage].tween("opacity",1)}}},showNext:function(){$clear(this.period);var a=this.currentImage;if((a+1)>=this.images.length){a=0}else{a=a+1}if(this.currentImage!=a){this.images[this.currentImage].tween("opacity",0);this.currentImage=a;this.images[this.currentImage].tween("opacity",1)}},showPrev:function(){$clear(this.period);var a=this.currentImage;if((a-1)<0){a=this.images.length-1}else{a=a-1}if(this.currentImage!=a){this.images[this.currentImage].tween("opacity",0);this.currentImage=a;this.images[this.currentImage].tween("opacity",1)}},changeImage:function(){this.images[this.currentImage].tween("opacity",0);this.currentImage=(this.currentImage+1)%this.images.length;this.images[this.currentImage].tween("opacity",1)},runSlideshow:function(){this.images=this.options.container.getChildren("img");this.images.set("tween",{duration:this.options.duration});this.period=this.changeImage.periodical(this.options.delay+this.options.duration,this)},preloadOthers:function(){this.element=$A(this.element.slice(1,this.element.length));var a=this;var b=new Asset.images(this.element,{onComplete:function(){b.setStyles({opacity:0});b.inject(a.options.container);a.runSlideshow.run([],a)}})},preloadSlide:function(){var a=this;var b=new Asset.image(this.element[0],{onload:function(){b.inject(a.options.container);a.preloadOthers.run([],a)}})}});
