<%@ page contentType="text/html; charset=gb2312" %>
<%@ page import="gbase.menu.*"%>
<head>
<meta http-equiv=Content-Type content="text/html; charset=GB2312">
<title>系统管理左边菜单</title>
</head>

<body>

<STYLE type="text/css">
<!--
A {COLOR: #000099; TEXT-DECORATION: none;}
A:hover {COLOR: #0000ff; TEXT-DECORATION: underline;}
-->
</STYLE>
<%  //调用MenuTree类，得到菜单数组;
    String user_id=session.getAttribute("user_id")==null?"":(String)session.getAttribute("user_id");
    String user_account=session.getAttribute("user_account")==null?"":(String)session.getAttribute("user_account");
    
    WebMenuTree theWebMenuTree=new WebMenuTree();
    String record[][]=null;
    record=theWebMenuTree.getUserMenuTree(user_id,user_account);
    int record_length=record.length+3;
%>
<SCRIPT>
 var record;
 record = new Array(<%=record_length%>)
 for (var i = 0; i < record.length; i++)
 {
	         record[i] = new Array(4);
 }
 </SCRIPT>
 <%
 for(int i=0;i<record.length;i++){
   for(int j=0;j<record[0].length;j++){
      %>
      <SCRIPT>
      record[<%=i%>][<%=j%>]='<%=record[i][j]%>';
      </SCRIPT>
      <%
   }
 }
 %>
 <SCRIPT>
 record[<%=(record.length)%>][0]='99';
 record[<%=(record.length)%>][1]='其他功能';
 record[<%=(record.length)%>][2]='0';
 record[<%=(record.length)%>][3]='';
 
 record[<%=(record.length+1)%>][0]='9901';
 record[<%=(record.length+1)%>][1]='修改自身资料';
 record[<%=(record.length+1)%>][2]='99';
 record[<%=(record.length+1)%>][3]='../user/myuser.jsp';
 
 record[<%=(record.length+2)%>][0]='9902';
 record[<%=(record.length+2)%>][1]='退出系统';
 record[<%=(record.length+2)%>][2]='99';
 record[<%=(record.length+2)%>][3]='../user/exit.jsp';
 </SCRIPT>
<SCRIPT language="JavaScript" src="scripts/menu_functions.js"></SCRIPT>
<SCRIPT language="JavaScript" src="scripts/cookie.js"></SCRIPT>
<SCRIPT language="JavaScript">
          if (isNav4)
          {
            document.write("<link rel='stylesheet' href='../css/css.css'>")
          }
          if (isIE)
          {
            if (isDom)
            {
              document.write("<link rel='stylesheet' href='../css/css.css'>")
            }
            else
            {
              document.write("<link rel='stylesheet' href='../css/css.css'>")
            }
          }
         document.write("<link rel='stylesheet' href='../css/css.css'>")
         
</SCRIPT>

		<script language="javascript">
		  function findRootIndex(tArry)
		  {
		     var index=-1;
		     var minLength=1000;
		     for(var i=0;i<tArry.length && tArry[i][0]!=null;i++)
		     {
		        if(tArry[i].length<minLength)
		        {
		           index=i;
		           minLength=tArry[i].length;
		        }
		     }
		     return index;
		  }

		  function addBranch(parentObj,tArry)
		  {
                     var str="";
		     for(var i=0;i<tArry.length && tArry[i][0]!=null;i++)
		     {
		        str=tArry[i][2];
		        if( (parentObj.value==str)&&(parentObj.value!=tArry[i][0])&&(tArry[i][4]!=true) )
		        {
		           //var child=addItem (parentObj, '', tArry[i][1],"javascript:clk('"+tArry[i][0]+"','"+tArry[i][1]+"','"+tArry[i][3]+"')", tArry[i][0]);
		           var child=null;
		           if(tArry[i][3]=='' || tArry[i][3]==null)
		           {
		           child=addItem (parentObj, '', tArry[i][1],"",  tArry[i][0]);
		           }
		           else
		           {
		           child=addItem (parentObj, '', tArry[i][1],"<a href='"+tArry[i][3]+"' target=main>"+tArry[i][1]+ "</a>",  tArry[i][0]);
		           }
		           str=tArry[i][4]=true;
		           addBranch(child,tArry);
		        }
		     }
		  }

		  function buildTree(tArry)
		  {
	     var rootInx=findRootIndex(tArry)
             root = addRoot ('', tArry[rootInx][1], "<a href='"+tArry[rootInx][3]+"' target=main>"+tArry[rootInx][1]+ "</a>", tArry[rootInx][0]);		     
    
             tArry[rootInx][4]=true;
             if (root != null)
             {
                addBranch(root,tArry);
             }
		     for(var i=0;i<tArry.length && tArry[i][0]!=null;i++)
		     {
		        if(tArry[i][4]!=true)
		        {
                   tArry[i][2]=tArry[rootInx][0];
                   addBranch(root,tArry);
		        }
		     }
             setShowExpanders(true);
             setExpandDepth (1);
             initialize();
             searchNode(root,GetCookie('selTzzbm'));
//           searchNode(root,'001');
         }
		</script>
		<SCRIPT language="JavaScript" src="scripts/maintree.js"></SCRIPT>
	</HEAD>
	<BODY class="navtree">
		<SCRIPT language="javascript" type="text/javascript">
        function Cheader()
        {
          this.treeopen = new Array();
          this.treecontent = new Array();
          this.tmptreecontent = new Array();
          this.tmptreeopen = new Array();
          this.treecounter = 0;
          this.NSdone = false;
        }
       
        function Ctop()
        {
           this.header=new Cheader();
        }
        var top=new Ctop();
        folder = new Array (2);
        folder["open"] = "open_folder.gif";
        folder["close"] = "closed_folder.gif";
        
        
        //alert(record[15][0]);
        buildTree(record);
        //aa('<%=record%>');
	</SCRIPT>
		
</body>

</html>
