(function(o, c, q) {
    var m = c.event, n; m.special.smartresize = { setup: function() { c(this).bind("resize", m.special.smartresize.handler) }, teardown: function() { c(this).unbind("resize", m.special.smartresize.handler) }, handler: function(a, d) { var b = this, f = arguments; a.type = "smartresize"; n && clearTimeout(n); n = setTimeout(function() { jQuery.event.handle.apply(b, f) }, "execAsap" === d ? 0 : 100) } }; c.fn.smartresize = function(a) { return a ? this.bind("smartresize", a) : this.trigger("smartresize", ["execAsap"]) }; c.Mason = function(a, d) {
        this.element =
c(d); this._create(a); this._init()
    }; var l = ["position", "height"]; c.Mason.settings = { isResizable: !0, isAnimated: !1, animationOptions: { queue: !1, duration: 500 }, gutterWidth: 0, isRTL: !1, isFitWidth: !1 }; c.Mason.prototype = { _filterFindBricks: function(a) { var d = this.options.itemSelector; return !d ? a : a.filter(d).add(a.find(d)) }, _getBricks: function(a) { return this._filterFindBricks(a).css({ position: "absolute" }).addClass("masonry-brick") }, _create: function(a) {
        this.options = c.extend(!0, {}, c.Mason.settings, a); this.styleQueue =
[]; this.reloadItems(); a = this.element[0].style; this.originalStyle = {}; for (var d = 0, b = l.length; d < b; d++) { var f = l[d]; this.originalStyle[f] = a[f] || "" } this.element.css({ position: "relative" }); this.horizontalDirection = this.options.isRTL ? "right" : "left"; this.offset = {}; a = c(document.createElement("div")); this.element.prepend(a); this.offset.y = Math.round(a.position().top); this.options.isRTL ? (a.css({ "float": "right", display: "inline-block" }), this.offset.x = Math.round(this.element.outerWidth() - a.position().left)) : this.offset.x =
Math.round(a.position().left); a.remove(); var e = this; setTimeout(function() { e.element.addClass("masonry") }, 0); this.options.isResizable && c(o).bind("smartresize.masonry", function() { e.resize() })
    }, _init: function(a) { this._getColumns("masonry"); this._reLayout(a) }, option: function(a) { if (c.isPlainObject(a)) this.options = c.extend(!0, this.options, a) }, layout: function(a, d) {
        for (var b, f, e, i, k, j, g = 0, h = a.length; g < h; g++) if (b = c(a[g]), f = Math.ceil(b.outerWidth(!0) / this.columnWidth), f = Math.min(f, this.cols), 1 === f) this._placeBrick(b,
this.colYs); else { e = this.cols + 1 - f; i = []; for (j = 0; j < e; j++) k = this.colYs.slice(j, j + f), i[j] = Math.max.apply(Math, k); this._placeBrick(b, i) } h = {}; h.height = Math.max.apply(Math, this.colYs) - this.offset.y; if (this.options.isFitWidth) { b = 0; for (g = this.cols; --g && !(this.colYs[g] !== this.offset.y); ) b++; h.width = (this.cols - b) * this.columnWidth - this.options.gutterWidth } this.styleQueue.push({ $el: this.element, style: h }); b = !this.isLaidOut ? "css" : this.options.isAnimated ? "animate" : "css"; f = this.options.animationOptions; for (g = 0, h = this.styleQueue.length; g <
h; g++) e = this.styleQueue[g], e.$el[b](e.style, f); this.styleQueue = []; d && d.call(a); this.isLaidOut = !0
    }, _getColumns: function() { var a = (this.options.isFitWidth ? this.element.parent() : this.element).width(); this.columnWidth = this.options.columnWidth || this.$bricks.outerWidth(!0) || a; this.columnWidth += this.options.gutterWidth; this.cols = Math.floor((a + this.options.gutterWidth) / this.columnWidth); this.cols = Math.max(this.cols, 1) }, _placeBrick: function(a, d) {
        for (var b = Math.min.apply(Math, d), f = 0, e = 0, c = d.length; e < c; e++) if (d[e] ===
b) { f = e; break } e = { top: b }; e[this.horizontalDirection] = this.columnWidth * f + this.offset.x; this.styleQueue.push({ $el: a, style: e }); b += a.outerHeight(!0); c = this.cols + 1 - c; for (e = 0; e < c; e++) this.colYs[f + e] = b
    }, resize: function() { var a = this.cols; this._getColumns("masonry"); this.cols !== a && this._reLayout() }, _reLayout: function(a) { var d = this.cols; for (this.colYs = []; d--; ) this.colYs.push(this.offset.y); this.layout(this.$bricks, a) }, reloadItems: function() { this.$bricks = this._getBricks(this.element.children()) }, reload: function(a) {
        this.reloadItems();
        this._init(a)
    }, appended: function(a, d, b) { if (d) { this._filterFindBricks(a).css({ top: this.element.height() }); var c = this; setTimeout(function() { c._appended(a, b) }, 1) } else this._appended(a, b) }, _appended: function(a, d) { var b = this._getBricks(a); this.$bricks = this.$bricks.add(b); this.layout(b, d) }, remove: function(a) { this.$bricks = this.$bricks.not(a); a.remove() }, destroy: function() {
        this.$bricks.removeClass("masonry-brick").each(function() { this.style.position = ""; this.style.top = ""; this.style.left = "" }); for (var a = this.element[0].style,
d = 0, b = l.length; d < b; d++) { var f = l[d]; a[f] = this.originalStyle[f] } this.element.unbind(".masonry").removeClass("masonry").removeData("masonry"); c(o).unbind(".masonry")
    } 
    }; c.fn.imagesLoaded = function(a) {
        function d() { a.call(c, e) } function b() { 0 >= --i && this.src !== k && (setTimeout(d), e.unbind("load error", b)) } var c = this, e = c.find("img").add(c.filter("img")), i = e.length, k = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw=="; i || d(); e.bind("load error", b).each(function() {
            if (this.complete || this.complete ===
q) { var a = this.src; this.src = k; this.src = a } 
        }); return c
    }; var p = function(a) { this.console && console.error(a) }; c.fn.masonry = function(a) {
        if ("string" === typeof a) { var d = Array.prototype.slice.call(arguments, 1); this.each(function() { var b = c.data(this, "masonry"); b ? !c.isFunction(b[a]) || "_" === a.charAt(0) ? p("no such method '" + a + "' for masonry instance") : b[a].apply(b, d) : p("cannot call methods on masonry prior to initialization; attempted to call method '" + a + "'") }) } else this.each(function() {
            var b = c.data(this, "masonry");
            b ? (b.option(a || {}), b._init()) : c.data(this, "masonry", new c.Mason(a, this))
        }); return this
    } 
})(window, jQuery);
