/***************************************/
/*** 实现功能：三级菜单树—添加主菜单模块
/*** 设计日期：2004-12-1
/*** 更新日期：2008-4-23
/*** 版权所有：CopyRight By 湖南青果软件有限公司
/***************************************/

var RGB_Atvbord='0 solid #A2B4E0';
var RGB_Atvfont='#FFFFFF'; 
var RGB_Atvbgrd='#14784D';
var RGB_FontHover='red';

var RGB_Chkbord='0 solid #F58220'; 
var RGB_Chkfont='#FFFFFF';

var barActiveStyle=" valign=center style='height:25; cursor:hand; color:"+RGB_Atvfont+"; border:"+RGB_Atvbord+"; background-color:"+RGB_Atvbgrd+";' align=left ";
var tableStyle=" style='height:100%;width:100%' border=0 valign=middle align=center cellspacing='0' cellpadding='0' ";

function KingoMemu()
{
	this.barArray=new Array();
	this.addBar=addBar;
	this.curBarIndex=-1;
	this.lastLinkObj='';
	this.lastLayerID='';
	this.showBar=showBar;
}

function addBar(pText,pID)
{	
	KingoMemuBar.barArray[KingoMemuBar.barArray.length]=new textArray(pText,pID);		
}
function textArray(pText,pID)
{
	this.id=pID;
	this.text=pText;
}

function barOver(theID){if(theID.style.cursor=='hand') 
theID.style.color=RGB_FontHover;
}
function barOut(theID){if(theID.style.cursor=='hand') 
theID.style.color=RGB_Atvfont;
}
function showBar()
{
	var sHTML="<table "+tableStyle+">";

	for (i=0;i<(KingoMemuBar.barArray.length);i++)
	{
			sHTML+="<tr id=memuBarBtn"+i+" name=memuBarBtn"+i+" >";
			sHTML+="<td id=memuBarText"+i+" name=memuBarText"+i+" align=center valign=center "+barActiveStyle;
			sHTML+=" onmouseover='barOver(this)' onmouseout='barOut(this)' ";
			sHTML+=" onclick='openTheBar("+i+")' key='"+KingoMemuBar.barArray[i].id+"' >";
			sHTML+="<b>"+KingoMemuBar.barArray[i].text+"</b></td></tr>";
			
			sHTML+="<tr id=memuLnkBtn"+i+" name=memuLnkBtn"+i+" >";
			sHTML+="<td id=memuLinkDiv"+i+" name=memuLinkDiv"+i+" valign=top align=center style='width:100%;";
			sHTML+=(i!=KingoMemuBar.curBarIndex)?"display:none'>":"'><br></td></tr>"
	}

	sHTML+="<tr><td id=blankdiv name=blankdiv valign=top align=center style='height:100%;width:100%'";
	sHTML+=(i!=KingoMemuBar.curBarIndex)?"display:none'>":"'>";
	sHTML+="<br></td></tr>";
	
	//sHTML+="<tr><td height=8 background='../themes/default/menu/menuBtm.gif'></td></tr>";	
	sHTML+="</table>";	
	document.getElementById("divTheMenu").innerHTML=sHTML;
}

function openTheBar(pIndex)
{
	var whichEl; var lastIndex;	
	lastIndex = KingoMemuBar.curBarIndex;
	
	if (pIndex==lastIndex) {
		KingoMemuBar.curBarIndex=-1;	
		document.getElementById("blankdiv").style.display='';
		doBar('close',pIndex);
		
	}else if ((pIndex!=lastIndex)&&(pIndex<KingoMemuBar.barArray.length)){
		KingoMemuBar.curBarIndex=pIndex;	
		document.getElementById("blankdiv").style.display='none';
			
		if(lastIndex!=-1) doBar('close',lastIndex);
		doBar('open',pIndex);
		////hideTheMenu('T');
	}
}

function doBar(pDo,pIndex){try{
	var theObj=document.getElementById("memuBarText"+pIndex);
	if(pDo=='close'){
		document.getElementById("memuLinkDiv"+pIndex).style.display='none';
		document.getElementById("memuLinkDiv"+pIndex).style.height="100%";

		theObj.style.cursor='hand';
		theObj.style.border=RGB_Atvbord;
		theObj.style.color=RGB_Atvfont;		
			
	}else if(pDo=='open'){
		document.getElementById("memuLinkDiv"+pIndex).style.display='';
		document.getElementById("memuLinkDiv"+pIndex).style.height="100%";
			
		theObj.style.cursor='';
		theObj.style.border=RGB_Chkbord;		
		theObj.style.color=RGB_Chkfont;		
	}
}catch(e){}}

function openTheMenu(pIndex,pLayerID){try{
	openTheBar(pIndex);

	if (pLayerID!=''){
	var objDiv=eval("divGrp"+pLayerID);
	var objImg=eval("imgGrp"+pLayerID);
	if(typeof(objDiv)=='object')
	objDiv.style.display='';
	objImg.src='../themes/default/tree/-1.gif';
	KingoMemuBar.lastLayerID=pLayerID;			
	}
}catch(e){}}

function hideTheMenu(pTF){try{
	var objBar,objLnk;
	var vID=KingoMemuBar.curBarIndex;
	
	for(i=0;i<KingoMemuBar.barArray.length;i++){
	eval("objBar=memuBarBtn"+i);
	eval("objLnk=memuLnkBtn"+i);
		
	if(i!=vID){
		if(objBar.style.display=='')
		{objBar.style.display='none';objLnk.style.display='none';}
		else{objBar.style.display='';objLnk.style.display='';}
	}else if(pTF=='F'){	 //复位一级菜单	
		doBar('close',vID);
		//objLnk.style.display='none'; //去掉粗底线!!!
		document.getElementById("blankdiv").style.display='';
		KingoMemuBar.curBarIndex=-1;

	}else{window.top.menu.onhide2_Ex('down');} //隐藏一级菜单		
	
	}
	return true;
}catch(e){return false}}

function ShowMenuTree(){ try{
	var sTree,sKey;
	var i,barLen=KingoMemuBar.barArray.length;
	var IE6=window.navigator.userAgent.indexOf('MSIE 6');

	for(i=0;i<barLen;i++){
	sTree=''; sKey=KingoMemuBar.barArray[i].id;
	eval("sTree=showMenu_"+sKey+"()");
	sTree="<table style='width:115px' border=0 align=left CELLPADDING=0 CELLSPACING=0>"+sTree+"</table>";
	if(IE6>0) sTree="<div style='overflow:auto;width:100%;height:100%'>"+sTree+"</div>";
	document.getElementById("memuLinkDiv"+i).innerHTML=sTree;
	}

	//var vUID='';
	//try{vUID=window.top.banner.js_UserID;}catch(e){}
	//if(vUID.toLowerCase()=='oamaster') openTheBar(0);

}catch(e){alert('【加载用户菜单】网络繁忙,请稍后刷新再试!')}
}

function ReloadMenuTree(pBarIndex,pBarKey){try{
	var sTree=''; 
	eval("sTree=showMenu_"+pBarKey+"()");
	sTree="<table style='width:116px' border=0 align=left CELLPADDING=0 CELLSPACING=0>"+sTree+"</table>";
	if(IE6>0) sTree="<div style='overflow:auto;width:100%;height:100%'>"+sTree+"</div>";
	document.getElementById("memuLinkDiv"+pBarIndex).innerHTML=sTree;	
}catch(e){}}

