/****************************************************/
/** 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     **/
/****************************************************/

function getPhotoId(optionlist)
{
	var list = document.getElementById(optionlist);
	var str = list.options[list.selectedIndex].value;
	return str.substring(0,str.indexOf(':'));
}

function getPhotoCaption(optionlist)
{
	var list = document.getElementById(optionlist);
	var str = list.options[list.selectedIndex].text;
	return str;
}

function getImagePath(str)
{
	return str.substring(str.indexOf(':')+1);
}

function changeImage(optionlist,imagename)
{
	var list = document.getElementById(optionlist);
	var imageobj = document.getElementById(imagename);
	//alert('PhotoId:' + getPhotoId(list.options[list.selectedIndex].value));
	imageobj.src = getImagePath(list.options[list.selectedIndex].value);
}

function prevImage(optionlist,imagename)
{
	var list = document.getElementById(optionlist);
	if(list.selectedIndex == 0)
	{
		list.selectedIndex = list.options.length-1;
	}
	else
	{
		list.selectedIndex--;
	}
	changeImage(optionlist,imagename);
}

function nextImage(optionlist,imagename)
{
	var list = document.getElementById(optionlist);
	if(list.selectedIndex == list.options.length-1)
	{
		list.selectedIndex = 0;
	}
	else
	{
		list.selectedIndex++;
	}
	changeImage(optionlist,imagename);
}
