/*highlight v2Highlights arbitrary terms.<http://johannburkard.de/blog/programming/javascript/highlight-javascript-text-higlighting-jquery-plugin.html>MIT license.Johann Burkard<http://johannburkard.de><mailto:jb@eaio.com>Modified by Pavel Hrbacek to insert HTML link together with class name*/$(function(node, te, insertURL) {	function isNodesChild(o, node) {		var parent = o.parentNode;		alert(parent);		/*		while (parent != o && parent != null) {			if (parent == node || o == node) return true;			parent = o.parentNode;		};		*/		return (o == node);	} jQuery.highlight = document.body.createTextRange ? /*Version for IE using TextRanges.*/  function(node, te, insertURL) {   var r = document.body.createTextRange();   r.moveToElementText(node);      for (var i = 0; r.findText(te.toUpperCase(), 100000, 2); i++) {//    r.pasteHTML('<span class="highlight">' +  r.text + '<\/span>'); 	 r.pasteHTML('<a href="'+ insertURL +'" class="highlight" title="Click here to get more info about this term.">' +  r.text + '<\/a>');      r.collapse(false);   }  } :/* (Complicated) version for Mozilla and Opera using span tags.*/  function(node, te, insertURL) {   var pos, skip, spannode, middlebit, endbit, middleclone, chrS, chrE, goAhead;   skip = 0;   if (node.nodeType == 3) { //  pos = node.data.toUpperCase().indexOf(te); 	pos = node.data.toUpperCase().indexOf(te.toUpperCase());      if (pos >= 0) {		chrS = (pos == 0)? '' : node.data.substr(pos-1,1);     		chrE = (pos == (node.data.length-1))? '' : node.data.substr(pos+te.length,1);   	//	goAhead = (chrS == null || chrS=='' || chrS==' ' || chrS=='.' || chrS==',' || chrS==';') && (chrE == null || chrE=='' || chrE==' ' || chrE=='.' || chrE==',' || chrE==';') 		goAhead = (chrS == null || chrS=='' || ("\n\t\'\"\\ .,;:=*/".indexOf(chrS) >= 0)) && (chrE == null || chrE=='' || ("\n\t\'\"\\ .,;:=*/".indexOf(chrE) >= 0) );  // 		goAhead = (chrE == null || chrE=='' || ("\'\"\\ .,;:=*/".indexOf(chrE) >= 0) );   		//   		alert(">"+chrS + "->" +  ("\'\"\\ .,;:=*/".indexOf(chrS) >= 0) );   		//   		alert(">"+chrE + "->" +  ("\'\"\\ .,;:=*/".indexOf(chrE) >= 0) );   		   		if (goAhead === true)    		{		     spannode = document.createElement('a');     		spannode.className = 'highlight';	     	spannode.href = insertURL;	     	spannode.title = "Click here to get more info about this term.";	     	middlebit = node.splitText(pos);		     endbit = middlebit.splitText(te.length);     		middleclone = middlebit.cloneNode(true);		     spannode.appendChild(middleclone);     		middlebit.parentNode.replaceChild(spannode, middlebit);	     	skip = 1;	    	}    }   }   else if (node.nodeType == 1 && node.childNodes && !/(script|style)/i.test(node.tagName)) {    for (var i = 0; i < node.childNodes.length; ++i) {     i += $.highlight(node.childNodes[i], te, insertURL);    }   }   return skip;  } ;});jQuery.fn.removeHighlight = function() { this.find("span.highlight").each(function() {  with (this.parentNode) {   replaceChild(this.firstChild, this);   normalize();  } }); return this;};
