window.onload = function() {
	if (navigator.platform == 'MacPPC' && navigator.appName == 'Microsoft Internet Explorer') return;
	var uls = document.getElementById('header_menu').childNodes;
	for (var i = 0; i < uls.length; i++) {
		var this_ul = uls[i];
		if (this_ul.tagName == 'UL') {
			var lis = this_ul.childNodes;
			for (var j = 0; j < lis.length; j++) {
				var this_li = lis[j];
				if (this_li.tagName == 'LI') {
					// for mouseover-activated menus in IE (others covered by CSS)
					if (navigator.appName == 'Microsoft Internet Explorer') {
						this_li.onmouseover = function() { this.className = 'scriptfocus'; };
						this_li.onmouseout = function() { this.className = ''; };
						}
					
					// for keyboard-activated menus in all browsers
					var focusHandler = makeFocusHandler(this_li);
					var blurHandler = makeBlurHandler(this_li);
					var anchors = this_li.getElementsByTagName('A');
					for(var k = 0; k < anchors.length; k++) {
						anchors[k].onfocus = focusHandler;
						anchors[k].onblur = blurHandler;
						}
					}
				}
			}
		}
	};

function makeFocusHandler(e) {
	return function() {
		if (e.menuTimer != null) {
			window.clearTimeout(e.menuTimer);
			e.menuTimer = null;
			}
		e.className = 'scriptfocus';
		};
	}

function makeBlurHandler(e) {
	return function() {
		// defer closing the menu, otherwise the links in the menus will be skipped
		e.menuTimer = window.setTimeout(function () { e.className = '' }, 0);
		}
	}
