myBrowser=navigator.appName
myVersion=navigator.appVersion
var version45=(myVersion.indexOf("4.")!=-1||myVersion.indexOf("5.")!=-1)
var NS=(myBrowser.indexOf("Netscape")!=-1 && version45)
var IE=(myBrowser.indexOf("Explorer")!=-1 && version45)

function changemsgDiv(toThis)
{
	if(IE)
    msgDiv.innerHTML="<div>"+toThis+"</div>"

	if(NS)
		with(document.msgDiv.document)
			{
				open()
				write("<div>"+toThis+"</div>")
				close()
			}
}

// Preload all the images.
allImg = new Array()
for(i=0 ; i < imgList.length ; i++)
{
	allImg[i] = new Image()
	allImg[i].src = "../jpg/tour/" + imgList[i] + ".JPG"
}

currentImg = 0
imgCt = imgList.length
play  = "playing"

function rotate() 
{
	if (document.images) {
		if (document.screenImg.complete) {
			if (currentImg == imgCt) {
				currentImg = 0
			}
			document.screenImg.src = allImg[currentImg].src

			formatMsg()
							
			currentImg++
		}
 	 	playingImg = setTimeout("rotate()", imgDelay[currentImg-1] * 1000)
  	}
}

function formatMsg()
{
	var allmsg = "<ol>";
	for(i=0 ; i < imgCt ; i++)
	{
		if(i == currentImg)	// highlight msg associated with the current image
			allmsg = allmsg + "<li><font class='TextHighlight'>" + msgList[i] + "</font>&nbsp;&nbsp;&nbsp;&nbsp;" + imgDelay[i] + "sec(s)<br>"
		else
			allmsg = allmsg + "<li><font class='TextBold'>" + msgList[i] + "</font>&nbsp;&nbsp;&nbsp;&nbsp;" + imgDelay[i] + "sec(s)<br>"
	}
	allmsg = allmsg + "</ol>"
	changemsgDiv(allmsg)
}
	
function callBackward()
{
	if(play == "playing")
	{
		clearTimeout(playingImg)
		play = "stopped"
		document.tour.playstatus.value = "tour stopped"
		currentImg--
	}

	if (currentImg <= 0)
		currentImg = imgCt - 1
	else
		currentImg--

	document.screenImg.src = allImg[currentImg].src
	formatMsg()
}

function callForward()
{
	if(play == "playing")
	{
		clearTimeout(playingImg)
		play = "stopped"
		document.tour.playstatus.value = "tour stopped"
		currentImg--
	}
	if (currentImg >= imgCt - 1)
		currentImg = 0
	else
		currentImg++

	document.screenImg.src = allImg[currentImg].src
	formatMsg()
}

function callPlay()
{
	clearTimeout(playingImg)

	document.tour.playstatus.value = "tour playing"
	play = "playing"
	rotate()
}

function callStop()
{
	clearTimeout(playingImg)
	if(play == "playing")
	{
		play = "stopped"
	}
	document.tour.playstatus.value = "tour stopped"
}
