var nowMenu;
function fhideDiv(Divobj){
  if (nowMenu){
    nowMenu.className ='MenuCss';
    //nowMenu = "";
  }
  Divobj.style.visibility = 'hidden';
}

function fShowDiv(Divobj){
  nowMenu.className ='MenuCss_move';
  Divobj.style.visibility = 'visible';
}

function fSetOut(tbObj){
  nowMenu.className ='MenuCss';
  nowMenu = "";
  tbObj.className='MenuCss';
}

function fSetMove(tbObj){
  if (nowMenu){
    nowMenu.className ='MenuCss';
    nowMenu = "";
  }
  tbObj.className='MenuCss_move';
  nowMenu = tbObj;
  SubMenu.style.visibility = 'hidden';
}

function getLocation(e,lct){ 
  var t = e.offsetTop; 
  var l = e.offsetLeft; 
  while(e=e.offsetParent){ 
    t += e.offsetTop; 
    l += e.offsetLeft; 
  } 
  if (lct == 't'){
    return t;
  }else if (lct == 'l'){
    return l;
  }
}

function fShowMenu(TableObj,ShowType){
  var tblRow= TableObj.rows[0];
  var menuBody;
  var strTemp;
  for(i=0;i<RootMenu.length;i++){
    newcell = tblRow.insertCell(); 
    if (!RootMenu[i][3]){
      strTemp = 'onmouseover="fSetMove(this);" onmouseout="fSetOut(this);"';
    }else{
      strTemp = '';
    }
    menuBody = '<table border="0" cellpadding="0" cellspacing="1" class="MenuCss" '+ strTemp +
                ' id="Menu'+ RootMenu[i][0] +'"> '+
                '    <tr> '+
                '      <td height="18" style="padding-left:2px;"><img src="/images/Menu/menu_13.gif" /></td> '+
                '      <td>'+ RootMenu[i][2] +'</td> '+
                '    </tr> '+
                '  </table> ';
    newcell.innerHTML = menuBody;
    newcell = tblRow.insertCell();
    newcell.width = "5";
  }  
  if (ShowType==1){
    newcell = tblRow.insertCell(); 
    menuBody = '<table border="0" cellpadding="0" cellspacing="1" class="MenuCss"'+
                ' onmouseover="fSetMove(this);" onmouseout="fSetOut(this);" id="MenuIndex"> '+
                '    <tr> '+
                '      <td height="18" style="padding-left:2px;"><img src="/images/Menu/menu_13.gif" /></td> '+
                '      <td><a href=\"/default.jsp\">·µ»ØÊ×Ò³</a></td> '+
                '    </tr> '+
                '  </table> ';
    newcell.innerHTML = menuBody;

  }
}

function fShowSub(id){
  if (nowMenu){
    nowMenu.className ='MenuCss';
    nowMenu = "";
  }
  var prtTB= eval("Menu"+id);
  var subTbObj = window.SubTable;
  var subMenu = eval("MenuSub"+id);
  
  //set parent table
  prtTB.className ='MenuCss_move';
  prtTB.onmouseout ='';

  SubMenu.style.left=24;
  SubMenu.style.visibility = 'hidden';

  var tblRow= subTbObj.rows[0];
  //Del body
    for (i=0; i < subTbObj.rows.length; i++){ 
      subTbObj.deleteRow();
    }
  //insert body  
  tblRow = subTbObj.insertRow();
  newcell = tblRow.insertCell();
  newcell.width = "10";
  var menuBody;
  for(i=0;i<subMenu.length;i++){
    menuBody = '<table border="0" cellspacing="0" cellpadding="0">' +
               '  <tr>' +
               '    <td><img src="/images/Menu/menu_24.gif" width="4" height="6" /></td>' +
               '    <td class="MenuSubCss" nowrap="nowrap">'+ subMenu[i][2] +'</td>' +
               '    <td width="5" nowrap="nowrap"></td> '+
               '  </tr>'+
               '</table>';
    newcell = tblRow.insertCell(); 
    newcell.innerHTML = menuBody;
    newcell.nowrap="nowrap";
  }
  nowMenu = prtTB;

  //location
  var prtTbWidth = prtTB.clientWidth;
  var divWidth = SubMenu.clientWidth;
  var prtTbLeft = getLocation(prtTB,"l");

  var setLeft = prtTbLeft + prtTbWidth/2 - divWidth/2;
  if (setLeft < 24) setLeft = 24;

  //alert(setLeft +"::" +(setLeft +divWidth) + "::"+ divWidth);
  
  if ((setLeft +divWidth) > 989) setLeft = 969-divWidth;
  
  SubMenu.style.left=setLeft;
  //alert(SubMenu.style.width)
  if (subMenu.length >0) SubMenu.style.visibility = 'visible';
}