// JScript 文件

var xmlJsonClass = {
    xml2json: function(a, e) {
        if (a.nodeType === 9) a = a.documentElement;
        a = this.toJson(this.toObj(this.removeWhite(a)), a.nodeName, "\t");
        return "{\n" + e + (e ? a.replace(/\t/g, e) : a.replace(/\t|\n/g, "")) + "\n}"
    },
    json2xml: function(a, e) {
        var d = function(g, h, j) {
            var c = "",
            k, l;
            if (g instanceof Array) if (g.length === 0) c += j + "<" + h + ">__EMPTY_ARRAY_</" + h + ">\n";
            else {
                k = 0;
                for (l = g.length; k < l; k += 1) {
                    var o = j + d(g[k], h, j + "\t") + "\n";
                    c += o
                }
            } else if (typeof g === "object") {
                k = false;
                c += j + "<" + h;
                for (l in g) if (g.hasOwnProperty(l)) if (l.charAt(0) === "@") c += " " + l.substr(1) + '="' + g[l].toString() + '"';
                else k = true;
                c += k ? ">": "/>";
                if (k) {
                    for (l in g) if (g.hasOwnProperty(l)) if (l === "#text") c += g[l];
                    else if (l === "#cdata") c += "<![CDATA[" + g[l] + "]]\>";
                    else if (l.charAt(0) !== "@") c += d(g[l], l, j + "\t");
                    c += (c.charAt(c.length - 1) === "\n" ? j: "") + "</" + h + ">"
                }
            } else c += typeof g === "function" ? j + "<" + h + "><![CDATA[" + g + "]]\></" + h + ">": g.toString() === '""' || g.toString().length === 0 ? j + "<" + h + ">__EMPTY_STRING_</" + h + ">": j + "<" + h + ">" + g.toString() + "</" + h + ">";
            return c
        },
        b = "",
        f;
        for (f in a) if (a.hasOwnProperty(f)) b += d(a[f], f, "");
        return e ? b.replace(/\t/g, e) : b.replace(/\t|\n/g, "")
    },
    toObj: function(a) {
        var e = {},
        d = /function/i;
        if (a.nodeType === 1) {
            if (a.attributes.length) {
                var b;
                for (b = 0; b < a.attributes.length; b += 1) e["@" + a.attributes[b].nodeName] = (a.attributes[b].nodeValue || "").toString()
            }
            if (a.firstChild) {
                var f = b = 0,
                g = false,
                h;
                for (h = a.firstChild; h; h = h.nextSibling) if (h.nodeType === 1) g = true;
                else if (h.nodeType === 3 && h.nodeValue.match(/[^ \f\n\r\t\v]/)) b += 1;
                else if (h.nodeType === 4) f += 1;
                if (g) if (b < 2 && f < 2) {
                    this.removeWhite(a);
                    for (h = a.firstChild; h; h = h.nextSibling) if (h.nodeType === 3) e["#text"] = this.escape(h.nodeValue);
                    else if (h.nodeType === 4) if (d.test(h.nodeValue)) e[h.nodeName] = [e[h.nodeName], h.nodeValue];
                    else e["#cdata"] = this.escape(h.nodeValue);
                    else if (e[h.nodeName]) if (e[h.nodeName] instanceof Array) e[h.nodeName][e[h.nodeName].length] = this.toObj(h);
                    else e[h.nodeName] = [e[h.nodeName], this.toObj(h)];
                    else e[h.nodeName] = this.toObj(h)
                } else if (a.attributes.length) e["#text"] = this.escape(this.innerXml(a));
                else e = this.escape(this.innerXml(a));
                else if (b) if (a.attributes.length) e["#text"] = this.escape(this.innerXml(a));
                else {
                    e = this.escape(this.innerXml(a));
                    if (e === "__EMPTY_ARRAY_") e = "[]";
                    else if (e === "__EMPTY_STRING_") e = ""
                } else if (f) if (f > 1) e = this.escape(this.innerXml(a));
                else for (h = a.firstChild; h; h = h.nextSibling) if (d.test(a.firstChild.nodeValue)) {
                    e = a.firstChild.nodeValue;
                    break
                } else e["#cdata"] = this.escape(h.nodeValue)
            }
            if (!a.attributes.length && !a.firstChild) e = null
        } else if (a.nodeType === 9) e = this.toObj(a.documentElement);
        else alert("unhandled node type: " + a.nodeType);
        return e
    },
    toJson: function(a, e, d) {
        var b = e ? '"' + e + '"': "";
        if (a === "[]") b += e ? ":[]": "[]";
        else if (a instanceof Array) {
            var f, g, h = [];
            g = 0;
            for (f = a.length; g < f; g += 1) h[g] = this.toJson(a[g], "", d + "\t");
            b += (e ? ":[": "[") + (h.length > 1 ? "\n" + d + "\t" + h.join(",\n" + d + "\t") + "\n" + d: h.join("")) + "]"
        } else if (a === null) b += (e && ":") + "null";
        else if (typeof a === "object") {
            f = [];
            for (g in a) if (a.hasOwnProperty(g)) f[f.length] = this.toJson(a[g], g, d + "\t");
            b += (e ? ":{": "{") + (f.length > 1 ? "\n" + d + "\t" + f.join(",\n" + d + "\t") + "\n" + d: f.join("")) + "}"
        } else if (typeof a === "string") {
            d = /function/i;
            f = a.toString();
            b += /(^-?\d+\.?\d*$)/.test(f) || d.test(f) || f === "false" || f === "true" ? (e && ":") + f: (e && ":") + '"' + a + '"'
        } else b += (e && ":") + a.toString();
        return b
    },
    innerXml: function(a) {
        var e = "";
        if ("innerHTML" in a) e = a.innerHTML;
        else {
            var d = function(b) {
                var f = "",
                g;
                if (b.nodeType === 1) {
                    f += "<" + b.nodeName;
                    for (g = 0; g < b.attributes.length; g += 1) f += " " + b.attributes[g].nodeName + '="' + (b.attributes[g].nodeValue || "").toString() + '"';
                    if (b.firstChild) {
                        f += ">";
                        for (g = b.firstChild; g; g = g.nextSibling) f += d(g);
                        f += "</" + b.nodeName + ">"
                    } else f += "/>"
                } else if (b.nodeType === 3) f += b.nodeValue;
                else if (b.nodeType === 4) f += "<![CDATA[" + b.nodeValue + "]]\>";
                return f
            };
            for (a = a.firstChild; a; a = a.nextSibling) e += d(a)
        }
        return e
    },
    escape: function(a) {
        return a.replace(/[\\]/g, "\\\\").replace(/[\"]/g, '\\"').replace(/[\n]/g, "\\n").replace(/[\r]/g, "\\r")
    },
    removeWhite: function(a) {
        a.normalize();
        var e;
        for (e = a.firstChild; e;) if (e.nodeType === 3) if (e.nodeValue.match(/[^ \f\n\r\t\v]/)) e = e.nextSibling;
        else {
            var d = e.nextSibling;
            a.removeChild(e);
            e = d
        } else {
            e.nodeType === 1 && this.removeWhite(e);
            e = e.nextSibling
        }
        return a
    }
}; (function(a) {
    a.jgrid = a.jgrid || {};
    a.extend(a.jgrid, {
        htmlDecode: function(e) {
            if (e == "&nbsp;" || e == "&#160;" || e.length == 1 && e.charCodeAt(0) == 160) return "";
            return ! e ? e: String(e).replace(/&amp;/g, "&").replace(/&gt;/g, ">").replace(/&lt;/g, "<").replace(/&quot;/g, '"')
        },
        htmlEncode: function(e) {
            return ! e ? e: String(e).replace(/&/g, "&amp;").replace(/>/g, "&gt;").replace(/</g, "&lt;").replace(/\"/g, "&quot;")
        },
        format: function(e) {
            var d = a.makeArray(arguments).slice(1);
            if (e === undefined) e = "";
            return e.replace(/\{(\d+)\}/g,
            function(b, f) {
                return d[f]
            })
        },
        getCellIndex: function(e) {
            e = a(e);
            if (e.is("tr")) return - 1;
            e = (!e.is("td") && !e.is("th") ? e.closest("td,th") : e)[0];
            if (a.browser.msie) return a.inArray(e, e.parentNode.cells);
            return e.cellIndex
        },
        stripHtml: function(e) {
            e += "";
            var d = /<("[^"]*"|'[^']*'|[^'">])*>/gi;
            if (e) return (e = e.replace(d, "")) && e !== "&nbsp;" && e !== "&#160;" ? e.replace(/\"/g, "'") : "";
            else return e
        },
        stringToDoc: function(e) {
            var d;
            if (typeof e !== "string") return e;
            try {
                d = (new DOMParser).parseFromString(e, "text/xml")
            } catch(b) {
                d = new ActiveXObject("Microsoft.XMLDOM");
                d.async = false;
                d.loadXML(e)
            }
            return d && d.documentElement && d.documentElement.tagName != "parsererror" ? d: null
        },
        parse: function(e) {
            e = e;
            if (e.substr(0, 9) == "while(1);") e = e.substr(9);
            if (e.substr(0, 2) == "/*") e = e.substr(2, e.length - 4);
            e || (e = "{}");
            return a.jgrid.useJSON === true && typeof JSON === "object" && typeof JSON.parse === "function" ? JSON.parse(e) : eval("(" + e + ")")
        },
        parseDate: function(e, d) {
            var b = {
                m: 1,
                d: 1,
                y: 1970,
                h: 0,
                i: 0,
                s: 0
            },
            f,
            g,
            h;
            if (d && d !== null && d !== undefined) {
                d = a.trim(d);
                d = d.split(/[\\\/:_;.\t\T\s-]/);
                e = e.split(/[\\\/:_;.\t\T\s-]/);
                var j = a.jgrid.formatter.date.monthNames,
                c = a.jgrid.formatter.date.AmPm,
                k = function(l, o) {
                    if (l === 0) {
                        if (o == 12) o = 0
                    } else if (o != 12) o += 12;
                    return o
                };
                f = 0;
                for (g = e.length; f < g; f++) {
                    if (e[f] == "M") {
                        h = a.inArray(d[f], j);
                        if (h !== -1 && h < 12) d[f] = h + 1
                    }
                    if (e[f] == "F") {
                        h = a.inArray(d[f], j);
                        if (h !== -1 && h > 11) d[f] = h + 1 - 12
                    }
                    if (e[f] == "a") {
                        h = a.inArray(d[f], c);
                        if (h !== -1 && h < 2 && d[f] == c[h]) {
                            d[f] = h;
                            b.h = k(d[f], b.h)
                        }
                    }
                    if (e[f] == "A") {
                        h = a.inArray(d[f], c);
                        if (h !== -1 && h > 1 && d[f] == c[h]) {
                            d[f] = h - 2;
                            b.h = k(d[f], b.h)
                        }
                    }
                    if (d[f] !== undefined) b[e[f].toLowerCase()] = parseInt(d[f], 10)
                }
                b.m = parseInt(b.m, 10) - 1;
                e = b.y;
                if (e >= 70 && e <= 99) b.y = 1900 + b.y;
                else if (e >= 0 && e <= 69) b.y = 2E3 + b.y
            }
            return new Date(b.y, b.m, b.d, b.h, b.i, b.s, 0)
        },
        jqID: function(e) {
            e += "";
            return e.replace(/([\.\:\[\]])/g, "\\$1")
        },
        getAccessor: function(e, d) {
            var b, f, g, h;
            if (typeof d === "function") return d(e);
            b = e[d];
            if (b === undefined) try {
                if (typeof d === "string") g = d.split(".");
                if (h = g.length) for (b = e; b && h--;) {
                    f = g.shift();
                    b = b[f]
                }
            } catch(j) {}
            return b
        },
        ajaxOptions: {},
        from: function(e) {
            return new(function(d, b) {
                if (typeof d == "string") d = a.data(d);
                var f = this,
                g = d,
                h = true,
                j = false,
                c = b,
                k = /[\$,%]/g,
                l = null,
                o = null,
                n = false,
                r = "",
                q = [],
                t = true;
                if (typeof d == "object" && d.push) {
                    if (d.length > 0) t = typeof d[0] != "object" ? false: true
                } else throw "data provides is not an array";
                this._hasData = function() {
                    return g === null ? false: g.length === 0 ? false: true
                };
                this._getStr = function(m) {
                    var p = [];
                    j && p.push("jQuery.trim(");
                    p.push("String(" + m + ")");
                    j && p.push(")");
                    h || p.push(".toLowerCase()");
                    return p.join("")
                };
                this._strComp = function(m) {
                    return typeof m == "string" ? ".toString()": ""
                };
                this._group = function(m, p) {
                    return {
                        field: m.toString(),
                        unique: p,
                        items: []
                    }
                };
                this._toStr = function(m) {
                    if (j) m = a.trim(m);
                    h || (m = m.toLowerCase());
                    return m = m.toString().replace(new RegExp('\\"', "g"), '\\"')
                };
                this._funcLoop = function(m) {
                    var p = [];
                    a.each(g,
                    function(v, y) {
                        p.push(m(y))
                    });
                    return p
                };
                this._append = function(m) {
                    if (c === null) c = "";
                    else c += r == "" ? " && ": r;
                    if (n) c += "!";
                    c += "(" + m + ")";
                    n = false;
                    r = ""
                };
                this._setCommand = function(m, p) {
                    l = m;
                    o = p
                };
                this._resetNegate = function() {
                    n = false
                };
                this._repeatCommand = function(m, p) {
                    if (l === null) return f;
                    if (m != null && p != null) return l(m, p);
                    if (o === null) return l(m);
                    if (!t) return l(m);
                    return l(o, m)
                };
                this._equals = function(m, p) {
                    return f._compare(m, p, 1) === 0
                };
                this._compare = function(m, p, v) {
                    if (v === undefined) v = 1;
                    if (m === undefined) m = null;
                    if (p === undefined) p = null;
                    if (m === null && p === null) return 0;
                    if (m === null && p !== null) return 1;
                    if (m !== null && p === null) return - 1;
                    if (!h) {
                        m = m.toLowerCase();
                        p = p.toLowerCase()
                    }
                    if (m < p) return - v;
                    if (m > p) return v;
                    return 0
                };
                this._performSort = function() {
                    if (q.length !== 0) g = f._doSort(g, 0)
                };
                this._doSort = function(m, p) {
                    var v = q[p].by,
                    y = q[p].dir,
                    B = q[p].type,
                    C = q[p].datefmt;
                    if (p == q.length - 1) return f._getOrder(m, v, y, B, C);
                    p++;
                    m = f._getGroup(m, v, y, B, C);
                    v = [];
                    for (y = 0; y < m.length; y++) {
                        B = f._doSort(m[y].items, p);
                        for (C = 0; C < B.length; C++) v.push(B[C])
                    }
                    return v
                };
                this._getOrder = function(m, p, v, y, B) {
                    var C = [],
                    I = [],
                    w = v == "a" ? 1 : -1,
                    A,
                    G;
                    if (y === undefined) y = "text";
                    G = y == "float" || y == "number" || y == "currency" || y == "numeric" ?
                    function(O) {
                        O = parseFloat(String(O).replace(k, ""));
                        return isNaN(O) ? 0 : O
                    }: y == "int" || y == "integer" ?
                    function(O) {
                        return O ? parseFloat(String(O).replace(k, "")) : 0
                    }: y == "date" || y == "datetime" ?
                    function(O) {
                        return a.jgrid.parseDate(B, O).getTime()
                    }: a.isFunction(y) ? y: function(O) {
                        O || (O = "");
                        return a.trim(String(O).toUpperCase())
                    };
                    a.each(m,
                    function(O, P) {
                        A = a.jgrid.getAccessor(P, p);
                        if (A === undefined) A = "";
                        A = G(A, P);
                        I.push({
                            vSort: A,
                            index: O
                        })
                    });
                    I.sort(function(O, P) {
                        O = O.vSort;
                        P = P.vSort;
                        return f._compare(O, P, w)
                    });
                    y = 0;
                    for (var M = m.length; y < M;) {
                        v = I[y].index;
                        C.push(m[v]);
                        y++
                    }
                    return C
                };
                this._getGroup = function(m, p, v, y, B) {
                    var C = [],
                    I = null,
                    w = null,
                    A;
                    a.each(f._getOrder(m, p, v, y, B),
                    function(G, M) {
                        A = a.jgrid.getAccessor(M, p);
                        if (A === undefined) A = "";
                        if (!f._equals(w, A)) {
                            w = A;
                            I != null && C.push(I);
                            I = f._group(p, A)
                        }
                        I.items.push(M)
                    });
                    I != null && C.push(I);
                    return C
                };
                this.ignoreCase = function() {
                    h = false;
                    return f
                };
                this.useCase = function() {
                    h = true;
                    return f
                };
                this.trim = function() {
                    j = true;
                    return f
                };
                this.noTrim = function() {
                    j = false;
                    return f
                };
                this.combine = function(m) {
                    var p = a.from(g);
                    h || p.ignoreCase();
                    j && p.trim();
                    result = m(p).showQuery();
                    f._append(result);
                    return f
                };
                this.execute = function() {
                    var m = c,
                    p = [];
                    if (m === null) return f;
                    a.each(g,
                    function() {
                        eval(m) && p.push(this)
                    });
                    g = p;
                    return f
                };
                this.data = function() {
                    return g
                };
                this.select = function(m) {
                    f._performSort();
                    if (!f._hasData()) return [];
                    f.execute();
                    if (a.isFunction(m)) {
                        var p = [];
                        a.each(g,
                        function(v, y) {
                            p.push(m(y))
                        });
                        return p
                    }
                    return g
                };
                this.hasMatch = function() {
                    if (!f._hasData()) return false;
                    f.execute();
                    return g.length > 0
                };
                this.showQuery = function(m) {
                    var p = c;
                    if (p === null) p = "no query found";
                    if (a.isFunction(m)) {
                        m(p);
                        return f
                    }
                    return p
                };
                this.andNot = function(m, p, v) {
                    n = !n;
                    return f.and(m, p, v)
                };
                this.orNot = function(m, p, v) {
                    n = !n;
                    return f.or(m, p, v)
                };
                this.not = function(m, p, v) {
                    return f.andNot(m, p, v)
                };
                this.and = function(m, p, v) {
                    r = " && ";
                    if (m === undefined) return f;
                    return f._repeatCommand(m, p, v)
                };
                this.or = function(m, p, v) {
                    r = " || ";
                    if (m === undefined) return f;
                    return f._repeatCommand(m, p, v)
                };
                this.isNot = function(m) {
                    n = !n;
                    return f.is(m)
                };
                this.is = function(m) {
                    f._append("this." + m);
                    f._resetNegate();
                    return f
                };
                this._compareValues = function(m, p, v, y, B) {
                    var C;
                    C = t ? "this." + p: "this";
                    if (v === undefined) v = null;
                    v = v === null ? p: v;
                    switch (B.stype === undefined ? "text": B.stype) {
                    case "int":
                    case "integer":
                        v = isNaN(Number(v)) ? "0": v;
                        C = "parseInt(" + C + ",10)";
                        v = "parseInt(" + v + ",10)";
                        break;
                    case "float":
                    case "number":
                    case "numeric":
                        v = String(v).replace(k, "");
                        v = isNaN(Number(v)) ? "0": v;
                        C = "parseFloat(" + C + ")";
                        v = "parseFloat(" + v + ")";
                        break;
                    case "date":
                    case "datetime":
                        v = String(a.jgrid.parseDate(B.newfmt || "Y-m-d", v).getTime());
                        C = 'jQuery.jgrid.parseDate("' + B.srcfmt + '",' + C + ").getTime()";
                        break;
                    default:
                        C = f._getStr(C);
                        v = f._getStr('"' + f._toStr(v) + '"')
                    }
                    f._append(C + " " + y + " " + v);
                    f._setCommand(m, p);
                    f._resetNegate();
                    return f
                };
                this.equals = function(m, p, v) {
                    return f._compareValues(f.equals, m, p, "==", v)
                };
                this.greater = function(m, p, v) {
                    return f._compareValues(f.greater, m, p, ">", v)
                };
                this.less = function(m, p, v) {
                    return f._compareValues(f.less, m, p, "<", v)
                };
                this.greaterOrEquals = function(m, p, v) {
                    return f._compareValues(f.greaterOrEquals, m, p, ">=", v)
                };
                this.lessOrEquals = function(m, p, v) {
                    return f._compareValues(f.lessOrEquals, m, p, "<=", v)
                };
                this.startsWith = function(m, p) {
                    var v = p === undefined || p === null ? m: p;
                    v = j ? a.trim(v.toString()).length: v.toString().length;
                    if (t) f._append(f._getStr("this." + m) + ".substr(0," + v + ") == " + f._getStr('"' + f._toStr(p) + '"'));
                    else {
                        v = j ? a.trim(p.toString()).length: p.toString().length;
                        f._append(f._getStr("this") + ".substr(0," + v + ") == " + f._getStr('"' + f._toStr(m) + '"'))
                    }
                    f._setCommand(f.startsWith, m);
                    f._resetNegate();
                    return f
                };
                this.endsWith = function(m, p) {
                    var v = p === undefined || p === null ? m: p;
                    v = j ? a.trim(v.toString()).length: v.toString().length;
                    t ? f._append(f._getStr("this." + m) + ".substr(" + f._getStr("this." + m) + ".length-" + v + "," + v + ') == "' + f._toStr(p) + '"') : f._append(f._getStr("this") + ".substr(" + f._getStr("this") + '.length-"' + f._toStr(m) + '".length,"' + f._toStr(m) + '".length) == "' + f._toStr(m) + '"');
                    f._setCommand(f.endsWith, m);
                    f._resetNegate();
                    return f
                };
                this.contains = function(m, p) {
                    t ? f._append(f._getStr("this." + m) + '.indexOf("' + f._toStr(p) + '",0) > -1') : f._append(f._getStr("this") + '.indexOf("' + f._toStr(m) + '",0) > -1');
                    f._setCommand(f.contains, m);
                    f._resetNegate();
                    return f
                };
                this.groupBy = function(m, p, v, y) {
                    if (!f._hasData()) return null;
                    return f._getGroup(g, m, p, v, y)
                };
                this.orderBy = function(m, p, v, y) {
                    p = p === undefined || p === null ? "a": a.trim(p.toString().toLowerCase());
                    if (v === null || v === undefined) v = "text";
                    if (y === null || y === undefined) y = "Y-m-d";
                    if (p == "desc" || p == "descending") p = "d";
                    if (p == "asc" || p == "ascending") p = "a";
                    q.push({
                        by: m,
                        dir: p,
                        type: v,
                        datefmt: y
                    });
                    return f
                };
                return f
            })(e, null)
        },
        extend: function(e) {
            a.extend(a.fn.jqGrid, e);
            this.no_legacy_api || a.fn.extend(e)
        }
    });
    a.fn.jqGrid = function(e) {
        if (typeof e == "string") {
            var d = a.jgrid.getAccessor(a.fn.jqGrid, e);
            if (!d) throw "jqGrid - No such method: " + e;
            var b = a.makeArray(arguments).slice(1);
            return d.apply(this, b)
        }
        return this.each(function() {
            if (!this.grid) {
                var f = a.extend(true, {
                    url: "",
                    height: 150,
                    page: 1,
                    rowNum: 20,
                    rowTotal: null,
                    records: 0,
                    pager: "",
                    pgbuttons: true,
                    pginput: true,
                    colModel: [],
                    rowList: [],
                    colNames: [],
                    sortorder: "asc",
                    sortname: "",
                    datatype: "xml",
                    mtype: "GET",
                    altRows: false,
                    selarrrow: [],
                    savedRow: [],
                    shrinkToFit: true,
                    xmlReader: {},
                    jsonReader: {},
                    subGrid: false,
                    subGridModel: [],
                    reccount: 0,
                    lastpage: 0,
                    lastsort: 0,
                    selrow: null,
                    beforeSelectRow: null,
                    onSelectRow: null,
                    onSortCol: null,
                    ondblClickRow: null,
                    onRightClickRow: null,
                    onPaging: null,
                    onSelectAll: null,
                    loadComplete: null,
                    gridComplete: null,
                    loadError: null,
                    loadBeforeSend: null,
                    afterInsertRow: null,
                    beforeRequest: null,
                    onHeaderClick: null,
                    viewrecords: false,
                    loadonce: false,
                    multiselect: false,
                    multikey: false,
                    editurl: null,
                    search: false,
                    caption: "",
                    hidegrid: true,
                    hiddengrid: false,
                    postData: {},
                    userData: {},
                    treeGrid: false,
                    treeGridModel: "nested",
                    treeReader: {},
                    treeANode: -1,
                    ExpandColumn: null,
                    tree_root_level: 0,
                    prmNames: {
                        page: "page",
                        rows: "rows",
                        sort: "sidx",
                        order: "sord",
                        search: "_search",
                        nd: "nd",
                        id: "id",
                        oper: "oper",
                        editoper: "edit",
                        addoper: "add",
                        deloper: "del",
                        subgridid: "id",
                        npage: null,
                        totalrows: "totalrows"
                    },
                    forceFit: false,
                    gridstate: "visible",
                    cellEdit: false,
                    cellsubmit: "remote",
                    nv: 0,
                    loadui: "enable",
                    toolbar: [false, ""],
                    scroll: false,
                    multiboxonly: false,
                    deselectAfterSort: true,
                    scrollrows: false,
                    autowidth: false,
                    scrollOffset: 18,
                    cellLayout: 5,
                    subGridWidth: 20,
                    multiselectWidth: 20,
                    gridview: false,
                    rownumWidth: 25,
                    rownumbers: false,
                    pagerpos: "center",
                    recordpos: "right",
                    footerrow: false,
                    userDataOnFooter: false,
                    hoverrows: true,
                    altclass: "ui-priority-secondary",
                    viewsortcols: [false, "vertical", true],
                    resizeclass: "",
                    autoencode: false,
                    remapColumns: [],
                    ajaxGridOptions: {},
                    direction: "ltr",
                    toppager: false,
                    headertitles: false,
                    scrollTimeout: 40,
                    data: [],
                    _index: {},
                    grouping: false,
                    groupingView: {
                        groupField: [],
                        groupOrder: [],
                        groupText: [],
                        groupColumnShow: [],
                        groupSummary: [],
                        sortitems: [],
                        sortnames: [],
                        groupDataSorted: false,
                        summary: [],
                        summaryval: [],
                        plusicon: "ui-icon-circlesmall-plus",
                        minusicon: "ui-icon-circlesmall-minus"
                    }
                },
                a.jgrid.defaults, e || {}),
                g = {
                    headers: [],
                    cols: [],
                    footers: [],
                    dragStart: function(s, u, x) {
                        this.resizing = {
                            idx: s,
                            startX: u.clientX,
                            sOL: x[0]
                        };
                        this.hDiv.style.cursor = "col-resize";
                        this.curGbox = a("#rs_m" + f.id, "#gbox_" + f.id);
                        this.curGbox.css({
                            display: "block",
                            left: x[0],
                            top: x[1],
                            height: x[2]
                        });
                        a.isFunction(f.resizeStart) && f.resizeStart.call(this, u, s);
                        document.onselectstart = function() {
                            return false
                        }
                    },
                    dragMove: function(s) {
                        if (this.resizing) {
                            var u = s.clientX - this.resizing.startX;
                            s = this.headers[this.resizing.idx];
                            var x = f.direction === "ltr" ? s.width + u: s.width - u,
                            E;
                            if (x > 33) {
                                this.curGbox.css({
                                    left: this.resizing.sOL + u
                                });
                                if (f.forceFit === true) {
                                    E = this.headers[this.resizing.idx + f.nv];
                                    u = f.direction === "ltr" ? E.width - u: E.width + u;
                                    if (u > 33) {
                                        s.newWidth = x;
                                        E.newWidth = u
                                    }
                                } else {
                                    this.newWidth = f.direction === "ltr" ? f.tblwidth + u: f.tblwidth - u;
                                    s.newWidth = x
                                }
                            }
                        }
                    },
                    dragEnd: function() {
                        this.hDiv.style.cursor = "default";
                        if (this.resizing) {
                            var s = this.resizing.idx,
                            u = this.headers[s].newWidth || this.headers[s].width;
                            u = parseInt(u, 10);
                            this.resizing = false;
                            a("#rs_m" + f.id).css("display", "none");
                            f.colModel[s].width = u;
                            this.headers[s].width = u;
                            this.headers[s].el.style.width = u + "px";
                            this.cols[s].style.width = u + "px";
                            if (this.footers.length > 0) this.footers[s].style.width = u + "px";
                            if (f.forceFit === true) {
                                u = this.headers[s + f.nv].newWidth || this.headers[s + f.nv].width;
                                this.headers[s + f.nv].width = u;
                                this.headers[s + f.nv].el.style.width = u + "px";
                                this.cols[s + f.nv].style.width = u + "px";
                                if (this.footers.length > 0) this.footers[s + f.nv].style.width = u + "px";
                                f.colModel[s + f.nv].width = u
                            } else {
                                f.tblwidth = this.newWidth || f.tblwidth;
                                a("table:first", this.bDiv).css("width", f.tblwidth + "px");
                                a("table:first", this.hDiv).css("width", f.tblwidth + "px");
                                this.hDiv.scrollLeft = this.bDiv.scrollLeft;
                                if (f.footerrow) {
                                    a("table:first", this.sDiv).css("width", f.tblwidth + "px");
                                    this.sDiv.scrollLeft = this.bDiv.scrollLeft
                                }
                            }
                            a.isFunction(f.resizeStop) && f.resizeStop.call(this, u, s)
                        }
                        this.curGbox = null;
                        document.onselectstart = function() {
                            return true
                        }
                    },
                    populateVisible: function() {
                        g.timer && clearTimeout(g.timer);
                        g.timer = null;
                        var s = a(g.bDiv).height();
                        if (s) {
                            var u = a("table:first", g.bDiv),
                            x = a("> tbody > tr:gt(0):visible:first", u).outerHeight() || g.prevRowHeight;
                            if (x) {
                                g.prevRowHeight = x;
                                var E = f.rowNum,
                                D = g.scrollTop = g.bDiv.scrollTop,
                                U = Math.round(u.position().top) - D,
                                L = U + u.height();
                                x = x * E;
                                var Q, W, J;
                                if (L < s && U <= 0 && (f.lastpage === undefined || parseInt((L + D + x - 1) / x, 10) <= f.lastpage)) {
                                    W = parseInt((s - L + x - 1) / x, 10);
                                    if (L >= 0 || W < 2 || f.scroll === true) {
                                        Q = Math.round((L + D) / x) + 1;
                                        U = -1
                                    } else U = 1
                                }
                                if (U > 0) {
                                    Q = parseInt(D / x, 10) + 1;
                                    W = parseInt((D + s) / x, 10) + 2 - Q;
                                    J = true
                                }
                                if (W) if (! (f.lastpage && Q > f.lastpage || f.lastpage == 1)) if (g.hDiv.loading) g.timer = setTimeout(g.populateVisible, f.scrollTimeout);
                                else {
                                    f.page = Q;
                                    if (J) {
                                        g.selectionPreserver(u[0]);
                                        g.emptyRows(g.bDiv, false)
                                    }
                                    g.populate(W)
                                }
                            }
                        }
                    },
                    scrollGrid: function() {
                        if (f.scroll) {
                            var s = g.bDiv.scrollTop;
                            if (g.scrollTop === undefined) g.scrollTop = 0;
                            if (s != g.scrollTop) {
                                g.scrollTop = s;
                                g.timer && clearTimeout(g.timer);
                                g.timer = setTimeout(g.populateVisible, f.scrollTimeout)
                            }
                        }
                        g.hDiv.scrollLeft = g.bDiv.scrollLeft;
                        if (f.footerrow) g.sDiv.scrollLeft = g.bDiv.scrollLeft
                    },
                    selectionPreserver: function(s) {
                        var u = s.p,
                        x = u.selrow,
                        E = u.selarrrow ? a.makeArray(u.selarrrow) : null,
                        D = s.grid.bDiv.scrollLeft,
                        U = u.gridComplete;
                        u.gridComplete = function() {
                            u.selrow = null;
                            u.selarrrow = [];
                            if (u.multiselect && E && E.length > 0) for (var L = 0; L < E.length; L++) E[L] != x && a(s).jqGrid("setSelection", E[L], false);
                            x && a(s).jqGrid("setSelection", x, false);
                            s.grid.bDiv.scrollLeft = D;
                            u.gridComplete = U;
                            u.gridComplete && U()
                        }
                    }
                };
                if (this.tagName != "TABLE") alert("Element is not a table");
                else {
                    this.p = f;
                    var h, j, c;
                    if (this.p.colNames.length === 0) for (h = 0; h < this.p.colModel.length; h++) this.p.colNames[h] = this.p.colModel[h].label || this.p.colModel[h].name;
                    if (this.p.colNames.length !== this.p.colModel.length) alert(a.jgrid.errors.model);
                    else {
                        var k = a("<div class='ui-jqgrid-view'></div>"),
                        l,
                        o = a.browser.msie ? true: false,
                        n = a.browser.safari ? true: false;
                        c = this;
                        c.p.direction = a.trim(c.p.direction.toLowerCase());
                        if (a.inArray(c.p.direction, ["ltr", "rtl"]) == -1) c.p.direction = "ltr";
                        j = c.p.direction;
                        a(k).insertBefore(this);
                        a(this).appendTo(k).removeClass("scroll");
                        var r = a("<div class='ui-jqgrid ui-widget ui-widget-content ui-corner-all'></div>");
                        a(r).insertBefore(k).attr({
                            id: "gbox_" + this.id,
                            dir: j
                        });
                        a(k).appendTo(r).attr("id", "gview_" + this.id);
                        l = o && a.browser.version <= 6 ? '<iframe style="display:block;position:absolute;z-index:-1;filter:Alpha(Opacity=\'0\');" src="javascript:false;"></iframe>': "";
                        a("<div class='ui-widget-overlay jqgrid-overlay' id='lui_" + this.id + "'></div>").append(l).insertBefore(k);
                        a("<div class='loading ui-state-default ui-state-active' id='load_" + this.id + "'>" + this.p.loadtext + "</div>").insertBefore(k);
                        a(this).attr({
                            cellSpacing: "0",
                            cellPadding: "0",
                            border: "0",
                            role: "grid",
                            "aria-multiselectable": !!this.p.multiselect,
                            "aria-labelledby": "gbox_" + this.id
                        });
                        var q = function(s, u) {
                            s = parseInt(s, 10);
                            return isNaN(s) ? u ? u: 0 : s
                        },
                        t = function(s, u, x) {
                            var E = c.p.colModel[s],
                            D = E.align,
                            U = 'style="',
                            L = E.classes,
                            Q = E.name;
                            if (D) U += "text-align:" + D + ";";
                            if (E.hidden === true) U += "display:none;";
                            if (u === 0) U += "width: " + g.headers[s].width + "px;";
                            U += '"' + (L !== undefined ? ' class="' + L + '"': "") + (E.title && x ? ' title="' + a.jgrid.stripHtml(x) + '"': "");
                            U += ' aria-describedby="' + c.p.id + "_" + Q + '"';
                            return U
                        },
                        m = function(s) {
                            return s === undefined || s === null || s === "" ? "&#160;": c.p.autoencode ? a.jgrid.htmlEncode(s) : s + ""
                        },
                        p = function(s, u, x, E, D) {
                            x = c.p.colModel[x];
                            if (typeof x.formatter !== "undefined") {
                                s = {
                                    rowId: s,
                                    colModel: x,
                                    gid: c.p.id
                                };
                                u = a.isFunction(x.formatter) ? x.formatter.call(c, u, s, E, D) : a.fmatter ? a.fn.fmatter(x.formatter, u, s, E, D) : m(u)
                            } else u = m(u);
                            return u
                        },
                        v = function(s, u, x, E, D) {
                            s = p(s, u, x, D, "add");
                            return '<td role="gridcell" ' + t(x, E, s) + ">" + s + "</td>"
                        },
                        y = function(s, u, x) {
                            s = '<input role="checkbox" type="checkbox" id="jqg_' + c.p.id + "_" + s + '" class="cbox" name="jqg_' + c.p.id + "_" + s + '"/>';
                            u = t(u, x, "");
                            return '<td role="gridcell" aria-describedby="' + c.p.id + '_cb" ' + u + ">" + s + "</td>"
                        },
                        B = function(s, u, x, E) {
                            x = (parseInt(x, 10) - 1) * parseInt(E, 10) + 1 + u;
                            s = t(s, u, "");
                            return '<td role="gridcell" aria-describedby="' + c.p.id + '_rn" class="ui-state-default jqgrid-rownum" ' + s + ">" + x + "</td>"
                        },
                        C = function(s) {
                            var u, x = [],
                            E = 0,
                            D;
                            for (D = 0; D < c.p.colModel.length; D++) {
                                u = c.p.colModel[D];
                                if (u.name !== "cb" && u.name !== "subgrid" && u.name !== "rn") {
                                    x[E] = s == "local" ? u.name: s == "xml" ? u.xmlmap || u.name: u.jsonmap || u.name;
                                    E++
                                }
                            }
                            return x
                        },
                        I = function(s) {
                            var u = c.p.remapColumns;
                            if (!u || !u.length) u = a.map(c.p.colModel,
                            function(x, E) {
                                return E
                            });
                            if (s) u = a.map(u,
                            function(x) {
                                return x < s ? null: x - s
                            });
                            return u
                        },
                        w = function(s, u) {
                            if (c.p.deepempty) a("#" + c.p.id + " tbody:first tr:gt(0)").remove();
                            else {
                                var x = a("#" + c.p.id + " tbody:first tr:first")[0];
                                a("#" + c.p.id + " tbody:first").empty().append(x)
                            }
                            if (u && c.p.scroll) {
                                a(">div:first", s).css({
                                    height: "auto"
                                }).children("div:first").css({
                                    height: 0,
                                    display: "none"
                                });
                                s.scrollTop = 0
                            }
                        },
                        A = function(s, u, x, E, D) {
                            var U = new Date,
                            L = c.p.datatype != "local" && c.p.loadonce || c.p.datatype == "xmlstring",
                            Q, W = c.p.datatype == "local" ? "local": "xml";
                            if (L) {
                                c.p.data = [];
                                c.p._index = {};
                                c.p.localReader.id = Q = "_id_"
                            }
                            c.p.reccount = 0;
                            if (a.isXMLDoc(s)) {
                                if (c.p.treeANode === -1 && !c.p.scroll) {
                                    w(u, false);
                                    x = 1
                                } else x = x > 1 ? x: 1;
                                var J, S = 0,
                                K, ca, la = 0,
                                T = 0,
                                ha = 0,
                                ma, oa = [],
                                qa,
                                pa = {},
                                ja,
                                ia,
                                sa = [],
                                Ha = c.p.altRows === true ? " " + c.p.altclass: "";
                                c.p.xmlReader.repeatitems || (oa = C(W));
                                ma = c.p.keyIndex === false ? c.p.xmlReader.id: c.p.keyIndex;
                                if (oa.length > 0 && !isNaN(ma)) {
                                    if (c.p.remapColumns && c.p.remapColumns.length) ma = a.inArray(ma, c.p.remapColumns);
                                    ma = oa[ma]
                                }
                                W = (ma + "").indexOf("[") === -1 ? oa.length ?
                                function(Da, va) {
                                    return a(ma, Da).text() || va
                                }: function(Da, va) {
                                    return a(c.p.xmlReader.cell, Da).eq(ma).text() || va
                                }: function(Da, va) {
                                    return Da.getAttribute(ma.replace(/[\[\]]/g, "")) || va
                                };
                                c.p.userData = {};
                                a(c.p.xmlReader.page, s).each(function() {
                                    c.p.page = this.textContent || this.text || 0
                                });
                                a(c.p.xmlReader.total, s).each(function() {
                                    c.p.lastpage = this.textContent || this.text;
                                    if (c.p.lastpage === undefined) c.p.lastpage = 1
                                });
                                a(c.p.xmlReader.records, s).each(function() {
                                    c.p.records = this.textContent || this.text || 0
                                });
                                a(c.p.xmlReader.userdata, s).each(function() {
                                    c.p.userData[this.getAttribute("name")] = this.textContent || this.text
                                });
                                s = a(c.p.xmlReader.root + " " + c.p.xmlReader.row, s);
                                var Ea = s.length,
                                wa = 0;
                                if (s && Ea) {
                                    var Fa = parseInt(c.p.rowNum, 10),
                                    Ka = c.p.scroll ? (parseInt(c.p.page, 10) - 1) * Fa + 1 : 1;
                                    if (D) Fa *= D + 1;
                                    D = a.isFunction(c.p.afterInsertRow);
                                    var Ja = {},
                                    La = "";
                                    if (c.p.grouping && c.p.groupingView.groupCollapse === true) La = ' style="display:none;"';
                                    for (; wa < Ea;) {
                                        ja = s[wa];
                                        ia = W(ja, Ka + wa);
                                        J = x === 0 ? 0 : x + 1;
                                        J = (J + wa) % 2 == 1 ? Ha: "";
                                        sa.push("<tr" + La + ' id="' + ia + '" role="row" class ="ui-widget-content jqgrow ui-row-' + c.p.direction + "" + J + '">');
                                        if (c.p.rownumbers === true) {
                                            sa.push(B(0, wa, c.p.page, c.p.rowNum));
                                            ha = 1
                                        }
                                        if (c.p.multiselect === true) {
                                            sa.push(y(ia, ha, wa));
                                            la = 1
                                        }
                                        if (c.p.subGrid === true) {
                                            sa.push(a(c).jqGrid("addSubGridCell", la + ha, wa + x));
                                            T = 1
                                        }
                                        if (c.p.xmlReader.repeatitems) {
                                            qa || (qa = I(la + T + ha));
                                            var Ma = a(c.p.xmlReader.cell, ja);
                                            a.each(qa,
                                            function(Da) {
                                                var va = Ma[this];
                                                if (!va) return false;
                                                K = va.textContent || va.text;
                                                pa[c.p.colModel[Da + la + T + ha].name] = K;
                                                sa.push(v(ia, K, Da + la + T + ha, wa + x, ja))
                                            })
                                        } else for (J = 0; J < oa.length; J++) {
                                            K = a(oa[J], ja).text();
                                            pa[c.p.colModel[J + la + T + ha].name] = K;
                                            sa.push(v(ia, K, J + la + T + ha, wa + x, ja))
                                        }
                                        sa.push("</tr>");
                                        if (c.p.grouping) {
                                            J = c.p.groupingView.groupField.length;
                                            ca = [];
                                            for (z = 0; z < J; z++) ca.push(pa[c.p.groupingView.groupField[z]]);
                                            Ja = a(c).jqGrid("groupingPrepare", sa, ca, Ja, pa);
                                            sa = []
                                        }
                                        if (L) {
                                            pa[Q] = ia;
                                            c.p.data.push(pa)
                                        }
                                        if (c.p.gridview === false) {
                                            if (c.p.treeGrid === true) {
                                                J = c.p.treeANode >= -1 ? c.p.treeANode: 0;
                                                ca = a(sa.join(""))[0];
                                                a(c.rows[wa + J + x]).after(ca);
                                                try {
                                                    a(c).jqGrid("setTreeNode", pa, ca)
                                                } catch(Na) {}
                                            } else a("tbody:first", u).append(sa.join(""));
                                            if (c.p.subGrid === true) try {
                                                a(c).jqGrid("addSubGrid", c.rows[c.rows.length - 1], la + ha)
                                            } catch(Oa) {}
                                            D && c.p.afterInsertRow.call(c, ia, pa, ja);
                                            sa = []
                                        }
                                        pa = {};
                                        S++;
                                        wa++;
                                        if (S == Fa) break
                                    }
                                }
                                if (c.p.gridview === true) if (c.p.grouping && qa) {
                                    a(c).jqGrid("groupingRender", Ja, qa.length + la + T + ha);
                                    Ja = null
                                } else a("tbody:first", u).append(sa.join(""));
                                c.p.totaltime = new Date - U;
                                if (S > 0) if (c.p.records === 0) c.p.records = Ea;
                                sa = null;
                                if (!c.p.treeGrid && !c.p.scroll) c.grid.bDiv.scrollTop = 0;
                                c.p.reccount = S;
                                c.p.treeANode = -1;
                                c.p.userDataOnFooter && a(c).jqGrid("footerData", "set", c.p.userData, true);
                                if (L) {
                                    c.p.records = Ea;
                                    c.p.lastpage = Math.ceil(Ea / Fa)
                                }
                                E || O(false, true);
                                if (L) {
                                    for (; S < Ea;) {
                                        ja = s[S];
                                        ia = W(ja, S);
                                        if (c.p.xmlReader.repeatitems) {
                                            qa || (qa = I(la + T + ha));
                                            Ma = a(c.p.xmlReader.cell, ja);
                                            a.each(qa,
                                            function(Da) {
                                                var va = Ma[this];
                                                if (!va) return false;
                                                K = va.textContent || va.text;
                                                pa[c.p.colModel[Da + la + T + ha].name] = K
                                            })
                                        } else for (J = 0; J < oa.length; J++) {
                                            K = a(oa[J], ja).text();
                                            pa[c.p.colModel[J + la + T + ha].name] = K
                                        }
                                        pa[Q] = ia;
                                        c.p.data.push(pa);
                                        pa = {};
                                        S++
                                    }
                                    V()
                                }
                            }
                        },
                        G = function(s, u, x, E, D) {
                            var U = new Date;
                            if (s) {
                                if (c.p.treeANode === -1 && !c.p.scroll) {
                                    w(u, false);
                                    x = 1
                                } else x = x > 1 ? x: 1;
                                var L, Q, W = c.p.datatype != "local" && c.p.loadonce || c.p.datatype == "jsonstring";
                                if (W) {
                                    c.p.data = [];
                                    c.p._index = {};
                                    L = c.p.localReader.id = "_id_"
                                }
                                c.p.reccount = 0;
                                if (c.p.datatype == "local") {
                                    u = c.p.localReader;
                                    Q = "local"
                                } else {
                                    u = c.p.jsonReader;
                                    Q = "json"
                                }
                                var J = 0,
                                S, K, ca, la = [],
                                T,
                                ha = 0,
                                ma = 0,
                                oa = 0,
                                qa,
                                pa,
                                ja = {},
                                ia;
                                ca = [];
                                var sa = c.p.altRows === true ? " " + c.p.altclass: "";
                                c.p.page = a.jgrid.getAccessor(s, u.page) || 0;
                                qa = a.jgrid.getAccessor(s, u.total);
                                c.p.lastpage = qa === undefined ? 1 : qa;
                                c.p.records = a.jgrid.getAccessor(s, u.records) || 0;
                                c.p.userData = a.jgrid.getAccessor(s, u.userdata) || {};
                                u.repeatitems || (T = la = C(Q));
                                Q = c.p.keyIndex === false ? u.id: c.p.keyIndex;
                                if (la.length > 0 && !isNaN(Q)) {
                                    if (c.p.remapColumns && c.p.remapColumns.length) Q = a.inArray(Q, c.p.remapColumns);
                                    Q = la[Q]
                                }
                                if (pa = a.jgrid.getAccessor(s, u.root)) {
                                    qa = pa.length;
                                    s = 0;
                                    var Ha = parseInt(c.p.rowNum, 10),
                                    Ea = c.p.scroll ? (parseInt(c.p.page, 10) - 1) * Ha + 1 : 1;
                                    if (D) Ha *= D + 1;
                                    var wa = a.isFunction(c.p.afterInsertRow),
                                    Fa = {},
                                    Ka = "";
                                    if (c.p.grouping && c.p.groupingView.groupCollapse === true) Ka = ' style="display:none;"';
                                    for (; s < qa;) {
                                        D = pa[s];
                                        ia = a.jgrid.getAccessor(D, Q);
                                        if (ia === undefined) {
                                            ia = Ea + s;
                                            if (la.length === 0) if (u.cell) {
                                                S = D[u.cell];
                                                ia = S[Q] || ia
                                            }
                                        }
                                        S = x === 1 ? 0 : x;
                                        S = (S + s) % 2 == 1 ? sa: "";
                                        ca.push("<tr" + Ka + ' id="' + ia + '" role="row" class= "ui-widget-content jqgrow ui-row-' + c.p.direction + "" + S + '">');
                                        if (c.p.rownumbers === true) {
                                            ca.push(B(0, s, c.p.page, c.p.rowNum));
                                            oa = 1
                                        }
                                        if (c.p.multiselect) {
                                            ca.push(y(ia, oa, s));
                                            ha = 1
                                        }
                                        if (c.p.subGrid) {
                                            ca.push(a(c).jqGrid("addSubGridCell", ha + oa, s + x));
                                            ma = 1
                                        }
                                        if (u.repeatitems) {
                                            if (u.cell) D = a.jgrid.getAccessor(D, u.cell);
                                            T || (T = I(ha + ma + oa))
                                        }
                                        for (K = 0; K < T.length; K++) {
                                            S = a.jgrid.getAccessor(D, T[K]);
                                            ca.push(v(ia, S, K + ha + ma + oa, s + x, D));
                                            ja[c.p.colModel[K + ha + ma + oa].name] = S
                                        }
                                        ca.push("</tr>");
                                        if (c.p.grouping) {
                                            S = c.p.groupingView.groupField.length;
                                            K = [];
                                            for (z = 0; z < S; z++) K.push(ja[c.p.groupingView.groupField[z]]);
                                            Fa = a(c).jqGrid("groupingPrepare", ca, K, Fa, ja);
                                            ca = []
                                        }
                                        if (W) {
                                            ja[L] = ia;
                                            c.p.data.push(ja)
                                        }
                                        if (c.p.gridview === false) {
                                            if (c.p.treeGrid === true) {
                                                S = c.p.treeANode >= -1 ? c.p.treeANode: 0;
                                                ca = a(ca.join(""))[0];
                                                a(c.rows[s + S + x]).after(ca);
                                                try {
                                                    a(c).jqGrid("setTreeNode", ja, ca)
                                                } catch(Ja) {}
                                            } else a("#" + c.p.id + " tbody:first").append(ca.join(""));
                                            if (c.p.subGrid === true) try {
                                                a(c).jqGrid("addSubGrid", c.rows[c.rows.length - 1], ha + oa)
                                            } catch(La) {}
                                            wa && c.p.afterInsertRow.call(c, ia, ja, D);
                                            ca = []
                                        }
                                        ja = {};
                                        J++;
                                        s++;
                                        if (J == Ha) break
                                    }
                                    if (c.p.gridview === true) c.p.grouping && T ? a(c).jqGrid("groupingRender", Fa, T.length + ha + ma + oa) : a("#" + c.p.id + " tbody:first").append(ca.join(""));
                                    c.p.totaltime = new Date - U;
                                    if (J > 0) if (c.p.records === 0) c.p.records = qa;
                                    if (!c.p.treeGrid && !c.p.scroll) c.grid.bDiv.scrollTop = 0;
                                    c.p.reccount = J;
                                    c.p.treeANode = -1;
                                    c.p.userDataOnFooter && a(c).jqGrid("footerData", "set", c.p.userData, true);
                                    if (W) {
                                        c.p.records = qa;
                                        c.p.lastpage = Math.ceil(qa / Ha)
                                    }
                                    E || O(false, true);
                                    if (W) {
                                        for (; J < qa;) {
                                            D = pa[J];
                                            ia = a.jgrid.getAccessor(D, Q);
                                            if (ia === undefined) {
                                                ia = Ea + J;
                                                if (la.length === 0) if (u.cell) {
                                                    S = D[u.cell];
                                                    ia = S[Q] || ia
                                                }
                                            }
                                            if (D) {
                                                if (u.repeatitems) {
                                                    if (u.cell) D = a.jgrid.getAccessor(D, u.cell);
                                                    T || (T = I(ha + ma + oa))
                                                }
                                                for (K = 0; K < T.length; K++) {
                                                    S = a.jgrid.getAccessor(D, T[K]);
                                                    ja[c.p.colModel[K + ha + ma + oa].name] = S
                                                }
                                                ja[L] = ia;
                                                c.p.data.push(ja);
                                                ja = {}
                                            }
                                            J++
                                        }
                                        V()
                                    }
                                }
                            }
                        },
                        M = function() {
                            var s, u = false,
                            x = grtypes = [],
                            E,
                            D;
                            if (c.p.data.length) {
                                var U = c.p.grouping ? c.p.groupingView: false;
                                a.each(c.p.colModel,
                                function() {
                                    sorttype = this.sorttype || "text";
                                    if (sorttype == "date" || sorttype == "datetime") {
                                        if (this.formatter && typeof this.formatter === "string" && this.formatter == "date") {
                                            E = this.formatoptions && this.formatoptions.srcformat ? this.formatoptions.srcformat: a.jgrid.formatter.date.srcformat;
                                            D = this.formatoptions && this.formatoptions.newformat ? this.formatoptions.newformat: a.jgrid.formatter.date.newformat
                                        } else E = D = this.datefmt || "Y-m-d";
                                        x[this.name] = {
                                            stype: sorttype,
                                            srcfmt: E,
                                            newfmt: D
                                        }
                                    } else x[this.name] = {
                                        stype: sorttype,
                                        srcfmt: "",
                                        newfmt: ""
                                    };
                                    if (c.p.grouping && this.name == U.groupField[0]) grtypes[0] = x[this.name];
                                    if (!u && (this.index == c.p.sortname || this.name == c.p.sortname)) {
                                        s = this.name;
                                        u = true
                                    }
                                });
                                if (c.p.treeGrid) a(c).jqGrid("SortTree", s, c.p.sortorder, x[s].stype, x[s].srcfmt);
                                else {
                                    var L = {
                                        eq: function(T) {
                                            return T.equals
                                        },
                                        ne: function(T) {
                                            return T.not().equals
                                        },
                                        lt: function(T) {
                                            return T.less
                                        },
                                        le: function(T) {
                                            return T.lessOrEquals
                                        },
                                        gt: function(T) {
                                            return T.greater
                                        },
                                        ge: function(T) {
                                            return T.greaterOrEquals
                                        },
                                        cn: function(T) {
                                            return T.contains
                                        },
                                        nc: function(T) {
                                            return T.not().contains
                                        },
                                        bw: function(T) {
                                            return T.startsWith
                                        },
                                        bn: function(T) {
                                            return T.not().startsWith
                                        },
                                        en: function(T) {
                                            return T.not().endsWith
                                        },
                                        ew: function(T) {
                                            return T.endsWith
                                        },
                                        ni: function(T) {
                                            return T.not().equals
                                        },
                                        "in": function(T) {
                                            return T.equals
                                        }
                                    },
                                    Q = a.jgrid.from(c.p.data);
                                    if (c.p.search === true) {
                                        var W = c.p.postData.filters;
                                        if (W) {
                                            if (typeof W == "string") W = a.jgrid.parse(W);
                                            for (var J = 0,
                                            S = W.rules.length,
                                            K; J < S; J++) {
                                                K = W.rules[J];
                                                var ca = W.groupOp;
                                                if (L[K.op] && K.field && K.data && ca) Q = ca.toUpperCase() == "OR" ? L[K.op](Q)(K.field, K.data, x[K.field]).or() : L[K.op](Q)(K.field, K.data, x[K.field])
                                            }
                                        } else try {
                                            Q = L[c.p.postData.searchOper](Q)(c.p.postData.searchField, c.p.postData.searchString, x[c.p.postData.searchField])
                                        } catch(la) {}
                                    }
                                    if (c.p.grouping) {
                                        Q.orderBy(U.groupField[0], U.groupOrder[0], grtypes[0].stype, grtypes[0].srcfmt);
                                        U.groupDataSorted = true
                                    }
                                    if (s && c.p.sortorder && u) c.p.sortorder.toUpperCase() == "DESC" ? Q.orderBy(c.p.sortname, "d", x[s].stype, x[s].srcfmt) : Q.orderBy(c.p.sortname, "a", x[s].stype, x[s].srcfmt);
                                    L = Q.select();
                                    Q = parseInt(c.p.rowNum, 10);
                                    W = L.length;
                                    J = parseInt(c.p.page, 10);
                                    S = Math.ceil(W / Q);
                                    K = {};
                                    L = L.slice((J - 1) * Q, J * Q);
                                    x = Q = null;
                                    K[c.p.localReader.total] = S;
                                    K[c.p.localReader.page] = J;
                                    K[c.p.localReader.records] = W;
                                    K[c.p.localReader.root] = L;
                                    L = null;
                                    return K
                                }
                            }
                        },
                        O = function(s, u) {
                            var x, E, D, U, L, Q, W, J = "";
                            D = parseInt(c.p.page, 10) - 1;
                            if (D < 0) D = 0;
                            D *= parseInt(c.p.rowNum, 10);
                            L = D + c.p.reccount;
                            if (c.p.scroll) {
                                x = a("tbody:first > tr:gt(0)", c.grid.bDiv);
                                D = L - x.length;
                                c.p.reccount = x.length;
                                if (E = x.outerHeight() || c.grid.prevRowHeight) {
                                    x = D * E;
                                    E = parseInt(c.p.records, 10) * E;
                                    a(">div:first", c.grid.bDiv).css({
                                        height: E
                                    }).children("div:first").css({
                                        height: x,
                                        display: x ? "": "none"
                                    })
                                }
                                c.grid.bDiv.scrollLeft = c.grid.hDiv.scrollLeft
                            }
                            J = c.p.pager ? c.p.pager: "";
                            J += c.p.toppager ? J ? "," + c.p.toppager: c.p.toppager: "";
                            if (J) {
                                W = a.jgrid.formatter.integer || {};
                                x = q(c.p.page);
                                E = q(c.p.lastpage);
                                a(".selbox", J).attr("disabled", false);
                                if (c.p.pginput === true) {
                                    a(".ui-pg-input", J).val(c.p.page);
                                    a("#sp_1", J).html(a.fmatter ? a.fmatter.util.NumberFormat(c.p.lastpage, W) : c.p.lastpage)
                                }
                                if (c.p.viewrecords) if (c.p.reccount === 0) a(".ui-paging-info", J).html(c.p.emptyrecords);
                                else {
                                    U = D + 1;
                                    Q = c.p.records;
                                    if (a.fmatter) {
                                        U = a.fmatter.util.NumberFormat(U, W);
                                        L = a.fmatter.util.NumberFormat(L, W);
                                        Q = a.fmatter.util.NumberFormat(Q, W)
                                    }
                                    a(".ui-paging-info", J).html(a.jgrid.format(c.p.recordtext, U, L, Q))
                                }
                                if (c.p.pgbuttons === true) {
                                    if (x <= 0) x = E = 0;
                                    if (x == 1 || x === 0) {
                                        a("#first, #prev", c.p.pager).addClass("ui-state-disabled").removeClass("ui-state-hover");
                                        c.p.toppager && a("#first_t, #prev_t", c.p.toppager).addClass("ui-state-disabled").removeClass("ui-state-hover")
                                    } else {
                                        a("#first, #prev", c.p.pager).removeClass("ui-state-disabled");
                                        c.p.toppager && a("#first_t, #prev_t", c.p.toppager).removeClass("ui-state-disabled")
                                    }
                                    if (x == E || x === 0) {
                                        a("#next, #last", c.p.pager).addClass("ui-state-disabled").removeClass("ui-state-hover");
                                        c.p.toppager && a("#next_t, #last_t", c.p.toppager).addClass("ui-state-disabled").removeClass("ui-state-hover")
                                    } else {
                                        a("#next, #last", c.p.pager).removeClass("ui-state-disabled");
                                        c.p.toppager && a("#next_t, #last_t", c.p.toppager).removeClass("ui-state-disabled")
                                    }
                                }
                            }
                            s === true && c.p.rownumbers === true && a("td.jqgrid-rownum", c.rows).each(function(S) {
                                a(this).html(D + 1 + S)
                            });
                            u && c.p.jqgdnd && a(c).jqGrid("gridDnD", "updateDnD");
                            a.isFunction(c.p.gridComplete) && c.p.gridComplete.call(c)
                        },
                        P = function(s) {
                            if (!c.grid.hDiv.loading) {
                                var u = c.p.scroll && s === false,
                                x = {},
                                E, D = c.p.prmNames;
                                if (c.p.page <= 0) c.p.page = 1;
                                if (D.search !== null) x[D.search] = c.p.search;
                                if (D.nd !== null) x[D.nd] = (new Date).getTime();
                                if (D.rows !== null) x[D.rows] = c.p.rowNum;
                                if (D.page !== null) x[D.page] = c.p.page;
                                if (D.sort !== null) x[D.sort] = c.p.sortname;
                                if (D.order !== null) x[D.order] = c.p.sortorder;
                                if (c.p.rowTotal !== null && D.totalrows !== null) x[D.totalrows] = c.p.rowTotal;
                                var U = c.p.loadComplete,
                                L = a.isFunction(U);
                                L || (U = null);
                                var Q = 0;
                                s = s || 1;
                                if (s > 1) if (D.npage !== null) {
                                    x[D.npage] = s;
                                    Q = s - 1;
                                    s = 1
                                } else U = function(J) {
                                    c.p.page++;
                                    c.grid.hDiv.loading = false;
                                    L && c.p.loadComplete.call(c, J);
                                    P(s - 1)
                                };
                                else D.npage !== null && delete c.p.postData[D.npage];
                                if (c.p.grouping) {
                                    a(c).jqGrid("groupingSetup");
                                    if (c.p.groupingView.groupDataSorted == true) x[D.sort] = c.p.groupingView.groupField[0] + " " + c.p.groupingView.groupOrder[0] + ", " + x[D.sort]
                                }
                                a.extend(c.p.postData, x);
                                var W = !c.p.scroll ? 1 : c.rows.length - 1;
                                if (a.isFunction(c.p.datatype)) c.p.datatype.call(c, c.p.postData, "load_" + c.p.id);
                                else {
                                    a.isFunction(c.p.beforeRequest) && c.p.beforeRequest.call(c);
                                    E = c.p.datatype.toLowerCase();
                                    switch (E) {
                                    case "json":
                                    case "jsonp":
                                    case "xml":
                                    case "script":
                                        a.ajax(a.extend({
                                            url:
                                            c.p.url,
                                            type: c.p.mtype,
                                            dataType: E,
                                            data: a.isFunction(c.p.serializeGridData) ? c.p.serializeGridData.call(c, c.p.postData) : c.p.postData,
                                            success: function(J) {
                                                E === "xml" ? A(J, c.grid.bDiv, W, s > 1, Q) : G(J, c.grid.bDiv, W, s > 1, Q);
                                                U && U.call(c, J);
                                                u && c.grid.populateVisible();
                                                if (c.p.loadonce || c.p.treeGrid) c.p.datatype = "local";
                                                ga()
                                            },
                                            error: function(J, S, K) {
                                                a.isFunction(c.p.loadError) && c.p.loadError.call(c, J, S, K);
                                                ga()
                                            },
                                            beforeSend: function(J) {
                                                da();
                                                a.isFunction(c.p.loadBeforeSend) && c.p.loadBeforeSend.call(c, J)
                                            }
                                        },
                                        a.jgrid.ajaxOptions, c.p.ajaxGridOptions));
                                        break;
                                    case "xmlstring":
                                        da();
                                        x = a.jgrid.stringToDoc(c.p.datastr);
                                        L && c.p.loadComplete.call(c, x);
                                        A(x, c.grid.bDiv);
                                        c.p.datatype = "local";
                                        c.p.datastr = null;
                                        ga();
                                        break;
                                    case "jsonstring":
                                        da();
                                        x = typeof c.p.datastr == "string" ? a.jgrid.parse(c.p.datastr) : c.p.datastr;
                                        L && c.p.loadComplete.call(c, x);
                                        G(x, c.grid.bDiv);
                                        c.p.datatype = "local";
                                        c.p.datastr = null;
                                        ga();
                                        break;
                                    case "local":
                                    case "clientside":
                                        da();
                                        c.p.datatype = "local";
                                        x = M();
                                        G(x, c.grid.bDiv, W, s > 1, Q);
                                        U && U.call(c, x);
                                        u && c.grid.populateVisible();
                                        ga();
                                        break
                                    }
                                }
                            }
                        },
                        V = function() {
                            var s = c.p.data.length,
                            u, x, E;
                            u = c.p.rownumbers === true ? 1 : 0;
                            x = c.p.multiselect === true ? 1 : 0;
                            E = c.p.subGrid === true ? 1 : 0;
                            u = c.p.keyIndex === false || c.p.loadonce === true ? c.p.localReader.id: c.p.colModel[c.p.keyIndex + x + E + u].name;
                            for (x = 0; x < s; x++) {
                                E = a.jgrid.getAccessor(c.p.data[x], u);
                                c.p._index[E] = x
                            }
                        },
                        da = function() {
                            c.grid.hDiv.loading = true;
                            if (!c.p.hiddengrid) switch (c.p.loadui) {
                            case "disable":
                                break;
                            case "enable":
                                a("#load_" + c.p.id).show();
                                break;
                            case "block":
                                a("#lui_" + c.p.id).show();
                                a("#load_" + c.p.id).show();
                                break
                            }
                        },
                        ga = function() {
                            c.grid.hDiv.loading = false;
                            switch (c.p.loadui) {
                            case "disable":
                                break;
                            case "enable":
                                a("#load_" + c.p.id).hide();
                                break;
                            case "block":
                                a("#lui_" + c.p.id).hide();
                                a("#load_" + c.p.id).hide();
                                break
                            }
                        };
                        l = function(s, u) {
                            var x = "",
                            E = "<table cellspacing='0' cellpadding='0' border='0' style='table-layout:auto;' class='ui-pg-table'><tbody><tr>",
                            D = "",
                            U, L, Q, W, J = function(S) {
                                var K;
                                if (a.isFunction(c.p.onPaging)) K = c.p.onPaging.call(c, S);
                                c.p.selrow = null;
                                if (c.p.multiselect) {
                                    c.p.selarrrow = [];
                                    a("#cb_" + a.jgrid.jqID(c.p.id), c.grid.hDiv).attr("checked", false)
                                }
                                c.p.savedRow = [];
                                if (K == "stop") return false;
                                return true
                            };
                            s = s.substr(1);
                            U = "pg_" + s;
                            L = s + "_left";
                            Q = s + "_center";
                            W = s + "_right";
                            a("#" + s).append("<div id='" + U + "' class='ui-pager-control' role='group'><table cellspacing='0' cellpadding='0' border='0' class='ui-pg-table' style='width:100%;table-layout:fixed;' role='row'><tbody><tr><td id='" + L + "' align='left'></td><td id='" + Q + "' align='center' style='white-space:pre;'></td><td id='" + W + "' align='right'></td></tr></tbody></table></div>").attr("dir", "ltr");
                            if (c.p.rowList.length > 0) {
                                D = "<td dir='" + j + "'>";
                                D += "<select class='ui-pg-selbox' role='listbox'>";
                                for (L = 0; L < c.p.rowList.length; L++) D += '<option role="option" value="' + c.p.rowList[L] + '"' + (c.p.rowNum == c.p.rowList[L] ? ' selected="selected"': "") + ">" + c.p.rowList[L] + "</option>";
                                D += "</select></td>"
                            }
                            if (j == "rtl") E += D;
                            if (c.p.pginput === true) x = "<td dir='" + j + "'>" + a.jgrid.format(c.p.pgtext || "", "<input class='ui-pg-input' type='text' size='2' maxlength='7' value='0' role='textbox'/>", "<span id='sp_1'></span>") + "</td>";
                            if (c.p.pgbuttons === true) {
                                L = ["first" + u, "prev" + u, "next" + u, "last" + u];
                                j == "rtl" && L.reverse();
                                E += "<td id='" + L[0] + "' class='ui-pg-button ui-corner-all'><span class='ui-icon ui-icon-seek-first'></span></td>";
                                E += "<td id='" + L[1] + "' class='ui-pg-button ui-corner-all'><span class='ui-icon ui-icon-seek-prev'></span></td>";
                                E += x != "" ? "<td class='ui-pg-button ui-state-disabled' style='width:4px;'><span class='ui-separator'></span></td>" + x + "<td class='ui-pg-button ui-state-disabled' style='width:4px;'><span class='ui-separator'></span></td>": "";
                                E += "<td id='" + L[2] + "' class='ui-pg-button ui-corner-all'><span class='ui-icon ui-icon-seek-next'></span></td>";
                                E += "<td id='" + L[3] + "' class='ui-pg-button ui-corner-all'><span class='ui-icon ui-icon-seek-end'></span></td>"
                            } else if (x != "") E += x;
                            if (j == "ltr") E += D;
                            E += "</tr></tbody></table>";
                            c.p.viewrecords === true && a("td#" + s + "_" + c.p.recordpos, "#" + U).append("<div dir='" + j + "' style='text-align:" + c.p.recordpos + "' class='ui-paging-info'></div>");
                            a("td#" + s + "_" + c.p.pagerpos, "#" + U).append(E);
                            D = a(".ui-jqgrid").css("font-size") || "11px";
                            a(document.body).append("<div id='testpg' class='ui-jqgrid ui-widget ui-widget-content' style='font-size:" + D + ";visibility:hidden;' ></div>");
                            E = a(E).clone().appendTo("#testpg").width();
                            a("#testpg").remove();
                            if (E > 0) {
                                if (x != "") E += 50;
                                a("td#" + s + "_" + c.p.pagerpos, "#" + U).width(E)
                            }
                            c.p._nvtd = [];
                            c.p._nvtd[0] = E ? Math.floor((c.p.width - E) / 2) : Math.floor(c.p.width / 3);
                            c.p._nvtd[1] = 0;
                            E = null;
                            a(".ui-pg-selbox", "#" + U).bind("change",
                            function() {
                                c.p.page = Math.round(c.p.rowNum * (c.p.page - 1) / this.value - 0.5) + 1;
                                c.p.rowNum = this.value;
                                if (u) a(".ui-pg-selbox", c.p.pager).val(this.value);
                                else c.p.toppager && a(".ui-pg-selbox", c.p.toppager).val(this.value);
                                if (!J("records")) return false;
                                P();
                                return false
                            });
                            if (c.p.pgbuttons === true) {
                                a(".ui-pg-button", "#" + U).hover(function() {
                                    if (a(this).hasClass("ui-state-disabled")) this.style.cursor = "default";
                                    else {
                                        a(this).addClass("ui-state-hover");
                                        this.style.cursor = "pointer"
                                    }
                                },
                                function() {
                                    if (!a(this).hasClass("ui-state-disabled")) {
                                        a(this).removeClass("ui-state-hover");
                                        this.style.cursor = "default"
                                    }
                                });
                                a("#first" + u + ", #prev" + u + ", #next" + u + ", #last" + u, "#" + s).click(function() {
                                    var S = q(c.p.page, 1),
                                    K = q(c.p.lastpage, 1),
                                    ca = false,
                                    la = true,
                                    T = true,
                                    ha = true,
                                    ma = true;
                                    if (K === 0 || K === 1) ma = ha = T = la = false;
                                    else if (K > 1 && S >= 1) if (S === 1) T = la = false;
                                    else {
                                        if (! (S > 1 && S < K)) if (S === K) ma = ha = false
                                    } else if (K > 1 && S === 0) {
                                        ma = ha = false;
                                        S = K - 1
                                    }
                                    if (this.id === "first" + u && la) {
                                        c.p.page = 1;
                                        ca = true
                                    }
                                    if (this.id === "prev" + u && T) {
                                        c.p.page = S - 1;
                                        ca = true
                                    }
                                    if (this.id === "next" + u && ha) {
                                        c.p.page = S + 1;
                                        ca = true
                                    }
                                    if (this.id === "last" + u && ma) {
                                        c.p.page = K;
                                        ca = true
                                    }
                                    if (ca) {
                                        if (!J(this.id)) return false;
                                        P()
                                    }
                                    return false
                                })
                            }
                            c.p.pginput === true && a("input.ui-pg-input", "#" + U).keypress(function(S) {
                                if ((S.charCode ? S.charCode: S.keyCode ? S.keyCode: 0) == 13) {
                                    c.p.page = a(this).val() > 0 ? a(this).val() : c.p.page;
                                    if (!J("user")) return false;
                                    P();
                                    return false
                                }
                                return this
                            })
                        };
                        var ua = function(s, u, x, E) {
                            if (c.p.colModel[u].sortable) if (! (c.p.savedRow.length > 0)) {
                                if (!x) {
                                    if (c.p.lastsort == u) if (c.p.sortorder == "asc") c.p.sortorder = "desc";
                                    else {
                                        if (c.p.sortorder == "desc") c.p.sortorder = "asc"
                                    } else c.p.sortorder = c.p.colModel[u].firstsortorder || "asc";
                                    c.p.page = 1
                                }
                                if (E) if (c.p.lastsort == u && c.p.sortorder == E && !x) return;
                                else c.p.sortorder = E;
                                x = a("thead:first", c.grid.hDiv).get(0);
                                a("tr th:eq(" + c.p.lastsort + ") span.ui-grid-ico-sort", x).addClass("ui-state-disabled");
                                a("tr th:eq(" + c.p.lastsort + ")", x).attr("aria-selected", "false");
                                a("tr th:eq(" + u + ") span.ui-icon-" + c.p.sortorder, x).removeClass("ui-state-disabled");
                                a("tr th:eq(" + u + ")", x).attr("aria-selected", "true");
                                if (!c.p.viewsortcols[0]) if (c.p.lastsort != u) {
                                    a("tr th:eq(" + c.p.lastsort + ") span.s-ico", x).hide();
                                    a("tr th:eq(" + u + ") span.s-ico", x).show()
                                }
                                s = s.substring(5);
                                c.p.sortname = c.p.colModel[u].index || s;
                                x = c.p.sortorder;
                                if (a.isFunction(c.p.onSortCol)) if (c.p.onSortCol.call(c, s, u, x) == "stop") {
                                    c.p.lastsort = u;
                                    return
                                }
                                if (c.p.datatype == "local") c.p.deselectAfterSort && a(c).jqGrid("resetSelection");
                                else {
                                    c.p.selrow = null;
                                    c.p.multiselect && a("#cb_" + a.jgrid.jqID(c.p.id), c.grid.hDiv).attr("checked", false);
                                    c.p.selarrrow = [];
                                    c.p.savedRow = []
                                }
                                if (c.p.scroll) {
                                    x = c.grid.bDiv.scrollLeft;
                                    w(c.grid.bDiv, true);
                                    c.grid.hDiv.scrollLeft = x
                                }
                                c.p.subGrid && c.p.datatype == "local" && a("td.sgexpanded", "#" + c.p.id).each(function() {
                                    a(this).trigger("click")
                                });
                                P();
                                c.p.lastsort = u;
                                if (c.p.sortname != s && u) c.p.lastsort = u
                            }
                        },
                        za = function(s) {
                            var u = s,
                            x;
                            for (x = s + 1; x < c.p.colModel.length; x++) if (c.p.colModel[x].hidden !== true) {
                                u = x;
                                break
                            }
                            return u - s
                        },
                        Aa = function(s) {
                            var u, x = {},
                            E = n ? 0 : c.p.cellLayout;
                            for (u = x[0] = x[1] = x[2] = 0; u <= s; u++) if (c.p.colModel[u].hidden === false) x[0] += c.p.colModel[u].width + E;
                            if (c.p.direction == "rtl") x[0] = c.p.width - x[0];
                            x[0] -= c.grid.bDiv.scrollLeft;
                            if (a(c.grid.cDiv).is(":visible")) x[1] += a(c.grid.cDiv).height() + parseInt(a(c.grid.cDiv).css("padding-top"), 10) + parseInt(a(c.grid.cDiv).css("padding-bottom"), 10);
                            if (c.p.toolbar[0] === true && (c.p.toolbar[1] == "top" || c.p.toolbar[1] == "both")) x[1] += a(c.grid.uDiv).height() + parseInt(a(c.grid.uDiv).css("border-top-width"), 10) + parseInt(a(c.grid.uDiv).css("border-bottom-width"), 10);
                            if (c.p.toppager) x[1] += a(c.grid.topDiv).height() + parseInt(a(c.grid.topDiv).css("border-bottom-width"), 10);
                            x[2] += a(c.grid.bDiv).height() + a(c.grid.hDiv).height();
                            return x
                        };
                        this.p.id = this.id;
                        if (a.inArray(c.p.multikey, ["shiftKey", "altKey", "ctrlKey"]) == -1) c.p.multikey = false;
                        c.p.keyIndex = false;
                        for (h = 0; h < c.p.colModel.length; h++) if (c.p.colModel[h].key === true) {
                            c.p.keyIndex = h;
                            break
                        }
                        c.p.sortorder = c.p.sortorder.toLowerCase();
                        if (c.p.grouping === true) {
                            c.p.scroll = false;
                            c.p.rownumbers = false;
                            c.p.subGrid = false;
                            c.p.treeGrid = false;
                            c.p.gridview = true
                        }
                        if (this.p.treeGrid === true) {
                            try {
                                a(this).jqGrid("setTreeGrid")
                            } catch(Ga) {}
                            if (c.p.datatype != "local") c.p.localReader = {
                                id: "_id_"
                            }
                        }
                        if (this.p.subGrid) try {
                            a(c).jqGrid("setSubGrid")
                        } catch(F) {}
                        if (this.p.multiselect) {
                            this.p.colNames.unshift("<input role='checkbox' id='cb_" + this.p.id + "' class='cbox' type='checkbox'/>");
                            this.p.colModel.unshift({
                                name: "cb",
                                width: n ? c.p.multiselectWidth + c.p.cellLayout: c.p.multiselectWidth,
                                sortable: false,
                                resizable: false,
                                hidedlg: true,
                                search: false,
                                align: "center",
                                fixed: true
                            })
                        }
                        if (this.p.rownumbers) {
                            this.p.colNames.unshift("");
                            this.p.colModel.unshift({
                                name: "rn",
                                width: c.p.rownumWidth,
                                sortable: false,
                                resizable: false,
                                hidedlg: true,
                                search: false,
                                align: "center",
                                fixed: true
                            })
                        }
                        c.p.xmlReader = a.extend(true, {
                            root: "rows",
                            row: "row",
                            page: "rows>page",
                            total: "rows>total",
                            records: "rows>records",
                            repeatitems: true,
                            cell: "cell",
                            id: "[id]",
                            userdata: "userdata",
                            subgrid: {
                                root: "rows",
                                row: "row",
                                repeatitems: true,
                                cell: "cell"
                            }
                        },
                        c.p.xmlReader);
                        c.p.jsonReader = a.extend(true, {
                            root: "rows",
                            page: "page",
                            total: "total",
                            records: "records",
                            repeatitems: true,
                            cell: "cell",
                            id: "id",
                            userdata: "userdata",
                            subgrid: {
                                root: "rows",
                                repeatitems: true,
                                cell: "cell"
                            }
                        },
                        c.p.jsonReader);
                        c.p.localReader = a.extend(true, {
                            root: "rows",
                            page: "page",
                            total: "total",
                            records: "records",
                            repeatitems: false,
                            cell: "cell",
                            id: "id",
                            userdata: "userdata",
                            subgrid: {
                                root: "rows",
                                repeatitems: true,
                                cell: "cell"
                            }
                        },
                        c.p.localReader);
                        if (c.p.scroll) {
                            c.p.pgbuttons = false;
                            c.p.pginput = false;
                            c.p.rowList = []
                        }
                        c.p.data.length && V();
                        var H = "<thead><tr class='ui-jqgrid-labels' role='rowheader'>",
                        Z, N, ea, X, Y, aa, R, ka;
                        N = ka = "";
                        if (c.p.shrinkToFit === true && c.p.forceFit === true) for (h = c.p.colModel.length - 1; h >= 0; h--) if (!c.p.colModel[h].hidden) {
                            c.p.colModel[h].resizable = false;
                            break
                        }
                        if (c.p.viewsortcols[1] == "horizontal") {
                            ka = " ui-i-asc";
                            N = " ui-i-desc"
                        }
                        Z = o ? "class='ui-th-div-ie'": "";
                        ka = "<span class='s-ico' style='display:none'><span sort='asc' class='ui-grid-ico-sort ui-icon-asc" + ka + " ui-state-disabled ui-icon ui-icon-triangle-1-n ui-sort-" + j + "'></span>";
                        ka += "<span sort='desc' class='ui-grid-ico-sort ui-icon-desc" + N + " ui-state-disabled ui-icon ui-icon-triangle-1-s ui-sort-" + j + "'></span></span>";
                        for (h = 0; h < this.p.colNames.length; h++) {
                            N = c.p.headertitles ? ' title="' + a.jgrid.stripHtml(c.p.colNames[h]) + '"': "";
                            H += "<th id='" + c.p.id + "_" + c.p.colModel[h].name + "' role='columnheader' class='ui-state-default ui-th-column ui-th-" + j + "'" + N + ">";
                            N = c.p.colModel[h].index || c.p.colModel[h].name;
                            H += "<div id='jqgh_" + c.p.colModel[h].name + "' " + Z + ">" + c.p.colNames[h];
                            c.p.colModel[h].width = c.p.colModel[h].width ? parseInt(c.p.colModel[h].width, 10) : 150;
                            if (typeof c.p.colModel[h].title !== "boolean") c.p.colModel[h].title = true;
                            if (N == c.p.sortname) c.p.lastsort = h;
                            H += ka + "</div></th>"
                        }
                        H += "</tr></thead>";
                        ka = null;
                        a(this).append(H);
                        a("thead tr:first th", this).hover(function() {
                            a(this).addClass("ui-state-hover")
                        },
                        function() {
                            a(this).removeClass("ui-state-hover")
                        });
                        if (this.p.multiselect) {
                            var ba = [],
                            ta;
                            a("#cb_" + a.jgrid.jqID(c.p.id), this).bind("click",
                            function() {
                                if (this.checked) {
                                    a("[id^=jqg_" + c.p.id + "_]").attr("checked", true);
                                    a(c.rows).each(function(s) {
                                        if (!a(this).hasClass("subgrid") && !a(this).hasClass("jqgroup")) {
                                            a(this).addClass("ui-state-highlight").attr("aria-selected", "true");
                                            c.p.selarrrow[s] = c.p.selrow = this.id
                                        }
                                    });
                                    ta = true;
                                    ba = []
                                } else {
                                    a("[id^=jqg_" + c.p.id + "_]").attr("checked", false);
                                    a(c.rows).each(function(s) {
                                        if (!a(this).hasClass("subgrid")) {
                                            a(this).removeClass("ui-state-highlight").attr("aria-selected", "false");
                                            ba[s] = this.id
                                        }
                                    });
                                    c.p.selarrrow = [];
                                    c.p.selrow = null;
                                    ta = false
                                }
                                if (a.isFunction(c.p.onSelectAll)) c.p.onSelectAll.call(c, ta ? c.p.selarrrow: ba, ta)
                            })
                        }
                        if (c.p.autowidth === true) {
                            H = a(r).innerWidth();
                            c.p.width = H > 0 ? H: "nw"
                        } (function() {
                            var s = 0,
                            u = c.p.cellLayout,
                            x = 0,
                            E, D = c.p.scrollOffset,
                            U, L = false,
                            Q, W = 0,
                            J = 0,
                            S = 0,
                            K;
                            if (n) u = 0;
                            a.each(c.p.colModel,
                            function() {
                                if (typeof this.hidden === "undefined") this.hidden = false;
                                if (this.hidden === false) {
                                    s += q(this.width, 0);
                                    if (this.fixed) {
                                        W += this.width;
                                        J += this.width + u
                                    } else x++;
                                    S++
                                }
                            });
                            if (isNaN(c.p.width)) c.p.width = g.width = s;
                            else g.width = c.p.width;
                            c.p.tblwidth = s;
                            if (c.p.shrinkToFit === false && c.p.forceFit === true) c.p.forceFit = false;
                            if (c.p.shrinkToFit === true && x > 0) {
                                Q = g.width - u * x - J;
                                if (!isNaN(c.p.height)) {
                                    Q -= D;
                                    L = true
                                }
                                s = 0;
                                a.each(c.p.colModel,
                                function(ca) {
                                    if (this.hidden === false && !this.fixed) {
                                        this.width = U = Math.round(Q * this.width / (c.p.tblwidth - W));
                                        s += U;
                                        E = ca
                                    }
                                });
                                K = 0;
                                if (L) {
                                    if (g.width - J - (s + u * x) !== D) K = g.width - J - (s + u * x) - D
                                } else if (!L && Math.abs(g.width - J - (s + u * x)) !== 1) K = g.width - J - (s + u * x);
                                c.p.colModel[E].width += K;
                                c.p.tblwidth = s + K + W + S * u;
                                if (c.p.tblwidth > c.p.width) {
                                    c.p.colModel[E].width -= c.p.tblwidth - parseInt(c.p.width, 10);
                                    c.p.tblwidth = c.p.width
                                }
                            }
                        })();
                        a(r).css("width", g.width + "px").append("<div class='ui-jqgrid-resize-mark' id='rs_m" + c.p.id + "'>&#160;</div>");
                        a(k).css("width", g.width + "px");
                        H = a("thead:first", c).get(0);
                        var fa = "";
                        if (c.p.footerrow) fa += "<table role='grid' style='width:" + c.p.tblwidth + "px' class='ui-jqgrid-ftable' cellspacing='0' cellpadding='0' border='0'><tbody><tr role='row' class='ui-widget-content footrow footrow-" + j + "'>";
                        k = a("tr:first", H);
                        var xa = "<tr class='jqgfirstrow' role='row' style='height:auto'>";
                        c.p.disableClick = false;
                        a("th", k).each(function(s) {
                            ea = c.p.colModel[s].width;
                            if (typeof c.p.colModel[s].resizable === "undefined") c.p.colModel[s].resizable = true;
                            if (c.p.colModel[s].resizable) {
                                X = document.createElement("span");
                                a(X).html("&#160;").addClass("ui-jqgrid-resize ui-jqgrid-resize-" + j);
                                a.browser.opera || a(X).css("cursor", "col-resize");
                                a(this).addClass(c.p.resizeclass)
                            } else X = "";
                            a(this).css("width", ea + "px").prepend(X);
                            var u = "";
                            if (c.p.colModel[s].hidden) {
                                a(this).css("display", "none");
                                u = "display:none;"
                            }
                            xa += "<td role='gridcell' style='height:0px;width:" + ea + "px;" + u + "'>";
                            g.headers[s] = {
                                width: ea,
                                el: this
                            };
                            Y = c.p.colModel[s].sortable;
                            if (typeof Y !== "boolean") Y = c.p.colModel[s].sortable = true;
                            u = c.p.colModel[s].name;
                            u == "cb" || u == "subgrid" || u == "rn" || c.p.viewsortcols[2] && a("div", this).addClass("ui-jqgrid-sortable");
                            if (Y) if (c.p.viewsortcols[0]) {
                                a("div span.s-ico", this).show();
                                s == c.p.lastsort && a("div span.ui-icon-" + c.p.sortorder, this).removeClass("ui-state-disabled")
                            } else if (s == c.p.lastsort) {
                                a("div span.s-ico", this).show();
                                a("div span.ui-icon-" + c.p.sortorder, this).removeClass("ui-state-disabled")
                            }
                            if (c.p.footerrow) fa += "<td role='gridcell' " + t(s, 0, "") + ">&#160;</td>"
                        }).mousedown(function(s) {
                            if (a(s.target).closest("th>span.ui-jqgrid-resize").length == 1) {
                                var u = a.jgrid.getCellIndex(this);
                                if (c.p.forceFit === true) c.p.nv = za(u);
                                g.dragStart(u, s, Aa(u));
                                return false
                            }
                        }).click(function(s) {
                            if (c.p.disableClick) return c.p.disableClick = false;
                            var u = "th>div.ui-jqgrid-sortable",
                            x, E;
                            c.p.viewsortcols[2] || (u = "th>div>span>span.ui-grid-ico-sort");
                            s = a(s.target).closest(u);
                            if (s.length == 1) {
                                u = a.jgrid.getCellIndex(this);
                                if (!c.p.viewsortcols[2]) {
                                    x = true;
                                    E = s.attr("sort")
                                }
                                ua(a("div", this)[0].id, u, x, E);
                                return false
                            }
                        });
                        if (c.p.sortable && a.fn.sortable) try {
                            a(c).jqGrid("sortableColumns", k)
                        } catch(ya) {}
                        if (c.p.footerrow) fa += "</tr></tbody></table>";
                        xa += "</tr>";
                        this.appendChild(document.createElement("tbody"));
                        a(this).addClass("ui-jqgrid-btable").append(xa);
                        xa = null;
                        k = a("<table class='ui-jqgrid-htable' style='width:" + c.p.tblwidth + "px' role='grid' aria-labelledby='gbox_" + this.id + "' cellspacing='0' cellpadding='0' border='0'></table>").append(H);
                        var na = c.p.caption && c.p.hiddengrid === true ? true: false;
                        h = a("<div class='ui-jqgrid-hbox" + (j == "rtl" ? "-rtl": "") + "'></div>");
                        H = null;
                        g.hDiv = document.createElement("div");
                        a(g.hDiv).css({
                            width: g.width + "px"
                        }).addClass("ui-state-default ui-jqgrid-hdiv").append(h);
                        a(h).append(k);
                        k = null;
                        na && a(g.hDiv).hide();
                        if (c.p.pager) {
                            if (typeof c.p.pager == "string") {
                                if (c.p.pager.substr(0, 1) != "#") c.p.pager = "#" + c.p.pager
                            } else c.p.pager = "#" + a(c.p.pager).attr("id");
                            a(c.p.pager).css({
                                width: g.width + "px"
                            }).appendTo(r).addClass("ui-state-default ui-jqgrid-pager ui-corner-bottom");
                            na && a(c.p.pager).hide();
                            l(c.p.pager, "")
                        }
                        c.p.cellEdit === false && c.p.hoverrows === true && a(c).bind("mouseover",
                        function(s) {
                            R = a(s.target).closest("tr.jqgrow");
                            a(R).attr("class") !== "subgrid" && a(R).addClass("ui-state-hover");
                            return false
                        }).bind("mouseout",
                        function(s) {
                            R = a(s.target).closest("tr.jqgrow");
                            a(R).removeClass("ui-state-hover");
                            return false
                        });
                        var Ca, ra;
                        a(c).before(g.hDiv).click(function(s) {
                            aa = s.target;
                            var u = a(aa).hasClass("cbox");
                            R = a(aa, c.rows).closest("tr.jqgrow");
                            if (a(R).length === 0) return this;
                            var x = true;
                            if (a.isFunction(c.p.beforeSelectRow)) x = c.p.beforeSelectRow.call(c, R[0].id, s);
                            if (aa.tagName == "A" || (aa.tagName == "INPUT" || aa.tagName == "TEXTAREA" || aa.tagName == "OPTION" || aa.tagName == "SELECT") && !u) return this;
                            if (x === true) {
                                if (c.p.cellEdit === true) if (c.p.multiselect && u) a(c).jqGrid("setSelection", R[0].id, true);
                                else {
                                    Ca = R[0].rowIndex;
                                    ra = a.jgrid.getCellIndex(aa);
                                    try {
                                        a(c).jqGrid("editCell", Ca, ra, true)
                                    } catch(E) {}
                                } else if (c.p.multikey) if (s[c.p.multikey]) a(c).jqGrid("setSelection", R[0].id, true);
                                else {
                                    if (c.p.multiselect && u) {
                                        u = a("[id^=jqg_" + c.p.id + "_]").attr("checked");
                                        a("[id^=jqg_" + c.p.id + "_]").attr("checked", !u)
                                    }
                                } else {
                                    if (c.p.multiselect && c.p.multiboxonly) if (!u) {
                                        a(c.p.selarrrow).each(function(D, U) {
                                            D = c.rows.namedItem(U);
                                            a(D).removeClass("ui-state-highlight");
                                            a("#jqg_" + c.p.id + "_" + a.jgrid.jqID(U)).attr("checked", false)
                                        });
                                        c.p.selarrrow = [];
                                        a("#cb_" + a.jgrid.jqID(c.p.id), c.grid.hDiv).attr("checked", false)
                                    }
                                    a(c).jqGrid("setSelection", R[0].id, true)
                                }
                                if (a.isFunction(c.p.onCellSelect)) {
                                    Ca = R[0].id;
                                    ra = a.jgrid.getCellIndex(aa);
                                    c.p.onCellSelect.call(c, Ca, ra, a(aa).html(), s)
                                }
                                s.stopPropagation()
                            } else return this
                        }).bind("reloadGrid",
                        function(s, u) {
                            if (c.p.treeGrid === true) c.p.datatype = c.p.treedatatype;
                            u && u.current && c.grid.selectionPreserver(c);
                            if (c.p.datatype == "local") {
                                a(c).jqGrid("resetSelection");
                                c.p.data.length && V()
                            } else if (!c.p.treeGrid) {
                                c.p.selrow = null;
                                if (c.p.multiselect) {
                                    c.p.selarrrow = [];
                                    a("#cb_" + a.jgrid.jqID(c.p.id), c.grid.hDiv).attr("checked", false)
                                }
                                c.p.savedRow = []
                            }
                            c.p.scroll && w(c.grid.bDiv, true);
                            if (u && u.page) {
                                s = u.page;
                                if (s > c.p.lastpage) s = c.p.lastpage;
                                if (s < 1) s = 1;
                                c.p.page = s;
                                c.grid.bDiv.scrollTop = c.grid.prevRowHeight ? (s - 1) * c.grid.prevRowHeight * c.p.rowNum: 0
                            }
                            if (c.grid.prevRowHeight && c.p.scroll) {
                                delete c.p.lastpage;
                                c.grid.populateVisible()
                            } else c.grid.populate();
                            return false
                        });
                        a.isFunction(this.p.ondblClickRow) && a(this).dblclick(function(s) {
                            aa = s.target;
                            R = a(aa, c.rows).closest("tr.jqgrow");
                            if (a(R).length === 0) return false;
                            Ca = R[0].rowIndex;
                            ra = a.jgrid.getCellIndex(aa);
                            c.p.ondblClickRow.call(c, a(R).attr("id"), Ca, ra, s);
                            return false
                        });
                        a.isFunction(this.p.onRightClickRow) && a(this).bind("contextmenu",
                        function(s) {
                            aa = s.target;
                            R = a(aa, c.rows).closest("tr.jqgrow");
                            if (a(R).length === 0) return false;
                            c.p.multiselect || a(c).jqGrid("setSelection", R[0].id, true);
                            Ca = R[0].rowIndex;
                            ra = a.jgrid.getCellIndex(aa);
                            c.p.onRightClickRow.call(c, a(R).attr("id"), Ca, ra, s);
                            return false
                        });
                        g.bDiv = document.createElement("div");
                        a(g.bDiv).append(a('<div style="position:relative;' + (o && a.browser.version < 8 ? "height:0.01%;": "") + '"></div>').append("<div></div>").append(this)).addClass("ui-jqgrid-bdiv").css({
                            height: c.p.height + (isNaN(c.p.height) ? "": "px"),
                            width: g.width + "px"
                        }).scroll(g.scrollGrid);
                        a("table:first", g.bDiv).css({
                            width: c.p.tblwidth + "px"
                        });
                        if (o) {
                            a("tbody", this).size() == 2 && a("tbody:gt(0)", this).remove();
                            c.p.multikey && a(g.bDiv).bind("selectstart",
                            function() {
                                return false
                            })
                        } else c.p.multikey && a(g.bDiv).bind("mousedown",
                        function() {
                            return false
                        });
                        na && a(g.bDiv).hide();
                        g.cDiv = document.createElement("div");
                        var Ba = c.p.hidegrid === true ? a("<a role='link' href='javascript:void(0)'/>").addClass("ui-jqgrid-titlebar-close HeaderButton").hover(function() {
                            Ba.addClass("ui-state-hover")
                        },
                        function() {
                            Ba.removeClass("ui-state-hover")
                        }).append("<span class='ui-icon ui-icon-circle-triangle-n'></span>").css(j == "rtl" ? "left": "right", "0px") : "";
                        a(g.cDiv).append(Ba).append("<span class='ui-jqgrid-title" + (j == "rtl" ? "-rtl": "") + "'>" + c.p.caption + "</span>").addClass("ui-jqgrid-titlebar ui-widget-header ui-corner-top ui-helper-clearfix");
                        a(g.cDiv).insertBefore(g.hDiv);
                        if (c.p.toolbar[0]) {
                            g.uDiv = document.createElement("div");
                            if (c.p.toolbar[1] == "top") a(g.uDiv).insertBefore(g.hDiv);
                            else c.p.toolbar[1] == "bottom" && a(g.uDiv).insertAfter(g.hDiv);
                            if (c.p.toolbar[1] == "both") {
                                g.ubDiv = document.createElement("div");
                                a(g.uDiv).insertBefore(g.hDiv).addClass("ui-userdata ui-state-default").attr("id", "t_" + this.id);
                                a(g.ubDiv).insertAfter(g.hDiv).addClass("ui-userdata ui-state-default").attr("id", "tb_" + this.id);
                                na && a(g.ubDiv).hide()
                            } else a(g.uDiv).width(g.width).addClass("ui-userdata ui-state-default").attr("id", "t_" + this.id);
                            na && a(g.uDiv).hide()
                        }
                        if (c.p.toppager) {
                            c.p.toppager = c.p.id + "_toppager";
                            g.topDiv = a("<div id='" + c.p.toppager + "'></div>")[0];
                            c.p.toppager = "#" + c.p.toppager;
                            a(g.topDiv).insertBefore(g.hDiv).addClass("ui-state-default ui-jqgrid-toppager").width(g.width);
                            l(c.p.toppager, "_t")
                        }
                        if (c.p.footerrow) {
                            g.sDiv = a("<div class='ui-jqgrid-sdiv'></div>")[0];
                            h = a("<div class='ui-jqgrid-hbox" + (j == "rtl" ? "-rtl": "") + "'></div>");
                            a(g.sDiv).append(h).insertAfter(g.hDiv).width(g.width);
                            a(h).append(fa);
                            g.footers = a(".ui-jqgrid-ftable", g.sDiv)[0].rows[0].cells;
                            if (c.p.rownumbers) g.footers[0].className = "ui-state-default jqgrid-rownum";
                            na && a(g.sDiv).hide()
                        }
                        h = null;
                        if (c.p.caption) {
                            var Ia = c.p.datatype;
                            if (c.p.hidegrid === true) {
                                a(".ui-jqgrid-titlebar-close", g.cDiv).click(function(s) {
                                    var u = a.isFunction(c.p.onHeaderClick);
                                    if (c.p.gridstate == "visible") {
                                        a(".ui-jqgrid-bdiv, .ui-jqgrid-hdiv", "#gview_" + c.p.id).slideUp("fast");
                                        c.p.pager && a(c.p.pager).slideUp("fast");
                                        c.p.toppager && a(c.p.toppager).slideUp("fast");
                                        if (c.p.toolbar[0] === true) {
                                            c.p.toolbar[1] == "both" && a(g.ubDiv).slideUp("fast");
                                            a(g.uDiv).slideUp("fast")
                                        }
                                        c.p.footerrow && a(".ui-jqgrid-sdiv", "#gbox_" + c.p.id).slideUp("fast");
                                        a("span", this).removeClass("ui-icon-circle-triangle-n").addClass("ui-icon-circle-triangle-s");
                                        c.p.gridstate = "hidden";
                                        a("#gbox_" + c.p.id).hasClass("ui-resizable") && a(".ui-resizable-handle", "#gbox_" + c.p.id).hide();
                                        if (u) na || c.p.onHeaderClick.call(c, c.p.gridstate, s)
                                    } else if (c.p.gridstate == "hidden") {
                                        a(".ui-jqgrid-hdiv, .ui-jqgrid-bdiv", "#gview_" + c.p.id).slideDown("fast");
                                        c.p.pager && a(c.p.pager).slideDown("fast");
                                        c.p.toppager && a(c.p.toppager).slideDown("fast");
                                        if (c.p.toolbar[0] === true) {
                                            c.p.toolbar[1] == "both" && a(g.ubDiv).slideDown("fast");
                                            a(g.uDiv).slideDown("fast")
                                        }
                                        c.p.footerrow && a(".ui-jqgrid-sdiv", "#gbox_" + c.p.id).slideDown("fast");
                                        a("span", this).removeClass("ui-icon-circle-triangle-s").addClass("ui-icon-circle-triangle-n");
                                        if (na) {
                                            c.p.datatype = Ia;
                                            P();
                                            na = false
                                        }
                                        c.p.gridstate = "visible";
                                        a("#gbox_" + c.p.id).hasClass("ui-resizable") && a(".ui-resizable-handle", "#gbox_" + c.p.id).show();
                                        u && c.p.onHeaderClick.call(c, c.p.gridstate, s)
                                    }
                                    return false
                                });
                                if (na) {
                                    c.p.datatype = "local";
                                    a(".ui-jqgrid-titlebar-close", g.cDiv).trigger("click")
                                }
                            }
                        } else a(g.cDiv).hide();
                        a(g.hDiv).after(g.bDiv).mousemove(function(s) {
                            if (g.resizing) {
                                g.dragMove(s);
                                return false
                            }
                        });
                        a(".ui-jqgrid-labels", g.hDiv).bind("selectstart",
                        function() {
                            return false
                        });
                        a(document).mouseup(function() {
                            if (g.resizing) {
                                g.dragEnd();
                                return false
                            }
                            return true
                        });
                        c.formatCol = t;
                        c.sortData = ua;
                        c.updatepager = O;
                        c.refreshIndex = V;
                        c.formatter = function(s, u, x, E, D) {
                            return p(s, u, x, E, D)
                        };
                        a.extend(g, {
                            populate: P,
                            emptyRows: w
                        });
                        this.grid = g;
                        c.addXmlData = function(s) {
                            A(s, c.grid.bDiv)
                        };
                        c.addJSONData = function(s) {
                            G(s, c.grid.bDiv)
                        };
                        this.grid.cols = this.rows[0].cells;
                        P();
                        c.p.hiddengrid = false;
                        a(window).unload(function() {
                            c = null
                        })
                    }
                }
            }
        })
    };
    a.jgrid.extend({
        getGridParam: function(e) {
            var d = this[0];
            if (d && d.grid) return e ? typeof d.p[e] != "undefined" ? d.p[e] : null: d.p
        },
        setGridParam: function(e) {
            return this.each(function() {
                this.grid && typeof e === "object" && a.extend(true, this.p, e)
            })
        },
        getDataIDs: function() {
            var e = [],
            d = 0,
            b,
            f = 0;
            this.each(function() {
                if ((b = this.rows.length) && b > 0) for (; d < b;) {
                    if (a(this.rows[d]).hasClass("jqgrow")) {
                        e[f] = this.rows[d].id;
                        f++
                    }
                    d++
                }
            });
            return e
        },
        setSelection: function(e, d) {
            return this.each(function() {
                function b(j) {
                    var c = a(f.grid.bDiv)[0].clientHeight,
                    k = a(f.grid.bDiv)[0].scrollTop,
                    l = f.rows[j].offsetTop;
                    j = f.rows[j].clientHeight;
                    if (l + j >= c + k) a(f.grid.bDiv)[0].scrollTop = l - (c + k) + j + k;
                    else if (l < c + k) if (l < k) a(f.grid.bDiv)[0].scrollTop = l
                }
                var f = this,
                g, h;
                if (e !== undefined) {
                    d = d === false ? false: true;
                    if (g = f.rows.namedItem(e + "")) {
                        if (f.p.scrollrows === true) {
                            h = f.rows.namedItem(e).rowIndex;
                            h >= 0 && b(h)
                        }
                        if (f.p.multiselect) {
                            f.p.selrow = g.id;
                            h = a.inArray(f.p.selrow, f.p.selarrrow);
                            if (h === -1) {
                                g.className !== "ui-subgrid" && a(g).addClass("ui-state-highlight").attr("aria-selected", "true");
                                g = true;
                                a("#jqg_" + f.p.id + "_" + a.jgrid.jqID(f.p.selrow)).attr("checked", g);
                                f.p.selarrrow.push(f.p.selrow);
                                f.p.onSelectRow && d && f.p.onSelectRow.call(f, f.p.selrow, g)
                            } else {
                                g.className !== "ui-subgrid" && a(g).removeClass("ui-state-highlight").attr("aria-selected", "false");
                                g = false;
                                a("#jqg_" + f.p.id + "_" + a.jgrid.jqID(f.p.selrow)).attr("checked", g);
                                f.p.selarrrow.splice(h, 1);
                                f.p.onSelectRow && d && f.p.onSelectRow.call(f, f.p.selrow, g);
                                g = f.p.selarrrow[0];
                                f.p.selrow = g === undefined ? null: g
                            }
                        } else if (g.className !== "ui-subgrid") {
                            f.p.selrow && a(f.rows.namedItem(f.p.selrow)).removeClass("ui-state-highlight").attr("aria-selected", "false");
                            f.p.selrow = g.id;
                            a(g).addClass("ui-state-highlight").attr("aria-selected", "true");
                            f.p.onSelectRow && d && f.p.onSelectRow.call(f, f.p.selrow, true)
                        }
                    }
                }
            })
        },
        resetSelection: function() {
            return this.each(function() {
                var e = this,
                d;
                if (e.p.multiselect) {
                    a(e.p.selarrrow).each(function(b, f) {
                        d = e.rows.namedItem(f);
                        a(d).removeClass("ui-state-highlight").attr("aria-selected", "false");
                        a("#jqg_" + e.p.id + "_" + a.jgrid.jqID(f)).attr("checked", false)
                    });
                    a("#cb_" + a.jgrid.jqID(e.p.id)).attr("checked", false);
                    e.p.selarrrow = []
                } else if (e.p.selrow) {
                    a("#" + e.p.id + " tbody:first tr#" + a.jgrid.jqID(e.p.selrow)).removeClass("ui-state-highlight").attr("aria-selected", "false");
                    e.p.selrow = null
                }
                e.p.savedRow = []
            })
        },
        getRowData: function(e) {
            var d = {},
            b, f = false,
            g, h = 0;
            this.each(function() {
                var j = this,
                c, k;
                if (typeof e == "undefined") {
                    f = true;
                    b = [];
                    g = j.rows.length
                } else {
                    k = j.rows.namedItem(e);
                    if (!k) return d;
                    g = 2
                }
                for (; h < g;) {
                    if (f) k = j.rows[h];
                    if (a(k).hasClass("jqgrow")) {
                        a("td", k).each(function(l) {
                            c = j.p.colModel[l].name;
                            if (c !== "cb" && c !== "subgrid" && c !== "rn") if (j.p.treeGrid === true && c == j.p.ExpandColumn) d[c] = a.jgrid.htmlDecode(a("span:first", this).html());
                            else try {
                                d[c] = a.unformat(this, {
                                    rowId: k.id,
                                    colModel: j.p.colModel[l]
                                },
                                l)
                            } catch(o) {
                                d[c] = a.jgrid.htmlDecode(a(this).html())
                            }
                        });
                        if (f) {
                            b.push(d);
                            d = {}
                        }
                    }
                    h++
                }
            });
            return b ? b: d
        },
        delRowData: function(e) {
            var d = false,
            b, f;
            this.each(function() {
                var g = this;
                if (b = g.rows.namedItem(e)) {
                    a(b).remove();
                    g.p.records--;
                    g.p.reccount--;
                    g.updatepager(true, false);
                    d = true;
                    if (g.p.multiselect) {
                        f = a.inArray(e, g.p.selarrrow);
                        f != -1 && g.p.selarrrow.splice(f, 1)
                    }
                    if (e == g.p.selrow) g.p.selrow = null
                } else return false;
                if (g.p.datatype == "local") {
                    var h = g.p._index[e];
                    if (typeof h != "undefined") {
                        g.p.data.splice(h, 1);
                        g.refreshIndex()
                    }
                }
                if (g.p.altRows === true && d) {
                    var j = g.p.altclass;
                    a(g.rows).each(function(c) {
                        c % 2 == 1 ? a(this).addClass(j) : a(this).removeClass(j)
                    })
                }
            });
            return d
        },
        setRowData: function(e, d, b) {
            var f, g = true,
            h;
            this.each(function() {
                if (!this.grid) return false;
                var j = this,
                c, k, l = typeof b,
                o = {};
                k = j.rows.namedItem(e);
                if (!k) return false;
                if (d) try {
                    a(this.p.colModel).each(function(q) {
                        f = this.name;
                        if (d[f] !== undefined) {
                            o[f] = this.formatter && typeof this.formatter === "string" && this.formatter == "date" ? a.unformat.date(d[f], this) : d[f];
                            c = j.formatter(e, d[f], q, d, "edit");
                            h = this.title ? {
                                title: a.jgrid.stripHtml(c)
                            }: {};
                            j.p.treeGrid === true && f == j.p.ExpandColumn ? a("td:eq(" + q + ") > span:first", k).html(c).attr(h) : a("td:eq(" + q + ")", k).html(c).attr(h)
                        }
                    });
                    if (j.p.datatype == "local") {
                        var n = j.p._index[e];
                        if (typeof n != "undefined") j.p.data[n] = a.extend(true, j.p.data[n], o);
                        o = null
                    }
                } catch(r) {
                    g = false
                }
                if (g) if (l === "string") a(k).addClass(b);
                else l === "object" && a(k).css(b)
            });
            return g
        },
        addRowData: function(e, d, b, f) {
            b || (b = "last");
            var g = false,
            h, j, c, k, l, o, n, r, q = "",
            t, m, p, v, y;
            if (d) {
                if (a.isArray(d)) {
                    t = true;
                    b = "last";
                    m = e
                } else {
                    d = [d];
                    t = false
                }
                this.each(function() {
                    var B = this,
                    C = d.length;
                    l = B.p.rownumbers === true ? 1 : 0;
                    c = B.p.multiselect === true ? 1 : 0;
                    k = B.p.subGrid === true ? 1 : 0;
                    if (!t) if (typeof e != "undefined") e += "";
                    else {
                        e = B.p.records + 1 + "";
                        if (B.p.keyIndex !== false) {
                            m = B.p.colModel[B.p.keyIndex + c + k + l].name;
                            if (typeof d[0][m] != "undefined") e = d[0][m]
                        }
                    }
                    p = B.p.altclass;
                    for (var I = 0,
                    w = "",
                    A = {},
                    G = a.isFunction(B.p.afterInsertRow) ? true: false; I < C;) {
                        v = d[I];
                        j = "";
                        if (t) {
                            try {
                                e = v[m]
                            } catch(M) {
                                e = B.p.records + 1 + ""
                            }
                            w = B.p.altRows === true ? (B.rows.length - 1) % 2 === 0 ? p: "": ""
                        }
                        if (l) {
                            q = B.formatCol(0, 1, "");
                            j += '<td role="gridcell" aria-describedby="' + B.p.id + '_rn" class="ui-state-default jqgrid-rownum" ' + q + ">0</td>"
                        }
                        if (c) {
                            r = '<input role="checkbox" type="checkbox" id="jqg_' + B.p.id + "_" + e + '" class="cbox"/>';
                            q = B.formatCol(l, 1, "");
                            j += '<td role="gridcell" aria-describedby="' + B.p.id + '_cb" ' + q + ">" + r + "</td>"
                        }
                        if (k) j += a(B).jqGrid("addSubGridCell", c + l, 1);
                        for (n = c + k + l; n < B.p.colModel.length; n++) {
                            y = B.p.colModel[n];
                            h = y.name;
                            A[h] = y.formatter && typeof y.formatter === "string" && y.formatter == "date" ? a.unformat.date(v[h], y) : v[h];
                            r = B.formatter(e, a.jgrid.getAccessor(v, h), n, v, "edit");
                            q = B.formatCol(n, 1, r);
                            j += '<td role="gridcell" aria-describedby="' + B.p.id + "_" + h + '" ' + q + ">" + r + "</td>"
                        }
                        j = '<tr id="' + e + '" role="row" class="ui-widget-content jqgrow ui-row-' + B.p.direction + " " + w + '">' + j + "</tr>";
                        if (B.p.subGrid === true) {
                            j = a(j)[0];
                            a(B).jqGrid("addSubGrid", j, c + l)
                        }
                        if (B.rows.length === 0) a("table:first", B.grid.bDiv).append(j);
                        else switch (b) {
                        case "last":
                            a(B.rows[B.rows.length - 1]).after(j);
                            break;
                        case "first":
                            a(B.rows[0]).after(j);
                            break;
                        case "after":
                            if (o = B.rows.namedItem(f)) a(B.rows[o.rowIndex + 1]).hasClass("ui-subgrid") ? a(B.rows[o.rowIndex + 1]).after(j) : a(o).after(j);
                            break;
                        case "before":
                            if (o = B.rows.namedItem(f)) {
                                a(o).before(j);
                                o = o.rowIndex
                            }
                            break
                        }
                        B.p.records++;
                        B.p.reccount++;
                        G && B.p.afterInsertRow.call(B, e, v, v);
                        I++;
                        if (B.p.datatype == "local") {
                            B.p._index[e] = B.p.data.length;
                            B.p.data.push(A);
                            A = {}
                        }
                    }
                    if (B.p.altRows === true && !t) if (b == "last")(B.rows.length - 1) % 2 == 1 && a(B.rows[B.rows.length - 1]).addClass(p);
                    else a(B.rows).each(function(O) {
                        O % 2 == 1 ? a(this).addClass(p) : a(this).removeClass(p)
                    });
                    B.updatepager(true, true);
                    g = true
                })
            }
            return g
        },
        footerData: function(e, d, b) {
            function f(k) {
                for (var l in k) if (k.hasOwnProperty(l)) return false;
                return true
            }
            var g, h = false,
            j = {},
            c;
            if (typeof e == "undefined") e = "get";
            if (typeof b != "boolean") b = true;
            e = e.toLowerCase();
            this.each(function() {
                var k = this,
                l;
                if (!k.grid || !k.p.footerrow) return false;
                if (e == "set") if (f(d)) return false;
                h = true;
                a(this.p.colModel).each(function(o) {
                    g = this.name;
                    if (e == "set") {
                        if (d[g] !== undefined) {
                            l = b ? k.formatter("", d[g], o, d, "edit") : d[g];
                            c = this.title ? {
                                title: a.jgrid.stripHtml(l)
                            }: {};
                            a("tr.footrow td:eq(" + o + ")", k.grid.sDiv).html(l).attr(c);
                            h = true
                        }
                    } else if (e == "get") j[g] = a("tr.footrow td:eq(" + o + ")", k.grid.sDiv).html()
                })
            });
            return e == "get" ? j: h
        },
        ShowHideCol: function(e, d) {
            return this.each(function() {
                var b = this,
                f = false;
                if (b.grid) {
                    if (typeof e === "string") e = [e];
                    d = d != "none" ? "": "none";
                    var g = d == "" ? true: false;
                    a(this.p.colModel).each(function(h) {
                        if (a.inArray(this.name, e) !== -1 && this.hidden === g) {
                            a("tr", b.grid.hDiv).each(function() {
                                a("th:eq(" + h + ")", this).css("display", d)
                            });
                            a(b.rows).each(function(j) {
                                a("td:eq(" + h + ")", b.rows[j]).css("display", d)
                            });
                            b.p.footerrow && a("td:eq(" + h + ")", b.grid.sDiv).css("display", d);
                            if (d == "none") b.p.tblwidth -= this.width + b.p.cellLayout;
                            else b.p.tblwidth += this.width;
                            this.hidden = !g;
                            f = true
                        }
                    });
                    if (f === true) {
                        a("table:first", b.grid.hDiv).width(b.p.tblwidth);
                        a("table:first", b.grid.bDiv).width(b.p.tblwidth);
                        b.grid.hDiv.scrollLeft = b.grid.bDiv.scrollLeft;
                        if (b.p.footerrow) {
                            a("table:first", b.grid.sDiv).width(b.p.tblwidth);
                            b.grid.sDiv.scrollLeft = b.grid.bDiv.scrollLeft
                        }
                        b.p.shrinkToFit === true && a(b).jqGrid("setGridWidth", b.grid.width - 0.0010, true)
                    }
                }
            })
        },
        hideCol: function(e) {
            return this.each(function() {
                a(this).jqGrid("ShowHideCol", e, "none")
            })
        },
        showCol: function(e) {
            return this.each(function() {
                a(this).jqGrid("ShowHideCol", e, "")
            })
        },
        remapColumns: function(e, d, b) {
            function f(j) {
                var c;
                c = j.length ? a.makeArray(j) : a.extend({},
                j);
                a.each(e,
                function(k) {
                    j[k] = c[this]
                })
            }
            function g(j, c) {
                a(">tr" + (c || ""), j).each(function() {
                    var k = this,
                    l = a.makeArray(k.cells);
                    a.each(e,
                    function() {
                        var o = l[this];
                        o && k.appendChild(o)
                    })
                })
            }
            var h = this.get(0);
            f(h.p.colModel);
            f(h.p.colNames);
            f(h.grid.headers);
            g(a("thead:first", h.grid.hDiv), b && ":not(.ui-jqgrid-labels)");
            d && g(a("#" + h.p.id + " tbody:first"), ".jqgfirstrow, tr.jqgrow, tr.jqfoot");
            h.p.footerrow && g(a("tbody:first", h.grid.sDiv));
            if (h.p.remapColumns) if (h.p.remapColumns.length) f(h.p.remapColumns);
            else h.p.remapColumns = a.makeArray(e);
            h.p.lastsort = a.inArray(h.p.lastsort, e);
            if (h.p.treeGrid) h.p.expColInd = a.inArray(h.p.expColInd, e)
        },
        setGridWidth: function(e, d) {
            return this.each(function() {
                if (this.grid) {
                    var b = this,
                    f, g = 0,
                    h = b.p.cellLayout,
                    j, c = 0,
                    k = false,
                    l = b.p.scrollOffset,
                    o, n = 0,
                    r = 0,
                    q = 0,
                    t;
                    if (typeof d != "boolean") d = b.p.shrinkToFit;
                    if (!isNaN(e)) {
                        e = parseInt(e, 10);
                        b.grid.width = b.p.width = e;
                        a("#gbox_" + b.p.id).css("width", e + "px");
                        a("#gview_" + b.p.id).css("width", e + "px");
                        a(b.grid.bDiv).css("width", e + "px");
                        a(b.grid.hDiv).css("width", e + "px");
                        b.p.pager && a(b.p.pager).css("width", e + "px");
                        b.p.toppager && a(b.p.toppager).css("width", e + "px");
                        if (b.p.toolbar[0] === true) {
                            a(b.grid.uDiv).css("width", e + "px");
                            b.p.toolbar[1] == "both" && a(b.grid.ubDiv).css("width", e + "px")
                        }
                        b.p.footerrow && a(b.grid.sDiv).css("width", e + "px");
                        if (d === false && b.p.forceFit === true) b.p.forceFit = false;
                        if (d === true) {
                            if (a.browser.safari) h = 0;
                            a.each(b.p.colModel,
                            function() {
                                if (this.hidden === false) {
                                    g += parseInt(this.width, 10);
                                    if (this.fixed) {
                                        r += this.width;
                                        n += this.width + h
                                    } else c++;
                                    q++
                                }
                            });
                            if (c !== 0) {
                                b.p.tblwidth = g;
                                o = e - h * c - n;
                                if (!isNaN(b.p.height)) if (a(b.grid.bDiv)[0].clientHeight < a(b.grid.bDiv)[0].scrollHeight || b.rows.length === 1) {
                                    k = true;
                                    o -= l
                                }
                                g = 0;
                                var m = b.grid.cols.length > 0;
                                a.each(b.p.colModel,
                                function(p) {
                                    if (this.hidden === false && !this.fixed) {
                                        f = Math.round(o * this.width / (b.p.tblwidth - r));
                                        if (! (f < 0)) {
                                            this.width = f;
                                            g += f;
                                            b.grid.headers[p].width = f;
                                            b.grid.headers[p].el.style.width = f + "px";
                                            if (b.p.footerrow) b.grid.footers[p].style.width = f + "px";
                                            if (m) b.grid.cols[p].style.width = f + "px";
                                            j = p
                                        }
                                    }
                                });
                                t = 0;
                                if (k) {
                                    if (e - n - (g + h * c) !== l) t = e - n - (g + h * c) - l
                                } else if (Math.abs(e - n - (g + h * c)) !== 1) t = e - n - (g + h * c);
                                b.p.colModel[j].width += t;
                                b.p.tblwidth = g + t + r + h * q;
                                if (b.p.tblwidth > e) {
                                    k = b.p.tblwidth - parseInt(e, 10);
                                    b.p.tblwidth = e;
                                    f = b.p.colModel[j].width -= k
                                } else f = b.p.colModel[j].width;
                                b.grid.headers[j].width = f;
                                b.grid.headers[j].el.style.width = f + "px";
                                if (m) b.grid.cols[j].style.width = f + "px";
                                a("table:first", b.grid.bDiv).css("width", b.p.tblwidth + "px");
                                a("table:first", b.grid.hDiv).css("width", b.p.tblwidth + "px");
                                b.grid.hDiv.scrollLeft = b.grid.bDiv.scrollLeft;
                                if (b.p.footerrow) {
                                    b.grid.footers[j].style.width = f + "px";
                                    a("table:first", b.grid.sDiv).css("width", b.p.tblwidth + "px")
                                }
                            }
                        }
                    }
                }
            })
        },
        setGridHeight: function(e) {
            return this.each(function() {
                var d = this;
                if (d.grid) {
                    a(d.grid.bDiv).css({
                        height: e + (isNaN(e) ? "": "px")
                    });
                    d.p.height = e;
                    d.p.scroll && d.grid.populateVisible()
                }
            })
        },
        setCaption: function(e) {
            return this.each(function() {
                this.p.caption = e;
                a("span.ui-jqgrid-title", this.grid.cDiv).html(e);
                a(this.grid.cDiv).show()
            })
        },
        setLabel: function(e, d, b, f) {
            return this.each(function() {
                var g = this,
                h = -1;
                if (g.grid) {
                    if (isNaN(e)) a(g.p.colModel).each(function(k) {
                        if (this.name == e) {
                            h = k;
                            return false
                        }
                    });
                    else h = parseInt(e, 10);
                    if (h >= 0) {
                        var j = a("tr.ui-jqgrid-labels th:eq(" + h + ")", g.grid.hDiv);
                        if (d) {
                            var c = a(".s-ico", j);
                            a("[id^=jqgh_]", j).empty().html(d).append(c);
                            g.p.colNames[h] = d
                        }
                        if (b) typeof b === "string" ? a(j).addClass(b) : a(j).css(b);
                        typeof f === "object" && a(j).attr(f)
                    }
                }
            })
        },
        setCell: function(e, d, b, f, g, h) {
            return this.each(function() {
                var j = this,
                c = -1,
                k, l;
                if (j.grid) {
                    if (isNaN(d)) a(j.p.colModel).each(function(n) {
                        if (this.name == d) {
                            c = n;
                            return false
                        }
                    });
                    else c = parseInt(d, 10);
                    if (c >= 0) if (k = j.rows.namedItem(e)) {
                        var o = a("td:eq(" + c + ")", k);
                        if (b !== "" || h === true) {
                            k = j.formatter(e, b, c, k, "edit");
                            l = j.p.colModel[c].title ? {
                                title: a.jgrid.stripHtml(k)
                            }: {};
                            j.p.treeGrid && a(".tree-wrap", a(o)).length > 0 ? a("span", a(o)).html(k).attr(l) : a(o).html(k).attr(l);
                            if (j.p.datatype == "local") {
                                k = j.p.colModel[c];
                                b = k.formatter && typeof k.formatter === "string" && k.formatter == "date" ? a.unformat.date(b, k) : b;
                                if (l = j.p._index[e]) j.p.data[l][k.name] = b
                            }
                        }
                        if (typeof f === "string") a(o).addClass(f);
                        else f && a(o).css(f);
                        typeof g === "object" && a(o).attr(g)
                    }
                }
            })
        },
        getCell: function(e, d) {
            var b = false;
            this.each(function() {
                var f = this,
                g = -1;
                if (f.grid) {
                    if (isNaN(d)) a(f.p.colModel).each(function(c) {
                        if (this.name === d) {
                            g = c;
                            return false
                        }
                    });
                    else g = parseInt(d, 10);
                    if (g >= 0) {
                        var h = f.rows.namedItem(e);
                        if (h) try {
                            b = a.unformat(a("td:eq(" + g + ")", h), {
                                rowId: h.id,
                                colModel: f.p.colModel[g]
                            },
                            g)
                        } catch(j) {
                            b = a.jgrid.htmlDecode(a("td:eq(" + g + ")", h).html())
                        }
                    }
                }
            });
            return b
        },
        getCol: function(e, d, b) {
            var f = [],
            g,
            h = 0;
            d = typeof d != "boolean" ? false: d;
            if (typeof b == "undefined") b = false;
            this.each(function() {
                var j = this,
                c = -1;
                if (j.grid) {
                    if (isNaN(e)) a(j.p.colModel).each(function(n) {
                        if (this.name === e) {
                            c = n;
                            return false
                        }
                    });
                    else c = parseInt(e, 10);
                    if (c >= 0) {
                        var k = j.rows.length,
                        l = 0;
                        if (k && k > 0) {
                            for (; l < k;) {
                                if (a(j.rows[l]).hasClass("jqgrow")) {
                                    try {
                                        g = a.unformat(a(j.rows[l].cells[c]), {
                                            rowId: j.rows[l].id,
                                            colModel: j.p.colModel[c]
                                        },
                                        c)
                                    } catch(o) {
                                        g = a.jgrid.htmlDecode(j.rows[l].cells[c].innerHTML)
                                    }
                                    if (b) h += parseFloat(g);
                                    else if (d) f.push({
                                        id: j.rows[l].id,
                                        value: g
                                    });
                                    else f[l] = g
                                }
                                l++
                            }
                            if (b) switch (b.toLowerCase()) {
                            case "sum":
                                f = h;
                                break;
                            case "avg":
                                f = h / k;
                                break;
                            case "count":
                                f = k;
                                break
                            }
                        }
                    }
                }
            });
            return f
        },
        clearGridData: function(e) {
            return this.each(function() {
                var d = this;
                if (d.grid) {
                    if (typeof e != "boolean") e = false;
                    if (d.p.deepempty) a("#" + d.p.id + " tbody:first tr:gt(0)").remove();
                    else {
                        var b = a("#" + d.p.id + " tbody:first tr:first")[0];
                        a("#" + d.p.id + " tbody:first").empty().append(b)
                    }
                    d.p.footerrow && e && a(".ui-jqgrid-ftable td", d.grid.sDiv).html("&#160;");
                    d.p.selrow = null;
                    d.p.selarrrow = [];
                    d.p.savedRow = [];
                    d.p.records = 0;
                    d.p.page = "0";
                    d.p.lastpage = "0";
                    d.p.reccount = 0;
                    d.p.data = [];
                    d.p_index = {};
                    d.updatepager(true, false)
                }
            })
        },
        getInd: function(e, d) {
            var b = false,
            f;
            this.each(function() {
                if (f = this.rows.namedItem(e)) b = d === true ? f: f.rowIndex
            });
            return b
        }
    })
})(jQuery); (function(a) {
    a.jgrid.extend({
        editCell: function(e, d, b) {
            return this.each(function() {
                var f = this,
                g, h, j;
                if (! (!f.grid || f.p.cellEdit !== true)) {
                    d = parseInt(d, 10);
                    f.p.selrow = f.rows[e].id;
                    f.p.knv || a(f).jqGrid("GridNav");
                    if (f.p.savedRow.length > 0) {
                        if (b === true) if (e == f.p.iRow && d == f.p.iCol) return;
                        a(f).jqGrid("saveCell", f.p.savedRow[0].id, f.p.savedRow[0].ic)
                    } else window.setTimeout(function() {
                        a("#" + f.p.knv).attr("tabindex", "-1").focus()
                    },
                    0);
                    g = f.p.colModel[d].name;
                    if (! (g == "subgrid" || g == "cb" || g == "rn")) {
                        j = a("td:eq(" + d + ")", f.rows[e]);
                        if (f.p.colModel[d].editable === true && b === true && !j.hasClass("not-editable-cell")) {
                            if (parseInt(f.p.iCol, 10) >= 0 && parseInt(f.p.iRow, 10) >= 0) {
                                a("td:eq(" + f.p.iCol + ")", f.rows[f.p.iRow]).removeClass("edit-cell ui-state-highlight");
                                a(f.rows[f.p.iRow]).removeClass("selected-row ui-state-hover")
                            }
                            a(j).addClass("edit-cell ui-state-highlight");
                            a(f.rows[e]).addClass("selected-row ui-state-hover");
                            try {
                                h = a.unformat(j, {
                                    rowId: f.rows[e].id,
                                    colModel: f.p.colModel[d]
                                },
                                d)
                            } catch(c) {
                                h = a(j).html()
                            }
                            if (f.p.autoencode) h = a.jgrid.htmlDecode(h);
                            if (!f.p.colModel[d].edittype) f.p.colModel[d].edittype = "text";
                            f.p.savedRow.push({
                                id: e,
                                ic: d,
                                name: g,
                                v: h
                            });
                            if (a.isFunction(f.p.formatCell)) {
                                var k = f.p.formatCell.call(f, f.rows[e].id, g, h, e, d);
                                if (k !== undefined) h = k
                            }
                            k = a.extend({},
                            f.p.colModel[d].editoptions || {},
                            {
                                id: e + "_" + g,
                                name: g
                            });
                            var l = createEl(f.p.colModel[d].edittype, k, h, true, a.extend({},
                            a.jgrid.ajaxOptions, f.p.ajaxSelectOptions || {}));
                            a.isFunction(f.p.beforeEditCell) && f.p.beforeEditCell.call(f, f.rows[e].id, g, h, e, d);
                            a(j).html("").append(l).attr("tabindex", "0");
                            window.setTimeout(function() {
                                a(l).focus()
                            },
                            0);
                            a("input, select, textarea", j).bind("keydown",
                            function(o) {
                                if (o.keyCode === 27) if (a("input.hasDatepicker", j).length > 0) a(".ui-datepicker").is(":hidden") ? a(f).jqGrid("restoreCell", e, d) : a("input.hasDatepicker", j).datepicker("hide");
                                else a(f).jqGrid("restoreCell", e, d);
                                o.keyCode === 13 && a(f).jqGrid("saveCell", e, d);
                                if (o.keyCode == 9) if (f.grid.hDiv.loading) return false;
                                else o.shiftKey ? a(f).jqGrid("prevCell", e, d) : a(f).jqGrid("nextCell", e, d);
                                o.stopPropagation()
                            });
                            a.isFunction(f.p.afterEditCell) && f.p.afterEditCell.call(f, f.rows[e].id, g, h, e, d)
                        } else {
                            if (parseInt(f.p.iCol, 10) >= 0 && parseInt(f.p.iRow, 10) >= 0) {
                                a("td:eq(" + f.p.iCol + ")", f.rows[f.p.iRow]).removeClass("edit-cell ui-state-highlight");
                                a(f.rows[f.p.iRow]).removeClass("selected-row ui-state-hover")
                            }
                            j.addClass("edit-cell ui-state-highlight");
                            a(f.rows[e]).addClass("selected-row ui-state-hover");
                            if (a.isFunction(f.p.onSelectCell)) {
                                h = j.html().replace(/\&#160\;/ig, "");
                                f.p.onSelectCell.call(f, f.rows[e].id, g, h, e, d)
                            }
                        }
                        f.p.iCol = d;
                        f.p.iRow = e
                    }
                }
            })
        },
        saveCell: function(e, d) {
            return this.each(function() {
                var b = this,
                f;
                if (! (!b.grid || b.p.cellEdit !== true)) {
                    f = b.p.savedRow.length >= 1 ? 0 : null;
                    if (f !== null) {
                        var g = a("td:eq(" + d + ")", b.rows[e]),
                        h,
                        j,
                        c = b.p.colModel[d],
                        k = c.name,
                        l = a.jgrid.jqID(k);
                        switch (c.edittype) {
                        case "select":
                            if (c.editoptions.multiple) {
                                l = a("#" + e + "_" + l, b.rows[e]);
                                var o = [];
                                if (h = a(l).val()) h.join(",");
                                else h = "";
                                a("option:selected", l).each(function(v, y) {
                                    o[v] = a(y).text()
                                });
                                j = o.join(",")
                            } else {
                                h = a("#" + e + "_" + l + ">option:selected", b.rows[e]).val();
                                j = a("#" + e + "_" + l + ">option:selected", b.rows[e]).text()
                            }
                            if (c.formatter) j = h;
                            break;
                        case "checkbox":
                            var n = ["Yes", "No"];
                            if (c.editoptions) n = c.editoptions.value.split(":");
                            j = h = a("#" + e + "_" + l, b.rows[e]).attr("checked") ? n[0] : n[1];
                            break;
                        case "password":
                        case "text":
                        case "textarea":
                        case "button":
                            j = h = a("#" + e + "_" + l, b.rows[e]).val();
                            break;
                        case "custom":
                            try {
                                if (c.editoptions && a.isFunction(c.editoptions.custom_value)) {
                                    h = c.editoptions.custom_value.call(b, a(".customelement", g), "get");
                                    if (h === undefined) throw "e2";
                                    else j = h
                                } else throw "e1";
                            } catch(r) {
                                r == "e1" && info_dialog(jQuery.jgrid.errors.errcap, "function 'custom_value' " + a.jgrid.edit.msg.nodefined, jQuery.jgrid.edit.bClose);
                                r == "e2" ? info_dialog(jQuery.jgrid.errors.errcap, "function 'custom_value' " + a.jgrid.edit.msg.novalue, jQuery.jgrid.edit.bClose) : info_dialog(jQuery.jgrid.errors.errcap, r.message, jQuery.jgrid.edit.bClose)
                            }
                            break
                        }
                        if (j != b.p.savedRow[f].v) {
                            if (a.isFunction(b.p.beforeSaveCell)) if (f = b.p.beforeSaveCell.call(b, b.rows[e].id, k, h, e, d)) h = f;
                            var q = checkValues(h, d, b);
                            if (q[0] === true) {
                                f = {};
                                if (a.isFunction(b.p.beforeSubmitCell))(f = b.p.beforeSubmitCell.call(b, b.rows[e].id, k, h, e, d)) || (f = {});
                                a("input.hasDatepicker", g).length > 0 && a("input.hasDatepicker", g).datepicker("hide");
                                if (b.p.cellsubmit == "remote") if (b.p.cellurl) {
                                    var t = {};
                                    if (b.p.autoencode) h = a.jgrid.htmlEncode(h);
                                    t[k] = h;
                                    n = b.p.prmNames;
                                    c = n.id;
                                    l = n.oper;
                                    t[c] = b.rows[e].id;
                                    t[l] = n.editoper;
                                    t = a.extend(f, t);
                                    a("#lui_" + b.p.id).show();
                                    b.grid.hDiv.loading = true;
                                    a.ajax(a.extend({
                                        url: b.p.cellurl,
                                        data: a.isFunction(b.p.serializeCellData) ? b.p.serializeCellData.call(b, t) : t,
                                        type: "POST",
                                        complete: function(v, y) {
                                            a("#lui_" + b.p.id).hide();
                                            b.grid.hDiv.loading = false;
                                            if (y == "success") if (a.isFunction(b.p.afterSubmitCell)) {
                                                v = b.p.afterSubmitCell.call(b, v, t.id, k, h, e, d);
                                                if (v[0] === true) {
                                                    a(g).empty();
                                                    a(b).jqGrid("setCell", b.rows[e].id, d, j, false, false, true);
                                                    a(g).addClass("dirty-cell");
                                                    a(b.rows[e]).addClass("edited");
                                                    a.isFunction(b.p.afterSaveCell) && b.p.afterSaveCell.call(b, b.rows[e].id, k, h, e, d);
                                                    b.p.savedRow.splice(0, 1)
                                                } else {
                                                    info_dialog(a.jgrid.errors.errcap, v[1], a.jgrid.edit.bClose);
                                                    a(b).jqGrid("restoreCell", e, d)
                                                }
                                            } else {
                                                a(g).empty();
                                                a(b).jqGrid("setCell", b.rows[e].id, d, j, false, false, true);
                                                a(g).addClass("dirty-cell");
                                                a(b.rows[e]).addClass("edited");
                                                a.isFunction(b.p.afterSaveCell) && b.p.afterSaveCell.call(b, b.rows[e].id, k, h, e, d);
                                                b.p.savedRow.splice(0, 1)
                                            }
                                        },
                                        error: function(v, y) {
                                            a("#lui_" + b.p.id).hide();
                                            b.grid.hDiv.loading = false;
                                            a.isFunction(b.p.errorCell) ? b.p.errorCell.call(b, v, y) : info_dialog(a.jgrid.errors.errcap, v.status + " : " + v.statusText + "<br/>" + y, a.jgrid.edit.bClose);
                                            a(b).jqGrid("restoreCell", e, d)
                                        }
                                    },
                                    a.jgrid.ajaxOptions, b.p.ajaxCellOptions || {}))
                                } else try {
                                    info_dialog(a.jgrid.errors.errcap, a.jgrid.errors.nourl, a.jgrid.edit.bClose);
                                    a(b).jqGrid("restoreCell", e, d)
                                } catch(m) {}
                                if (b.p.cellsubmit == "clientArray") {
                                    a(g).empty();
                                    a(b).jqGrid("setCell", b.rows[e].id, d, j, false, false, true);
                                    a(g).addClass("dirty-cell");
                                    a(b.rows[e]).addClass("edited");
                                    a.isFunction(b.p.afterSaveCell) && b.p.afterSaveCell.call(b, b.rows[e].id, k, h, e, d);
                                    b.p.savedRow.splice(0, 1)
                                }
                            } else try {
                                window.setTimeout(function() {
                                    info_dialog(a.jgrid.errors.errcap, h + " " + q[1], a.jgrid.edit.bClose)
                                },
                                100);
                                a(b).jqGrid("restoreCell", e, d)
                            } catch(p) {}
                        } else a(b).jqGrid("restoreCell", e, d)
                    }
                    a.browser.opera ? a("#" + b.p.knv).attr("tabindex", "-1").focus() : window.setTimeout(function() {
                        a("#" + b.p.knv).attr("tabindex", "-1").focus()
                    },
                    0)
                }
            })
        },
        restoreCell: function(e, d) {
            return this.each(function() {
                var b = this,
                f;
                if (! (!b.grid || b.p.cellEdit !== true)) {
                    f = b.p.savedRow.length >= 1 ? 0 : null;
                    if (f !== null) {
                        var g = a("td:eq(" + d + ")", b.rows[e]);
                        if (a.isFunction(a.fn.datepicker)) try {
                            a("input.hasDatepicker", g).datepicker("hide")
                        } catch(h) {}
                        a(g).empty().attr("tabindex", "-1");
                        a(b).jqGrid("setCell", b.rows[e].id, d, b.p.savedRow[f].v, false, false, true);
                        a.isFunction(b.p.afterRestoreCell) && b.p.afterRestoreCell.call(b, b.rows[e].id, b.p.savedRow[f].v, e, d);
                        b.p.savedRow.splice(0, 1)
                    }
                    window.setTimeout(function() {
                        a("#" + b.p.knv).attr("tabindex", "-1").focus()
                    },
                    0)
                }
            })
        },
        nextCell: function(e, d) {
            return this.each(function() {
                var b = this,
                f = false;
                if (! (!b.grid || b.p.cellEdit !== true)) {
                    for (var g = d + 1; g < b.p.colModel.length; g++) if (b.p.colModel[g].editable === true) {
                        f = g;
                        break
                    }
                    if (f !== false) a(b).jqGrid("editCell", e, f, true);
                    else b.p.savedRow.length > 0 && a(b).jqGrid("saveCell", e, d)
                }
            })
        },
        prevCell: function(e, d) {
            return this.each(function() {
                var b = this,
                f = false;
                if (! (!b.grid || b.p.cellEdit !== true)) {
                    for (var g = d - 1; g >= 0; g--) if (b.p.colModel[g].editable === true) {
                        f = g;
                        break
                    }
                    if (f !== false) a(b).jqGrid("editCell", e, f, true);
                    else b.p.savedRow.length > 0 && a(b).jqGrid("saveCell", e, d)
                }
            })
        },
        GridNav: function() {
            return this.each(function() {
                function e(j, c, k) {
                    if (k.substr(0, 1) == "v") {
                        var l = a(b.grid.bDiv)[0].clientHeight,
                        o = a(b.grid.bDiv)[0].scrollTop,
                        n = b.rows[j].offsetTop + b.rows[j].clientHeight,
                        r = b.rows[j].offsetTop;
                        if (k == "vd") if (n >= l) a(b.grid.bDiv)[0].scrollTop = a(b.grid.bDiv)[0].scrollTop + b.rows[j].clientHeight;
                        if (k == "vu") if (r < o) a(b.grid.bDiv)[0].scrollTop = a(b.grid.bDiv)[0].scrollTop - b.rows[j].clientHeight
                    }
                    if (k == "h") {
                        k = a(b.grid.bDiv)[0].clientWidth;
                        l = a(b.grid.bDiv)[0].scrollLeft;
                        o = b.rows[j].cells[c].offsetLeft;
                        if (b.rows[j].cells[c].offsetLeft + b.rows[j].cells[c].clientWidth >= k + parseInt(l, 10)) a(b.grid.bDiv)[0].scrollLeft = a(b.grid.bDiv)[0].scrollLeft + b.rows[j].cells[c].clientWidth;
                        else if (o < l) a(b.grid.bDiv)[0].scrollLeft = a(b.grid.bDiv)[0].scrollLeft - b.rows[j].cells[c].clientWidth
                    }
                }
                function d(j, c) {
                    var k, l;
                    if (c == "lft") {
                        k = j + 1;
                        for (l = j; l >= 0; l--) if (b.p.colModel[l].hidden !== true) {
                            k = l;
                            break
                        }
                    }
                    if (c == "rgt") {
                        k = j - 1;
                        for (l = j; l < b.p.colModel.length; l++) if (b.p.colModel[l].hidden !== true) {
                            k = l;
                            break
                        }
                    }
                    return k
                }
                var b = this;
                if (! (!b.grid || b.p.cellEdit !== true)) {
                    b.p.knv = b.p.id + "_kn";
                    var f = a("<span style='width:0px;height:0px;background-color:black;' tabindex='0'><span tabindex='-1' style='width:0px;height:0px;background-color:grey' id='" + b.p.knv + "'></span></span>"),
                    g,
                    h;
                    a(f).insertBefore(b.grid.cDiv);
                    a("#" + b.p.knv).focus().keydown(function(j) {
                        h = j.keyCode;
                        if (b.p.direction == "rtl") if (h == 37) h = 39;
                        else if (h == 39) h = 37;
                        switch (h) {
                        case 38:
                            if (b.p.iRow - 1 > 0) {
                                e(b.p.iRow - 1, b.p.iCol, "vu");
                                a(b).jqGrid("editCell", b.p.iRow - 1, b.p.iCol, false)
                            }
                            break;
                        case 40:
                            if (b.p.iRow + 1 <= b.rows.length - 1) {
                                e(b.p.iRow + 1, b.p.iCol, "vd");
                                a(b).jqGrid("editCell", b.p.iRow + 1, b.p.iCol, false)
                            }
                            break;
                        case 37:
                            if (b.p.iCol - 1 >= 0) {
                                g = d(b.p.iCol - 1, "lft");
                                e(b.p.iRow, g, "h");
                                a(b).jqGrid("editCell", b.p.iRow, g, false)
                            }
                            break;
                        case 39:
                            if (b.p.iCol + 1 <= b.p.colModel.length - 1) {
                                g = d(b.p.iCol + 1, "rgt");
                                e(b.p.iRow, g, "h");
                                a(b).jqGrid("editCell", b.p.iRow, g, false)
                            }
                            break;
                        case 13:
                            parseInt(b.p.iCol, 10) >= 0 && parseInt(b.p.iRow, 10) >= 0 && a(b).jqGrid("editCell", b.p.iRow, b.p.iCol, true);
                            break
                        }
                        return false
                    })
                }
            })
        },
        getChangedCells: function(e) {
            var d = [];
            e || (e = "all");
            this.each(function() {
                var b = this,
                f; ! b.grid || b.p.cellEdit !== true || a(b.rows).each(function(g) {
                    var h = {};
                    if (a(this).hasClass("edited")) {
                        a("td", this).each(function(j) {
                            f = b.p.colModel[j].name;
                            if (f !== "cb" && f !== "subgrid") if (e == "dirty") {
                                if (a(this).hasClass("dirty-cell")) try {
                                    h[f] = a.unformat(this, {
                                        rowId: b.rows[g].id,
                                        colModel: b.p.colModel[j]
                                    },
                                    j)
                                } catch(c) {
                                    h[f] = a.jgrid.htmlDecode(a(this).html())
                                }
                            } else try {
                                h[f] = a.unformat(this, {
                                    rowId: b.rows[g].id,
                                    colModel: b.p.colModel[j]
                                },
                                j)
                            } catch(k) {
                                h[f] = a.jgrid.htmlDecode(a(this).html())
                            }
                        });
                        h.id = this.id;
                        d.push(h)
                    }
                })
            });
            return d
        }
    })
})(jQuery);
var showModal = function(a) {
    a.w.show()
},
closeModal = function(a) {
    a.w.hide().attr("aria-hidden", "true");
    a.o && a.o.remove()
},
hideModal = function(a, e) {
    e = jQuery.extend({
        jqm: true,
        gb: ""
    },
    e || {});
    if (e.onClose) {
        var d = e.onClose(a);
        if (typeof d == "boolean" && !d) return
    }
    if (jQuery.fn.jqm && e.jqm === true) jQuery(a).attr("aria-hidden", "true").jqmHide();
    else {
        if (e.gb != "") try {
            jQuery(".jqgrid-overlay:first", e.gb).hide()
        } catch(b) {}
        jQuery(a).hide().attr("aria-hidden", "true")
    }
};
function findPos(a) {
    var e = 0,
    d = 0;
    if (a.offsetParent) {
        do {
            e += a.offsetLeft;
            d += a.offsetTop
        } while ( a = a . offsetParent )
    }
    return [e, d]
}
var createModal = function(a, e, d, b, f, g) {
    var h = document.createElement("div"),
    j;
    j = jQuery(d.gbox).attr("dir") == "rtl" ? true: false;
    h.className = "ui-widget ui-widget-content ui-corner-all ui-jqdialog";
    h.id = a.themodal;
    var c = document.createElement("div");
    c.className = "ui-jqdialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix";
    c.id = a.modalhead;
    jQuery(c).append("<span class='ui-jqdialog-title'>" + d.caption + "</span>");
    var k = jQuery("<a href='javascript:void(0)' class='ui-jqdialog-titlebar-close ui-corner-all'></a>").hover(function() {
        k.addClass("ui-state-hover")
    },
    function() {
        k.removeClass("ui-state-hover")
    }).append("<span class='ui-icon ui-icon-closethick'></span>");
    jQuery(c).append(k);
    if (j) {
        h.dir = "rtl";
        jQuery(".ui-jqdialog-title", c).css("float", "right");
        jQuery(".ui-jqdialog-titlebar-close", c).css("left", "0.3em")
    } else {
        h.dir = "ltr";
        jQuery(".ui-jqdialog-title", c).css("float", "left");
        jQuery(".ui-jqdialog-titlebar-close", c).css("right", "0.3em")
    }
    var l = document.createElement("div");
    jQuery(l).addClass("ui-jqdialog-content ui-widget-content").attr("id", a.modalcontent);
    jQuery(l).append(e);
    h.appendChild(l);
    jQuery(h).prepend(c);
    g === true ? jQuery("body").append(h) : jQuery(h).insertBefore(b);
    if (typeof d.jqModal === "undefined") d.jqModal = true;
    e = {};
    if (jQuery.fn.jqm && d.jqModal === true) {
        if (d.left === 0 && d.top === 0) {
            b = [];
            b = findPos(f);
            d.left = b[0] + 4;
            d.top = b[1] + 4
        }
        e.top = d.top + "px";
        e.left = d.left
    } else if (d.left !== 0 || d.top !== 0) {
        e.left = d.left;
        e.top = d.top + "px"
    }
    jQuery("a.ui-jqdialog-titlebar-close", c).click(function() {
        var r = jQuery("#" + a.themodal).data("onClose") || d.onClose,
        q = jQuery("#" + a.themodal).data("gbox") || d.gbox;
        hideModal("#" + a.themodal, {
            gb: q,
            jqm: d.jqModal,
            onClose: r
        });
        return false
    });
    if (d.width === 0 || !d.width) d.width = 300;
    if (d.height === 0 || !d.height) d.height = 200;
    if (!d.zIndex) d.zIndex = 950;
    f = 0;
    if (j && e.left && !g) {
        f = jQuery(d.gbox).width() - (!isNaN(d.width) ? parseInt(d.width, 10) : 0) - 8;
        e.left = parseInt(e.left, 10) + parseInt(f, 10)
    }
    if (e.left) e.left += "px";
    jQuery(h).css(jQuery.extend({
        width: isNaN(d.width) ? "auto": d.width + "px",
        height: isNaN(d.height) ? "auto": d.height + "px",
        zIndex: d.zIndex,
        overflow: "hidden"
    },
    e)).attr({
        tabIndex: "-1",
        role: "dialog",
        "aria-labelledby": a.modalhead,
        "aria-hidden": "true"
    });
    if (typeof d.drag == "undefined") d.drag = true;
    if (typeof d.resize == "undefined") d.resize = true;
    if (d.drag) {
        jQuery(c).css("cursor", "move");
        if (jQuery.fn.jqDrag) jQuery(h).jqDrag(c);
        else try {
            jQuery(h).draggable({
                handle: jQuery("#" + c.id)
            })
        } catch(o) {}
    }
    if (d.resize) if (jQuery.fn.jqResize) {
        jQuery(h).append("<div class='jqResize ui-resizable-handle ui-resizable-se ui-icon ui-icon-gripsmall-diagonal-se ui-icon-grip-diagonal-se'></div>");
        jQuery("#" + a.themodal).jqResize(".jqResize", a.scrollelm ? "#" + a.scrollelm: false)
    } else try {
        jQuery(h).resizable({
            handles: "se, sw",
            alsoResize: a.scrollelm ? "#" + a.scrollelm: false
        })
    } catch(n) {}
    d.closeOnEscape === true && jQuery(h).keydown(function(r) {
        if (r.which == 27) {
            r = jQuery("#" + a.themodal).data("onClose") || d.onClose;
            hideModal(this, {
                gb: d.gbox,
                jqm: d.jqModal,
                onClose: r
            })
        }
    })
},
viewModal = function(a, e) {
    e = jQuery.extend({
        toTop: true,
        overlay: 10,
        modal: false,
        onShow: showModal,
        onHide: closeModal,
        gbox: "",
        jqm: true,
        jqM: true
    },
    e || {});
    if (jQuery.fn.jqm && e.jqm === true) e.jqM ? jQuery(a).attr("aria-hidden", "false").jqm(e).jqmShow() : jQuery(a).attr("aria-hidden", "false").jqmShow();
    else {
        if (e.gbox != "") {
            jQuery(".jqgrid-overlay:first", e.gbox).show();
            jQuery(a).data("gbox", e.gbox)
        }
        jQuery(a).show().attr("aria-hidden", "false");
        try {
            jQuery(":input:visible", a)[0].focus()
        } catch(d) {}
    }
};
function info_dialog(a, e, d, b) {
    var f = {
        width: 290,
        height: "auto",
        dataheight: "auto",
        drag: true,
        resize: false,
        caption: "<b>" + a + "</b>",
        left: 250,
        top: 170,
        zIndex: 1E3,
        jqModal: true,
        modal: false,
        closeOnEscape: true,
        align: "center",
        buttonalign: "center",
        buttons: []
    };
    jQuery.extend(f, b || {});
    var g = f.jqModal;
    if (jQuery.fn.jqm && !g) g = false;
    a = "";
    if (f.buttons.length > 0) for (b = 0; b < f.buttons.length; b++) {
        if (typeof f.buttons[b].id == "undefined") f.buttons[b].id = "info_button_" + b;
        a += "<a href='javascript:void(0)' id='" + f.buttons[b].id + "' class='fm-button ui-state-default ui-corner-all'>" + f.buttons[b].text + "</a>"
    }
    b = isNaN(f.dataheight) ? f.dataheight: f.dataheight + "px";
    var h = "<div id='info_id'>";
    h += "<div id='infocnt' style='margin:0px;padding-bottom:1em;width:100%;overflow:auto;position:relative;height:" + b + ";" + ("text-align:" + f.align + ";") + "'>" + e + "</div>";
    h += d ? "<div class='ui-widget-content ui-helper-clearfix' style='text-align:" + f.buttonalign + ";padding-bottom:0.8em;padding-top:0.5em;background-image: none;border-width: 1px 0 0 0;'><a href='javascript:void(0)' id='closedialog' class='fm-button ui-state-default ui-corner-all'>" + d + "</a>" + a + "</div>": a != "" ? "<div class='ui-widget-content ui-helper-clearfix' style='text-align:" + f.buttonalign + ";padding-bottom:0.8em;padding-top:0.5em;background-image: none;border-width: 1px 0 0 0;'>" + a + "</div>": "";
    h += "</div>";
    try {
        jQuery("#info_dialog").attr("aria-hidden") == "false" && hideModal("#info_dialog", {
            jqm: g
        });
        jQuery("#info_dialog").remove()
    } catch(j) {}
    createModal({
        themodal: "info_dialog",
        modalhead: "info_head",
        modalcontent: "info_content",
        scrollelm: "infocnt"
    },
    h, f, "", "", true);
    a && jQuery.each(f.buttons,
    function(k) {
        jQuery("#" + this.id, "#info_id").bind("click",
        function() {
            f.buttons[k].onClick.call(jQuery("#info_dialog"));
            return false
        })
    });
    jQuery("#closedialog", "#info_id").click(function() {
        hideModal("#info_dialog", {
            jqm: g
        });
        return false
    });
    jQuery(".fm-button", "#info_dialog").hover(function() {
        jQuery(this).addClass("ui-state-hover")
    },
    function() {
        jQuery(this).removeClass("ui-state-hover")
    });
    jQuery.isFunction(f.beforeOpen) && f.beforeOpen();
    viewModal("#info_dialog", {
        onHide: function(k) {
            k.w.hide().remove();
            k.o && k.o.remove()
        },
        modal: f.modal,
        jqm: g
    });
    jQuery.isFunction(f.afterOpen) && f.afterOpen();
    try {
        $("#info_dialog").focus()
    } catch(c) {}
}
function createEl(a, e, d, b, f) {
    function g(q, t) {
        if (jQuery.isFunction(t.dataInit)) {
            q.id = t.id;
            t.dataInit(q);
            delete t.id;
            delete t.dataInit
        }
        if (t.dataEvents) {
            jQuery.each(t.dataEvents,
            function() {
                this.data !== undefined ? jQuery(q).bind(this.type, this.data, this.fn) : jQuery(q).bind(this.type, this.fn)
            });
            delete t.dataEvents
        }
        return t
    }
    var h = "";
    e.defaultValue && delete e.defaultValue;
    switch (a) {
    case "textarea":
        h = document.createElement("textarea");
        if (b) e.cols || jQuery(h).css({
            width: "98%"
        });
        else if (!e.cols) e.cols = 20;
        if (!e.rows) e.rows = 2;
        if (d == "&nbsp;" || d == "&#160;" || d.length == 1 && d.charCodeAt(0) == 160) d = "";
        h.value = d;
        e = g(h, e);
        jQuery(h).attr(e).attr({
            role: "textbox",
            multiline: "true"
        });
        break;
    case "checkbox":
        h = document.createElement("input");
        h.type = "checkbox";
        if (e.value) {
            var j = e.value.split(":");
            if (d === j[0]) {
                h.checked = true;
                h.defaultChecked = true
            }
            h.value = j[0];
            jQuery(h).attr("offval", j[1]);
            try {
                delete e.value
            } catch(c) {}
        } else {
            j = d.toLowerCase();
            if (j.search(/(false|0|no|off|undefined)/i) < 0 && j !== "") {
                h.checked = true;
                h.defaultChecked = true;
                h.value = d
            } else h.value = "on";
            jQuery(h).attr("offval", "off")
        }
        e = g(h, e);
        jQuery(h).attr(e).attr("role", "checkbox");
        break;
    case "select":
        h = document.createElement("select");
        h.setAttribute("role", "select");
        var k, l = [];
        if (e.multiple === true) {
            k = true;
            h.multiple = "multiple";
            $(h).attr("aria-multiselectable", "true")
        } else k = false;
        if (typeof e.dataUrl != "undefined") jQuery.ajax(jQuery.extend({
            url: e.dataUrl,
            type: "GET",
            dataType: "html",
            success: function(q) {
                try {
                    delete e.dataUrl;
                    delete e.value
                } catch(t) {}
                if (typeof e.buildSelect != "undefined") {
                    q = e.buildSelect(q);
                    q = jQuery(q).html();
                    delete e.buildSelect
                } else q = jQuery(q).html();
                if (q) {
                    jQuery(h).append(q);
                    e = g(h, e);
                    if (typeof e.size === "undefined") e.size = k ? 3 : 1;
                    if (k) {
                        l = d.split(",");
                        l = jQuery.map(l,
                        function(m) {
                            return jQuery.trim(m)
                        })
                    } else l[0] = jQuery.trim(d);
                    jQuery(h).attr(e);
                    setTimeout(function() {
                        jQuery("option", h).each(function(m) {
                            if (m === 0) this.selected = "";
                            $(this).attr("role", "option");
                            if (jQuery.inArray(jQuery.trim(jQuery(this).text()), l) > -1 || jQuery.inArray(jQuery.trim(jQuery(this).val()), l) > -1) {
                                this.selected = "selected";
                                if (!k) return false
                            }
                        })
                    },
                    0)
                }
            }
        },
        f || {}));
        else if (e.value) {
            if (k) {
                l = d.split(",");
                l = jQuery.map(l,
                function(q) {
                    return jQuery.trim(q)
                });
                if (typeof e.size === "undefined") e.size = 3
            } else e.size = 1;
            if (typeof e.value === "function") e.value = e.value();
            if (typeof e.value === "string") {
                b = e.value.split(";");
                for (j = 0; j < b.length; j++) {
                    f = b[j].split(":");
                    if (f.length > 2) f[1] = jQuery.map(f,
                    function(q, t) {
                        if (t > 0) return q
                    }).join(":");
                    a = document.createElement("option");
                    a.setAttribute("role", "option");
                    a.value = f[0];
                    a.innerHTML = f[1];
                    if (!k && (jQuery.trim(f[0]) == jQuery.trim(d) || jQuery.trim(f[1]) == jQuery.trim(d))) a.selected = "selected";
                    if (k && (jQuery.inArray(jQuery.trim(f[1]), l) > -1 || jQuery.inArray(jQuery.trim(f[0]), l) > -1)) a.selected = "selected";
                    h.appendChild(a)
                }
            } else if (typeof e.value === "object") {
                b = e.value;
                for (j in b) if (b.hasOwnProperty(j)) {
                    a = document.createElement("option");
                    a.setAttribute("role", "option");
                    a.value = j;
                    a.innerHTML = b[j];
                    if (!k && (jQuery.trim(j) == jQuery.trim(d) || jQuery.trim(b[j]) == jQuery.trim(d))) a.selected = "selected";
                    if (k && (jQuery.inArray(jQuery.trim(b[j]), l) > -1 || jQuery.inArray(jQuery.trim(j), l) > -1)) a.selected = "selected";
                    h.appendChild(a)
                }
            }
            e = g(h, e);
            try {
                delete e.value
            } catch(o) {}
            jQuery(h).attr(e)
        }
        break;
    case "text":
    case "password":
    case "button":
        j = a == "button" ? "button": "textbox";
        h = document.createElement("input");
        h.type = a;
        h.value = d;
        e = g(h, e);
        if (a != "button") if (b) e.size || jQuery(h).css({
            width: "98%"
        });
        else if (!e.size) e.size = 20;
        jQuery(h).attr(e).attr("role", j);
        break;
    case "image":
    case "file":
        h = document.createElement("input");
        h.type = a;
        e = g(h, e);
        jQuery(h).attr(e);
        break;
    case "custom":
        h = document.createElement("span");
        try {
            if (jQuery.isFunction(e.custom_element)) {
                var n = e.custom_element.call(this, d, e);
                if (n) {
                    n = jQuery(n).addClass("customelement").attr({
                        id: e.id,
                        name: e.name
                    });
                    jQuery(h).empty().append(n)
                } else throw "e2";
            } else throw "e1";
        } catch(r) {
            r == "e1" && info_dialog(jQuery.jgrid.errors.errcap, "function 'custom_element' " + jQuery.jgrid.edit.msg.nodefined, jQuery.jgrid.edit.bClose);
            r == "e2" ? info_dialog(jQuery.jgrid.errors.errcap, "function 'custom_element' " + jQuery.jgrid.edit.msg.novalue, jQuery.jgrid.edit.bClose) : info_dialog(jQuery.jgrid.errors.errcap, typeof r === "string" ? r: r.message, jQuery.jgrid.edit.bClose)
        }
        break
    }
    return h
}
function daysInFebruary(a) {
    return a % 4 === 0 && (a % 100 !== 0 || a % 400 === 0) ? 29 : 28
}
function DaysArray(a) {
    for (var e = 1; e <= a; e++) {
        this[e] = 31;
        if (e == 4 || e == 6 || e == 9 || e == 11) this[e] = 30;
        if (e == 2) this[e] = 29
    }
    return this
}
function checkDate(a, e) {
    var d = {},
    b;
    a = a.toLowerCase();
    b = a.indexOf("/") != -1 ? "/": a.indexOf("-") != -1 ? "-": a.indexOf(".") != -1 ? ".": "/";
    a = a.split(b);
    e = e.split(b);
    if (e.length != 3) return false;
    b = -1;
    for (var f, g = -1,
    h = -1,
    j = 0; j < a.length; j++) {
        f = isNaN(e[j]) ? 0 : parseInt(e[j], 10);
        d[a[j]] = f;
        f = a[j];
        if (f.indexOf("y") != -1) b = j;
        if (f.indexOf("m") != -1) h = j;
        if (f.indexOf("d") != -1) g = j
    }
    f = a[b] == "y" || a[b] == "yyyy" ? 4 : a[b] == "yy" ? 2 : -1;
    j = DaysArray(12);
    var c;
    if (b === -1) return false;
    else {
        c = d[a[b]].toString();
        if (f == 2 && c.length == 1) f = 1;
        if (c.length != f || d[a[b]] === 0 && e[b] != "00") return false
    }
    if (h === -1) return false;
    else {
        c = d[a[h]].toString();
        if (c.length < 1 || d[a[h]] < 1 || d[a[h]] > 12) return false
    }
    if (g === -1) return false;
    else {
        c = d[a[g]].toString();
        if (c.length < 1 || d[a[g]] < 1 || d[a[g]] > 31 || d[a[h]] == 2 && d[a[g]] > daysInFebruary(d[a[b]]) || d[a[g]] > j[d[a[h]]]) return false
    }
    return true
}
function isEmpty(a) {
    return a.match(/^\s+$/) || a == "" ? true: false
}
function checkTime(a) {
    var e = /^(\d{1,2}):(\d{2})([ap]m)?$/;
    if (!isEmpty(a)) if (a = a.match(e)) {
        if (a[3]) {
            if (a[1] < 1 || a[1] > 12) return false
        } else if (a[1] > 23) return false;
        if (a[2] > 59) return false
    } else return false;
    return true
}
function checkValues(a, e, d) {
    var b, f, g;
    if (typeof e == "string") {
        f = 0;
        for (len = d.p.colModel.length; f < len; f++) if (d.p.colModel[f].name == e) {
            b = d.p.colModel[f].editrules;
            e = f;
            try {
                g = d.p.colModel[f].formoptions.label
            } catch(h) {}
            break
        }
    } else if (e >= 0) b = d.p.colModel[e].editrules;
    if (b) {
        g || (g = d.p.colNames[e]);
        if (b.required === true) if (isEmpty(a)) return [false, g + ": " + jQuery.jgrid.edit.msg.required, ""];
        f = b.required === false ? false: true;
        if (b.number === true) if (! (f === false && isEmpty(a))) if (isNaN(a)) return [false, g + ": " + jQuery.jgrid.edit.msg.number, ""];
        if (typeof b.minValue != "undefined" && !isNaN(b.minValue)) if (parseFloat(a) < parseFloat(b.minValue)) return [false, g + ": " + jQuery.jgrid.edit.msg.minValue + " " + b.minValue, ""];
        if (typeof b.maxValue != "undefined" && !isNaN(b.maxValue)) if (parseFloat(a) > parseFloat(b.maxValue)) return [false, g + ": " + jQuery.jgrid.edit.msg.maxValue + " " + b.maxValue, ""];
        var j;
        if (b.email === true) if (! (f === false && isEmpty(a))) {
            j = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i;
            if (!j.test(a)) return [false, g + ": " + jQuery.jgrid.edit.msg.email, ""]
        }
        if (b.integer === true) if (! (f === false && isEmpty(a))) {
            if (isNaN(a)) return [false, g + ": " + jQuery.jgrid.edit.msg.integer, ""];
            if (a % 1 !== 0 || a.indexOf(".") != -1) return [false, g + ": " + jQuery.jgrid.edit.msg.integer, ""]
        }
        if (b.date === true) if (! (f === false && isEmpty(a))) {
            e = d.p.colModel[e].formatoptions && d.p.colModel[e].formatoptions.newformat ? d.p.colModel[e].formatoptions.newformat: d.p.colModel[e].datefmt || "Y-m-d";
            if (!checkDate(e, a)) return [false, g + ": " + jQuery.jgrid.edit.msg.date + " - " + e, ""]
        }
        if (b.time === true) if (! (f === false && isEmpty(a))) if (!checkTime(a)) return [false, g + ": " + jQuery.jgrid.edit.msg.date + " - hh:mm (am/pm)", ""];
        if (b.url === true) if (! (f === false && isEmpty(a))) {
            j = /^(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;
            if (!j.test(a)) return [false, g + ": " + jQuery.jgrid.edit.msg.url, ""]
        }
        if (b.custom === true) if (! (f === false && isEmpty(a))) if (jQuery.isFunction(b.custom_func)) {
            a = b.custom_func.call(d, a, g);
            return jQuery.isArray(a) ? a: [false, jQuery.jgrid.edit.msg.customarray, ""]
        } else return [false, jQuery.jgrid.edit.msg.customfcheck, ""]
    }
    return [true, "", ""]
} (function(a) {
    a.jgrid.extend({
        getColProp: function(e) {
            var d = {},
            b = this[0];
            if (b.grid) {
                b = b.p.colModel;
                for (var f = 0; f < b.length; f++) if (b[f].name == e) {
                    d = b[f];
                    break
                }
                return d
            }
        },
        setColProp: function(e, d) {
            return this.each(function() {
                if (this.grid) if (d) for (var b = this.p.colModel,
                f = 0; f < b.length; f++) if (b[f].name == e) {
                    a.extend(this.p.colModel[f], d);
                    break
                }
            })
        },
        sortGrid: function(e, d, b) {
            return this.each(function() {
                var f = this,
                g = -1;
                if (f.grid) {
                    if (!e) e = f.p.sortname;
                    for (var h = 0; h < f.p.colModel.length; h++) if (f.p.colModel[h].index == e || f.p.colModel[h].name == e) {
                        g = h;
                        break
                    }
                    if (g != -1) {
                        h = f.p.colModel[g].sortable;
                        if (typeof h !== "boolean") h = true;
                        if (typeof d !== "boolean") d = false;
                        h && f.sortData("jqgh_" + e, g, d, b)
                    }
                }
            })
        },
        GridDestroy: function() {
            return this.each(function() {
                if (this.grid) {
                    this.p.pager && a(this.p.pager).remove();
                    var e = this.id;
                    try {
                        a("#gbox_" + e).remove()
                    } catch(d) {}
                }
            })
        },
        GridUnload: function() {
            return this.each(function() {
                if (this.grid) {
                    var e = {
                        id: a(this).attr("id"),
                        cl: a(this).attr("class")
                    };
                    this.p.pager && a(this.p.pager).empty().removeClass("ui-state-default ui-jqgrid-pager corner-bottom");
                    var d = document.createElement("table");
                    a(d).attr({
                        id: e.id
                    });
                    d.className = e.cl;
                    e = this.id;
                    a(d).removeClass("ui-jqgrid-btable");
                    if (a(this.p.pager).parents("#gbox_" + e).length === 1) {
                        a(d).insertBefore("#gbox_" + e).show();
                        a(this.p.pager).insertBefore("#gbox_" + e)
                    } else a(d).insertBefore("#gbox_" + e).show();
                    a("#gbox_" + e).remove()
                }
            })
        },
        setGridState: function(e) {
            return this.each(function() {
                if (this.grid) {
                    var d = this;
                    if (e == "hidden") {
                        a(".ui-jqgrid-bdiv, .ui-jqgrid-hdiv", "#gview_" + d.p.id).slideUp("fast");
                        d.p.pager && a(d.p.pager).slideUp("fast");
                        d.p.toppager && a(d.p.toppager).slideUp("fast");
                        if (d.p.toolbar[0] === true) {
                            d.p.toolbar[1] == "both" && a(d.grid.ubDiv).slideUp("fast");
                            a(d.grid.uDiv).slideUp("fast")
                        }
                        d.p.footerrow && a(".ui-jqgrid-sdiv", "#gbox_" + d.p.id).slideUp("fast");
                        a(".ui-jqgrid-titlebar-close span", d.grid.cDiv).removeClass("ui-icon-circle-triangle-n").addClass("ui-icon-circle-triangle-s");
                        d.p.gridstate = "hidden"
                    } else if (e == "visible") {
                        a(".ui-jqgrid-hdiv, .ui-jqgrid-bdiv", "#gview_" + d.p.id).slideDown("fast");
                        d.p.pager && a(d.p.pager).slideDown("fast");
                        d.p.toppager && a(d.p.toppager).slideDown("fast");
                        if (d.p.toolbar[0] === true) {
                            d.p.toolbar[1] == "both" && a(d.grid.ubDiv).slideDown("fast");
                            a(d.grid.uDiv).slideDown("fast")
                        }
                        d.p.footerrow && a(".ui-jqgrid-sdiv", "#gbox_" + d.p.id).slideDown("fast");
                        a(".ui-jqgrid-titlebar-close span", d.grid.cDiv).removeClass("ui-icon-circle-triangle-s").addClass("ui-icon-circle-triangle-n");
                        d.p.gridstate = "visible"
                    }
                }
            })
        },
        updateGridRows: function(e, d, b) {
            var f, g = false,
            h;
            this.each(function() {
                var j = this,
                c, k, l, o;
                if (!j.grid) return false;
                d || (d = "id");
                e && e.length > 0 && a(e).each(function() {
                    l = this;
                    if (k = j.rows.namedItem(l[d])) {
                        o = l[d];
                        if (b === true) if (j.p.jsonReader.repeatitems === true) {
                            if (j.p.jsonReader.cell) l = l[j.p.jsonReader.cell];
                            for (var n = 0; n < l.length; n++) {
                                c = j.formatter(o, l[n], n, l, "edit");
                                h = j.p.colModel[n].title ? {
                                    title: a.jgrid.stripHtml(c)
                                }: {};
                                j.p.treeGrid === true && f == j.p.ExpandColumn ? a("td:eq(" + n + ") > span:first", k).html(c).attr(h) : a("td:eq(" + n + ")", k).html(c).attr(h)
                            }
                            return g = true
                        }
                        a(j.p.colModel).each(function(r) {
                            f = b === true ? this.jsonmap || this.name: this.name;
                            if (l[f] !== undefined) {
                                c = j.formatter(o, l[f], r, l, "edit");
                                h = this.title ? {
                                    title: a.jgrid.stripHtml(c)
                                }: {};
                                j.p.treeGrid === true && f == j.p.ExpandColumn ? a("td:eq(" + r + ") > span:first", k).html(c).attr(h) : a("td:eq(" + r + ")", k).html(c).attr(h);
                                g = true
                            }
                        })
                    }
                })
            });
            return g
        },
        filterGrid: function(e, d) {
            d = a.extend({
                gridModel: false,
                gridNames: false,
                gridToolbar: false,
                filterModel: [],
                formtype: "horizontal",
                autosearch: true,
                formclass: "filterform",
                tableclass: "filtertable",
                buttonclass: "filterbutton",
                searchButton: "Search",
                clearButton: "Clear",
                enableSearch: false,
                enableClear: false,
                beforeSearch: null,
                afterSearch: null,
                beforeClear: null,
                afterClear: null,
                url: "",
                marksearched: true
            },
            d || {});
            return this.each(function() {
                var b = this;
                this.p = d;
                if (this.p.filterModel.length === 0 && this.p.gridModel === false) alert("No filter is set");
                else if (e) {
                    this.p.gridid = e.indexOf("#") != -1 ? e: "#" + e;
                    var f = a(this.p.gridid).jqGrid("getGridParam", "colModel");
                    if (f) {
                        if (this.p.gridModel === true) {
                            var g = a(this.p.gridid)[0],
                            h;
                            a.each(f,
                            function(o) {
                                var n = [];
                                this.search = this.search === false ? false: true;
                                h = this.editrules && this.editrules.searchhidden === true ? true: this.hidden === true ? false: true;
                                if (this.search === true && h === true) {
                                    n.label = b.p.gridNames === true ? g.p.colNames[o] : "";
                                    n.name = this.name;
                                    n.index = this.index || this.name;
                                    n.stype = this.edittype || "text";
                                    if (n.stype != "select") n.stype = "text";
                                    n.defval = this.defval || "";
                                    n.surl = this.surl || "";
                                    n.sopt = this.editoptions || {};
                                    n.width = this.width;
                                    b.p.filterModel.push(n)
                                }
                            })
                        } else a.each(b.p.filterModel,
                        function() {
                            for (var o = 0; o < f.length; o++) if (this.name == f[o].name) {
                                this.index = f[o].index || this.name;
                                break
                            }
                            if (!this.index) this.index = this.name
                        });
                        var j = function() {
                            var o = {},
                            n = 0,
                            r, q = a(b.p.gridid)[0],
                            t;
                            q.p.searchdata = {};
                            a.isFunction(b.p.beforeSearch) && b.p.beforeSearch();
                            a.each(b.p.filterModel,
                            function() {
                                t = this.index;
                                switch (this.stype) {
                                case "select":
                                    if (r = a("select[name=" + t + "]", b).val()) {
                                        o[t] = r;
                                        b.p.marksearched && a("#jqgh_" + this.name, q.grid.hDiv).addClass("dirty-cell");
                                        n++
                                    } else {
                                        b.p.marksearched && a("#jqgh_" + this.name, q.grid.hDiv).removeClass("dirty-cell");
                                        try {
                                            delete q.p.postData[this.index]
                                        } catch(v) {}
                                    }
                                    break;
                                default:
                                    if (r = a("input[name=" + t + "]", b).val()) {
                                        o[t] = r;
                                        b.p.marksearched && a("#jqgh_" + this.name, q.grid.hDiv).addClass("dirty-cell");
                                        n++
                                    } else {
                                        b.p.marksearched && a("#jqgh_" + this.name, q.grid.hDiv).removeClass("dirty-cell");
                                        try {
                                            delete q.p.postData[this.index]
                                        } catch(y) {}
                                    }
                                }
                            });
                            var m = n > 0 ? true: false;
                            a.extend(q.p.postData, o);
                            var p;
                            if (b.p.url) {
                                p = a(q).jqGrid("getGridParam", "url");
                                a(q).jqGrid("setGridParam", {
                                    url: b.p.url
                                })
                            }
                            a(q).jqGrid("setGridParam", {
                                search: m
                            }).trigger("reloadGrid", [{
                                page: 1
                            }]);
                            p && a(q).jqGrid("setGridParam", {
                                url: p
                            });
                            a.isFunction(b.p.afterSearch) && b.p.afterSearch()
                        },
                        c = function() {
                            var o = {},
                            n, r = 0,
                            q = a(b.p.gridid)[0],
                            t;
                            a.isFunction(b.p.beforeClear) && b.p.beforeClear();
                            a.each(b.p.filterModel,
                            function() {
                                t = this.index;
                                n = this.defval ? this.defval: "";
                                if (!this.stype) this.stype = "text";
                                switch (this.stype) {
                                case "select":
                                    var v;
                                    a("select[name=" + t + "] option", b).each(function(C) {
                                        if (C === 0) this.selected = true;
                                        if (a(this).text() == n) {
                                            this.selected = true;
                                            v = a(this).val();
                                            return false
                                        }
                                    });
                                    if (v) {
                                        o[t] = v;
                                        b.p.marksearched && a("#jqgh_" + this.name, q.grid.hDiv).addClass("dirty-cell");
                                        r++
                                    } else {
                                        b.p.marksearched && a("#jqgh_" + this.name, q.grid.hDiv).removeClass("dirty-cell");
                                        try {
                                            delete q.p.postData[this.index]
                                        } catch(y) {}
                                    }
                                    break;
                                case "text":
                                    a("input[name=" + t + "]", b).val(n);
                                    if (n) {
                                        o[t] = n;
                                        b.p.marksearched && a("#jqgh_" + this.name, q.grid.hDiv).addClass("dirty-cell");
                                        r++
                                    } else {
                                        b.p.marksearched && a("#jqgh_" + this.name, q.grid.hDiv).removeClass("dirty-cell");
                                        try {
                                            delete q.p.postData[this.index]
                                        } catch(B) {}
                                    }
                                    break
                                }
                            });
                            var m = r > 0 ? true: false;
                            a.extend(q.p.postData, o);
                            var p;
                            if (b.p.url) {
                                p = a(q).jqGrid("getGridParam", "url");
                                a(q).jqGrid("setGridParam", {
                                    url: b.p.url
                                })
                            }
                            a(q).jqGrid("setGridParam", {
                                search: m
                            }).trigger("reloadGrid", [{
                                page: 1
                            }]);
                            p && a(q).jqGrid("setGridParam", {
                                url: p
                            });
                            a.isFunction(b.p.afterClear) && b.p.afterClear()
                        },
                        k = a("<form name='SearchForm' style=display:inline;' class='" + this.p.formclass + "'></form>"),
                        l = a("<table class='" + this.p.tableclass + "' cellspacing='0' cellpading='0' border='0'><tbody></tbody></table>");
                        a(k).append(l); (function() {
                            var o = document.createElement("tr"),
                            n,
                            r,
                            q,
                            t;
                            b.p.formtype == "horizontal" && a(l).append(o);
                            a.each(b.p.filterModel,
                            function(m) {
                                q = document.createElement("td");
                                a(q).append("<label for='" + this.name + "'>" + this.label + "</label>");
                                t = document.createElement("td");
                                var p = this;
                                if (!this.stype) this.stype = "text";
                                switch (this.stype) {
                                case "select":
                                    if (this.surl) a(t).load(this.surl,
                                    function() {
                                        p.defval && a("select", this).val(p.defval);
                                        a("select", this).attr({
                                            name: p.index || p.name,
                                            id: "sg_" + p.name
                                        });
                                        p.sopt && a("select", this).attr(p.sopt);
                                        b.p.gridToolbar === true && p.width && a("select", this).width(p.width);
                                        b.p.autosearch === true && a("select", this).change(function() {
                                            j();
                                            return false
                                        })
                                    });
                                    else if (p.sopt.value) {
                                        var v = p.sopt.value,
                                        y = document.createElement("select");
                                        a(y).attr({
                                            name: p.index || p.name,
                                            id: "sg_" + p.name
                                        }).attr(p.sopt);
                                        var B;
                                        if (typeof v === "string") {
                                            m = v.split(";");
                                            for (var C = 0; C < m.length; C++) {
                                                v = m[C].split(":");
                                                B = document.createElement("option");
                                                B.value = v[0];
                                                B.innerHTML = v[1];
                                                if (v[1] == p.defval) B.selected = "selected";
                                                y.appendChild(B)
                                            }
                                        } else if (typeof v === "object") for (C in v) if (v.hasOwnProperty(C)) {
                                            m++;
                                            B = document.createElement("option");
                                            B.value = C;
                                            B.innerHTML = v[C];
                                            if (v[C] == p.defval) B.selected = "selected";
                                            y.appendChild(B)
                                        }
                                        b.p.gridToolbar === true && p.width && a(y).width(p.width);
                                        a(t).append(y);
                                        b.p.autosearch === true && a(y).change(function() {
                                            j();
                                            return false
                                        })
                                    }
                                    break;
                                case "text":
                                    y = this.defval ? this.defval: "";
                                    a(t).append("<input type='text' name='" + (this.index || this.name) + "' id='sg_" + this.name + "' value='" + y + "'/>");
                                    p.sopt && a("input", t).attr(p.sopt);
                                    if (b.p.gridToolbar === true && p.width) a.browser.msie ? a("input", t).width(p.width - 4) : a("input", t).width(p.width - 2);
                                    b.p.autosearch === true && a("input", t).keypress(function(I) {
                                        if ((I.charCode ? I.charCode: I.keyCode ? I.keyCode: 0) == 13) {
                                            j();
                                            return false
                                        }
                                        return this
                                    });
                                    break
                                }
                                if (b.p.formtype == "horizontal") {
                                    b.p.gridToolbar === true && b.p.gridNames === false ? a(o).append(t) : a(o).append(q).append(t);
                                    a(o).append(t)
                                } else {
                                    n = document.createElement("tr");
                                    a(n).append(q).append(t);
                                    a(l).append(n)
                                }
                            });
                            t = document.createElement("td");
                            if (b.p.enableSearch === true) {
                                r = "<input type='button' id='sButton' class='" + b.p.buttonclass + "' value='" + b.p.searchButton + "'/>";
                                a(t).append(r);
                                a("input#sButton", t).click(function() {
                                    j();
                                    return false
                                })
                            }
                            if (b.p.enableClear === true) {
                                r = "<input type='button' id='cButton' class='" + b.p.buttonclass + "' value='" + b.p.clearButton + "'/>";
                                a(t).append(r);
                                a("input#cButton", t).click(function() {
                                    c();
                                    return false
                                })
                            }
                            if (b.p.enableClear === true || b.p.enableSearch === true) if (b.p.formtype == "horizontal") a(o).append(t);
                            else {
                                n = document.createElement("tr");
                                a(n).append("<td>&#160;</td>").append(t);
                                a(l).append(n)
                            }
                        })();
                        a(this).append(k);
                        this.triggerSearch = j;
                        this.clearSearch = c
                    } else alert("Could not get grid colModel")
                } else alert("No target grid is set!")
            })
        },
        filterToolbar: function(e) {
            e = a.extend({
                autosearch: true,
                searchOnEnter: true,
                beforeSearch: null,
                afterSearch: null,
                beforeClear: null,
                afterClear: null,
                searchurl: "",
                stringResult: false,
                groupOp: "AND",
                defaultSearch: "bw"
            },
            e || {});
            return this.each(function() {
                function d(j, c) {
                    var k = a(j);
                    k[0] && jQuery.each(c,
                    function() {
                        this.data !== undefined ? k.bind(this.type, this.data, this.fn) : k.bind(this.type, this.fn)
                    })
                }
                var b = this,
                f = function() {
                    var j = {},
                    c = 0,
                    k, l, o = {};
                    a.each(b.p.colModel,
                    function() {
                        l = this.index || this.name;
                        var p = this.searchoptions && this.searchoptions.sopt ? this.searchoptions.sopt[0] : e.defaultSearch;
                        switch (this.stype) {
                        case "select":
                            if (k = a("select[name=" + l + "]", b.grid.hDiv).val()) {
                                j[l] = k;
                                o[l] = p;
                                c++
                            } else try {
                                delete b.p.postData[l]
                            } catch(v) {}
                            break;
                        case "text":
                            if (k = a("input[name=" + l + "]", b.grid.hDiv).val()) {
                                j[l] = k;
                                o[l] = p;
                                c++
                            } else try {
                                delete b.p.postData[l]
                            } catch(y) {}
                            break
                        }
                    });
                    var n = c > 0 ? true: false;
                    if (e.stringResult === true || b.p.datatype == "local") {
                        var r = '{"groupOp":"' + e.groupOp + '","rules":[',
                        q = 0;
                        a.each(j,
                        function(p, v) {
                            if (q > 0) r += ",";
                            r += '{"field":"' + p + '",';
                            r += '"op":"' + o[p] + '",';
                            r += '"data":"' + v + '"}';
                            q++
                        });
                        r += "]}";
                        a.extend(b.p.postData, {
                            filters: r
                        })
                    } else a.extend(b.p.postData, j);
                    var t;
                    if (b.p.searchurl) {
                        t = b.p.url;
                        a(b).jqGrid("setGridParam", {
                            url: b.p.searchurl
                        })
                    }
                    var m = false;
                    if (a.isFunction(e.beforeSearch)) m = e.beforeSearch.call(b);
                    m || a(b).jqGrid("setGridParam", {
                        search: n
                    }).trigger("reloadGrid", [{
                        page: 1
                    }]);
                    t && a(b).jqGrid("setGridParam", {
                        url: t
                    });
                    a.isFunction(e.afterSearch) && e.afterSearch()
                },
                g = a("<tr class='ui-search-toolbar' role='rowheader'></tr>"),
                h;
                a.each(b.p.colModel,
                function() {
                    var j = this,
                    c, k, l, o;
                    k = a("<th role='columnheader' class='ui-state-default ui-th-column ui-th-" + b.p.direction + "'></th>");
                    c = a("<div style='width:100%;position:relative;height:100%;padding-right:0.3em;'></div>");
                    this.hidden === true && a(k).css("display", "none");
                    this.search = this.search === false ? false: true;
                    if (typeof this.stype == "undefined") this.stype = "text";
                    l = a.extend({},
                    this.searchoptions || {});
                    if (this.search) switch (this.stype) {
                    case "select":
                        if (o = this.surl || l.dataUrl) a.ajax(a.extend({
                            url: o,
                            dataType: "html",
                            complete: function(m) {
                                if (l.buildSelect !== undefined)(m = l.buildSelect(m)) && a(c).append(m);
                                else a(c).append(m.responseText);
                                l.defaultValue && a("select", c).val(l.defaultValue);
                                a("select", c).attr({
                                    name: j.index || j.name,
                                    id: "gs_" + j.name
                                });
                                l.attr && a("select", c).attr(l.attr);
                                a("select", c).css({
                                    width: "100%"
                                });
                                l.dataInit !== undefined && l.dataInit(a("select", c)[0]);
                                l.dataEvents !== undefined && d(a("select", c)[0], l.dataEvents);
                                e.autosearch === true && a("select", c).change(function() {
                                    f();
                                    return false
                                });
                                m = null
                            }
                        },
                        a.jgrid.ajaxOptions, b.p.ajaxSelectOptions || {}));
                        else {
                            var n;
                            if (j.searchoptions && j.searchoptions.value) n = j.searchoptions.value;
                            else if (j.editoptions && j.editoptions.value) n = j.editoptions.value;
                            if (n) {
                                o = document.createElement("select");
                                o.style.width = "100%";
                                a(o).attr({
                                    name: j.index || j.name,
                                    id: "gs_" + j.name
                                });
                                var r, q;
                                if (typeof n === "string") {
                                    n = n.split(";");
                                    for (var t = 0; t < n.length; t++) {
                                        r = n[t].split(":");
                                        q = document.createElement("option");
                                        q.value = r[0];
                                        q.innerHTML = r[1];
                                        o.appendChild(q)
                                    }
                                } else if (typeof n === "object") for (r in n) if (n.hasOwnProperty(r)) {
                                    q = document.createElement("option");
                                    q.value = r;
                                    q.innerHTML = n[r];
                                    o.appendChild(q)
                                }
                                l.defaultValue && a(o).val(l.defaultValue);
                                l.attr && a(o).attr(l.attr);
                                l.dataInit !== undefined && l.dataInit(o);
                                l.dataEvents !== undefined && d(o, l.dataEvents);
                                a(c).append(o);
                                e.autosearch === true && a(o).change(function() {
                                    f();
                                    return false
                                })
                            }
                        }
                        break;
                    case "text":
                        o = l.defaultValue ? l.defaultValue: "";
                        a(c).append("<input type='text' style='width:95%;padding:0px;' name='" + (j.index || j.name) + "' id='gs_" + j.name + "' value='" + o + "'/>");
                        l.attr && a("input", c).attr(l.attr);
                        l.dataInit !== undefined && l.dataInit(a("input", c)[0]);
                        l.dataEvents !== undefined && d(a("input", c)[0], l.dataEvents);
                        if (e.autosearch === true) e.searchOnEnter ? a("input", c).keypress(function(m) {
                            if ((m.charCode ? m.charCode: m.keyCode ? m.keyCode: 0) == 13) {
                                f();
                                return false
                            }
                            return this
                        }) : a("input", c).keydown(function(m) {
                            switch (m.which) {
                            case 13:
                                return false;
                            case 9:
                            case 16:
                            case 37:
                            case 38:
                            case 39:
                            case 40:
                            case 27:
                                break;
                            default:
                                h && clearTimeout(h);
                                h = setTimeout(function() {
                                    f()
                                },
                                500)
                            }
                        });
                        break
                    }
                    a(k).append(c);
                    a(g).append(k)
                });
                a("table thead", b.grid.hDiv).append(g);
                this.triggerToolbar = f;
                this.clearToolbar = function(j) {
                    var c = {},
                    k, l = 0,
                    o;
                    j = typeof j != "boolean" ? true: j;
                    a.each(b.p.colModel,
                    function() {
                        k = this.searchoptions && this.searchoptions.defaultValue ? this.searchoptions.defaultValue: "";
                        o = this.index || this.name;
                        switch (this.stype) {
                        case "select":
                            var p;
                            a("select[name=" + o + "] option", b.grid.hDiv).each(function(B) {
                                if (B === 0) this.selected = true;
                                if (a(this).text() == k) {
                                    this.selected = true;
                                    p = a(this).val();
                                    return false
                                }
                            });
                            if (p) {
                                c[o] = p;
                                l++
                            } else try {
                                delete b.p.postData[o]
                            } catch(v) {}
                            break;
                        case "text":
                            a("input[name=" + o + "]", b.grid.hDiv).val(k);
                            if (k) {
                                c[o] = k;
                                l++
                            } else try {
                                delete b.p.postData[o]
                            } catch(y) {}
                            break
                        }
                    });
                    var n = l > 0 ? true: false;
                    if (e.stringResult === true || b.p.datatype == "local") {
                        var r = '{"groupOp":"' + e.groupOp + '","rules":[',
                        q = 0;
                        a.each(c,
                        function(p, v) {
                            if (q > 0) r += ",";
                            r += '{"field":"' + p + '",';
                            r += '"op":"eq",';
                            r += '"data":"' + v + '"}';
                            q++
                        });
                        r += "]}";
                        a.extend(b.p.postData, {
                            filters: r
                        })
                    } else a.extend(b.p.postData, c);
                    var t;
                    if (b.p.searchurl) {
                        t = b.p.url;
                        a(b).jqGrid("setGridParam", {
                            url: b.p.searchurl
                        })
                    }
                    var m = false;
                    if (a.isFunction(e.beforeClear)) m = e.beforeClear.call(b);
                    m || j && a(b).jqGrid("setGridParam", {
                        search: n
                    }).trigger("reloadGrid", [{
                        page: 1
                    }]);
                    t && a(b).jqGrid("setGridParam", {
                        url: t
                    });
                    a.isFunction(e.afterClear) && e.afterClear()
                };
                this.toggleToolbar = function() {
                    var j = a("tr.ui-search-toolbar", b.grid.hDiv);
                    j.css("display") == "none" ? j.show() : j.hide()
                }
            })
        }
    })
})(jQuery); (function(a) {
    var e = null;
    a.jgrid.extend({
        searchGrid: function(d) {
            d = a.extend({
                recreateFilter: false,
                drag: true,
                sField: "searchField",
                sValue: "searchString",
                sOper: "searchOper",
                sFilter: "filters",
                loadDefaults: true,
                beforeShowSearch: null,
                afterShowSearch: null,
                onInitializeSearch: null,
                closeAfterSearch: false,
                closeAfterReset: false,
                closeOnEscape: false,
                multipleSearch: false,
                cloneSearchRowOnAdd: true,
                sopt: null,
                stringResult: undefined,
                onClose: null,
                useDataProxy: false,
                overlay: true
            },
            a.jgrid.search, d || {});
            return this.each(function() {
                function b(y, B) {
                    B = y.p.postData[B.sFilter];
                    if (typeof B == "string") B = a.jgrid.parse(B);
                    if (B) {
                        B.groupOp && y.SearchFilter.setGroupOp(B.groupOp);
                        if (B.rules) {
                            var C, I = 0,
                            w = B.rules.length;
                            for (C = false; I < w; I++) {
                                C = B.rules[I];
                                if (C.field !== undefined && C.op !== undefined && C.data !== undefined)(C = y.SearchFilter.setFilter({
                                    sfref: y.SearchFilter.$.find(".sf:last"),
                                    filter: a.extend({},
                                    C)
                                })) && y.SearchFilter.add()
                            }
                        }
                    }
                }
                function f(y) {
                    var B = y !== undefined,
                    C = a("#" + c.p.id),
                    I = {};
                    if (d.multipleSearch === false) {
                        I[d.sField] = y.rules[0].field;
                        I[d.sValue] = y.rules[0].data;
                        I[d.sOper] = y.rules[0].op
                    } else I[d.sFilter] = y;
                    C[0].p.search = B;
                    a.extend(C[0].p.postData, I);
                    C.trigger("reloadGrid", [{
                        page: 1
                    }]);
                    d.closeAfterSearch && h(a("#" + k))
                }
                function g(y) {
                    y = y && y.hasOwnProperty("reload") ? y.reload: true;
                    grid = a("#" + c.p.id);
                    sdata = [];
                    grid[0].p.search = false;
                    if (d.multipleSearch === false) sdata[d.sField] = sdata[d.sValue] = sdata[d.sOper] = "";
                    else sdata[d.sFilter] = "";
                    a.extend(grid[0].p.postData, sdata);
                    y && grid.trigger("reloadGrid", [{
                        page: 1
                    }]);
                    d.closeAfterReset && h(a("#" + k))
                }
                function h(y) {
                    if (d.onClose) {
                        var B = d.onClose(y);
                        if (typeof B == "boolean" && !B) return
                    }
                    y.hide();
                    d.overlay === true && a(".jqgrid-overlay:first", "#gbox_" + c.p.id).hide()
                }
                function j() {
                    var y = a(".ui-searchFilter").length;
                    if (y > 1) {
                        var B = a("#" + k).css("zIndex");
                        a("#" + k).css({
                            zIndex: parseInt(B, 10) + y
                        })
                    }
                    a("#" + k).show();
                    d.overlay === true && a(".jqgrid-overlay:first", "#gbox_" + c.p.id).show();
                    try {
                        a(":input:visible", "#" + k)[0].focus()
                    } catch(C) {}
                }
                var c = this;
                if (c.grid) if (a.fn.searchFilter) {
                    var k = "fbox_" + c.p.id;
                    d.recreateFilter === true && a("#" + k).remove();
                    if (a("#" + k).html() != null) {
                        a.isFunction(d.beforeShowSearch) && d.beforeShowSearch(a("#" + k));
                        j();
                        a.isFunction(d.afterShowSearch) && d.afterShowSearch(a("#" + k))
                    } else {
                        var l = [],
                        o = a("#" + c.p.id).jqGrid("getGridParam", "colNames"),
                        n = a("#" + c.p.id).jqGrid("getGridParam", "colModel"),
                        r = ["eq", "ne", "lt", "le", "gt", "ge", "bw", "bn", "in", "ni", "ew", "en", "cn", "nc"],
                        q,
                        t,
                        m,
                        p = [];
                        if (d.sopt !== null) for (q = m = 0; q < d.sopt.length; q++) {
                            if ((t = a.inArray(d.sopt[q], r)) != -1) {
                                p[m] = {
                                    op: d.sopt[q],
                                    text: d.odata[t]
                                };
                                m++
                            }
                        } else for (q = 0; q < r.length; q++) p[q] = {
                            op: r[q],
                            text: d.odata[q]
                        };
                        a.each(n,
                        function(y, B) {
                            var C = typeof B.search === "undefined" ? true: B.search,
                            I = B.hidden === true;
                            y = a.extend({},
                            {
                                text: o[y],
                                itemval: B.index || B.name
                            },
                            this.searchoptions);
                            B = y.searchhidden === true;
                            if (typeof y.sopt !== "undefined") {
                                m = 0;
                                y.ops = [];
                                if (y.sopt.length > 0) for (q = 0; q < y.sopt.length; q++) if ((t = a.inArray(y.sopt[q], r)) != -1) {
                                    y.ops[m] = {
                                        op: y.sopt[q],
                                        text: d.odata[t]
                                    };
                                    m++
                                }
                            }
                            if (typeof this.stype === "undefined") this.stype = "text";
                            if (this.stype == "select") if (y.dataUrl === undefined) {
                                var w;
                                if (y.value) w = y.value;
                                else if (this.editoptions) w = this.editoptions.value;
                                if (w) {
                                    y.dataValues = [];
                                    if (typeof w === "string") {
                                        w = w.split(";");
                                        var A;
                                        for (q = 0; q < w.length; q++) {
                                            A = w[q].split(":");
                                            y.dataValues[q] = {
                                                value: A[0],
                                                text: A[1]
                                            }
                                        }
                                    } else if (typeof w === "object") {
                                        q = 0;
                                        for (A in w) if (w.hasOwnProperty(A)) {
                                            y.dataValues[q] = {
                                                value: A,
                                                text: w[A]
                                            };
                                            q++
                                        }
                                    }
                                }
                            }
                            if (B && C || C && !I) l.push(y)
                        });
                        if (l.length > 0) {
                            a("<div id='" + k + "' role='dialog' tabindex='-1'></div>").insertBefore("#gview_" + c.p.id);
                            if (d.stringResult === undefined) d.stringResult = d.multipleSearch;
                            c.SearchFilter = a("#" + k).searchFilter(l, {
                                groupOps: d.groupOps,
                                operators: p,
                                onClose: h,
                                resetText: d.Reset,
                                searchText: d.Find,
                                windowTitle: d.caption,
                                rulesText: d.rulesText,
                                matchText: d.matchText,
                                onSearch: f,
                                onReset: g,
                                stringResult: d.stringResult,
                                ajaxSelectOptions: a.extend({},
                                a.jgrid.ajaxOptions, c.p.ajaxSelectOptions || {}),
                                clone: d.cloneSearchRowOnAdd
                            });
                            a(".ui-widget-overlay", "#" + k).remove();
                            c.p.direction == "rtl" && a(".ui-closer", "#" + k).css("float", "left");
                            if (d.drag === true) {
                                a("#" + k + " table thead tr:first td:first").css("cursor", "move");
                                if (jQuery.fn.jqDrag) a("#" + k).jqDrag(a("#" + k + " table thead tr:first td:first"));
                                else try {
                                    a("#" + k).draggable({
                                        handle: a("#" + k + " table thead tr:first td:first")
                                    })
                                } catch(v) {}
                            }
                            if (d.multipleSearch === false) {
                                a(".ui-del, .ui-add, .ui-del, .ui-add-last, .matchText, .rulesText", "#" + k).hide();
                                a("select[name='groupOp']", "#" + k).hide()
                            }
                            d.multipleSearch === true && d.loadDefaults === true && b(c, d);
                            a.isFunction(d.onInitializeSearch) && d.onInitializeSearch(a("#" + k));
                            a.isFunction(d.beforeShowSearch) && d.beforeShowSearch(a("#" + k));
                            j();
                            a.isFunction(d.afterShowSearch) && d.afterShowSearch(a("#" + k));
                            d.closeOnEscape === true && a("#" + k).keydown(function(y) {
                                y.which == 27 && h(a("#" + k))
                            })
                        }
                    }
                }
            })
        },
        editGridRow: function(d, b) {
            e = b = a.extend({
                top: 0,
                left: 0,
                width: 300,
                height: "auto",
                dataheight: "auto",
                modal: false,
                drag: true,
                resize: true,
                url: null,
                mtype: "POST",
                clearAfterAdd: true,
                closeAfterEdit: false,
                reloadAfterSubmit: true,
                onInitializeForm: null,
                beforeInitData: null,
                beforeShowForm: null,
                afterShowForm: null,
                beforeSubmit: null,
                afterSubmit: null,
                onclickSubmit: null,
                afterComplete: null,
                onclickPgButtons: null,
                afterclickPgButtons: null,
                editData: {},
                recreateForm: true,
                jqModal: true,
                closeOnEscape: false,
                addedrow: "first",
                topinfo: "",
                bottominfo: "",
                saveicon: [],
                closeicon: [],
                savekey: [false, 13],
                navkeys: [false, 38, 40],
                checkOnSubmit: false,
                checkOnUpdate: false,
                _savedData: {},
                processing: false,
                onClose: null,
                ajaxEditOptions: {},
                serializeEditData: null,
                viewPagerButtons: true
            },
            a.jgrid.edit, b || {});
            return this.each(function() {
                function f(F, H) {
                    F === 0 ? a("#pData", "#" + t + "_2").addClass("ui-state-disabled") : a("#pData", "#" + t + "_2").removeClass("ui-state-disabled");
                    F == H ? a("#nData", "#" + t + "_2").addClass("ui-state-disabled") : a("#nData", "#" + t + "_2").removeClass("ui-state-disabled")
                }
                function g() {
                    var F = a(n).jqGrid("getDataIDs"),
                    H = a("#id_g", "#" + t).val();
                    return [a.inArray(H, F), F]
                }
                function h() {
                    var F = true;
                    a("#FormError", "#" + t).hide();
                    if (e.checkOnUpdate) {
                        w = {};
                        A = {};
                        j();
                        G = a.extend({},
                        w, A);
                        if (M = o(G, e._savedData)) {
                            a("#" + q).data("disabled", true);
                            a(".confirm", "#" + m.themodal).show();
                            F = false
                        }
                    }
                    return F
                }
                function j() {
                    a(".FormElement", "#" + t).each(function() {
                        var F = a(".customelement", this);
                        if (F.length) {
                            var H = a(F[0]).attr("name");
                            a.each(n.p.colModel,
                            function() {
                                if (this.name == H && this.editoptions && a.isFunction(this.editoptions.custom_value)) {
                                    try {
                                        w[H] = this.editoptions.custom_value(a("#" + H, "#" + t), "get");
                                        if (w[H] === undefined) throw "e1";
                                    } catch(N) {
                                        N == "e1" ? info_dialog(jQuery.jgrid.errors.errcap, "function 'custom_value' " + a.jgrid.edit.msg.novalue, jQuery.jgrid.edit.bClose) : info_dialog(jQuery.jgrid.errors.errcap, N.message, jQuery.jgrid.edit.bClose)
                                    }
                                    return true
                                }
                            })
                        } else {
                            switch (a(this).get(0).type) {
                            case "checkbox":
                                if (a(this).attr("checked")) w[this.name] = a(this).val();
                                else {
                                    F = a(this).attr("offval");
                                    w[this.name] = F
                                }
                                break;
                            case "select-one":
                                w[this.name] = a("option:selected", this).val();
                                A[this.name] = a("option:selected", this).text();
                                break;
                            case "select-multiple":
                                w[this.name] = a(this).val();
                                w[this.name] = w[this.name] ? w[this.name].join(",") : "";
                                var Z = [];
                                a("option:selected", this).each(function(N, ea) {
                                    Z[N] = a(ea).text()
                                });
                                A[this.name] = Z.join(",");
                                break;
                            case "password":
                            case "text":
                            case "textarea":
                            case "button":
                                w[this.name] = a(this).val();
                                break
                            }
                            if (n.p.autoencode) w[this.name] = a.jgrid.htmlEncode(w[this.name])
                        }
                    });
                    return true
                }
                function c(F, H, Z, N) {
                    for (var ea, X, Y, aa = 0,
                    R, ka, ba, ta = [], fa = false, xa = "", ya = 1; ya <= N; ya++) xa += "<td class='CaptionTD ui-widget-content'>&#160;</td><td class='DataTD ui-widget-content' style='white-space:pre'>&#160;</td>";
                    if (F != "_empty") fa = a(H).jqGrid("getInd", F);
                    a(H.p.colModel).each(function(na) {
                        ea = this.name;
                        ka = (X = this.editrules && this.editrules.edithidden === true ? false: this.hidden === true ? true: false) ? "style='display:none'": "";
                        if (ea !== "cb" && ea !== "subgrid" && this.editable === true && ea !== "rn") {
                            if (fa === false) R = "";
                            else if (ea == H.p.ExpandColumn && H.p.treeGrid === true) R = a("td:eq(" + na + ")", H.rows[fa]).text();
                            else try {
                                R = a.unformat(a("td:eq(" + na + ")", H.rows[fa]), {
                                    rowId: F,
                                    colModel: this
                                },
                                na)
                            } catch(Ca) {
                                R = a("td:eq(" + na + ")", H.rows[fa]).html()
                            }
                            var ra = a.extend({},
                            this.editoptions || {},
                            {
                                id: ea,
                                name: ea
                            }),
                            Ba = a.extend({},
                            {
                                elmprefix: "",
                                elmsuffix: "",
                                rowabove: false,
                                rowcontent: ""
                            },
                            this.formoptions || {}),
                            Ia = parseInt(Ba.rowpos, 10) || aa + 1,
                            s = parseInt((parseInt(Ba.colpos, 10) || 1) * 2, 10);
                            if (F == "_empty" && ra.defaultValue) R = a.isFunction(ra.defaultValue) ? ra.defaultValue() : ra.defaultValue;
                            if (!this.edittype) this.edittype = "text";
                            if (n.p.autoencode) R = a.jgrid.htmlDecode(R);
                            ba = createEl(this.edittype, ra, R, false, a.extend({},
                            a.jgrid.ajaxOptions, H.p.ajaxSelectOptions || {}));
                            if (R == "" && this.edittype == "checkbox") R = a(ba).attr("offval");
                            if (R == "" && this.edittype == "select") R = a("option:eq(0)", ba).text();
                            if (e.checkOnSubmit || e.checkOnUpdate) e._savedData[ea] = R;
                            a(ba).addClass("FormElement");
                            Y = a(Z).find("tr[rowpos=" + Ia + "]");
                            if (Ba.rowabove) {
                                ra = a("<tr><td class='contentinfo' colspan='" + N * 2 + "'>" + Ba.rowcontent + "</td></tr>");
                                a(Z).append(ra);
                                ra[0].rp = Ia
                            }
                            if (Y.length === 0) {
                                Y = a("<tr " + ka + " rowpos='" + Ia + "'></tr>").addClass("FormData").attr("id", "tr_" + ea);
                                a(Y).append(xa);
                                a(Z).append(Y);
                                Y[0].rp = Ia
                            }
                            a("td:eq(" + (s - 2) + ")", Y[0]).html(typeof Ba.label === "undefined" ? H.p.colNames[na] : Ba.label);
                            a("td:eq(" + (s - 1) + ")", Y[0]).append(Ba.elmprefix).append(ba).append(Ba.elmsuffix);
                            ta[aa] = na;
                            aa++
                        }
                    });
                    if (aa > 0) {
                        ya = a("<tr class='FormData' style='display:none'><td class='CaptionTD'></td><td colspan='" + (N * 2 - 1) + "' class='DataTD'><input class='FormElement' id='id_g' type='text' name='" + H.p.id + "_id' value='" + F + "'/></td></tr>");
                        ya[0].rp = aa + 999;
                        a(Z).append(ya);
                        if (e.checkOnSubmit || e.checkOnUpdate) e._savedData[H.p.id + "_id"] = F
                    }
                    return ta
                }
                function k(F, H, Z) {
                    var N, ea = 0,
                    X, Y, aa, R, ka;
                    if (e.checkOnSubmit || e.checkOnUpdate) {
                        e._savedData = {};
                        e._savedData[H.p.id + "_id"] = F
                    }
                    var ba = H.p.colModel;
                    if (F == "_empty") {
                        a(ba).each(function() {
                            N = this.name;
                            aa = a.extend({},
                            this.editoptions || {});
                            Y = a("#" + a.jgrid.jqID(N), "#" + Z);
                            if (Y[0] != null) {
                                R = "";
                                if (aa.defaultValue) {
                                    R = a.isFunction(aa.defaultValue) ? aa.defaultValue() : aa.defaultValue;
                                    if (Y[0].type == "checkbox") {
                                        ka = R.toLowerCase();
                                        if (ka.search(/(false|0|no|off|undefined)/i) < 0 && ka !== "") {
                                            Y[0].checked = true;
                                            Y[0].defaultChecked = true;
                                            Y[0].value = R
                                        } else Y.attr({
                                            checked: "",
                                            defaultChecked: ""
                                        })
                                    } else Y.val(R)
                                } else if (Y[0].type == "checkbox") {
                                    Y[0].checked = false;
                                    Y[0].defaultChecked = false;
                                    R = a(Y).attr("offval")
                                } else if (Y[0].type && Y[0].type.substr(0, 6) == "select") Y[0].selectedIndex = 0;
                                else Y.val(R);
                                if (e.checkOnSubmit === true || e.checkOnUpdate) e._savedData[N] = R
                            }
                        });
                        a("#id_g", "#" + Z).val(F)
                    } else {
                        var ta = a(H).jqGrid("getInd", F, true);
                        if (ta) {
                            a("td", ta).each(function(fa) {
                                N = ba[fa].name;
                                if (N !== "cb" && N !== "subgrid" && N !== "rn" && ba[fa].editable === true) {
                                    if (N == H.p.ExpandColumn && H.p.treeGrid === true) X = a(this).text();
                                    else try {
                                        X = a.unformat(this, {
                                            rowId: F,
                                            colModel: ba[fa]
                                        },
                                        fa)
                                    } catch(xa) {
                                        X = a(this).html()
                                    }
                                    if (n.p.autoencode) X = a.jgrid.htmlDecode(X);
                                    if (e.checkOnSubmit === true || e.checkOnUpdate) e._savedData[N] = X;
                                    N = a.jgrid.jqID(N);
                                    switch (ba[fa].edittype) {
                                    case "password":
                                    case "text":
                                    case "button":
                                    case "image":
                                        a("#" + N, "#" + Z).val(X);
                                        break;
                                    case "textarea":
                                        if (X == "&nbsp;" || X == "&#160;" || X.length == 1 && X.charCodeAt(0) == 160) X = "";
                                        a("#" + N, "#" + Z).val(X);
                                        break;
                                    case "select":
                                        var ya = X.split(",");
                                        ya = a.map(ya,
                                        function(Ca) {
                                            return a.trim(Ca)
                                        });
                                        a("#" + N + " option", "#" + Z).each(function() {
                                            this.selected = !ba[fa].editoptions.multiple && (ya[0] == a.trim(a(this).text()) || ya[0] == a.trim(a(this).val())) ? true: ba[fa].editoptions.multiple ? a.inArray(a.trim(a(this).text()), ya) > -1 || a.inArray(a.trim(a(this).val()), ya) > -1 ? true: false: false
                                        });
                                        break;
                                    case "checkbox":
                                        X += "";
                                        if (ba[fa].editoptions && ba[fa].editoptions.value) if (ba[fa].editoptions.value.split(":")[0] == X) {
                                            a("#" + N, "#" + Z).attr("checked", true);
                                            a("#" + N, "#" + Z).attr("defaultChecked", true)
                                        } else {
                                            a("#" + N, "#" + Z).attr("checked", false);
                                            a("#" + N, "#" + Z).attr("defaultChecked", "")
                                        } else {
                                            X = X.toLowerCase();
                                            if (X.search(/(false|0|no|off|undefined)/i) < 0 && X !== "") {
                                                a("#" + N, "#" + Z).attr("checked", true);
                                                a("#" + N, "#" + Z).attr("defaultChecked", true)
                                            } else {
                                                a("#" + N, "#" + Z).attr("checked", false);
                                                a("#" + N, "#" + Z).attr("defaultChecked", "")
                                            }
                                        }
                                        break;
                                    case "custom":
                                        try {
                                            if (ba[fa].editoptions && a.isFunction(ba[fa].editoptions.custom_value)) ba[fa].editoptions.custom_value(a("#" + N, "#" + Z), "set", X);
                                            else throw "e1";
                                        } catch(na) {
                                            na == "e1" ? info_dialog(jQuery.jgrid.errors.errcap, "function 'custom_value' " + a.jgrid.edit.msg.nodefined, jQuery.jgrid.edit.bClose) : info_dialog(jQuery.jgrid.errors.errcap, na.message, jQuery.jgrid.edit.bClose)
                                        }
                                        break
                                    }
                                    ea++
                                }
                            });
                            ea > 0 && a("#id_g", "#" + t).val(F)
                        }
                    }
                }
                function l() {
                    var F, H = [true, "", ""],
                    Z = {},
                    N = n.p.prmNames,
                    ea,
                    X;
                    if (a.isFunction(e.beforeCheckValues)) {
                        var Y = e.beforeCheckValues(w, a("#" + q), w[n.p.id + "_id"] == "_empty" ? N.addoper: N.editoper);
                        if (Y && typeof Y === "object") w = Y
                    }
                    for (var aa in w) if (w.hasOwnProperty(aa)) {
                        H = checkValues(w[aa], aa, n);
                        if (H[0] === false) break
                    }
                    if (H[0]) {
                        if (a.isFunction(e.onclickSubmit)) Z = e.onclickSubmit(e, w) || {};
                        if (a.isFunction(e.beforeSubmit)) H = e.beforeSubmit(w, a("#" + q))
                    }
                    if (H[0] && !e.processing) {
                        e.processing = true;
                        a("#sData", "#" + t + "_2").addClass("ui-state-active");
                        X = N.oper;
                        ea = N.id;
                        w[X] = a.trim(w[n.p.id + "_id"]) == "_empty" ? N.addoper: N.editoper;
                        if (w[X] != N.addoper) w[ea] = w[n.p.id + "_id"];
                        else if (w[ea] === undefined) w[ea] = w[n.p.id + "_id"];
                        delete w[n.p.id + "_id"];
                        w = a.extend(w, e.editData, Z);
                        Z = a.extend({
                            url: e.url ? e.url: a(n).jqGrid("getGridParam", "editurl"),
                            type: e.mtype,
                            data: a.isFunction(e.serializeEditData) ? e.serializeEditData(w) : w,
                            complete: function(R, ka) {
                                if (ka != "success") {
                                    H[0] = false;
                                    H[1] = a.isFunction(e.errorTextFormat) ? e.errorTextFormat(R) : ka + " Status: '" + R.statusText + "'. Error code: " + R.status
                                } else if (a.isFunction(e.afterSubmit)) H = e.afterSubmit(R, w);
                                if (H[0] === false) {
                                    a("#FormError>td", "#" + t).html(H[1]);
                                    a("#FormError", "#" + t).show()
                                } else {
                                    a.each(n.p.colModel,
                                    function() {
                                        if (A[this.name] && this.formatter && this.formatter == "select") try {
                                            delete A[this.name]
                                        } catch(fa) {}
                                    });
                                    w = a.extend(w, A);
                                    n.p.autoencode && a.each(w,
                                    function(fa, xa) {
                                        w[fa] = a.jgrid.htmlDecode(xa)
                                    });
                                    e.reloadAfterSubmit = e.reloadAfterSubmit && n.p.datatype != "local";
                                    if (w[X] == N.addoper) {
                                        H[2] || (H[2] = parseInt(n.p.records, 10) + 1 + "");
                                        w[ea] = H[2];
                                        if (e.closeAfterAdd) {
                                            if (e.reloadAfterSubmit) a(n).trigger("reloadGrid");
                                            else {
                                                a(n).jqGrid("addRowData", H[2], w, b.addedrow);
                                                a(n).jqGrid("setSelection", H[2])
                                            }
                                            hideModal("#" + m.themodal, {
                                                gb: "#gbox_" + r,
                                                jqm: b.jqModal,
                                                onClose: e.onClose
                                            })
                                        } else if (e.clearAfterAdd) {
                                            e.reloadAfterSubmit ? a(n).trigger("reloadGrid") : a(n).jqGrid("addRowData", H[2], w, b.addedrow);
                                            k("_empty", n, q)
                                        } else e.reloadAfterSubmit ? a(n).trigger("reloadGrid") : a(n).jqGrid("addRowData", H[2], w, b.addedrow)
                                    } else {
                                        if (e.reloadAfterSubmit) {
                                            a(n).trigger("reloadGrid");
                                            e.closeAfterEdit || setTimeout(function() {
                                                a(n).jqGrid("setSelection", w[ea])
                                            },
                                            1E3)
                                        } else n.p.treeGrid === true ? a(n).jqGrid("setTreeRow", w[ea], w) : a(n).jqGrid("setRowData", w[ea], w);
                                        e.closeAfterEdit && hideModal("#" + m.themodal, {
                                            gb: "#gbox_" + r,
                                            jqm: b.jqModal,
                                            onClose: e.onClose
                                        })
                                    }
                                    if (a.isFunction(e.afterComplete)) {
                                        F = R;
                                        setTimeout(function() {
                                            e.afterComplete(F, w, a("#" + q));
                                            F = null
                                        },
                                        500)
                                    }
                                }
                                e.processing = false;
                                if (e.checkOnSubmit || e.checkOnUpdate) {
                                    a("#" + q).data("disabled", false);
                                    if (e._savedData[n.p.id + "_id"] != "_empty") for (var ba in e._savedData) if (w[ba]) e._savedData[ba] = w[ba]
                                }
                                a("#sData", "#" + t + "_2").removeClass("ui-state-active");
                                try {
                                    a(":input:visible", "#" + q)[0].focus()
                                } catch(ta) {}
                            },
                            error: function(R, ka, ba) {
                                a("#FormError>td", "#" + t).html(ka + " : " + ba);
                                a("#FormError", "#" + t).show();
                                e.processing = false;
                                a("#" + q).data("disabled", false);
                                a("#sData", "#" + t + "_2").removeClass("ui-state-active")
                            }
                        },
                        a.jgrid.ajaxOptions, e.ajaxEditOptions);
                        if (!Z.url && !e.useDataProxy) if (a.isFunction(n.p.dataProxy)) e.useDataProxy = true;
                        else {
                            H[0] = false;
                            H[1] += " " + a.jgrid.errors.nourl
                        }
                        if (H[0]) e.useDataProxy ? n.p.dataProxy.call(n, Z, "set_" + n.p.id) : a.ajax(Z)
                    }
                    if (H[0] === false) {
                        a("#FormError>td", "#" + t).html(H[1]);
                        a("#FormError", "#" + t).show()
                    }
                }
                function o(F, H) {
                    var Z = false,
                    N;
                    for (N in F) if (F[N] != H[N]) {
                        Z = true;
                        break
                    }
                    return Z
                }
                var n = this;
                if (n.grid && d) {
                    var r = n.p.id,
                    q = "FrmGrid_" + r,
                    t = "TblGrid_" + r,
                    m = {
                        themodal: "editmod" + r,
                        modalhead: "edithd" + r,
                        modalcontent: "editcnt" + r,
                        scrollelm: q
                    },
                    p = a.isFunction(e.beforeShowForm) ? e.beforeShowForm: false,
                    v = a.isFunction(e.afterShowForm) ? e.afterShowForm: false,
                    y = a.isFunction(e.beforeInitData) ? e.beforeInitData: false,
                    B = a.isFunction(e.onInitializeForm) ? e.onInitializeForm: false,
                    C = 1,
                    I = 0,
                    w,
                    A,
                    G,
                    M;
                    if (d == "new") {
                        d = "_empty";
                        b.caption = b.addCaption
                    } else b.caption = b.editCaption;
                    b.recreateForm === true && a("#" + m.themodal).html() != null && a("#" + m.themodal).remove();
                    var O = true;
                    if (b.checkOnUpdate && b.jqModal && !b.modal) O = false;
                    if (a("#" + m.themodal).html() != null) {
                        a(".ui-jqdialog-title", "#" + m.modalhead).html(b.caption);
                        a("#FormError", "#" + t).hide();
                        if (e.topinfo) {
                            a(".topinfo", "#" + t + "_2").html(e.topinfo);
                            a(".tinfo", "#" + t + "_2").show()
                        } else a(".tinfo", "#" + t + "_2").hide();
                        if (e.bottominfo) {
                            a(".bottominfo", "#" + t + "_2").html(e.bottominfo);
                            a(".binfo", "#" + t + "_2").show()
                        } else a(".binfo", "#" + t + "_2").hide();
                        y && y(a("#" + q));
                        k(d, n, q);
                        d == "_empty" || !e.viewPagerButtons ? a("#pData, #nData", "#" + t + "_2").hide() : a("#pData, #nData", "#" + t + "_2").show();
                        if (e.processing === true) {
                            e.processing = false;
                            a("#sData", "#" + t + "_2").removeClass("ui-state-active")
                        }
                        if (a("#" + q).data("disabled") === true) {
                            a(".confirm", "#" + m.themodal).hide();
                            a("#" + q).data("disabled", false)
                        }
                        p && p(a("#" + q));
                        a("#" + m.themodal).data("onClose", e.onClose);
                        viewModal("#" + m.themodal, {
                            gbox: "#gbox_" + r,
                            jqm: b.jqModal,
                            jqM: false,
                            closeoverlay: O,
                            modal: b.modal
                        });
                        O || a(".jqmOverlay").click(function() {
                            if (!h()) return false;
                            hideModal("#" + m.themodal, {
                                gb: "#gbox_" + r,
                                jqm: b.jqModal,
                                onClose: e.onClose
                            });
                            return false
                        });
                        v && v(a("#" + q))
                    } else {
                        a(n.p.colModel).each(function() {
                            var F = this.formoptions;
                            C = Math.max(C, F ? F.colpos || 0 : 0);
                            I = Math.max(I, F ? F.rowpos || 0 : 0)
                        });
                        var P = isNaN(b.dataheight) ? b.dataheight: b.dataheight + "px",
                        V;
                        P = a("<form name='FormPost' id='" + q + "' class='FormGrid' onSubmit='return false;' style='width:100%;overflow:auto;position:relative;height:" + P + ";'></form>").data("disabled", false);
                        var da = a("<table id='" + t + "' class='EditTable' cellspacing='0' cellpading='0' border='0'><tbody></tbody></table>");
                        a(P).append(da);
                        V = a("<tr id='FormError' style='display:none'><td class='ui-state-error' colspan='" + C * 2 + "'></td></tr>");
                        V[0].rp = 0;
                        a(da).append(V);
                        V = a("<tr style='display:none' class='tinfo'><td class='topinfo' colspan='" + C * 2 + "'>" + e.topinfo + "</td></tr>");
                        V[0].rp = 0;
                        a(da).append(V);
                        y && y(a("#" + q));
                        V = (y = n.p.direction == "rtl" ? true: false) ? "nData": "pData";
                        var ga = y ? "pData": "nData";
                        c(d, n, da, C);
                        V = "<a href='javascript:void(0)' id='" + V + "' class='fm-button ui-state-default ui-corner-left'><span class='ui-icon ui-icon-triangle-1-w'></span></div>";
                        ga = "<a href='javascript:void(0)' id='" + ga + "' class='fm-button ui-state-default ui-corner-right'><span class='ui-icon ui-icon-triangle-1-e'></span></div>";
                        var ua = "<a href='javascript:void(0)' id='sData' class='fm-button ui-state-default ui-corner-all'>" + b.bSubmit + "</a>",
                        za = "<a href='javascript:void(0)' id='cData' class='fm-button ui-state-default ui-corner-all'>" + b.bCancel + "</a>";
                        V = "<table border='0' class='EditTable' id='" + t + "_2'><tbody><tr id='Act_Buttons'><td class='navButton ui-widget-content'>" + (y ? ga + V: V + ga) + "</td><td class='EditButton ui-widget-content'>" + ua + za + "</td></tr>";
                        V += "<tr style='display:none' class='binfo'><td class='bottominfo' colspan='2'>" + e.bottominfo + "</td></tr>";
                        V += "</tbody></table>";
                        if (I > 0) {
                            var Aa = [];
                            a.each(a(da)[0].rows,
                            function(F, H) {
                                Aa[F] = H
                            });
                            Aa.sort(function(F, H) {
                                if (F.rp > H.rp) return 1;
                                if (F.rp < H.rp) return - 1;
                                return 0
                            });
                            a.each(Aa,
                            function(F, H) {
                                a("tbody", da).append(H)
                            })
                        }
                        b.gbox = "#gbox_" + r;
                        var Ga = false;
                        if (b.closeOnEscape === true) {
                            b.closeOnEscape = false;
                            Ga = true
                        }
                        P = a("<span></span>").append(P).append(V);
                        createModal(m, P, b, "#gview_" + n.p.id, a("#gbox_" + n.p.id)[0]);
                        if (y) {
                            a("#pData, #nData", "#" + t + "_2").css("float", "right");
                            a(".EditButton", "#" + t + "_2").css("text-align", "left")
                        }
                        e.topinfo && a(".tinfo", "#" + t + "_2").show();
                        e.bottominfo && a(".binfo", "#" + t + "_2").show();
                        V = P = null;
                        a("#" + m.themodal).keydown(function(F) {
                            var H = F.target;
                            if (a("#" + q).data("disabled") === true) return false;
                            if (e.savekey[0] === true && F.which == e.savekey[1]) if (H.tagName != "TEXTAREA") {
                                a("#sData", "#" + t + "_2").trigger("click");
                                return false
                            }
                            if (F.which === 27) {
                                if (!h()) return false;
                                Ga && hideModal(this, {
                                    gb: b.gbox,
                                    jqm: b.jqModal,
                                    onClose: e.onClose
                                });
                                return false
                            }
                            if (e.navkeys[0] === true) {
                                if (a("#id_g", "#" + t).val() == "_empty") return true;
                                if (F.which == e.navkeys[1]) {
                                    a("#pData", "#" + t + "_2").trigger("click");
                                    return false
                                }
                                if (F.which == e.navkeys[2]) {
                                    a("#nData", "#" + t + "_2").trigger("click");
                                    return false
                                }
                            }
                        });
                        if (b.checkOnUpdate) {
                            a("a.ui-jqdialog-titlebar-close span", "#" + m.themodal).removeClass("jqmClose");
                            a("a.ui-jqdialog-titlebar-close", "#" + m.themodal).unbind("click").click(function() {
                                if (!h()) return false;
                                hideModal("#" + m.themodal, {
                                    gb: "#gbox_" + r,
                                    jqm: b.jqModal,
                                    onClose: e.onClose
                                });
                                return false
                            })
                        }
                        b.saveicon = a.extend([true, "left", "ui-icon-disk"], b.saveicon);
                        b.closeicon = a.extend([true, "left", "ui-icon-close"], b.closeicon);
                        if (b.saveicon[0] === true) a("#sData", "#" + t + "_2").addClass(b.saveicon[1] == "right" ? "fm-button-icon-right": "fm-button-icon-left").append("<span class='ui-icon " + b.saveicon[2] + "'></span>");
                        if (b.closeicon[0] === true) a("#cData", "#" + t + "_2").addClass(b.closeicon[1] == "right" ? "fm-button-icon-right": "fm-button-icon-left").append("<span class='ui-icon " + b.closeicon[2] + "'></span>");
                        if (e.checkOnSubmit || e.checkOnUpdate) {
                            ua = "<a href='javascript:void(0)' id='sNew' class='fm-button ui-state-default ui-corner-all' style='z-index:1002'>" + b.bYes + "</a>";
                            ga = "<a href='javascript:void(0)' id='nNew' class='fm-button ui-state-default ui-corner-all' style='z-index:1002'>" + b.bNo + "</a>";
                            za = "<a href='javascript:void(0)' id='cNew' class='fm-button ui-state-default ui-corner-all' style='z-index:1002'>" + b.bExit + "</a>";
                            P = b.zIndex || 999;
                            P++;
                            a("<div class='ui-widget-overlay jqgrid-overlay confirm' style='z-index:" + P + ";display:none;'>&#160;" + (a.browser.msie && a.browser.version == 6 ? '<iframe style="display:block;position:absolute;z-index:-1;filter:Alpha(Opacity=\'0\');" src="javascript:false;"></iframe>': "") + "</div><div class='confirm ui-widget-content ui-jqconfirm' style='z-index:" + (P + 1) + "'>" + b.saveData + "<br/><br/>" + ua + ga + za + "</div>").insertAfter("#" + q);
                            a("#sNew", "#" + m.themodal).click(function() {
                                l();
                                a("#" + q).data("disabled", false);
                                a(".confirm", "#" + m.themodal).hide();
                                return false
                            });
                            a("#nNew", "#" + m.themodal).click(function() {
                                a(".confirm", "#" + m.themodal).hide();
                                a("#" + q).data("disabled", false);
                                setTimeout(function() {
                                    a(":input", "#" + q)[0].focus()
                                },
                                0);
                                return false
                            });
                            a("#cNew", "#" + m.themodal).click(function() {
                                a(".confirm", "#" + m.themodal).hide();
                                a("#" + q).data("disabled", false);
                                hideModal("#" + m.themodal, {
                                    gb: "#gbox_" + r,
                                    jqm: b.jqModal,
                                    onClose: e.onClose
                                });
                                return false
                            })
                        }
                        B && B(a("#" + q));
                        d == "_empty" || !e.viewPagerButtons ? a("#pData,#nData", "#" + t + "_2").hide() : a("#pData,#nData", "#" + t + "_2").show();
                        p && p(a("#" + q));
                        a("#" + m.themodal).data("onClose", e.onClose);
                        viewModal("#" + m.themodal, {
                            gbox: "#gbox_" + r,
                            jqm: b.jqModal,
                            closeoverlay: O,
                            modal: b.modal
                        });
                        O || a(".jqmOverlay").click(function() {
                            if (!h()) return false;
                            hideModal("#" + m.themodal, {
                                gb: "#gbox_" + r,
                                jqm: b.jqModal,
                                onClose: e.onClose
                            });
                            return false
                        });
                        v && v(a("#" + q));
                        a(".fm-button", "#" + m.themodal).hover(function() {
                            a(this).addClass("ui-state-hover")
                        },
                        function() {
                            a(this).removeClass("ui-state-hover")
                        });
                        a("#sData", "#" + t + "_2").click(function() {
                            w = {};
                            A = {};
                            a("#FormError", "#" + t).hide();
                            j();
                            if (w[n.p.id + "_id"] == "_empty") l();
                            else if (b.checkOnSubmit === true) {
                                G = a.extend({},
                                w, A);
                                if (M = o(G, e._savedData)) {
                                    a("#" + q).data("disabled", true);
                                    a(".confirm", "#" + m.themodal).show()
                                } else l()
                            } else l();
                            return false
                        });
                        a("#cData", "#" + t + "_2").click(function() {
                            if (!h()) return false;
                            hideModal("#" + m.themodal, {
                                gb: "#gbox_" + r,
                                jqm: b.jqModal,
                                onClose: e.onClose
                            });
                            return false
                        });
                        a("#nData", "#" + t + "_2").click(function() {
                            if (!h()) return false;
                            a("#FormError", "#" + t).hide();
                            var F = g();
                            F[0] = parseInt(F[0], 10);
                            if (F[0] != -1 && F[1][F[0] + 1]) {
                                a.isFunction(b.onclickPgButtons) && b.onclickPgButtons("next", a("#" + q), F[1][F[0]]);
                                k(F[1][F[0] + 1], n, q);
                                a(n).jqGrid("setSelection", F[1][F[0] + 1]);
                                a.isFunction(b.afterclickPgButtons) && b.afterclickPgButtons("next", a("#" + q), F[1][F[0] + 1]);
                                f(F[0] + 1, F[1].length - 1)
                            }
                            return false
                        });
                        a("#pData", "#" + t + "_2").click(function() {
                            if (!h()) return false;
                            a("#FormError", "#" + t).hide();
                            var F = g();
                            if (F[0] != -1 && F[1][F[0] - 1]) {
                                a.isFunction(b.onclickPgButtons) && b.onclickPgButtons("prev", a("#" + q), F[1][F[0]]);
                                k(F[1][F[0] - 1], n, q);
                                a(n).jqGrid("setSelection", F[1][F[0] - 1]);
                                a.isFunction(b.afterclickPgButtons) && b.afterclickPgButtons("prev", a("#" + q), F[1][F[0] - 1]);
                                f(F[0] - 1, F[1].length - 1)
                            }
                            return false
                        })
                    }
                    p = g();
                    f(p[0], p[1].length - 1)
                }
            })
        },
        viewGridRow: function(d, b) {
            b = a.extend({
                top: 0,
                left: 0,
                width: 0,
                height: "auto",
                dataheight: "auto",
                modal: false,
                drag: true,
                resize: true,
                jqModal: true,
                closeOnEscape: false,
                labelswidth: "30%",
                closeicon: [],
                navkeys: [false, 38, 40],
                onClose: null,
                beforeShowForm: null,
                viewPagerButtons: true
            },
            a.jgrid.view, b || {});
            return this.each(function() {
                function f() {
                    if (b.closeOnEscape === true || b.navkeys[0] === true) setTimeout(function() {
                        a(".ui-jqdialog-titlebar-close", "#" + r.modalhead).focus()
                    },
                    0)
                }
                function g(A, G) {
                    A === 0 ? a("#pData", "#" + n + "_2").addClass("ui-state-disabled") : a("#pData", "#" + n + "_2").removeClass("ui-state-disabled");
                    A == G ? a("#nData", "#" + n + "_2").addClass("ui-state-disabled") : a("#nData", "#" + n + "_2").removeClass("ui-state-disabled")
                }
                function h() {
                    var A = a(k).jqGrid("getDataIDs"),
                    G = a("#id_g", "#" + n).val();
                    return [a.inArray(G, A), A]
                }
                function j(A, G, M, O) {
                    for (var P, V, da, ga = 0,
                    ua, za, Aa = [], Ga = false, F = "<td class='CaptionTD form-view-label ui-widget-content' width='" + b.labelswidth + "'>&#160;</td><td class='DataTD form-view-data ui-helper-reset ui-widget-content'>&#160;</td>", H = "", Z = ["integer", "number", "currency"], N = 0, ea = 0, X, Y, aa, R = 1; R <= O; R++) H += R == 1 ? F: "<td class='CaptionTD form-view-label ui-widget-content'>&#160;</td><td class='DataTD form-view-data ui-widget-content'>&#160;</td>";
                    a(G.p.colModel).each(function() {
                        V = this.editrules && this.editrules.edithidden === true ? false: this.hidden === true ? true: false;
                        if (!V && this.align === "right") if (this.formatter && a.inArray(this.formatter, Z) !== -1) N = Math.max(N, parseInt(this.width, 10));
                        else ea = Math.max(ea, parseInt(this.width, 10))
                    });
                    X = N !== 0 ? N: ea !== 0 ? ea: 0;
                    Ga = a(G).jqGrid("getInd", A);
                    a(G.p.colModel).each(function(ka) {
                        P = this.name;
                        Y = false;
                        za = (V = this.editrules && this.editrules.edithidden === true ? false: this.hidden === true ? true: false) ? "style='display:none'": "";
                        aa = typeof this.viewable != "boolean" ? true: this.viewable;
                        if (P !== "cb" && P !== "subgrid" && P !== "rn" && aa) {
                            ua = Ga === false ? "": P == G.p.ExpandColumn && G.p.treeGrid === true ? a("td:eq(" + ka + ")", G.rows[Ga]).text() : a("td:eq(" + ka + ")", G.rows[Ga]).html();
                            Y = this.align === "right" && X !== 0 ? true: false;
                            a.extend({},
                            this.editoptions || {},
                            {
                                id: P,
                                name: P
                            });
                            var ba = a.extend({},
                            {
                                rowabove: false,
                                rowcontent: ""
                            },
                            this.formoptions || {}),
                            ta = parseInt(ba.rowpos, 10) || ga + 1,
                            fa = parseInt((parseInt(ba.colpos, 10) || 1) * 2, 10);
                            if (ba.rowabove) {
                                var xa = a("<tr><td class='contentinfo' colspan='" + O * 2 + "'>" + ba.rowcontent + "</td></tr>");
                                a(M).append(xa);
                                xa[0].rp = ta
                            }
                            da = a(M).find("tr[rowpos=" + ta + "]");
                            if (da.length === 0) {
                                da = a("<tr " + za + " rowpos='" + ta + "'></tr>").addClass("FormData").attr("id", "trv_" + P);
                                a(da).append(H);
                                a(M).append(da);
                                da[0].rp = ta
                            }
                            a("td:eq(" + (fa - 2) + ")", da[0]).html("<b>" + (typeof ba.label === "undefined" ? G.p.colNames[ka] : ba.label) + "</b>");
                            a("td:eq(" + (fa - 1) + ")", da[0]).append("<span>" + ua + "</span>").attr("id", "v_" + P);
                            Y && a("td:eq(" + (fa - 1) + ") span", da[0]).css({
                                "text-align": "right",
                                width: X + "px"
                            });
                            Aa[ga] = ka;
                            ga++
                        }
                    });
                    if (ga > 0) {
                        A = a("<tr class='FormData' style='display:none'><td class='CaptionTD'></td><td colspan='" + (O * 2 - 1) + "' class='DataTD'><input class='FormElement' id='id_g' type='text' name='id' value='" + A + "'/></td></tr>");
                        A[0].rp = ga + 99;
                        a(M).append(A)
                    }
                    return Aa
                }
                function c(A, G) {
                    var M, O, P = 0,
                    V, da;
                    if (da = a(G).jqGrid("getInd", A, true)) {
                        a("td", da).each(function(ga) {
                            M = G.p.colModel[ga].name;
                            O = G.p.colModel[ga].editrules && G.p.colModel[ga].editrules.edithidden === true ? false: G.p.colModel[ga].hidden === true ? true: false;
                            if (M !== "cb" && M !== "subgrid" && M !== "rn") {
                                V = M == G.p.ExpandColumn && G.p.treeGrid === true ? a(this).text() : a(this).html();
                                a.extend({},
                                G.p.colModel[ga].editoptions || {});
                                M = a.jgrid.jqID("v_" + M);
                                a("#" + M + " span", "#" + n).html(V);
                                O && a("#" + M, "#" + n).parents("tr:first").hide();
                                P++
                            }
                        });
                        P > 0 && a("#id_g", "#" + n).val(A)
                    }
                }
                var k = this;
                if (k.grid && d) {
                    if (!b.imgpath) b.imgpath = k.p.imgpath;
                    var l = k.p.id,
                    o = "ViewGrid_" + l,
                    n = "ViewTbl_" + l,
                    r = {
                        themodal: "viewmod" + l,
                        modalhead: "viewhd" + l,
                        modalcontent: "viewcnt" + l,
                        scrollelm: o
                    },
                    q = 1,
                    t = 0;
                    if (a("#" + r.themodal).html() != null) {
                        a(".ui-jqdialog-title", "#" + r.modalhead).html(b.caption);
                        a("#FormError", "#" + n).hide();
                        c(d, k);
                        a.isFunction(b.beforeShowForm) && b.beforeShowForm(a("#" + o));
                        viewModal("#" + r.themodal, {
                            gbox: "#gbox_" + l,
                            jqm: b.jqModal,
                            jqM: false,
                            modal: b.modal
                        });
                        f()
                    } else {
                        a(k.p.colModel).each(function() {
                            var A = this.formoptions;
                            q = Math.max(q, A ? A.colpos || 0 : 0);
                            t = Math.max(t, A ? A.rowpos || 0 : 0)
                        });
                        var m = isNaN(b.dataheight) ? b.dataheight: b.dataheight + "px",
                        p = a("<form name='FormPost' id='" + o + "' class='FormGrid' style='width:100%;overflow:auto;position:relative;height:" + m + ";'></form>"),
                        v = a("<table id='" + n + "' class='EditTable' cellspacing='1' cellpading='2' border='0' style='table-layout:fixed'><tbody></tbody></table>");
                        a(p).append(v);
                        j(d, k, v, q);
                        m = k.p.direction == "rtl" ? true: false;
                        var y = "<a href='javascript:void(0)' id='" + (m ? "nData": "pData") + "' class='fm-button ui-state-default ui-corner-left'><span class='ui-icon ui-icon-triangle-1-w'></span></div>",
                        B = "<a href='javascript:void(0)' id='" + (m ? "pData": "nData") + "' class='fm-button ui-state-default ui-corner-right'><span class='ui-icon ui-icon-triangle-1-e'></span></div>",
                        C = "<a href='javascript:void(0)' id='cData' class='fm-button ui-state-default ui-corner-all'>" + b.bClose + "</a>";
                        if (t > 0) {
                            var I = [];
                            a.each(a(v)[0].rows,
                            function(A, G) {
                                I[A] = G
                            });
                            I.sort(function(A, G) {
                                if (A.rp > G.rp) return 1;
                                if (A.rp < G.rp) return - 1;
                                return 0
                            });
                            a.each(I,
                            function(A, G) {
                                a("tbody", v).append(G)
                            })
                        }
                        b.gbox = "#gbox_" + l;
                        var w = false;
                        if (b.closeOnEscape === true) {
                            b.closeOnEscape = false;
                            w = true
                        }
                        p = a("<span></span>").append(p).append("<table border='0' class='EditTable' id='" + n + "_2'><tbody><tr id='Act_Buttons'><td class='navButton ui-widget-content' width='" + b.labelswidth + "'>" + (m ? B + y: y + B) + "</td><td class='EditButton ui-widget-content'>" + C + "</td></tr></tbody></table>");
                        createModal(r, p, b, "#gview_" + k.p.id, a("#gview_" + k.p.id)[0]);
                        if (m) {
                            a("#pData, #nData", "#" + n + "_2").css("float", "right");
                            a(".EditButton", "#" + n + "_2").css("text-align", "left")
                        }
                        b.viewPagerButtons || a("#pData, #nData", "#" + n + "_2").hide();
                        p = null;
                        a("#" + r.themodal).keydown(function(A) {
                            if (A.which === 27) {
                                w && hideModal(this, {
                                    gb: b.gbox,
                                    jqm: b.jqModal,
                                    onClose: b.onClose
                                });
                                return false
                            }
                            if (b.navkeys[0] === true) {
                                if (A.which === b.navkeys[1]) {
                                    a("#pData", "#" + n + "_2").trigger("click");
                                    return false
                                }
                                if (A.which === b.navkeys[2]) {
                                    a("#nData", "#" + n + "_2").trigger("click");
                                    return false
                                }
                            }
                        });
                        b.closeicon = a.extend([true, "left", "ui-icon-close"], b.closeicon);
                        if (b.closeicon[0] === true) a("#cData", "#" + n + "_2").addClass(b.closeicon[1] == "right" ? "fm-button-icon-right": "fm-button-icon-left").append("<span class='ui-icon " + b.closeicon[2] + "'></span>");
                        a.isFunction(b.beforeShowForm) && b.beforeShowForm(a("#" + o));
                        viewModal("#" + r.themodal, {
                            gbox: "#gbox_" + l,
                            jqm: b.jqModal,
                            modal: b.modal
                        });
                        a(".fm-button:not(.ui-state-disabled)", "#" + n + "_2").hover(function() {
                            a(this).addClass("ui-state-hover")
                        },
                        function() {
                            a(this).removeClass("ui-state-hover")
                        });
                        f();
                        a("#cData", "#" + n + "_2").click(function() {
                            hideModal("#" + r.themodal, {
                                gb: "#gbox_" + l,
                                jqm: b.jqModal,
                                onClose: b.onClose
                            });
                            return false
                        });
                        a("#nData", "#" + n + "_2").click(function() {
                            a("#FormError", "#" + n).hide();
                            var A = h();
                            A[0] = parseInt(A[0], 10);
                            if (A[0] != -1 && A[1][A[0] + 1]) {
                                a.isFunction(b.onclickPgButtons) && b.onclickPgButtons("next", a("#" + o), A[1][A[0]]);
                                c(A[1][A[0] + 1], k);
                                a(k).jqGrid("setSelection", A[1][A[0] + 1]);
                                a.isFunction(b.afterclickPgButtons) && b.afterclickPgButtons("next", a("#" + o), A[1][A[0] + 1]);
                                g(A[0] + 1, A[1].length - 1)
                            }
                            f();
                            return false
                        });
                        a("#pData", "#" + n + "_2").click(function() {
                            a("#FormError", "#" + n).hide();
                            var A = h();
                            if (A[0] != -1 && A[1][A[0] - 1]) {
                                a.isFunction(b.onclickPgButtons) && b.onclickPgButtons("prev", a("#" + o), A[1][A[0]]);
                                c(A[1][A[0] - 1], k);
                                a(k).jqGrid("setSelection", A[1][A[0] - 1]);
                                a.isFunction(b.afterclickPgButtons) && b.afterclickPgButtons("prev", a("#" + o), A[1][A[0] - 1]);
                                g(A[0] - 1, A[1].length - 1)
                            }
                            f();
                            return false
                        })
                    }
                    m = h();
                    g(m[0], m[1].length - 1)
                }
            })
        },
        delGridRow: function(d, b) {
            e = b = a.extend({
                top: 0,
                left: 0,
                width: 240,
                height: "auto",
                dataheight: "auto",
                modal: false,
                drag: true,
                resize: true,
                url: "",
                mtype: "POST",
                reloadAfterSubmit: true,
                beforeShowForm: null,
                afterShowForm: null,
                beforeSubmit: null,
                onclickSubmit: null,
                afterSubmit: null,
                jqModal: true,
                closeOnEscape: false,
                delData: {},
                delicon: [],
                cancelicon: [],
                onClose: null,
                ajaxDelOptions: {},
                processing: false,
                serializeDelData: null,
                useDataProxy: false
            },
            a.jgrid.del, b || {});
            return this.each(function() {
                var f = this;
                if (f.grid) if (d) {
                    var g = typeof b.beforeShowForm === "function" ? true: false,
                    h = typeof b.afterShowForm === "function" ? true: false,
                    j = f.p.id,
                    c = {},
                    k = "DelTbl_" + j,
                    l,
                    o,
                    n,
                    r,
                    q = {
                        themodal: "delmod" + j,
                        modalhead: "delhd" + j,
                        modalcontent: "delcnt" + j,
                        scrollelm: k
                    };
                    if (jQuery.isArray(d)) d = d.join();
                    if (a("#" + q.themodal).html() != null) {
                        a("#DelData>td", "#" + k).text(d);
                        a("#DelError", "#" + k).hide();
                        if (e.processing === true) {
                            e.processing = false;
                            a("#dData", "#" + k).removeClass("ui-state-active")
                        }
                        g && b.beforeShowForm(a("#" + k));
                        viewModal("#" + q.themodal, {
                            gbox: "#gbox_" + j,
                            jqm: b.jqModal,
                            jqM: false,
                            modal: b.modal
                        })
                    } else {
                        var t = isNaN(b.dataheight) ? b.dataheight: b.dataheight + "px";
                        t = "<div id='" + k + "' class='formdata' style='width:100%;overflow:auto;position:relative;height:" + t + ";'>";
                        t += "<table class='DelTable'><tbody>";
                        t += "<tr id='DelError' style='display:none'><td class='ui-state-error'></td></tr>";
                        t += "<tr id='DelData' style='display:none'><td >" + d + "</td></tr>";
                        t += '<tr><td class="delmsg" style="white-space:pre;">' + b.msg + "</td></tr><tr><td >&#160;</td></tr>";
                        t += "</tbody></table></div>";
                        t += "<table cellspacing='0' cellpadding='0' border='0' class='EditTable' id='" + k + "_2'><tbody><tr><td class='DataTD ui-widget-content'></td></tr><tr style='display:block;height:3px;'><td></td></tr><tr><td class='DelButton EditButton'>" + ("<a href='javascript:void(0)' id='dData' class='fm-button ui-state-default ui-corner-all'>" + b.bSubmit + "</a>") + "&#160;" + ("<a href='javascript:void(0)' id='eData' class='fm-button ui-state-default ui-corner-all'>" + b.bCancel + "</a>") + "</td></tr></tbody></table>";
                        b.gbox = "#gbox_" + j;
                        createModal(q, t, b, "#gview_" + f.p.id, a("#gview_" + f.p.id)[0]);
                        a(".fm-button", "#" + k + "_2").hover(function() {
                            a(this).addClass("ui-state-hover")
                        },
                        function() {
                            a(this).removeClass("ui-state-hover")
                        });
                        b.delicon = a.extend([true, "left", "ui-icon-scissors"], b.delicon);
                        b.cancelicon = a.extend([true, "left", "ui-icon-cancel"], b.cancelicon);
                        if (b.delicon[0] === true) a("#dData", "#" + k + "_2").addClass(b.delicon[1] == "right" ? "fm-button-icon-right": "fm-button-icon-left").append("<span class='ui-icon " + b.delicon[2] + "'></span>");
                        if (b.cancelicon[0] === true) a("#eData", "#" + k + "_2").addClass(b.cancelicon[1] == "right" ? "fm-button-icon-right": "fm-button-icon-left").append("<span class='ui-icon " + b.cancelicon[2] + "'></span>");
                        a("#dData", "#" + k + "_2").click(function() {
                            var m = [true, ""];
                            c = {};
                            var p = a("#DelData>td", "#" + k).text();
                            if (typeof b.onclickSubmit === "function") c = b.onclickSubmit(e, p) || {};
                            if (typeof b.beforeSubmit === "function") m = b.beforeSubmit(p);
                            if (m[0] && !e.processing) {
                                e.processing = true;
                                a(this).addClass("ui-state-active");
                                n = f.p.prmNames;
                                l = a.extend({},
                                e.delData, c);
                                r = n.oper;
                                l[r] = n.deloper;
                                o = n.id;
                                l[o] = p;
                                var v = a.extend({
                                    url: e.url ? e.url: a(f).jqGrid("getGridParam", "editurl"),
                                    type: b.mtype,
                                    data: a.isFunction(b.serializeDelData) ? b.serializeDelData(l) : l,
                                    complete: function(y, B) {
                                        if (B != "success") {
                                            m[0] = false;
                                            m[1] = a.isFunction(e.errorTextFormat) ? e.errorTextFormat(y) : B + " Status: '" + y.statusText + "'. Error code: " + y.status
                                        } else if (typeof e.afterSubmit === "function") m = e.afterSubmit(y, l);
                                        if (m[0] === false) {
                                            a("#DelError>td", "#" + k).html(m[1]);
                                            a("#DelError", "#" + k).show()
                                        } else {
                                            if (e.reloadAfterSubmit && f.p.datatype != "local") a(f).trigger("reloadGrid");
                                            else {
                                                B = [];
                                                B = p.split(",");
                                                if (f.p.treeGrid === true) try {
                                                    a(f).jqGrid("delTreeNode", B[0])
                                                } catch(C) {} else for (var I = 0; I < B.length; I++) a(f).jqGrid("delRowData", B[I]);
                                                f.p.selrow = null;
                                                f.p.selarrrow = []
                                            }
                                            a.isFunction(e.afterComplete) && setTimeout(function() {
                                                e.afterComplete(y, p)
                                            },
                                            500)
                                        }
                                        e.processing = false;
                                        a("#dData", "#" + k + "_2").removeClass("ui-state-active");
                                        m[0] && hideModal("#" + q.themodal, {
                                            gb: "#gbox_" + j,
                                            jqm: b.jqModal,
                                            onClose: e.onClose
                                        })
                                    },
                                    error: function(y, B, C) {
                                        a("#DelError>td", "#" + k).html(B + " : " + C);
                                        a("#DelError", "#" + k).show();
                                        e.processing = false;
                                        a("#dData", "#" + k + "_2").removeClass("ui-state-active")
                                    }
                                },
                                a.jgrid.ajaxOptions, b.ajaxDelOptions);
                                if (!v.url && !e.useDataProxy) if (a.isFunction(f.p.dataProxy)) e.useDataProxy = true;
                                else {
                                    m[0] = false;
                                    m[1] += " " + a.jgrid.errors.nourl
                                }
                                if (m[0]) e.useDataProxy ? f.p.dataProxy.call(f, v, "del_" + f.p.id) : a.ajax(v)
                            }
                            if (m[0] === false) {
                                a("#DelError>td", "#" + k).html(m[1]);
                                a("#DelError", "#" + k).show()
                            }
                            return false
                        });
                        a("#eData", "#" + k + "_2").click(function() {
                            hideModal("#" + q.themodal, {
                                gb: "#gbox_" + j,
                                jqm: b.jqModal,
                                onClose: e.onClose
                            });
                            return false
                        });
                        g && b.beforeShowForm(a("#" + k));
                        viewModal("#" + q.themodal, {
                            gbox: "#gbox_" + j,
                            jqm: b.jqModal,
                            modal: b.modal
                        })
                    }
                    h && b.afterShowForm(a("#" + k));
                    b.closeOnEscape === true && setTimeout(function() {
                        a(".ui-jqdialog-titlebar-close", "#" + q.modalhead).focus()
                    },
                    0)
                }
            })
        },
        navGrid: function(d, b, f, g, h, j, c) {
            b = a.extend({
                edit: true,
                editicon: "ui-icon-pencil",
                add: true,
                addicon: "ui-icon-plus",
                del: true,
                delicon: "ui-icon-trash",
                search: true,
                searchicon: "ui-icon-search",
                refresh: true,
                refreshicon: "ui-icon-refresh",
                refreshstate: "firstpage",
                view: false,
                viewicon: "ui-icon-document",
                position: "left",
                closeOnEscape: true,
                beforeRefresh: null,
                afterRefresh: null,
                cloneToTop: false
            },
            a.jgrid.nav, b || {});
            return this.each(function() {
                var k = {
                    themodal: "alertmod",
                    modalhead: "alerthd",
                    modalcontent: "alertcnt"
                },
                l = this,
                o,
                n,
                r;
                if (! (!l.grid || typeof d != "string")) {
                    if (a("#" + k.themodal).html() === null) {
                        if (typeof window.innerWidth != "undefined") {
                            o = window.innerWidth;
                            n = window.innerHeight
                        } else if (typeof document.documentElement != "undefined" && typeof document.documentElement.clientWidth != "undefined" && document.documentElement.clientWidth !== 0) {
                            o = document.documentElement.clientWidth;
                            n = document.documentElement.clientHeight
                        } else {
                            o = 1024;
                            n = 768
                        }
                        createModal(k, "<div>" + b.alerttext + "</div><span tabindex='0'><span tabindex='-1' id='jqg_alrt'></span></span>", {
                            gbox: "#gbox_" + l.p.id,
                            jqModal: true,
                            drag: true,
                            resize: true,
                            caption: b.alertcap,
                            top: n / 2 - 25,
                            left: o / 2 - 100,
                            width: 200,
                            height: "auto",
                            closeOnEscape: b.closeOnEscape
                        },
                        "", "", true)
                    }
                    o = 1;
                    if (b.cloneToTop && l.p.toppager) o = 2;
                    for (n = 0; n < o; n++) {
                        var q = a("<table cellspacing='0' cellpadding='0' border='0' class='ui-pg-table navtable' style='float:left;table-layout:auto;'><tbody><tr></tr></tbody></table>"),
                        t,
                        m;
                        if (n === 0) {
                            t = d;
                            m = l.p.id;
                            if (t == l.p.toppager) {
                                m += "_top";
                                o = 1
                            }
                        } else {
                            t = l.p.toppager;
                            m = l.p.id + "_top"
                        }
                        l.p.direction == "rtl" && a(q).attr("dir", "rtl").css("float", "right");
                        if (b.add) {
                            g = g || {};
                            r = a("<td class='ui-pg-button ui-corner-all'></td>");
                            a(r).append("<div class='ui-pg-div'><span class='ui-icon " + b.addicon + "'></span>" + b.addtext + "</div>");
                            a("tr", q).append(r);
                            a(r, q).attr({
                                title: b.addtitle || "",
                                id: g.id || "add_" + m
                            }).click(function() {
                                a(this).hasClass("ui-state-disabled") || (typeof b.addfunc == "function" ? b.addfunc() : a(l).jqGrid("editGridRow", "new", g));
                                return false
                            }).hover(function() {
                                a(this).hasClass("ui-state-disabled") || a(this).addClass("ui-state-hover")
                            },
                            function() {
                                a(this).removeClass("ui-state-hover")
                            });
                            r = null
                        }
                        if (b.edit) {
                            r = a("<td class='ui-pg-button ui-corner-all'></td>");
                            f = f || {};
                            a(r).append("<div class='ui-pg-div'><span class='ui-icon " + b.editicon + "'></span>" + b.edittext + "</div>");
                            a("tr", q).append(r);
                            a(r, q).attr({
                                title: b.edittitle || "",
                                id: f.id || "edit_" + m
                            }).click(function() {
                                if (!a(this).hasClass("ui-state-disabled")) {
                                    var p = l.p.selrow;
                                    if (p) typeof b.editfunc == "function" ? b.editfunc(p) : a(l).jqGrid("editGridRow", p, f);
                                    else {
                                        viewModal("#" + k.themodal, {
                                            gbox: "#gbox_" + l.p.id,
                                            jqm: true
                                        });
                                        a("#jqg_alrt").focus()
                                    }
                                }
                                return false
                            }).hover(function() {
                                a(this).hasClass("ui-state-disabled") || a(this).addClass("ui-state-hover")
                            },
                            function() {
                                a(this).removeClass("ui-state-hover")
                            });
                            r = null
                        }
                        if (b.view) {
                            r = a("<td class='ui-pg-button ui-corner-all'></td>");
                            c = c || {};
                            a(r).append("<div class='ui-pg-div'><span class='ui-icon " + b.viewicon + "'></span>" + b.viewtext + "</div>");
                            a("tr", q).append(r);
                            a(r, q).attr({
                                title: b.viewtitle || "",
                                id: c.id || "view_" + m
                            }).click(function() {
                                if (!a(this).hasClass("ui-state-disabled")) {
                                    var p = l.p.selrow;
                                    if (p) a(l).jqGrid("viewGridRow", p, c);
                                    else {
                                        viewModal("#" + k.themodal, {
                                            gbox: "#gbox_" + l.p.id,
                                            jqm: true
                                        });
                                        a("#jqg_alrt").focus()
                                    }
                                }
                                return false
                            }).hover(function() {
                                a(this).hasClass("ui-state-disabled") || a(this).addClass("ui-state-hover")
                            },
                            function() {
                                a(this).removeClass("ui-state-hover")
                            });
                            r = null
                        }
                        if (b.del) {
                            r = a("<td class='ui-pg-button ui-corner-all'></td>");
                            h = h || {};
                            a(r).append("<div class='ui-pg-div'><span class='ui-icon " + b.delicon + "'></span>" + b.deltext + "</div>");
                            a("tr", q).append(r);
                            a(r, q).attr({
                                title: b.deltitle || "",
                                id: h.id || "del_" + m
                            }).click(function() {
                                if (!a(this).hasClass("ui-state-disabled")) {
                                    var p;
                                    if (l.p.multiselect) {
                                        p = l.p.selarrrow;
                                        if (p.length === 0) p = null
                                    } else p = l.p.selrow;
                                    if (p)"function" == typeof b.delfunc ? b.delfunc(p) : a(l).jqGrid("delGridRow", p, h);
                                    else {
                                        viewModal("#" + k.themodal, {
                                            gbox: "#gbox_" + l.p.id,
                                            jqm: true
                                        });
                                        a("#jqg_alrt").focus()
                                    }
                                }
                                return false
                            }).hover(function() {
                                a(this).hasClass("ui-state-disabled") || a(this).addClass("ui-state-hover")
                            },
                            function() {
                                a(this).removeClass("ui-state-hover")
                            });
                            r = null
                        }
                        if (b.add || b.edit || b.del || b.view) a("tr", q).append("<td class='ui-pg-button ui-state-disabled' style='width:4px;'><span class='ui-separator'></span></td>");
                        if (b.search) {
                            r = a("<td class='ui-pg-button ui-corner-all'></td>");
                            j = j || {};
                            a(r).append("<div class='ui-pg-div'><span class='ui-icon " + b.searchicon + "'></span>" + b.searchtext + "</div>");
                            a("tr", q).append(r);
                            a(r, q).attr({
                                title: b.searchtitle || "",
                                id: j.id || "search_" + m
                            }).click(function() {
                                a(this).hasClass("ui-state-disabled") || a(l).jqGrid("searchGrid", j);
                                return false
                            }).hover(function() {
                                a(this).hasClass("ui-state-disabled") || a(this).addClass("ui-state-hover")
                            },
                            function() {
                                a(this).removeClass("ui-state-hover")
                            });
                            r = null
                        }
                        if (b.refresh) {
                            r = a("<td class='ui-pg-button ui-corner-all'></td>");
                            a(r).append("<div class='ui-pg-div'><span class='ui-icon " + b.refreshicon + "'></span>" + b.refreshtext + "</div>");
                            a("tr", q).append(r);
                            a(r, q).attr({
                                title: b.refreshtitle || "",
                                id: "refresh_" + m
                            }).click(function() {
                                if (!a(this).hasClass("ui-state-disabled")) {
                                    a.isFunction(b.beforeRefresh) && b.beforeRefresh();
                                    l.p.search = false;
                                    try {
                                        a("#fbox_" + l.p.id).searchFilter().reset({
                                            reload: false
                                        });
                                        a.isFunction(l.clearToolbar) && l.clearToolbar(false)
                                    } catch(p) {}
                                    switch (b.refreshstate) {
                                    case "firstpage":
                                        a(l).trigger("reloadGrid", [{
                                            page: 1
                                        }]);
                                        break;
                                    case "current":
                                        a(l).trigger("reloadGrid", [{
                                            current: true
                                        }]);
                                        break
                                    }
                                    a.isFunction(b.afterRefresh) && b.afterRefresh()
                                }
                                return false
                            }).hover(function() {
                                a(this).hasClass("ui-state-disabled") || a(this).addClass("ui-state-hover")
                            },
                            function() {
                                a(this).removeClass("ui-state-hover")
                            });
                            r = null
                        }
                        r = a(".ui-jqgrid").css("font-size") || "11px";
                        a("body").append("<div id='testpg2' class='ui-jqgrid ui-widget ui-widget-content' style='font-size:" + r + ";visibility:hidden;' ></div>");
                        r = a(q).clone().appendTo("#testpg2").width();
                        a("#testpg2").remove();
                        a(t + "_" + b.position, t).append(q);
                        if (l.p._nvtd) {
                            if (r > l.p._nvtd[0]) {
                                a(t + "_" + b.position, t).width(r);
                                l.p._nvtd[0] = r
                            }
                            l.p._nvtd[1] = r
                        }
                        q = r = r = null
                    }
                }
            })
        },
        navButtonAdd: function(d, b) {
            b = a.extend({
                caption: "newButton",
                title: "",
                buttonicon: "ui-icon-newwin",
                onClickButton: null,
                position: "last",
                cursor: "pointer"
            },
            b || {});
            return this.each(function() {
                if (this.grid) {
                    if (d.indexOf("#") !== 0) d = "#" + d;
                    var f = a(".navtable", d)[0],
                    g = this;
                    if (f) {
                        var h = a("<td></td>");
                        b.buttonicon.toString().toUpperCase() == "NONE" ? a(h).addClass("ui-pg-button ui-corner-all").append("<div class='ui-pg-div'>" + b.caption + "</div>") : a(h).addClass("ui-pg-button ui-corner-all").append("<div class='ui-pg-div'><span class='ui-icon " + b.buttonicon + "'></span>" + b.caption + "</div>");
                        b.id && a(h).attr("id", b.id);
                        if (b.position == "first") f.rows[0].cells.length === 0 ? a("tr", f).append(h) : a("tr td:eq(0)", f).before(h);
                        else a("tr", f).append(h);
                        a(h, f).attr("title", b.title || "").click(function(j) {
                            a(this).hasClass("ui-state-disabled") || a.isFunction(b.onClickButton) && b.onClickButton.call(g, j);
                            return false
                        }).hover(function() {
                            a(this).hasClass("ui-state-disabled") || a(this).addClass("ui-state-hover")
                        },
                        function() {
                            a(this).removeClass("ui-state-hover")
                        })
                    }
                }
            })
        },
        navSeparatorAdd: function(d, b) {
            b = a.extend({
                sepclass: "ui-separator",
                sepcontent: ""
            },
            b || {});
            return this.each(function() {
                if (this.grid) {
                    if (d.indexOf("#") !== 0) d = "#" + d;
                    var f = a(".navtable", d)[0];
                    if (f) {
                        var g = "<td class='ui-pg-button ui-state-disabled' style='width:4px;'><span class='" + b.sepclass + "'></span>" + b.sepcontent + "</td>";
                        a("tr", f).append(g)
                    }
                }
            })
        },
        GridToForm: function(d, b) {
            return this.each(function() {
                var f = this;
                if (f.grid) {
                    var g = a(f).jqGrid("getRowData", d);
                    if (g) for (var h in g) a("[name=" + h + "]", b).is("input:radio") || a("[name=" + h + "]", b).is("input:checkbox") ? a("[name=" + h + "]", b).each(function() {
                        a(this).val() == g[h] ? a(this).attr("checked", "checked") : a(this).attr("checked", "")
                    }) : a("[name=" + h + "]", b).val(g[h])
                }
            })
        },
        FormToGrid: function(d, b, f, g) {
            return this.each(function() {
                var h = this;
                if (h.grid) {
                    f || (f = "set");
                    g || (g = "first");
                    var j = a(b).serializeArray(),
                    c = {};
                    a.each(j,
                    function(k, l) {
                        c[l.name] = l.value
                    });
                    if (f == "add") a(h).jqGrid("addRowData", d, c, g);
                    else f == "set" && a(h).jqGrid("setRowData", d, c)
                }
            })
        }
    })
})(jQuery); (function(a) {
    a.jgrid.extend({
        groupingSetup: function() {
            return this.each(function() {
                var e = this,
                d = e.p.groupingView;
                if (d !== null && isObject(d)) if (d.groupField.length) {
                    for (var b = 0; b < d.groupField.length; b++) {
                        d.groupOrder[b] || (d.groupOrder[b] = "asc");
                        d.groupText[b] || (d.groupText[b] = "{0}");
                        if (typeof d.groupColumnShow[b] != "boolean") d.groupColumnShow[b] = true;
                        if (typeof d.groupSummary[b] != "boolean") d.groupSummary[b] = false;
                        d.groupColumnShow[b] === true ? a(e).jqGrid("showCol", d.groupField[b]) : a(e).jqGrid("hideCol", d.groupField[b]);
                        d.sortitems[b] = [];
                        d.sortnames[b] = [];
                        d.summaryval[b] = [];
                        if (d.groupSummary[b]) {
                            d.summary[b] = [];
                            for (var f = e.p.colModel,
                            g = 0,
                            h = f.length; g < h; g++) f[g].summaryType && d.summary[b].push({
                                nm: f[g].name,
                                st: f[g].summaryType,
                                v: ""
                            })
                        }
                    }
                    e.p.scroll = false;
                    e.p.rownumbers = false;
                    e.p.subGrid = false;
                    e.p.treeGrid = false;
                    e.p.gridview = true
                } else e.p.grouping = false;
                else e.p.grouping = false
            })
        },
        groupingPrepare: function(e, d, b, f) {
            this.each(function() {
                var g = d[0] ? d[0].split(" ").join("") : "",
                h = this.p.groupingView,
                j = this;
                if (b.hasOwnProperty(g)) b[g].push(e);
                else {
                    b[g] = [];
                    b[g].push(e);
                    h.sortitems[0].push(g);
                    h.sortnames[0].push(a.trim(d[0]));
                    h.summaryval[0][g] = a.extend(true, {},
                    h.summary[0])
                }
                h.groupSummary[0] && a.each(h.summaryval[0][g],
                function() {
                    this.v = a.isFunction(this.st) ? this.st.call(j, this.v, this.nm, f) : a(j).jqGrid("groupingCalculations." + this.st, this.v, this.nm, f)
                })
            });
            return b
        },
        groupingToggle: function(e) {
            this.each(function() {
                var d = e.lastIndexOf("_"),
                b = e.substring(0, d + 1);
                d = parseInt(e.substring(d + 1)) + 1;
                var f = this.p.groupingView.minusicon,
                g = this.p.groupingView.plusicon;
                if (a("#" + e + " span").hasClass(f)) {
                    a("#" + e).nextUntil("#" + b + String(d)).hide();
                    a("#" + e + " span").removeClass(f).addClass(g)
                } else {
                    a("#" + e).nextUntil("#" + b + String(d)).show();
                    a("#" + e + " span").removeClass(g).addClass(f)
                }
            });
            return false
        },
        groupingRender: function(e, d) {
            return this.each(function() {
                var b = this,
                f = b.p.groupingView,
                g = "",
                h = "",
                j, c = "";
                if (!f.groupDataSorted) {
                    f.sortitems[0].sort();
                    f.sortnames[0].sort();
                    f.groupOrder[0].toLowerCase() == "desc" && f.sortitems[0].reverse()
                }
                c = f.groupCollapse ? f.plusicon: f.minusicon;
                c += " tree-wrap-" + b.p.direction;
                a.each(f.sortitems[0],
                function(k, l) {
                    j = b.p.id + "ghead_" + k;
                    h = "<span style='cursor:pointer;' class='ui-icon " + c + "' onclick=\"jQuery('#" + b.p.id + "').jqGrid('groupingToggle','" + j + "');return false;\"></span>";
                    g += '<tr id="' + j + '" role="row" class= "ui-widget-content jqgroup ui-row-' + b.p.direction + '"><td colspan="' + d + '">' + h + a.jgrid.format(f.groupText[0], f.sortnames[0][k], e[l].length) + "</td></tr>";
                    for (k = 0; k < e[l].length; k++) g += e[l][k].join("");
                    if (f.groupSummary[0]) {
                        k = "";
                        if (f.groupCollapse) k = ' style="display:none;"';
                        g += "<tr" + k + ' role="row" class="ui-widget-content jqfoot ui-row-' + b.p.direction + '">';
                        k = f.summaryval[0][l];
                        for (var o = b.p.colModel,
                        n, r = e[l].length, q = 0; q < d; q++) {
                            var t = "<td " + b.formatCol(q, 1, "") + ">&#160;</td>",
                            m = "{0}";
                            a.each(k,
                            function() {
                                if (this.nm == o[q].name) {
                                    if (o[q].summaryTpl) m = o[q].summaryTpl;
                                    if (this.st == "avg") if (this.v && r > 0) this.v /= r;
                                    try {
                                        n = b.formatter("", this.v, q, this)
                                    } catch(p) {
                                        n = this.v
                                    }
                                    t = "<td " + b.formatCol(q, 1, "") + ">" + a.jgrid.format(m, n) + "</td>";
                                    return false
                                }
                            });
                            g += t
                        }
                        g += "</tr>"
                    }
                });
                a("#" + b.p.id + " tbody:first").append(g);
                g = null;
                f.sortitems[0] = [];
                f.sortnames[0] = [];
                f.summaryval[0] = []
            })
        },
        groupingGroupBy: function(e, d) {
            return this.each(function() {
                var b = this;
                if (typeof e == "string") e = [e];
                var f = b.p.groupingView;
                b.p.grouping = true;
                for (var g = 0; g < f.groupField.length; g++) f.groupColumnShow[g] || a(b).jqGrid("showCol", f.groupField[g]);
                b.p.groupingView = a.extend(b.p.groupingView, d || {});
                f.groupField = e;
                a(b).trigger("reloadGrid")
            })
        },
        groupingRemove: function(e) {
            return this.each(function() {
                var d = this;
                if (typeof e == "undefined") e = true;
                d.p.grouping = false;
                e === true ? a("tr.jqgroup, tr.jqfoot", "#" + d.p.id + " tbody:first").remove() : a(d).trigger("reloadGrid")
            })
        },
        groupingCalculations: {
            sum: function(e, d, b) {
                return parseFloat(e || 0) + parseFloat(b[d] || 0)
            },
            min: function(e, d, b) {
                if (e === "") return parseFloat(b[d] || 0);
                return Math.min(parseFloat(e), parseFloat(b[d] || 0))
            },
            max: function(e, d, b) {
                if (e === "") return parseFloat(b[d] || 0);
                return Math.max(parseFloat(e), parseFloat(b[d] || 0))
            },
            count: function(e, d, b) {
                if (e === "") e = 0;
                return b.hasOwnProperty(d) ? e + 1 : 0
            },
            avg: function(e, d, b) {
                return parseFloat(e || 0) + parseFloat(b[d] || 0)
            }
        }
    })
})(jQuery); (function(a) {
    a.jgrid.extend({
        jqGridImport: function(e) {
            e = a.extend({
                imptype: "xml",
                impstring: "",
                impurl: "",
                mtype: "GET",
                impData: {},
                xmlGrid: {
                    config: "roots>grid",
                    data: "roots>rows"
                },
                jsonGrid: {
                    config: "grid",
                    data: "data"
                },
                ajaxOptions: {}
            },
            e || {});
            return this.each(function() {
                var d = this,
                b = function(h, j) {
                    var c = a(j.xmlGrid.config, h)[0];
                    j = a(j.xmlGrid.data, h)[0];
                    var k;
                    if (xmlJsonClass.xml2json && a.jgrid.parse) {
                        c = xmlJsonClass.xml2json(c, " ");
                        c = a.jgrid.parse(c);
                        for (var l in c) if (c.hasOwnProperty(l)) k = c[l];
                        if (j) {
                            l = c.grid.datatype;
                            c.grid.datatype = "xmlstring";
                            c.grid.datastr = h;
                            a(d).jqGrid(k).jqGrid("setGridParam", {
                                datatype: l
                            })
                        } else a(d).jqGrid(k)
                    } else alert("xml2json or parse are not present")
                },
                f = function(h, j) {
                    if (h && typeof h == "string") {
                        var c = a.jgrid.parse(h);
                        h = c[j.jsonGrid.config];
                        if (j = c[j.jsonGrid.data]) {
                            c = h.datatype;
                            h.datatype = "jsonstring";
                            h.datastr = j;
                            a(d).jqGrid(h).jqGrid("setGridParam", {
                                datatype: c
                            })
                        } else a(d).jqGrid(h)
                    }
                };
                switch (e.imptype) {
                case "xml":
                    a.ajax(a.extend({
                        url:
                        e.impurl,
                        type: e.mtype,
                        data: e.impData,
                        dataType: "xml",
                        complete: function(h, j) {
                            if (j == "success") {
                                b(h.responseXML, e);
                                a.isFunction(e.importComplete) && e.importComplete(h)
                            }
                        }
                    },
                    e.ajaxOptions));
                    break;
                case "xmlstring":
                    if (e.impstring && typeof e.impstring == "string") {
                        var g = a.jgrid.stringToDoc(e.impstring);
                        if (g) {
                            b(g, e);
                            a.isFunction(e.importComplete) && e.importComplete(g);
                            e.impstring = null
                        }
                        g = null
                    }
                    break;
                case "json":
                    a.ajax(a.extend({
                        url:
                        e.impurl,
                        type: e.mtype,
                        data: e.impData,
                        dataType: "json",
                        complete: function(h, j) {
                            if (j == "success") {
                                f(h.responseText, e);
                                a.isFunction(e.importComplete) && e.importComplete(h)
                            }
                        }
                    },
                    e.ajaxOptions));
                    break;
                case "jsonstring":
                    if (e.impstring && typeof e.impstring == "string") {
                        f(e.impstring, e);
                        a.isFunction(e.importComplete) && e.importComplete(e.impstring);
                        e.impstring = null
                    }
                    break
                }
            })
        },
        jqGridExport: function(e) {
            e = a.extend({
                exptype: "xmlstring",
                root: "grid",
                ident: "\t"
            },
            e || {});
            var d = null;
            this.each(function() {
                if (this.grid) {
                    var b = a.extend({},
                    a(this).jqGrid("getGridParam"));
                    if (b.rownumbers) {
                        b.colNames.splice(0, 1);
                        b.colModel.splice(0, 1)
                    }
                    if (b.multiselect) {
                        b.colNames.splice(0, 1);
                        b.colModel.splice(0, 1)
                    }
                    if (b.subGrid) {
                        b.colNames.splice(0, 1);
                        b.colModel.splice(0, 1)
                    }
                    b.knv = null;
                    if (b.treeGrid) for (var f in b.treeReader) if (b.treeReader.hasOwnProperty(f)) {
                        b.colNames.splice(b.colNames.length - 1);
                        b.colModel.splice(b.colModel.length - 1)
                    }
                    switch (e.exptype) {
                    case "xmlstring":
                        d = "<" + e.root + ">" + xmlJsonClass.json2xml(b, e.ident) + "</" + e.root + ">";
                        break;
                    case "jsonstring":
                        d = "{" + xmlJsonClass.toJson(b, e.root, e.ident) + "}";
                        if (b.postData.filters !== undefined) {
                            d = d.replace(/filters":"/, 'filters":');
                            d = d.replace(/}]}"/, "}]}")
                        }
                        break
                    }
                }
            });
            return d
        },
        excelExport: function(e) {
            e = a.extend({
                exptype: "remote",
                url: null,
                oper: "oper",
                tag: "excel",
                exportOptions: {}
            },
            e || {});
            return this.each(function() {
                if (this.grid) {
                    var d;
                    if (e.exptype == "remote") {
                        d = a.extend({},
                        this.p.postData);
                        d[e.oper] = e.tag;
                        d = jQuery.param(d);
                        d = e.url.indexOf("?") != -1 ? e.url + "&" + d: e.url + "?" + d;
                        window.location = d
                    }
                }
            })
        }
    })
})(jQuery); (function(a) {
    a.jgrid.extend({
        editRow: function(e, d, b, f, g, h, j, c, k) {
            return this.each(function() {
                var l = this,
                o, n, r = 0,
                q = null,
                t = {},
                m, p;
                if (l.grid) {
                    m = a(l).jqGrid("getInd", e, true);
                    if (m !== false) if ((a(m).attr("editable") || "0") == "0" && !a(m).hasClass("not-editable-row")) {
                        p = l.p.colModel;
                        a("td", m).each(function(v) {
                            o = p[v].name;
                            var y = l.p.treeGrid === true && o == l.p.ExpandColumn;
                            if (y) n = a("span:first", this).html();
                            else try {
                                n = a.unformat(this, {
                                    rowId: e,
                                    colModel: p[v]
                                },
                                v)
                            } catch(B) {
                                n = a(this).html()
                            }
                            if (o != "cb" && o != "subgrid" && o != "rn") {
                                if (l.p.autoencode) n = a.jgrid.htmlDecode(n);
                                t[o] = n;
                                if (p[v].editable === true) {
                                    if (q === null) q = v;
                                    y ? a("span:first", this).html("") : a(this).html("");
                                    var C = a.extend({},
                                    p[v].editoptions || {},
                                    {
                                        id: e + "_" + o,
                                        name: o
                                    });
                                    if (!p[v].edittype) p[v].edittype = "text";
                                    C = createEl(p[v].edittype, C, n, true, a.extend({},
                                    a.jgrid.ajaxOptions, l.p.ajaxSelectOptions || {}));
                                    a(C).addClass("editable");
                                    y ? a("span:first", this).append(C) : a(this).append(C);
                                    p[v].edittype == "select" && p[v].editoptions.multiple === true && a.browser.msie && a(C).width(a(C).width());
                                    r++
                                }
                            }
                        });
                        if (r > 0) {
                            t.id = e;
                            l.p.savedRow.push(t);
                            a(m).attr("editable", "1");
                            a("td:eq(" + q + ") input", m).focus();
                            d === true && a(m).bind("keydown",
                            function(v) {
                                v.keyCode === 27 && a(l).jqGrid("restoreRow", e, k);
                                if (v.keyCode === 13) {
                                    if (v.target.tagName == "TEXTAREA") return true;
                                    a(l).jqGrid("saveRow", e, f, g, h, j, c, k);
                                    return false
                                }
                                v.stopPropagation()
                            });
                            a.isFunction(b) && b.call(l, e)
                        }
                    }
                }
            })
        },
        saveRow: function(e, d, b, f, g, h, j) {
            return this.each(function() {
                var c = this,
                k, l = {},
                o = {},
                n, r, q, t;
                if (c.grid) {
                    t = a(c).jqGrid("getInd", e, true);
                    if (t !== false) {
                        n = a(t).attr("editable");
                        b = b ? b: c.p.editurl;
                        if (n === "1") {
                            var m;
                            a("td", t).each(function(B) {
                                m = c.p.colModel[B];
                                k = m.name;
                                if (k != "cb" && k != "subgrid" && m.editable === true && k != "rn") {
                                    switch (m.edittype) {
                                    case "checkbox":
                                        var C = ["Yes", "No"];
                                        if (m.editoptions) C = m.editoptions.value.split(":");
                                        l[k] = a("input", this).attr("checked") ? C[0] : C[1];
                                        break;
                                    case "text":
                                    case "password":
                                    case "textarea":
                                    case "button":
                                        l[k] = a("input, textarea", this).val();
                                        break;
                                    case "select":
                                        if (m.editoptions.multiple) {
                                            C = a("select", this);
                                            var I = [];
                                            l[k] = a(C).val();
                                            l[k] = l[k] ? l[k].join(",") : "";
                                            a("select > option:selected", this).each(function(A, G) {
                                                I[A] = a(G).text()
                                            });
                                            o[k] = I.join(",")
                                        } else {
                                            l[k] = a("select>option:selected", this).val();
                                            o[k] = a("select>option:selected", this).text()
                                        }
                                        if (m.formatter && m.formatter == "select") o = {};
                                        break;
                                    case "custom":
                                        try {
                                            if (m.editoptions && a.isFunction(m.editoptions.custom_value)) {
                                                l[k] = m.editoptions.custom_value.call(c, a(".customelement", this), "get");
                                                if (l[k] === undefined) throw "e2";
                                            } else throw "e1";
                                        } catch(w) {
                                            w == "e1" && info_dialog(jQuery.jgrid.errors.errcap, "function 'custom_value' " + a.jgrid.edit.msg.nodefined, jQuery.jgrid.edit.bClose);
                                            w == "e2" ? info_dialog(jQuery.jgrid.errors.errcap, "function 'custom_value' " + a.jgrid.edit.msg.novalue, jQuery.jgrid.edit.bClose) : info_dialog(jQuery.jgrid.errors.errcap, w.message, jQuery.jgrid.edit.bClose)
                                        }
                                        break
                                    }
                                    q = checkValues(l[k], B, c);
                                    if (q[0] === false) {
                                        q[1] = l[k] + " " + q[1];
                                        return false
                                    }
                                    if (c.p.autoencode) l[k] = a.jgrid.htmlEncode(l[k])
                                }
                            });
                            if (q[0] === false) try {
                                var p = findPos(a("#" + a.jgrid.jqID(e), c.grid.bDiv)[0]);
                                info_dialog(a.jgrid.errors.errcap, q[1], a.jgrid.edit.bClose, {
                                    left: p[0],
                                    top: p[1]
                                })
                            } catch(v) {
                                alert(q[1])
                            } else {
                                if (l) {
                                    var y;
                                    p = c.p.prmNames;
                                    y = p.oper;
                                    n = p.id;
                                    l[y] = p.editoper;
                                    l[n] = e;
                                    if (typeof c.p.inlineData == "undefined") c.p.inlineData = {};
                                    if (typeof f == "undefined") f = {};
                                    l = a.extend({},
                                    l, c.p.inlineData, f)
                                }
                                if (b == "clientArray") {
                                    l = a.extend({},
                                    l, o);
                                    c.p.autoencode && a.each(l,
                                    function(B, C) {
                                        l[B] = a.jgrid.htmlDecode(C)
                                    });
                                    n = a(c).jqGrid("setRowData", e, l);
                                    a(t).attr("editable", "0");
                                    for (p = 0; p < c.p.savedRow.length; p++) if (c.p.savedRow[p].id == e) {
                                        r = p;
                                        break
                                    }
                                    r >= 0 && c.p.savedRow.splice(r, 1);
                                    a.isFunction(g) && g.call(c, e, n)
                                } else {
                                    a("#lui_" + c.p.id).show();
                                    a.ajax(a.extend({
                                        url: b,
                                        data: a.isFunction(c.p.serializeRowData) ? c.p.serializeRowData.call(c, l) : l,
                                        type: "POST",
                                        complete: function(B, C) {
                                            a("#lui_" + c.p.id).hide();
                                            if (C === "success") if ((a.isFunction(d) ? d.call(c, B) : true) === true) {
                                                c.p.autoencode && a.each(l,
                                                function(I, w) {
                                                    l[I] = a.jgrid.htmlDecode(w)
                                                });
                                                l = a.extend({},
                                                l, o);
                                                a(c).jqGrid("setRowData", e, l);
                                                a(t).attr("editable", "0");
                                                for (C = 0; C < c.p.savedRow.length; C++) if (c.p.savedRow[C].id == e) {
                                                    r = C;
                                                    break
                                                }
                                                r >= 0 && c.p.savedRow.splice(r, 1);
                                                a.isFunction(g) && g.call(c, e, B)
                                            } else a(c).jqGrid("restoreRow", e, j)
                                        },
                                        error: function(B, C) {
                                            a("#lui_" + c.p.id).hide();
                                            a.isFunction(h) ? h.call(c, e, B, C) : alert("Error Row: " + e + " Result: " + B.status + ":" + B.statusText + " Status: " + C);
                                            a(c).jqGrid("restoreRow", e, j)
                                        }
                                    },
                                    a.jgrid.ajaxOptions, c.p.ajaxRowOptions || {}))
                                }
                                a(t).unbind("keydown")
                            }
                        }
                    }
                }
            })
        },
        restoreRow: function(e, d) {
            return this.each(function() {
                var b = this,
                f, g, h = {};
                if (b.grid) {
                    g = a(b).jqGrid("getInd", e, true);
                    if (g !== false) {
                        for (var j = 0; j < b.p.savedRow.length; j++) if (b.p.savedRow[j].id == e) {
                            f = j;
                            break
                        }
                        if (f >= 0) {
                            if (a.isFunction(a.fn.datepicker)) try {
                                a("input.hasDatepicker", "#" + a.jgrid.jqID(g.id)).datepicker("hide")
                            } catch(c) {}
                            a.each(b.p.colModel,
                            function() {
                                if (this.editable === true && this.name in b.p.savedRow[f]) h[this.name] = b.p.savedRow[f][this.name]
                            });
                            a(b).jqGrid("setRowData", e, h);
                            a(g).attr("editable", "0").unbind("keydown");
                            b.p.savedRow.splice(f, 1)
                        }
                        a.isFunction(d) && d.call(b, e)
                    }
                }
            })
        }
    })
})(jQuery); (function(a) {
    if (a.browser.msie && a.browser.version == 8) a.expr[":"].hidden = function(d) {
        return d.offsetWidth === 0 || d.offsetHeight === 0 || d.style.display == "none"
    };
    a.jgrid._multiselect = false;
    if (a.ui) if (a.ui.multiselect) {
        if (a.ui.multiselect.prototype._setSelected) {
            var e = a.ui.multiselect.prototype._setSelected;
            a.ui.multiselect.prototype._setSelected = function(d, b) {
                d = e.call(this, d, b);
                if (b && this.selectedList) {
                    var f = this.element;
                    this.selectedList.find("li").each(function() {
                        a(this).data("optionLink") && a(this).data("optionLink").remove().appendTo(f)
                    })
                }
                return d
            }
        }
        if (a.ui.multiselect.prototype.destroy) a.ui.multiselect.prototype.destroy = function() {
            this.element.show();
            this.container.remove();
            a.Widget === undefined ? a.widget.prototype.destroy.apply(this, arguments) : a.Widget.prototype.destroy.apply(this, arguments)
        };
        a.jgrid._multiselect = true
    }
    a.jgrid.extend({
        sortableColumns: function(d) {
            return this.each(function() {
                function b() {
                    f.p.disableClick = true
                }
                var f = this,
                g = {
                    tolerance: "pointer",
                    axis: "x",
                    scrollSensitivity: "1",
                    items: ">th:not(:has(#jqgh_cb,#jqgh_rn,#jqgh_subgrid),:hidden)",
                    placeholder: {
                        element: function(j) {
                            return a(document.createElement(j[0].nodeName)).addClass(j[0].className + " ui-sortable-placeholder ui-state-highlight").removeClass("ui-sortable-helper")[0]
                        },
                        update: function(j, c) {
                            c.height(j.currentItem.innerHeight() - parseInt(j.currentItem.css("paddingTop") || 0, 10) - parseInt(j.currentItem.css("paddingBottom") || 0, 10));
                            c.width(j.currentItem.innerWidth() - parseInt(j.currentItem.css("paddingLeft") || 0, 10) - parseInt(j.currentItem.css("paddingRight") || 0, 10))
                        }
                    },
                    update: function(j, c) {
                        j = a(c.item).parent();
                        j = a(">th", j);
                        var k = {};
                        a.each(f.p.colModel,
                        function(o) {
                            k[this.name] = o
                        });
                        var l = [];
                        j.each(function() {
                            var o = a(">div", this).get(0).id.replace(/^jqgh_/, "");
                            o in k && l.push(k[o])
                        });
                        a(f).jqGrid("remapColumns", l, true, true);
                        a.isFunction(f.p.sortable.update) && f.p.sortable.update(l);
                        setTimeout(function() {
                            f.p.disableClick = false
                        },
                        50)
                    }
                };
                if (f.p.sortable.options) a.extend(g, f.p.sortable.options);
                else if (a.isFunction(f.p.sortable)) f.p.sortable = {
                    update: f.p.sortable
                };
                if (g.start) {
                    var h = g.start;
                    g.start = function(j, c) {
                        b();
                        h.call(this, j, c)
                    }
                } else g.start = b;
                if (f.p.sortable.exclude) g.items += ":not(" + f.p.sortable.exclude + ")";
                d.sortable(g).data("sortable").floating = true
            })
        },
        columnChooser: function(d) {
            function b(r, q, t) {
                if (q >= 0) {
                    var m = r.slice(),
                    p = m.splice(q, Math.max(r.length - q, q));
                    if (q > r.length) q = r.length;
                    m[q] = t;
                    return m.concat(p)
                }
            }
            function f(r, q) {
                if (r) if (typeof r == "string") a.fn[r] && a.fn[r].apply(q, a.makeArray(arguments).slice(2));
                else a.isFunction(r) && r.apply(q, a.makeArray(arguments).slice(2))
            }
            var g = this;
            if (!a("#colchooser_" + g[0].p.id).length) {
                var h = a('<div id="colchooser_' + g[0].p.id + '" style="position:relative;overflow:hidden"><div><select multiple="multiple"></select></div></div>'),
                j = a("select", h);
                d = a.extend({
                    width: 420,
                    height: 240,
                    classname: null,
                    done: function(r) {
                        r && g.jqGrid("remapColumns", r, true)
                    },
                    msel: "multiselect",
                    dlog: "dialog",
                    dlog_opts: function(r) {
                        var q = {};
                        q[r.bSubmit] = function() {
                            r.apply_perm();
                            r.cleanup(false)
                        };
                        q[r.bCancel] = function() {
                            r.cleanup(true)
                        };
                        return {
                            buttons: q,
                            close: function() {
                                r.cleanup(true)
                            },
                            modal: false,
                            resizable: false,
                            width: r.width + 20
                        }
                    },
                    apply_perm: function() {
                        a("option", j).each(function() {
                            this.selected ? g.jqGrid("showCol", c[this.value].name) : g.jqGrid("hideCol", c[this.value].name)
                        });
                        var r = [];
                        a("option[selected]", j).each(function() {
                            r.push(parseInt(this.value, 10))
                        });
                        a.each(r,
                        function() {
                            delete l[c[parseInt(this, 10)].name]
                        });
                        a.each(l,
                        function() {
                            var q = parseInt(this, 10);
                            r = b(r, q, q)
                        });
                        d.done && d.done.call(g, r)
                    },
                    cleanup: function(r) {
                        f(d.dlog, h, "destroy");
                        f(d.msel, j, "destroy");
                        h.remove();
                        r && d.done && d.done.call(g)
                    },
                    msel_opts: {}
                },
                a.jgrid.col, d || {});
                if (a.ui) if (a.ui.multiselect) if (d.msel == "multiselect") {
                    if (!a.jgrid._multiselect) {
                        alert("Multiselect plugin loaded after jqGrid. Please load the plugin before the jqGrid!");
                        return
                    }
                    d.msel_opts = a.extend(a.ui.multiselect.defaults, d.msel_opts)
                }
                d.caption && h.attr("title", d.caption);
                if (d.classname) {
                    h.addClass(d.classname);
                    j.addClass(d.classname)
                }
                if (d.width) {
                    a(">div", h).css({
                        width: d.width,
                        margin: "0 auto"
                    });
                    j.css("width", d.width)
                }
                if (d.height) {
                    a(">div", h).css("height", d.height);
                    j.css("height", d.height - 10)
                }
                var c = g.jqGrid("getGridParam", "colModel"),
                k = g.jqGrid("getGridParam", "colNames"),
                l = {},
                o = [];
                j.empty();
                a.each(c,
                function(r) {
                    l[this.name] = r;
                    if (this.hidedlg) this.hidden || o.push(r);
                    else j.append("<option value='" + r + "' " + (this.hidden ? "": "selected='selected'") + ">" + k[r] + "</option>")
                });
                var n = a.isFunction(d.dlog_opts) ? d.dlog_opts.call(g, d) : d.dlog_opts;
                f(d.dlog, h, n);
                n = a.isFunction(d.msel_opts) ? d.msel_opts.call(g, d) : d.msel_opts;
                f(d.msel, j, n)
            }
        },
        sortableRows: function(d) {
            return this.each(function() {
                var b = this;
                if (b.grid) if (!b.p.treeGrid) if (a.fn.sortable) {
                    d = a.extend({
                        cursor: "move",
                        axis: "y",
                        items: ".jqgrow"
                    },
                    d || {});
                    if (d.start && a.isFunction(d.start)) {
                        d._start_ = d.start;
                        delete d.start
                    } else d._start_ = false;
                    if (d.update && a.isFunction(d.update)) {
                        d._update_ = d.update;
                        delete d.update
                    } else d._update_ = false;
                    d.start = function(f, g) {
                        a(g.item).css("border-width", "0px");
                        a("td", g.item).each(function(c) {
                            this.style.width = b.grid.cols[c].style.width
                        });
                        if (b.p.subGrid) {
                            var h = a(g.item).attr("id");
                            try {
                                a(b).jqGrid("collapseSubGridRow", h)
                            } catch(j) {}
                        }
                        d._start_ && d._start_.apply(this, [f, g])
                    };
                    d.update = function(f, g) {
                        a(g.item).css("border-width", "");
                        b.p.rownumbers === true && a("td.jqgrid-rownum", b.rows).each(function(h) {
                            a(this).html(h + 1)
                        });
                        d._update_ && d._update_.apply(this, [f, g])
                    };
                    a("tbody:first", b).sortable(d);
                    a("tbody:first", b).disableSelection()
                }
            })
        },
        gridDnD: function(d) {
            return this.each(function() {
                function b() {
                    var h = a.data(f, "dnd");
                    a("tr.jqgrow:not(.ui-draggable)", f).draggable(a.isFunction(h.drag) ? h.drag.call(a(f), h) : h.drag)
                }
                var f = this;
                if (f.grid) if (!f.p.treeGrid) if (a.fn.draggable && a.fn.droppable) {
                    a("#jqgrid_dnd").html() === null && a("body").append("<table id='jqgrid_dnd' class='ui-jqgrid-dnd'></table>");
                    if (typeof d == "string" && d == "updateDnD" && f.p.jqgdnd === true) b();
                    else {
                        d = a.extend({
                            drag: function(h) {
                                return a.extend({
                                    start: function(j, c) {
                                        if (f.p.subGrid) {
                                            var k = a(c.helper).attr("id");
                                            try {
                                                a(f).jqGrid("collapseSubGridRow", k)
                                            } catch(l) {}
                                        }
                                        for (k = 0; k < a.data(f, "dnd").connectWith.length; k++) a(a.data(f, "dnd").connectWith[k]).jqGrid("getGridParam", "reccount") == "0" && a(a.data(f, "dnd").connectWith[k]).jqGrid("addRowData", "jqg_empty_row", {});
                                        c.helper.addClass("ui-state-highlight");
                                        a("td", c.helper).each(function(o) {
                                            this.style.width = f.grid.headers[o].width + "px"
                                        });
                                        h.onstart && a.isFunction(h.onstart) && h.onstart.call(a(f), j, c)
                                    },
                                    stop: function(j, c) {
                                        if (c.helper.dropped) {
                                            var k = a(c.helper).attr("id");
                                            a(f).jqGrid("delRowData", k)
                                        }
                                        for (k = 0; k < a.data(f, "dnd").connectWith.length; k++) a(a.data(f, "dnd").connectWith[k]).jqGrid("delRowData", "jqg_empty_row");
                                        h.onstop && a.isFunction(h.onstop) && h.onstop.call(a(f), j, c)
                                    }
                                },
                                h.drag_opts || {})
                            },
                            drop: function(h) {
                                return a.extend({
                                    accept: function(j) {
                                        var c = a(j).closest("table.ui-jqgrid-btable");
                                        if (a.data(c[0], "dnd") !== undefined) {
                                            j = a.data(c[0], "dnd").connectWith;
                                            return a.inArray("#" + this.id, j) != -1 ? true: false
                                        }
                                        return j
                                    },
                                    drop: function(j, c) {
                                        var k = a(c.draggable).attr("id");
                                        k = a("#" + f.id).jqGrid("getRowData", k);
                                        if (!h.dropbyname) {
                                            var l = 0,
                                            o = {},
                                            n, r = a("#" + this.id).jqGrid("getGridParam", "colModel");
                                            try {
                                                for (var q in k) {
                                                    if (k.hasOwnProperty(q) && r[l]) {
                                                        n = r[l].name;
                                                        o[n] = k[q]
                                                    }
                                                    l++
                                                }
                                                k = o
                                            } catch(t) {}
                                        }
                                        c.helper.dropped = true;
                                        if (h.beforedrop && a.isFunction(h.beforedrop)) {
                                            n = h.beforedrop.call(this, j, c, k, a("#" + f.id), a(this));
                                            if (typeof n != "undefined" && n !== null && typeof n == "object") k = n
                                        }
                                        if (c.helper.dropped) {
                                            var m;
                                            if (h.autoid) if (a.isFunction(h.autoid)) m = h.autoid.call(this, k);
                                            else {
                                                m = Math.ceil(Math.random() * 1E3);
                                                m = h.autoidprefix + m
                                            }
                                            a("#" + this.id).jqGrid("addRowData", m, k, h.droppos)
                                        }
                                        h.ondrop && a.isFunction(h.ondrop) && h.ondrop.call(this, j, c, k)
                                    }
                                },
                                h.drop_opts || {})
                            },
                            onstart: null,
                            onstop: null,
                            beforedrop: null,
                            ondrop: null,
                            drop_opts: {
                                activeClass: "ui-state-active",
                                hoverClass: "ui-state-hover"
                            },
                            drag_opts: {
                                revert: "invalid",
                                helper: "clone",
                                cursor: "move",
                                appendTo: "#jqgrid_dnd",
                                zIndex: 5E3
                            },
                            dropbyname: false,
                            droppos: "first",
                            autoid: true,
                            autoidprefix: "dnd_"
                        },
                        d || {});
                        if (d.connectWith) {
                            d.connectWith = d.connectWith.split(",");
                            d.connectWith = a.map(d.connectWith,
                            function(h) {
                                return a.trim(h)
                            });
                            a.data(f, "dnd", d);
                            f.p.reccount != "0" && !f.p.jqgdnd && b();
                            f.p.jqgdnd = true;
                            for (var g = 0; g < d.connectWith.length; g++) a(d.connectWith[g]).droppable(a.isFunction(d.drop) ? d.drop.call(a(f), d) : d.drop)
                        }
                    }
                }
            })
        },
        gridResize: function(d) {
            return this.each(function() {
                var b = this;
                if (b.grid && a.fn.resizable) {
                    d = a.extend({},
                    d || {});
                    if (d.alsoResize) {
                        d._alsoResize_ = d.alsoResize;
                        delete d.alsoResize
                    } else d._alsoResize_ = false;
                    if (d.stop && a.isFunction(d.stop)) {
                        d._stop_ = d.stop;
                        delete d.stop
                    } else d._stop_ = false;
                    d.stop = function(f, g) {
                        a(b).jqGrid("setGridParam", {
                            height: a("#gview_" + b.p.id + " .ui-jqgrid-bdiv").height()
                        });
                        a(b).jqGrid("setGridWidth", g.size.width, d.shrinkToFit);
                        d._stop_ && d._stop_.call(b, f, g)
                    };
                    d.alsoResize = d._alsoResize_ ? eval("(" + ("{'#gview_" + b.p.id + " .ui-jqgrid-bdiv':true,'" + d._alsoResize_ + "':true}") + ")") : a(".ui-jqgrid-bdiv", "#gview_" + b.p.id);
                    delete d._alsoResize_;
                    a("#gbox_" + b.p.id).resizable(d)
                }
            })
        }
    })
})(jQuery); (function(a) {
    a.jgrid.extend({
        getPostData: function() {
            var e = this[0];
            if (e.grid) return e.p.postData
        },
        setPostData: function(e) {
            var d = this[0];
            if (d.grid) if (typeof e === "object") d.p.postData = e;
            else alert("Error: cannot add a non-object postData value. postData unchanged.")
        },
        appendPostData: function(e) {
            var d = this[0];
            if (d.grid) typeof e === "object" ? a.extend(d.p.postData, e) : alert("Error: cannot append a non-object postData value. postData unchanged.")
        },
        setPostDataItem: function(e, d) {
            var b = this[0];
            if (b.grid) b.p.postData[e] = d
        },
        getPostDataItem: function(e) {
            var d = this[0];
            if (d.grid) return d.p.postData[e]
        },
        removePostDataItem: function(e) {
            var d = this[0];
            d.grid && delete d.p.postData[e]
        },
        getUserData: function() {
            var e = this[0];
            if (e.grid) return e.p.userData
        },
        getUserDataItem: function(e) {
            var d = this[0];
            if (d.grid) return d.p.userData[e]
        }
    })
})(jQuery); (function(a) {
    a.jgrid.extend({
        setColumns: function(e) {
            e = a.extend({
                top: 0,
                left: 0,
                width: 200,
                height: "auto",
                dataheight: "auto",
                modal: false,
                drag: true,
                beforeShowForm: null,
                afterShowForm: null,
                afterSubmitForm: null,
                closeOnEscape: true,
                ShrinkToFit: false,
                jqModal: false,
                saveicon: [true, "left", "ui-icon-disk"],
                closeicon: [true, "left", "ui-icon-close"],
                onClose: null,
                colnameview: true,
                closeAfterSubmit: true,
                updateAfterCheck: false,
                recreateForm: false
            },
            a.jgrid.col, e || {});
            return this.each(function() {
                var d = this;
                if (d.grid) {
                    var b = typeof e.beforeShowForm === "function" ? true: false,
                    f = typeof e.afterShowForm === "function" ? true: false,
                    g = typeof e.afterSubmitForm === "function" ? true: false,
                    h = d.p.id,
                    j = "ColTbl_" + h,
                    c = {
                        themodal: "colmod" + h,
                        modalhead: "colhd" + h,
                        modalcontent: "colcnt" + h,
                        scrollelm: j
                    };
                    e.recreateForm === true && a("#" + c.themodal).html() != null && a("#" + c.themodal).remove();
                    if (a("#" + c.themodal).html() != null) {
                        b && e.beforeShowForm(a("#" + j));
                        viewModal("#" + c.themodal, {
                            gbox: "#gbox_" + h,
                            jqm: e.jqModal,
                            jqM: false,
                            modal: e.modal
                        })
                    } else {
                        var k = isNaN(e.dataheight) ? e.dataheight: e.dataheight + "px";
                        k = "<div id='" + j + "' class='formdata' style='width:100%;overflow:auto;position:relative;height:" + k + ";'>";
                        k += "<table class='ColTable' cellspacing='1' cellpading='2' border='0'><tbody>";
                        for (i = 0; i < this.p.colNames.length; i++) d.p.colModel[i].hidedlg || (k += "<tr><td style='white-space: pre;'><input type='checkbox' style='margin-right:5px;' id='col_" + this.p.colModel[i].name + "' class='cbox' value='T' " + (this.p.colModel[i].hidden === false ? "checked": "") + "/><label for='col_" + this.p.colModel[i].name + "'>" + this.p.colNames[i] + (e.colnameview ? " (" + this.p.colModel[i].name + ")": "") + "</label></td></tr>");
                        k += "</tbody></table></div>";
                        k += "<table border='0' class='EditTable' id='" + j + "_2'><tbody><tr style='display:block;height:3px;'><td></td></tr><tr><td class='DataTD ui-widget-content'></td></tr><tr><td class='ColButton EditButton'>" + (!e.updateAfterCheck ? "<a href='javascript:void(0)' id='dData' class='fm-button ui-state-default ui-corner-all'>" + e.bSubmit + "</a>": "") + "&#160;" + ("<a href='javascript:void(0)' id='eData' class='fm-button ui-state-default ui-corner-all'>" + e.bCancel + "</a>") + "</td></tr></tbody></table>";
                        e.gbox = "#gbox_" + h;
                        createModal(c, k, e, "#gview_" + d.p.id, a("#gview_" + d.p.id)[0]);
                        if (e.saveicon[0] == true) a("#dData", "#" + j + "_2").addClass(e.saveicon[1] == "right" ? "fm-button-icon-right": "fm-button-icon-left").append("<span class='ui-icon " + e.saveicon[2] + "'></span>");
                        if (e.closeicon[0] == true) a("#eData", "#" + j + "_2").addClass(e.closeicon[1] == "right" ? "fm-button-icon-right": "fm-button-icon-left").append("<span class='ui-icon " + e.closeicon[2] + "'></span>");
                        e.updateAfterCheck ? a(":input", "#" + j).click(function() {
                            var l = this.id.substr(4);
                            if (l) {
                                this.checked ? a(d).jqGrid("showCol", l) : a(d).jqGrid("hideCol", l);
                                e.ShrinkToFit === true && a(d).jqGrid("setGridWidth", d.grid.width - 0.0010, true)
                            }
                            return this
                        }) : a("#dData", "#" + j + "_2").click(function() {
                            for (i = 0; i < d.p.colModel.length; i++) if (!d.p.colModel[i].hidedlg) {
                                var l = d.p.colModel[i].name.replace(".", "\\.");
                                if (a("#col_" + l, "#" + j).attr("checked")) {
                                    a(d).jqGrid("showCol", d.p.colModel[i].name);
                                    a("#col_" + l, "#" + j).attr("defaultChecked", true)
                                } else {
                                    a(d).jqGrid("hideCol", d.p.colModel[i].name);
                                    a("#col_" + l, "#" + j).attr("defaultChecked", "")
                                }
                            }
                            e.ShrinkToFit === true && a(d).jqGrid("setGridWidth", d.grid.width - 0.0010, true);
                            e.closeAfterSubmit && hideModal("#" + c.themodal, {
                                gb: "#gbox_" + h,
                                jqm: e.jqModal,
                                onClose: e.onClose
                            });
                            g && e.afterSubmitForm(a("#" + j));
                            return false
                        });
                        a("#eData", "#" + j + "_2").click(function() {
                            hideModal("#" + c.themodal, {
                                gb: "#gbox_" + h,
                                jqm: e.jqModal,
                                onClose: e.onClose
                            });
                            return false
                        });
                        a("#dData, #eData", "#" + j + "_2").hover(function() {
                            a(this).addClass("ui-state-hover")
                        },
                        function() {
                            a(this).removeClass("ui-state-hover")
                        });
                        b && e.beforeShowForm(a("#" + j));
                        viewModal("#" + c.themodal, {
                            gbox: "#gbox_" + h,
                            jqm: e.jqModal,
                            jqM: true,
                            modal: e.modal
                        })
                    }
                    f && e.afterShowForm(a("#" + j))
                }
            })
        }
    })
})(jQuery); (function(a) {
    a.jgrid.extend({
        setSubGrid: function() {
            return this.each(function() {
                var e = this;
                e.p.colNames.unshift("");
                e.p.colModel.unshift({
                    name: "subgrid",
                    width: a.browser.safari ? e.p.subGridWidth + e.p.cellLayout: e.p.subGridWidth,
                    sortable: false,
                    resizable: false,
                    hidedlg: true,
                    search: false,
                    fixed: true
                });
                e = e.p.subGridModel;
                if (e[0]) {
                    e[0].align = a.extend([], e[0].align || []);
                    for (var d = 0; d < e[0].name.length; d++) e[0].align[d] = e[0].align[d] || "left"
                }
            })
        },
        addSubGridCell: function(e, d) {
            var b = "",
            f, g;
            this.each(function() {
                b = this.formatCol(e, d);
                f = this.p.gridview;
                g = this.p.id
            });
            return f === false ? '<td role="grid" aria-describedby="' + g + '_subgrid" class="ui-sgcollapsed sgcollapsed" ' + b + "><a href='javascript:void(0);'><span class='ui-icon ui-icon-plus'></span></a></td>": '<td role="grid" aria-describedby="' + g + '_subgrid" ' + b + "></td>"
        },
        addSubGrid: function(e, d) {
            return this.each(function() {
                var b = this;
                if (b.grid) {
                    var f, g, h, j, c, k, l;
                    a("td:eq(" + d + ")", e).click(function() {
                        if (a(this).hasClass("sgcollapsed")) {
                            h = b.p.id;
                            f = a(this).parent();
                            j = d >= 1 ? "<td colspan='" + d + "'>&#160;</td>": "";
                            g = a(f).attr("id");
                            l = true;
                            if (a.isFunction(b.p.subGridBeforeExpand)) l = b.p.subGridBeforeExpand(h + "_" + g, g);
                            if (l === false) return false;
                            c = 0;
                            a.each(b.p.colModel,
                            function() {
                                if (this.hidden === true || this.name == "rn" || this.name == "cb") c++
                            });
                            k = "<tr role='row' class='ui-subgrid'>" + j + "<td class='ui-widget-content subgrid-cell'><span class='ui-icon ui-icon-carat-1-sw'/></td><td colspan='" + parseInt(b.p.colNames.length - 1 - c, 10) + "' class='ui-widget-content subgrid-data'><div id=" + h + "_" + g + " class='tablediv'>";
                            a(this).parent().after(k + "</div></td></tr>");
                            a.isFunction(b.p.subGridRowExpanded) ? b.p.subGridRowExpanded(h + "_" + g, g) : o(f);
                            a(this).html("<a href='javascript:void(0);'><span class='ui-icon ui-icon-minus'></span></a>").removeClass("sgcollapsed").addClass("sgexpanded")
                        } else if (a(this).hasClass("sgexpanded")) {
                            l = true;
                            if (a.isFunction(b.p.subGridRowColapsed)) {
                                f = a(this).parent();
                                g = a(f).attr("id");
                                l = b.p.subGridRowColapsed(h + "_" + g, g)
                            }
                            if (l === false) return false;
                            a(this).parent().next().remove(".ui-subgrid");
                            a(this).html("<a href='javascript:void(0);'><span class='ui-icon ui-icon-plus'></span></a>").removeClass("sgexpanded").addClass("sgcollapsed")
                        }
                        return false
                    });
                    var o = function(t) {
                        var m, p, v, y;
                        m = a(t).attr("id");
                        p = {
                            nd_: (new Date).getTime()
                        };
                        p[b.p.prmNames.subgridid] = m;
                        if (!b.p.subGridModel[0]) return false;
                        if (b.p.subGridModel[0].params) for (y = 0; y < b.p.subGridModel[0].params.length; y++) for (v = 0; v < b.p.colModel.length; v++) if (b.p.colModel[v].name == b.p.subGridModel[0].params[y]) p[b.p.colModel[v].name] = a("td:eq(" + v + ")", t).text().replace(/\&#160\;/ig, "");
                        if (!b.grid.hDiv.loading) {
                            b.grid.hDiv.loading = true;
                            a("#load_" + b.p.id).show();
                            if (!b.p.subgridtype) b.p.subgridtype = b.p.datatype;
                            if (a.isFunction(b.p.subgridtype)) b.p.subgridtype(p);
                            else b.p.subgridtype = b.p.subgridtype.toLowerCase();
                            switch (b.p.subgridtype) {
                            case "xml":
                            case "json":
                                a.ajax(a.extend({
                                    type:
                                    b.p.mtype,
                                    url: b.p.subGridUrl,
                                    dataType: b.p.subgridtype,
                                    data: a.isFunction(b.p.serializeSubGridData) ? b.p.serializeSubGridData(p) : p,
                                    complete: function(B) {
                                        b.p.subgridtype == "xml" ? r(B.responseXML, m) : q(a.jgrid.parse(B.responseText), m)
                                    }
                                },
                                a.jgrid.ajaxOptions, b.p.ajaxSubgridOptions || {}));
                                break
                            }
                        }
                        return false
                    },
                    n = function(t, m, p) {
                        m = a("<td align='" + b.p.subGridModel[0].align[p] + "'></td>").html(m);
                        a(t).append(m)
                    },
                    r = function(t, m) {
                        var p, v, y, B = a("<table cellspacing='0' cellpadding='0' border='0'><tbody></tbody></table>"),
                        C = a("<tr></tr>");
                        for (v = 0; v < b.p.subGridModel[0].name.length; v++) {
                            p = a("<th class='ui-state-default ui-th-subgrid ui-th-column ui-th-" + b.p.direction + "'></th>");
                            a(p).html(b.p.subGridModel[0].name[v]);
                            a(p).width(b.p.subGridModel[0].width[v]);
                            a(C).append(p)
                        }
                        a(B).append(C);
                        if (t) {
                            y = b.p.xmlReader.subgrid;
                            a(y.root + " " + y.row, t).each(function() {
                                C = a("<tr class='ui-widget-content ui-subtblcell'></tr>");
                                if (y.repeatitems === true) a(y.cell, this).each(function(w) {
                                    n(C, a(this).text() || "&#160;", w)
                                });
                                else {
                                    var I = b.p.subGridModel[0].mapping || b.p.subGridModel[0].name;
                                    if (I) for (v = 0; v < I.length; v++) n(C, a(I[v], this).text() || "&#160;", v)
                                }
                                a(B).append(C)
                            })
                        }
                        t = a("table:first", b.grid.bDiv).attr("id") + "_";
                        a("#" + t + m).append(B);
                        b.grid.hDiv.loading = false;
                        a("#load_" + b.p.id).hide();
                        return false
                    },
                    q = function(t, m) {
                        var p, v, y, B, C = a("<table cellspacing='0' cellpadding='0' border='0'><tbody></tbody></table>"),
                        I = a("<tr></tr>");
                        for (v = 0; v < b.p.subGridModel[0].name.length; v++) {
                            p = a("<th class='ui-state-default ui-th-subgrid ui-th-column ui-th-" + b.p.direction + "'></th>");
                            a(p).html(b.p.subGridModel[0].name[v]);
                            a(p).width(b.p.subGridModel[0].width[v]);
                            a(I).append(p)
                        }
                        a(C).append(I);
                        if (t) {
                            p = b.p.jsonReader.subgrid;
                            t = t[p.root];
                            if (typeof t !== "undefined") for (v = 0; v < t.length; v++) {
                                y = t[v];
                                I = a("<tr class='ui-widget-content ui-subtblcell'></tr>");
                                if (p.repeatitems === true) {
                                    if (p.cell) y = y[p.cell];
                                    for (B = 0; B < y.length; B++) n(I, y[B] || "&#160;", B)
                                } else {
                                    var w = b.p.subGridModel[0].mapping || b.p.subGridModel[0].name;
                                    if (w.length) for (B = 0; B < w.length; B++) n(I, y[w[B]] || "&#160;", B)
                                }
                                a(C).append(I)
                            }
                        }
                        v = a("table:first", b.grid.bDiv).attr("id") + "_";
                        a("#" + v + m).append(C);
                        b.grid.hDiv.loading = false;
                        a("#load_" + b.p.id).hide();
                        return false
                    };
                    b.subGridXml = function(t, m) {
                        r(t, m)
                    };
                    b.subGridJson = function(t, m) {
                        q(t, m)
                    }
                }
            })
        },
        expandSubGridRow: function(e) {
            return this.each(function() {
                var d = this;
                if (d.grid || e) if (d.p.subGrid === true) if (d = a(this).jqGrid("getInd", e, true))(d = a("td.sgcollapsed", d)[0]) && a(d).trigger("click")
            })
        },
        collapseSubGridRow: function(e) {
            return this.each(function() {
                var d = this;
                if (d.grid || e) if (d.p.subGrid === true) if (d = a(this).jqGrid("getInd", e, true))(d = a("td.sgexpanded", d)[0]) && a(d).trigger("click")
            })
        },
        toggleSubGridRow: function(e) {
            return this.each(function() {
                var d = this;
                if (d.grid || e) if (d.p.subGrid === true) if (d = a(this).jqGrid("getInd", e, true)) {
                    var b = a("td.sgcollapsed", d)[0];
                    if (b) a(b).trigger("click");
                    else(b = a("td.sgexpanded", d)[0]) && a(b).trigger("click")
                }
            })
        }
    })
})(jQuery);
function tableToGrid(a, e) {
    jQuery(a).each(function() {
        if (!this.grid) {
            jQuery(this).width("99%");
            var d = jQuery(this).width(),
            b = jQuery("input[type=checkbox]:first", jQuery(this)),
            f = jQuery("input[type=radio]:first", jQuery(this)),
            g = b.length > 0,
            h = !g && f.length > 0,
            j = g || h;
            b = b.attr("name") || f.attr("name");
            var c = [],
            k = [];
            jQuery("th", jQuery(this)).each(function() {
                if (c.length === 0 && j) {
                    c.push({
                        name: "__selection__",
                        index: "__selection__",
                        width: 0,
                        hidden: true
                    });
                    k.push("__selection__")
                } else {
                    c.push({
                        name: jQuery(this).attr("id") || jQuery.trim(jQuery.jgrid.stripHtml(jQuery(this).html())).split(" ").join("_"),
                        index: jQuery(this).attr("id") || jQuery.trim(jQuery.jgrid.stripHtml(jQuery(this).html())).split(" ").join("_"),
                        width: jQuery(this).width() || 150
                    });
                    k.push(jQuery(this).html())
                }
            });
            var l = [],
            o = [],
            n = [];
            jQuery("tbody > tr", jQuery(this)).each(function() {
                var r = {},
                q = 0;
                jQuery("td", jQuery(this)).each(function() {
                    if (q === 0 && j) {
                        var t = jQuery("input", jQuery(this)),
                        m = t.attr("value");
                        o.push(m || l.length);
                        t.attr("checked") && n.push(m);
                        r[c[q].name] = t.attr("value")
                    } else r[c[q].name] = jQuery(this).html();
                    q++
                });
                q > 0 && l.push(r)
            });
            jQuery(this).empty();
            jQuery(this).addClass("scroll");
            jQuery(this).jqGrid(jQuery.extend({
                datatype: "local",
                width: d,
                colNames: k,
                colModel: c,
                multiselect: g
            },
            e || {}));
            for (d = 0; d < l.length; d++) {
                g = null;
                if (o.length > 0) if ((g = o[d]) && g.replace) g = encodeURIComponent(g).replace(/[.\-%]/g, "_");
                if (g === null) g = d + 1;
                jQuery(this).jqGrid("addRowData", g, l[d])
            }
            for (d = 0; d < n.length; d++) jQuery(this).jqGrid("setSelection", n[d])
        }
    })
} (function(a) {
    a.jgrid.extend({
        setTreeNode: function(e, d) {
            return this.each(function() {
                var b = this;
                if (b.grid && b.p.treeGrid) {
                    var f = b.p.expColInd,
                    g = b.p.treeReader.expanded_field,
                    h = b.p.treeReader.leaf_field,
                    j = b.p.treeReader.level_field;
                    d.level = e[j];
                    if (b.p.treeGridModel == "nested") {
                        var c = e[b.p.treeReader.left_field],
                        k = e[b.p.treeReader.right_field];
                        e[h] || (e[h] = parseInt(k, 10) === parseInt(c, 10) + 1 ? "true": "false")
                    }
                    k = parseInt(e[j], 10);
                    if (b.p.tree_root_level === 0) {
                        c = k + 1;
                        k = k
                    } else {
                        c = k;
                        k = k - 1
                    }
                    c = "<div class='tree-wrap tree-wrap-" + b.p.direction + "' style='width:" + c * 18 + "px;'>";
                    c += "<div style='" + (b.p.direction == "rtl" ? "right:": "left:") + k * 18 + "px;' class='ui-icon ";
                    if (e[h] == "true" || e[h] === true) {
                        c += b.p.treeIcons.leaf + " tree-leaf'";
                        e[h] = true;
                        e[g] = false
                    } else {
                        if (e[g] == "true" || e[g] === true) {
                            c += b.p.treeIcons.minus + " tree-minus treeclick'";
                            e[g] = true
                        } else {
                            c += b.p.treeIcons.plus + " tree-plus treeclick'";
                            e[g] = false
                        }
                        e[h] = false
                    }
                    c += "</div></div>";
                    if (!b.p.loadonce) {
                        e[b.p.localReader.id] = d.id;
                        b.p.data.push(e);
                        b.p._index[d.id] = b.p.data.length - 1
                    }
                    if (parseInt(e[j], 10) !== parseInt(b.p.tree_root_level, 10)) a(b).jqGrid("isVisibleNode", e) || a(d).css("display", "none");
                    a("td:eq(" + f + ")", d).wrapInner("<span></span>").prepend(c);
                    a(".treeclick", d).bind("click",
                    function(l) {
                        l = a(l.target || l.srcElement, b.rows).closest("tr.jqgrow")[0].id;
                        l = b.p._index[l];
                        var o = b.p.treeReader.expanded_field;
                        if (!b.p.data[l][b.p.treeReader.leaf_field]) if (b.p.data[l][o]) {
                            a(b).jqGrid("collapseRow", b.p.data[l]);
                            a(b).jqGrid("collapseNode", b.p.data[l])
                        } else {
                            a(b).jqGrid("expandRow", b.p.data[l]);
                            a(b).jqGrid("expandNode", b.p.data[l])
                        }
                        return false
                    });
                    b.p.ExpandColClick === true && a("span", d).css("cursor", "pointer").bind("click",
                    function(l) {
                        l = a(l.target || l.srcElement, b.rows).closest("tr.jqgrow")[0].id;
                        var o = b.p._index[l],
                        n = b.p.treeReader.expanded_field;
                        if (!b.p.data[o][b.p.treeReader.leaf_field]) if (b.p.data[o][n]) {
                            a(b).jqGrid("collapseRow", b.p.data[o]);
                            a(b).jqGrid("collapseNode", b.p.data[o])
                        } else {
                            a(b).jqGrid("expandRow", b.p.data[o]);
                            a(b).jqGrid("expandNode", b.p.data[o])
                        }
                        a(b).jqGrid("setSelection", l);
                        return false
                    })
                }
            })
        },
        setTreeGrid: function() {
            return this.each(function() {
                var e = this,
                d = 0;
                if (e.p.treeGrid) {
                    e.p.treedatatype || a.extend(e.p, {
                        treedatatype: e.p.datatype
                    });
                    e.p.subGrid = false;
                    e.p.altRows = false;
                    e.p.pgbuttons = false;
                    e.p.pginput = false;
                    e.p.multiselect = false;
                    e.p.rowList = [];
                    e.p.treeIcons = a.extend({
                        plus: "ui-icon-triangle-1-" + (e.p.direction == "rtl" ? "w": "e"),
                        minus: "ui-icon-triangle-1-s",
                        leaf: "ui-icon-radio-off"
                    },
                    e.p.treeIcons || {});
                    if (e.p.treeGridModel == "nested") e.p.treeReader = a.extend({
                        level_field: "level",
                        left_field: "lft",
                        right_field: "rgt",
                        leaf_field: "isLeaf",
                        expanded_field: "expanded"
                    },
                    e.p.treeReader);
                    else if (e.p.treeGridModel == "adjacency") e.p.treeReader = a.extend({
                        level_field: "level",
                        parent_id_field: "parent",
                        leaf_field: "isLeaf",
                        expanded_field: "expanded"
                    },
                    e.p.treeReader);
                    for (var b in e.p.colModel) if (e.p.colModel.hasOwnProperty(b)) {
                        if (e.p.colModel[b].name == e.p.ExpandColumn) {
                            e.p.expColInd = d;
                            break
                        }
                        d++
                    }
                    if (!e.p.expColInd) e.p.expColInd = 0;
                    a.each(e.p.treeReader,
                    function(f, g) {
                        if (g) {
                            e.p.colNames.push(g);
                            e.p.colModel.push({
                                name: g,
                                width: 1,
                                hidden: true,
                                sortable: false,
                                resizable: false,
                                hidedlg: true,
                                editable: true,
                                search: false
                            })
                        }
                    })
                }
            })
        },
        expandRow: function(e) {
            this.each(function() {
                var d = this;
                if (d.grid && d.p.treeGrid) {
                    var b = a(d).jqGrid("getNodeChildren", e),
                    f = d.p.treeReader.expanded_field;
                    a(b).each(function() {
                        var g = a.jgrid.getAccessor(this, d.p.localReader.id);
                        a("#" + g, d.grid.bDiv).css("display", "");
                        this[f] && a(d).jqGrid("expandRow", this)
                    })
                }
            })
        },
        collapseRow: function(e) {
            this.each(function() {
                var d = this;
                if (d.grid && d.p.treeGrid) {
                    var b = a(d).jqGrid("getNodeChildren", e),
                    f = d.p.treeReader.expanded_field;
                    a(b).each(function() {
                        var g = a.jgrid.getAccessor(this, d.p.localReader.id);
                        a("#" + g, d.grid.bDiv).css("display", "none");
                        this[f] && a(d).jqGrid("collapseRow", this)
                    })
                }
            })
        },
        getRootNodes: function() {
            var e = [];
            this.each(function() {
                var d = this;
                if (d.grid && d.p.treeGrid) switch (d.p.treeGridModel) {
                case "nested":
                    var b = d.p.treeReader.level_field;
                    a(d.p.data).each(function() {
                        parseInt(this[b], 10) === parseInt(d.p.tree_root_level, 10) && e.push(this)
                    });
                    break;
                case "adjacency":
                    var f = d.p.treeReader.parent_id_field;
                    a(d.p.data).each(function() {
                        if (this[f] === null || String(this[f]).toLowerCase() == "null") e.push(this)
                    });
                    break
                }
            });
            return e
        },
        getNodeDepth: function(e) {
            var d = null;
            this.each(function() {
                if (this.grid && this.p.treeGrid) {
                    var b = this;
                    switch (b.p.treeGridModel) {
                    case "nested":
                        d = parseInt(e[b.p.treeReader.level_field], 10) - parseInt(b.p.tree_root_level, 10);
                        break;
                    case "adjacency":
                        d = a(b).jqGrid("getNodeAncestors", e).length;
                        break
                    }
                }
            });
            return d
        },
        getNodeParent: function(e) {
            var d = null;
            this.each(function() {
                var b = this;
                if (b.grid && b.p.treeGrid) switch (b.p.treeGridModel) {
                case "nested":
                    var f = b.p.treeReader.left_field,
                    g = b.p.treeReader.right_field,
                    h = b.p.treeReader.level_field,
                    j = parseInt(e[f], 10),
                    c = parseInt(e[g], 10),
                    k = parseInt(e[h], 10);
                    a(this.p.data).each(function() {
                        if (parseInt(this[h], 10) === k - 1 && parseInt(this[f], 10) < j && parseInt(this[g], 10) > c) {
                            d = this;
                            return false
                        }
                    });
                    break;
                case "adjacency":
                    var l = b.p.treeReader.parent_id_field,
                    o = b.p.localReader.id;
                    a(this.p.data).each(function() {
                        if (this[o] == e[l]) {
                            d = this;
                            return false
                        }
                    });
                    break
                }
            });
            return d
        },
        getNodeChildren: function(e) {
            var d = [];
            this.each(function() {
                var b = this;
                if (b.grid && b.p.treeGrid) switch (b.p.treeGridModel) {
                case "nested":
                    var f = b.p.treeReader.left_field,
                    g = b.p.treeReader.right_field,
                    h = b.p.treeReader.level_field,
                    j = parseInt(e[f], 10),
                    c = parseInt(e[g], 10),
                    k = parseInt(e[h], 10);
                    a(this.p.data).each(function() {
                        parseInt(this[h], 10) === k + 1 && parseInt(this[f], 10) > j && parseInt(this[g], 10) < c && d.push(this)
                    });
                    break;
                case "adjacency":
                    var l = b.p.treeReader.parent_id_field,
                    o = b.p.localReader.id;
                    a(this.p.data).each(function() {
                        this[l] == e[o] && d.push(this)
                    });
                    break
                }
            });
            return d
        },
        getFullTreeNode: function(e) {
            var d = [];
            this.each(function() {
                var b = this,
                f;
                if (b.grid && b.p.treeGrid) switch (b.p.treeGridModel) {
                case "nested":
                    var g = b.p.treeReader.left_field,
                    h = b.p.treeReader.right_field,
                    j = b.p.treeReader.level_field,
                    c = parseInt(e[g], 10),
                    k = parseInt(e[h], 10),
                    l = parseInt(e[j], 10);
                    a(this.p.data).each(function() {
                        parseInt(this[j], 10) >= l && parseInt(this[g], 10) >= c && parseInt(this[g], 10) <= k && d.push(this)
                    });
                    break;
                case "adjacency":
                    d.push(e);
                    var o = b.p.treeReader.parent_id_field,
                    n = b.p.localReader.id;
                    a(this.p.data).each(function(r) {
                        f = d.length;
                        for (r = 0; r < f; r++) if (d[r][n] == this[o]) {
                            d.push(this);
                            break
                        }
                    });
                    break
                }
            });
            return d
        },
        getNodeAncestors: function(e) {
            var d = [];
            this.each(function() {
                if (this.grid && this.p.treeGrid) for (var b = a(this).jqGrid("getNodeParent", e); b;) {
                    d.push(b);
                    b = a(this).jqGrid("getNodeParent", b)
                }
            });
            return d
        },
        isVisibleNode: function(e) {
            var d = true;
            this.each(function() {
                var b = this;
                if (b.grid && b.p.treeGrid) {
                    var f = a(b).jqGrid("getNodeAncestors", e),
                    g = b.p.treeReader.expanded_field;
                    a(f).each(function() {
                        d = d && this[g];
                        if (!d) return false
                    })
                }
            });
            return d
        },
        isNodeLoaded: function(e) {
            var d;
            this.each(function() {
                var b = this;
                if (b.grid && b.p.treeGrid) {
                    var f = b.p.treeReader.leaf_field;
                    d = e.loaded !== undefined ? e.loaded: e[f] || a(b).jqGrid("getNodeChildren", e).length > 0 ? true: false
                }
            });
            return d
        },
        expandNode: function(e) {
            return this.each(function() {
                if (this.grid && this.p.treeGrid) {
                    var d = this.p.treeReader.expanded_field;
                    if (!e[d]) {
                        var b = a.jgrid.getAccessor(e, this.p.localReader.id),
                        f = a("#" + b, this.grid.bDiv)[0],
                        g = this.p._index[b];
                        if (a(this).jqGrid("isNodeLoaded", this.p.data[g])) {
                            e[d] = true;
                            a("div.treeclick", f).removeClass(this.p.treeIcons.plus + " tree-plus").addClass(this.p.treeIcons.minus + " tree-minus")
                        } else {
                            e[d] = true;
                            a("div.treeclick", f).removeClass(this.p.treeIcons.plus + " tree-plus").addClass(this.p.treeIcons.minus + " tree-minus");
                            this.p.treeANode = f.rowIndex;
                            this.p.datatype = this.p.treedatatype;
                            this.p.treeGridModel == "nested" ? a(this).jqGrid("setGridParam", {
                                postData: {
                                    nodeid: b,
                                    n_left: e.lft,
                                    n_right: e.rgt,
                                    n_level: e.level
                                }
                            }) : a(this).jqGrid("setGridParam", {
                                postData: {
                                    nodeid: b,
                                    parentid: e.parent_id,
                                    n_level: e.level
                                }
                            });
                            a(this).trigger("reloadGrid");
                            this.p.treeGridModel == "nested" ? a(this).jqGrid("setGridParam", {
                                postData: {
                                    nodeid: "",
                                    n_left: "",
                                    n_right: "",
                                    n_level: ""
                                }
                            }) : a(this).jqGrid("setGridParam", {
                                postData: {
                                    nodeid: "",
                                    parentid: "",
                                    n_level: ""
                                }
                            })
                        }
                    }
                }
            })
        },
        collapseNode: function(e) {
            return this.each(function() {
                if (this.grid && this.p.treeGrid) if (e.expanded) {
                    e.expanded = false;
                    var d = a.jgrid.getAccessor(e, this.p.localReader.id);
                    d = a("#" + d, this.grid.bDiv)[0];
                    a("div.treeclick", d).removeClass(this.p.treeIcons.minus + " tree-minus").addClass(this.p.treeIcons.plus + " tree-plus")
                }
            })
        },
        SortTree: function(e, d, b, f) {
            return this.each(function() {
                if (this.grid && this.p.treeGrid) {
                    var g, h, j, c = [],
                    k = this,
                    l;
                    g = a(this).jqGrid("getRootNodes");
                    g = a.jgrid.from(g);
                    g.orderBy(e, d, b, f);
                    l = g.select();
                    g = 0;
                    for (h = l.length; g < h; g++) {
                        j = l[g];
                        c.push(j);
                        a(this).jqGrid("collectChildrenSortTree", c, j, e, d, b, f)
                    }
                    a.each(c,
                    function(o) {
                        var n = a.jgrid.getAccessor(this, k.p.localReader.id);
                        if (o === 0) {
                            o = a("#" + n, k.grid.bDiv);
                            a("td", o).each(function(r) {
                                a(this).css("width", k.grid.headers[r].width + "px")
                            });
                            k.grid.cols = o[0].cells
                        }
                        a("tbody", k.grid.bDiv).append(a("#" + n, k.grid.bDiv))
                    });
                    c = l = g = null
                }
            })
        },
        collectChildrenSortTree: function(e, d, b, f, g, h) {
            return this.each(function() {
                if (this.grid && this.p.treeGrid) {
                    var j, c, k, l;
                    j = a(this).jqGrid("getNodeChildren", d);
                    j = a.jgrid.from(j);
                    j.orderBy(b, f, f, g, h);
                    l = j.select();
                    j = 0;
                    for (c = l.length; j < c; j++) {
                        k = l[j];
                        e.push(k);
                        a(this).jqGrid("collectChildrenSortTree", e, k, b, f, g, h)
                    }
                }
            })
        },
        setTreeRow: function(e, d) {
            var b = false;
            this.each(function() {
                var f = this;
                if (f.grid && f.p.treeGrid) b = a(f).jqGrid("setRowData", e, d)
            });
            return b
        },
        delTreeNode: function(e) {
            return this.each(function() {
                var d = this;
                if (d.grid && d.p.treeGrid) {
                    var b = a(d).jqGrid("getInd", e, true);
                    if (b) {
                        var f = a(d).jqGrid("getNodeChildren", b);
                        if (f.length > 0) for (var g = 0; g < f.length; g++) a(d).jqGrid("delRowData", f[g].id);
                        a(d).jqGrid("delRowData", b.id)
                    }
                }
            })
        }
    })
})(jQuery); (function(a) {
    a.fn.jqDrag = function(j) {
        return g(this, j, "d")
    };
    a.fn.jqResize = function(j, c) {
        return g(this, j, "r", c)
    };
    a.jqDnR = {
        dnr: {},
        e: 0,
        drag: function(j) {
            if (d.k == "d") b.css({
                left: d.X + j.pageX - d.pX,
                top: d.Y + j.pageY - d.pY
            });
            else {
                b.css({
                    width: Math.max(j.pageX - d.pX + d.W, 0),
                    height: Math.max(j.pageY - d.pY + d.H, 0)
                });
                M1 && f.css({
                    width: Math.max(j.pageX - M1.pX + M1.W, 0),
                    height: Math.max(j.pageY - M1.pY + M1.H, 0)
                })
            }
            return false
        },
        stop: function() {
            a(document).unbind("mousemove", e.drag).unbind("mouseup", e.stop)
        }
    };
    var e = a.jqDnR,
    d = e.dnr,
    b = e.e,
    f, g = function(j, c, k, l) {
        return j.each(function() {
            c = c ? a(c, j) : j;
            c.bind("mousedown", {
                e: j,
                k: k
            },
            function(o) {
                var n = o.data,
                r = {};
                b = n.e;
                f = l ? a(l) : false;
                if (b.css("position") != "relative") try {
                    b.position(r)
                } catch(q) {}
                d = {
                    X: r.left || h("left") || 0,
                    Y: r.top || h("top") || 0,
                    W: h("width") || b[0].scrollWidth || 0,
                    H: h("height") || b[0].scrollHeight || 0,
                    pX: o.pageX,
                    pY: o.pageY,
                    k: n.k
                };
                M1 = f && n.k != "d" ? {
                    X: r.left || f1("left") || 0,
                    Y: r.top || f1("top") || 0,
                    W: f[0].offsetWidth || f1("width") || 0,
                    H: f[0].offsetHeight || f1("height") || 0,
                    pX: o.pageX,
                    pY: o.pageY,
                    k: n.k
                }: false;
                try {
                    a("input.hasDatepicker", b[0]).datepicker("hide")
                } catch(t) {}
                a(document).mousemove(a.jqDnR.drag).mouseup(a.jqDnR.stop);
                return false
            })
        })
    },
    h = function(j) {
        return parseInt(b.css(j)) || false
    };
    f1 = function(j) {
        return parseInt(f.css(j)) || false
    }
})(jQuery); (function(a) {
    a.fn.jqm = function(o) {
        var n = {
            overlay: 50,
            closeoverlay: true,
            overlayClass: "jqmOverlay",
            closeClass: "jqmClose",
            trigger: ".jqModal",
            ajax: g,
            ajaxText: "",
            target: g,
            modal: g,
            toTop: g,
            onShow: g,
            onHide: g,
            onLoad: g
        };
        return this.each(function() {
            if (this._jqm) return d[this._jqm].c = a.extend({},
            d[this._jqm].c, o);
            e++;
            this._jqm = e;
            d[e] = {
                c: a.extend(n, a.jqm.params, o),
                a: g,
                w: a(this).addClass("jqmID" + e),
                s: e
            };
            n.trigger && a(this).jqmAddTrigger(n.trigger)
        })
    };
    a.fn.jqmAddClose = function(o) {
        return l(this, o, "jqmHide")
    };
    a.fn.jqmAddTrigger = function(o) {
        return l(this, o, "jqmShow")
    };
    a.fn.jqmShow = function(o) {
        return this.each(function() {
            a.jqm.open(this._jqm, o)
        })
    };
    a.fn.jqmHide = function(o) {
        return this.each(function() {
            a.jqm.close(this._jqm, o)
        })
    };
    a.jqm = {
        hash: {},
        open: function(o, n) {
            var r = d[o],
            q = r.c,
            t = "." + q.closeClass,
            m = parseInt(r.w.css("z-index"));
            m = m > 0 ? m: 3E3;
            var p = a("<div></div>").css({
                height: "100%",
                width: "100%",
                position: "fixed",
                left: 0,
                top: 0,
                "z-index": m - 1,
                opacity: q.overlay / 100
            });
            if (r.a) return g;
            r.t = n;
            r.a = true;
            r.w.css("z-index", m);
            if (q.modal) {
                b[0] || setTimeout(function() {
                    c("bind")
                },
                1);
                b.push(o)
            } else if (q.overlay > 0) q.closeoverlay && r.w.jqmAddClose(p);
            else p = g;
            r.o = p ? p.addClass(q.overlayClass).prependTo("body") : g;
            if (f) {
                a("html,body").css({
                    height: "100%",
                    width: "100%"
                });
                if (p) {
                    p = p.css({
                        position: "absolute"
                    })[0];
                    for (var v in {
                        Top: 1,
                        Left: 1
                    }) p.style.setExpression(v.toLowerCase(), "(_=(document.documentElement.scroll" + v + " || document.body.scroll" + v + "))+'px'")
                }
            }
            if (q.ajax) {
                o = q.target || r.w;
                m = q.ajax;
                o = typeof o == "string" ? a(o, r.w) : a(o);
                m = m.substr(0, 1) == "@" ? a(n).attr(m.substring(1)) : m;
                o.html(q.ajaxText).load(m,
                function() {
                    q.onLoad && q.onLoad.call(this, r);
                    t && r.w.jqmAddClose(a(t, r.w));
                    h(r)
                })
            } else t && r.w.jqmAddClose(a(t, r.w));
            q.toTop && r.o && r.w.before('<span id="jqmP' + r.w[0]._jqm + '"></span>').insertAfter(r.o);
            q.onShow ? q.onShow(r) : r.w.show();
            h(r);
            return g
        },
        close: function(o) {
            o = d[o];
            if (!o.a) return g;
            o.a = g;
            if (b[0]) {
                b.pop();
                b[0] || c("unbind")
            }
            o.c.toTop && o.o && a("#jqmP" + o.w[0]._jqm).after(o.w).remove();
            if (o.c.onHide) o.c.onHide(o);
            else {
                o.w.hide();
                o.o && o.o.remove()
            }
            return g
        },
        params: {}
    };
    var e = 0,
    d = a.jqm.hash,
    b = [],
    f = a.browser.msie && a.browser.version == "6.0",
    g = false,
    h = function(o) {
        var n = a('<iframe src="javascript:false;document.write(\'\');" class="jqm"></iframe>').css({
            opacity: 0
        });
        if (f) if (o.o) o.o.html('<p style="width:100%;height:100%"/>').prepend(n);
        else a("iframe.jqm", o.w)[0] || o.w.prepend(n);
        j(o)
    },
    j = function(o) {
        try {
            a(":input:visible", o.w)[0].focus()
        } catch(n) {}
    },
    c = function(o) {
        a(document)[o]("keypress", k)[o]("keydown", k)[o]("mousedown", k)
    },
    k = function(o) {
        var n = d[b[b.length - 1]]; (o = !a(o.target).parents(".jqmID" + n.s)[0]) && j(n);
        return ! o
    },
    l = function(o, n, r) {
        return o.each(function() {
            var q = this._jqm;
            a(n).each(function() {
                if (!this[r]) {
                    this[r] = [];
                    a(this).click(function() {
                        for (var t in {
                            jqmShow: 1,
                            jqmHide: 1
                        }) for (var m in this[t]) d[this[t][m]] && d[this[t][m]].w[t](this);
                        return g
                    })
                }
                this[r].push(q)
            })
        })
    }
})(jQuery); (function(a) {
    function e(d, b, f, g, h) {
        var j = b;
        if (a.fn.fmatter[d]) j = a.fn.fmatter[d](b, f, g, h);
        return j
    }
    a.fmatter = {};
    a.fn.fmatter = function(d, b, f, g, h) {
        f = a.extend({},
        a.jgrid.formatter, f);
        return e(d, b, f, g, h)
    };
    a.fmatter.util = {
        NumberFormat: function(d, b) {
            isNumber(d) || (d *= 1);
            if (isNumber(d)) {
                var f = d < 0,
                g = d + "",
                h = b.decimalSeparator ? b.decimalSeparator: ".";
                if (isNumber(b.decimalPlaces)) {
                    var j = b.decimalPlaces;
                    g = Math.pow(10, j);
                    g = Math.round(d * g) / g + "";
                    d = g.lastIndexOf(".");
                    if (j > 0) {
                        if (d < 0) {
                            g += h;
                            d = g.length - 1
                        } else if (h !== ".") g = g.replace(".", h);
                        for (; g.length - 1 - d < j;) g += "0"
                    }
                }
                if (b.thousandsSeparator) {
                    j = b.thousandsSeparator;
                    d = g.lastIndexOf(h);
                    d = d > -1 ? d: g.length;
                    h = g.substring(d);
                    for (var c = -1,
                    k = d; k > 0; k--) {
                        c++;
                        if (c % 3 === 0 && k !== d && (!f || k > 1)) h = j + h;
                        h = g.charAt(k - 1) + h
                    }
                    g = h
                }
                g = b.prefix ? b.prefix + g: g;
                return g = b.suffix ? g + b.suffix: g
            } else return d
        },
        DateFormat: function(d, b, f, g) {
            var h = function(y, B) {
                y = String(y);
                for (B = parseInt(B, 10) || 2; y.length < B;) y = "0" + y;
                return y
            },
            j = {
                m: 1,
                d: 1,
                y: 1970,
                h: 0,
                i: 0,
                s: 0,
                u: 0
            },
            c = 0,
            k,
            l,
            o = ["i18n"];
            o.i18n = {
                dayNames: g.dayNames,
                monthNames: g.monthNames
            };
            if (d in g.masks) d = g.masks[d];
            if (b.constructor === Number) c = new Date(b);
            else if (b.constructor === Date) c = b;
            else {
                b = b.split(/[\\\/:_;.,\t\T\s-]/);
                d = d.split(/[\\\/:_;.,\t\T\s-]/);
                k = 0;
                for (l = d.length; k < l; k++) {
                    if (d[k] == "M") {
                        c = a.inArray(b[k], o.i18n.monthNames);
                        if (c !== -1 && c < 12) b[k] = c + 1
                    }
                    if (d[k] == "F") {
                        c = a.inArray(b[k], o.i18n.monthNames);
                        if (c !== -1 && c > 11) b[k] = c + 1 - 12
                    }
                    if (b[k]) j[d[k].toLowerCase()] = parseInt(b[k], 10)
                }
                if (j.f) j.m = j.f;
                if (j.m == 0 && j.y == 0 && j.d == 0) return "&#160;";
                j.m = parseInt(j.m, 10) - 1;
                c = j.y;
                if (c >= 70 && c <= 99) j.y = 1900 + j.y;
                else if (c >= 0 && c <= 69) j.y = 2E3 + j.y;
                c = new Date(j.y, j.m, j.d, j.h, j.i, j.s, j.u)
            }
            if (f in g.masks) f = g.masks[f];
            else f || (f = "Y-m-d");
            j = c.getHours();
            d = c.getMinutes();
            b = c.getDate();
            k = c.getMonth() + 1;
            l = c.getTimezoneOffset();
            var n = c.getSeconds(),
            r = c.getMilliseconds(),
            q = c.getDay(),
            t = c.getFullYear(),
            m = (q + 6) % 7 + 1,
            p = (new Date(t, k - 1, b) - new Date(t, 0, 1)) / 864E5,
            v = {
                d: h(b),
                D: o.i18n.dayNames[q],
                j: b,
                l: o.i18n.dayNames[q + 7],
                N: m,
                S: g.S(b),
                w: q,
                z: p,
                W: m < 5 ? Math.floor((p + m - 1) / 7) + 1 : Math.floor((p + m - 1) / 7) || (((new Date(t - 1, 0, 1)).getDay() + 6) % 7 < 4 ? 53 : 52),
                F: o.i18n.monthNames[k - 1 + 12],
                m: h(k),
                M: o.i18n.monthNames[k - 1],
                n: k,
                t: "?",
                L: "?",
                o: "?",
                Y: t,
                y: String(t).substring(2),
                a: j < 12 ? g.AmPm[0] : g.AmPm[1],
                A: j < 12 ? g.AmPm[2] : g.AmPm[3],
                B: "?",
                g: j % 12 || 12,
                G: j,
                h: h(j % 12 || 12),
                H: h(j),
                i: h(d),
                s: h(n),
                u: r,
                e: "?",
                I: "?",
                O: (l > 0 ? "-": "+") + h(Math.floor(Math.abs(l) / 60) * 100 + Math.abs(l) % 60, 4),
                P: "?",
                T: (String(c).match(/\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g) || [""]).pop().replace(/[^-+\dA-Z]/g, ""),
                Z: "?",
                c: "?",
                r: "?",
                U: Math.floor(c / 1E3)
            };
            return f.replace(/\\.|[dDjlNSwzWFmMntLoYyaABgGhHisueIOPTZcrU]/g,
            function(y) {
                return y in v ? v[y] : y.substring(1)
            })
        }
    };
    a.fn.fmatter.defaultFormat = function(d, b) {
        return isValue(d) && d !== "" ? d: b.defaultValue ? b.defaultValue: "&#160;"
    };
    a.fn.fmatter.email = function(d, b) {
        return isEmpty(d) ? a.fn.fmatter.defaultFormat(d, b) : '<a href="mailto:' + d + '">' + d + "</a>"
    };
    a.fn.fmatter.checkbox = function(d, b) {
        var f = a.extend({},
        b.checkbox);
        isUndefined(b.colModel.formatoptions) || (f = a.extend({},
        f, b.colModel.formatoptions));
        b = f.disabled === true ? "disabled": "";
        if (isEmpty(d) || isUndefined(d)) d = a.fn.fmatter.defaultFormat(d, f);
        d += "";
        d = d.toLowerCase();
        return '<input type="checkbox" ' + (d.search(/(false|0|no|off)/i) < 0 ? " checked='checked' ": "") + ' value="' + d + '" offval="no" ' + b + "/>"
    };
    a.fn.fmatter.link = function(d, b) {
        var f = {
            target: b.target
        },
        g = "";
        isUndefined(b.colModel.formatoptions) || (f = a.extend({},
        f, b.colModel.formatoptions));
        if (f.target) g = "target=" + f.target;
        return isEmpty(d) ? a.fn.fmatter.defaultFormat(d, b) : "<a " + g + ' href="' + d + '">' + d + "</a>"
    };
    a.fn.fmatter.showlink = function(d, b) {
        var f = {
            baseLinkUrl: b.baseLinkUrl,
            showAction: b.showAction,
            addParam: b.addParam || "",
            target: b.target,
            idName: b.idName
        },
        g = "";
        isUndefined(b.colModel.formatoptions) || (f = a.extend({},
        f, b.colModel.formatoptions));
        if (f.target) g = "target=" + f.target;
        f = f.baseLinkUrl + f.showAction + "?" + f.idName + "=" + b.rowId + f.addParam;
        return isString(d) || isNumber(d) ? "<a " + g + ' href="' + f + '">' + d + "</a>": a.fn.fmatter.defaultFormat(d, b)
    };
    a.fn.fmatter.integer = function(d, b) {
        var f = a.extend({},
        b.integer);
        isUndefined(b.colModel.formatoptions) || (f = a.extend({},
        f, b.colModel.formatoptions));
        if (isEmpty(d)) return f.defaultValue;
        return a.fmatter.util.NumberFormat(d, f)
    };
    a.fn.fmatter.number = function(d, b) {
        var f = a.extend({},
        b.number);
        isUndefined(b.colModel.formatoptions) || (f = a.extend({},
        f, b.colModel.formatoptions));
        if (isEmpty(d)) return f.defaultValue;
        return a.fmatter.util.NumberFormat(d, f)
    };
    a.fn.fmatter.currency = function(d, b) {
        var f = a.extend({},
        b.currency);
        isUndefined(b.colModel.formatoptions) || (f = a.extend({},
        f, b.colModel.formatoptions));
        if (isEmpty(d)) return f.defaultValue;
        return a.fmatter.util.NumberFormat(d, f)
    };
    a.fn.fmatter.date = function(d, b, f, g) {
        f = a.extend({},
        b.date);
        isUndefined(b.colModel.formatoptions) || (f = a.extend({},
        f, b.colModel.formatoptions));
        return ! f.reformatAfterEdit && g == "edit" ? a.fn.fmatter.defaultFormat(d, b) : isEmpty(d) ? a.fn.fmatter.defaultFormat(d, b) : a.fmatter.util.DateFormat(f.srcformat, d, f.newformat, f)
    };
    a.fn.fmatter.select = function(d, b) {
        d += "";
        var f = false,
        g = [];
        if (isUndefined(b.colModel.formatoptions)) {
            if (!isUndefined(b.colModel.editoptions)) f = b.colModel.editoptions.value
        } else f = b.colModel.formatoptions.value;
        if (f) {
            var h = b.colModel.editoptions.multiple === true ? true: false,
            j = [],
            c;
            if (h) {
                j = d.split(",");
                j = a.map(j,
                function(n) {
                    return a.trim(n)
                })
            }
            if (isString(f)) for (var k = f.split(";"), l = 0, o = 0; o < k.length; o++) {
                c = k[o].split(":");
                if (c.length > 2) c[1] = jQuery.map(c,
                function(n, r) {
                    if (r > 0) return n
                }).join(":");
                if (h) {
                    if (jQuery.inArray(c[0], j) > -1) {
                        g[l] = c[1];
                        l++
                    }
                } else if (a.trim(c[0]) == a.trim(d)) {
                    g[0] = c[1];
                    break
                }
            } else if (isObject(f)) if (h) g = jQuery.map(j,
            function(n) {
                return f[n]
            });
            else g[0] = f[d] || ""
        }
        d = g.join(", ");
        return d == "" ? a.fn.fmatter.defaultFormat(d, b) : d
    };
    a.fn.fmatter.rowactions = function(d, b, f, g) {
        switch (f) {
        case "edit":
            f = function() {
                a("tr#" + d + " div.ui-inline-edit, tr#" + d + " div.ui-inline-del", "#" + b).show();
                a("tr#" + d + " div.ui-inline-save, tr#" + d + " div.ui-inline-cancel", "#" + b).hide()
            };
            a("#" + b).jqGrid("editRow", d, g, null, null, null, {
                oper: "edit"
            },
            f, null, f);
            a("tr#" + d + " div.ui-inline-edit, tr#" + d + " div.ui-inline-del", "#" + b).hide();
            a("tr#" + d + " div.ui-inline-save, tr#" + d + " div.ui-inline-cancel", "#" + b).show();
            break;
        case "save":
            a("#" + b).jqGrid("saveRow", d, null, null);
            a("tr#" + d + " div.ui-inline-edit, tr#" + d + " div.ui-inline-del", "#" + b).show();
            a("tr#" + d + " div.ui-inline-save, tr#" + d + " div.ui-inline-cancel", "#" + b).hide();
            break;
        case "cancel":
            a("#" + b).jqGrid("restoreRow", d);
            a("tr#" + d + " div.ui-inline-edit, tr#" + d + " div.ui-inline-del", "#" + b).show();
            a("tr#" + d + " div.ui-inline-save, tr#" + d + " div.ui-inline-cancel", "#" + b).hide();
            break
        }
    };
    a.fn.fmatter.actions = function(d, b) {
        d = {
            keys: false,
            editbutton: true,
            delbutton: true
        };
        isUndefined(b.colModel.formatoptions) || (d = a.extend(d, b.colModel.formatoptions));
        var f = b.rowId,
        g = "",
        h;
        if (typeof f == "undefined" || isEmpty(f)) return "";
        if (d.editbutton) {
            h = "onclick=$.fn.fmatter.rowactions('" + f + "','" + b.gid + "','edit'," + d.keys + ");";
            g = g + "<div style='margin-left:8px;'><div title='" + a.jgrid.nav.edittitle + "' style='float:left;cursor:pointer;' class='ui-pg-div ui-inline-edit' " + h + "><span class='ui-icon ui-icon-pencil'></span></div>"
        }
        if (d.delbutton) {
            h = "onclick=jQuery('#" + b.gid + "').jqGrid('delGridRow','" + f + "');";
            g = g + "<div title='" + a.jgrid.nav.deltitle + "' style='float:left;margin-left:5px;' class='ui-pg-div ui-inline-del' " + h + "><span class='ui-icon ui-icon-trash'></span></div>"
        }
        h = "onclick=$.fn.fmatter.rowactions('" + f + "','" + b.gid + "','save',false);";
        g = g + "<div title='" + a.jgrid.edit.bSubmit + "' style='float:left;display:none' class='ui-pg-div ui-inline-save'><span class='ui-icon ui-icon-disk' " + h + "></span></div>";
        h = "onclick=$.fn.fmatter.rowactions('" + f + "','" + b.gid + "','cancel',false);";
        return g = g + "<div title='" + a.jgrid.edit.bCancel + "' style='float:left;display:none;margin-left:5px;' class='ui-pg-div ui-inline-cancel'><span class='ui-icon ui-icon-cancel' " + h + "></span></div></div>"
    };
    a.unformat = function(d, b, f, g) {
        var h, j = b.colModel.formatter,
        c = b.colModel.formatoptions || {},
        k = /([\.\*\_\'\(\)\{\}\+\?\\])/g;
        unformatFunc = b.colModel.unformat || a.fn.fmatter[j] && a.fn.fmatter[j].unformat;
        if (typeof unformatFunc !== "undefined" && isFunction(unformatFunc)) h = unformatFunc(a(d).text(), b, d);
        else if (typeof j !== "undefined" && isString(j)) {
            h = a.jgrid.formatter || {};
            switch (j) {
            case "integer":
                c = a.extend({},
                h.integer, c);
                b = c.thousandsSeparator.replace(k, "\\$1");
                b = new RegExp(b, "g");
                h = a(d).text().replace(b, "");
                break;
            case "number":
                c = a.extend({},
                h.number, c);
                b = c.thousandsSeparator.replace(k, "\\$1");
                b = new RegExp(b, "g");
                h = a(d).text().replace(b, "").replace(c.decimalSeparator, ".");
                break;
            case "currency":
                c = a.extend({},
                h.currency, c);
                b = c.thousandsSeparator.replace(k, "\\$1");
                b = new RegExp(b, "g");
                h = a(d).text().replace(b, "").replace(c.decimalSeparator, ".").replace(c.prefix, "").replace(c.suffix, "");
                break;
            case "checkbox":
                c = b.colModel.editoptions ? b.colModel.editoptions.value.split(":") : ["Yes", "No"];
                h = a("input", d).attr("checked") ? c[0] : c[1];
                break;
            case "select":
                h = a.unformat.select(d, b, f, g);
                break;
            case "actions":
                return "";
            default:
                h = a(d).text()
            }
        }
        return h ? h: g === true ? a(d).text() : a.jgrid.htmlDecode(a(d).html())
    };
    a.unformat.select = function(d, b, f, g) {
        f = [];
        d = a(d).text();
        if (g === true) return d;
        b = a.extend({},
        b.colModel.editoptions);
        if (b.value) {
            var h = b.value;
            b = b.multiple === true ? true: false;
            g = [];
            var j;
            if (b) {
                g = d.split(",");
                g = a.map(g,
                function(o) {
                    return a.trim(o)
                })
            }
            if (isString(h)) for (var c = h.split(";"), k = 0, l = 0; l < c.length; l++) {
                j = c[l].split(":");
                if (j.length > 2) j[1] = jQuery.map(j,
                function(o, n) {
                    if (n > 0) return o
                }).join(":");
                if (b) {
                    if (jQuery.inArray(j[1], g) > -1) {
                        f[k] = j[0];
                        k++
                    }
                } else if (a.trim(j[1]) == a.trim(d)) {
                    f[0] = j[0];
                    break
                }
            } else if (isObject(h) || a.isArray(h)) {
                b || (g[0] = d);
                f = jQuery.map(g,
                function(o) {
                    var n;
                    a.each(h,
                    function(r, q) {
                        if (q == o) {
                            n = r;
                            return false
                        }
                    });
                    if (typeof n != "undefined") return n
                })
            }
            return f.join(", ")
        } else return d || ""
    };
    a.unformat.date = function(d, b) {
        var f = a.jgrid.formatter.date || {};
        isUndefined(b.formatoptions) || (f = a.extend({},
        f, b.formatoptions));
        return isEmpty(d) ? a.fn.fmatter.defaultFormat(d, b) : a.fmatter.util.DateFormat(f.newformat, d, f.srcformat, f)
    };
    isValue = function(d) {
        return isObject(d) || isString(d) || isNumber(d) || isBoolean(d)
    };
    isBoolean = function(d) {
        return typeof d === "boolean"
    };
    isNull = function(d) {
        return d === null
    };
    isNumber = function(d) {
        return typeof d === "number" && isFinite(d)
    };
    isString = function(d) {
        return typeof d === "string"
    };
    isEmpty = function(d) {
        if (!isString(d) && isValue(d)) return false;
        else if (!isValue(d)) return true;
        d = a.trim(d).replace(/\&nbsp\;/ig, "").replace(/\&#160\;/ig, "");
        return d === ""
    };
    isUndefined = function(d) {
        return typeof d === "undefined"
    };
    isObject = function(d) {
        return d && (typeof d === "object" || isFunction(d)) || false
    };
    isFunction = function(d) {
        return typeof d === "function"
    }
})(jQuery);
jQuery.fn.searchFilter = function(a, e) {
    function d(b, f, g) {
        this.$ = b;
        this.add = function(w) {
            w == null ? b.find(".ui-add-last").click() : b.find(".sf:eq(" + w + ") .ui-add").click();
            return this
        };
        this.del = function(w) {
            w == null ? b.find(".sf:last .ui-del").click() : b.find(".sf:eq(" + w + ") .ui-del").click();
            return this
        };
        this.search = function() {
            b.find(".ui-search").click();
            return this
        };
        this.reset = function(w) {
            if (w === undefined) w = false;
            b.find(".ui-reset").trigger("click", [w]);
            return this
        };
        this.close = function() {
            b.find(".ui-closer").click();
            return this
        };
        if (f != null) {
            function h() {
                jQuery(this).toggleClass("ui-state-hover");
                return false
            }
            function j(w) {
                jQuery(this).toggleClass("ui-state-active", w.type == "mousedown");
                return false
            }
            function c(w, A) {
                return "<option value='" + w + "'>" + A + "</option>"
            }
            function k(w, A, G) {
                return "<select class='" + w + "'" + (G ? " style='display:none;'": "") + ">" + A + "</select>"
            }
            function l(w, A) {
                w = b.find("tr.sf td.data " + w);
                w[0] != null && A(w)
            }
            function o(w, A) {
                var G = b.find("tr.sf td.data " + w);
                G[0] != null && jQuery.each(A,
                function() {
                    this.data != null ? G.bind(this.type, this.data, this.fn) : G.bind(this.type, this.fn)
                })
            }
            var n = jQuery.extend({},
            jQuery.fn.searchFilter.defaults, g),
            r = -1,
            q = "";
            jQuery.each(n.groupOps,
            function() {
                q += c(this.op, this.text)
            });
            q = "<select name='groupOp'>" + q + "</select>";
            b.html("").addClass("ui-searchFilter").append("<div class='ui-widget-overlay' style='z-index: -1'>&#160;</div><table class='ui-widget-content ui-corner-all'><thead><tr><td colspan='5' class='ui-widget-header ui-corner-all' style='line-height: 18px;'><div class='ui-closer ui-state-default ui-corner-all ui-helper-clearfix' style='float: right;'><span class='ui-icon ui-icon-close'></span></div>" + n.windowTitle + "</td></tr></thead><tbody><tr class='sf'><td class='fields'></td><td class='ops'></td><td class='data'></td><td><div class='ui-del ui-state-default ui-corner-all'><span class='ui-icon ui-icon-minus'></span></div></td><td><div class='ui-add ui-state-default ui-corner-all'><span class='ui-icon ui-icon-plus'></span></div></td></tr><tr><td colspan='5' class='divider'><div>&#160;</div></td></tr></tbody><tfoot><tr><td colspan='3'><span class='ui-reset ui-state-default ui-corner-all' style='display: inline-block; float: left;'><span class='ui-icon ui-icon-arrowreturnthick-1-w' style='float: left;'></span><span style='line-height: 18px; padding: 0 7px 0 3px;'>" + n.resetText + "</span></span><span class='ui-search ui-state-default ui-corner-all' style='display: inline-block; float: right;'><span class='ui-icon ui-icon-search' style='float: left;'></span><span style='line-height: 18px; padding: 0 7px 0 3px;'>" + n.searchText + "</span></span><span class='matchText'>" + n.matchText + "</span> " + q + " <span class='rulesText'>" + n.rulesText + "</span></td><td>&#160;</td><td><div class='ui-add-last ui-state-default ui-corner-all'><span class='ui-icon ui-icon-plusthick'></span></div></td></tr></tfoot></table>");
            var t = b.find("tr.sf"),
            m = t.find("td.fields"),
            p = t.find("td.ops"),
            v = t.find("td.data"),
            y = "";
            jQuery.each(n.operators,
            function() {
                y += c(this.op, this.text)
            });
            y = k("default", y, true);
            p.append(y);
            v.append("<input type='text' class='default' style='display:none;' />");
            var B = "",
            C = false,
            I = false;
            jQuery.each(f,
            function(w) {
                B += c(this.itemval, this.text);
                if (this.ops != null) {
                    C = true;
                    var A = "";
                    jQuery.each(this.ops,
                    function() {
                        A += c(this.op, this.text)
                    });
                    A = k("field" + w, A, true);
                    p.append(A)
                }
                if (this.dataUrl != null) {
                    if (w > r) r = w;
                    I = true;
                    var G = this.dataEvents,
                    M = this.dataInit,
                    O = this.buildSelect;
                    jQuery.ajax(jQuery.extend({
                        url: this.dataUrl,
                        complete: function(V) {
                            V = O != null ? jQuery("<div />").append(O(V)) : jQuery("<div />").append(V.responseText);
                            V.find("select").addClass("field" + w).hide();
                            v.append(V.html());
                            M && l(".field" + w, M);
                            G && o(".field" + w, G);
                            w == r && b.find("tr.sf td.fields select[name='field']").change()
                        }
                    },
                    n.ajaxSelectOptions))
                } else if (this.dataValues != null) {
                    I = true;
                    var P = "";
                    jQuery.each(this.dataValues,
                    function() {
                        P += c(this.value, this.text)
                    });
                    P = k("field" + w, P, true);
                    v.append(P)
                } else if (this.dataEvents != null || this.dataInit != null) {
                    I = true;
                    P = "<input type='text' class='field" + w + "' />";
                    v.append(P)
                }
                this.dataInit != null && w != r && l(".field" + w, this.dataInit);
                this.dataEvents != null && w != r && o(".field" + w, this.dataEvents)
            });
            B = "<select name='field'>" + B + "</select>";
            m.append(B);
            f = m.find("select[name='field']");
            C ? f.change(function(w) {
                var A = w.target.selectedIndex;
                w = jQuery(w.target).parents("tr.sf").find("td.ops");
                w.find("select").removeAttr("name").hide();
                A = w.find(".field" + A);
                if (A[0] == null) A = w.find(".default");
                A.attr("name", "op").show();
                return false
            }) : p.find(".default").attr("name", "op").show();
            I ? f.change(function(w) {
                var A = w.target.selectedIndex;
                w = jQuery(w.target).parents("tr.sf").find("td.data");
                w.find("select,input").removeClass("vdata").hide();
                A = w.find(".field" + A);
                if (A[0] == null) A = w.find(".default");
                A.show().addClass("vdata");
                return false
            }) : v.find(".default").show().addClass("vdata");
            if (C || I) f.change();
            b.find(".ui-state-default").hover(h, h).mousedown(j).mouseup(j);
            b.find(".ui-closer").click(function() {
                n.onClose(jQuery(b.selector));
                return false
            });
            b.find(".ui-del").click(function(w) {
                w = jQuery(w.target).parents(".sf");
                if (w.siblings(".sf").length > 0) {
                    n.datepickerFix === true && jQuery.fn.datepicker !== undefined && w.find(".hasDatepicker").datepicker("destroy");
                    w.remove()
                } else {
                    w.find("select[name='field']")[0].selectedIndex = 0;
                    w.find("select[name='op']")[0].selectedIndex = 0;
                    w.find(".data input").val("");
                    w.find(".data select").each(function() {
                        this.selectedIndex = 0
                    });
                    w.find("select[name='field']").change(function(A) {
                        A.stopPropagation()
                    })
                }
                return false
            });
            b.find(".ui-add").click(function(w) {
                w = jQuery(w.target).parents(".sf");
                var A = w.clone(true).insertAfter(w);
                A.find(".ui-state-default").removeClass("ui-state-hover ui-state-active");
                if (n.clone) {
                    A.find("select[name='field']")[0].selectedIndex = w.find("select[name='field']")[0].selectedIndex;
                    if (A.find("select[name='op']")[0] != null) A.find("select[name='op']").focus()[0].selectedIndex = w.find("select[name='op']")[0].selectedIndex;
                    var G = A.find("select.vdata");
                    if (G[0] != null) G[0].selectedIndex = w.find("select.vdata")[0].selectedIndex
                } else {
                    A.find(".data input").val("");
                    A.find("select[name='field']").focus()
                }
                n.datepickerFix === true && jQuery.fn.datepicker !== undefined && w.find(".hasDatepicker").each(function() {
                    var M = jQuery.data(this, "datepicker").settings;
                    A.find("#" + this.id).unbind().removeAttr("id").removeClass("hasDatepicker").datepicker(M)
                });
                A.find("select[name='field']").change(function(M) {
                    M.stopPropagation()
                });
                return false
            });
            b.find(".ui-search").click(function() {
                var w = jQuery(b.selector),
                A,
                G = w.find("select[name='groupOp'] :selected").val();
                A = n.stringResult ? '{"groupOp":"' + G + '","rules":[': {
                    groupOp: G,
                    rules: []
                };
                w.find(".sf").each(function(M) {
                    var O = jQuery(this).find("select[name='field'] :selected").val(),
                    P = jQuery(this).find("select[name='op'] :selected").val(),
                    V = jQuery(this).find("input.vdata,select.vdata :selected").val();
                    V += "";
                    V = V.replace(/\\/g, "\\\\").replace(/\"/g, '\\"');
                    if (n.stringResult) {
                        if (M > 0) A += ",";
                        A += '{"field":"' + O + '",';
                        A += '"op":"' + P + '",';
                        A += '"data":"' + V + '"}'
                    } else A.rules.push({
                        field: O,
                        op: P,
                        data: V
                    })
                });
                if (n.stringResult) A += "]}";
                n.onSearch(A);
                return false
            });
            b.find(".ui-reset").click(function(w, A) {
                w = jQuery(b.selector);
                w.find(".ui-del").click();
                w.find("select[name='groupOp']")[0].selectedIndex = 0;
                n.onReset(A);
                return false
            });
            b.find(".ui-add-last").click(function() {
                var w = jQuery(b.selector + " .sf:last"),
                A = w.clone(true).insertAfter(w);
                A.find(".ui-state-default").removeClass("ui-state-hover ui-state-active");
                A.find(".data input").val("");
                A.find("select[name='field']").focus();
                n.datepickerFix === true && jQuery.fn.datepicker !== undefined && w.find(".hasDatepicker").each(function() {
                    var G = jQuery.data(this, "datepicker").settings;
                    A.find("#" + this.id).unbind().removeAttr("id").removeClass("hasDatepicker").datepicker(G)
                });
                A.find("select[name='field']").change(function(G) {
                    G.stopPropagation()
                });
                return false
            });
            this.setGroupOp = function(w) {
                selDOMobj = b.find("select[name='groupOp']")[0];
                var A = {},
                G = selDOMobj.options.length,
                M;
                for (M = 0; M < G; M++) A[selDOMobj.options[M].value] = M;
                selDOMobj.selectedIndex = A[w];
                jQuery(selDOMobj).change(function(O) {
                    O.stopPropagation()
                })
            };
            this.setFilter = function(w) {
                var A = w.sfref;
                w = w.filter;
                var G = [],
                M,
                O,
                P,
                V,
                da = {};
                selDOMobj = A.find("select[name='field']")[0];
                M = 0;
                for (P = selDOMobj.options.length; M < P; M++) {
                    da[selDOMobj.options[M].value] = {
                        index: M,
                        ops: {}
                    };
                    G.push(selDOMobj.options[M].value)
                }
                M = 0;
                for (P = G.length; M < P; M++) {
                    if (selDOMobj = A.find(".ops > select[class='field" + M + "']")[0]) {
                        O = 0;
                        for (V = selDOMobj.options.length; O < V; O++) da[G[M]].ops[selDOMobj.options[O].value] = O
                    }
                    if (selDOMobj = A.find(".data > select[class='field" + M + "']")[0]) {
                        da[G[M]].data = {};
                        O = 0;
                        for (V = selDOMobj.options.length; O < V; O++) da[G[M]].data[selDOMobj.options[O].value] = O
                    }
                }
                var ga, ua, za, Aa;
                G = w.field;
                if (da[G]) ga = da[G].index;
                if (ga != null) {
                    ua = da[G].ops[w.op];
                    if (ua === undefined) {
                        M = 0;
                        for (P = g.operators.length; M < P; M++) if (g.operators[M].op == w.op) {
                            ua = M;
                            break
                        }
                    }
                    za = w.data;
                    Aa = da[G].data == null ? -1 : da[G].data[za]
                }
                if (ga != null && ua != null && Aa != null) {
                    A.find("select[name='field']")[0].selectedIndex = ga;
                    A.find("select[name='field']").change();
                    A.find("select[name='op']")[0].selectedIndex = ua;
                    A.find("input.vdata").val(za);
                    if (A = A.find("select.vdata")[0]) A.selectedIndex = Aa;
                    return true
                } else return false
            }
        }
    }
    return new d(this, a, e)
};
jQuery.fn.searchFilter.version = "1.2.9";
jQuery.fn.searchFilter.defaults = {
    clone: true,
    datepickerFix: true,
    onReset: function(a) {
        alert("Reset Clicked. Data Returned: " + a)
    },
    onSearch: function(a) {
        alert("Search Clicked. Data Returned: " + a)
    },
    onClose: function(a) {
        a.hide()
    },
    groupOps: [{
        op: "AND",
        text: "all"
    },
    {
        op: "OR",
        text: "any"
    }],
    operators: [{
        op: "eq",
        text: "is equal to"
    },
    {
        op: "ne",
        text: "is not equal to"
    },
    {
        op: "lt",
        text: "is less than"
    },
    {
        op: "le",
        text: "is less or equal to"
    },
    {
        op: "gt",
        text: "is greater than"
    },
    {
        op: "ge",
        text: "is greater or equal to"
    },
    {
        op: "in",
        text: "is in"
    },
    {
        op: "ni",
        text: "is not in"
    },
    {
        op: "bw",
        text: "begins with"
    },
    {
        op: "bn",
        text: "does not begin with"
    },
    {
        op: "ew",
        text: "ends with"
    },
    {
        op: "en",
        text: "does not end with"
    },
    {
        op: "cn",
        text: "contains"
    },
    {
        op: "nc",
        text: "does not contain"
    }],
    matchText: "match",
    rulesText: "rules",
    resetText: "Reset",
    searchText: "Search",
    stringResult: true,
    windowTitle: "Search Rules",
    ajaxSelectOptions: {}
};