// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 5000;
// Duration of crossfade (seconds)
var crossFadeDuration = 3;

var t;

var numimgs = Pic.length;  // num images to use in slideshow
var curImage = -1; //img num currently being shown	
var curIndex = -1; // index into preLoad array currently being shown
var ssNum = 0;
var numSS = 0;
var im1 = 0;
var im2 = 1;
var preLoad = new Array();
for (i = 0; i < numimgs; i++) {
	preLoad[i] = new Image();
}

function randomPict() {
	num = Math.floor(Math.random() * numimgs);
	return num;
	}

function SlideShow() {
	imgs = mahGetElementById('SlideShow' + (ssNum));
	if (isMSIE) {
		imgs.style.filter = "blendTrans(duration="+crossFadeDuration+")";
		imgs.filters.blendTrans.Apply();
		imgs.setAttribute('src', preLoad[curIndex].src);
		imgs.filters.blendTrans.Play();
		}
	else {
		imgs.src = preLoad[curIndex].src;
		}
	
///	alert('curindex = ' + curIndex + ' name = ' + preLoad[curIndex].src + ' pic=' + Pic[curImage]);
	ssNum = ssNum + 1;
	if (ssNum >= numSS) {ssNum = 0;}
	
	// preload the next image to be shown
	curImage++;
	curIndex++;
	if (curIndex >= numimgs) {
		curIndex = curIndex - numimgs;
		curImage = curImage - numimgs;
		}
	preLoad[curIndex].src = Pic[curImage];
	
	t = setTimeout('SlideShow()', slideShowSpeed);
	}

function startShow(i){
	var imgs;
	numSS = i;
	curImage = randomPict();  // start at random location
	curIndex = curImage;
	// first, put a random pict in each of the slideshows
	for (j=0; j<numSS; j++) {
		imgs = mahGetElementById('SlideShow' + (j));
		preLoad[curIndex].src = Pic[curImage];
		imgs.src = preLoad[curIndex].src;
		curImage++;
		curIndex++;
		}
	preLoad[curIndex].src = Pic[curImage];
	t = setTimeout('SlideShow()', slideShowSpeed);
	}
