var timeoutID
var playing = false
var currentImage = 0
var slideshowSecondsInterval = 4

function StartStopSlideShow()
	{
		if (playing == false)
		{
			playing = true
			slideShow()
			timeoutID = setInterval("slideShow()", slideshowSecondsInterval * 1000)
		//	document.images.previouspagebutton.src = "images\previous_button.gif"
		//	document.images.nextpagebutton.src = "images\next_button.gif"
		}else{
			playing = false
			clearTimeout(timeoutID)
		//	window.location.href= stopUrl + (currentImage-1);
		}	
//document.images.PlayButton.src = "images\stop_button.gif"
//timeoutID = setInterval("slideShow()", 3000)
}



function adjustSlideShowInterval(newInterval)
{
	slideshowSecondsInterval = newInterval;
}	

function decrementSlideShowInterval()
{
		if (slideshowSecondsInterval > 2)
	{
		//StartStopSlideShow();
		slideshowSecondsInterval = slideshowSecondsInterval - 2;
		playing = false
		clearTimeout(timeoutID);
		playing = true
		slideShow()
		timeoutID = setInterval("slideShow()", slideshowSecondsInterval * 1000)
		
//timeoutID = setInterval("slideShow()", slideshowSecondsInterval * 1000)
		//StartStopSlideShow();
	}	
	alert("Your slide show interval is now "+slideshowSecondsInterval+" seconds");
}
function incrementSlideShowInterval()
{
		//StartStopSlideShow();
		slideshowSecondsInterval = slideshowSecondsInterval + 2;
			playing = false
		clearTimeout(timeoutID);
		playing = true
		slideShow()
		timeoutID = setInterval("slideShow()", slideshowSecondsInterval * 1000)
		
		//timeoutID = setInterval("slideShow()", slideshowSecondsInterval * 1000)
		//StartStopSlideShow();
	alert("Your slide show interval is now "+slideshowSecondsInterval+" seconds");
}


function slideShow()
{
	if (currentImage == -1)
	{
	self.location = endUrl
	}
	else 
	if (playing == true)
	{ 
		//alert(imageArray[currentImage])
		
		document.images.DisplayImage.src = imageArray[currentImage];
		//alert(currentImage);
		document.links[5].href = stopUrl + currentImage;
		if (commentArray[currentImage].length > 0 )
		{
		slideshowcomment.innerHTML = "<b>Comment:</b> " + commentArray[currentImage];
		}else{
		slideshowcomment.innerHTML = "";
		}
		//if (audioArray[currentImage].length > 0 )
		//{
		//audioimage.src = "images\\speaker.gif";
		//}else{
		//audioimage.src = "images\\spacer.gif";
		//}
		//alert(document.links(2).href);
		currentImage = currentImage + 1;
		if (currentImage >= imageArray.length)
		{
			currentImage = -1;
		}
		
	}
}

function NavigateNextImage(url)
{
	document.images.DisplayImage.src = imageArray[currentImage]
}

function PopUpImage(imagePath)
{
	winAtts="width=440,height=460,toolbar=no,directories=no,resizable=yes";
  	window.open("PopUpImageDisplay.aspx?image="+imagePath,"ImageViewer",winAtts);
}
function PopUpLargeImage(imagePath)
{
	winLAtts="width=925,height=900,toolbar=no,directories=no,scrollbars=yes,resizable=yes";
  	window.open("PopUpImageDisplay.aspx?image="+imagePath,"LargeImageViewer",winLAtts);
}
function PopUpDefinedImage(imagePath,width,height)
{
	winLAtts="width="+width+",height="+height+",toolbar=no,directories=no,scrollbars=yes,resizable=yes";
  	window.open("PopUpImageDisplay.aspx?image="+imagePath,"LargeImageViewer",winLAtts);
}
function PlayWAVInTabularDisplay(WavLoc)
{
//alert(document.getElementById('sound').src);
	var currentWav = document.getElementById('sound').src;
	if (currentWav.length = 0)
	{
	document.getElementById('sound').src = WavLoc;
	}
	else if (currentWav == WavLoc)
	{
	document.getElementById('sound').src = "";
	}
	else if (currentWav != WavLoc)
	{
	document.getElementById('sound').src = WavLoc;
	}
	else 
	{
	document.getElementById('sound').src = WavLoc;
	}
	//alert(document.getElementById('sound').src);
}
