//Parse the version of IE
if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) {
    var ieversion=new Number(RegExp.$1);
}

//Execute hover() if the browser is IE version below 8
if (ieversion<8) {
    hover = function() {
		//Create an array of the li tags in #nav
        var Elements = document.getElementById("nav").getElementsByTagName("LI");
		//For each of the li tags in #nav, add the class "hover" on mouseover and add a background color based on its parent node
        for (var i=0; i<Elements.length; i++) {
            Elements[i].onmouseover=function() {
                this.className+=" hover";
				if (this.parentNode.id=="nav") {
					this.style.backgroundColor="#e3de52";
				}
				else if (this.parentNode.parentNode.parentNode.id=="nav") {
					this.style.backgroundColor="#e3de52";
				}
				else if (this.parentNode.parentNode.parentNode.parentNode.parentNode.id=="nav") {
					this.style.backgroundColor="#a1513e";
				}
			}
		//For each of the li tags in #nav, replace the class "hover" with nothing on mouseout and add a background color based on its parent node
        Elements[i].onmouseout=function() {
            this.className=this.className.replace(new RegExp(" hover\\b"), "");
				if (this.parentNode.id=="nav") {
					this.style.backgroundColor="#fffd7a";
				}
				
				else if (this.parentNode.parentNode.parentNode.id=="nav") {
					if (this.className=="alternatingHighlight") {
						this.style.backgroundColor="#efea56";
					}
					else {
						this.style.backgroundColor="#fffd7a";
					}
				}
								
				else if (this.parentNode.parentNode.parentNode.parentNode.parentNode.id=="nav") {
					if (this.className=="alternatingHighlight") {
						this.style.backgroundColor="#c9654e";
					}
					else {
						this.style.backgroundColor="#ff8063";
					}
				}
            }
        }
    }
	//Execute script on load
    if (window.attachEvent) window.attachEvent("onload", hover);
}
