function gallery_select(index)
{
	if (document.getElementById)
	{
		var jpg = 'image'+index+'.jpg';
		document.getElementById('gallery_image').src = jpg;
		
		if (document.getElementsByClassName)
		{
			var active = document.getElementsByClassName('gallery_active');
			for (var a = 0; a < active.length; a++)
			{
				active.item(a).setAttribute('class', 'gallery_inactive');
			}
			document.getElementById('gallery_thumb'+index).setAttribute('class', 'gallery_active');
		}
		else
		{
			for (var elemNo = 0; elemNo < 100; ++elemNo)
			{
				var elem = document.getElementById('gallery_thumb'+elemNo);
				if (elem == null)
				{
					break;
				}
				elem.setAttribute('class', (elemNo == index) ? 'gallery_active' : 'gallery_inactive');
			}
		}
		return false;
	}
	else
	{
		return true;
	}
}

function gallery_create(count, iwidth, iheight, twidth, theight)
{
	document.write('<p class="centred">');
	for (var i=0; i < count; ++i)
	{
		if (i > 0)
		{
			document.write('&nbsp;');
		}
		document.write('<a onclick="return gallery_select('+i+')" href="image'+i+'.jpg"><img id="gallery_thumb'+i+'" class="gallery_inactive" src="thumb'+i+'.jpg" width="'+twidth+'" height="'+theight+'" /></a>');
	}
	document.write('<br /><br />');
	document.write('<img id="gallery_image" alt="Screenshot" src="image0.jpg" width="'+iwidth+'" height="'+iheight+'" /><br />');
	document.write('</p>');
	gallery_select(0);
}
