/*
 Galleria Fullscreen Theme 2011-06-08
 http://galleria.aino.se

 Copyright (c) 2011, Aino
*/
(function (b) {
    Galleria.addTheme({
        name: "fullscreen",
        author: "Galleria",
        css: "galleria.fullscreen.css",
        defaults: {
            transition: "none",
            imageCrop: !0,
            thumbCrop: "height",
            easing: "galleriaOut",
            _hideDock: Galleria.TOUCH ? !1 : !0,
            _closeOnClick: !1
        },
        init: function (e) {
            this.addElement("thumbnails-tab");
            this.appendChild("thumbnails-container", "thumbnails-tab");
            var d = this.$("thumbnails-tab"),
                i = this.$("loader"),
                f = this.$("thumbnails-container"),
                h = this.$("thumbnails-list"),
                l = this.$("info-text"),
                j = this.$("info"),
                c = !e._hideDock,
                g = 0;
            Galleria.IE && (this.addElement("iefix"), this.appendChild("container", "iefix"), this.$("iefix").css({
                zIndex: 3,
                position: "absolute",
                backgroundColor: "#000",
                opacity: 0.4,
                top: 0
            }));
            e.thumbnails === !1 && f.hide();
            var k = this.proxy(function (a) {
                if (a || a.width) a = Math.min(a.width, b(window).width()), l.width(a - 40), Galleria.IE && this.getOptions("showInfo") && this.$("iefix").width(j.outerWidth()).height(j.outerHeight())
            });
            this.bind("rescale", function () {
                g = this.getStageHeight() - d.height() - 2;
                f.css("top", c ? g - h.outerHeight() + 2 : g);
                var a = this.getActiveImage();
                a && k(a)
            });
            this.bind("loadstart", function (a) {
                a.cached;
                b(a.thumbTarget).css("opacity", 1).parent().siblings().children().css("opacity", 0.6)
            });
            this.bind("loadfinish", function () {
                i.fadeOut(300);
                this.$("info, iefix").toggle(this.hasInfo())
            });
            this.bind("image", function (a) {
                k(a.imageTarget)
            });
            this.bind("thumbnail", function (a) {
                b(a.thumbTarget).parent(":not(.active)").children().css("opacity", 0.6);
                b(a.thumbTarget).click(function () {
                    c && e._closeOnClick && d.click()
                })
            });
            this.trigger("rescale");
            Galleria.TOUCH || (this.addIdleState(f, {
                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 () {
                b(this).animate({
                    opacity: 1
                }, 100)
            }, function () {
                b(this).animate({
                    opacity: 0
                })
            }).show();
            e._hideDock ? d.click(this.proxy(function () {
                d.toggleClass("open", !c);
                c ? f.animate({
                    top: g
                }, 400, e.easing) : f.animate({
                    top: g - h.outerHeight() + 2
                }, 400, e.easing);
                c = !c
            })) : (this.bind("thumbnail", function () {
                f.css("top", g - h.outerHeight() + 2)
            }), d.css("visibility", "hidden"));
            this.$("thumbnails").children().hover(function () {
                b(this).not(".active").children().stop().fadeTo(100, 1)
            }, function () {
                b(this).not(".active").children().stop().fadeTo(400, 0.6)
            });
            this.enterFullscreen();
            this.attachKeyboard({
                escape: function () {
                    return !1
                },
                up: function (a) {
                    c || d.click();
                    a.preventDefault()
                },
                down: function (a) {
                    c && d.click();
                    a.preventDefault()
                }
            })
        }
    })
})(jQuery);
