//**********************************************************************************
//  it-berater.js
//  Google Search Highlighter
//**********************************************************************************
//
// Copyright(C)2006 
// Theo Gottwald * info@it-berater.org
//
// This code is copyrighted, copy only with permission of the author.
//
var lcgt = '#000000';var lcgo = new Array('#ffff88','#a8ffff','#aaffaa','#ffbbbb','#ffaaff');
function proA(){ var pattern = /google\./i; if (pattern.exec(document.referrer) != null){var url_parts = document.referrer.split('?');
 if (url_parts[1]){var url_args = url_parts[1].split('&');
 for(var i=0; i<url_args.length; i++){var keyval = url_args[i].split('=');
 if (keyval[0] == 'q'){proC(proB(keyval[1]));
  return;}}}}}
function proB(url){return unescape(url.replace(/\+/g,' '));} function proC(terms){terms = terms.replace(/\"/g,"");
 var vst = terms.split(' '); var c = 0; for(var i=0; i<vst.length; i++){proD(vst[i], document.body,lcgo[c]); c = (c == lcgo.length-1)?0:c+1;}}
function proD(term, container, color){var term_low = term.toLowerCase(); for(var i=0; i<container.childNodes.length; i++){var node = container.childNodes[i];
 if (node.nodeType == 3){var data = node.data;
 var data_low = data.toLowerCase(); if (data_low.indexOf(term_low) != -1){var new_node = document.createElement('SPAN');
 node.parentNode.replaceChild(new_node,node); var result; while((result = data_low.indexOf(term_low)) != -1){new_node.appendChild(document.createTextNode(data.substr(0,result)));
  new_node.appendChild(proE(document.createTextNode(data.substr(result,term.length)),color)); data = data.substr(result + term.length); data_low = data_low.substr(result + term.length);}
 new_node.appendChild(document.createTextNode(data));}}else{proD(term, node, color);}}}
function proE(child, color){var node = document.createElement('SPAN'); node.style.backgroundColor = color; node.style.color = lcgt; node.appendChild(child); return node;}
if (window.addEventListener) window.addEventListener("load", proA, false)
else if (window.attachEvent) window.attachEvent("onload", proA)
else if (document.getElementById) 
window.onload=proA
