var itemIdMaster;
var bottomval=0;

function showMenu(itemId, classNm){
    itemIdMaster = itemId;
	if (document.getElementById) {
       var nav_id = document.getElementById(itemId);
	   //var menuFoot_id = document.getElementById(itemId+'_foot');
	   if (nav_id!=null){
	  		nav_id.className = classNm;
	   }
	   	   
	   if (menuFoot_id!=null){	
	     	menuFoot_id.className = 'orangeLower';
	   }
	   
	}
}

function isMouseLeaveOrEnter(e, handler)
{		
	if (e.type != 'mouseout' && e.type != 'mouseover') return false;
	var reltg = e.relatedTarget ? e.relatedTarget :
	e.type == 'mouseout' ? e.toElement : e.fromElement;
	while (reltg && reltg != handler) reltg = reltg.parentNode;
	return (reltg != handler);
}

/*function showQuickSubMenu(itemId){
	if (document.getElementById) {
       var nav_id = document.getElementById(itemId);
	   		if (nav_id!=null){								
	   			nav_id.className = 'subContainer show';	
	   		}
	  }
}*/

function showQuickSubMenu(itemId){
	if (document.getElementById) {
       var nav_id = document.getElementById(itemId);
	   var nav_subId = document.getElementById(itemId+'Contents');
	   		if (nav_id!=null){								
	   			nav_id.className = 'subContainer show';
				maxHeight=nav_subId.offsetHeight;
				bottomval=maxHeight;
				nav_subId.style.clip="rect(0px,210px,"+maxHeight+"px,0px)";	
	   		}
	  }
}

function showSubMenu(itemId){
	if(bottomval==1){
		bottomval = 0;
	}	
	 if (document.getElementById && bottomval==0) {
       var nav_id = document.getElementById(itemId);
	   var nav_subId = document.getElementById(itemId+'Contents');
	   		if (nav_id!=null){	
				nav_subId.style.clip="rect(0px,210px,0px,0px)";							
	   			nav_id.className = 'subContainer show';
				maxHeight=nav_subId.offsetHeight;
				openScrollMenu(""+itemId+'Contents'+"", maxHeight);	
	   		}
	  }
}

function openScrollMenu(subItem, maxHeight){
	var nav_subId = document.getElementById(subItem);
	if(bottomval<maxHeight && bottomval!=1){ 
		bottomval=bottomval+5;
		nav_subId.style.clip="rect(0px,210px,"+bottomval+"px,0px)";
		setTimeout("openScrollMenu('"+subItem+"',"+maxHeight+")",10);
		
	}
}

function hideSubMenu(itemId){
	bottomval = 1;	
	 if (document.getElementById) {
       var nav_id = document.getElementById(itemId);
	   var nav_subId = document.getElementById(itemId+'Contents');
	   		if (nav_id!=null){				
				nav_id.className = 'subContainer hide';
				nav_subId.style.clip="rect(0px,210px,0px,0px)";	   			
	   		}

	  }
}


function hoverMenu(itemId, classNm){
	if (document.getElementById) {
       var nav_id = document.getElementById(itemId);
	   if (nav_id!=null){
		   	if(itemIdMaster!=itemId){
	  			nav_id.className = classNm;
			}else{
				if(classNm!='menu1'){
					nav_id.className = classNm;	
				}
			}
	   }
	}
}