function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			if (oldonload) {
				oldonload();
			}
			func();
		}
	}
};

function tribHover() {
	var timeout = 600;
	var cssClass = "highlight";
	var thisPage = readCookie("mainPage")

	var queue = [];
	var reCSS = new RegExp("\\b" + cssClass + "\\b");
	var tribEls = document.getElementById("root").getElementsByTagName("li");

 	for (var i=0; i<tribEls.length; i++) {
	 	if(/subStay/.test(tribEls[i].parentNode.className))
	  	{

		} else {

		// mouseover and mouseout handlers for regular mouse based interface.
			tribEls[i].onmouseover = function() {
				queueFlush();
				this.className += " " + cssClass;
				$$('#root li a.mainNav').each(function(link){
			        if(link.readAttribute('href') == thisPage ){
						link.up(0).removeClassName(cssClass);
					}
			    });
			}
			tribEls[i].onmouseout = function() {
				queue.push([setTimeout(queueTimeout, timeout), this]);
			}
			// focus and blur handlers for keyboard based navigation.
			tribEls[i].onfocus = function() {
				queueFlush();
				this.className += " " + cssClass;
			}
			tribEls[i].onblur = function() {
				queue.push([setTimeout(queueTimeout, timeout), this]);
//			}

			// click event handler needed for tablet type interfaces (e.g. Apple iPhone).
			tribEls[i].onclick = function(e) {
				if (this.className.search(reCSS) == -1) {
					// CSS not set, so clear all sibling (and decendants) menus, and then set CSS on this menu...
					var elems = this.parentNode.getElementsByTagName("li");
					for (var i=0; i<elems.length; i++) {
						elems[i].className = elems[i].className.replace(reCSS, "");
					}
					this.className += " " + cssClass;
				} else {
					// CSS already set, so clear all decendant menus and then this menu...
					var elems = this.getElementsByTagName("li");
					for (var i=0; i<elems.length; i++) {
						elems[i].className = elems[i].className.replace(reCSS, "");
					}
					this.className = this.className.replace(reCSS, "");
				}
				if (e && e.stopPropagation)
					e.stopPropagation();
				else
					window.event.cancelBubble = true;
			}
		}

		queueFlush = function () {
			while (queue.length) {
				clearTimeout(queue[0][0]);
				queueTimeout();
			}
		}

		queueTimeout = function() {
			if (queue.length) {
				var el = queue.shift()[1];
				el.className = el.className.replace(reCSS, "");
				$$('#root li a.mainNav').each(function(link){
			        if(link.readAttribute('href') == thisPage){
						link.up(0).addClassName(cssClass);
                        var arr = link.next('ul').descendants();
                        arr.each(function(subLink){
                            subLink.descendants().each(function(subLinkA){
                                if(subLinkA.readAttribute('href') == "<%=csection%>"){
                                    subLinkA.up(0).addClassName('highlight');
                                }
                            });
                        });
					}
			    });
			}
		}
	}
}
}
