function getElementsByClass (searchClass, node, tag) {
  var classElements = new Array();
  if (node == null)
    node = document;
  if (tag == null)
    tag = '*';
  var els = node.getElementsByTagName (tag);
  var elsLen = els.length;
  var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
  for (i = 0, j = 0; i < elsLen; i++) {
    if (pattern.test (els[i].className) ) {
      classElements[j] = els[i];
      j++;
    }
  }
  return classElements;
}

// fix hover in dropdown menus for MSIE
// not active: fix first-child and last-child for MSIE
// annotate alternating menu choices for all browsers
// send people with MSIE 5/MacOS away

function fixupDropdown () {
  if ((navigator.appVersion.indexOf('MSIE 5') != -1)
   && (navigator.platform.indexOf('Mac') != -1)) {
    alert ('Sorry, we cannot support your browser. In June 2003, the Microsoft Macintosh Business Unit announced that Internet Explorer for Mac would undergo no further development, and support would cease in 2005.');
    document.location.href = 'http://www.microsoft.com/Mac/ie/';
  }

  var needHover = (document.all&&document.getElementById);
  var debug = 0;

  var menuDivs = getElementsByClass ("menuDropdown", null, "div");
  if (debug) {alert ("Divs "+menuDivs.length);}

  for (md=0; md < menuDivs.length; md++) {
    var menuLists = menuDivs[md].childNodes[0].getElementsByTagName ("ul");
    if (debug) {alert ("Lists "+menuLists.length);}

    var menuBar = menuDivs[0].childNodes[0].childNodes;
    // if necesssary to mark the top UL
    // menuDivs[0].childNodes[0].id = 'menuBar';
    // menuDivs[0].childNodes[0].className = 'menuBar';
    var mbx = -1;
    for (mb=0; mb < menuBar.length; mb++) {
      var node = menuBar [mb];
      if (node.nodeName == "LI") {
        node.className += ' menuBar';
        node.style.zIndex = (menuBar.length - mb);
        if (mbx == -1) {
          node.id = 'firstMenu';
        }
        mbx = mb;
      }
    }
    menuBar[mbx].id = 'lastMenu';

    for (ml=0; ml < menuLists.length; ml++) {
      var menuChoices = menuLists[ml].getElementsByTagName ("li");
      if (debug) {alert ("Choices "+menuChoices.length);}
      for (i=0; i < menuChoices.length; i++) {
        var node = menuChoices [i];
        node.className += ' o'+((i+1)%2);
      }
    }

    if (needHover) {
      var menuItems = menuDivs[md].childNodes[0].getElementsByTagName ("li");
      if (debug) {alert ("Items "+menuItems.length);}
      for (i=0; i < menuItems.length; i++) {
        var node = menuItems [i];
        if (node.className.indexOf ("menuBar") == -1) {
          node.onmouseover = function() {
            this.className += " over";
          }
          node.onmouseout = function() {
            this.className = this.className.replace(" over", "");
          }
        } else {
          node.onmouseover = function() {
            this.className += " menuBarOver";
          }
          node.onmouseout = function() {
            this.className = this.className.replace(" menuBarOver", "");
          }
        }
      }
    }
  }
}

