(function(){function f(a,b,d){if(!a)return 0;var c=a.$n("real");b=b?"offsetWidth":"offsetHeight";c=c[b];d&&(d=a.$n("colled"),a=a.$n("split"),d&&(c+=d[b]),a&&(c+=a[b]));return c}var m={north:function(a,b,d,c){a.w=d-a.w;b.y=a.ts;b.h-=a.ts},south:function(a,b,d,c){a.w=d-a.w;a.y=c-a.y;b.h-=a.ts},east:function(a,b,d){a.y+=b.y;a.h=b.h-a.h;a.x=d-a.x;b.w-=a.ts},west:function(a,b){a.y+=b.y;a.h=b.h-a.h;b.x+=a.ts;b.w-=a.ts}},k=zul.layout.Borderlayout=zk.$extends(zul.Widget,{setResize:function(){this.resize()},
onChildAdded_:function(a){this.$supers("onChildAdded_",arguments);var b=zul.layout.Borderlayout;switch(a.getPosition()){case b.NORTH:this.north=a;break;case b.SOUTH:this.south=a;break;case b.CENTER:this.center=a;break;case b.WEST:this.west=a;break;case b.EAST:this.east=a}this._shallResize=!0},onChildRemoved_:function(a){this.$supers("onChildRemoved_",arguments);a==this.north?this.north=null:a==this.south?this.south=null:a==this.center?this.center=null:a==this.west?this.west=null:a==this.east&&(this.east=
null);this.childReplacing_||(this._shallResize=!0)},bind_:function(){this.$supers(k,"bind_",arguments);zWatch.listen({onSize:this,onCommandReady:this})},unbind_:function(){zWatch.unlisten({onSize:this,onCommandReady:this});this.$supers(k,"unbind_",arguments)},onCommandReady:function(){this._shallResize&&this.resize()},beforeMinFlex_:function(a){var b=this.east,d=this.west,c=this.north,e=this.south,l=this.center;return"w"==a?Math.max(f(c,!0),f(e,!0),f(b,!0,!0)+f(d,!0,!0)+f(l,!0)):f(c,!1,!0)+f(e,!1,
!0)+Math.max(f(b),f(d),f(l))},afterChildrenFlex_:function(){this._isOnSize&&this._resize(!0)},resize:function(){this.desktop&&this._resize()},_resize:function(a){this._shallResize=!1;this._isOnSize=a;if(zk(this.$n()).isRealVisible()){for(var b=["north","south","west","east"],d=b.length,c,e=0;e<d;++e)if((c=this[b[e]])&&zk(c.$n()).isVisible()&&(c._nvflex&&void 0===c._vflexsz||c._nhflex&&void 0===c._hflexsz))return;c=this.$n();var f=c.offsetWidth,g=c.offsetHeight;a={x:0,y:0,w:f,h:g};!zk.opera||g||c.style.height&&
"100%"!=c.style.height||(a.h=g=c.parentNode.offsetHeight);for(e=0;e<d;++e)if((c=this[b[e]])&&zk(c.$n()).isVisible()){var h=c._ambit();m[b[e]](h,a,f,g);this._resizeWgt(c,h);h=c._isVertical()?"width":"height";jq(c.$n("title")).width(jq(c.$n("colled"))[h]()-jq(c.$n("btned"))[h]())}this.center&&zk(this.center.$n()).isVisible()&&(b=this.center.getCurrentMargins_(),a.x+=b.left,a.y+=b.top,a.w-=b.left+b.right,a.h-=b.top+b.bottom,this._resizeWgt(this.center,a));this._isOnSize=!1}},_resizeWgt:function(a,b,
d){if(a._open)!d&&a.$n("split")&&(a._fixSplit(),b=a._reszSplt(b)),zk.copy(a.$n("real").style,{left:jq.px(b.x),top:jq.px(b.y)}),this._resizeBody(a,b);else{a.$n("split").style.display="none";if(d=a.$n("colled"))zk(d),zk.copy(d.style,{left:jq.px(b.x),top:jq.px(b.y),width:jq.px0(b.w),height:jq.px0(b.h)});if((d=a.$n("real"))&&zk(d).isVisible()){var c=a.$instanceof(zul.layout.South),e=a.$instanceof(zul.layout.East);if(c||a.$instanceof(zul.layout.North))b.h=d.offsetHeight,c&&(d.style.top=jq.px(b.y-b.h));
if(e||a.$instanceof(zul.layout.West))b.w=d.offsetWidth,e&&(d.style.left=jq.px(b.x-b.w));this._resizeBody(a,b)}}},_resizeBody:function(a,b){b.w=Math.max(0,b.w);b.h=Math.max(0,b.h);var d=a.$n("real");if(!this._ignoreResize(d,b.w,b.h)){var c=a.isFlex()&&a.getFirstChild(),e=(c?a.getFirstChild().$n():a.$n("cave")).style,f=zk(d);d.style.width=jq.px0(b.w);var g=f.contentWidth();8<zk.ie&&(a.$instanceof(zul.layout.West)||a.$instanceof(zul.layout.East))&&!a._width&&!a._hflex&&g++;e.width=jq.px0(g);d.style.height=
jq.px0(b.h);a.$n("cap")&&(b.h=Math.max(0,b.h-a.$n("cap").offsetHeight));c&&(d=a.$n("cave"))&&(d.style.height=jq.px0(b.h-f.padBorderHeight()));e.height=jq.px0(b.h-f.padBorderHeight());a._nativebar&&a.isAutoscroll()&&(e.overflow="auto",e.position="relative");this._isOnSize||zUtl.fireSized(a)}},_ignoreResize:function(a,b,d){if(a._lastSize&&a._lastSize.width==b&&a._lastSize.height==d)return!0;a._lastSize={width:b,height:d};return!1},onSize:function(){this._resize(!0)}},{NORTH:"north",SOUTH:"south",EAST:"east",
WEST:"west",CENTER:"center"})})();
