var ImgPrefix = "slide_";
var titles = new Array();
var descriptions = new Array();
var images = new Array();

var CurrSlideNum = 1;
var SavedSlideLink = "";	// The navigation bar link for the slide that is currently showing.

var imgShowing = 0;	// The index number for the slide that is currently showing.

var colorOn = "yellow";
var colorOff = "lightblue";

var MaxWidth = 480;
var MaxHeight = 480;

var sizeConstraint = "?m=c&w=" + MaxWidth + "&h=" + MaxHeight;
var fullSize = "?m=s&p=100";

var MaxSlides = 1;

function ShowSlide(slideNum, imgWidth, imgHeight)
{
	var slideID = "";
	var space = "&nbsp;";

	if(imgWidth > 0) MaxWidth = imgWidth;
	if(imgHeight > 0) MaxHeight = imgHeight;

	sizeConstraint = "?m=c&w=" + MaxWidth + "&h=" + MaxHeight;

	if(slideNum > MaxSlides || slideNum < 1)
	{
		return;
	}

	CurrSlideNum = slideNum;

	if(titles[slideNum-1] != null)
	{
		document.getElementById('TitleCell').innerHTML = "<b>" + titles[slideNum-1] + "</b>";
	}
	if(images[slideNum-1] != null)
	{
		document.getElementById('CurrentSlide').src = images[slideNum-1] + sizeConstraint;
		document.getElementById('CurrentSlideTarget').href = images[slideNum-1] + fullSize;
	}
	if(descriptions[slideNum-1] != null)
	{
		document.getElementById('DescCell').innerHTML = "<b>" + descriptions[slideNum-1] + "</b>";
	}

	// Update the location highlighting.
	if(imgShowing > 0 && imgShowing <= MaxSlides)
	{
		// Restore the link information for that slide that we're leaving.
		slideID = ImgPrefix + imgShowing;
		document.getElementById(slideID).innerHTML = SavedSlideLink;
		document.getElementById(slideID).style.backgroundColor = colorOff;
	}

	// Save the link information for the current slide.
	slideID = ImgPrefix + CurrSlideNum;
	SavedSlideLink = document.getElementById(slideID).innerHTML;
	if(CurrSlideNum < 10)
	{
		document.getElementById(slideID).innerHTML = space + CurrSlideNum + space;
	}
	else
	{
		document.getElementById(slideID).innerHTML = CurrSlideNum;
	}
	document.getElementById(slideID).style.backgroundColor = colorOff;
	imgShowing = CurrSlideNum;

} // end ShowSlide

function PrevSlide()
{
	ShowSlide(CurrSlideNum - 1);
}

function NextSlide()
{
	ShowSlide(CurrSlideNum + 1);
}

function SetMaxSlides(num)
{
	MaxSlides = num;
}
