<html>
<head>
<script language=javascript>
    //cMenuClosed,cMenuOpened
    var cMenuClosed = "+";
    var cMenuOpened = "-";
    var cPreWidth = "10%";
    var cContentWidth = "90%";
    var cChildTrNamePre = "SubMenu_";    //ALL
    var Root = new Array("ALL", "-1");
    var Offices = new Array();
    Offices[0] = "";
    Offices[1] = new Array();
    Offices[1][0] = "AA";
    Offices[1][1] = "1";
    Offices[1][2] = "0";
    Offices[1][3] = new Array();
    Offices[1][3][0] = "";
    Offices[1][3][1] = new Array("b","100","0");
    Offices[1][3][2] = new Array("c", "101", "0");
    Offices[1][3][3] = new Array("d", "103", "0");
    Offices[1][3][4] = new Array("e", "104", "0");
    Offices[1][3][5] = new Array("f", "105", "0");    Offices[2] = new Array();
    Offices[2][0] = "BB";
    Offices[2][1] = "1";
    Offices[2][2] = "0";
    Offices[2][3] = new Array();
    Offices[2][3][0] = "";
    Offices[2][3][1] = new Array("g","200","0");
    Offices[2][3][2] = new Array("h", "201", "0");
    Offices[2][3][3] = new Array("i", "203", "0");
    Offices[2][3][4] = new Array("j", "204", "0");
    Offices[2][3][5] = new Array("k", "205", "0");    var OfficeSelect = '200';
    var OfficeSelectPath = new Array('','1');    function TNodes_Detail_Ck(Aele, eleid){
var tableObj = document.getElementById(eleid);
if(tableObj.style.display == "none"){
            Aele.innerHTML = cMenuOpened;
            tableObj.style.display == "";
        }else{
            Aele.innerHTML = cMenuClosed;
            tableObj.style.display == "none";
        }
    }    function inOfficeSelectPath(OfficeCode){
for(var i=1; i<OfficeSelectPath.length-1; i++)
if (OfficeSelectPath[i] == OfficeCode) return true;
return false;
    }    function CreateOfficesTree(){
        //first create root
var debugid=0;
try{
//alert('');
document.writeln('<tr>');
document.writeln('  <td width="'+cPreWidth+'" align="right">');
if(Offices.length==0){
document.writeln(cMenuClose);
}else{
var bOpen = OfficeSelectPath.length>1?true:false;
document.writeln('    <a href="javascript:TNodes_Detail_Ck(this,\''+cChildTrNamePre+Root[1]+'\')">' + bOpen?cMenuOpened:cMenuClosed + '</a>');
}
document.writeln('  </td>');
document.writeln('  <td width="'+cContentWidth+'">');
document.writeln('    <a href="main.cgi?OfficeCode='+Root[1]+'" target="mainFrame">'+cChildTrNamePre+Root[0]+'</a>');
document.writeln('  </td>');
document.writeln('</tr>');
debugid=1;
//second create offices
if(Offices.length>1){
document.writeln('  <tr id="'+cChildTrNamePre+Root[1]+'">');
document.writeln('    <td width="10%" align="right">');
document.writeln('    </td>');
document.writeln('    <td width="90%">');
document.writeln('      <table width="100%" cellpadding="0" cellspacing="0" border="1">');

//output Office level 1
for(var i=1; i<Offices.length; i++){
var bOpen = inOfficeSelectPath(Offices[i][1]);
document.writeln('         <tr>');
document.writeln('           <td align="right">');
if(Offices[i][2]=='0'){
document.writeln('             '+cMenuOpened);
}
else{
document.writeln('             <a href="javascript:TNodes_Detail_Ck(this,\''+cChildTrNamePre+Offices[i][1]+'\')">' + bOpen?cMenuOpened:cMenuClosed + '</a>');
}
document.writeln('           </td>');
document.writeln('           <td>');
document.writeln('             <a href="main.cgi?OfficeCode='+Offices[i][1]+'" target="mainFrame">'+Offices[i][0]+'</a>');
document.writeln('           </td>');
document.writeln('         </tr>');

//output Office level 2
if(Offices[i][3].length>1){
document.writeln('        <tr>');
document.writeln('          <td align="right">');
document.writeln('          </td>');
document.writeln('          <td>');
document.writeln('            <table width="100%" cellpadding="0" cellspacing="0" border="1">');

document.writeln('            </table>');
document.writeln('          </td>');
document.writeln('        </tr>'); }
}
debugid=2;
document.writeln('      </table>');
document.writeln('    </td>');
document.writeln('  </tr>');
}
}catch(e){
alert(e+" "+debugid);
}
    }    
  </script>
</head>
<body topmargin="0" leftmargin="0">
<table width="100%" cellpadding="0" cellspacing="0" border="1">
  <tr>
    <td width="100%" bgcolor="#99CCCC" align="center" colspan=3>
      tree
    </td>
  </tr>
<script language=javascript>
CreateOfficesTree();
</script>
</table>
</body>
</html>