ASPxClientSchedulerToolTip = _aspxCreateClass(ASPxClientControl, {
 constructor: function(name){
  this.constructor.prototype.constructor.call(this, name);
  this.canShowToolTip = true;
 },
 Initialize: function(){
  this.constructor.prototype.Initialize.call(this);
  this.mainDiv = this.GetElementById("mainDiv");
  this.toolTipParent = this.mainDiv.parentNode;
  this.mainDiv.isToolTip = true;
  if(this.isVisible)
   this.ShowToolTip();   
 },
 HideToolTip: function() {  
  if(!this.isVisible)
   return;
  this.isVisible = false;
  _aspxSetElementDisplay(this.mainDiv, false);  
  this.aspxParentControl.activeToolTip = null;
 },
 ShouldResetPositionByTimer: function() {
  if (!_aspxIsExists(this.templatedToolTip))
   return false;
  return this.templatedToolTip.ShouldResetPositionByTimer();
 },
 CanCloseByMouseClick: function() {
  if (!_aspxIsExists(this.templatedToolTip))
   return false;
  return this.templatedToolTip.CanCloseByMouseClick();
 },
 ShowToolTip: function(documentX, documentY) {
  if (_aspxIsExists(this.aspxParentControl.activeToolTip) && this.aspxParentControl.activeToolTip != this ) {
   return;
  }
  this.aspxParentControl.activeToolTip = this;
  this.isVisible = true;
  this.mainDiv.dataObject = this.dataObject;
  _aspxSetElementVisibility(this.mainDiv, false);
  _aspxSetElementDisplay(this.mainDiv, true);
  var positionX = documentX - _aspxGetAbsoluteX(this.toolTipParent);
  var positionY = documentY - _aspxGetAbsoluteY(this.toolTipParent);
  var position = new ASPxClientPoint(positionX, positionY);
  if (_aspxIsExists(this.templatedToolTip)) {
   var bounds = new ASPxClientRect(positionX, positionY, this.mainDiv.offsetWidth, this.mainDiv.offsetHeight);
   position = this.templatedToolTip.CalculatePosition(bounds);
  }
  this.SetDivPosition(this.mainDiv, position.GetX(), position.GetY());
  _aspxSetElementVisibility(this.mainDiv, true);
 },
 SetDivPosition: function(element, left, dxtop) {
  element.style.left = left + "px";
  element.style.top = dxtop + "px";
 },
 CanShowToolTip: function() {
  return this.canShowToolTip; 
 },
 AdjustImageWidth: function(element) {
 },
 AdjustCellSize: function(cell, image) {
 },
 GetElementById: function(id) {
  return _aspxGetElementById(this.name + "_" + id);
 },
 SetContent: function(toolTipData) {
  if (!_aspxIsExists(this.templatedToolTip))
   return;
  this.templatedToolTip.Update(toolTipData); 
 },
 FinalizeUpdate: function(toolTipData) {
  if (!_aspxIsExists(this.templatedToolTip))
   return;
  this.templatedToolTip.FinalizeUpdate(toolTipData); 
 }
});
ASPxClientSchedulerToolTipData = _aspxCreateClass(null, {
 constructor: function(appointment, interval, resources) {
  this.appointment = _aspxIsExists(appointment) ? appointment : null;
  this.interval = _aspxIsExists(interval) ? interval : null;
  this.resources = _aspxIsExists(resources) ? resources : null;
 },
 GetAppointment: function() {
  return this.appointment;
 },
 GetInterval: function() {
  return this.interval;
 },
 GetResources: function() {
  return this.resoruces;
 }
});
ASPxClientToolTipBase = _aspxCreateClass(null, {
 constructor: function(scheduler) {
  this.constructor.prototype.constructor.call(this);
  this.scheduler = scheduler; 
  this.controls = new Object;
  this.canCloseByClick = false;
 },
 Initialize: function() {
 },
 FinalizeUpdate: function(toolTipData) {
 },
 Update: function(toolTipData) {
 },
 Close: function() {
  if (_aspxIsExists(this.scheduler)) {
   this.scheduler.HideAllToolTips();
  }
 },
 CalculatePosition: function(bounds) {
  return new ASPxClientPoint(bounds.GetLeft() - bounds.GetWidth() / 2, bounds.GetTop() - bounds.GetHeight());
 },
 ShowAppointmentMenu: function(s) {
  var evt = _aspxGetEvent(s);
  if(!_aspxIsExists(evt)) return null;
  var sender = __aspxIE ? evt.srcElement : evt.target
  if(!_aspxIsExists(sender)) return null;
  this.scheduler.OnAppointmentToolTipClick(sender, evt);
 },
 ShowViewMenu: function(s) {
  var evt = _aspxGetEvent(s);
  if(!_aspxIsExists(evt)) return null;
  var sender = __aspxIE ? evt.srcElement : evt.target
  if(!_aspxIsExists(sender)) return null;
  this.scheduler.menuManager.ShowViewMenu(sender, evt);
 },
 ShouldResetPositionByTimer: function() {
  if (_aspxIsExists(this.resetPositionByTimer))
   return this.resetPositionByTimer;
  return false;
 },
 CanCloseByMouseClick: function() {
  return this.canCloseByClick;
 },
 ConvertIntervalToString: function(interval) {
  var formatter = new ASPxDateFormatter();
  var startTimeFormat = this.SelectStartTimeFormat(this.scheduler, interval);
  var endTimeFormat = this.SelectEndTimeFormat(this.scheduler, interval);
  formatter.SetFormatString(startTimeFormat);
  var result = formatter.Format(interval.GetStart());
  if(_aspxIsExists(endTimeFormat)) {
   formatter.SetFormatString(endTimeFormat);
   result += " - " + formatter.Format(interval.GetEnd());
  }
  return result;  
 },
 SelectStartTimeFormat: function(scheduler, interval) {
  var intervalStart = interval.GetStart();
  var intervalEnd = interval.GetEnd();
   var startDate = intervalStart.getDate();
  var startYear = intervalStart.getYear();
  var startMonth = intervalStart.getMonth();
  var endDate = intervalEnd.getDate();
  var endYear = intervalEnd.getYear();
  var endMonth = intervalEnd.getMonth();
  var truncStartDate = new Date(startYear, startMonth, startDate);
  var truncEndDate = new Date(endYear, endMonth, endDate);
  var datesEquals = startDate == endDate && startMonth == endMonth && startYear == endYear;
  if(datesEquals) {
    if(interval.IsSmallerThanDay())
     return scheduler.formatsTimeWithMonthDay[0];
    else
     return scheduler.formatsWithoutYearAndWeekDay[0];
   }
  else {
   if(truncStartDate - interval.GetStart() == 0&& truncEndDate - interval.GetEnd() == 0) {   
    if(startYear == endYear || interval.IsDurationEqualToDay())
      return scheduler.formatsWithoutYearAndWeekDay[0];    
     else
      return scheduler.formatsDateWithYear[0];    
    }
    else {
     if(startYear == endYear)
      return scheduler.formatsTimeWithMonthDay[0];    
     else
      return scheduler.formatsDateTimeWithYear[0];    
   }
  }
 },
 SelectEndTimeFormat: function(scheduler, interval) {
   var intervalStart = interval.GetStart();
  var intervalEnd = interval.GetEnd();
  var startDate = intervalStart.getDate();
  var startYear = intervalStart.getYear();
  var startMonth = intervalStart.getMonth();
  var endDate = intervalEnd.getDate();
  var endYear = intervalEnd.getYear();
  var endMonth = intervalEnd.getMonth();
  var truncStartDate = new Date(startYear, startMonth, startDate);
  var truncEndDate = new Date(endYear, endMonth, endDate);
  var datesEquals = startDate == endDate && startMonth == endMonth && startYear == endYear;
  if(datesEquals) {
    if(interval.IsSmallerThanDay())
     return scheduler.formatsTimeOnly[0];
    else
     return null;
  }
  else {
   if(truncStartDate - interval.GetStart() == 0&& truncEndDate - interval.GetEnd() == 0) {   
    if(startYear == endYear || interval.IsDurationEqualToDay())
      return (interval.IsDurationEqualToDay()) ? null : scheduler.formatsWithoutYearAndWeekDay[0];    
     else
      return scheduler.formatsDateWithYear[0];    
   }
   else {
    if(startYear == endYear)
      return scheduler.formatsTimeWithMonthDay[0];    
     else
      return scheduler.formatsDateTimeWithYear[0];    
   }
  }
 } 
});
