function AdfResizeTrackManager(a){this.Init(a)}AdfObject.createSubclass(AdfResizeTrackManager);AdfResizeTrackManager.prototype.Init=function(a){AdfResizeTrackManager.superclass.Init.call(this);this._listeners=[];this._element=a;this._RETRY_MAX_COUNT=2;this._retrySetScroll=0;this._onResizeTimeout=this._scrollListener=this._resizeListener=this._detectContraction=this._detectExpansion=this._oldHeight=this._oldWidth=this._invokeId=null};AdfResizeTrackManager.prototype.addListener=function(a){this._listeners.push(a)};
AdfResizeTrackManager.prototype.removeListener=function(a){for(var b=this._listeners.length-1;0<=b;b--)if(this._listeners[b]===a){this._listeners.splice(b,1);break}};AdfResizeTrackManager.prototype.isEmpty=function(){return 0==this._listeners.length};
AdfResizeTrackManager.prototype.start=function(){this._scrollListener=this.createCallback(AdfResizeTrackManager._handleScroll);if(this._element.attachEvent)this._resizeListener=this.createCallback(AdfResizeTrackManager._handleResize),this._element.attachEvent("onresize",this._resizeListener);else{var a=this._element.childNodes[0];this._detectExpansion=document.createElement("div");AdfDomUtils.addInlineStyle(this._detectExpansion,"position:absolute; overflow:hidden; visibility:hidden; top:0; left:0; right:0; bottom:0; direction:ltr;");
this._detectExpansion.className="AFDetectExpansion";var b=document.createElement("div");this._detectExpansion.appendChild(b);null!=a?this._element.insertBefore(this._detectExpansion,a):this._element.appendChild(this._detectExpansion);this._detectExpansion.addEventListener("scroll",this._scrollListener,!1);this._detectContraction=document.createElement("div");this._detectContraction.className="AFDetectContraction";AdfDomUtils.addInlineStyle(this._detectContraction,"position:absolute; overflow:hidden; visibility:hidden; top:0; left:0; right:0; bottom:0; direction:ltr;");
a=document.createElement("div");a.style.width="200%";a.style.height="200%";this._detectContraction.appendChild(a);this._element.insertBefore(this._detectContraction,this._detectExpansion);this._detectContraction.addEventListener("scroll",this._scrollListener,!1);this.initializeElements(!1)}};
AdfResizeTrackManager.prototype.stop=function(){null!=this._invokeId&&(AdfResizeTrackManager._cancelInvokeAfterPaint(this._invokeId),this._invokeId=null);null!=this._detectExpansion?(this._detectExpansion.removeEventListener("scroll",this._scrollListener,!1),this._detectContraction.removeEventListener("scroll",this._scrollListener,!1),this._element.removeChild(this._detectExpansion),this._element.removeChild(this._detectContraction)):this._element.detachEvent("onresize",this._resizeListener)};
AdfResizeTrackManager.prototype.initializeElements=function(a){var b=this._checkSize(a);a&&!b&&null!=this._detectExpansion.offsetParent&&this._adjust(this._oldWidth,this._oldHeight)};
AdfResizeTrackManager.prototype._checkSize=function(a){var b=!1;if(null!=this._detectExpansion.offsetParent){var c=this._detectExpansion.offsetWidth,d=this._detectExpansion.offsetHeight,e=AdfAgent.AGENT.getDomWindow().innerHeight;if(this._oldWidth!==c||this._oldHeight!==d&&d<e)this._retrySetScroll=this._RETRY_MAX_COUNT,this._adjust(c,d),b=!0,a&&this._notifyListeners(!0)}return b};
AdfResizeTrackManager.prototype._notifyListeners=function(a){if(0<this._listeners.length)if(a){null!==this._invokeId&&AdfResizeTrackManager._cancelInvokeAfterPaint(this._invokeId);var b=this;this._invokeId=AdfResizeTrackManager._invokeAfterPaint(function(){b._invokeId=null;for(var a=0;a<b._listeners.length;a++)b._listeners[a]()})}else for(a=0;a<this._listeners.length;a++)this._listeners[a]()};
AdfResizeTrackManager._handleScroll=function(a){a.stopPropagation();this._onResizeTimeout||(this._onResizeTimeout=AdfPage.PAGE.scheduleTimer(this,AdfResizeTrackManager._onResizeHandlerTimeout,{},100))};
AdfResizeTrackManager._onResizeHandlerTimeout=function(){!this._checkSize(!0)&&0<this._retrySetScroll&&null!=this._detectExpansion.offsetParent&&(0==this._detectExpansion.scrollLeft||0==this._detectExpansion.scrollTop)&&(this._retrySetScroll--,this._adjust(this._oldWidth,this._oldHeight));this._onResizeTimeout=null};AdfResizeTrackManager._handleResize=function(){this._notifyListeners(!1)};
AdfResizeTrackManager.prototype._adjust=function(a,b){this._oldWidth=a;this._oldHeight=b;var c=this._detectExpansion.firstChild.style,d=1;do c.width=a+d+"px",c.height=b+d+"px",this._detectExpansion.scrollLeft=this._detectExpansion.scrollTop=d,d++;while((0==this._detectExpansion.scrollTop||0==this._detectExpansion.scrollLeft)&&5>=d);this._detectContraction.scrollLeft=a;this._detectContraction.scrollTop=b};
AdfResizeTrackManager._invokeAfterPaint=function(a){var b=AdfAgent.AGENT;return b.getDomWindow().requestAnimationFrame?b.getDomWindow().requestAnimationFrame(a):b.getDomWindow().mozRequestAnimationFrame?b.getDomWindow().mozRequestAnimationFrame(a):b.getDomWindow().webkitRequestAnimationFrame?b.getDomWindow().webkitRequestAnimationFrame(a):b.getDomWindow().setTimeout(a,0)};
AdfResizeTrackManager._cancelInvokeAfterPaint=function(a){var b=AdfAgent.AGENT;return b.getDomWindow().cancelAnimationFrame?b.getDomWindow().cancelAnimationFrame(a):b.getDomWindow().mozCancelAnimationFrame?b.getDomWindow().mozCancelAnimationFrame(a):b.getDomWindow().webkitCancelAnimationFrame?b.getDomWindow().webkitCancelAnimationFrame(a):b.getDomWindow().clearTimeout(a)};