// Set the slideshow speed (in milliseconds)
var SlideShowSpeed = 6000;

var SScount = 1;
var SSmax = 0;
var SSinterval;
var SSopacity = 0;
var SSeffect;

window.onload = function() {
	if(document.getElementById('slideshow'))
		init_slideShow();
}

function init_slideShow() {
	if(document.getElementById('slideshowBank'))
	{
		var object = document.createElement("img");
		object.id = "fadeImage";
		document.getElementById('slideshow').appendChild(object);
		
		object.style.opacity = "0";
		object.style.filter = "alpha(Opacity=0)";
		
		SSmax = document.getElementById('slideshowBank').getElementsByTagName('img').length;
		if(SSmax > 1)
			SSinterval = setInterval('run_slideShow()', SlideShowSpeed);
	}
}

function run_slideShow() {
	SScount++;
	if (SScount > SSmax)
		SScount = 1;
	if(SSopacity == 0) {
		var fadeImage = document.getElementById('fadeImage');
		fadeImage.src = document.getElementById('ssM'+SScount).src;
		fadeImage.alt = document.getElementById('ssM'+SScount).alt;
		SSeffect = setInterval('fadeIn_slideShow()', 15);
	}
	else {
		var image = document.getElementById('ssM');
		image.src = document.getElementById('ssM'+SScount).src;
		image.alt = document.getElementById('ssM'+SScount).alt;
		SSeffect = setInterval('fadeOut_slideShow()', 15);
	}
}

function fadeIn_slideShow() {
	SSopacity++;
	object = document.getElementById('fadeImage');
	if(SSopacity < 100) {
		object.style.opacity = SSopacity * .01;
		object.style.filter = "alpha(Opacity="+SSopacity+")";
	}
	else {
		clearInterval(SSeffect);
		object.style.opacity = "1";
		object.style.filter = "alpha(Opacity=100)";
	}
}

function fadeOut_slideShow() {
	SSopacity--;
	object = document.getElementById('fadeImage');
	if(SSopacity > 0) {
		object.style.opacity = SSopacity * .01;
		object.style.filter = "alpha(Opacity="+SSopacity+")";
	}
	else {
		clearInterval(SSeffect);
		object.style.opacity = "0";
		object.style.filter = "alpha(Opacity=0)";
	}
}