	
//---------------------------------------------------
//Correct the Housemenu active state and IE hover problems
//---------------------------------------------------

var strId = "HouseMenuNavCurrentItem"

var sParentClass = "CurrentItemParent"
var sChildClass = "CurrentItemChild"



	function setHouseMenuCurrentItem(){	
		//get the current active node, this is the LI containing the active link
		var oMenu = document.getElementById (strId);

		if (undefined != oMenu){
			searchUp (oMenu);
			setActiveChildClass(oMenu);
		}
	}
	
	
		
	function searchUp(oNode){
	//move up from the active item in the dom to set the classes to active
			var oParent = oNode.parentNode;
			
			//Stop search if the root Div is reached
			if (oParent.tagName != "DIV"){
				//Do not handle the LI's
				if (oParent.tagName == "LI"){
					var oChildren = oParent.childNodes;
					for (var i=0; i<oChildren.length; i++) {
						//Set the calssname for all but A
						if (oChildren[i]){
							if (oChildren[i].tagName == "A"){
								oChildren[i].className = sParentClass;
							}
						}
					}

				}
				oParent.className += " ";
				oParent.className += sParentClass;
				searchUp(oParent);
				
			}
	}
	
	
	
	function setActiveChildClass(oMenu){
		var oChildUl = oMenu.getElementsByTagName('UL');
			for (var i=0; i<oChildUl.length; i++){
				if (oChildUl[i].parentNode == oMenu){
					oChildUl[i].className = sChildClass
				}
			}				
	}
	
	//Correct hover for IE 6
	function newHoverFix(menuId) {
		var oMenu = document.getElementById(menuId);
		if (undefined != oMenu){
		 //alert (menuId);
			var ieLIs = oMenu.getElementsByTagName('LI');
			for (var i=0; i<ieLIs.length; i++) if (ieLIs[i]){
				ieLIs[i].onmouseover=function() {this.className+=" sfhover";}
				ieLIs[i].onmouseout=function() {this.className=this.className.replace(new RegExp("( ?|^)sfhover\\b"), '');}
			}
		}	
	}
	
	
	function InitAll()
		{
		setHouseMenuCurrentItem();
		newHoverFix ("HouseMenuNav");
		}
		
		//Add function to load event of page
		if (window.addEventListener){
			window.addEventListener("load", InitAll, false);
		}
		else if (window.attachEvent){
			window.attachEvent ("onload", InitAll)
		} 
