// Swaps the thumbnail image when the select menu value changes
/*
Insert the following after the select menu
<script language="JavaScript">
<!--
InitImageSelect('selectMenuId');
// -->
</script>
*/

var imageArray;

function onChoiceChange(selectMenu)
{
	var ChoiceImage = document.getElementById('ChoiceImage');
	var SelectedIndex = -1;
	if(selectMenu)
	{
	    for(i=0;i<selectMenu.length;i++)
	    {
		    if(selectMenu.options[i].selected)
			    SelectedIndex = i;
	    }
	}
	if(SelectedIndex > -1 && ChoiceImage)
	{
		if(imageArray[SelectedIndex])
		    ChoiceImage.src = imageArray[SelectedIndex];
	}
}


function InitImageSelect(selectMenuId)
{					
	var selectMenu = document.getElementById(selectMenuId);
	imageArray = new Array();
	if(selectMenu)
	{
	    for(i=0;i<selectMenu.length;i++)
	    {	
		    var optionText = selectMenu.options[i].text;
		    if(optionText.match(/{.*}/))
		    {
			    imageArray.push(optionText.substring((optionText.indexOf('{')+1), optionText.indexOf('}')) + '.jpg');
			    selectMenu.options[i].text = optionText.substring(0, optionText.indexOf('{'));
		    }
	    }
	}
}