	//------ Script  该代码来自一个WEB控件 Generated by cdm -------//
	//------ Constants ------//
	var MOVE_MENU_MOVE_TYPE = "1";
	var MOVE_DIALOG_MOVE_TYPE = "2";
		
	//-- Attributes --//
	var maOpenMenuID = new Array();	
	var miMoveType=null;
	var mbInitialized=false;	
	var m_objMenu = null;
	
	//--------------- Event Functions ---------------//
	function mb_c(e)
	{
		initMenu();
		
		var objCell = 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 = event.srcElement;
		applyBorder(objCell, 1, SPM_SHADOWCOLOR, SPM_HIGHLIGHTCOLOR);
	}
	function mb_mu(e)
	{

		var objCell = event.srcElement;
		applyBorder(objCell, 1, SPM_HIGHLIGHTCOLOR, SPM_SHADOWCOLOR);
	}
	function mb_mo(e)
	{
		initMenu();
		var objCell = event.srcElement;
		var sID = objCell.id.substr(2);
		var objMenu = document.all["tbl" + sID];
		if (maOpenMenuID.length)
		{
			//--- 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);
		}
	}
	function mb_mout(e)
	{
		var objCell = event.srcElement;
		var sID = objCell.id.substr(2);
		applyBorder(objCell, 1, SPM_COLOR, SPM_COLOR, "none");	
	}
	function mbi_c(e)
	{
		initMenu();
		var objRow = getSourceTR(event.srcElement);
		var sID = objRow.id.substr(2);
		if (itemHasChildren(sID) == false)
		{		
			hideAllMenus();
		}
		window.event.cancelBubble = true;
	}
	function mbi_mo(e)
	{		
		handlembi_mo(getSourceTR(event.srcElement));
	}
	function mbi_mout(e)
	{	
		handlembi_mout(getSourceTR(event.srcElement));
	}
	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 (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;	
		}
	}
	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;
		document.all["icon" + sID].style.backgroundColor = SPM_SELECTEDCOLOR;
		applyRowBorder(objRow, 1, SPM_SELECTEDBORDERCOLOR, true);

		if (maOpenMenuID.join(',').indexOf(objRow.id.replace('tr', '')) == -1)
		{
			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);					
				}
				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;	
			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)
			{
				objMenu.style.left = document.body.clientWidth - objMenu.offsetWidth;
				objMenu.style.top = elementTop(objCell) + objCell.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)
		}	
	}
	//------ End Script 来自一个WEB控件 Generated by cdm -------//
	

