// slideshow config
var ss_im_1 = false;
var ss_im_2 = false;
var ss_nu = 1;
var ss_aantal = 0;
var ss_target = false;
var ss_interval = 3000;
var ss_roling = true;

// init slideshow
function slideshow(target){
	ss_target = $(target);
	ss_aantal = slideshowPics.length;
	
	// containers
	var c1 = new Element('div',{'id':'ss_1','class':'slideshowImage'}).hide();
	var c2 = new Element('div',{'id':'ss_2','class':'slideshowImage'}).hide();
	ss_target.appendChild(c1);
	ss_target.appendChild(c2);
	
	// eerste opstarten, daarna vanzelf
	var p1 = new Element('img');
	new Event.observe(p1,'load',function(){
		c1.appendChild(p1);
		new Effect.Appear(c1);//.show();
		
		setTimeout(function(){
			slideshow_shuffle(1);
		},ss_interval)		
	});
	p1.setAttribute('src',slideshowPics[0]);
}

// volgende afbeelding
function slideshow_shuffle(nu){
	if(ss_roling){
		var show = nu == 1 ? 2 : 1;
		var hide = nu == 1 ? 1 : 2;
		var next = 0;
		
		$('ss_'+show).update();
		var p1 = new Element('img');
		new Event.observe(p1,'load',function(){
			$('ss_'+show).appendChild(p1);
			new Effect.Fade($('ss_'+hide));
			new Effect.Appear($('ss_'+show));//.show();
			
			setTimeout(function(){
				slideshow_shuffle(show);
			},ss_interval)		
		});
		
		// volgende?
		next = ss_nu++;
		if(next >= ss_aantal){
			next = ss_nu = 0;
		}
		
		p1.setAttribute('src',slideshowPics[next]);
	}
}
