if(!JsNamespace.exist("Eco.XComp.PositionSize")){JsNamespace.declare("Eco.XComp.PositionSize",{getTopLevelFormBox:function(_a){var _b=Eco.XComp.getTopLevelForm(_a);var _c=Eco.XComp.PositionSize.convertXY(_b,[0,0],_a);return [_c[0],_c[1],_a.width,_a.height];},convertXY:function(_a,_b,_c){var _d,_e;var _f,_g;if(_c){_d=system.clientToScreenX(_c,_b[0]);_e=system.clientToScreenY(_c,_b[1]);var _h=Eco.XComp.PositionSize;_f=system.screenToClientX(_a,_d)+_h.getScrollLeft(_a);_g=system.screenToClientY(_a,_e)+_h.getScrollTop(_a);}else{_f=_b[0];_g=_b[1];}return [_f,_g];},getScrollTop:function(_a){return (_a.vscrollbar&&_a.vscrollbar.visible?_a.vscrollbar.pos:0);},getScrollLeft:function(_a){return (_a.hscrollbar&&_a.hscrollbar.visible?_a.hscrollbar.pos:0);},getScrollBarSize:function(_a,_b){var _c=(_b=="horz")?_a.hscrollbar:_a.vscrollbar;var _d=0;if(_c){_d=_c.currentstyle.scrollbarsize;return (_d===null?(_b=="horz"?_c.height:_c.width):_d);}else{return _d;}},getCurrentScrollBarSize:function(_a,_b){var _c=(_b=="horz")?_a.hscrollbar:_a.vscrollbar;return (_c&&_c.visible?(_b=="horz"?_c.height:_c.width):0);},getClientWidth:function(_a,_b){var _c=0,_d=0,_e=0,_f=0;if(_b){_c=_b;}else{_c=_a.width;}_d=Eco.XComp.Style.getBorderWidth(_a);_e=Eco.XComp.Style.getMargin(_a);_c-=_d[0]+_d[2];_c-=_e[0]+_e[2];_f=Eco.XComp.PositionSize.getCurrentScrollBarSize(_a,"horz");_c-=_f;return _c;},getClientHeight:function(_a,_b){var _c=0,_d=0,_e=0,_f=0;if(_b){_c=_b;}else{_c=_a.height;}_d=Eco.XComp.Style.getBorderWidth(_a);_e=Eco.XComp.Style.getMargin(_a);_c-=_d[1]+_d[3];_c-=_e[1]+_e[3];_f=Eco.XComp.PositionSize.getCurrentScrollBarSize(_a);_c-=_f;return _c;},getScrollWidth:function(_a){var _b=0;_b=(_a.hscrollbar&&_a.hscrollbar.visible?_a.hscrollbar.max:0);_b+=Eco.XComp.PositionSize.getClientWidth(_a);return _b;},getScrollHeight:function(_a){var _b=0;_b=(_a.vscrollbar&&_a.vscrollbar.visible?_a.vscrollbar.max:0);_b+=Eco.XComp.PositionSize.getClientHeight(_a);return _b;},_fontCache:{},getTextSize:function(_a,_b,_c,_d,_e){var _f;if(_a instanceof nexacro.Style_font){_f=_a;_c=Eco.isEmpty(_c)?false:_c;if(_c&&_d==null){_d=50;}}else{_f=_a.currentstyle.font;if(Eco.isEmpty(_f)){_f=nexacro.Component._default_font;}_b=Eco.isEmpty(_b)?_a.text:_b;_c=Eco.isEmpty(_c)?(_a["wordwrap"]?true:false):_c;if(_c&&_d==null){_d=_a.getOffsetWidth();}}var _g=[0,0];if(Eco.isEmpty(_b)){return _g;}if(nexacro.Browser!="Runtime"){var _h=Eco._textSizeDiv;if(!_h){var _i=nexacro._managerFrameDoc;_h=_i.createElement("div");_i.body.appendChild(_h);Eco._textSizeDiv=_h;}var _j=_h.style;_j.position="absolute";_j.visibility="hidden";if(_c){_j.width=_d+"px";_j.height="auto";_j.whiteSpace="pre-wrap";_j.wordBreak="break-all";_j.wordWrap="break-word";}else{_j.width="auto";_j.height="auto";_j.whiteSpace="pre";_j.wordWrap="normal";}_j.font=_f._sysvalue;if(_e==true){_j.lineHeight="100%";}if(nexacro.Browser=="IE"&&nexacro.BrowserVersion<9){_h.innerText=_b;var _k=_h.getBoundingClientRect();_g=[_k.right-_k.left,_k.bottom-_k.top];}else{_h.innerHTML=_b;var _k=_h.getBoundingClientRect();_g=[_k.width,_k.height];}}else{_g=nexacro._getTextSize2(_b,_f,_c,_d);}_g[0]=Math.ceil(_g[0]);_g[1]=Math.ceil(_g[1]);return _g;},getImageSize:function(_a,_b,_c){if(!_a){return null;}if(_a.substring(0,4).toLowerCase()=="url("){_a=_a.substring(5,_a.length-2);}if(!_a){return null;}var _d;if(_c&&_c._getRefFormBaseUrl){_d=_c._getRefFormBaseUrl();}else{_d=application.getActiveForm();}var _e=application._getImageLocation(_a,_d);var _f=nexacro._ImgInfoCacheList[_e];if(_f){_b.call(_c,_a,_f.width,_f.height);}else{var _g=Eco.XComp.PositionSize;_g._getImageSizeCallbackInfo[_e]=[_a,_b,_c];_f=nexacro._getImageSize(_e,_g._getImageSizeOnLoad,_g);if(_f){_b.call(_c,_a,_f.width,_f.height);}}},_getImageSizeCallbackInfo:{},_getImageSizeOnLoad:function(_a,_b,_c){var _d=Eco.XComp.PositionSize;var _e=_d._getImageSizeCallbackInfo[_a];_e[1].call(_e[2],_e[0],_b,_c);delete _d._getImageSizeCallbackInfo[_a];},getContentSize:function(_a){var _b=[0,0];if(Eco.isXComponent(_a)){var _c=0,_d=0;if(!Eco.isEmpty(_a.hscrollbar)&&!Eco.isEmpty(_a.vscrollbar)){if(Eco.XComp.typeOf(_a)=="Tabpage"){_c=_a.width;_d=_a.height;}else{_c=_a.width;_d=_a.height;}_b=[_c,_d];}else{var _e=this._getStyleSpaceSize(_a);_c+=_e[0];_d+=_e[1];var _f=_a.text;if(Eco.isEmpty(_f)){_e=Eco.XComp.PositionSize.getTextSize(_a,"W",false);}else{_e=Eco.XComp.PositionSize.getTextSize(_a,_f);}_c+=_e[0];_d+=_e[1];var _g=Eco.XComp.typeOf(_a);if(_g=="Calendar"){if(_a.type=="monthonly"){return [_a.width,_a.height];}else{_e=Eco.XComp.PositionSize._getStyleSpaceSize(_a.calendaredit);_c+=_e[0];_d+=_e[1];}}else if(_g=="Combo"){_e=Eco.XComp.PositionSize._getStyleSpaceSize(_a.comboedit);_c+=_e[0];_d+=_e[1];}else if(_g=="Radio"){var _h=_a.currentstyle.itempadding;_c+=isNaN(_h.left)?0:_h.left;_c+=isNaN(_h.right)?0:_h.right;_d+=isNaN(_h.top)?0:_h.top;_d+=isNaN(_h.bottom)?0:_h.bottom;}if(_g=="CheckBox"||_g=="Radio"){_c+=3;}var _i=nexacro.toNumber(_a.currentstyle.buttonsize);if(!Eco.isEmpty(_i)&&!isNaN(_i)){if(_i<0){_c+=_i;}else{_c+=_i;}}var _j=_a.currentstyle.textpadding;if(_j){_c+=isNaN(_j.left)?0:_j.left;_c+=isNaN(_j.right)?0:_j.right;_d+=isNaN(_j.top)?0:_j.top;_d+=isNaN(_j.bottom)?0:_j.bottom;}_b[0]=_c;_b[1]=_d;}}return _b;},_getStyleSpaceSize:function(_a){var _b=Eco.XComp.Style;var _c=0,_d=0;var _e=_b.getMargin(_a);_c+=_e[0]+_e[2];_d+=_e[1]+_e[3];var _f=_b.getBorderWidth(_a);_c+=_f[0]+_f[2];_d+=_f[1]+_f[3];var _g=_b.getPadding(_a);_c+=_g[0]+_g[2];_d+=_g[1]+_g[3];return [_c,_d];},getPopupPosition:function(_a,_b,_c,_d,_e){var _f=_a._getWindow();var _g=_f.clientWidth;var _h=_f.clientHeight;var _i=Eco.XComp.PositionSize.convertXY(application.mainframe,[0,0],_a);var _j=_i[0];var _k=_i[1];if(isNaN(_i[0])||isNaN(_i[1])){return;}var _j=[_i[0],_i[0]+_a.getOffsetWidth()];var _k=[_i[1],_i[1]+_a.getOffsetHeight()];var _l={'left':0,'top':0,'right':_g,'bottom':_h,'width':_g,'height':_h};var _m=Eco.XComp.PositionSize._getDisplayPosition(_b,_c,_j,_k,_l,_d,_e);return _m;},_getDisplayPosition:function(_a,_b,_c,_d,_e,_f,_g,_h){if(_h!=true){_h=false;}var _i=Eco.XComp.PositionSize;var _j;if(_f=="horz"){_j=_i._getHorizontalPosition(_a,_b,_c,_d,_e,_f,_g,_h);}else if(_f=="vert"){_j=_i._getVerticalPosition(_a,_b,_c,_d,_e,_f,_g,_h);}var _k=_j[0];if(_j[1]===undefined&&_j[2]===undefined){if(_a>_e.width){_a=_e.width;}if(_b>_e.height){_b=_e.height;}_j=[_k,_e.left,_e.top,_a,_b];}else if(_j[1]===undefined){_j=[_k,_e.left,_j[2],_e.width,_b];}else if(_j[2]===undefined){_j=[_k,_j[1],_e.top,_a,_e.height];}return _j;},_getVerticalPosition:function(_a,_b,_c,_d,_e,_f,_g,_h){var _i=Eco.XComp.PositionSize;var _j;if(_e.bottom>=(_d[1]+_b+_g)){_j="bottom";_d=_d[1]+_g;}else if(_e.top<(_d[0]-_b-_g)){_j="top";_d=_d[0]-_b-_g;}else{if(_h==true){return ["right",undefined,undefined];}_f=(_f=="vert")?"horz":"vert";var _k=_i._getDisplayPosition(_a,_b,_c,_d,_e,_f,_g,true);return _k;}_c=_i._getHorizontalAlign(_a,_b,_c,_d,_e,_f,_g);return [_j,_c,_d];},_getHorizontalPosition:function(_a,_b,_c,_d,_e,_f,_g,_h){var _i=Eco.XComp.PositionSize;var _j;if(_e.right>=(_c[1]+_a+_g)){_j="right";_c=_c[1]+_g;}else if(_e.left<(_c[0]-_a-_g)){_j="left";_c=_c[0]-_a-_g;}else{if(_h==true){return ["bottom",undefined,undefined];}_f=(_f=="vert")?"horz":"vert";var _k=_i._getDisplayPosition(_a,_b,_c,_d,_e,_f,_g,true);return _k;}_d=_i._getVerticalAlign(_a,_b,_c,_d,_e,_f,_g);return [_j,_c,_d];},_getHorizontalAlign:function(_a,_b,_c,_d,_e,_f,_g){var _h=_e.right-(_c[0]+_a);if(_h>=0){_c=_c[0];}else if(_h<0){_c=_c[0]+_h;if(_c<_e.left){_c=undefined;}}else{_c=undefined;Eco.Logger.error({message:"unexpected situation!!",stack:true});}return _c;},_getVerticalAlign:function(_a,_b,_c,_d,_e,_f,_g){var _h=_e.bottom-(_d[0]+_b);if(_h>=0){_d=_d[0];}else if(_h<0){_d=_d[0]+_h;if(_d<_e.top){_d=undefined;}}else{_d=undefined;Eco.Logger.error({message:"unexpected situation!!",stack:true});}return _d;}});}