function getChildNodeById(sId, oElem)
{
	if (oElem == null)
	{
		oElem = document;
		if (document.getElementById)
			return document.getElementById(sId);
	}
	var childNodes = oElem.childNodes
	for (var i = 0; i < childNodes.length; i++)
	{
		var oElem = childNodes[i];
		if (oElem.id == sId)
			return(oElem);
		if ((oElem = getChildNodeById(sId, oElem)) != null)
			return(oElem);
	}
}

function switchIMG(list_, index_)
{
	if (index_ == null)
		index_ = list_.selectedIndex;
	if (index_ < 0 || index_ >= list_.length)
		return false;
	var form_ = list_.form;
	var img = getChildNodeById(getChildNodeById("ImageID").value)
	//form_.Image1.src = "http://www.leesburgflorida.gov/library/images/library/new/sshow/" + list_.options[index_].value + ".jpg"
	img.src = path_ + list_.options[index_].value + ".jpg"
	//alert(img.src);
	//alert(form_.Image1.src);
	linkListText_.innerHTML = list_.options[index_].text;
	inputListIndex_.value = index_;
	return true;
}

var indexSlideShow = -1;
var iTimeoutSlideShow = null;
var bNoSlideShow = false;
var playing = false;
function slideShow(increment_, timeout_)
{
	if (bNoSlideShow)
	{
		if (iTimeoutSlideShow != null)
		{
			clearTimeout(iTimeoutSlideShow);
			iTimeoutSlideShow = null;
		}
		playing = false;
		return;
	}
	if (switchIMG(list_, indexSlideShow += increment_)) {
		iTimeoutSlideShow = setTimeout("slideShow(" + increment_ + ", " + timeout_ + ")", timeout_);
	} else {
		indexSlideShow = -1;
		playing = false;
	}
}

function startSlideShow()
{
    if ( !playing ) {
	    var form_ = list_.form;
	    var listIncrement_ = 1;
	    var listTimeout_ = 2;
	    var increment_ = 1;
	    var timeout_ = 3000;
	    bNoSlideShow = false;
	    if (iTimeoutSlideShow != null)
	    {
		    clearTimeout(iTimeoutSlideShow);
		    iTimeoutSlideShow = null;
		    status_.innerHTML = ": Stopped :";
	    }
	    if (indexSlideShow < 0)
		    indexSlideShow = list_.selectedIndex;
	    playing = true;
	    status_.innerHTML = ": Playing :";
	    slideShow(increment_, timeout_);
    }
}

function suspendSlideShow()
{
	if (indexSlideShow > 0)
	    bNoSlideShow = true;
	status_.innerHTML = ": Paused :";
}

function stopSlideShow()
{
    playing = false;
	bNoSlideShow = true;
	indexSlideShow = -1;
	switchIMG(list_);
	status_.innerHTML = ": Stopped :";
}

function gotoListItem()
{
	var list_ = getChildNodeById(getChildNodeById("ListBoxID").value);
	list_.selectedIndex = list_.form.ListBox1Index.value;
}

var list_, linkListText_, inputListIndex_, status_;
window.onload = function() {
	list_ = getChildNodeById(getChildNodeById("ListBoxID").value);
	status_ = getChildNodeById("status");
	linkListText_ = getChildNodeById("HyperLink4");
	inputListIndex_ = getChildNodeById("ListBox1Index");
	path_ = getChildNodeById("SlidePath").value;
};
