/**
 * @preserve Galleria Classic Theme 2011-08-01
 * http://galleria.aino.se
 *
 * Copyright (c) 2011, Aino
 * Licensed under the MIT license.
 */

/*global jQuery, Galleria */

Galleria.requires(1.25, 'This version of Classic theme requires Galleria 1.2.5 or later');

(function(b) {
    Galleria.addTheme({
        name: "circles",
        author: "Tofarco",
        css: "../css/galleria.circles.css",
        defaults: {
            transition: "fade",
            thumbCrop: true,
            imageCrop: true,
            carousel: false,
            clicknext: true,
            autoplay: 6000,
            width: 630,
            height: 384            
        },
        init: function (e) {
            var c = this,
                g = !1,
                a;
            a = 0;
            var f, i, h;
            this.addElement("desc", "dots");
            this.append({
                container: ["desc", "dots", "info-description"]
            });
            h = this.$("thumbnails-container").hide().css("visibility", "visible");
            var j = function (d) {
                    return b("<div>").click(function (d) {
                        return function (a) {
                            a.preventDefault();
                            c.show(d)
                        }
                    }(d))
                };
            for (a = 0; a < this.getDataLength(); a++) this.$("dots").append(j(a));
            a = this.$("dots").outerWidth();
            f = this.$("desc").hide().hover(function () {
                b(this).addClass("hover")
            }, function () {
                b(this).removeClass("hover")
            }).click(function () {
                b(this).hide()
            });
            i = this.$("loader");
            this.bind("loadstart", function (d) {
                d.cached || this.$("loader").show().fadeTo(200, 0.4)
            });
            this.bind("loadfinish", function (d) {
                var a = c.getData().title,
                    b = c.getData().description,
                    t = c.getData().thumb;
                f.hide();
                i.fadeOut(200);
                this.$("dots").children("div").eq(d.index).addClass("active").siblings(".active").removeClass("active");
                f.empty().append("<strong>" + a + "</strong>", "<p>" + b + "</p>").css({
                    marginTop: this.$("desc").outerHeight() / -2
                });
                h.fadeOut(e.fadeSpeed);
                c.$("thumbs").removeClass("active");
                $("#change_me").attr('src', t).fadeTo(1, 0.5).fadeTo(800, 1)
            });
            this.bind("thumbnail", function (a) {
                b(a.thumbTarget).hover(function () {
                    c.setInfo(a.index)
                }, function () {
                    c.setInfo()
                })
            });
        }
    })
})(jQuery);
