document.write('<SCRIPT type="text/javascript" src="menu.js"></SCRIPT>');

var MenuBGColor = '#DDEEFF';
var MenuHLColor = '#66AACC';
var MenuTextColor = '#884422';
var MenuHLTextColor = '#FFFFFF';

var MenuBorderColor = '#0000FF';
MenuBorderColor = MenuBGColor;


function mv(i) {
  for (var j=1; j<=getMainMenuLength(); j++)
    if (i!=j) {
//      document.getElementById('t' + j).style.borderStyle = 'solid';
//      document.getElementById('t' + j).style.borderColor = MenuBGColor;
      if (getNumOfChild(getMainMenuId(j)) > 0) document.getElementById('t_' + getMainMenuId(j)).style.visibility = 'hidden';
    }

  if (i>0) {
//    if (document.getElementById('mouse_status').innerHTML == 'down') {
//      document.getElementById('t' + i).style.borderStyle = 'inset';
      if (getNumOfChild(getMainMenuId(i)) > 0) document.getElementById('t_' + getMainMenuId(i)).style.visibility = 'visible';

  document.getElementById('mouse_status').innerHTML = 'down';

//    } else {
//      document.getElementById('t' + i).style.borderStyle = 'outset';
//      if (getNumOfChild(getMainMenuId(i)) > 0) document.getElementById('t_' + getMainMenuId(i)).style.visibility = 'hidden';
//    }
//    document.getElementById('t' + i).style.borderColor = '';
    for (var j=1; j<=getNumOfTable(); j++)
      if (getTableId(j) != getMainMenuId(i)) document.getElementById('t_' + getTableId(j)).style.visibility = 'hidden';
  } else
    for (var j=1; j<=getNumOfTable(); j++) {
      document.getElementById('t_' + getTableId(j)).style.visibility = 'hidden';
      for (var k=1; k<=MainMenuLength; k++)
        document.getElementById('i' + k).src = 'images/index_02b' + (k+1) + '.gif';
    }
    document.selection.empty();
}

function mo(i) {
  if ('' + document.getElementById('mouse_status').innerHTML != 'down') {
//    document.getElementById('t' + i).style.borderStyle = 'solid';
//    document.getElementById('t' + i).style.borderColor = MenuBGColor;
  }
}

function md(i) {
  if ('' + document.getElementById('mouse_status').innerHTML != 'down') {
    if (i>=0) document.getElementById('mouse_status').innerHTML = 'down';
  } else
    document.getElementById('mouse_status').innerHTML = 'up';
  mv(i);
}

function mv2(parentId, i, childId) {
  if (i != 0) {
    var tname = 't_' + parentId + '_' + i;

    document.getElementById(tname + 'a').style.backgroundColor = MenuHLColor;
    document.getElementById(tname + 'a').style.color = MenuHLTextColor;
    document.getElementById(tname + 'a').style.borderColor = MenuHLColor;

    document.getElementById(tname + 'b').style.backgroundColor = MenuHLColor;
    document.getElementById(tname + 'b').style.color = MenuHLTextColor;
    document.getElementById(tname + 'b').style.borderColor = MenuHLColor;

    document.getElementById(tname + 'c').style.backgroundColor = MenuHLColor;
    document.getElementById(tname + 'c').style.color = MenuHLTextColor;
    document.getElementById(tname + 'c').style.borderColor = MenuHLColor;

    if (getNumOfChild(childId) > 0) document.getElementById(tname + 'd').style.backgroundColor = MenuHLColor;
  }

  var t, vis;
  var tt;
  for (var j=1; j<=getNumOfTable(); j++) {
    vis = false;
    t = ((childId.length>0)?childId:parentId);
    while (t.length > 0) {
      if (t == getTableId(j)) {
        document.getElementById('t_' + getTableId(j)).style.visibility = 'visible';
        vis = true;
        break;
      }
      tt = getParentId(t);
      if (tt.length == 0) {
        for (var k=1; k<=MainMenuLength; k++) {
          if (getMainMenuId(k) == t)
            document.getElementById('i' + k).src = 'images/index_02b' + (k+1) + '_on.gif';
          else
            document.getElementById('i' + k).src = 'images/index_02b' + (k+1) + '.gif';
        }
      }
      t = tt;
    }
    if (i!=0)
      if (!(vis)) document.getElementById('t_' + getTableId(j)).style.visibility = 'hidden';
  }
  document.selection.empty();
}

function mo2(parentId, i, childId) {
  var tname = 't_' + parentId + '_' + i;

  document.getElementById(tname + 'a').style.backgroundColor = MenuBGColor;
  document.getElementById(tname + 'a').style.color = MenuTextColor;
  document.getElementById(tname + 'a').style.borderColor = MenuBGColor;

  document.getElementById(tname + 'b').style.backgroundColor = MenuBGColor;
  document.getElementById(tname + 'b').style.color = MenuTextColor;
  document.getElementById(tname + 'b').style.borderColor = MenuBGColor;

  document.getElementById(tname + 'c').style.backgroundColor = MenuBGColor;
  document.getElementById(tname + 'c').style.color = MenuTextColor;
  document.getElementById(tname + 'c').style.borderColor = MenuBGColor;

  if (getNumOfChild(childId) > 0) {
    document.getElementById(tname + 'd').style.backgroundColor = MenuBGColor;
  }
}

function DrawSubMenuTable(parentId, x, y, lv) {
//  document.write('<TABLE id="t_' + parentId + '" border="2" width="94" bgcolor="' + MenuBGColor + '" cellspacing="0" cellpadding="0" style="position:absolute;top:' + y + 'px;left:' + x + 'px;z-index:' + (10*(lv+1)) + ';visibility:hidden">');
  document.write('<TABLE id="t_' + parentId + '" border="1" width="94" bgcolor="' + MenuBGColor + '" cellspacing="0" cellpadding="0" style="position:absolute;top:' + y + 'px;left:' + x + 'px;z-index:' + (10*(lv+1)) + ';visibility:hidden;filter:progid:DXImageTransform.Microsoft.Glow(color=#FFFFFF, strength=0);" onMouseOver="mv2(\'' + parentId + '\', 0, \'\')">');
  for (var i=1; i<=getNumOfChild(parentId); i++) {
    document.write('<TR id="t_' + parentId + '_' + i + '" height="20" valign="middle" onMouseOver="mv2(\'' + parentId + '\', ' + i + ', \'' + loadSubMenuItem('id', parentId, i) + '\')" onMouseOut="mo2(\'' + parentId + '\', ' + i + ', \'' + loadSubMenuItem('id', parentId, i) + '\')"');

    if (loadSubMenuItem('target', parentId, i).length > 0) {
      if (loadSubMenuItem('target', parentId, i) == '_self')
        if (loadSubMenuItem('url', parentId, i).length > 0)
          document.write(' onClick="window.location.href=\'' + loadSubMenuItem('url', parentId, i) + '\';"');
    } else {
      if (loadSubMenuItem('url', parentId, i).length > 0)
        document.write(' onClick="window.open(\'' + loadSubMenuItem('url', parentId, i) + '\');"');
    }

    document.write('>');

    document.write('<TD id="t_' + parentId + '_' + i + 'a" width="10" style="');
    if (i!=1) document.write('border-top:0px;');
    if (i!=getNumOfChild(parentId)) document.write('border-bottom:0px;');
    document.write('border-style:solid;border-color:' + MenuBorderColor + ';');
    document.write('background-color:' + MenuBGColor + ';color:' + MenuTextColor + '"');
    document.write(' align="center">&nbsp;</TD>');

    document.write('<TD id="t_' + parentId + '_' + i + 'b" style="');
    if (i!=1) document.write('border-top:0px;');
    if (i!=getNumOfChild(parentId)) document.write('border-bottom:0px;');
    document.write('border-style:solid;border-color:' + MenuBorderColor + ';');
    document.write('background-color:' + MenuBGColor + ';color:' + MenuTextColor + '"');
    document.write(' nowrap><FONT style="font-size:9pt">' + loadSubMenuItem('title_chi', parentId, i) + '</FONT></TD>');

    document.write('<TD id="t_' + parentId + '_' + i + 'c" width="15" style="');
    if (i!=1) document.write('border-top:0px;');
    if (i!=getNumOfChild(parentId)) document.write('border-bottom:0px;');
    document.write('border-style:solid;border-color:' + MenuBorderColor + ';');
    document.write('background-color:' + MenuBGColor + ';color:' + MenuTextColor + '"');
    document.write(' align="center">');
    if (getNumOfChild(loadSubMenuItem('id', parentId, i)) > 0) {
//      document.write('<FONT id="t_' + parentId + '_' + i + 'd" style="width:10px;height:8px;font-size:8pt;filter:fliph;background-color:' + MenuBGColor + '">&#017;</FONT>');
      document.write('<FONT id="t_' + parentId + '_' + i + 'd" style="font-size:8pt">&#x25B6;</FONT>');
    } else
      document.write('&nbsp;');
    document.write('</TD>');

    document.write('</TR>');
  }
  document.write('</TABLE>');

  for (i=1; i<=getNumOfChild(parentId); i++) {
    if (getNumOfChild(loadSubMenuItem('id', parentId, i)) > 0) DrawSubMenuTable(loadSubMenuItem('id', parentId, i), x+90, y+(20*(i-1))+2, lv+1);
  }
}

function ChangeMainMenuButton(i) {
  for (var j=1; j<=getMainMenuLength(); j++) {
    if (i != j)
      document.getElementById('i' + j).src = 'images/index_02b' + (j+1) + '.gif';
    else
      document.getElementById('i' + j).src = 'images/index_02b' + (j+1) + '_on.gif';
  }
}

function show_menu() {

// -- main menu --

document.write('<SPAN id="mouse_status" style="visibility:hidden"></SPAN>');
document.write('<TABLE id="mainmenu" width="1000" border="0" cellspacing="0" cellpadding="0" style="position:absolute;top:191px;left:0px;z-index:10"><TR height="26">');
document.write('<TD width="390"><IMG width="390" height="27" src="images/index_02a.gif" onMouseOver="mv(99);" onMouseDown="md(-1);"></TD>');
document.write('<TD width="36"><IMG src="images/index_02b1.gif" width="36" height="27" onMouseOver="this.src=\'images/index_02b1_on.gif\';mv(99);" onMouseDown="md(-1);" onMouseOut="this.src=\'images/index_02b1.gif\';"></TD>');

var i = 1;
while (loadMainMenuItem('id', i).length > 0) {
  document.write('<TD id="t' + i + '" width="80" align="center" style="color:' + MenuTextColor + '">');
  if (loadMainMenuItem('url', i).length > 0) {
    document.write('<A href="' + loadMainMenuItem('url', i) + '"');
    if (loadMainMenuItem('target', i).length > 0) document.write(' target="' + loadMainMenuItem('target', i) + '"');
    document.write('>');
    document.write('<IMG id="i' + i + '" src="images/index_02b' + (i+1) + '.gif" border="0" width="66" height="27" onMouseOver="ChangeMainMenuButton(' + i + ');mv(' + i + ');" onMouseOut="this.src=\'images/index_02b' + (i+1) + '.gif\';mo(' + i + ');" onMouseDown="md(' + i + ');">');
    document.write('</A>');
  } else
    document.write('<IMG id="i' + i + '" src="images/index_02b' + (i+1) + '.gif" width="66" height="27" onMouseOver="ChangeMainMenuButton(' + i + ');mv(' + i + ');" onMouseOut="this.src=\'images/index_02b' + (i+1) + '.gif\';mo(' + i + ');" onMouseDown="md(' + i + ');">');
  document.write('</TD>');
  i++;
}

document.write('<TD width="27"><IMG src="images/index_02c.gif" onMouseOver="mv(99);" onMouseDown="md(-1);"></TD>');
document.write('</TR></TABLE>');

// -- sub menu --

for (var i=1; i<=getMainMenuLength(); i++)
  DrawSubMenuTable(loadMainMenuItem('id', i), 428+66*(i-1), 213, 1);

}
