var imagesCount = 5;

function showPhoto(id) {	
	imgPreload = new Image();
	imgPreload.onload = function() {
		
		Effect.Fade("homepagePhoto", { afterFinish: function() { nextFrame(id); } });
	}
	imgPreload.src = "images/homepage/" + id + ".jpg";
}

function nextFrame(id) {	
	document.getElementById("homepagePhoto").src = "images/homepage/" + id + ".jpg";
		
	if (id >= imagesCount) {
		var newId = 1;
	} else {
		var newId = id + 1;
	}
	
	Effect.Appear("homepagePhoto", { afterFinish: function() { setTimeout("showPhoto(" + newId + ")",5000); } });
}