   function bd_Browser() {

       var ua, s, i;

       this.isIE    = false;  // Internet Explorer
               this.isNS    = false;  // Netscape
               this.version = null;

               ua = navigator.userAgent;

               s = "MSIE";
               if ((i = ua.indexOf(s)) >= 0) {
                   this.isIE = true;
                   this.version = parseFloat(ua.substr(i + s.length));
                   return;
               }

               s = "Netscape6/";
               if ((i = ua.indexOf(s)) >= 0) {
                   this.isNS = true;
                   this.version = parseFloat(ua.substr(i + s.length));
                   return;
               }

               // Treat any other "Gecko" browser as NS 6.1.

               s = "Gecko";
               if ((i = ua.indexOf(s)) >= 0) {
                   this.isNS = true;
                   this.version = 6.1;
                   return;
               }
       }

       var browser = new bd_Browser();

       // Global variable for tracking the currently active button.

       var bdactiveButton = null;

       // Capture mouse clicks on the page so any active button can be
       // deactivated.


               function bd_pageMousedown(event) {

               var el;

               // If there is no active menu, exit.

               if (!bdactiveButton)
                   return;

              // Find the element that was clicked on.

              if (browser.isIE)
                  el = window.event.srcElement;
              if (browser.isNS)
                  el = (event.target.className ? event.target : event.target.parentNode);

              // If the active button was clicked on, exit.

              if (el == bdactiveButton)
                  return;

              // If the element clicked on was not a menu button or item, close the
              // active menu.

              if (el.className != "bd_menu"  && el.className != "bd_catActive" &&
                  el.className != "bd_co" && el.className != "bd_wh" && el.type != 'a' && el.className != 'bd_shead')
                  bd_resetButton(el);
              }

function bd_buttonClick(bdbutton, menuName) {

    // Blur focus from the link to remove that annoying outline.

    bdbutton.blur();

    // Associate the named menu to this button if not already done.

  if (!bdbutton.menu)
  {
    bdbutton.menu = document.getElementById(menuName);

    if (menuName == "topicmenu")
    {
        document.getElementById("tbutton1").className = "bd_catActive";
    }
    if (menuName == "options")
    {
        document.getElementById("tbutton2").className = "bd_catActive";
    }
  }

  // Reset the currently active button, if any.

  if (bdactiveButton && bdactiveButton != bdbutton)
    bd_resetButton(bdactiveButton);

  // Toggle the button's state.

  if (bdbutton.isDepressed)
    bd_resetButton(bdbutton);
  else
    bd_depressButton(bdbutton);

  return false;
}

function bd_buttonMouseover(bdbutton, menuName) {

  // If any other button menu is active, deactivate it and activate this one.
  // Note: if this button has no menu, leave the active menu alone.

  if (bdactiveButton && bdactiveButton != bdbutton) {
    bd_resetButton(bdactiveButton);
    if (menuName)
      bd_buttonClick(bdbutton, menuName);
  }
}

function bd_depressButton(bdbutton) {

  var w, dw, x, y;

  // Change the button's style class to make it look like it's depressed.

  bdbutton.className = "catmenuActive";

  // For IE, set an explicit width on the first menu item. This will
  // cause link hovers to work on all the menu's items even when the
  // cursor is not over the link's text.

  if (browser.isIE && !bdbutton.menu.firstChild.style.width) {
    w = bdbutton.menu.firstChild.offsetWidth;
    bdbutton.menu.firstChild.style.width = w + "px";
    dw = bdbutton.menu.firstChild.offsetWidth - w;
      w -= dw;
      bdbutton.menu.firstChild.style.width = w + "px";
    }

    // Position the associated drop down menu under the button and
    // show it. Note that the position must be adjusted according to
    // browser, styling and positioning.

    x = getPageOffsetLeft(bdbutton);
    y = getPageOffsetTop(bdbutton) + bdbutton.offsetHeight;
    if (browser.isIE) {
      x += 2;
      y += 2;
    }
    if (browser.isNS && browser.version < 6.1)
      y--;

    if (bdbutton.menu.id == "topicmenu")
    {
        x = x - 25;
    }
    if (bdbutton.menu.id == "options")
    {
        x = x - 157;
    }
    // Position and show the menu.

    bdbutton.menu.style.left = x + "px";
    bdbutton.menu.style.top  = y + "px";
    bdbutton.menu.style.visibility = "visible";

    // Set button state and let the world know which button is
    // active.

    bdbutton.isDepressed = true;
    bdactiveButton = bdbutton;
    }

function bd_resetButton(bdbutton) {

    // Restore the button's style class.

    document.getElementById("tbutton1").className = "bd_catmenu";
    document.getElementById("tbutton2").className = "bd_catmenu";

    // Hide the button's menu.
     if (bdbutton.menu)
       bdbutton.menu.style.visibility = "hidden";

     // Set button state and clear active menu global.

     bdbutton.isDepressed = false;
     bdactiveButton = null;

     }

     function bd_getPageOffsetLeft(el) {

     // Return the true x coordinate of an element relative to the page.

       return el.offsetLeft + (el.offsetParent ? getPageOffsetLeft(el.offsetParent) : 0);
     }

     function bd_getPageOffsetTop(el) {

     // Return the true y coordinate of an element relative to the page.

     return el.offsetTop + (el.offsetParent ? getPageOffsetTop(el.offsetParent) : 0);
     }

