/*************************************************
**  jQuery Masonry version 1.3.0
**  Copyright David DeSandro, licensed MIT
**  http://desandro.com/resources/jquery-masonry
**************************************************/
;(function(e){var l=e.event,m;l.special.smartresize={setup:function(){e(this).bind("resize",l.special.smartresize.handler)},teardown:function(){e(this).unbind("resize",l.special.smartresize.handler)},handler:function(j,k){var f=this,b=arguments;j.type="smartresize";m&&clearTimeout(m);m=setTimeout(function(){jQuery.event.handle.apply(f,b)},k==="execAsap"?0:100)}};e.fn.smartresize=function(j){return j?this.bind("smartresize",j):this.trigger("smartresize",["execAsap"])};e.fn.masonry=function(j,k){var f=
{getBricks:function(b,d,a){var c=a.itemSelector===undefined;d.$bricks=a.appendedContent===undefined?c?b.children():b.find(a.itemSelector):c?a.appendedContent:a.appendedContent.filter(a.itemSelector)},placeBrick:function(b,d,a,c,g){var h=Math.min.apply(Math,a);d=a.indexOf(h);var i=h+b.outerHeight(true);a=c.colCount+1-a.length;b.applyStyle({left:c.colW*d+c.posLeft,top:h},e.extend(true,{},g.animationOptions));for(b=0;b<a;b++)c.colY[d+b]=i},setup:function(b,d,a){f.getBricks(b,a,d);if(a.masoned)a.previousData=
b.data("masonry");a.colW=d.columnWidth===undefined?a.masoned?a.previousData.colW:a.$bricks.outerWidth(true):d.columnWidth;a.colCount=Math.floor(b.width()/a.colW);a.colCount=Math.max(a.colCount,1)},arrange:function(b,d,a){var c;if(a.masoned){a.posTop=a.previousData.posTop;a.posLeft=a.previousData.posLeft}else{b.css("position","relative");var g=e(document.createElement("div"));b.prepend(g);a.posTop=Math.round(g.position().top);a.posLeft=Math.round(g.position().left);g.remove()}if(!a.masoned||d.appendedContent!==
undefined)a.$bricks.css("position","absolute");if(a.masoned&&d.appendedContent!==undefined){a.colY=a.previousData.colY;for(c=a.previousData.colCount;c<a.colCount;c++)a.colY[c]=a.posTop}else{a.colY=[];for(c=a.colCount;c--;)a.colY.push(a.posTop)}e.fn.applyStyle=a.masoned&&d.animate?e.fn.animate:e.fn.css;d.singleMode?a.$bricks.each(function(){var h=e(this);f.placeBrick(h,a.colCount,a.colY,a,d)}):a.$bricks.each(function(){var h=e(this),i=Math.ceil(h.outerWidth(true)/a.colW);i=Math.min(i,a.colCount);if(i===
1)f.placeBrick(h,a.colCount,a.colY,a,d);else{var n=a.colCount+1-i,o=[];for(c=0;c<n;c++){var p=a.colY.slice(c,c+i);o[c]=Math.max.apply(Math,p)}f.placeBrick(h,n,o,a,d)}});a.wallH=Math.max.apply(Math,a.colY);b.applyStyle({height:a.wallH-a.posTop},e.extend(true,[],d.animationOptions));a.masoned||setTimeout(function(){b.addClass("masoned")},1);k.call(a.$bricks);b.data("masonry",a)},resize:function(b,d,a){a.masoned=b.data("masonry")!==null;var c=b.data("masonry").colCount;f.setup(b,d,a);a.colCount!=c&&
f.arrange(b,d,a)}};return this.each(function(){var b=e(this),d={};d.masoned=b.data("masonry")!==null;var a=d.masoned?b.data("masonry").options:{},c=e.extend({},e.fn.masonry.defaults,a,j),g=a.resizeable;d.options=c.saveOptions?c:a;k=k||function(){};f.getBricks(b,d,c);if(!d.$bricks.length)return this;f.setup(b,c,d);f.arrange(b,c,d);!g&&c.resizeable&&e(window).bind("smartresize.masonry",function(){f.resize(b,c,d)});g&&!c.resizeable&&e(window).unbind("smartresize.masonry")})};e.fn.masonry.defaults={singleMode:false,
columnWidth:undefined,itemSelector:undefined,appendedContent:undefined,saveOptions:true,resizeable:true,animate:false,animationOptions:{}}})(jQuery);
