activeMenu = null;
lastMenu = null;
origMenu = null;
menuStatus = null;

function mlon(obj){
	obj.getElementsByTagName("div")[0].style.display = "block";
	menuStatus = true;
	if(activeMenu == null || activeMenu == ""){
		activeMenu = obj.getElementsByTagName("div")[0].offsetParent.id;
		origMenu = 	obj.getElementsByTagName("div")[0].offsetParent.id;	
		highlightfirstanchor(obj);		
	}  else if (activeMenu != obj.getElementsByTagName("div")[0].offsetParent.id){
		activeMenu = obj.getElementsByTagName("div")[0].offsetParent.id;
		highlightfirstanchor(obj);
		unhighlightfirstanchor(lastMenu);
	}
		else {
		activeMenu = obj.getElementsByTagName("div")[0].offsetParent.id;
		highlightfirstanchor(obj);
	}
		
	var browserName=navigator.appName; 
	if (browserName=="Microsoft Internet Explorer") {	
		var IfrRef = document.getElementById('DivShim');	
		IfrRef.style.width = obj.getElementsByTagName("div")[0].offsetParent.offsetWidth;
		IfrRef.style.height = obj.getElementsByTagName("div")[0].offsetParent.offsetHeight;
		IfrRef.style.top = obj.getElementsByTagName("div")[0].offsetParent.offsetTop;	
		IfrRef.style.left = obj.getElementsByTagName("div")[0].offsetParent.offsetLeft;
		IfrRef.style.zIndex = obj.getElementsByTagName("div")[0].style.zIndex +1;
		IfrRef.style.display = "block";
	}
}

function mlonsub(obj){
	obj.getElementsByTagName("div")[0].style.display = "block";
	menuStatus = true;
	var browserName=navigator.appName; 
	if (browserName=="Microsoft Internet Explorer") {	
		var IfrRef = document.getElementById('DivShim');	
		IfrRef.style.width = obj.getElementsByTagName("div")[0].offsetParent.offsetWidth;
		IfrRef.style.height = obj.getElementsByTagName("div")[0].offsetParent.offsetHeight;
		IfrRef.style.top = obj.getElementsByTagName("div")[0].offsetParent.offsetTop;	
		IfrRef.style.left = obj.getElementsByTagName("div")[0].offsetParent.offsetLeft;
		IfrRef.style.zIndex = obj.getElementsByTagName("div")[0].style.zIndex +1;
		IfrRef.style.display = "block";		
	}
}

function mloff(obj) {
	if(lastMenu == null || lastMenu == ""){
		lastMenu = obj;
		lastMenuId = lastMenu.getElementsByTagName("div")[0].offsetParent.id;
		currentOffMenu = lastMenu.getElementsByTagName("div")[0].offsetParent.id;
		obj.getElementsByTagName("div")[0].style.display = "none"	
		}
		 else if (activeMenu != lastMenuId && activeMenu != currentOffMenu){
			unhighlightfirstanchor(lastMenu);
			lastMenu = obj;	
			lastMenuId = lastMenu.getElementsByTagName("div")[0].offsetParent.id;	
			currentOffMenu = obj.getElementsByTagName("div")[0].offsetParent.id;
			obj.getElementsByTagName("div")[0].style.display = "none"		
		} 
		else {
			lastMenuId = lastMenu.getElementsByTagName("div")[0].offsetParent.id;
			currentOffMenu = obj.getElementsByTagName("div")[0].offsetParent.id;
			obj.getElementsByTagName("div")[0].style.display = "none";
			
			if(obj.getElementsByTagName("div")[0].id == "submenu"){
				obj.getElementsByTagName("div")[0].style.display = "none";	
		}
	}			

	menuStatus = false;	
	setTimeout("checkDisplay(lastMenu)", 100);
	var browserName=navigator.appName; 
	if (browserName=="Microsoft Internet Explorer") {					
		var IfrRef = document.getElementById('DivShim');
		IfrRef.style.display = "none";
	}
}

function mloff2(name){
	if (window.event){
		if(window.event.srcElement.tagName == "img") {
		//setTimeout("unhighlightfirstanchor(lastMenu)",5000);
		//setTimeout("unlightsub(lastMenu)", 5000)
			lastMenu.getElementsByTagName("div")[0].style.display = "none";		
			unhighlightfirstanchor(lastMenu);
			} else {
          //do nothing
		}
	}
}

function subon(menuName){
	adviceMenu = document.getElementById(menuName); adviceMenu.style.backgroundColor = "#98b85b"; adviceMenu.style.color = "#ffffff";
	//adviceMenu.offsetParent.offsetParent.style.backgroundColor = "#86a44c";
	if(menuName == "askHim" || menuName == "ian"){		
		adviceMenu = document.getElementById('advice'); adviceMenu.style.backgroundColor = "#98b85b"; adviceMenu.style.color = "#ffffff";	
	}
}

function suboff(menuName){
	adviceMenu = document.getElementById(menuName); adviceMenu.style.backgroundColor = "#709696"; adviceMenu.style.color = "#ffffff";
	//adviceMenu.offsetParent.offsetParent.style.backgroundColor = "#709696";	
	if(window.event){
		if(window.event.srcElement.tagName != "div"){
			adviceMenu = document.getElementById(menuName); adviceMenu.style.backgroundColor = "#709696"; adviceMenu.style.color = "#ffffff";
			} else {adviceMenu = document.getElementById(menuName); adviceMenu.style.backgroundColor = "#ffe5f2"; adviceMenu.style.color = "#ffffff";}
	}
}


function highlightfirstanchor(obj){
	obj.getElementsByTagName("a")[0].style.backgroundPosition = "0px -28px";
}

function unhighlightfirstanchor(obj){
	obj.getElementsByTagName("a")[0].style.backgroundPosition = "0px 0px";
}

function unlightsub(obj){
	obj.getElementsByTagName("div")[0].style.display = "none";
}

function checkDisplay(obj){
	if(menuStatus == false){
		unhighlightfirstanchor(lastMenu);
		obj.getElementsByTagName("div")[0].style.display = "none";
	}
}