function keepStyle (elem) {
liRoot = document.getElementById(elem);
/*
	if (liRoot.parentNode.getAttribute("className") == "menulist0" || liRoot.parentNode.getAttribute("className") == "menulist1" || liRoot.parentNode.getAttribute("className") == "menulist2") {
		liRoot.style.backgroundColor = '#ffffff';
	} else {
		liRoot.style.backgroundColor = '#c72700';
	}
*/
//alert(liRoot.getAttribute("class") + "|" + liRoot.getAttribute("className"));
if (liRoot.getAttribute("class") == "firstLevel" || liRoot.getAttribute("className") == "firstLevel" ) {
liRoot.style.backgroundColor = '#c72700';
var acolor = '#ffffff';
} else {
liRoot.style.backgroundColor = '#ffffff';
var acolor = '#000000';
}
for (i=0; i<liRoot.childNodes.length; i++) {
		node = liRoot.childNodes[i];
		if (node.nodeName=="A") {
			node.style.color = acolor;
	   	}
	}
}
function loseStyle (elem) {
liRoot = document.getElementById(elem);
liRoot.style.backgroundColor = '';
if (liRoot.getAttribute("class") == "firstLevel" || liRoot.getAttribute("className") == "firstLevel") {
var acolor = '#000000';
} else {
var acolor = '#ffffff';
}
for (i=0; i<liRoot.childNodes.length; i++) {
		node = liRoot.childNodes[i];
		if (node.nodeName=="A") {
			node.style.color = acolor;
	   	}
	}
}

// Get maxlength of longest linkname in the unordered list and resize the list -->

function resizeList() { 
    var lists = document.getElementsByTagName("ul"); 
    for (x = 0; x < lists.length; x++) { 
        var list = lists[x]; 
		var maxlength = 10;
		if (list.getAttribute("class") == "menulist0" || list.getAttribute("className") == "menulist0" || list.getAttribute("class") == "menulist1" || list.getAttribute("className") == "menulist1" || list.getAttribute("class") == "menulist2" || list.getAttribute("className") == "menulist2") { 
            var listitems = list.childNodes; 
			for (j = 0; j < listitems.length; j++) {
				node = listitems[j];
				if (node.nodeName == "LI") {
					linkitems = node.childNodes;
					for (k = 0; k < linkitems.length; k++) {
						linkitem = linkitems[k];
						if (linkitem.nodeName == "A") {
							var linktext = linkitem.childNodes[0].nodeValue; 
							if (linktext.length > maxlength) { 
				    	                	maxlength = linktext.length; 
			        	        	}
						}
					}
	            		}
			}
			list.style.width = ((maxlength/4)*2)+1.5 + "em"; 	
			var ulitems = list.getElementsByTagName("ul"); 
	        for (j = 0; j < ulitems.length; j++) { 
				ulitems[j].style.left = ((maxlength/4)*2)+0.9 + "em"; 
	        }
		}
	
    } 
} 
window.onload = resizeList; 

