/*
 Galleria v 1.2.5 2011-08-03
 http://galleria.aino.se

 Copyright (c) 2011, Aino
 Licensed under the MIT license.
*/
(function (j) {
    var t = this,
        w = t.document,
        R = j(w),
        M = j(t),
        N = true,
        W = 3E4,
        da = false,
        aa = navigator.userAgent.toLowerCase(),
        ca = t.location.hash.replace(/#\//, ""),
        X = function () {
            var c = 3,
                i = w.createElement("div"),
                n = i.getElementsByTagName("i");
            do i.innerHTML = "<\!--[if gt IE " + ++c + "]><i></i><![endif]--\>";
            while (n[0]);
            return c > 4 ? c : void 0
        }(),
        P = function () {
            return {
                html: w.documentElement,
                body: w.body,
                head: w.getElementsByTagName("head")[0],
                title: w.title
            }
        },
        ia = function () {
            var c = [];
            j.each("data ready thumbnail loadstart loadfinish image play pause progress fullscreen_enter fullscreen_exit idle_enter idle_exit rescale lightbox_open lightbox_close lightbox_image".split(" "), function (i, n) {
                c.push(n);
                /_/.test(n) && c.push(n.replace(/_/g, ""))
            });
            return c
        }(),
        ja = function (c) {
            var i;
            if (typeof c !== "object") return c;
            j.each(c, function (n, k) {
                if (/^[a-z]+_/.test(n)) {
                    i = "";
                    j.each(n.split("_"), function (s, C) {
                        i += s > 0 ? C.substr(0, 1).toUpperCase() + C.substr(1) : C
                    });
                    c[i] = k;
                    delete c[n]
                }
            });
            return c
        },
        la = function (c) {
            if (j.inArray(c, ia) > -1) return Galleria[c.toUpperCase()];
            return c
        },
        d = {
            trunk: {},
            add: function (c, i, n, k) {
                k = k || false;
                this.clear(c);
                if (k) {
                    var s = i;
                    i = function () {
                        s();
                        d.add(c, i, n)
                    }
                }
                this.trunk[c] = t.setTimeout(i, n)
            },
            clear: function (c) {
                var i = function (k) {
                        t.clearTimeout(this.trunk[k]);
                        delete this.trunk[k]
                    },
                    n;
                if (c && c in this.trunk) i.call(d, c);
                else if (typeof c === "undefined") for (n in this.trunk) this.trunk.hasOwnProperty(n) && i.call(d, n)
            }
        },
        $ = [],
        ea = [],
        A = false,
        fa = false,
        qa = [],
        ka = function (c) {
            Galleria.theme = c;
            j.each(qa, function (i, n) {
                n._init.call(n)
            })
        },
        q = function () {
            return {
                array: function (c) {
                    return Array.prototype.slice.call(c, 0)
                },
                create: function (c, i) {
                    var n = w.createElement(i || "div");
                    n.className = c;
                    return n
                },
                getScriptPath: function (c) {
                    c = c || j("script:last").attr("src");
                    c = c.split("/");
                    if (c.length == 1) return "";
                    c.pop();
                    return c.join("/") + "/"
                },
                animate: function () {
                    var c = function (D) {
                            var J = "transition WebkitTransition MozTransition OTransition".split(" "),
                                L;
                            if (t.opera) return false;
                            for (L = 0; J[L]; L++) if (typeof D[J[L]] !== "undefined") return J[L];
                            return false
                        }((w.body || w.documentElement).style),
                        i = {
                            MozTransition: "transitionend",
                            OTransition: "oTransitionEnd",
                            WebkitTransition: "webkitTransitionEnd",
                            transition: "transitionend"
                        }[c],
                        n = {
                            _default: [0.25, 0.1, 0.25, 1],
                            galleria: [0.645, 0.045, 0.355, 1],
                            galleriaIn: [0.55, 0.085, 0.68, 0.53],
                            galleriaOut: [0.25, 0.46, 0.45, 0.94],
                            ease: [0.25, 0, 0.25, 1],
                            linear: [0.25, 0.25, 0.75, 0.75],
                            "ease-in": [0.42, 0, 1, 1],
                            "ease-out": [0, 0, 0.58, 1],
                            "ease-in-out": [0.42, 0, 0.58, 1]
                        },
                        k = function (D, J, L) {
                            var T = {};
                            L = L || "transition";
                            j.each("webkit moz ms o".split(" "), function () {
                                T["-" + this + "-" + L] = J
                            });
                            D.css(T)
                        },
                        s = function (D) {
                            k(D, "none", "transition");
                            if (Galleria.WEBKIT && Galleria.TOUCH) {
                                k(D, "translate3d(0,0,0)", "transform");
                                if (D.data("revert")) {
                                    D.css(D.data("revert"));
                                    D.data("revert", null)
                                }
                            }
                        },
                        C, E, B, p, r, I, O;
                    return function (D, J, L) {
                        L = j.extend({
                            duration: 400,
                            complete: function () {},
                            stop: false
                        }, L);
                        D = j(D);
                        if (L.duration) if (c) {
                            if (L.stop) {
                                D.unbind(i);
                                s(D)
                            }
                            C = false;
                            j.each(J, function (T, Z) {
                                O = D.css(T);
                                if (q.parseValue(O) != q.parseValue(Z)) C = true;
                                D.css(T, O)
                            });
                            if (C) {
                                E = [];
                                B = L.easing in n ? n[L.easing] : n._default;
                                p = " " + L.duration + "ms cubic-bezier(" + B.join(",") + ")";
                                t.setTimeout(function () {
                                    D.one(i, function (T) {
                                        return function () {
                                            s(T);
                                            L.complete.call(T[0])
                                        }
                                    }(D));
                                    if (Galleria.WEBKIT && Galleria.TOUCH) {
                                        r = {};
                                        I = [0, 0, 0];
                                        j.each(["left", "top"], function (T, Z) {
                                            if (Z in J) {
                                                I[T] = q.parseValue(J[Z]) - q.parseValue(D.css(Z)) + "px";
                                                r[Z] = J[Z];
                                                delete J[Z]
                                            }
                                        });
                                        if (I[0] || I[1]) {
                                            D.data("revert", r);
                                            E.push("-webkit-transform" + p);
                                            k(D, "translate3d(" + I.join(",") + ")", "transform")
                                        }
                                    }
                                    j.each(J, function (T) {
                                        E.push(T + p)
                                    });
                                    k(D, E.join(","));
                                    D.css(J)
                                }, 1)
                            } else t.setTimeout(function () {
                                L.complete.call(D[0])
                            }, L.duration)
                        } else D.animate(J, L);
                        else {
                            D.css(J);
                            L.complete.call(D[0])
                        }
                    }
                }(),
                removeAlpha: function (c) {
                    if (X < 9 && c) {
                        var i = c.style;
                        c = (c = c.currentStyle) && c.filter || i.filter || "";
                        if (/alpha/.test(c)) i.filter = c.replace(/alpha\([^)]*\)/i, "")
                    }
                },
                forceStyles: function (c, i) {
                    c = j(c);
                    c.attr("style") && c.data("styles", c.attr("style")).removeAttr("style");
                    c.css(i)
                },
                revertStyles: function () {
                    j.each(q.array(arguments), function (c, i) {
                        i = j(i);
                        i.removeAttr("style");
                        i.attr("style", "");
                        i.data("styles") && i.attr("style", i.data("styles")).data("styles", null)
                    })
                },
                moveOut: function (c) {
                    q.forceStyles(c, {
                        position: "absolute",
                        left: -1E4
                    })
                },
                moveIn: function () {
                    q.revertStyles.apply(q, q.array(arguments))
                },
                elem: function (c) {
                    return c instanceof j ? {
                        $: c,
                        dom: c[0]
                    } : {
                        $: j(c),
                        dom: c
                    }
                },
                hide: function (c, i, n) {
                    n = n ||
                    function () {};
                    var k = q.elem(c),
                        s = k.$;
                    c = k.dom;
                    s.data("opacity") || s.data("opacity", s.css("opacity"));
                    k = {
                        opacity: 0
                    };
                    if (i) q.animate(c, k, {
                        duration: i,
                        complete: X < 9 && c ?
                        function () {
                            q.removeAlpha(c);
                            c.style.visibility = "visible";
                            n.call(c)
                        } : n,
                        stop: true
                    });
                    else if (X < 9 && c) {
                        q.removeAlpha(c);
                        c.style.visibility = "visible"
                    } else s.css(k)
                },
                show: function (c, i, n) {
                    n = n ||
                    function () {};
                    var k = q.elem(c),
                        s = k.$;
                    c = k.dom;
                    var C = {
                        opacity: parseFloat(s.data("opacity")) || 1
                    };
                    if (i) {
                        if (X < 9) {
                            s.css("opacity", 0);
                            c.style.visibility = "visible"
                        }
                        q.animate(c, C, {
                            duration: i,
                            complete: X < 9 && c ?
                            function () {
                                C.opacity == 1 && q.removeAlpha(c);
                                n.call(c)
                            } : n,
                            stop: true
                        })
                    } else if (X < 9 && C.opacity == 1 && c) {
                        q.removeAlpha(c);
                        c.style.visibility = "visible"
                    } else s.css(C)
                },
                optimizeTouch: function () {
                    var c, i, n, k, s = {},
                        C = function (p) {
                            p.preventDefault();
                            s = j.extend({}, p, true)
                        },
                        E = function () {
                            this.evt = s
                        },
                        B = function () {
                            this.handler.call(c, this.evt)
                        };
                    return function (p) {
                        j(p).bind("touchend", function (r) {
                            c = r.target;
                            for (k = true; c.parentNode && c != r.currentTarget && k;) {
                                i = j(c).data("events");
                                n = j(c).data("fakes");
                                if (i && "click" in i) {
                                    k = false;
                                    r.preventDefault();
                                    j(c).click(C).click();
                                    i.click.pop();
                                    j.each(i.click, E);
                                    j(c).data("fakes", i.click);
                                    delete i.click
                                } else if (n) {
                                    k = false;
                                    r.preventDefault();
                                    j.each(n, B)
                                }
                                c = c.parentNode
                            }
                        })
                    }
                }(),
                addTimer: function () {
                    d.add.apply(d, q.array(arguments));
                    return this
                },
                clearTimer: function () {
                    d.clear.apply(d, q.array(arguments));
                    return this
                },
                wait: function (c) {
                    c = j.extend({
                        until: function () {
                            return false
                        },
                        success: function () {},
                        error: function () {
                            Galleria.raise("Could not complete wait function.")
                        },
                        timeout: 3E3
                    }, c);
                    var i = q.timestamp(),
                        n, k, s = function () {
                            k = q.timestamp();
                            n = k - i;
                            if (c.until(n)) {
                                c.success();
                                return false
                            }
                            if (k >= i + c.timeout) {
                                c.error();
                                return false
                            }
                            t.setTimeout(s, 10)
                        };
                    t.setTimeout(s, 10)
                },
                toggleQuality: function (c, i) {
                    if (!(X !== 7 && X !== 8 || !c)) {
                        if (typeof i === "undefined") i = c.style.msInterpolationMode === "nearest-neighbor";
                        c.style.msInterpolationMode = i ? "bicubic" : "nearest-neighbor"
                    }
                },
                insertStyleTag: function (c) {
                    var i = w.createElement("style");
                    P().head.appendChild(i);
                    if (i.styleSheet) i.styleSheet.cssText = c;
                    else {
                        c = w.createTextNode(c);
                        i.appendChild(c)
                    }
                },
                loadScript: function (c, i) {
                    var n = false,
                        k = j("<script>").attr({
                            src: c,
                            async: true
                        }).get(0);
                    k.onload = k.onreadystatechange = function () {
                        if (!n && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete")) {
                            n = true;
                            k.onload = k.onreadystatechange = null;
                            typeof i === "function" && i.call(this, this)
                        }
                    };
                    P().head.appendChild(k)
                },
                parseValue: function (c) {
                    if (typeof c === "number") return c;
                    else if (typeof c === "string") return (c = c.match(/\-?\d|\./g)) && c.constructor === Array ? c.join("") * 1 : 0;
                    else return 0
                },
                timestamp: function () {
                    return (new Date).getTime()
                },
                loadCSS: function (c, i, n) {
                    var k, s = false,
                        C;
                    j("link[rel=stylesheet]").each(function () {
                        if (RegExp(c).test(this.href)) {
                            k = this;
                            return false
                        }
                    });
                    if (typeof i === "function") {
                        n = i;
                        i = void 0
                    }
                    n = n ||
                    function () {};
                    if (k) {
                        n.call(k, k);
                        return k
                    }
                    C = w.styleSheets.length;
                    if (N) c += "?" + q.timestamp();
                    if (j("#" + i).length) {
                        j("#" + i).attr("href", c);
                        C--;
                        s = true
                    } else {
                        k = j("<link>").attr({
                            rel: "stylesheet",
                            href: c,
                            id: i
                        }).get(0);
                        t.setTimeout(function () {
                            var E = j('link[rel="stylesheet"], style');
                            E.length ? E.get(0).parentNode.insertBefore(k, E[0]) : P().head.appendChild(k);
                            if (X) if (C >= 31) Galleria.raise("You have reached the browser stylesheet limit (31)", true);
                            else k.onreadystatechange = function () {
                                if (!s && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete")) s = true
                            };
                            else if (/file:\/\//i.test(c)) s = true;
                            else j.ajax({
                                url: c,
                                success: function () {
                                    s = true
                                },
                                error: function (B) {
                                    if (B.isRejected() && Galleria.WEBKIT) s = true
                                }
                            })
                        }, 10)
                    }
                    typeof n === "function" && q.wait({
                        until: function () {
                            return s && w.styleSheets.length > C
                        },
                        success: function () {
                            t.setTimeout(function () {
                                n.call(k, k)
                            }, 100)
                        },
                        error: function () {
                            Galleria.raise("Theme CSS could not load", true)
                        },
                        timeout: 1E4
                    });
                    return k
                }
            }
        }(),
        ra = function () {
            var c = function (i, n, k, s) {
                    var C = this.getOptions("easing"),
                        E = this.getStageWidth(),
                        B = {
                            left: E * (i.rewind ? -1 : 1)
                        },
                        p = {
                            left: 0
                        };
                    if (k) {
                        B.opacity = 0;
                        p.opacity = 1
                    }
                    j(i.next).css(B);
                    q.animate(i.next, p, {
                        duration: i.speed,
                        complete: function (r) {
                            return function () {
                                n();
                                r.css({
                                    left: 0
                                })
                            }
                        }(j(i.next).add(i.prev)),
                        queue: false,
                        easing: C
                    });
                    if (s) i.rewind = !i.rewind;
                    if (i.prev) {
                        B = {
                            left: 0
                        };
                        p = {
                            left: E * (i.rewind ? 1 : -1)
                        };
                        if (k) {
                            B.opacity = 1;
                            p.opacity = 0
                        }
                        j(i.prev).css(B);
                        q.animate(i.prev, p, {
                            duration: i.speed,
                            queue: false,
                            easing: C,
                            complete: function () {
                                j(this).css("opacity", 0)
                            }
                        })
                    }
                };
            return {
                fade: function (i, n) {
                    j(i.next).css("opacity", 0).show();
                    q.animate(i.next, {
                        opacity: 1
                    }, {
                        duration: i.speed,
                        complete: n
                    });
                    if (i.prev) {
                        j(i.prev).css("opacity", 1).show();
                        q.animate(i.prev, {
                            opacity: 0
                        }, {
                            duration: i.speed
                        })
                    }
                },
                flash: function (i, n) {
                    j(i.next).css("opacity", 0);
                    i.prev ? q.animate(i.prev, {
                        opacity: 0
                    }, {
                        duration: i.speed / 2,
                        complete: function () {
                            q.animate(i.next, {
                                opacity: 1
                            }, {
                                duration: i.speed,
                                complete: n
                            })
                        }
                    }) : q.animate(i.next, {
                        opacity: 1
                    }, {
                        duration: i.speed,
                        complete: n
                    })
                },
                pulse: function (i, n) {
                    i.prev && j(i.prev).hide();
                    j(i.next).css("opacity", 0).show();
                    q.animate(i.next, {
                        opacity: 1
                    }, {
                        duration: i.speed,
                        complete: n
                    })
                },
                slide: function () {
                    c.apply(this, q.array(arguments))
                },
                fadeslide: function () {
                    c.apply(this, q.array(arguments).concat([true]))
                },
                doorslide: function () {
                    c.apply(this, q.array(arguments).concat([false, true]))
                }
            }
        }();
    Galleria = function () {
        var c = this;
        this._theme = void 0;
        this._options = {};
        this._playing = false;
        this._playtime = 5E3;
        this._active = null;
        this._queue = {
            length: 0
        };
        this._data = [];
        this._dom = {};
        this._thumbnails = [];
        this._layers = [];
        this._firstrun = this._initialized = false;
        this._stageHeight = this._stageWidth = 0;
        this._target = void 0;
        this._id = Math.random();
        j.each("container stage images image-nav image-nav-left image-nav-right info info-text info-title info-description thumbnails thumbnails-list thumbnails-container thumb-nav-left thumb-nav-right loader counter tooltip".split(" "), function (p, r) {
            c._dom[r] = q.create("galleria-" + r)
        });
        j.each("current total".split(" "), function (p, r) {
            c._dom[r] = q.create("galleria-" + r, "span")
        });
        var i = this._keyboard = {
            keys: {
                UP: 38,
                DOWN: 40,
                LEFT: 37,
                RIGHT: 39,
                RETURN: 13,
                ESCAPE: 27,
                BACKSPACE: 8,
                SPACE: 32
            },
            map: {},
            bound: false,
            press: function (p) {
                var r = p.keyCode || p.which;
                r in i.map && typeof i.map[r] === "function" && i.map[r].call(c, p)
            },
            attach: function (p) {
                var r, I;
                for (r in p) if (p.hasOwnProperty(r)) {
                    I = r.toUpperCase();
                    if (I in i.keys) i.map[i.keys[I]] = p[r];
                    else i.map[I] = p[r]
                }
                if (!i.bound) {
                    i.bound = true;
                    R.bind("keydown", i.press)
                }
            },
            detach: function () {
                i.bound = false;
                i.map = {};
                R.unbind("keydown", i.press)
            }
        },
            n = this._controls = {
                0: void 0,
                1: void 0,
                active: 0,
                swap: function () {
                    n.active = n.active ? 0 : 1
                },
                getActive: function () {
                    return n[n.active]
                },
                getNext: function () {
                    return n[1 - n.active]
                }
            },
            k = this._carousel = {
                next: c.$("thumb-nav-right"),
                prev: c.$("thumb-nav-left"),
                width: 0,
                current: 0,
                max: 0,
                hooks: [],
                update: function () {
                    var p = 0,
                        r = 0,
                        I = [0];
                    j.each(c._thumbnails, function (O, D) {
                        if (D.ready) {
                            p += D.outerWidth || j(D.container).outerWidth(true);
                            I[O + 1] = p;
                            r = Math.max(r, D.outerHeight || j(D.container).outerHeight(true))
                        }
                    });
                    c.$("thumbnails").css({
                        width: p,
                        height: r
                    });
                    k.max = p;
                    k.hooks = I;
                    k.width = c.$("thumbnails-list").width();
                    k.setClasses();
                    c.$("thumbnails-container").toggleClass("galleria-carousel", p > k.width);
                    k.width = c.$("thumbnails-list").width()
                },
                bindControls: function () {
                    var p;
                    k.next.bind("click", function (r) {
                        r.preventDefault();
                        if (c._options.carouselSteps === "auto") for (p = k.current; p < k.hooks.length; p++) {
                            if (k.hooks[p] - k.hooks[k.current] > k.width) {
                                k.set(p - 2);
                                break
                            }
                        } else k.set(k.current + c._options.carouselSteps)
                    });
                    k.prev.bind("click", function (r) {
                        r.preventDefault();
                        if (c._options.carouselSteps === "auto") for (p = k.current; p >= 0; p--) if (k.hooks[k.current] - k.hooks[p] > k.width) {
                            k.set(p + 2);
                            break
                        } else {
                            if (p === 0) {
                                k.set(0);
                                break
                            }
                        } else k.set(k.current - c._options.carouselSteps)
                    })
                },
                set: function (p) {
                    for (p = Math.max(p, 0); k.hooks[p - 1] + k.width >= k.max && p >= 0;) p--;
                    k.current = p;
                    k.animate()
                },
                getLast: function (p) {
                    return (p || k.current) - 1
                },
                follow: function (p) {
                    if (p === 0 || p === k.hooks.length - 2) k.set(p);
                    else {
                        for (var r = k.current; k.hooks[r] - k.hooks[k.current] < k.width && r <= k.hooks.length;) r++;
                        if (p - 1 < k.current) k.set(p - 1);
                        else p + 2 > r && k.set(p - r + k.current + 2)
                    }
                },
                setClasses: function () {
                    k.prev.toggleClass("disabled", !k.current);
                    k.next.toggleClass("disabled", k.hooks[k.current] + k.width >= k.max)
                },
                animate: function () {
                    k.setClasses();
                    var p = k.hooks[k.current] * -1;
                    isNaN(p) || q.animate(c.get("thumbnails"), {
                        left: p
                    }, {
                        duration: c._options.carouselSpeed,
                        easing: c._options.easing,
                        queue: false
                    })
                }
            },
            s = this._tooltip = {
                initialized: false,
                open: false,
                init: function () {
                    s.initialized = true;
                    q.insertStyleTag(".galleria-tooltip{padding:3px 8px;max-width:50%;background:#ffe;color:#000;z-index:3;position:absolute;font-size:11px;line-height:1.3opacity:0;box-shadow:0 0 2px rgba(0,0,0,.4);-moz-box-shadow:0 0 2px rgba(0,0,0,.4);-webkit-box-shadow:0 0 2px rgba(0,0,0,.4);}");
                    c.$("tooltip").css("opacity", 0.8);
                    q.hide(c.get("tooltip"))
                },
                move: function (p) {
                    var r = c.getMousePosition(p).x;
                    p = c.getMousePosition(p).y;
                    var I = c.$("tooltip"),
                        O = p,
                        D = I.outerHeight(true) + 1,
                        J = I.outerWidth(true),
                        L = D + 15;
                    J = c.$("container").width() - J - 2;
                    D = c.$("container").height() - D - 2;
                    if (!isNaN(r) && !isNaN(O)) {
                        r += 10;
                        O -= 30;
                        r = Math.max(0, Math.min(J, r));
                        O = Math.max(0, Math.min(D, O));
                        if (p < L) O = L;
                        I.css({
                            left: r,
                            top: O
                        })
                    }
                },
                bind: function (p, r) {
                    if (!Galleria.TOUCH) {
                        s.initialized || s.init();
                        var I = function (O, D) {
                                s.define(O, D);
                                j(O).hover(function () {
                                    q.clearTimer("switch_tooltip");
                                    c.$("container").unbind("mousemove", s.move).bind("mousemove", s.move).trigger("mousemove");
                                    s.show(O);
                                    Galleria.utils.addTimer("tooltip", function () {
                                        c.$("tooltip").stop().show().animate({
                                            opacity: 1
                                        });
                                        s.open = true
                                    }, s.open ? 0 : 500)
                                }, function () {
                                    c.$("container").unbind("mousemove", s.move);
                                    q.clearTimer("tooltip");
                                    c.$("tooltip").stop().animate({
                                        opacity: 0
                                    }, 200, function () {
                                        c.$("tooltip").hide();
                                        q.addTimer("switch_tooltip", function () {
                                            s.open = false
                                        }, 1E3)
                                    })
                                })
                            };
                        typeof r === "string" ? I(p in c._dom ? c.get(p) : p, r) : j.each(p, function (O, D) {
                            I(c.get(O), D)
                        })
                    }
                },
                show: function (p) {
                    p = j(p in c._dom ? c.get(p) : p);
                    var r = p.data("tt"),
                        I = function (O) {
                            t.setTimeout(function (D) {
                                return function () {
                                    s.move(D)
                                }
                            }(O), 10);
                            p.unbind("mouseup", I)
                        };
                    if (r = typeof r === "function" ? r() : r) {
                        c.$("tooltip").html(r.replace(/\s/, "&nbsp;"));
                        p.bind("mouseup", I)
                    }
                },
                define: function (p, r) {
                    if (typeof r !== "function") {
                        var I = r;
                        r = function () {
                            return I
                        }
                    }
                    p = j(p in c._dom ? c.get(p) : p).data("tt", r);
                    s.show(p)
                }
            },
            C = this._fullscreen = {
                scrolled: 0,
                crop: c._options.imageCrop,
                active: false,
                keymap: c._keyboard.map,
                enter: function (p) {
                    C.active = true;
                    q.hide(c.getActiveImage());
                    c.$("container").addClass("fullscreen");
                    C.scrolled = M.scrollTop();
                    q.forceStyles(c.get("container"), {
                        position: "fixed",
                        top: 0,
                        left: 0,
                        width: "100%",
                        height: "100%",
                        zIndex: 1E4
                    });
                    var r = {
                        height: "100%",
                        overflow: "hidden",
                        margin: 0,
                        padding: 0
                    },
                        I = c.getData();
                    q.forceStyles(P().html, r);
                    q.forceStyles(P().body, r);
                    C.keymap = j.extend({}, c._keyboard.map);
                    c.attachKeyboard({
                        escape: c.exitFullscreen,
                        right: c.next,
                        left: c.prev
                    });
                    if (c._options.fullscreenCrop !== void 0) c._options.imageCrop = c._options.fullscreenCrop;
                    if (I && I.big && I.image !== I.big) {
                        r = new Galleria.Picture;
                        var O = r.isCached(I.big),
                            D = c.getIndex(),
                            J = c._thumbnails[D];
                        c.trigger({
                            type: Galleria.LOADSTART,
                            cached: O,
                            rewind: false,
                            index: D,
                            imageTarget: c.getActiveImage(),
                            thumbTarget: J
                        });
                        r.load(I.big, function (L) {
                            c._scaleImage(L, {
                                complete: function (T) {
                                    c.trigger({
                                        type: Galleria.LOADFINISH,
                                        cached: O,
                                        index: D,
                                        rewind: false,
                                        imageTarget: T.image,
                                        thumbTarget: J
                                    });
                                    var Z = c._controls.getActive().image;
                                    Z && j(Z).width(T.image.width).height(T.image.height).attr("style", j(T.image).attr("style")).attr("src", T.image.src)
                                }
                            })
                        })
                    }
                    c.rescale(function () {
                        q.addTimer("fullscreen_enter", function () {
                            q.show(c.getActiveImage());
                            typeof p === "function" && p.call(c)
                        }, 100);
                        c.trigger(Galleria.FULLSCREEN_ENTER)
                    });
                    M.resize(function () {
                        C.scale()
                    })
                },
                scale: function () {
                    c.rescale()
                },
                exit: function (p) {
                    C.active = false;
                    q.hide(c.getActiveImage());
                    c.$("container").removeClass("fullscreen");
                    q.revertStyles(c.get("container"), P().html, P().body);
                    t.scrollTo(0, C.scrolled);
                    c.detachKeyboard();
                    c.attachKeyboard(C.keymap);
                    if (c._options.fullscreenCrop !== void 0) c._options.imageCrop = C.crop;
                    c.rescale(function () {
                        q.addTimer("fullscreen_exit", function () {
                            q.show(c.getActiveImage());
                            typeof p === "function" && p.call(c)
                        }, 50);
                        c.trigger(Galleria.FULLSCREEN_EXIT)
                    });
                    M.unbind("resize", C.scale)
                }
            },
            E = this._idle = {
                trunk: [],
                bound: false,
                add: function (p, r) {
                    if (p) {
                        E.bound || E.addEvent();
                        p = j(p);
                        var I = {},
                            O;
                        for (O in r) if (r.hasOwnProperty(O)) I[O] = p.css(O);
                        p.data("idle", {
                            from: I,
                            to: r,
                            complete: true,
                            busy: false
                        });
                        E.addTimer();
                        E.trunk.push(p)
                    }
                },
                remove: function (p) {
                    p = jQuery(p);
                    j.each(E.trunk, function (r, I) {
                        if (I.length && !I.not(p).length) {
                            c._idle.show(p);
                            c._idle.trunk.splice(r, 1)
                        }
                    });
                    if (!E.trunk.length) {
                        E.removeEvent();
                        q.clearTimer("idle")
                    }
                },
                addEvent: function () {
                    E.bound = true;
                    c.$("container").bind("mousemove click", E.showAll)
                },
                removeEvent: function () {
                    E.bound = false;
                    c.$("container").unbind("mousemove click", E.showAll)
                },
                addTimer: function () {
                    q.addTimer("idle", function () {
                        c._idle.hide()
                    }, c._options.idleTime)
                },
                hide: function () {
                    if (c._options.idleMode) {
                        c.trigger(Galleria.IDLE_ENTER);
                        j.each(E.trunk, function (p, r) {
                            var I = r.data("idle");
                            if (I) {
                                r.data("idle").complete = false;
                                q.animate(r, I.to, {
                                    duration: c._options.idleSpeed
                                })
                            }
                        })
                    }
                },
                showAll: function () {
                    q.clearTimer("idle");
                    j.each(c._idle.trunk, function (p, r) {
                        c._idle.show(r)
                    })
                },
                show: function (p) {
                    var r = p.data("idle");
                    if (!r.busy && !r.complete) {
                        r.busy = true;
                        c.trigger(Galleria.IDLE_EXIT);
                        q.clearTimer("idle");
                        q.animate(p, r.from, {
                            duration: c._options.idleSpeed / 2,
                            complete: function () {
                                j(this).data("idle").busy = false;
                                j(this).data("idle").complete = true
                            }
                        })
                    }
                    E.addTimer()
                }
            },
            B = this._lightbox = {
                width: 0,
                height: 0,
                initialized: false,
                active: null,
                image: null,
                elems: {},
                keymap: false,
                init: function () {
                    c.trigger(Galleria.LIGHTBOX_OPEN);
                    if (!B.initialized) {
                        B.initialized = true;
                        var p = {},
                            r = c._options,
                            I = "";
                        r = {
                            overlay: "position:fixed;display:none;opacity:" + r.overlayOpacity + ";filter:alpha(opacity=" + r.overlayOpacity * 100 + ");top:0;left:0;width:100%;height:100%;background:" + r.overlayBackground + ";z-index:99990",
                            box: "position:fixed;display:none;width:400px;height:400px;top:50%;left:50%;margin-top:-200px;margin-left:-200px;z-index:99991",
                            shadow: "position:absolute;background:#000;width:100%;height:100%;",
                            content: "position:absolute;background-color:#fff;top:10px;left:10px;right:10px;bottom:10px;overflow:hidden",
                            info: "position:absolute;bottom:10px;left:10px;right:10px;color:#444;font:11px/13px arial,sans-serif;height:13px",
                            close: "position:absolute;top:10px;right:10px;height:20px;width:20px;background:#fff;text-align:center;cursor:pointer;color:#444;font:16px/22px arial,sans-serif;z-index:99999",
                            image: "position:absolute;top:10px;left:10px;right:10px;bottom:30px;overflow:hidden;display:block;",
                            prevholder: "position:absolute;width:50%;top:0;bottom:40px;cursor:pointer;",
                            nextholder: "position:absolute;width:50%;top:0;bottom:40px;right:-1px;cursor:pointer;",
                            prev: "position:absolute;top:50%;margin-top:-20px;height:40px;width:30px;background:#fff;left:20px;display:none;text-align:center;color:#000;font:bold 16px/36px arial,sans-serif",
                            next: "position:absolute;top:50%;margin-top:-20px;height:40px;width:30px;background:#fff;right:20px;left:auto;display:none;font:bold 16px/36px arial,sans-serif;text-align:center;color:#000",
                            title: "float:left",
                            counter: "float:right;margin-left:8px;"
                        };
                        var O = {};
                        if (X === 8) {
                            r.nextholder += "background:#000;filter:alpha(opacity=0);";
                            r.prevholder += "background:#000;filter:alpha(opacity=0);"
                        }
                        j.each(r, function (D, J) {
                            I += ".galleria-lightbox-" + D + "{" + J + "}"
                        });
                        q.insertStyleTag(I);
                        j.each("overlay box content shadow title info close prevholder prev nextholder next counter image".split(" "), function (D, J) {
                            c.addElement("lightbox-" + J);
                            p[J] = B.elems[J] = c.get("lightbox-" + J)
                        });
                        B.image = new Galleria.Picture;
                        j.each({
                            box: "shadow content close prevholder nextholder",
                            info: "title counter",
                            content: "info image",
                            prevholder: "prev",
                            nextholder: "next"
                        }, function (D, J) {
                            var L = [];
                            j.each(J.split(" "), function (T, Z) {
                                L.push("lightbox-" + Z)
                            });
                            O["lightbox-" + D] = L
                        });
                        c.append(O);
                        j(p.image).append(B.image.container);
                        j(P().body).append(p.overlay, p.box);
                        q.optimizeTouch(p.box);
                        (function (D) {
                            return D.hover(function () {
                                j(this).css("color", "#bbb")
                            }, function () {
                                j(this).css("color", "#444")
                            })
                        })(j(p.close).bind("click", B.hide).html("&#215;"));
                        j.each(["Prev", "Next"], function (D, J) {
                            var L = j(p[J.toLowerCase()]).html(/v/.test(J) ? "&#8249;&nbsp;" : "&nbsp;&#8250;"),
                                T = j(p[J.toLowerCase() + "holder"]);
                            T.bind("click", function () {
                                B["show" + J]()
                            });
                            X < 8 || Galleria.TOUCH ? L.show() : T.hover(function () {
                                L.show()
                            }, function () {
                                L.stop().fadeOut(200)
                            })
                        });
                        j(p.overlay).bind("click", B.hide);
                        if (Galleria.IPAD) c._options.lightboxTransitionSpeed = 0
                    }
                },
                rescale: function (p) {
                    var r = Math.min(M.width() - 40, B.width),
                        I = Math.min(M.height() - 60, B.height);
                    I = Math.min(r / B.width, I / B.height);
                    r = Math.round(B.width * I) + 40;
                    I = Math.round(B.height * I) + 60;
                    r = {
                        width: r,
                        height: I,
                        "margin-top": Math.ceil(I / 2) * -1,
                        "margin-left": Math.ceil(r / 2) * -1
                    };
                    p ? j(B.elems.box).css(r) : j(B.elems.box).animate(r, {
                        duration: c._options.lightboxTransitionSpeed,
                        easing: c._options.easing,
                        complete: function () {
                            var O = B.image,
                                D = c._options.lightboxFadeSpeed;
                            c.trigger({
                                type: Galleria.LIGHTBOX_IMAGE,
                                imageTarget: O.image
                            });
                            j(O.container).show();
                            q.show(O.image, D);
                            q.show(B.elems.info, D)
                        }
                    })
                },
                hide: function () {
                    B.image.image = null;
                    M.unbind("resize", B.rescale);
                    j(B.elems.box).hide();
                    q.hide(B.elems.info);
                    c.detachKeyboard();
                    c.attachKeyboard(B.keymap);
                    B.keymap = false;
                    q.hide(B.elems.overlay, 200, function () {
                        j(this).hide().css("opacity", c._options.overlayOpacity);
                        c.trigger(Galleria.LIGHTBOX_CLOSE)
                    })
                },
                showNext: function () {
                    B.show(c.getNext(B.active))
                },
                showPrev: function () {
                    B.show(c.getPrev(B.active))
                },
                show: function (p) {
                    B.active = p = typeof p === "number" ? p : c.getIndex();
                    B.initialized || B.init();
                    if (!B.keymap) {
                        B.keymap = j.extend({}, c._keyboard.map);
                        c.attachKeyboard({
                            escape: B.hide,
                            right: B.showNext,
                            left: B.showPrev
                        })
                    }
                    M.unbind("resize", B.rescale);
                    var r = c.getData(p),
                        I = c.getDataLength();
                    q.hide(B.elems.info);
                    B.image.load(r.big || r.image, function (O) {
                        B.width = O.original.width;
                        B.height = O.original.height;
                        j(O.image).css({
                            width: "100.5%",
                            height: "100.5%",
                            top: 0,
                            zIndex: 99998
                        });
                        q.hide(O.image);
                        B.elems.title.innerHTML = r.title || "";
                        B.elems.counter.innerHTML = p + 1 + " / " + I;
                        M.resize(B.rescale);
                        B.rescale()
                    });
                    j(B.elems.overlay).show();
                    j(B.elems.box).show()
                }
            };
        return this
    };
    Galleria.prototype = {
        constructor: Galleria,
        init: function (c, i) {
            i = ja(i);
            this._original = {
                target: c,
                options: i,
                data: null
            };
            this._target = this._dom.target = c.nodeName ? c : j(c).get(0);
            ea.push(this);
            if (this._target) {
                this._options = {
                    autoplay: false,
                    carousel: true,
                    carouselFollow: true,
                    carouselSpeed: 400,
                    carouselSteps: "auto",
                    clicknext: false,
                    dataConfig: function () {
                        return {}
                    },
                    dataSelector: "img",
                    dataSource: this._target,
                    debug: void 0,
                    dummy: void 0,
                    easing: "galleria",
                    extend: function () {},
                    fullscreenCrop: void 0,
                    fullscreenDoubleTap: true,
                    fullscreenTransition: void 0,
                    height: "auto",
                    idleMode: true,
                    idleTime: 3E3,
                    idleSpeed: 200,
                    imageCrop: false,
                    imageMargin: 0,
                    imagePan: false,
                    imagePanSmoothness: 12,
                    imagePosition: "50%",
                    imageTimeout: void 0,
                    initialTransition: void 0,
                    keepSource: false,
                    layerFollow: true,
                    lightbox: false,
                    lightboxFadeSpeed: 200,
                    lightboxTransitionSpeed: 200,
                    linkSourceImages: true,
                    maxScaleRatio: void 0,
                    minScaleRatio: void 0,
                    overlayOpacity: 0.85,
                    overlayBackground: "#0b0b0b",
                    pauseOnInteraction: true,
                    popupLinks: false,
                    preload: 2,
                    queue: true,
                    show: 0,
                    showInfo: true,
                    showCounter: true,
                    showImagenav: true,
                    swipe: true,
                    thumbCrop: true,
                    thumbEventType: "click",
                    thumbFit: true,
                    thumbMargin: 0,
                    thumbQuality: "auto",
                    thumbnails: true,
                    touchTransition: void 0,
                    transition: "fade",
                    transitionInitial: void 0,
                    transitionSpeed: 400,
                    useCanvas: false,
                    width: "auto"
                };
                this._options.initialTransition = this._options.initialTransition || this._options.transitionInitial;
                if (i && i.debug === false) N = false;
                if (i && typeof i.imageTimeout === "number") W = i.imageTimeout;
                if (i && typeof i.dummy === "string") da = i.dummy;
                j(this._target).children().hide();
                typeof Galleria.theme === "object" ? this._init() : qa.push(this);
                return this
            } else Galleria.raise("Target not found.", true)
        },
        _init: function () {
            var c = this;
            if (this._initialized) {
                Galleria.raise("Init failed: Gallery instance already initialized.");
                return this
            }
            this._initialized = true;
            if (!Galleria.theme) {
                Galleria.raise("Init failed: No theme found.");
                return this
            }
            j.extend(true, this._options, Galleria.theme.defaults, this._original.options);
            (function (k) {
                if ("getContext" in k) fa = fa || {
                    elem: k,
                    context: k.getContext("2d"),
                    cache: {},
                    length: 0
                }
            })(w.createElement("canvas"));
            this.bind(Galleria.DATA, function () {
                this._original.data = this._data;
                this.get("total").innerHTML = this.getDataLength();
                var k = this.$("container"),
                    s = {
                        width: 0,
                        height: 0
                    },
                    C = function () {
                        return c.$("stage").height()
                    };
                q.wait({
                    until: function () {
                        j.each(["width", "height"], function (E, B) {
                            s[B] = c._options[B] && typeof c._options[B] === "number" ? c._options[B] : Math.max(q.parseValue(k.css(B)), q.parseValue(c.$("target").css(B)), k[B](), c.$("target")[B]());
                            k[B](s[B])
                        });
                        return C() && s.width && s.height > 10
                    },
                    success: function () {
                        Galleria.WEBKIT ? t.setTimeout(function () {
                            c._run()
                        }, 1) : c._run()
                    },
                    error: function () {
                        C() ? Galleria.raise("Could not extract sufficient width/height of the gallery container. Traced measures: width:" + s.width + "px, height: " + s.height + "px.", true) : Galleria.raise("Could not extract a stage height from the CSS. Traced height: " + C() + "px.", true)
                    },
                    timeout: 2E3
                })
            });
            this.append({
                "info-text": ["info-title", "info-description"],
                info: ["info-text"],
                "image-nav": ["image-nav-right", "image-nav-left"],
                stage: ["images", "loader", "counter", "image-nav"],
                "thumbnails-list": ["thumbnails"],
                "thumbnails-container": ["thumb-nav-left", "thumbnails-list", "thumb-nav-right"],
                container: ["stage", "thumbnails-container", "info", "tooltip"]
            });
            q.hide(this.$("counter").append(this.get("current"), " / ", this.get("total")));
            this.setCounter("&#8211;");
            q.hide(c.get("tooltip"));
            this.$("container").addClass(Galleria.TOUCH ? "touch" : "notouch");
            j.each(Array(2), function (k) {
                var s = new Galleria.Picture;
                j(s.container).css({
                    position: "absolute",
                    top: 0,
                    left: 0
                }).prepend(c._layers[k] = j(q.create("galleria-layer")).css({
                    position: "absolute",
                    top: 0,
                    left: 0,
                    right: 0,
                    bottom: 0,
                    zIndex: 2
                })[0]);
                c.$("images").append(s.container);
                c._controls[k] = s
            });
            this.$("images").css({
                position: "relative",
                top: 0,
                left: 0,
                width: "100%",
                height: "100%"
            });
            this.$("thumbnails, thumbnails-list").css({
                overflow: "hidden",
                position: "relative"
            });
            this.$("image-nav-right, image-nav-left").bind("click", function (k) {
                c._options.clicknext && k.stopPropagation();
                c._options.pauseOnInteraction && c.pause();
                k = /right/.test(this.className) ? "next" : "prev";
                c[k]()
            });
            j.each(["info", "counter", "image-nav"], function (k, s) {
                c._options["show" + s.substr(0, 1).toUpperCase() + s.substr(1).replace(/-/, "")] === false && q.moveOut(c.get(s.toLowerCase()))
            });
            this.load();
            if (!this._options.keep_source && !X) this._target.innerHTML = "";
            this.get("errors") && this.appendChild("target", "errors");
            this.appendChild("target", "container");
            if (this._options.carousel) {
                var i = 0,
                    n = this._options.show;
                this.bind(Galleria.THUMBNAIL, function () {
                    this.updateCarousel();
                    ++i == this.getDataLength() && typeof n == "number" && n > 0 && this._carousel.follow(n)
                })
            }
            if (this._options.swipe) {
                (function (k) {
                    var s = [0, 0],
                        C = [0, 0],
                        E = false,
                        B = 0,
                        p, r = {
                            start: "touchstart",
                            move: "touchmove",
                            stop: "touchend"
                        },
                        I = function (D) {
                            if (!(D.originalEvent.touches && D.originalEvent.touches.length > 1)) {
                                p = D.originalEvent.touches ? D.originalEvent.touches[0] : D;
                                C = [p.pageX, p.pageY];
                                s[0] || (s = C);
                                Math.abs(s[0] - C[0]) > 10 && D.preventDefault()
                            }
                        },
                        O = function (D) {
                            k.unbind(r.move, I);
                            if (D.originalEvent.touches && D.originalEvent.touches.length || E) E = !E;
                            else {
                                if (q.timestamp() - B < 1E3 && Math.abs(s[0] - C[0]) > 30 && Math.abs(s[1] - C[1]) < 100) {
                                    D.preventDefault();
                                    c[s[0] > C[0] ? "next" : "prev"]()
                                }
                                s = C = [0, 0]
                            }
                        };
                    k.bind(r.start, function (D) {
                        if (!(D.originalEvent.touches && D.originalEvent.touches.length > 1)) {
                            p = D.originalEvent.touches ? D.originalEvent.touches[0] : D;
                            B = q.timestamp();
                            s = C = [p.pageX, p.pageY];
                            k.bind(r.move, I).one(r.stop, O)
                        }
                    })
                })(c.$("images"));
                this._options.fullscreenDoubleTap && this.$("stage").bind("touchstart", function () {
                    var k, s, C, E, B, p;
                    return function (r) {
                        p = Galleria.utils.timestamp();
                        s = (r.originalEvent.touches ? r.originalEvent.touches[0] : r).pageX;
                        C = (r.originalEvent.touches ? r.originalEvent.touches[0] : r).pageY;
                        if (p - k < 500 && s - E < 20 && C - B < 20) {
                            c.toggleFullscreen();
                            r.preventDefault();
                            c.$("stage").unbind("touchend", arguments.callee)
                        } else {
                            k = p;
                            E = s;
                            B = C
                        }
                    }
                }())
            }
            q.optimizeTouch(this.get("container"));
            return this
        },
        _createThumbnails: function () {
            this.get("total").innerHTML = this.getDataLength();
            var c, i, n, k, s, C = this,
                E = this._options,
                B = function () {
                    var J = C.$("thumbnails").find(".active");
                    if (!J.length) return false;
                    return J.find("img").attr("src")
                }(),
                p = typeof E.thumbnails === "string" ? E.thumbnails.toLowerCase() : null,
                r = function (J) {
                    return w.defaultView && w.defaultView.getComputedStyle ? w.defaultView.getComputedStyle(n.container, null)[J] : s.css(J)
                },
                I = function (J, L, T) {
                    return function () {
                        j(T).append(J);
                        C.trigger({
                            type: Galleria.THUMBNAIL,
                            thumbTarget: J,
                            index: L
                        })
                    }
                },
                O = function (J) {
                    E.pauseOnInteraction && C.pause();
                    var L = j(J.currentTarget).data("index");
                    C.getIndex() !== L && C.show(L);
                    J.preventDefault()
                },
                D = function (J) {
                    J.scale({
                        width: J.data.width,
                        height: J.data.height,
                        crop: E.thumbCrop,
                        margin: E.thumbMargin,
                        canvas: E.useCanvas,
                        complete: function (L) {
                            var T = ["left", "top"],
                                Z, ma;
                            j.each(["Width", "Height"], function (sa, ya) {
                                Z = ya.toLowerCase();
                                if ((E.thumbCrop !== true || E.thumbCrop === Z) && E.thumbFit) {
                                    ma = {};
                                    ma[Z] = L[Z];
                                    j(L.container).css(ma);
                                    ma = {};
                                    ma[T[sa]] = 0;
                                    j(L.image).css(ma)
                                }
                                L["outer" + ya] = j(L.container)["outer" + ya](true)
                            });
                            q.toggleQuality(L.image, E.thumbQuality === true || E.thumbQuality === "auto" && L.original.width < L.width * 3);
                            C.trigger({
                                type: Galleria.THUMBNAIL,
                                thumbTarget: L.image,
                                index: L.data.order
                            })
                        }
                    })
                };
            this._thumbnails = [];
            this.$("thumbnails").empty();
            for (c = 0; this._data[c]; c++) {
                k = this._data[c];
                if (E.thumbnails === true) {
                    n = new Galleria.Picture(c);
                    i = k.thumb || k.image;
                    this.$("thumbnails").append(n.container);
                    s = j(n.container);
                    n.data = {
                        width: q.parseValue(r("width")),
                        height: q.parseValue(r("height")),
                        order: c
                    };
                    E.thumbFit && E.thumbCrop !== true ? s.css({
                        width: 0,
                        height: 0
                    }) : s.css({
                        width: n.data.width,
                        height: n.data.height
                    });
                    n.load(i, D);
                    E.preload === "all" && n.preload(k.image)
                } else if (p === "empty" || p === "numbers") {
                    n = {
                        container: q.create("galleria-image"),
                        image: q.create("img", "span"),
                        ready: true
                    };
                    p === "numbers" && j(n.image).text(c + 1);
                    this.$("thumbnails").append(n.container);
                    t.setTimeout(I(n.image, c, n.container), 50 + c * 20)
                } else n = {
                    container: null,
                    image: null
                };
                j(n.container).add(E.keepSource && E.linkSourceImages ? k.original : null).data("index", c).bind(E.thumbEventType, O);
                B === i && j(n.container).addClass("active");
                this._thumbnails.push(n)
            }
        },
        _run: function () {
            var c = this;
            c._createThumbnails();
            q.wait({
                until: function () {
                    Galleria.OPERA && c.$("stage").css("display", "inline-block");
                    c._stageWidth = c.$("stage").width();
                    c._stageHeight = c.$("stage").height();
                    return c._stageWidth && c._stageHeight > 50
                },
                success: function () {
                    $.push(c);
                    q.show(c.get("counter"));
                    c._options.carousel && c._carousel.bindControls();
                    if (c._options.autoplay) {
                        c.pause();
                        if (typeof c._options.autoplay === "number") c._playtime = c._options.autoplay;
                        c.trigger(Galleria.PLAY);
                        c._playing = true
                    }
                    if (c._firstrun) typeof c._options.show === "number" && c.show(c._options.show);
                    else {
                        c._firstrun = true;
                        if (c._options.clicknext && !Galleria.TOUCH) {
                            j.each(c._data, function (i, n) {
                                delete n.link
                            });
                            c.$("stage").css({
                                cursor: "pointer"
                            }).bind("click", function () {
                                c._options.pauseOnInteraction && c.pause();
                                c.next()
                            })
                        }
                        Galleria.History && Galleria.History.change(function (i) {
                            isNaN(i) ? t.history.go(-1) : c.show(i, void 0, true)
                        });
                        j.each(Galleria.ready.callbacks, function () {
                            this.call(c, c._options)
                        });
                        c.trigger(Galleria.READY);
                        Galleria.theme.init.call(c, c._options);
                        c._options.extend.call(c, c._options);
                        if (/^[0-9]{1,4}$/.test(ca) && Galleria.History) c.show(ca, void 0, true);
                        else c._data[c._options.show] && c.show(c._options.show)
                    }
                },
                error: function () {
                    Galleria.raise("Stage width or height is too small to show the gallery. Traced measures: width:" + c._stageWidth + "px, height: " + c._stageHeight + "px.", true)
                }
            })
        },
        load: function (c, i, n) {
            var k = this;
            this._data = [];
            this._thumbnails = [];
            this.$("thumbnails").empty();
            if (typeof i === "function") {
                n = i;
                i = null
            }
            c = c || this._options.dataSource;
            i = i || this._options.dataSelector;
            n = n || this._options.dataConfig;
            if (/^function Object/.test(c.constructor)) c = [c];
            if (c.constructor === Array) {
                if (this.validate(c)) {
                    this._data = c;
                    this._parseData().trigger(Galleria.DATA)
                } else Galleria.raise("Load failed: JSON Array not valid.");
                return this
            }
            j(c).find(i).each(function (s, C) {
                C = j(C);
                var E = {},
                    B = C.parent(),
                    p = B.attr("href");
                B = B.attr("rel");
                if (p) E.image = E.big = p;
                if (B) E.big = B;
                k._data.push(j.extend({
                    title: C.attr("title") || "",
                    thumb: C.attr("src"),
                    image: C.attr("src"),
                    big: C.attr("src"),
                    description: C.attr("alt") || "",
                    link: C.attr("longdesc"),
                    original: C.get(0)
                }, E, n(C)))
            });
            this.getDataLength() ? this.trigger(Galleria.DATA) : Galleria.raise("Load failed: no data found.");
            return this
        },
        _parseData: function () {
            var c = this;
            j.each(this._data, function (i, n) {
                if ("thumb" in n === false) c._data[i].thumb = n.image;
                if (false in n) c._data[i].big = n.image
            });
            return this
        },
        splice: function () {
            Array.prototype.splice.apply(this._data, q.array(arguments));
            return this._parseData()._createThumbnails()
        },
        push: function () {
            Array.prototype.push.apply(this._data, q.array(arguments));
            return this._parseData()._createThumbnails()
        },
        _getActive: function () {
            return this._controls.getActive()
        },
        validate: function () {
            return true
        },
        bind: function (c, i) {
            c = la(c);
            this.$("container").bind(c, this.proxy(i));
            return this
        },
        unbind: function (c) {
            c = la(c);
            this.$("container").unbind(c);
            return this
        },
        trigger: function (c) {
            c = typeof c === "object" ? j.extend(c, {
                scope: this
            }) : {
                type: la(c),
                scope: this
            };
            this.$("container").trigger(c);
            return this
        },
        addIdleState: function () {
            this._idle.add.apply(this._idle, q.array(arguments));
            return this
        },
        removeIdleState: function () {
            this._idle.remove.apply(this._idle, q.array(arguments));
            return this
        },
        enterIdleMode: function () {
            this._idle.hide();
            return this
        },
        exitIdleMode: function () {
            this._idle.showAll();
            return this
        },
        enterFullscreen: function () {
            this._fullscreen.enter.apply(this, q.array(arguments));
            return this
        },
        exitFullscreen: function () {
            this._fullscreen.exit.apply(this, q.array(arguments));
            return this
        },
        toggleFullscreen: function () {
            this._fullscreen[this.isFullscreen() ? "exit" : "enter"].apply(this, q.array(arguments));
            return this
        },
        bindTooltip: function () {
            this._tooltip.bind.apply(this._tooltip, q.array(arguments));
            return this
        },
        defineTooltip: function () {
            this._tooltip.define.apply(this._tooltip, q.array(arguments));
            return this
        },
        refreshTooltip: function () {
            this._tooltip.show.apply(this._tooltip, q.array(arguments));
            return this
        },
        openLightbox: function () {
            this._lightbox.show.apply(this._lightbox, q.array(arguments));
            return this
        },
        closeLightbox: function () {
            this._lightbox.hide.apply(this._lightbox, q.array(arguments));
            return this
        },
        getActiveImage: function () {
            return this._getActive().image || void 0
        },
        getActiveThumb: function () {
            return this._thumbnails[this._active].image || void 0
        },
        getMousePosition: function (c) {
            return {
                x: c.pageX - this.$("container").offset().left,
                y: c.pageY - this.$("container").offset().top
            }
        },
        addPan: function (c) {
            if (this._options.imageCrop !== false) {
                c = j(c || this.getActiveImage());
                var i = this,
                    n = c.width() / 2,
                    k = c.height() / 2,
                    s = parseInt(c.css("left"), 10),
                    C = parseInt(c.css("top"), 10),
                    E = s || 0,
                    B = C || 0,
                    p = 0,
                    r = 0,
                    I = false,
                    O = q.timestamp(),
                    D = 0,
                    J = 0,
                    L = function (Z, ma, sa) {
                        if (Z > 0) {
                            J = Math.round(Math.max(Z * -1, Math.min(0, ma)));
                            if (D !== J) {
                                D = J;
                                if (X === 8) c.parent()["scroll" + sa](J * -1);
                                else {
                                    Z = {};
                                    Z[sa.toLowerCase()] = J;
                                    c.css(Z)
                                }
                            }
                        }
                    },
                    T = function (Z) {
                        if (!(q.timestamp() - O < 50)) {
                            I = true;
                            n = i.getMousePosition(Z).x;
                            k = i.getMousePosition(Z).y
                        }
                    };
                if (X === 8) {
                    c.parent().scrollTop(B * -1).scrollLeft(E * -1);
                    c.css({
                        top: 0,
                        left: 0
                    })
                }
                this.$("stage").unbind("mousemove", T).bind("mousemove", T);
                q.addTimer("pan", function () {
                    if (I) {
                        p = c.width() - i._stageWidth;
                        r = c.height() - i._stageHeight;
                        s = n / i._stageWidth * p * -1;
                        C = k / i._stageHeight * r * -1;
                        E += (s - E) / i._options.imagePanSmoothness;
                        B += (C - B) / i._options.imagePanSmoothness;
                        L(r, B, "Top");
                        L(p, E, "Left")
                    }
                }, 50, true);
                return this
            }
        },
        proxy: function (c, i) {
            if (typeof c !== "function") return function () {};
            i = i || this;
            return function () {
                return c.apply(i, q.array(arguments))
            }
        },
        removePan: function () {
            this.$("stage").unbind("mousemove");
            q.clearTimer("pan");
            return this
        },
        addElement: function () {
            var c = this._dom;
            j.each(q.array(arguments), function (i, n) {
                c[n] = q.create("galleria-" + n)
            });
            return this
        },
        attachKeyboard: function () {
            this._keyboard.attach.apply(this._keyboard, q.array(arguments));
            return this
        },
        detachKeyboard: function () {
            this._keyboard.detach.apply(this._keyboard, q.array(arguments));
            return this
        },
        appendChild: function (c, i) {
            this.$(c).append(this.get(i) || i);
            return this
        },
        prependChild: function (c, i) {
            this.$(c).prepend(this.get(i) || i);
            return this
        },
        remove: function () {
            this.$(q.array(arguments).join(",")).remove();
            return this
        },
        append: function (c) {
            var i, n;
            for (i in c) if (c.hasOwnProperty(i)) if (c[i].constructor === Array) for (n = 0; c[i][n]; n++) this.appendChild(i, c[i][n]);
            else this.appendChild(i, c[i]);
            return this
        },
        _scaleImage: function (c, i) {
            c = c || this._controls.getActive();
            var n, k = function (s) {
                    j(s.container).children(":first").css({
                        top: Math.max(0, q.parseValue(s.image.style.top)),
                        left: Math.max(0, q.parseValue(s.image.style.left)),
                        width: q.parseValue(s.image.width),
                        height: q.parseValue(s.image.height)
                    })
                };
            i = j.extend({
                width: this._stageWidth,
                height: this._stageHeight,
                crop: this._options.imageCrop,
                max: this._options.maxScaleRatio,
                min: this._options.minScaleRatio,
                margin: this._options.imageMargin,
                position: this._options.imagePosition
            }, i);
            if (this._options.layerFollow && this._options.imageCrop !== true) if (typeof i.complete == "function") {
                n = i.complete;
                i.complete = function () {
                    n.call(c, c);
                    k(c)
                }
            } else i.complete = k;
            else j(c.container).children(":first").css({
                top: 0,
                left: 0
            });
            c.scale(i);
            return this
        },
        updateCarousel: function () {
            this._carousel.update();
            return this
        },
        rescale: function (c, i, n) {
            var k = this;
            if (typeof c === "function") {
                n = c;
                c = void 0
            }
            var s = function () {
                    k._stageWidth = c || k.$("stage").width();
                    k._stageHeight = i || k.$("stage").height();
                    k._scaleImage();
                    k._options.carousel && k.updateCarousel();
                    k.trigger(Galleria.RESCALE);
                    typeof n === "function" && n.call(k)
                };
            Galleria.WEBKIT && !c && !i ? q.addTimer("scale", s, 10) : s.call(k);
            return this
        },
        refreshImage: function () {
            this._scaleImage();
            this._options.imagePan && this.addPan();
            return this
        },
        show: function (c, i, n) {
            if (!(c === false || !this._options.queue && this._queue.stalled)) {
                c = Math.max(0, Math.min(parseInt(c, 10), this.getDataLength() - 1));
                i = typeof i !== "undefined" ? !! i : c < this.getIndex();
                if (!n && Galleria.History) Galleria.History.set(c.toString());
                else {
                    this._active = c;
                    Array.prototype.push.call(this._queue, {
                        index: c,
                        rewind: i
                    });
                    this._queue.stalled || this._show();
                    return this
                }
            }
        },
        _show: function () {
            var c = this,
                i = this._queue[0],
                n = this.getData(i.index);
            if (n) {
                var k = this.isFullscreen() && "big" in n ? n.big : n.image,
                    s = this._controls.getActive(),
                    C = this._controls.getNext(),
                    E = C.isCached(k),
                    B = this._thumbnails[i.index],
                    p = function (L, T, Z, ma, sa) {
                        return function () {
                            c._queue.stalled = false;
                            q.toggleQuality(T.image, c._options.imageQuality);
                            c._layers[c._controls.active].innerHTML = "";
                            j(Z.container).css({
                                zIndex: 0,
                                opacity: 0
                            }).show();
                            j(T.container).css({
                                zIndex: 1
                            }).show();
                            c._controls.swap();
                            c._options.imagePan && c.addPan(T.image);
                            if (L.link || c._options.lightbox) j(T.image).css({
                                cursor: "pointer"
                            }).bind("mouseup", function () {
                                if (L.link) if (c._options.popupLinks) t.open(L.link, "_blank");
                                else t.location.href = L.link;
                                else c.openLightbox()
                            });
                            Array.prototype.shift.call(c._queue);
                            c._queue.length && c._show();
                            c._playCheck();
                            c.trigger({
                                type: Galleria.IMAGE,
                                index: ma.index,
                                imageTarget: T.image,
                                thumbTarget: sa.image
                            })
                        }
                    }(n, C, s, i, B);
                this._options.carousel && this._options.carouselFollow && this._carousel.follow(i.index);
                if (this._options.preload) {
                    var r, I, O = this.getNext(),
                        D;
                    try {
                        for (I = this._options.preload; I > 0; I--) {
                            r = new Galleria.Picture;
                            D = c.getData(O);
                            r.preload(this.isFullscreen() && "big" in D ? D.big : D.image);
                            O = c.getNext(O)
                        }
                    } catch (J) {}
                }
                q.show(C.container);
                j(c._thumbnails[i.index].container).addClass("active").siblings(".active").removeClass("active");
                c.trigger({
                    type: Galleria.LOADSTART,
                    cached: E,
                    index: i.index,
                    rewind: i.rewind,
                    imageTarget: C.image,
                    thumbTarget: B.image
                });
                C.load(k, function (L) {
                    j(c._layers[1 - c._controls.active]).html(n.layer || "").hide();
                    c._scaleImage(L, {
                        complete: function (T) {
                            "image" in s && q.toggleQuality(s.image, false);
                            q.toggleQuality(T.image, false);
                            c._queue.stalled = true;
                            c.removePan();
                            c.setInfo(i.index);
                            c.setCounter(i.index);
                            n.layer && j(c._layers[1 - c._controls.active]).show();
                            c.trigger({
                                type: Galleria.LOADFINISH,
                                cached: E,
                                index: i.index,
                                rewind: i.rewind,
                                imageTarget: T.image,
                                thumbTarget: c._thumbnails[i.index].image
                            });
                            var Z = c._options.transition;
                            j.each({
                                initial: s.image === null,
                                touch: Galleria.TOUCH,
                                fullscreen: c.isFullscreen()
                            }, function (ma, sa) {
                                if (sa && c._options[ma + "Transition"] !== void 0) {
                                    Z = c._options[ma + "Transition"];
                                    return false
                                }
                            });
                            Z in ra === false ? p() : ra[Z].call(c, {
                                prev: s.container,
                                next: T.container,
                                rewind: i.rewind,
                                speed: c._options.transitionSpeed || 400
                            }, p)
                        }
                    })
                })
            }
        },
        getNext: function (c) {
            c = typeof c === "number" ? c : this.getIndex();
            return c === this.getDataLength() - 1 ? 0 : c + 1
        },
        getPrev: function (c) {
            c = typeof c === "number" ? c : this.getIndex();
            return c === 0 ? this.getDataLength() - 1 : c - 1
        },
        next: function () {
            this.getDataLength() > 1 && this.show(this.getNext(), false);
            return this
        },
        prev: function () {
            this.getDataLength() > 1 && this.show(this.getPrev(), true);
            return this
        },
        get: function (c) {
            return c in this._dom ? this._dom[c] : null
        },
        getData: function (c) {
            return c in this._data ? this._data[c] : this._data[this._active]
        },
        getDataLength: function () {
            return this._data.length
        },
        getIndex: function () {
            return typeof this._active === "number" ? this._active : false
        },
        getStageHeight: function () {
            return this._stageHeight
        },
        getStageWidth: function () {
            return this._stageWidth
        },
        getOptions: function (c) {
            return typeof c === "undefined" ? this._options : this._options[c]
        },
        setOptions: function (c, i) {
            if (typeof c === "object") j.extend(this._options, c);
            else this._options[c] = i;
            return this
        },
        play: function (c) {
            this._playing = true;
            this._playtime = c || this._playtime;
            this._playCheck();
            this.trigger(Galleria.PLAY);
            return this
        },
        pause: function () {
            this._playing = false;
            this.trigger(Galleria.PAUSE);
            return this
        },
        playToggle: function (c) {
            return this._playing ? this.pause() : this.play(c)
        },
        isPlaying: function () {
            return this._playing
        },
        isFullscreen: function () {
            return this._fullscreen.active
        },
        _playCheck: function () {
            var c = this,
                i = 0,
                n = q.timestamp(),
                k = "play" + this._id;
            if (this._playing) {
                q.clearTimer(k);
                var s = function () {
                        i = q.timestamp() - n;
                        if (i >= c._playtime && c._playing) {
                            q.clearTimer(k);
                            c.next()
                        } else if (c._playing) {
                            c.trigger({
                                type: Galleria.PROGRESS,
                                percent: Math.ceil(i / c._playtime * 100),
                                seconds: Math.floor(i / 1E3),
                                milliseconds: i
                            });
                            q.addTimer(k, s, 20)
                        }
                    };
                q.addTimer(k, s, 20)
            }
        },
        setPlaytime: function (c) {
            this._playtime = c;
            return this
        },
        setIndex: function (c) {
            this._active = c;
            return this
        },
        setCounter: function (c) {
            if (typeof c === "number") c++;
            else if (typeof c === "undefined") c = this.getIndex() + 1;
            this.get("current").innerHTML = c;
            if (X) {
                c = this.$("counter");
                var i = c.css("opacity");
                parseInt(i, 10) === 1 ? q.removeAlpha(c[0]) : this.$("counter").css("opacity", i)
            }
            return this
        },
        setInfo: function (c) {
            var i = this,
                n = this.getData(c);
            j.each(["title", "description"], function (k, s) {
                var C = i.$("info-" + s);
                n[s] ? C[n[s].length ? "show" : "hide"]().html(n[s]) : C.empty().hide()
            });
            return this
        },
        hasInfo: function (c) {
            var i = "title description".split(" "),
                n;
            for (n = 0; i[n]; n++) if (this.getData(c)[i[n]]) return true;
            return false
        },
        jQuery: function (c) {
            var i = this,
                n = [];
            j.each(c.split(","), function (s, C) {
                C = j.trim(C);
                i.get(C) && n.push(C)
            });
            var k = j(i.get(n.shift()));
            j.each(n, function (s, C) {
                k = k.add(i.get(C))
            });
            return k
        },
        $: function () {
            return this.jQuery.apply(this, q.array(arguments))
        }
    };
    j.each(ia, function (c, i) {
        var n = /_/.test(i) ? i.replace(/_/g, "") : i;
        Galleria[i.toUpperCase()] = "galleria." + n
    });
    j.extend(Galleria, {
        IE9: X === 9,
        IE8: X === 8,
        IE7: X === 7,
        IE6: X === 6,
        IE: X,
        WEBKIT: /webkit/.test(aa),
        SAFARI: /safari/.test(aa),
        CHROME: /chrome/.test(aa),
        QUIRK: X && w.compatMode && w.compatMode === "BackCompat",
        MAC: /mac/.test(navigator.platform.toLowerCase()),
        OPERA: !! t.opera,
        IPHONE: /iphone/.test(aa),
        IPAD: /ipad/.test(aa),
        ANDROID: /android/.test(aa),
        TOUCH: "ontouchstart" in w
    });
    Galleria.addTheme = function (c) {
        c.name || Galleria.raise("No theme name specified");
        c.defaults = typeof c.defaults !== "object" ? {} : ja(c.defaults);
        var i = false,
            n;
        if (typeof c.css === "string") {
            j("link").each(function (k, s) {
                n = RegExp(c.css);
                if (n.test(s.href)) {
                    i = true;
                    ka(c);
                    return false
                }
            });
            i || j("script").each(function (k, s) {
                n = RegExp("galleria\\." + c.name.toLowerCase() + "\\.");
                if (n.test(s.src)) {
                    i = s.src.replace(/[^\/]*$/, "") + c.css;
                    q.addTimer("css", function () {
                        q.loadCSS(i, "galleria-theme", function () {
                            ka(c)
                        })
                    }, 1)
                }
            });
            i || Galleria.raise("No theme CSS loaded")
        } else ka(c);
        return c
    };
    Galleria.loadTheme = function (c, i) {
        var n = $.length,
            k = t.setTimeout(function () {
                Galleria.raise("Theme at " + c + " could not load, check theme path.", true)
            }, 5E3);
        Galleria.theme = void 0;
        q.loadScript(c, function () {
            t.clearTimeout(k);
            if (n) {
                var s = [];
                j.each(Galleria.get(), function (C, E) {
                    var B = j.extend(E._original.options, {
                        data_source: E._data
                    }, i);
                    E.$("container").remove();
                    var p = new Galleria;
                    p._id = E._id;
                    p.init(E._original.target, B);
                    s.push(p)
                });
                $ = s
            }
        })
    };
    Galleria.get = function (c) {
        if (ea[c]) return ea[c];
        else if (typeof c !== "number") return ea;
        else Galleria.raise("Gallery index " + c + " not found")
    };
    Galleria.addTransition = function (c, i) {
        ra[c] = i
    };
    Galleria.utils = q;
    Galleria.log = function () {
        return "console" in t && "log" in t.console ? t.console.log : function () {
            t.alert(q.array(arguments).join(", "))
        }
    }();
    Galleria.ready = function (c) {
        j.each($, function (i, n) {
            c.call(n, n._options)
        });
        Galleria.ready.callbacks.push(c)
    };
    Galleria.ready.callbacks = [];
    Galleria.raise = function (c, i) {
        var n = i ? "Fatal error" : "Error",
            k = function (s) {
                var C = '<div style="padding:4px;margin:0 0 2px;background:#' + (i ? "811" : "222") + '";>' + (i ? "<strong>" + n + ": </strong>" : "") + s + "</div>";
                j.each(ea, function () {
                    var E = this.$("errors"),
                        B = this.$("target");
                    if (!E.length) {
                        B.css("position", "relative");
                        E = this.addElement("errors").appendChild("target", "errors").$("errors").css({
                            color: "#fff",
                            position: "absolute",
                            top: 0,
                            left: 0,
                            zIndex: 1E5
                        })
                    }
                    E.append(C)
                })
            };
        if (N) {
            k(c);
            if (i) throw Error(n + ": " + c);
        } else if (i) if (!A) {
            A = true;
            i = false;
            k("Image gallery could not load.")
        }
    };
    Galleria.version = 1.25;
    Galleria.requires = function (c, i) {
        Galleria.version < c && Galleria.raise(i || "You need to upgrade Galleria to version " + c + " to use one or more components.", true)
    };
    Galleria.Picture = function (c) {
        this.id = c || null;
        this.image = null;
        this.container = q.create("galleria-image");
        j(this.container).css({
            overflow: "hidden",
            position: "relative"
        });
        this.original = {
            width: 0,
            height: 0
        };
        this.ready = false;
        this.tid = null
    };
    Galleria.Picture.prototype = {
        cache: {},
        show: function () {
            q.show(this.image)
        },
        hide: function () {
            q.moveOut(this.image)
        },
        clear: function () {
            this.image = null
        },
        isCached: function (c) {
            return !!this.cache[c]
        },
        preload: function (c) {
            j(new Image).load(function (i, n) {
                return function () {
                    n[i] = i
                }
            }(c, this.cache)).attr("src", c)
        },
        load: function (c, i) {
            this.tid = t.setTimeout(function (E) {
                return function () {
                    Galleria.raise("Image not loaded in " + Math.round(W / 1E3) + " seconds: " + E)
                }
            }(c), W);
            this.image = new Image;
            var n = false,
                k = j(this.container),
                s = j(this.image),
                C = function (E, B, p) {
                    return function () {
                        var r = function () {
                                E.original = {
                                    height: this.height,
                                    width: this.width
                                };
                                E.cache[p] = p;
                                t.clearTimeout(E.tid);
                                typeof B == "function" && t.setTimeout(function () {
                                    B.call(E, E)
                                }, 1)
                            };
                        !this.width || !this.height ? t.setTimeout(function (I) {
                            return function () {
                                I.width && I.height ? r.call(I) : Galleria.raise("Could not extract width/height from image: " + I.src + ". Traced measures: width:" + I.width + "px, height: " + I.height + "px.")
                            }
                        }(this), 2) : r.call(this)
                    }
                }(this, i, c);
            k.find("img").remove();
            s.css("display", "block").appendTo(this.container);
            q.hide(this.image);
            if (this.cache[c]) {
                this.image.src = c;
                C.call(this.image);
                return this.container
            }
            j(this.image).load(C).error(function () {
                if (n) da ? j(this).attr("src", da) : Galleria.raise("Image not found: " + c);
                else {
                    n = true;
                    t.setTimeout(function (E, B) {
                        return function () {
                            E.attr("src", B + "?" + q.timestamp())
                        }
                    }(j(this), c), 50)
                }
            }).attr("src", c);
            return this.container
        },
        scale: function (c) {
            c = j.extend({
                width: 0,
                height: 0,
                min: void 0,
                max: void 0,
                margin: 0,
                complete: function () {},
                position: "center",
                crop: false,
                canvas: false
            }, c);
            if (!this.image) return this.container;
            var i, n, k = this,
                s = j(k.container),
                C;
            q.wait({
                until: function () {
                    i = c.width || s.width() || q.parseValue(s.css("width"));
                    n = c.height || s.height() || q.parseValue(s.css("height"));
                    return i && n
                },
                success: function () {
                    var E = (i - c.margin * 2) / k.original.width,
                        B = (n - c.margin * 2) / k.original.height,
                        p = {
                            "true": Math.max(E, B),
                            width: E,
                            height: B,
                            "false": Math.min(E, B)
                        }[c.crop.toString()];
                    E = "";
                    if (c.max) p = Math.min(c.max, p);
                    if (c.min) p = Math.max(c.min, p);
                    j.each(["width", "height"], function (D, J) {
                        j(k.image)[J](k[J] = k.image[J] = Math.round(k.original[J] * p))
                    });
                    j(k.container).width(i).height(n);
                    if (c.canvas && fa) {
                        fa.elem.width = k.width;
                        fa.elem.height = k.height;
                        E = k.image.src + ":" + k.width + "x" + k.height;
                        k.image.src = fa.cache[E] ||
                        function (D) {
                            fa.context.drawImage(k.image, 0, 0, k.original.width * p, k.original.height * p);
                            try {
                                C = fa.elem.toDataURL();
                                fa.length += C.length;
                                return fa.cache[D] = C
                            } catch (J) {
                                return k.image.src
                            }
                        }(E)
                    }
                    var r = {},
                        I = {};
                    E = function (D, J, L) {
                        var T = 0;
                        if (/\%/.test(D)) {
                            D = parseInt(D, 10) / 100;
                            J = k.image[J] || j(k.image)[J]();
                            T = Math.ceil(J * -1 * D + L * D)
                        } else T = q.parseValue(D);
                        return T
                    };
                    var O = {
                        top: {
                            top: 0
                        },
                        left: {
                            left: 0
                        },
                        right: {
                            left: "100%"
                        },
                        bottom: {
                            top: "100%"
                        }
                    };
                    j.each(c.position.toLowerCase().split(" "), function (D, J) {
                        if (J === "center") J = "50%";
                        r[D ? "top" : "left"] = J
                    });
                    j.each(r, function (D, J) {
                        O.hasOwnProperty(J) && j.extend(I, O[J])
                    });
                    r = r.top ? j.extend(r, I) : I;
                    r = j.extend({
                        top: "50%",
                        left: "50%"
                    }, r);
                    j(k.image).css({
                        position: "absolute",
                        top: E(r.top, "height", n),
                        left: E(r.left, "width", i)
                    });
                    k.show();
                    k.ready = true;
                    c.complete.call(k, k)
                },
                error: function () {
                    Galleria.raise("Could not scale image: " + k.image.src)
                },
                timeout: 1E3
            });
            return this
        }
    };
    j.extend(j.easing, {
        galleria: function (c, i, n, k, s) {
            if ((i /= s / 2) < 1) return k / 2 * i * i * i + n;
            return k / 2 * ((i -= 2) * i * i + 2) + n
        },
        galleriaIn: function (c, i, n, k, s) {
            return k * (i /= s) * i + n
        },
        galleriaOut: function (c, i, n, k, s) {
            return -k * (i /= s) * (i - 2) + n
        }
    });
    j.fn.galleria = function (c) {
        return this.each(function () {
            j(this).data("galleria", (new Galleria).init(this, c))
        })
    }
})(jQuery);
(function (j) {
    var t = {
        prototyping: function () {
            j('img[src="#"]').attr("src", "/media/i/placeholder.png").addClass("placeholder").each(function () {
                this.width -= 2;
                this.height -= 2
            });
            j('a[href="#"]').click(function (w) {
                w.preventDefault()
            })
        },
        BROWSER: {
            IE: function () {
                for (var w = 3, R = document.createElement("div"); R.innerHTML = "<\!--[if gt IE " + ++w + "]><i></i><![endif]--\>", R.getElementsByTagName("i")[0];);
                return w > 4 ? w : void 0
            }()
        }
    };
    window.Aino = t;
    window.STATIC_URL = "/static/";
    window.THEMES_URL = STATIC_URL + "themes/"
})(jQuery);
var G_DEMO_IMAGES = [{
    title: "Manzanar birds on wire",
    thumb: STATIC_URL + "i/sample/00_m.jpg",
    image: STATIC_URL + "i/sample/00.jpg",
    description: "Birds on wire, evening, Manzanar Relocation Center / photograph by Ansel Adams."
}, {
    title: "Antarctic Sunset",
    thumb: STATIC_URL + "i/sample/12_m.jpg",
    image: STATIC_URL + "i/sample/12.jpg",
    description: "An Antarctic Sunset, photo taken by Calee Allen on April 6th, 2008."
}, {
    title: "Locomotives Roundhouse",
    thumb: STATIC_URL + "i/sample/01_m.jpg",
    image: STATIC_URL + "i/sample/01.jpg",
    description: "Steam locomotives of the Chicago & North Western Railway."
}, {
    title: "Braunwald Alps",
    thumb: STATIC_URL + "i/sample/11_m.jpg",
    image: STATIC_URL + "i/sample/11.jpg",
    description: "View from Braunwald, Switzerland."
}, {
    title: "Icebergs in the High Arctic",
    thumb: STATIC_URL + "i/sample/02_m.jpg",
    image: STATIC_URL + "i/sample/02.jpg",
    description: "\u201dThe debris loading isn't particularly extensive, but the color is usual.\u201d"
}, {
    title: "Ara\u00f1a",
    thumb: STATIC_URL + "i/sample/03_m.jpg",
    image: STATIC_URL + "i/sample/03.jpg",
    description: "Xysticus cristatus, A Estrada, Galicia, Spain"
}, {
    title: "Museo storia naturale",
    thumb: STATIC_URL + "i/sample/04_m.jpg",
    image: STATIC_URL + "i/sample/04.jpg"
}, {
    title: "Grj\u00f3tagj\u00e1 caves in summer 2009",
    thumb: STATIC_URL + "i/sample/05_m.jpg",
    image: STATIC_URL + "i/sample/05.jpg"
}, {
    title: "Thermes",
    thumb: STATIC_URL + "i/sample/06_m.jpg",
    image: STATIC_URL + "i/sample/06.jpg",
    description: "Xanthi hot-spa springs, Xanthi Prefecture, Greece"
}, {
    title: "Polish Army Ko\u0142obrzeg",
    thumb: STATIC_URL + "i/sample/07_m.jpg",
    image: STATIC_URL + "i/sample/07.jpg",
    description: "A display of the Polish Army. Both the soldier, and the vehicle belong to the 7th Pomeranian Coastal Defence Brigade, a part of the Szczecin-based 12th Mechanized Division \u201dBoles\u0142aw Krzywousty\u201d"
}, {
    title: "Zlatograd Bulgaria",
    thumb: STATIC_URL + "i/sample/08_m.jpg",
    image: STATIC_URL + "i/sample/08.jpg"
}, {
    title: "09-28-2001 in New York City",
    thumb: STATIC_URL + "i/sample/09_m.jpg",
    image: STATIC_URL + "i/sample/09.jpg",
    description: "New York, NY, September 28, 2001 -- Debris on surrounding roofs at the site of the World Trade Center. Photo by Andrea Booher/ FEMA News Photo"
}, {
    thumb: STATIC_URL + "i/sample/10_m.jpg",
    image: STATIC_URL + "i/sample/10.jpg"
}];
(function (j, t, w) {
    var R = [],
        M = j.G = {
            init: function (N) {
                this.views._global.call(this);
                for (var W = document.body.className.split(" "), da = 0; da < W.length; da++) W[da] in this.views && this.views[W[da]].call(this);
                typeof N === "number" && M.run(N)
            },
            make: function (N, W) {
                R[N] = W
            },
            run: function (N, W, da) {
                W = W || "#demo";
                da = da ||
                function () {};
                w.theme = R[N];
                w.utils.loadCSS(THEMES_URL + N + "/" + N + ".css", "galleria-theme", function () {
                    t(W).galleria({
                        data_source: G_DEMO_IMAGES,
                        extend: function (aa) {
                            da.call(this, aa)
                        }
                    })
                })
            },
            trackDownload: function (N) {
                t(N).each(function () {
                    t(this).click(function () {
                        var W = this.href.split("/");
                        _gaq.push(["_trackEvent", "Stats", "Download", W.length > 1 ? W[W.length - 1] : "unknown"])
                    })
                })
            },
            views: {
                _global: function () {
                    t("a:path").addClass("active");
                    t(".secondary .box li:last").addClass("last");
                    M.trackDownload("a.dl, a.download")
                },
                home: function () {
                    M.run(1, "#demo", function () {
                        Galleria.TOUCH && this.setOptions("transition", "fadeslide")
                    })
                },
                tp: function () {
                    var N = t("#themes");
                    t("#theme-switcher").click(function () {
                        N.toggle()
                    }).trigger("click")
                },
                docs: function () {},
                "theme-purchase": function () {
                    t("input[type=image]").each(function () {
                        var N = t("<a>", {
                            href: "",
                            html: "Buy Now <span>$" + t(this).siblings('[name|="amount"]').val() + "</span>",
                            click: function (W) {
                                W.preventDefault();
                                W = t(this).closest("form");
                                W.length && W.submit()
                            }
                        });
                        t(this).replaceWith(N);
                        N.wrap('<div class="btn" />')
                    })
                }
            }
        };
    j.G = M
})(window, jQuery, Galleria);
(function (j) {
    G.make(0, {
        defaults: {
            transition: "pulse",
            thumbCrop: true,
            imageCrop: true,
            carousel: false,
            imagePan: true,
            clicknext: true,
            _locale: {
                enter_fullscreen: "Enter fullscreen",
                exit_fullscreen: "Exit fullscreen",
                click_to_close: "Click to close",
                show_thumbnails: "Show thumbnails",
                show_info: "Show info"
            }
        },
        init: function (t) {
            var w = this,
                R = false,
                M;
            M = 0;
            var N, W, da;
            this.addElement("desc", "dots", "thumbs", "fs", "more");
            this.append({
                container: ["desc", "dots", "thumbs", "fs", "info-description", "more"]
            });
            da = this.$("thumbnails-container").hide().css("visibility", "visible");
            var aa = function (ca) {
                    return j("<div>").click(function (X) {
                        return function (P) {
                            P.preventDefault();
                            w.show(X)
                        }
                    }(ca))
                };
            for (M = 0; M < this.getDataLength(); M++) this.$("dots").append(aa(M));
            M = this.$("dots").outerWidth();
            N = this.$("desc").hide().hover(function () {
                j(this).addClass("hover")
            }, function () {
                j(this).removeClass("hover")
            }).click(function () {
                j(this).hide()
            });
            W = this.$("loader");
            this.bindTooltip({
                fs: function () {
                    return R ? t._locale.exit_fullscreen : t._locale.enter_fullscreen
                },
                desc: t._locale.click_to_close,
                more: t._locale.show_info,
                thumbs: t._locale.show_thumbnails
            });
            this.bind("loadstart", function (ca) {
                ca.cached || this.$("loader").show().fadeTo(200, 0.4)
            });
            this.bind("loadfinish", function (ca) {
                var X = w.getData().title,
                    P = w.getData().description;
                N.hide();
                W.fadeOut(200);
                this.$("dots").children("div").eq(ca.index).addClass("active").siblings(".active").removeClass("active");
                if (X && P) {
                    N.empty().append("<strong>" + X + "</strong>", "<p>" + P + "</p>").css({
                        marginTop: this.$("desc").outerHeight() / -2
                    });
                    this.$("more").show()
                } else this.$("more").hide();
                da.fadeOut(t.fadeSpeed);
                w.$("thumbs").removeClass("active")
            });
            this.bind("thumbnail", function (ca) {
                j(ca.thumbTarget).hover(function () {
                    w.setInfo(ca.index)
                }, function () {
                    w.setInfo()
                })
            });
            this.$("fs").click(function () {
                w.toggleFullscreen();
                R = !R
            });
            this.$("thumbs").click(function (ca) {
                ca.preventDefault();
                da.toggle();
                j(this).toggleClass("active");
                N.hide()
            });
            this.$("more").click(function () {
                N.toggle()
            });
            this.$("info").css({
                width: this.getStageWidth() - M - 30,
                left: M + 10
            })
        }
    });
    G.make(1, {
        defaults: {
            transition: "pulse",
            transitionSpeed: 500,
            imageCrop: true,
            thumbCrop: true,
            carousel: false,
            _locale: {
                show_thumbnails: "Show thumbnails",
                hide_thumbnails: "Hide thumbnails",
                play: "Play slideshow",
                pause: "Pause slideshow",
                enter_fullscreen: "Enter fullscreen",
                exit_fullscreen: "Exit fullscreen",
                popout_image: "Popout image",
                showing_image: "Showing image %s of %s"
            },
            _showFullscreen: true,
            _showPopout: true,
            _showProgress: true,
            _showTooltip: true
        },
        init: function (t) {
            this.addElement("bar", "fullscreen", "play", "popout", "thumblink", "s1", "s2", "s3", "s4", "progress");
            this.append({
                stage: "progress",
                container: ["bar", "tooltip"],
                bar: ["fullscreen", "play", "popout", "thumblink", "info", "s1", "s2", "s3", "s4"]
            });
            this.prependChild("info", "counter");
            var w = this,
                R = this.$("thumbnails-container"),
                M = this.$("thumblink"),
                N = this.$("fullscreen"),
                W = this.$("play"),
                da = this.$("popout"),
                aa = this.$("bar"),
                ca = this.$("progress"),
                X = t.transition,
                P = t._locale,
                ia = false,
                ja = false,
                la = !! t.autoplay,
                d = false,
                $ = function () {
                    R.height(w.getStageHeight()).width(w.getStageWidth()).css("top", ia ? 0 : w.getStageHeight() + 30)
                },
                ea = function () {
                    if (ia && d) w.play();
                    else {
                        d = la;
                        w.pause()
                    }
                    Galleria.utils.animate(R, {
                        top: ia ? w.getStageHeight() + 30 : 0
                    }, {
                        easing: "galleria",
                        duration: 400,
                        complete: function () {
                            w.defineTooltip("thumblink", ia ? P.show_thumbnails : P.hide_thumbnails);
                            M[ia ? "removeClass" : "addClass"]("open");
                            ia = !ia
                        }
                    })
                };
            $();
            t._showTooltip && w.bindTooltip({
                thumblink: P.show_thumbnails,
                fullscreen: P.enter_fullscreen,
                play: P.play,
                popout: P.popout_image,
                caption: function () {
                    var A = w.getData(),
                        fa = "";
                    if (A) {
                        if (A.title && A.title.length) fa += "<strong>" + A.title + "</strong>";
                        if (A.description && A.description.length) fa += "<br>" + A.description
                    }
                    return fa
                },
                counter: function () {
                    return P.showing_image.replace(/\%s/, w.getIndex() + 1).replace(/\%s/, w.getDataLength())
                }
            });
            t.showInfo || this.$("info").hide();
            this.bind("play", function () {
                la = true;
                W.addClass("playing")
            });
            this.bind("pause", function () {
                la = false;
                W.removeClass("playing");
                ca.width(0)
            });
            t._showProgress && this.bind("progress", function (A) {
                ca.width(A.percent / 100 * this.getStageWidth())
            });
            this.bind("loadstart", function (A) {
                A.cached || this.$("loader").show()
            });
            this.bind("loadfinish", function () {
                ca.width(0);
                this.$("loader").hide();
                this.refreshTooltip("counter", "caption")
            });
            this.bind("thumbnail", function (A) {
                j(A.thumbTarget).hover(function () {
                    w.setInfo(A.thumbOrder);
                    w.setCounter(A.thumbOrder)
                }, function () {
                    w.setInfo();
                    w.setCounter()
                }).click(function () {
                    ea()
                })
            });
            this.bind("fullscreen_enter", function () {
                ja = true;
                w.setOptions("transition", false);
                N.addClass("open");
                aa.css("bottom", 0);
                this.defineTooltip("fullscreen", P.exit_fullscreen);
                Galleria.TOUCH || this.addIdleState(aa, {
                    bottom: -31
                })
            });
            this.bind("fullscreen_exit", function () {
                ja = false;
                Galleria.utils.clearTimer("bar");
                w.setOptions("transition", X);
                N.removeClass("open");
                aa.css("bottom", 0);
                this.defineTooltip("fullscreen", P.enter_fullscreen);
                Galleria.TOUCH || this.removeIdleState(aa, {
                    bottom: -31
                })
            });
            this.bind("rescale", $);
            if (!Galleria.TOUCH) {
                this.addIdleState(this.get("image-nav-left"), {
                    left: -36
                });
                this.addIdleState(this.get("image-nav-right"), {
                    right: -36
                })
            }
            M.click(ea);
            if (t._showPopout) da.click(function (A) {
                w.openLightbox();
                A.preventDefault()
            });
            else {
                da.remove();
                if (t._showFullscreen) {
                    this.$("s4").remove();
                    this.$("info").css("right", 40);
                    N.css("right", 0)
                }
            }
            W.click(function () {
                w.defineTooltip("play", la ? P.play : P.pause);
                if (la) w.pause();
                else {
                    ia && M.click();
                    w.play()
                }
            });
            if (t._showFullscreen) N.click(function () {
                ja ? w.exitFullscreen() : w.enterFullscreen()
            });
            else {
                N.remove();
                if (t._show_popout) {
                    this.$("s4").remove();
                    this.$("info").css("right", 40);
                    da.css("right", 0)
                }
            }
            if (!t._showFullscreen && !t._showPopout) {
                this.$("s3,s4").remove();
                this.$("info").css("right", 10)
            }
            t.autoplay && this.trigger("play")
        }
    });
    G.make(2, {
        defaults: {
            transition: "none",
            imageCrop: true,
            thumbCrop: "height",
            easing: "galleriaOut",
            _hideDock: Galleria.TOUCH ? false : true,
            _closeOnClick: false
        },
        init: function (t) {
            this.addElement("thumbnails-tab");
            this.appendChild("thumbnails-container", "thumbnails-tab");
            var w = this.$("thumbnails-tab"),
                R = this.$("loader"),
                M = this.$("thumbnails-container"),
                N = this.$("thumbnails-list"),
                W = this.$("info-text"),
                da = this.$("info"),
                aa = !t._hideDock,
                ca = 0;
            if (Galleria.IE) {
                this.addElement("iefix");
                this.appendChild("container", "iefix");
                this.$("iefix").css({
                    zIndex: 3,
                    position: "absolute",
                    backgroundColor: "#000",
                    opacity: 0.4,
                    top: 0
                })
            }
            t.thumbnails === false && M.hide();
            var X = this.proxy(function (P) {
                if (P || P.width) {
                    P = Math.min(P.width, j(window).width());
                    W.width(P - 40);
                    Galleria.IE && this.getOptions("showInfo") && this.$("iefix").width(da.outerWidth()).height(da.outerHeight())
                }
            });
            this.bind("rescale", function () {
                ca = this.getStageHeight() - w.height() - 2;
                M.css("top", aa ? ca - N.outerHeight() + 2 : ca);
                var P = this.getActiveImage();
                P && X(P)
            });
            this.bind("loadstart", function (P) {
                P.cached || R.show().fadeTo(100, 1);
                j(P.thumbTarget).css("opacity", 1).parent().siblings().children().css("opacity", 0.6)
            });
            this.bind("loadfinish", function () {
                R.fadeOut(300);
                this.$("info, iefix").toggle(this.hasInfo())
            });
            this.bind("image", function (P) {
                X(P.imageTarget)
            });
            this.bind("thumbnail", function (P) {
                j(P.thumbTarget).parent(":not(.active)").children().css("opacity", 0.6);
                j(P.thumbTarget).click(function () {
                    aa && t._closeOnClick && w.click()
                })
            });
            this.trigger("rescale");
            if (!Galleria.TOUCH) {
                this.addIdleState(M, {
                    opacity: 0
                });
                this.addIdleState(this.get("info"), {
                    opacity: 0
                })
            }
            Galleria.IE && this.addIdleState(this.get("iefix"), {
                opacity: 0
            });
            this.$("image-nav-left, image-nav-right").css("opacity", 0.01).hover(function () {
                j(this).animate({
                    opacity: 1
                }, 100)
            }, function () {
                j(this).animate({
                    opacity: 0
                })
            }).show();
            if (t._hideDock) w.click(this.proxy(function () {
                w.toggleClass("open", !aa);
                aa ? M.animate({
                    top: ca
                }, 400, t.easing) : M.animate({
                    top: ca - N.outerHeight() + 2
                }, 400, t.easing);
                aa = !aa
            }));
            else {
                this.bind("thumbnail", function () {
                    M.css("top", ca - N.outerHeight() + 2)
                });
                w.css("visibility", "visible")
            }
            this.$("thumbnails").children().hover(function () {
                j(this).not(".active").children().stop().fadeTo(100, 1)
            }, function () {
                j(this).not(".active").children().stop().fadeTo(400, 0.6)
            });
            this.enterFullscreen();
            this.attachKeyboard({
                escape: function () {
                    return false
                },
                up: function (P) {
                    aa || w.click();
                    P.preventDefault()
                },
                down: function (P) {
                    aa && w.click();
                    P.preventDefault()
                }
            })
        }
    });
    G.make(3, {
        defaults: {
            transition: "slide",
            thumbCrop: "height",
            _toggleInfo: true
        },
        init: function (t) {
            this.addElement("info-link", "info-close");
            this.append({
                info: ["info-link", "info-close"]
            });
            var w = this.$("info-link,info-close,info-text"),
                R = Galleria.TOUCH,
                M = R ? "touchstart" : "click";
            this.$("loader,counter").show().css("opacity", 0.4);
            if (!R) {
                this.addIdleState(this.get("image-nav-left"), {
                    left: -50
                });
                this.addIdleState(this.get("image-nav-right"), {
                    right: -50
                });
                this.addIdleState(this.get("counter"), {
                    opacity: 0
                })
            }
            if (t._toggleInfo === true) w.bind(M, function () {
                w.toggle()
            });
            else {
                w.show();
                this.$("info-link, info-close").hide()
            }
            this.bind("thumbnail", function (N) {
                if (R) j(N.thumbTarget).css("opacity", N.index == t.show ? 1 : 0.6);
                else {
                    j(N.thumbTarget).css("opacity", 0.6).parent().hover(function () {
                        j(this).not(".active").children().stop().fadeTo(100, 1)
                    }, function () {
                        j(this).not(".active").children().stop().fadeTo(400, 0.6)
                    });
                    N.index === t.show && j(N.thumbTarget).css("opacity", 1)
                }
            });
            this.bind("loadstart", function (N) {
                N.cached || this.$("loader").show().fadeTo(200, 0.4);
                this.$("info").toggle(this.hasInfo());
                j(N.thumbTarget).css("opacity", 1).parent().siblings().children().css("opacity", 0.6)
            });
            this.bind("loadfinish", function () {
                this.$("loader").fadeOut(200)
            })
        }
    });
    G.make(4, {
        defaults: {
            transition: "pulse",
            thumbCrop: "width",
            imageCrop: false,
            carousel: false,
            show: false,
            easing: "galleriaOut",
            fullscreenDoubleTap: false,
            _webkitCursor: true,
            _animate: true
        },
        init: function (t) {
            this.addElement("preloader", "loaded", "close").append({
                container: "preloader",
                preloader: "loaded",
                stage: "close"
            });
            var w = this,
                R = this.$("stage"),
                M = this.$("thumbnails"),
                N = this.$("images"),
                W = this.$("info"),
                da = this.$("loader"),
                aa = this.$("target"),
                ca = 0,
                X = aa.width(),
                P = 0,
                ia = t.show,
                ja = false,
                la = function ($) {
                    w.$("info").css({
                        left: Math.max(20, j(window).width() / 2 - $ / 2 + 10)
                    })
                },
                d = function ($, ea) {
                    ea = j.extend({
                        speed: 400,
                        width: 190,
                        onbrick: function () {},
                        onheight: function () {},
                        delay: 0,
                        debug: false
                    }, ea);
                    $ = j($);
                    var A = $.children(),
                        fa = $.width(),
                        qa = Math.floor(fa / ea.width),
                        ka = [],
                        q, ra, c;
                    fa = {
                        "float": "none",
                        position: "absolute",
                        display: j.browser.safari ? "inline-block" : "block"
                    };
                    if ($.data("colCount") !== qa) {
                        $.data("colCount", qa);
                        if (A.length) {
                            for (q = 0; q < qa; q++) ka[q] = 0;
                            $.css("position", "relative");
                            A.css(fa).each(function (i, n) {
                                n = j(n);
                                for (q = qa - 1; q > -1; q--) if (ka[q] === Math.min.apply(window, ka)) ra = q;
                                c = {
                                    top: ka[ra],
                                    left: ea.width * ra
                                };
                                if (!(typeof c.top !== "number" || typeof c.left !== "number")) {
                                    if (ea.speed) window.setTimeout(function (k, s, C) {
                                        return function () {
                                            Galleria.utils.animate(k, C, {
                                                easing: "galleriaOut",
                                                duration: s.speed,
                                                complete: s.onbrick
                                            })
                                        }
                                    }(n, ea, c), i * ea.delay);
                                    else {
                                        n.css(c);
                                        ea.onbrick.call(n)
                                    }
                                    n.data("height") || n.data("height", n.outerHeight(true));
                                    ka[ra] += n.data("height")
                                }
                            });
                            A = Math.max.apply(window, ka);
                            if (!(A < 0)) if (typeof A === "number") if (ea.speed) $.animate({
                                height: Math.max.apply(window, ka)
                            }, ea.speed, ea.onheight);
                            else {
                                $.height(Math.max.apply(window, ka));
                                ea.onheight.call($)
                            }
                        }
                    }
                };
            Galleria.OPERA && this.$("stage").css("display", "none");
            this.bind("fullscreen_enter", function () {
                N.css("visibility", "visible");
                R.show();
                this.$("container").css("height", "100%");
                ja = true
            });
            this.bind("fullscreen_exit", function () {
                R.hide();
                M.show();
                W.hide();
                ja = false
            });
            this.bind("thumbnail", function ($) {
                this.addElement("plus");
                var ea = $.thumbTarget,
                    A = this.$("plus").css({
                        display: "block"
                    }).insertAfter(ea),
                    fa = j(ea).parent().data("index", $.index);
                t.showInfo && this.hasInfo($.index) && A.append("<span>" + this.getData($.index).title + "</span>");
                P = P || j(ea).parent().outerWidth(true);
                j(ea).css("opacity", 0);
                fa.unbind(t.thumbEventType);
                Galleria.IE ? A.hide() : A.css("opacity", 0);
                Galleria.TOUCH ? fa.bind("touchstart", function () {
                    A.css("opacity", 1)
                }).bind("touchend", function () {
                    A.hide()
                }) : fa.hover(function () {
                    Galleria.IE ? A.show() : A.stop().css("opacity", 1)
                }, function () {
                    Galleria.IE ? A.hide() : A.stop().animate({
                        opacity: 0
                    }, 300)
                });
                ca++;
                this.$("loaded").css("width", ca / this.getDataLength() * 100 + "%");
                if (ca === this.getDataLength()) {
                    this.$("preloader").fadeOut(100);
                    d(M, {
                        width: P,
                        speed: t._animate ? 400 : 0,
                        onbrick: function () {
                            var qa = j(this).find("img");
                            window.setTimeout(function (ka) {
                                return function () {
                                    Galleria.utils.animate(ka, {
                                        opacity: 1
                                    }, {
                                        duration: t.transition_speed
                                    });
                                    ka.parent().bind(Galleria.TOUCH ? "mouseup" : "click", function () {
                                        M.hide();
                                        W.hide();
                                        var q = j(this);
                                        w.enterFullscreen(function () {
                                            w.show(q.data("index"));
                                            if (q.data("index") === ia) {
                                                N.css("visibility", "hidden");
                                                W.toggle(w.hasInfo())
                                            }
                                        })
                                    })
                                }
                            }(qa), t._animate ? qa.parent().data("index") * 100 : 0)
                        },
                        onheight: function () {
                            aa.height(M.height())
                        }
                    })
                }
            });
            this.bind("loadstart", function ($) {
                $.cached || da.show()
            });
            this.bind("loadfinish", function ($) {
                W.hide();
                ia = this.getIndex();
                N.css("visibility", "visible");
                da.hide();
                if (this.hasInfo() && t.showInfo) W.fadeIn(t.transition ? t.transitionSpeed : 0);
                la($.imageTarget.width)
            });
            if (!Galleria.TOUCH) {
                this.addIdleState(this.get("image-nav-left"), {
                    left: -100
                });
                this.addIdleState(this.get("image-nav-right"), {
                    right: -100
                });
                this.addIdleState(this.get("info"), {
                    opacity: 0
                });
                this.addIdleState(this.get("close"), {
                    top: -50
                })
            }
            this.$("container").css({
                width: t.width,
                height: "auto"
            });
            t._webkitCursor && Galleria.WEBKIT && this.$("image-nav-right,image-nav-left").addClass("cur");
            if (Galleria.TOUCH) {
                this.setOptions({
                    transition: "fadeslide",
                    initialTransition: false
                });
                this.$("image-nav").hide()
            }
            this.$("close").click(function () {
                w.exitFullscreen()
            });
            j(window).resize(function () {
                if (ja) w.getActiveImage() && la(w.getActiveImage().width);
                else {
                    var $ = aa.width();
                    if ($ !== X) {
                        X = $;
                        d(M, {
                            width: P,
                            delay: 50,
                            debug: true,
                            onheight: function () {
                                aa.height(M.height())
                            }
                        })
                    }
                }
            })
        }
    })
})(jQuery);
(function (j) {
    var t = {
        ignoreFiles: ["index.htm", "index.html", "index.shtml", "index.cgi", "index.php"],
        strictQuery: true,
        ignore: function () {
            return RegExp("(" + this.ignoreFiles.join("|") + ")", "i")
        },
        window: function () {
            var w = window.location,
                R = w.href.cleanPath(this.ignore()).split("/");
            w = w.search.substring(1).length > 0 ? w.search.substring(1).split("&") : [];
            this.strictQuery || w.sort();
            return R.concat(w)
        },
        anchor: function (w) {
            var R = w.getAttribute("href", 1);
            if (!R || w.nodeName != "A") return false;
            w = window.location;
            R = R.absUrl().cleanPath(this.ignore());
            if (R === (w.protocol + "//" + w.hostname).replace(/www\./, "").noSlash()) return false;
            w = R.split("?");
            R = w[0].noSlash().split("/");
            w = w.length > 1 ? w[1].split("&") : [];
            this.strictQuery || w.sort();
            return R.concat(w)
        },
        compareArray: function (w, R) {
            if (w.length != R.length) return false;
            for (var M = 0; M < R.length; M++) if (w[M] !== R[M]) return false;
            return true
        },
        match: function (w) {
            if (j(w).attr("href") == "#") return false;
            var R = this.anchor(w),
                M = this.window();
            if (w.pathname.split("/").length < 3) return this.compareArray(M, R);
            return M.length < R.length ? false : this.compareArray(M.slice(0, R.length), R)
        },
        current: function (w) {
            if (j(w).attr("href") == "#") return false;
            w = this.anchor(w);
            return this.compareArray(this.window(), w)
        }
    };
    j.extend(j.expr[":"], {
        path: function (w) {
            return t.match(w)
        }
    });
    j.extend(j.expr[":"], {
        current: function (w) {
            return t.current(w)
        }
    });
    String.prototype.noSlash = function () {
        return this.lastIndexOf("/") === this.length - 1 || this.lastIndexOf("#") === this.length - 1 ? this.substr(0, this.length - 1) : this.toString()
    };
    String.prototype.absUrl = function () {
        var w = window.location,
            R, M;
        if (/^\w+:/.test(this)) return this.toString();
        R = w.protocol + "//" + w.host;
        if (this.indexOf("/") === 0) return R + this.toString();
        w = w.pathname.replace(/\/[^\/]*$/, "");
        if (M = this.match(/\.\.\//g)) {
            var N = this.substring(M.length * 3);
            for (M = M.length; M--;) w = w.substring(0, w.lastIndexOf("/"))
        } else N = this.toString();
        return R + w + "/" + N
    };
    String.prototype.cleanPath = function (w) {
        return this.replace(/www\./i, "").replace(w, "").replace(/\.\//, "").noSlash().toString()
    }
})(jQuery);
