function preloadImg() {
	for (var i = 0; i < images.length; i++) {
    im = new Image();
    im.src = images[i];
  }
	current_img = 0;
}

function slideShow() {
	images = new Array();
	for (var i = 0; i < arguments.length; i++) {
		images[i] = '/images/' + arguments[i] + '.jpg';
	}
	preloadImg();
	new PeriodicalExecuter(changeImg, 5);
}

function changeImg() {
	if (current_img == images.length - 1) { current_img = 0; }
	else { current_img++; }
	$('picture').style.background = "url('" + images[current_img] + "')";
	new Effect.Fade('image-fade', { 
		duration: 2, 
		fps: 50,
		queue: 'end',
		afterFinish: function() {
			$('image-fade').src = images[current_img];
			$('image-fade').show();
		}
	}	)	
}


