__aspxSchedulerStatusInfosQueue = new Array();
ASPxSchedulerStatusInfoType = _aspxCreateClass(null, { 
});
ASPxSchedulerStatusInfoType.Exception = "Exception";
ASPxSchedulerStatusInfoType.Error = "Error";
ASPxSchedulerStatusInfoType.Warning= "Warning";
ASPxSchedulerStatusInfoType.Info = "Info";
function aspxSchedulerRefreshStatusInfos(name) {
 AfterInitializeStatusInfos();
 var statusInfo = aspxGetControlCollection().Get(name);
 if (_aspxIsExists(statusInfo)) {
  statusInfo.RefreshStatusInfos();  
 }   
}
function AfterInitializeStatusInfos() {
 var count = __aspxSchedulerStatusInfosQueue.length;
 if(count == 0)
  return;
 for(var i = count - 1; i >= 0; i--) {
  var statusInfo = __aspxSchedulerStatusInfosQueue[i];
  var scheduler = aspxGetControlCollection().Get(statusInfo.schedulerControlId);
  if(_aspxIsExists(scheduler))
   scheduler.statusInfoManager.AddStatusInfo(statusInfo);
 }
 __aspxSchedulerStatusInfosQueue = new Array();
}
ASPxClientSchedulerStatusInfoManager = _aspxCreateClass(ASPxClientSchedulerRelatedControlBase, {   
 constructor: function(name) {
  this.constructor.prototype.constructor.call(this, name);
  this.statusInfos = new Array();
  this.visibleStatusInfo = null;
  this.image = new Object();
  this.ClearInfo();
 },
 Initialize: function() {
  this.constructor.prototype.Initialize.call(this);
  var scheduler = aspxGetControlCollection().Get(this.schedulerControlId);
  if (_aspxIsExists(scheduler)) {
   if(_aspxIsExists(scheduler.statusInfoManager)) {
    this.statusInfos = scheduler.statusInfoManager.statusInfos;
    this.visibleStatusInfo = scheduler.statusInfoManager.visibleStatusInfo;
    this.contentDiv = scheduler.statusInfoManager.contentDiv;
    this.subjectSpan = scheduler.statusInfoManager.subjectSpan;
    this.detailInfoSpan = scheduler.statusInfoManager.detailInfoSpan;
    this.image = scheduler.statusInfoManager.image;
    this.visibleImage = scheduler.statusInfoManager.visibleImage;
    this.detailInfoLink = scheduler.statusInfoManager.detailInfoLink;
   }
   else {
    this.contentDiv =  _aspxGetElementById(this.name + "_contentDiv");
    this.subjectSpan = _aspxGetElementById(this.name + "_subject");
    this.detailInfoSpan = _aspxGetElementById(this.name + "_detailInfo");
    this.detailInfoLink = _aspxGetElementById(this.name + "_detailInfoLink");
    this.image[ASPxSchedulerStatusInfoType.Exception] = _aspxGetElementById(this.name + "_exceptionImg");
    this.image[ASPxSchedulerStatusInfoType.Error] = _aspxGetElementById(this.name + "_errorImg");
    this.image[ASPxSchedulerStatusInfoType.Warning] = _aspxGetElementById(this.name + "_warningImg");
    this.image[ASPxSchedulerStatusInfoType.Info] = _aspxGetElementById(this.name + "_infoImg");
    this.visibleImage = null;    
    this.contentDiv.parentNode.removeChild(this.contentDiv);
   }
   scheduler.statusInfoManager = this;
  }
  var func = new Function("aspxSchedulerRefreshStatusInfos('" + this.name + "');");  
  _aspxSetTimeout(func, 1);
 },
 SetInfo: function(imageType, subject, detail) {
  this.subject = subject;
  this.detailInfo = detail;
  this.imageType = imageType;
 },
 ClearInfo: function() {
  this.SetInfo("", "", "");
 },
 AddStatusInfo: function(statusInfo) {
  _aspxArrayPush(this.statusInfos, statusInfo);  
 },
 Clear: function() {
  this.ClearInfo();
  this.RefreshStatusInfos();  
 }, 
 RegisterScriptsRestartHandler: function() { 
  var func = new Function("aspxSchedulerRefreshStatusInfos('" + this.name + "');");  
  _aspxAddScriptsRestartHandler(this.name, func);
 },
 RefreshStatusInfos: function() {
  var statusInfo = this.GetStatusInfo();
  if(_aspxIsExists(this.visibleStatusInfo))
   this.visibleStatusInfo.HideContent();
  if(_aspxIsExists(statusInfo) && (this.subject != "" || this.detailInfo != "")) {
   this.subjectSpan.innerHTML = this.subject;
   this.detailInfoSpan.innerHTML = this.detailInfo;
   _aspxSetElementDisplay(this.detailInfoLink, this.detailInfo != "");
   if(_aspxIsExists(this.visibleImage))
    _aspxSetElementDisplay(this.visibleImage, false);
   this.visibleImage = this.image[this.imageType];
   if(_aspxIsExists(this.visibleImage))
    _aspxSetElementDisplay(this.visibleImage, true);   
   statusInfo.SetContent(this.contentDiv);
   this.visibleStatusInfo = statusInfo;   
  }
 },
 GetStatusInfo: function() {
  var maxPriority = -1;
  var result = null;
  for(var i = this.statusInfos.length - 1; i >= 0; i--) {
   var statusInfo = this.statusInfos[i];
   if(statusInfo.IsVisible()) {
    if(statusInfo.priority > maxPriority) {
     maxPriority = statusInfo.priority;
     result = statusInfo;
    }
   }
   else
    _aspxArrayRemoveAt(this.statusInfos, i);
  }
  return result;  
 },
 ShowExceptionInfo: function(msg) {
  var subjectLengthEnd = msg.indexOf(",");
  var detailInfoLengthEnd = msg.indexOf("|");
  var subjectLength = parseInt(msg.substr(0, subjectLengthEnd));
  var detailInfoLength = parseInt(msg.substr(subjectLengthEnd + 1, detailInfoLengthEnd - subjectLengthEnd - 1));
  var subject = msg.substr(detailInfoLengthEnd + 1, subjectLength);
  var detailInfo = msg.substr(detailInfoLengthEnd + subjectLength + 1, detailInfoLength);
  this.SetInfo(ASPxSchedulerStatusInfoType.Exception, subject, detailInfo);
 }
});
ASPxClientSchedulerStatusInfo = _aspxCreateClass(ASPxClientControl, {   
 constructor: function(name) {
  this.constructor.prototype.constructor.call(this, name);
  this.priority = 0;
  this.currentContent = null;
 },
 Initialize: function() {
  this.constructor.prototype.Initialize.call(this);  
  this.contentDiv = _aspxGetElementById(this.name + "_mainDiv");
  this.outerContainer = this.isInsideRow ? this.contentDiv.parentNode.parentNode : this.contentDiv;
  _aspxArrayPush(__aspxSchedulerStatusInfosQueue, this);        
 },
 SetContent: function(content) {
  this.HideContent();
  var newContent = content.cloneNode(true);
  this.contentDiv.appendChild(newContent);
  _aspxSetElementDisplay(this.outerContainer, true);
  this.currentContent = newContent;
 },
 HideContent: function() {
  if(_aspxIsExists(this.currentContent)) {
   var parentNode = this.currentContent.parentNode;
   if(_aspxIsExists(parentNode)) {
    parentNode.removeChild(this.currentContent);
   }
   }
   if(_aspxIsExists(this.contentDiv))
   _aspxSetElementDisplay(this.outerContainer, false);
  this.currentContent = null;
 },
 IsVisible: function()  {
  this.contentDiv = _aspxGetElementById(this.name + "_mainDiv");
  if(_aspxIsExists(this.contentDiv)) {
   this.outerContainer = this.isInsideRow ? this.contentDiv.parentNode.parentNode : this.contentDiv;
   return true;
  }
  return false;
 }
});

