/*
 Galleria v 1.2.3 2011-04-14
 http://galleria.aino.se

 Copyright (c) 2011, Aino
 Licensed under the MIT license.
*/
(function (e) {
    var j = this,
        m = j.document,
        A = e(m),
        w = !1,
        o = navigator.userAgent.toLowerCase(),
        B = j.location.hash.replace(/#\//, ""),
        p = function () {
            return g.TOUCH ? "touchstart" : "click"
        },
        n = function () {
            var a = 3,
                b = m.createElement("div"),
                c = b.getElementsByTagName("i");
            do b.innerHTML = "<\!--[if gt IE " + ++a + "]><i></i><![endif]--\>";
            while (c[0]);
            return a > 4 ? a : void 0
        }(),
        q = function () {
            return {
                html: m.documentElement,
                body: m.body,
                head: m.getElementsByTagName("head")[0],
                title: m.title
            }
        },
        C = function () {
            var a = [];
            e.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 (b, c) {
                a.push(c);
                /_/.test(c) && a.push(c.replace(/_/g, ""))
            });
            return a
        }(),
        D = function (a) {
            var b;
            if (typeof a !== "object") return a;
            e.each(a, function (c, d) {
                /^[a-z]+_/.test(c) && (b = "", e.each(c.split("_"), function (a, c) {
                    b += a > 0 ? c.substr(0, 1).toUpperCase() + c.substr(1) : c
                }), a[b] = d, delete a[c])
            });
            return a
        },
        x = function (a) {
            if (e.inArray(a, C) > -1) return g[a.toUpperCase()];
            return a
        },
        r = {
            trunk: {},
            add: function (a, b, c, d) {
                d = d || !1;
                this.clear(a);
                if (d) var e = b,
                    b = function () {
                        e();
                        r.add(a, b, c)
                    };
                this.trunk[a] = j.setTimeout(b, c)
            },
            clear: function (a) {
                var b = function (a) {
                        j.clearTimeout(this.trunk[a]);
                        delete this.trunk[a]
                    },
                    c;
                if (a && a in this.trunk) b.call(r, a);
                else if (typeof a === "undefined") for (c in this.trunk) this.trunk.hasOwnProperty(c) && b.call(r, c)
            }
        },
        t = [],
        f = function () {
            return {
                array: function (a) {
                    return Array.prototype.slice.call(a)
                },
                create: function (a, b) {
                    var c = m.createElement(b || "div");
                    c.className = a;
                    return c
                },
                forceStyles: function (a, b) {
                    a = e(a);
                    a.attr("style") && a.data("styles", a.attr("style")).removeAttr("style");
                    a.css(b)
                },
                revertStyles: function () {
                    e.each(f.array(arguments), function (a, b) {
                        b = e(b).removeAttr("style");
                        b.data("styles") && b.attr("style", b.data("styles")).data("styles", null)
                    })
                },
                moveOut: function (a) {
                    f.forceStyles(a, {
                        position: "absolute",
                        left: -1E4
                    })
                },
                moveIn: function () {
                    f.revertStyles.apply(f, f.array(arguments))
                },
                hide: function (a, b, c) {
                    a = e(a);
                    a.data("opacity") || a.data("opacity", a.css("opacity"));
                    var d = {
                        opacity: 0
                    };
                    b ? a.stop().animate(d, b, c) : a.css(d)
                },
                show: function (a, b, c) {
                    var a = e(a),
                        d = {
                            opacity: parseFloat(a.data("opacity")) || 1
                        };
                    b ? a.stop().animate(d, b, c) : a.css(d)
                },
                addTimer: function () {
                    r.add.apply(r, f.array(arguments));
                    return this
                },
                clearTimer: function () {
                    r.clear.apply(r, f.array(arguments));
                    return this
                },
                wait: function (a) {
                    var a = e.extend({
                        until: function () {
                            return !1
                        },
                        success: function () {},
                        error: function () {
                            g.raise("Could not complete wait function.")
                        },
                        timeout: 3E3
                    }, a),
                        b = f.timestamp(),
                        c, d, i = function () {
                            d = f.timestamp();
                            c = d - b;
                            if (a.until(c)) return a.success(), !1;
                            if (d >= b + a.timeout) return a.error(), !1;
                            j.setTimeout(i, 2)
                        };
                    j.setTimeout(i, 2)
                },
                toggleQuality: function (a, b) {
                    if (!(n !== 7 && n !== 8) && a) typeof b === "undefined" && (b = a.style.msInterpolationMode === "nearest-neighbor"), a.style.msInterpolationMode = b ? "bicubic" : "nearest-neighbor"
                },
                insertStyleTag: function (a) {
                    var b = m.createElement("style");
                    q().head.appendChild(b);
                    b.styleSheet ? b.styleSheet.cssText = a : (a = m.createTextNode(a), b.appendChild(a))
                },
                loadScript: function (a, b) {
                    var c = !1,
                        d = e("<script>").attr({
                            src: a,
                            async: !0
                        }).get(0);
                    d.onload = d.onreadystatechange = function () {
                        if (!c && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete")) c = !0, d.onload = d.onreadystatechange = null, typeof b === "function" && b.call(this, this)
                    };
                    q().head.appendChild(d)
                },
                parseValue: function (a) {
                    return typeof a === "number" ? a : typeof a === "string" ? (a = a.match(/\-?\d/g)) && a.constructor === Array ? parseInt(a.join(""), 10) : 0 : 0
                },
                timestamp: function () {
                    return (new Date).getTime()
                },
                loadCSS: function (a, b, c) {
                    var d, i = !1,
                        l;
                    e("link[rel=stylesheet]").each(function () {
                        if (RegExp(a).test(this.href)) return d = this, !1
                    });
                    typeof b === "function" && (c = b, b = void 0);
                    c = c ||
                    function () {};
                    if (d) return c.call(d, d), d;
                    l = m.styleSheets.length;
                    w && (a += "?" + f.timestamp());
                    e("#" + b).length ? (e("#" + b).attr("href", a), l--, i = !0) : (d = e("<link>").attr({
                        rel: "stylesheet",
                        href: a,
                        id: b
                    }).get(0), j.setTimeout(function () {
                        var a = e('link[rel="stylesheet"], style');
                        a.length ? a.get(0).parentNode.insertBefore(d, a[0]) : q().head.appendChild(d);
                        n ? d.attachEvent("onreadystatechange", function () {
                            d.readyState === "complete" && (i = !0)
                        }) : i = !0
                    }, 10));
                    typeof c === "function" && f.wait({
                        until: function () {
                            return i && m.styleSheets.length > l
                        },
                        success: function () {
                            f.addTimer("css", function () {
                                c.call(d, d)
                            }, 100)
                        },
                        error: function () {
                            g.raise("Theme CSS could not load")
                        },
                        timeout: 1E4
                    });
                    return d
                }
            }
        }(),
        y = {
            fade: function (a, b) {
                e(a.next).css("opacity", 0).show().animate({
                    opacity: 1
                }, a.speed, b);
                a.prev && e(a.prev).css("opacity", 1).show().animate({
                    opacity: 0
                }, a.speed)
            },
            flash: function (a, b) {
                e(a.next).css("opacity", 0);
                a.prev ? e(a.prev).animate({
                    opacity: 0
                }, a.speed / 2, function () {
                    e(a.next).animate({
                        opacity: 1
                    }, a.speed, b)
                }) : e(a.next).animate({
                    opacity: 1
                }, a.speed, b)
            },
            pulse: function (a, b) {
                a.prev && e(a.prev).hide();
                e(a.next).css("opacity", 0).animate({
                    opacity: 1
                }, a.speed, b)
            },
            slide: function (a, b) {
                var c = e(a.next).parent(),
                    d = this.$("images"),
                    f = this._stageWidth,
                    g = this.getOptions("easing");
                c.css({
                    left: f * (a.rewind ? -1 : 1)
                });
                d.animate({
                    left: f * (a.rewind ? 1 : -1)
                }, {
                    duration: a.speed,
                    queue: !1,
                    easing: g,
                    complete: function () {
                        d.css("left", 0);
                        c.css("left", 0);
                        b()
                    }
                })
            },
            fadeslide: function (a, b) {
                var c = 0,
                    d = this.getOptions("easing"),
                    g = this.getStageWidth();
                a.prev && (c = f.parseValue(e(a.prev).css("left")), e(a.prev).css({
                    opacity: 1,
                    left: c
                }).animate({
                    opacity: 0,
                    left: c + g * (a.rewind ? 1 : -1)
                }, {
                    duration: a.speed,
                    queue: !1,
                    easing: d
                }));
                c = f.parseValue(e(a.next).css("left"));
                e(a.next).css({
                    left: c + g * (a.rewind ? -1 : 1),
                    opacity: 0
                }).animate({
                    opacity: 1,
                    left: c
                }, {
                    duration: a.speed,
                    complete: b,
                    queue: !1,
                    easing: d
                })
            }
        },
        g = function () {
            var a = this;
            this._theme = void 0;
            this._options = {};
            this._playing = !1;
            this._playtime = 5E3;
            this._active = null;
            this._queue = {
                length: 0
            };
            this._data = [];
            this._dom = {};
            this._thumbnails = [];
            this._initialized = !1;
            this._stageHeight = this._stageWidth = 0;
            this._target = void 0;
            this._id = Math.random();
            e.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 (b, c) {
                a._dom[c] = f.create("galleria-" + c)
            });
            e.each("current total".split(" "), function (b, c) {
                a._dom[c] = f.create("galleria-" + c, "span")
            });
            var b = this._keyboard = {
                keys: {
                    UP: 38,
                    DOWN: 40,
                    LEFT: 37,
                    RIGHT: 39,
                    RETURN: 13,
                    ESCAPE: 27,
                    BACKSPACE: 8,
                    SPACE: 32
                },
                map: {},
                bound: !1,
                press: function (c) {
                    var d = c.keyCode || c.which;
                    d in b.map && typeof b.map[d] === "function" && b.map[d].call(a, c)
                },
                attach: function (a) {
                    var c, d;
                    for (c in a) a.hasOwnProperty(c) && (d = c.toUpperCase(), d in b.keys ? b.map[b.keys[d]] = a[c] : b.map[d] = a[c]);
                    if (!b.bound) b.bound = !0, A.bind("keydown", b.press)
                },
                detach: function () {
                    b.bound = !1;
                    b.map = {};
                    A.unbind("keydown", b.press)
                }
            },
                c = this._controls = {
                    0: void 0,
                    1: void 0,
                    active: 0,
                    swap: function () {
                        c.active = c.active ? 0 : 1
                    },
                    getActive: function () {
                        return c[c.active]
                    },
                    getNext: function () {
                        return c[1 - c.active]
                    }
                },
                d = this._carousel = {
                    next: a.$("thumb-nav-right"),
                    prev: a.$("thumb-nav-left"),
                    width: 0,
                    current: 0,
                    max: 0,
                    hooks: [],
                    update: function () {
                        var b = 0,
                            c = 0,
                            f = [0];
                        e.each(a._thumbnails, function (a, d) {
                            d.ready && (b += d.outerWidth || e(d.container).outerWidth(!0), f[a + 1] = b, c = Math.max(c, d.outerHeight || e(d.container).outerHeight(!0)))
                        });
                        a.$("thumbnails").css({
                            //width: b,
                            //height: c
                        });
                        d.max = b;
                        d.hooks = f;
                        d.width = a.$("thumbnails-list").width();
                        d.setClasses();
                        a.$("thumbnails-container").toggleClass("galleria-carousel", b > d.width);
                        d.width = a.$("thumbnails-list").width()
                    },
                    bindControls: function () {
                        var b;
                        d.next.bind(p(), function (c) {
                            c.preventDefault();
                            if (a._options.carouselSteps === "auto") for (b = d.current; b < d.hooks.length; b++) {
                                if (d.hooks[b] - d.hooks[d.current] > d.width) {
                                    d.set(b - 2);
                                    break
                                }
                            } else d.set(d.current + a._options.carouselSteps)
                        });
                        d.prev.bind(p(), function (c) {
                            c.preventDefault();
                            if (a._options.carouselSteps === "auto") for (b = d.current; b >= 0; b--) if (d.hooks[d.current] - d.hooks[b] > d.width) {
                                d.set(b + 2);
                                break
                            } else {
                                if (b === 0) {
                                    d.set(0);
                                    break
                                }
                            } else d.set(d.current - a._options.carouselSteps)
                        })
                    },
                    set: function (a) {
                        for (a = Math.max(a, 0); d.hooks[a - 1] + d.width >= d.max && a >= 0;) a--;
                        d.current = a;
                        d.animate()
                    },
                    getLast: function (a) {
                        return (a || d.current) - 1
                    },
                    follow: function (a) {
                        if (a === 0 || a === d.hooks.length - 2) d.set(a);
                        else {
                            for (var b = d.current; d.hooks[b] - d.hooks[d.current] < d.width && b <= d.hooks.length;) b++;
                            a - 1 < d.current ? d.set(a - 1) : a + 2 > b && d.set(a - b + d.current + 2)
                        }
                    },
                    setClasses: function () {
                        d.prev.toggleClass("disabled", !d.current);
                        d.next.toggleClass("disabled", d.hooks[d.current] + d.width >= d.max)
                    },
                    animate: function () {
                        d.setClasses();
                        var b = d.hooks[d.current] * -1;
                        isNaN(b) || a.$("thumbnails").animate({
                            //left: b
                        }, {
                            duration: a._options.carouselSpeed,
                            easing: a._options.easing,
                            queue: !1
                        })
                    }
                },
                i = this._tooltip = {
                    initialized: !1,
                    open: !1,
                    init: function () {
                        i.initialized = !0;
                        f.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);}");
                        a.$("tooltip").css("opacity", 0.8);
                        f.hide(a.get("tooltip"))
                    },
                    move: function (b) {
                        var c = a.getMousePosition(b).x,
                            b = a.getMousePosition(b).y,
                            d = a.$("tooltip"),
                            e = b,
                            f = d.outerHeight(!0) + 1,
                            g = d.outerWidth(!0),
                            i = f + 15,
                            g = a.$("container").width() - g - 2,
                            f = a.$("container").height() - f - 2;
                        !isNaN(c) && !isNaN(e) && (c += 10, e -= 30, c = Math.max(0, Math.min(g, c)), e = Math.max(0, Math.min(f, e)), b < i && (e = i), d.css({
                            left: c,
                            top: e
                        }))
                    },
                    bind: function (b, c) {
                        i.initialized || i.init();
                        var d = function (b, c) {
                                i.define(b, c);
                                e(b).hover(function () {
                                    f.clearTimer("switch_tooltip");
                                    a.$("container").unbind("mousemove", i.move).bind("mousemove", i.move).trigger("mousemove");
                                    i.show(b);
                                    g.utils.addTimer("tooltip", function () {
                                        a.$("tooltip").stop().show();
                                        f.show(a.get("tooltip"), 400);
                                        i.open = !0
                                    }, i.open ? 0 : 500)
                                }, function () {
                                    a.$("container").unbind("mousemove", i.move);
                                    f.clearTimer("tooltip");
                                    a.$("tooltip").stop();
                                    f.hide(a.get("tooltip"), 200, function () {
                                        a.$("tooltip").hide();
                                        f.addTimer("switch_tooltip", function () {
                                            i.open = !1
                                        }, 1E3)
                                    })
                                })
                            };
                        typeof c === "string" ? d(b in a._dom ? a.get(b) : b, c) : e.each(b, function (b, c) {
                            d(a.get(b), c)
                        })
                    },
                    show: function (b) {
                        var b = e(b in a._dom ? a.get(b) : b),
                            c = b.data("tt"),
                            d = function (a) {
                                j.setTimeout(function (a) {
                                    return function () {
                                        i.move(a)
                                    }
                                }(a), 10);
                                b.unbind("mouseup", d)
                            };
                        if (c = typeof c === "function" ? c() : c) a.$("tooltip").html(c.replace(/\s/, "&nbsp;")), b.bind("mouseup", d)
                    },
                    define: function (b, c) {
                        if (typeof c !== "function") var d = c,
                            c = function () {
                                return d
                            };
                        b = e(b in a._dom ? a.get(b) : b).data("tt", c);
                        i.show(b)
                    }
                },
                l = this._fullscreen = {
                    scrolled: 0,
                    active: !1,
                    keymap: a._keyboard.map,
                    enter: function (b) {
                        l.active = !0;
                        f.hide(a.getActiveImage());
                        a.$("container").addClass("fullscreen");
                        l.scrolled = e(j).scrollTop();
                        f.forceStyles(a.get("container"), {
                            position: "fixed",
                            top: 0,
                            left: 0,
                            width: "100%",
                            height: "100%",
                            zIndex: 1E4
                        });
                        var c = {
                            height: "100%",
                            overflow: "hidden",
                            margin: 0,
                            padding: 0
                        },
                            d = a.getData();
                        f.forceStyles(q().html, c);
                        f.forceStyles(q().body, c);
                        l.keymap = e.extend({}, a._keyboard.map);
                        a.attachKeyboard({
                            escape: a.exitFullscreen,
                            right: a.next,
                            left: a.prev
                        });
                        if (d && d.big && d.image !== d.big) {
                            var c = new g.Picture,
                                i = c.isCached(d.big),
                                h = a.getIndex(),
                                k = a._thumbnails[h];
                            a.trigger({
                                type: g.LOADSTART,
                                cached: i,
                                index: h,
                                imageTarget: a.getActiveImage(),
                                thumbTarget: k
                            });
                            c.load(d.big, function (b) {
                                a._scaleImage(b, {
                                    complete: function (b) {
                                        a.trigger({
                                            type: g.LOADFINISH,
                                            cached: i,
                                            index: h,
                                            imageTarget: b.image,
                                            thumbTarget: k
                                        });
                                        var c = a._controls.getActive().image;
                                        c && e(c).width(b.image.width).height(b.image.height).attr("style", e(b.image).attr("style")).attr("src", b.image.src)
                                    }
                                })
                            })
                        }
                        a.rescale(function () {
                            f.addTimer("fullscreen_enter", function () {
                                f.show(a.getActiveImage());
                                typeof b === "function" && b.call(a)
                            }, 100);
                            a.trigger(g.FULLSCREEN_ENTER)
                        });
                        e(j).resize(function () {
                            l.scale()
                        })
                    },
                    scale: function () {
                        a.rescale()
                    },
                    exit: function (b) {
                        l.active = !1;
                        f.hide(a.getActiveImage());
                        a.$("container").removeClass("fullscreen");
                        f.revertStyles(a.get("container"), q().html, q().body);
                        j.scrollTo(0, l.scrolled);
                        a.detachKeyboard();
                        a.attachKeyboard(l.keymap);
                        a.rescale(function () {
                            f.addTimer("fullscreen_exit", function () {
                                f.show(a.getActiveImage());
                                typeof b === "function" && b.call(a)
                            }, 50);
                            a.trigger(g.FULLSCREEN_EXIT)
                        });
                        e(j).unbind("resize", l.scale)
                    }
                },
                k = this._idle = {
                    trunk: [],
                    bound: !1,
                    add: function (a, b) {
                        if (a) {
                            k.bound || k.addEvent();
                            var a = e(a),
                                c = {},
                                d;
                            for (d in b) b.hasOwnProperty(d) && (c[d] = a.css(d));
                            a.data("idle", {
                                from: c,
                                to: b,
                                complete: !0,
                                busy: !1
                            });
                            k.addTimer();
                            k.trunk.push(a)
                        }
                    },
                    remove: function (b) {
                        b = jQuery(b);
                        e.each(k.trunk, function (c, d) {
                            d.length && !d.not(b).length && (a._idle.show(b), a._idle.trunk.splice(c, 1))
                        });
                        k.trunk.length || (k.removeEvent(), f.clearTimer("idle"))
                    },
                    addEvent: function () {
                        k.bound = !0;
                        a.$("container").bind("mousemove click", k.showAll)
                    },
                    removeEvent: function () {
                        k.bound = !1;
                        a.$("container").unbind("mousemove click", k.showAll)
                    },
                    addTimer: function () {
                        f.addTimer("idle", function () {
                            a._idle.hide()
                        }, a._options.idleTime)
                    },
                    hide: function () {
                        a.trigger(g.IDLE_ENTER);
                        e.each(k.trunk, function (b, c) {
                            var d = c.data("idle");
                            if (d) c.data("idle").complete = !1, c.stop().animate(d.to, {
                                duration: a._options.idleSpeed,
                                queue: !1,
                                easing: "swing"
                            })
                        })
                    },
                    showAll: function () {
                        f.clearTimer("idle");
                        e.each(a._idle.trunk, function (b, c) {
                            a._idle.show(c)
                        })
                    },
                    show: function (b) {
                        var c = b.data("idle");
                        if (!c.busy && !c.complete) c.busy = !0, a.trigger(g.IDLE_EXIT), f.clearTimer("idle"), b.stop().animate(c.from, {
                            duration: a._options.idleSpeed / 2,
                            queue: !1,
                            easing: "swing",
                            complete: function () {
                                e(this).data("idle").busy = !1;
                                e(this).data("idle").complete = !0
                            }
                        });
                        k.addTimer()
                    }
                },
                h = this._lightbox = {
                    width: 0,
                    height: 0,
                    initialized: !1,
                    active: null,
                    image: null,
                    elems: {},
                    init: function () {
                        a.trigger(g.LIGHTBOX_OPEN);
                        if (!h.initialized) {
                            h.initialized = !0;
                            var b = {},
                                c = a._options,
                                d = "",
                                c = {
                                    overlay: "position:fixed;display:none;opacity:" + c.overlayOpacity + ";filter:alpha(opacity=" + c.overlayOpacity * 100 + ");top:0;left:0;width:100%;height:100%;background:" + c.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;"
                                },
                                i = {};
                            n === 8 && (c.nextholder += "background:#000;filter:alpha(opacity=0);", c.prevholder += "background:#000;filter:alpha(opacity=0);");
                            e.each(c, function (a, b) {
                                d += ".galleria-lightbox-" + a + "{" + b + "}"
                            });
                            f.insertStyleTag(d);
                            e.each("overlay box content shadow title info close prevholder prev nextholder next counter image".split(" "), function (c, d) {
                                a.addElement("lightbox-" + d);
                                b[d] = h.elems[d] = a.get("lightbox-" + d)
                            });
                            h.image = new g.Picture;
                            e.each({
                                box: "shadow content close prevholder nextholder",
                                info: "title counter",
                                content: "info image",
                                prevholder: "prev",
                                nextholder: "next"
                            }, function (a, b) {
                                var c = [];
                                e.each(b.split(" "), function (a, b) {
                                    c.push("lightbox-" + b)
                                });
                                i["lightbox-" + a] = c
                            });
                            a.append(i);
                            e(b.image).append(h.image.container);
                            e(q().body).append(b.overlay, b.box);
                            (function (a) {
                                return a.hover(function () {
                                    e(this).css("color", "#bbb")
                                }, function () {
                                    e(this).css("color", "#444")
                                })
                            })(e(b.close).bind(p(), h.hide).html("&#215;"));
                            e.each(["Prev", "Next"], function (a, c) {
                                var d = e(b[c.toLowerCase()]).html(/v/.test(c) ? "&#8249;&nbsp;" : "&nbsp;&#8250;"),
                                    f = e(b[c.toLowerCase() + "holder"]);
                                f.bind(p(), function () {
                                    h["show" + c]()
                                });
                                n < 8 ? d.show() : f.hover(function () {
                                    d.show()
                                }, function () {
                                    d.stop().fadeOut(200)
                                })
                            });
                            e(b.overlay).bind(p(), h.hide)
                        }
                    },
                    rescale: function (b) {
                        var c = Math.min(e(j).width() - 40, h.width),
                            d = Math.min(e(j).height() - 60, h.height),
                            d = Math.min(c / h.width, d / h.height),
                            c = h.width * d + 40,
                            d = h.height * d + 60,
                            c = {
                                width: c,
                                height: d,
                                marginTop: Math.ceil(d / 2) * -1,
                                marginLeft: Math.ceil(c / 2) * -1
                            };
                        b ? e(h.elems.box).css(c) : e(h.elems.box).animate(c, a._options.lightboxTransitionSpeed, a._options.easing, function () {
                            var b = h.image,
                                c = a._options.lightboxFadeSpeed;
                            a.trigger({
                                type: g.LIGHTBOX_IMAGE,
                                imageTarget: b.image
                            });
                            e(b.container).show();
                            f.show(b.image, c);
                            f.show(h.elems.info, c)
                        })
                    },
                    hide: function () {
                        h.image.image = null;
                        e(j).unbind("resize", h.rescale);
                        e(h.elems.box).hide();
                        f.hide(h.elems.info);
                        f.hide(h.elems.overlay, 200, function () {
                            e(this).hide().css("opacity", a._options.overlayOpacity);
                            a.trigger(g.LIGHTBOX_CLOSE)
                        })
                    },
                    showNext: function () {
                        h.show(a.getNext(h.active))
                    },
                    showPrev: function () {
                        h.show(a.getPrev(h.active))
                    },
                    show: function (b) {
                        h.active = b = typeof b === "number" ? b : a.getIndex();
                        h.initialized || h.init();
                        e(j).unbind("resize", h.rescale);
                        var c = a.getData(b),
                            d = a.getDataLength();
                        f.hide(h.elems.info);
                        h.image.load(c.image, function (a) {
                            h.width = a.original.width;
                            h.height = a.original.height;
                            e(a.image).css({
                                width: "100.5%",
                                height: "100.5%",
                                top: 0,
                                zIndex: 99998
                            });
                            f.hide(a.image);
                            h.elems.title.innerHTML = c.title;
                            h.elems.counter.innerHTML = b + 1 + " / " + d;
                            e(j).resize(h.rescale);
                            h.rescale()
                        });
                        e(h.elems.overlay).show();
                        e(h.elems.box).show()
                    }
                };
            return this
        };
    g.prototype = {
        constructor: g,
        init: function (a, b) {
            var c = this,
                b = D(b);
            t.push(this);
            this._original = {
                target: a,
                options: b,
                data: null
            };
            (this._target = this._dom.target = a.nodeName ? a : e(a).get(0)) ? (this._options = {
                autoplay: !1,
                carousel: !0,
                carouselFollow: !0,
                carouselSpeed: 400,
                carouselSteps: "auto",
                clicknext: !1,
                dataConfig: function () {
                    return {}
                },
                dataSelector: "img",
                dataSource: this._target,
                debug: void 0,
                easing: "galleria",
                extend: function () {},
                height: "auto",
                idleTime: 3E3,
                idleSpeed: 200,
                imageCrop: !1,
                imageMargin: 0,
                imagePan: !1,
                imagePanSmoothness: 12,
                imagePosition: "50%",
                keepSource: !1,
                lightbox: !1,
                lightboxFadeSpeed: 200,
                lightboxTransitionSpeed: 400,
                linkSourceTmages: !0,
                maxScaleRatio: void 0,
                minScaleRatio: void 0,
                overlayOpacity: 0.85,
                overlayBackground: "#0b0b0b",
                pauseOnInteraction: !0,
                popupLinks: !1,
                preload: 2,
                queue: !0,
                show: 0,
                showInfo: !0,
                showCounter: !0,
                showImagenav: !0,
                thumbCrop: !0,
                thumbEventType: p(),
                thumbFit: !0,
                thumbMargin: 0,
                thumbQuality: "auto",
                thumbnails: !0,
                transition: "fade",
                transitionInitial: void 0,
                transitionSpeed: 400,
                width: "auto"
            }, b && b.debug === !0 && (w = !0), e(this._target).children().hide(), typeof g.theme === "object" ? this._init() : f.wait({
                until: function () {
                    return typeof g.theme === "object"
                },
                success: function () {
                    c._init.call(c)
                },
                error: function () {
                    g.raise("No theme found.", !0)
                },
                timeout: 5E3
            })) : g.raise("Target not found.")
        },
        _init: function () {
            var a = this;
            if (this._initialized) return g.raise("Init failed: Gallery instance already initialized."), this;
            this._initialized = !0;
            if (!g.theme) return g.raise("Init failed: No theme found."), this;
            e.extend(!0, this._options, g.theme.defaults, this._original.options);
            this.bind(g.DATA, function () {
                this._original.data = this._data;
                this.get("total").innerHTML = this.getDataLength();
                var b = this.$("container"),
                    c = {
                        width: 0,
                        height: 0
                    },
                    d = f.create("galleria-image");
                f.wait({
                    until: function () {
                        e.each(["width", "height"], function (d, e) {
                            c[e] = a._options[e] && typeof a._options[e] === "number" ? a._options[e] : Math.max(f.parseValue(b.css(e)), f.parseValue(a.$("target").css(e)), b[e](), a.$("target")[e]())
                        });
                        var g = function () {
                                return !0
                            };
                        a._options.thumbnails && (a.$("thumbnails").append(d), g = function () {
                            return !!e(d).height()
                        });
                        return g() && c.width && c.height > 10
                    },
                    success: function () {
                        e(d).remove();
                        b.width(c.width);
                        b.height(c.height);
                        g.WEBKIT ? j.setTimeout(function () {
                            a._run()
                        }, 1) : a._run()
                    },
                    error: function () {
                        g.raise("Width & Height not found.", !0)
                    },
                    timeout: 2E3
                })
            });
            this.bind(g.READY, function (b) {
                return function () {
                    f.show(this.get("counter"));
                    this._options.carousel && this._carousel.bindControls();
                    if (this._options.autoplay) {
                        this.pause();
                        if (typeof this._options.autoplay === "number") this._playtime = this._options.autoplay;
                        this.trigger(g.PLAY);
                        this._playing = !0
                    }
                    b ? typeof this._options.show === "number" && this.show(this._options.show) : (b = !0, this._options.clicknext && (e.each(this._data, function (a, b) {
                        delete b.link
                    }), this.$("stage").css({
                        cursor: "pointer"
                    }).bind(p(), function () {
                        a._options.pauseOnInteraction && a.pause();
                        a.next()
                    })), g.History && g.History.change(function (b) {
                        b = parseInt(b.value.replace(/\//, ""), 10);
                        isNaN(b) ? j.history.go(-1) : a.show(b, void 0, !0)
                    }), g.theme.init.call(this, this._options), this._options.extend.call(this, this._options), /^[0-9]{1,4}$/.test(B) && g.History ? this.show(B, void 0, !0) : this._data[this._options.show] && this.show(this._options.show))
                }
            }(!1));
            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"]
            });
            f.hide(this.$("counter").append(this.get("current"), " / ", this.get("total")));
            this.setCounter("&#8211;");
            f.hide(a.get("tooltip"));
            e.each(Array(2), function (b) {
                var c = new g.Picture;
                e(c.container).css({
                    position: "absolute",
                    top: 0,
                    left: 0
                });
                a.$("images").append(c.container);
                a._controls[b] = c
            });
            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(p(), function (b) {
                a._options.clicknext && b.stopPropagation();
                a._options.pauseOnInteraction && a.pause();
                b = /right/.test(this.className) ? "next" : "prev";
                a[b]()
            });
            e.each(["info", "counter", "image-nav"], function (b, c) {
                a._options["show" + c.substr(0, 1).toUpperCase() + c.substr(1).replace(/-/, "")] === !1 && f.moveOut(a.get(c.toLowerCase()))
            });
            this.load();
            if (!this._options.keep_source && !n) this._target.innerHTML = "";
            this.$("target").append(this.get("container"));
            this._options.carousel && this.bind(g.THUMBNAIL, function () {
                this.updateCarousel()
            });
            return this
        },
        _createThumbnails: function () {
            this.get("total").innerHTML = this.getDataLength();
            var a, b, c, d, i, l = this,
                k = this._options,
                h = function () {
                    var a = l.$("thumbnails").find(".active");
                    if (!a.length) return !1;
                    return a.find("img").attr("src")
                }(),
                z = typeof k.thumbnails === "string" ? k.thumbnails.toLowerCase() : null,
                n = function (a) {
                    return m.defaultView && m.defaultView.getComputedStyle ? m.defaultView.getComputedStyle(c.container, null)[a] : i.css(a)
                },
                v = function (a, b, c) {
                    return function () {
                        e(c).append(a);
                        l.trigger({
                            type: g.THUMBNAIL,
                            thumbTarget: a,
                            index: b
                        })
                    }
                },
                s = function (a) {
                    k.pauseOnInteraction && l.pause();
                    var b = e(a.currentTarget).data("index");
                    l.getIndex() !== b && l.show(b);
                    a.preventDefault()
                },
                u = function (a) {
                    a.scale({
                        width: a.data.width,
                        height: a.data.height,
                        crop: k.thumbCrop,
                        margin: k.thumbMargin,
                        complete: function (a) {
                            var b = ["left", "top"],
                                c, d;
                            e.each(["Width", "Height"], function (f, g) {
                                c = g.toLowerCase();
                                if ((k.thumbCrop !== !0 || k.thumbCrop === c) && k.thumbFit) d = {}, d[c] = a[c], e(a.container).css(d), d = {}, d[b[f]] = 0, e(a.image).css(d);
                                a["outer" + g] = e(a.container)["outer" + g](!0)
                            });
                            f.toggleQuality(a.image, k.thumbQuality === !0 || k.thumbQuality === "auto" && a.original.width < a.width * 3);
                            l.trigger({
                                type: g.THUMBNAIL,
                                thumbTarget: a.image,
                                index: a.data.order
                            })
                        }
                    })
                };
            this._thumbnails = [];
            this.$("thumbnails").empty();
            for (a = 0; this._data[a]; a++) d = this._data[a], k.thumbnails === !0 ? (c = new g.Picture(a), b = d.thumb || d.image, this.$("thumbnails").append(c.container), i = e(c.container), c.data = {
                width: f.parseValue(n("width")),
                height: f.parseValue(n("height")),
                order: a
            }, k.thumbFit && k.thumbCrop !== !0 ? i.css({
                width: 0,
                height: 0
            }) : i.css({
                width: c.data.width,
                height: c.data.height
            }), c.load(b, u), k.preload === "all" && c.add(d.image)) : z === "empty" || z === "numbers" ? (c = {
                container: f.create("galleria-image"),
                image: f.create("img", "span"),
                ready: !0
            }, z === "numbers" && e(c.image).text(a + 1), this.$("thumbnails").append(c.container), j.setTimeout(v(c.image, a, c.container), 50 + a * 20)) : c = {
                container: null,
                image: null
            }, e(c.container).add(k.keepSource && k.linkSourceImages ? d.original : null).data("index", a).bind(k.thumbEventType, s), h === b && e(c.container).addClass("active"), this._thumbnails.push(c)
        },
        _run: function () {
            var a = this;
            a._createThumbnails();
            f.wait({
                until: function () {
                    g.OPERA && a.$("stage").css("display", "inline-block");
                    a._stageWidth = a.$("stage").width();
                    a._stageHeight = a.$("stage").height();
                    return a._stageWidth && a._stageHeight > 50
                },
                success: function () {
                    a.trigger(g.READY)
                },
                error: function () {
                    g.raise("Stage measures not found", !0)
                }
            })
        },
        load: function (a, b, c) {
            var d = this;
            this._data = [];
            this._thumbnails = [];
            this.$("thumbnails").empty();
            typeof b === "function" && (c = b, b = null);
            a = a || this._options.dataSource;
            b = b || this._options.dataSelector;
            c = c || this._options.dataConfig;
            if (a.constructor === Array) return this.validate(a) ? (this._data = a, this._parseData().trigger(g.DATA)) : g.raise("Load failed: JSON Array not valid."), this;
            e(a).find(b).each(function (a, b) {
                var b = e(b),
                    f = {},
                    g = b.parent().attr("href");
                if (/\.(png|gif|jpg|jpeg)(\?.*)?$/i.test(g)) f.image = f.big = g;
                else if (g) f.link = g;
                d._data.push(e.extend({
                    title: b.attr("title"),
                    thumb: b.attr("src"),
                    image: b.attr("src"),
                    big: b.attr("src"),
                    description: b.attr("alt"),
                    link: b.attr("longdesc"),
                    original: b.get(0)
                }, f, c(b)))
            });
            this.getDataLength() ? this.trigger(g.DATA) : g.raise("Load failed: no data found.");
            return this
        },
        _parseData: function () {
            var a = this;
            e.each(this._data, function (b, c) {
                if ("thumb" in c === !1) a._data[b].thumb = c.image;
                if (!1 in c) a._data[b].big = c.image
            });
            return this
        },
        splice: function () {
            Array.prototype.splice.apply(this._data, f.array(arguments));
            return this._parseData()._createThumbnails()
        },
        push: function () {
            Array.prototype.push.apply(this._data, f.array(arguments));
            return this._parseData()._createThumbnails()
        },
        _getActive: function () {
            return this._controls.getActive()
        },
        validate: function () {
            return !0
        },
        bind: function (a, b) {
            a = x(a);
            this.$("container").bind(a, this.proxy(b));
            return this
        },
        unbind: function (a) {
            a = x(a);
            this.$("container").unbind(a);
            return this
        },
        trigger: function (a) {
            a = typeof a === "object" ? e.extend(a, {
                scope: this
            }) : {
                type: x(a),
                scope: this
            };
            this.$("container").trigger(a);
            return this
        },
        addIdleState: function () {
            this._idle.add.apply(this._idle, f.array(arguments));
            return this
        },
        removeIdleState: function () {
            this._idle.remove.apply(this._idle, f.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, f.array(arguments));
            return this
        },
        exitFullscreen: function () {
            this._fullscreen.exit.apply(this, f.array(arguments));
            return this
        },
        toggleFullscreen: function () {
            this._fullscreen[this.isFullscreen() ? "exit" : "enter"].apply(this, f.array(arguments));
            return this
        },
        bindTooltip: function () {
            this._tooltip.bind.apply(this._tooltip, f.array(arguments));
            return this
        },
        defineTooltip: function () {
            this._tooltip.define.apply(this._tooltip, f.array(arguments));
            return this
        },
        refreshTooltip: function () {
            this._tooltip.show.apply(this._tooltip, f.array(arguments));
            return this
        },
        openLightbox: function () {
            this._lightbox.show.apply(this._lightbox, f.array(arguments));
            return this
        },
        closeLightbox: function () {
            this._lightbox.hide.apply(this._lightbox, f.array(arguments));
            return this
        },
        getActiveImage: function () {
            return this._getActive().image || void 0
        },
        getActiveThumb: function () {
            return this._thumbnails[this._active].image || void 0
        },
        getMousePosition: function (a) {
            return {
                x: a.pageX - this.$("container").offset().left,
                y: a.pageY - this.$("container").offset().top
            }
        },
        addPan: function (a) {
            if (this._options.imageCrop !== !1) {
                var a = e(a || this.getActiveImage()),
                    b = this,
                    c = a.width() / 2,
                    d = a.height() / 2,
                    g = parseInt(a.css("left"), 10),
                    l = parseInt(a.css("top"), 10),
                    k = g || 0,
                    h = l || 0,
                    j = 0,
                    m = 0,
                    v = !1,
                    s = f.timestamp(),
                    u = 0,
                    o = 0,
                    E = function (b, c, d) {
                        if (b > 0 && (o = Math.round(Math.max(b * -1, Math.min(0, c))), u !== o)) if (u = o, n === 8) a.parent()["scroll" + d](o * -1);
                        else b = {}, b[d.toLowerCase()] = o, a.css(b)
                    },
                    p = function (a) {
                        if (!(f.timestamp() - s < 50)) v = !0, c = b.getMousePosition(a).x, d = b.getMousePosition(a).y
                    };
                n === 8 && (a.parent().scrollTop(h * -1).scrollLeft(k * -1), a.css({
                    top: 0,
                    left: 0
                }));
                this.$("stage").unbind("mousemove", p).bind("mousemove", p);
                f.addTimer("pan", function () {
                    v && (j = a.width() - b._stageWidth, m = a.height() - b._stageHeight, g = c / b._stageWidth * j * -1, l = d / b._stageHeight * m * -1, k += (g - k) / b._options.imagePanSmoothness, h += (l - h) / b._options.imagePanSmoothness, E(m, h, "Top"), E(j, k, "Left"))
                }, 50, !0);
                return this
            }
        },
        proxy: function (a, b) {
            if (typeof a !== "function") return function () {};
            b = b || this;
            return function () {
                return a.apply(b, f.array(arguments))
            }
        },
        removePan: function () {
            this.$("stage").unbind("mousemove");
            f.clearTimer("pan");
            return this
        },
        addElement: function () {
            var a = this._dom;
            e.each(f.array(arguments), function (b, c) {
                a[c] = f.create("galleria-" + c)
            });
            return this
        },
        attachKeyboard: function () {
            this._keyboard.attach.apply(this._keyboard, f.array(arguments));
            return this
        },
        detachKeyboard: function () {
            this._keyboard.detach.apply(this._keyboard, f.array(arguments));
            return this
        },
        appendChild: function (a, b) {
            this.$(a).append(this.get(b) || b);
            return this
        },
        prependChild: function (a, b) {
            this.$(a).prepend(this.get(b) || b);
            return this
        },
        remove: function () {
            this.$(f.array(arguments).join(",")).remove();
            return this
        },
        append: function (a) {
            var b, c;
            for (b in a) if (a.hasOwnProperty(b)) if (a[b].constructor === Array) for (c = 0; a[b][c]; c++) this.appendChild(b, a[b][c]);
            else this.appendChild(b, a[b]);
            return this
        },
        _scaleImage: function (a, b) {
            b = e.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
            }, b);
            (a || this._controls.getActive()).scale(b);
            return this
        },
        updateCarousel: function () {
            this._carousel.update();
            return this
        },
        rescale: function (a, b, c) {
            var d = this;
            typeof a === "function" && (c = a, a = void 0);
            var e = function () {
                    d._stageWidth = a || d.$("stage").width();
                    d._stageHeight = b || d.$("stage").height();
                    d._scaleImage();
                    d._options.carousel && d.updateCarousel();
                    d.trigger(g.RESCALE);
                    typeof c === "function" && c.call(d)
                };
            g.WEBKIT && !a && !b ? f.addTimer("scale", e, 5) : e.call(d);
            return this
        },
        refreshImage: function () {
            this._scaleImage();
            this._options.imagePan && this.addPan();
            return this
        },
        show: function (a, b, c) {
            if (!(a === !1 || !this._options.queue && this._queue.stalled)) if (a = Math.max(0, Math.min(parseInt(a, 10), this.getDataLength() - 1)), b = typeof b !== "undefined" ? !! b : a < this.getIndex(), !c && g.History) g.History.value(a.toString());
            else return this._active = a, Array.prototype.push.call(this._queue, {
                index: a,
                rewind: b
            }), this._queue.stalled || this._show(), this
        },
        _show: function () {
            var a = this,
                b = this._queue[0],
                c = this.getData(b.index);
            if (c) {
                var d = this.isFullscreen() && "big" in c ? c.big : c.image,
                    i = this._controls.getActive(),
                    l = this._controls.getNext(),
                    k = l.isCached(d),
                    h = this._thumbnails[b.index],
                    m = function () {
                        a._queue.stalled = !1;
                        f.toggleQuality(l.image, a._options.imageQuality);
                        e(i.container).css({
                            zIndex: 0,
                            opacity: 0
                        });
                        e(l.container).css({
                            zIndex: 1,
                            opacity: 1
                        });
                        a._controls.swap();
                        a._options.imagePan && a.addPan(l.image);
                        (c.link || a._options.lightbox) && e(l.image).css({
                            cursor: "pointer"
                        }).bind(p(), function () {
                            c.link ? a._options.popupLinks ? j.open(c.link, "_blank") : j.location.href = c.link : a.openLightbox()
                        });
                        Array.prototype.shift.call(a._queue);
                        a._queue.length && a._show();
                        a._playCheck();
                        a.trigger({
                            type: g.IMAGE,
                            index: b.index,
                            imageTarget: l.image,
                            thumbTarget: h.image
                        })
                    };
                this._options.carousel && this._options.carouselFollow && this._carousel.follow(b.index);
                if (this._options.preload) {
                    var n, o, s = this.getNext();
                    try {
                        for (o = this._options.preload; o > 0; o--) n = new g.Picture, c = a.getData(s), n.add(this.isFullscreen() && "big" in c ? c.big : c.image), s = a.getNext(s)
                    } catch (u) {}
                }
                f.show(l.container);
                e(a._thumbnails[b.index].container).addClass("active").siblings(".active").removeClass("active");
                a.trigger({
                    type: g.LOADSTART,
                    cached: k,
                    index: b.index,
                    imageTarget: l.image,
                    thumbTarget: h.image
                });
                l.load(d, function (c) {
                    a._scaleImage(c, {
                        complete: function (c) {
                            f.show(c.container);
                            "image" in i && f.toggleQuality(i.image, !1);
                            f.toggleQuality(c.image, !1);
                            a._queue.stalled = !0;
                            a.removePan();
                            a.setInfo(b.index);
                            a.setCounter(b.index);
                            a.trigger({
                                type: g.LOADFINISH,
                                cached: k,
                                index: b.index,
                                imageTarget: c.image,
                                thumbTarget: a._thumbnails[b.index].image
                            });
                            var d = i.image === null && a._options.transitionInitial ? a._options.transitionInitial : a._options.transition;
                            d in y === !1 ? m() : y[d].call(a, {
                                prev: i.image,
                                next: c.image,
                                rewind: b.rewind,
                                speed: a._options.transitionSpeed || 400
                            }, m)
                        }
                    })
                })
            }
        },
        getNext: function (a) {
            a = typeof a === "number" ? a : this.getIndex();
            return a === this.getDataLength() - 1 ? 0 : a + 1
        },
        getPrev: function (a) {
            a = typeof a === "number" ? a : this.getIndex();
            return a === 0 ? this.getDataLength() - 1 : a - 1
        },
        next: function () {
            this.getDataLength() > 1 && this.show(this.getNext(), !1);
            return this
        },
        prev: function () {
            this.getDataLength() > 1 && this.show(this.getPrev(), !0);
            return this
        },
        get: function (a) {
            return a in this._dom ? this._dom[a] : null
        },
        getData: function (a) {
            return a in this._data ? this._data[a] : this._data[this._active]
        },
        getDataLength: function () {
            return this._data.length
        },
        getIndex: function () {
            return typeof this._active === "number" ? this._active : !1
        },
        getStageHeight: function () {
            return this._stageHeight
        },
        getStageWidth: function () {
            return this._stageWidth
        },
        getOptions: function (a) {
            return typeof a === "undefined" ? this._options : this._options[a]
        },
        setOptions: function (a, b) {
            typeof a === "object" ? e.extend(this._options, a) : this._options[a] = b;
            return this
        },
        play: function (a) {
            this._playing = !0;
            this._playtime = a || this._playtime;
            this._playCheck();
            this.trigger(g.PLAY);
            return this
        },
        pause: function () {
            this._playing = !1;
            this.trigger(g.PAUSE);
            return this
        },
        playToggle: function (a) {
            return this._playing ? this.pause() : this.play(a)
        },
        isPlaying: function () {
            return this._playing
        },
        isFullscreen: function () {
            return this._fullscreen.active
        },
        _playCheck: function () {
            var a = this,
                b = 0,
                c = f.timestamp(),
                d = "play" + this._id;
            if (this._playing) {
                f.clearTimer(d);
                var e = function () {
                        b = f.timestamp() - c;
                        b >= a._playtime && a._playing ? (f.clearTimer(d), a.next()) : a._playing && (a.trigger({
                            type: g.PROGRESS,
                            percent: Math.ceil(b / a._playtime * 100),
                            seconds: Math.floor(b / 1E3),
                            milliseconds: b
                        }), f.addTimer(d, e, 20))
                    };
                f.addTimer(d, e, 20)
            }
        },
        setIndex: function (a) {
            this._active = a;
            return this
        },
        setCounter: function (a) {
            typeof a === "number" ? a++ : typeof a === "undefined" && (a = this.getIndex() + 1);
            this.get("current").innerHTML = a;
            if (n) {
                var a = this.$("counter"),
                    b = a.css("opacity"),
                    c = a.attr("style");
                c && parseInt(b, 10) === 1 ? a.attr("style", c.replace(/filter[^\;]+\;/i, "")) : this.$("counter").css("opacity", b)
            }
            return this
        },
        setInfo: function (a) {
            var b = this,
                c = this.getData(a);
            e.each(["title", "description"], function (a, e) {
                var f = b.$("info-" + e);
                c[e] ? f[c[e].length ? "show" : "hide"]().html(c[e]) : f.empty().hide()
            });
            return this
        },
        hasInfo: function (a) {
            var b = "title description".split(" "),
                c;
            for (c = 0; b[c]; c++) if (this.getData(a)[b[c]]) return !0;
            return !1
        },
        jQuery: function (a) {
            var b = this,
                c = [];
            e.each(a.split(","), function (a, d) {
                d = e.trim(d);
                b.get(d) && c.push(d)
            });
            var d = e(b.get(c.shift()));
            e.each(c, function (a, c) {
                d = d.add(b.get(c))
            });
            return d
        },
        $: function () {
            return this.jQuery.apply(this, f.array(arguments))
        }
    };
    e.each(C, function (a, b) {
        var c = /_/.test(b) ? b.replace(/_/g, "") : b;
        g[b.toUpperCase()] = "galleria." + c
    });
    e.extend(g, {
        IE9: n === 9,
        IE8: n === 8,
        IE7: n === 7,
        IE6: n === 6,
        IE: !! n,
        WEBKIT: /webkit/.test(o),
        SAFARI: /safari/.test(o),
        CHROME: /chrome/.test(o),
        QUIRK: n && m.compatMode && m.compatMode === "BackCompat",
        MAC: /mac/.test(navigator.platform.toLowerCase()),
        OPERA: !! j.opera,
        IPHONE: /iphone/.test(o),
        IPAD: /ipad/.test(o),
        ANDROID: /android/.test(o),
        TOUCH: !(!/iphone/.test(o) && !/ipad/.test(o) && !/android/.test(o))
    });
    g.addTheme = function (a) {
        a.name || g.raise("No theme name specified");
        a.defaults = typeof a.defaults !== "object" ? {} : D(a.defaults);
        var b = !1,
            c;
        typeof a.css === "string" ? (e("link").each(function (d, e) {
            c = RegExp(a.css);
            if (c.test(e.href)) return b = !0, g.theme = a, !1
        }), b || e("script").each(function (d, e) {
            c = RegExp("galleria\\." + a.name.toLowerCase() + "\\.");
            c.test(e.src) && (b = e.src.replace(/[^\/]*$/, "") + a.css, f.addTimer("css", function () {
                f.loadCSS(b, "galleria-theme", function () {
                    g.theme = a
                })
            }, 1))
        }), b || g.raise("No theme CSS loaded")) : g.theme = a;
        return a
    };
    g.loadTheme = function (a, b) {
        var c = !1,
            d = t.length;
        g.theme = void 0;
        f.loadScript(a, function () {
            c = !0
        });
        f.wait({
            until: function () {
                return c
            },
            error: function () {
                g.raise("Theme at " + a + " could not load, check theme path.", !0)
            },
            success: function () {
                if (d) {
                    var a = [];
                    e.each(g.get(), function (c, d) {
                        var f = e.extend(d._original.options, {
                            data_source: d._data
                        }, b);
                        d.$("container").remove();
                        var j = new g;
                        j._id = d._id;
                        j.init(d._original.target, f);
                        a.push(j)
                    });
                    t = a
                }
            },
            timeout: 2E3
        })
    };
    g.get = function (a) {
        if (t[a]) return t[a];
        else if (typeof a !== "number") return t;
        else g.raise("Gallery index " + a + " not found")
    };
    g.addTransition = function (a, b) {
        y[a] = b
    };
    g.utils = f;
    g.log = function () {
        try {
            j.console.log.apply(j.console, f.array(arguments))
        } catch (a) {
            try {
                j.opera.postError.apply(j.opera, arguments)
            } catch (b) {
                j.alert(f.array(arguments).split(", "))
            }
        }
    };
    g.raise = function (a, b) {
        if (w || b) throw Error((b ? "Fatal error" : "Error") + ": " + a);
    };
    g.Picture = function (a) {
        this.id = a || null;
        this.image = null;
        this.container = f.create("galleria-image");
        e(this.container).css({
            overflow: "hidden",
            position: "relative"
        });
        this.original = {
            width: 0,
            height: 0
        };
        this.loaded = this.ready = !1
    };
    g.Picture.prototype = {
        cache: {},
        add: function (a) {
            var b = 0,
                c = this,
                d = new Image,
                f = function () {
                    if ((!this.width || !this.height) && b < 1E3) b++, e(d).load(f).attr("src", a + "?" + (new Date).getTime());
                    c.original = {
                        height: this.height,
                        width: this.width
                    };
                    c.cache[a] = a;
                    c.loaded = !0
                };
            e(d).css("display", "block");
            if (c.cache[a]) return d.src = a, f.call(d), d;
            e(d).load(f).attr("src", a);
            return d
        },
        show: function () {
            f.show(this.image)
        },
        hide: function () {
            f.moveOut(this.image)
        },
        clear: function () {
            this.image = null
        },
        isCached: function (a) {
            return !!this.cache[a]
        },
        load: function (a, b) {
            var c = this;
            e(this.container).empty(!0);
            this.image = this.add(a);
            f.hide(this.image);
            e(this.container).append(this.image);
            f.wait({
                until: function () {
                    return c.loaded && c.image.complete && c.original.width && c.image.width
                },
                success: function () {
                    j.setTimeout(function () {
                        b.call(c, c)
                    }, 50)
                },
                error: function () {
                    j.setTimeout(function () {
                        b.call(c, c)
                    }, 50);
                    g.raise("image not loaded in 30 seconds: " + a)
                },
                timeout: 3E4
            });
            return this.container
        },
        scale: function (a) {
            a = e.extend({
                width: 0,
                height: 0,
                min: void 0,
                max: void 0,
                margin: 0,
                complete: function () {},
                position: "center",
                crop: !1
            }, a);
            if (!this.image) return this.container;
            var b, c, d = this,
                i = e(d.container);
            f.wait({
                until: function () {
                    b = a.width || i.width() || f.parseValue(i.css("width"));
                    c = a.height || i.height() || f.parseValue(i.css("height"));
                    return b && c
                },
                success: function () {
                    var g = (b - a.margin * 2) / d.original.width,
                        i = (c - a.margin * 2) / d.original.height,
                        h = {
                            "true": Math.max(g, i),
                            width: g,
                            height: i,
                            "false": Math.min(g, i)
                        }[a.crop.toString()];
                    a.max && (h = Math.min(a.max, h));
                    a.min && (h = Math.max(a.min, h));
                    e(d.container).width(b).height(c);
                    e.each(["width", "height"], function (a, b) {
                        e(d.image)[b](d.image[b] = d[b] = Math.round(d.original[b] * h))
                    });
                    var j = {},
                        m = {},
                        g = function (a, b, c) {
                            var g = 0;
                            /\%/.test(a) ? (a = parseInt(a, 10) / 100, b = d.image[b] || e(d.image)[b](), g = Math.ceil(b * -1 * a + c * a)) : g = f.parseValue(a);
                            return g
                        },
                        n = {
                            top: {
                                top: 0
                            },
                            left: {
                                left: 0
                            },
                            right: {
                                left: "100%"
                            },
                            bottom: {
                                top: "100%"
                            }
                        };
                    e.each(a.position.toLowerCase().split(" "), function (a, b) {
                        b === "center" && (b = "50%");
                        j[a ? "top" : "left"] = b
                    });
                    e.each(j, function (a, b) {
                        n.hasOwnProperty(b) && e.extend(m, n[b])
                    });
                    j = j.top ? e.extend(j, m) : m;
                    j = e.extend({
                        top: "50%",
                        left: "50%"
                    }, j);
                    e(d.image).css({
                        position: "relative",
                        top: g(j.top, "height", c),
                        left: g(j.left, "width", b)
                    });
                    d.show();
                    d.ready = !0;
                    a.complete.call(d, d)
                },
                error: function () {
                    g.raise("Could not scale image: " + d.image.src)
                },
                timeout: 1E3
            });
            return this
        }
    };
    e.extend(e.easing, {
        galleria: function (a, b, c, d, e) {
            if ((b /= e / 2) < 1) return d / 2 * b * b * b * b + c;
            return -d / 2 * ((b -= 2) * b * b * b - 2) + c
        },
        galleriaIn: function (a, b, c, d, e) {
            return d * (b /= e) * b * b * b + c
        },
        galleriaOut: function (a, b, c, d, e) {
            return -d * ((b = b / e - 1) * b * b * b - 1) + c
        }
    });
    e.fn.galleria = function (a) {
        return this.each(function () {
            (new g).init(this, a)
        })
    };
    j.Galleria = g
})(jQuery);
