/****************************************************/
/** Free script for any use, but please include    **/
/** a link to i-code.co.uk in any redistribution.  **/
/**                                                **/
/** Author : Stephen Griffin, www.i-code.co.uk     **/
/****************************************************/
/****************************************************/
/** modified: Botond B Kiss, www.eskolar.com       **/
/** added play loop functions                      **/

/******************************* BKB ******************************/
g_pha_width = 320;
g_fPlayMode = 1;
g_dwTimeOutSec=3;

//function OnImgLoad()
//	{
//	if (g_fPlayMode)
//	window.setTimeout("Tick()", g_dwTimeOutSec*1000);
//	}

function Tick() 
{
	if (g_fPlayMode)
	nextImage();
}
/******************************* BKB ******************************/

function changeImage(pVar)
{
	//alert("pVar "+ pVar)
	if(pVar == "stop"){
		g_fPlayMode = 0;
	}
	if(pVar == "play"){
		g_fPlayMode = 1;
	}
	
	var list = document.getElementById('optionlist');
	document.mainimage.src = list.options[list.selectedIndex].value;
	document.mainimage.width = g_pha_width;
	if (g_fPlayMode){
	window.setTimeout("Tick()", g_dwTimeOutSec*1000);
	}	
}

function prevImage()
{
	g_fPlayMode = 0;
	var list = document.getElementById('optionlist');
	if(list.selectedIndex == 0)
	{
	list.selectedIndex = list.options.length-1;
	}
	else
	{
	list.selectedIndex--;
	}
	changeImage();
}

function nextImage(pVar)
{		
	//alert("pVar "+ pVar)
	if(pVar == "stop"){
		g_fPlayMode = 0;
	}
	if(pVar == "play"){
		g_fPlayMode = 0;
	}
	var list = document.getElementById('optionlist');
	if(list.selectedIndex == list.options.length-1)
	{
	list.selectedIndex = 0;
	}
	else
	{
	list.selectedIndex++;
	}
	changeImage(pVar);
}

function stop(){
g_fPlayMode = 0;
}

function start(){
g_fPlayMode = 1;
changeImage("play")
}

          
