function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

/* http://www.kryogenix.org/code/browser/searchhi/ */
/* Modified 20021006 to fix query string parsing and add case insensitivity */
/* Modified 22.10.2003 Tomasz Lewandowski */

var searchWordValue = '';

// Wort hervorheben
function highlightWord(node,word)
{
  if (word == "")
  {
    return;
  }

  // Iterate into this nodes childNodes
  if (node.hasChildNodes())
  {
    var hi_cn;
    for (hi_cn=0;hi_cn<node.childNodes.length;hi_cn++)
    {
      highlightWord(node.childNodes[hi_cn],word);
    }
  }

  // And do this node itself
  if (node.nodeType == 3) // text node
  {
    tempNodeVal = node.nodeValue.toLowerCase();
    tempWordVal = word.toLowerCase();
    if (tempNodeVal.indexOf(tempWordVal) != -1)
    {
      var pn = node.parentNode;
      if (pn.className != "searchword")
      {
        // word has not already been highlighted!
        var nv = node.nodeValue;
        var ni = tempNodeVal.indexOf(tempWordVal);
        // Create a load of replacement nodes
        var before = document.createTextNode(nv.substr(0,ni));
        var docWordVal = nv.substr(ni,word.length);
        var after = document.createTextNode(nv.substr(ni+word.length));
        var hiwordtext = document.createTextNode(docWordVal);
        var hiword = document.createElement("span");
        hiword.className = "searchword";
        hiword.appendChild(hiwordtext);
        pn.insertBefore(before,node);
        pn.insertBefore(hiword,node);
        pn.insertBefore(after,node);
        pn.removeChild(node);
      }
    }
  }
}

// Worthervorhebung entfernen
function clearWord(node)
{
  // Iterate into this nodes childNodes
  if (node.hasChildNodes())
  {
    var hi_cn;
    for (hi_cn=0;hi_cn<node.childNodes.length;hi_cn++)
    {
      clearWord(node.childNodes[hi_cn]);
    }
  }

  // And do this node itself
  if (node.nodeType == 3) // text node
  {
    var pn = node.parentNode;
    // Wenn Wort bereits hervorgehoben
    // dann die Klasse ändern
    if (pn.className == "searchword")
    {
      pn.className = "searchwordClear";
    }
  }
}

// Worthervorhebung entfernen
function clearSearchWord()
{
  var bodyElement = document.getElementsByTagName("body")[0];
  if (bodyElement == null)
  {
    bodyElement = document.body;
  }
  clearWord(bodyElement, searchWordValue);
}

// Wort suchen und hervorheben
function searchWord()
{
  var siteSearchForm = document.getElementById('siteSearch');
  searchWordValue = siteSearchForm.word.value;
  var bodyElement = document.getElementById('body');
  if (bodyElement == null)
  {
    bodyElement = document.body;
  }
  highlightWord(bodyElement, searchWordValue);
}

// falls der Besucher von einer Suchmachine kommt
// koennen die Treffer direkt angezeigt werden
function googleSearchHighlight()
{
  if (!document.createElement) return;

  // Referrer ermitteln
  var ref = document.referrer;
  if (ref.indexOf('?') == -1) return;

  // Query Parameter ermitteln
  var queryString = ref.substr(ref.indexOf('?')+1);

  // Query Key-Value-Paare erzeugen
  var queryStringPair = queryString.split('&');

  // alle Paare durchgehen
  for (i=0;i<queryStringPair.length;i++)
  {
    // Key und Value trennen
    var pair = queryStringPair[i].split('=');
    if (pair.length == 1) continue;

    // q= for Google, p= for Yahoo
    if (pair[0] == 'q' || pair[0] == 'p')
    {
      // Suchworte aus Value ermitteln
      var words = unescape(pair[1].replace(/\+/g,' ')).split(/\s+/);

      // jedes Wort im Dokument sichtbar machen
      for (w=0;w<words.length;w++)
      {
        highlightWord(document.getElementsByTagName("body")[0],words[w]);
      }
    }
  }
}

