function DL_GetElementLeft(eElement)
{
    if (!eElement && this)                      // if argument is invalid</font>
    {                                           // (not specified, is <tt>null</tt> or is <tt>0</tt>)</font>
        eElement = this;                        // and function is a method</font>
    }                                           // identify the element as the method owner</font>
    
    var nLeftPos = eElement.offsetLeft;         // initialize var to store calculations</font>
    var eParElement = eElement.offsetParent;    // identify first offset parent element</font>  
    while (eParElement != null)
    {                                           // move up through element hierarchy</font>
        nLeftPos += eParElement.offsetLeft;     // appending left offset of each parent</font>
        eParElement = eParElement.offsetParent; // until no more offset parents exist</font>
    }
    return nLeftPos;                            // return the number calculated</font>
}


function DL_GetElementTop(eElement)
{
    if (!eElement && this)
    {
        eElement = this;
    }

    var nTopPos = eElement.offsetTop;
    var eParElement = eElement.offsetParent;
    while (eParElement != null)
    {
        nTopPos += eParElement.offsetTop;
        eParElement = eParElement.offsetParent;
    }
    return nTopPos;
}

function activateMenuItem(id) {
	var mnu=document.getElementById(id);
	mnu.className='activemenuitem';
	if (document.currentVisibleSubmenu && document.currentVisibleSubmenu!=mnu.subId) {
		document.getElementById(document.currentVisibleSubmenu).hideSub();
		document.currentVisibleSubmenu=false;
	}
}
function deactivateMenuItem(id) {
	var mnu=document.getElementById(id);
	mnu.className='menuitem';
}

var currentVisibleSubmenu=false;
function attachSubmenu(mnuId,submnuId) {
	var mnu=document.getElementById(mnuId);
	var smnu=document.getElementById(submnuId);
	if (!mnu || !smnu) return;
	
	
	smnu.menuId=mnuId;
	smnu.myId=submnuId;
	mnu.subId=submnuId;
	
	var id=mnuId;
	var idsub=submnuId;
	
	mnu.onmouseover=function() {
		document.getElementById(idsub).showSub();
	};
	
	mnu.onmouseout=function() {
		document.getElementById(idsub).scheduleHide();
	};
	
	
	smnu.unscheduleHide=function() {
		if (this.timer) window.clearTimeout(this.timer);
		this.timer=false;
	}
	smnu.scheduleHide=function() {
		this.timer=window.setTimeout(function() {
			smnu.hideSub();
		},500);
	}
	smnu.onmouseover=function() { smnu.unscheduleHide(); };
	smnu.onmouseout=function() { smnu.scheduleHide(); };
	smnu.hideSub=function() {
		this.unscheduleHide();
		var mnu=document.getElementById(this.menuId);
		mnu.className='menuitem';
		this.style.display='none';
		document.currentVisibleSubmenu=false;
	}
	smnu.showSub=function() {
		this.unscheduleHide();
		if (document.currentVisibleSubmenu && document.currentVisibleSubmenu!=this.myId) {
			document.getElementById(document.currentVisibleSubmenu).hideSub();
		}
		document.currentVisibleSubmenu=this.myId;
		var mnu=document.getElementById(this.menuId);
		if (mnu.className!='activemenuitem') mnu.className='activemenuitem';
		if (!this.initialized) {
			this.initialized=true;
			var y = DL_GetElementTop(mnu);
			if (navigator.userAgent.indexOf("MSIE") == -1) 
				y-=12;
			var x = DL_GetElementLeft(mnu) + Math.max(mnu.offsetWidth,mnu.clientWidth); 
			this.style.position='absolute';
			this.style.top=y + 'px';
			this.style.left=x + 'px';
			//this.style.width='191px';
		}
		this.style.display='block';
		
	}
	
}
