var nOP = 0;
var nOP5 = 0;
var nIE=0;
var nIE4=0;
var nIE5=0;
var nNN=0;
var nNN4=0;
var nNN6=0;
var nMac=0;
var nIEM=0
var nIEW=0;
var NS4=0;
var nVer=0.0;
var bDelBorder=0;
var bAddBorder=0;
var st_rl_id = null;
var st_cl_w = 0;
var st_cl_h = 0;
var st_buf=[];
var st_loaded=0;
var oMenus = [];
var CurrentMenu = 0;
detectNav();

if(!nNN4)
{
  var s = '<STYLE>\n.st_tbcss,.st_tdcss,.st_divcss,.st_ftcss{border:none;padding:0px;margin:0px;height:43px}\n</STYLE>';
  for(i=0; i < 2; i++)
  {
    s += '<FONT ID="st_global' + i + '"></FONT>';
  }
  if(nIEW && nVer >= 5.0 && document.body)
  {
   document.body.insertAdjacentHTML('AfterBegin', s);
  }
  else
  {
    document.write(s);
  }
}

function detectNav()
{
  var naVer = navigator.appVersion;
  var naAgn = navigator.userAgent;
  nMac = naVer.indexOf('Mac')>=0;
  nOP = naAgn.indexOf('Opera')>=0;
  if(nOP)
  {
    nVer= parseFloat(naAgn.substring(naAgn.indexOf('Opera ') + 6, naAgn.length));
    nOP5= nVer >= 5.12 && !nMac && naAgn.indexOf('MSIE 5.0') >= 0;
  }
  else
  {
    nIE = document.all ? 1 : 0;
    if(nIE)
    {
      nIE4 = (eval(naVer.substring(0, 1) >= 4));
      nVer = parseFloat(naAgn.substring(naAgn.indexOf('MSIE ') + 5, naAgn.length));
      nIE5 = nVer>=5.0 && nVer<5.5;
      nIEM = nIE4 && nMac;
      nIEW = nIE4 && !nMac;
    }
    else
    {
      nNN4 = navigator.appName.toLowerCase() == 'netscape' && naVer.substring(0,1) == '4' ? 1 : 0;
      if(nNN4)
      {
       nVer=parseFloat(naVer);
      }
      else
      {
        nNN6=(document.getElementsByTagName('*') && naAgn.indexOf('Gecko')!=-1);
        if(nNN6)
        {
          nVer=parseInt(navigator.productSub);
          if(naAgn.indexOf('Netscape') >= 0)
          {
            bDelBorder= nVer < 20001108 + 1;
            bAddBorder = nVer > 20020512 - 1;
          }
          else
          {
            bDelBorder = nVer < 20010628 + 1;
            bAddBorder = nVer > 20011221-1;
          }
        }
      }
      nNN=nNN4||nNN6;
    }
  }
}

function closeMenu()
{
  var menuHTML='';
  var st_ht = '';
  var max_l = this.subMenus.length;
  for(MenuIndex=0; MenuIndex < max_l; MenuIndex++)
  {
    var oSub = this.subMenus[MenuIndex];
    var bodyHTML = this.getBodyText(oSub);
    if(oSub.isstatic)
	
      bodyHTML = '<TABLE BORDER="0" STYLE="border:none; height:auto; margin:0px 0px 0px 0px" cellpadding="0" cellspacing="0"><TR><TD NOWRAP class="st_tdcss">' + bodyHTML;
	  
    for(ItemIndex=0; ItemIndex < oSub.items.length; ItemIndex++)
    {
      var item = oSub.items[ItemIndex];
      var itemHTML = '';
      itemHTML += oSub.arrange=='v' ? '<TR ID="' + item.block + 'TR">' : '';
      itemHTML += getItemText(item);
      itemHTML += (oSub.arrange=='v' ? '</TR>' : '');
      bodyHTML += itemHTML;
    }
    bodyHTML += getBodyTextE();
    if(oSub.isstatic)
      bodyHTML += '</TD></TR></TABLE>';
    if(oSub.isstatic || nNN4)
      menuHTML+=bodyHTML;
    else
      st_ht += bodyHTML;
  }

  if(menuHTML != '')
  {
    document.write(menuHTML);
    // alert(menuHTML);
  }
  if(!(nIEM || (nIEW && nVer < 5.0)))
  {
    if(st_ht != '')
    {
      var obj=getob('st_global' + 0, 'font');
      if(nNN6)
        obj.innerHTML=st_ht;
      else if(nIE && nVer>=5.0)
        obj.insertAdjacentHTML('BeforeEnd', st_ht);
      else
        obj.document.write(st_ht);
    }
    if(!nOP && !nNN4)
      prefix(this);
  }
}

function getBodyTextH(oSub)
{
  var s='';
  if(nNN4)
  {
    s += oSub.isstatic ? '<ILAYER' : '<LAYER';
    s += ' STYLE="margin:0px;padding:0px"';
    s += ' VISIBILITY=hide';
    s += ' ID=' + oSub.block;
    s += ' Z-INDEX=' + oSub.z_index;
    s += '><LAYER STYLE="margin:0px;padding:0px">';
    s += '<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"';
    if(oSub.bgcolor != 'transparent')
      s += ' BGCOLOR="' + oSub.bgcolor + '"';
    s += ' ID="' + oSub.block + '"';
    s += '>';
  }
  else
  {
    // var stdiv='position:' + (oSub.MenuIndex ? 'absolute' : getme(oSub).pos) + ';';
    var stdiv='position:' + (oSub.MenuIndex ? 'absolute' : 'static') + ';';
    stdiv += 'z-index:' + oSub.z_index + ';';
    stdiv += 'visibility:hidden';
    s += '<TABLE class="st_tbcss" CELLPADDING="0" CELLSPACING="0"';
    s += this.getBodyEvent(oSub);
    s += ' ID="' + oSub.block + '"';
    s += ' STYLE="';
    if(nIEM)
      s+='width:1px;';
    else if(nIE)
      s+='width:0px;';
    s += getFilterCSS(oSub);
    s+=stdiv;
    s+='">';
    s+='<TD NOWRAP class="st_tdcss" ID="' + oSub.block + 'TTD">';
    s+='<TABLE class="st_tbcss" CELLSPACING="0" CELLPADDING="0"';
    s+=' ID="' + oSub.block + 'TB"';
    if (oSub.width > 0)
      s+= ' width="' + oSub.width + '"';
    s+=' STYLE="' + getBodyCSS(oSub) + '">';
  }
  return s;
}

function getBodyTextE()
{
  var s = '</TABLE>';
  if(nNN4)
    s+='</LAYER></LAYER>';
  s+='</TD></TABLE>';
  return s;
}

function getItemText(item)
{
  var s='';
  if(nNN4)
  {
    var max_i=nNN4 ? 2 : 1;
    s+='<TD WIDTH="1" NOWRAP>';
    s+='<FONT STYLE="font-size:1pt;">';
    s+='<ILAYER ID=' + item.block + ' STYLE="margin:0px;padding:0px"><LAYER STYLE="margin:0px;padding:0px"';
    if(item.border)
      s+=' BGCOLOR=' + item.bordercolor[0];
    s+='>';

    for(i=0;i<max_i;i++)
    {
      s+='<LAYER STYLE="margin:0px;padding:0px" Z-INDEX=10 VISIBILITY=' + (i ? 'HIDE' : 'SHOW');
      s+='>';

      s+='<TABLE align="left" width="100%" border="0" cellspacing="0" cellpadding="0"';
      if(item.bgcolor[i] != 'transparent')
        s += ' BGCOLOR=' + item.bgcolor[i];
      s+='>';

      s+='<TD nowrap width="100%"'
      if(item.Class == '')
      {
        s+=' align="' + item.align + '" valign="' + item.valign + '"';
      }
      else
      {
        s+=' class="' + item.Class + '"';
      }
      s+=' id="' + item.block + 'MTD">';
      if(item.url > '')
        s+='<A HREF="' + item.url + '"';
      if(item.target > '') 
        s+=' TARGET="' + item.target + '"';
      s+=' CLASS="' + item.block + 'TX' + i + '"';
      if(item.tip > '')
        s+=' alt="' + item.tip + '"';
      s+='>';
      if(item.img > '')
      {
        s+='<img id="' + item.tag + '" src="' + item.img + '" border="0">';
      }
      else
      {
        s+=item.text;
      }
      s+='</A>';
      s+='</TD>';
      s+='</TABLE>';
      if(item.border)
        s+='<BR CLEAR=ALL><SPACER HEIGHT=1 WIDTH=' + item.border + '></SPACER><SPACER WIDTH=1 HEIGHT=' + item.border + '></SPACER>';
      s+='</LAYER>';
    }
    s+='<LAYER Z-INDEX=20></LAYER>';
    s+='</LAYER></ILAYER>'
    s+='</FONT>';
    s+='</TD>';
  }
  else
  {
    s+='<TD nowrap align="' + item.align + '" valign="' + item.valign + '"';
    s+=' class="st_tdcss"';
    s+=' ID="' + getParent(item).block + item.ItemIndex + '"';
    s+='>';
    if(!nOP&&!nIE)
    {
      s+='<DIV class="st_divcss" id="' + item.block + '"';
      s+=getItemEventString(item);
      s+=' STYLE="' + getItemCSS(item);
      s+='"';
      s+='>';
    }
    s+='<TABLE class="st_tbcss" cellspacing="0" cellpadding="0"';
    if(!nOP)
      s+=' HEIGHT=100%';
    s+=' STYLE="';
    if(nOP || nIE)
      s+=getItemCSS(item);
    s+='"';
    if(nOP||nIE)
      s+=getItemEventString(item);
    if(getParent(item).arrange == 'v' || nIEM)
      s+=' WIDTH=100%';
    s+=' ID=' + (nOP||nIE ? item.block : (item.block + 'TB'));
    if(!nOP && item.tip > '')
      s+=' TITLE="' + item.tip + '"';
    s+='>';
    s+='<TD width="100%" NOWRAP';
    if(item.Class == '')
    {
      s+=' align="' + item.align + '" valign="' + item.valign + '"';
      s+=' class="st_tdcss" HEIGHT="100%"';
      if(item.padding > 0 || item.fontcolor[0] > '')
      {
        s+= ' STYLE="margin:0px';
        if(item.fontcolor[0] > '')
          s+= ';color:' + item.fontcolor[0];
        if(item.padding > 0)
          s+= ';padding:' + item.padding;
        s+= '"';
      }
    }
    else
    {
      s+=' class="' + item.Class + '"';
    }
    s+=' ID="' + item.block + 'MTD">';
    s+='<FONT class="st_ftcss" ID="' + item.txblock + '">';
    if(item.img > '')
    {
      s+='<img id="' + item.tag + '" src="' + item.img + '" border="0">';
    }
    else
    {
      s+=item.text;
    }
    s+='</FONT>';
    s+='</TD>';
    s+='</TABLE>';
    if(!nOP&&!nIE)
      s+='</DIV>';
    s+='</TD>';
  }
  if((item.itemspacing > 0 || item.height > 0) && getParent(item).arrange=='h')
    s+='<TD><IMG src="' + getme(item).blank + '" width="' + item.itemspacing + '" height="' + item.height + '" border="0"></TD>';
  return s;
}

function getBodyCSS(oSub)
{
  var s='';
  if(oSub.border > 0)
  {
    s+='border-style:solid;';
    s+='border-width:' + oSub.border + 'px;';
    s+='border-color:' + oSub.bordercolor + ';';
  }
  if(oSub.bgcolor > '')
    s+='background-color:' + (oSub.bgcolor) + ';';
  return s;
}

function getFilterCSS(oSub)
{
  var s = '';
  var dxpre = 'progid:DXImageTransform.Microsoft.';
  if(nIEW && (nVer>=5.0 || !oSub.isstatic))
  {
    s += 'filter: ';
    if(nVer>=5.5)
      s += dxpre;
    s+='Alpha(opacity=' + oSub.opacity + ')';
    if(oSub.shadowsize!=0)
    {
      s+=' ';
      if(nVer>=5.5)
        s += dxpre;
      if(oSub.shadowsize)
        s+='dropshadow(color=' + oSub.shadowcolor + ',offx=' + oSub.shadowsize + ',offy=' + oSub.shadowsize + ',positive=1) ';
      else
        s+='Shadow(color=' + oSub.shadowcolor + ',direction=135,strength=' + oSub.shadowsize + ') ';
    }
    s+=';';
  }
  return s;
}

function getItemCSS(item)
{
  var s='';
  if(item.fontcolor[0] > '')
    s+='color:' + item.fontcolor[0] + ';';
  if(item.bgcolor[0] > '')
    s += 'background-color:' + item.bgcolor[0] + ';';
  if(item.border > 0)
  {
    s+='border-style:solid;';
    s+='border-width:' + item.border + 'px;';
    s+='border-color:' + item.bordercolor[0] + ';';
  }
  s+= 'CURSOR: default';
  return s;
}

function doitov(e,obj,it)
{
  if(nIEW)
  {
    if(!it.layer)
      it.layer=obj;
    if(!getParent(it).isshow||(e.fromElement&&obj.contains(e.fromElement)))
      return;
  }
  else
  {
    if(!getParent(it).isshow||(!nNN&&(e.fromElement&&e.fromElement.id&&e.fromElement.id.indexOf(it.block)>=0)))
      return ;
  }
  if(nNN4)
    getlayer(it).document.layers[0].captureEvents(Event.CLICK);
  
  if(typeof(onitov)=='function')
    onitov(it.MenuIndex,it.ItemIndex);

  if(getme(it).hdid)
  {
    clearTimeout(getme(it).hdid);
    getme(it).hdid=null;
  }
  if(getParent(it).currentItem != it.ItemIndex)
  {
    if(getParent(it).currentItem >= 0)
    {
      hditpop(getParent(it).items[getParent(it).currentItem]);
      getParent(it).currentItem = -1;
    }
    shitpop(it);
    getParent(it).currentItem = it.ItemIndex;
  }
  else
  {
    if(getsub(it) && !getsub(it).isshow)
    {
      shitst(it,1);
      showpop(getsub(it));
    }
  }
  if(it.url != '')
    window.status=it.url;
  if(it.st_text != '')
    window.status = it.st_text;
}

function doitou(e,obj,it)
{
  if(nIEW)
  {
    if(!getParent(it).isshow||e.toElement&&obj.contains(e.toElement))
      return;
  }
  else
  {
    if(!getParent(it).isshow||(!nNN&&(e.toElement&&e.toElement.id&&e.toElement.id.indexOf(it.block)>=0)))
      return ;
  }
  if(nNN4)
    getlayer(it).document.layers[0].releaseEvents(Event.CLICK);
  
  if(typeof(onitou)=='function')
    onitou(it.MenuIndex,it.ItemIndex);

  if(!getsub(it) || !getsub(it).isshow)
  {
    shitst(it,0);
    if(it.overimg > '')
    {
      document.getElementById(it.tag).src = it.img;
    }
    else
    {
      if(it.OverClass > '')
        document.getElementById(it.block + 'MTD').className = it.Class;
    }
    getParent(it).currentItem = -1;
  }
  else
  {
    if(getsub(it) && getsub(it).isshow && !getsub(it).exec_ed)
    {
      hditpop(it);
    }
  }
  window.status='';
}

function doitck(e, obj, it)
{
  if(e.button && e.button >= 2)
    return;
  
  if(it.url != '')
  {
    var _preurl='javascript:';
    if(it.url.toLowerCase().indexOf(_preurl)==0)
      eval(it.url.substring(_preurl.length,it.url.length));
    else if(it.target == '_self' || it.target == '_parent' || it.target == '_top')
      setTimeout('window.' + it.target.substring(1,it.target.length) + '.location.href="' + it.url + '";', 100);
    else if(typeof(parent.frames[it.target])=='undefined')
      window.open(it.url,it.target);
    else
      setTimeout('parent.frames["' + it.target + '"].location.href="' + it.url + '";', 100);
  }
}

function getrect(mbit)
{
  var obj = getlayer(mbit);
  if(nNN4)
  {
    return [obj.pageX, obj.pageY, obj.clip.width, obj.clip.height];
  }
  else
  {
    var l = 0;
    var t = 0;
    var w=parseInt(nOP ? obj.style.pixelWidth : obj.offsetWidth);
    var h=parseInt(nOP ? obj.style.pixelHeight : obj.offsetHeight);   

    if(!nOP && !nIEM && typeof(mbit.ItemIndex)=='undefined')
      h -= mbit.shadowsize*2;

    while(obj)
    {
      l += obj.offsetLeft;
      t += obj.offsetTop;     
      obj = obj.offsetParent;
    }

    if(nIEM)
    {
      l += parseInt(document.body.leftMargin);
      l -= mbit.border;
      t -= mbit.border;
    }
    if(typeof(mbit.ItemIndex) != 'undefined')
    {
      if(bDelBorder)
      {
        l -= mbit.border;
        t -= mbit.border;
      }
      if(bAddBorder)
      {
        l += getParent(mbit).border;
        t += getParent(mbit).border;
      }
    }
    return [l,t,w,h];
  }
}

function getxy(oSub)
{
  var x = oSub.offset_left;
  var y = oSub.offset_top;
  var subrc = getrect(oSub);
  oSub.rc = subrc;
  if(oSub.MenuIndex == 0)
  {
    return [subrc[0],subrc[1]];
  }
  var itrc=getrect(getParent(oSub));
  var bdrc=getrect(getParent(getParent(oSub)));
  switch(oSub.offset)
  {
    case 'left':
      x+=itrc[0]-subrc[2];
      y+=itrc[1];
      break;
    case 'up':
      x+=itrc[0];
      y+=itrc[1]-subrc[3];
      if(nIEM)
        y+=oSub.shadowsize;
      break;
    case 'right':
      x+=itrc[0]+itrc[2];
      y+=itrc[1];
      break;
    case 'down':
      x+=itrc[0];
      y+=itrc[1]+itrc[3];
      break;
    case 'auto':
    default:
      break;
  }
  if(!nOP&&!nNN4)
  {
    x-=oSub.shadowsize;
    y-=oSub.shadowsize;
  }
  return adjust([x,y],oSub);
}

function adjust(xy,oSub)
{
  var rc=getrect(oSub);
  var tx=xy[0];
  var ty=xy[1];
  var c_l = getClientLeft();
  var c_t = getClientTop();
  var c_r = c_l + getClientWidth();
  var c_b = c_t + getClientHeight();
  if(tx+rc[2]>c_r)
    tx=c_r-rc[2];
  tx=tx>c_l ? tx : c_l;
  if(ty+rc[3]>c_b)
    ty=c_b-rc[3];
  ty=ty>c_t ? ty : c_t;
  return [tx,ty];
}

function ckPage()
{
  var st_or_w = st_cl_w;
  var st_or_h = st_cl_h;
  var st_or_l = st_cl_l;
  var st_or_t = st_cl_t;
  st_cl_w = getClientWidth();
  st_cl_h = getClientHeight();
  st_cl_l = getClientLeft();
  st_cl_t = getClientTop();
  if((nOP || nNN4) && (st_cl_w - st_or_w || st_cl_h - st_or_h))
    document.location.reload();
}

function shitst(it,nst)
{
  if(nNN4)
  {
    var st_lay=get_st_lay(it);
    st_lay[nst].parentLayer.bgColor = it.bordercolor[nst];
    st_lay[nst].visibility='show';
    st_lay[1-nst].visibility='hide';
  }
  else
  {
    var objs=getlayer(it).style;
    
    if(nIE && nMac)
    {
      if(it.background[0] != it.background[1])
        objs.background = it.background[nst];
    }
    else
    {
      if(nOP)
        objs.background = it.bgcolor[nst];
      else
      {
        if(it.bgcolor[0] != it.bgcolor[1]) 
          objs.backgroundColor = it.bgcolor[nst];
      }
    }

    if(it.bordercolor[0] != it.bordercolor[1])
      objs.borderColor = it.bordercolor[nst];
    if(!it.txstyle)
      it.txstyle=getob(it.txblock, 'font').style;
    if(it.fontcolor[0] != it.fontcolor[1])
    {
      if(nOP)
        getob(it.block + 'MTD', 'td').style.color = it.fontcolor[nst];
      else
        it.txstyle.color = it.fontcolor[nst];
    }
  }
}

function dombov(e,obj,mb)
{
  if(nIEW)
  {
    if(!mb.layer)
      mb.layer=obj;
    if(!mb.isshow||(e.fromElement&&obj.contains(e.fromElement)))
      return;
  }
  else
  {
    if(!mb.isshow||(!nNN&&(e.fromElement&&e.fromElement.id&&e.fromElement.id.indexOf(mb.block)>=0)))
      return ;
  }

  if(getme(mb).hdid)
  {
    clearTimeout(getme(mb).hdid);
    getme(mb).hdid=null;
  }
}

function dombou(e, obj, menu, nIndex)
{
  var mb = menu.subMenus[nIndex];
  if(nIEW)
  {
    if(!mb.isshow || (e.toElement && obj.contains(e.toElement)))
      return;
  }
  else
  {
    if(!mb.isshow || (!nNN && (e.toElement && e.toElement.id && e.toElement.id.indexOf(mb.block)>=0)))
      return;
  }

  if(getme(mb).hdid)
  {
    clearTimeout(getme(mb).hdid);
    getme(mb).hdid=null;
  }
  getme(mb).hdid=setTimeout('hideall(' + menu.id + ');', 500);
}

function showpop(oSub)
{
  show(oSub);
}

function hidepop(oSub)
{
  if(oSub.currentItem >= 0)
  {
    var tmp = getsub(oSub.items[oSub.currentItem]);
    if(tmp && tmp.isshow)
      hidepop(tmp);
    shitst(oSub.items[oSub.currentItem],0);
    oSub.currentItem = -1;
  }
  hide(oSub);
}

function shitpop(item)
{
  if(getsub(item))
  {
    if(!getsub(item).isshow)
      showpop(getsub(item));
  }
  shitst(item,1);
}

function hditpop(item)
{
  if(getsub(item) && getsub(item).isshow)
    hidepop(getsub(item));
  if(item.overimg > '')
  {
    document.getElementById(item.tag).src = item.img;
  }
  else
  {
    if(item.Class > '')
      document.getElementById(item.block + 'MTD').className = item.Class;
  }
  shitst(item,0);
}

function hideall(menu)
{
  menu.clicked = 0;
  var oSub = menu.subMenus[0];
  if(oSub.isshow)
  {
    if(oSub.currentItem >= 0)
    {
      hditpop(oSub.items[oSub.currentItem]);
      oSub.currentItem = -1;
    }
  }
  menu.hdid=null;
}

function normal_sh(oSub)
{
  moveto(getxy(oSub), oSub);
  ck_win_els(-1, oSub);
  _sh(oSub);
}

function normal_hd(oSub)
{
  _hd(oSub);
  ck_win_els(+1, oSub);
}


function movetoex(menu,xy)
{
  menu.pos_l=xy[0];
  menu.pos_t=xy[1];
}

function getme(mbit)
{
  return oMenus[mbit.menu];
}

function getClientLeft()
{
  return parseInt(nNN || nOP ? window.pageXOffset : document.body.scrollLeft);
}

function getClientTop()
{
  return parseInt(nNN||nOP ? window.pageYOffset : document.body.scrollTop);
}

function getClientWidth()
{
  return parseInt(nNN||nOP ? window.innerWidth : (nIEW&&document.compatMode=='CSS1Compat' ? document.documentElement.clientWidth : document.body.clientWidth));
}

function getClientHeight()
{
  return parseInt(nNN||nOP ? window.innerHeight : (nIEW&&document.compatMode=='CSS1Compat' ? document.documentElement.clientHeight : document.body.clientHeight));
}

function get_sdstr(mb, isShow)
{
  var s = 'var _mb = ' + oMenus[mb.menu].id + '.subMenus[' + mb.MenuIndex + '];';
  s += ' _mb.tmid=null;'; 
  s += ' normal' + (isShow? '_sh(' : '_hd(') + '_mb);';
  s += ' _mb.exec_ed=1;'
  return s;
}

function getlayer(mbit)
{
  if(!mbit.layer)
  {
    if(typeof(mbit.ItemIndex)=='undefined')
      mbit.layer=getob(mbit.block,'table');
    else
      mbit.layer=nNN4 ? getlayer(getParent(mbit)).document.layers[0].document.layers[mbit.block] : getob(mbit.block,nIEW ? 'table' : null);
  }
  return mbit.layer;
}

function get_st_lay(item)
{
  return getlayer(item).document.layers[0].document.layers;
}

function moveto(xy, oSub)
{
  if(xy && (oSub.MenuIndex || getme(oSub).pos == 'absolute'))
  {
    var ly = getlayer(oSub);
    if(nNN4)
      ly.moveToAbsolute(xy[0],xy[1]);
    else if(nOP)
    {
      var lys = ly.style;
      lys.pixelLeft=xy[0];
      lys.pixelTop=xy[1];
    }
    else
    {
      var lys = ly.style;
      lys.left=xy[0]+'px';
      lys.top=xy[1]+'px';
    }
    oSub.rc=[xy[0], xy[1], oSub.rc[2], oSub.rc[3]];
  }
}

function show(oSub)
{
  oSub.exec_ed = 0;
  if(!oSub.rc)
    getxy(oSub);
  if(oSub.tmid)
  {
    clearTimeout(oSub.tmid);
    oSub.tmid=null;
    ck_win_els(1,oSub)
  }
  oSub.tmid = setTimeout(get_sdstr(oSub, true), 100);
  oSub.isshow=1;
}

function _sh(oSub)
{
  var ly = getlayer(oSub);
  if(nNN4)
    ly.visibility='show';
  else
    ly.style.visibility='visible';
}

function hide(oSub)
{
  if(oSub.tmid)
  {
    clearTimeout(oSub.tmid);
    oSub.tmid=null;
  }
  if(oSub.isshow && !oSub.exec_ed)
  {
    oSub.exec_ed = 0;
    oSub.isshow = false;
  }
  else
  {
    oSub.exec_ed = 0;
    oSub.isshow = false;
    eval(get_sdstr(oSub, false));
  }
}

function _hd(oSub)
{
  var ly=getlayer(oSub);
  if(nNN4)
    ly.visibility='hide';
  else
  {
    var lyf;
    if(nIE5 && !nMac)
    {
      lyf = ly.filters['Alpha'];
      lyf.opacity=0;
    }
    ly.style.visibility='hidden';
    if(nIE5&&!nMac) lyf.opacity=oSub.opacity;
  }
}

function fixmenu(menu)
{
  for(MenuIndex=0;MenuIndex<menu.subMenus.length;MenuIndex++)
  {
    var oSub = menu.subMenus[MenuIndex];
    if(nOP&&nVer<6.0)
      getlayer(oSub).style.pixelWidth = parseInt(getob(oSub.block + 'TB','table').style.pixelWidth);
    if(nIEW && nIE5)
      getlayer(oSub).style.width=getlayer(oSub).offsetWidth;
    else if(nIEM || !nIE)
    {
      if(oSub.arrange != 'v')
      {
        var ItemIndex=0;
        var fixit=getob(oSub.block + ItemIndex);
        var h=parseInt(nOP ? fixit.style.pixelHeight : fixit.offsetHeight);
        if(h)
        {
          for(ItemIndex = 0; ItemIndex < oSub.items.length; ItemIndex++)
          {
            var item=oSub.items[ItemIndex];
            var lys=getlayer(item).style;
            var tm_h = h-2 * oSub.spacing;
            if(nOP)
              lys.pixelHeight=tm_h;
            else if(nIE)
              lys.height=tm_h+'px';
            else
              lys.height=tm_h-2*item.border+'px';
  
            if(nIEM)
            {
              var fh = h-2 * oSub.spacing;
              lltd=getob(item.block + 'LLTD');
              ltd=getob(item.block + 'LTD');
              rtd=getob(item.block + 'RTD');
              rrtd=getob(item.block + 'RRTD');
              if(lltd)
                lltd.style.height = fh + 'px';
              if(ltd)
                ltd.style.height = fh + 'px';
              getob(item.block + 'MTD').style.height = fh + 'px';
              if(rtd)
                rtd.style.height = fh + 'px';
              if(rrtd)
                rrtd.style.height = fh + 'px';
            }
          }
        }
      }
    }
  }
}

function prefix(menu)
{
  var oSub = menu.subMenus[menu.subMenus.length-1];
  var item = oSub.items[oSub.items.length-1];
  while(1)
    if(getlayer(item)) break;
  if(!nNN4)
    fixmenu(menu);
  show(menu.subMenus[0]);
  if(!st_rl_id)
  {
    st_cl_w = getClientWidth();
    st_cl_h = getClientHeight();
    st_cl_l = getClientLeft();
    st_cl_t = getClientTop();
    st_rl_id = setInterval('ckPage();',500);
  }
}

function ck_win_els(change,obj)
{
  if(!st_loaded||nNN4||nOP||obj.isstatic) return;
  win_ele_vis('SELECT', change, obj);
}

function win_ele_vis(tagName, change, obj)
{
  var els=nNN6 ? document.getElementsByTagName(tagName) : document.all.tags(tagName);
  var i;
  for (i=0;i<els.length;i++)
  {
    var el=els.item(i);
    var flag;
    for(flag=0,tmobj=el.offsetParent;tmobj;tmobj=tmobj.offsetParent)
      if(tmobj.id && tmobj.id.indexOf('STM') >= 0)
        flag=1;
    if(flag)
      continue;
    else if(elements_overlap(el,obj))
    {
      if (el.visLevel)
        el.visLevel+=change;
      else
        el.visLevel=change;
      if (el.visLevel==-1)
      {
        if(typeof(el.visSave)=='undefined')
          el.visSave = el.style.visibility;
        el.style.visibility = 'hidden';
      }
      else if (el.visLevel==0)
        el.style.visibility = el.visSave;
    }
  }
}

function elements_overlap(el,obj)
{
  var left=0;
  var top=0;
  var width=el.offsetWidth;
  var height=el.offsetHeight;
    
  if(width)
    el._width=width;
  else
    width=el._width;
  if(height)
    el._height=height;
  else
    height=el._height;
  
  while(el)
  {
    left+=el.offsetLeft;
    top+=el.offsetTop;
    el=el.offsetParent;
  }
  return ((left<obj.rc[2]+obj.rc[0]) && (left+width>obj.rc[0]) && (top<obj.rc[3]+obj.rc[1]) && (top+height>obj.rc[1]));
}

function getob(id,t)
{
  if(nNN6)
    return document.getElementById(id);
  else if(nNN4)
    return document.layers[id];
  else
    return t ? document.all.tags(t)[id] : document.all[id];
}

function getBodyEventString(oSub)
{
  var s=' onMouseOver="dombov(event, this, ' + this.id + '.subMenus[' + oSub.MenuIndex + ']);"';
  s+=' onMouseOut="dombou(event, this, ' + this.id + ', ' + oSub.MenuIndex + ');"';
  return s;
}

function getItemEventString(item)
{
  var s = ' onMouseOver="doitov(event, this, ' + oMenus[item.menu].id + '.subMenus[' + item.MenuIndex + '].items[' + item.ItemIndex + ']);';
  if(item.overimg > '')
  {
    s+=item.tag + '.src=\'' + item.overimg + '\';';
  }
  else
  {
    if(item.OverClass > '')
        s+= 'document.getElementById(\'' + item.block + 'MTD\').className = \'' + item.OverClass + '\';';
  }
  s+= '"';
  s += ' onMouseOut="doitou(event, this, ' + oMenus[item.menu].id + '.subMenus[' + item.MenuIndex + '].items[' + item.ItemIndex + ']);';
  s+= '"';
  s += ' onClick="doitck(event, this, ' + oMenus[item.menu].id + '.subMenus[' + item.MenuIndex + '].items[' + item.ItemIndex + ']);"';
  return s;
}

function getParent(mbit)
{
  return mbit.parent;
}

function getsub(item)
{
  return item.subMenu;
}

function MenuBlock(sID)
{
  CurrentMenu = oMenus.length;
  this.subMenus = [];
  this.hdid = null;
  this.block = 'STM' + CurrentMenu;
  this.pos_l = 0;
  this.pos_t = 0;
  this.blank = '../images/clear.gif';
  this.clicked = 0;
  this.currentSub = 0;
  this.id = sID;
  oMenus[CurrentMenu] = this;
}

function SubMenu()
{
  this.items = [];
  this.parent = null;
  this.menu = CurrentMenu;
  this.width = 0;
  this.MenuIndex = 0;
  this.LastItem = 0;
  this.block = '';
  this.subMenu = null;
  this.tmid = null;
  this.currentItem = -1;
  this.isshow = false;
  this.isitem = 0;
  this.isstatic = true;
  this.isvisible = true;
  this.exec_ed = 0;
  this.arrange = 'v';
  this.offset = 'down';
  this.offset_left = 0;
  this.offset_top = 0;
  this.spacing = 0;
  this.padding = 0;
  this.bgcolor = '';
  this.background = '';
  this.border = 0;
  this.bordercolor = '';
  this.opacity = 100;
  this.fl_type = -1;
  this.shadowsize = 0;
  this.shadowcolor = '';
  this.z_index = 1000;
}

function MenuItem()
{
  this.parent = null;
  this.menu = CurrentMenu;
  this.MenuIndex = 0;
  this.ItemIndex = 0;
  this.block = '';
  this.isitem = 1;
  this.txblock = '';
  this.tag = '';
  this.tmid = null;
  this.text = '';
  this.img = '';
  this.overimg = '';
  this.align = 'center';
  this.valign = 'middle';
  this.Class = '';
  this.OverClass = '';
  this.bgcolor = ['FFFFFF', '000000'];
  this.tip = '';
  this.url = '';
  this.target = '_self';
  this.fontsize =  '8pt';
  this.fontcolor = ['000000', 'FFFFFF'];
  this.fontfamily = 'Arial';
  this.weight = '';
  this.style = '';
  this.textDec = 'none';
  this.border = 0;
  this.bordercolor = ['', ''];
  this.st_text = '';
  this.itemspacing = 0;
  this.height = 0;
  this.width = 0;
}

function newSubMenu(arrange, spacing, padding, bgColor, borderSize, borderColor, shadowSize, shadowColor)
{
  var nextItem = this.subMenus.length;
  this.subMenus[nextItem] = new SubMenu();
  var oItem = this.subMenus[nextItem];
  oItem.MenuIndex = nextItem;
  oItem.block = 'STM' + CurrentMenu + 'X' + nextItem + 'Y';
  oItem.arrange = arrange;
  oItem.spacing = spacing;
  oItem.padding = padding;
  oItem.bgcolor = bgColor;
  oItem.background = '';
  oItem.shadowsize = shadowSize;
  oItem.shadowcolor = shadowColor;
  if(nextItem > 0)
  {
    var oParent = this.subMenus[this.currentSub]
    // oItem.parent = [oParent.MenuIndex, oParent.LastItem];
    oItem.parent = oParent.items[oParent.LastItem];
    oItem.isstatic = false;
    oItem.isvisible = false;
    oItem.parent.subMenu = oItem;
    oItem.z_index = getParent(getParent(oItem)).z_index + 10;
    oItem.offset = getParent(getParent(oItem)).arrange == 'v' ? 'right' : 'down';
  }
  if(!nNN4 && borderSize && borderColor != '')
    oItem.bordercolor = (borderColor + ' ' + borderColor + ' ' + borderColor + ' ' + borderColor);
  this.currentSub = nextItem;
  return oItem;
}

function lastSubMenu()
{
  var oItem = this.subMenus[this.currentSub];
  var oParent = oItem.parent;
  if(oParent == null)
  {
    this.currentSub = 0;
  }
  else
  {
    this.currentSub = oParent.MenuIndex;
  }
  if(this.currentSub < 0)
    this.currentSub = 0;
  return this.subMenus[this.currentSub];
}

function newMenuItem()
{
  var nextItem = this.items.length;
  this.items[nextItem] = new MenuItem();
  var oItem = this.items[nextItem];
  oItem.parent = this;
  oItem.MenuIndex = this.MenuIndex;
  oItem.ItemIndex = nextItem;
  oItem.block = 'STM' + CurrentMenu + 'X' + this.MenuIndex + 'Y' + nextItem + 'Z',
  oItem.txblock = 'STM' + CurrentMenu + 'X' + this.MenuIndex + 'Y' + nextItem + 'Z' + 'TX';
  oItem.tag = 'A' + CurrentMenu + '_' + this.MenuIndex + '_' + nextItem;
  // oItem.background = oItem.bgcolor;
  this.LastItem = nextItem;
  return oItem;
}

MenuBlock.prototype.addSubMenu = newSubMenu;
MenuBlock.prototype.getLastSubMenu = lastSubMenu;
MenuBlock.prototype.endMenu = closeMenu;
MenuBlock.prototype.getBodyText = getBodyTextH;
MenuBlock.prototype.getBodyEvent = getBodyEventString;
SubMenu.prototype.addMenuItem = newMenuItem;
