// FILE: page_efx.js
// GOAL: To define functions to support page special effects

// Begin
// Set slideShowSpeed [milliseconds]
var slideShowSpeed = 3000;

// Duration of crossfade [seconds]
var crossFadeDuration = 2;

// lastSlide is the last slide on the page (offset one)
var lastSlide = 1;

// nextSlide is the next slide to change - chosen at random
var nextSlide = 1;

// Specify the image files
var Pic = new Array();

// To add more images, just add to the array below
// Pic[0] = 'images/sp1.jpg'
// Pic[1] = 'images/sp2.jpg'
// Pic[2] = 'images/sp3.jpg'
// Pic[3] = 'images/sp4.jpg'
// Pic[4] = 'images/sp5.jpg'
// ...

var img;
var t;
var j = 1;
var p = Pic.length;
var preLoad = new Array();

// FUNCTION: runSlideShow
// PURPOSE:  To run the show by changing out the images
function runSlideShow()
{
	// Change image reference
	switch (nextSlide)
	{
		case 1:
			img = document.images.Slide_1;
			break;
		case 2:
			img = document.images.Slide_2;
			break;
		case 3:
			img = document.images.Slide_3;
			break;
		case 4:
			img = document.images.Slide_4;
			break;
		case 5:
			img = document.images.Slide_5;
			break;
		default:
			img = document.images.Slide_1;
			break;
	}
	
    if (document.all) 
    {
        img.style.filter="blendTrans(duration=crossFadeDuration)";
        img.filters.blendTrans.Apply();
    }
    img.src = preLoad[j].src;
	// ##DX: alert('Slide ' + nextSlide + ' is now ' + preLoad[j].src);
	
    if (document.all) 
    {
        img.filters.blendTrans.Play();
    }
	
	// Advance counter
    j = j + 1;
    if (j > (Pic.length - 1)) j = 0;
	
	// Select next slide
	// nextSlide = nextSlide + 1;
	// if (nextSlide > lastSlide) nextSlide = 1;
	
	// Set timeout value to run again
    t = setTimeout('runSlideShow()', slideShowSpeed);
}


// FUNCTION: loadSlideArray(pix)
// PURPOSE:  To load the slide array with specific images for the page
function loadSlideArray(pix)
{	// Add the image to the pictures on the page
    p = Pic.length; 	// Get next array ref
	Pic[p] = 'images/' + pix;
	preLoad[p] = new Image();
	preLoad[p].src = 'images/' + pix;
	// ##DX: alert('Image ' + 'images/' + pix + ' has been loaded');
	
}


// Finally, initialize the Slide Show:
window.onload = runSlideShow;


//  End



