
var tm_h,tm_w,tm_l,tm_t;
var tm_topMar = 9;
var tm_leftMar = -5;
var tm_space = 1;
var tm_isvisible;
var tm_shadow_color=color_3;	//定义下拉菜单阴影色
var tm_link_color=bg_color;	//定义链接地址颜色
var tm_global = window.document
tm_global.fo_currentMenu = null
tm_global.fo_shadows = new Array

function menu_format(mvar)
{
  var dim_tmp,dim_tmp2;
  var temp1="<table border=0 width=100% cellpadding=0 cellspacing=0 bgcolor="+tm_shadow_color+">";
  dim_tmp=mvar.split("|")
  for(var i=0;i<dim_tmp.length;i++)
  {
    dim_tmp2=dim_tmp[i].split(",");
    temp1+="<tr><td height=20 align=center onmouseover=\"javascript:mm_over(this);\" onmouseout=\"javascript:mm_out(this);\"><a href=\'"+dim_tmp2[1]+"\' class=h_o><font color="+tm_link_color+">"+dim_tmp2[0]+"</font></a></td></tr>";
  }
  temp1+="</table>";
  return temp1;
}

function mm_over(tt)
{
  tt.style.backgroundColor="#000000";
  //tt.style.cursor="HAND";
}

function mm_out(tt)
{
  tt.style.backgroundColor="";
  //tt.style.cursor="";
}

function tm_HideMenu()
{
  var mX,mY,vDiv,mDiv;
  if (tm_isvisible == true)
  {
    vDiv = document.all("menuDiv");
    mX = window.event.clientX + document.body.scrollLeft;
    mY = window.event.clientY + document.body.scrollTop;
    if ((mX < parseInt(vDiv.style.left)) || (mX > parseInt(vDiv.style.left)+vDiv.offsetWidth) || (mY < parseInt(vDiv.style.top)-tm_h) || (mY > parseInt(vDiv.style.top)+vDiv.offsetHeight))
    {
      vDiv.style.visibility = "hidden";
      tm_isvisible = false;
    }
  }
}

function tm_ShowMenu(vMnuCode,tWidth)
{
  vSrc = window.event.srcElement;
  vMnuCode = "<table id='submenu' cellspacing=0 cellpadding=1 style='border:1px; background-color: "+color_1+"; line-height:16px; width:"+tWidth+"' onmouseout='javascript:tm_HideMenu();'><tr height=23><td nowrap align=center class=bg_1>" + menu_format(vMnuCode) + "</td></tr></table>";
  tm_h = vSrc.offsetHeight;
  tm_w = vSrc.offsetWidth;
  tm_l = vSrc.offsetLeft + tm_leftMar+4;
  tm_t = vSrc.offsetTop + tm_topMar + tm_h + tm_space-2;
  vParent = vSrc.offsetParent;
  while (vParent.tagName.toUpperCase() != "BODY")
  {
    tm_l += vParent.offsetLeft;
    tm_t += vParent.offsetTop;
    vParent = vParent.offsetParent;
  }

  menuDiv.innerHTML = vMnuCode;
  menuDiv.style.top = tm_t-8;
  menuDiv.style.left = tm_l;
  menuDiv.style.visibility = "visible";
  tm_isvisible = true;
  makeRectangularDropShadow(submenu, tm_shadow_color, 4)
}

function makeRectangularDropShadow(el, color, size)
{
  var i;
  for (i=size; i>0; i--)
  {
    var rect = document.createElement('div');
    var rs = rect.style
    rs.position = 'absolute';
    rs.left = (el.style.posLeft + i) + 'px';
    rs.top = (el.style.posTop + i) + 'px';
    rs.width = el.offsetWidth + 'px';
    rs.height = el.offsetHeight + 'px';
    rs.zIndex = el.style.zIndex - i;
    rs.backgroundColor = color;
    var opacity = 1 - i / (i + 1);
    rs.filter = 'alpha(opacity=' + (50 * opacity) + ')';
    el.insertAdjacentElement('afterEnd', rect);
    tm_global.fo_shadows[tm_global.fo_shadows.length] = rect;
  }
}
