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;
	form_.Image1.src = "IMGHandler.ashx?id=" + list_.options[index_].value
		+ "&cam=" + form_.DropDownList4.options[form_.DropDownList4.selectedIndex].value;
//		+ "&timestamp=" + form_.Timestamp.value;
//	var linkListText_ = getChildNodeById("HyperLink4");
//	var inputListIndex_ = getChildNodeById("ListBox1Index");
	linkListText_.innerHTML = list_.options[index_].text;
	inputListIndex_.value = index_;
	return true;
}

var indexSlideShow = -1;
var iTimeoutSlideShow = null;
var bNoSlideShow = false;
function slideShow(increment_, timeout_)
{
	if (bNoSlideShow)
	{
		if (iTimeoutSlideShow != null)
		{
			clearTimeout(iTimeoutSlideShow);
			iTimeoutSlideShow = null;
		}
		return;
	}
//	var list_ = getChildNodeById("ListBox1");
	if (switchIMG(list_, indexSlideShow += increment_))
		iTimeoutSlideShow = setTimeout("slideShow(" + increment_ + ", " + timeout_ + ")", timeout_);
	else
		indexSlideShow = -1;
}

function startSlideShow()
{
//	var list_ = getChildNodeById("ListBox1");
	var form_ = list_.form;
	var listIncrement_ = form_.DropDownList5;
	var listTimeout_ = form_.DropDownList6;
	var increment_ = parseInt(listIncrement_.options[listIncrement_.selectedIndex].value);
	var timeout_ = parseInt(listTimeout_.options[listTimeout_.selectedIndex].value);
	bNoSlideShow = false;
	if (indexSlideShow < 0)
		indexSlideShow = list_.selectedIndex;
	slideShow(increment_, timeout_);
}

function suspendSlideShow()
{
	if (indexSlideShow > 0)
		if (!(bNoSlideShow = !bNoSlideShow))
			startSlideShow();
}

function stopSlideShow()
{
	bNoSlideShow = true;
	indexSlideShow = -1;
	switchIMG(list_);
}

function gotoListItem()
{
	var list_ = getChildNodeById("ListBox1");
	list_.selectedIndex = list_.form.ListBox1Index.value;
}

var list_, linkListText_, inputListIndex_;
window.onload = function() {
	list_ = getChildNodeById("ListBox1");
	linkListText_ = getChildNodeById("HyperLink4");
	inputListIndex_ = getChildNodeById("ListBox1Index");
};
