fadeout = function() {
	if (currentimage < image.length)
	{
		$('homepreload').style.backgroundImage = 'url(\'' + image[currentimage+1] + '\')';
	}
	abouttochange = true;
	new Effect.Opacity('homeimage', { from: 1.0, to: 0.0, duration: FADELENGTH/2, afterFinish: changeimage });
	new Effect.Opacity('homeimage', { from: 0.0, to: 1.0, duration: FADELENGTH/2, queue: 'end' });
}
changeimage = function() {
	abouttochange = false;
	$('homeimage').style.backgroundImage = 'url(\'' + image[currentimage] + '\')';
	previousimage = currentimage;
	currentimage++;
	if (currentimage >= image.length)
	{
		currentimage = 0;
	}
}
showimage = function(num) {
	clearInterval(timer);
	if (!abouttochange && num != currentimage)
	{
		fadeout();
	}
	currentimage = num;
	timer = setInterval(fadeout, PERIOD * 1000);
}

var timer = setInterval(fadeout, PERIOD * 1000);
