/* first values of slideshows */
var slideshows = new Array();
slideshows[1] = 0;

/* preload of images */
var images = new Array();
images[1] = new Array();

function slideshow(id) {
	if (slideshows[id] == null) {
		return;
	}
	slideshows[id] = slideshows[id] + 1;
	if (images[id].length <= slideshows[id]) {
		slideshows[id] = 0;
	}
	try {
		new Effect.Fade('slideshow_' + id, {
			duration: 0.3,
			from: 1.0,
			to: 0.1,
			afterFinish: function() {
				document.getElementById('slideshow_' + id).src = images[id][slideshows[id]].src;
				new Effect.Fade('slideshow_' + id, {
					duration: 0.3,
					from: 0.1,
					to: 1.0,
					afterFinish: function() {
						setTimeout('slideshow(' + id + ')', 5000);
					}.bind(this)
				});
			}.bind(this)
		});
	}
	catch (error) {
		return;
	}	
}

function addimagestoslideshow(id, album, count) {
	if (count > 100) {
		count = 100;
	}
	for (var i = 0; i < count; i++) {
		var image = 'http://pics.plaggenhouwers.nl/image.php?album=' + album + '&pic=0';
		if (i < 9) {
			image = image + '0';
		}
		image = image + (i + 1) + '&slideshow=true';
		images[id][i] = new Image();
		images[id][i].src = image;
	}
}