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

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

// Set up the (multi-dimensional) pictures array
var Pics = new Array();
Pics[0]    = new Array('../images/case-studies/cs-splash-ind-1.jpg','../images/case-studies/cs-splash-ind-2.jpg','../images/case-studies/cs-splash-ind-3.jpg');
Pics[1]    = new Array('../images/case-studies/cs-splash-com-1.jpg','../images/case-studies/cs-splash-com-2.jpg','../images/case-studies/cs-splash-com-3.jpg');
Pics[2]    = new Array('../images/case-studies/cs-splash-res-1.jpg','../images/case-studies/cs-splash-res-2.jpg','../images/case-studies/cs-splash-res-3.jpg');

// Number of place holders
var ph = 3;

// Number of images per place-holder
var pi = 3;

// Pre-load the images
var i = 0;
var j = 0;
var Pre = new Array();
for (i=0;i<ph;i++)
{
	Pre[i] = new Array();
	for (j=0;j<pi;j++)
	{	
		Pre[i][j] = new Image();
		Pre[i][j].src = Pics[i][j];
	}
}

// Slideshow counter (starts on zero)
var i = 0;
var j = 1;

var start_flag = 0;

function runSlideShow()
{
	// this loop kicks in when we first run the function
	// it simply delays the first slide - otherwise it would switch immediately
	if (start_flag == 0)
	{
		start_flag = 1;
		
		// call the slideshow function
		setTimeout('runSlideShow()', speed);
	}
	// check that we can access the image by its element id
	else if (document.getElementById)
	{
		// check that the next image in the slideshow have loaded
		if (Pre[i][j].complete)
		{
			picToChange = document.getElementById('picChange'+i);
		
			// set up the filters
			try{
				// standard blend transition
				picToChange.style.filter="blendTrans(duration=1)";
				picToChange.filters.blendTrans.Apply();
			}
			catch(err){}
			
			// swap the images
			picToChange.src = Pre[i][j].src;

			// again check if the image can be filtered
			try{
				// standard blend transition
				picToChange.filters.blendTrans.Play();
			}
			catch(err){}
			
			// move counters onto next image
			i++;
			if (i>=ph)
			{
				i=0;
				j++;
				if (j>=pi) j=0;
			}
		
			// call the slideshow function
			setTimeout('runSlideShow()', speed);
		}
		// images not yet loaded so wait a while
		else
		{
			// call the slideshow function
			setTimeout('runSlideShow()', speed);
		}
	}
}