view src/main/webapp/imageServer/resources/js/diva.min.js @ 19:7f4e574966bd

info zu ref anzeigen
author dwinter
date Mon, 13 Apr 2015 11:14:52 +0000
parents 764f47286679
children 0f907d47b956
line wrap: on
line source

Storage.prototype.setObject = function (b, e) {
    this.setItem(b, JSON.stringify(e))
};
Storage.prototype.getObject = function (b) {
    return (b = this.getItem(b)) && JSON.parse(b)
};
(function (b) {
    var e = 1;
    b.generateId = function (b) {
        var c;
        do c = e+++(b ? "-" + b : ""); while (document.getElementById(c));
        return c
    }
})(jQuery);
(function (b) {
    b.getScrollbarWidth = function () {
        var b = document.createElement("p");
        b.style.width = "100%";
        b.style.height = "200px";
        var d = document.createElement("div");
        d.style.position = "absolute";
        d.style.top = "0px";
        d.style.left = "0px";
        d.style.visibility = "hidden";
        d.style.width = "200px";
        d.style.height = "150px";
        d.style.overflow = "hidden";
        d.appendChild(b);
        document.body.appendChild(d);
        var c = b.offsetWidth;
        d.style.overflow = "scroll";
        b = b.offsetWidth;
        c == b && (b = d.clientWidth);
        document.body.removeChild(d);
        return c - b
    }
})(jQuery);
(function (b) {
    b.getHashParam = function (b) {
        var d = window.location.hash;
        if ("" !== d) {
            var c = 0 < d.indexOf("&" + b + "=") ? d.indexOf("&" + b + "=") : d.indexOf("#" + b + "=");
            if (0 <= c) return c += b.length + 2, b = d.indexOf("&", c), b > c ? d.substring(c, b) : 0 > b ? d.substring(c) : ""
        }
        return !1
    }
})(jQuery);
(function (b) {
    b.updateHashParam = function (e, d) {
        var c = b.getHashParam(e),
            a = window.location.hash;
        if (c !== d)
            if ("string" == typeof c) {
                var f = 0 < a.indexOf("&" + e + "=") ? a.indexOf("&" + e + "=") : a.indexOf("#" + e + "="),
                    c = f + e.length + 2 + c.length,
                    l = 0 === f ? "#" : "&";
                window.location.replace(a.substring(0, f) + l + e + "=" + d + a.substring(c))
            } else 0 === a.length ? window.location.replace("#" + e + "=" + d) : window.location.replace(a + "&" + e + "=" + d)
    }
})(jQuery);
jQuery.fn.oneFingerScroll = function () {
    var b, e;
    $(this).bind("touchstart", function (d) {
        d = d.originalEvent;
        b = $(this).scrollTop() + d.touches[0].pageY;
        e = $(this).scrollLeft() + d.touches[0].pageX;
        d.preventDefault()
    });
    $(this).bind("touchmove", function (d) {
        d = d.originalEvent;
        $(this).scrollTop(b - d.touches[0].pageY);
        $(this).scrollLeft(e - d.touches[0].pageX);
        d.preventDefault()
    });
    return this
};
(function (b) {
    b.fn.dragscrollable = function (e) {
        var d = b.extend({
            dragSelector: ">:first",
            acceptPropagatedEvent: !0,
            preventDefault: !0
        }, e || {}),
            c = {
                mouseDownHandler: function (a) {
                    if (1 != a.which || !a.data.acceptPropagatedEvent && a.target != this) return !1;
                    a.data.lastCoord = {
                        left: a.clientX,
                        top: a.clientY
                    };
                    b.event.add(document, "mouseup", c.mouseUpHandler, a.data);
                    b.event.add(document, "mousemove", c.mouseMoveHandler, a.data);
                    if (a.data.preventDefault) return a.preventDefault(), !1
                },
                mouseMoveHandler: function (a) {
                    var b = a.clientX -
                        a.data.lastCoord.left,
                        c = a.clientY - a.data.lastCoord.top;
                    a.data.scrollable.scrollLeft(a.data.scrollable.scrollLeft() - b);
                    a.data.scrollable.scrollTop(a.data.scrollable.scrollTop() - c);
                    a.data.lastCoord = {
                        left: a.clientX,
                        top: a.clientY
                    };
                    if (a.data.preventDefault) return a.preventDefault(), !1
                },
                mouseUpHandler: function (a) {
                    b.event.remove(document, "mousemove", c.mouseMoveHandler);
                    b.event.remove(document, "mouseup", c.mouseUpHandler);
                    if (a.data.preventDefault) return a.preventDefault(), !1
                }
            };
        this.each(function () {
            var a = {
                scrollable: b(this),
                acceptPropagatedEvent: d.acceptPropagatedEvent,
                preventDefault: d.preventDefault
            };
            b(this).find(d.dragSelector).bind("mousedown", a, c.mouseDownHandler)
        })
    }
})(jQuery);
(function (b, e) {
    function d(a, d) {
        var e, f, m, n = a.nodeName.toLowerCase();
        return "area" === n ? (e = a.parentNode, f = e.name, a.href && f && "map" === e.nodeName.toLowerCase() ? (m = b("img[usemap=#" + f + "]")[0], !! m && c(m)) : !1) : (/input|select|textarea|button|object/.test(n) ? !a.disabled : "a" === n ? a.href || d : d) && c(a)
    }

    function c(a) {
        return b.expr.filters.visible(a) && !b(a).parents().addBack().filter(function () {
            return "hidden" === b.css(this, "visibility")
        }).length
    }
    var a = 0,
        f = /^ui-id-\d+$/;
    b.ui = b.ui || {};
    b.extend(b.ui, {
        version: "1.10.3",
        keyCode: {
            BACKSPACE: 8,
            COMMA: 188,
            DELETE: 46,
            DOWN: 40,
            END: 35,
            ENTER: 13,
            ESCAPE: 27,
            HOME: 36,
            LEFT: 37,
            NUMPAD_ADD: 107,
            NUMPAD_DECIMAL: 110,
            NUMPAD_DIVIDE: 111,
            NUMPAD_ENTER: 108,
            NUMPAD_MULTIPLY: 106,
            NUMPAD_SUBTRACT: 109,
            PAGE_DOWN: 34,
            PAGE_UP: 33,
            PERIOD: 190,
            RIGHT: 39,
            SPACE: 32,
            TAB: 9,
            UP: 38
        }
    });
    b.fn.extend({
        focus: function (a) {
            return function (d, c) {
                return "number" == typeof d ? this.each(function () {
                    var a = this;
                    setTimeout(function () {
                        b(a).focus();
                        c && c.call(a)
                    }, d)
                }) : a.apply(this, arguments)
            }
        }(b.fn.focus),
        scrollParent: function () {
            var a;
            return a = b.ui.ie && /(static|relative)/.test(this.css("position")) ||
                /absolute/.test(this.css("position")) ? this.parents().filter(function () {
                    return /(relative|absolute|fixed)/.test(b.css(this, "position")) && /(auto|scroll)/.test(b.css(this, "overflow") + b.css(this, "overflow-y") + b.css(this, "overflow-x"))
                }).eq(0) : this.parents().filter(function () {
                    return /(auto|scroll)/.test(b.css(this, "overflow") + b.css(this, "overflow-y") + b.css(this, "overflow-x"))
                }).eq(0), /fixed/.test(this.css("position")) || !a.length ? b(document) : a
        },
        zIndex: function (a) {
            if (a !== e) return this.css("zIndex", a);
            if (this.length) {
                var d,
                    c;
                for (a = b(this[0]); a.length && a[0] !== document;) {
                    if (d = a.css("position"), ("absolute" === d || "relative" === d || "fixed" === d) && (c = parseInt(a.css("zIndex"), 10), !isNaN(c) && 0 !== c)) return c;
                    a = a.parent()
                }
            }
            return 0
        },
        uniqueId: function () {
            return this.each(function () {
                this.id || (this.id = "ui-id-" + ++a)
            })
        },
        removeUniqueId: function () {
            return this.each(function () {
                f.test(this.id) && b(this).removeAttr("id")
            })
        }
    });
    b.extend(b.expr[":"], {
        data: b.expr.createPseudo ? b.expr.createPseudo(function (a) {
            return function (d) {
                return !!b.data(d, a)
            }
        }) : function (a, d, c) {
            return !!b.data(a, c[3])
        },
        focusable: function (a) {
            return d(a, !isNaN(b.attr(a, "tabindex")))
        },
        tabbable: function (a) {
            var c = b.attr(a, "tabindex"),
                e = isNaN(c);
            return (e || 0 <= c) && d(a, !e)
        }
    });
    b("<a>").outerWidth(1).jquery || b.each(["Width", "Height"], function (a, c) {
        function d(a, c, e, l) {
            return b.each(f, function () {
                c -= parseFloat(b.css(a, "padding" + this)) || 0;
                e && (c -= parseFloat(b.css(a, "border" + this + "Width")) || 0);
                l && (c -= parseFloat(b.css(a, "margin" + this)) || 0)
            }), c
        }
        var f = "Width" === c ? ["Left", "Right"] : ["Top", "Bottom"],
            m = c.toLowerCase(),
            n = {
                innerWidth: b.fn.innerWidth,
                innerHeight: b.fn.innerHeight,
                outerWidth: b.fn.outerWidth,
                outerHeight: b.fn.outerHeight
            };
        b.fn["inner" + c] = function (a) {
            return a === e ? n["inner" + c].call(this) : this.each(function () {
                b(this).css(m, d(this, a) + "px")
            })
        };
        b.fn["outer" + c] = function (a, e) {
            return "number" != typeof a ? n["outer" + c].call(this, a) : this.each(function () {
                b(this).css(m, d(this, a, !0, e) + "px")
            })
        }
    });
    b.fn.addBack || (b.fn.addBack = function (a) {
        return this.add(null == a ? this.prevObject : this.prevObject.filter(a))
    });
    b("<a>").data("a-b", "a").removeData("a-b").data("a-b") && (b.fn.removeData = function (a) {
        return function (c) {
            return arguments.length ? a.call(this, b.camelCase(c)) : a.call(this)
        }
    }(b.fn.removeData));
    b.ui.ie = !! /msie [\w.]+/.exec(navigator.userAgent.toLowerCase());
    b.support.selectstart = "onselectstart" in document.createElement("div");
    b.fn.extend({
        disableSelection: function () {
            return this.bind((b.support.selectstart ? "selectstart" : "mousedown") + ".ui-disableSelection", function (a) {
                a.preventDefault()
            })
        },
        enableSelection: function () {
            return this.unbind(".ui-disableSelection")
        }
    });
    b.extend(b.ui, {
        plugin: {
            add: function (a, c, d) {
                var e;
                a = b.ui[a].prototype;
                for (e in d) a.plugins[e] = a.plugins[e] || [], a.plugins[e].push([c, d[e]])
            },
            call: function (a, b, c) {
                var d = a.plugins[b];
                if (d && a.element[0].parentNode && 11 !== a.element[0].parentNode.nodeType)
                    for (b = 0; d.length > b; b++) a.options[d[b][0]] && d[b][1].apply(a.element, c)
            }
        },
        hasScroll: function (a, c) {
            if ("hidden" === b(a).css("overflow")) return !1;
            var d = c && "left" === c ? "scrollLeft" : "scrollTop",
                e = !1;
            return 0 < a[d] ? !0 : (a[d] = 1, e = 0 < a[d], a[d] = 0, e)
        }
    })
})(jQuery);
(function (b, e) {
    var d = 0,
        c = Array.prototype.slice,
        a = b.cleanData;
    b.cleanData = function (c) {
        for (var d, e = 0; null != (d = c[e]); e++) try {
            b(d).triggerHandler("remove")
        } catch (k) {}
        a(c)
    };
    b.widget = function (a, c, d) {
        var k, h, m, n, t = {}, v = a.split(".")[0];
        a = a.split(".")[1];
        k = v + "-" + a;
        d || (d = c, c = b.Widget);
        b.expr[":"][k.toLowerCase()] = function (a) {
            return !!b.data(a, k)
        };
        b[v] = b[v] || {};
        h = b[v][a];
        m = b[v][a] = function (a, b) {
            return this._createWidget ? (arguments.length && this._createWidget(a, b), e) : new m(a, b)
        };
        b.extend(m, h, {
            version: d.version,
            _proto: b.extend({}, d),
            _childConstructors: []
        });
        n = new c;
        n.options = b.widget.extend({}, n.options);
        b.each(d, function (a, d) {
            return b.isFunction(d) ? (t[a] = function () {
                var b = function () {
                    return c.prototype[a].apply(this, arguments)
                }, e = function (b) {
                        return c.prototype[a].apply(this, b)
                    };
                return function () {
                    var a, c = this._super,
                        f = this._superApply;
                    return this._super = b, this._superApply = e, a = d.apply(this, arguments), this._super = c, this._superApply = f, a
                }
            }(), e) : (t[a] = d, e)
        });
        m.prototype = b.widget.extend(n, {
            widgetEventPrefix: h ? n.widgetEventPrefix : a
        }, t, {
            constructor: m,
            namespace: v,
            widgetName: a,
            widgetFullName: k
        });
        h ? (b.each(h._childConstructors, function (a, c) {
            var d = c.prototype;
            b.widget(d.namespace + "." + d.widgetName, m, c._proto)
        }), delete h._childConstructors) : c._childConstructors.push(m);
        b.widget.bridge(a, m)
    };
    b.widget.extend = function (a) {
        for (var d, g, k = c.call(arguments, 1), h = 0, m = k.length; m > h; h++)
            for (d in k[h]) g = k[h][d], k[h].hasOwnProperty(d) && g !== e && (a[d] = b.isPlainObject(g) ? b.isPlainObject(a[d]) ? b.widget.extend({}, a[d], g) : b.widget.extend({}, g) : g);
        return a
    };
    b.widget.bridge = function (a, d) {
        var g = d.prototype.widgetFullName || a;
        b.fn[a] = function (k) {
            var h = "string" == typeof k,
                m = c.call(arguments, 1),
                n = this;
            return k = !h && m.length ? b.widget.extend.apply(null, [k].concat(m)) : k, h ? this.each(function () {
                var d, c = b.data(this, g);
                return c ? b.isFunction(c[k]) && "_" !== k.charAt(0) ? (d = c[k].apply(c, m), d !== c && d !== e ? (n = d && d.jquery ? n.pushStack(d.get()) : d, !1) : e) : b.error("no such method '" + k + "' for " + a + " widget instance") : b.error("cannot call methods on " + a + " prior to initialization; attempted to call method '" +
                    k + "'")
            }) : this.each(function () {
                var a = b.data(this, g);
                a ? a.option(k || {})._init() : b.data(this, g, new d(k, this))
            }), n
        }
    };
    b.Widget = function () {};
    b.Widget._childConstructors = [];
    b.Widget.prototype = {
        widgetName: "widget",
        widgetEventPrefix: "",
        defaultElement: "<div>",
        options: {
            disabled: !1,
            create: null
        },
        _createWidget: function (a, c) {
            c = b(c || this.defaultElement || this)[0];
            this.element = b(c);
            this.uuid = d++;
            this.eventNamespace = "." + this.widgetName + this.uuid;
            this.options = b.widget.extend({}, this.options, this._getCreateOptions(), a);
            this.bindings = b();
            this.hoverable = b();
            this.focusable = b();
            c !== this && (b.data(c, this.widgetFullName, this), this._on(!0, this.element, {
                remove: function (a) {
                    a.target === c && this.destroy()
                }
            }), this.document = b(c.style ? c.ownerDocument : c.document || c), this.window = b(this.document[0].defaultView || this.document[0].parentWindow));
            this._create();
            this._trigger("create", null, this._getCreateEventData());
            this._init()
        },
        _getCreateOptions: b.noop,
        _getCreateEventData: b.noop,
        _create: b.noop,
        _init: b.noop,
        destroy: function () {
            this._destroy();
            this.element.unbind(this.eventNamespace).removeData(this.widgetName).removeData(this.widgetFullName).removeData(b.camelCase(this.widgetFullName));
            this.widget().unbind(this.eventNamespace).removeAttr("aria-disabled").removeClass(this.widgetFullName + "-disabled ui-state-disabled");
            this.bindings.unbind(this.eventNamespace);
            this.hoverable.removeClass("ui-state-hover");
            this.focusable.removeClass("ui-state-focus")
        },
        _destroy: b.noop,
        widget: function () {
            return this.element
        },
        option: function (a, c) {
            var d, k, h, m = a;
            if (0 === arguments.length) return b.widget.extend({}, this.options);
            if ("string" == typeof a)
                if (m = {}, d = a.split("."), a = d.shift(), d.length) {
                    k = m[a] = b.widget.extend({}, this.options[a]);
                    for (h = 0; d.length - 1 > h; h++) k[d[h]] = k[d[h]] || {}, k = k[d[h]];
                    if (a = d.pop(), c === e) return k[a] === e ? null : k[a];
                    k[a] = c
                } else {
                    if (c === e) return this.options[a] === e ? null : this.options[a];
                    m[a] = c
                }
            return this._setOptions(m), this
        },
        _setOptions: function (a) {
            for (var b in a) this._setOption(b, a[b]);
            return this
        },
        _setOption: function (a, b) {
            return this.options[a] =
                b, "disabled" === a && (this.widget().toggleClass(this.widgetFullName + "-disabled ui-state-disabled", !! b).attr("aria-disabled", b), this.hoverable.removeClass("ui-state-hover"), this.focusable.removeClass("ui-state-focus")), this
        },
        enable: function () {
            return this._setOption("disabled", !1)
        },
        disable: function () {
            return this._setOption("disabled", !0)
        },
        _on: function (a, c, d) {
            var k, h = this;
            "boolean" != typeof a && (d = c, c = a, a = !1);
            d ? (c = k = b(c), this.bindings = this.bindings.add(c)) : (d = c, c = this.element, k = this.widget());
            b.each(d, function (d,
                n) {
                function t() {
                    return a || !0 !== h.options.disabled && !b(this).hasClass("ui-state-disabled") ? ("string" == typeof n ? h[n] : n).apply(h, arguments) : e
                }
                "string" != typeof n && (t.guid = n.guid = n.guid || t.guid || b.guid++);
                var g = d.match(/^(\w+)\s*(.*)$/),
                    p = g[1] + h.eventNamespace;
                (g = g[2]) ? k.delegate(g, p, t) : c.bind(p, t)
            })
        },
        _off: function (a, b) {
            b = (b || "").split(" ").join(this.eventNamespace + " ") + this.eventNamespace;
            a.unbind(b).undelegate(b)
        },
        _delay: function (a, b) {
            var c = this;
            return setTimeout(function () {
                return ("string" == typeof a ?
                    c[a] : a).apply(c, arguments)
            }, b || 0)
        },
        _hoverable: function (a) {
            this.hoverable = this.hoverable.add(a);
            this._on(a, {
                mouseenter: function (a) {
                    b(a.currentTarget).addClass("ui-state-hover")
                },
                mouseleave: function (a) {
                    b(a.currentTarget).removeClass("ui-state-hover")
                }
            })
        },
        _focusable: function (a) {
            this.focusable = this.focusable.add(a);
            this._on(a, {
                focusin: function (a) {
                    b(a.currentTarget).addClass("ui-state-focus")
                },
                focusout: function (a) {
                    b(a.currentTarget).removeClass("ui-state-focus")
                }
            })
        },
        _trigger: function (a, c, d) {
            var e, h = this.options[a];
            if (d = d || {}, c = b.Event(c), c.type = (a === this.widgetEventPrefix ? a : this.widgetEventPrefix + a).toLowerCase(), c.target = this.element[0], a = c.originalEvent)
                for (e in a) e in c || (c[e] = a[e]);
            return this.element.trigger(c, d), !(b.isFunction(h) && !1 === h.apply(this.element[0], [c].concat(d)) || c.isDefaultPrevented())
        }
    };
    b.each({
        show: "fadeIn",
        hide: "fadeOut"
    }, function (a, c) {
        b.Widget.prototype["_" + a] = function (d, e, h) {
            "string" == typeof e && (e = {
                effect: e
            });
            var m, n = e ? !0 === e || "number" == typeof e ? c : e.effect || c : a;
            e = e || {};
            "number" == typeof e &&
                (e = {
                duration: e
            });
            m = !b.isEmptyObject(e);
            e.complete = h;
            e.delay && d.delay(e.delay);
            m && b.effects && b.effects.effect[n] ? d[a](e) : n !== a && d[n] ? d[n](e.duration, e.easing, h) : d.queue(function (c) {
                b(this)[a]();
                h && h.call(d[0]);
                c()
            })
        }
    })
})(jQuery);
(function (b) {
    var e = !1;
    b(document).mouseup(function () {
        e = !1
    });
    b.widget("ui.mouse", {
        version: "1.10.3",
        options: {
            cancel: "input,textarea,button,select,option",
            distance: 1,
            delay: 0
        },
        _mouseInit: function () {
            var d = this;
            this.element.bind("mousedown." + this.widgetName, function (b) {
                return d._mouseDown(b)
            }).bind("click." + this.widgetName, function (c) {
                return !0 === b.data(c.target, d.widgetName + ".preventClickEvent") ? (b.removeData(c.target, d.widgetName + ".preventClickEvent"), c.stopImmediatePropagation(), !1) : void 0
            });
            this.started = !1
        },
        _mouseDestroy: function () {
            this.element.unbind("." + this.widgetName);
            this._mouseMoveDelegate && b(document).unbind("mousemove." + this.widgetName, this._mouseMoveDelegate).unbind("mouseup." + this.widgetName, this._mouseUpDelegate)
        },
        _mouseDown: function (d) {
            if (!e) {
                this._mouseStarted && this._mouseUp(d);
                this._mouseDownEvent = d;
                var c = this,
                    a = 1 === d.which,
                    f = "string" == typeof this.options.cancel && d.target.nodeName ? b(d.target).closest(this.options.cancel).length : !1;
                return a && !f && this._mouseCapture(d) ? (this.mouseDelayMet = !this.options.delay, this.mouseDelayMet || (this._mouseDelayTimer = setTimeout(function () {
                    c.mouseDelayMet = !0
                }, this.options.delay)), this._mouseDistanceMet(d) && this._mouseDelayMet(d) && (this._mouseStarted = !1 !== this._mouseStart(d), !this._mouseStarted) ? (d.preventDefault(), !0) : (!0 === b.data(d.target, this.widgetName + ".preventClickEvent") && b.removeData(d.target, this.widgetName + ".preventClickEvent"), this._mouseMoveDelegate = function (a) {
                        return c._mouseMove(a)
                    }, this._mouseUpDelegate = function (a) {
                        return c._mouseUp(a)
                    },
                    b(document).bind("mousemove." + this.widgetName, this._mouseMoveDelegate).bind("mouseup." + this.widgetName, this._mouseUpDelegate), d.preventDefault(), e = !0, !0)) : !0
            }
        },
        _mouseMove: function (d) {
            return b.ui.ie && (!document.documentMode || 9 > document.documentMode) && !d.button ? this._mouseUp(d) : this._mouseStarted ? (this._mouseDrag(d), d.preventDefault()) : (this._mouseDistanceMet(d) && this._mouseDelayMet(d) && (this._mouseStarted = !1 !== this._mouseStart(this._mouseDownEvent, d), this._mouseStarted ? this._mouseDrag(d) : this._mouseUp(d)), !this._mouseStarted)
        },
        _mouseUp: function (d) {
            return b(document).unbind("mousemove." + this.widgetName, this._mouseMoveDelegate).unbind("mouseup." + this.widgetName, this._mouseUpDelegate), this._mouseStarted && (this._mouseStarted = !1, d.target === this._mouseDownEvent.target && b.data(d.target, this.widgetName + ".preventClickEvent", !0), this._mouseStop(d)), !1
        },
        _mouseDistanceMet: function (b) {
            return Math.max(Math.abs(this._mouseDownEvent.pageX - b.pageX), Math.abs(this._mouseDownEvent.pageY - b.pageY)) >= this.options.distance
        },
        _mouseDelayMet: function () {
            return this.mouseDelayMet
        },
        _mouseStart: function () {},
        _mouseDrag: function () {},
        _mouseStop: function () {},
        _mouseCapture: function () {
            return !0
        }
    })
})(jQuery);
(function (b) {
    b.widget("ui.slider", b.ui.mouse, {
        version: "1.10.3",
        widgetEventPrefix: "slide",
        options: {
            animate: !1,
            distance: 0,
            max: 100,
            min: 0,
            orientation: "horizontal",
            range: !1,
            step: 1,
            value: 0,
            values: null,
            change: null,
            slide: null,
            start: null,
            stop: null
        },
        _create: function () {
            this._mouseSliding = this._keySliding = !1;
            this._animateOff = !0;
            this._handleIndex = null;
            this._detectOrientation();
            this._mouseInit();
            this.element.addClass("ui-slider ui-slider-" + this.orientation + " ui-widget ui-widget-content ui-corner-all");
            this._refresh();
            this._setOption("disabled", this.options.disabled);
            this._animateOff = !1
        },
        _refresh: function () {
            this._createRange();
            this._createHandles();
            this._setupEvents();
            this._refreshValue()
        },
        _createHandles: function () {
            var e, d;
            e = this.options;
            var c = this.element.find(".ui-slider-handle").addClass("ui-state-default ui-corner-all"),
                a = [];
            d = e.values && e.values.length || 1;
            c.length > d && (c.slice(d).remove(), c = c.slice(0, d));
            for (e = c.length; d > e; e++) a.push("<a class='ui-slider-handle ui-state-default ui-corner-all' href='#'></a>");
            this.handles = c.add(b(a.join("")).appendTo(this.element));
            this.handle = this.handles.eq(0);
            this.handles.each(function (a) {
                b(this).data("ui-slider-handle-index", a)
            })
        },
        _createRange: function () {
            var e = this.options,
                d = "";
            e.range ? (!0 === e.range && (e.values ? e.values.length && 2 !== e.values.length ? e.values = [e.values[0], e.values[0]] : b.isArray(e.values) && (e.values = e.values.slice(0)) : e.values = [this._valueMin(), this._valueMin()]), this.range && this.range.length ? this.range.removeClass("ui-slider-range-min ui-slider-range-max").css({
                left: "",
                bottom: ""
            }) : (this.range = b("<div></div>").appendTo(this.element), d = "ui-slider-range ui-widget-header ui-corner-all"), this.range.addClass(d + ("min" === e.range || "max" === e.range ? " ui-slider-range-" + e.range : ""))) : this.range = b([])
        },
        _setupEvents: function () {
            var b = this.handles.add(this.range).filter("a");
            this._off(b);
            this._on(b, this._handleEvents);
            this._hoverable(b);
            this._focusable(b)
        },
        _destroy: function () {
            this.handles.remove();
            this.range.remove();
            this.element.removeClass("ui-slider ui-slider-horizontal ui-slider-vertical ui-widget ui-widget-content ui-corner-all");
            this._mouseDestroy()
        },
        _mouseCapture: function (e) {
            var d, c, a, f, l, g, k, h, m = this,
                n = this.options;
            return n.disabled ? !1 : (this.elementSize = {
                    width: this.element.outerWidth(),
                    height: this.element.outerHeight()
                }, this.elementOffset = this.element.offset(), d = {
                    x: e.pageX,
                    y: e.pageY
                }, c = this._normValueFromMouse(d), a = this._valueMax() - this._valueMin() + 1, this.handles.each(function (d) {
                    var e = Math.abs(c - m.values(d));
                    (a > e || a === e && (d === m._lastChangedValue || m.values(d) === n.min)) && (a = e, f = b(this), l = d)
                }), g = this._start(e, l), !1 === g ? !1 :
                (this._mouseSliding = !0, this._handleIndex = l, f.addClass("ui-state-active").focus(), k = f.offset(), h = !b(e.target).parents().addBack().is(".ui-slider-handle"), this._clickOffset = h ? {
                    left: 0,
                    top: 0
                } : {
                    left: e.pageX - k.left - f.width() / 2,
                    top: e.pageY - k.top - f.height() / 2 - (parseInt(f.css("borderTopWidth"), 10) || 0) - (parseInt(f.css("borderBottomWidth"), 10) || 0) + (parseInt(f.css("marginTop"), 10) || 0)
                }, this.handles.hasClass("ui-state-hover") || this._slide(e, l, c), this._animateOff = !0, !0))
        },
        _mouseStart: function () {
            return !0
        },
        _mouseDrag: function (b) {
            var d =
                this._normValueFromMouse({
                    x: b.pageX,
                    y: b.pageY
                });
            return this._slide(b, this._handleIndex, d), !1
        },
        _mouseStop: function (b) {
            return this.handles.removeClass("ui-state-active"), this._mouseSliding = !1, this._stop(b, this._handleIndex), this._change(b, this._handleIndex), this._handleIndex = null, this._clickOffset = null, this._animateOff = !1, !1
        },
        _detectOrientation: function () {
            this.orientation = "vertical" === this.options.orientation ? "vertical" : "horizontal"
        },
        _normValueFromMouse: function (b) {
            var d, c, a, f, l;
            return "horizontal" ===
                this.orientation ? (d = this.elementSize.width, c = b.x - this.elementOffset.left - (this._clickOffset ? this._clickOffset.left : 0)) : (d = this.elementSize.height, c = b.y - this.elementOffset.top - (this._clickOffset ? this._clickOffset.top : 0)), a = c / d, 1 < a && (a = 1), 0 > a && (a = 0), "vertical" === this.orientation && (a = 1 - a), f = this._valueMax() - this._valueMin(), l = this._valueMin() + a * f, this._trimAlignValue(l)
        },
        _start: function (b, d) {
            var c = {
                handle: this.handles[d],
                value: this.value()
            };
            return this.options.values && this.options.values.length && (c.value =
                this.values(d), c.values = this.values()), this._trigger("start", b, c)
        },
        _slide: function (b, d, c) {
            var a, f, l;
            this.options.values && this.options.values.length ? (a = this.values(d ? 0 : 1), 2 === this.options.values.length && !0 === this.options.range && (0 === d && c > a || 1 === d && a > c) && (c = a), c !== this.values(d) && (f = this.values(), f[d] = c, l = this._trigger("slide", b, {
                handle: this.handles[d],
                value: c,
                values: f
            }), this.values(d ? 0 : 1), !1 !== l && this.values(d, c, !0))) : c !== this.value() && (l = this._trigger("slide", b, {
                    handle: this.handles[d],
                    value: c
                }), !1 !==
                l && this.value(c))
        },
        _stop: function (b, d) {
            var c = {
                handle: this.handles[d],
                value: this.value()
            };
            this.options.values && this.options.values.length && (c.value = this.values(d), c.values = this.values());
            this._trigger("stop", b, c)
        },
        _change: function (b, d) {
            if (!this._keySliding && !this._mouseSliding) {
                var c = {
                    handle: this.handles[d],
                    value: this.value()
                };
                this.options.values && this.options.values.length && (c.value = this.values(d), c.values = this.values());
                this._lastChangedValue = d;
                this._trigger("change", b, c)
            }
        },
        value: function (b) {
            return arguments.length ?
                (this.options.value = this._trimAlignValue(b), this._refreshValue(), this._change(null, 0), void 0) : this._value()
        },
        values: function (e, d) {
            var c, a, f;
            if (1 < arguments.length) return this.options.values[e] = this._trimAlignValue(d), this._refreshValue(), this._change(null, e), void 0;
            if (!arguments.length) return this._values();
            if (!b.isArray(arguments[0])) return this.options.values && this.options.values.length ? this._values(e) : this.value();
            c = this.options.values;
            a = arguments[0];
            for (f = 0; c.length > f; f += 1) c[f] = this._trimAlignValue(a[f]),
            this._change(null, f);
            this._refreshValue()
        },
        _setOption: function (e, d) {
            var c, a = 0;
            switch ("range" === e && !0 === this.options.range && ("min" === d ? (this.options.value = this._values(0), this.options.values = null) : "max" === d && (this.options.value = this._values(this.options.values.length - 1), this.options.values = null)), b.isArray(this.options.values) && (a = this.options.values.length), b.Widget.prototype._setOption.apply(this, arguments), e) {
            case "orientation":
                this._detectOrientation();
                this.element.removeClass("ui-slider-horizontal ui-slider-vertical").addClass("ui-slider-" +
                    this.orientation);
                this._refreshValue();
                break;
            case "value":
                this._animateOff = !0;
                this._refreshValue();
                this._change(null, 0);
                this._animateOff = !1;
                break;
            case "values":
                this._animateOff = !0;
                this._refreshValue();
                for (c = 0; a > c; c += 1) this._change(null, c);
                this._animateOff = !1;
                break;
            case "min":
            case "max":
                this._animateOff = !0;
                this._refreshValue();
                this._animateOff = !1;
                break;
            case "range":
                this._animateOff = !0, this._refresh(), this._animateOff = !1
            }
        },
        _value: function () {
            return this._trimAlignValue(this.options.value)
        },
        _values: function (b) {
            var d,
                c;
            if (arguments.length) return d = this.options.values[b], this._trimAlignValue(d);
            if (this.options.values && this.options.values.length) {
                d = this.options.values.slice();
                for (c = 0; d.length > c; c += 1) d[c] = this._trimAlignValue(d[c]);
                return d
            }
            return []
        },
        _trimAlignValue: function (b) {
            if (this._valueMin() >= b) return this._valueMin();
            if (b >= this._valueMax()) return this._valueMax();
            var d = 0 < this.options.step ? this.options.step : 1,
                c = (b - this._valueMin()) % d;
            b -= c;
            return 2 * Math.abs(c) >= d && (b += 0 < c ? d : -d), parseFloat(b.toFixed(5))
        },
        _valueMin: function () {
            return this.options.min
        },
        _valueMax: function () {
            return this.options.max
        },
        _refreshValue: function () {
            var e, d, c, a, f, l = this.options.range,
                g = this.options,
                k = this,
                h = this._animateOff ? !1 : g.animate,
                m = {};
            this.options.values && this.options.values.length ? this.handles.each(function (a) {
                d = 100 * ((k.values(a) - k._valueMin()) / (k._valueMax() - k._valueMin()));
                m["horizontal" === k.orientation ? "left" : "bottom"] = d + "%";
                b(this).stop(1, 1)[h ? "animate" : "css"](m, g.animate);
                !0 === k.options.range && ("horizontal" === k.orientation ? (0 === a && k.range.stop(1, 1)[h ? "animate" :
                    "css"]({
                    left: d + "%"
                }, g.animate), 1 === a && k.range[h ? "animate" : "css"]({
                    width: d - e + "%"
                }, {
                    queue: !1,
                    duration: g.animate
                })) : (0 === a && k.range.stop(1, 1)[h ? "animate" : "css"]({
                    bottom: d + "%"
                }, g.animate), 1 === a && k.range[h ? "animate" : "css"]({
                    height: d - e + "%"
                }, {
                    queue: !1,
                    duration: g.animate
                })));
                e = d
            }) : (c = this.value(), a = this._valueMin(), f = this._valueMax(), d = f !== a ? 100 * ((c - a) / (f - a)) : 0, m["horizontal" === this.orientation ? "left" : "bottom"] = d + "%", this.handle.stop(1, 1)[h ? "animate" : "css"](m, g.animate), "min" === l && "horizontal" === this.orientation &&
                this.range.stop(1, 1)[h ? "animate" : "css"]({
                    width: d + "%"
                }, g.animate), "max" === l && "horizontal" === this.orientation && this.range[h ? "animate" : "css"]({
                    width: 100 - d + "%"
                }, {
                    queue: !1,
                    duration: g.animate
                }), "min" === l && "vertical" === this.orientation && this.range.stop(1, 1)[h ? "animate" : "css"]({
                    height: d + "%"
                }, g.animate), "max" === l && "vertical" === this.orientation && this.range[h ? "animate" : "css"]({
                    height: 100 - d + "%"
                }, {
                    queue: !1,
                    duration: g.animate
                }))
        },
        _handleEvents: {
            keydown: function (e) {
                var d, c, a, f = b(e.target).data("ui-slider-handle-index");
                switch (e.keyCode) {
                case b.ui.keyCode.HOME:
                case b.ui.keyCode.END:
                case b.ui.keyCode.PAGE_UP:
                case b.ui.keyCode.PAGE_DOWN:
                case b.ui.keyCode.UP:
                case b.ui.keyCode.RIGHT:
                case b.ui.keyCode.DOWN:
                case b.ui.keyCode.LEFT:
                    if (e.preventDefault(), !this._keySliding && (this._keySliding = !0, b(e.target).addClass("ui-state-active"), d = this._start(e, f), !1 === d)) return
                }
                switch (a = this.options.step, d = c = this.options.values && this.options.values.length ? this.values(f) : this.value(), e.keyCode) {
                case b.ui.keyCode.HOME:
                    c = this._valueMin();
                    break;
                case b.ui.keyCode.END:
                    c = this._valueMax();
                    break;
                case b.ui.keyCode.PAGE_UP:
                    c = this._trimAlignValue(d + (this._valueMax() - this._valueMin()) / 5);
                    break;
                case b.ui.keyCode.PAGE_DOWN:
                    c = this._trimAlignValue(d - (this._valueMax() - this._valueMin()) / 5);
                    break;
                case b.ui.keyCode.UP:
                case b.ui.keyCode.RIGHT:
                    if (d === this._valueMax()) return;
                    c = this._trimAlignValue(d + a);
                    break;
                case b.ui.keyCode.DOWN:
                case b.ui.keyCode.LEFT:
                    if (d === this._valueMin()) return;
                    c = this._trimAlignValue(d - a)
                }
                this._slide(e, f, c)
            },
            click: function (b) {
                b.preventDefault()
            },
            keyup: function (e) {
                var d = b(e.target).data("ui-slider-handle-index");
                this._keySliding && (this._keySliding = !1, this._stop(e, d), this._change(e, d), b(e.target).removeClass("ui-state-active"))
            }
        }
    })
})(jQuery);
(function (b) {
    var e = {
        cursor: "move",
        decelerate: !0,
        triggerHardware: !1,
        y: !0,
        x: !0,
        slowdown: 0.9,
        maxvelocity: 40,
        throttleFPS: 60,
        movingClass: {
            up: "kinetic-moving-up",
            down: "kinetic-moving-down",
            left: "kinetic-moving-left",
            right: "kinetic-moving-right"
        },
        deceleratingClass: {
            up: "kinetic-decelerating-up",
            down: "kinetic-decelerating-down",
            left: "kinetic-decelerating-left",
            right: "kinetic-decelerating-right"
        }
    };
    window.requestAnimationFrame || (window.requestAnimationFrame = function () {
        return window.webkitRequestAnimationFrame ||
            window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function (a, b) {
                window.setTimeout(a, 1E3 / 60)
        }
    }());
    b.support = b.support || {};
    b.extend(b.support, {
        touch: "ontouchend" in document
    });
    var d = function () {
        return !1
    }, c = function (a, b) {
            var c = a;
            0 < a ? a > b && (c = b) : a < 0 - b && (c = 0 - b);
            return c
        }, a = function (a, b) {
            this.removeClass(a.movingClass.up).removeClass(a.movingClass.down).removeClass(a.movingClass.left).removeClass(a.movingClass.right).removeClass(a.deceleratingClass.up).removeClass(a.deceleratingClass.down).removeClass(a.deceleratingClass.left).removeClass(a.deceleratingClass.right);
            0 < a.velocity && this.addClass(b.right);
            0 > a.velocity && this.addClass(b.left);
            0 < a.velocityY && this.addClass(b.down);
            0 > a.velocityY && this.addClass(b.up)
        }, f = function (a, b) {
            b.velocity = 0;
            b.velocityY = 0;
            b.decelerate = !0;
            "function" === typeof b.stopped && b.stopped.call(a, b)
        }, l = function (b, c) {
            var d = b[0];
            c.x && 0 < d.scrollWidth ? (d.scrollLeft = c.scrollLeft = d.scrollLeft + c.velocity, 0 < Math.abs(c.velocity) && (c.velocity = c.decelerate ? 0 === Math.floor(Math.abs(c.velocity)) ? 0 : c.velocity * c.slowdown : c.velocity)) : c.velocity = 0;
            c.y && 0 < d.scrollHeight ?
                (d.scrollTop = c.scrollTop = d.scrollTop + c.velocityY, 0 < Math.abs(c.velocityY) && (c.velocityY = c.decelerate ? 0 === Math.floor(Math.abs(c.velocityY)) ? 0 : c.velocityY * c.slowdown : c.velocityY)) : c.velocityY = 0;
            a.call(b, c, c.deceleratingClass);
            "function" === typeof c.moved && c.moved.call(b, c);
            0 < Math.abs(c.velocity) || 0 < Math.abs(c.velocityY) ? window.requestAnimationFrame(function () {
                l(b, c)
            }) : f(b, c)
        }, g = function (a, c) {
            var d = b.kinetic.callMethods[a],
                e = Array.prototype.slice.call(arguments);
            d && this.each(function () {
                var a = e.slice(1),
                    c = b(this).data("kinetic-settings");
                a.unshift(c);
                d.apply(this, a)
            })
        }, k = function (a, c) {
            b.support.touch ? a.bind("touchstart", c.events.touchStart).bind("touchend", c.events.inputEnd).bind("touchmove", c.events.touchMove) : a.mousedown(c.events.inputDown).mouseup(c.events.inputEnd).mousemove(c.events.inputMove);
            a.click(c.events.inputClick).scroll(c.events.scroll).bind("selectstart", d).bind("dragstart", c.events.dragStart)
        }, h = function (d) {
            this.addClass("kinetic-active").each(function () {
                var f = this,
                    h = b(this);
                if (!h.data("kinetic-settings")) {
                    var g =
                        b.extend({}, e, d),
                        p, q = !1,
                        u, w = !1,
                        r = !1,
                        I = 1E3 / g.throttleFPS,
                        x, z;
                    g.velocity = 0;
                    g.velocityY = 0;
                    var K = function () {
                        r = u = p = !1
                    };
                    b(document).mouseup(K).click(K);
                    var s = function () {
                        g.velocity = c(q - p, g.maxvelocity);
                        g.velocityY = c(w - u, g.maxvelocity)
                    }, A = function (c, d) {
                            if (!x || new Date > new Date(x.getTime() + I)) x = new Date, r && (p || u) && (z && (b(z).blur(), z = null, h.focus()), g.decelerate = !1, g.velocity = g.velocityY = 0, h[0].scrollLeft = g.scrollLeft = g.x ? h[0].scrollLeft - (c - p) : h[0].scrollLeft, h[0].scrollTop = g.scrollTop = g.y ? h[0].scrollTop - (d -
                                u) : h[0].scrollTop, q = p, w = u, p = c, u = d, s(), a.call(h, g, g.movingClass), "function" === typeof g.moved && g.moved.call(h, g))
                        };
                    g.events = {
                        touchStart: function (a) {
                            var c;
                            if (b.isFunction(g.filterTarget) ? !1 !== g.filterTarget.call(f, a.target) : 1) {
                                c = a.originalEvent.touches[0];
                                var d = c.clientX;
                                c = c.clientY;
                                r = !0;
                                g.velocity = q = 0;
                                g.velocityY = w = 0;
                                p = d;
                                u = c;
                                a.stopPropagation()
                            }
                        },
                        touchMove: function (a) {
                            var b;
                            r && (b = a.originalEvent.touches[0], A(b.clientX, b.clientY), a.preventDefault && a.preventDefault())
                        },
                        inputDown: function (a) {
                            if (b.isFunction(g.filterTarget) ? !1 !== g.filterTarget.call(f, a.target) : 1) {
                                var c = a.clientX,
                                    d = a.clientY;
                                r = !0;
                                g.velocity = q = 0;
                                g.velocityY = w = 0;
                                p = c;
                                u = d;
                                z = a.target;
                                "IMG" === a.target.nodeName && a.preventDefault();
                                a.stopPropagation()
                            }
                        },
                        inputEnd: function (a) {
                            p && q && !1 === g.decelerate && (g.decelerate = !0, s(), p = q = r = !1, l(h, g));
                            z = null;
                            a.preventDefault && a.preventDefault()
                        },
                        inputMove: function (a) {
                            r && (A(a.clientX, a.clientY), a.preventDefault && a.preventDefault())
                        },
                        scroll: function (a) {
                            "function" === typeof g.moved && g.moved.call(h, g);
                            a.preventDefault && a.preventDefault()
                        },
                        inputClick: function (a) {
                            if (0 < Math.abs(g.velocity)) return a.preventDefault(), !1
                        },
                        dragStart: function (a) {
                            if (z) return !1
                        }
                    };
                    k(h, g);
                    h.data("kinetic-settings", g).css("cursor", g.cursor);
                    g.triggerHardware && h.css({
                        "-webkit-transform": "translate3d(0,0,0)",
                        "-webkit-perspective": "1000",
                        "-webkit-backface-visibility": "hidden"
                    })
                }
            })
        };
    b.kinetic = {
        settingsKey: "kinetic-settings",
        callMethods: {
            start: function (a, c) {
                var d = b(this);
                if (a = b.extend(a, c)) a.decelerate = !1, l(d, a)
            },
            end: function (a, c) {
                b(this);
                a && (a.decelerate = !0)
            },
            stop: function (a,
                c) {
                var d = b(this);
                f(d, a)
            },
            detach: function (a, c) {
                var e = b(this);
                b.support.touch ? e.unbind("touchstart", a.events.touchStart).unbind("touchend", a.events.inputEnd).unbind("touchmove", a.events.touchMove) : e.unbind("mousedown", a.events.inputDown).unbind("mouseup", a.events.inputEnd).unbind("mousemove", a.events.inputMove).unbind("scroll", a.events.scroll);
                e.unbind("click", a.events.inputClick).unbind("selectstart", d);
                e.unbind("dragstart", a.events.dragStart);
                e.removeClass("kinetic-active").css("cursor", "")
            },
            attach: function (a,
                c) {
                var d = b(this);
                k(d, a);
                d.addClass("kinetic-active").css("cursor", "move")
            }
        }
    };
    b.fn.kinetic = function (a) {
        "string" === typeof a ? g.apply(this, arguments) : h.call(this, a);
        return this
    }
})(window.jQuery || window.Zepto);
var Events = function () {
    var b = {};
    return {
        publish: function (e, d, c) {
            if (b[e]) {
                e = b[e];
                for (var a = e.length; a--;) e[a].apply(c || this, d || [])
            }
        },
        subscribe: function (e, d) {
            b[e] || (b[e] = []);
            b[e].push(d);
            return [e, d]
        },
        unsubscribe: function (e, d) {
            var c = e[0],
                a = b[c].length;
            if (b[c])
                for (; a--;) b[c][a] === e[1] && (b[c].splice(b[c][a], 1), d && delete b[c])
        }
    }
}();
window.divaPlugins = [];
(function (b) {
    var e = function (d, c) {
        var a = b.extend({}, {
            adaptivePadding: 0.05,
            blockMobileMove: !0,
            contained: !1,
            objectData: "",
            enableAutoHeight: !1,
            enableAutoTitle: !0,
            enableAutoWidth: !0,
            enableCanvas: !0,
            enableDownload: !0,
            enableFilename: !0,
            enableFullscreen: !0,
            enableGotoPage: !0,
            enableGridIcon: !0,
            enableGridSlider: !0,
            enableKeyScroll: !0,
            enableLinkIcon: !0,
            enableSpaceScroll: !1,
            enableToolbar: !0,
            enableZoomSlider: !0,
            fixedPadding: 10,
            fixedHeightGrid: !0,
            goDirectlyTo: 0,
            iipServerURL: "",
            digiId: "",
            inFullscreen: !1,
            inGrid: !1,
            imageDir: "",
            maxPagesPerRow: 8,
            maxZoomLevel: -1,
            minPagesPerRow: 2,
            minZoomLevel: 0,
            onDocumentLoaded: null,
            onModeToggle: null,
            onViewToggle: null,
            onJump: null,
            onPageLoad: null,
            onPageLoaded: null,
            onReady: null,
            onScroll: null,
            onScrollDown: null,
            onScrollUp: null,
            onSetCurrentPage: null,
            onZoom: null,
            onZoomIn: null,
            onZoomOut: null,
            pageLoadTimeout: 200,
            pagesPerRow: 5,
            rowLoadTimeout: 50,
            throbberTimeout: 100,
            tileHeight: 256,
            tileWidth: 256,
            toolbarParentSelector: null,
            viewerHeightPadding: 15,
            viewerWidthPadding: 30,
            viewportMargin: 200,
            zoomLevel: 2
        }, c);
        b.extend(a, {
            allTilesLoaded: [],
            averageHeights: [],
            averageWidths: [],
            currentPageIndex: 0,
            dimAfterZoom: 0,
            firstPageLoaded: -1,
            firstRowLoaded: -1,
            gridPageWidth: 0,
            hashParamSuffix: "",
            heightAbovePages: [],
            horizontalOffset: 0,
            horizontalPadding: 0,
            ID: null,
            innerSelector: "",
            itemTitle: "",
            lastPageLoaded: -1,
            lastRowLoaded: -1,
            leftScrollSoFar: 0,
            loaded: !1,
            maxWidths: [],
            maxRatio: 0,
            minHeight: 0,
            minRatio: 0,
            minWidth: 0,
            mobileWebkit: !1,
            numPages: 0,
            numRows: 0,
            oldPagesPerRow: 0,
            oldZoomLevel: -1,
            orientationChange: !1,
            originalHeight: 0,
            originalWidth: 0,
            outerSelector: "",
            pages: [],
            pageLeftOffsets: [],
            pageTimeouts: [],
            pageTools: "",
            panelHeight: 0,
            panelWidth: 0,
            plugins: [],
            previousTopScroll: 0,
            preZoomOffset: null,
            realMaxZoom: -1,
            resizeTimer: -1,
            rowHeight: 0,
            scaleWait: !1,
            selector: "",
            singleClick: !1,
            scrollbarWidth: 0,
            throbberTimeoutID: -1,
            toolbar: null,
            topScrollSoFar: 0,
            totalHeights: [],
            totalHeight: 0,
            verticalOffset: 0,
            verticalPadding: 0,
            viewerXOffset: 0,
            viewerYOffset: 0
        });
        var e = this,
            l = function (a) {
                var b, c, d;
                if ("function" === typeof a) {
                    b = [];
                    c = 1;
                    for (d = arguments.length; c < d; c++) b.push(arguments[c]);
                    a.apply(e, b);
                    return !0
                }
                return !1
            }, g = function (b, c) {
                return a.pages[b].d[a.zoomLevel][c]
            }, k = function (b) {
                var c, d = a.numPages;
                for (c = 0; c < d; c++)
                    if (a.pages[c].f === b) return c;
                return -1
            }, h = function (b, c) {
                var d = a.topScrollSoFar - a.viewportMargin,
                    e = d + a.panelHeight + 2 * a.viewportMargin;
                return b >= d && b <= e || b <= d && c >= e || c >= d && c <= e
            }, m = function (b) {
                return 0 <= b && b < a.numPages
            }, n = function (b) {
                var c = a.heightAbovePages[b];
                b = c + g(b, "h") + a.verticalPadding;
                return h(c, b)
            }, t = function (c) {
                if (!(0 < b(document.getElementById(a.ID + "page-" + c)).length &&
                    a.allTilesLoaded[c])) {
                    var d = a.pages[c].f,
                        e = g(c, "w"),
                        f = g(c, "h"),
                        k = a.heightAbovePages[c] + a.verticalPadding,
                        s = a.selector + "page-" + c,
                        m;
                    if (!(0 < b(document.getElementById(a.ID + "page-" + c)).length))
                        for (m in b(document.getElementById(a.ID + "inner")).append('<div id="' + a.ID + "page-" + c + '" style="top: ' + k + "px; width: " + e + "px; height: " + f + 'px;" class="diva-document-page" title="Page ' + (c + 1) + '" data-index="' + c + '" data-filename="' + d + '">' + a.pageTools + "</div>"), l(a.onPageLoad, c, d, s), Events.publish("PageHasLoaded", [c,
                            d, s
                        ]), a.plugins) l(a.plugins[m].onPageLoad, c, d, s);
                    a.pageTimeouts.push(setTimeout(function () {
                        if (n(c)) {
                            var k = a.imageDir + "/",
                                m = g(c, "r"),
                                O = g(c, "c"),
                                A = [],
                                F = !0,
                                J = 0,
                                G = f - (m - 1) * a.tileHeight,
                                B = e - (O - 1) * a.tileWidth,
                                H, R, p, E, u, t;
                            baseImageURL = a.iipServerURL + "?FIF=" + k + d + "&JTL=" + (a.zoomLevel + a.pages[c].m - a.realMaxZoom) + ",";
                            for (k = 0; k < m;) {
                                for (H = 0; H < O;) {
                                    E = k * a.tileHeight;
                                    u = H * a.tileWidth;
                                    R = k === m - 1 ? G : a.tileHeight;
                                    p = H === O - 1 ? B : a.tileWidth;
                                    t = baseImageURL + J;
                                    if (!1 !== document.getElementById(a.ID + "tile-" + c + "-" + J)) {
                                        var y = a.heightAbovePages[c] +
                                            k * a.tileHeight + a.verticalPadding,
                                            q = a.pageLeftOffsets[c] + H * a.tileWidth,
                                            r = q + a.tileWidth;
                                        if (y = h(y, y + a.tileHeight)) var y = a.leftScrollSoFar - a.viewportMargin,
                                        w = y + a.panelWidth + 2 * a.viewportMargin, z = r >= y && r <= w, r = q <= y && r >= w, y = q >= y && q <= w || r || z;
                                        y ? A.push('<div id="' + a.ID + "tile-" + c + "-" + J + '" style="display:inline; position: absolute; top: ' + E + "px; left: " + u + "px; background-image: url('" + t + "'); height: " + R + "px; width: " + p + 'px;"></div>') : F = !1
                                    }
                                    J++;
                                    H++
                                }
                                k++
                            }
                            a.allTilesLoaded[c] = F;
                            b(document.getElementById(a.ID + "page-" +
                                c)).append(A.join(""));
                            l(a.onPageLoaded, c, d, s)
                        }
                    }, a.pageLoadTimeout))
                }
            }, v = function (c) {
                b(document.getElementById(a.ID + "page-" + c)).empty().remove()
            }, p = function (b, c) {
                0 < c ? m(b) && (n(b) ? (t(b), a.lastPageLoaded = b, p(a.lastPageLoaded + 1, c)) : a.heightAbovePages[b] + g(b, "h") + a.verticalPadding < a.topScrollSoFar && p(b + 1, c)) : m(b) && (n(b) ? (t(b), a.firstPageLoaded = b, p(a.firstPageLoaded - 1, c)) : a.heightAbovePages[b] > a.topScrollSoFar + a.panelHeight && p(b - 1, c))
            }, q = function (b, c) {
                0 < c ? m(b) && a.heightAbovePages[b] + g(b, "h") + a.verticalPadding <
                    a.topScrollSoFar && (v(b), a.firstPageLoaded = b + 1, q(a.firstPageLoaded, c)) : m(b) && a.heightAbovePages[b] > a.topScrollSoFar + a.panelHeight && (v(b), a.lastPageLoaded = b - 1, q(a.lastPageLoaded, c))
            }, u = function (b) {
                return 0 <= b && b < a.numRows
            }, w = function (b) {
                b *= a.rowHeight;
                return h(b, b + a.rowHeight + a.fixedPadding)
            }, r = function (c) {
                if (!(0 < b(a.selector + "row-" + c).length)) {
                    var d = [];
                    d.push('<div class="diva-row" id="' + a.ID + "row-" + c + '" style="height: ' + a.rowHeight + "; top: " + (a.rowHeight * c + a.fixedPadding) + 'px;">');
                    var e, f, k, s, h, l,
                        A = a.imageDir + "/",
                        F = a.pagesPerRow;
                    for (e = 0; e < F; e++) {
                        f = c * a.pagesPerRow + e;
                        if (!m(f)) break;
                        k = a.pages[f].f;
                        s = g(f, "w");
                        h = g(f, "h");
                        l = a.fixedHeightGrid ? (a.rowHeight - a.fixedPadding) * s / h : a.gridPageWidth;
                        s = a.fixedHeightGrid ? a.rowHeight - a.fixedPadding : l / s * h;
                        h = parseInt(e * (a.fixedPadding + a.gridPageWidth) + a.fixedPadding, 10);
                        l = parseInt(l, 10);
                        s = parseInt(s, 10);
                        h += a.fixedHeightGrid ? (a.gridPageWidth - l) / 2 : 0;
                        k = a.iipServerURL + "?FIF=" + A + k + "&amp;HEI=" + (s + 2) + "&amp;CVT=JPEG";
                        d.push('<div id="' + a.ID + "page-" + f + '" class="diva-page" style="width: ' +
                            l + "px; height: " + s + "px; left: " + h + 'px;" title="Page ' + (f + 1) + '"></div>');
                        K(c, f, k, l, s)
                    }
                    d.push("</div>");
                    b(document.getElementById(a.ID + "inner")).append(d.join(""))
                }
            }, I = function (c) {
                b(document.getElementById(a.ID + "row-" + c)).empty().remove()
            }, x = function (b, c) {
                0 < c ? u(b) && (w(b) ? (r(b), a.lastRowLoaded = b, x(a.lastRowLoaded + 1, c)) : a.rowHeight * (b + 1) < a.topScrollSoFar && x(b + 1, c)) : u(b) && (w(b) ? (r(b), a.firstRowLoaded = b, x(a.firstRowLoaded - 1, c)) : a.rowHeight * b > a.topScrollSoFar + a.panelHeight && x(b - 1, c))
            }, z = function (b, c) {
                0 <
                    c ? u(b) && a.rowHeight * (b + 1) < a.topScrollSoFar && (I(b), a.firstRowLoaded++, z(a.firstRowLoaded, c)) : u(b) && a.rowHeight * b > a.topScrollSoFar + a.panelHeight && (I(b), a.lastRowLoaded--, z(a.lastRowLoaded, c))
            }, K = function (c, d, e, f, g) {
                a.pageTimeouts.push(setTimeout(function () {
                    w(c) && b(a.selector + "page-" + d).html('<img src="' + e + '" style="width: ' + f + "px; height: " + g + 'px;" />')
                }, a.rowLoadTimeout))
            }, s = function (b) {
                var c = a.topScrollSoFar + a.panelHeight / 2,
                    d = a.currentPageIndex,
                    e = a.currentPageIndex + b,
                    f = !1;
                0 > b ? 0 <= e && a.heightAbovePages[e] +
                    g(e, "h") + a.verticalPadding >= c && (f = !0) : 0 < b && a.heightAbovePages[d] + g(d, "h") + a.verticalPadding < c && (f = !0);
                return f ? (a.currentPageIndex = e, 0 === b || s(b) || (b = a.pages[e].f, l(a.onSetCurrentPage, e, b), Events.publish("VisiblePageDidChange", [e, b])), !0) : !1
            }, A = function (b) {
                var c = Math.floor(a.currentPageIndex / a.pagesPerRow),
                    d = c + parseInt(b, 10),
                    e = a.topScrollSoFar + a.panelHeight / 2,
                    f = !1;
                0 > b ? 0 <= d && (a.rowHeight * c >= e || a.rowHeight * d >= a.topScrollSoFar) && (f = !0) : 0 < b && a.rowHeight * (c + 1) < a.topScrollSoFar && u(d) && (f = !0);
                return f ? (a.currentPageIndex =
                    d * a.pagesPerRow, 0 === b || A(b) || (b = a.currentPageIndex, Events.publish("VisiblePageDidChange", [b, a.pages[b].f])), !0) : !1
            }, F = function (c, d, e) {
                d = a.heightAbovePages[c] + ("undefined" !== typeof d ? d : 0);
                e = (a.maxWidths[a.zoomLevel] - a.panelWidth) / 2 + a.horizontalPadding + ("undefined" !== typeof e ? e : 0);
                b(a.outerSelector).scrollTop(d);
                b(a.outerSelector).scrollLeft(e);
                a.currentPageIndex = c;
                e = a.pages[c].f;
                Events.publish("VisiblePageDidChange", [c, e]);
                l(a.onSetCurrentPage, c, e);
                l(a.onJump, c)
            }, J = function (c) {
                var d = Math.floor(c / a.pagesPerRow) *
                    a.rowHeight;
                b(a.outerSelector).scrollTop(d);
                a.currentPageIndex = c;
                Events.publish("VisiblePageDidChange", [c, a.pages[c].f])
            }, H = function () {
                a.allTilesLoaded = [];
                b(a.outerSelector).scrollTop(0);
                a.topScrollSoFar = 0;
                b(a.innerSelector).empty();
                a.firstPageLoaded = 0;
                a.firstRowLoaded = -1;
                a.previousTopScroll = 0;
                for (clearTimeout(a.resizeTimer); a.pageTimeouts.length;) clearTimeout(a.pageTimeouts.pop())
            }, B = function () {
                a.inGrid ? S() : y()
            }, y = function () {
                H();
                a.zoomLevel = a.zoomLevel >= a.minZoomLevel && a.zoomLevel <= a.maxZoomLevel ?
                    a.zoomLevel : a.minZoomLevel;
                var c = a.zoomLevel;
                0 < a.adaptivePadding ? (a.horizontalPadding = a.averageWidths[c] * a.adaptivePadding, a.verticalPadding = a.averageHeights[c] * a.adaptivePadding) : (a.horizontalPadding = a.fixedPadding, a.verticalPadding = a.fixedPadding);
                a.pageTools.length && (a.verticalPadding = Math.max(40, a.horizontalPadding));
                a.totalHeight = a.totalHeights[c] + a.verticalPadding * (a.numPages + 1);
                a.dimAfterZoom = a.totalHeight;
                var d = Math.max(a.maxWidths[c] + 2 * a.horizontalPadding, a.panelWidth),
                    e = 0,
                    f;
                for (f = 0; f < a.numPages; f++) a.heightAbovePages[f] =
                    e, e = a.heightAbovePages[f] + g(f, "h") + a.verticalPadding, a.pageLeftOffsets[f] = (d - g(f, "w")) / 2, n(f) && (t(f), a.lastPageLoaded = f);
                0 <= a.oldZoomLevel && (a.oldZoomLevel < a.zoomLevel ? l(a.onZoomIn, c) : l(a.onZoomOut, c), l(a.onZoom, c));
                b(a.innerSelector).height(Math.round(a.totalHeight));
                b(a.innerSelector).width(Math.round(d));
                a.preZoomOffset ? (d = a.preZoomOffset.i, c = a.heightAbovePages[d] + a.verticalPadding, e = a.pageLeftOffsets[d], d = Math.pow(2, a.zoomLevel - a.oldZoomLevel), e = a.preZoomOffset.x * d - (a.preZoomOffset.originalX -
                    a.viewerXOffset) + e, c = a.preZoomOffset.y * d - (a.preZoomOffset.originalY - a.viewerYOffset) + c, b(a.outerSelector).scrollTop(c).scrollLeft(e), a.preZoomOffset = void 0) : (m(a.goDirectlyTo) || (a.goDirectlyTo = 0), F(a.goDirectlyTo, a.verticalOffset, a.horizontalOffset), a.horizontalOffset = 0, a.verticalOffset = 0);
                a.scaleWait && (a.scaleWait = !1);
                c = a.pages[a.currentPageIndex].f;
                l(a.onDocumentLoaded, a.lastPageLoaded, c);
                Events.publish("DocumentHasFinishedLoading", [a.lastPageLoaded, c])
            }, S = function () {
                H();
                a.pagesPerRow = a.pagesPerRow >=
                    a.minPagesPerRow && a.pagesPerRow <= a.maxPagesPerRow ? a.pagesPerRow : a.maxPagesPerRow;
                var c = (a.panelWidth - a.fixedPadding * (a.pagesPerRow + 1)) / a.pagesPerRow;
                a.gridPageWidth = c;
                a.rowHeight = a.fixedHeightGrid ? a.fixedPadding + a.minRatio * c : a.fixedPadding + a.maxRatio * c;
                a.numRows = Math.ceil(a.numPages / a.pagesPerRow);
                a.totalHeight = a.numRows * a.rowHeight + a.fixedPadding;
                b(a.innerSelector).height(Math.round(a.totalHeight));
                b(a.innerSelector).width(Math.round(a.panelWidth));
                J(a.goDirectlyTo);
                for (var d, e = a.numPages, c = 0; c <
                    e; c += a.pagesPerRow) d = Math.floor(c / a.pagesPerRow), w(d) && (a.firstRowLoaded = 0 > a.firstRowLoaded ? d : a.firstRowLoaded, r(d), a.lastRowLoaded = d)
            }, G = function (c) {
                if (0 <= a.oldZoomLevel && !a.inGrid) {
                    var d = b(a.selector + "page-" + a.currentPageIndex).offset(),
                        e = -(d.top - a.verticalPadding - a.viewerYOffset),
                        f = (a.panelWidth - g(a.currentPageIndex, "w")) / 2,
                        d = -(d.left - a.viewerXOffset - f);
                    a.verticalOffset = e;
                    a.horizontalOffset = d
                }
                Events.publish("ModeDidSwitch", null);
                b(a.selector + "fullscreen").toggleClass("diva-in-fullscreen");
                b(a.outerSelector).toggleClass("diva-fullscreen");
                b("body").toggleClass("diva-hide-scrollbar");
                b(a.parentSelector).toggleClass("diva-full-width");
                a.panelHeight = b(a.outerSelector).height();
                a.panelWidth = b(a.outerSelector).width() - a.scrollbarWidth;
                b(a.innerSelector).width(a.panelWidth);
                a.viewerXOffset = b(a.outerSelector).offset().left;
                a.viewerYOffset = b(a.outerSelector).offset().top;
                c ? (a.inGrid = !a.inGrid, E()) : B();
                l(a.onModeToggle, a.inFullscreen);
                Events.publish("ModeHasChanged", [a.inFullScreen])
            }, E = function () {
                B();
                l(a.onViewToggle, a.inGrid);
                Events.publish("ViewDidSwitch", [a.inGrid])
            }, N = function () {
                a.goDirectlyTo = a.currentPageIndex;
                a.inFullscreen = !a.inFullscreen;
                G(!1)
            }, L = function () {
                a.goDirectlyTo = a.currentPageIndex;
                a.inGrid = !a.inGrid;
                E()
            }, T = function (c) {
                var d = b(this).offset();
                a.preZoomOffset = {
                    x: c.pageX - d.left,
                    y: c.pageY - d.top,
                    originalX: c.pageX,
                    originalY: c.pageY,
                    i: b(this).attr("data-index")
                };
                M(c.ctrlKey ? a.zoomLevel - 1 : a.zoomLevel + 1)
            }, M = function (b) {
                var c = b >= a.minZoomLevel && b <= a.maxZoomLevel ? b : a.minZoomLevel;
                if (c !== b) return !1;
                a.oldZoomLevel = a.zoomLevel;
                a.zoomLevel = c;
                Events.publish("ZoomLevelDidChange",
                    null);
                y();
                return !0
            }, U = function (b) {
                var c = b >= a.minPagesPerRow && b <= a.maxPagesPerRow ? b : a.maxPagesPerRow;
                if (c !== b) return !1;
                a.oldPagesPerRow = a.zoomLevel;
                a.pagesPerRow = c;
                Events.publish("GridRowNumberDidChange", null);
                S()
            }, V = function () {
                var c = a.inFullscreen,
                    d = a.inGrid,
                    e = a.zoomLevel,
                    f = a.pagesPerRow,
                    g = a.enableFilename ? a.pages[a.currentPageIndex].f : !1,
                    k = a.enableFilename ? !1 : a.currentPageIndex + 1,
                    s;
                a.inGrid ? s = !1 : (s = document.getElementById(a.ID + "outer").scrollTop, s = parseInt(s - a.heightAbovePages[a.currentPageIndex],
                    10));
                var h;
                a.inGrid ? h = !1 : (h = (a.maxWidths[a.zoomLevel] + 2 * a.horizontalPadding - a.panelWidth) / 2, h = document.getElementById(a.ID + "outer").scrollLeft - h, h = parseInt(h, 10));
                return {
                    f: c,
                    g: d,
                    z: e,
                    n: f,
                    i: g,
                    p: k,
                    y: s,
                    x: h,
                    h: a.inFullscreen ? !1 : a.panelHeight,
                    w: a.inFullscreen ? !1 : b(a.outerSelector).width()
                }
            }, W = function () {
                var b = V(),
                    c = [],
                    d;
                for (d in b)!1 !== b[d] && c.push(d + a.hashParamSuffix + "=" + b[d]);
                return c.join("&")
            }, X = function () {
                return location.protocol + "//" + location.host + location.pathname + "?digiId=" + c.digiId + "#" + W()
            }, C = function () {
                var c = b(a.outerSelector).offset().top;
                a.panelHeight = window.innerHeight - c - a.viewerHeightPadding;
                a.panelWidth = window.innerWidth - a.viewerWidthPadding;
                a.parentSelector.style.width = a.panelWidth + "px";
                a.enableAutoHeight && (document.getElementById(a.ID + "outer").style.height = a.panelHeight + "px");
                a.enableAutoWidth && (document.getElementById(a.ID + "outer").style.width = a.panelWidth + "px")
            }, D = function () {
                var c = b(a.outerSelector).height(),
                    d = b(a.parentSelector).width() - a.scrollbarWidth,
                    e = b(a.outerSelector).offset().top,
                    f = (window.innerWidth || document.documentElement.clientWidth) -
                        a.viewerWidthPadding - a.scrollbarWidth - 2,
                    g = (window.innerHeight || document.documentElement.clientHeight) - e - a.viewerHeightPadding - 1;
                a.enableAutoHeight && (c + e + 16 > window.innerHeight ? c = g : c <= a.originalHeight && (c = Math.min(g, a.originalHeight)));
                a.enableAutoWidth && (d + 32 > window.innerWidth ? d = f : d <= a.originalWidth && (d = Math.min(f, a.originalWidth)), a.parentSelector[0].style.width = d + a.scrollbarWidth);
                return d !== a.panelWidth || c !== a.panelHeight ? (e = document.getElementById(a.ID + "outer"), e.style.height = c + "px", e.style.width =
                    d + a.scrollbarWidth + "px", a.panelWidth = d, a.panelHeight = c, !0) : !1
            }, P = function (c, d) {
                c >= a.minWidth && (a.originalWidth = c, b(a.outerSelector).width(c), document.getElementById(a.ID + "outer").style.width = c + "px", a.panelWidth = c - a.scrollbarWidth, a.parentSelector[0].style.width = c + "px");
                d >= a.minHeight && (a.originalHeight = d, document.getElementById(a.ID + "outer").style.height = d + "px", a.panelHeight = d)
            }, Z = function () {
                a.enableFullscreen && b(a.selector + "fullscreen").click(function () {
                    N()
                });
                b(a.innerSelector).mouseover(function () {
                    b(this).removeClass("diva-grabbing").addClass("diva-grab")
                });
                b(a.innerSelector).mouseout(function () {
                    b(this).removeClass("diva-grab")
                });
                b(a.innerSelector).mousedown(function () {
                    b(this).removeClass("diva-grab").addClass("diva-grabbing")
                });
                b(a.innerSelector).mouseup(function () {
                    b(this).removeClass("diva-grabbing").addClass("diva-grab")
                });
                b(a.outerSelector + ", " + a.innerSelector).dragscrollable({
                    dragSelector: ".diva-dragger",
                    acceptPropagatedEvent: !0
                });
                b(a.outerSelector).scroll(function () {
                    a.topScrollSoFar = document.getElementById(a.ID + "outer").scrollTop;
                    var c = a.topScrollSoFar -
                        a.previousTopScroll;
                    if (a.inGrid) 0 > c ? (x(a.firstRowLoaded, -1), A(-1), z(a.lastRowLoaded, -1)) : 0 < c && (x(a.lastRowLoaded, 1), A(1), z(a.firstRowLoaded, 1)), l(a.onScroll, a.topScrollSoFar), 0 < c ? l(a.onScrollDown, a.topScrollSoFar) : 0 > c && l(a.onScrollUp, a.topScrollSoFar);
                    else {
                        var d;
                        if (0 > c) p(a.firstPageLoaded, c), s(-1), q(a.lastPageLoaded, c);
                        else if (0 < c) p(a.lastPageLoaded, c), s(1), q(a.firstPageLoaded, c);
                        else {
                            var e = a.lastPageLoaded;
                            for (d = Math.max(a.firstPageLoaded, 0); d <= e; d++) n(d) && t(d)
                        }
                        l(a.onScroll, a.topScrollSoFar);
                        0 < c ?
                            l(a.onScrollDown, a.topScrollSoFar) : 0 > c && l(a.onScrollUp, a.topScrollSoFar);
                        a.leftScrollSoFar = b(this).scrollLeft()
                    }
                    a.previousTopScroll = a.topScrollSoFar
                });
                b(a.outerSelector).on("dblclick", ".diva-document-page", function (a) {
                    T.call(this, a)
                });
                b(a.outerSelector).on("contextmenu", ".diva-document-page", function (b) {
                    if (b.ctrlKey) return clearTimeout(a.singleClickTimeout), a.singleClick ? (T.call(this, b), a.singleClick = !1) : (a.singleClick = !0, a.singleClickTimeout = setTimeout(function () {
                        a.singleClick = !1
                    }, 500)), !1
                });
                b(a.outerSelector).on("dblclick",
                    ".diva-row", function (b) {
                        var c = document.getElementById(a.ID + "outer");
                        a.goDirectlyTo = Math.floor((b.pageY - a.viewerYOffset + c.scrollTop) / a.rowHeight) * a.pagesPerRow + Math.floor((b.pageX - a.viewerXOffset + c.scrollLeft) / (a.panelWidth / a.pagesPerRow));
                        a.inGrid = !1;
                        E()
                    });
                if (a.mobileWebkit) {
                    var c = [];
                    c.push('<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1" />');
                    c.push('<meta name="apple-mobile-web-app-capable" content="yes" />');
                    c.push('<meta name="apple-mobile-web-app-status-bar-style" content="black" />');
                    b("head").append(c.join("\n"));
                    a.blockMobileMove && b("body").bind("touchmove", function (a) {
                        a.originalEvent.preventDefault();
                        return !1
                    });
                    b("body").bind("gestureend", function (b) {
                        b = b.originalEvent;
                        if (!a.scaleWait)
                            if (a.goDirectlyTo = a.currentPageIndex, a.inGrid) a.inGrid = !1, E();
                            else a: {
                                var c = a.zoomLevel;
                                if (1 < b.scale && c < a.maxZoomLevel) c++;
                                else if (1 > b.scale && c > a.minZoomLevel) c--;
                                else break a;
                                a.scaleWait = !0;
                                M(c)
                            }
                            return !1
                    });
                    b(window).bind("orientationchange", function (b) {
                        a.orientationChange = !0;
                        C();
                        a.goDirectlyTo =
                            a.currentPageIndex;
                        B()
                    });
                    b(a.outerSelector).kinetic()
                }
                if (a.enableSpaceScroll || a.enableKeyScroll) {
                    var d = b.ui.keyCode.SPACE,
                        e = b.ui.keyCode.PAGE_UP,
                        f = b.ui.keyCode.PAGE_DOWN,
                        g = b.ui.keyCode.HOME,
                        h = b.ui.keyCode.END;
                    b(document).keydown(function (c) {
                        if (a.enableSpaceScroll && c.keyCode === d || a.enableKeyScroll && c.keyCode === f) return b(a.outerSelector).scrollTop(a.topScrollSoFar + a.panelHeight), !1;
                        if (a.enableKeyScroll && c.keyCode === e) return b(a.outerSelector).scrollTop(a.topScrollSoFar - a.panelHeight), !1;
                        if (a.enableKeyScroll &&
                            c.keyCode === g) return b(a.outerSelector).scrollTop(0), !1;
                        if (a.enableKeyScroll && c.keyCode === h) return b(a.outerSelector).scrollTop(a.totalHeight), !1
                    });
                    a.mobileWebkit || b(window).resize(function () {
                        var b;
                        a.inFullscreen ? (a.panelWidth = window.innerWidth - a.scrollbarWidth, a.panelHeight = window.innerHeight, b = !0) : b = D();
                        b && (clearTimeout(a.resizeTimer), a.resizeTimer = setTimeout(function () {
                            a.goDirectlyTo = a.currentPageIndex;
                            B()
                        }, 200))
                    })
                }
            }, aa = function () {
                var c = a.enableGridIcon ? '<div class="diva-grid-icon' + (a.inGrid ? " diva-in-grid" :
                    "") + '" id="' + a.ID + 'grid-icon" title="Toggle grid view"></div>' : "",
                    d = a.enableLinkIcon ? '<div class="diva-link-icon" id="' + a.ID + 'link-icon" style="' + (a.enableGridIcon ? "border-left: 0px" : "") + '" title="Link to this page"></div>' : "",
                    e = a.enableZoomSlider ? '<div id="' + a.ID + 'zoom-slider"></div>' : "",
                    f = a.enableGridSlider ? '<div id="' + a.ID + 'grid-slider"></div>' : "",
                    g = a.enableGotoPage ? '<form id="' + a.ID + 'goto-page" class="diva-goto-form"><input type="text" id="' + a.ID + 'goto-page-input" / class="diva-input"> <input type="submit" value="Go" style="margin-top: 0px;" /></form>' :
                        "",
                    h = a.enableZoomSlider ? '<div id="' + a.ID + 'zoom-slider-label" class="diva-slider-label">Zoom level: <span id="' + a.ID + 'zoom-level">' + a.zoomLevel + "</span></div>" : "",
                    s = a.enableGridSlider ? '<div id="' + a.ID + 'grid-slider-label" class="diva-slider-label">Pages per row: <span id="' + a.ID + 'pages-per-row">' + a.pagesPerRow + "</span></div>" : "",
                    k = '<div class="diva-page-label">Page <span id="' + a.ID + 'current-page">1</span> of <span id="' + a.ID + 'num-pages">' + a.numPages + "</span></div>",
                    l = "";
                a.contained && ("static" === b(a.parentSelector).css("position") &&
                    b(a.parentSelector).addClass("diva-relative-position"), l = " diva-fullscreen-space", a.enableAutoTitle && b(a.selector + "fullscreen").addClass("diva-contained"));
                c = '<div id="' + a.ID + 'tools-left" class="diva-tools-left' + l + '">' + e + f + h + s + '</div><div id="' + a.ID + 'tools-right" class="diva-tools-right">' + d + c + '<div class="diva-page-nav">' + g + k + "</div></div>";
                a.toolbarParentSelector ? b(a.toolbarParentSelector).prepend('<div id="' + a.ID + 'tools" class="diva-tools">' + c + "</div>") : b(a.parentSelector).prepend('<div id="' +
                    a.ID + 'tools" class="diva-tools">' + c + "</div>");
                b(a.selector + "zoom-slider").slider({
                    value: a.zoomLevel,
                    min: a.minZoomLevel,
                    max: a.maxZoomLevel,
                    step: 1,
                    slide: function (c, d) {
                        var e = a.currentPageIndex;
                        a.goDirectlyTo = e;
                        var f = Math.pow(2, d.value - a.zoomLevel),
                            g = a.maxWidths[a.zoomLevel] + 2 * a.horizontalPadding,
                            h = b(a.outerSelector).scrollLeft() - (g - a.panelWidth) / 2;
                        a.horizontalOffset = g > a.panelWidth ? h * f : 0;
                        a.verticalOffset = f * (b(a.outerSelector).scrollTop() - a.heightAbovePages[e]);
                        M(d.value)
                    },
                    change: function (b, c) {
                        c.value !==
                            a.zoomLevel && M(c.value)
                    }
                });
                b(a.selector + "grid-slider").slider({
                    value: a.pagesPerRow,
                    min: a.minPagesPerRow,
                    max: a.maxPagesPerRow,
                    step: 1,
                    slide: function (a, b) {
                        U(b.value)
                    },
                    change: function (b, c) {
                        c.value !== a.pagesPerRow && U(c.value)
                    }
                });
                b(a.selector + "grid-icon").click(function () {
                    L()
                });
                b(a.selector + "goto-page").submit(function () {
                    var c = parseInt(b(a.selector + "goto-page-input").val(), 10) - 1;
                    m(c) ? a.inGrid ? J(c) : F(c, 0, 0) : alert("Invalid page number");
                    return !1
                });
                b(a.selector + "link-icon").click(function () {
                    b("body").prepend('<div id="' +
                        a.ID + 'link-popup" class="diva-link-popup"><input id="' + a.ID + 'link-popup-input" class="diva-input" type="text" value="' + X() + '"/></div>');
                    if (a.inFullscreen) b(a.selector + "link-popup").addClass("in-fullscreen");
                    else {
                        var c = b(a.outerSelector).offset().left + a.panelWidth,
                            c = c + (a.scrollbarWidth - 240 - 1),
                            d = b(a.outerSelector).offset().top + 1;
                        b(a.selector + "link-popup").removeClass("in-fullscreen").css({
                            top: d + "px",
                            left: c + "px"
                        })
                    }
                    b("body").mouseup(function (c) {
                        c = c.target.id;
                        c !== a.ID + "link-popup" && c !== a.ID + "link-popup-input" &&
                            b(a.selector + "link-popup").remove()
                    });
                    b(a.outerSelector).scroll(function () {
                        b(a.selector + "link-popup").remove()
                    });
                    b(a.selector + "link-popup input").click(function () {
                        b(this).focus().select()
                    });
                    return !1
                });
                var A = a.inGrid ? "grid" : "zoom";
                b(a.selector + A + "-slider").show();
                b(a.selector + A + "-slider-label").show();
                return {
                    updateCurrentPage: function () {
                        b(a.selector + "current-page").text(a.currentPageIndex + 1)
                    },
                    setNumPages: function (c) {
                        b(a.selector + "num-pages").text(c)
                    },
                    updateZoomSlider: function () {
                        a.zoomLevel !== b(a.selector +
                            "zoom-slider").slider("value") && b(a.selector + "zoom-slider").slider({
                            value: a.zoomLevel
                        });
                        b(a.selector + "zoom-level").text(a.zoomLevel)
                    },
                    updateGridSlider: function () {
                        a.pagesPerRow !== b(a.selector + "grid-slider").slider("value") && b(a.selector + "grid-slider").slider({
                            value: a.pagesPerRow
                        });
                        b(a.selector + "pages-per-row").text(a.pagesPerRow)
                    },
                    switchView: function () {
                        b(a.selector + A + "-slider").hide();
                        b(a.selector + A + "-slider-label").hide();
                        A = a.inGrid ? "grid" : "zoom";
                        b(a.selector + A + "-slider").show();
                        b(a.selector + A + "-slider-label").show();
                        b(a.selector + "grid-icon").toggleClass("diva-in-grid")
                    },
                    switchMode: function () {
                        b(a.selector + "tools").toggleClass("diva-fullscreen-tools");
                        a.inFullscreen ? (b(a.selector + "tools-right").after(b(a.selector + "tools-left")), b(a.selector + "tools-left").addClass("in-fullscreen")) : (b(a.selector + "tools-left").after(b(a.selector + "tools-right")), b(a.selector + "tools-left").removeClass("in-fullscreen"))
                    }
                }
            }, ba = function () {
                if (window.divaPlugins) {
                    var c = [];
                    b.each(window.divaPlugins, function (d, g) {
                        var h = g.pluginName[0].toUpperCase() +
                            g.pluginName.substring(1);
                        a["enable" + h] && g.init(a, e) && (h = g.titleText || h + " plugin", "function" === typeof g.handleClick && (c.push('<div class="diva-' + g.pluginName + '-icon" title="' + h + '"></div>'), b(a.outerSelector).delegate(".diva-" + g.pluginName + "-icon", "click", function (b) {
                            g.handleClick.call(this, b, a)
                        })), a.plugins.push(g))
                    });
                    c.length && (a.pageTools = '<div class="diva-page-tools">' + c.join("") + "</div>")
                }
            }, Y = function () {
                clearTimeout(a.throbberTimeoutID);
                b(a.selector + "throbber").hide()
            }, ca = function () {
                var c = '<div id="' +
                    a.ID + 'throbber" class="diva-throbber"></div>';
                b(a.outerSelector).append(c);
                a.throbberTimeoutID = setTimeout(function () {
                    b(a.selector + "throbber").show()
                }, a.throbberTimeout);
                b.ajax({
                    url: a.objectData,
                    cache: !0,
                    dataType: "json",
                    error: function (c, d, e) {
                        Y();
                        b(a.outerSelector).text("Invalid URL. Error code: " + d + " " + e)
                    },
                    success: function (c, d, e) {
                        Y();
                        a.pages = c.pgs;
                        a.maxRatio = c.dims.max_ratio;
                        a.minRatio = c.dims.min_ratio;
                        a.itemTitle = c.item_title;
                        a.numPages = c.pgs.length;
                        a.maxWidths = c.dims.max_w;
                        a.averageWidths = c.dims.a_wid;
                        a.averageHeights = c.dims.a_hei;
                        a.totalHeights = c.dims.t_hei;
                        a.realMaxZoom = c.max_zoom;
                        a.maxZoomLevel = 0 <= a.maxZoomLevel && a.maxZoomLevel <= c.max_zoom ? a.maxZoomLevel : c.max_zoom;
                        a.minZoomLevel = 0 <= a.minZoomLevel && a.minZoomLevel <= a.maxZoomLevel ? a.minZoomLevel : 0;
                        a.minPagesPerRow = Math.max(2, a.minPagesPerRow);
                        a.maxPagesPerRow = Math.max(a.minPagesPerRow, a.maxPagesPerRow);
                        a.enableFilename ? (c = b.getHashParam("i" + a.hashParamSuffix), c = k(c)) : c = parseInt(b.getHashParam("p" + a.hashParamSuffix), 10) - 1;
                        m(c) && (a.goDirectlyTo =
                            c);
                        b.each(a.plugins, function (b, c) {
                            l(c.setupHook, a)
                        });
                        a.enableToolbar && (a.toolbar = aa(), Events.subscribe("VisiblePageDidChange", a.toolbar.updateCurrentPage), Events.subscribe("ModeDidSwitch", a.toolbar.switchMode), Events.subscribe("ViewDidSwitch", a.toolbar.switchView), Events.subscribe("ZoomLevelDidChange", a.toolbar.updateZoomSlider), Events.subscribe("GridRowNumberDidChange", a.toolbar.updateGridSlider));
                        b(a.selector + "current label").text(a.numPages);
                        a.enableAutoTitle && b(a.parentSelector).prepend('<div id="' +
                            a.ID + 'title" class="diva-title">' + a.itemTitle + "</div>");
                        a.mobileWebkit ? C() : (a.originalWidth = b(a.parentSelector).width() - a.scrollbarWidth, a.originalHeight = b(a.outerSelector).height(), D());
                        c = b(a.outerSelector).offset();
                        a.viewerXOffset = c.left;
                        a.viewerYOffset = c.top;
                        a.inFullscreen ? G(!1) : B();
                        l(a.onReady, a);
                        Events.publish("ViewerHasFinishedLoading", [a]);
                        a.loaded = !0
                    }
                })
            }, Q = function () {
                return a.loaded ? !0 : (console.warn("The viewer is not completely initialized. This is likely because it is still downloading data. To fix this, only call this function if the isReady() method returns true."), !1)
            };
        (function () {
            a.scrollbarWidth = b.getScrollbarWidth();
            a.mobileWebkit = void 0 !== window.orientation;
            a.ID = b.generateId("diva-");
            a.selector = "#" + a.ID;
            var c = parseInt(a.ID, 10);
            1 < c && (a.hashParamSuffix = c);
            a.outerSelector = a.selector + "outer";
            a.innerSelector = a.selector + "inner";
            b(a.parentSelector).append('<div id="' + a.ID + 'outer" class="diva-outer"></div>');
            b(a.outerSelector).append('<div id="' + a.ID + 'inner" class="diva-inner diva-dragger"></div>');
            a.enableFullscreen && b(a.parentSelector).prepend('<div id="' + a.ID +
                'fullscreen" class="diva-fullscreen-icon" title="Toggle fullscreen mode"></div>');
            c = parseInt(b.getHashParam("n" + a.hashParamSuffix), 10);
            c >= a.minPagesPerRow && c <= a.maxPagesPerRow && (a.pagesPerRow = c);
            c = b.getHashParam("z" + a.hashParamSuffix);
            "" !== c && (c = parseInt(c, 10), c >= a.minZoomLevel && (a.zoomLevel = c));
            c = parseInt(b.getHashParam("y" + a.hashParamSuffix), 10);
            isNaN(c) || (a.verticalOffset = c);
            c = parseInt(b.getHashParam("x" + a.hashParamSuffix), 10);
            isNaN(c) || (a.horizontalOffset = c);
            var c = b.getHashParam("g" + a.hashParamSuffix),
                d = "true" === c,
                e = b.getHashParam("f" + a.hashParamSuffix);
            a.inGrid = a.inGrid && "false" !== c || d;
            a.inFullscreen = a.inFullscreen && "false" !== e || "true" === e;
            c = parseInt(b.getHashParam("h" + a.hashParamSuffix), 10);
            d = parseInt(b.getHashParam("w" + a.hashParamSuffix), 10);
            a.minHeight = parseInt(b(a.outerSelector).css("min-height"), 10);
            a.minWidth = parseInt(b(a.outerSelector).css("min-width"), 10);
            (0 < c || 0 < d) && P(d, c);
            ca();
            ba();
            Z()
        })();
        this.getItemTitle = function () {
            return a.itemTitle
        };
        this.gotoPageByNumber = function (a) {
            a -= 1;
            return m(a) ?
                (F(a, 0, 0), !0) : !1
        };
        this.gotoPageByIndex = function (a) {
            return m(a) ? (F(a, 0, 0), !0) : !1
        };
        this.getCurrentPage = function () {
            console.warn("Deprecated. Use getCurrentPageIndex instead.");
            return a.currentPageIndex
        };
        this.getNumberOfPages = function () {
            return Q() ? a.numPages : !1
        };
        this.getPageDimensionsAtZoomLevel = function (b, c) {
            if (!Q()) return !1;
            var d = a.pages[b].d[parseInt(c - 1, 10)];
            return {
                width: d.w,
                height: d.h
            }
        };
        this.getCurrentPageDimensionsAtCurrentZoomLevel = function () {
            return this.getPageDimensionsAtZoomLevel(a.currentPageIndex,
                a.zoomLevel)
        };
        this.isReady = function () {
            return a.loaded
        };
        this.getCurrentPageIndex = function () {
            return a.currentPageIndex
        };
        this.getCurrentPageFilename = function () {
            return a.pages[a.currentPageIndex].f
        };
        this.getCurrentPageNumber = function () {
            return a.currentPageIndex + 1
        };
        this.getZoomLevel = function () {
            return a.zoomLevel
        };
        this.getMaxZoomLevel = function () {
            return a.maxZoomLevel
        };
        this.getMaxZoomLevelForPage = function (b) {
            return Q ? a.pages[b].m : !1
        };
        this.getMinZoomLevel = function () {
            return a.minZoomLevel
        };
        this.setZoomLevel =
            function (b) {
                a.inGrid && L();
                return M(b)
        };
        this.zoomIn = function () {
            return this.setZoomLevel(a.zoomLevel + 1)
        };
        this.zoomOut = function () {
            return this.setZoomLevel(a.zoomLevel - 1)
        };
        this.inViewport = function (b, c, d) {
            b = a.heightAbovePages[b - 1] + c;
            return h(b, b + d)
        };
        this.toggleFullscreenMode = function () {
            N()
        };
        this.enterFullscreenMode = function () {
            return a.inFullscreen ? !1 : (N(), !0)
        };
        this.leaveFullscreenMode = function () {
            return a.inFullscreen ? (N(), !0) : !1
        };
        this.toggleGridView = function () {
            L()
        };
        this.enterGridView = function () {
            return a.inGrid ? !1 : (L(), !0)
        };
        this.leaveGridView = function () {
            return a.inGrid ? (L(), !0) : !1
        };
        this.gotoPageByName = function (a) {
            a = k(a);
            return m(a) ? (F(a, 0, 0), !0) : !1
        };
        this.getPageIndex = function (a) {
            return k(a)
        };
        this.getCurrentURL = function () {
            return X()
        };
        this.getURLHash = function () {
            return W()
        };
        this.getState = function () {
            return V()
        };
        this.getInstanceSelector = function () {
            return a.selector
        };
        this.getInstanceId = function () {
            return a.ID
        };
        this.getSettings = function () {
            return a
        };
        this.setState = function (b) {
            var c;
            P(b.w, b.h);
            c = k(b.i);
            m(c) ? a.goDirectlyTo =
                c : m(b.p) && (a.goDirectlyTo = b.p);
            a.horizontalOffset = parseInt(b.x, 10);
            a.verticalOffset = parseInt(b.y, 10);
            b.z >= a.minZoomLevel && b.z <= a.maxZoomLevel && (a.zoomLevel = b.z);
            b.n >= a.minPagesPerRow && b.n <= a.maxPagesPerRow && (a.pagesPerRow = b.n);
            a.inFullscreen !== b.f ? (a.inFullscreen = b.f, G(a.inGrid !== b.g)) : a.inGrid !== b.g ? (a.inGrid = b.g, E()) : B()
        };
        this.resize = function (a, b) {
            P(a, b);
            B()
        };
        this.destroy = function () {
            b("body").removeClass("diva-hide-scrollbar");
            b(a.parentSelector).empty().removeData("diva");
            b.each(a.plugins, function (a,
                b) {
                l(b.destroy)
            });
            b(a.parentSelector).removeAttr("style").removeAttr("class")
        }
    };
    b.fn.diva = function (d) {
        return this.each(function () {
            var c = b(this);
            if (!c.data("diva")) {
                d.parentSelector = c;
                var a = new e(this, d);
                c.data("diva", a)
            }
        })
    }
})(jQuery);
(function (b) {
    window.divaPlugins.push(function () {
        var e = {}, d = {}, c = {}, a, f, l, g = {
                brightnessMax: 150,
                brightnessMin: -100,
                brightnessStep: 1,
                contrastMax: 3,
                contrastMin: -1,
                contrastStep: 0.05,
                localStoragePrefix: "canvas-",
                mobileWebkitMaxZoom: 2,
                onInit: null,
                rgbMax: 50,
                rgbMin: -50,
                throbberFadeSpeed: 200,
                throbberTimeout: 100,
                buttons: ["contrast", "brightness", "rotation", "zoom"]
            }, k = function (b, c) {
                var d = b.context,
                    e = b.size / 2,
                    f = -(b.width / 2),
                    g = -(b.height / 2);
                d.clearRect(0, 0, b.size, b.size);
                d.save();
                d.translate(e, e);
                d.rotate(c * Math.PI /
                    180);
                d.drawImage(a, f, g, b.width, b.height);
                d.restore();
                b.data = d.getImageData(0, 0, b.size, b.size)
            }, h = function () {
                for (var a in f)
                    if (f[a].current !== f[a].previous) return !0;
                return !1
            }, m = function () {
                k(d, f.rotation.current);
                v(d)
            }, n = function () {
                var a = f.rotation.current,
                    d = f.zoom.current,
                    g = f.zoom.previous;
                if (a !== f.rotation.previous || d !== g) {
                    var l = b("#diva-canvas-wrapper").scrollLeft(),
                        m = b("#diva-canvas-wrapper").scrollTop(),
                        n = c.viewport.width / 2,
                        y = c.viewport.height / 2,
                        l = l + n - e.centerX,
                        p = -(m + y - e.centerY),
                        G = (f.rotation.previous -
                            a) * Math.PI / 180,
                        m = Math.cos(G) * l - Math.sin(G) * p + e.centerX,
                        l = -(Math.sin(G) * l + Math.cos(G) * p) + e.centerY,
                        d = Math.pow(2, d - g),
                        n = d * m - n,
                        y = d * l - y;
                    k(e, a);
                    b("#diva-canvas-wrapper").scrollLeft(n);
                    b("#diva-canvas-wrapper").scrollTop(y)
                }
                if (h()) {
                    v(e);
                    for (var E in f) f[E].previous = f[E].current
                }
            }, t = function (a) {
                var b = f[a].current !== f[a].initial;
                return f[a].current !== f[a].previous || b
            }, v = function (a) {
                var b = a.data,
                    d = a.context.createImageData(b),
                    e = d.data,
                    g, h;
                g = 0;
                for (h = e.length; g < h; g++) e[g] = b.data[g];
                b = d.data;
                g = f.contrast.current;
                e = (1 + Math.min(c.brightnessMax, Math.max(c.brightnessMin, f.brightness.current)) / c.brightnessMax) * g;
                g = 128 - 128 * g;
                h = f.red.current;
                var k = f.green.current,
                    l = f.blue.current,
                    m = t("red"),
                    n = t("green"),
                    p = t("blue"),
                    u = t("brightness"),
                    r = t("contrast"),
                    u = u || r,
                    q, w, z, x, v, C, D, r = 0;
                for (w = d.width; r < w; r++)
                    for (q = 0, z = d.height; q < z; q++) x = 4 * (q * w + r), v = b[x], C = b[x + 1], D = b[x + 2], 0 < v + C + D && (m && v && (v += h), n && C && (C += k), p && D && (D += l), u && (v && (v = v * e + g), C && (C = C * e + g), D && (D = D * e + g)), b[x] = v, b[x + 1] = C, b[x + 2] = D);
                a.context.clearRect(0, 0, w, z);
                a.context.putImageData(d,
                    0, 0)
            }, p = function () {
                var a = b("#diva-canvas-wrapper").scrollLeft() * d.scaleFactor,
                    e = b("#diva-canvas-wrapper").scrollTop() * d.scaleFactor,
                    f = Math.min(Math.round(c.viewport.height * d.scaleFactor), c.mapSize) - 4,
                    g = Math.min(Math.round(c.viewport.width * d.scaleFactor), c.mapSize) - 4;
                b("#diva-map-viewbox").height(f).width(g).css({
                    top: e,
                    left: a
                })
            }, q = function (f, g) {
                a = new Image;
                a.src = f;
                a.onload = function () {
                    e.size = Math.sqrt(a.width * a.width + a.height * a.height);
                    e.canvas = document.getElementById("diva-canvas");
                    e.canvas.width =
                        e.size;
                    e.canvas.height = e.size;
                    e.cornerX = (e.size - a.width) / 2;
                    e.cornerY = (e.size - a.height) / 2;
                    e.width = a.width;
                    e.height = a.height;
                    e.centerX = e.size / 2;
                    e.centerY = e.size / 2;
                    e.context = e.canvas.getContext("2d");
                    e.context.drawImage(a, e.cornerX, e.cornerY, e.width, e.height);
                    e.data = e.context.getImageData(0, 0, e.size, e.size);
                    if (void 0 === g) {
                        var f = a;
                        d.canvas = document.getElementById("diva-canvas-minimap");
                        d.size = c.mapSize;
                        d.canvas.width = d.size;
                        d.canvas.height = d.size;
                        d.context = d.canvas.getContext("2d");
                        d.context.fillRect(0,
                            0, d.size, d.size);
                        d.scaleFactor = c.mapSize / e.size;
                        d.cornerX = e.cornerX * d.scaleFactor;
                        d.cornerY = e.cornerY * d.scaleFactor;
                        d.width = f.width * d.scaleFactor;
                        d.height = f.height * d.scaleFactor;
                        d.context.drawImage(f, d.cornerX, d.cornerY, d.width, d.height);
                        d.data = d.context.getImageData(0, 0, c.mapSize, c.mapSize);
                        b("#diva-map-viewbox").show();
                        p()
                    }
                    m();
                    n(e);
                    x();
                    "function" === typeof g && g.call(g)
                }
            }, u = function () {
                var a = f[l],
                    c = a.current,
                    a = a.transform ? a.transform(c) : c;
                b("#diva-canvas-value").html(a)
            }, w = function () {
                b("#diva-canvas-slider").slider({
                    value: f[l].current
                })
            },
            r = function (a) {
                a = c.zoomWidthRatio * Math.pow(2, a);
                return c.proxyURL ? c.proxyURL + "?f=" + c.filename + "&w=" + a : c.iipServerURL + "?FIF=" + (c.imageDir + "/") + c.filename + "&WID=" + a + "&CVT=JPEG"
            }, I = function () {
                (2 < f.zoom.current || c.mobileWebkit) && b(c.selector + "throbber").addClass("canvas-throbber").show()
            }, x = function () {
                b(c.selector + "throbber").removeClass("canvas-throbber").hide()
            }, z = function () {
                var a = {}, b = !1,
                    d = c.localStoragePrefix + c.filename,
                    e;
                for (e in f) f[e].previous !== f[e].initial && (a[e] = f[e].previous, b = !0);
                b ? (c.pluginIcon.addClass("new"),
                    localStorage.setObject(d, a)) : (c.pluginIcon.removeClass("new"), localStorage.removeItem(d))
            }, K = function (a, b) {
                c.zoomLevel = a;
                var f = r(a);
                q(f, function () {
                    d.scaleFactor = d.size / e.size;
                    p();
                    z()
                })
            };
        return {
            init: function (a, k) {
                if (!window.HTMLCanvasElement) return !1;
                b.extend(c, g, a.canvasPlugin);
                c.inCanvas = !1;
                c.iipServerURL = a.iipServerURL;
                c.digiId = a.digiId;
                c.imageDir = a.imageDir;
                c.selector = a.selector;
                c.mobileWebkit = a.mobileWebkit;
                f = {
                    contrast: {
                        initial: 1,
                        min: c.contrastMin,
                        max: c.contrastMax,
                        step: c.contrastStep,
                        transform: function (a) {
                            return a.toFixed(2)
                        },
                        title: "Change the contrast"
                    },
                    brightness: {
                        initial: 0,
                        min: c.brightnessMin,
                        max: c.brightnessMax,
                        step: c.brightnessStep,
                        title: "Adjust the brightness"
                    },
                    rotation: {
                        initial: 0,
                        min: 0,
                        max: 359,
                        step: 1,
                        transform: function (a) {
                            return a + "&deg;"
                        },
                        title: "Rotate the image"
                    },
                    zoom: {
                        initial: 0,
                        min: 0,
                        max: 0,
                        step: 1,
                        title: "Adjust the zoom level"
                    },
                    red: {
                        initial: 0,
                        min: c.rgbMin,
                        max: c.rgbMax,
                        step: 1,
                        title: "Adjust the red channel"
                    },
                    green: {
                        initial: 0,
                        min: c.rgbMin,
                        max: c.rgbMax,
                        step: 1,
                        title: "Adjust the green channel"
                    },
                    blue: {
                        initial: 0,
                        min: c.rgbMin,
                        max: c.rgbMax,
                        step: 1,
                        title: "Adjust the blue channel"
                    }
                };
                var r = function () {
                    var a, b, c;
                    for (c in f) b = f[c], a = b.initial, b.current = a, b.previous = a
                };
                r();
                if (b("#diva-canvas-backdrop").length) return !0;
                var q = [],
                    t, B, y;
                for (y in c.buttons) t = c.buttons[y], B = f[t].title, t = '<div class="' + t + '" title="' + B + '"></div>', q.push(t);
                q = '<div id="diva-canvas-backdrop">' + ('<div id="diva-canvas-tools"><div id="diva-canvas-toolbar"><div id="diva-canvas-close" title="Return to the document viewer"></div><div id="diva-canvas-minimise" title="Minimise the toolbar"></div><span id="diva-canvas-info">Test</span></div><div id="diva-canvas-toolwindow"><div id="diva-map-viewbox"></div><canvas id="diva-canvas-minimap"></canvas><div id="diva-canvas-buttons">' +
                    q.join("") + '</div><div id="diva-canvas-pane"><p id="diva-canvas-tooltip"><span id="diva-canvas-mode">contrast</span>: <span id="diva-canvas-value">0</span> <span id="diva-canvas-reset" class="link">(Reset)</span></p><div id="diva-canvas-slider"></div></div><br /><div class="action-buttons"><a href="#" id="diva-canvas-reset-all">Reset all</a><a href="#" id="diva-canvas-apply">Apply</a></div></div></div>') + '<div id="diva-canvas-wrapper"><canvas id="diva-canvas"></canvas></div></div>';
                b("body").append(q);
                c.mapSize = b("#diva-canvas-minimap").width();
                b("#diva-canvas-buttons div").click(function () {
                    b("#diva-canvas-buttons .clicked").removeClass("clicked");
                    v(b(this).attr("class"))
                });
                var v = function (a) {
                    l = a;
                    a = f[l];
                    b("#diva-canvas-buttons ." + l).addClass("clicked");
                    b("#diva-canvas-mode").text(l);
                    var c = a.current,
                        d = a.transform ? a.transform(c) : c;
                    b("#diva-canvas-slider").slider({
                        min: a.min,
                        max: a.max,
                        step: a.step
                    }).slider("value", c);
                    b("#diva-canvas-value").html(d)
                };
                v("contrast");
                b("#diva-canvas-slider").slider({
                    slide: function (a,
                        b) {
                        f[l].current = b.value;
                        u();
                        m()
                    }
                });
                b("#diva-canvas-reset-all").click(function () {
                    for (var a in f) f[a].current = f[a].initial;
                    u();
                    w();
                    m()
                });
                b("#diva-canvas-reset").click(function () {
                    f[l].current = f[l].initial;
                    u();
                    w();
                    m()
                });
                b("#diva-canvas-apply").click(function () {
                    h() && (I(), setTimeout(function () {
                        f.zoom.current !== f.zoom.previous ? K(f.zoom.current) : (n(), x(), z())
                    }, c.throbberTimeout))
                });
                b("#diva-canvas-close").click(function () {
                    b("body").removeClass("overflow-hidden");
                    e.context.clearRect(0, 0, e.size, e.size);
                    d.context.clearRect(0,
                        0, d.size, d.size);
                    b("#diva-canvas-wrapper").scrollTop(0).scrollLeft(0);
                    b("#diva-canvas-backdrop").hide();
                    b("#diva-map-viewbox").hide();
                    r();
                    u();
                    w();
                    b("#diva-canvas-buttons .clicked").removeClass("clicked");
                    v("contrast");
                    Events.publish("CanvasViewDidHide")
                });
                b("#diva-canvas-minimise").click(function () {
                    b("#diva-canvas-toolwindow").slideToggle("fast")
                });
                b(window).resize(function () {
                    c.viewport = {
                        height: window.innerHeight - a.scrollbarWidth,
                        width: window.innerWidth - a.scrollbarWidth
                    };
                    c.inCanvas && p()
                });
                b("#diva-canvas-wrapper").scroll(function () {
                    c.inCanvas &&
                        p()
                });
                b("#diva-canvas-minimap, #diva-map-viewbox").mouseup(function (a) {
                    var e = b("#diva-canvas-minimap").offset(),
                        f = (a.pageX - e.left) / d.scaleFactor;
                    a = (a.pageY - e.top) / d.scaleFactor;
                    b("#diva-canvas-wrapper").scrollTop(a - c.viewport.height / 2);
                    b("#diva-canvas-wrapper").scrollLeft(f - c.viewport.width / 2)
                });
                b("#diva-canvas").mousedown(function () {
                    b(this).addClass("grabbing")
                }).mouseup(function () {
                    b(this).removeClass("grabbing")
                });
                c.mobileWebkit ? b("#diva-canvas-wrapper").kinetic() : b("#diva-canvas-wrapper").dragscrollable({
                    acceptPropagatedEvent: !0
                });
                "function" === typeof c.onInit && c.onInit.call(this, c);
                return !0
            },
            pluginName: "canvas",
            titleText: "View the image on a canvas and adjust various settings",
            setupHook: function (a) {
                c.viewport = {
                    height: window.innerHeight - a.scrollbarWidth,
                    width: window.innerWidth - a.scrollbarWidth
                };
                c.minZoomLevel = a.minZoomLevel;
                c.maxZoomLevel = a.maxZoomLevel;
                c.mobileWebkit && (c.maxZoomLevel = Math.min(c.maxZoomLevel, c.mobileWebkitMaxZoom));
                f.zoom.min = c.minZoomLevel;
                f.zoom.max = c.maxZoomLevel
            },
            handleClick: function (a, d) {
                var e = b(this).parent().parent(),
                    g = b(e).attr("data-filename"),
                    h = b(e).width() - 1,
                    k = d.zoomLevel,
                    m;
                c.zoomWidthRatio = h / Math.pow(2, k);
                c.pluginIcon = b(this);
                c.mobileWebkit && (k = Math.min(c.maxZoomLevel, k));
                c.filename = g;
                f.zoom.initial = k;
                f.zoom.current = k;
                if (g = localStorage.getObject(c.localStoragePrefix + c.filename))
                    for (m in g) f[m].current = g[m], m === l && (u(), w()), "zoom" === m && (k = g[m]);
                f.zoom.previous = k;
                b("body").addClass("overflow-hidden");
                b("#diva-canvas-backdrop").show();
                c.inCanvas = !0;
                k = r(k);
                b("#diva-canvas-info").text(b(e).attr("title"));
                I();
                Events.publish("CanvasViewDidActivate", [e]);
                q(k)
            },
            onPageLoad: function (a, d, e) {
                null !== localStorage.getItem(c.localStoragePrefix + d) && b(e).find(".diva-canvas-icon").addClass("new")
            },
            destroy: function () {
                b("#diva-canvas-backdrop").remove()
            }
        }
    }())
})(jQuery);
(function (b) {
    window.divaPlugins.push(function () {
        var e, d;
        return {
            init: function (b, a) {
                e = b.iipServerURL;
                d = b.imageDir;
                return !0
            },
            pluginName: "download",
            titleText: "Download image at the given zoom level",
            handleClick: function (c) {
                var a = b(this).parent().parent();
                c = b(a).attr("data-filename");
                a = b(a).width() - 1;
                window.open(e + "?FIF=" + (d + "/") + c + "&WID=" + a + "&CVT=JPEG")
            }
        }
    }())
})(jQuery);
(function (b) {
    window.divaPlugins.push(function () {
        return {
            init: function (b, d) {
                b.parentSelector.data("highlights", {});
                Events.subscribe("PageHasLoaded", function (c, a, f) {
                    var l = b.parentSelector.data("highlights");
                    if (l.hasOwnProperty(c)) {
                        a = d.getInstanceId() + "page-" + c;
                        a = document.getElementById(a);
                        f = l[c].regions;
                        c = l[c].colour;
                        for (var l = d.getMaxZoomLevel() - d.getZoomLevel(), g = f.length; g--;) {
                            var k = document.createElement("div");
                            k.style.width = f[g].width / Math.pow(2, l) + "px";
                            k.style.height = f[g].height / Math.pow(2, l) +
                                "px";
                            k.style.top = f[g].uly / Math.pow(2, l) + "px";
                            k.style.left = f[g].ulx / Math.pow(2, l) + "px";
                            k.style.backgroundColor = c;
                            k.style.border = "1px solid #555";
                            k.style.position = "absolute";
                            k.style.zIndex = 1E3;
                            k.className = "search-result";
                            a.appendChild(k)
                        }
                    }
                });
                d.resetHighlights = function () {
                    for (var c = document.getElementsByClassName("search-result"), a = c.length; a--;) c[a].parentNode.removeChild(c[a]);
                    b.parentSelector.data("highlights", {})
                };
                d.removeHighlightsOnPage = function (c) {
                    var a = b.parentSelector.data("highlights");
                    if (a.hasOwnProperty(c)) {
                        for (var f =
                            d.getInstanceId() + "page-" + c, f = document.getElementById(f), l = f.getElementsByClassName("search-result"), g = l.length; g--;) f.removeChild(l[g]);
                        delete a[c]
                    }
                };
                d.highlightOnPages = function (b, a, e) {
                    for (var l = b.length; l--;) d.highlightOnPage(b[l], a, e)
                };
                d.highlightOnPage = function (c, a, f) {
                    "undefined" === typeof f && (f = "rgba(255, 0, 0, 0.5)");
                    d.getMaxZoomLevel();
                    b.parentSelector.data("highlights")[c] = {
                        regions: a,
                        colour: f
                    };
                    return !0
                };
                return !0
            },
            pluginName: "highlight",
            titleText: "Highlight regions of pages"
        }
    }())
})(jQuery);
(function (b) {
    window.divaPlugins.push(function () {
        return {
            init: function (b, d) {
                return !0
            },
            pluginName: "text",
            titleText: "View the text of this page"
        }
    }())
})(jQuery);