	//------ Script Generated by SolpartWebControl -------//
	//------ Constants ------//
	var MOVE_MENU_MOVE_TYPE = "1";
	var MOVE_DIALOG_MOVE_TYPE = "2";
		
	//-- Attributes --//
	var maOpenMenuID = new Array();	
	var maMenuHeaders = new Array();	
	var miMoveType=null;
	var mbInitialized=false;	
	var m_objMenu = null;
	var m_iSelectedMenu = 0;
  
  var m_dHideTimer = null;
  
	//--------------- Event Functions ---------------//
	function mb_c(e)
	{
		initMenu();
		var objCell = e; //event.srcElement;
		var sID = objCell.id.substr(2);

		var objMenu = document.all["tbl" + sID];
		
		if (objMenu != null)
		{
			if (objMenu.style.display == "")
			{
				hideAllMenus();		
				showElement("SELECT");
			}
			else
			{
				positionMenu(objMenu, objCell);
				
				handleTransition(objMenu);
				objMenu.style.display = "";
				maOpenMenuID[0] = sID;
				hideElement("SELECT",objMenu);
			}
		}
		
		window.event.cancelBubble = true;
	}
	
	function handleTransition(objMenu)
	{
		if (SPM_HANDLETRANSITION)
			spm_doTransition(objMenu);
	}
	function mb_md(e)
	{
		var objCell = e; //event.srcElement;
		applyBorder(objCell, 1, SPM_SHADOWCOLOR, SPM_HIGHLIGHTCOLOR);
	}
	function mb_mu(e)
	{
		var objCell = e; //event.srcElement;
		applyBorder(objCell, 1, SPM_HIGHLIGHTCOLOR, SPM_SHADOWCOLOR);
	}
	function mb_mo(e)
	{
		initMenu();
		var objCell = e; //event.srcElement;
		var sID = objCell.id.substr(2);
		var objMenu = document.all["tbl" + sID];
		if (maOpenMenuID.length || SPM_MOUSEOVEREXPAND == '-1')
		{
			//--- if menu is shown then mouseover triggers the showing of all menus ---//
			hideAllMenus();
			if (objMenu != null)
			{
				positionMenu(objMenu, objCell);
				handleTransition(objMenu);
				objMenu.style.display = "";
				maOpenMenuID[0] = sID;
				hideElement("SELECT",objMenu);
			}
			applyBorder(objCell, 1, SPM_SHADOWCOLOR, SPM_HIGHLIGHTCOLOR);
		}
		else
		{
			applyBorder(objCell, 1, SPM_HIGHLIGHTCOLOR, SPM_SHADOWCOLOR);
		}
		m_dHideTimer = null;
	}
	function mb_mout(e)
	{
		var objCell = e; //event.srcElement;
		var sID = objCell.id.substr(2);
		applyBorder(objCell, 1, SPM_COLOR, SPM_COLOR, "none");	
		m_dHideTimer = new Date();
		setTimeout(hideMenuTime, SPM_MOUSEOUTDELAY);
	}
	function mbi_c(e)
	{
		initMenu();
		var objRow = getSourceTR(e);  //event.srcElement
		var sID = objRow.id.substr(2);
		if (itemHasChildren(sID) == false)
		{		
			hideAllMenus();
		}
		window.event.cancelBubble = true;
	}
	function mbi_mo(e)
	{		
		handlembi_mo(getSourceTR(e)); //event.srcElement
		m_dHideTimer = null;
	}
	function mbi_mout(e)
	{	
		handlembi_mout(getSourceTR(e));  //event.srcElement
		m_dHideTimer = new Date;
		setTimeout(hideMenuTime, SPM_MOUSEOUTDELAY);
	}
	
	function menuhook_KeyPress()
	{
    //not yet
	}
	function menuhook_KeyDown()
	{
    //not yet
	}
	
	function menuhook_MenuFocus()
	{
		var tbl = event.srcElement;
		mb_c(tbl.rows[0].cells[0]);
	}
	
	function menuhook_MouseMove(e) 
	{
		var iNewLeft=0, iNewTop = 0
		if ((event.button==1)) {
			hideAllMenus();
			if (m_objMenu.startLeft == null)
				m_objMenu.startLeft = m_objMenu.offsetLeft;
			iNewLeft=event.clientX - m_objMenu.startLeft - 3;
			m_objMenu.style.pixelLeft= iNewLeft;
			if (m_objMenu.startTop == null)
				m_objMenu.startTop = m_objMenu.offsetTop;
			iNewTop=event.clientY - m_objMenu.startTop;
			m_objMenu.style.pixelTop = iNewTop - 10;
			event.returnValue = false
			event.cancelBubble = true
			miMoveType = MOVE_MENU_MOVE_TYPE;
		}
	}
	function menuhook_MouseDown(e)
	{
		m_objMenu = getElement(e, "tblMenuBar");
	}
	function menuhook_MouseUp(e)
	{
		m_objMenu = null;
	}
	function document_MouseMove(e)
	{
		switch(miMoveType)
		{
			case (MOVE_MENU_MOVE_TYPE):
			{
				menuhook_MouseMove(e);
				break;
			}
			case (MOVE_DIALOG_MOVE_TYPE):
			{
				dialoghook_MouseMove(m_objDlg);
				break;
			}
		}
	}
	function document_MouseDown(e)
	{
		miMoveType = null;
	}
	function document_MouseUp(e)
	{
		miMoveType=null;
	}
	function bodyclick()
	{
		hideAllMenus();
	}

	//--------- Internal (private) Functions --------//
	function applyBorder(objCell, iSize, sTopLeftColor, sBottomRightColor, sStyle)
	{
	
		if (SPM_MOUSEOVERDISPLAY == 'Outset')
		{
			if (sStyle == null)
				sStyle = "solid";
			if (sTopLeftColor.length && sBottomRightColor.length)
			{
				objCell.style.borderTop = sStyle + " " + iSize + "px " + sTopLeftColor;
				objCell.style.borderLeft = sStyle + " " + iSize + "px " + sTopLeftColor;
				objCell.style.borderRight = sStyle + " " + iSize + "px " + sBottomRightColor;
				objCell.style.borderBottom = sStyle + " " + iSize + "px " + sBottomRightColor;	
			}
		}
		if (SPM_MOUSEOVERDISPLAY == 'Highlight')
		{
		  
			if (sTopLeftColor == SPM_COLOR)
			{
				objCell.style.backgroundColor = '';
        setClassColor(objCell, 'spmitm', '');
			}
			else
			{
				objCell.style.backgroundColor = SPM_SELECTEDCOLOR;
        setClassColor(objCell, 'spmitm', SPM_SELECTEDFORECOLOR);
			}
		}		
	}

	function applyRowBorder(objRow, iSize, sColor, bSelected, sStyle)
	{
		var sColor2=sColor;
		if (sStyle == null)
			sStyle = "solid";
		if (sColor == "")
		{
			if (bSelected)
				sColor2 = SPM_SELECTEDCOLOR;
			else
				sColor2 = objRow.cells[0].style.backgroundColor;
		}
		objRow.cells[0].style.borderLeft = sStyle + " " + iSize + "px " + sColor2;
		objRow.cells[0].style.borderTop = sStyle + " " + iSize + "px " + sColor2;
		objRow.cells[0].style.borderBottom = sStyle + " " + iSize + "px " + sColor2;
		if (sColor == "")
			sColor2 = objRow.style.backgroundColor;
		objRow.cells[1].style.borderTop = sStyle + " " + iSize + "px " + sColor2;
		objRow.cells[1].style.borderBottom = sStyle + " " + iSize + "px " + sColor2;
		objRow.cells[2].style.borderRight = sStyle + " " + iSize + "px " + sColor2;
		objRow.cells[2].style.borderTop = sStyle + " " + iSize + "px " + sColor2;
		objRow.cells[2].style.borderBottom = sStyle + " " + iSize + "px " + sColor2;
	}
	function elementTop(eSrc)
	{
		var iTop = 0;
		var eParent;
		eParent = eSrc;
		while (eParent.tagName.toUpperCase() != "BODY")
		{
			iTop += eParent.offsetTop;
			eParent = eParent.offsetParent;
		}
		return iTop;
	}
	function elementLeft(eSrc)
	{	
		var iLeft = 0;
		var eParent;
		eParent = eSrc;
		while (eParent.tagName.toUpperCase() != "BODY")
		{
			iLeft += eParent.offsetLeft;
			eParent = eParent.offsetParent;
		}
		return iLeft;
	}
	function getElement(e, sID) 
	{
		var o=e;
		var i=0;
		while (o.id != sID)
		{
			o=o.parentNode;
			i++;
		}
		return o;
	}
	function handleNewItemSelect(sID)
	{
		var i;
		var iNewLength=-1;
		var bDeleteRest=false; 
		for (i=0; i<maOpenMenuID.length; i++)
		{		
			if (bDeleteRest)
				document.all["tbl" + maOpenMenuID[i]].style.display = "none";
			if (maOpenMenuID[i] == sID)
			{
				bDeleteRest=true;
				iNewLength = i;
			}				
		}
		if (iNewLength != -1)
			maOpenMenuID.length = iNewLength+1;
	}
	function hideAllMenus()
	{
		var i;
		for (i=0; i<maOpenMenuID.length; i++)
		{		
			document.all["tbl" + maOpenMenuID[i]].style.display = "none";
		}
		maOpenMenuID.length = 0;
		showElement("SELECT");
	}		
	function itemHasChildren(sID)
	{
		objTable = document.all["tbl" + sID];
		if (objTable != null)
		{
			if (objTable.rows != null)
			{
				if (objTable.rows.length > 0)
					return true;
				else
					return false;
			}		
		}
	}
	function getSourceTR(e)
	{
		while (e.id == "")
		{
			e= e.parentElement;
		}
		if (e.id.indexOf("arrow") != -1)
		{
			var sID = e.id.substr(5);
			return document.all["tr" + sID];
		}
		else if (e.id.indexOf("td") != -1)
		{
			var sID = e.id.substr(2);
			return document.all["tr" + sID];
		}	
		else if (e.id.indexOf("icon") != -1)
		{
			var sID = e.id.substr(4);
			return document.all["tr" + sID];
		}	
		else if (e.id.indexOf("img") != -1)
		{
			var sID = e.id.substr(3);
			return document.all["tr" + sID];
		}	
		else
		{
			return e;
		}
	}
	function handlembi_mo(objRow)
	{
		var sID = objRow.id.substr(2);
		objRow.style.backgroundColor = SPM_SELECTEDCOLOR;
		//objRow.style.color = SPM_SELECTEDFORECOLOR;
		objRow.style.color = SPM_SELECTEDFORECOLOR;
    setClassColor(objRow, 'spmitm', SPM_SELECTEDFORECOLOR);
		
		document.all["icon" + sID].style.backgroundColor = SPM_SELECTEDCOLOR;
		applyRowBorder(objRow, 1, SPM_SELECTEDBORDERCOLOR, true);

		//if (maOpenMenuID.join(',').indexOf(objRow.id.replace('tr', '')) == -1)
		if (maOpenMenuID[maOpenMenuID.length - 1] != objRow.id.replace('tr', ''))
		{
			handleNewItemSelect(objRow.parentID);
		
			if (document.all["tbl" + sID] != null)
			{
				objMenu = document.all["tbl" + sID];
				
				objMenu.style.left = elementLeft(objRow) + objRow.offsetWidth;
				objMenu.style.top = elementTop(objRow);
				
				handleTransition(objMenu);
				objMenu.style.display = "";
				if (elementLeft(objRow) + objRow.offsetWidth + objMenu.offsetWidth > document.body.clientWidth)
				{
					objMenu.style.left = elementLeft(objRow) - objMenu.offsetWidth;
					//objMenu.style.top = elementTop(objRow);					
				}

			  if (elementTop(objMenu) + objMenu.offsetHeight > document.body.clientHeight)
			  {
				  objMenu.style.top = document.body.clientHeight - objMenu.offsetHeight;
			  }
				
				maOpenMenuID[maOpenMenuID.length] = sID;
				hideElement("SELECT",objMenu);
			}	
		}
	}
	
	function handlembi_mout(objRow)
	{
			var sID = objRow.id.substr(2);
			objRow.style.backgroundColor = SPM_COLOR;
			//objRow.style.color = SPM_FORECOLOR;	
			objRow.style.color = '';
			setClassColor(objRow, 'spmitm', '');
			document.all["icon" + sID].style.backgroundColor = SPM_ICONBACKGROUNDCOLOR;
			applyRowBorder(objRow, 1, "", false);

	}
		
	function positionMenu(objMenu, objCell)
	{
		if (SPM_DISPLAYVERTICAL)
		{
			objMenu.style.left = elementLeft(objCell) + objCell.offsetWidth;
			objMenu.style.top = elementTop(objCell);
		}
		else
		{
			objMenu.style.left = elementLeft(objCell);
			objMenu.style.top = elementTop(objCell) + objCell.offsetHeight;
			objMenu.style.display = "";
			if (elementLeft(objMenu) + objMenu.offsetWidth > document.body.clientWidth)
			{
			  if (document.body.clientWidth - objMenu.offsetWidth > 0)  //only do this if it fits
				  objMenu.style.left = document.body.clientWidth - objMenu.offsetWidth;
//				objMenu.style.top = elementTop(objCell) + objCell.offsetHeight;
			}
			if (elementTop(objMenu) + objMenu.offsetHeight > document.body.clientHeight)
			{
			  if (elementTop(objCell) - objMenu.offsetHeight > 0) //only do this if it fits
				  objMenu.style.top = elementTop(objCell) - objMenu.offsetHeight;
			}
			objMenu.style.display = "none";
		}
	}
		
	function hideElement(elmID, eMenu)
	{
		var obj;
		// Hide any element that overlaps with the dropdown menu
		for (i = 0; i < document.all.tags(elmID).length; i++)
		{
			obj = document.all.tags(elmID)[i];
			if (elementTop(obj) > parseInt(eMenu.style.top) + eMenu.offsetHeight)
			{
				//if element is below bottom of menu then do nothing
			}
			else if (elementLeft(obj) > parseInt(eMenu.style.left) + eMenu.offsetWidth)
			{
				//if element is to the right of menu then do nothing
			}
			else if (elementLeft(obj) + obj.offsetWidth < parseInt(eMenu.style.left))
			{
				//if element is to the left of menu then do nothing
			}
			else if (elementTop(obj) + obj.offsetHeight < parseInt(eMenu.style.top))
			{
				//if element is to the top of menu then do nothing
			}
			else
			{
				obj.style.visibility = "hidden";
			}
		}
	}

	function showElement(elmID)
	{
		// Display any element that was hidden
		for (i = 0; i < document.all.tags(elmID).length; i++)
		{
			obj = document.all.tags(elmID)[i];
			if (! obj || ! obj.offsetParent)
				continue;
			obj.style.visibility = "";
		}
	}

	function initMenu()
	{
		if (mbInitialized == false)
		{	
			document.attachEvent("onmousemove", document_MouseMove);
			document.attachEvent("onmousedown", document_MouseDown);
			document.all.tags("BODY")[0].attachEvent("onclick", bodyclick)
			
			var oCells = document.all['tblMenuBar'].rows[0].cells;
			for (var i=0; i<oCells.length; i++)
			{
			  if (oCells[i].id.length)
			    maMenuHeaders[maMenuHeaders.length] = oCells[i].id;
			}
			
			
		}	
	}
	//------ End Script Generated by SolpartWebControl -------//
	

  function hideMenuTime()
  {
    if (m_dHideTimer != null && SPM_MOUSEOUTDELAY > 0)
    {
      if (new Date() - m_dHideTimer >= SPM_MOUSEOUTDELAY)
      {
        hideAllMenus();
        m_dHideTimer = null;
      }
      else
        setTimeout(hideMenuTime, SPM_MOUSEOUTDELAY);
    }
  }

  function setClassColor(oCtl, sClass, sColor)
  {
    var o;
    for (var i=0; i<oCtl.childNodes.length; i++)
    {
      o = oCtl.childNodes[i];
      if (o.className == sClass)
        o.style.color = sColor;
      
      if (o.childNodes.length)
        setClassColor(o, sClass, sColor)
    }
  }
