attachOnload(function() {
  var prod = document.getElementById('prod');
      prod.sections = [];

  var prodhead = document.getElementById('prodhead');

  var prodmenu = document.createElement('ul');
      prodmenu.id = "prodmenu";

  for (var x = 0, i = 0, heading; x < prod.childNodes.length; x++) {
    if (prod.childNodes[x].nodeName == "DIV" && prod.childNodes[x].className == "prodsection") {
      i++;

      var li = document.createElement('li');
          li.title = prod.childNodes[x].getAttribute('title');
          li.sibling = prod.childNodes[x];
          li.sections = prod.sections;
        var a = document.createElement('a');
            a.appendChild(document.createTextNode(li.title));
            a.location = "#" + prod.childNodes[x].id;
            a.href = window.location.href.replace(/#.*?$/, "") + "#" + prod.childNodes[x].id;
            a.onclick = function() {
              var menu = this.parentNode.parentNode.getElementsByTagName('li');
              for (var y = 0; y < this.parentNode.sections.length; y++) {
                this.parentNode.sections[y].style.display = "none";
                this.parentNode.sections[y].style.opacity = 0; // transition
                menu[y].className = "";
              }
              this.parentNode.sibling.style.display = "block";

              // Cause a reflow for Chrome/Firefox
              var reflow = this.parentNode.sibling.offsetTop;

              this.parentNode.sibling.style.opacity = 1; // transition
              this.parentNode.className = "selected";
              if (isIE6) {
                document.body.style.height = "auto";
                document.body.style.height = document.body.offsetHeight + "px";
              }
              window.scrollTo(0, 0);
              return false;
            };
          li.appendChild(a);

        for (var y = 0; y < prod.childNodes[x].childNodes.length; y++) {
          if (prod.childNodes[x].childNodes[y].nodeName == "#text") continue;
          if (prod.childNodes[x].childNodes[y].nodeName == "H5") {
            heading = prod.childNodes[x].childNodes[y];
            li.title = heading.firstChild.nodeValue;
            prod.childNodes[x].removeChild(heading);
          } break;
        }

        prodmenu.insertBefore(li, prodmenu.firstChild);

      prod.sections.push(prod.childNodes[x]);
      prod.childNodes[x].style.display = "none";
      prod.childNodes[x].style.opacity = 0; // transition
      prod.childNodes[x].title = "";
    }
  }

  if (i > 1) prod.insertBefore(prodmenu, prodhead.nextSibling);

  prodmenu.lastChild.firstChild.onclick();
  for (var x = 0, c = false; !c && x < prodmenu.childNodes.length; x++)
    if (prodmenu.childNodes[x].firstChild.location == window.location.hash)
      prodmenu.childNodes[x].firstChild.onclick();

  var as = document.getElementsByTagName('a');
  var requestURI = window.location.href.replace(/#.*$/, '');
  for (var x = 0, hsym; x < as.length; x++) {
    if (!as[x].onclick && as[x].href.replace(/#.*$/, '') == requestURI) {
      as[x].tabs = prodmenu.getElementsByTagName('a');
      as[x].mhsh = ((hsym = as[x].href.indexOf("#")) > -1) ? as[x].href.substr(hsym) : "";
      as[x].onclick = function() {
        for (var y = 0, c; y < this.tabs.length; y++)
          if (this.tabs[y].location == this.mhsh)
            return this.tabs[y].onclick();
        return this.tabs[this.tabs.length - 1].onclick();
      };
    }
  }

  var tables = document.getElementById('content').getElementsByTagName('table');
  for (var x = 0; x < tables.length; x++) {
    if (tables[x].className == "pantable") {
      var show = tables[x].tBodies[0].rows[0].getElementsByTagName('img')[0]
      var imgs = tables[x].tBodies[0].rows[1].getElementsByTagName('img');
      for (var y = 0; y < imgs.length; y++) {
        imgs[y].header = tables[x].tHead.rows[0].cells[0].firstChild;
        imgs[y].show = show;
        imgs[y].style.width = (720 / tables[x].tBodies[0].rows[1].cells.length - 10) + "px";
        imgs[y].onclick = function() {
          this.show.src = this.src;
          this.header.nodeValue = this.title;
        };
      }
    }
  }
});
