ASPxControlResizeManager = {
 GetControlCollection: function() {
  if(!_aspxIsExists(this.controls)) {
   this.controls = new Array();
   _aspxAttachEventToElement(window, "resize", new Function("ASPxControlResizeManager.OnWindowResizing();"));
   this.resizeTimerId = window.setTimeout("ASPxControlResizeManager.CheckResize();", 1000);
   }
  return this.controls;
 },
 Add: function(control) {
  if(!_aspxIsExists(control.GetCurrentSize))
   return;
  control.lastCheckedSize = control.GetCurrentSize();
  this.GetControlCollection().push(control);
 },
 Remove: function(control) {
  _aspxArrayRemove(this.GetControlCollection(), control);
 },
 Clear: function() {
  this.controls = null;
  window.clearTimeout(this.resizeTimerId);
 },
 CheckResize: function() {
  window.clearTimeout(this.resizeTimerId);
  var collection = this.GetControlCollection();
  var count = collection.length;
  var hasLiveElements = false;
  for(var i = count - 1; i >= 0; i--) {
   var control = collection[i];
   var size = control.GetCurrentSize();
   if(size == null) {
    this.Remove(control);
    continue;
   }
   var lastCheckedSize = control.lastCheckedSize;
   if(lastCheckedSize[0] != size[0]) {
    control.lastCheckedSize = size;
    control.OnWindowResized();
   }
   hasLiveElements = true;
  }
  if(hasLiveElements)
   this.resizeTimerId = window.setTimeout("ASPxControlResizeManager.CheckResize();", 1000);
  else
   this.Clear();
 },
 OnWindowResizing: function() {
  window.clearTimeout(this.resizeTimerId);
  this.resizeTimerId = window.setTimeout("ASPxControlResizeManager.CheckResize();", 250);
 }
};
