﻿log = function (a) {
    console.log("%s: %o", a, this);
    return this
};
$(window).load(function () {

    $('td#file_gen a.item_modal').click(function (e) {
        e.preventDefault();

        var $this = $(this);
        var horizontalPadding = 30;
        var verticalPadding = 30;
        $('<iframe id="externalSite" class="externalSite" src="' + this.href + '" />').dialog({
            title: ($this.attr('title')) ? $this.attr('title') : 'Sunlight Supply - File Generator',
            autoOpen: true,
            width: 310,
            height: 600,
            modal: true,
            resizable: true,
            autoResize: true,
            overlay: {
                opacity: 0.9,
                background: "black"
            }
        }).width(310 - horizontalPadding).height(600 - verticalPadding);
    });
    var a = $("img[id*='PRODUCTPic']").width();
    if (a < 280) { }
});
jQuery(function (c) {
    c("table.tblData     td a.item_modal").click(function (h) {
        h.preventDefault();
        var g = c(this);
        var j = 30;
        var f = 30;
        c('<iframe id="externalSite" class="externalSite" src="' + this.href + '" />').dialog({
            title: (g.attr("title")) ? g.attr("title") : "Sunlight Supply Customer Invoice",
            autoOpen: true,
            width: 870,
            height: 580,
            modal: true,
            resizable: true,
            autoResize: true,
            overlay: {
                opacity: 0.9,
                background: "black"
            }
        }).width(870 - j).height(580 - f)
    });
    c("table.tblData").tablesorter({
        widgets: ["zebra"]
    }).tablesorterFilter({
        filterContainer: c("#filterBox"),
        filterClearContainer: c("#filterClear"),
        filterColumns: [0, 1, 2, 4, 6],
        filterCaseSensitive: false
    });
    if (c("span.bad_news").length > 0) { }
    c("div.list-notmyfault").closest("h1").remove();
    var b = GetUrlScriptname();
    if (b == "c-665-lighting.aspx" || b == "c-666-gardening.aspx") {
        c("h1").remove()
    }
    c("#show_clients").click(function (g) {
        var f = c(this);
        g.preventDefault();
        c("#distinctive_clients").dialog({
            title: (f.attr("title")) ? f.attr("title") : "Sunlight Supply Distinctive Customers",
            autoOpen: true,
            width: 335,
            height: 420,
            modal: true,
            resizable: true,
            autoResize: true,
            overlay: {
                opacity: 0.9,
                background: "black"
            }
        })
    });
    c(".phresh_calc").click(function (h) {
        h.preventDefault();
        var g = c(this);
        var j = 30;
        var f = 30;
        c('<iframe id="externalSite" class="externalSite" src="' + this.href + '" />').dialog({
            title: (g.attr("title")) ? g.attr("title") : "Phresh Filter Calculator",
            autoOpen: true,
            width: 515,
            height: 410,
            modal: true,
            resizable: true,
            autoResize: true,
            overlay: {
                opacity: 0.9,
                background: "black"
            }
        }).width(515 - j).height(410 - f)
    });
    c("a.variant_qty_view").click(function (g) {
        g.preventDefault();
        var f = c(this).closest("div.qty_disc_link").val();
        alert(f);
        c(this).closest("div.qty_disc_link").fadeIn("slow")
    });
    var e = c(".slide-out-div");
    c("a[rel^='prettyPhoto']").prettyPhoto();
    c("#accordion").accordion({
        autoHeight: false,
        collapsible: true,
        collapsed: true,
        icons: {
            header: "ui-icon-plus",
            headerSelected: "ui-icon-minus"
        }
    });
    c("#ctl00_PageContent_SLS_DealerOrders1_txtDateFrom").datepicker();
    c("#ctl00_PageContent_SLS_DealerOrders1_txtDateTo").datepicker();
    c("#ctl00_PageContent_SLS_DealerInvoices1_txtDateFrom").datepicker();
    c("#ctl00_PageContent_SLS_DealerInvoices1_txtDateTo").datepicker();
    if (c(".CallToOrder").length > 0) {
        c("#tableOrderAddToCart").hide()
    } ("slow");

    function a() {
        c("#cartList").hide();
        c("#imgLoading").show();
        c("#cartList").load("SLSMiniCart.aspx", {
            variable: 1
        }, function () {
            c("#imgLoading").hide()
        }).fadeIn("slow").draggable()
    }
    c(".slide-out-div").tabSlideOut({
        tabHandle: ".handle",
        pathToTabImage: "images/dlr_search_tab.png",
        imageHeight: "200px",
        imageWidth: "52px",
        tabLocation: "left",
        speed: 300,
        action: "click",
        topPos: "200px",
        leftPos: "20px",
        fixedPosition: false
    });
    c("a[title]").qtip({
        style: {
            name: "green",
            tip: true
        }
    });
    c("img.info").qtip({
        style: {
            name: "green",
            tip: true
        }
    });
    c("#ctl00_Search1_SearchText").bind("keyup", function () {
        tSearch(this)
    });
    c("#ctl00_txtPartSearch").bind("keyup", function () {
        partSearch(this)
    });
    c("#bulk_order input.part_field").blur(function (f) {
        c("div#part_search_results").fadeOut("slow")
    });
    c("#ctl00_Search1_SearchText").blur(function (f) {
        c("div#tsearch_results").fadeOut("slow")
    });
    c(".dlr_link").click(function (f) {
        f.preventDefault();
        c("#ctl00_PageContent_SLS_DealerSearch1_txtSearch").focus().effect("highlight", {}, 4000)
    });
    c("#part_search_results ul li a.picker").live("click", function (f) {
        f.preventDefault();
        c(this).next("input").val(c(this).html())
    });
    var d = "../images/loading9.gif";
    var b = GetUrlScriptname();
    c('.menu_block ul li a[href$="' + b + '"]').addClass("selected");
    c("ul.product_gallery a").lightBox();
    c("#slider").easySlider({
        auto: true,
        speed: 900,
        pause: 5000,
        continuous: true,
        numeric: true
    });
    c("#dropdownNavigation").droppy();
    c("#tabs").tabs({
        selected: "#overview"
    });
    c("#user_info_box").draggable();
    c(".fcTable tbody tr:odd").addClass("odd");
    c(".tblResults tbody tr:odd").addClass("odd");
    c(".tblWeight tbody tr:odd").addClass("odd");
    c(".tblSearchResults tbody tr:odd").addClass("odd");
    c(".tblPartList tbody tr:odd").addClass("odd");
    c("#tabs").tabs({
        selected: "#tabs-1"
    })
});

function SetCookie(a, c) {
    var b = 30;
    var d = new Date();
    d.setTime(d.getTime() + b * 24 * 60 * 60 * 1000);
    document.cookie = a + "=" + escape(c) + ";expires=" + d.toGMTString()
}
function getCookie(b) {
    var a = document.cookie.match(new RegExp("(^| )" + b + "=([^;]*)(;|$)"));
    if (a != null) {
        return unescape(a[2])
    }
    return null
}
function delCookie(a) {
    var c = new Date();
    c.setTime(c.getTime() - 1);
    var b = getCookie(a);
    if (b != null) {
        document.cookie = a + "=" + b + ";expires=" + c.toGMTString()
    }
}
function GetUrlScriptname() {
    var b = new RegExp("\\/[^\\/]+\\.\\w+($|\\?)");
    var a = b.exec(location.pathname);
    if (a == null) {
        return "default.aspx"
    } else {
        return a[0].substring(1)
    }
}
function getParameterByName(b) {
    b = b.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
    var a = "[\\?&]" + b + "=([^&#]*)";
    var d = new RegExp(a);
    var c = d.exec(window.location.href);
    if (c == null) {
        return ""
    } else {
        return decodeURIComponent(c[1].replace(/\+/g, " "))
    }
}
function tsCreateRequestObject() {
    var b;
    var a = navigator.appName;
    if (a == "Microsoft Internet Explorer") {
        b = new ActiveXObject("Microsoft.XMLHTTP")
    } else {
        b = new XMLHttpRequest()
    }
    return b
}
var http = tsCreateRequestObject();

function tsSendRequest(a) {
    http.open("get", a);
    http.onreadystatechange = handleResponse;
    http.send(null)
}
function handleResponse() {
    if (http.readyState == 4) {
        var a = document.getElementById("tsearch_results");
        a.innerHTML = http.responseText;
        if (a.innerHTML.length > 9) {
            a.style.display = "block"
        }
    }
}
function tSearch(d) {
    var c = d.value;
    if (c.length > 1) {
        var e = document.getElementById("tsearch_results");
        if (e == null) {
            e = document.createElement("div");
            e.id = "tsearch_results";
            d.parentNode.insertBefore(e, d)
        }
        var b = "ajaxCompunixtSearch.aspx?searchQuery=" + c;
        tsSendRequest(b)
    } else {
        var a = document.getElementById("tsearch_results");
        if (a != null) {
            a.style.display = "none"
        }
    }
    return false
}
function $bindMethod(a, b) {
    return function () {
        return b.apply(a, arguments)
    }
}
function $window_addLoad(b) {
    if (window.addEventListener) {
        window.addEventListener("load", b, false)
    } else {
        if (document.addEventListener) {
            document.addEventListener("load", b, false)
        } else {
            if (window.attachEvent) {
                window.attachEvent("onload", b)
            } else {
                if (typeof window.onload == "function") {
                    var a = window.onload;
                    window.onload = function () {
                        a();
                        b()
                    }
                } else {
                    window.onload = init
                }
            }
        }
    }
}
function $getElement(c, b) {
    var a = document.getElementById(c);
    return a
}
var Keys = {
    Enter: 13
};

function $handleSearchEnterKey(d, c) {
    var b = $getElement(d);
    if (b) {
        var a = function (g) {
            var f;
            if (g && g.which) {
                f = g.which
            } else {
                if (typeof (event) != "undefined") {
                    f = event.keyCode
                }
            }
            if (f == Keys.Enter) {
                if (typeof (Page_ClientValidate) != "undefined") {
                    if (Page_ClientValidate() == false) {
                        return
                    }
                }
                c();
                return false
            }
        };
        b.onkeypress = a
    }
}
$.fn.droppy = function (a) {
    a = $.extend({
        speed: 20
    }, a || {});
    this.each(function () {
        var c = this,
            g = 3000;

        function f(j) {
            if (j.nodeName.toLowerCase() == "li") {
                var h = $("> ul", j);
                return h.length ? h[0] : null
            } else {
                return j
            }
        }
        function d(h) {
            if (h.nodeName.toLowerCase() == "ul") {
                return $(h).parents("li")[0]
            } else {
                return h
            }
        }
        function e() {
            var h = f(this);
            if (!h) {
                return
            }
            $.data(h, "cancelHide", false);
            setTimeout(function () {
                if (!$.data(h, "cancelHide")) {
                    $(h).slideUp(a.speed)
                }
            }, 500)
        }
        function b() {
            var j = f(this);
            if (!j) {
                return
            }
            $.data(j, "cancelHide", true);
            $(j).css({
                zIndex: g++
            }).slideDown(a.speed);
            if (this.nodeName.toLowerCase() == "ul") {
                var h = d(this);
                $(h).addClass("hover");
                $("> a", h).addClass("hover")
            }
        }
        $("ul, li", this).hover(b, e);
        $("li", this).hover(function () {
            $(this).addClass("hover");
            $("> a", this).addClass("hover")
        }, function () {
            $(this).removeClass("hover");
            $("> a", this).removeClass("hover")
        })
    })
};
(function (a) {
    a.fn.easySlider = function (b) {
        var c = {
            prevId: "prevBtn",
            prevText: "Previous",
            nextId: "nextBtn",
            nextText: "Next",
            controlsShow: true,
            controlsBefore: "",
            controlsAfter: "",
            controlsFade: true,
            firstId: "firstBtn",
            firstText: "First",
            firstShow: false,
            lastId: "lastBtn",
            lastText: "Last",
            lastShow: false,
            vertical: false,
            speed: 800,
            auto: false,
            pause: 2000,
            continuous: false,
            numeric: false,
            numericId: "controls"
        };
        var b = a.extend(c, b);
        this.each(function () {
            var g = a(this);
            var u = a("li", g).length;
            var q = a("li", g).width();
            var j = a("li", g).height();
            var l = true;
            g.width(q);
            g.height(j);
            g.css("overflow", "hidden");
            var m = u - 1;
            var r = 0;
            a("ul", g).css("width", u * q);
            if (b.continuous) {
                a("ul", g).prepend(a("ul li:last-child", g).clone().css("margin-left", "-" + q + "px"));
                a("ul", g).append(a("ul li:nth-child(2)", g).clone());
                a("ul", g).css("width", (u + 1) * q)
            }
            if (!b.vertical) {
                a("li", g).css("float", "left")
            }
            if (b.controlsShow) {
                var k = b.controlsBefore;
                if (b.numeric) {
                    k += '<ol id="' + b.numericId + '"></ol>'
                } else {
                    if (b.firstShow) {
                        k += '<span id="' + b.firstId + '"><a href="javascript:void(0);">' + b.firstText + "</a></span>"
                    }
                    k += ' <span id="' + b.prevId + '"><a href="javascript:void(0);">' + b.prevText + "</a></span>";
                    k += ' <span id="' + b.nextId + '"><a href="javascript:void(0);">' + b.nextText + "</a></span>";
                    if (b.lastShow) {
                        k += ' <span id="' + b.lastId + '"><a href="javascript:void(0);">' + b.lastText + "</a></span>"
                    }
                }
                k += b.controlsAfter;
                a(g).after(k)
            }
            if (b.numeric) {
                for (var f = 0; f < u; f++) {
                    a(document.createElement("li")).attr("id", b.numericId + (f + 1)).html("<a rel=" + f + ' href="javascript:void(0);">' + (f + 1) + "</a>").appendTo(a("#" + b.numericId)).click(function () {
                        d(a("a", a(this)).attr("rel"), true)
                    })
                }
            } else {
                a("a", "#" + b.nextId).click(function () {
                    d("next", true)
                });
                a("a", "#" + b.prevId).click(function () {
                    d("prev", true)
                });
                a("a", "#" + b.firstId).click(function () {
                    d("first", true)
                });
                a("a", "#" + b.lastId).click(function () {
                    d("last", true)
                })
            }
            function e(h) {
                h = parseInt(h) + 1;
                a("li", "#" + b.numericId).removeClass("current");
                a("li#" + b.numericId + h).addClass("current")
            }
            function o() {
                if (r > m) {
                    r = 0
                }
                if (r < 0) {
                    r = m
                }
                if (!b.vertical) {
                    a("ul", g).css("margin-left", (r * q * -1))
                } else {
                    a("ul", g).css("margin-left", (r * j * -1))
                }
                l = true;
                if (b.numeric) {
                    e(r)
                }
            }
            function d(h, s) {
                if (l) {
                    l = false;
                    var t = r;
                    switch (h) {
                        case "next":
                            r = (t >= m) ? (b.continuous ? r + 1 : m) : r + 1;
                            break;
                        case "prev":
                            r = (r <= 0) ? (b.continuous ? r - 1 : 0) : r - 1;
                            break;
                        case "first":
                            r = 0;
                            break;
                        case "last":
                            r = m;
                            break;
                        default:
                            r = h;
                            break
                    }
                    var w = Math.abs(t - r);
                    var v = w * b.speed;
                    if (!b.vertical) {
                        p = (r * q * -1);
                        a("ul", g).animate({
                            marginLeft: p
                        }, {
                            queue: false,
                            duration: v,
                            complete: o
                        })
                    } else {
                        p = (r * j * -1);
                        a("ul", g).animate({
                            marginTop: p
                        }, {
                            queue: false,
                            duration: v,
                            complete: o
                        })
                    }
                    if (!b.continuous && b.controlsFade) {
                        if (r == m) {
                            a("a", "#" + b.nextId).hide();
                            a("a", "#" + b.lastId).hide()
                        } else {
                            a("a", "#" + b.nextId).show();
                            a("a", "#" + b.lastId).show()
                        }
                        if (r == 0) {
                            a("a", "#" + b.prevId).hide();
                            a("a", "#" + b.firstId).hide()
                        } else {
                            a("a", "#" + b.prevId).show();
                            a("a", "#" + b.firstId).show()
                        }
                    }
                    if (s) {
                        clearTimeout(n)
                    }
                    if (b.auto && h == "next" && !s) {
                        n = setTimeout(function () {
                            d("next", false)
                        }, w * b.speed + b.pause)
                    }
                }
            }
            var n;
            if (b.auto) {
                n = setTimeout(function () {
                    d("next", false)
                }, b.pause)
            }
            if (b.numeric) {
                e(0)
            }
            if (!b.continuous && b.controlsFade) {
                a("a", "#" + b.prevId).hide();
                a("a", "#" + b.firstId).hide()
            }
        })
    }
})(jQuery);
(function (d) {
    d.fn.jqm = function (f) {
        var e = {
            overlay: 50,
            overlayClass: "jqmOverlay",
            closeClass: "jqmClose",
            trigger: ".jqModal",
            ajax: o,
            ajaxText: "",
            target: o,
            modal: o,
            toTop: o,
            onShow: o,
            onHide: o,
            onLoad: o
        };
        return this.each(function () {
            if (this._jqm) {
                return n[this._jqm].c = d.extend({}, n[this._jqm].c, f)
            }
            q++;
            this._jqm = q;
            n[q] = {
                c: d.extend(e, d.jqm.params, f),
                a: o,
                w: d(this).addClass("jqmID" + q),
                s: q
            };
            if (e.trigger) {
                d(this).jqmAddTrigger(e.trigger)
            }
        })
    };
    d.fn.jqmAddClose = function (f) {
        return l(this, f, "jqmHide")
    };
    d.fn.jqmAddTrigger = function (f) {
        return l(this, f, "jqmShow")
    };
    d.fn.jqmShow = function (e) {
        return this.each(function () {
            e = e || window.event;
            d.jqm.open(this._jqm, e)
        })
    };
    d.fn.jqmHide = function (e) {
        return this.each(function () {
            e = e || window.event;
            d.jqm.close(this._jqm, e)
        })
    };
    d.jqm = {
        hash: {},
        open: function (D, C) {
            var v = n[D],
                w = v.c,
                m = "." + w.closeClass,
                x = (parseInt(v.w.css("z-index"))),
                x = (x > 0) ? x : 3000,
                f = d("<div></div>").css({
                    height: "100%",
                    width: "100%",
                    position: "fixed",
                    left: 0,
                    top: 0,
                    "z-index": x - 1,
                    opacity: w.overlay / 100
                });
            if (v.a) {
                return o
            }
            v.t = C;
            v.a = true;
            v.w.css("z-index", x);
            if (w.modal) {
                if (!a[0]) {
                    k("bind")
                }
                a.push(D)
            } else {
                if (w.overlay > 0) {
                    v.w.jqmAddClose(f)
                } else {
                    f = o
                }
            }
            v.o = (f) ? f.addClass(w.overlayClass).prependTo("body") : o;
            if (c) {
                d("html,body").css({
                    height: "100%",
                    width: "100%"
                });
                if (f) {
                    f = f.css({
                        position: "absolute"
                    })[0];
                    for (var A in {
                        Top: 1,
                        Left: 1
                    }) {
                        f.style.setExpression(A.toLowerCase(), "(_=(document.documentElement.scroll" + A + " || document.body.scroll" + A + "))+'px'")
                    }
                }
            }
            if (w.ajax) {
                var e = w.target || v.w,
                    B = w.ajax,
                    e = (typeof e == "string") ? d(e, v.w) : d(e),
                    B = (B.substr(0, 1) == "@") ? d(C).attr(B.substring(1)) : B;
                e.html(w.ajaxText).load(B, function () {
                    if (w.onLoad) {
                        w.onLoad.call(this, v)
                    }
                    if (m) {
                        v.w.jqmAddClose(d(m, v.w))
                    }
                    j(v)
                })
            } else {
                if (m) {
                    v.w.jqmAddClose(d(m, v.w))
                }
            }
            if (w.toTop && v.o) {
                v.w.before('<span id="jqmP' + v.w[0]._jqm + '"></span>').insertAfter(v.o)
            } (w.onShow) ? w.onShow(v) : v.w.show();
            j(v);
            return o
        },
        close: function (f) {
            var e = n[f];
            if (!e.a) {
                return o
            }
            e.a = o;
            if (a[0]) {
                a.pop();
                if (!a[0]) {
                    k("unbind")
                }
            }
            if (e.c.toTop && e.o) {
                d("#jqmP" + e.w[0]._jqm).after(e.w).remove()
            }
            if (e.c.onHide) {
                e.c.onHide(e)
            } else {
                e.w.hide();
                if (e.o) {
                    e.o.remove()
                }
            }
            return o
        },
        params: {}
    };
    var q = 0,
        n = d.jqm.hash,
        a = [],
        c = d.browser.msie && (d.browser.version == "6.0"),
        o = false,
        g = d('<iframe src="javascript:false;document.write(\'\');" class="jqm"></iframe>').css({
            opacity: 0
        }),
        j = function (e) {
            if (c) {
                if (e.o) {
                    e.o.html('<p style="width:100%;height:100%"/>').prepend(g)
                } else {
                    if (!d("iframe.jqm", e.w)[0]) {
                        e.w.prepend(g)
                    }
                }
            }
            h(e)
        },
        h = function (f) {
            try {
                d(":input:visible", f.w)[0].focus()
            } catch (e) { }
        },
        k = function (e) {
            d()[e]("keypress", b)[e]("keydown", b)[e]("mousedown", b)
        },
        b = function (s) {
            var f = n[a[a.length - 1]],
                m = (!d(s.target).parents(".jqmID" + f.s)[0]);
            if (m) {
                h(f)
            }
            return !m
        },
        l = function (e, f, m) {
            return e.each(function () {
                var r = this._jqm;
                d(f).each(function () {
                    if (!this[m]) {
                        this[m] = [];
                        d(this).click(function () {
                            for (var t in {
                                jqmShow: 1,
                                jqmHide: 1
                            }) {
                                for (var u in this[t]) {
                                    if (n[this[t][u]]) {
                                        n[this[t][u]].w[t](this)
                                    }
                                }
                            }
                            return o
                        })
                    }
                    this[m].push(r)
                })
            })
        }
})(jQuery);
(function (b) {
    b.fn.ajaxSubmit = function (u) {
        if (!this.length) {
            a("ajaxSubmit: skipping submit process - no element selected");
            return this
        }
        if (typeof u == "function") {
            u = {
                success: u
            }
        }
        var e = b.trim(this.attr("action"));
        if (e) {
            e = (e.match(/^([^#]+)/) || [])[1]
        }
        e = e || window.location.href || "";
        u = b.extend({
            url: e,
            type: this.attr("method") || "GET",
            iframeSrc: /^https/i.test(window.location.href || "") ? "javascript:false" : "about:blank"
        }, u || {});
        var w = {};
        this.trigger("form-pre-serialize", [this, u, w]);
        if (w.veto) {
            a("ajaxSubmit: submit vetoed via form-pre-serialize trigger");
            return this
        }
        if (u.beforeSerialize && u.beforeSerialize(this, u) === false) {
            a("ajaxSubmit: submit aborted via beforeSerialize callback");
            return this
        }
        var o = this.formToArray(u.semantic);
        if (u.data) {
            u.extraData = u.data;
            for (var f in u.data) {
                if (u.data[f] instanceof Array) {
                    for (var g in u.data[f]) {
                        o.push({
                            name: f,
                            value: u.data[f][g]
                        })
                    }
                } else {
                    o.push({
                        name: f,
                        value: u.data[f]
                    })
                }
            }
        }
        if (u.beforeSubmit && u.beforeSubmit(o, this, u) === false) {
            a("ajaxSubmit: submit aborted via beforeSubmit callback");
            return this
        }
        this.trigger("form-submit-validate", [o, this, u, w]);
        if (w.veto) {
            a("ajaxSubmit: submit vetoed via form-submit-validate trigger");
            return this
        }
        var d = b.param(o);
        if (u.type.toUpperCase() == "GET") {
            u.url += (u.url.indexOf("?") >= 0 ? "&" : "?") + d;
            u.data = null
        } else {
            u.data = d
        }
        var v = this,
            m = [];
        if (u.resetForm) {
            m.push(function () {
                v.resetForm()
            })
        }
        if (u.clearForm) {
            m.push(function () {
                v.clearForm()
            })
        }
        if (!u.dataType && u.target) {
            var s = u.success ||
            function () { };
            m.push(function (j) {
                b(u.target).html(j).each(s, arguments)
            })
        } else {
            if (u.success) {
                m.push(u.success)
            }
        }
        u.success = function (q, k) {
            for (var n = 0, j = m.length; n < j; n++) {
                m[n].apply(u, [q, k, v])
            }
        };
        var c = b("input:file", this).fieldValue();
        var t = false;
        for (var l = 0; l < c.length; l++) {
            if (c[l]) {
                t = true
            }
        }
        var h = false;
        if ((c.length && u.iframe !== false) || u.iframe || t || h) {
            if (u.closeKeepAlive) {
                b.get(u.closeKeepAlive, r)
            } else {
                r()
            }
        } else {
            b.ajax(u)
        }
        this.trigger("form-submit-notify", [this, u]);
        return this;

        function r() {
            var y = v[0];
            if (b(":input[name=submit]", y).length) {
                alert('Error: Form elements must not be named "submit".');
                return
            }
            var q = b.extend({}, b.ajaxSettings, u);
            var I = b.extend(true, {}, b.extend(true, {}, b.ajaxSettings), q);
            var x = "jqFormIO" + (new Date().getTime());
            var E = b('<iframe id="' + x + '" name="' + x + '" src="' + q.iframeSrc + '" />');
            var G = E[0];
            E.css({
                position: "absolute",
                top: "-1000px",
                left: "-1000px"
            });
            var H = {
                aborted: 0,
                responseText: null,
                responseXML: null,
                status: 0,
                statusText: "n/a",
                getAllResponseHeaders: function () { },
                getResponseHeader: function () { },
                setRequestHeader: function () { },
                abort: function () {
                    this.aborted = 1;
                    E.attr("src", q.iframeSrc)
                }
            };
            var F = q.global;
            if (F && !b.active++) {
                b.event.trigger("ajaxStart")
            }
            if (F) {
                b.event.trigger("ajaxSend", [H, q])
            }
            if (I.beforeSend && I.beforeSend(H, I) === false) {
                I.global && b.active--;
                return
            }
            if (H.aborted) {
                return
            }
            var k = 0;
            var B = 0;
            var j = y.clk;
            if (j) {
                var z = j.name;
                if (z && !j.disabled) {
                    u.extraData = u.extraData || {};
                    u.extraData[z] = j.value;
                    if (j.type == "image") {
                        u.extraData[name + ".x"] = y.clk_x;
                        u.extraData[name + ".y"] = y.clk_y
                    }
                }
            }
            setTimeout(function () {
                var L = v.attr("target"),
                    J = v.attr("action");
                y.setAttribute("target", x);
                if (y.getAttribute("method") != "POST") {
                    y.setAttribute("method", "POST")
                }
                if (y.getAttribute("action") != q.url) {
                    y.setAttribute("action", q.url)
                }
                if (!u.skipEncodingOverride) {
                    v.attr({
                        encoding: "multipart/form-data",
                        enctype: "multipart/form-data"
                    })
                }
                if (q.timeout) {
                    setTimeout(function () {
                        B = true;
                        C()
                    }, q.timeout)
                }
                var K = [];
                try {
                    if (u.extraData) {
                        for (var M in u.extraData) {
                            K.push(b('<input type="hidden" name="' + M + '" value="' + u.extraData[M] + '" />').appendTo(y)[0])
                        }
                    }
                    E.appendTo("body");
                    G.attachEvent ? G.attachEvent("onload", C) : G.addEventListener("load", C, false);
                    y.submit()
                } finally {
                    y.setAttribute("action", J);
                    L ? y.setAttribute("target", L) : v.removeAttr("target");
                    b(K).remove()
                }
            }, 10);
            var A = 50;

            function C() {
                if (k++) {
                    return
                }
                G.detachEvent ? G.detachEvent("onload", C) : G.removeEventListener("load", C, false);
                var J = true;
                try {
                    if (B) {
                        throw "timeout"
                    }
                    var K, N;
                    N = G.contentWindow ? G.contentWindow.document : G.contentDocument ? G.contentDocument : G.document;
                    var O = q.dataType == "xml" || N.XMLDocument || b.isXMLDoc(N);
                    a("isXml=" + O);
                    if (!O && (N.body == null || N.body.innerHTML == "")) {
                        if (--A) {
                            k = 0;
                            setTimeout(C, 100);
                            return
                        }
                        a("Could not access iframe DOM after 50 tries.");
                        return
                    }
                    H.responseText = N.body ? N.body.innerHTML : null;
                    H.responseXML = N.XMLDocument ? N.XMLDocument : N;
                    H.getResponseHeader = function (Q) {
                        var P = {
                            "content-type": q.dataType
                        };
                        return P[Q]
                    };
                    if (q.dataType == "json" || q.dataType == "script") {
                        var n = N.getElementsByTagName("textarea")[0];
                        if (n) {
                            H.responseText = n.value
                        } else {
                            var M = N.getElementsByTagName("pre")[0];
                            if (M) {
                                H.responseText = M.innerHTML
                            }
                        }
                    } else {
                        if (q.dataType == "xml" && !H.responseXML && H.responseText != null) {
                            H.responseXML = D(H.responseText)
                        }
                    }
                    K = b.httpData(H, q.dataType)
                } catch (L) {
                    J = false;
                    b.handleError(q, H, "error", L)
                }
                if (J) {
                    q.success(K, "success");
                    if (F) {
                        b.event.trigger("ajaxSuccess", [H, q])
                    }
                }
                if (F) {
                    b.event.trigger("ajaxComplete", [H, q])
                }
                if (F && ! --b.active) {
                    b.event.trigger("ajaxStop")
                }
                if (q.complete) {
                    q.complete(H, J ? "success" : "error")
                }
                setTimeout(function () {
                    E.remove();
                    H.responseXML = null
                }, 100)
            }
            function D(n, J) {
                if (window.ActiveXObject) {
                    J = new ActiveXObject("Microsoft.XMLDOM");
                    J.async = "false";
                    J.loadXML(n)
                } else {
                    J = (new DOMParser()).parseFromString(n, "text/xml")
                }
                return (J && J.documentElement && J.documentElement.tagName != "parsererror") ? J : null
            }
        }
    };
    b.fn.ajaxForm = function (c) {
        return this.ajaxFormUnbind().bind("submit.form-plugin", function () {
            b(this).ajaxSubmit(c);
            return false
        }).bind("click.form-plugin", function (j) {
            var h = j.target;
            var f = b(h);
            if (!(f.is(":submit,input:image"))) {
                var d = f.closest(":submit");
                if (d.length == 0) {
                    return
                }
                h = d[0]
            }
            var g = this;
            g.clk = h;
            if (h.type == "image") {
                if (j.offsetX != undefined) {
                    g.clk_x = j.offsetX;
                    g.clk_y = j.offsetY
                } else {
                    if (typeof b.fn.offset == "function") {
                        var k = f.offset();
                        g.clk_x = j.pageX - k.left;
                        g.clk_y = j.pageY - k.top
                    } else {
                        g.clk_x = j.pageX - h.offsetLeft;
                        g.clk_y = j.pageY - h.offsetTop
                    }
                }
            }
            setTimeout(function () {
                g.clk = g.clk_x = g.clk_y = null
            }, 100)
        })
    };
    b.fn.ajaxFormUnbind = function () {
        return this.unbind("submit.form-plugin click.form-plugin")
    };
    b.fn.formToArray = function (r) {
        var q = [];
        if (this.length == 0) {
            return q
        }
        var d = this[0];
        var h = r ? d.getElementsByTagName("*") : d.elements;
        if (!h) {
            return q
        }
        for (var k = 0, m = h.length; k < m; k++) {
            var e = h[k];
            var f = e.name;
            if (!f) {
                continue
            }
            if (r && d.clk && e.type == "image") {
                if (!e.disabled && d.clk == e) {
                    q.push({
                        name: f,
                        value: b(e).val()
                    });
                    q.push({
                        name: f + ".x",
                        value: d.clk_x
                    }, {
                        name: f + ".y",
                        value: d.clk_y
                    })
                }
                continue
            }
            var s = b.fieldValue(e, true);
            if (s && s.constructor == Array) {
                for (var g = 0, c = s.length; g < c; g++) {
                    q.push({
                        name: f,
                        value: s[g]
                    })
                }
            } else {
                if (s !== null && typeof s != "undefined") {
                    q.push({
                        name: f,
                        value: s
                    })
                }
            }
        }
        if (!r && d.clk) {
            var l = b(d.clk),
                o = l[0],
                f = o.name;
            if (f && !o.disabled && o.type == "image") {
                q.push({
                    name: f,
                    value: l.val()
                });
                q.push({
                    name: f + ".x",
                    value: d.clk_x
                }, {
                    name: f + ".y",
                    value: d.clk_y
                })
            }
        }
        return q
    };
    b.fn.formSerialize = function (c) {
        return b.param(this.formToArray(c))
    };
    b.fn.fieldSerialize = function (d) {
        var c = [];
        this.each(function () {
            var h = this.name;
            if (!h) {
                return
            }
            var f = b.fieldValue(this, d);
            if (f && f.constructor == Array) {
                for (var g = 0, e = f.length; g < e; g++) {
                    c.push({
                        name: h,
                        value: f[g]
                    })
                }
            } else {
                if (f !== null && typeof f != "undefined") {
                    c.push({
                        name: this.name,
                        value: f
                    })
                }
            }
        });
        return b.param(c)
    };
    b.fn.fieldValue = function (h) {
        for (var g = [], e = 0, c = this.length; e < c; e++) {
            var f = this[e];
            var d = b.fieldValue(f, h);
            if (d === null || typeof d == "undefined" || (d.constructor == Array && !d.length)) {
                continue
            }
            d.constructor == Array ? b.merge(g, d) : g.push(d)
        }
        return g
    };
    b.fieldValue = function (c, j) {
        var e = c.name,
            q = c.type,
            r = c.tagName.toLowerCase();
        if (typeof j == "undefined") {
            j = true
        }
        if (j && (!e || c.disabled || q == "reset" || q == "button" || (q == "checkbox" || q == "radio") && !c.checked || (q == "submit" || q == "image") && c.form && c.form.clk != c || r == "select" && c.selectedIndex == -1)) {
            return null
        }
        if (r == "select") {
            var k = c.selectedIndex;
            if (k < 0) {
                return null
            }
            var m = [],
                d = c.options;
            var g = (q == "select-one");
            var l = (g ? k + 1 : d.length);
            for (var f = (g ? k : 0); f < l; f++) {
                var h = d[f];
                if (h.selected) {
                    var o = h.value;
                    if (!o) {
                        o = (h.attributes && h.attributes.value && !(h.attributes.value.specified)) ? h.text : h.value
                    }
                    if (g) {
                        return o
                    }
                    m.push(o)
                }
            }
            return m
        }
        return c.value
    };
    b.fn.clearForm = function () {
        return this.each(function () {
            b("input,select,textarea", this).clearFields()
        })
    };
    b.fn.clearFields = b.fn.clearInputs = function () {
        return this.each(function () {
            var d = this.type,
                c = this.tagName.toLowerCase();
            if (d == "text" || d == "password" || c == "textarea") {
                this.value = ""
            } else {
                if (d == "checkbox" || d == "radio") {
                    this.checked = false
                } else {
                    if (c == "select") {
                        this.selectedIndex = -1
                    }
                }
            }
        })
    };
    b.fn.resetForm = function () {
        return this.each(function () {
            if (typeof this.reset == "function" || (typeof this.reset == "object" && !this.reset.nodeType)) {
                this.reset()
            }
        })
    };
    b.fn.enable = function (c) {
        if (c == undefined) {
            c = true
        }
        return this.each(function () {
            this.disabled = !c
        })
    };
    b.fn.selected = function (c) {
        if (c == undefined) {
            c = true
        }
        return this.each(function () {
            var d = this.type;
            if (d == "checkbox" || d == "radio") {
                this.checked = c
            } else {
                if (this.tagName.toLowerCase() == "option") {
                    var e = b(this).parent("select");
                    if (c && e[0] && e[0].type == "select-one") {
                        e.find("option").selected(false)
                    }
                    this.selected = c
                }
            }
        })
    };

    function a() {
        if (b.fn.ajaxSubmit.debug && window.console && window.console.log) {
            window.console.log("[jquery.form] " + Array.prototype.join.call(arguments, ""))
        }
    }
})(jQuery);
(function (a) {
    a.prompt = function (r, s) {
        s = a.extend({}, a.prompt.defaults, s);
        a.prompt.currentPrefix = s.prefix;
        var e = (a.browser.msie && a.browser.version < 7);
        var g = a(document.body);
        var c = a(window);
        s.classes = a.trim(s.classes);
        if (s.classes != "") {
            s.classes = " " + s.classes
        }
        var b = '<div class="' + s.prefix + "box" + s.classes + '" id="' + s.prefix + 'box">';
        if (s.useiframe && ((a("object, applet").length > 0) || e)) {
            b += '<iframe src="javascript:false;" style="display:block;position:absolute;z-index:-1;" class="' + s.prefix + 'fade" id="' + s.prefix + 'fade"></iframe>'
        } else {
            if (e) {
                a("select").css("visibility", "hidden")
            }
            b += '<div class="' + s.prefix + 'fade" id="' + s.prefix + 'fade"></div>'
        }
        b += '<div class="' + s.prefix + '" id="' + s.prefix + '"><div class="' + s.prefix + 'container"><div class="';
        b += s.prefix + 'close">X</div><div id="' + s.prefix + 'states"></div>';
        b += "</div></div></div>";
        var q = a(b).appendTo(g);
        var m = q.children("#" + s.prefix);
        var n = q.children("#" + s.prefix + "fade");
        if (r.constructor == String) {
            r = {
                state0: {
                    html: r,
                    buttons: s.buttons,
                    focus: s.focus,
                    submit: s.submit
                }
            }
        }
        var o = "";
        a.each(r, function (u, t) {
            t = a.extend({}, a.prompt.defaults.state, t);
            r[u] = t;
            o += '<div id="' + s.prefix + "_state_" + u + '" class="' + s.prefix + '_state" style="display:none;"><div class="' + s.prefix + 'message">' + t.html + '</div><div class="' + s.prefix + 'buttons">';
            a.each(t.buttons, function (x, w) {
                if (typeof w == "object") {
                    o += '<button name="' + s.prefix + "_" + u + "_button" + w.title.replace(/[^a-z0-9]+/gi, "") + '" id="' + s.prefix + "_" + u + "_button" + w.title.replace(/[^a-z0-9]+/gi, "") + '" value="' + w.value + '">' + w.title + "</button>"
                } else {
                    o += '<button name="' + s.prefix + "_" + u + "_button" + x + '" id="' + s.prefix + "_" + u + "_button" + x + '" value="' + w + '">' + x + "</button>"
                }
            });
            o += "</div></div>"
        });
        m.find("#" + s.prefix + "states").html(o).children("." + s.prefix + "_state:first").css("display", "block");
        m.find("." + s.prefix + "buttons:empty").css("display", "none");
        a.each(r, function (v, u) {
            var t = m.find("#" + s.prefix + "_state_" + v);
            t.children("." + s.prefix + "buttons").children("button").click(function () {
                var z = t.children("." + s.prefix + "message");
                var x = u.buttons[a(this).text()];
                if (x == undefined) {
                    for (var w in u.buttons) {
                        if (u.buttons[w].title == a(this).text()) {
                            x = u.buttons[w].value
                        }
                    }
                }
                if (typeof x == "object") {
                    x = x.value
                }
                var A = {};
                a.each(m.find("#" + s.prefix + "states :input").serializeArray(), function (B, C) {
                    if (A[C.name] === undefined) {
                        A[C.name] = C.value
                    } else {
                        if (typeof A[C.name] == Array || typeof A[C.name] == "object") {
                            A[C.name].push(C.value)
                        } else {
                            A[C.name] = [A[C.name], C.value]
                        }
                    }
                });
                var y = u.submit(x, z, A);
                if (y === undefined || y) {
                    d(true, x, z, A)
                }
            });
            t.find("." + s.prefix + "buttons button:eq(" + u.focus + ")").addClass(s.prefix + "defaultbutton")
        });
        var f = function () {
            q.css({
                top: c.scrollTop()
            })
        };
        var k = function () {
            if (s.persistent) {
                var u = 0;
                q.addClass(s.prefix + "warning");
                var t = setInterval(function () {
                    q.toggleClass(s.prefix + "warning");
                    if (u++ > 1) {
                        clearInterval(t);
                        q.removeClass(s.prefix + "warning")
                    }
                }, 100)
            } else {
                d()
            }
        };
        var h = function (w) {
            var v = (window.event) ? event.keyCode : w.keyCode;
            if (v == 27) {
                k()
            }
            if (v == 9) {
                var x = a(":input:enabled:visible", q);
                var u = !w.shiftKey && w.target == x[x.length - 1];
                var t = w.shiftKey && w.target == x[0];
                if (u || t) {
                    setTimeout(function () {
                        if (!x) {
                            return
                        }
                        var y = x[t === true ? x.length - 1 : 0];
                        if (y) {
                            y.focus()
                        }
                    }, 10);
                    return false
                }
            }
        };
        var j = function () {
            q.css({
                position: (e) ? "absolute" : "fixed",
                height: c.height(),
                width: "100%",
                top: (e) ? c.scrollTop() : 0,
                left: 0,
                right: 0,
                bottom: 0
            });
            n.css({
                position: "absolute",
                height: c.height(),
                width: "100%",
                top: 0,
                left: 0,
                right: 0,
                bottom: 0
            });
            m.css({
                position: "absolute",
                top: s.top,
                left: "50%",
                marginLeft: ((m.outerWidth() / 2) * -1)
            })
        };
        var l = function () {
            n.css({
                zIndex: s.zIndex,
                display: "none",
                opacity: s.opacity
            });
            m.css({
                zIndex: s.zIndex + 1,
                display: "none"
            });
            q.css({
                zIndex: s.zIndex
            })
        };
        var d = function (v, u, w, t) {
            m.remove();
            if (e) {
                g.unbind("scroll", f)
            }
            c.unbind("resize", j);
            n.fadeOut(s.overlayspeed, function () {
                n.unbind("click", k);
                n.remove();
                if (v) {
                    s.callback(u, w, t)
                }
                q.unbind("keypress", h);
                q.remove();
                if (e && !s.useiframe) {
                    a("select").css("visibility", "visible")
                }
            })
        };
        j();
        l();
        if (e) {
            c.scroll(f)
        }
        n.click(k);
        c.resize(j);
        q.bind("keydown keypress", h);
        m.find("." + s.prefix + "close").click(d);
        n.fadeIn(s.overlayspeed);
        m[s.show](s.promptspeed, s.loaded);
        m.find("#" + s.prefix + "states ." + s.prefix + "_state:first ." + s.prefix + "defaultbutton").focus();
        if (s.timeout > 0) {
            setTimeout(a.prompt.close, s.timeout)
        }
        return q
    };
    a.prompt.defaults = {
        prefix: "jqi",
        classes: "",
        buttons: {
            Ok: true
        },
        loaded: function () { },
        submit: function () {
            return true
        },
        callback: function () { },
        opacity: 0.6,
        zIndex: 999,
        overlayspeed: "slow",
        promptspeed: "fast",
        show: "fadeIn",
        focus: 0,
        useiframe: false,
        top: "15%",
        persistent: true,
        timeout: 0,
        state: {
            html: "",
            buttons: {
                Ok: true
            },
            focus: 0,
            submit: function () {
                return true
            }
        }
    };
    a.prompt.currentPrefix = a.prompt.defaults.prefix;
    a.prompt.setDefaults = function (b) {
        a.prompt.defaults = a.extend({}, a.prompt.defaults, b)
    };
    a.prompt.setStateDefaults = function (b) {
        a.prompt.defaults.state = a.extend({}, a.prompt.defaults.state, b)
    };
    a.prompt.getStateContent = function (b) {
        return a("#" + a.prompt.currentPrefix + "_state_" + b)
    };
    a.prompt.getCurrentState = function () {
        return a("." + a.prompt.currentPrefix + "_state:visible")
    };
    a.prompt.getCurrentStateName = function () {
        var b = a.prompt.getCurrentState().attr("id");
        return b.replace(a.prompt.currentPrefix + "_state_", "")
    };
    a.prompt.goToState = function (b, c) {
        a("." + a.prompt.currentPrefix + "_state").slideUp("slow");
        a("#" + a.prompt.currentPrefix + "_state_" + b).slideDown("slow", function () {
            a(this).find("." + a.prompt.currentPrefix + "defaultbutton").focus();
            if (typeof c == "function") {
                c()
            }
        })
    };
    a.prompt.nextState = function (c) {
        var b = a("." + a.prompt.currentPrefix + "_state:visible").next();
        a("." + a.prompt.currentPrefix + "_state").slideUp("slow");
        b.slideDown("slow", function () {
            b.find("." + a.prompt.currentPrefix + "defaultbutton").focus();
            if (typeof c == "function") {
                c()
            }
        })
    };
    a.prompt.prevState = function (c) {
        var b = a("." + a.prompt.currentPrefix + "_state:visible").prev();
        a("." + a.prompt.currentPrefix + "_state").slideUp("slow");
        b.slideDown("slow", function () {
            b.find("." + a.prompt.currentPrefix + "defaultbutton").focus();
            if (typeof c == "function") {
                c()
            }
        })
    };
    a.prompt.close = function () {
        a("#" + a.prompt.currentPrefix + "box").fadeOut("fast", function () {
            a(this).remove()
        })
    };
    a.fn.prompt = function (b) {
        if (b == undefined) {
            b = {}
        }
        if (b.withDataAndEvents == undefined) {
            b.withDataAndEvents = false
        }
        a.prompt(a(this).clone(b.withDataAndEvents).html(), b)
    }
})(jQuery);
(function (a) {
    a.prettyPhoto = {
        version: "3.0"
    };
    a.fn.prettyPhoto = function (d) {
        d = jQuery.extend({
            animation_speed: "fast",
            slideshow: false,
            autoplay_slideshow: false,
            opacity: 0.8,
            show_title: true,
            allow_resize: true,
            default_width: 500,
            default_height: 344,
            counter_separator_label: "/",
            theme: "facebook",
            hideflash: false,
            wmode: "opaque",
            autoplay: true,
            modal: false,
            overlay_gallery: true,
            keyboard_shortcuts: true,
            changepicturecallback: function () { },
            callback: function () { },
            markup: '<div class="pp_pic_holder"><div class="ppt">&nbsp;</div><div class="pp_top"><div class="pp_left"></div><div class="pp_middle"></div><div class="pp_right"></div></div><div class="pp_content_container"><div class="pp_left"><div class="pp_right"><div class="pp_content"><div class="pp_loaderIcon"></div><div class="pp_fade"><a href="#" class="pp_expand" title="Expand the image">Expand</a><div class="pp_hoverContainer"><a class="pp_next" href="#">next</a><a class="pp_previous" href="#">previous</a></div><div id="pp_full_res"></div><div class="pp_details clearfix"><p class="pp_description"></p><a class="pp_close" href="#">Close</a><div class="pp_nav"><a href="#" class="pp_arrow_previous">Previous</a><p class="currentTextHolder">0/0</p><a href="#" class="pp_arrow_next">Next</a></div></div></div></div></div></div></div><div class="pp_bottom"><div class="pp_left"></div><div class="pp_middle"></div><div class="pp_right"></div></div></div><div class="pp_overlay"></div>',
            gallery_markup: '<div class="pp_gallery"><a href="#" class="pp_arrow_previous">Previous</a><ul>{gallery}</ul><a href="#" class="pp_arrow_next">Next</a></div>',
            image_markup: '<img id="fullResImage" src="" />',
            flash_markup: '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="{width}" height="{height}"><param name="wmode" value="{wmode}" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="{path}" /><embed src="{path}" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="{width}" height="{height}" wmode="{wmode}"></embed></object>',
            quicktime_markup: '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" height="{height}" width="{width}"><param name="src" value="{path}"><param name="autoplay" value="{autoplay}"><param name="type" value="video/quicktime"><embed src="{path}" height="{height}" width="{width}" autoplay="{autoplay}" type="video/quicktime" pluginspage="http://www.apple.com/quicktime/download/"></embed></object>',
            iframe_markup: '<iframe src ="{path}" width="{width}" height="{height}" frameborder="no"></iframe>',
            inline_markup: '<div class="pp_inline clearfix">{content}</div>',
            custom_markup: ""
        }, d);
        var j = this,
            h = false,
            u, n, o, q, t, w, e = a(window).height(),
            z = a(window).width(),
            f;
        doresize = true, scroll_pos = x();
        a(window).unbind("resize").resize(function () {
            m();
            s()
        });
        if (d.keyboard_shortcuts) {
            a(document).unbind("keydown").keydown(function (A) {
                if (typeof $pp_pic_holder != "undefined") {
                    if ($pp_pic_holder.is(":visible")) {
                        switch (A.keyCode) {
                            case 37:
                                a.prettyPhoto.changePage("previous");
                                break;
                            case 39:
                                a.prettyPhoto.changePage("next");
                                break;
                            case 27:
                                if (!settings.modal) {
                                    a.prettyPhoto.close()
                                }
                                break
                        }
                        return false
                    }
                }
            })
        }
        a.prettyPhoto.initialize = function () {
            settings = d;
            if (a.browser.msie && parseInt(a.browser.version) == 6) {
                settings.theme = "light_square"
            }
            v(this);
            if (settings.allow_resize) {
                a(window).scroll(function () {
                    m()
                })
            }
            m();
            set_position = jQuery.inArray(a(this).attr("href"), pp_images);
            a.prettyPhoto.open();
            return false
        };
        a.prettyPhoto.open = function () {
            if (typeof settings == "undefined") {
                settings = d;
                if (a.browser.msie && a.browser.version == 6) {
                    settings.theme = "light_square"
                }
                v(this);
                pp_images = a.makeArray(arguments[0]);
                pp_titles = (arguments[1]) ? a.makeArray(arguments[1]) : a.makeArray("");
                pp_descriptions = (arguments[2]) ? a.makeArray(arguments[2]) : a.makeArray("");
                isSet = (pp_images.length > 1) ? true : false;
                set_position = 0
            }
            if (a.browser.msie && a.browser.version == 6) {
                a("select").css("visibility", "hidden")
            }
            if (settings.hideflash) {
                a("object,embed").css("visibility", "hidden")
            }
            g(a(pp_images).size());
            a(".pp_loaderIcon").show();
            if ($ppt.is(":hidden")) {
                $ppt.css("opacity", 0).show()
            }
            $pp_overlay.show().fadeTo(settings.animation_speed, settings.opacity);
            $pp_pic_holder.find(".currentTextHolder").text((set_position + 1) + settings.counter_separator_label + a(pp_images).size());
            $pp_pic_holder.find(".pp_description").show().html(unescape(pp_descriptions[set_position]));
            (settings.show_title && pp_titles[set_position] != "") ? $ppt.html(unescape(pp_titles[set_position])) : $ppt.html("&nbsp;");
            movie_width = (parseFloat(b("width", pp_images[set_position]))) ? b("width", pp_images[set_position]) : settings.default_width.toString();
            movie_height = (parseFloat(b("height", pp_images[set_position]))) ? b("height", pp_images[set_position]) : settings.default_height.toString();
            if (movie_width.indexOf("%") != -1 || movie_height.indexOf("%") != -1) {
                movie_height = parseFloat((a(window).height() * parseFloat(movie_height) / 100) - 150);
                movie_width = parseFloat((a(window).width() * parseFloat(movie_width) / 100) - 150);
                h = true
            } else {
                h = false
            }
            $pp_pic_holder.fadeIn(function () {
                imgPreloader = "";
                switch (y(pp_images[set_position])) {
                    case "image":
                        imgPreloader = new Image();
                        nextImage = new Image();
                        if (isSet && set_position > a(pp_images).size()) {
                            nextImage.src = pp_images[set_position + 1]
                        }
                        prevImage = new Image();
                        if (isSet && pp_images[set_position - 1]) {
                            prevImage.src = pp_images[set_position - 1]
                        }
                        $pp_pic_holder.find("#pp_full_res")[0].innerHTML = settings.image_markup;
                        $pp_pic_holder.find("#fullResImage").attr("src", pp_images[set_position]);
                        imgPreloader.onload = function () {
                            u = l(imgPreloader.width, imgPreloader.height);
                            _showContent()
                        };
                        imgPreloader.onerror = function () {
                            alert("Image cannot be loaded. Make sure the path is correct and image exist.");
                            a.prettyPhoto.close()
                        };
                        imgPreloader.src = pp_images[set_position];
                        break;
                    case "youtube":
                        u = l(movie_width, movie_height);
                        movie = "http://www.youtube.com/v/" + b("v", pp_images[set_position]);
                        if (settings.autoplay) {
                            movie += "&autoplay=1"
                        }
                        toInject = settings.flash_markup.replace(/{width}/g, u.width).replace(/{height}/g, u.height).replace(/{wmode}/g, settings.wmode).replace(/{path}/g, movie);
                        break;
                    case "vimeo":
                        u = l(movie_width, movie_height);
                        movie_id = pp_images[set_position];
                        var B = /http:\/\/(www\.)?vimeo.com\/(\d+)/;
                        var A = movie_id.match(B);
                        movie = "http://player.vimeo.com/video/" + A[2] + "?title=0&amp;byline=0&amp;portrait=0";
                        if (settings.autoplay) {
                            movie += "&autoplay=1;"
                        }
                        vimeo_width = u.width + "/embed/?moog_width=" + u.width;
                        toInject = settings.iframe_markup.replace(/{width}/g, vimeo_width).replace(/{height}/g, u.height).replace(/{path}/g, movie);
                        break;
                    case "quicktime":
                        u = l(movie_width, movie_height);
                        u.height += 15;
                        u.contentHeight += 15;
                        u.containerHeight += 15;
                        toInject = settings.quicktime_markup.replace(/{width}/g, u.width).replace(/{height}/g, u.height).replace(/{wmode}/g, settings.wmode).replace(/{path}/g, pp_images[set_position]).replace(/{autoplay}/g, settings.autoplay);
                        break;
                    case "flash":
                        u = l(movie_width, movie_height);
                        flash_vars = pp_images[set_position];
                        flash_vars = flash_vars.substring(pp_images[set_position].indexOf("flashvars") + 10, pp_images[set_position].length);
                        filename = pp_images[set_position];
                        filename = filename.substring(0, filename.indexOf("?"));
                        toInject = settings.flash_markup.replace(/{width}/g, u.width).replace(/{height}/g, u.height).replace(/{wmode}/g, settings.wmode).replace(/{path}/g, filename + "?" + flash_vars);
                        break;
                    case "iframe":
                        u = l(movie_width, movie_height);
                        frame_url = pp_images[set_position];
                        frame_url = frame_url.substr(0, frame_url.indexOf("iframe") - 1);
                        toInject = settings.iframe_markup.replace(/{width}/g, u.width).replace(/{height}/g, u.height).replace(/{path}/g, frame_url);
                        break;
                    case "custom":
                        u = l(movie_width, movie_height);
                        toInject = settings.custom_markup;
                        break;
                    case "inline":
                        myClone = a(pp_images[set_position]).clone().css({
                            width: settings.default_width
                        }).wrapInner('<div id="pp_full_res"><div class="pp_inline clearfix"></div></div>').appendTo(a("body"));
                        u = l(a(myClone).width(), a(myClone).height());
                        a(myClone).remove();
                        toInject = settings.inline_markup.replace(/{content}/g, a(pp_images[set_position]).html());
                        break
                }
                if (!imgPreloader) {
                    $pp_pic_holder.find("#pp_full_res")[0].innerHTML = toInject;
                    _showContent()
                }
            });
            return false
        };
        a.prettyPhoto.changePage = function (A) {
            currentGalleryPage = 0;
            if (A == "previous") {
                set_position--;
                if (set_position < 0) {
                    set_position = 0;
                    return
                }
            } else {
                if (A == "next") {
                    set_position++;
                    if (set_position > a(pp_images).size() - 1) {
                        set_position = 0
                    }
                } else {
                    set_position = A
                }
            }
            if (!doresize) {
                doresize = true
            }
            a(".pp_contract").removeClass("pp_contract").addClass("pp_expand");
            k(function () {
                a.prettyPhoto.open()
            })
        };
        a.prettyPhoto.changeGalleryPage = function (A) {
            if (A == "next") {
                currentGalleryPage++;
                if (currentGalleryPage > totalPage) {
                    currentGalleryPage = 0
                }
            } else {
                if (A == "previous") {
                    currentGalleryPage--;
                    if (currentGalleryPage < 0) {
                        currentGalleryPage = totalPage
                    }
                } else {
                    currentGalleryPage = A
                }
            }
            itemsToSlide = (currentGalleryPage == totalPage) ? pp_images.length - ((totalPage) * itemsPerPage) : itemsPerPage;
            $pp_pic_holder.find(".pp_gallery li").each(function (B) {
                a(this).animate({
                    left: (B * itemWidth) - ((itemsToSlide * itemWidth) * currentGalleryPage)
                })
            })
        };
        a.prettyPhoto.startSlideshow = function () {
            if (typeof f == "undefined") {
                $pp_pic_holder.find(".pp_play").unbind("click").removeClass("pp_play").addClass("pp_pause").click(function () {
                    a.prettyPhoto.stopSlideshow();
                    return false
                });
                f = setInterval(a.prettyPhoto.startSlideshow, settings.slideshow)
            } else {
                a.prettyPhoto.changePage("next")
            }
        };
        a.prettyPhoto.stopSlideshow = function () {
            $pp_pic_holder.find(".pp_pause").unbind("click").removeClass("pp_pause").addClass("pp_play").click(function () {
                a.prettyPhoto.startSlideshow();
                return false
            });
            clearInterval(f);
            f = undefined
        };
        a.prettyPhoto.close = function () {
            clearInterval(f);
            $pp_pic_holder.stop().find("object,embed").css("visibility", "hidden");
            a("div.pp_pic_holder,div.ppt,.pp_fade").fadeOut(settings.animation_speed, function () {
                a(this).remove()
            });
            $pp_overlay.fadeOut(settings.animation_speed, function () {
                if (a.browser.msie && a.browser.version == 6) {
                    a("select").css("visibility", "visible")
                }
                if (settings.hideflash) {
                    a("object,embed").css("visibility", "visible")
                }
                a(this).remove();
                a(window).unbind("scroll");
                settings.callback();
                doresize = true;
                n = false;
                delete settings
            })
        };
        _showContent = function () {
            a(".pp_loaderIcon").hide();
            $ppt.fadeTo(settings.animation_speed, 1);
            projectedTop = scroll_pos.scrollTop + ((e / 2) - (u.containerHeight / 2));
            if (projectedTop < 0) {
                projectedTop = 0
            }
            $pp_pic_holder.find(".pp_content").animate({
                height: u.contentHeight
            }, settings.animation_speed);
            $pp_pic_holder.animate({
                top: projectedTop,
                left: (z / 2) - (u.containerWidth / 2),
                width: u.containerWidth
            }, settings.animation_speed, function () {
                $pp_pic_holder.find(".pp_hoverContainer,#fullResImage").height(u.height).width(u.width);
                $pp_pic_holder.find(".pp_fade").fadeIn(settings.animation_speed);
                if (isSet && y(pp_images[set_position]) == "image") {
                    $pp_pic_holder.find(".pp_hoverContainer").show()
                } else {
                    $pp_pic_holder.find(".pp_hoverContainer").hide()
                }
                if (u.resized) {
                    a("a.pp_expand,a.pp_contract").fadeIn(settings.animation_speed)
                }
                if (settings.autoplay_slideshow && !f && !n) {
                    a.prettyPhoto.startSlideshow()
                }
                settings.changepicturecallback();
                n = true
            });
            c()
        };

        function k(A) {
            $pp_pic_holder.find("#pp_full_res object,#pp_full_res embed").css("visibility", "hidden");
            $pp_pic_holder.find(".pp_fade").fadeOut(settings.animation_speed, function () {
                a(".pp_loaderIcon").show();
                A()
            })
        }
        function g(A) {
            if (set_position == A - 1) {
                $pp_pic_holder.find("a.pp_next").css("visibility", "hidden");
                $pp_pic_holder.find("a.pp_next").addClass("disabled").unbind("click")
            } else {
                $pp_pic_holder.find("a.pp_next").css("visibility", "visible");
                $pp_pic_holder.find("a.pp_next.disabled").removeClass("disabled").bind("click", function () {
                    a.prettyPhoto.changePage("next");
                    return false
                })
            }
            if (set_position == 0) {
                $pp_pic_holder.find("a.pp_previous").css("visibility", "hidden").addClass("disabled").unbind("click")
            } else {
                $pp_pic_holder.find("a.pp_previous.disabled").css("visibility", "visible").removeClass("disabled").bind("click", function () {
                    a.prettyPhoto.changePage("previous");
                    return false
                })
            } (A > 1) ? a(".pp_nav").show() : a(".pp_nav").hide()
        }
        function l(B, A) {
            resized = false;
            r(B, A);
            imageWidth = B, imageHeight = A;
            if (((w > z) || (t > e)) && doresize && settings.allow_resize && !h) {
                resized = true, fitting = false;
                while (!fitting) {
                    if ((w > z)) {
                        imageWidth = (z - 200);
                        imageHeight = (A / B) * imageWidth
                    } else {
                        if ((t > e)) {
                            imageHeight = (e - 200);
                            imageWidth = (B / A) * imageHeight
                        } else {
                            fitting = true
                        }
                    }
                    t = imageHeight, w = imageWidth
                }
                r(imageWidth, imageHeight)
            }
            return {
                width: Math.floor(imageWidth),
                height: Math.floor(imageHeight),
                containerHeight: Math.floor(t),
                containerWidth: Math.floor(w) + 40,
                contentHeight: Math.floor(o),
                contentWidth: Math.floor(q),
                resized: resized
            }
        }
        function r(B, A) {
            B = parseFloat(B);
            A = parseFloat(A);
            $pp_details = $pp_pic_holder.find(".pp_details");
            $pp_details.width(B);
            detailsHeight = parseFloat($pp_details.css("marginTop")) + parseFloat($pp_details.css("marginBottom"));
            $pp_details = $pp_details.clone().appendTo(a("body")).css({
                position: "absolute",
                top: -10000
            });
            detailsHeight += $pp_details.height();
            detailsHeight = (detailsHeight <= 34) ? 36 : detailsHeight;
            if (a.browser.msie && a.browser.version == 7) {
                detailsHeight += 8
            }
            $pp_details.remove();
            o = A + detailsHeight;
            q = B;
            t = o + $ppt.height() + $pp_pic_holder.find(".pp_top").height() + $pp_pic_holder.find(".pp_bottom").height();
            w = B
        }
        function y(A) {
            if (A.match(/youtube\.com\/watch/i)) {
                return "youtube"
            } else {
                if (A.match(/vimeo\.com/i)) {
                    return "vimeo"
                } else {
                    if (A.indexOf(".mov") != -1) {
                        return "quicktime"
                    } else {
                        if (A.indexOf(".swf") != -1) {
                            return "flash"
                        } else {
                            if (A.indexOf("iframe") != -1) {
                                return "iframe"
                            } else {
                                if (A.indexOf("custom") != -1) {
                                    return "custom"
                                } else {
                                    if (A.substr(0, 1) == "#") {
                                        return "inline"
                                    } else {
                                        return "image"
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        function m() {
            if (doresize && typeof $pp_pic_holder != "undefined") {
                scroll_pos = x();
                titleHeight = $ppt.height(), contentHeight = $pp_pic_holder.height(), contentwidth = $pp_pic_holder.width();
                projectedTop = (e / 2) + scroll_pos.scrollTop - (contentHeight / 2);
                $pp_pic_holder.css({
                    top: projectedTop,
                    left: (z / 2) + scroll_pos.scrollLeft - (contentwidth / 2)
                })
            }
        }
        function x() {
            if (self.pageYOffset) {
                return {
                    scrollTop: self.pageYOffset,
                    scrollLeft: self.pageXOffset
                }
            } else {
                if (document.documentElement && document.documentElement.scrollTop) {
                    return {
                        scrollTop: document.documentElement.scrollTop,
                        scrollLeft: document.documentElement.scrollLeft
                    }
                } else {
                    if (document.body) {
                        return {
                            scrollTop: document.body.scrollTop,
                            scrollLeft: document.body.scrollLeft
                        }
                    }
                }
            }
        }
        function s() {
            e = a(window).height(), z = a(window).width();
            if (typeof $pp_overlay != "undefined") {
                $pp_overlay.height(a(document).height())
            }
        }
        function c() {
            if (isSet && settings.overlay_gallery && y(pp_images[set_position]) == "image") {
                itemWidth = 52 + 5;
                navWidth = (settings.theme == "facebook") ? 58 : 38;
                itemsPerPage = Math.floor((u.containerWidth - 100 - navWidth) / itemWidth);
                itemsPerPage = (itemsPerPage < pp_images.length) ? itemsPerPage : pp_images.length;
                totalPage = Math.ceil(pp_images.length / itemsPerPage) - 1;
                if (totalPage == 0) {
                    navWidth = 0;
                    $pp_pic_holder.find(".pp_gallery .pp_arrow_next,.pp_gallery .pp_arrow_previous").hide()
                } else {
                    $pp_pic_holder.find(".pp_gallery .pp_arrow_next,.pp_gallery .pp_arrow_previous").show()
                }
                galleryWidth = itemsPerPage * itemWidth + navWidth;
                $pp_pic_holder.find(".pp_gallery").width(galleryWidth).css("margin-left", -(galleryWidth / 2));
                $pp_pic_holder.find(".pp_gallery ul").width(itemsPerPage * itemWidth).find("li.selected").removeClass("selected");
                goToPage = (Math.floor(set_position / itemsPerPage) <= totalPage) ? Math.floor(set_position / itemsPerPage) : totalPage;
                if (itemsPerPage) {
                    $pp_pic_holder.find(".pp_gallery").hide().show().removeClass("disabled")
                } else {
                    $pp_pic_holder.find(".pp_gallery").hide().addClass("disabled")
                }
                a.prettyPhoto.changeGalleryPage(goToPage);
                $pp_pic_holder.find(".pp_gallery ul li:eq(" + set_position + ")").addClass("selected")
            } else {
                $pp_pic_holder.find(".pp_content").unbind("mouseenter mouseleave");
                $pp_pic_holder.find(".pp_gallery").hide()
            }
        }
        function v(A) {
            theRel = a(A).attr("rel");
            galleryRegExp = /\[(?:.*)\]/;
            isSet = (galleryRegExp.exec(theRel)) ? true : false;
            pp_images = (isSet) ? jQuery.map(j, function (F, E) {
                if (a(F).attr("rel").indexOf(theRel) != -1) {
                    return a(F).attr("href")
                }
            }) : a.makeArray(a(A).attr("href"));
            pp_titles = (isSet) ? jQuery.map(j, function (F, E) {
                if (a(F).attr("rel").indexOf(theRel) != -1) {
                    return (a(F).find("img").attr("alt")) ? a(F).find("img").attr("alt") : ""
                }
            }) : a.makeArray(a(A).find("img").attr("alt"));
            pp_descriptions = (isSet) ? jQuery.map(j, function (F, E) {
                if (a(F).attr("rel").indexOf(theRel) != -1) {
                    return (a(F).attr("title")) ? a(F).attr("title") : ""
                }
            }) : a.makeArray(a(A).attr("title"));
            a("body").append(settings.markup);
            $pp_pic_holder = a(".pp_pic_holder"), $ppt = a(".ppt"), $pp_overlay = a("div.pp_overlay");
            if (isSet && settings.overlay_gallery) {
                currentGalleryPage = 0;
                toInject = "";
                for (var C = 0; C < pp_images.length; C++) {
                    var D = new RegExp("(.*?).(jpg|jpeg|png|gif)$");
                    var B = D.exec(pp_images[C]);
                    if (!B) {
                        classname = "default"
                    } else {
                        classname = ""
                    }
                    toInject += "<li class='" + classname + "'><a href='#'><img src='" + pp_images[C] + "' width='50' alt='' /></a></li>"
                }
                toInject = settings.gallery_markup.replace(/{gallery}/g, toInject);
                $pp_pic_holder.find("#pp_full_res").after(toInject);
                $pp_pic_holder.find(".pp_gallery .pp_arrow_next").click(function () {
                    a.prettyPhoto.changeGalleryPage("next");
                    a.prettyPhoto.stopSlideshow();
                    return false
                });
                $pp_pic_holder.find(".pp_gallery .pp_arrow_previous").click(function () {
                    a.prettyPhoto.changeGalleryPage("previous");
                    a.prettyPhoto.stopSlideshow();
                    return false
                });
                $pp_pic_holder.find(".pp_content").hover(function () {
                    $pp_pic_holder.find(".pp_gallery:not(.disabled)").fadeIn()
                }, function () {
                    $pp_pic_holder.find(".pp_gallery:not(.disabled)").fadeOut()
                });
                itemWidth = 52 + 5;
                $pp_pic_holder.find(".pp_gallery ul li").each(function (E) {
                    a(this).css({
                        position: "absolute",
                        left: E * itemWidth
                    });
                    a(this).find("a").unbind("click").click(function () {
                        a.prettyPhoto.changePage(E);
                        a.prettyPhoto.stopSlideshow();
                        return false
                    })
                })
            }
            if (settings.slideshow) {
                $pp_pic_holder.find(".pp_nav").prepend('<a href="#" class="pp_play">Play</a>');
                $pp_pic_holder.find(".pp_nav .pp_play").click(function () {
                    a.prettyPhoto.startSlideshow();
                    return false
                })
            }
            $pp_pic_holder.attr("class", "pp_pic_holder " + settings.theme);
            $pp_overlay.css({
                opacity: 0,
                height: a(document).height(),
                width: a(document).width()
            }).bind("click", function () {
                if (!settings.modal) {
                    a.prettyPhoto.close()
                }
            });
            a("a.pp_close").bind("click", function () {
                a.prettyPhoto.close();
                return false
            });
            a("a.pp_expand").bind("click", function (E) {
                if (a(this).hasClass("pp_expand")) {
                    a(this).removeClass("pp_expand").addClass("pp_contract");
                    doresize = false
                } else {
                    a(this).removeClass("pp_contract").addClass("pp_expand");
                    doresize = true
                }
                k(function () {
                    a.prettyPhoto.open()
                });
                return false
            });
            $pp_pic_holder.find(".pp_previous, .pp_nav .pp_arrow_previous").bind("click", function () {
                a.prettyPhoto.changePage("previous");
                a.prettyPhoto.stopSlideshow();
                return false
            });
            $pp_pic_holder.find(".pp_next, .pp_nav .pp_arrow_next").bind("click", function () {
                a.prettyPhoto.changePage("next");
                a.prettyPhoto.stopSlideshow();
                return false
            });
            m()
        }
        return this.unbind("click").click(a.prettyPhoto.initialize)
    };

    function b(e, d) {
        e = e.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
        var c = "[\\?&]" + e + "=([^&#]*)";
        var g = new RegExp(c);
        var f = g.exec(d);
        return (f == null) ? "" : f[1]
    }
})(jQuery);
(function (e) {
    var a = 0;
    var b = {
        iframe: "iframe",
        popup: "popup"
    };
    var d = {
        mode: b.iframe,
        popHt: 500,
        popWd: 400,
        popX: 200,
        popY: 200,
        popTitle: "",
        popClose: false
    };
    var c = {};
    e.fn.printArea = function (o) {
        e.extend(c, d, o);
        a++;
        var q = "printArea_";
        e("[id^=" + q + "]").remove();
        var s = j(e(this));
        c.id = q + a;
        var m;
        var n;
        switch (c.mode) {
            case b.iframe:
                var r = new g();
                m = r.doc;
                n = r.contentWindow || r;
                break;
            case b.popup:
                n = new l();
                m = n.doc
        }
        m.open();
        m.write(h() + "<html>" + k() + f(s) + "</html>");
        m.close();
        n.focus();
        n.print();
        if (c.mode == b.popup && c.popClose) {
            n.close()
        }
    };

    function h() {
        if (c.mode == b.iframe || !c.strict) {
            return ""
        }
        var m = c.strict == false ? " Trasitional" : "";
        var n = c.strict == false ? "loose" : "strict";
        return '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01' + m + '//EN" "http://www.w3.org/TR/html4/' + n + '.dtd">'
    }
    function k() {
        var m = "<head><title>" + c.popTitle + "</title>";
        e(document).find("link").filter(function () {
            return e(this).attr("rel").toLowerCase() == "stylesheet"
        }).filter(function () {
            var n = e(this).attr("media");
            return (n.toLowerCase() == "" || n.toLowerCase() == "print")
        }).each(function () {
            m += '<link type="text/css" rel="stylesheet" href="' + e(this).attr("href") + '" >'
        });
        m += "</head>";
        return m
    }
    function f(m) {
        return '<body><div class="' + e(m).attr("class") + '">' + e(m).html() + "</div></body>"
    }
    function j(m) {
        e("input,select,textarea", m).each(function () {
            var o = e(this).attr("type");
            if (o == "radio" || o == "checkbox") {
                if (e(this).is(":not(:checked)")) {
                    this.removeAttribute("checked")
                } else {
                    this.setAttribute("checked", true)
                }
            } else {
                if (o == "text") {
                    this.setAttribute("value", e(this).val())
                } else {
                    if (o == "select-multiple" || o == "select-one") {
                        e(this).find("option").each(function () {
                            if (e(this).is(":not(:selected)")) {
                                this.removeAttribute("selected")
                            } else {
                                this.setAttribute("selected", true)
                            }
                        })
                    } else {
                        if (o == "textarea") {
                            var n = e(this).attr("value");
                            if (e.browser.mozilla) {
                                if (this.firstChild) {
                                    this.firstChild.textContent = n
                                } else {
                                    this.textContent = n
                                }
                            } else {
                                this.innerHTML = n
                            }
                        }
                    }
                }
            }
        });
        return m
    }
    function g() {
        var o = c.id;
        var m = "border:0;position:absolute;width:0px;height:0px;left:0px;top:0px;";
        var n;
        try {
            n = document.createElement("iframe");
            document.body.appendChild(n);
            e(n).attr({
                style: m,
                id: o,
                src: ""
            });
            n.doc = null;
            n.doc = n.contentDocument ? n.contentDocument : (n.contentWindow ? n.contentWindow.document : n.document)
        } catch (q) {
            throw q + ". iframes may not be supported in this browser."
        }
        if (n.doc == null) {
            throw "Cannot find document."
        }
        return n
    }
    function l() {
        var n = "location=yes,statusbar=no,directories=no,menubar=no,titlebar=no,toolbar=no,dependent=no";
        n += ",width=" + c.popWd + ",height=" + c.popHt;
        n += ",resizable=yes,screenX=" + c.popX + ",screenY=" + c.popY + ",personalbar=no,scrollbars=no";
        var m = window.open("", "_blank", n);
        m.doc = m.document;
        return m
    }
})(jQuery);
(function (c) {
    var b = c.browser.msie && parseInt(c.browser.version) == 6 && typeof window.XMLHttpRequest != "object",
        d = null,
        a = [];
    c.modal = function (f, e) {
        return c.modal.impl.init(f, e)
    };
    c.modal.close = function () {
        c.modal.impl.close()
    };
    c.fn.modal = function (e) {
        return c.modal.impl.init(this, e)
    };
    c.modal.defaults = {
        appendTo: "body",
        focus: true,
        opacity: 50,
        overlayId: "simplemodal-overlay",
        overlayCss: {},
        containerId: "simplemodal-container",
        containerCss: {},
        dataId: "simplemodal-data",
        dataCss: {},
        minHeight: null,
        minWidth: null,
        maxHeight: null,
        maxWidth: null,
        autoResize: false,
        autoPosition: true,
        zIndex: 1000,
        close: true,
        closeHTML: '<a class="modalCloseImg" title="Close"></a>',
        closeClass: "simplemodal-close",
        escClose: true,
        overlayClose: false,
        position: null,
        persist: false,
        modal: true,
        onOpen: null,
        onShow: null,
        onClose: null
    };
    c.modal.impl = {
        o: null,
        d: {},
        init: function (g, e) {
            var f = this;
            if (f.d.data) {
                return false
            }
            d = c.browser.msie && !c.boxModel;
            f.o = c.extend({}, c.modal.defaults, e);
            f.zIndex = f.o.zIndex;
            f.occb = false;
            if (typeof g == "object") {
                g = g instanceof jQuery ? g : c(g);
                f.d.placeholder = false;
                if (g.parent().parent().size() > 0) {
                    g.before(c("<span></span>").attr("id", "simplemodal-placeholder").css({
                        display: "none"
                    }));
                    f.d.placeholder = true;
                    f.display = g.css("display");
                    if (!f.o.persist) {
                        f.d.orig = g.clone(true)
                    }
                }
            } else {
                if (typeof g == "string" || typeof g == "number") {
                    g = c("<div></div>").html(g)
                } else {
                    alert("SimpleModal Error: Unsupported data type: " + typeof g);
                    return f
                }
            }
            f.create(g);
            g = null;
            f.open();
            if (c.isFunction(f.o.onShow)) {
                f.o.onShow.apply(f, [f.d])
            }
            return f
        },
        create: function (f) {
            var e = this;
            a = e.getDimensions();
            if (e.o.modal && b) {
                e.d.iframe = c('<iframe src="javascript:false;"></iframe>').css(c.extend(e.o.iframeCss, {
                    display: "none",
                    opacity: 0,
                    position: "fixed",
                    height: a[0],
                    width: a[1],
                    zIndex: e.o.zIndex,
                    top: 0,
                    left: 0
                })).appendTo(e.o.appendTo)
            }
            e.d.overlay = c("<div></div>").attr("id", e.o.overlayId).addClass("simplemodal-overlay").css(c.extend(e.o.overlayCss, {
                display: "none",
                opacity: e.o.opacity / 100,
                height: e.o.modal ? a[0] : 0,
                width: e.o.modal ? a[1] : 0,
                position: "fixed",
                left: 0,
                top: 0,
                zIndex: e.o.zIndex + 1
            })).appendTo(e.o.appendTo);
            e.d.container = c("<div></div>").attr("id", e.o.containerId).addClass("simplemodal-container").css(c.extend(e.o.containerCss, {
                display: "none",
                position: "fixed",
                zIndex: e.o.zIndex + 2
            })).append(e.o.close && e.o.closeHTML ? c(e.o.closeHTML).addClass(e.o.closeClass) : "").appendTo(e.o.appendTo);
            e.d.wrap = c("<div></div>").attr("tabIndex", -1).addClass("simplemodal-wrap").css({
                height: "100%",
                outline: 0,
                width: "100%"
            }).appendTo(e.d.container);
            e.d.data = f.attr("id", f.attr("id") || e.o.dataId).addClass("simplemodal-data").css(c.extend(e.o.dataCss, {
                display: "none"
            })).appendTo("body");
            f = null;
            e.setContainerDimensions();
            e.d.data.appendTo(e.d.wrap);
            if (b || d) {
                e.fixIE()
            }
        },
        bindEvents: function () {
            var e = this;
            c("." + e.o.closeClass).bind("click.simplemodal", function (f) {
                f.preventDefault();
                e.close()
            });
            if (e.o.modal && e.o.close && e.o.overlayClose) {
                e.d.overlay.bind("click.simplemodal", function (f) {
                    f.preventDefault();
                    e.close()
                })
            }
            c(document).bind("keydown.simplemodal", function (f) {
                if (e.o.modal && e.o.focus && f.keyCode == 9) {
                    e.watchTab(f)
                } else {
                    if ((e.o.close && e.o.escClose) && f.keyCode == 27) {
                        f.preventDefault();
                        e.close()
                    }
                }
            });
            c(window).bind("resize.simplemodal", function () {
                a = e.getDimensions();
                e.setContainerDimensions(true);
                if (b || d) {
                    e.fixIE()
                } else {
                    if (e.o.modal) {
                        e.d.iframe && e.d.iframe.css({
                            height: a[0],
                            width: a[1]
                        });
                        e.d.overlay.css({
                            height: a[0],
                            width: a[1]
                        })
                    }
                }
            })
        },
        unbindEvents: function () {
            c("." + this.o.closeClass).unbind("click.simplemodal");
            c(document).unbind("keydown.simplemodal");
            c(window).unbind("resize.simplemodal");
            this.d.overlay.unbind("click.simplemodal")
        },
        fixIE: function () {
            var e = this,
                f = e.o.position;
            c.each([e.d.iframe || null, !e.o.modal ? null : e.d.overlay, e.d.container], function (t, k) {
                if (k) {
                    var q = "document.body.clientHeight",
                        v = "document.body.clientWidth",
                        x = "document.body.scrollHeight",
                        u = "document.body.scrollLeft",
                        n = "document.body.scrollTop",
                        j = "document.body.scrollWidth",
                        h = "document.documentElement.clientHeight",
                        r = "document.documentElement.clientWidth",
                        o = "document.documentElement.scrollLeft",
                        y = "document.documentElement.scrollTop",
                        z = k[0].style;
                    z.position = "absolute";
                    if (t < 2) {
                        z.removeExpression("height");
                        z.removeExpression("width");
                        z.setExpression("height", "" + x + " > " + q + " ? " + x + " : " + q + ' + "px"');
                        z.setExpression("width", "" + j + " > " + v + " ? " + j + " : " + v + ' + "px"')
                    } else {
                        var m, g;
                        if (f && f.constructor == Array) {
                            var w = f[0] ? typeof f[0] == "number" ? f[0].toString() : f[0].replace(/px/, "") : k.css("top").replace(/px/, "");
                            m = w.indexOf("%") == -1 ? w + " + (t = " + y + " ? " + y + " : " + n + ') + "px"' : parseInt(w.replace(/%/, "")) + " * ((" + h + " || " + q + ") / 100) + (t = " + y + " ? " + y + " : " + n + ') + "px"';
                            if (f[1]) {
                                var l = typeof f[1] == "number" ? f[1].toString() : f[1].replace(/px/, "");
                                g = l.indexOf("%") == -1 ? l + " + (t = " + o + " ? " + o + " : " + u + ') + "px"' : parseInt(l.replace(/%/, "")) + " * ((" + r + " || " + v + ") / 100) + (t = " + o + " ? " + o + " : " + u + ') + "px"'
                            }
                        } else {
                            m = "(" + h + " || " + q + ") / 2 - (this.offsetHeight / 2) + (t = " + y + " ? " + y + " : " + n + ') + "px"';
                            g = "(" + r + " || " + v + ") / 2 - (this.offsetWidth / 2) + (t = " + o + " ? " + o + " : " + u + ') + "px"'
                        }
                        z.removeExpression("top");
                        z.removeExpression("left");
                        z.setExpression("top", m);
                        z.setExpression("left", g)
                    }
                }
            })
        },
        focus: function (h) {
            var f = this,
                g = h || "first";
            var e = c(":input:enabled:visible:" + g, f.d.wrap);
            e.length > 0 ? e.focus() : f.d.wrap.focus()
        },
        getDimensions: function () {
            var f = c(window);
            var e = c.browser.opera && c.browser.version > "9.5" && c.fn.jquery <= "1.2.6" ? document.documentElement.clientHeight : c.browser.opera && c.browser.version < "9.5" && c.fn.jquery > "1.2.6" ? window.innerHeight : f.height();
            return [e, f.width()]
        },
        getVal: function (e) {
            return e == "auto" ? 0 : e.indexOf("%") > 0 ? e : parseInt(e.replace(/px/, ""))
        },
        setContainerDimensions: function (h) {
            var k = this;
            if (!h || (h && k.o.autoResize)) {
                var j = c.browser.opera ? k.d.container.height() : k.getVal(k.d.container.css("height")),
                    e = c.browser.opera ? k.d.container.width() : k.getVal(k.d.container.css("width")),
                    l = k.d.data.outerHeight(true),
                    g = k.d.data.outerWidth(true);
                var f = k.o.maxHeight && k.o.maxHeight < a[0] ? k.o.maxHeight : a[0],
                    m = k.o.maxWidth && k.o.maxWidth < a[1] ? k.o.maxWidth : a[1];
                if (!j) {
                    if (!l) {
                        j = k.o.minHeight
                    } else {
                        if (l > f) {
                            j = f
                        } else {
                            if (l < k.o.minHeight) {
                                j = k.o.minHeight
                            } else {
                                j = l
                            }
                        }
                    }
                } else {
                    j = j > f ? f : j
                }
                if (!e) {
                    if (!g) {
                        e = k.o.minWidth
                    } else {
                        if (g > m) {
                            e = m
                        } else {
                            if (g < k.o.minWidth) {
                                e = k.o.minWidth
                            } else {
                                e = g
                            }
                        }
                    }
                } else {
                    e = e > m ? m : e
                }
                k.d.container.css({
                    height: j,
                    width: e
                });
                if (l > j || g > e) {
                    k.d.wrap.css({
                        overflow: "auto"
                    })
                }
            }
            if (k.o.autoPosition) {
                k.setPosition()
            }
        },
        setPosition: function () {
            var f = this,
                h, g, j = (a[0] / 2) - (f.d.container.outerHeight(true) / 2),
                e = (a[1] / 2) - (f.d.container.outerWidth(true) / 2);
            if (f.o.position && Object.prototype.toString.call(f.o.position) === "[object Array]") {
                h = f.o.position[0] || j;
                g = f.o.position[1] || e
            } else {
                h = j;
                g = e
            }
            f.d.container.css({
                left: g,
                top: h
            })
        },
        watchTab: function (g) {
            var f = this;
            if (c(g.target).parents(".simplemodal-container").length > 0) {
                f.inputs = c(":input:enabled:visible:first, :input:enabled:visible:last", f.d.data[0]);
                if ((!g.shiftKey && g.target == f.inputs[f.inputs.length - 1]) || (g.shiftKey && g.target == f.inputs[0]) || f.inputs.length == 0) {
                    g.preventDefault();
                    var h = g.shiftKey ? "last" : "first";
                    setTimeout(function () {
                        f.focus(h)
                    }, 10)
                }
            } else {
                g.preventDefault();
                setTimeout(function () {
                    f.focus()
                }, 10)
            }
        },
        open: function () {
            var e = this;
            e.d.iframe && e.d.iframe.show();
            if (c.isFunction(e.o.onOpen)) {
                e.o.onOpen.apply(e, [e.d])
            } else {
                e.d.overlay.show();
                e.d.container.show();
                e.d.data.show()
            }
            e.focus();
            e.bindEvents()
        },
        close: function () {
            var e = this;
            if (!e.d.data) {
                return false
            }
            e.unbindEvents();
            if (c.isFunction(e.o.onClose) && !e.occb) {
                e.occb = true;
                e.o.onClose.apply(e, [e.d])
            } else {
                if (e.d.placeholder) {
                    var f = c("#simplemodal-placeholder");
                    if (e.o.persist) {
                        f.replaceWith(e.d.data.removeClass("simplemodal-data").css("display", e.display))
                    } else {
                        e.d.data.hide().remove();
                        f.replaceWith(e.d.orig)
                    }
                } else {
                    e.d.data.hide().remove()
                }
                e.d.container.hide().remove();
                e.d.overlay.hide().remove();
                e.d.iframe && e.d.iframe.hide().remove();
                e.d = {}
            }
        }
    }
})(jQuery);
(function (a) {
    a.extend({
        tablesorterFilter: new function () {
            function c(j, h, e) {
                var g = e ? j : j.toLowerCase();
                for (var f = 0; f < h.length; f++) {
                    if (g.indexOf(h[f]) === -1) {
                        return false
                    }
                }
                return true
            }
            function d(s, g) {
                if (s.config.debug) {
                    var q = new Date()
                }
                var t = g.length;
                var o = s.config.filterCaseSensitive;
                var m = o ? g.split(" ") : g.toLowerCase().split(" ");
                var h = s.config.filterColumns;
                var n = [];
                var r = function (u) {
                    u.show();
                    n.push(u)
                };
                var f = function (u) { };
                if (h) {
                    var k = "";
                    for (var j = 0; j < h.length; j++) {
                        k += "td:eq(" + h[j] + "),"
                    }
                    var e = function () {
                        var u = jQuery(this);
                        c(u.find(k).text(), m, o) ? r(u) : f(u)
                    }
                } else {
                    var e = function () {
                        var u = jQuery(this);
                        c(u.text(), m, o) ? r(u) : f(u)
                    }
                }
                var l = s.config.cache.row;
                for (var j = 0; j < l.length; j++) {
                    l[j].each(e)
                }
                a.tablesorter.clearTableBody(s);
                for (var j = 0; j < n.length; j++) {
                    a(s.tBodies[0]).append(n[j])
                }
                a(s).trigger("update");
                a(s).trigger("appendCache");
                if (s.config.debug) {
                    a.tablesorter.benchmark("Apply filter:", q)
                }
                return s
            }
            function b(h) {
                if (h.config.debug) {
                    var e = new Date()
                }
                var g = h.config.cache.row;
                a.tablesorter.clearTableBody(h);
                for (var f = 0; f < g.length; f++) {
                    a(h.tBodies[0]).append(g[f])
                }
                a(h).trigger("update");
                a(h).trigger("appendCache");
                if (h.config.debug) {
                    a.tablesorter.benchmark("Clear filter:", e)
                }
                return h
            }
            this.defaults = {
                filterContainer: "#filter-box",
                filterClearContainer: "#filter-clear-button",
                filterColumns: null,
                filterCaseSensitive: false
            };
            this.construct = function (e) {
                return this.each(function () {
                    config = a.extend(this.config, a.tablesorterFilter.defaults, e);
                    var f = this;

                    function h(j, k) {
                        var l = j.value;
                        if ((l != j.lastValue) || (k)) {
                            j.lastValue = l;
                            d(f, l)
                        }
                    }
                    var g;
                    a(config.filterContainer).keyup(function () {
                        var m = 500;
                        var l = false;
                        var j = this;
                        if (j.keyCode == 13) {
                            m = 1;
                            l = true
                        }
                        var k = function () {
                            h(j, l)
                        };
                        clearTimeout(g);
                        g = setTimeout(k, m);
                        return false
                    });
                    a(config.filterClearContainer).click(function () {
                        b(f);
                        a(config.filterContainer).val("").focus()
                    });
                    a(f).bind("clearFilter", function () {
                        b(f)
                    })
                })
            }
        }
    });
    a.fn.extend({
        tablesorterFilter: a.tablesorterFilter.construct
    })
})(jQuery);
(function ($) {
    $.extend({
        tablesorter: new function () {
            var parsers = [],
                widgets = [];
            this.defaults = {
                cssHeader: "header",
                cssAsc: "headerSortUp",
                cssDesc: "headerSortDown",
                sortInitialOrder: "asc",
                sortMultiSortKey: "shiftKey",
                sortForce: null,
                sortAppend: null,
                textExtraction: "simple",
                parsers: {},
                widgets: [],
                widgetZebra: {
                    css: ["even", "odd"]
                },
                headers: {},
                widthFixed: false,
                cancelSelection: true,
                sortList: [],
                headerList: [],
                dateFormat: "us",
                decimal: ".",
                debug: false
            };

            function benchmark(s, d) {
                log(s + "," + (new Date().getTime() - d.getTime()) + "ms")
            }
            this.benchmark = benchmark;

            function log(s) {
                if (typeof console != "undefined" && typeof console.debug != "undefined") {
                    console.log(s)
                } else {
                    alert(s)
                }
            }
            function buildParserCache(table, $headers) {
                if (table.config.debug) {
                    var parsersDebug = ""
                }
                var rows = table.tBodies[0].rows;
                if (table.tBodies[0].rows[0]) {
                    var list = [],
                        cells = rows[0].cells,
                        l = cells.length;
                    for (var i = 0; i < l; i++) {
                        var p = false;
                        if ($.metadata && ($($headers[i]).metadata() && $($headers[i]).metadata().sorter)) {
                            p = getParserById($($headers[i]).metadata().sorter)
                        } else {
                            if ((table.config.headers[i] && table.config.headers[i].sorter)) {
                                p = getParserById(table.config.headers[i].sorter)
                            }
                        }
                        if (!p) {
                            p = detectParserForColumn(table, cells[i])
                        }
                        if (table.config.debug) {
                            parsersDebug += "column:" + i + " parser:" + p.id + "\n"
                        }
                        list.push(p)
                    }
                }
                if (table.config.debug) {
                    log(parsersDebug)
                }
                return list
            }
            function detectParserForColumn(table, node) {
                var l = parsers.length;
                for (var i = 1; i < l; i++) {
                    if (parsers[i].is($.trim(getElementText(table.config, node)), table, node)) {
                        return parsers[i]
                    }
                }
                return parsers[0]
            }
            function getParserById(name) {
                var l = parsers.length;
                for (var i = 0; i < l; i++) {
                    if (parsers[i].id.toLowerCase() == name.toLowerCase()) {
                        return parsers[i]
                    }
                }
                return false
            }
            function buildCache(table) {
                if (table.config.debug) {
                    var cacheTime = new Date()
                }
                var totalRows = (table.tBodies[0] && table.tBodies[0].rows.length) || 0,
                    totalCells = (table.tBodies[0].rows[0] && table.tBodies[0].rows[0].cells.length) || 0,
                    parsers = table.config.parsers,
                    cache = {
                        row: [],
                        normalized: []
                    };
                for (var i = 0; i < totalRows; ++i) {
                    var c = table.tBodies[0].rows[i],
                        cols = [];
                    cache.row.push($(c));
                    for (var j = 0; j < totalCells; ++j) {
                        cols.push(parsers[j].format(getElementText(table.config, c.cells[j]), table, c.cells[j]))
                    }
                    cols.push(i);
                    cache.normalized.push(cols);
                    cols = null
                }
                if (table.config.debug) {
                    benchmark("Building cache for " + totalRows + " rows:", cacheTime)
                }
                return cache
            }
            function getElementText(config, node) {
                if (!node) {
                    return ""
                }
                var t = "";
                if (config.textExtraction == "simple") {
                    if (node.childNodes[0] && node.childNodes[0].hasChildNodes()) {
                        t = node.childNodes[0].innerHTML
                    } else {
                        t = node.innerHTML
                    }
                } else {
                    if (typeof (config.textExtraction) == "function") {
                        t = config.textExtraction(node)
                    } else {
                        t = $(node).text()
                    }
                }
                return t
            }
            function appendToTable(table, cache) {
                if (table.config.debug) {
                    var appendTime = new Date()
                }
                var c = cache,
                    r = c.row,
                    n = c.normalized,
                    totalRows = n.length,
                    tableBody = $(table.tBodies[0]),
                    rows = [];
                if (totalRows > 0) {
                    var checkCell = (n[0].length - 1);
                    for (var i = 0; i < totalRows; i++) {
                        rows.push(r[n[i][checkCell]]);
                        if (!table.config.appender) {
                            var o = r[n[i][checkCell]];
                            var l = o.length;
                            for (var j = 0; j < l; j++) {
                                tableBody[0].appendChild(o[j])
                            }
                        }
                    }
                }
                if (table.config.appender) {
                    table.config.appender(table, rows)
                }
                rows = null;
                if (table.config.debug) {
                    benchmark("Rebuilt table:", appendTime)
                }
                applyWidget(table);
                setTimeout(function () {
                    $(table).trigger("sortEnd")
                }, 0)
            }
            function buildHeaders(table) {
                if (table.config.debug) {
                    var time = new Date()
                }
                var meta = ($.metadata) ? true : false,
                    tableHeadersRows = [];
                for (var i = 0; i < table.tHead.rows.length; i++) {
                    tableHeadersRows[i] = 0
                }
                $tableHeaders = $("thead th", table);
                $tableHeaders.each(function (index) {
                    this.count = 0;
                    this.column = index;
                    this.order = formatSortingOrder(table.config.sortInitialOrder);
                    if (checkHeaderMetadata(this) || checkHeaderOptions(table, index)) {
                        this.sortDisabled = true
                    }
                    if (!this.sortDisabled) {
                        $(this).addClass(table.config.cssHeader)
                    }
                    table.config.headerList[index] = this
                });
                if (table.config.debug) {
                    benchmark("Built headers:", time);
                    log($tableHeaders)
                }
                return $tableHeaders
            }
            function checkCellColSpan(table, rows, row) {
                var arr = [],
                    r = table.tHead.rows,
                    c = r[row].cells;
                for (var i = 0; i < c.length; i++) {
                    var cell = c[i];
                    if (cell.colSpan > 1) {
                        arr = arr.concat(checkCellColSpan(table, headerArr, row++))
                    } else {
                        if (table.tHead.length == 1 || (cell.rowSpan > 1 || !r[row + 1])) {
                            arr.push(cell)
                        }
                    }
                }
                return arr
            }
            function checkHeaderMetadata(cell) {
                if (($.metadata) && ($(cell).metadata().sorter === false)) {
                    return true
                }
                return false
            }
            function checkHeaderOptions(table, i) {
                if ((table.config.headers[i]) && (table.config.headers[i].sorter === false)) {
                    return true
                }
                return false
            }
            function applyWidget(table) {
                var c = table.config.widgets;
                var l = c.length;
                for (var i = 0; i < l; i++) {
                    getWidgetById(c[i]).format(table)
                }
            }
            function getWidgetById(name) {
                var l = widgets.length;
                for (var i = 0; i < l; i++) {
                    if (widgets[i].id.toLowerCase() == name.toLowerCase()) {
                        return widgets[i]
                    }
                }
            }
            function formatSortingOrder(v) {
                if (typeof (v) != "Number") {
                    i = (v.toLowerCase() == "desc") ? 1 : 0
                } else {
                    i = (v == (0 || 1)) ? v : 0
                }
                return i
            }
            function isValueInArray(v, a) {
                var l = a.length;
                for (var i = 0; i < l; i++) {
                    if (a[i][0] == v) {
                        return true
                    }
                }
                return false
            }
            function setHeadersCss(table, $headers, list, css) {
                $headers.removeClass(css[0]).removeClass(css[1]);
                var h = [];
                $headers.each(function (offset) {
                    if (!this.sortDisabled) {
                        h[this.column] = $(this)
                    }
                });
                var l = list.length;
                for (var i = 0; i < l; i++) {
                    h[list[i][0]].addClass(css[list[i][1]])
                }
            }
            function fixColumnWidth(table, $headers) {
                var c = table.config;
                if (c.widthFixed) {
                    var colgroup = $("<colgroup>");
                    $("tr:first td", table.tBodies[0]).each(function () {
                        colgroup.append($("<col>").css("width", $(this).width()))
                    });
                    $(table).prepend(colgroup)
                }
            }
            function updateHeaderSortCount(table, sortList) {
                var c = table.config,
                    l = sortList.length;
                for (var i = 0; i < l; i++) {
                    var s = sortList[i],
                        o = c.headerList[s[0]];
                    o.count = s[1];
                    o.count++
                }
            }
            function multisort(table, sortList, cache) {
                if (table.config.debug) {
                    var sortTime = new Date()
                }
                var dynamicExp = "var sortWrapper = function(a,b) {",
                    l = sortList.length;
                for (var i = 0; i < l; i++) {
                    var c = sortList[i][0];
                    var order = sortList[i][1];
                    var s = (getCachedSortType(table.config.parsers, c) == "text") ? ((order == 0) ? "sortText" : "sortTextDesc") : ((order == 0) ? "sortNumeric" : "sortNumericDesc");
                    var e = "e" + i;
                    dynamicExp += "var " + e + " = " + s + "(a[" + c + "],b[" + c + "]); ";
                    dynamicExp += "if(" + e + ") { return " + e + "; } ";
                    dynamicExp += "else { "
                }
                var orgOrderCol = cache.normalized[0].length - 1;
                dynamicExp += "return a[" + orgOrderCol + "]-b[" + orgOrderCol + "];";
                for (var i = 0; i < l; i++) {
                    dynamicExp += "}; "
                }
                dynamicExp += "return 0; ";
                dynamicExp += "}; ";
                eval(dynamicExp);
                cache.normalized.sort(sortWrapper);
                if (table.config.debug) {
                    benchmark("Sorting on " + sortList.toString() + " and dir " + order + " time:", sortTime)
                }
                return cache
            }
            function sortText(a, b) {
                return ((a < b) ? -1 : ((a > b) ? 1 : 0))
            }
            function sortTextDesc(a, b) {
                return ((b < a) ? -1 : ((b > a) ? 1 : 0))
            }
            function sortNumeric(a, b) {
                return a - b
            }
            function sortNumericDesc(a, b) {
                return b - a
            }
            function getCachedSortType(parsers, i) {
                return parsers[i].type
            }
            this.construct = function (settings) {
                return this.each(function () {
                    if (!this.tHead || !this.tBodies) {
                        return
                    }
                    var $this, $document, $headers, cache, config, shiftDown = 0,
                        sortOrder;
                    this.config = {};
                    config = $.extend(this.config, $.tablesorter.defaults, settings);
                    $this = $(this);
                    $headers = buildHeaders(this);
                    this.config.parsers = buildParserCache(this, $headers);
                    cache = buildCache(this);
                    this.config.cache = cache;
                    var sortCSS = [config.cssDesc, config.cssAsc];
                    fixColumnWidth(this);
                    $headers.click(function (e) {
                        $this.trigger("sortStart");
                        var totalRows = ($this[0].tBodies[0] && $this[0].tBodies[0].rows.length) || 0;
                        if (!this.sortDisabled && totalRows > 0) {
                            var $cell = $(this);
                            var i = this.column;
                            this.order = this.count++ % 2;
                            if (!e[config.sortMultiSortKey]) {
                                config.sortList = [];
                                if (config.sortForce != null) {
                                    var a = config.sortForce;
                                    for (var j = 0; j < a.length; j++) {
                                        if (a[j][0] != i) {
                                            config.sortList.push(a[j])
                                        }
                                    }
                                }
                                config.sortList.push([i, this.order])
                            } else {
                                if (isValueInArray(i, config.sortList)) {
                                    for (var j = 0; j < config.sortList.length; j++) {
                                        var s = config.sortList[j],
                                            o = config.headerList[s[0]];
                                        if (s[0] == i) {
                                            o.count = s[1];
                                            o.count++;
                                            s[1] = o.count % 2
                                        }
                                    }
                                } else {
                                    config.sortList.push([i, this.order])
                                }
                            }
                            setTimeout(function () {
                                setHeadersCss($this[0], $headers, config.sortList, sortCSS);
                                appendToTable($this[0], multisort($this[0], config.sortList, cache))
                            }, 1);
                            return false
                        }
                    }).mousedown(function () {
                        if (config.cancelSelection) {
                            this.onselectstart = function () {
                                return false
                            };
                            return false
                        }
                    });
                    $this.bind("update", function () {
                        this.config.parsers = buildParserCache(this, $headers);
                        cache = buildCache(this)
                    }).bind("sorton", function (e, list) {
                        $(this).trigger("sortStart");
                        config.sortList = list;
                        var sortList = config.sortList;
                        updateHeaderSortCount(this, sortList);
                        setHeadersCss(this, $headers, sortList, sortCSS);
                        appendToTable(this, multisort(this, sortList, cache))
                    }).bind("appendCache", function () {
                        appendToTable(this, cache)
                    }).bind("applyWidgetId", function (e, id) {
                        getWidgetById(id).format(this)
                    }).bind("applyWidgets", function () {
                        applyWidget(this)
                    });
                    if ($.metadata && ($(this).metadata() && $(this).metadata().sortlist)) {
                        config.sortList = $(this).metadata().sortlist
                    }
                    if (config.sortList.length > 0) {
                        $this.trigger("sorton", [config.sortList])
                    }
                    applyWidget(this)
                })
            };
            this.addParser = function (parser) {
                var l = parsers.length,
                    a = true;
                for (var i = 0; i < l; i++) {
                    if (parsers[i].id.toLowerCase() == parser.id.toLowerCase()) {
                        a = false
                    }
                }
                if (a) {
                    parsers.push(parser)
                }
            };
            this.addWidget = function (widget) {
                widgets.push(widget)
            };
            this.formatFloat = function (s) {
                var i = parseFloat(s);
                return (isNaN(i)) ? 0 : i
            };
            this.formatInt = function (s) {
                var i = parseInt(s);
                return (isNaN(i)) ? 0 : i
            };
            this.isDigit = function (s, config) {
                var DECIMAL = "\\" + config.decimal;
                var exp = "/(^[+]?0(" + DECIMAL + "0+)?$)|(^([-+]?[1-9][0-9]*)$)|(^([-+]?((0?|[1-9][0-9]*)" + DECIMAL + "(0*[1-9][0-9]*)))$)|(^[-+]?[1-9]+[0-9]*" + DECIMAL + "0+$)/";
                return RegExp(exp).test($.trim(s))
            };
            this.clearTableBody = function (table) {
                if ($.browser.msie) {
                    function empty() {
                        while (this.firstChild) {
                            this.removeChild(this.firstChild)
                        }
                    }
                    empty.apply(table.tBodies[0])
                } else {
                    table.tBodies[0].innerHTML = ""
                }
            }
        }
    });
    $.fn.extend({
        tablesorter: $.tablesorter.construct
    });
    var ts = $.tablesorter;
    ts.addParser({
        id: "text",
        is: function (s) {
            return true
        },
        format: function (s) {
            return $.trim(s.toLowerCase())
        },
        type: "text"
    });
    ts.addParser({
        id: "digit",
        is: function (s, table) {
            var c = table.config;
            return $.tablesorter.isDigit(s, c)
        },
        format: function (s) {
            return $.tablesorter.formatFloat(s)
        },
        type: "numeric"
    });
    ts.addParser({
        id: "currency",
        is: function (s) {
            return /^[Â£$â‚¬?.]/.test(s)
        },
        format: function (s) {
            return $.tablesorter.formatFloat(s.replace(new RegExp(/[^0-9.]/g), ""))
        },
        type: "numeric"
    });
    ts.addParser({
        id: "ipAddress",
        is: function (s) {
            return /^\d{2,3}[\.]\d{2,3}[\.]\d{2,3}[\.]\d{2,3}$/.test(s)
        },
        format: function (s) {
            var a = s.split("."),
                r = "",
                l = a.length;
            for (var i = 0; i < l; i++) {
                var item = a[i];
                if (item.length == 2) {
                    r += "0" + item
                } else {
                    r += item
                }
            }
            return $.tablesorter.formatFloat(r)
        },
        type: "numeric"
    });
    ts.addParser({
        id: "url",
        is: function (s) {
            return /^(https?|ftp|file):\/\/$/.test(s)
        },
        format: function (s) {
            return jQuery.trim(s.replace(new RegExp(/(https?|ftp|file):\/\//), ""))
        },
        type: "text"
    });
    ts.addParser({
        id: "isoDate",
        is: function (s) {
            return /^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/.test(s)
        },
        format: function (s) {
            return $.tablesorter.formatFloat((s != "") ? new Date(s.replace(new RegExp(/-/g), "/")).getTime() : "0")
        },
        type: "numeric"
    });
    ts.addParser({
        id: "percent",
        is: function (s) {
            return /\%$/.test($.trim(s))
        },
        format: function (s) {
            return $.tablesorter.formatFloat(s.replace(new RegExp(/%/g), ""))
        },
        type: "numeric"
    });
    ts.addParser({
        id: "usLongDate",
        is: function (s) {
            return s.match(new RegExp(/^[A-Za-z]{3,10}\.? [0-9]{1,2}, ([0-9]{4}|'?[0-9]{2}) (([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\s(AM|PM)))$/))
        },
        format: function (s) {
            return $.tablesorter.formatFloat(new Date(s).getTime())
        },
        type: "numeric"
    });
    ts.addParser({
        id: "shortDate",
        is: function (s) {
            return /\d{1,2}[\/\-]\d{1,2}[\/\-]\d{2,4}/.test(s)
        },
        format: function (s, table) {
            var c = table.config;
            s = s.replace(/\-/g, "/");
            if (c.dateFormat == "us") {
                s = s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{4})/, "$3/$1/$2")
            } else {
                if (c.dateFormat == "uk") {
                    s = s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{4})/, "$3/$2/$1")
                } else {
                    if (c.dateFormat == "dd/mm/yy" || c.dateFormat == "dd-mm-yy") {
                        s = s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{2})/, "$1/$2/$3")
                    }
                }
            }
            return $.tablesorter.formatFloat(new Date(s).getTime())
        },
        type: "numeric"
    });
    ts.addParser({
        id: "time",
        is: function (s) {
            return /^(([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\s(am|pm)))$/.test(s)
        },
        format: function (s) {
            return $.tablesorter.formatFloat(new Date("2000/01/01 " + s).getTime())
        },
        type: "numeric"
    });
    ts.addParser({
        id: "metadata",
        is: function (s) {
            return false
        },
        format: function (s, table, cell) {
            var c = table.config,
                p = (!c.parserMetadataName) ? "sortValue" : c.parserMetadataName;
            return $(cell).metadata()[p]
        },
        type: "numeric"
    });
    ts.addWidget({
        id: "zebra",
        format: function (table) {
            if (table.config.debug) {
                var time = new Date()
            }
            $("tr:visible", table.tBodies[0]).filter(":even").removeClass(table.config.widgetZebra.css[1]).addClass(table.config.widgetZebra.css[0]).end().filter(":odd").removeClass(table.config.widgetZebra.css[0]).addClass(table.config.widgetZebra.css[1]);
            if (table.config.debug) {
                $.tablesorter.benchmark("Applying Zebra widget", time)
            }
        }
    })
})(jQuery);
(function (a) {
    a.fn.tabSlideOut = function (l) {
        var e = a.extend({
            tabHandle: ".handle",
            speed: 300,
            action: "click",
            tabLocation: "left",
            topPos: "200px",
            leftPos: "20px",
            fixedPosition: false,
            positioning: "absolute",
            pathToTabImage: null,
            imageHeight: null,
            imageWidth: null,
            onLoadSlideOut: false
        }, l || {});
        e.tabHandle = a(e.tabHandle);
        var f = this;
        if (e.fixedPosition === true) {
            e.positioning = "fixed"
        } else {
            e.positioning = "absolute"
        }
        if (document.all && !window.opera && !window.XMLHttpRequest) {
            e.positioning = "absolute"
        }
        if (e.pathToTabImage != null) {
            e.tabHandle.css({
                background: "url(" + e.pathToTabImage + ") no-repeat",
                width: e.imageWidth,
                height: e.imageHeight
            })
        }
        e.tabHandle.css({
            display: "block",
            textIndent: "-99999px",
            outline: "none",
            position: "absolute"
        });
        f.css({
            "line-height": "1",
            position: e.positioning
        });
        var j = {
            containerWidth: parseInt(f.outerWidth(), 10) + "px",
            containerHeight: parseInt(f.outerHeight(), 10) + "px",
            tabWidth: parseInt(e.tabHandle.outerWidth(), 10) + "px",
            tabHeight: parseInt(e.tabHandle.outerHeight(), 10) + "px"
        };
        if (e.tabLocation === "top" || e.tabLocation === "bottom") {
            f.css({
                left: e.leftPos
            });
            e.tabHandle.css({
                right: 0
            })
        }
        if (e.tabLocation === "top") {
            f.css({
                top: "-" + j.containerHeight
            });
            e.tabHandle.css({
                bottom: "-" + j.tabHeight
            })
        }
        if (e.tabLocation === "bottom") {
            f.css({
                bottom: "-" + j.containerHeight,
                position: "fixed"
            });
            e.tabHandle.css({
                top: "-" + j.tabHeight
            })
        }
        if (e.tabLocation === "left" || e.tabLocation === "right") {
            f.css({
                height: j.containerHeight,
                top: e.topPos
            });
            e.tabHandle.css({
                top: 0
            })
        }
        if (e.tabLocation === "left") {
            f.css({
                left: "-" + j.containerWidth
            });
            e.tabHandle.css({
                right: "-" + j.tabWidth
            })
        }
        if (e.tabLocation === "right") {
            f.css({
                right: "-" + j.containerWidth
            });
            e.tabHandle.css({
                left: "-" + j.tabWidth
            });
            a("html").css("overflow-x", "hidden")
        }
        e.tabHandle.click(function (m) {
            m.preventDefault()
        });
        var d = function () {
            if (e.tabLocation === "top") {
                f.animate({
                    top: "-" + j.containerHeight
                }, e.speed).removeClass("open")
            } else {
                if (e.tabLocation === "left") {
                    f.animate({
                        left: "-" + j.containerWidth
                    }, e.speed).removeClass("open")
                } else {
                    if (e.tabLocation === "right") {
                        f.animate({
                            right: "-" + j.containerWidth
                        }, e.speed).removeClass("open")
                    } else {
                        if (e.tabLocation === "bottom") {
                            f.animate({
                                bottom: "-" + j.containerHeight
                            }, e.speed).removeClass("open")
                        }
                    }
                }
            }
        };
        var g = function () {
            if (e.tabLocation == "top") {
                f.animate({
                    top: "-3px"
                }, e.speed).addClass("open")
            } else {
                if (e.tabLocation == "left") {
                    f.animate({
                        left: "-3px"
                    }, e.speed).addClass("open")
                } else {
                    if (e.tabLocation == "right") {
                        f.animate({
                            right: "-3px"
                        }, e.speed).addClass("open")
                    } else {
                        if (e.tabLocation == "bottom") {
                            f.animate({
                                bottom: "-3px"
                            }, e.speed).addClass("open")
                        }
                    }
                }
            }
        };
        var c = function () {
            f.click(function (m) {
                m.stopPropagation()
            });
            a(document).click(function () {
                d()
            })
        };
        var k = function () {
            e.tabHandle.click(function (m) {
                if (f.hasClass("open")) {
                    d()
                } else {
                    g()
                }
            });
            c()
        };
        var h = function () {
            f.hover(function () {
                g()
            }, function () {
                d()
            });
            e.tabHandle.click(function (m) {
                if (f.hasClass("open")) {
                    d()
                }
            });
            c()
        };
        var b = function () {
            d();
            setTimeout(g, 500)
        };
        if (e.action === "click") {
            k()
        }
        if (e.action === "hover") {
            h()
        }
        if (e.onLoadSlideOut) {
            b()
        }
    }
})(jQuery);
