var currentSubMenu = "";
function showSubMenu(menuid){
 showSubMenuMain(menuid,184);
}
function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }

  function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }

function showSubMenuMain(menuid,offY){
	hideSubMenu(currentSubMenu);
	var menuname;
	menuname = "sub" + menuid;
	var elem, vis;
	if( document.getElementById ) // this is the way the standards work    
		elem = document.getElementById( menuname );
	else if( document.all ) // this is the way old msie versions work
		elem = document.all[menuname];  
	else if( document.layers ) // this is the way nn4 works    
		elem = document.layers[menuname];  
	
	if (elem) {
		currentSubMenu = menuid;
		vis = elem.style;   
		vis.display = 'block';

        var mainMenuName = "main" + menuid;
        var mainElem;
	    if( document.getElementById ) // this is the way the standards work    
		    mainElem = document.getElementById( mainMenuName );
	    else if( document.all ) // this is the way old msie versions work
		    mainElem = document.all[mainMenuName];  
	    else if( document.layers ) // this is the way nn4 works    
		    mainElem = document.layers[mainMenuName];  
    	
	    if (mainElem) {
	        var oSet=  mainElem.offsetLeft;
	        var agt=navigator.userAgent.toLowerCase();
	        if(agt.indexOf("msie")!=-1)
	        {
	            oSet = oSet + mainElem.offsetParent.offsetLeft;
	        }
	        else
	        
	        {
                oSet = findPosX(mainElem);
            }
            vis.left = oSet;
            vis.top = offY;
        }
	
	}
}


function hideSubMenu( menuid ) {
	
	var menuname;	
	menuname = "sub" + menuid;
	if( document.getElementById ) // this is the way the standards work    
		elem = document.getElementById( menuname );
	else if( document.all ) // this is the way old msie versions work
		elem = document.all[menuname];  
	else if( document.layers ) // this is the way nn4 works    
		elem = document.layers[menuname];
		
	if (elem) {
		vis = elem.style;   
		vis.display = 'none';
	}
}

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);
}

