(function(A){var C=A.event,B;
C.special.smartresize={setup:function(){A(this).bind("resize",C.special.smartresize.handler)
},teardown:function(){A(this).unbind("resize",C.special.smartresize.handler)
},handler:function(E,D){var F=this,G=arguments;
E.type="smartresize";
B&&clearTimeout(B);
B=setTimeout(function(){jQuery.event.handle.apply(F,G)
},D==="execAsap"?0:100)
}};
A.fn.smartresize=function(D){return D?this.bind("smartresize",D):this.trigger("smartresize",["execAsap"])
};
A.fn.masonry=function(E,D){var F={getBricks:function(I,G,H){var J=H.itemSelector===undefined;
G.$bricks=H.appendedContent===undefined?J?I.children():I.find(H.itemSelector):J?H.appendedContent:H.appendedContent.filter(H.itemSelector)
},placeBrick:function(L,N,O,M,J){N=Math.min.apply(Math,O);
for(var I=N+L.outerHeight(true),K=O.length,H=K,G=M.colCount+1-K;
K--;
){if(O[K]==N){H=K
}}L.applyStyle({left:M.colW*H+M.posLeft,top:N},A.extend(true,{},J.animationOptions));
for(K=0;
K<G;
K++){M.colY[H+K]=I
}},setup:function(I,G,H){F.getBricks(I,H,G);
if(H.masoned){H.previousData=I.data("masonry")
}H.colW=G.columnWidth===undefined?H.masoned?H.previousData.colW:H.$bricks.outerWidth(true):G.columnWidth;
H.colCount=Math.floor(I.width()/H.colW);
H.colCount=Math.max(H.colCount,1)
},arrange:function(J,G,H){var K;
if(!H.masoned||G.appendedContent!==undefined){H.$bricks.css("position","absolute")
}if(H.masoned){H.posTop=H.previousData.posTop;
H.posLeft=H.previousData.posLeft
}else{J.css("position","relative");
var I=A(document.createElement("div"));
J.prepend(I);
H.posTop=Math.round(I.position().top);
H.posLeft=Math.round(I.position().left);
I.remove()
}if(H.masoned&&G.appendedContent!==undefined){H.colY=H.previousData.colY;
for(K=H.previousData.colCount;
K<H.colCount;
K++){H.colY[K]=H.posTop
}}else{H.colY=[];
for(K=H.colCount;
K--;
){H.colY.push(H.posTop)
}}A.fn.applyStyle=H.masoned&&G.animate?A.fn.animate:A.fn.css;
G.singleMode?H.$bricks.each(function(){var L=A(this);
F.placeBrick(L,H.colCount,H.colY,H,G)
}):H.$bricks.each(function(){var N=A(this),O=Math.ceil(N.outerWidth(true)/H.colW);
O=Math.min(O,H.colCount);
if(O===1){F.placeBrick(N,H.colCount,H.colY,H,G)
}else{var M=H.colCount+1-O,L=[];
for(K=0;
K<M;
K++){var P=H.colY.slice(K,K+O);
L[K]=Math.max.apply(Math,P)
}F.placeBrick(N,M,L,H,G)
}});
H.wallH=Math.max.apply(Math,H.colY);
J.applyStyle({height:H.wallH-H.posTop},A.extend(true,[],G.animationOptions));
H.masoned||setTimeout(function(){J.addClass("masoned")
},1);
D.call(H.$bricks);
J.data("masonry",H)
},resize:function(I,G,H){H.masoned=!!I.data("masonry");
var J=I.data("masonry").colCount;
F.setup(I,G,H);
H.colCount!=J&&F.arrange(I,G,H)
}};
return this.each(function(){var J=A(this),G={};
G.masoned=!!J.data("masonry");
var H=G.masoned?J.data("masonry").options:{},K=A.extend({},A.fn.masonry.defaults,H,E),I=H.resizeable;
G.options=K.saveOptions?K:H;
D=D||function(){};
F.getBricks(J,G,K);
if(!G.$bricks.length){return this
}F.setup(J,K,G);
F.arrange(J,K,G);
!I&&K.resizeable&&A(window).bind("smartresize.masonry",function(){F.resize(J,K,G)
});
I&&!K.resizeable&&A(window).unbind("smartresize.masonry")
})
};
A.fn.masonry.defaults={singleMode:false,columnWidth:undefined,itemSelector:undefined,appendedContent:undefined,saveOptions:true,resizeable:true,animate:false,animationOptions:{}}
})(jQuery);
$(window).load(function(){$(".homepage #content ul.stories,.hero .hero-group-full-hero-homepage ul.group-blocks,.hero .hero-group-offset-hero-homepage ul.group-blocks,.hero .hero-group-split-hero-homepage ul.group-blocks").masonry({singleMode:false,columnWidth:320,itemSelector:"li"});
$(".search-results ul.search-results").masonry({singleMode:false,columnWidth:320,itemSelector:"li"})
});
