/**
* Simple Slide Show v.0.2
* @author Enrique Erne
* @copyright 2008 MILD
* @license GPL V2 or newer
*/

var active;
var imgsCount;

function slideShow () {
	var i = 0;
	$ES('#slideShow a').each(function(el) {
		i++;
		if (active === imgsCount) {
			el.setOpacity(1);
		}
		if (active === i) {
			if (active === 1) {
				$ES('#slideShow a').getLast().fx.start(0, 1);
				active  = imgsCount+1;
			} else {
				el.fx.start(1, 0);
			}
		}
	});
	active--;
}

window.addEvent('domready', function(){
	if ( $chk($E('#slideShow')) ) {
		$ES('#slideShow a').setOpacity(0);
		$ES('#slideShow a').getLast().setOpacity(1);
		var slide;
		imgsCount = $E('#slideShow').getChildren().length;
		active = imgsCount;
		$ES('#slideShow a').each(function(el){
			el.fx = new Fx.Style(el, 'opacity', {
				duration: 2000, // laenge der ueberblendung
				fps: 34
			});
		});
		slideShow.periodical(5000, slide); // interval 
	}
});

