﻿var SlideShow = Class.create();var SlideShow_old = Class.create();var SlideShowImage = Class.create();var SlideShowList = new Array();SlideShow.prototype = {		initialize: function( showID, inImage ) {		this.path = SlideShowList[showID]['path'];		this.preloadImageList = [];		this.imageList = [];				this.transidionSpeed	= SlideShowList[showID]["blendTime"];		this.hasPreloadImage	= SlideShowList[showID]["hasPreloadImage"];		this.pauseTime			= SlideShowList[showID]["pauseTime"];		this.isRandom			= SlideShowList[showID]["random"];		this.doesRepeat			= SlideShowList[showID]["repeat"];		this.currentImageNr = 0;		this.nextImageNr = 1; 				for ( var i=0,length = SlideShowList[showID]['list'].length ; i<length ; i++ )  {			var name = SlideShowList[showID]['list'][i];			if( this.preloadImageList[name] == null ) {				this.preloadImageList[name] = new SlideShowImage( this.path+name, this );			}			this.imageList[i] = this.preloadImageList[name];					}		this.image1 = inImage;		this.imageList[this.nextImageNr].load();		this.createImageDiv();	},		createImageDiv: function( ) {				/** create a div to wrapp around the image **/		this.imageContainer = document.createElement("div");		//this.imageContainer.className = "blendImage";		Element.setStyle(this.imageContainer,{ position:"relative",left:0,top:0});		this.imageContainer.style.width = this.image1.width+"px";		this.imageContainer.style.height = this.image1.height+"px";		/** wrapp the div around the image **/		this.image1.parentNode.insertBefore(this.imageContainer,this.image1);		this.image1.parentNode.removeChild(this.image1);		this.imageContainer.appendChild(this.image1);				this.image2 = document.createElement("img");		Element.setOpacity(this.image2,0);				Element.setStyle(this.image1,{zIndex:1, position:"absolute",left:0,top:0});		Element.setStyle(this.image2,{zIndex:2, position:"absolute",left:0,top:0});										this.imageContainer.appendChild(this.image2);				/*this.loadNextImage();*/		tmpTimer = new TimedExecution(this.callback.bind(this),this.getCurrentPauseTime());	},		callback : function() {		if( this.imageList[this.nextImageNr].isLoaded() ) {						//alert(this.transidionSpeed);			this.image2.src = this.imageList[this.nextImageNr].image.src;			Effect.Appear(this.image2, {duration: this.transidionSpeed*100, "afterFinish":this.imageBlende.bind(this)});		} else {			return 0.0001;		}	},		imageBlende : function() {		var tmpImage = this.image1;		this.image1 = this.image2;		this.image2 = tmpImage;		this.currentImageNr = this.nextImageNr;		this.nextImageNr++;		if( this.nextImageNr >= this.imageList.length ) {			this.nextImageNr = 0;		}				Element.setOpacity(this.image2,0);		Element.setStyle(this.image1,{zIndex:1});		Element.setStyle(this.image2,{zIndex:2});		this.imageList[this.nextImageNr].load();				tmpTimer = new TimedExecution(this.callback.bind(this),this.getCurrentPauseTime());	},		getCurrentPauseTime : function() {		if( typeof this.pauseTime == "number" ) {			return this.pauseTime;		} else {			return this.pauseTime[this.currentImageNr];		}	},		imageLoaded : function( image ) {	}}SlideShowImage.prototype = {	initialize: function( path, slideshow ) {		this.path = path;		this.image = null;		this.slideshow = slideshow;		this._loaded = false;	},		isLoaded : function() {		return this._loaded;	},		loaded : function() {		this._loaded = true;		this.slideshow.imageLoaded(this);	},		load : function() {		if( this.image == null ) {			this.image = new Image();			this.image.onload = this.loaded.bind(this);			this.image.src = this.path;		}	}}function initSlideShow() {	imgList = document.getElementsByTagName("img");	Event.stopObserving(window,"load",initSlideShow,true);		for( i=0 ; i<imgList.length ; i++ ) {		if( imgList[i].name.toLowerCase().match("slideshow_") ) {			showID = imgList[i].name.substring(10);			SlideShowList[showID]["slideshow"] = new SlideShow(showID,imgList[i]);		}	}}Event.observe(window,"load",initSlideShow,true);/*********************************************/var TimedExecution = Class.create();TimedExecution.prototype = {	initialize: function( callback, interval ) {		this.callback = callback;		this.interval = interval;		//this.currentlyExecuting = false;				this.registerCallback();				this.timeOut = null;	},		registerCallback: function() {		this.timeOut = setTimeout(this.onTimerEvent.bind(this), this.interval*1000);	},		onTimerEvent: function() {		try {			nextInterval = this.callback();						if( nextInterval == -1 ) {				nextInterval = this.interval; 			}						if( nextInterval > 0 ) {								this.interval = nextInterval;				this.timeOut = setTimeout(this.onTimerEvent.bind(this), this.interval*1000);			}			} catch(e) {		}	}}//Event.observe(window,"load",initSlideShow,true);