//MJ
// To use define a hovermenu array with the IDs of the images:
// var HoverMenu = ['whoweare','healthstuff','contacts','staffarea'];
// Then call InitHoverMenu after the elements have been loaded
//the images must be .png and the second images must be b.png



function InitHoverMenu()
{
	for (t=0;t<HoverMenu.length;t++)
	{
		var element = document.getElementById(HoverMenu[t]);
		imagename = element.src;
		PreFetchImage(ToBImage(imagename));
		eval('function mh() {  HoverMenuHandler("'+HoverMenu[t]+'")};');
		eval('function mdeh() {  DeHoverMenuHandler("'+HoverMenu[t]+'")};');
		
		try
		{
				//IE Method				
			element.attachEvent('onmouseover' , mh);
			element.attachEvent('onmouseout' , mdeh);
		}catch (a)
		{
			//try w3c method
			element.addEventListener('mouseover' , mh,false);
			element.addEventListener('mouseout', mdeh,false);	
		}
	}
}


function ToBImage(name)
{
	return name.substring(0,name.indexOf('.gif')) + 'b.gif';
}

function PreFetchImage(name)
{
	document.write('<image src="' + name + '" style="visibility:hidden"/>');
}


function HoverMenuHandler(id)
{

	var item = document.getElementById(id);
	item.src = ToBImage(item.src);
}

function DeHoverMenuHandler(id)
{
	var item = document.getElementById(id);
	item.src = item.src.substring(0,item.src.indexOf('b.gif')) + '.gif';
}

