// JavaScript Document

var active_sfeer = 0;
var sfeer_id = 1;
var slideshow_length = slideshow_afb.length;

function slideshow()
{
	active_sfeer++;
	active_sfeer_id = sfeer_id;
	sfeer_id++;
	if(active_sfeer == slideshow_length)
	{
		active_sfeer = 0;
	}
	if(sfeer_id > 2)
	{
		sfeer_id = 1;
	}

	image = new Image();
	image.src = slideshow_afb[active_sfeer];
	
	$('sfeer'+sfeer_id).src = image.src;
	
	new Effect.Fade('sfeer'+active_sfeer_id, {
		delay: 2.5,
		duration: 1.0
	});
	new Effect.Appear('sfeer'+sfeer_id, {
		from: 0.0,
		to: 1.0,
		duration: 1.0,
		delay: 2.5,
		afterFinish: function() { 
			slideshow(); 
		}
	});
}

/*var image = 1;
function fotofader(id, pictures) {
	setTimeout(function() {
		image++;
		var images = pictures.split(',');
		var src	   = images[(image - 1)];
		preload = new Image(); 
		preload.src = src;
		
		new Effect.Opacity('foto', {
			duration: 1,
			from: 1, 
			to: 0,
			afterFinish: function() { $('foto').src = src }
		});
		new Effect.Opacity('foto_pl', {
			delay: 0.2,
			duration: 1,
			from: 0, 
			to: 1,
			beforeStart: function() { $('foto_pl').src = src; $('foto_pl').setOpacity(0); $('foto_pl').show(); },
			afterFinish: function() { $('foto').setOpacity(100); fotofader(id, pictures); }
		});	
		
		if(image == images.length) {
			image = 0;
		}
	 }, 
	 3000);
}*/