
//
// Global Variables
//

// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 5000

// Duration of crossfade (seconds)
var crossFadeDuration = 3

// Variable which hold's the timer
var objTimer; 

// Counter Variable for each picture
var intImageCount = -1;
var intCount      = 0;

// Loaded Images Array
var arrImages = new Array();


//
// Load all Images and set the intImageCount correctly
function loadSlideShow( strImagePath ) {
	//
	// If we have more Images, Load them also
	window.status = "Images loaded...";
	do {
		intImageCount++;
		arrImages[intImageCount]       = new Image();

		if( intImageCount == 0 ) {
			arrImages[intImageCount].src = strImagePath;
		} else {
			arrImages[intImageCount].src = strImagePath.replace(/\./, "_" + intImageCount + ".");
		}
		window.status += " " + intImageCount;
	} while( (arrImages[intImageCount].width + ' / ' + arrImages[intImageCount].height) != '0 / 0' );
}

//
// Run the slideshow as Requested
function runSlideShow(strSlideShowElementId) {
	var objSlideShow = document.getElementById(strSlideShowElementId);

	if( objSlideShow ) {

		if( document.all ) {
		   objSlideShow.style.filter="blendTrans(duration=2)";
		   objSlideShow.style.filter="blendTrans(duration=crossFadeDuration)";
		   objSlideShow.filters.blendTrans.Apply();
		}

		objSlideShow.src = arrImages[intCount].src;

		if( document.all ) {
		   objSlideShow.filters.blendTrans.Play();
		}

		intCount++; 

		// Clear the count if we are on the last Image
		if( intCount > (intImageCount-1) ) {
			intCount = 0;
		}

		// Set the timer for the next Image
		objTimer = setTimeout('runSlideShow(\'' + strSlideShowElementId + '\')', slideShowSpeed);
   }
}
