var __aspxCalendarWeekCount=6;var __aspxCalendarMsPerDay=86400000;var __aspxActiveCalendar=null;ASPxClientCalendar=_aspxCreateClass(ASPxClientEdit,{constructor:function(name){this.constructor.prototype.constructor.call(this,name);this.SelectionChanged=new ASPxClientEvent();this.VisibleMonthChanged=new ASPxClientEvent();this.SelectionChanging=new ASPxClientEvent();this.visibleDate=new Date();this.selectedDate=null;this.firstDayOfWeek=0;this.showWeekNumbers=true;this.monthNames=[];this.readonly=false;this.forceMouseUp=false;this.isMouseDown=false;},Initialize:function(){var monthCell=this.GetMonthCell();if(_aspxIsExistsElement(monthCell))_aspxPreventElementDragAndSelect(monthCell,false);_aspxAttachEventToDocument("mouseup",aspxEdCCancelMouseDown);this.savedSelection=this.selectedDate;this.constructor.prototype.Initialize.call(this);},InitializeMouseOver:function(){var index;for(var i=0;i<__aspxCalendarWeekCount;i++){for(var j=0;j<7;j++){index=i*7+j;_aspxAttachEventToElement(this.GetDayCell(index),"mouseover",new Function("aspxEdCDayMouseEvt('"+this.name+"', "+index+", 'over');"));}}},FindInputElement:function(){return _aspxGetElementById(this.name+"_STATE");},GetStartDate:function(){var date=new Date(this.visibleDate.getFullYear(),this.visibleDate.getMonth(),1);var offset=date.getDay()-this.firstDayOfWeek;if(offset<0)offset+=7;var result=ASPxClientCalendar.AddDays(date,-offset);return result;},GetDateByDayIndex:function(index){return ASPxClientCalendar.AddDays(this.GetStartDate(),index);},GetIndexByDate:function(date){var ms=ASPxClientCalendar.GetUTCTime(date)-ASPxClientCalendar.GetUTCTime(this.GetStartDate());return Math.floor(ms/__aspxCalendarMsPerDay);},IsDateSelected:function(date){return ASPxClientCalendar.AreDatesEqual(date,this.selectedDate);},IsDateOtherMonth:function(date){if(date==null)return false;return date.getMonth()!=this.visibleDate.getMonth()||date.getFullYear()!=this.visibleDate.getFullYear();},IsDateWeekend:function(date){var day=date.getDay();return day==0||day==6;},Redraw:function(){this.UpdateDays();this.UpdateTitle();this.DrawSelection();},UpdateDays:function(){var date=this.GetStartDate();var offset=this.firstDayOfWeek-1;if(offset<0)offset+=7;var weekNumber=ASPxClientCalendar.GetISO8601WeekOfYear(ASPxClientCalendar.AddDays(date,offset));for(var i=0;i<__aspxCalendarWeekCount;i++){if(this.showWeekNumbers)this.GetWeekNumberCell(i).innerHTML=(weekNumber<10?"0":"")+weekNumber.toString();for(var j=0;j<7;j++){var cell=this.GetDayCell(i*7+j);cell.innerHTML=date.getDate();this.ApplyDayCellStyle(cell,date,false);date=ASPxClientCalendar.AddDays(date,1);}if(++weekNumber>52)weekNumber=ASPxClientCalendar.GetISO8601WeekOfYear(ASPxClientCalendar.AddDays(date,offset));}},UpdateTitle:function(){var title=this.GetTitleCell();if(title){title.innerHTML=this.monthNames[this.visibleDate.getMonth()]+" "+this.visibleDate.getFullYear();}},SetSelection:function(date){this.HideSelection();this.selectedDate=date;this.DrawSelection();},HideSelection:function(date){this.DrawHideSelectionCore(date,false);},DrawSelection:function(date){this.DrawHideSelectionCore(date,true);},DrawHideSelectionCore:function(date,showSelection){if(!_aspxIsExistsType(typeof(date)))date=this.selectedDate;if(date!=null){var index=this.GetIndexByDate(date);if(index<0||index>7*__aspxCalendarWeekCount-1)return;var cell=this.GetDayCell(index);this.ApplyDayCellStyle(cell,date,showSelection);}},ApplyDayCellStyle:function(cell,date,applySelection){var info=new Object();info.className="";info.cssText="";this.ImportEtalonStyle(info,"_DE");if(this.IsDateWeekend(date))this.ImportEtalonStyle(info,"_DWE");if(this.IsDateOtherMonth(date))this.ImportEtalonStyle(info,"_DOE");if(applySelection)this.ImportEtalonStyle(info,"_DSE");cell.className=info.className;cell.style.cssText=info.cssText;},ImportEtalonStyle:function(info,suffix){var etalonCell=_aspxGetElementById(this.name+suffix);var cssText;var pos;if(etalonCell){if(info.className.length>1)info.className+=" ";info.className+=etalonCell.className;cssText=etalonCell.style.cssText;pos=cssText.length-1;while(pos>-1&&cssText.charAt(pos)==" ")--pos;if(cssText.charAt(pos)!=";")cssText+=";";info.cssText+=cssText;}},GetWeekNumberCell:function(index){return _aspxGetElementById(this.name+"_wn"+index);},GetDayCell:function(index){return _aspxGetElementById(this.name+"_d"+index);},GetTitleCell:function(){return _aspxGetElementById(this.name+"_t");},GetMonthCell:function(){if(this.cachedMonthCell==null)this.cachedMonthCell=_aspxGetElementById(this.name+"_mc");return this.cachedMonthCell;},SaveClientState:function(){var element=this.GetInputElement();if(element!=null){element.value=ASPxClientCalendar.GetInvariantDateString(this.visibleDate)+":"+ASPxClientCalendar.GetInvariantDateString(this.selectedDate);}},OnShiftMonth:function(offset){if(!offset)return;var newMonth=this.visibleDate.getMonth()+offset;var newYear=this.visibleDate.getFullYear();while(newMonth<0){newYear--;newMonth+=12;}while(newMonth>11){newYear++;newMonth-=12;}
var day=this.visibleDate.getDate();var date=new Date(newYear,newMonth,day);if(date.getDate()<day)date=ASPxClientCalendar.AddDays(date,-date.getDate());this.OnVisibleMonthChanged(date);},OnDayMouseEvent:function(index,type){if(!this.readonly){var date=this.GetDateByDayIndex(index);if(type=="down"){__aspxActiveCalendar=this;this.isMouseDown=true;this.savedSelection=this.selectedDate;this.SetSelection(date);}else if(type=="up"&&(this.isMouseDown||this.forceMouseUp)){this.isMouseDown=false;__aspxActiveCalendar=null;this.SetSelection(date);this.OnSelectionChanging(date);}else if(type=="over"&&this.isMouseDown){this.SetSelection(date);}}},OnTodayClick:function(){var date=new Date();if(this.IsDateOtherMonth(date))this.OnVisibleMonthChanged(date);this.OnSelectionChanging(date);},OnClearClick:function(){this.OnSelectionChanging(null);},OnSelectDate:function(date){if(!ASPxClientCalendar.AreDatesEqual(date,this.savedSelection))this.OnSelectionChanged(date);},OnSelectionChanging:function(date){if(!this.SelectionChanging.IsEmpty()){var args=new ASPxClientDateEventArgs(false,date);this.SelectionChanging.FireEvent(this,args);}
this.OnSelectDate(date);},OnSelectionChanged:function(date){this.SetSelectedDate(date);this.OnValueChanged();},OnVisibleMonthChanged:function(date){this.SetVisibleDate(date);var processOnServer=this.autoPostBack;if(_aspxIsExists(this.RaiseVisibleMonthChanged))processOnServer=this.RaiseVisibleMonthChanged();if(processOnServer)this.SendPostBackInternal("");},RaiseValueChangedEvent:function(){var processOnServer=ASPxClientEdit.prototype.RaiseValueChangedEvent.call(this);if(_aspxIsExists(this.RaiseSelectionChanged))processOnServer=this.RaiseSelectionChanged()||processOnServer;return processOnServer;},GetValue:function(){return this.selectedDate;},GetValueString:function(){return(this.selectedDate==null)?null:ASPxClientCalendar.GetInvariantDateString(this.selectedDate);},SetValue:function(value){if(value!=null)this.SetVisibleDate(value);this.SetSelectedDate(value);},SetVisibleDate:function(date){var old=this.visibleDate;this.visibleDate=date;if(!ASPxClientCalendar.AreDatesOfSameMonth(date,old))this.Redraw();this.SaveClientState();},SetSelectedDate:function(date){this.SetSelection(date);this.SaveClientState();this.savedSelection=date;}});ASPxClientCalendar.AreDatesEqual=function(date1,date2){if(date1==date2)return true;if(!date1||!date2)return false;return date1.getFullYear()==date2.getFullYear()&&date1.getMonth()==date2.getMonth()&&date1.getDate()==date2.getDate();}
ASPxClientCalendar.AreDatesOfSameMonth=function(date1,date2){if(!date1||!date2)return false;return date1.getFullYear()==date2.getFullYear()&&date1.getMonth()==date2.getMonth();}
ASPxClientCalendar.GetUTCTime=function(date){return Date.UTC(date.getFullYear(),date.getMonth(),date.getDate());}
ASPxClientCalendar.GetFirstDayOfYear=function(date){return new Date(date.getFullYear(),0,1);}
ASPxClientCalendar.GetDayOfYear=function(date){var ms=ASPxClientCalendar.GetUTCTime(date)-ASPxClientCalendar.GetUTCTime(ASPxClientCalendar.GetFirstDayOfYear(date));return 1+Math.floor(ms/__aspxCalendarMsPerDay);}
ASPxClientCalendar.GetInvariantDateString=function(date){if(date){var day=date.getDate();var month=date.getMonth()+1;var year=date.getFullYear();var result="";if(month<10)result+="0";result+=month.toString()+"/";if(day<10)result+="0";result+=day.toString()+"/"+year.toString();return result;}return "01/01/0001";}
ASPxClientCalendar.GetISO8601WeekOfYear=function(date){var firstDate=new Date(date.getFullYear(),0,1);var firstDayOfWeek=firstDate.getDay();if(firstDayOfWeek==0)firstDayOfWeek=7;var daysInFirstWeek=8-firstDayOfWeek;var lastDate=new Date(date.getFullYear(),11,31);var lastDayOfWeek=lastDate.getDay();if(lastDayOfWeek==0)lastDayOfWeek=7;var daysInLastWeek=8-lastDayOfWeek;var fullWeeks=Math.ceil((ASPxClientCalendar.GetDayOfYear(date)-daysInFirstWeek)/7);var result=fullWeeks;if(daysInFirstWeek>3)result++;var isThursday=firstDayOfWeek==4||lastDayOfWeek==4;if(result>52&&!isThursday)result=1;if(result==0)return ASPxClientCalendar.GetISO8601WeekOfYear(new Date(date.getFullYear()-1,11,31));return result;}
ASPxClientCalendar.AddDays=function(date,count){var newDate=new Date();newDate.setTime(date.getTime());newDate.setDate(count+newDate.getDate());return newDate;}
function aspxEdCShiftMonth(name,monthOffset){if(monthOffset!=0){var edit=aspxGetControlCollection().Get(name);if(edit!=null)edit.OnShiftMonth(monthOffset);}}
function aspxEdCDayMouseEvt(name,dayIndex,type){var edit=aspxGetControlCollection().Get(name);if(edit!=null)edit.OnDayMouseEvent(dayIndex,type);}
function aspxEdCTodayClick(name){var edit=aspxGetControlCollection().Get(name);if(edit!=null)edit.OnTodayClick();}
function aspxEdCClearClick(name){var edit=aspxGetControlCollection().Get(name);if(edit!=null)edit.OnClearClick();}
function aspxEdCCancelMouseDown(evt){var target=_aspxGetEventSource(evt);if(_aspxIsExistsElement(target)&&__aspxActiveCalendar!=null){if(__aspxActiveCalendar.isMouseDown){var monthCell=__aspxActiveCalendar.GetMonthCell();var parent=target.parentNode;while(_aspxIsExistsElement(parent)){if(parent==monthCell)return;parent=parent.parentNode;}
__aspxActiveCalendar.isMouseDown=false;__aspxActiveCalendar.SetSelection(__aspxActiveCalendar.savedSelection);__aspxActiveCalendar=null;}}}