


function galleryImgId(galleryid, imgfunction)
{
	// no container found so don't bother
	if (typeof document.getElementById == 'undefined') { return; }
	
	// Look for the container to the gallery images
	// it should have an id specified by gallerid 
	
	var tree = document.getElementById(galleryid);
	if (tree)
	{
		// get the images within the container
		var items = tree.getElementsByTagName('img');
		
		// for each image allocate an id 
		// based on the container id plus sequence number
		for (var i = 0; i < items.length; i++)
		{
			items[i].id = "gallery_" + i;
			$imgsrc = items[i].src;
			$imgalt = items[i].alt;
			//$imgwidth = items[i].width;
			$imgonmouseover = imgfunction +'("'+ $imgsrc + '","' + $imgalt + '"); return false;';
			items[i].onmouseover = new Function ($imgonmouseover);
			items[i].style.cursor = 'pointer';
			items[i].title = $imgalt;
		}
	// all images in the container should now have a unique id
	// and and onclick call
	// and a title = alt text

	}
}

function attachEventListener(target, eventType, functionRef, capture)
{
	if (typeof target.addEventListener != 'undefined')
	{
		target.addEventListener(eventType, functionRef, capture);
	}
	else if (typeof target.attachEvent != 'undefined')
	{
		target.attachEvent('on' + eventType, functionRef);
	}
	else
	{
		eventType = 'on' + eventType;

		if (typeof target[eventType] == 'function')
		{
			var oldListener = target[eventType];

			target[eventType] = function()
			{
				oldListener();

				return functionRef();
			}
		}
		else
		{
			target[eventType] = functionRef;
		}
	}
	
	return true;
}

function addLoadListener(fn)
{
	if (typeof window.addEventListener != 'undefined')
	{
		window.addEventListener('load', fn, false);
	}
	else if (typeof document.addEventListener != 'undefined')
	{
		document.addEventListener('load', fn, false);
	}
	else if (typeof window.attachEvent != 'undefined')
	{
		window.attachEvent('onload', fn);
	}
	else
	{
		var oldfn = window.onload;
		if (typeof window.onload != 'function')
		{
			window.onload = fn;
		}
		else
		{
			window.onload = function()
			{
				oldfn();
				fn();
			};
		}
	}
}


function showImg($img,$alt){

$main_img = document.getElementById('galleryimg');
var thisimage = new Image();
thisimage.src = $img;
if(thisimage.width > $max_width){thisimage.width = $max_width;}
$main_img.src = $img;
$main_img.alt = $alt;
$main_img.width = thisimage.width;
}

$max_width = 400;
addLoadListener(function() { galleryImgId('galleryleft','showImg'); });

