var intStartDelay = 0;			// New feature to allow a delayed start
var intSlideShowSpeed = 5000;	// Set the slideshow speed (in milliseconds)
var intCrossFadeDuration = 3;	// Set the duration of crossfade (in seconds)
var intPictureIndex = 0;		// Starting index
var objTimeOut = null;			// tracking timeout for slideshow
var blnIsPlaying = false;		// if slideshow is playing
var arrPics = new Array();
var arrCapt = new Array();

function prevPicture() {
	intPictureIndex = intPictureIndex - 1;
	if (intPictureIndex < 0) intPictureIndex = arrPics.length - 1;
    loadPicture();
}

function nextPicture() {
	intPictureIndex = intPictureIndex + 1;
	if (intPictureIndex == arrPics.length) intPictureIndex = 0;
	loadPicture();
}

function loadPicture() {
	document.getElementById('PictureBox').src = arrPics[intPictureIndex];
	document.getElementById('PictureBox').alt = 'Slideshow image #' + parseInt(intPictureIndex + 1);
	document.getElementById('CaptionBox').innerHTML = arrCapt[intPictureIndex];
	document.getElementById('article_link').href = arrPics[intPictureIndex];
	if (arrCapt[intPictureIndex] == '') {
		document.getElementById('CaptionBox').innerHTML = document.getElementById('PictureBox').alt
	}
}

function startSlideShowDelayed(intStartDelay) {
	objTimeOut = setTimeout('SlideShow()',intStartDelay);
}

function SlideShow(){
	nextPicture();
	objTimeOut = setTimeout('SlideShow()', intSlideShowSpeed);
	blnIsPlaying = true;
}

function startStop( objLink ) {
	if ( objLink.title.indexOf('Pause') != -1 ) {
		clearTimeout( objTimeOut );
		objLink.title = "Resume slideshow";
		blnIsPlaying = false;
	} else {
		objLink.title = "Pause slideshow";
		SlideShow();
	}
	document.getElementById('ssStopStart').alt = objLink.title;
}

function addPicture( strPictureUrl, strPictureCaption ) {
	arrPics[arrPics.length] = strPictureUrl;
	arrCapt[arrCapt.length] = strPictureCaption;
}

function mouseHighlight(objImg,intGrayScale) {
	if (objImg.tagName == 'IMG') {
		if (objImg.style.border == '') {
			objImg.style.filter = 'progid:DXImageTransform.Microsoft.BasicImage(grayScale=' + intGrayScale +')';
		}
	}
}

function viewThumbnails() {
	if ( document.getElementById('contactSheet') ) {
		thumbnailviewer.centerDiv( document.getElementById('contactSheet') );
	}
}

function getPuzzle() {
	strPuzzleUrl = 'activitybook_jigsaw.asp?img=' + arrPics[intPictureIndex];
	window.location = strPuzzleUrl;
}