/*Copyright (c) 2005 S. M. Eskola*/
var slide=0;
function tmgSlideShow(position){	//Move Next or Previous
	if(position == "next"){
		tmgPause();
		slide += 1;	//Advance Slide Image
		if(slide >= imgList.length){slide = 0;} //At end of images return to first image
		if(slide < imgList.length-1){tmgPreImg(1);}
		//MM_swapImage('slide','',imgList[slide],1)	//Swap Image
		tmgSwap(imgList[slide])
		tmgSlideLoc("SlideCount");
	}
	if(position == "prev"){
		tmgPause();
		slide -= 1;	//Retreat Slide Image
		if(slide < 0){slide = imgList.length-1;} //At start of images return to last image
		if(slide > 0){tmgPreImg(-1);}
		//MM_swapImage('slide','',imgList[slide],1)	//Swap Image
		tmgSwap(imgList[slide])
		tmgSlideLoc("SlideCount");
	}
	if(position == "play"){
		slide += 1;	//Advance Slide Image
		if(slide >= imgList.length){slide = 0;} //At end of images return to first image
		if(slide < imgList.length-1){tmgPreImg(1);}
		//MM_swapImage('slide','',imgList[slide],1)	//Swap Image
		tmgSwap(imgList[slide])
		tmgSlideLoc("SlideCount");
	}
	else {
		if(position < imgList.length-1 && position >= 0){ //Go to specific slide
			slide = position; //Set new location
			tmgPreImg(0);
			//MM_swapImage('slide','',imgList[slide],1)	//Swap Image
			tmgSwap(imgList[slide]);
			tmgSlideLoc("SlideCount");
			tmgPreImg(1);
		}
	}
}
function tmgSlideLoc(tmgID){	//Display progress x/y
	document.getElementById(tmgID).innerHTML = (slide + 1) + "/" + imgList.length;
}
function tmgPreImg (stepSize){	//Preload Images
	stepSize += slide;
	MM_preloadImages(imgList[stepSize]);
}
var tmgTimer;
function tmgPlay(cmd){	//Play Slideshow
	if(cmd == "play"){
		document.getElementById("Play").innerHTML = "<a href=javascript:tmgSlideShow('prev');>Previous</a> | <a href=javascript:tmgPlay('pause');>Pause</a> | <a href=javascript:tmgSlideShow('next');>Next</a>";
		tmgSlideShow("play");
		tmgTimer = setTimeout("tmgPlay('play')",5000);
	}else {tmgPause();}
}
function tmgPause(){	//Pause Slideshow
	document.getElementById("Play").innerHTML = "<a href=javascript:tmgSlideShow('prev');>Previous</a> | <a href=javascript:tmgPlay('play');>Play</a> | <a href=javascript:tmgSlideShow('next');>Next</a>";
	clearTimeout(tmgTimer);
}
function tmgSwap(img){		//Swap Image
	document.getElementById("slide").src = img;
}