/*---- master.js ----*/
if (top != self) {
    top.location.replace(document.location);
    alert("For security reasons, framing is not allowed; click OK to remove the frames.")
	  //alert("出于安全考虑，frame框架调用是禁止的。点击“OK”移除框架。")
}
$(function() {
    $.ajaxSetup({
        cache: false
    })
});
$.fn.extend({
    fadeOutAndRemove: function(a) {
        return this.each(function() {
            var b = $(this);
            b.fadeOut("fast",
            function() {
                b.remove()
            })
        })
    }
});
function enableSubmitButton(a) {
    setSubmitButtonDisabled(a, false)
}
function disableSubmitButton(a) {
    setSubmitButtonDisabled(a, true)
}
function setSubmitButtonDisabled(b, a) {
    $(b).find("input[type='submit']").attr("disabled", a ? "disabled": "")
}
function setConfirmUnload(a) {
    window.onbeforeunload = a ?
    function() {
        return a
    }: null
}
function showAjaxError(a, c) {
    var d = $('<div class="error-notification supernovabg"><h2>' + c + "</h2>(click on this box to dismiss)</div>");
	  //var d = $('<div class="error-notification supernovabg"><h2>' + c + "</h2>（点击，即可隐藏本信息框）</div>");
    var b = function() {
        $(".error-notification").fadeOut("fast",
        function() {
            $(this).remove()
        })
    };
    d.click(function(e) {
        b()
    });
    $(a).append(d);
    d.fadeIn("fast");
    setTimeout(b, 1000 * 30)
}
function styleCode() {
    var a = false;
    $("pre code").parent().each(function() {
        if (!$(this).hasClass("prettyprint")) {
            $(this).addClass("prettyprint");
            a = true
        }
    });
    if (a) {
        prettyPrint()
    }
}
function appendLoader(a) {
    $(a).append('<img class="ajax-loader" src="/theme/en/image/ajax-loader.gif" title="loading..." alt="loading..." />')
}
function removeLoader() {
    $("img.ajax-loader").remove()
}
function savePreference(a, b, c) {
    $.post("/users/save_preference", {
        fkey: preffkey,
        key: a,
        value: b
    },
    c)
}
var notify = function() {
    var d = false;
    var e = 0;
    var c = -1;
    var f = "m";
    var a = function(h) {
        if (!d) {
            $("#notify-container").append('<table id="notify-table"></table>');
            d = true
        }
        var g = "<tr" + (h.messageTypeId ? ' id="notify-' + h.messageTypeId + '"': "");
        g += ' class="notify" style="display:none"><td class="notify">' + h.text;
        if (h.showProfile) {
            var i = escape("/users/" + h.userId);
            g += ' See your <a href="/messages/mark-as-read?messagetypeid=' + h.messageTypeId + "&returnurl=" + i + '">profile</a>.'
        }
        g += '</td><td class="notify-close"><a title="dismiss this notification" onclick="notify.close(';
		    //g += '</td><td class="notify-close"><a title="关闭本提示信息" onclick="notify.close(';
        g += (h.messageTypeId ? h.messageTypeId: "") + ')">&times;</a></td></tr>';
        $("#notify-table").append(g)
    };
    var b = function() {
        $.cookie("m", "-1", {
            expires: 90,
            path: "/"
        })
    };
    return {
        showFirstTime: function() {
			return;//xcl
            if ($.cookie("new")) {
                $.cookie("new", "0", {
                    expires: -1,
                    path: "/"
                });
                b()
            }
            if ($.cookie("m")) {
                return
            }
            $("body").css("margin-top", "2.5em");
            a({
                messageTypeId: c,
                text: 'First time here? Check out the <a onclick="notify.closeFirstTime()">FAQ</a>!'
				        //text: '您是第一次访问本站？请查看<a onclick="notify.closeFirstTime()">FAQ</a>！'
            });
            $(".notify").fadeIn("slow")
        },
        showMessages: function(g) {
            for (var h = 0; h < g.length; h++) {
                a(g[h])
            }
            $(".notify").fadeIn("slow");
            e = g.length
        },
        show: function(g) {
            $("body").css("margin-top", "2.5em");
            a({
                text: g
            });
            $(".notify").fadeIn("slow")
        },
        close: function(g) {
            var i;
            var h = 0;
            if (g && g != c) {
                $.post("/messages/mark-as-read", {
                    messagetypeid: g
                });
                i = $("#notify-" + g);
                if (e > 1) {
                    h = parseInt($("body").css("margin-top").match(/\d+/));
                    h = h - (h / e)
                }
            } else {
                if (g && g == c) {
                    b()
                }
                i = $(".notify")
            }
            i.children("td").css("border-bottom", "none").end().fadeOut("fast",
            function() {
                $("body").css("margin-top", h + "px");
                i.remove()
            })
        },
        closeFirstTime: function() {
            b();
            document.location = "/faq"
        }
    }
} ();
function applyPrefs(c) {
    var b = $("#ignoredTags > a");
    var e = $("#interestingTags > a");
    if (c && b.length == 0 && e.length == 0) {
        return
    }
    $("div.question-summary").removeClass("tagged-ignored tagged-ignored-hidden tagged-interesting");
    var f = getTagsSelector(b);
    var d = getTagsSelector(e);
    if (f.length > 0) {
        var a = $("#hideIgnored").is(":checked") ? "tagged-ignored-hidden": "tagged-ignored";
        $(f).parents("div.question-summary").addClass(a)
    }
    if (d.length > 0) {
        $(d).parents("div.question-summary").addClass("tagged-interesting")
    }
}
function getTagsSelector(c) {
    var b = "";
    var a = "";
    c.each(function() {
        var d = false;
        a = $(this).text();
        if (a.indexOf("#") > -1) {
            a = a.replace(/#/g, "JJJ")
        }
        if (a.indexOf("+") > -1) {
            a = a.replace(/\+/g, "XXX")
        }
        if (a.indexOf(".") > -1) {
            a = a.replace(/\./g, "ZZZ")
        }
        if (a.indexOf("*") > -1) {
            d = true
        }
        if (d) {
            b += "div.tags:regex(class, t-" + a.replace(/\*/g, ".*") + "),"
        } else {
            b += "div.t-" + a + ","
        }
    });
    if (b.length > 0) {
        b = b.substring(0, b.length - 1)
    }
    return b
}
function saveTags(d, a, g, h) {
    var b = $.trim($(d).val());
    var e = b.split(" ");
    var f = false;
    for (var c = 0; c < e.length; c++) {
        if ($.trim(e[c]).length != 0) {
            $(a).children().each(function() {
                if ($(this).text() == e[c]) {
                    $(this).fadeTo(500, 0.1).fadeTo(500, 1);
                    f = true;
                    return
                }
            });
            if (!f) {
                $(a).append("<a id='" + e[c] + "' href='/questions/tagged/" + e[c].replace(/\*/g, "") + "' class='" + h + "' title='click to delete this tag'>" + e[c] + "</a> ");
                initDeleteBindings(g)
            }
            f = false
        }
    }
    $(d).val("").focus();
    savePreference(g, $(a).text());
    applyPrefs()
}
function initTagPrefs() {
    initDeleteBindings(0);
    $("#ignoredAdd").click(function() {
        saveTags("#ignoredTag", "#ignoredTags", 25, "post-tag")
    });
    $("#interestingAdd").click(function() {
        saveTags("#interestingTag", "#interestingTags", 20, "post-tag")
    });
    $("#hideIgnored").click(function() {
        savePreference(30, $(this).is(":checked"));
        applyPrefs()
    });
    bindTagFilterAutoComplete("#ignoredTag");
    bindTagFilterAutoComplete("#interestingTag")
}
function initDeleteBindings(d) {
    var b = imagePath + "comment-del.png";
    var a = imagePath + "comment-del-hover.png";
    var c = "<img class='delete' src=\"" + b + "\" onmouseover=\"$(this).attr('src', '" + a + "')\" onmouseout=\"$(this).attr('src', '" + b;
    c += '\')" title="remove this tag" />';
    if (d == 0) {
        $("#ignoredTags > .post-tag").after(c)
    }
    if (d == 25) {
        $("#ignoredTags > .post-tag:last").after(c)
    }
    $("#ignoredTags > .delete").click(function() {
        $(this).prev().remove();
        $(this).remove();
        savePreference(25, $("#ignoredTags").text());
        applyPrefs()
    });
    if (d == 0) {
        $("#interestingTags > .post-tag").after(c)
    }
    if (d == 20) {
        $("#interestingTags > .post-tag:last").after(c)
    }
    $("#interestingTags > .delete").click(function() {
        $(this).prev().remove();
        $(this).remove();
        savePreference(20, $("#interestingTags").text());
        applyPrefs()
    })
}
function initBindingsAddSuggestedTag() {
    var b = "http://sstatic.net/so/img/add-small.png";
    var a = "http://sstatic.net/so/img/add-small-hover.png";
    var c = "<img class='add' src=\"" + b + "\" onmouseover=\"$(this).attr('src', '" + a + "')\" onmouseout=\"$(this).attr('src', '" + b;
    c += '\')" title="add this tag to interesting tags" />';
	  //c += '\')" title="设置为感兴趣标签" />';
    $("#suggestedTags > .post-tag").after(c);
    $("#suggestedTags > .add").click(function() {
        $("#interestingTag").val($("#interestingTag").val() + $(this).prev().text() + " ")
    })
}
jQuery.cookie = function(b, j, m) {
    if (typeof j != "undefined") {
        m = m || {};
        if (j === null) {
            j = "";
            m.expires = -1
        }
        var e = "";
        if (m.expires && (typeof m.expires == "number" || m.expires.toUTCString)) {
            var f;
            if (typeof m.expires == "number") {
                f = new Date();
                f.setTime(f.getTime() + (m.expires * 24 * 60 * 60 * 1000))
            } else {
                f = m.expires
            }
            e = "; expires=" + f.toUTCString()
        }
        var l = m.path ? "; path=" + (m.path) : "";
        var g = m.domain ? "; domain=" + (m.domain) : "";
        var a = m.secure ? "; secure": "";
        document.cookie = [b, "=", encodeURIComponent(j), e, l, g, a].join("")
    } else {
        var d = null;
        if (document.cookie && document.cookie != "") {
            var k = document.cookie.split(";");
            for (var h = 0; h < k.length; h++) {
                var c = jQuery.trim(k[h]);
                if (c.substring(0, b.length + 1) == (b + "=")) {
                    d = decodeURIComponent(c.substring(b.length + 1));
                    break
                }
            }
        }
        return d
    }
};
window.PR_SHOULD_USE_CONTINUATION = true;
window.PR_TAB_WIDTH = 8;
window.PR_normalizedHtml = window.PR = window.prettyPrintOne = window.prettyPrint = void 0;
window._pr_isIE6 = function() {
    var a = navigator && navigator.userAgent && /\bMSIE 6\./.test(navigator.userAgent);
    window._pr_isIE6 = function() {
        return a
    };
    return a
}; (function() {
    function X(av) {
        av = av.split(/ /g);
        var aw = {};
        for (var au = av.length; --au >= 0;) {
            var at = av[au];
            if (at) {
                aw[at] = null
            }
        }
        return aw
    }
    var n = "break continue do else for if return while ";
    var D = n + "auto case char const default double enum extern float goto int long register short signed sizeof static struct switch typedef union unsigned void volatile ";
    var w = D + "catch class delete false import new operator private protected public this throw true try ";
    var p = w + "alignof align_union asm axiom bool concept concept_map const_cast constexpr decltype dynamic_cast explicit export friend inline late_check mutable namespace nullptr reinterpret_cast static_assert static_cast template typeid typename typeof using virtual wchar_t where ";
    var G = w + "boolean byte extends final finally implements import instanceof null native package strictfp super synchronized throws transient ";
    var ap = G + "as base by checked decimal delegate descending event fixed foreach from group implicit in interface internal into is lock object out override orderby params readonly ref sbyte sealed stackalloc string select uint ulong unchecked unsafe ushort var ";
    var F = w + "debugger eval export function get null set undefined var with Infinity NaN ";
    var y = "caller delete die do dump elsif eval exit foreach for goto if import last local my next no our print package redo require sub undef unless until use wantarray while BEGIN END ";
    var ac = n + "and as assert class def del elif except exec finally from global import in is lambda nonlocal not or pass print raise try with yield False True None ";
	var k = n + "alias and begin case class def defined elsif end ensure false in module next nil not or redo rescue retry self super then true undef unless until when yield BEGIN END ";
    var ab = n + "case done elif esac eval fi function in local set then until ";
    var M = (p + ap + F + y + ac + k + ab);
    var P = "str";
    var L = "kwd";
    var o = "com";
    var al = "typ";
    var Z = "lit";
    var ai = "pun";
    var W = "pln";
    var q = "tag";
    var V = "dec";
    var ae = "src";
    var ao = "atn";
    var s = "atv";
    var ak = "nocode";
    function aq(at) {
        return (at >= "a" && at <= "z") || (at >= "A" && at <= "Z")
    }
    function O(aw, au, at, av) {
        aw.unshift(at, av || 0);
        try {
            au.splice.apply(au, aw)
        } finally {
            aw.splice(0, 2)
        }
    }
    var aj = function() {
        var av = ["!", "!=", "!==", "#", "%", "%=", "&", "&&", "&&=", "&=", "(", "*", "*=", "+=", ",", "-=", "->", "/", "/=", ":", "::", ";", "<", "<<", "<<=", "<=", "=", "==", "===", ">", ">=", ">>", ">>=", ">>>", ">>>=", "?", "@", "[", "^", "^=", "^^", "^^=", "{", "|", "|=", "||", "||=", "~", "break", "case", "continue", "delete", "do", "else", "finally", "instanceof", "return", "throw", "try", "typeof"];
        var aw = "(?:(?:(?:^|[^0-9.])\\.{1,3})|(?:(?:^|[^\\+])\\+)|(?:(?:^|[^\\-])-)";
        for (var at = 0; at < av.length; ++at) {
            var au = av[at];
            if (aq(au.charAt(0))) {
                aw += "|\\b" + au
            } else {
                aw += "|" + au.replace(/([^=<>:&])/g, "\\$1")
            }
        }
        aw += "|^)\\s*$";
        return new RegExp(aw)
    } ();
    var T = /&/g;
    var aa = /</g;
    var x = />/g;
    var K = /\"/g;
    function E(at) {
        return at.replace(T, "&amp;").replace(aa, "&lt;").replace(x, "&gt;").replace(K, "&quot;")
    }
    function r(at) {
        return at.replace(T, "&amp;").replace(aa, "&lt;").replace(x, "&gt;")
    }
    var e = /&lt;/g;
    var C = /&gt;/g;
    var d = /&apos;/g;
    var i = /&quot;/g;
    var ar = /&amp;/g;
    var J = /&nbsp;/g;
    function t(aw) {
        var ay = aw.indexOf("&");
        if (ay < 0) {
            return aw
        }
        for (--ay; (ay = aw.indexOf("&#", ay + 1)) >= 0;) {
            var at = aw.indexOf(";", ay);
            if (at >= 0) {
                var av = aw.substring(ay + 3, at);
                var ax = 10;
                if (av && av.charAt(0) === "x") {
                    av = av.substring(1);
                    ax = 16
                }
                var au = parseInt(av, ax);
                if (!isNaN(au)) {
                    aw = (aw.substring(0, ay) + String.fromCharCode(au) + aw.substring(at + 1))
                }
            }
        }
        return aw.replace(e, "<").replace(C, ">").replace(d, "'").replace(i, '"').replace(ar, "&").replace(J, " ")
    }
    function S(at) {
        return "XMP" === at.tagName
    }
    function an(ax, av) {
        switch (ax.nodeType) {
        case 1:
            var au = ax.tagName.toLowerCase();
            av.push("<", au);
            for (var aw = 0; aw < ax.attributes.length; ++aw) {
                var at = ax.attributes[aw];
                if (!at.specified) {
                    continue
                }
                av.push(" ");
                an(at, av)
            }
            av.push(">");
            for (var ay = ax.firstChild; ay; ay = ay.nextSibling) {
                an(ay, av)
            }
            if (ax.firstChild || !/^(?:br|link|img)$/.test(au)) {
                av.push("</", au, ">")
            }
            break;
        case 2:
            av.push(ax.name.toLowerCase(), '="', E(ax.value), '"');
            break;
        case 3:
        case 4:
            av.push(r(ax.nodeValue));
            break
        }
    }
    var am = null;
    function b(aw) {
        if (null === am) {
            var au = document.createElement("PRE");
            au.appendChild(document.createTextNode('<!DOCTYPE foo PUBLIC "foo bar">\n<foo />'));
            am = !/</.test(au.innerHTML)
        }
        if (am) {
            var av = aw.innerHTML;
            if (S(aw)) {
                av = r(av)
            }
            return av
        }
        var at = [];
        for (var ax = aw.firstChild; ax; ax = ax.nextSibling) {
            an(ax, at)
        }
        return at.join("")
    }
    function ah(av) {
        var at = "                ";
        var au = 0;
        return function(az) {
            var ax = null;
            var aC = 0;
            for (var ay = 0,
            aB = az.length; ay < aB; ++ay) {
                var aA = az.charAt(ay);
                switch (aA) {
                case "\t":
                    if (!ax) {
                        ax = []
                    }
                    ax.push(az.substring(aC, ay));
                    var aw = av - (au % av);
                    au += aw;
                    for (; aw >= 0; aw -= at.length) {
                        ax.push(at.substring(0, aw))
                    }
                    aC = ay + 1;
                    break;
                case "\n":
                    au = 0;
                    break;
                default:
                    ++au
                }
            }
            if (!ax) {
                return az
            }
            ax.push(az.substring(aC));
            return ax.join("")
        }
    }
    var R = /(?:[^<]+|<!--[\s\S]*?-->|<!\[CDATA\[([\s\S]*?)\]\]>|<\/?[a-zA-Z][^>]*>|<)/g;
    var v = /^<!--/;
    var U = /^<\[CDATA\[/;
    var u = /^<br\b/i;
    var h = /^<(\/?)([a-zA-Z]+)/;
    function B(aF) {
        var aB = aF.match(R);
        var aE = [];
        var aw = 0;
        var at = [];
        if (aB) {
            for (var aA = 0,
            av = aB.length; aA < av; ++aA) {
                var aC = aB[aA];
                if (aC.length > 1 && aC.charAt(0) === "<") {
                    if (v.test(aC)) {
                        continue
                    }
                    if (U.test(aC)) {
                        aE.push(aC.substring(9, aC.length - 3));
                        aw += aC.length - 12
                    } else {
                        if (u.test(aC)) {
                            aE.push("\n"); ++aw
                        } else {
                            if (aC.indexOf(ak) >= 0 && ad(aC)) {
                                var au = aC.match(h)[2];
                                var az = 1;
                                var ay;
                                end_tag_loop: for (ay = aA + 1; ay < av; ++ay) {
                                    var aD = aB[ay].match(h);
                                    if (aD && aD[2] === au) {
                                        if (aD[1] === "/") {
                                            if (--az === 0) {
                                                break end_tag_loop
                                            }
                                        } else {++az
                                        }
                                    }
                                }
                                if (ay < av) {
                                    at.push(aw, aB.slice(aA, ay + 1).join(""));
                                    aA = ay
                                } else {
                                    at.push(aw, aC)
                                }
                            } else {
                                at.push(aw, aC)
                            }
                        }
                    }
                } else {
                    var ax = t(aC);
                    aE.push(ax);
                    aw += ax.length
                }
            }
        }
        return {
            source: aE.join(""),
            tags: at
        }
    }
    function ad(at) {
        return !! at.replace(/\s(\w+)\s*=\s*(?:\"([^\"]*)\"|'([^\']*)'|(\S+))/g, ' $1="$2$3$4"').match(/[cC][lL][aA][sS][sS]=\"[^\"]*\bnocode\b/)
    }
    function N(ay, aw, ax, au) {
        if (!aw) {
            return
        }
        var at = ax.call({},
        aw);
        if (ay) {
            for (var av = at.length; (av -= 2) >= 0;) {
                at[av] += ay
            }
        }
        au.push.apply(au, at)
    }
    function j(av, au) {
        var at = {}; (function() {
            var az = av.concat(au);
            for (var aA = az.length; --aA >= 0;) {
                var aD = az[aA];
                var aB = aD[3];
                if (aB) {
                    for (var aC = aB.length; --aC >= 0;) {
                        at[aB.charAt(aC)] = aD
                    }
                }
            }
        })();
        var ay = au.length;
        var ax = /\S/;
        var aw = function(az, aP) {
            aP = aP || 0;
            var aC = [aP, W];
            var aO = "";
            var aD = 0;
            var aG = az;
            while (aG.length) {
                var aN;
                var aE = null;
                var aF;
                var aA = at[aG.charAt(0)];
                if (aA) {
                    aF = aG.match(aA[1]);
                    aE = aF[0];
                    aN = aA[0]
                } else {
                    for (var aL = 0; aL < ay; ++aL) {
                        aA = au[aL];
                        var aM = aA[2];
                        if (aM && !aM.test(aO)) {
                            continue
                        }
                        aF = aG.match(aA[1]);
                        if (aF) {
                            aE = aF[0];
                            aN = aA[0];
                            break
                        }
                    }
                    if (!aE) {
                        aN = W;
                        aE = aG.substring(0, 1)
                    }
                }
                var aJ = "lang-" === aN.substring(0, 5);
                if (aJ && !(aF && aF[1])) {
                    aJ = false;
                    aN = ae
                }
                if (!aJ) {
                    aC.push(aP + aD, aN)
                } else {
                    var aI = aF[1];
                    var aH = aE.indexOf(aI);
                    var aB = aH + aI.length;
                    var aQ = aN.substring(5);
                    if (!A.hasOwnProperty(aQ)) {
                        aQ = /^\s*</.test(aI) ? "default-markup": "default-code"
                    }
                    var aK = aC.length - 10;
                    N(aP + aD, aE.substring(0, aH), aw, aC);
                    N(aP + aD + aH, aE.substring(aH, aB), A[aQ], aC);
                    N(aP + aD + aB, aE.substring(aB), aw, aC)
                }
                aD += aE.length;
                aG = aG.substring(aE.length);
                if (aN !== o && ax.test(aE)) {
                    aO = aE
                }
            }
            return aC
        };
        return aw
    }
    var a = j([], [[W, /^[^<?]+/, null], [V, /^<!\w[^>]*(?:>|$)/, null], [o, /^<!--[\s\S]*?(?:-->|$)/, null], ["lang-", /^<\?([\s\S]+?)(?:\?>|$)/, null], ["lang-", /^<%([\s\S]+?)(?:%>|$)/, null], [ai, /^(?:<[%?]|[%?]>)/, null], ["lang-", /^<xmp\b[^>]*>([\s\S]+?)<\/xmp\b[^>]*>/i, null], ["lang-js", /^<script\b[^>]*>([\s\S]+?)<\/script\b[^>]*>/i, null], ["lang-css", /^<style\b[^>]*>([\s\S]+?)<\/style\b[^>]*>/i, null], [q, /^<\/?\w[^<>]*>/, null]]);
    var z = /^(<[^>]*>)([\s\S]*)(<\/[^>]*>)$/;
    function af(ay) {
        var av = a(ay);
        for (var ax = 0; ax < av.length; ax += 2) {
            if (av[ax + 1] === ae) {
                var az, au;
                az = av[ax];
                au = ax + 2 < av.length ? av[ax + 2] : ay.length;
                var at = ay.substring(az, au);
                var aw = at.match(z);
                if (aw) {
                    av.splice(ax, 2, az, q, az + aw[1].length, ae, az + aw[1].length + (aw[2] || "").length, q)
                }
            }
        }
        return av
    }
    var Y = j([[s, /^\'[^\']*(?:\'|$)/, null, "'"], [s, /^\"[^\"]*(?:\"|$)/, null, '"'], [ai, /^[<>\/=]+/, null, "<>/="]], [[q, /^[\w:\-]+/, /^</], [s, /^[\w\-]+/, /^=/], [ao, /^[\w:\-]+/, null], [W, /^\s+/, null, " \t\r\n"]]);
    function I(ay, au) {
        for (var aw = 0; aw < au.length; aw += 2) {
            var ax = au[aw + 1];
            if (ax === q) {
                var aA, at;
                aA = au[aw];
                at = aw + 2 < au.length ? au[aw + 2] : ay.length;
                var av = ay.substring(aA, at);
                var az = Y(av, aA);
                O(az, au, aw, 2);
                aw += az.length - 2
            }
        }
        return au
    }
    function m(aw) {
        var ay = [],
        av = [];
        if (aw.tripleQuotedStrings) {
            ay.push([P, /^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/, null, "'\""])
        } else {
            if (aw.multiLineStrings) {
                ay.push([P, /^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/, null, "'\"`"])
            } else {
                ay.push([P, /^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/, null, "\"'"])
            }
        }
        av.push([W, /^(?:[^\'\"\`\/\#]+)/, null, " \r\n"]);
        if (aw.hashComments) {
            ay.push([o, /^#[^\r\n]*/, null, "#"])
        }
        if (aw.cStyleComments) {
            av.push([o, /^\/\/[^\r\n]*/, null]);
            av.push([o, /^\/\*[\s\S]*?(?:\*\/|$)/, null])
        }
        if (aw.regexLiterals) {
            var aA = ("^/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+(?:/|$)");
            av.push([P, new RegExp(aA), aj])
        }
        var ax = X(aw.keywords);
        aw = null;
        var au = j(ay, av);
        var az = j([], [[W, /^\s+/, null, " \r\n"], [W, /^[a-z_$@][a-z_$@0-9]*/i, null], [Z, /^0x[a-f0-9]+[a-z]/i, null], [Z, /^(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d+)(?:e[+\-]?\d+)?[a-z]*/i, null, "123456789"], [ai, /^[^\s\w\.$@]+/, null]]);
        function at(aB, aF) {
            for (var aJ = 0; aJ < aF.length; aJ += 2) {
                var aC = aF[aJ + 1];
                if (aC === W) {
                    var aD, aH, aL, aK;
                    aD = aF[aJ];
                    aH = aJ + 2 < aF.length ? aF[aJ + 2] : aB.length;
                    aL = aB.substring(aD, aH);
                    aK = az(aL, aD);
                    for (var aI = 0,
                    aE = aK.length; aI < aE; aI += 2) {
                        var aM = aK[aI + 1];
                        if (aM === W) {
                            var aO = aK[aI];
                            var aN = aI + 2 < aE ? aK[aI + 2] : aL.length;
                            var aG = aB.substring(aO, aN);
                            if (aG === ".") {
                                aK[aI + 1] = ai
                            } else {
                                if (aG in ax) {
                                    aK[aI + 1] = L
                                } else {
                                    if (/^@?[A-Z][A-Z$]*[a-z][A-Za-z$]*$/.test(aG)) {
                                        aK[aI + 1] = aG.charAt(0) === "@" ? Z: al
                                    }
                                }
                            }
                        }
                    }
                    O(aK, aF, aJ, 2);
                    aJ += aK.length - 2
                }
            }
            return aF
        }
        return function(aC) {
            var aB = au(aC);
            aB = at(aC, aB);
            return aB
        }
    }
    var ag = m({
        keywords: M,
        hashComments: true,
        cStyleComments: true,
        multiLineStrings: true,
        regexLiterals: true
    });
    function c(at, aB) {
        var aI = false;
        for (var aF = 0; aF < aB.length; aF += 2) {
            var av = aB[aF + 1];
            var ax, aD;
            if (av === ao) {
                ax = aB[aF];
                aD = aF + 2 < aB.length ? aB[aF + 2] : at.length;
                aI = /^on|^style$/i.test(at.substring(ax, aD))
            } else {
                if (av === s) {
                    if (aI) {
                        ax = aB[aF];
                        aD = aF + 2 < aB.length ? aB[aF + 2] : at.length;
                        var aG = at.substring(ax, aD);
                        var au = aG.length;
                        var aA = (au >= 2 && /^[\"\']/.test(aG) && aG.charAt(0) === aG.charAt(au - 1));
                        var aw;
                        var ay;
                        var aC;
                        if (aA) {
                            ay = ax + 1;
                            aC = aD - 1;
                            aw = aG
                        } else {
                            ay = ax + 1;
                            aC = aD - 1;
                            aw = aG.substring(1, aG.length - 1)
                        }
                        var aH = ag(aw);
                        for (var aE = 0,
                        az = aH.length; aE < az; aE += 2) {
                            aH[aE] += ay
                        }
                        if (aA) {
                            aH.push(aC, s);
                            O(aH, aB, aF + 2, 0)
                        } else {
                            O(aH, aB, aF, 2)
                        }
                    }
                    aI = false
                }
            }
        }
        return aB
    }
    function l(au) {
        var at = af(au);
        at = I(au, at);
        at = c(au, at);
        return at
    }
    function Q(aJ, au, ay) {
        var aB = [];
        var aI = 0;
        var ax = null;
        var aC = null;
        var av = 0;
        var aH = 0;
        var az = ah(window.PR_TAB_WIDTH);
        var aw = /([\r\n ]) /g;
        var aF = /(^| ) /gm;
        var aA = /\r\n?|\n/g;
        var aD = /[ \r\n]$/;
        var aE = true;
        function aG(aK) {
            if (aK > aI) {
                if (ax && ax !== aC) {
                    aB.push("</span>");
                    ax = null
                }
                if (!ax && aC) {
                    ax = aC;
                    aB.push('<span class="', ax, '">')
                }
                var aL = r(az(aJ.substring(aI, aK))).replace(aE ? aF: aw, "$1&nbsp;");
                aE = aD.test(aL);
                aB.push(aL.replace(aA, "<br>"));
                aI = aK
            }
        }
        while (true) {
            var at;
            if (av < au.length) {
                if (aH < ay.length) {
                    at = au[av] <= ay[aH]
                } else {
                    at = true
                }
            } else {
                at = false
            }
            if (at) {
                aG(au[av]);
                if (ax) {
                    aB.push("</span>");
                    ax = null
                }
                aB.push(au[av + 1]);
                av += 2
            } else {
                if (aH < ay.length) {
                    aG(ay[aH]);
                    aC = ay[aH + 1];
                    aH += 2
                } else {
                    break
                }
            }
        }
        aG(aJ.length);
        if (ax) {
            aB.push("</span>")
        }
        return aB.join("")
    }
    var A = {};
    function g(av, aw) {
        for (var at = aw.length; --at >= 0;) {
            var au = aw[at];
            if (!A.hasOwnProperty(au)) {
                A[au] = av
            } else {
                if ("console" in window) {
                    console.log("cannot override language handler %s", au)
                }
            }
        }
    }
    g(ag, ["default-code"]);
    g(l, ["default-markup", "htm", "html", "mxml", "xhtml", "xml", "xsl"]);
    g(m({
        keywords: p,
        hashComments: true,
        cStyleComments: true
    }), ["c", "cc", "cpp", "cxx", "cyc", "m"]);
    g(m({
        keywords: ap,
        hashComments: true,
        cStyleComments: true
    }), ["cs"]);
    g(m({
        keywords: G,
        cStyleComments: true
    }), ["java"]);
    g(m({
        keywords: ab,
        hashComments: true,
        multiLineStrings: true
    }), ["bsh", "csh", "sh"]);
    g(m({
        keywords: ac,
        hashComments: true,
        multiLineStrings: true,
        tripleQuotedStrings: true
    }), ["cv", "py"]);
    g(m({
        keywords: y,
        hashComments: true,
        multiLineStrings: true,
        regexLiterals: true
    }), ["perl", "pl", "pm"]);
    g(m({
        keywords: k,
        hashComments: true,
        multiLineStrings: true,
        regexLiterals: true
    }), ["rb"]);
    g(m({
        keywords: F,
        cStyleComments: true,
        regexLiterals: true
    }), ["js"]);
    function H(ay, aw) {
        try {
            var az = B(ay);
            var av = az.source;
            var at = az.tags;
            if (!A.hasOwnProperty(aw)) {
                aw = /^\s*</.test(av) ? "default-markup": "default-code"
            }
            var au = A[aw].call({},
            av);
            return Q(av, at, au)
        } catch(ax) {
            if ("console" in window) {
                console.log(ax);
                console.trace()
            }
            return ay
        }
    }
    function f(aB) {
        var ax = window._pr_isIE6();
        var aA = [document.getElementsByTagName("pre"), document.getElementsByTagName("code"), document.getElementsByTagName("xmp")];
        var at = [];
        for (var az = 0; az < aA.length; ++az) {
            for (var ay = 0,
            av = aA[az].length; ay < av; ++ay) {
                at.push(aA[az][ay])
            }
        }
        aA = null;
        var aw = 0;
        function au() {
            var aH = (window.PR_SHOULD_USE_CONTINUATION ? new Date().getTime() + 250 : Infinity);
            for (; aw < at.length && new Date().getTime() < aH; aw++) {
                var aI = at[aw];
                if (aI.className && aI.className.indexOf("prettyprint") >= 0) {
                    var aE = aI.className.match(/\blang-(\w+)\b/);
                    if (aE) {
                        aE = aE[1]
                    }
                    var aN = false;
                    for (var aC = aI.parentNode; aC; aC = aC.parentNode) {
                        if ((aC.tagName === "pre" || aC.tagName === "code" || aC.tagName === "xmp") && aC.className && aC.className.indexOf("prettyprint") >= 0) {
                            aN = true;
                            break
                        }
                    }
                    if (!aN) {
                        var aK = b(aI);
                        aK = aK.replace(/(?:\r\n?|\n)$/, "");
                        var aO = H(aK, aE);
                        if (!S(aI)) {
                            aI.innerHTML = aO
                        } else {
                            var aD = document.createElement("PRE");
                            for (var aG = 0; aG < aI.attributes.length; ++aG) {
                                var aP = aI.attributes[aG];
                                if (aP.specified) {
                                    var aL = aP.name.toLowerCase();
                                    if (aL === "class") {
                                        aD.className = aP.value
                                    } else {
                                        aD.setAttribute(aP.name, aP.value)
                                    }
                                }
                            }
                            aD.innerHTML = aO;
                            aI.parentNode.replaceChild(aD, aI);
                            aI = aD
                        }
                        if (ax && aI.tagName === "PRE") {
                            var aJ = aI.getElementsByTagName("br");
                            for (var aF = aJ.length; --aF >= 0;) {
                                var aM = aJ[aF];
                                aM.parentNode.replaceChild(document.createTextNode("\r\n"), aM)
                            }
                        }
                    }
                }
            }
            if (aw < at.length) {
                setTimeout(au, 250)
            } else {
                if (aB) {
                    aB()
                }
            }
        }
        au()
    }
    window.PR_normalizedHtml = an;
    window.prettyPrintOne = H;
    window.prettyPrint = f;
    window.PR = {
        createSimpleLexer: j,
        registerLangHandler: g,
        sourceDecorator: m,
        PR_ATTRIB_NAME: ao,
        PR_ATTRIB_VALUE: s,
        PR_COMMENT: o,
        PR_DECLARATION: V,
        PR_KEYWORD: L,
        PR_LITERAL: Z,
        PR_NOCODE: ak,
        PR_PLAIN: W,
        PR_PUNCTUATION: ai,
        PR_SOURCE: ae,
        PR_STRING: P,
        PR_TAG: q,
        PR_TYPE: al
    }
})();
jQuery.expr[":"].regex = function(g, d, c) {
    var h = c[3].split(","),
    b = /^(data|css):/,
    a = {
        method: h[0].match(b) ? h[0].split(":")[0] : "attr",
        property: h.shift().replace(b, "")
    },
    f = "ig",
    e = new RegExp(h.join("").replace(/^\s+|\s+$/g, ""), f);
    return e.test(jQuery(g)[a.method](a.property))
};
/*---- master.js end----*/

/*---- question.js ----*/
var vote = function() {
    var k = {
        informModerator: -1,
        undoMod: 0,
        acceptedByOwner: 1,
        upMod: 2,
        downMod: 3,
        offensive: 4,
        favorite: 5,
        close: 6,
        reopen: 7,
        deletion: 10,
        undeletion: 11,
        spam: 12
    };
    var f = imagePath + "vote-arrow-down.png";
    var c = imagePath + "vote-arrow-down-on.png";
    var x = imagePath + "vote-arrow-up.png";
    var w = imagePath + "vote-arrow-up-on.png";
    var A = imagePath + "vote-favorite-on.png";
    var o = imagePath + "vote-favorite-off.png";
    var l = function() {
        var C = '<a href="/login?returnurl=' + escape(document.location) + '">login or register</a>';
        $("div.vote").find("img").not(".vote-accepted").unbind("click").click(function() {
			tmp=check_wk_login($(this));if(!tmp){return false;}if(User_id.length==8){document.location.reload();}
           // u($(this), "Please " + C + " to use voting.")
        });
        z().unbind("click").click(function() {
			tmp=check_wk_login($(this));if(!tmp){return false;}if(User_id.length==8){document.location.reload();}
            //u($(this), "Please " + C + " to flag this post.")
        })
    };
    var B = function(C) {
        if (!C) {
            C = "div.vote"
        }
        $(C).find("img.vote-up").unbind("click").click(function() {
            vote.up($(this))
        });
        $(C).find("img.vote-down").unbind("click").click(function() {
            vote.down($(this))
        });
        $(C).find("img.vote-favorite").unbind("click").click(function() {
            vote.favorite($(this))
        })
    };
    var i = function(C) {
        C.parent().find("img").not(".vote-accepted").unbind("click")
    };
    var d = function(C) {
        $.ajax({
            type: "GET",
            url: "/posts/" + C + "/votes",
            dataType: "json",
            success: v,
            cache: false
        })
    };
    var v = function(C) {
        $.each(C,
        function() {
            var D = $("div.vote:has(input[value=" + this.PostId + "])");
            switch (this.VoteTypeId) {
            case k.upMod:
                D.find("img.vote-up").attr("src", w);
                break;
            case k.downMod:
                D.find("img.vote-down").attr("src", c);
                break;
            case k.favorite:
                D.find("img.vote-favorite").attr("src", A);
                D.find("div.favoritecount b").addClass("favoritecount-selected");
                break;
            default:
                alert("site.vote.js > highlightExistingVotes has no case for " + this.VoteTypeId);
                break
            }
        });
        votesCast = null
    };
    var r = function() {
        return $("div.vote img[id^='vote-accepted-']")
    };
    var e = function() {
        return $("div.post-menu a[id^='lock-post-']")
    };
    var z = function() {
        return $("div.post-menu a[id^='flag-post-']")
    };
    var n = function() {
        var C = new Image();
        C.src = w;
        C = new Image();
        C.src = c
    };
    var m = function(C) {
        return C.attr("src") == w
    };
    var q = function(C) {
        return C.attr("src") == A
    };
    var a = function(C) {
        return C.attr("src") == c
    };
    var h = function(C) {
        return C.parent().find("input").val()
    };
    var y = function(D, C) {
        if (m(D)) {
            D.attr("src", x)
        }
        if (a(C)) {
            C.attr("src", f)
        }
    };
    var s = function(C, D) {
        //var E = C.siblings("span.vote-count-post");
		var E = C.parent().parent().find("span.vote-count-post");
        E.text(parseInt(E.text(), 10) + D)
    };
    var t = function(E, D) {
        i(E);
        var C = h(E);
        p(E, C, D, b)
    };
    var p = function(F, D, C, I, H) {
        var G = {
            fkey: fkey
        };
        if (H) {
            for (var E in H) {
                G[E] = H[E]
            }
        }
        $.ajax({
            type: "POST",
            //url: "/posts/" + D + "/vote/" + C,
			url: "/ajax/" + D + "/vote/" + C,
            data: G,
            dataType: "json",
            success: function(J) {
                I(F, D, J)
            },
            error: function() {
                u(F, "An error has occurred - please retry your request.")
            }
        })
    };
    var b = function(D, C, E) {
        if (E.Success) {
            if (E.Message) {
                g(D, E.Message)
            }
        } else {
            if (window.console && window.console.firebug && (!E.Message || E.Message.length < 5)) {
                u(D, "FireBug seems to be enabled, which can sometimes interfere with voting;<br>please refresh the page to see if your vote was processed.<br><br>If this persists, consider disabling FireBug for this site.")
            } else {
                u(D, E.Message);
                y(D, D);
               	//D.parent().find("span.vote-count-post").text(E.NewScore);
				D.parent().parent().find("span.vote-count-post").text(E.NewScore);
                if (E.LastVoteTypeId) {
                    j(D, E.LastVoteTypeId)
                }
            }
        }
        B(D.parent())
    };
    var j = function(F, D) {
        var E, C;
        if (D == k.upMod) {
            E = "img.vote-up";
            C = w
        } else {
            if (D == k.downMod) {
                E = "img.vote-down";
                C = c
            }
        }
        if (E) {
            F.parent().find(E).attr("src", C)
        }
    };
    var u = function(C, D) {
        var E = $('<div class="error-notification supernovabg"><h2>' + D + "</h2>(click on this box to dismiss)</div>");
        E.click(function(F) {
            $(".error-notification").fadeOut("fast",
            function() {
                $(this).remove()
            })
        });
        C.parent().append(E);
        E.fadeIn("fast")
    };
    var g = function(D, F) {
        var G = $('<div class="error-notification supernovabg"><h2>' + F + "</h2></div>");
        D.parent().append(G);
        G.fadeIn("fast");
        var C = function() {
            $(".error-notification").fadeOut("fast",
            function() {
                $(this).remove()
            })
        };
        var E = Math.max(2500, F.length * 40);
        setTimeout(C, E)
    };
    return {
        init: function(C) {
            if (typeof isRegistered != "undefined" && isRegistered) {
                n();
                if (votesCast == null) {
                    d(C)
                } else {
                    v(votesCast)
                }
                B();
                z().unbind("click").click(function() {
                    vote.flag($(this))
                })
            } else {
                l()
            }
            r().unbind("click").click(function() {
                vote.acceptedAnswer($(this))
            });
            var D = $("div.post-menu a[id^='close-question-']");
            D.unbind("click").click(function() {
                vote.close(D)
            });
            $("div.post-menu a[id^='delete-post-']").unbind("click").click(function() {
                vote.deletion($(this))
            })
        },
        up: function(F) {
            var G = F.parent().find("img.vote-up");
            var E = F.parent().find("img.vote-down");
            var D = m(G);
            var C = a(E);
            var H = D ? -1 : (C ? 2 : 1);
            s(F, H);
            y(G, E);
            if (!D) {
                G.attr("src", w)
            }
            t(F, D ? k.undoMod: k.upMod)
        },
        down: function(F) {
            var G = F.parent().find("img.vote-up");
            var E = F.parent().find("img.vote-down");
            var D = a(E);
            var C = m(G);
            var H = D ? 1 : (C ? -2 : -1);
            s(F, H);
            y(G, E);
            if (!D) {
                E.attr("src", c)
            }
            t(F, D ? k.undoMod: k.downMod)
        },
        favorite: function(D) {
            var E = D.parent().find("div.favoritecount b");
            var C = parseInt("0" + E.text().replace(/^\s+|\s+$/g, ""), 10);
            if (!q(D)) {
                D.attr("src", A);
                E.addClass("favoritecount-selected").text(++C)
            } else {
                D.attr("src", o);
                E.removeClass("favoritecount-selected").text((C--<=0) ? "": C)
            }
            D.unbind("click");
            p(D, h(D), k.favorite,
            function(F) {
                D.click(function() {
                    vote.favorite($(this))
                })
            })
        },
        acceptedAnswer: function(D) {
            if (typeof hasOpenBounty != "undefined" && hasOpenBounty) {
                var E = ($("#" + C + "-is-owned-by-question-owner").length > 0) ? "Are you sure you want to accept your own answer?  You will STILL LOSE the offered rep and THIS CANNOT BE UNDONE!": "Are you sure you want to accept this answer to your bounty question - THIS CANNOT BE UNDONE!";
                if (!confirm(E)) {
                    return
                }
            }
            if (typeof isBountyQuestion != "undefined" && isBountyQuestion && typeof hasOpenBounty == "undefined") {
                u(D, "You cannot change the accepted answer on a bounty question");
                return
            }
            r().unbind("click");
            var C = D.attr("id").substring("vote-accepted-".length);
            p(D, C, k.acceptedByOwner,
            function(I, G, K) {
                if (K.Message.indexOf(imagePath) > -1) {
                    var H = "comments-link";
                    var J = "comments-container";
                    $("div.answer").removeClass("accepted-answer");
                    $("img.vote-accepted").attr("src", imagePath + "vote-accepted.png");
                    $("a.comments-link-accepted").removeClass().addClass(H);
                    $("div.comments-container-accepted").removeClass().addClass(J);
                    var F = function(L) {
                        L.find(".comments-link").removeClass().addClass("comments-link-owner").end().find(".comments-container").removeClass().addClass("comments-container-owner")
                    };
                    $("div.answer:has(input[id$='-is-owned-by-question-owner'])").not(".owner-answer").addClass("owner-answer").each(function() {
                        F($(this))
                    });
					
                    if (K.Message == imagePath + "vote-accepted-on.png") {
						
                        $("div.answer:has(img[id^='vote-accepted-" + G + "'])").removeClass("owner-answer").addClass("accepted-answer");
                        H = H + "-accepted";
                        J = J + "-accepted"
                    } else {
                        if ($("#" + G + "-is-owned-by-question-owner").length > 0) {
                            F($("#answer-" + G))
                        }
                    }
                    $("a[id='comments-link-" + G + "']").removeClass().addClass(H).siblings("div").removeClass().addClass(J);
                    I.attr("src", K.Message);
                    if (typeof hasOpenBounty != "undefined" && hasOpenBounty) {
                        hasOpenBounty = false;
                        $("#bounty-notification").hide()
                    }
                } else {
                    u(I, K.Message)
                }
                r().click(function() {
                    vote.acceptedAnswer($(this))
                })
            })
        },
        flag: function(E) {
            var C = E.attr("id").substring("flag-post-".length);
            var J = "form-flag-" + C;
            var M = $("#" + C + "-is-owned-by-current-user").length > 0;
            var K = [[k.offensive, "Offensive, Abusive, or Hate Speech", !M], [k.spam, "Spam", !M], [k.informModerator, "Requires Moderator attention", true]];
			var H = '<div class="popup flag-menu"><h2>Please flag with care:</h2>';
            H += '<div class="flag-reasons"><form id="' + J + '">';
            for (var F = 0; F < K.length; F++) {
                if (K[F][2]) {
                    var L = "flag-radio" + C + "-" + K[F][0];
                    H += '<input type="radio" id="' + L + '" name="flag-' + C + '" value="' + K[F][0] + '">';
                    H += '<label for="' + L + '">' + K[F][1] + "</label><br>"
                }
            }
            H += '<div class="flag-comment">Why are you flagging this post?<textarea name="flag-reason" cols="33" rows="4"></textarea>';
            H += '<br><span class="text-counter"></span></div>';
            H += "</form></div>";
            H += '<input type="button" class="flag-cancel" value="Cancel"><input type="button" class="flag-submit" value="Flag Post">';
            H += "</div>";
            var G = $(H);
            var D = G.find("#" + J);
            var I = D.find("textarea");
            D.find("input").click(function() {
                var N = D.find("div.flag-comment");
                var O = vote.flagIsInform(D);
                N.toggle(O);
                if (O) {
                    I.focus()
                }
                vote.flagAllowSubmit(G, I, O)
            });
            I.bind("blur focus keyup",
            function() {
                comments.updateTextCounter(this, 150);
                vote.flagAllowSubmit(G, I, vote.flagIsInform(D))
            });
            G.find(".flag-submit").click(function() {
                if (vote.flagIsInform(D) && !vote.flagTextValid(I)) {
                    return
                }
                vote.flagSubmit(E, C, D, I)
            });
            G.find(".flag-cancel").click(function() {
                vote.flagClosePopup(E)
            });
            E.parent().append(G);
            G.fadeIn("fast")
        },
        flagIsInform: function(C) {
            var D = C.find("input:radio:checked");
            if (D.length == 0) {
                return false
            }
            return D.val() == k.informModerator
        },
        flagAllowSubmit: function(D, E, F) {
            var C = F ? vote.flagTextValid(E) : true;
            D.find(".flag-submit").toggle(C)
        },
        flagTextValid: function(D) {
            var C = D.val().length;
            return (C >= 3 && C <= 150)
        },
        flagClosePopup: function(C) {
            C.parent().find(".popup").fadeOut("fast",
            function() {
                $(this).remove()
            })
        },
        flagSubmit: function(F, D, C, G) {
            vote.flagClosePopup(F);
            var E = C.find("input:radio:checked").val();
            var D = F.attr("id").substring("flag-post-".length);
            if (E == k.informModerator) {
                $.ajax({
                    type: "POST",
                    //url: "/messages/inform-moderator-about-post/" + D,
					//url: "/messages/inform-moderator-about-post/" + D,
					//url: "/ajax/" + D + "/vote/" + C,
					url: "/ajax/inform-moderator/" + D,
					
                    dataType: "json",
                    data: {
                        fkey: fkey,
                        msg: G.val()
                    },
                    success: function(H) {
                        showAjaxError(F.parent(), H.Message)
                    },
                    error: function(H, J, I) {
                        showAjaxError(F.parent(), (H.responseText && H.responseText.length < 100 ? H.responseText: "An error occurred during submission"))
                    }
                })
            } else {
                p(F, D, E, vote.flagSubmitCallback, {
                    comment: G.val()
                })
            }
        },
        flagSubmitCallback: function(D, C, F) {
            if (F && F.Success) {
                if (F.Message) {}
            } else {
                var E = D.parent();
                if (F && F.Message) {
                    showAjaxError(E, F.Message)
                } else {
                    showAjaxError(E, "A problem occurred during flagging")
                }
            }
        },
        close: function(D) {
            var E = D.text().indexOf("open") > -1;
            var C = D.attr("id").substring("close-question-".length);
            if (E) {
                if (confirm("Nominate this question for reopening?")) {
                    p(D, C, k.reopen, vote.close_result)
                }
            } else {
                if (!vote.close_reasons) {
                    vote.close_fetchReasons(D, C)
                } else {
                    vote.close_renderForm(D)
                }
            }
        },
        close_reasons: null,
        close_fetchReasons: function(D, C) {
            $(".error-notification").fadeOutAndRemove();
            appendLoader(D);
			$.ajax({
                type: "POST",
               	//url: "/posts/close-reasons/" + C,
			    url: "/ajax/close-reasons/" + C,
                dataType: "json",
                success: function(E) {
                    removeLoader();
                    vote.close_reasons = E;
                    vote.close_renderForm(D)
                },
                error: function(E, G, F) {
                    removeLoader();
                    showAjaxError(D.parent(), (E.responseText && E.responseText.length < 100 ? E.responseText: "An error occurred while fetching close reasons"))
                }
            })
        },
        close_renderForm: function(F) {
            var D = F.attr("id").substring("close-question-".length);
            var C = "close-popup-" + D;
            var K = "form-close-" + D;
            $("#" + C).remove();
            var I = '<div id="' + C + '" class="popup" style="width:310px"><h2>Why should this question be closed?</h2><ul class="close-reasons">';
            for (var G = 0; G < vote.close_reasons.length; G++) {
                var J = vote.close_reasons[G];
                var E = "close-reason-" + J.id;
                I += '<li><input type="radio" id="' + E + '" name="close-' + D + '" value="' + J.id + '"><label for="' + E + '"' + (J.description ? ' title="' + J.description + '"': "") + ">" + J.name + "" + (J.count > 0 ? ' <span title="this many votes already exist">(' + J.count + ")</span>": "") + "</label></li>"
            }
            I += '</ul><input type="button" class="close-cancel" value="Cancel"><input type="button" class="close-submit" value="Vote to Close">';
            I += "</div>";
            var H = $(I);
            H.find('input[type="radio"]').click(function() {
                H.find(".close-submit").show()
            });
            H.find(".close-submit").click(function() {
                vote.close_reasonClick(F, H, D)
            });
            H.find(".close-cancel").click(function() {
                H.fadeOutAndRemove()
            });
            F.parent().append(H);
            H.fadeIn("fast")
        },
        close_reasonExactDuplicateId: 1,
        close_hasLinkedDuplicateQuestions: false,
        close_reasonClick: function(D, E, C) {
            var F = E.find('input[type="radio"]:checked').val();
            if (F == vote.close_reasonExactDuplicateId) {
                vote.close_duplicateForm(D, E, C)
            } else {
                E.fadeOutAndRemove();
                appendLoader(D);
                p(D, C, k.close, vote.close_result, {
                    "close-reason-id": F
                })
            }
        },
        close_duplicateForm: function(F, G, D) {
            G.find("h2, ul, .close-submit").remove();
            G.css("width", "490px");
            var H = "duplicate-question-" + D;
            var E = '<div style="padding-bottom:18px"><h2>This question is a duplicate of which other question?</h2><input id="' + H + '" type="text" size="78"><br><span class="close-duplicate-prompt">Type a question id or title to search for valid targets</span><div class="existing-linked-questions"></div></div><input type="button" class="close-submit" value="Vote to Close">';
            var C = $(E);
            C.find("#" + H).autocomplete("/search/duplicate-questions/" + D, {
                highlightItem: true,
                matchContains: true,
                scroll: true,
                scrollHeight: 300,
                formatItem: function(I) {
                    G.find("a.close-submit").hide();
                    var K = I[0];
                    var J = I[1];
                    return (K == "-1") ? ('<b style="color:#990000">' + J + "</b>") : (K + " - " + J)
                },
                formatResult: function(I) {
                    var J = I[0];
                    return (J == "-1") ? " ": J
                }
            }).result(function(J, I) {
                G.find(".close-submit").toggle((I && I[0] != "-1"))
            });
            G.prepend(C);
            vote.close_showExistingDuplicates(G, D);
            G.find("#" + H).focus();
            G.find(".close-submit").click(function() {
                G.fadeOutAndRemove();
                p(F, D, k.close, vote.close_result, {
                    "close-reason-id": vote.close_reasonExactDuplicateId,
                    "duplicate-question-id": $("#" + H).val()
                })
            })
        },
        close_showExistingDuplicates: function(H, C) {
            var G = false;
            for (var E = 0; E < vote.close_reasons.length; E++) {
                var F = vote.close_reasons[E];
                if (F.id == vote.close_reasonExactDuplicateId) {
                    if (F.count > 0) {
                        G = true
                    }
                    break
                }
            }
            if (!G) {
                return
            }
            var D = H.find("div.existing-linked-questions");
            appendLoader(D);
            D.append("<p>Other users chose these questions as the master question:</p>");
            $.getJSON("/posts/existing-close-duplicate-questions/" + C,
            function(J) {
                removeLoader();
                for (var I = 0; I < J.length; I++) {
                    D.append('<li><a href="' + J[I].url + '" target="_blank">' + J[I].title + "</a></li>")
                }
            })
        },
        close_result: function(D, C, F) {
            removeLoader();
            if (F && F.Success) {
                if (F.Message) {
                    var G = D.text().indexOf("open") > -1;
                    D.text(D.text().replace(/\w?\(\d\)/, "") + " " + F.Message);
                    u(D, "This question still needs " + F.NewScore + " vote(s) from other users to " + (G ? "reopen": "close"))
                } else {
                    location.reload(true)
                }
                vote.close_reasons = null
            } else {
                var E = D.parent();
                if (F && F.Message) {
                    showAjaxError(E, F.Message)
                } else {
                    showAjaxError(E, "A problem occurred during closing/reopening")
                }
            }
        },
        deletion: function(E) {
            var C = E.attr("id").substring("delete-post-".length);
            var D = E.text().indexOf("undelete") > -1;
            if (confirm("Vote to " + (D ? "un": "") + "delete this post?")) {
                p(E, C, (D ? k.undeletion: k.deletion), vote.deletionCallback)
            }
        },
        deletionCallback: function(F, E, G) {
            var H = F.text().indexOf("undelete") > -1;
			
            if (G && G.Success) {
				//alert(G);
                F.text(G.Message);
                if (G.NewScore < 0) {
                    var D = $("#question:has(a[id='delete-post-" + E + "'])").length > 0;
                    var C = D ? "#question, div.answer": "#answer-" + E;
			//		alert(C);
                    vote.setDeleteStyles($(C), !H)
                } else {
                    u(F, "This post still needs " + G.NewScore + " vote(s) from other users to " + (H ? "un": "") + "delete")
                }
            } else {
                var I = (G && G.Message) ? G.Message: "A problem occurred during " + (H ? "un": "") + "deletion";
                showAjaxError(F.parent(), I)
            }
        },
        setDeleteStyles: function(D, C) {
            if (C) {
                $("div.question-status:has(span:contains('delete'))").show();
                D.addClass("deleted-answer").find("a[id^='delete-post-']").addClass("deleted-post").end().find("div[id^='comments-']").addClass("comments-container-deleted").end().find("a[id^='comments-link-']").addClass("comments-link-deleted")
            } else {
                document.location.reload(true)
            }
        },
        bountyStart: function(D) {
            var C = $("#question div.vote input:first").val();
            //$.post("/posts/" + C + "/bounty-start", {
			  $.post("/ajax/" + C + "/bounty-start", {
                fkey: fkey,
                amount: D
            },
            function(E) {
                if (E.Success) {
                    location.reload(true)
                } else {
                    u($("#bounty-errors"), E.Message);
                    $("#bounty-submit").attr("disabled", "")
                }
            },
            "json")
        }
    }
} ();
var comments = function() {
    var l = imagePath + "comment-flag.png";
    var f = imagePath + "comment-flag-hover.png";
    var c = imagePath + "comment-up.png";
    var m = imagePath + "comment-up-hover.png";
    var e = imagePath + "comment-del.png";
    var i = imagePath + "comment-del-hover.png";
    var q = 600;
    var b = function(r) {
        return $("#comments-" + r)
    };
    var o = function(r) {
        appendLoader("#comments-" + r + " div.comments")
    };
    var j = function(s, v) {
        var r = $("#form-comments-" + s);
        if (r.length > 0) {
            var u = '<table><tr><td><textarea name="comment" cols="68" rows="3" maxlength="' + q;
            u += '" onblur="comments.updateTextCounter(this)" ';
            u += 'onfocus="comments.updateTextCounter(this)" onkeyup="comments.updateTextCounter(this)"></textarea>';
            u += '<input type="submit" value="Add Comment" /></td></tr><tr><td><span class="text-counter"></span>';
            u += '<span class="form-error"></span></td></tr></table>';
            r.append(u);
            r.submit(function() {
                var w = true;
                var x = function(y) {
                    w = y
                };
                bindLengthValidation(r.find("textarea"), 5, "* required - at least 15 characters", r.find(".form-error"), x);
                if (w) {
                    disableSubmitButton(r);
                    g(s, r)
                }
                return false
            });
            var t = $("#comments-" + s + " tr.comment:first td.comment-actions").width() || -1;
            t += 9;
            r.children("table").css("margin-left", t + "px")
        }
    };
    var h = function(r, s) {
        o(r);
        $.ajax({
            type: "GET",
            //url: "/posts/" + r + "/comments",
			url: "/ajax/" + r + "/comments",
            dataType: "html",
            success: function(t) {
                a(r, t)
            },
            error: function(t, v, u) {
                removeLoader();               
                showAjaxError("#comments-" + r, (t.responseText && t.responseText.length < 50 ? t.responseText: "An error has occured while fetching comments"))
            }
        })
    };
    var a = function(r, s) {
        var t = b(r).find("div.comments");
        if (t.children().length > 0) {
            t.children().remove()
        }
        t.append(s);
        n();
        p();
        removeLoader()
    };
    var d = function(t) {
        var r = "";
        if (t && t > 0) {
            var s = t < 5 ? "": t <= 15 ? "warm": t <= 30 ? "hot": "supernova";
            r += '<span title="number of \'great comment\' votes received" class="' + s + '">' + t + "</span>"
        }
        return r
    };
    var p = function() {
        $("img.comment-up").click(function() {
            k($(this), 2, c, m,
            function(s, r) {
                s.closest("tr").siblings("tr").remove();
                s.parent().siblings().children().remove();
                s.parent().siblings().append(d(r.NewScore))
            })
        }).hover(function() {
            $(this).attr("src", m)
        },
        function() {
            $(this).attr("src", c)
        });
        $("img.comment-flag").click(function() {            
             if (confirm("Really flag this comment as noise, offensive or spam?")) {	
                k($(this), 4, l, f,
                function(s, r) {
                    if (r.NewScore == -1) {
                        s.parents("tr.comment").remove()
                    } else {
                        s.parents("tr.comment").find("img.comment-up").remove();
                        s.remove()
                    }
                })
            }
        }).hover(function() {
            $(this).attr("src", f)
        },
        function() {
            $(this).attr("src", l)
        });
        $("img.comment-delete").click(function() {
            if (confirm("Really delete this comment?")) {
                k($(this), 10, e, i,
                function(s, r) {
                    s.parents("tr.comment").remove()
                })
            }
        }).hover(function() {
            $(this).attr("src", i)
        },
        function() {
            $(this).attr("src", e)
        });
        $("tr.comment").hover(function() {
            $(this).find("img.comment-up, img.comment-flag, img.comment-delete").css("visibility", "visible").closest("tr.comment").addClass("comment-hover")
        },
        function() {
            $(this).removeClass("comment-hover").find("img.comment-up, img.comment-flag, img.comment-delete").css("visibility", "hidden")
        })
    };
    var n = function() {
        $("tr.comment").unbind("mouseenter mouseleave");
        $("img.comment-up, img.comment-flag, img.comment-delete").unbind("click mouseenter mouseleave")
    };
    var k = function(y, u, x, v, t) {
        var w = y.parents("tr.comment").attr("id").substr("comment-".length);
        var s = y.attr("class");
        $("div.error-notification").hide();
        y.removeClass().unbind("click mouseenter mouseleave").attr("src", v);
        appendLoader(y.parent());
        var r = function() {
            y.addClass(s).click(function() {
                k(y, u, x, v, t)
            }).attr("src", x)
        };
        $.ajax({
            type: "POST",
           // url: "/posts/comments/" + w + "/vote/" + u,
		    url: "/ajax/" + w + "/vote/" + u,
		//	{"Success":true,"NewScore":-1,"Message":null,"LastVoteTypeId":null}
            dataType: "json",
            data: {
                fkey: fkey
            },
            success: function(z) {
                if (z.Success) {
                    t(y, z)
                } else {
                    showAjaxError(y.parent(), z.Message);
                    r()
                }
            },
            error: function(z, B, A) {
                showAjaxError(y.parent(), (z.responseText && z.responseText.length < 100 ? z.responseText: "An error occurred during voting"));
                r()
            }
        });
        removeLoader()
    };
    var g = function(t, s) {
        var r = s.find("textarea");
        if (r.val() && r.val().length > q) {
            showAjaxError(s, "Comments are limited to " + q + " ");
            enableSubmitButton(s);
            return
        }
        o(t);
        var u = function() {
            $(".error-notification").fadeOut("fast",
            function() {
                $(this).remove()
            })
        };
        $.ajax({
            type: "POST",
           // url: "/posts/" + t + "/comments",
		   //貌似是此处有效，另一处待测试
			url: "/ajax/" + t + "/comments",
            dataType: "html",
            data: {
                comment: r.val(),
                fkey: fkey
            },
            success: function(v) {
                u();
                a(t, v);
                r.val("");
                comments.updateTextCounter(r);
                enableSubmitButton(s)
            },
            error: function(v, x, w) {
                removeLoader();
                u();
                 showAjaxError(s, (v.responseText && v.responseText.length < 100 ? v.responseText: "An error occurred during comment submission"));
                enableSubmitButton(s)
            }
        })
    };
    return {
        init: function() {
            $("a[id^='comments-link-']").unbind("click").click(function() {
                var r = $(this).attr("id").substr("comments-link-".length);
                var u = b(r);
                j(r, u);
                u.removeClass("display-none");
				
				//xcl 查看全部评论，与界面上的文字有关。。。
                if ($(this).text().indexOf("more comment") > -1) 
				{
					
                    h(r, u)
                } else {
                    var s = u.find("form textarea");
                    var t = 200 + ($('form[id^="form-comments-"] > table').length * 2);
                    s.attr("tabindex", t++);
                    u.find("form input").attr("tabindex", t);
                    s.focus()
                }
                $(this).hide()
            });
            p()
        },
        updateTextCounter: function(t, s) {
            if (!s) {
                s = q
            }
            var u = t.value ? t.value.length: 0;
            var r = u > s * 0.8 ? "supernova": u > s * 0.6 ? "hot": u > s * 0.4 ? "warm": "cool";
            var v = $(t);
			v.parents("form").find("span.text-counter").html((s - u) + " character" + (u < s - 1 ? "s": "") + " left").removeClass().addClass("text-counter").addClass(r)
        }
    }
} ();
function editorReady(a) {
    $.get("/questions/ticks",
    function(b) {
        $("#post-editor-hidden").append("<input type='hidden' name='i1l' value='" + b + "' />")
    });
    if ($("#show-editor-button").length == 0) {
        initPostEditor(a)
    }
}
function initPostEditor(c) {
	//xcl:不再需要此编辑器，且干掉wmd.js文件
	/*
    var b = $("#post-form");
    var a = $("#question_content");
    b.submit(function() {
        var d = true;
        var e = function(f) {
            d = f
        };
        bindLengthValidation("#question_title", 3, "* required - at least 3 characters", null, e);
        bindLengthValidation(a, 15, "* required - at least 15 characters", $("#wmd-form-error").find(".form-error"), e);
        bindLengthValidation("#question_tags", 1, "* required", null, e);
        bindLengthValidation("#display-name", 1, "* required if you're not using an OpenID", $('label[for="display-name"] > span.form-error'), e, "#openid_identifier");
        bindLengthValidation("#m-address", 1, "* required if you're not login", $('label[for="m-address"] > span.form-error'), e, "#openid_identifier");
        if (d) {
            disableSubmitButton(b);
            setConfirmUnload(null)
        }
        return d
    });
    a.not(".processed").TextAreaResizer();
    a.typeWatch({
        highlight: false,
        wait: 5000,
        captureLength: 5,
        callback: styleCode
    });
    Attacklab.wmdBase();
    Attacklab.Util.startEditor();
    if (c) {
        a.keypress(heartbeat.start)
    }
    a.keypress(initNavPrevention)
	*/
}
var invalidElements = function() {
    var b = [];
    var a = function(c) {
        return c.attr("name")
    };
    return {
        add: function(e) {
            var c = a(e);
            var f = true;
            for (var d = 0; d < b.length; d++) {
                if (b[d] == c) {
                    f = false;
                    break
                }
            }
            if (f) {
                b.push(c)
            }
        },
        remove: function(e) {
            var c = a(e);
            for (var d = 0; d < b.length; d++) {
                if (b[d] == c) {
                    b.splice(d, 1)
                }
            }
        },
        any: function() {
            return b.length > 0
        }
    }
} ();
function bindLengthValidation(f, a, d, b, e, c) {
    $(f).each(function() {
        var j = $(this);
        var i = j.parents("form");
        var h = b ? $(b) : j.parent().find(".form-error");
        var m = function() {
            return j.val().length >= a
        };
        var g = function() {
            h.text(d)
        };
        var n = function() {
            g();
            disableSubmitButton(i);
            invalidElements.add(j)
        };
        var l = function() {
            return (c && $(c).val().length > 0)
        };
        if (!l() && !m()) {
            e(false);
            n();
            if (!j.attr("hasLengthValidationEvent")) {
                j.attr("hasLengthValidationEvent", "true");
                var k = function() {
                    if (!l() && !m()) {
                        n()
                    } else {
                        h.text("");
                        invalidElements.remove(j);
                        if (!invalidElements.any()) {
                            enableSubmitButton(i)
                        }
                    }
                };
                j.keyup(k);
                if (c) {
                    $(c).keyup(k)
                }
            }
        }
    })
}
function initNavPrevention(a) {
    if (a.which == "undefined") {
		alert('undefined');
        return
    }
    $("#wmd-input").unbind("keypress", initNavPrevention);
    setConfirmUnload("You have started writing or editing a post.")
}
var heartbeat = function() {
    var d = 1000 * 60;
    var b;
    var e = 0;
    var a = false;
    var c = 0;
    return {
        start: function(f) {
            if (f.which == "undefined") {
                return
            }
            if (e++>0) {
                return
            }
            $("#wmd-input").unbind("keypress", heartbeat.start);
            b = location.href.match(/\/questions\/(\d+)/i)[1];
            setTimeout(heartbeat.ping, d)
        },
        ping: function() {
            var f = "";
            $("div.answer").each(function() {
                f += this.id.substring("answer-".length) + " "
            });
            $.post("/posts/" + b + "/new-activity-heartbeat", {
                answerIds: f
            },
            heartbeat.result, "json")
        },
        result: function(g) {
            var f = ++c < 30;
            if (g && !a) {
                if (g.NoPosting) {
                    var h = "This question has been " + g.Msg + " - no more answers will be accepted.";
                    notify.show(h);
                    a = true;
                    disableSubmitButton("#post-form");
                    setConfirmUnload(null);
                    f = false
                } else {
                    if (g.Result) {                       
                        var h = g.Count + " new answer" + (g.Count == 1 ? " has": "s have") + " been posted - ";
                        h += '<a onclick="heartbeat.update()">load new answers.</a>';
                        notify.show(h);
                        a = true
                    }
                }
            }
            if (f) {
                setTimeout(heartbeat.ping, d)
            }
        },
        update: function() {
            var f = [];
            $.get("/questions/" + b,
            function(i) {
                var l = $(i);
                l.find("div.answer").each(function() {
                    var m = this.id.substring("answer-".length);
                    if ($("#answer-" + m).length == 0) {
                        f.push(this.id)
                    }
                });
                if (f.length > 0) {
                    var h = "#" + f.join(",#");
                    var k = l.find(h);
                    var g = $("div.answer:last");
                    if (g.length == 0) {
                        g = $("#answers-header")
                    }
                    k.hide();
                    g.after(k);
                    k.fadeIn("slow");
                    var j = $("div.answer").length;
                    $("#subheader h2").text(j + " Answer" + (j > 1 ? "s": ""));
                    vote.init(b);
                    comments.init()
                }
                notify.close();
                a = false
            },
            "html")
        }
    }
} (); (function(a) {
    a.fn.typeWatch = function(d) {
        var b = a.extend({
            wait: 750,
            callback: function() {},
            highlight: true,
            captureLength: 2
        },
        d);
        function c(h, g) {
            var f = a(h.el).val();
            if ((f.length > b.captureLength && f.toUpperCase() != h.text) || (g && f.length > b.captureLength)) {
                h.text = f.toUpperCase();
                h.cb(f)
            }
        }
        function e(g) {
            if (g.type.toUpperCase() == "TEXT" || g.nodeName.toUpperCase() == "TEXTAREA") {
                var h = {
                    timer: null,
                    text: a(g).val().toUpperCase(),
                    cb: b.callback,
                    el: g,
                    wait: b.wait
                };
                if (b.highlight) {
                    a(g).focus(function() {
                        this.select()
                    })
                }
                var f = function(i) {
                    var l = h.wait;
                    var k = false;
                    if (i.keyCode == 13 && this.type.toUpperCase() == "TEXT") {
                        l = 1;
                        k = true
                    }
                    var j = function() {
                        c(h, k)
                    };
                    clearTimeout(h.timer);
                    h.timer = setTimeout(j, l)
                };
                a(g).keydown(f)
            }
        }
        return this.each(function(f) {
            e(this)
        })
    }
})(jQuery); (function(c) {
    var h, i;
    var d = 0;
    var a = 32;
    var e;
    c.fn.TextAreaResizer = function() {
        return this.each(function() {
            h = c(this).addClass("processed"),
            i = null;
            c(this).parent().append(c('<div class="grippie"></div>').bind("mousedown", {
                el: this
            },
            b));
            var k = c("div.grippie", c(this).parent())[0];
            k.style.marginRight = (k.offsetWidth - c(this)[0].offsetWidth) + "px"
        })
    };
    function b(k) {
        h = c(k.data.el);
        h.blur();
        d = j(k).y;
        i = h.height() - d;
        h.css("opacity", 0.25);
        c(document).mousemove(g).mouseup(f);
        return false
    }
    function g(m) {
        var k = j(m).y;
        var l = i + k;
        if (d >= (k)) {
            l -= 5
        }
        d = k;
        l = Math.max(a, l);
        h.height(l + "px");
        if (l < a) {
            f(m)
        }
        return false
    }
    function f(k) {
        c(document).unbind("mousemove", g).unbind("mouseup", f);
        h.css("opacity", 1);
        h.focus();
        h = null;
        i = null;
        d = 0
    }
    function j(k) {
        return {
            x: k.clientX + document.documentElement.scrollLeft,
            y: k.clientY + document.documentElement.scrollTop
        }
    }
})(jQuery);

/*---- question.js end ----*/

/*---- tageditor.js ----*/
function bindTagFilterAutoComplete(a) {
    $(a).autocomplete("/ajax/tags", {
        max: 6,
        highlightItem: true,
        multiple: true,
        multipleSeparator: " ",
        matchContains: true,
        scroll: true,
        scrollHeight: 300,
        formatItem: function(d) {
            var b = d[0];
            var c = d[1];
            return b + " (" + c + ")"
        },
        formatResult: function(c) {
            var b = c[0];
            return b
        }
    })
} 
(function(a) {
    a.fn.extend({
        autocomplete: function(b, c) {
            var d = typeof b == "string";
            c = a.extend({},
            a.Autocompleter.defaults, {
                url: d ? b: null,
                data: d ? null: b,
                delay: d ? a.Autocompleter.defaults.delay: 10,
                max: c && !c.scroll ? 10 : 150
            },
            c);
            c.highlight = c.highlight ||
            function(e) {
                return e
            };
            c.formatMatch = c.formatMatch || c.formatItem;
            return this.each(function() {
                new a.Autocompleter(this, c)
            })
        },
        result: function(b) {
            return this.bind("result", b)
        },
        search: function(b) {
            return this.trigger("search", [b])
        },
        flushCache: function() {
            return this.trigger("flushCache")
        },
        setOptions: function(b) {
            return this.trigger("setOptions", [b])
        },
        unautocomplete: function() {
            return this.trigger("unautocomplete")
        }
    });
    a.Autocompleter = function(l, g) {
        var c = {
            UP: 38,
            DOWN: 40,
            DEL: 46,
            TAB: 9,
            RETURN: 13,
            ESC: 27,
            COMMA: 188,
            PAGEUP: 33,
            PAGEDOWN: 34,
            BACKSPACE: 8
        };
        var b = a(l).attr("autocomplete", "off").addClass(g.inputClass);
        var j;
        var p = "";
        var m = a.Autocompleter.Cache(g);
        var e = 0;
        var u;
        var x = {
            mouseDownOnSelect: false
        };
        var r = a.Autocompleter.Select(g, l, d, x);
        var w;
        a.browser.opera && a(l.form).bind("submit.autocomplete",
        function() {
            if (w) {
                w = false;
                return false
            }
        });
        b.bind((a.browser.opera ? "keypress": "keydown") + ".autocomplete",
        function(y) {
            u = y.keyCode;
            switch (y.keyCode) {
            case c.UP:
                y.preventDefault();
                if (r.visible()) {
                    r.prev()
                } else {
                    t(0, true)
                }
                break;
            case c.DOWN:
                y.preventDefault();
                if (r.visible()) {
                    r.next()
                } else {
                    t(0, true)
                }
                break;
            case c.PAGEUP:
                y.preventDefault();
                if (r.visible()) {
                    r.pageUp()
                } else {
                    t(0, true)
                }
                break;
            case c.PAGEDOWN:
                y.preventDefault();
                if (r.visible()) {
                    r.pageDown()
                } else {
                    t(0, true)
                }
                break;
            case g.multiple && a.trim(g.multipleSeparator) == "," && c.COMMA: case c.TAB:
            case c.RETURN:
                if (d()) {
                    y.preventDefault();
                    w = true;
                    return false
                }
                break;
            case c.ESC:
                r.hide();
                break;
            default:
                clearTimeout(j);
                j = setTimeout(t, g.delay);
                break
            }
        }).focus(function() {
            e++
        }).blur(function() {
            e = 0;
            if (!x.mouseDownOnSelect) {
                s()
            }
        }).click(function() {
            if (e++>1 && !r.visible()) {
                t(0, true)
            }
        }).bind("search",
        function() {
            var y = (arguments.length > 1) ? arguments[1] : null;
            function z(D, C) {
                var A;
                if (C && C.length) {
                    for (var B = 0; B < C.length; B++) {
                        if (C[B].result.toLowerCase() == D.toLowerCase()) {
                            A = C[B];
                            break
                        }
                    }
                }
                if (typeof y == "function") {
                    y(A)
                } else {
                    b.trigger("result", A && [A.data, A.value])
                }
            }
            a.each(h(b.val()),
            function(A, B) {
                f(B, z, z)
            })
        }).bind("flushCache",
        function() {
            m.flush()
        }).bind("setOptions",
        function() {
            a.extend(g, arguments[1]);
            if ("data" in arguments[1]) {
                m.populate()
            }
        }).bind("unautocomplete",
        function() {
            r.unbind();
            b.unbind();
            a(l.form).unbind(".autocomplete")
        });
        function d() {
            var B = r.selected();
            if (!B) {
                return false
            }
            var y = B.result;
            p = y;
            if (g.multiple) {
                var E = h(b.val());
                if (E.length > 1) {
                    var A = g.multipleSeparator.length;
                    var D = a(l).selection().start;
                    var C, z = 0;
                    a.each(E,
                    function(F, G) {
                        z += G.length;
                        if (D <= z) {
                            C = F;
                            return false
                        }
                        z += A
                    });
                    E[C] = y;
                    y = E.join(g.multipleSeparator)
                }
                y += g.multipleSeparator
            }
            b.val(y);
            v();
            b.trigger("result", [B.data, B.value]);
            return true
        }
        function t(A, z) {
            if (u == c.DEL) {
                r.hide();
                return
            }
            var y = b.val();
            if (!z && y == p) {
                return
            }
            p = y;
            y = i(y);
            if (y.length >= g.minChars) {
                b.addClass(g.loadingClass);
                if (!g.matchCase) {
                    y = y.toLowerCase()
                }
                f(y, k, v)
            } else {
                n();
                r.hide()
            }
        }
        function h(z) {
            if (!z) {
                return [""]
            }
            var A = z.split(g.multipleSeparator);
            var y = [];
            a.each(A,
            function(B, C) {
                if (a.trim(C)) {
                    y[B] = a.trim(C)
                }
            });
            return y
        }
        function i(y) {
            if (!g.multiple) {
                return y
            }
            var A = h(y);
            if (A.length == 1) {
                return A[0]
            }
            var z = a(l).selection().start;
            if (z == y.length) {
                A = h(y)
            } else {
                A = h(y.replace(y.substring(z), ""))
            }
            return A[A.length - 1]
        }
        function q(y, z) {
            if (g.autoFill && (i(b.val()).toLowerCase() == y.toLowerCase()) && u != c.BACKSPACE) {
                b.val(b.val() + z.substring(i(p).length));
                a(l).selection(p.length, p.length + z.length)
            }
        }
        function s() {
            clearTimeout(j);
            j = setTimeout(v, 200)
        }
        function v() {
            var y = r.visible();
            r.hide();
            clearTimeout(j);
            n();
            if (g.mustMatch) {
                b.search(function(z) {
                    if (!z) {
                        if (g.multiple) {
                            var A = h(b.val()).slice(0, -1);
                            b.val(A.join(g.multipleSeparator) + (A.length ? g.multipleSeparator: ""))
                        } else {
                            b.val("")
                        }
                    }
                })
            }
        }
        function k(z, y) {
            if (y && y.length && e) {
                n();
                r.display(y, z);
                q(z, y[0].value);
                r.show()
            } else {
                v()
            }
        }
        function f(z, B, y) {
            if (!g.matchCase) {
                z = z.toLowerCase()
            }
            var A = m.load(z);
            if (A && A.length) {
                B(z, A)
            } else {
                if ((typeof g.url == "string") && (g.url.length > 0)) {
                    var C = {
                        timestamp: +new Date()
                    };
                    a.each(g.extraParams,
                    function(D, E) {
                        C[D] = typeof E == "function" ? E() : E
                    });
                    a.ajax({
                        mode: "abort",
                        port: "autocomplete" + l.name,
                        dataType: g.dataType,
                        url: g.url,
                        data: a.extend({
                            q: i(z),
                            limit: g.max
                        },
                        C),
                        success: function(E) {
                            var D = g.parse && g.parse(E) || o(E);
                            m.add(z, D);
                            B(z, D)
                        }
                    })
                } else {
                    r.emptyList();
                    y(z)
                }
            }
        }
        function o(B) {
            var y = [];
            var A = B.split("\n");
            for (var z = 0; z < A.length; z++) {
                var C = a.trim(A[z]);
                if (C) {
                    C = C.split("|");
                    y[y.length] = {
                        data: C,
                        value: C[0],
                        result: g.formatResult && g.formatResult(C, C[0]) || C[0]
                    }
                }
            }
            return y
        }
        function n() {
            b.removeClass(g.loadingClass)
        }
    };
    a.Autocompleter.defaults = {
        inputClass: "ac_input",
        resultsClass: "ac_results",
        loadingClass: "ac_loading",
        minChars: 1,
        delay: 400,
        matchCase: false,
        matchSubset: true,
        matchContains: false,
        cacheLength: 10,
        max: 100,
        mustMatch: false,
        extraParams: {},
        selectFirst: true,
        formatItem: function(b) {
            return b[0]
        },
        formatMatch: null,
        autoFill: false,
        width: 0,
        multiple: false,
        multipleSeparator: ", ",
        highlight: function(c, b) {
            return c.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + b.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi, "\\$1") + ")(?![^<>]*>)(?![^&;]+;)", "gi"), "<strong>$1</strong>")
        },
        scroll: true,
        scrollHeight: 180
    };
    a.Autocompleter.Cache = function(c) {
        var f = {};
        var d = 0;
        function h(l, k) {
            if (!c.matchCase) {
                l = l.toLowerCase()
            }
            var j = l.indexOf(k);
            if (c.matchContains == "word") {
                j = l.toLowerCase().search("\\b" + k.toLowerCase())
            }
            if (j == -1) {
                return false
            }
            return j == 0 || c.matchContains
        }
        function g(j, i) {
            if (d > c.cacheLength) {
                b()
            }
            if (!f[j]) {
                d++
            }
            f[j] = i
        }
        function e() {
            if (!c.data) {
                return false
            }
            var k = {},
            j = 0;
            if (!c.url) {
                c.cacheLength = 1
            }
            k[""] = [];
            for (var m = 0,
            l = c.data.length; m < l; m++) {
                var p = c.data[m];
                p = (typeof p == "string") ? [p] : p;
                var o = c.formatMatch(p, m + 1, c.data.length);
                if (o === false) {
                    continue
                }
                var n = o.charAt(0).toLowerCase();
                if (!k[n]) {
                    k[n] = []
                }
                var q = {
                    value: o,
                    data: p,
                    result: c.formatResult && c.formatResult(p) || o
                };
                k[n].push(q);
                if (j++<c.max) {
                    k[""].push(q)
                }
            }
            a.each(k,
            function(r, s) {
                c.cacheLength++;
                g(r, s)
            })
        }
        setTimeout(e, 25);
        function b() {
            f = {};
            d = 0
        }
        return {
            flush: b,
            add: g,
            populate: e,
            load: function(n) {
                if (!c.cacheLength || !d) {
                    return null
                }
                if (!c.url && c.matchContains) {
                    var m = [];
                    for (var j in f) {
                        if (j.length > 0) {
                            var o = f[j];
                            a.each(o,
                            function(p, k) {
                                if (h(k.value, n)) {
                                    m.push(k)
                                }
                            })
                        }
                    }
                    return m
                } else {
                    if (f[n]) {
                        return f[n]
                    } else {
                        if (c.matchSubset) {
                            for (var l = n.length - 1; l >= c.minChars; l--) {
                                var o = f[n.substr(0, l)];
                                if (o) {
                                    var m = [];
                                    a.each(o,
                                    function(p, k) {
                                        if (h(k.value, n)) {
                                            m[m.length] = k
                                        }
                                    });
                                    return m
                                }
                            }
                        }
                    }
                }
                return null
            }
        }
    };
    a.Autocompleter.Select = function(e, j, l, p) {
        var i = {
            ACTIVE: "ac_over"
        };
        var k, f = -1,
        r, m = "",
        s = true,
        c, o;
        function n() {
            if (!s) {
                return
            }
            c = a("<div/>").hide().addClass(e.resultsClass).css("position", "absolute").appendTo(document.body);
            o = a("<ul/>").appendTo(c).mouseover(function(t) {
                if (q(t).nodeName && q(t).nodeName.toUpperCase() == "LI") {
                    f = a("li", o).removeClass(i.ACTIVE).index(q(t));
                    a(q(t)).addClass(i.ACTIVE)
                }
            }).click(function(t) {
                a(q(t)).addClass(i.ACTIVE);
                l();
                j.focus();
                return false
            }).mousedown(function() {
                p.mouseDownOnSelect = true
            }).mouseup(function() {
                p.mouseDownOnSelect = false
            });
            if (e.width > 0) {
                c.css("width", e.width)
            }
            s = false
        }
        function q(u) {
            var t = u.target;
            while (t && t.tagName != "LI") {
                t = t.parentNode
            }
            if (!t) {
                return []
            }
            return t
        }
        function h(t) {
            k.slice(f, f + 1).removeClass(i.ACTIVE);
            g(t);
            var v = k.slice(f, f + 1).addClass(i.ACTIVE);
            if (e.scroll) {
                var u = 0;
                k.slice(0, f).each(function() {
                    u += this.offsetHeight
                });
                if ((u + v[0].offsetHeight - o.scrollTop()) > o[0].clientHeight) {
                    o.scrollTop(u + v[0].offsetHeight - o.innerHeight())
                } else {
                    if (u < o.scrollTop()) {
                        o.scrollTop(u)
                    }
                }
            }
        }
        function g(t) {
            f += t;
            if (f < 0) {
                f = k.size() - 1
            } else {
                if (f >= k.size()) {
                    f = 0
                }
            }
        }
        function b(t) {
            return e.max && e.max < t ? e.max: t
        }
        function d() {
            o.empty();
            var u = b(r.length);
            for (var v = 0; v < u; v++) {
                if (!r[v]) {
                    continue
                }
                var w = e.formatItem(r[v].data, v + 1, u, r[v].value, m);
                if (w === false) {
                    continue
                }
                var t = a("<li/>").html(e.highlight(w, m)).addClass(v % 2 == 0 ? "ac_even": "ac_odd").appendTo(o)[0];
                a.data(t, "ac_data", r[v])
            }
            k = o.find("li");
            if (e.selectFirst) {
                k.slice(0, 1).addClass(i.ACTIVE);
                f = 0
            }
            if (a.fn.bgiframe) {
                o.bgiframe()
            }
        }
        return {
            display: function(u, t) {
                n();
                r = u;
                m = t;
                d()
            },
            next: function() {
                h(1)
            },
            prev: function() {
                h( - 1)
            },
            pageUp: function() {
                if (f != 0 && f - 8 < 0) {
                    h( - f)
                } else {
                    h( - 8)
                }
            },
            pageDown: function() {
                if (f != k.size() - 1 && f + 8 > k.size()) {
                    h(k.size() - 1 - f)
                } else {
                    h(8)
                }
            },
            hide: function() {
                c && c.hide();
                k && k.removeClass(i.ACTIVE);
                f = -1
            },
            visible: function() {
                return c && c.is(":visible")
            },
            current: function() {
                return this.visible() && (k.filter("." + i.ACTIVE)[0] || e.selectFirst && k[0])
            },
            show: function() {
                var v = a(j).offset();
                c.css({
                    width: typeof e.width == "string" || e.width > 0 ? e.width: a(j).width(),
                    top: v.top + j.offsetHeight,
                    left: v.left
                }).show();
                if (e.scroll) {
                    o.scrollTop(0);
                    o.css({
                        maxHeight: e.scrollHeight,
                        overflow: "auto"
                    });
                    if (a.browser.msie && typeof document.body.style.maxHeight === "undefined") {
                        var t = 0;
                        k.each(function() {
                            t += this.offsetHeight
                        });
                        var u = t > e.scrollHeight;
                        o.css("height", u ? e.scrollHeight: t);
                        if (!u) {
                            k.width(o.width() - parseInt(k.css("padding-left")) - parseInt(k.css("padding-right")))
                        }
                    }
                }
            },
            selected: function() {
                var t = k && k.filter("." + i.ACTIVE).removeClass(i.ACTIVE);
                return t && t.length && a.data(t[0], "ac_data")
            },
            emptyList: function() {
                o && o.empty()
            },
            unbind: function() {
                c && c.remove()
            }
        }
    };
    a.fn.selection = function(i, b) {
        if (i !== undefined) {
            return this.each(function() {
                if (this.createTextRange) {
                    var j = this.createTextRange();
                    if (b === undefined || i == b) {
                        j.move("character", i);
                        j.select()
                    } else {
                        j.collapse(true);
                        j.moveStart("character", i);
                        j.moveEnd("character", b);
                        j.select()
                    }
                } else {
                    if (this.setSelectionRange) {
                        this.setSelectionRange(i, b)
                    } else {
                        if (this.selectionStart) {
                            this.selectionStart = i;
                            this.selectionEnd = b
                        }
                    }
                }
            })
        }
        var g = this[0];
        if (g.createTextRange) {
            var c = document.selection.createRange(),
            h = g.value,
            f = "<->",
            d = c.text.length;
            c.text = f;
            var e = g.value.indexOf(f);
            g.value = h;
            this.selection(e, e + d);
            return {
                start: e,
                end: e + d
            }
        } else {
            if (g.selectionStart !== undefined) {
                return {
                    start: g.selectionStart,
                    end: g.selectionEnd
                }
            }
        }
    }
})(jQuery); (function(a) {
    a.fn.bgIframe = a.fn.bgiframe = function(c) {
        if (a.browser.msie && /6.0/.test(navigator.userAgent)) {
            c = a.extend({
                top: "auto",
                left: "auto",
                width: "auto",
                height: "auto",
                opacity: true,
                src: "javascript:false;"
            },
            c || {});
            var d = function(e) {
                return e && e.constructor == Number ? e + "px": e
            },
            b = '<iframe class="bgiframe"frameborder="0"tabindex="-1"src="' + c.src + '"style="display:block;position:absolute;z-index:-1;' + (c.opacity !== false ? "filter:Alpha(Opacity='0');": "") + "top:" + (c.top == "auto" ? "expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+'px')": d(c.top)) + ";left:" + (c.left == "auto" ? "expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+'px')": d(c.left)) + ";width:" + (c.width == "auto" ? "expression(this.parentNode.offsetWidth+'px')": d(c.width)) + ";height:" + (c.height == "auto" ? "expression(this.parentNode.offsetHeight+'px')": d(c.height)) + ';"/>';
            return this.each(function() {
                if (a("> iframe.bgiframe", this).length == 0) {
                    this.insertBefore(document.createElement(b), this.firstChild)
                }
            })
        }
        return this
    }
})(jQuery);
/*---- tageditor.js end----*/
