
// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 3000;

// Duration of crossfade (seconds)
var crossFadeDuration = 2;

// Specify the image files
var url; //initial URL

var j = 0;
var t;

var nWhichSlideshow = 1;	// NJK


// Set the Slideshow container to hold the n'th image in the slideshow.
function setSlideshowImage(nSlideshowID, n)
{
	if (!eval("document.images.SlideShow" + nSlideshowID))
	{
		return;	// Stop if no slideshow!
	}
	
	var sTarget;
	var sURL;
	eval("sTarget = SlideshowPicturesTargetArray" + nSlideshowID + "[n]");
	eval("sURL = SlideshowPicturesURLArray" + nSlideshowID + "[n]");

	if (sTarget == 'popup')
	{		
		eval("document.images.SlideShow" + nSlideshowID + ".src = preLoad" + nSlideshowID + "[n].src");
		eval("document.getElementById('SlideShowAnchor" + nSlideshowID + "').href = \"javascript:windowOpen('" + sURL + "', 600, 500);\"");
		eval("document.getElementById('SlideShowAnchor" + nSlideshowID + "').target = '_self'");
	}
	else
	{
		eval("document.images.SlideShow" + nSlideshowID + ".src = preLoad" + nSlideshowID + "[n].src");
		eval("document.getElementById('SlideShowAnchor" + nSlideshowID + "').href = sURL");
		eval("document.getElementById('SlideShowAnchor" + nSlideshowID + "').target = SlideshowPicturesTargetArray" + nSlideshowID + "[n]");
	}
}


// Initialise and then run the slideshow loop.
function runSlideShow()
{
	// Preload!!!
	for (var x = 1; x <= nTotalNumOfSlideshow; x++)
	{
		var sID;
		sID = nSlideshow[x];
			// Get the corresponding Slideshow ID.

		if (sID && window["SlideshowPictures" + sID])
		{
			for (i = 0; i < eval("SlideshowPictures" + sID + ".length"); i++)
			{
				eval("preLoad" + sID + "[i] = new Image()");
				eval("preLoad" + sID + "[i].src = SlideshowPictures" + sID + "[i]");
			}
		}
	}

	runSlideShowLoop();
}


// Run the slideshow loop.
// Once this function is called, a setTimeout() will
// continue the calls to this function.
// NOTE: NO Preloading is done in this function!
function runSlideShowLoop() 
{
	/*
	'here will control the movement of the slideshow
	if (document.all) 
	{
		document.images.SlideShow.style.filter = "blendTrans(duration=2)";
		document.images.SlideShow.style.filter = "blendTrans(duration=crossFadeDuration)";
		document.images.SlideShow.filters.blendTrans.Apply();
	}

	if (document.all)
	{
		document.images.SlideShow.filters.blendTrans.Play();
	}*/
	
	for (var x = 1; x <= nTotalNumOfSlideshow; x++)
	{
		var sID = nSlideshow[x];
		if (sID && window["SlideshowPictures" + sID])
		{
			var ss;
			eval ("ss = SlideshowPictures" + sID);
			if (ss)
			{
				// Get the "cursor" for this slideshow.
				var nCursor;
				eval("nCursor = SlideshowCursor" + sID);

				// Set the image.
				setSlideshowImage (sID, nCursor);
				
				// Increment the cursor, and wrap if required.
				nCursor++;
				var l;
				eval("l = SlideshowPictures" + sID + ".length");
				if (nCursor >= l)
				{
					nCursor = 0;
				}

				// Remember the "cursor" for the slideshow...
				eval("SlideshowCursor" + sID + " = nCursor");
			}
		}
	}

	// Thank you. Come again!
	t = setTimeout('runSlideShowLoop()', slideShowSpeed);
}
