
function CrossFadeSlideshow(slideshow, timeout) {
	this.slides = [];
	this.timeout = timeout;
	this.current = 0;
	
	var items = $(slideshow).getElementsByTagName('div');
	
	for (var i=0; i<items.length; i++) {
		if (Element.hasClassName(items[i], 'slide')) {
			this.slides.push(items[i]);
		}
	}
	
	for (var i=0; i<this.slides.length; i++) {
		this.slides[i].style.zIndex = this.slides.length - i;
	}

	Element.show(slideshow);
	setTimeout((function(){this.next();}).bind(this), this.timeout + 350);


	if ($('home-logo-eden')) {
		Effect.Appear('home-logo-eden', {duration: 4.0});
		Effect.Appear('home-logo-arcade', {duration: 4.0});
	}
}

CrossFadeSlideshow.prototype = {
	next: function() {
		for (var i=0; i<this.slides.length -1; i++) {
			var slide = this.slides[(this.current + i) % this.slides.length];
			slide.style.zIndex = this.slides.length - i;
		}

		Effect.Fade(this.slides[this.current], {
			afterFinish: function(effect) {
				effect.element.style.zIndex = 0;
				Element.show(effect.element);
				Element.setOpacity(effect.element, 1);
			}
		});
    		
		this.current = (this.current + 1) % this.slides.length;
		setTimeout((function(){this.next();}).bind(this), this.timeout + 350);
	}
}

function changePictureRightBackgroundColor(color) {
	$('picture-right').style.background = color;
}

