/*
 * slideshow.js
 *
 * Tony Mactutis
 * St. Philomena Parish, Des Moines, WA
 */

function slideshow()
{
	/*
	 * 1. copy the foreground to the background
	 * 2. set the opacity of the foreground to 0 (invisible)
	 * 3. gradually increase the opacity of the foreground
	 */
	background.style.backgroundImage = "url(img/slideshow/"+i+".JPG)";

	i = i + 1;
	if (i > 14)
		i = 1;		

	opacity = 0;
	foreground.style.opacity = opacity;
	foreground.style.filter = "alpha(opacity="+opacity*100+")";
	foreground.src = "img/slideshow/"+i+".JPG";
	
	window.setTimeout("slideshow();", 8000);
	window.setTimeout("fade();", 100);
}

function fade()
{
	foreground.style.opacity = opacity;
	foreground.style.filter = "alpha(opacity="+opacity*100+")";
	
	opacity += .1;
	if (opacity > 1)
		opacity = 1;
	if (opacity < 1)
		window.setTimeout("fade();", 100);
}

var opacity = 1;
var i = 1;

var foreground = document.getElementById("slideshowimage");
var background = document.getElementById("slideshowbackground");

if (foreground)
	window.setTimeout("slideshow();", 8000);

