if(typeof GetUrlParam == "undefined") {
  function GetUrlParam( paramName )
  {
  	var oRegex = new RegExp( '[\?&]' + paramName + '=([^&]+)', 'i' ) ;
  	var oMatch = oRegex.exec( decodeURIComponent(window.location.search) ) ;
	
  	if ( oMatch && oMatch.length > 1 )
  		return oMatch[1] ;
  	else
  		return '' ;
  }
}

;(function(jQuery) {
  jQuery.fn.modx_highLight = function(cfg) {
    cfg = jQuery.extend({
      param :  "searched", // Param from $_GET
      cssClass : "searchterm" // CSS Class will be use for highlighting
    }, cfg || {});
      
    var helper = '<span class="'+cfg.cssClass+'">[>REPLACE<]</span>';
    var textForSearch = this.html();
    var words = GetUrlParam(cfg.param).split("+");
    var newWords = [];
    for(var i in words) {
      newWords[i] = helper.replace('[>REPLACE<]', words[i]);
      textForSearch = textForSearch.replace(words[i], newWords[i]);
    }
    this.html(textForSearch);    
    return jQuery;
  }
})(jQuery);
