// bypass incapacity of interpreting the "hover" CSS pseudo-class if IE < 7

function show_it(the_li) {
//window.alert("the_ul="+the_ul+"&the_li="+the_li);
	var menu_children2 = document.getElementById("menu").childNodes;
	for (i=0;i<menu_children2.length;i++) {
		if (menu_children2[i].nodeName=='LI') {
			menu_children2[i].getElementsByTagName('A')[0].style.backgroundColor='#bdb39f';
			for (j=0;j<menu_children2[i].childNodes.length;j++) {
				if (menu_children2[i].childNodes[j].nodeName=='UL') {
					menu_children2[i].childNodes[j].style.display='none';
				}
			}
		}
	}
	if (typeof the_li != 'undefined') {
		menu_children2[the_li].getElementsByTagName('A')[0].style.backgroundColor='#c21e2a';
		for (j=0;j<menu_children2[the_li].childNodes.length;j++) {
			if (menu_children2[the_li].childNodes[j].nodeName=='UL') {
				menu_children2[the_li].childNodes[j].style.display='block';
			}
		}
	}
}
function hover_it() {
	found_li = "";
	var heading_url = location.href.substring(location.href.lastIndexOf("/")+1);
	var menu_children = document.getElementById("menu").childNodes;
	for (i=0;i<menu_children.length;i++) {
		if (found_li !== "") {
			break
		}
		if (menu_children[i].nodeName=='LI') {
			for (j=0;j<menu_children[i].childNodes.length;j++) {
				if (menu_children[i].childNodes[j].nodeName=='A') {
					the_anchor = menu_children[i].childNodes[j]+'';
					the_anchor = the_anchor.substring(the_anchor.lastIndexOf("/")+1);
					if (heading_url == the_anchor) {
						found_li = i;
					}
				}
				if (found_li !== "") {
					break;
				}
			}
		}
	}
	for (i=0;i<menu_children.length;i++) {
		if (menu_children[i].nodeName=='LI') {
			var a_function = new Function('', 'show_it('+i+');');
			var a_function2 = new Function('', 'show_it('+found_li+');');
			if (window.addEventListener) {
				menu_children[i].addEventListener('mouseover', a_function, false);
				menu_children[i].addEventListener('mouseout', a_function2, false);
			}
			else if (window.attachEvent) {
				menu_children[i].attachEvent('onmouseover', a_function);
				menu_children[i].attachEvent('onmouseout', a_function2);
			}
		}
	}
	if (found_li != "") {
//		window.alert("found_li="+found_li);
		show_it(found_li);
//		document.getElementById("menu").childNodes[the_li].childNodes[found_heading].style.backgroundColor="#7A221B";
	}
}
if (window.addEventListener) {
	window.addEventListener('load', hover_it, false);
}
else if (window.attachEvent) {
	window.attachEvent('onload', hover_it);
}
