
var mouse_over_popup = 'none';
var offset_menu = document.layers ? 14 : 20;

// The good, the bad + the ugly
var ua_w3 = document.getElementById ? 1 : 0;
var ua_ie = document.all ? 1 : 0;
var ua_n4 = document.layers ? 1 : 0;


// For N4 only: index offset of first menu title image
var netscfourimgoffset = 8;


function omo(itemname) {

	if (itemname == currentdocument.substr(0, 1)) {
		// If this is the currently active (ie: hightlighted)
		// section, return (currentdocument is defined in inline JS)
		return;
	}

	mouse_over_popup = itemname.substr(0, 1);

	if (ua_n4) {
		// NETSCAPE 4
		if (itemname.length == 1) {
			// Rollover for menu title
			offset = itemname.charCodeAt(0) - 97;
			document.images[netscfourimgoffset + offset].src = eval('menu'+itemname+'_a.src');
		}
		else {
			// Rollover for menu item
			offset = itemname.charCodeAt(1) - 97;
			eval('document.menu'+mouse_over_popup+'.document.images['+offset+'].src = menu'+itemname+'_a.src');
		}
	}
	else if (ua_w3) {
		// W3CDOM-compliant
		document.getElementById('imgmenu' + itemname).src = eval('menu'+itemname+'_a.src');	
	}
	else {
		// IE4 or whatever
		eval('document.all.imgmenu' + itemname + '.src = menu' + itemname + '_a.src');
	}

} // function omo()



function omout(itemname) {

	if (itemname == currentdocument.substr(0, 1)) {
		// If this is the currently active (ie: hightlighted)
		// section, return (currentdocument is defined in inline JS)
		return;
	}

	if (ua_n4) {
		// NETSCAPE 4
		if (itemname.length == 1) {
			// Rollover for menu title
			offset = itemname.charCodeAt(0) - 97;
			document.images[netscfourimgoffset + offset].src = eval('menu'+itemname+'.src');
		}
		else {
			// Rollover for menu item
			offset = itemname.charCodeAt(1) - 97;
			eval('document.menu'+mouse_over_popup+'.document.images['+offset+'].src = menu'+itemname+'.src');
		}
	}
	else if (ua_w3) {
		// W3CDOM-compliant
		document.getElementById('imgmenu' + itemname).src = eval('menu'+itemname+'.src');
	}
	else {
		// IE4 or whatever
		eval('document.all.imgmenu' + itemname + '.src = menu' + itemname + '.src');
	}

	mouse_over_popup = 'none';
	window.setTimeout('hide_menus_immediately()', 900);

} // function omout(itemname)



function hide_menus_immediately() {

	if (mouse_over_popup != 'a')
		changeObjectVisibility('menua', 'hidden');
	if (mouse_over_popup != 'b')
		changeObjectVisibility('menub', 'hidden');
	if (mouse_over_popup != 'c')
		changeObjectVisibility('menuc', 'hidden');
	if (mouse_over_popup != 'd')
		changeObjectVisibility('menud', 'hidden');
	if (mouse_over_popup != 'e')
		changeObjectVisibility('menue', 'hidden');

} // function hide_menus_immediately()



function show_menu(itemname, eventObj) {

	hide_menus_immediately();
	var menuid = 'menu' + itemname;

	if(changeObjectVisibility(menuid, 'visible')) {
		eventObj.cancelBubble = true;
		omo(itemname);
		return true;
	}
	else {
		return false;
	}

} // function show_menu(menuname, eventObj)



function getStyleObject(objectId) {

	// cross-browser function to get an object's style object given its id
	if(document.getElementById && document.getElementById(objectId)) {
		// W3C DOM
		return document.getElementById(objectId).style;
	}
	else if (document.all && document.all(objectId)) {
		// MSIE 4 DOM
		return document.all(objectId).style;
	}
	else if (document.layers && document.layers[objectId]) {
		// NN 4 DOM.. note: this won't find nested layers
		return document.layers[objectId];
	}
	else {
		return false;
	}

} // function getStyleObject(objectId)



function changeObjectVisibility(objectId, newVisibility) {

	// get a reference to the cross-browser style object and make sure the object exists
	var styleObject = getStyleObject(objectId);
	if(styleObject) {
		styleObject.visibility = newVisibility;
		return true;
	}
	else {
		// we couldn't find the object, so we can't change its visibility
		return false;
	}

} // function changeObjectVisibility(objectId, newVisibility)



function popupwindow(url) {

	// Used for opening a window for newsletter subscription or contact
	// An arbitrary heigth can be supplied in a second, optional argument
	
	if (popupwindow.arguments.length == 2)
		height = popupwindow.arguments[1];
	else
		height = 470;
	
	w = window.open(url, 'popup', 'status=1,width=390,height='+height+',scrollbars,resizable=yes');
	w.focus();

} // function popupwindow(url)



function mapwindow(url, w, h) {

	// Used for opening a window showing a map for a single branch
	
	w = window.open(url, 'popup', 'status=1,width='+w+',height='+h+',scrollbars,resizable=yes');
	w.focus();

} // function mapwindow(url)


