var Preloader=Class.create({callbacks:[],images:[],loadedImages:[],imagesLoaded:[],add:function(B){if(typeof B=="string"){this.images.push(B)}if(typeof B=="array"||typeof B=="object"){for(var A=0;A<B.length;A++){this.images.push(B[A])}}},onFinish:function(B){if(typeof B=="function"){this.callbacks.push(B)}if(typeof B=="array"||typeof B=="object"){for(var A=0;A<B.length;A++){this.callbacks.push(B[A])}}},load:function(){for(var A=0;A<this.images.length;A++){this.loadedImages[A]=new Image();this.loadedImages[A].onload=this.checkFinished.bind(this);this.loadedImages[A].src=this.images[A]}},checkFinished:function(){this.imagesLoaded++;if(this.imagesLoaded==this.images.length){this.fireFinish()}},fireFinish:function(){for(var A=0;A<this.callbacks.length;A++){this.callbacks[A]()}this.images=[];this.loadedImages=[];this.imagesLoaded=0;this.callbacks=[]}});var Slideshow=Class.create({slideDelay:3,fadeDuration:1,currentImageNumber:0,imageLoaded:{0:true},banners:[],initialize:function(B,C,A){this.container=B.up();this.banners.push(B);this.currentBanner=this.banners[0];this.images=A.collect(function(D){return C+D});this.startTime=this.getCurrentTime()-(this.fadeDuration*1000);this.preloadNextImage();new PeriodicalExecuter(this.tick.bind(this),0.25)},getCurrentTime:function(){return(new Date()).getTime()},preloadNextImage:function(){this.currentImageNumber=this.currentImageNumber+1;if(!this.images[this.currentImageNumber]){this.currentImageNumber=0}var B=this.images[this.currentImageNumber];if(!this.imageLoaded[this.currentImageNumber]){var A=new Preloader();A.callbacks.push(this.onImageLoad.bind(this,this.currentImageNumber));A.add(B);A.load()}},onImageLoad:function(A){this.imageLoaded[A]=true},changeImage:function(B){var A=this.currentBanner;A.setStyle({zIndex:1});this.currentBanner=this.getBanner(B);this.currentBanner.setStyle({zIndex:2,opacity:0,display:"block"});Effect.Appear(this.currentBanner,{duration:this.fadeDuration,afterFinish:function(){A.setStyle({display:"none"})}});this.startTime=this.getCurrentTime()},getBanner:function(A){if(!this.banners[A]){this.banners[A]=new Element("img",{src:this.images[A],"class":"bannerImage"});this.container.insert(this.banners[A])}return this.banners[A]},tick:function(){var A=this.getCurrentTime();if(A-this.startTime>=(this.slideDelay+this.fadeDuration)*1000&&this.imageLoaded[this.currentImageNumber]){this.changeImage(this.currentImageNumber);this.preloadNextImage()}}});