var MIN_COLS=2;var COL_WIDTH=206;var GAP=10;var nwarr_offx,nwarr_offy,nwarr_w=0;maxy=new Array();$(function(){arrange();});$(window).resize(function(){arrange();});$(window).load(function(){arrange();});function arrange(){nwarr_offy=$('#NewsContainer').offset().top;nwarr_offx=$('#NewsContainer').offset().left;nwarr_w=$('#NewsContainer').width();nwarr_maxh=0;var columns=Math.max(MIN_COLS,parseInt(nwarr_w/(COL_WIDTH+GAP)));$('.NewsArticle').css({position:'absolute',width:COL_WIDTH+'px'});$('.twocols').css('width',COL_WIDTH*2+GAP);$('.threecols').css('width',COL_WIDTH*3+GAP*2);for(x=0;x<columns;x++){maxy[x]=0;}$('.NewsArticle').each(function(i){var pos,cursor,w,altura=0;w=(Math.floor($(this).outerWidth()/COL_WIDTH));cursor=0;if(w>1){for(x=0;x<columns-(w-1);x++){cursor=maxy[x]<maxy[cursor]?x:cursor;}pos=cursor;for(var x=0;x<w;x++){altura=Math.max(altura,maxy[pos+x]);}for(var x=0;x<w;x++){maxy[pos+x]=parseInt($(this).outerHeight())+GAP+altura;}$(this).css('left',pos*(COL_WIDTH+GAP)+nwarr_offx).css('top',altura+nwarr_offy);}else{for(x=0;x<columns;x++){cursor=maxy[x]<maxy[cursor]?x:cursor;}$(this).css('left',cursor*(COL_WIDTH+GAP)+nwarr_offx).css('top',maxy[cursor]+nwarr_offy);maxy[cursor]+=$(this).outerHeight()+GAP;}nwarr_maxh=Math.max(nwarr_maxh,maxy[cursor]);$('#NewsContainer').height(nwarr_maxh);});}