var sVisibleMenu = '';
var oMenuItemOn = '';

function showmenu(oMenuItem, sName,sSection) {
	var oMenuDiv;
	var oAnchor;
	//
	//oAnchor=oMenuItem.children[0];
	//oAnchor.className='MENUITEM-HOVER'
	if (sVisibleMenu!='') {
		hidemenu(sVisibleMenu);
	}
	oMenuItem.className = 'MENUHIGHLIGHTED-' + sSection;

	//
	sName = 'menu_' + sName;
	oMenuDiv = eval(sName);
	oMenuDiv.style.display = 'block';
	//
	setMenuPosition(oMenuDiv,oMenuItem)
	//
	sVisibleMenu = sName;
    oMenuItemOn = oMenuItem
}

function setMenuPosition(oMenuDiv, oRelative) {
	var lnLeft, lnTop, oCurrentItem, lnRight;
	//
	lnLeft = 0;
	lnTop = oRelative.offsetParent.scrollHeight-4;
	oCurrentItem = oRelative;
	//
	while(oCurrentItem!=null) {
		lnLeft+=oCurrentItem.offsetLeft;
		lnTop+=oCurrentItem.offsetTop;
		oCurrentItem=oCurrentItem.offsetParent;
	}
	//
	if (oRelative.clientWidth>oMenuDiv.clientWidth)	{
		// this is bad hard-coding ... it asssumes there is a child and sets the width of that rather than the div!
		oMenuDiv.children[1].style.width = oRelative.clientWidth;
	}
	//
	oCurrentItem = menu_table;
	//
	lnRight = menu_table.clientWidth;
	//
	while(oCurrentItem!=null) {
		lnRight+=oCurrentItem.offsetLeft;
		oCurrentItem=oCurrentItem.offsetParent;
	}
	//
	if ((lnLeft + oMenuDiv.clientWidth) > lnRight ) {
		lnLeft=lnLeft-((lnLeft + oMenuDiv.clientWidth)-lnRight)
	}
	if ((oRelative.nextSibling) != null ) {
		oMenuDiv.style.left = lnLeft;
	} else {
		oMenuDiv.style.left = lnRight-oMenuDiv.clientWidth;
	}
	oMenuDiv.style.top = lnTop;
}

function hidemenu() {
	var oMenu, oItem, oMenuItem, oAnchor;
	//oMenuItem = eval(sVisibleMenu.slice (5,sVisibleMenu.length));
	oMenu = eval(sVisibleMenu);
	oItem = event.toElement;
	while (oItem!=null) {
		if (oMenu == oItem)	{return;}
		oItem = oItem.parentNode;
	}
	oMenu.style.display = 'none';
	oMenuItemOn.className = 'MENUNORMAL';
	
	//oAnchor=oMenuItemOn.children[0];
	//oAnchor.className='MENUITEM-H';

    sVisibleMenu = '';
	oMenuItemOn = '';
}

function highlightRow(oSpan,sSection) {
	//
	oSpan.className = 'ROWHIGHLIGHTED-'+sSection;
	oSpan.style.color = 'F0F0F0';
}

function remhighlightRow(oSpan,sSection) {
	oSpan.className = 'ROWNORMAL-'+sSection;
	oSpan.style.color = '#555555';
}
