/*
		GNU General Public License version 2 or later; see LICENSE.txt
*/
if(typeof(Joomla)==="undefined"){var Joomla={}}Joomla.Highlighter=function(h){var d,f,i={autoUnhighlight:true,caseSensitive:false,startElement:false,endElement:false,elements:[],className:"highlight",onlyWords:true,tag:"span"},b=function(l){if(l.constructor===String){l=[l]}if(i.autoUnhighlight){g(l)}var k=i.onlyWords?"\b"+k+"\b":"("+l.join("\\b|\\b")+")",j=new RegExp(k,i.caseSensitive?"":"i");i.elements.map(function(m){a(m,j,i.className)});return this},g=function(l){if(l.constructor===String){l=[l]}var k,j;l.map(function(m){m=(i.caseSensitive?m:m.toUpperCase());if(l[m]){k=d(l[m]);k.removeClass();k.each(function(n,o){j=document.createTextNode(d(o).text());o.parentNode.replaceChild(j,o)})}});return this},a=function(k,r,q){if(k.nodeType===3){var o=k.nodeValue.match(r),l,j,s,p,n,m;if(o){l=document.createElement(i.tag);j=d(l);j.addClass(q);s=k.splitText(o.index);s.splitText(o[0].length);p=s.cloneNode(true);j.append(p);d(s).replaceWith(l);j.attr("rel",j.text());n=j.text();if(!i.caseSensitive){n=j.text().toUpperCase()}if(!f[n]){f[n]=[]}f[n].push(l);return 1}}else{if((k.nodeType===1&&k.childNodes)&&!/(script|style|textarea|iframe)/i.test(k.tagName)&&!(k.tagName===i.tag.toUpperCase()&&k.className===q)){for(m=0;m<k.childNodes.length;m++){m+=a(k.childNodes[m],r,q)}}}return 0},e=function(l,k){var j=l.next();if(j.attr("id")!==k.attr("id")){i.elements.push(j.get(0));e(j,k)}},c=function(j){d=jQuery.noConflict();d.extend(i,j);e(d(i.startElement),d(i.endElement));f=[]};c(h);return{highlight:b,unhighlight:g}};