SchedulerMenuItemId = _aspxCreateClass(null, {
});
SchedulerMenuItemId.Custom = "Custom";
SchedulerMenuItemId.OpenAppointment = "OpenAppointment";
SchedulerMenuItemId.PrintAppointment = "PrintAppointment";
SchedulerMenuItemId.DeleteAppointment = "DeleteAppointment";
SchedulerMenuItemId.EditSeries = "EditSeries";
SchedulerMenuItemId.NewAppointment = "NewAppointment";
SchedulerMenuItemId.NewAllDayEvent = "NewAllDayEvent";
SchedulerMenuItemId.NewRecurringAppointment = "NewRecurringAppointment";
SchedulerMenuItemId.NewRecurringEvent = "NewRecurringEvent";
SchedulerMenuItemId.GotoThisDay = "GotoThisDay";
SchedulerMenuItemId.GotoToday = "GotoToday";
SchedulerMenuItemId.GotoDate = "GotoDate";
SchedulerMenuItemId.OtherSettings = "OtherSettings";
SchedulerMenuItemId.CustomizeCurrentView = "CustomizeCurrentView";
SchedulerMenuItemId.CustomizeTimeRuler = "CustomizeTimeRuler";
SchedulerMenuItemId.AppointmentDragMove = "AppointmentDragMove";
SchedulerMenuItemId.AppointmentDragCopy = "AppointmentDragCopy";
SchedulerMenuItemId.AppointmentDragCancel = "AppointmentDragCancel";
SchedulerMenuItemId.StatusSubMenu = "StatusSubMenu";
SchedulerMenuItemId.LabelSubMenu = "LabelSubMenu";
SchedulerMenuItemId.RulerMenu = "RulerMenu";
SchedulerMenuItemId.AppointmentMenu = "AppointmentMenu";
SchedulerMenuItemId.DefaultMenu = "DefaultMenu";
SchedulerMenuItemId.AppointmentDragMenu = "AppointmentDragMenu";
SchedulerMenuItemId.RestoreOccurrence = "RestoreOccurrence";
SchedulerMenuItemId.SwitchViewMenu = "SwitchViewMenu";
SchedulerMenuItemId.SwitchToDayView = "SwitchToDayView";
SchedulerMenuItemId.SwitchToWorkWeekView = "SwitchToWorkWeekView";
SchedulerMenuItemId.SwitchToWeekView = "SwitchToWeekView";
SchedulerMenuItemId.SwitchToMonthView = "SwitchToMonthView";
SchedulerMenuItemId.SwitchToTimelineView = "SwitchToTimelineView";
SchedulerMenuItemId.TimeScaleEnable = "TimeScaleEnable";
SchedulerMenuItemId.TimeScaleVisible = "TimeScaleVisible";
AppointmentPropertyNames = _aspxCreateClass(null, {});
AppointmentPropertyNames.Normal = "Description;Subject;Start;AllDay;StatusId;LabelId;Location";
AppointmentPropertyNames.Pattern = "Description;Subject;Start;AllDay;StatusId;LabelId;Location;Pattern";
ASPxRelativeCoordinatesCalculatorBase = _aspxCreateClass(null, {
 constructor: function(parentElement) {
  this.parentElement = parentElement;
  this.calculatedElements = new Array();
  this.innerParentElement = this.GetInnerParentElement();
  this.CreateLayers();
  this.SetInnerParentElementPosition();
 },
 GetInnerParentElement: function() {
  return this.parentElement;
 },
 SetInnerParentElementPosition: function() {
 },
 CreateLayers: function() {
  this.selectionLayer = this.CreateLayer();
  this.appointmentLayer = this.CreateLayer();
  this.navButtonLayer = this.CreateLayer();
  this.moreButtonLayer = this.CreateLayer();
 },
 CreateLayer: function() {
  var result = document.createElement(__aspxIE ? 'SPAN' : 'DIV');
  this.innerParentElement.appendChild(result);
  return result;
 },
 RemoveLayers: function(keepPrevAppointments) {  
  _aspxRemoveChildFromParent(this.innerParentElement, this.selectionLayer);
  if(keepPrevAppointments)
   this.innerParentElement.removeChild(this.appointmentLayer);
  else
   _aspxRemoveChildFromParent(this.innerParentElement, this.appointmentLayer);
  _aspxRemoveChildFromParent(this.innerParentElement, this.navButtonLayer);
  _aspxRemoveChildFromParent(this.innerParentElement, this.moreButtonLayer);
 },
 CalcRelativeElementLeft: function(element) {
  if(!_aspxIsExists(element.absoluteCellLeft)) {
   element.absoluteCellLeft = _aspxGetAbsoluteX(element) - _aspxGetAbsoluteX(this.innerParentElement);
   this.AddToCalculatedElements(element);
  }
  return element.absoluteCellLeft;
 },
 CalcRelativeElementRight: function(element) {
  if(!_aspxIsExists(element.absoluteCellRight)) {
   element.absoluteCellRight = this.CalcRelativeElementLeft(element) + element.offsetWidth;
   this.AddToCalculatedElements(element);
  }
  return element.absoluteCellRight;
 },
 CalcRelativeElementTop: function(element) {
  if(!_aspxIsExists(element.absoluteCellTop)) {
   element.absoluteCellTop = _aspxGetAbsoluteY(element) - _aspxGetAbsoluteY(this.innerParentElement);
   this.AddToCalculatedElements(element);
  }
  return element.absoluteCellTop;
 },
 CalcRelativeElementBottom: function(element) {
  if(!_aspxIsExists(element.absoluteCellBottom)) {
   element.absoluteCellBottom = this.CalcRelativeElementTop(element) + element.offsetHeight;;
   this.AddToCalculatedElements(element);
  }
  return element.absoluteCellBottom;
 },
 CalcRelativeContainerBounds: function(viewInfo, container) {
  if(!_aspxIsExists(container.isCalculated) || !container.isCalculated) {
   var firstCell = viewInfo.GetCell(container.containerIndex, 0);
   var lastCell = viewInfo.GetCell(container.containerIndex, container.cellCount - 1);
   var left = this.CalcRelativeElementLeft(firstCell);
   var dxtop = this.CalcRelativeElementTop(firstCell);
   var right = this.CalcRelativeElementRight(lastCell);
   var bottom = this.CalcRelativeElementBottom(lastCell);
   var bounds = new Object();
   bounds.left = left;
   bounds.top = dxtop;
   bounds.width = right - left;
   bounds.height = bottom - dxtop;
   container.bounds = bounds;
   this.AddToCalculatedElements(container);
  }
  return container.bounds;
 },
 AddToCalculatedElements: function(element) {
    if(!_aspxIsExists(element.isCalculated) || !element.isCalculated) {
   element.isCalculated = true;
   _aspxArrayPush(this.calculatedElements, element);
    }
 },
 Clear: function() {
  var count = this.calculatedElements.length;
  for(var i = 0; i < count; i++) {
   var element = this.calculatedElements[i];
   if(!_aspxIsExists(element.bounds)) {
    element.isCalculated = false;
    element.absoluteCellLeft = null;
    element.absoluteCellRight = null;
    element.absoluteCellTop = null;
    element.absoluteCellBottom = null;
   }
   else {
    element.isCalculated = false;
   }
   if(_aspxIsExists(element.hasMoreButton))
    element.hasMoreButton = false;
  }
  this.ClearMoreButtonLayer();
  this.SetInnerParentElementPosition();
  _aspxArrayClear(this.calculatedElements);
 },
 ClearMoreButtonLayer: function() {
  this.moreButtonLayer.innerHTML = "";
 }, 
 AppendChildToLayer: function(child, layer) {
  layer.appendChild(child);
 },
 AppendChildToNavButtonLayer: function(child, layer) {
  if(!_aspxIsExists(layer))
   layer = this.navButtonLayer;
  if(child.parentNode != layer)
   layer.appendChild(child);
 },
 AppendChildToAppointmentLayer: function(child) {
  this.appointmentLayer.appendChild(child);
 },
 AppendChildToMoreButtonLayer: function(child) {
  this.moreButtonLayer.appendChild(child);
 },
 AfterCalculateAppointments: function(appointmentCalculator) {
 },
 CalcCellHeight: function(cell) {
  return cell.offsetHeight;
 }
});
ASPxRelativeCoordinatesCalculator = _aspxCreateClass(ASPxRelativeCoordinatesCalculatorBase, {
 constructor: function(parentElement) {
  this.constructor.prototype.constructor.call(this, parentElement);
 }
});
ASPxSchedulerHitTestResult = _aspxCreateClass(null, {
 constructor: function(cell, selectionDiv, appointmentDiv, resizeDiv, smartTag) {
  this.cell = cell;
  this.selectionDiv = selectionDiv;
  this.appointmentDiv = appointmentDiv;
  this.resizeDiv = resizeDiv;
  this.smartTag = smartTag;
 }
});
ASPxRelativeCoordinatesCalculatorWithScrolling = _aspxCreateClass(ASPxRelativeCoordinatesCalculatorBase, {
 constructor: function(parentElement, viewInfo, scrollableContainer) {
  this.viewInfo = viewInfo;
  this.scrollableContainer = scrollableContainer;
  this.constructor.prototype.constructor.call(this, parentElement);
  this.bottomAppointmentIndent = 2;
 },
 GetInnerParentElement: function() {
  return this.scrollableContainer;
 },
 SetInnerParentElementPosition: function() {
  var containerCount = this.viewInfo.cellContainers.length;
  var cellCount = this.viewInfo.cellContainers[containerCount - 1].cellCount;
  var startCell = this.viewInfo.GetCell(0, 0);
  var endCell = this.viewInfo.GetCell(containerCount - 1,  cellCount - 1);
  if(!_aspxIsExists(startCell) || !_aspxIsExists(endCell))
   return;
  var parentLeft = _aspxGetAbsoluteX(startCell) - _aspxGetAbsoluteX(this.parentElement);
  var parentRight = _aspxGetAbsoluteX(endCell) - _aspxGetAbsoluteX(this.parentElement) + endCell.offsetWidth;
  var parentTop = _aspxGetAbsoluteY(startCell) - _aspxGetAbsoluteY(this.parentElement);
  var parentBottom = _aspxGetAbsoluteY(endCell) - _aspxGetAbsoluteY(this.parentElement) + endCell.offsetHeight;
  this.innerParentElement.style.left = parentLeft + "px";
  this.innerParentElement.style.top = parentTop + "px";
  this.innerParentElement.style.width = parentRight - parentLeft + "px";
  this.innerParentElement.style.height = parentBottom - parentTop + "px";
  if(!__aspxOpera) {
   var scrollWidth = this.innerParentElement.offsetWidth - this.innerParentElement.clientWidth;
   this.innerParentElement.style.width = this.innerParentElement.offsetWidth + scrollWidth + "px";
  }
 },
 CalcCellHeight: function(cell) {
  return this.innerParentElement.scrollHeight;
 },
 AfterCalculateAppointments: function(appointmentCalculator) {
  var startCell = this.viewInfo.GetCell(0, 0);
  if(_aspxIsExists(this.viewInfo.scheduler.privateAllDayAreaHeight))
   this.innerParentElement.style.height = this.viewInfo.scheduler.privateAllDayAreaHeight;
  else
   if(_aspxIsExists(appointmentCalculator.maxBottom) && appointmentCalculator.maxBottom > 0) {
    this.innerParentElement.style.height = "";
    startCell.style.height = "";
    var newHeight = Math.max(appointmentCalculator.maxBottom + this.bottomAppointmentIndent, startCell.offsetHeight);
    this.innerParentElement.style.height = newHeight + "px";
   }
  if(_aspxIsExists(startCell)) {
   var borderHeight = startCell.offsetHeight - startCell.clientHeight;
   startCell.style.height = this.scrollableContainer.offsetHeight - borderHeight + "px";
  }
  if(__aspxOpera) {
   var scrollWidth = this.innerParentElement.offsetWidth - this.innerParentElement.clientWidth;
   this.innerParentElement.style.width = this.innerParentElement.offsetWidth + scrollWidth + "px";
  }
 }
});
function OnSchedulerWindowResizingStub() {
 ASPxControlResizeManager.OnWindowResizing();
}
ASPxControlResizeManager = {
 GetControlCollection: function() {
  if(!_aspxIsExists(this.controls)) {
   this.controls = new Array();
   _aspxAttachEventToElement(window, "resize", new Function("OnSchedulerWindowResizingStub();"));
   this.resizeTimerId = window.setTimeout("ASPxControlResizeManager.CheckResize();", 1000);
   }
  return this.controls;
 },
 Add: function(control) {
  if(!_aspxIsExists(control.GetCurrentSize))
   return;
  control.lastCheckedSize = control.GetCurrentSize();
  _aspxArrayPush(this.GetControlCollection(), 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);
 }
};
ASPxClientScheduler = _aspxCreateClass(ASPxClientControl, {
 constructor: function(name){  
  this.constructor.prototype.constructor.call(this, name);
  this.cellIdRegExp = /DXCnt(([hv])(\d+))_(\d+)/;
  this.ActiveViewChanging = new ASPxClientEvent();
  this.ActiveViewChanged = new ASPxClientEvent();
  this.SelectionChanged = new ASPxClientEvent();
  this.VisibleIntervalChanged = new ASPxClientEvent();
  this.MoreButtonClicked = new ASPxClientEvent();
  this.AppointmentsSelectionChanged = new ASPxClientEvent();
  this.MenuItemClicked = new ASPxClientEvent();
  this.AppointmentDrop = new ASPxClientEvent();
  this.AppointmentResize = new ASPxClientEvent();
  this.isInsideBeginInit = false;
  this.isReadyForCallbacks = false;
  this.changedBlocks = null;
  this.isCallbackMode = true;
  this.menuManager = new ASPxSchedulerMenuManager(this);
  this.activeFormType = ASPxSchedulerFormType.None;
  this.aptFormVisibility = ASPxSchedulerFormVisibility.None;
  this.gotoDateFormVisibility = ASPxSchedulerFormVisibility.None;
  this.recurrentAppointmentDeleteFormVisibility = ASPxSchedulerFormVisibility.None;
  this.allowMultipleCallbacks = false;  
  this.privateAllowAppointmentMultiSelect = true;
  this.privateShowAllAppointmentsOnTimeCells = false;
  this.contextMenuHandlers = [];
  this.prevCallbackResults = new Object();
  this.funcCallbacks = new Array();
  this.appointmentSmartTagEnabled = true;
  this.selectionSmartTagEnabled = true;
  this.funcCallbackCount = 0;
  this.visibleIntervals = new Array();
 },
 _constDXAppointment: function() { return "_AptDiv"; },
 _constDXSchedulerContentCell: function() { return "DXCnt"; },
 _constDXSelectionDiv: function() { return "selectionDiv"; },
 _constDXAppointmentAdorner: function() { return "aptAdornerDiv"; },
 _constEmptyResource: function() { return "null"; },
 Initialize: function(){
  this.constructor.prototype.Initialize.call(this);
  this.EndInit();
 },
 BeginInit: function() {
  this.reminderUpTimeDelay = null;
  if(_aspxIsExists(this.onCallback))
   this.onCallback();
  this.isInsideBeginInit = true;
  ASPxControlResizeManager.Remove(this);
  this.deferredSetScrollPosition = null;
  this.syncColumnCount = -1;
  this.syncMasterRowIndex = -1;
  this.appointmentSelection = new ASPxAppointmentSelection(this);
  this.appointmentSelection.BeginUpdate();
  this.selection = null;
  this.navButtonAnchors = new Array();
  this.ClearNavigationButtons();
  this.appointments = new Object();
  this.nonpermanentAppointments = new Object();
  this.timelineHeaderLevels = new Array();
  this.privateAllDayAreaHeight = null;
  this.privateShowMoreButtonsOnEachColumn = false;
  this.RecreateViewInfo();
  this.privateRaiseActiveViewTypeChanged = false;
  this.privateRaiseVisibleIntervalChanged = false;
 },
 RecreateViewInfo: function() {
  var usePrevContainer = this.changedBlocks && !this.changedBlocks.ContainerBlockChanged;
  var usePrevNavButtons = this.changedBlocks && !this.changedBlocks.NavButtonsBlockChanged;
  if(!usePrevNavButtons)
   this.navButtonsCache = new Object();
  if(usePrevContainer) {
   var keepPrevAppointment = this.changedBlocks && !this.changedBlocks.AppointmentsBlockChanged;
   this.horizontalViewInfo.parent.RemoveLayers(keepPrevAppointment);
   this.verticalViewInfo.parent.RemoveLayers(keepPrevAppointment);
   this.ResetCellsAbsolutePosition();
  }
  if(this.horizontalViewInfo)
   this.horizontalViewInfo.Dispose();
  if(this.verticalViewInfo)
   this.verticalViewInfo.Dispose();
  this.horizontalViewInfo = new ASPxClientHorizontalSchedulerViewInfo(this, this.horizontalViewInfo, usePrevContainer);
  this.verticalViewInfo = new ASPxClientVerticalSchedulerViewInfo(this, this.verticalViewInfo, usePrevContainer);
 },
 EndInit: function() {
  this.SubscribeEvents();
  this.isInsideBeginInit = false;
  this.resourceNavigatorRow = this.GetChild("_resourceNavigatorRow");
  this.innerContentElement = _aspxGetElementById(this.name + "_containerBlock_content");
  this.containerTable = _aspxGetElementById(this.name + "_containerBlock_containerTable");
  this.containerCell = _aspxGetElementById(this.name + "_containerBlock_innerContent");
  this.selectionDiv = _aspxGetElementById(this.name + "_commonControlsBlock_selectionDiv");
  this.smartTagDiv = _aspxGetElementById(this.name + "_commonControlsBlock_selectionSmartTagDiv_mainDiv");
  this.topResizeDiv = _aspxGetElementById(this.name + "_commonControlsBlock_topResizeControlDiv");
  this.bottomResizeDiv = _aspxGetElementById(this.name + "_commonControlsBlock_bottomResizeControlDiv");
  this.leftResizeDiv = _aspxGetElementById(this.name + "_commonControlsBlock_leftResizeControlDiv");
  this.rightResizeDiv = _aspxGetElementById(this.name + "_commonControlsBlock_rightResizeControlDiv");
  this.aptAdorner = _aspxGetElementById(this.name + "_commonControlsBlock_aptAdornerDiv");
  if(_aspxIsExists(this.smartTagDiv)) {
   this.smartTagDiv.aspxParentControl = this; 
   this.smartTagDiv.smartTagType = ASPxSchedulerSmartTagType.Selection;
  }
  this.appointmentSmartTagDiv = _aspxGetElementById(this.name + "_commonControlsBlock_appointmentSmartTagDiv_mainDiv");
  if(_aspxIsExists(this.appointmentSmartTagDiv)) {
   this.appointmentSmartTagDiv.aspxParentControl = this;
   this.appointmentSmartTagDiv.smartTagType = ASPxSchedulerSmartTagType.Appointment;
  }
  this.mainDiv = _aspxGetElementById(this.name);
  this.ObtainCellTables();
  this.PrepareSchedulerViewInfos();
  this.appointmentSelection.Prepare();
  if(_aspxIsExists(this.innerContentElement)) {
   this.RecalcLayout();
   this.ShowCellSelection();
   if(_aspxIsExists(this.deferredSetScrollPosition))
    this.SetScrollPosition(this.deferredSetScrollPosition);
   ASPxControlResizeManager.Add(this);
   this.EnableResize();
  }
  this.appointmentSelection.EndUpdate();
  this.HideLoadingPanel();
  this.RaiseClientEvents();
  this.isReadyForCallbacks = true;
  this.SetReminderTimer();
 },
 SetVisibleInterval: function(transferVisibleInterval) {
  _aspxArrayClear(this.visibleIntervals); 
  var count = transferVisibleInterval.length;
  var propertyApplyController = new ASPxSchedulerPropertyApplyController(this);
  var result = new Array();
  for (var i = 0; i < count; i++) {
   var transerInterval = transferVisibleInterval[i];
   var interval = propertyApplyController.CreateIntervalPropertyValue(null, transerInterval);
   _aspxArrayPush(this.visibleIntervals, interval);
  }
 },
 SetReminders: function(delay) {
  this.reminderUpTimeDelay = delay;
  this.reminderTimerId = null;
  this.enableReminderTimer = true;
  this.suspendedCallAspxReminderAlerted = false;
 },
 SetReminderTimer: function() {
  if (this.reminderUpTimeDelay == null)
   return;
  this.reminderTimerId = _aspxSetTimeout("aspxReminderAlerted(" + '"'+this.name + '")', this.reminderUpTimeDelay);  
 },
 ClearReminderTimer: function() {
  if (this.reminderTimerId != null) {
   _aspxClearTimer(this.reminderTimerId);
   this.reminderTimerId = null;
  }
 },
 DisableReminderTimer: function() {
  this.enableReminderTimer = false;
 },
 EnableReminderTimer: function() {
  this.enableReminderTimer = true;
  if (this.suspendedCallAspxReminderAlerted) {
   this.suspendedCallAspxReminderAlerted = false;
   aspxReminderAlerted(this.name);
  }
 },
 AddContextMenuEvent: function(elementId, handlerFunc) {
  _aspxArrayPush(this.contextMenuHandlers, [elementId, handlerFunc]);
 },
 SubscribeEvents: function() {
  var count = this.contextMenuHandlers.length;
  for(var i = 0; i < count; i++) {
   var current = this.contextMenuHandlers[i];
   var element = _aspxGetElementById(current[0]);
   if(_aspxIsExists(element)) {
    element.oncontextmenu = new Function("event", current[1]);
   }
  }
 },
 RaiseClientEvents: function() {
  if(_aspxIsExists(this.RaiseActiveViewChanged) && this.privateRaiseActiveViewTypeChanged)
   this.RaiseActiveViewChanged();
  if(_aspxIsExists(this.RaiseVisibleIntervalChanged) && this.privateRaiseVisibleIntervalChanged)
   this.RaiseVisibleIntervalChanged();
 },
 GetCurrentSize: function() {
  if(this.mainDiv && this.mainDiv.parentNode)
   return [this.innerContentElement.clientWidth, this.innerContentElement.clientHeight];
  else
   return null;
 },
 GetToolTipControl: function() {
  return aspxGetControlCollection().Get(this.name + "_commonControlsBlock_toolTipControl");
 },
 PrivateSetActiveViewType: function(newViewType) {
  var activeViewType = this.GetActiveViewType();
  if (activeViewType == newViewType)
   return;
  this.privateActiveViewType = newViewType;
  this.privateRaiseActiveViewTypeChanged = true;
 },
 PrivateSetAllDayAreaHeight: function(height) {
  this.privateAllDayAreaHeight = height;
 },
 PrivateSetGroupType: function(newGroupType) {
  this.privateGroupType = newGroupType;
 },
 PrivateSetAppointmentHeight: function(height) {
  this.privateAppointmentHeight = parseInt(height);
 },
 BeginAppointmentResizeAtLeft: function(appointmentViewInfo) {
  var appointmentDiv = appointmentViewInfo.contentDiv;
  if(_aspxIsExists(appointmentDiv))
   new ASPxResizeHelper(this, appointmentDiv, aspxAppointmentResizeLeft);
 },
 BeginAppointmentResizeAtRight: function(appointmentViewInfo) {
  var appointmentDiv = appointmentViewInfo.contentDiv;
  if(_aspxIsExists(appointmentDiv))
   new ASPxResizeHelper(this, appointmentDiv, aspxAppointmentResizeRight);
 },
 BeginAppointmentResizeAtTop: function(appointmentViewInfo) {
  var appointmentDiv = appointmentViewInfo.contentDiv;
  if(_aspxIsExists(appointmentDiv))
   new ASPxResizeHelper(this, appointmentDiv, aspxAppointmentResizeTop);
 },
 BeginAppointmentResizeAtBottom: function(appointmentViewInfo) {
  var appointmentDiv = appointmentViewInfo.contentDiv;
  if(_aspxIsExists(appointmentDiv))
   new ASPxResizeHelper(this, appointmentDiv, aspxAppointmentResizeBottom);
 },
 ObtainCellTables: function() {
  this.horzTable = this.GetContainerElementById("horzContainerTable");
  if(!_aspxIsExists(this.horzTable))
   this.horzTable = this.GetContainerElementById("content");
  this.vertTable = this.GetContainerElementById("vertTable");
  if(!_aspxIsExists(this.vertTable))
   this.vertTable = this.GetContainerElementById("content");
 },
 GetIsDayBasedView: function() {
  return this.privateActiveViewType == ASPxSchedulerViewType.Day || this.privateActiveViewType == ASPxSchedulerViewType.WorkWeek;
 },
 PrepareSchedulerViewInfos: function() {
  this.horizontalViewInfo.Initialize(this.horzTable);
  this.verticalViewInfo.Initialize(this.vertTable);
  var horizontalContainer = this.GetContainerElementById("horizontalContainer");
  var dayBasedView = this.GetIsDayBasedView();
  if(!_aspxIsExists(horizontalContainer))
   this.horizontalParent = new ASPxRelativeCoordinatesCalculator(this.containerCell);
  else {
   var scrollableContainer = this.GetContainerElementById("scrollableContainer");
   if(_aspxIsExists(scrollableContainer))
    this.horizontalParent = new ASPxRelativeCoordinatesCalculatorWithScrolling(horizontalContainer, this.horizontalViewInfo, scrollableContainer);
  else
   this.horizontalParent = new ASPxRelativeCoordinatesCalculator(horizontalContainer);
  }
  this.horizontalViewInfo.Prepare(this.horizontalParent);
  var verticalContainer = this.GetContainerElementById("verticalContainer");
  if (!_aspxIsExists(verticalContainer))
   this.verticalParent = new ASPxRelativeCoordinatesCalculator(this.containerCell);
  else
   this.verticalParent = new ASPxRelativeCoordinatesCalculator(verticalContainer);
  this.verticalViewInfo.Prepare(this.verticalParent);
 },
 EnableResize: function() {
  this.processResize = true;
 },
 DisableResize: function() {
  this.processResize = false;
 },
 IsResizeEnabled: function() {
  return _aspxIsExists(this.processResize) && this.processResize;
 },
 OnWindowResized: function() {
  if(this.isInsideBeginInit || !this.IsResizeEnabled())
   return;
  this.DisableResize();
  this.ResetCellsAbsolutePosition();
  this.RecalcLayout();
  this.ShowCellSelection();
  this.AlignNavigationButtons();
  this.appointmentSelection.RecalcSelection();
  this.EnableResize();
 },
 ResetCellsAbsolutePosition: function() {
  this.verticalViewInfo.parent.Clear();
  this.horizontalViewInfo.parent.Clear();
 }, 
 FormatHeadersContentOptimally: function() {
  this.FormatHeadersContentOptimallyCore(this.datesForFormatsWithoutYearToolTips, this.datesForFormatsWithoutYearLocations, this.datesForFormatsWithoutYear, this.formatsWithoutYear, ASPxSchedulerMeasurer.SetOptimalHeadersContent);
  this.FormatHeadersContentOptimallyCore(this.datesForFormatsWithoutYearAndWeekDayToolTips, this.datesForFormatsWithoutYearAndWeekDayLocations, this.datesForFormatsWithoutYearAndWeekDay, this.formatsWithoutYearAndWeekDay, ASPxSchedulerMeasurer.SetOptimalHeadersContent);
  this.FormatHeadersContentOptimallyCore(this.datesForFormatsNewYearLocationsToolTips, this.datesForFormatsNewYearLocations, this.datesForFormatsNewYear, this.formatsNewYear, ASPxSchedulerMeasurer.SetOptimalHeadersContent);
  this.FormatHeadersContentOptimallyCore(this.daysForDayOfWeekFormatsLocationsToolTips, this.daysForDayOfWeekFormatsLocations, this.daysForDayOfWeekFormats, null, ASPxSchedulerMeasurer.SetOptimalDayOfWeekHeadersContent);
  this.FormatHeadersContentOptimallyCore(this.datesForDayNumberFormatToolTips, this.datesForDayNumberFormatLocations, this.datesForDayNumberFormat, null, ASPxSchedulerMeasurer.SetOptimalDayNumberHeaderContent);
  this.FormatHeadersContentOptimallyCore(this.datesForDateCustomFormatToolTips, this.datesForDateCustomFormatLocations, this.datesForDateCustomFormat, this.datesForDateCustomFormatCaptions, ASPxSchedulerMeasurer.SetCustomDateHeaderContent);
  this.FormatHeadersContentOptimallyCore(this.datesForDayOfWeekCustomFormatToolTips, this.datesForDayOfWeekCustomFormatLocations, this.datesForDayOfWeekCustomFormat, this.datesForDayOfWeekCustomFormatCaptions, ASPxSchedulerMeasurer.SetCustomDayOfWeekHeaderContent);
 },
 ClearDatesForFormats: function() {
  delete this.datesForFormatsWithoutYearLocations;
  delete this.datesForFormatsWithoutYearAndWeekDayLocations;
  delete this.datesForFormatsNewYearLocations;
  delete this.daysForDayOfWeekFormatsLocations;
  delete this.datesForDayNumberFormatLocations;
  delete this.datesForDateCustomFormatLocations;
  delete this.datesForDayOfWeekCustomFormatLocations;
 },
 FormatHeadersContentOptimallyCore: function(headerToolTips, headerLocations, dates, formats, delegate) {
   if (_aspxIsExists(headerLocations)) {
   var headers = this.GetHeadersByLocation(headerLocations);
   if (headers.length > 0 && _aspxIsExists(dates)) 
    delegate.call(ASPxSchedulerMeasurer, headers, dates, formats, headerToolTips);
   }
 },
 GetHeadersByLocation: function(locations) {
  var count = locations.length;
  var headers = [];
  for (var i = 0; i<count; i++) {
   var location = locations[i];
   var rowIndex = location[0];
   var cellIndex = location[1];
   var header = this.horzTable.rows[rowIndex].cells[cellIndex];
   _aspxArrayPush(headers, header);
  }
  return headers;
 },
 ClearNavigationButtons: function() {
  if (_aspxIsExists(this.navButtons)) {
   var count = this.navButtons.length;
   for(var i = 0; i < count; i++)
    this.ClearNavigationButton(this.navButtons[i]);
   }
  this.navButtons = new Array();
 },
 ClearNavigationButton: function(navBtn) {
  var navBtnDiv = this.GetNavButtonElementById(navBtn.divId);
  if (!_aspxIsExists(navBtnDiv) || !_aspxIsExists(navBtnDiv.parentNode)) 
   return;  
  _aspxRemoveElement(navBtnDiv)
 },
 AlignNavigationButtons: function() {
  var count = this.navButtons.length;
  for(var i = 0; i < count; i++)
   this.AlignNavigationButton(this.navButtons[i]);
 },
 AlignNavigationButton: function(navBtn) {
  var div = this.GetNavButtonElementById(navBtn.divId);
  if(!_aspxIsExists(div))
   return;
  var leftTopAnchor = this.navButtonAnchors[navBtn.resourceId + "_Left"];
  var rightBottomAnchor = this.navButtonAnchors[navBtn.resourceId + "_Right"];
  if(!_aspxIsExists(leftTopAnchor) || !_aspxIsExists(rightBottomAnchor))
   return;
  var leftTopAnchorCell = this.vertTable.rows[leftTopAnchor[0]].cells[leftTopAnchor[1]];
  var rightBottomAnchorCell = this.vertTable.rows[rightBottomAnchor[0]].cells[rightBottomAnchor[1]];;
  if(!_aspxIsExists(leftTopAnchorCell) || !_aspxIsExists(rightBottomAnchorCell))
   return;
  var dxtop;
  var bottom;
  var parent;
  var verticalContainer = this.GetContainerElementById("verticalContainer");
  var navButtonLayer = null;
  var navButtonParent = this.containerCell;
  if (_aspxIsExists(verticalContainer)) {
   navButtonLayer = verticalContainer.parentNode.parentNode;
   parent = this.verticalParent;
   dxtop = _aspxGetAbsoluteY(navButtonLayer) - _aspxGetAbsoluteY(navButtonParent);
   bottom = dxtop + navButtonLayer.offsetHeight;
  }
  else {
   parent = this.horizontalParent;
   dxtop = parent.CalcRelativeElementTop(leftTopAnchorCell);
   bottom = parent.CalcRelativeElementBottom(rightBottomAnchorCell);
  }
  parent.AppendChildToNavButtonLayer(div, navButtonLayer);
  var left = parent.CalcRelativeElementLeft(leftTopAnchorCell) + 2;
  if(navBtn.anchorType == "Left")
   div.style.left = left + "px";
  else {
   var right = parent.CalcRelativeElementRight(rightBottomAnchorCell) - 2;
   div.style.left = right - div.offsetWidth + "px";
   }
   div.style.top = (dxtop + bottom - div.offsetHeight) / 2 + "px";
   _aspxSetElementDisplay(div, true);
 },
 RecalcLayout: function() {
  this.HideAppointments();
  if (_aspxIsExists(document.recalc))
   document.recalc(true);
  this.SyncDayViewHeadersWithColumns();
  this.FormatHeadersContentOptimally();
  this.horizontalViewInfo.parent.Clear();
  if(this.HasVerticalResourceHeaderColumn())
   this.LayoutVerticalResourceHeaderColumn();
  var timeLineHeaderCalculator = new ASPxClientTimelineHeaderLayoutCalculator(this);
  timeLineHeaderCalculator.CalculateLayout(this.timelineHeaderLevels);
  this.LayoutAppointments();
  this.AlignNavigationButtons();
 },
 HasVerticalResourceHeaderColumn: function() {
  var activeView = this.GetActiveViewType();
  var activeGroup = this.GetGroupType();
  if (activeView == ASPxSchedulerViewType.Timeline && activeGroup != ASPxSchedulerGroupType.None)
   return true;
  if ( (activeView == ASPxSchedulerViewType.Week || activeView == ASPxSchedulerViewType.Month) && activeGroup == ASPxSchedulerGroupType.Date)
   return true;
  return false;
 },
 LayoutVerticalResourceHeaderColumn: function() {
  var table = this.GetContainerElementById("content");
  var cells = table.tBodies[0].rows[0].cells;
  var leftCell = cells[0];
  var rightCell = cells[cells.length-1];
  if (table==null || leftCell==null || rightCell==null)
   return;
  if (_aspxIsExists(leftCell.correctedWidth))
   return;
  var saveRightCellStyleWidth = rightCell.style.width;
  if (!this.IsVerticalResourceHeaderColumnWidthAssignedByUser())
   rightCell.style.width = "100%";
  _aspxChangeTableLayout(table, "auto");
  leftCell.correctedWidth = leftCell.offsetWidth;
  rightCell.style.width = saveRightCellStyleWidth;
  _aspxChangeTableLayout(table, "fixed");
  _aspxSetTableCellOffsetWidth(leftCell, leftCell.correctedWidth);
 },
 IsVerticalResourceHeaderColumnWidthAssignedByUser: function() {
  if (this.MeasureVRHLocation == null)
   return false;
  var cell = _aspxGetItemByLocation(this.horzTable, this.MeasureVRHLocation);
  this.MeasureVRHLocation = null;
  if (cell.style["width"]=="") 
   return false;
  return true;
 },
 LayoutAppointments: function() {  
  var horizontalCalculator = this.CreateHorizontalAppointmentsCalculator();
  horizontalCalculator.CalculateLayout(this.horizontalViewInfo.appointmentViewInfos);
  this.horizontalViewInfo.parent.AfterCalculateAppointments(horizontalCalculator);
  var verticalCalculator = this.CreateVerticalAppointmentsCalculator();
  verticalCalculator.CalculateLayout(this.verticalViewInfo.appointmentViewInfos);
  this.verticalViewInfo.parent.AfterCalculateAppointments(verticalCalculator);
  if(this.GetIsDayBasedView()) {
   this.verticalViewInfo.ShowMoreButton();
  }
 },
 HideAppointments: function() {
  this.horizontalViewInfo.HideAppointments();
  this.verticalViewInfo.HideAppointments();
 },
 CreateVerticalAppointmentsCalculator: function() {
  return new ASPxClientVerticalAppointmentLayoutCalculator(this.verticalViewInfo, this.verticalParent);
 },
 CreateHorizontalAppointmentsCalculator: function() {
  var activeView = this.GetActiveViewType();
  if (activeView == ASPxSchedulerViewType.Day || activeView == ASPxSchedulerViewType.WorkWeek)
   return new ASPxClientHorizontalAppointmentLayoutCalculatorInfinityHeight(this.horizontalViewInfo);
  else
   return new ASPxClientHorizontalAppointmentLayoutCalculator(this.horizontalViewInfo);
 },
 SyncDayViewHeadersWithColumns: function() {
  if (this.syncColumnCount <= 0) {
   this.HideMasterRow();
   return;
  }
  var masterRow = this.vertTable.rows[this.syncMasterRowIndex];
  var slaveRow = this.horzTable.rows[this.syncSlaveRowIndex];
  masterRow.style.display = "";
  for (var i = this.syncColumnCount - 1; i >= 0; i--) {
   var style = _aspxGetCurrentStyle(this.GetMainElement());
   slaveRow.cells[i].style.borderColor = style.borderColor;
   _aspxRefreshTableCell(slaveRow.cells[i]);
  }
  var cell = slaveRow.cells[this.syncColumnCount];
  cell.style.width = this.CalcVerticalScrollbarWidth() + "px";
  _aspxRefreshTableCell(slaveRow.cells[this.syncColumnCount]);
  this.HideMasterRow();
  slaveRow.style.visibility = "hidden";
 },
 HideMasterRow: function() {
  if (!this.syncMasterRowIndex)
   return;
  if (this.syncMasterRowIndex <= 0) 
   return;
  var masterRow = this.vertTable.rows[this.syncMasterRowIndex];
  masterRow.style.display = "none";
 },
 SetSyncCells: function(syncColumnCount, syncMasterRowIndex, syncSlaveRowIndex) {
  this.syncColumnCount = syncColumnCount;
  this.syncMasterRowIndex = syncMasterRowIndex;
  this.syncSlaveRowIndex = syncSlaveRowIndex;
 },
 CalcVerticalScrollbarWidth: function() {
  var vsc = this.GetContainerElementById("verticalScrollContainer");
  if (_aspxIsExists(vsc)) {
   var clientWidth = vsc.clientWidth;
   if (!_aspxIsExists(clientWidth))
    return 0;
   else
    return vsc.offsetWidth - clientWidth;
  }
  else
   return 0;
 },
 CalculateLayout: function() {
  this.RecalcLayout();
  this.EnableResize();
 },
 GetBlockElementId: function(blockId, innerId) {
  return this.name + "_" + blockId + "_" + innerId;
 },
 GetElementById: function(id) {
  return _aspxGetElementById(this.name + "_" + id);
 },
 GetContainerElementById: function(id) {
  return _aspxGetElementById(this.name + "_containerBlock_" + id);
 },
 GetNavButtonElementById: function(id) {
  var div = this.navButtonsCache[id];
  if(!_aspxIsExists(div)) {
   div = _aspxGetElementById(this.name + "_navButtonsBlock_" + id);
   this.navButtonsCache[id] = div;
  }
  return div;
 },
 GetAppointmentBlockElementById: function(id) {
  return _aspxGetElementById(this.name + "_aptsBlock_" + id);
 },
 GetMainTable: function() {
  return this.innerContentElement;
 },
 GetCellInterval: function(cell) {
  var interval = cell.interval;
  if(_aspxIsExists(interval))
   return interval;
  else {
   this.InitializeCell(cell);
   return cell.interval;
  }
 },
 GetCellStartTime: function(cell) {
  return this.GetCellInterval(cell).GetStart();
 },
 GetCellDuration: function(cell) {
  return this.GetCellInterval(cell).GetDuration();
 },
 GetCellEndTime: function(cell) {
  return this.GetCellInterval(cell).GetEnd();
 },
 GetCellResource: function(cell) {
  var resource = cell.resource;
  if(_aspxIsExists(resource))
   return resource;
  else {
   this.InitializeCell(cell);
   return cell.resource;
  }
 }, 
 CancelFormChangesAndClose: function(visibility, callbackName) {
  if (visibility == ASPxSchedulerFormVisibility.FillControlArea) {
   this.RaiseCallback(callbackName);
  }
  else {
   var statusInfoManager = this.statusInfoManager;
   if (_aspxIsExists(statusInfoManager))
    statusInfoManager.Clear();
   this.HideCurrentPopupContainer();
   this.SaveActiveFormTypeState(ASPxSchedulerFormType.None);
   this.EnableReminderTimer();
  }
 },
 SaveActiveFormTypeState: function(formType) {
  this.activeFormType = formType;
  var element = this.GetStateElement("FRMTYPE");
  if(_aspxIsExists(element))
   element.value = formType;
 },
 SaveCurrentPopupContainer: function(popupId) {
  this.HideCurrentPopupContainer();
  this.currentPopupContainer = aspxGetControlCollection().Get(this.name + "_formBlock_" + popupId);
 },
 HideCurrentPopupContainer: function() {
  if(_aspxIsExists(this.currentPopupContainer)) {
   this.currentPopupContainer.CloseUp.ClearHandlers();
   this.currentPopupContainer.Hide();
   var mainElement = this.currentPopupContainer.GetWindowElement(-1);
   _aspxRemoveAttribute(mainElement, "modalElement");
   mainElement.modalElement = null;
   var modalElement = this.currentPopupContainer.FindWindowModalElement(-1);
   if(modalElement != null && _aspxIsExists(modalElement.parentNode)) {
    _aspxRecycleNode(modalElement);    
   }
   if(_aspxIsExists(mainElement.parentNode)) {
    _aspxRecycleNode(mainElement);
   }
   this.RemoveNonpermanentAppointments();
   this.currentPopupContainer = null;
  }
 },
 RemoveNonpermanentAppointments: function() {
  for (var aptId in this.nonpermanentAppointments) 
   this.RemoveAppointment(aptId);
 },
 RemoveAppointment: function(aptId) {
  this.RemoveViewInfosByAppointmentId(aptId);
  this.nonpermanentAppointments[aptId] = null;
  this.appointments[aptId] = null;
 },
 ShowFormPopupWindow: function(popupId) {
  if(_aspxIsExists(this.currentPopupContainer)) {
   this.DisableReminderTimer();
   var width = _aspxGetDocumentClientWidth();
   var height = _aspxGetDocumentClientHeight();
   var pcwElement = this.currentPopupContainer.GetWindowElement(-1);
   this.currentPopupContainer.SetWindowDisplay(-1, true);
   var popupWidth = pcwElement.offsetWidth;
   var popupHeight = pcwElement.offsetHeight;
   this.currentPopupContainer.SetWindowDisplay(-1, false);
   var xOffset = _aspxGetDocumentScrollLeft();
   var yOffset = _aspxGetDocumentScrollTop();
   this.currentPopupContainer.ShowAtPos(xOffset + ((width - popupWidth) >> 1), yOffset + ((height - popupHeight) >> 1));
  }
  },
  ShowInplacePopupWindow: function(inplaceEditorPopupId, aptId) {
  if(_aspxIsExists(this.currentPopupContainer)) {
   this.DisableReminderTimer();
   var aptViewInfo;
   if(_aspxIsExists(this.verticalViewInfo)) {
    aptViewInfo = this.verticalViewInfo.FindViewInfosByAppointmentId(aptId);
   }
   if (!_aspxIsExists(aptViewInfo) || (aptViewInfo.length <= 0)) {
    if(_aspxIsExists(this.horizontalViewInfo)) {
     aptViewInfo = this.horizontalViewInfo.FindViewInfosByAppointmentId(aptId);
    }
   }
   if (!_aspxIsExists(aptViewInfo) || (aptViewInfo.length <= 0))
    return;
   var contentDiv = aptViewInfo[0].contentDiv;
   if (!_aspxIsExists(contentDiv ))
    return;
   this.currentPopupContainer.SetSize(Math.max(200, contentDiv.offsetWidth), 0); 
   var div = this.currentPopupContainer.GetWindowElement(-1);
   if(!aptViewInfo[0].IsHorizontal()) {
    if(!_aspxIsExists(contentDiv.parentNode))
     return;
    contentDiv.parentNode.appendChild(div);
    this.currentPopupContainer.ShowAtPos(0, 0);
    this.ShowInplacePopupWindowCore(div, aptViewInfo[0]);
   }
   else {
    this.currentPopupContainer.ShowAtPos(_aspxGetAbsoluteX(contentDiv), _aspxGetAbsoluteY(contentDiv));
   }
  }
 },
 ShowInplacePopupWindowCore: function(inplaceEditorElement, appointmentViewInfo) {
  var contentDiv = appointmentViewInfo.contentDiv;
  var divLeft = contentDiv.offsetLeft;
  var divTop = contentDiv.offsetTop;
  if(appointmentViewInfo.IsHorizontal()) {
   this.currentPopupContainer.OnDrag(-1, divLeft, divTop);
   return;
  }
  var scrollContainer = this.GetContainerElementById("verticalScrollContainer");
  if(!_aspxIsExists(scrollContainer)) {
   this.currentPopupContainer.OnDrag(-1, divLeft, divTop);
   return;
  }
  if(inplaceEditorElement.offsetWidth + divLeft > scrollContainer.clientWidth)
   divLeft = scrollContainer.clientWidth - inplaceEditorElement.offsetWidth;
  if(inplaceEditorElement.offsetHeight + divTop > scrollContainer.scrollHeight)
   divTop = scrollContainer.scrollHeight - inplaceEditorElement.offsetHeight;
  this.currentPopupContainer.OnDrag(-1, divLeft, divTop);
  if(inplaceEditorElement.offsetTop < scrollContainer.scrollTop || inplaceEditorElement.offsetHeight > scrollContainer.offsetHeight) {
   scrollContainer.scrollTop = Math.max(inplaceEditorElement.offsetTop, 0);
   this.EnsureInplaceEditorPositionVisible(inplaceEditorElement);
     return;
  }
  var bottom = inplaceEditorElement.offsetTop + inplaceEditorElement.offsetHeight;
  var scrollBottom = scrollContainer.scrollTop + scrollContainer.offsetHeight;
  if(bottom > scrollBottom) {
   var newScrollTop = scrollContainer.scrollTop + bottom - scrollBottom;
   scrollContainer.scrollTop = Math.max(newScrollTop, 0);
   this.EnsureInplaceEditorPositionVisible(inplaceEditorElement);
   return;
  }
  this.EnsureInplaceEditorPositionVisible(inplaceEditorElement);
 },
 EnsureInplaceEditorPositionVisible: function(inplaceEditorElement) {
  var htmlParent = inplaceEditorElement.offsetParent;
  while(_aspxIsExists(htmlParent) && htmlParent.tagName != "HTML")
   htmlParent = htmlParent.parentNode;
  if(!_aspxIsExists(htmlParent))
   return;
  var posY = _aspxGetAbsolutePositionY(inplaceEditorElement);
  if(htmlParent.scrollTop > posY)
   inplaceEditorElement.scrollIntoView(true);
  else
   if(htmlParent.scrollTop + htmlParent.offsetHeight < posY + inplaceEditorElement.offsetHeight)
    inplaceEditorElement.scrollIntoView(false);
 },
 ShowCellSelection: function() {
  if(_aspxIsExists(this.selection)) {
   var dayBasedView = this.GetIsDayBasedView();
   var selectionVisible = this.appointmentSelection.selectedAppointmentIds.length == 0;
   this.horizontalViewInfo.ShowCellSelection(this.selection.interval, this.selection.resource, !dayBasedView, selectionVisible);
   this.verticalViewInfo.ShowCellSelection(this.selection.interval, this.selection.resource, true, selectionVisible);
  }
 },
 OnAppointmentSelectionChanged: function(selectedAppointmentIds) {
  this.SaveAppointmentSelectionState();
  this.ShowCellSelection();
  if(_aspxIsExists(this.RaiseAppointmentsSelectionChanged))
   this.RaiseAppointmentsSelectionChanged(selectedAppointmentIds);
 },
 SetFormsInitState: function(activeFormType, aptFormVisibility, gotoDateFormVisibility, recurrentAppointmentDeleteFormVisibility) {
  this.activeFormType = activeFormType;
  this.aptFormVisibility = aptFormVisibility;
  this.gotoDateFormVisibility = gotoDateFormVisibility;
  this.recurrentAppointmentDeleteFormVisibility = recurrentAppointmentDeleteFormVisibility;
 },
 SetSelection: function(start, duration, resourceId, firstSelectionStart, firstSelectionDuration) {
  var firstSelectedInterval = new ASPxClientTimeInterval(firstSelectionStart, firstSelectionDuration);
  var selectedInterval = new ASPxClientTimeInterval(start, duration);
  if (!_aspxIsExists(this.selection) ||
   !this.selection.interval.Equals(selectedInterval) ||
   !this.selection.firstSelectedInterval.Equals(firstSelectedInterval) ||
   this.selection.resource != resourceId)
   this.SetSelectionCore(new ASPxSchedulerSelection(selectedInterval, resourceId, firstSelectedInterval));
 },
 SetSelectionCore: function(newSelection) {
  this.selection = newSelection;
  this.SaveSelectionState();
  if(!this.isInsideBeginInit && this.isInitialized)
   this.ShowCellSelection();
 },
 SetSelectionInterval: function(newInterval) {
    this.selection.interval = newInterval;
    this.SaveSelectionState();
    this.ShowCellSelection();
 },
 SetSelectedAppointmentIds: function(appointmentIds) {
  this.appointmentSelection.BeginUpdate();
  var count = appointmentIds.length;
  for(var i = 0; i < count; i++)
   this.appointmentSelection.AddAppointmentToSelection(appointmentIds[i]);
  this.appointmentSelection.EndUpdate();
 },
 GetResourceString: function(resource) {
  return resource != null ? resource : this._constEmptyResource;
 },
 GetStateElement: function(name) {
  return this.GetChild("_stateBlock_"+name);
 },
 SaveSelectionState: function() {
  var resourceString = this.GetResourceString(this.selection.resource);
  var result = this.selection.interval.ToString()+ "," +
   this.selection.firstSelectedInterval.ToString() + "," +
   resourceString;
  var element = this.GetStateElement("SEL");
  if (_aspxIsExists(element))
   element.value = result;
  this.RaiseSelectionChanged();
 },
 SaveAppointmentSelectionState: function() {
  var selectedAppointmentsIds = this.appointmentSelection.selectedAppointmentIds;
  var count = selectedAppointmentsIds.length;
  var result = "";
  for(var i = 0; i < count; i++)
   result += selectedAppointmentsIds[i] + ",";
  var element = this.GetStateElement("APTSEL");
  if(_aspxIsExists(element))
   element.value = result;
 },
 AddNavigationButton: function(divId, resourceId, anchorType) {
  var btn = new ASPxNavigationButton(divId, resourceId, anchorType);
  _aspxArrayPush(this.navButtons, btn);
 },
 AddAppointmentPattern: function(pattern) {
  this.appointments[pattern.appointmentId] = pattern;
  for (var appointmentId in this.appointments) {
   var appointment = this.GetAppointment(appointmentId); 
   var aptType = appointment.appointmentType;
   var isRecurring = aptType != ASPxAppointmentType.Normal;
   if (!isRecurring || aptType == ASPxAppointmentType.Pattern)
    continue;
   var splittedId = appointmentId.split('_'); 
   var patternId = splittedId[0];
   var recurrenceIndex = splittedId[1];
   if (splittedId.length == 2 && patternId == pattern.appointmentId) {
    appointment.SetRecurrencePattern(pattern);
    appointment.RecurrenceIndex = recurrenceIndex;
   }
  }
 },
 AddAppointment: function(aptId, start, duration, resources, flagStr, appointmentType, labelId, statusId, isNonpermanentAppointment) {
  this.appointments[aptId] = this.CreateAppointmentFromArgs(aptId, start, duration, resources, flagStr, appointmentType, labelId, statusId);
  if (_aspxIsExists(isNonpermanentAppointment)) 
   this.nonpermanentAppointments[aptId] = this.appointments[aptId];
 },
 CreateAppointmentFromArgs : function(aptId, start, duration, resources, flagStr, appointmentType, labelId, statusId) {
  var flags = new ASPxClientAppointmentFlags();
  flags.allowDelete      = flagStr.charAt(0) == "1";
  flags.allowEdit     = flagStr.charAt(1) == "1";
  flags.allowResize      = flagStr.charAt(2) == "1";
  flags.allowCopy     = flagStr.charAt(3) == "1";
  flags.allowDrag     = flagStr.charAt(4) == "1";
  flags.allowDragBetweenResources = flagStr.charAt(5) == "1";
  flags.allowInplaceEditor  = flagStr.charAt(6) == "1";
  flags.allowConflicts   = flagStr.charAt(7) == "1";
  var interval = new ASPxClientTimeInterval(start, duration);
  return new ASPxClientAppointment(interval, resources, flags, aptId, appointmentType, statusId, labelId);
 },
 InitializeAppointmentDivCache: function() {
  if(this.changedBlocks && !this.changedBlocks.AppointmentsBlockChanged)
   return;
  if(_aspxIsExists(this.appointmentDivCache)) {
   for(var divId in this.appointmentDivCache) {
    var div = this.appointmentDivCache[divId];
    _aspxRemoveElement(div);
   }
  }
  this.appointmentDivCache = new Object();
  var aptsBlock = this.GetAppointmentBlockElementById("innerContent");
  if (_aspxIsExists(aptsBlock)) {
   var children = aptsBlock.childNodes;
   var count = children.length;
   for (var i = 0; i < count; i++) {
    var child = children[i];
    if (_aspxIsExists(child.tagName) && child.tagName.toUpperCase() == "DIV") {
     this.appointmentDivCache[child.id] = child;
    }
   }
  }
 },
 GetAppointmentDivById: function(divId) {
  return this.appointmentDivCache[this.name + "_aptsBlock_" + divId];
 },
 GetAppointmentFlags: function(aptId) {
  return this.GetAppointment(aptId).flags;
 },
 GetAppointment: function(aptId) {
  return this.appointments[aptId];
 },
 GetAppointmentInterval: function(aptId) {
  return this.appointments[aptId].interval;
 },
 GetAppointmentResources: function(aptId) {
  return this.appointments[aptId].resources;
 },
 AddAnchor: function(rowIndex, cellIndex, anchorId) {
  this.navButtonAnchors[anchorId] = [rowIndex, cellIndex];
 },
 AddHorizontalAppointment : function(firstCellIndex, lastCellIndex, startTime, duration, topRelativeIndent, bottomRelativeIndent, divId, appointmentId, statusBackDivId, statusForeDivId, statusStartOffset, statusEndOffset, hasLeftBorder, hasRightBorder) {
  var result1 = this.cellIdRegExp.exec(firstCellIndex);
  if(!_aspxIsExists(result1) || result1.length == 0)
   return;
  var containerIndex = parseInt(result1[3]);
  var cellIndex1 = parseInt(result1[4]);
  var result2 = this.cellIdRegExp.exec(lastCellIndex);
  if(!_aspxIsExists(result2) || result2.length == 0)
   return;
  var cellIndex2 = parseInt(result2[4]);
  var apt = new ASPxClientHorizontalAppointmentViewInfo(this.horizontalViewInfo, containerIndex, cellIndex1, cellIndex2, startTime, duration, topRelativeIndent, bottomRelativeIndent, divId, appointmentId, hasLeftBorder, hasRightBorder, statusBackDivId, statusForeDivId, statusStartOffset, statusEndOffset);
  this.horizontalViewInfo.AddViewInfo(apt);
 },
 AddVerticalAppointment: function(firstCellIndex, lastCellIndex, startTime, duration, topRelativeIndent, bottomRelativeIndent, divId, appointmentId, statusBackDivId, statusForeDivId, statusStartOffset, statusEndOffset, startHorizontalIndex, endHorizontalIndex, maxIndexInGroup, hasTopBorder, hasBottomBorder){
  var result1 = this.cellIdRegExp.exec(firstCellIndex);
  if(!_aspxIsExists(result1) || result1.length == 0)
   return;
  var containerIndex = parseInt(result1[3]);
  var cellIndex1 = parseInt(result1[4]);
  var result2 = this.cellIdRegExp.exec(lastCellIndex);
  if(!_aspxIsExists(result2) || result2.length == 0)
   return;
  var cellIndex2 = parseInt(result2[4]);
  var viewInfo = new ASPxClientVerticalAppointmentViewInfo(this.verticalViewInfo, containerIndex, cellIndex1, cellIndex2, startTime, duration, divId, startHorizontalIndex, endHorizontalIndex + 1, maxIndexInGroup + 1, topRelativeIndent, bottomRelativeIndent, appointmentId, hasTopBorder, hasBottomBorder, statusBackDivId, statusForeDivId, statusStartOffset, statusEndOffset);
  this.verticalViewInfo.AddViewInfo(viewInfo);
 },
 AddHorizontalContainer: function(containerIndex, cellCount, containerStartTime, cellsDurations, resource, cellsLocations) {
  this.horizontalViewInfo.AddCellContainer(containerIndex, cellCount, containerStartTime, cellsDurations, resource, cellsLocations);
 },
 AddVerticalContainer: function(containerIndex, cellCount, containerStartTime, cellsDurations, resource, cellsLocations) {
  this.verticalViewInfo.AddCellContainer(containerIndex, cellCount, containerStartTime, cellsDurations, resource, cellsLocations);
 },
 AddTimelineHeader: function(levelIndex, cellLocation, offset, baseCellLocation) { 
  if (this.timelineHeaderLevels.length == levelIndex) 
   this.timelineHeaderLevels[levelIndex] = new ASPxClientTimelineHeaderLevelViewInfo();
  this.timelineHeaderLevels[levelIndex].Add(cellLocation, offset, baseCellLocation);
 },
 RaiseShowInplaceEditorCallback: function() {
  this.RaiseCallback("INPLACESHOW|");
 },
 MainDivMouseDown: function(e) {
  var hitTestResult = this.CalcHitTest(e);
  if(_aspxIsExists(hitTestResult.appointmentDiv)) {
   var appointmentViewInfo = hitTestResult.appointmentDiv.appointmentViewInfo;
   var appointmentId = appointmentViewInfo.appointmentId;
   var appointmentClickHandler = null;
   var ctrlKeyPressed = _aspxGetCtrlKey(e);
   if(_aspxGetShiftKey(e))
    this.appointmentSelection.AddAppointmentToSelection(appointmentId);
   else {
    if(!ctrlKeyPressed) {
     if(_aspxGetIsLeftButtonPressed(e)) {
      var appointmentDiv = hitTestResult.appointmentDiv;
      if(_aspxIsExists(appointmentDiv.appointmentViewInfo.adornerDiv))
       appointmentClickHandler = this.OnActivateInplaceEditor;
     }
     this.appointmentSelection.SelectSingleAppointment(appointmentId);
    }
    else {
     if(!this.appointmentSelection.IsAppointmentSelected(appointmentId))
      this.appointmentSelection.AddAppointmentToSelection(appointmentId);
     else     
      appointmentClickHandler = function() { this.appointmentSelection.ChangeAppointmentSelection(appointmentId); };
    }
   }
   if(!_aspxIsExists(hitTestResult.resizeDiv) && _aspxIsExists(hitTestResult.cell))
    new ASPxClientAppointmentDragHelper(this, hitTestResult.appointmentDiv, hitTestResult.cell, e, appointmentClickHandler, this);
   return true;
  }
  if(!_aspxIsExists(hitTestResult.cell))
   return false;
  if(_aspxIsExists(hitTestResult.selectionDiv) && _aspxGetIsRightButtonPressed(e))
   return true;
  if(this.CanSelect(e)) {
   this.appointmentSelection.ClearSelection();
   new ASPxClientSchedulerSelectionHelper(this, hitTestResult.cell, _aspxGetShiftKey(e));
  }
 },
 CanSelect: function(e) {
  var eventSource = _aspxGetEventSource(e);
  if(!_aspxIsExists(eventSource))
   return false;
  var id = eventSource.id;
  return id.indexOf("containerBlock_DXCnt") >= 0 || id.indexOf("commonControlsBlock_selectionDiv") >= 0 || id.indexOf("containerBlock_scrollableContainer") >= 0;
 },
 OnActivateInplaceEditor: function(e) {
  if(this.appointmentSelection.selectedAppointmentIds.length != 1)
   return;
  var hitTestResult = this.CalcHitTest(e);
  var aptDiv = hitTestResult.appointmentDiv;
  if(_aspxIsExists(aptDiv)) {
   var aptFlags = this.GetAppointmentFlags(aptDiv.appointmentId);
   if(aptFlags != null && aptFlags.allowInplaceEditor)
    this.RaiseShowInplaceEditorCallback();
  }
 },
 LookupCellByMousePosition: function(viewInfo, e, containerIndex, firstCellIndex, lastCellIndex) {
  var x = _aspxGetEventX(e) - _aspxGetAbsoluteX(viewInfo.parent.innerParentElement);
  var y = _aspxGetEventY(e) - _aspxGetAbsoluteY(viewInfo.parent.innerParentElement);
  return viewInfo.FindCellByPosition(containerIndex, firstCellIndex, lastCellIndex, x, y);
 },
 GetCellContainer: function(cell) {
  var container = cell.container;
  if (_aspxIsExists(container))
   return container;
  this.InitializeCell(cell);
  return cell.container;
 },
 GetSmartTag: function(source) {
  while(source != null) {
   if(_aspxIsExists(source.isSmartTag) && source.isSmartTag)
    return source;
   source = source.parentNode;
  }
  return null;
 },
 CalcHitTest: function(e) {
  var eventSource = _aspxGetEventSource(e);
  if (!_aspxIsExists(eventSource))
   return new HitTestResult(null, null, null);
  var appointmentElement = _aspxGetParentByPartialId(eventSource, this._constDXAppointment());
  var appointmentDiv = appointmentElement;
  if(_aspxIsExists(appointmentElement) && _aspxIsExists(appointmentElement.appointmentDiv))
   appointmentDiv = appointmentElement.appointmentDiv;
  var smartTag = this.GetSmartTag(eventSource);
  if(!_aspxIsExists(appointmentDiv)) {
   var aptAdornerDiv = _aspxGetParentByPartialId(eventSource, this._constDXAppointmentAdorner());
   if(_aspxIsExists(aptAdornerDiv))
    appointmentDiv = aptAdornerDiv.appointmentDiv;
  }
  else {
   if(!_aspxIsExists(appointmentDiv.appointmentViewInfo))
    appointmentDiv = null;
  }
  var resizeDiv = null;
  if(_aspxIsExists(appointmentDiv))
      resizeDiv = _aspxGetParentByPartialId(eventSource, "ResizeControlDiv", appointmentDiv);
  var selectionDiv = _aspxGetParentByPartialId(eventSource, this._constDXSelectionDiv());
  var cell = _aspxGetParentByPartialId(eventSource, this._constDXSchedulerContentCell());
  if (!_aspxIsExists(cell)) {
   var containerIndex = null;
   var firstCellIndex = null;
   var lastCellIndex = null;
   if (_aspxIsExists(appointmentDiv)) {
    var viewInfo = appointmentDiv.appointmentViewInfo;
    containerIndex = viewInfo.containerIndex;
    firstCellIndex = viewInfo.visibleFirstCellIndex;
    lastCellIndex = viewInfo.visibleLastCellIndex;
   }
   else {
    if (_aspxIsExists(selectionDiv)) {
     containerIndex = selectionDiv.container.index;
     firstCellIndex = 0;
     lastCellIndex = selectionDiv.container.cellCount - 1;
    }
   }
   cell = this.LookupCellByMousePosition(this.horizontalViewInfo, e, containerIndex, firstCellIndex, lastCellIndex);
   if (!_aspxIsExists(cell))
    cell = this.LookupCellByMousePosition(this.verticalViewInfo, e, containerIndex, firstCellIndex, lastCellIndex);
  }
  return new ASPxSchedulerHitTestResult(cell, selectionDiv, appointmentDiv, resizeDiv, smartTag);
 },
 InitializeCell: function(cell) {
  var result = this.cellIdRegExp.exec(cell.id);
  if(!_aspxIsExists(result) || result.length == 0)
   return;
  var horizontalContainer = (result[2] == "h");
  var containerIndex = parseInt(result[3]);
  var cellIndex = parseInt(result[4]);
  if(horizontalContainer)
   this.horizontalViewInfo.InitializeCell(cell, containerIndex, cellIndex);
  else
   this.verticalViewInfo.InitializeCell(cell, containerIndex, cellIndex);
 },
 CanCreateCallback: function() {
  if(!this.isReadyForCallbacks) {
   return false;
  }
  if(this.constructor.prototype.CanCreateCallback.call(this)) {
   return true;
  }
  return this.funcCallbackCount == this.requestCount && this.funcCallbackCount > 0;
 },
 GetCallbackHandler: function(index) {
  if(index < 0 || index >= this.funcCallbacks.length)
   return null;
  var result = this.funcCallbacks[index];
  this.funcCallbacks[index] = null;
  return result;
 },
 RegisterCallbackHandler: function(onCallback) {
  this.funcCallbackCount++;
  var count = this.funcCallbacks.length;
  for(var i = 0; i < count; i++) {
   if(this.funcCallbacks[i] == null) {
    this.funcCallbacks[i] = onCallback;
    return i;
   }
  }
  this.funcCallbacks.push(onCallback);
  return this.funcCallbacks.length - 1;
 },
 ClearFuncCallbacks: function() {
  var count = this.funcCallbacks.length;
  for(var i = 0; i < count; i++) {
   if(this.funcCallbacks[i] != null) {
    this.funcCallbacks[i] = aspxSchedulerEmptyFuncCallbackHandler;
   }
  }
 },
 HideLoadingPanelOnCallback: function() {
  return false;
 },
 RaiseFuncCallback: function(callbackName, args, onCallback) {
  if(!_aspxIsExists(args) || args == "")
     return;
  this.ClearReminderTimer();
  this.allowMultipleCallbacks = true; 
  if(this.CanCreateCallback()) {
   var id = this.RegisterCallbackHandler(onCallback);
   this.CreateCallback(callbackName + id.toString() + "," + args);
  }
  this.allowMultipleCallbacks = false;
 },
 RaiseCallback: function(args) {  
  this.ClearReminderTimer();
  _aspxSchedulerSmartTagHelper.HideActiveSmartTag();
  this.SaveScrollPositionState();
  if (_aspxIsExists(this.callBack) && this.isCallbackMode) {
   if(!this.CanCreateCallback())
      return;
   this.ShowLoadingPanel();
   var statusInfoManager = this.statusInfoManager;
   if (_aspxIsExists(statusInfoManager))
    statusInfoManager.Clear();
   this.CreateCallback(args);
   this.ClearFuncCallbacks();
   this.isReadyForCallbacks = false;
  }
  else {
   ASPxControlResizeManager.Clear();
   aspxGetControlCollection().elements[this.name] = null;
   this.SendPostBack(args);
  }
 },
 SaveScrollPositionState: function() {
  var elementsId = ["verticalScrollContainer", "scrollableContainer"];
  var result = "";
  var count = elementsId.length;
  for(var i = 0; i < count; i++) {
   var id = elementsId[i];
   var element = this.GetContainerElementById(id);
   if(!_aspxIsExists(element))
    continue;
   var scrollLeft = element.scrollLeft;
   var scrollTop = element.scrollTop;
   if(result.length > 0)
    result += ",";
   result += "[\""+ id + "\"," + scrollLeft + "," + scrollTop + "]";
  }
  var element = this.GetStateElement("SCROLL");
  if (_aspxIsExists(element))
   element.value = "[" + result + "]";
 },
 SetScrollPosition: function(positions) {
  if(this.isInsideBeginInit) {
   this.deferredSetScrollPosition = positions;
   return;
  }
  var count = positions.length;
  for(var i = 0; i < count; i++) {
   var scrollPos = positions[i];
   var element = this.GetContainerElementById(scrollPos[0]);
   if(!_aspxIsExists(element))
    continue;
   element.scrollLeft = scrollPos[1];
   element.scrollTop = scrollPos[2];
  }
 },
 PerformCallbackHandler: function(index, res){
  var handler = this.GetCallbackHandler(index);
  if (handler != null)
   handler(res);
 },
 OnFuncCallback: function(result) {
  eval(result);
 },
 OnCallback: function(result) {
    if(result.indexOf("FB|") == 0) {
   this.funcCallbackCount--;
   _aspxSetTimeout("aspxSchedulerFuncCallback(\""+this.name+"\", \"" + escape(result.substr(3)) +"\");", 0);   
   return; 
  }
  this.changedBlocks = new Object();
  if(typeof aspxGetDropDownCollection != "undefined") {
   aspxGetDropDownCollection().focusedControlName = "";
   aspxGetDropDownCollection().droppedControlName = "";
  }
  _aspxClearSelection();
  this.HideCurrentPopupContainer();
  var element = this.GetMainElement();
  if (element != null) {
   this.DisableResize();
   ASPxRelatedControlManager.ParseResult(result);
  }
 },
 OnCallbackError: function(result, data) {
  if(_aspxIsExists(this.onCallbackError))
   this.onCallbackError();
  _aspxClearSelection();
  this.HideLoadingPanel();
  this.isReadyForCallbacks = true;
  if (!this.NotifyCallbackError(result))
   alert("CALLBACK ERROR: " + result);
 },
 OnCallbackGeneralError: function(result) {
  var length = result.length;  
  this.OnCallbackError(length + ",0|" + result, null);
 },
 ProcessCallbackResult: function(id, html, params) {
  if(!this.changedBlocks.ContainerBlockChanged && this.GetBlockElementId("containerBlock", "innerContent") == id) {
   this.changedBlocks.ContainerBlockChanged = true;
   this.RemoveContainerBlockChilds();
  }
  if(this.GetBlockElementId("formBlock", "innerContent") == id) {
   if(params == "#UsePrevResult") {
    html = this.prevCallbackResults.formBlock;
    params = "";
   }
   else {
    this.prevCallbackResults.formBlock = html;
   }
  }
  ASPxRelatedControlManager.ProcessCallbackResultDefault(id, html, params);
  if(!this.changedBlocks.AppointmentsBlockChanged && this.GetBlockElementId("aptsBlock", "innerContent") == id)
   this.changedBlocks.AppointmentsBlockChanged = true;
  if(!this.changedBlocks.NavButtonsBlockChanged && this.GetBlockElementId("navButtonsBlock", "innerContent") == id) {
   this.changedBlocks.NavButtonsBlockChanged = true;
   this.ClearNavigationButtons();
  }
 },
 RemoveContainerBlockChilds: function() {
  this.ClearCache(this.navButtonsCache, false);
  this.ClearCache(this.appointmentDivCache, true);
 },
 ClearCache: function(cache, alwaysCheckParent) {
  var parent = null;
  for(var divId in cache) {
   var div = cache[divId];
   if(!parent || alwaysCheckParent)
    parent = div.parentNode;
   if (_aspxIsExists(parent) && _aspxIsExists(parent.tagName))  {
    parent.removeChild(div);
   }
  }
 },
 NotifyCallbackError: function(msg) {
  var statusInfoManager = this.statusInfoManager;
  if (_aspxIsExists(statusInfoManager)) {
   statusInfoManager.ShowExceptionInfo(msg);
   return true;
  }
  else
   return false;
 },
 SetErrorInfoRowVisibility: function(cell, visible) {
  var row = cell.parentNode;
  if (_aspxIsExists(row) && row.tagName == "TR")
   _aspxSetElementDisplay(row, visible);
 },
 ShowResourceNavigatorRow: function(visible) {
  if (_aspxIsExists(this.resourceNavigatorRow)) {
   _aspxSetElementDisplay(this.resourceNavigatorRow, visible);
  }
 },
 SetCheckSums: function(checkSums) {
  var element = this.GetStateElement("CHECKSUMS");
  if (_aspxIsExists(element))
   element.value = checkSums;
 },
 FindViewInfosByAppointmentId: function(appointmentId) {
  var result = this.horizontalViewInfo.FindViewInfosByAppointmentId(appointmentId);
  return result.concat(this.verticalViewInfo.FindViewInfosByAppointmentId(appointmentId));
 },
 RemoveViewInfosByAppointmentId: function(appointmentId) {
  this.horizontalViewInfo.RemoveViewInfosByAppointmentId(appointmentId);
  this.verticalViewInfo.RemoveViewInfosByAppointmentId(appointmentId);
 },
 NavBtnClick: function(startTime, duration, resourceId) {
  this.RaiseCallback("NVBTN|" + _aspxDateTimeToMilliseconds(startTime) + "," + duration + "," + resourceId);
 },
 SetTimelineScalesInfo: function(enabledScales, visibleScales) {
  this.enabledTimeScalesInfo = enabledScales;
  this.visibleTimeScalesInfo = visibleScales;
 },
 SetCurrentTimeScaleMenuItemName: function(name) {
  this.currentTimeScaleMenuItemName = name;
 },
 CanShowSmartTag: function(dataObject, smartTagDiv) { 
  switch(smartTagDiv.smartTagType) {
   case ASPxSchedulerSmartTagType.Selection : return this.CanShowSelectionSmartTag(dataObject, smartTagDiv);
   case ASPxSchedulerSmartTagType.Appointment: return this.CanShowAptSmartTag(dataObject, smartTagDiv);
   default: return false;
  }  
 },
 CanShowSelectionSmartTag: function(dataObject, smartTagDiv) {
  if(!this.selectionSmartTagEnabled)
   return false;
  return this.menuManager.PrepareViewMenu() != null;
 },
 CanShowAptSmartTag: function(dataObject, smartTagDiv) {  
  if(!this.appointmentSmartTagEnabled)
   return false;
  return this.menuManager.PrepareAptMenu(dataObject, smartTagDiv.appointmentViewInfo);
 }, 
 OnAppointmentSmartTagClick: function(sender, e) {
  var dataObject = null;
  while(sender != null) {
   var dataObject = sender.dataObject;
   if(_aspxIsExists(dataObject))
    break;
   sender = sender.parentNode;
  }
  if(!_aspxIsExists(dataObject))
   return;
  var appointmentId = dataObject.appointmentId;
  if(!this.appointmentSelection.IsAppointmentSelected(appointmentId))
   this.appointmentSelection.SelectSingleAppointment(appointmentId);
  sender.appointmentViewInfo = dataObject;
  if(this.appointmentSelection.IsAppointmentSelected(appointmentId))
   this.menuManager.ShowAptMenu(sender, e);
 },
 GetDateInMilliseconds: function(date) {
  return date.valueOf() - 60000 * date.getTimezoneOffset();
 },
 RefreshClientAppointmentPropertiesCore: function(dictionary) {
  if (!dictionary.appointmentId)
   return;
  var apt = this.GetAppointment(dictionary.appointmentId);
  if (apt == null)
   apt = new ASPxClientAppointment();
  var propertyController = new ASPxClientAppointmentPropertyApplyController(this);
  propertyController.ApplyProperties(apt, dictionary);
  if (_aspxIsExists(this.RefreshClientAppointmentPropertiesUserCallbackFunction)) {
   this.RefreshClientAppointmentPropertiesUserCallbackFunction(apt); 
  }
 }
});
ASPxSchedulerMenuManager = _aspxCreateClass(null, {
 constructor: function(scheduler) {
  this.scheduler = scheduler;
 },
 OnAptMenuClick: function(itemName) {
  if (this.OnMenuItemClick(itemName))
   return;
  this.HandleAptMenuClickAtServerSide(itemName);
 },
 OnMenuItemClick: function(itemName) {
  this.HideMenu();
  if (this.scheduler.RaiseMenuItemClicked(itemName)) 
   return true;
 },
 OnViewMenuClick: function(itemName) {
  if (this.IsClientAPIEnabled()) {
   if (this.HandleViewMenuClickAtClientSide(itemName))
    return;
  }
  this.HandleViewMenuClickAtServerSide(itemName);
 },
 PrepareAptMenu: function(appointmentViewInfo) {
  var menu = aspxGetControlCollection().Get(this.scheduler.name + "_aptMenuBlock_SMAPT");
  if (!_aspxIsExists(menu))
   return null;
  if(!this.UpdateAppointmentMenuItems(appointmentViewInfo, menu))
   return null;
  return menu;
 },
 ShowAptMenu: function(sender, e) {
  var menu = this.PrepareAptMenu(sender.appointmentViewInfo);
  if(menu)
   this.ShowMenu(e, menu);  
 },
 PrepareViewMenu: function() {
  var menu = aspxGetControlCollection().Get(this.scheduler.name + "_viewMenuBlock_SMVIEW");
  if (!_aspxIsExists(menu))
   return null;
  this.UpdateViewMenuItems(menu);
  return menu;
 },
 ShowViewMenu: function(sender, e) {
  var menu = this.PrepareViewMenu();
  if(menu)
   this.ShowMenu(e, menu);
 },
 ShowMenu: function(e, menu) {
  if(this.scheduler.activeFormType != ASPxSchedulerFormType.None)
   return;
  menu.ShowInternal(e);
  e.returnValue = false;
  e.cancelBubble = true;
 },
 HideMenu: function(e, menu) {
  ASPxClientMenuBase.GetMenuCollection().HideAll();
 },
 HandleAptMenuClickAtServerSide: function(itemName) {
  this.scheduler.RaiseCallback("MNUAPT|" + itemName);
 },
 HandleViewMenuClickAtClientSide: function(itemName) {
  if (this.OnMenuItemClick(itemName)) 
   return true;
  switch (itemName) {
   case SchedulerMenuItemId.SwitchToDayView:
    this.scheduler.SetActiveViewType(ASPxSchedulerViewType.Day);
    return true;
   case SchedulerMenuItemId.SwitchToWorkWeekView:
    this.scheduler.SetActiveViewType(ASPxSchedulerViewType.WorkWeek);
    return true;
   case SchedulerMenuItemId.SwitchToWeekView:
    this.scheduler.SetActiveViewType(ASPxSchedulerViewType.Week);
    return true;
   case SchedulerMenuItemId.SwitchToMonthView:
    this.scheduler.SetActiveViewType(ASPxSchedulerViewType.Month);
    return true;
   case SchedulerMenuItemId.SwitchToTimelineView:
    this.scheduler.SetActiveViewType(ASPxSchedulerViewType.Timeline);
    return true;
   default:
    return false;
  }
 },
 HandleViewMenuClickAtServerSide: function(menuItemName) {
  this.scheduler.RaiseCallback("MNUVIEW|" + menuItemName);
 },
 IsClientAPIEnabled: function() {
  return _aspxIsExists(this.scheduler.SetActiveViewType);
 },
 UpdateAppointmentMenuItems: function(appointmentViewInfo, menu) {
  if (!_aspxIsExists(appointmentViewInfo))
   return;
  var apt = this.scheduler.GetAppointment(appointmentViewInfo.appointmentId);
  if (apt == null)
   return;
  var aptFlags = apt.flags;
  if (aptFlags == null)
   return;
  var canShowForm = this.scheduler.aptFormVisibility != ASPxSchedulerFormVisibility.None;
  var openAppointmentVisible = canShowForm && aptFlags.allowEdit;
  var deleteAppointmentVisible = aptFlags.allowDelete;
  var labelSubMenuVisible = aptFlags.allowEdit;
  var statusSubMenuVisible = aptFlags.allowEdit;
  this.SetMenuItemVisibility(menu, SchedulerMenuItemId.OpenAppointment, openAppointmentVisible);
  this.SetMenuItemVisibility(menu, SchedulerMenuItemId.DeleteAppointment, deleteAppointmentVisible);
  this.SetMenuItemVisibility(menu, SchedulerMenuItemId.LabelSubMenu, labelSubMenuVisible);
  this.SetMenuItemVisibility(menu, SchedulerMenuItemId.StatusSubMenu, statusSubMenuVisible);
  if (aptFlags.allowEdit) {
   this.UpdateAptSubMenu(menu, SchedulerMenuItemId.LabelSubMenu, apt.labelIndex);
   this.UpdateAptSubMenu(menu, SchedulerMenuItemId.StatusSubMenu, apt.statusIndex);
  }
  var aptType = apt.appointmentType;
  var isRecurring = aptType != ASPxAppointmentType.Normal;
  var editSeriesVisible = canShowForm && aptFlags.allowEdit && isRecurring;
  this.SetMenuItemVisibility(menu, SchedulerMenuItemId.EditSeries, editSeriesVisible);
  var isException = (aptType == ASPxAppointmentType.ChangedOccurrence || aptType == ASPxAppointmentType.DeletedOccurrence);
  var restoreOccurrenceVisible = aptFlags.allowEdit && isException;
  this.SetMenuItemVisibility(menu, SchedulerMenuItemId.RestoreOccurrence, restoreOccurrenceVisible);
  var count = menu.GetItemCount();
  for(var i = 0; i < count; i++) {
   var menuItem = menu.GetItem(i);
   if (menuItem.GetVisible())
    return true;
  }
  return false;
 },
 UpdateAptSubMenu: function(menu, subMenuName, subMenuItemIndex) {
  var subMenu = menu.GetItemByName(subMenuName);
  if (!_aspxIsExists(subMenu))
   return;
  this.UncheckAllSubMenuItems(subMenu);
  var item = subMenu.GetItem(subMenuItemIndex);
  if (_aspxIsExists(item))
   item.SetChecked(true);
 },
 UncheckAllSubMenuItems: function(subMenu) {
  var count = subMenu.items.length;
  for (var i = 0; i < count; i++) {
   var item = subMenu.items[i];
   item.SetChecked(false);
  }
 },
 UpdateViewMenuItems: function(menu) {
  this.UpdateSwitchViewSubMenu(menu);
  var viewType = this.scheduler.GetActiveViewType();
  if (viewType == ASPxSchedulerViewType.Timeline) {
   this.UpdateEnabledScalesSubMenu(menu);
   this.UpdateVisibleScalesSubMenu(menu);
  }
  else if (viewType == ASPxSchedulerViewType.Day || viewType == ASPxSchedulerViewType.WorkWeek)
   this.UpdateTimeSlotMenuItems(menu);
  var canShowAptForm = this.scheduler.aptFormVisibility != ASPxSchedulerFormVisibility.None;
  this.SetMenuItemVisibility(menu, SchedulerMenuItemId.NewAppointment, canShowAptForm);
  this.SetMenuItemVisibility(menu, SchedulerMenuItemId.NewAllDayEvent, canShowAptForm);
  this.SetMenuItemVisibility(menu, SchedulerMenuItemId.NewRecurringAppointment, canShowAptForm);
  this.SetMenuItemVisibility(menu, SchedulerMenuItemId.NewRecurringEvent, canShowAptForm);
  this.SetMenuItemVisibility(menu, SchedulerMenuItemId.GotoDate, this.scheduler.gotoDateFormVisibility != ASPxSchedulerFormVisibility.None);
 },
 SetMenuItemVisibility: function(menu, itemName, visible) {
  var item = menu.GetItemByName(itemName);
  if (_aspxIsExists(item))
   item.SetVisible(visible);
 },
 UpdateSwitchViewSubMenu: function(menu) {
  var subMenu = menu.GetItemByName(SchedulerMenuItemId.SwitchViewMenu);
  if (!_aspxIsExists(subMenu))
   return;
  var itemId = this.GetCurrentViewMenuId();
  var item = subMenu.GetItemByName(itemId);
  if (!_aspxIsExists(item))
   return;
  item.SetChecked(true);
 },
 UpdateEnabledScalesSubMenu: function(menu) {
  var subMenu = menu.GetItemByName(SchedulerMenuItemId.TimeScaleEnable);
  if (!_aspxIsExists(subMenu))
   return;
  var count = subMenu.GetItemCount();
  for (var i = 0; i < count; i++)
   subMenu.GetItem(i).SetChecked(this.scheduler.enabledTimeScalesInfo[i] != 0);
 },
 UpdateVisibleScalesSubMenu: function(menu) {
  var subMenu = menu.GetItemByName(SchedulerMenuItemId.TimeScaleVisible);
  if (!_aspxIsExists(subMenu))
   return;
  var count = subMenu.GetItemCount();
  for (var i = 0; i < count; i++) {
   var item = subMenu.GetItem(i);
   if (this.scheduler.enabledTimeScalesInfo[i] != 0) {
    item.SetEnabled(true);
    item.SetChecked(this.scheduler.visibleTimeScalesInfo[i] != 0);
   }
   else {
    item.SetEnabled(false);
    item.SetChecked(false);
   }
  }
 },
 UpdateTimeSlotMenuItems: function(menu) {
  var item = menu.GetItemByName(this.scheduler.currentTimeScaleMenuItemName);
  if (!_aspxIsExists(item))
   return;
  item.SetChecked(true);
 },
 GetCurrentViewMenuId: function() {
  switch (this.scheduler.GetActiveViewType()) {
   default:
   case ASPxSchedulerViewType.Day:
    return SchedulerMenuItemId.SwitchToDayView;
   case ASPxSchedulerViewType.WorkWeek:
    return SchedulerMenuItemId.SwitchToWorkWeekView;
   case ASPxSchedulerViewType.Week:
    return SchedulerMenuItemId.SwitchToWeekView;
   case ASPxSchedulerViewType.Month:
    return SchedulerMenuItemId.SwitchToMonthView;
   case ASPxSchedulerViewType.Timeline:
    return SchedulerMenuItemId.SwitchToTimelineView;
  }
 }
});
function aspxSchedulerShowViewMenu(name, sender, evt) {
 evt = _aspxGetEvent(evt);
 var scheduler = aspxGetControlCollection().Get(name);
 if(scheduler != null)
  scheduler.menuManager.ShowViewMenu(sender, evt);
}
function aspxSchedulerShowAptMenu(name, sender, evt) {
 evt = _aspxGetEvent(evt);
 var scheduler = aspxGetControlCollection().Get(name);
 if(scheduler != null)
  scheduler.menuManager.ShowAptMenu(sender, evt);
 evt.returnValue = false;
 evt.cancelBubble = true;
}
function aspxSchedulerAppointmentSmartTagClickMenu(name, sender, evt) {
 var scheduler = aspxGetControlCollection().Get(name);
 if(scheduler != null) {
  scheduler.OnAppointmentSmartTagClick(sender, evt);
 }
}
function aspxSchedulerGetSchedulerFromMenu(menu) {
 if(menu == null) return null;
 var pos = menu.name.lastIndexOf("_");
 if(pos < 0)
  return null;
  var name = menu.name.substring(0, pos);
  pos = name.lastIndexOf("_");  
  if(pos > -1)
  return aspxGetControlCollection().Get(menu.name.substring(0, pos));
 return null;
}
function aspxSchedulerOnViewMenuClick(s, args) {
 var scheduler = aspxSchedulerGetSchedulerFromMenu(s);
 if(scheduler != null) {
  if (args.item.GetItemCount() <= 0)
   scheduler.menuManager.OnViewMenuClick(args.item.name);
 }
}
function aspxSchedulerOnAptMenuClick(s, args) {
 var scheduler = aspxSchedulerGetSchedulerFromMenu(s);
 if(scheduler != null) {
  if (args.item.GetItemCount() <= 0)
   scheduler.menuManager.OnAptMenuClick(args.item.name);
 }
}
ASPxClientTimeInterval = _aspxCreateClass(null, {
 constructor: function(start, duration) {
  this.start = start;
  this.duration = duration;
  this.end = _aspxDateIncreaseWithUtcOffset(start, duration);
 },
 __toJsonExceptKeys: ['end'],
 ToString: function() {
  return _aspxDateTimeToMilliseconds(this.start) + "," + this.duration;
 },
 GetStart: function() {
  return this.start;
 },
 GetDuration: function() {
  return this.duration;
 },
 GetEnd: function() {
  return this.end;
 },
 SetStart: function(newStartTime) {
  this.duration -=  _aspxDateSubsWithTimezone(newStartTime, this.start);
  this.start = newStartTime;
 },
 SetDuration: function(newDuration) {
  this.duration = newDuration;
  this.end = _aspxDateIncreaseWithUtcOffset(this.start, this.duration);
 },
 SetEnd: function(newEndTime) {
  this.duration += _aspxDateSubsWithTimezone(newEndTime, this.end);
  this.end = newEndTime;
 },
 Equals: function(interval) {
  if(_aspxIsExists(interval) && _aspxIsExists(interval.start) && _aspxIsExists(interval.end))
   return (interval.start - this.start) == 0 && (interval.end - this.end) == 0;
  else
   return false;
 },
 IntersectsWith: function(interval) {
  return (interval.start - this.start) >= 0 && (interval.end - this.end) <= 0;
 },
 IntersectsWithExcludingBounds: function(interval) {
  if (this.duration == 0 && interval.duration == 0 && interval.start - this.start == 0)
   return true;
  return (interval.end - this.start) > 0 && (interval.start - this.end) < 0;
 },
 Contains: function(interval) {
  if (interval == null)
   return false;
  return interval.start >= this.start && interval.end <= this.end;
 },
 IsSmallerThanDay: function() {
  return this.duration < ASPxSchedulerDateTimeHelper.DaySpan;
 },
 IsDurationEqualToDay: function() {
  return this.duration == ASPxSchedulerDateTimeHelper.DaySpan;
 },
 IsZerroDurationInterval: function() {
  return this.duration == 0;
 },
 Clone: function() {
  return new ASPxClientTimeInterval(this.start, this.duration);
 }
});

