/*
 * jLayout Flow Layout - JavaScript Layout Algorithms v0.12
 *
 * Licensed under the new BSD License.
 * Copyright 2008-2009, Bram Stein
 * All rights reserved.
 */
(function(){jLayout=typeof jLayout==="undefined"?{}:jLayout;jLayout.flow=function(a){var d={},b={};d.hgap=typeof a.hgap==="number"&&!isNaN(a.hgap)?a.hgap:5;d.vgap=typeof a.vgap==="number"&&!isNaN(a.vgap)?a.vgap:5;d.items=a.items||[];d.alignment=(a.alignment&&(a.alignment==="center"||a.alignment==="right"||a.alignment==="left")&&a.alignment)||"left";b.items=function(){var f=[];Array.prototype.push.apply(f,d.items);return f};b.layout=function(f){var g=f.bounds(),h=f.insets(),k=0,l=d.items.length,o,n=[],m={width:0,height:0},j={x:h.left,y:h.top};g.width-=h.left+h.right;g.height-=h.top+h.bottom;for(;k<l;k+=1){if(d.items[k].isVisible()){o=d.items[k].preferredSize();if((m.width+o.width)>g.width){e(n,j,m,g);n=[];j.y+=m.height;j.x=h.left;m.width=0;m.height=0}m.height=Math.max(m.height,o.height+d.vgap);m.width+=o.width+d.hgap;n.push(d.items[k])}}e(n,j,m,g);return f};function e(m,l,j,k){var g={x:l.x,y:l.y},h=0,f=m.length;switch(d.alignment){case"center":g.x+=(d.hgap+k.width-j.width)/2;break;case"right":g.x+=k.width-j.width+d.hgap;break}for(;h<f;h+=1){g.y=l.y;m[h].bounds(g);m[h].doLayout();g.x+=m[h].bounds().width+d.hgap}}function c(f){return function(k){var m=0,n=0,g=0,l,j=false,h=k.insets();for(;m<d.items.length;m+=1){if(d.items[m].isVisible()){l=d.items[m][f+"Size"]();g=Math.max(g,l.height);n+=l.width}}return{width:n+h.left+h.right+(d.items.length-1)*d.hgap,height:g+h.top+h.bottom}}}b.preferred=c("preferred");b.minimum=c("minimum");b.maximum=c("maximum");return b}})();
