

SolpartMenu.prototype.GenerateMenuHTML = function (oXML)
{
  __db(this._m_oMenu.id + ' - GenerateMenuHTML');

  var sHTML = '';
  this._m_sOuterTables = '';

  if (oXML == null)
  {
    if (this._m_oDOM == null)
    {
      oXML = spm_createDOMDoc();
      this._m_oDOM = oXML;
            
      if (this.xml.length)
      {
        oXML.loadXML(this.xml);
      }

      if (this.xmlFileName.length)
      {
        oXML.onload = eval('onxmlload' + this._m_sNSpace); 
        oXML.load(this.xmlFileName);
        return;
      }
    }
  }
  else
  {
    this._m_oDOM = oXML;
  }

  if (this.display == "vertical")
  {
    sHTML += '<table id="tbl' + this._m_sNSpace + 'MenuBar" cellpadding=\'0\' cellspacing=\'0\' border="0" class="' + spm_fixCSSForMac(this.getIntCSSName('spmbctr') + this.cssMenuContainer) + '" height="100%" style="vertical-align: middle;">';
    sHTML += MyIIf(this.MBLeftHTML.length, '<tr><td>' + this.MBLeftHTML + '</td></tr>', '');
    sHTML += MyIIf(Number(this.moveable), '<tr><td id="td' + this._m_sNSpace + 'MenuMove" height=\'3px\' style=\'cursor: move; ' + spm_getMenuBorderStyle(this) + '\'>' + spm_getSpacer(this) + '</td></tr>', '');
    sHTML +=         this.GetMenuItems(this._m_oDOM.documentElement);
    sHTML += '       <tr><td height="100%">' + spm_getSpacer(this) + '</td>';
    sHTML += '   </tr>';
    sHTML += MyIIf(this.MBRightHTML.length, '<tr><td>' + this.MBRightHTML + '</td></tr>', '');
    sHTML += '</table>';
  }
  else
  {
    sHTML += '<table id="tbl' + this._m_sNSpace + 'MenuBar" cellpadding=\'0\' cellspacing=\'0\' border="0" class="' + spm_fixCSSForMac(this.getIntCSSName('spmbctr') + this.cssMenuContainer) + '" style="vertical-align: middle;">';
    sHTML += '  <tr>';
    sHTML += MyIIf(this.MBLeftHTML.length, '<td>' + this.MBLeftHTML + '</td>', '');
    sHTML += MyIIf(Number(this.moveable), '       <td id="td' + this._m_sNSpace + 'MenuMove" width=\'3px\' style=\'cursor: move; ' + spm_getMenuBorderStyle(this) + '\'>' + spm_getSpacer(this) + '</td>', '');
    sHTML += spm_getMenuSpacingImage('left', this);
    sHTML +=         this.GetMenuItems(this._m_oDOM.documentElement);
    sHTML += spm_getMenuSpacingImage('right', this);
    sHTML += MyIIf(this.MBRightHTML.length, '<td>' + this.MBRightHTML + '</td>', '');
    sHTML += '   </tr>';
    sHTML += '</table>';
  }

  this._m_oMenu.innerHTML = sHTML;
  this.GenerateSubMenus();
  this._m_oMenuMove = spm_getById('td' + this._m_sNSpace + 'MenuMove');

  spm_getTags("BODY")[0].onclick = spm_appendFunction(spm_getTags("BODY")[0].onclick, 'm_oSolpartMenu["' + this._m_sNSpace + '"].bodyclick();');
  this._m_oTblMenuBar = spm_getById('tbl' + this._m_sNSpace + 'MenuBar'); 
  this.fireEvent('onMenuComplete');

  __db(this._m_oMenu.id + ' - GenerateMenuHTML end');
}

SolpartMenu.prototype.GetMenuItems = function (oParent)
{
  var oNode;
  var sHTML = '';
  var sID;
  var sParentID;
  var sClickAction;

  if (oParent)
  {
    for (var i = 0; i < oParent.childNodes.length; i++)
    {
      oNode = oParent.childNodes[i];

      if ((oNode.nodeType != 3) && (oNode.nodeType != 8))
      {
        if (oNode.parentNode.nodeName != "menuitem")
        {
          sParentID = "-1";
        }
        else
        {
          sParentID = oNode.parentNode.getAttribute("id");
        }

        if (oNode.nodeName == "menuitem")
        {
          sID = oNode.getAttribute("id");
        }
        else
        {
          sID = "";
        }

        __db(sID + ' getmenuitems');
        sClickAction = spm_getMenuClickAction(oNode, this);

        if (sParentID == "-1")
        {
          if (this.display == "vertical")
          {
            sHTML += "<tr>";
          }

          if (oNode.nodeName == 'menubreak')
          {
            if (this.display == "vertical")
            {
              sHTML += "<tr>";
            }

            var sBreakHTML = spm_getAttr(oNode, 'lefthtml', '') + spm_getAttr(oNode, 'righthtml', '');
            if (sBreakHTML.length > 0)
            {
              sHTML += '   <td class="' + spm_fixCSSForMac(this.getIntCSSName('spmbrk') + this.cssMenuBreak) + '">' + sBreakHTML + '</td>';
            }
            else
            {
              sHTML += '   <td class="' + spm_fixCSSForMac(this.getIntCSSName('spmbrk') + this.cssMenuBreak) + '">' + spm_getMenuImage('spacer.gif', this, true, ' ') + '</td>';
            }

            if (this.display == "vertical")
            {
              sHTML += "</tr>";
            }
          }
          else
          {
            sHTML += '<td><table cellpadding="0" cellspacing="0" border="0"><tr id="td' + this._m_sNSpace + sID + '" ' + spm_getMenuBarEvents(this._m_sNSpace) + '  class="' + spm_fixCSSForMac(this.getIntCSSName('spmbar spmitm') + this.cssMenuBar + ' ' + this.cssMenuItem + ' ' + spm_getMenuItemCSS(oNode)) + '" savecss="' + spm_getMenuItemCSS(oNode) + '" saveselcss="' + spm_getMenuItemSelCSS(oNode) + '" menuclick="' + sClickAction + '" style="' + spm_getMenuItemStyle('item', oNode) + '">';
            var sAlign = this.display=='vertical' ? 'align="' + this.menuAlignment + '"' : '';
            sHTML += '<td unselectable="on" nowrap="nowrap" ' + sAlign + ' title="' + spm_getAttr(oNode, 'tooltip', '') + '">' + spm_getImage(oNode, this) + spm_getItemHTML(oNode, 'left', '') + spm_getAttr(oNode, 'title', '') + spm_getItemHTML(oNode, 'right') + MyIIf(Number(this.rootArrow) && spm_nodeHasChildren(oNode), '</td><td align="right" class="' + spm_fixCSSForMac(this.getIntCSSName('spmrarw') + this.cssMenuRootArrow) + '">' + spm_getArrow(this.rootArrowImage, this) + "", '') + '</td></tr></table></td>';
          }

          if (this.display == "vertical")
          {
            sHTML += "</tr>";
          }
        }
        else
        {
          switch(oNode.nodeName)
          {
            case ("menuitem"):
            {
              sHTML +=    '   <tr id="tr' + this._m_sNSpace + sID + '" ' + spm_getMenuItemEvents(this._m_sNSpace) + ' parentID="' + sParentID + '" class="' + spm_fixCSSForMac(this.getIntCSSName('spmitm') + this.cssMenuItem + ' ' + spm_getMenuItemCSS(oNode)) + '" savecss="' + spm_getMenuItemCSS(oNode) + '" saveselcss="' + spm_getMenuItemSelCSS(oNode) + '" menuclick="' + sClickAction + '" style="' + spm_getMenuItemStyle('item', oNode) + '">';
              sHTML +=    '       <td unselectable="on" id="icon' + this._m_sNSpace + sID + '" class="' + spm_fixCSSForMac(this.getIntCSSName('spmicn') + this.cssMenuIcon) + '" style="' + spm_getMenuItemStyle('image', oNode) + '; ' + spm_getMenuItemStyle('item', oNode) + '">' + spm_getImage(oNode, this) + '</td>';
              sHTML +=    '       <td unselectable="on" id="td' + this._m_sNSpace + sID + '" class="' + spm_fixCSSForMac(this.getIntCSSName('spmitm') + this.cssMenuItem + ' ' + spm_getMenuItemCSS(oNode)) + '" savecss="' + spm_getMenuItemCSS(oNode) + '" nowrap="nowrap" TITLE="' + spm_getAttr(oNode, 'tooltip', '') + '" style="' + spm_getMenuItemStyle('item', oNode) + '">' + spm_getItemHTML(oNode, 'left', '') + spm_getAttr(oNode, 'title', '') + spm_getItemHTML(oNode, 'right', '') + '</td>';
              sHTML +=    '       <td unselectable="on" id="arrow' + this._m_sNSpace + sID + '" width="15px" CLASS="' + spm_fixCSSForMac(this.getIntCSSName('spmarw') + this.cssMenuArrow) + '" style="' + spm_getMenuItemStyle('item', oNode) + '">' + MyIIf(spm_nodeHasChildren(oNode), spm_getArrow(this.arrowImage, this), spm_getSpacer(this)) + '</td>';
              sHTML +=    '   </tr>';

              break;
            }
            case ("menubreak"):
            {
              var sBreakHTML = spm_getAttr(oNode, 'lefthtml', '') + spm_getAttr(oNode, 'righthtml', '');
              if (sBreakHTML.length > 0)
              {
                sHTML += '<tr><td colspan="3" class="' + spm_fixCSSForMac(this.getIntCSSName('spmbrk') + this.cssMenuBreak) + '">' + sBreakHTML + '</td></tr>';
              }
              else
              {
                sHTML += '<tr><td style="height: 1px" class="' + spm_fixCSSForMac(this.getIntCSSName('spmicn') + this.cssMenuIcon) + '">' + spm_getMenuImage('spacer.gif', this, true, '') + '</td><td colspan="2" class="' + spm_fixCSSForMac(this.getIntCSSName('spmbrk') + this.cssMenuBreak) + '">' + spm_getMenuImage('spacer.gif', this, true, '') + '</td></tr>';
              }

              break;
            }
          }
        }

        if (oNode.childNodes.length > 0)
        {
          var sTag = 'div';
          var sStyle = '';

          if (spm_isMac('ie'))
          {
            sTag = 'p';
            sStyle = 'margin-top:0px; margin-left:0px;'
          }

          this._m_sOuterTables = '<' + sTag + ' id="tbl' + this._m_sNSpace + sID + '" class="' + spm_fixCSSForMac(this.getIntCSSName('spmsub') + this.cssSubMenu) + '" style="display:none; position: absolute;' + sStyle + this.menuTransitionStyle + '"><table cellpadding="0" cellspacing="0" border="0">' + this.GetMenuItems(oNode) + '</table></' + sTag + '>' + this._m_sOuterTables;
        }

      }
    }
  }

  return (sHTML);
}

function spm_getHTMLImage(sImage, sPath, bForce, sAlt)
{
  if ((spm_browserNeedsSpacer() == false) && (sImage == 'spacer.gif') && (bForce != true))
  {
    return ('');
  }
  else
  {
    return ("<img src=\"" + sPath + sImage + "\" " + spm_getAlt(sAlt) + ">");
  }
}

function spm_getElementHeight(o)
{
  if (o.offsetHeight == null || o.offsetHeight == 0)
  {
    if (o.offsetParent)
    {
      if (o.offsetParent.offsetHeight == null || o.offsetParent.offsetHeight == 0)
      {
        if (o.offsetParent.offsetParent != null)
        {
          return (o.offsetParent.offsetParent.offsetHeight);
        }
        else
        {
          return (0);
        }
      }
      else
      {
        return (o.offsetParent.offsetHeight);
      }
    }
  }
  else
  {
    return (o.offsetHeight);
  }
}

function spm_getElementWidth(o)
{
  if (o.offsetWidth == null || o.offsetWidth == 0)
  {
    if (o.offsetParent)
    {
      if (o.offsetParent.offsetWidth == null || o.offsetParent.offsetWidth == 0)
      {
        if (o.offsetParent.offsetParent != null)
        {
          return (o.offsetParent.offsetParent.offsetWidth);
        }
        else
        {
          return (0);
        }
      }
      else
      {
        return (o.offsetParent.offsetWidth);
      }
    }
  }
  else
  {
    return (o.offsetWidth);
  }
}

function spm_getMenuBarEvents(sCtl)
{
  return ('onmouseover="m_oSolpartMenu[\'' + sCtl + '\'].onMBMO(this);" onmouseout="m_oSolpartMenu[\'' + sCtl + '\'].onMBMOUT(this);" onclick="m_oSolpartMenu[\'' + sCtl + '\'].onMBC(this, event);" onmousedown="m_oSolpartMenu[\'' + sCtl + '\'].onMBMD(this);" onmouseup="m_oSolpartMenu[\'' + sCtl + '\'].onMBMU(this);"');
}

function spm_getMenuItemEvents(sCtl)
{
  return ('onmouseover="m_oSolpartMenu[\'' + sCtl + '\'].onMBIMO(this);" onmouseout="m_oSolpartMenu[\'' + sCtl + '\'].onMBIMOUT(this);" onclick="m_oSolpartMenu[\'' + sCtl + '\'].onMBIC(this, event);"');
}

function spm_iFrameIndex(eMenu, bShow, sysImgPath) {
    if (spm_browserType() == "op") {
        return;
    }

    if (document.readyState != "complete") {
        return;
    }

    if (bShow) {
        var oIFR = spm_getById("ifr" + eMenu.id);
        if (oIFR == null) {
            var oIFR = document.createElement("iframe");
            oIFR.id = "ifr" + eMenu.id;
            oIFR.src = sysImgPath + "spacer.gif";
            oIFR.style.top = spm_getCoord(0);
            oIFR.style.left = spm_getCoord(0);
            oIFR.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=0)";
            oIFR.scrolling = "no";
            oIFR.frameBorder = "no";
            oIFR.style.display = "none";
            oIFR.style.position = "absolute";
            document.body.appendChild(oIFR);
        }

        var oMDims = new spm_elementDims(eMenu);

        oIFR.style.width = oMDims.w;
        oIFR.style.height = oMDims.h;
        oIFR.style.top = spm_getCoord(oMDims.t);
        oIFR.style.left = spm_getCoord(oMDims.l);

        var iIndex = spm_getCurrentStyle(eMenu, "zIndex");

        if (iIndex == null || iIndex == 0 || isNaN(null) || iIndex == "auto") {
            iIndex = 0;
            eMenu.style.zIndex = 1;
        }

        oIFR.style.zIndex = iIndex - 1;
        oIFR.style.display = "block";
    }
    else if (spm_getById("ifr" + eMenu.id) != null) {
        spm_getById("ifr" + eMenu.id).style.display = "none";
    }
}

