      function linkText(id) {
        var textToLink = document.getElementById(id);
        if(textToLink) {
          linkElement(textToLink);
        }
      }
      function linkElement(node) {
        if(node.childNodes) {
          for(var i=0; i<node.childNodes.length; i++) {
            if(node.childNodes.item(i).nodeType == 3) {
              var foundTerm = linkTextNode(node.childNodes.item(i));
              if(foundTerm) {
                i++; // We just replaced one node with 3 nodes. Skip the newly created node since it's already been transformed.
              }
            } else {
              linkElement(node.childNodes.item(i));
            }
          }
        }
      }

      function linkTextNode(node) {
        var found = false;
        var firstSubstringIndex = 99999999999999999;
        var firstTermIndex = -1;
        var firstTermString = "";
        for (j in glossary) {
          var term = glossary[j][0];
          var stringSubstringIndex = node.nodeValue.search(new RegExp("\\b" + term + "\\b", "i"));
          if(stringSubstringIndex > -1 && stringSubstringIndex < firstSubstringIndex) {
            firstSubstringIndex = stringSubstringIndex;
            firstTermIndex = j;
            firstTermString = term;
          }
          // Check for hyphenated version of term if the term is two words (e.g. abrasion-resistant)
         /* if(term.indexOf(' ') > -1 && term.indexOf(' ') == term.lastIndexOf(' ')) {
            term = term.replace(" ", "-");
            stringSubstringIndex = node.nodeValue.search(new RegExp("\\b" + term + "\\b", "i"));
            if(stringSubstringIndex > -1 && stringSubstringIndex < firstSubstringIndex) {
              firstSubstringIndex = stringSubstringIndex;
              firstTermIndex = j;
              firstTermString = term;
            }
          }*/
        }
        if(firstTermIndex > -1) {
          var term = firstTermString;
          var stringStart = node.nodeValue.substring(0, firstSubstringIndex);
          var stringMiddle = node.nodeValue.substring(firstSubstringIndex, firstSubstringIndex + term.length);
          var stringEnd = node.nodeValue.substring(firstSubstringIndex + term.length);
          var nodeStart = document.createTextNode(stringStart); 
          var nodeMiddle = createGlossaryNode(stringMiddle, firstTermIndex);
          var nodeEnd = document.createTextNode(stringEnd);
          node.parentNode.replaceChild(nodeEnd, node);
          nodeEnd.parentNode.insertBefore(nodeMiddle, nodeEnd);
          nodeEnd.parentNode.insertBefore(nodeStart, nodeMiddle);
          found = true;
        }
        return found;
      }

      function createGlossaryNode(term, index) {
        var node;
        var tipString = "<span class='bold'>" + glossary[index][0] + "</span> " + glossary[index][1];
        if(typeof glossary[index][2] != "undefined" && glossary[index][2].length > 0) {
          tipString = tipString + "<p><img src='" + glossary[index][2] + "'>";
        }
        node = document.createElement("span");
        node.className = "tip";
        node.onmouseover = function() { return overlib(tipString, DELAY, 500, VAUTO); }
        node.onmouseout = function() { return nd(); }
        node.appendChild(document.createTextNode(term));
        return node;
      }
