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

// Set a flag to determine if the image can be filtered (ie only effect)
var filterFlag = false;

// Slideshow 1
var i1 = 0;
var j1 = 0;
var p1 = Pic1.length;

var Pre1 = new Array();
for (i1=0;i1<p1;i1++)
{
	Pre1[i1] = new Image();
	Pre1[i1].src = Pic1[i1];
}
// Slideshow 2
var i2 = 0;
var j2 = 0;
var p2 = Pic2.length;

var Pre2 = new Array();
for (i2=0;i2<p2;i2++)
{
	Pre2[i2] = new Image();
	Pre2[i2].src = Pic2[i2];
}
// Slideshow 3
var i3 = 0;
var j3 = 0;
var p3 = Pic3.length;

var Pre3 = new Array();
for (i3=0;i3<p3;i3++)
{
	Pre3[i3] = new Image();
	Pre3[i3].src = Pic3[i3];
}

function runSlideShow()
{
	// check that we can access the image by its element id
	if (document.getElementById)
	{
		// check that the next images in the slideshow have loaded
		if (Pre1[j1].complete && Pre2[j2].complete && Pre3[j3].complete)
		{
			img1 = document.getElementById('mainPhoto1');
			img2 = document.getElementById('mainPhoto2');
			img3 = document.getElementById('mainPhoto3');
		
			// set up the filters
			try{
				// standard blend transition
				img1.style.filter="blendTrans(duration=2)";
				img1.filters.blendTrans.Apply();
				img2.style.filter="blendTrans(duration=2)";
				img2.filters.blendTrans.Apply();
				img3.style.filter="blendTrans(duration=2)";
				img3.filters.blendTrans.Apply();
				// specialised reveal filters 
				//img1.style.filter="revealTrans(duration=filterDuration, transition=4)";
				//img1.filters.revealTrans.Apply();
				//img2.style.filter="revealTrans(duration=filterDuration, transition=4)";
				//img2.filters.revealTrans.Apply();
				//img3.style.filter="revealTrans(duration=filterDuration, transition=4)";
				//img3.filters.revealTrans.Apply();
			}catch(err){}
			// swap the images
			img1.src = Pre1[j1].src;
			img1.alt = Alt1[j1];
			img2.src = Pre2[j2].src;
			img2.alt = Alt2[j2];
			img3.src = Pre3[j3].src;
			img3.alt = Alt3[j3];

			// again check if the image can be filtered
			try{
				// standard blend transition
				img1.filters.blendTrans.Play();
				img2.filters.blendTrans.Play();
				img3.filters.blendTrans.Play();
				// specialised reveal filters 
				//img1.filters.revealTrans.Play();
				//img2.filters.revealTrans.Play();
				//img3.filters.revealTrans.Play();
			} catch(err){}
			// move counters onto next image
			j1++;j2++;j3++;
			if (j1>=p1) j1=0;
			if (j2>=p2)	j2=0;
			if (j3>=p3)	j3=0;
		
			// call the slideshow function
			setTimeout('runSlideShow()', speed);
		}
		// images not yet loaded so wait a while
		else
		{
			// call the slideshow function
			setTimeout('runSlideShow()', speed);
		}
	}
}