function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
		if (oldonload) {
			oldonload();
		}
			func();
		}
	}
}

function sfHover() {
	// define the UL-elements by their id in the array menus
	var menus = new Array("main-menu-list");
	var elements = new Array("LI", "TD");
	var idCounter = 0;
	for (var k = 0; k < elements.length; k++) {
		for (var j = 0; j < menus.length; j++) {
			var sfEls = document.getElementById(menus[j]).getElementsByTagName(elements[k]);
			for (var i=0; i<sfEls.length; i++) {
				sfEls[i].id = "menuElm" + idCounter;
				sfEls[i].onmouseover=function() {
					this.className+=" sfhover";
				}
				sfEls[i].onmouseout=function() {
					hideMenu(this.id);
				}
				idCounter++;
			}
		}
	}
}

function hideMenu(elmID) {
	setTimeout("hideIt('" + elmID + "')", 500);
}

function hideIt(elmID) {
	var menuObj = document.getElementById(elmID);
	menuObj.className=menuObj.className.replace(new RegExp("sfhover\\b"), "");
}

addLoadEvent(sfHover);
