<script language="javascript">
function PhenItem(id,pid,label,url,type,img,over,img2,over2,title,target){
   this.id=id;
   this.pid=pid;
   this.label=label;
   this.url=url;
   this.title=title;
   this.target=target;
   this.img=img;
   this.over=over;
   this.img2=img2;
   this.over2=over2;
   this.type=type;
   //this._ih = false; //is it the head item?
   this._hc = false;   //has the child item?
   this._ls = false; //has sibling item?
   this._io = false; //whether the panelbar is open?
};
//menu object
function PhenMenu(objName) {
    this.config = {
closeSameLevel : true
};
//alert("asdsdf");
this.obj = objName; this.items = [];
this.root = new PhenItem(-1);

};//add a new item to the item array
PhenMenu.prototype.add = function(id,pid,label,url,type,img,over,img2,over2,title,target){
this.items[this.items.length] = new PhenItem(id,pid,label,url,type,img,over,img2,over2,title,target);
};// Outputs the menu to the page --菜单输出到页面
PhenMenu.prototype.toString = function() {
//alert("arrived here");
var str = '<div>\n'; if (document.getElementById) { str += this.addItem(this.root); } else str += 'Browser not supported.'; str += '\n</div>';
    //alert(str);
//document.write(str);
//alert(this.items[0]._hc);
return str;
};
// Creates the menu structure --创建菜单结构
PhenMenu.prototype.addItem = function(pItem) { var str = ''; //var n=0; for (var n=0; n<this.items.length; n++) {

if(this.items[n].pid == pItem.id){

var ci = this.items[n];
//alert(ci.pid);
//alert(ci.id);
this.setHS(ci);
//alert("item:"+ci._hc);
//alert(ci._ls);
str += this.itemCreate(ci, n);

if(ci._ls) break;

} } return str;};// Creates the node icon, url and text --创建节点图标,URL和文字
PhenMenu.prototype.itemCreate = function(pItem, itemId) {
//alert(pItem.type.toLowerCase());
// alert(1);
var str = '';

    if(pItem.type == 'header')
     str = '<table width="100%" class="header" valign=top onmouseover="this.className=\'headerSelected\'" onmouseout="this.className=\'header\'" onclick="'+this.obj+'.o('+itemId+')"><tr valign=top><td>'; else
str = '<table width="100%" border="0" class="item" valign=top onmouseover="this.className=\'itemOver\'" onmouseout="this.className=\'item\'" onclick="'+this.obj+'.o('+itemId+')"><tr valign=top><td>'; if (pItem.img) {
alert(pItem.img);
str += '  <img id="i' + this.obj + itemId + '" src="' + pItem.img + '" alt="" />'; }
if (pItem.url) {

str += '<a id="s' + this.obj + itemId + '" class="navigation_item" href="' + pItem.url + '"';
if (pItem.title) str += ' title="' + pItem.title + '"';
if (pItem.target) str += ' target="' + pItem.target + '"';
str += ' onmouseover="window.status=\'' + pItem.label + '\';return true;" onmouseout="window.status=\'\';return true;"';
str += '>';
}
str += '    ' + pItem.label;
if (pItem.url) str += '</a><div style="border-top:1px dashed #cccccc;height: 1px;overflow:hidden"/>';
str += '</td></tr></table>';
//alert(pItem.url);
//alert(str);
if (pItem._hc) {
str += '<table id="ct' + this.obj + itemId + '" width="100%" style="display:' + ((pItem._io) ? 'block' : 'none') + '; FILTER: blendTrans(Duration=0.0); VISIBILITY: hidden"><tr><td align=left>';
str += this.addItem(pItem);
str += '</td></tr></table>';
//alert(str);
//document.write(str);
} return str;
};
// Checks whether a item has child and if it is the last sibling --检查项目是否有子项,是否是最后的.
PhenMenu.prototype.setHS = function(pItem) { var lastId; for (var n=0; n<this.items.length; n++) { if (this.items[n].pid == pItem.id) pItem._hc = true; if (this.items[n].pid == pItem.pid) lastId = this.items[n].id; } if (lastId==pItem.id) pItem._ls = true;};// Toggle Open or close -- 切换打开或关闭
PhenMenu.prototype.o = function(id) {
//alert(this.items.length);
var ci = this.items[id];
    //alert(ci);
//this.setHS(ci);
//alert(this.items[id]._hc);
this.itemStatus(!ci._io, id); ci._io = !ci._io;
    
if (this.config.closeSameLevel) this.closeLevel(ci);};// Change the status of a item(open or closed) --更改项目的状态(打开或关闭)
PhenMenu.prototype.itemStatus = function(status, id) {
cTable= document.getElementById('ct' + this.obj + id);
if(status){
cTable.filters.item(0).Apply();
cTable.style.display = 'block';
cTable.style.visibility = "";
cTable.filters.item(0).Play();
changeImg(status,id);
}
else{
cTable.style.display = 'none';
changeImg(status,id);
}
//cDiv.style.display = (status) ? 'block': 'none';};// Closes all items on the same level as certain item
PhenMenu.prototype.closeLevel = function(pItem) {
               //alert(this.items[0]._hc);
for (var n=0; n<this.items.length; n++) {
            //alert(this.items[n]._hc);
if ((this.items[n].pid == pItem.pid) && (this.items[n].id != pItem.id) && this.items[n]._hc) {

this.itemStatus(false, n); this.items[n]._io = false; this.closeAllChildren(this.items[n]); } }};PhenMenu.prototype.closeAllChildren = function(pItem) { for (var n=0; n<this.items.length; n++) { if (this.items[n].pid == pItem.id && this.items[n]._hc) { if (this.items[n]._io) this.itemStatus(false, n); this.items[n]._io = false; this.closeAllChildren(this.items[n]); } }};
//项目展开切换底图 add by wangyf on 20111122
function changeImg(status,id){
tit = document.getElementById('tit'+id);
//alert(id+">>"+tit);
if(status){
tit.style.backgroundImage = "url(images/kyxm_Br_tit2.jpg)";
}else{
tit.style.backgroundImage = "url(images/kyxm_Br_tit1.jpg)";
}
}
</script>
<style>
.header {
height:25px;
FONT-FAMILY: Arial,Verdana;
font-size:11px;
color: #666666;
}
.headerSelected {
height:25px;
FONT-FAMILY: Arial,Verdana;
font-size:11px;
background-repeat:repeat-x; 
COLOR: #333333;
CURSOR: pointer;
}.navigation_item {
PADDING-LEFT: 5px; FONT-SIZE: 11px; CURSOR: pointer; COLOR: #000000; FONT-FAMILY: Arial,Verdana; HEIGHT: 20px; TEXT-DECORATION: none
}
.item {
    PADDING-LEFT: 2px; FONT-SIZE: 11px; CURSOR: pointer; COLOR: #000000; FONT-FAMILY: Arial,Verdana; HEIGHT: 20px; 
}
.itemOver {
PADDING-LEFT: 2px; FONT-SIZE: 11px; CURSOR: pointer; COLOR: #ee4400; FONT-FAMILY: Arial,Verdana; HEIGHT: 20px; /*font-weight:bold;*/ 
}
.itemSelected {
PADDING-LEFT: 5px; FONT-SIZE: 11px; CURSOR: pointer; COLOR: #000000; FONT-FAMILY: Arial,Verdana; HEIGHT: 20px; TEXT-DECORATION: underline;
}
A.headerSelected {
PADDING-RIGHT: 0px; PADDING-LEFT: 0px; BACKGROUND-IMAGE: none; PADDING-BOTTOM: 0px; PADDING-TOP: 0px; HEIGHT: 10px
}
A:hover {
color:#ee4400;text-decoration: none;
}
</style></head>
<%
String userId=loginUser.getUserid();
    String appId="00000000000000001342";
    List categories=CommonServices.getLtcategoryService().findReadSubject(loginUser.getUserid(),appId);
    String subjectCode = "";
    String code="";
    String caption="";
    String extInfo="";
    String level = "";
    String temp = "";
    String type = "";
    String currCode = request.getParameter("currCode")==null?"100":request.getParameter("currCode");
 %>
<body style="padding-left: 5px;padding-top: 10px;" >
<table width="100%" height="100%" border="0" align="center" valign="top" cellpadding="0" cellspacing="1" >
  <tr>
        <td width="" height="25" align="left" valign="middle" background="images/kyxm_Br_left1.jpg">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="27">&nbsp;</td>
            <td width="112" class="Br_ttit">菜单栏</td>
            <td width="31"><img src="images/Br_pick-up.jpg" width="18" height="25" border="0" usemap="#Map" /></td>
          </tr>
        </table></td>
      </tr>
  <tr valign="top" height="100%">
    <td width="" align="center" height="" valign="top" class="">
     <table width="100%" height="" border="0" align="center" valign="top" cellpadding="0" cellspacing="0" >
     <tr valign="top">
     <td width="90%" valign="top" >
          <%
           if(categories!=null) {
           String pc = "";
          %>
           <script type="text/javascript">
p = new PhenMenu('p');
          <%
          int j = 0;
    for(int i=0;i<categories.size();i++){
        String href="";
        Ltcategory category=(Ltcategory)categories.get(i);
        code = category.getCode();
        caption = category.getCaption();
        extInfo =  category.getExtinfo();
        level= String.valueOf(category.getLev());
        type= category.getApptype();
        if(extInfo!=null&&extInfo.length()>0){
int f=extInfo.indexOf(">",60)+1;
int t=extInfo.indexOf("<",f);
href=contextPath + extInfo.substring(f,t);
}
temp = code.length()<=3?code:code.substring(0,3);
        if(code.length()>3){
         if(temp.equals(currCode)){
         if("2".equals(level)&&"cencms".equals(type)){
         pc = code.substring(0,6);
 %>
  p.add(<%=pc%>,-1,'<div id="tit<%=j++%>" style="background-image:url(images/kyxm_Br_tit1.jpg); width:160px; height:25px; line-height:25px; overflow:hidden;" align="left" valign="middle">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<%=caption%></div>','','');
<% }else{ ++j; %>
p.add(<%=i%>,<%=pc%>,'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&bull;&nbsp;<%=caption%>','<%=href%>','','','','','','','docframe');
<%             
         }
         }
        }
        
    }
%>
document.write(p);
</script>
<%
           }
           %>
</td>
     </tr>
     </table>
    </td>
    
  </tr>
</table>
</body>
</html>