/*
Methods:

slideShow = new SlideShow (slideWaitingFunction);
slideShow.AddSlide (name, thumbImage, largeImage, caption, credit);
slideShow.ShowSlide = SlideShow_ShowSlide (imageName);
*/

function GetSlide (slideShow, theSlide) {
	if (!slideShow.slideArray)
		return (null);
	var ctSlides = slideShow.slideArray.length;
	var ix = 0;
	for (ix = 0; ix < ctSlides; ix++) {
		if (slideShow.slideArray [ix].name == theSlide)
			return (slideShow.slideArray [ix]);
		}
	return (null);
	}
	
function SetSlide (slideShow, theSlide) {
	if (!slideShow.slideArray)
		return (null);
	var ctSlides = slideShow.slideArray.length;
	var ix = 0;
	for (ix = 0; ix < ctSlides; ix++) {
		if (slideShow.slideArray [ix].name == theSlide.name) {
			slideShow.slideArray [ix] = theSlide;
			return (theSlide);
			}
		}
	return (null);
	}

function SetCurrentThumbBorder (slideShow, theSlide) {
	//alert ('about to set border');
	if (!slideShow.slideArray)
		return;
	var ctSlides = slideShow.slideArray.length;
	var ix = 0;
	var idThumb = "";
	for (ix = 0; ix < ctSlides; ix++) {
		if (slideShow.slideArray [ix].idThumb != '')
			document.getElementById (slideShow.slideArray [ix].idThumb).style.borderColor = slideShow.thumbBorderOff;
		}
	if (theSlide)
		document.getElementById (theSlide).style.borderColor = slideShow.thumbBorderOn;
	}
	
function SlideShow_ShowSlide (theSlideName, idTargetImage, idCaption, idCredit) {
	
	var theSlide = GetSlide (this, theSlideName);
	if (!theSlide || !idTargetImage)
		return;
	document.getElementById (idTargetImage).style.visibility = 'hidden';
	document.getElementById (idTargetImage).src = this.imgPath + theSlide.imgName;
	document.getElementById (idTargetImage).style.visibility = 'visible';
	if (idCaption)
		document.getElementById (idCaption).innerHTML = theSlide.caption;
	if (idCredit)
		document.getElementById (idCredit).innerHTML = theSlide.credit;
	SetCurrentThumbBorder (this, theSlide.idThumb);
	}
	
/*
function SlideShow_SetLoadState (name) {
	var ctSlides = this.slideArray.length;
	var ix = 0;
	for (ix = 0; ix < ctSlides; ix++) {
		if (this.slideArray [ix].name == name) {
			this.slideArray [ix].flLoaded = 1;
			//alert ('slide successfully loaded: ' + this.slideArray [ix].img.src + ' width: ' + this.slideArray [ix].img.width + ' height: ' + this.slideArray [ix].img.height);
			return;
			}
		}
	}
*/

function SlideShow_AddSlide (name, idThumb, imgName, caption, credit) {
	var slide = new Object ();
	slide.name = name;
	slide.idThumb = idThumb;
	slide.imgName = imgName;
	slide.caption = caption;
	slide.credit = credit;
	if (!this.slideArray)
		this.slideArray = new Array ();
	var ctSlides = this.slideArray.length;
	this.slideArray [ctSlides] = slide;
	return (slide);
	}
	
function SlideShow (imgPath, thumbBorderOn, thumbBorderOff, waitForSlideProc) {
	this.imgPath = imgPath;
	this.thumbBorderOn = thumbBorderOn;
	this.thumbBorderOff = thumbBorderOff;
	this.slideArray = new Array ();
	this.AddSlide = SlideShow_AddSlide;
	this.ShowSlide = SlideShow_ShowSlide;
	//this.SetLoadState = SlideShow_SetLoadState;
	//this.waitForSlideProc = waitForSlideProc;
	//this.waitingOnSlideName = "";
	}

