/* 覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 *
 *  searchhi.js 
 *  -----------
 *  http://www.kryogenix.org/code/browser/searchhi/
 *
 *  Modified 17.01.2008 by multi-INTER-media GmbH
 * ------------------------------------------------------------------------------
 * <span class="nosearchhi"> ... TEXT ... </span>      ->   is still working
 *
 * .searchword0 {color: #222; background-color: #ff0; border: 1px dotted #ff0;}
 * ...
 * .searchword5 = CSS-Style with different colors for differnt searchterms
 * 覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 */

  function highlightWord(node,word,wordnr) 
  {
    if (node.hasChildNodes) 
    {
      var hi_cn;
      for (hi_cn=0;hi_cn<node.childNodes.length;hi_cn++) 
      {
        highlightWord(node.childNodes[hi_cn],word,wordnr);
      }
    }
    if (node.nodeType == 3) 
    { 
      tempNodeVal = node.nodeValue.toLowerCase();
      tempWordVal = word.toLowerCase();
      if (tempNodeVal.indexOf(tempWordVal) != -1) 
      {
        pn = node.parentNode;
        klasse = "searchword"+wordnr;
        checkn = pn;
        while (checkn.nodeType != 9 && 
        checkn.nodeName.toLowerCase() != 'body') 
        { 
          if ((checkn.className.match(/\bnosearchhi\b/)) || (checkn.className.match(/\bhornav\b/))) 
          { 
            return; 
          }
          checkn = checkn.parentNode;
        }
        if (pn.className != klasse) 
        {
          nv = node.nodeValue;
          ni = tempNodeVal.indexOf(tempWordVal);
          before = document.createTextNode(nv.substr(0,ni));
          docWordVal = nv.substr(ni,word.length);
          after = document.createTextNode(nv.substr(ni+word.length));
          hiwordtext = document.createTextNode(docWordVal);
          hiword = document.createElement("span");
          hiword.className = klasse;
          hiword.appendChild(hiwordtext);
          pn.insertBefore(before,node);
          pn.insertBefore(hiword,node);
          pn.insertBefore(after,node);
          pn.removeChild(node);
        }
      }
    }
  }
/* 覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 */
  function SearchHighlight(qs) 
  {
    if (!document.createElement) return;
    if (qs.length < 3) return;
    words = unescape(qs.replace(/\+/g,' ')).split(/\s+/);
    for (w=0;w<words.length;w++) 
    {
       highlightWord(document.getElementById("suchergebnisbereich"),words[w],w);
    }
  }
/* 覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 */

