zul.box.Layout=zk.$extends(zk.Widget,{_spacing:"5px",$define:{spacing:function(){var a=this.$n(),b=this.isVertical_(),c=this._spacing;a&&jq(a).children("div:not(:last-child)").css("padding-"+(b?"bottom":"right"),c&&"auto"!=c?c:"")}},_chdextr:function(a){return a.$n("chdex")||a.$n()},insertChildHTML_:function(a,b,c){if(b)jq(this._chdextr(b)).before(this.encloseChildHTML_(a));else{b=jq(this.$n());var e=this._spacing;b.children("div:last-child").css("padding-"+(this.isVertical_()?"bottom":"right"),e&&
"auto"!=e?e:"");b.append(this.encloseChildHTML_(a))}a.bind(c)},bind_:function(){this.$supers(zul.box.Layout,"bind_",arguments);zWatch.listen({onResponse:this})},unbind_:function(){zWatch.unlisten({onResponse:this});this.$supers(zul.box.Layout,"unbind_",arguments)},syncSize:function(){this._shallSize=!1;if(this.desktop)for(var a=this.firstChild;a;a=a.nextSibling)if(a._nvflex||a._nhflex){zUtl.fireSized(this);break}},onResponse:function(){this._shallSize&&this.syncSize()},onChildVisible_:function(a){this.$supers("onChildVisible_",
arguments);if(this.desktop){var b=a.$n("chdex");this._shallSize=!0;b&&(b.style.display=a.isVisible()?"":"none")}},onChildAdded_:function(a){this.$supers("onChildAdded_",arguments);if(this.desktop){var b=a.$n("chdex");this._shallSize=!0;b&&(b.style.display=a.isVisible()?"":"none")}},onChildRemoved_:function(){this.$supers("onChildRemoved_",arguments);this.desktop&&(this._shallSize=!0)},removeChildHTML_:function(a){this.$supers("removeChildHTML_",arguments);jq(a.uuid+"-chdex",zk).remove();"auto"!=this._spacing&&
this.lastChild==a&&jq(this.$n()).children("div:last-child").css("padding-"+(this.isVertical_()?"bottom":"right"),"")},encloseChildHTML_:function(a,b){var c=new zk.Buffer,e=this.isVertical_(),n=this._spacing;c.push('<div id="'+a.uuid+'-chdex" class="'+this.$s("inner")+'"');if(n&&"auto"!=n){c.push(' style="',a.isVisible()?"":"display:none;");var q=a.nextSibling;!q||q.$instanceof(zul.wgt.Popup)||a.$instanceof(zul.wgt.Popup)||c.push("padding-",e?"bottom:":"right:",n);c.push('"')}c.push(">");a.redraw(c);
c.push("</div>");if(!b)return c.join("");b.push(c.join(""))},isVertical_:zk.$void,_resetBoxSize:function(a){for(var b=this.firstChild;b;b=b.nextSibling){var c=b.$n("chdex");if(c){if(a&&b._nvflex&&"min"!=b.getVflex()){var e;(e=b.$n())&&(e.scrollTop||e.scrollLeft)||b.setFlexSize_({height:"",width:""});c&&(c.style.height="")}!a&&b._nhflex&&"min"!=b.getHflex()&&((e=b.$n())&&(e.scrollTop||e.scrollLeft)||b.setFlexSize_({height:"",width:""}),c&&(c.style.width=""))}}},afterResetChildSize_:function(a){for(var b=
this.firstChild;b;b=b.nextSibling){var c=b.$n("chdex");c&&("h"==a&&(c.style.height=""),"w"==a&&(c.style.width=""),c.style.minWidth="1px")}},resetSize_:function(a){this.$supers(zul.box.Layout,"resetSize_",arguments);for(var b=this.isVertical_(),c=this.firstChild;c;c=c.nextSibling)if(b?c._nvflex&&"min"!=c.getVflex():c._nhflex&&"min"!=c.getHflex()){var e=c.$n("chdex");e&&("h"==a&&(e.style.height=""),"w"==a&&(e.style.width=""))}},getChildMinSize_:function(a,b){var c=b.$n();if("w"==a&&b._hflex&&this.isVertical_()){a=
b.nextSibling;for(b=0;a;a=a.nextSibling)a._hflex||(c=zjq.minWidth(a.$n()),b=c>b?c:b);return b}return"h"==a?zk(c.parentNode).contentHeight():zjq.minWidth(c)},getContentEdgeHeight_:function(){for(var a=0,b=this.firstChild;b;b=b.nextSibling)a+=zk(b.$n("chdex")).paddingHeight();return a},getContentEdgeWidth_:function(){for(var a=0,b=this.firstChild;b;b=b.nextSibling)a+=zk(b.$n("chdex")).paddingWidth();return a},beforeChildrenFlex_:function(a){this._shallSize=!1;a._flexFixed=!0;var b=this.isVertical_(),
c=[],e=b?0:1,n=[],q=b?1:0,l=this.$n(),m=a.getParentSize_(l),f=zk(l);l=m.height;m=m.width;var h=this.firstChild,d;zk.mounting||this._resetBoxSize(b);f.hasVScroll()&&(m-=d=jq.scrollbarWidth());for(f.hasHScroll()&&(l-=d||jq.scrollbarWidth());h;h=h.nextSibling){var k;if("nodom"==h.getMold()){if(d=h.firstChild)d=d.$n().parentNode,f=zk(d),b?l-=f.offsetHeightDoubleValue()+f.marginHeight():m-=d.offsetWidth+f.marginWidth()}else if(h.isVisible()&&!(k=zk(h)).hasVParent()){d=h;var p=d.$n();f=p.parentNode;var g=
zk(f);if(h&&h._nvflex)if(d!==a&&(d._flexFixed=!0),"min"==d._vflex){d.fixMinFlex_(p,"h");var r=p.offsetHeight+k.marginHeight()+g.padBorderHeight();f.style.height=jq.px0(r);b&&(l-=f.offsetHeight+g.marginHeight())}else c.push(d),b&&(e+=d._nvflex,l-=g.marginHeight());else b&&(l-=g.offsetHeightDoubleValue()+g.marginHeight());d&&d._nhflex?(d!==a&&(d._flexFixed=!0),"min"==d._hflex?(d.fixMinFlex_(p,"w"),d=p.offsetWidth+k.marginWidth()+g.padBorderWidth(),f.style.width=jq.px0(g.revisedWidth(d)),b||(m-=f.offsetWidth+
g.marginWidth())):(n.push(d),b||(q+=d._nhflex,m-=g.marginWidth()))):b||(m-=f.offsetWidth+g.marginWidth())}}for(k=0<l?l:0;1<c.length;)d=c.shift(),h=(b?d._nvflex*l/e:l)|0,f=d.$n().offsetTop,p=h-(11>zk.ie&&0<f?2*f:0),f=d.$n("chdex"),g=zk(f).padBorderHeight(),d.setFlexSize_({height:p-g}),d._vflexsz=h-g,f.style.height=jq.px0(h),b&&(k-=h);c.length&&(d=c.shift(),f=d.$n().offsetTop,p=k-(11>zk.ie&&0<f?2*f:0),f=d.$n("chdex"),g=zk(f).padBorderHeight(),d.setFlexSize_({height:p-g}),d._vflexsz=k-g,f.style.height=
jq.px0(k));for(k=0<m?m:0;1<n.length;)d=n.shift(),c=(b?m:d._nhflex*m/q)|0,f=d.$n("chdex"),g=zk(f).padBorderWidth(),d.setFlexSize_({width:c-g}),d._hflexsz=c-g,f.style.width=jq.px0(c),b||(k-=c);n.length&&(d=n.shift(),f=d.$n("chdex"),g=zk(f).padBorderWidth(),d.setFlexSize_({width:k-g}),d._hflexsz=k-g,f.style.width=jq.px0(k));a.parent.afterChildrenFlex_(a);return a._flexFixed=!1},afterChildrenMinFlex_:function(a){var b=this.$n();if("h"==a)if(this.isVertical_()){var c=0;for(a=b.firstChild;a;a=a.nextSibling){var e=
a.firstChild;e.style.height?(e=e.offsetHeight+zk(a).padBorderHeight()+zk(e).marginHeight(),a.style.height=jq.px0(e),c+=e):c+=a.offsetHeight}b.style.height=jq.px0(c)}else{c=0;for(a=b.firstChild;a;a=a.nextSibling)e=a.offsetHeight+zk(a.firstChild).marginHeight(),e>c&&(c=e);b.style.height=jq.px0(c)}else if(this.isVertical_()){c=0;for(a=b.firstChild;a;a=a.nextSibling)e=a.firstChild.offsetWidth+zk(a.firstChild).marginWidth(),e>c&&(c=e);8<zk.ie&&this._hflexsz&&(c=Math.max(this._hflexsz,c));b.style.width=
jq.px0(c)}else{c=0;for(a=b.firstChild;a;a=a.nextSibling)e=a.firstChild,e.style.width?(e=e.offsetWidth+zk(a).padBorderWidth()+zk(e).marginWidth(),a.style.width=jq.px0(e),c+=e):c+=a.offsetWidth;8<zk.ie&&this._hflexsz&&(c=Math.max(this._hflexsz,c));b.style.width=jq.px0(c)}}});
