License violation! License is already in use at another online site: http://www.boligliv.dk/ [_LM_W3SVC_33_ROOT]﻿jQuery.extend({ highlight: function (a, b, c, d, e, f) {
    var excludedTags = ['H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'B', 'I', 'U', 'EM', 'STRONG'];

    if (a.tagName != undefined) {
        if ($.inArray(a.tagName.toUpperCase(), excludedTags) > -1) {
            return 0;
        }
    }
    if (a.nodeType === 3) {
        var g = a.data.match(b);
        if (g != null) {
            if (g.index > 1) {
                var foundChar = a.data.charAt(g.index - 1) + "";
                if (foundChar.match(/[a-zA-Zæøå0-9]/g)) {
                    return 0;
                }
            }
            //check if the tag word is already in a link not to highlight it
            var p = a.parentNode.tagName == "A";
            if (p == false && a.parentNode.tagName == "SPAN") {
                p = a.parentNode.parentNode.tagName == "A";
            }
            if (g && p == false) {
                var h = document.createElement(c || 'span');
                h.className = d || 'highlight';
                if (c == 'a') {
                    h.href = e;
                    h.alt = f;
                    h.title = f;
                }
                var j = a.splitText(g.index);

                j.splitText(g[0].length);
                var k = j.cloneNode(true);
                h.appendChild(k);
                if (j.parentNode.tagName != "H1") j.parentNode.replaceChild(h, j);
                return 1
            }
        }
    }
    else if ((a.nodeType === 1 && a.childNodes) && !/(script|style)/i.test(a.tagName) && !(a.tagName === c.toUpperCase() && a.className === d)) {
        for (var i = 0; i < a.childNodes.length; i++) { i += jQuery.highlight(a.childNodes[i], b, c, d, e, f) }
    } return 0
}
});
jQuery.fn.highlight = function (a, b) {
    var c = { className: 'highlight', element: 'span', caseSensitive: false, wordsOnly: false, linkUrl: '#', altText: '' };
    jQuery.extend(c, b);
    if (a.constructor === String) { a = [a] }
    var d = c.caseSensitive ? "" : "i";
    var e = "(" + a.join("|") + ")";
    //if (c.wordsOnly) { e = "(^\|[^a-zA-Z0-9æøå])" + e + "" }
    if (c.wordsOnly) { e = e + "(?![a-zA-Z0-9æøå])" }
    var f = new RegExp(e, d);

    return this.each(function () { jQuery.highlight(this, f, c.element, c.className, c.linkUrl, c.altText) })
};

