/**********************************************************
* Menu para os sistemas da Colortel - só roda em IE       *
***********************************************************/

/* -------------------------------- */

var CTMenuBars = new Array ();
var CTMENUSELBORDER = 2
var CTMENUTIMEOUT = 100;

/* -------------------------------- */

function setObjectByNameVisible (objName, visible)
{
  eval('document.all.'+objName).style.visibility=(visible? 'visible': 'hidden');
}

function setObjectVisible (obj, visible)
{
  obj.style.visibility=(visible? 'visible': 'hidden');
}

function getObjectHeight (obj)
{
  if (obj.style.pixelHeight) return obj.style.pixelHeight;
  else return obj.clientHeight;
}

/* -------------------------------- */


function hideMenu (bar, menu)
{
  var m=CTMenuBars[bar].allmenus[menu];
  var i, it;

  if (m.items.length > 1) {
     setObjectVisible (m.tblItems,0);
  }

  if (m.items[0].enable)
     setObjectVisible (m.items[0].tblSel, 0);

  for (i=1; i<m.items.length; i++) {
    if (m.tpitems[i]==1) //sub-menu
       it = m.items[i].items[0];
    else    // item
       it = m.items[i];
    setObjectVisible (it.tblNorm, 0);
    if (it.enable)
      setObjectVisible (it.tblSel, 0);
    setObjectVisible (it.tblDummy,0);
  }

  if (m.hideObjectsId.length != m.hideObjects.length) {
    m.hideObjects = new Array();
    for (i=0; i<m.hideObjectsId.length;i++) {
      m.hideObjects[i] = eval('document.all.'+m.hideObjectsId[i]);
    }
  }
  for (i=0; i<m.hideObjects.length;i++) {
    setObjectVisible (m.hideObjects[i], 1);
  }
}

function showMenu (bar, menu)
{
  var m=CTMenuBars[bar].allmenus[menu];
  var i, it;


  if (m.items.length > 1) {
     setObjectVisible (m.tblItems,1);
  }

  for (i=1; i<m.items.length; i++) {
    if (m.tpitems[i]==1) //sub-menu
       it = m.items[i].items[0];
    else    // item
       it = m.items[i];
    setObjectVisible (it.tblNorm, 1);
    setObjectVisible (it.tblDummy,1);
  }

  if (m.hideObjectsId.length != m.hideObjects.length) {
    m.hideObjects = new Array();
    for (i=0; i<m.hideObjectsId.length;i++) {
      m.hideObjects[i] = eval('document.all.'+m.hideObjectsId[i]);
    }
  }
  for (i=0; i<m.hideObjects.length;i++) {
    setObjectVisible (m.hideObjects[i], 0);
  }
}

/* -------------------------------- */

function overHdr (bar, menu)
{
  var b = CTMenuBars[bar];
  if (b.activemenu == menu)
  {
     b.newmenu = -1;
     b.newitem = -1;
     if (b.timerHdr) clearTimeout(b.timerHdr);
  }
  else
  {
     b.newmenu = menu;
     b.newitem = -1;
     if (b.timerHdr) clearTimeout(b.timerHdr);
     b.timerHdr = setTimeout ("timeoutHdr("+bar+");",CTMENUTIMEOUT);
  }
}

function outHdr (bar, menu)
{
  var b = CTMenuBars[bar];
  b.newmenu = -1;
  b.newitem = -1;
  if (b.timerHdr) clearTimeout(b.timerHdr);
  b.timerHdr = setTimeout ("timeoutHdr("+bar+");",CTMENUTIMEOUT);
}

function timeoutHdr (bar)
{
  var b = CTMenuBars[bar];
  if (b.timerHdr) clearTimeout(b.timerHdr);
  if (b.newmenu >= 0)
  {
    var m2 = b.allmenus[b.newmenu];
    // esconde o menu antigo (se nao for pai do novo)
    if (b.activemenu >= 0 && m2.fatherMenu != b.activemenu)
    {
       var m1 = b.allmenus[b.activemenu];
       setObjectVisible (m1.items[0].tblSel, 0);
       hideMenu (bar, b.activemenu);
       var father = m1.fatherMenu;
       if (father != -1 && m2.fatherMenu != father)
         hideParentMenu (bar, m1.fatherMenu, m1.fatherMenuItem, m2.fatherMenu);

       // nao tem nenhum item selecionado
       b.activeitem = -1;
    }
    else if (m2.fatherMenu == b.activemenu && b.activeitem >= 0)
    {
       // menu antigo é pai do novo. Esconde o item antigo.
       var m1 = b.allmenus[b.activemenu];
       setObjectVisible (m1.items[b.activeitem].tblSel, 0);
    }

    // mostra o menu novo
    if (m2.items[0].enable)
    {
      setObjectVisible (m2.items[0].tblSel, 1);
      if (m2.items.length > 1)
         showMenu (bar, b.newmenu);
      b.activemenu = b.newmenu;
      b.newmenu = -1;
    }
    else
    {
      b.activemenu = m2.items[0].fatherMenu;
      b.newmenu = -1;
    }

    // mostra o item novo
    if (b.newitem >=0)
    {
      if (m2.items[b.newitem].enable)
      {
         setObjectVisible (m2.items[b.newitem].tblSel, 1);
         b.activeitem = b.newitem;
         b.newitem = -1;
      }
      else
      {
        b.activeitem = -1;
        b.newitem = -1;
      }
    }
    else
    {
      b.activeitem = -1;
      b.newitem = -1;
    }
  }
  else if (b.newitem > 0)
  {
    // desmarca antigo item
    if (b.activeitem != -1)
      setObjectVisible (b.allmenus[b.activemenu].items[b.activeitem].tblSel, 0);

    // seleciona o novo item
    if (b.allmenus[b.activemenu].items[b.newitem].enable)
    {
      setObjectVisible (b.allmenus[b.activemenu].items[b.newitem].tblSel, 1);
      b.activeitem = b.newitem;
      b.newitem = -1;
    }
    else
    {
      b.activeitem = -1;
      b.newitem = -1;
    }
  }
  else if (b.activemenu >=0)
  {
    var m = b.allmenus[b.activemenu];
    clearTimeout(b.timerHdr);
    hideMenu (bar, b.activemenu);

    if (m.fatherMenu != -1)
    {
      hideParentMenu (bar, m.fatherMenu, m.fatherMenuItem, -1);
    }
    else
    {
      setObjectVisible (m.items[0].tblSel, 0);
    }

    b.activemenu = -1;
    b.activeitem = -1;
    b.newitem = -1;
  }
}

function hideParentMenu (bar, menu, item, newmenu)
{
  var m=CTMenuBars[bar].allmenus[menu];

  if (m.items[item].enable)
     setObjectVisible (m.items[item].tblSel, 0);

  hideMenu (bar, menu);
  if (m.fatherMenu != newmenu)
     hideParentMenu (bar, m.fatherMenu, m.fatherMenuItem, newmenu);
  else
     setObjectVisible (m.items[0].tblSel, 0);
}

function overItem (bar, menu, item)
{
  var b = CTMenuBars[bar];
  var m = CTMenuBars[bar].allmenus[menu];

  if (b.activemenu == menu && b.activeitem == item)
  {
     // mesmo menu, mesmo item
     b.newmenu = -1;
     b.newitem = -1;
     if (b.timerHdr) clearTimeout(b.timerHdr);
  }
  else if (b.activemenu == menu)
  {
     // mesmo menu, outro item
     b.newmenu = -1;
     b.newitem = item;
     if (b.timerHdr) clearTimeout(b.timerHdr);
     b.timerHdr = setTimeout ("timeoutHdr("+bar+");",CTMENUTIMEOUT);
  }
  else
  {
     // outro menu, outro item
     b.newmenu = menu;
     b.newitem = item;
     if (b.timerHdr) clearTimeout(b.timerHdr);
     b.timerHdr = setTimeout ("timeoutHdr("+bar+");",CTMENUTIMEOUT);
  }
}

function outItem (bar, menu, item)
{
  var b = CTMenuBars[bar];
  b.newmenu = -1;
  b.newitem = -1;
  if (b.timerHdr) clearTimeout(b.timerHdr);
  b.timerHdr = setTimeout ("timeoutHdr("+bar+");",CTMENUTIMEOUT);
}

function clickItem (bar, menu, item)
{
  m=CTMenuBars[bar].allmenus[menu].items[item];
  if(m.link=="") return true;
  setObjectVisible (m.tblSel, 0);
  hideMenu (bar, menu);

  if(m.link.indexOf("javascript:")==0) eval(m.link);
  //else window.location.href=m.link;
  else top.open(m.link,"colortel");
  return true;
}

/* -------------------------------- */

function createMenu (bar, menu, level)
{
  var b, m, i, yy, str, height, j, sub;

  b = CTMenuBars[bar];
  m = CTMenuBars[bar].allmenus[menu];
  yy = m.menuY;

  str ='<div id="Menu'+bar+'Hdr'+menu+'Items" style="position:absolute;">\n';
  str+='<table id="Menu'+bar+'Hdr'+menu+'ItemsTbl"'+(m.menuWidth>0? ' width='+m.menuWidth:'')+' bgcolor='+b.itemBgColor+' cellpadding='+b.padding+' cellspacing=0>\n';
  str+='<tr>\n';
  str+='<td>\n';
  str+='&nbsp\n';
  str+='</td>\n';
  str+='</tr>\n';
  str+='</table>\n';
  str+='</div>\n';
  document.write (str);

  for (j=1; j<m.items.length; j++) {

    if (m.tpitems[j]==1) //sub-menu
    {
       i = m.items[j].items[0];
        switch (m.items[j].pos)
        {
          case 1:
            m.items[j].seta = 4;
            break;
          case 2:
            m.items[j].seta = 6;
            break;
          case 3:
            m.items[j].seta = 3;
            break;
          default:
            m.items[j].seta = 5;
            break;
        }
    }
    else    // item
    {
       i = m.items[j];
    }

    // ------------  tabela Item normal (nao selecionado): MenuXHdrXItemXNorm  -------------------

    str ='<div id="Menu'+bar+'Hdr'+menu+'Item'+j+'Norm" style="position:absolute;">\n';
    str+='<table id="Menu'+bar+'Hdr'+menu+'Item'+j+'NormTbl"'+(m.menuWidth>0? ' width='+m.menuWidth:'')+' bgcolor='+b.itemBgColor+' cellpadding='+b.padding+' cellspacing=0>\n';
    str+='<tr>\n';
    w = m.menuWidth;
    if (m.tpitems[j]==1)
    {
      // diminui a TD para colocar a seta
      w -= b.itemFontSize * 1.5;
      if (w<0)
        w=0;
    }
    str+='<td'+(w>0? ' width='+w:'')+' bgcolor='+b.itemBgColor+'>\n';
    if (i.enable) str+='<SPAN STYLE="color:'+b.itemEnbFgColor+';font-family:'+b.itemFontFamily+';font-size:'+b.itemFontSize+'pt;font-style:'+b.itemFontStyle+';font-weight:'+b.itemFontWeight+';">\n';
    else str+='<SPAN STYLE="color:'+b.itemDisFgColor+';font-family:'+b.itemFontFamily+';font-size:'+b.itemFontSize+'pt;font-style:'+b.itemFontStyle+';font-weight:'+b.itemFontWeight+';">\n';
    str+=i.text+'\n';
    str+='</SPAN>\n';
    str+='</td>\n';
    if (m.tpitems[j]==1) {
      str+='<td width='+ b.itemFontSize * 1.5 +' bgcolor='+b.itemBgColor+'>\n';
      if (i.enable) str+='<SPAN STYLE="color:'+b.itemEnbFgColor+';font-family: Webdings; font-size:'+(b.itemFontSize-1)+'pt;font-style:plain;font-weight:'+b.itemFontWeight+';">\n'; 
      else str+='<SPAN STYLE="align:right;color:'+b.itemDisFgColor+';font-family:Webdings;font-size:'+(b.itemFontSize-1)+'pt;font-style:plain;font-weight:'+b.itemFontWeight+';">\n';
      str+=m.items[j].seta+'\n';
      str+='</SPAN>\n';
      str+='</td>\n';
    }
    str+='</tr>\n';
    str+='</table>\n';
    str+='</div>\n';

    document.write (str);

    i.tblNorm = eval('Menu'+bar+'Hdr'+menu+'Item'+j+'Norm');
    height=getObjectHeight(i.tblNorm);
    if (m.menuDir < 0)
      yy -= height;
    i.tblNorm.style.left=(m.menuX+CTMENUSELBORDER)+'px';
    i.tblNorm.style.top=(yy+(m.menuDir*CTMENUSELBORDER))+'px';
    i.tblNorm.style.zIndex=b.z+level;
    i.tblNorm.style.visibility="hidden";
    i.tblNorm.style.pixelWidth = m.menuWidth;
    m.menuHeight+=height;

    if (i.enable)
    {
      // ------------  tabela Item Selecionado: MenuXHdrXItemXSel  -------------------

      str ='<div id="Menu'+bar+'Hdr'+menu+'Item'+j+'Sel" style="position:absolute;">\n';
      str+='<table id="Menu'+bar+'Hdr'+menu+'Item'+j+'SelTbl" width='+m.menuWidth+' bgcolor='+b.itemSelBgColor+' cellpadding='+b.padding+' cellspacing=0>\n';
      str+='<tr>\n';
      w = m.menuWidth;
      if (m.tpitems[j]==1)
      {
        // diminui a TD para colocar a seta
        w -= b.itemFontSize * 1.5;
        if (w<0)
          w=0;
      }
      str+='<td'+(w>0? ' width='+w:'')+' bgcolor='+b.itemSelBgColor+'>\n';
      str+='<SPAN STYLE="color:'+b.itemSelFgColor+';font-family:'+b.itemFontFamily+';font-size:'+b.itemFontSize+'pt;font-style:'+b.itemFontStyle+';font-weight:'+b.itemFontWeight+';">\n';
      str+=i.text+'\n';
      str+='</SPAN>\n';
      str+='</td>\n';
      if (m.tpitems[j]==1) {
        str+='<td width='+ b.itemFontSize * 1.5 +' bgcolor='+b.itemSelBgColor+'>\n';
        str+='<SPAN STYLE="color:'+b.itemSelFgColor+';font-family: Webdings; font-size:'+(b.itemFontSize-1)+'pt;font-style:plain;font-weight:'+b.itemFontWeight+';">\n'; 
        str+=m.items[j].seta+'\n'; 
        str+='</SPAN>\n';
        str+='</td>\n';
      }
      str+='</tr>\n';
      str+='</table>\n';
      str+='</div>\n';

      document.write (str);

      i.tblSel = eval('Menu'+bar+'Hdr'+menu+'Item'+j+'Sel');
      i.tblSel.style.left=(m.menuX+CTMENUSELBORDER)+'px';
      i.tblSel.style.top=(yy+(m.menuDir*CTMENUSELBORDER))+'px';
      i.tblSel.style.zIndex=b.z+level;
      i.tblSel.style.visibility="hidden";
      i.tblSel.style.pixelWidth = m.menuWidth;
    }


    // ------------  tabela Item Dummy: MenuXHdrXItemXDummy  -------------------

    str ='<div id="Menu'+bar+'Hdr'+menu+'Item'+j+'Dummy" style="position:absolute;">\n';
    str+='<table id="Menu'+bar+'Hdr'+menu+'Item'+j+'DummyTbl" width='+m.menuWidth+' cellpadding='+b.padding+' cellspacing=0>\n';
    str+='<tr>\n';
    str+='<td'+(m.menuWidth>0? ' width='+m.menuWidth:'')+' height='+height+'>\n';
    str+='<SPAN STYLE="color:'+b.itemEnbFgColor+';font-family:'+b.itemFontFamily+';font-size:'+b.itemFontSize+'pt;font-style:'+b.itemFontStyle+';font-weight:'+b.itemFontWeight+';">\n';
    str+='&nbsp;\n';
    str+='</SPAN>\n';
    str+='</td>\n';
    str+='</tr>\n';
    str+='</table>\n';
    str+='</div>\n';

    document.write (str);

    i.tblDummy = eval('Menu'+bar+'Hdr'+menu+'Item'+j+'Dummy');
    i.tblDummy.style.left=(m.menuX+CTMENUSELBORDER)+'px';
    i.tblDummy.style.top=(yy+(m.menuDir*CTMENUSELBORDER))+'px';
    i.tblDummy.style.zIndex=b.z+level;
    i.tblDummy.style.visibility="hidden";
    i.tblDummy.style.pixelWidth = m.menuWidth;
    i.tblDummy.style.pixelHeight = height;


    if (m.tpitems[j]==1) //sub-menu
    {
      sub = CTMenuBars[bar].allmenus.length;
      CTMenuBars[bar].allmenus[sub]=m.items[j];

      if (m.items[j].items.length > 1 && m.items[j].items[0].enable)
      {
        switch (m.items[j].pos)
        {
          case 1:
            m.items[j].menuX = m.menuX+m.menuWidth;
            m.items[j].menuY = yy;
            m.items[j].menuDir = 1;
            m.items[j].seta = 4;
            break;
          case 2:
            m.items[j].menuX = m.menuX;
            m.items[j].menuY = yy+height;
            m.items[j].menuDir = 1;
            m.items[j].seta = 6;
            break;
          case 3:
            m.items[j].menuX = m.menuX - m.items[j].menuWidth;
            m.items[j].menuY = yy;
            m.items[j].menuDir = 1;
            m.items[j].seta = 3;
            break;
          default:
            m.items[j].menuX = m.menuX;
            m.items[j].menuY = yy;
            m.items[j].menuDir = -1;
            m.items[j].seta = 5;
            break;
        }
        m.items[j].hdrX = m.menuX;
        m.items[j].hdrY = yy;
        m.items[j].hdrHeight = height;
        m.items[j].menuHeight = 0;
        m.items[j].fatherMenu = menu;
        m.items[j].fatherMenuItem = j;
        createMenu (bar, sub, level+1);
      }
      if (i.enable)
      {
         eval ('i.tblDummy.onmouseout=function () { outHdr('+bar+', '+sub+');}');
         eval ('i.tblDummy.onmouseover=function () { overHdr('+bar+', '+sub+');}');
         eval ('i.tblDummy.onclick=function () { clickItem ('+bar+', '+sub+', 0);}');
      }
      else
      {
         eval ('i.tblDummy.onmouseout=function () { outItem('+bar+', '+menu+', '+j+');}');
         eval ('i.tblDummy.onmouseover=function () { overItem('+bar+', '+menu+', '+j+');}');
      }
    }
    else //item
    {
      eval ('i.tblDummy.onmouseout=function () { outItem('+bar+', '+menu+', '+j+');}');
      eval ('i.tblDummy.onmouseover=function () { overItem('+bar+', '+menu+', '+j+');}');
      eval ('i.tblDummy.onclick=function () { clickItem ('+bar+', '+menu+', '+j+');}');
    }

    if (m.menuDir > 0)
      yy += height;
  }

  m.tblItems = eval('document.all.Menu'+bar+'Hdr'+menu+'Items');
  m.tblItems.style.left=m.menuX+'px';
  if (m.menuDir < 0)
     m.tblItems.style.top=(m.menuY-m.menuHeight-(CTMENUSELBORDER*2))+'px';
  else
     m.tblItems.style.top=m.menuY+'px';
  
  m.tblItems.style.zIndex=b.z+level;
  m.tblItems.style.borderWidth=CTMENUSELBORDER+"px";
  m.tblItems.style.borderStyle='inset';
  m.tblItems.style.pixelWidth=m.menuWidth;
  m.tblItems.style.pixelHeight=m.menuHeight + (CTMENUSELBORDER*2);
  m.tblItems.style.visibility="hidden";


}

function CTMenuItem (text, link, enable){
 this.text=text;
 this.link=link;
 this.enable=enable;
}

function CTMenu (hdrWidth, menuWidth, pos){
 this.hdrWidth=hdrWidth;
 this.menuWidth=menuWidth;
 this.pos=pos;
 this.items=new Array();
 this.tpitems=new Array();
 this.hideObjects=new Array();
 this.hideObjectsId=new Array();
 this.addItem=CTMenuAddItem;
 this.addSubMenu=CTMenuAddSubMenu;
 this.addObjectId=CTMenuAddObjectId;
}

function CTMenuAddItem(item){
 this.items[this.items.length]=item;
 this.tpitems[this.tpitems.length] = 0;
}

function CTMenuAddSubMenu(menu){
 this.items[this.items.length]=menu;
 this.tpitems[this.tpitems.length] = 1;
}

function CTMenuAddObjectId(object){
 this.hideObjectsId[this.hideObjectsId.length]=object;
}

function CTMenuBar (width, cor_menu, cor_selecionado){
//function CTMenuBar (width){
 
 //cor_menu='#008FDF';
 //cor_selecionado='#004080';
 
 this.created=false;
 this.x=0;
 this.y=0;
 this.z=3;
 this.width=width;
 this.topmenus=new Array();
 this.allmenus=new Array();
 this.padding=1;
 this.hdrEnbFgColor="#FFFFFF";
 this.hdrDisFgColor="#888888";
 //this.hdrBgColor="#008FDF";   //Cor do Menu: azul claro
 this.hdrBgColor=cor_menu; 
 this.hdrSelFgColor="#FFFFFF";
 //this.hdrSelBgColor="#004080";   //Cor do Menu Selecionado: azul escuro
 this.hdrSelBgColor=cor_selecionado;   
 this.itemEnbFgColor="#FFFFFF";
 this.itemDisFgColor="#888888";
 this.itemBgColor=cor_menu;
 this.itemSelFgColor="#FFFFFF";
 this.itemSelBgColor=cor_selecionado;  

 this.hdrFontFamily="Verdana";
 this.hdrFontStyle="plain";
 this.hdrFontWeight="bold";
 this.hdrFontSize="8";
 this.itemFontFamily="Verdana";
 this.itemFontStyle="plain";
 this.itemFontWeight="bold";
 this.itemFontSize="8";
 this.addMenu=CTMenuBarAddMenu;
 this.create=CTMenuBarCreate;
 this.index=CTMenuBars.length;
 this.activemenu=-1;
 this.newmenu=-1;
 this.activeitem=-1;
 this.newitem=-1;
 this.timerHdr="";
 CTMenuBars[this.index]=this;
}


function CTMenuBarAddMenu(menu){
 if(!this.created)
  this.topmenus[this.topmenus.length]=menu;
}

function CTMenuBarCreate(){
 var item, row;
 var m;
 var i, j;
 var x, y;

 if(this.created) return;

 x = this.x;
 y = this.y;

 // -------------  tabela de fundo: MenuXBg  -------------------

 str ='<div id="Menu' + this.index + 'Bg" style="position:absolute;">\n';
 str+='<table id="Menu' + this.index + 'Bgtbl" width='+this.width+' bgcolor='+this.hdrBgColor+' cellpadding='+(this.padding+CTMENUSELBORDER)+' cellspacing=0>\n';

 str+='<tr>\n';
 str+='<td'+(this.width>0? ' width='+this.width:'') + ' style="color:'+this.hdrBgColor+';font-family:'+this.hdrFontFamily+';font-size:'+this.hdrFontSize+'pt;font-style:'+this.hdrFontStyle+';font-weight:'+this.hdrFontWeight+';" bgcolor='+this.hdrBgColor+'>\n';
 str+='&nbsp\n';
 str+='</td>\n';
 str+='</tr>\n';
 str+='</table>\n';
 str+='</div>\n';

 document.write (str);

 tblBg = eval ('document.all.Menu' + this.index + 'Bg');
 tblBg.style.left=this.x+'px';
 tblBg.style.top=this.y+'px';
 tblBg.style.zIndex=this.z;
 tblBg.style.visibility="hidden";


 // -------------  processando menus  -------------------

 for(i=0;i<this.topmenus.length;i++) {

  m = this.topmenus[i];

  menu = this.allmenus.length;
  this.allmenus[menu]=m;


  // ------------  tabela Header normal (nao selecionado): MenuXHdrXNorm  -------------------

  str ='<div id="Menu'+this.index+'Hdr'+menu+'Norm" style="position:absolute">\n';
  str+='<table id="Menu'+this.index+'Hdr'+menu+'NormTbl" bgcolor='+this.hdrBgColor+' width='+m.hdrWidth+'px cellpadding='+(this.padding+CTMENUSELBORDER)+' cellspacing=0>\n';
  str+='<tr>\n';
  str+='<td'+(m.hdrWidth>0? ' width='+m.hdrWidth:'')+' bgcolor='+this.hdrBgColor+'>\n';
  if (m.items[0].enable) str+='<SPAN STYLE="color:'+this.hdrEnbFgColor+';font-family:'+this.hdrFontFamily+';font-size:'+this.hdrFontSize+'pt;font-style:'+this.hdrFontStyle+';font-weight:'+this.hdrFontWeight+';">\n';
  else str+='<SPAN STYLE="color:'+this.hdrDisFgColor+';font-family:'+this.hdrFontFamily+';font-size:'+this.hdrFontSize+'pt;font-style:'+this.hdrFontStyle+';font-weight:'+this.hdrFontWeight+';">\n';
  str+=m.items[0].text+'\n';
  str+='</SPAN>\n';
  str+='</td>\n';
  str+='</tr>\n';
  str+='</table>\n';
  str+='</div>\n';

  document.write (str);

  m.items[0].tblNorm = eval('Menu'+this.index+'Hdr'+menu+'Norm');
  m.items[0].tblNorm.style.left=x+'px';
  m.items[0].tblNorm.style.top=y+'px';
  m.items[0].tblNorm.style.zIndex=this.z;
  m.items[0].tblNorm.style.pixelWidth=m.hdrWidth;
  m.hdrX=x;
  m.hdrY=y;
  m.hdrHeight=getObjectHeight(m.items[0].tblNorm);

  if (m.items[0].enable)
  {
     // ------------  tabela Header Selecionado: MenuXHdrXSel  -------------------

     str ='<div id="Menu'+this.index+'Hdr'+menu+'Sel" style="position:absolute;">\n';
     str+='<table id="Menu'+this.index+'Hdr'+menu+'SelTbl" width='+(m.hdrWidth-(CTMENUSELBORDER*2))+'px bgcolor='+this.hdrSelBgColor+' cellpadding='+this.padding+' cellspacing=0>\n';
     str+='<tr>\n';

     str+='<td'+(m.hdrWidth>0? ' width='+(m.hdrWidth-(CTMENUSELBORDER*2))+'px':'')+' bgcolor='+this.hdrBgColor+'>\n';
     str+='<SPAN STYLE="color:'+this.hdrEnbFgColor+';font-family:'+this.hdrFontFamily+';font-size:'+this.hdrFontSize+'pt;font-style:'+this.hdrFontStyle+';font-weight:'+this.hdrFontWeight+';">\n';
     str+=m.items[0].text+'\n';
     str+='</SPAN>\n';
     str+='</td>\n';
     str+='</tr>\n';
     str+='</table>\n';
     str+='</div>\n';

     document.write (str);

     m.items[0].tblSel = eval('document.all.Menu'+this.index+'Hdr'+menu+'Sel');
     m.items[0].tblSel.style.left=x+'px';
     m.items[0].tblSel.style.top=y+'px';
     m.items[0].tblSel.style.zIndex=this.z;
     m.items[0].tblSel.style.borderWidth=CTMENUSELBORDER+"px";
     m.items[0].tblSel.style.borderStyle='inset';
     m.items[0].tblSel.style.pixelWidth=m.hdrWidth-(CTMENUSELBORDER*2);
     m.items[0].tblSel.style.visibility="hidden";
  }
  // ------------  tabela Header Dummy: MenuXHdrXDummy  -------------------

  str ='<div id="Menu'+this.index+'Hdr'+menu+'Dummy" style="position:absolute;">\n';
  str+='<table id="Menu'+this.index+'Hdr'+menu+'DummyTbl" width='+m.hdrWidth+' cellpadding='+(this.padding+CTMENUSELBORDER)+' cellspacing=0>\n';
  str+='<tr>\n';
  str+='<td'+(m.hdrWidth>0? ' width='+m.hdrWidth:'')+'>\n';
  str+='<SPAN STYLE="color:'+this.hdrEnbFgColor+';font-family:'+this.hdrFontFamily+';font-size:'+this.hdrFontSize+'pt;font-style:'+this.hdrFontStyle+';font-weight:'+this.hdrFontWeight+';">\n'
  str+='&nbsp;\n';
  str+='</SPAN>\n'
  str+='</td>\n'
  str+='</tr>\n'
  str+='</table>\n'
  str+='</div>\n';

  document.write (str);

  m.items[0].tblDummy = eval('document.all.Menu'+this.index+'Hdr'+menu+'Dummy');
  m.items[0].tblDummy.style.left=x+'px';
  m.items[0].tblDummy.style.top=y+'px';
  m.items[0].tblDummy.style.zIndex=this.z;
  m.items[0].tblDummy.style.visibility="visible";
  m.items[0].tblDummy.style.pixelWidth=m.hdrWidth;
  m.items[0].tblDummy.style.pixelHeight=m.hdrHeight;
  eval ('m.items[0].tblDummy.onmouseout=function () { outHdr('+this.index+', '+menu+');}');
  if (m.items[0].enable)
  {
    eval ('m.items[0].tblDummy.onmouseover=function () { overHdr('+this.index+','+menu+');}');
    eval ('m.items[0].tblDummy.onclick=function () { clickItem ('+this.index+', '+menu+', 0);}');
  }

  m.menuHeight=0;
 
  m.fatherMenu = -1;
  m.fatherMenuItem = -1;
  if (m.items.length > 1 && m.items[0].enable)
  {
    switch (m.pos)
    {
      case 1:
        m.menuX = x+m.hdrWidth;
        m.menuY = m.hdrY;
        m.menuDir = 1;
        m.seta = 4;
        break;
      case 2:
        m.menuX = x;
        m.menuY = m.hdrY+m.hdrHeight;
        m.menuDir = 1;
        m.seta = 5;
        break;
      case 3:
        m.menuX = x - m.menuWidth;
        m.menuY = m.hdrY;
        m.menuDir = 1;
        m.seta = 3;
        break;
      default:
        m.menuX = x;
        m.menuY = m.hdrY;
        m.menuDir = -1;
        m.seta = 6;
        break;
    }
    createMenu (this.index, menu, 1);
  }

  x+=m.hdrWidth;
 }

 /* ajusta o tamanho do background */

 if(this.topmenus.length > 0) {
  tblBg.style.pixelWidth = this.width;
  tblBg.style.pixelHeight = this.topmenus[0].hdrHeight;
  tblBg.style.visibility="visible";
 }
 this.created = true;
}
