var a; (function(c){c.widget("ui.weekCalendar",{_init:function(){var b=this;b._computeOptions();b._setupEventDelegation();b._renderCalendar();b._loadCalEvents();b._resizeCalendar();b._scrollToHour(b.options.date.getHours());c(window).unbind("resize.weekcalendar");c(window).bind("resize.weekcalendar",function(){b._resizeCalendar()})},refresh:function(){this._clearCalendar();this._loadCalEvents(this.element.data("startDate"))},clear:function(){this._clearCalendar()},today:function(){this._clearCalendar();this._loadCalEvents(new Date)}, prevWeek:function(){var b=new Date(this.element.data("startDate").getTime()-k/6);this._clearCalendar();this._loadCalEvents(b)},nextWeek:function(){var b=new Date(this.element.data("startDate").getTime()+k+k/7);this._clearCalendar();this._loadCalEvents(b)},gotoWeek:function(b){this._clearCalendar();this._loadCalEvents(b)},removeEvent:function(b){this.element.find(".cal-event").each(function(){if(c(this).data("calEvent").id===b){c(this).fadeOut(function(){c(this).remove()});return false}})},removeUnsavedEvents:function(){this.element.find(".new-cal-event").fadeOut(function(){c(this).remove()})}, updateEvent:function(b){this._updateEventInCalendar(b)},getTimeslotTimes:function(b){var i=this.options,e=i.businessHours.limitDisplay?i.businessHours.start:0,d=[];b=(new Date(b.getFullYear(),b.getMonth(),b.getDate(),e)).getTime();for(e=0;e').appendTo(d.element);if(j.buttons){i='
";c(i).appendTo(b);b.find(".calendar-nav .today").click(function(){d.element.weekCalendar("today"); return false});b.find(".calendar-nav .prev").click(function(){d.element.weekCalendar("prevWeek");return false});b.find(".calendar-nav .next").click(function(){d.element.weekCalendar("nextWeek");return false})}i='';for(var g=1;g<=7;g++)i+='';i+='
';e='
";for(g=1;g<=7;g++)e+='';e+="
'; var l=j.businessHours.limitDisplay?j.businessHours.start:0,m=j.businessHours.limitDisplay?j.businessHours.end:24;for(g=l;g
';e+='
'}e+='
';for(g=l;g';e+=j.use24Hour?'
'+d._24HourForIndex(g)+ "
":'
'+d._hourForIndex(g)+''+d._amOrPm(g)+"
";e+=""}e+="
";c(i+e).appendTo(b);b.find(".day-column-inner").each(function(){c(this).height(j.timeslotHeight*j.timeslotsPerDay);if(!j.readonly){d._addDroppableToWeekDay(c(this));d._setupEventCreationForWeekDay(c(this))}});b.find(".time-slot").height(j.timeslotHeight- 1);b.find(".time-header-cell").css({height:j.timeslotHeight*j.timeslotsPerHour-11,padding:5})},_setupEventCreationForWeekDay:function(b){var i=this,e=this.options;b.mousedown(function(d){var j=c(d.target);if(j.hasClass("day-column-inner")){var g=c('
');g.css({lineHeight:e.timeslotHeight-2+"px",fontSize:e.timeslotHeight/2+"px"});j.append(g);var l=j.offset().top;d=d.pageY-l;var m=(d-d%e.timeslotHeight)/e.timeslotHeight*e.timeslotHeight; g.css({top:m});j.bind("mousemove.newevent",function(q){g.show();g.addClass("ui-resizable-resizing");q=Math.round(q.pageY-l-m);var u=q%e.timeslotHeight;if(u"+i._formatDate(d,e.dateFormat));i._isToday(d)?c(this).addClass("today"):c(this).removeClass("today");d=i._addDays(d,1)});d=i._dateFirstDayOfWeek(i._cloneDate(i.element.data("startDate"))); b.each(function(){c(this).data("startDate",i._cloneDate(d));c(this).data("endDate",new Date(d.getTime()+(f-1)));i._isToday(d)?c(this).parent().addClass("today"):c(this).parent().removeClass("today");d=i._addDays(d,1)})},_renderEvents:function(b,i){var e=this,d=this.options,j;if(c.isArray(b))j=e._cleanEvents(b);else if(b.events)j=e._cleanEvents(b.events);if(b.options){var g=false;c.each(b.options,function(l,m){if(m!==d[l]){d[l]=m;g=true}});e._computeOptions();if(g){e.element.empty();e._renderCalendar(); i=e.element.find(".week-calendar-time-slots .day-column-inner");e._updateDayColumnHeader(i);e._resizeCalendar()}}c.each(j,function(l,m){(l=e._findWeekDayForEvent(m,i))&&e._renderEvent(m,l)});i.each(function(){e._adjustOverlappingEvents(c(this))});d.calendarAfterLoad(e.element);j.length||d.noEvents()},_renderEvent:function(b,i){var e=this,d=this.options;if(!(b.start.getTime()>b.end.getTime())){var j,g;j=c('
'); j=(g=d.eventRender(b,j))?g.appendTo(i):j.appendTo(i);j.css({lineHeight:d.timeslotHeight-2+"px",fontSize:d.timeslotHeight/2+"px"});e._refreshEventDetails(b,j);e._positionEvent(i,j);j.show();!d.readonly&&d.resizable(b,j)&&e._addResizableToCalEvent(b,j,i);!d.readonly&&d.draggable(b,j)&&e._addDraggableToCalEvent(b,j);d.eventAfterRender(b,j);return j}},_adjustOverlappingEvents:function(b){var i=this;if(i.options.allowCalEventOverlap){b=i._groupOverlappingEventElements(b);c.each(b,function(){var e=this.length, d=this;if(i.options.overlapEventsSeparate)var j=100/e,g=j;else{j=100-e*10;g=(100-j)/(e-1)}c.each(this,function(l){l=l*g;i.options.overlapEventsSeparate||c(this).bind("mouseover.z-index",function(){var m=c(this);c.each(d,function(){c(this).css({"z-index":"1"})});m.css({"z-index":"3"})});c(this).css({width:j+"%",left:l+"%",right:0})})})}},_groupOverlappingEventElements:function(b){var i=b.find(".cal-event").sort(function(q,u){return c(q).data("calEvent").start.getTime()-c(u).data("calEvent").start.getTime()}), e=[],d=[],j,g=0,l=0,m=0;c.each(i,function(){j=c(this);g=j.data("calEvent").start.getTime();l=j.data("calEvent").end.getTime();j.css({width:"100%",left:"0%",right:"","z-index":"1"});j.unbind("mouseover.z-index");if(!(j.data("calEvent").start.getTime()c(this).data("calEvent").start.getTime()+1||ll)l=c(this).data("calEvent").end.getTime(); c.inArray(c(this),d)==-1&&d.push(c(this));c.inArray(j,d)==-1&&d.push(j)}});if(d.length){d.sort(function(q,u){return c(q).data("calEvent").start.getTime()>c(u).data("calEvent").start.getTime()?1:c(q).data("calEvent").start.getTime()=b.end.getTime()){e=c(this);return false}});return e},_updateEventInCalendar:function(b){var i=this;i._cleanEvent(b);b.id&&i.element.find(".cal-event").each(function(){if(c(this).data("calEvent").id===b.id||c(this).hasClass("new-cal-event")){c(this).remove(); return false}});var e=i._findWeekDayForEvent(b,i.element.find(".week-calendar-time-slots .day-column-inner"));if(e){i._renderEvent(b,e);i._adjustOverlappingEvents(e)}},_positionEvent:function(b,i){var e=this.options,d=i.data("calEvent");b=b.height()/e.millisToDisplay;e=e.businessHours.limitDisplay?e.businessHours.start:0;e=d.start.getTime()-(new Date(d.start.getFullYear(),d.start.getMonth(),d.start.getDate(),e)).getTime();d=d.end.getTime()-d.start.getTime();i.css({top:b*e,height:b*d})},_getEventDurationFromPositionedEventElement:function(b, i,e){var d=this.options,j=d.businessHours.limitDisplay?d.businessHours.start*60*60*1E3:0;b=new Date(b.data("startDate").getTime()+j+Math.round(e/d.timeslotHeight)*d.millisPerTimeslot);i=new Date(b.getTime()+i.height()/d.timeslotHeight*d.millisPerTimeslot);return{start:b,end:i}},_adjustForEventCollisions:function(b,i,e,d,j){if(!this.options.allowCalEventOverlap){var g,l,m=this;b.find(".cal-event").not(i).each(function(){var q=c(this).data("calEvent");if(e.start.getTime()= q.end.getTime())g=q.end;if(e.end.getTime()>q.start.getTime()&&e.start.getTime()<=q.start.getTime())l=q.start;if(e.end.getTime()<=q.end.getTime()&&e.start.getTime()>=q.start.getTime()){g=d.start;l=d.end;return false}});e.start=g||e.start;if(g&&j){e.end=new Date(g.getTime()+(d.end.getTime()-d.start.getTime()));m._adjustForEventCollisions(b,i,e,d)}else e.end=l||e.end;if(e.start.getTime()>=e.end.getTime()){e.start=d.start;e.end=d.end}i.data("calEvent",e)}},_addDraggableToCalEvent:function(b,i){var e= this,d=this.options;e._findWeekDayForEvent(b,e.element.find(".week-calendar-time-slots .day-column-inner"));i.draggable({handle:".time",containment:".calendar-scrollable-grid",revert:"valid",opacity:0.5,grid:[i.outerWidth()+1,d.timeslotHeight],start:function(j,g){d.eventDrag(b,g.draggable)}})},_addDroppableToWeekDay:function(b){var i=this,e=this.options;b.droppable({accept:".cal-event",drop:function(d,j){var g=j.draggable;d=Math.round(parseInt(j.position.top));j=i._getEventDurationFromPositionedEventElement(b, g,d);d=g.data("calEvent");j=c.extend(true,{start:j.start,end:j.end},d);i._adjustForEventCollisions(b,g,j,d,true);var l=i.element.find(".day-column-inner");l=i._renderEvent(j,i._findWeekDayForEvent(j,l));g.hide();e.eventDrop(j,d,l);g.data("preventClick",true);setTimeout(function(){var m=i._findWeekDayForEvent(g.data("calEvent"),i.element.find(".week-calendar-time-slots .day-column-inner"));g.remove();m.data("startDate")!=b.data("startDate")&&i._adjustOverlappingEvents(m);i._adjustOverlappingEvents(b)}, 500)}})},_addResizableToCalEvent:function(b,i,e){var d=this,j=this.options;i.resizable({grid:j.timeslotHeight,containment:e,handles:"s",minHeight:j.timeslotHeight,stop:function(g,l){var m=l.element;g=new Date(m.data("calEvent").start.getTime()+m.height()/j.timeslotHeight*j.millisPerTimeslot);g=c.extend(true,{start:b.start,end:g},b);d._adjustForEventCollisions(e,m,g,b);d._refreshEventDetails(g,m);d._positionEvent(e,m);j.eventResize(g,b,m);m.data("preventClick",true);setTimeout(function(){m.removeData("preventClick")}, 500)}})},_refreshEventDetails:function(b,i){var e=this,d=this.options;i.find(".time").text(e._formatDate(b.start,d.timeFormat)+d.timeSeparator+e._formatDate(b.end,d.timeFormat));i.find(".title").text(b.title);i.data("calEvent",b)},_clearCalendar:function(){this.element.find(".day-column-inner div").remove()},_scrollToHour:function(b){var i=this,e=this.options,d=this.element.find(".calendar-scrollable-grid"),j=b;if(i.options.businessHours.limitDisplay)if(b i.options.businessHours.end)j=i.options.businessHours.end-i.options.businessHours.start-1;var g=this.element.find(".grid-timeslot-header .hour-header:eq("+j+")");d.animate({scrollTop:0},0,function(){var l=g.offset().top-d.offset().top-g.outerHeight();d.animate({scrollTop:l},e.scrollToHourMillis)})},_hourForIndex:function(b){return b===0?12:b<13?b:b-12},_24HourForIndex:function(b){return b===0?"00:00":b<10?"0"+b+":00":b+":00"},_amOrPm:function(b){return b<12?"AM":"PM"},_isToday:function(b){b=this._cloneDate(b); this._clearTime(b);var i=new Date;this._clearTime(i);return i.getTime()===b.getTime()},_cleanEvents:function(b){var i=this;c.each(b,function(e,d){i._cleanEvent(d)});return b},_cleanEvent:function(b){if(b.date)b.start=b.date;b.start=this._cleanDate(b.start);b.end=this._cleanDate(b.end);if(!b.end)b.end=this._addDays(this._cloneDate(b.start),1)},_disableTextSelect:function(b){b.each(function(){if(c.browser.mozilla)c(this).css("MozUserSelect","none");else c.browser.msie?c(this).bind("selectstart",function(){return false}): c(this).mousedown(function(){return false})})},_dateFirstDayOfWeek:function(b){var i=this;b=new Date(b.getFullYear(),b.getMonth(),b.getDate());i=i._getAdjustedDayIndex(b)*864E5;return new Date(b.getTime()-i)},_dateLastDayOfWeek:function(b){var i=this;b=new Date(b.getFullYear(),b.getMonth(),b.getDate());i=(6-i._getAdjustedDayIndex(b))*f;return new Date(b.getTime()+i)},_getAdjustedDayIndex:function(b){b=(new Date(b.getFullYear(),b.getMonth(),b.getDate())).getDay();var i=[0,1,2,3,4,5,6];this._rotate(i, this.options.firstDayOfWeek);return i[b]},_dateLastMilliOfWeek:function(b){b=this._dateLastDayOfWeek(b);return new Date(b.getTime()+(f-1))},_clearTime:function(b){b.setHours(0);b.setMinutes(0);b.setSeconds(0);b.setMilliseconds(0);return b},_addDays:function(b,i,e){b.setDate(b.getDate()+i);if(e)return b;return this._clearTime(b)},_rotate:function(b,i){var e=b.length;i=(Math.abs(i)>=e&&(i%=e),i<0&&(i+=e),i);for(var d,j;i;i=(Math.ceil(e/i)-1)*i-e+(e=i))for(d=e;d>i;j=b[--d],b[d]=b[d-i],b[d-i]=j);return b}, _cloneDate:function(b){return new Date(+b)},_cleanDate:function(b){if(typeof b=="string")return c.weekCalendar.parseISO8601(b,true)||Date.parse(b)||new Date(parseInt(b));if(typeof b=="number")return new Date(b);return b},_formatDate:function(b,i){for(var e=this.options,d="",j=0;j0){var n=[],o=[];c.each(v,function(){var p=this;if(p.StartDateTime){if(typeof p.StartDateTime=="object"&&p.StartDateTime.getDate)this.StartDateTime=p.StartDateTime;if(typeof p.StartDateTime=="string"&& p.StartDateTime.split)this.StartDateTime=E(p.StartDateTime)}else if(p.Date){if(typeof p.Date=="object"&&p.Date.getDate)this.StartDateTime=p.Date;if(typeof p.Date=="string"&&p.Date.split)this.StartDateTime=E(p.Date)}else return;if(p.EndDateTime){if(typeof p.EndDateTime=="object"&&p.EndDateTime.getDate)this.EndDateTime=p.EndDateTime;if(typeof p.EndDateTime=="string"&&p.EndDateTime.split)this.EndDateTime=E(p.EndDateTime)}else this.EndDateTime=this.StartDateTime.clone();if(this.StartDateTime.clone().clearTime().compareTo(this.EndDateTime.clone().clearTime())== 0)o.push(this);else this.StartDateTime.clone().clearTime().compareTo(this.EndDateTime.clone().clearTime())==-1&&n.push(this)});n.sort(H);o.sort(H);v=[];c.merge(v,n);c.merge(v,o)}},H=function(n,o){return n.StartDateTime.compareTo(o.StartDateTime)},M=function(){I();k=[]},I=function(){for(var n=0;n").click(function(){c.J.ChangeMonth(n);return false}),p=i.clone().addMonths(1),z=c('").click(function(){c.J.ChangeMonth(p);return false}),B= i.clone().addYears(-1),w;if(s.navLinks.enablePrevYear)w=c('").click(function(){c.J.ChangeMonth(B);return false});var A=i.clone().addYears(1),t;if(s.navLinks.enableNextYear)t=c('").click(function(){c.J.ChangeMonth(A);return false});var x;if(s.navLinks.enableToday)x=c('").click(function(){c.J.ChangeMonth(new Date);return false}); var C=c('
'),y=c(".MonthNavigation",C);y.append(o,z);s.navLinks.enableToday&&y.append(x);y.append(c('
').append(Date.CultureInfo.monthNames[i.getMonth()]+" "+i.getFullYear()));s.navLinks.enablePrevYear&&y.append(w);s.navLinks.enableNextYear&&y.append(t);o=c("");for(z=s.firstDayOfWeek;z'+t+"")}o=c('').css({height:s.headerHeight+"px"}).append(o);return o=o.prepend(C)};c.J.DrawCalendar=function(n){var o=new Date;o.clearTime();var p=s.calendarStartDate;M();N(n);n=O();i.getMonth()==p.getMonth()&&(i.getFullYear(),p.getFullYear());var z=(c(s.containerId).outerHeight()-s.headerHeight)/m,B=null;p=c('');for(var w=0;w");B.css({height:z+"px"});p.append(B)}var t=(s.firstDayOfWeek+w)%7,x={"class":"DateBox"+(t==0||t==6?" Weekend ":""),date:A.toString("M/d/yyyy")};if(A.compareTo(d)==-1||A.compareTo(j)==1)x["class"]+=" Inactive";if(A.compareTo(o)==0)x["class"]+=" Today";t=c('");t.bind("click",{Date:A.clone()},s.onDayLinkClick);x=c("").attr(x).append(t);x.bind("dblclick",{Date:A.clone()},s.onDayCellDblClick);x.bind("click",{Date:A.clone()}, s.onDayCellClick);s.dragableEvents&&x.droppable({hoverClass:s.dragHoverClass,tolerance:"pointer",drop:function(C,y){var J=y.draggable.attr("eventid"),D=(new Date(c(this).attr("date"))).clearTime(),F;c.each(v,function(){if(this.EventID==J){var L=(new TimeSpan(D-this.StartDateTime)).days;this.StartDateTime.addDays(L);this.EndDateTime.addDays(L);F=this}});c.J.ClearEventsOnCalendar();G();s.onEventDropped.call(this,F,D)}});k.push(new f(w,A,x,t));B.append(x)}p.append(B);o=c(s.containerId);n=c('
').append(n, p);o.hide();o.html(n);o.fadeIn("normal");G()};var G=function(){K();I();if(v&&v.length>0){var n=c(s.containerId);c.each(v,function(){var p=this,z=p.StartDateTime.clone().clearTime(),B=p.EndDateTime.clone().clearTime(),w=(new TimeSpan(z-u.startDate)).days,A=(new TimeSpan(B-u.startDate)).days;A=A>k.length-1?k.length-1:A;for(w=w<0?0:w;w<=A;w++){var t=k[w],x=z.compareTo(t.date),C=B.compareTo(t.date),y=w!=0&&x==-1&&C>=0&&t.weekNumber!=k[w-1].weekNumber||w==0&&x==-1;if((x==0||w==0&&x==-1||y||x==-1&&C>=0)&& t.vOffset>=t.getCellBox().height()-t.getLabelHeight()-32){if(!t.isTooManySet){y=c('
'+s.navLinks.showMore+"
");x=t.getCellPosition();var J=w;y.css({top:x.top+(t.getCellBox().height()-t.getLabelHeight()),left:x.left,width:t.getLabelWidth()-7,position:"absolute"});y.click(function(F){P(F,J)});b[y.attr("id")]=y;t.isTooManySet=true}t.events.push(p)}else if(x==0||w==0&&x==-1||y){var D=Q(p,t.weekNumber);x=t.getCellPosition();D.css({top:x.top+t.getLabelHeight()+ t.vOffset,left:x.left,width:t.getLabelWidth()-7,position:"absolute"});t.vOffset+=19;if(y){D.prepend(c("").addClass("ui-icon").addClass("ui-icon-triangle-1-w"));(y=b["Event_"+p.EventID+"_"+(t.weekNumber-1)])&&y.prepend(c("").addClass("ui-icon").addClass("ui-icon-triangle-1-e"))}b[D.attr("id")]=D;t.events.push(p)}else if(x==-1&&C>=0)if(y=b["Event_"+p.EventID+"_"+t.weekNumber]){x=y.css("width");y.css({width:parseInt(x)+t.getLabelWidth()+1});t.vOffset+=19;t.events.push(p)}if(w==A&&C>0)(y= b["Event_"+p.EventID+"_"+t.weekNumber])&&y.prepend(c("").addClass("ui-icon").addClass("ui-icon-triangle-1-e"))}});for(var o in b){b[o].hide();n.append(b[o]);b[o].show()}}},Q=function(n,o){var p=c('
');n.CssClass&&p.addClass(n.CssClass);p.bind("click",{Event:n},s.onEventBlockClick);p.bind("mouseover",{Event:n},s.onEventBlockOver);p.bind("mouseout",{Event:n},s.onEventBlockOut);s.dragableEvents&&R(n,p,o);o=n.URL&& n.URL.length>0?c(''+n.Title+""):c(""+n.Title+"");o.bind("click",{Event:n},s.onEventLinkClick);p.append(o);return p},R=function(n,o,p){o.draggable({zIndex:4,delay:50,opacity:0.5,revertDuration:1E3,cursorAt:{left:5},start:function(){for(var z=0;z<=m;z++)if(z!=p){var B=b["Event_"+n.EventID+"_"+z];B&&B.hide()}}})},P=function(n,o){s.onShowMoreClick.call(this,k[o].events);n.stopPropagation()};c.J.ClearEventsOnCalendar=function(){I();c(".Event",c(s.containerId)).remove();c(".MoreEvents", c(s.containerId)).remove()};c.J.AddEvents=function(n){if(n){n.length>0?c.merge(v,n):v.push(n);c.J.ClearEventsOnCalendar();G()}};c.J.ReplaceEventCollection=function(n){if(n){v=[];v=n}c.J.ClearEventsOnCalendar();G()};c.J.ChangeMonth=function(n){if(!s.onMonthChanging.call(this,n)){c.J.DrawCalendar(n);s.onMonthChanged.call(this,n)}};c.J.Initialize=function(n,o){c.extend(s,n);if(o){c.J.ClearEventsOnCalendar();v=o}c.J.DrawCalendar()}})(jQuery); Date.CultureInfo={name:"en-US",englishName:"English (United States)",nativeName:"English (United States)",dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],abbreviatedDayNames:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],shortestDayNames:["Su","Mo","Tu","We","Th","Fr","Sa"],firstLetterDayNames:["S","M","T","W","T","F","S"],monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],abbreviatedMonthNames:["Jan", "Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],amDesignator:"AM",pmDesignator:"PM",firstDayOfWeek:0,twoDigitYearMax:2029,dateElementOrder:"mdy",formatPatterns:{shortDate:"M/d/yyyy",longDate:"dddd, MMMM dd, yyyy",shortTime:"h:mm tt",longTime:"h:mm:ss tt",fullDateTime:"dddd, MMMM dd, yyyy h:mm:ss tt",sortableDateTime:"yyyy-MM-ddTHH:mm:ss",universalSortableDateTime:"yyyy-MM-dd HH:mm:ssZ",rfc1123:"ddd, dd MMM yyyy HH:mm:ss GMT",monthDay:"MMMM dd",yearMonth:"MMMM, yyyy"},regexPatterns:{jan:/^jan(uary)?/i, feb:/^feb(ruary)?/i,mar:/^mar(ch)?/i,apr:/^apr(il)?/i,may:/^may/i,jun:/^jun(e)?/i,jul:/^jul(y)?/i,aug:/^aug(ust)?/i,sep:/^sep(t(ember)?)?/i,oct:/^oct(ober)?/i,nov:/^nov(ember)?/i,dec:/^dec(ember)?/i,sun:/^su(n(day)?)?/i,mon:/^mo(n(day)?)?/i,tue:/^tu(e(s(day)?)?)?/i,wed:/^we(d(nesday)?)?/i,thu:/^th(u(r(s(day)?)?)?)?/i,fri:/^fr(i(day)?)?/i,sat:/^sa(t(urday)?)?/i,future:/^next/i,past:/^last|past|prev(ious)?/i,add:/^(\+|after|from)/i,subtract:/^(\-|before|ago)/i,yesterday:/^yesterday/i,today:/^t(oday)?/i, tomorrow:/^tomorrow/i,now:/^n(ow)?/i,millisecond:/^ms|milli(second)?s?/i,second:/^sec(ond)?s?/i,minute:/^min(ute)?s?/i,hour:/^h(ou)?rs?/i,week:/^w(ee)?k/i,month:/^m(o(nth)?s?)?/i,day:/^d(ays?)?/i,year:/^y((ea)?rs?)?/i,shortMeridian:/^(a|p)/i,longMeridian:/^(a\.?m?\.?|p\.?m?\.?)/i,timezone:/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\s*(\+|\-)\s*\d\d\d\d?)|gmt)/i,ordinalSuffix:/^\s*(st|nd|rd|th)/i,timeContext:/^\s*(\:|a|p)/i},abbreviatedTimeZoneStandard:{GMT:"-000",EST:"-0400",CST:"-0500",MST:"-0600", PST:"-0700"},abbreviatedTimeZoneDST:{GMT:"-000",EDT:"-0500",CDT:"-0600",MDT:"-0700",PDT:"-0800"}};Date.getMonthNumberFromName=function(c){var f=Date.CultureInfo.monthNames,k=Date.CultureInfo.abbreviatedMonthNames;c=c.toLowerCase();for(var b=0;bc?1:this=c.getTime()&&k<=f.getTime()};a.addMilliseconds=function(c){this.setMilliseconds(this.getMilliseconds()+c);return this};a.addSeconds=function(c){return this.addMilliseconds(c*1E3)};a.addMinutes=function(c){return this.addMilliseconds(c*6E4)};a.addHours=function(c){return this.addMilliseconds(c*36E5)};a.addDays=function(c){return this.addMilliseconds(c*864E5)};a.addWeeks=function(c){return this.addMilliseconds(c*6048E5)}; a.addMonths=function(c){var f=this.getDate();this.setDate(1);this.setMonth(this.getMonth()+c);this.setDate(Math.min(f,this.getDaysInMonth()));return this};a.addYears=function(c){return this.addMonths(c*12)}; a.add=function(c){if(typeof c=="number"){this._orient=c;return this}if(c.millisecond||c.milliseconds)this.addMilliseconds(c.millisecond||c.milliseconds);if(c.second||c.seconds)this.addSeconds(c.second||c.seconds);if(c.minute||c.minutes)this.addMinutes(c.minute||c.minutes);if(c.hour||c.hours)this.addHours(c.hour||c.hours);if(c.month||c.months)this.addMonths(c.month||c.months);if(c.year||c.years)this.addYears(c.year||c.years);if(c.day||c.days)this.addDays(c.day||c.days);return this}; Date._validate=function(c,f,k,b){if(typeof c!="number")throw new TypeError(c+" is not a Number.");else if(ck)throw new RangeError(c+" is not a valid value for "+b+".");return true};Date.validateMillisecond=function(c){return Date._validate(c,0,999,"milliseconds")};Date.validateSecond=function(c){return Date._validate(c,0,59,"seconds")};Date.validateMinute=function(c){return Date._validate(c,0,59,"minutes")};Date.validateHour=function(c){return Date._validate(c,0,23,"hours")}; Date.validateDay=function(c,f,k){return Date._validate(c,1,Date.getDaysInMonth(f,k),"days")};Date.validateMonth=function(c){return Date._validate(c,0,11,"months")};Date.validateYear=function(c){return Date._validate(c,1,9999,"seconds")};a=Date.prototype; a.set=function(c){if(!c.millisecond&&c.millisecond!==0)c.millisecond=-1;if(!c.second&&c.second!==0)c.second=-1;if(!c.minute&&c.minute!==0)c.minute=-1;if(!c.hour&&c.hour!==0)c.hour=-1;if(!c.day&&c.day!==0)c.day=-1;if(!c.month&&c.month!==0)c.month=-1;if(!c.year&&c.year!==0)c.year=-1;c.millisecond!=-1&&Date.validateMillisecond(c.millisecond)&&this.addMilliseconds(c.millisecond-this.getMilliseconds());c.second!=-1&&Date.validateSecond(c.second)&&this.addSeconds(c.second-this.getSeconds());c.minute!=-1&& Date.validateMinute(c.minute)&&this.addMinutes(c.minute-this.getMinutes());c.hour!=-1&&Date.validateHour(c.hour)&&this.addHours(c.hour-this.getHours());c.month!==-1&&Date.validateMonth(c.month)&&this.addMonths(c.month-this.getMonth());c.year!=-1&&Date.validateYear(c.year)&&this.addYears(c.year-this.getFullYear());c.day!=-1&&Date.validateDay(c.day,this.getFullYear(),this.getMonth())&&this.addDays(c.day-this.getDate());c.timezone&&this.setTimezone(c.timezone);c.timezoneOffset&&this.setTimezoneOffset(c.timezoneOffset); return this};a.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0);this.setMilliseconds(0);return this};a.isLeapYear=function(){var c=this.getFullYear();return c%4===0&&c%100!==0||c%400===0};a.isWeekday=function(){return!(this.is().sat()||this.is().sun())};a.getDaysInMonth=function(){return Date.getDaysInMonth(this.getFullYear(),this.getMonth())};a.moveToFirstDayOfMonth=function(){return this.set({day:1})};a.moveToLastDayOfMonth=function(){return this.set({day:this.getDaysInMonth()})}; a.moveToDayOfWeek=function(c,f){c=(c-this.getDay()+7*(f||+1))%7;return this.addDays(c===0?(c+=7*(f||+1)):c)};a.moveToMonth=function(c,f){c=(c-this.getMonth()+12*(f||+1))%12;return this.addMonths(c===0?(c+=12*(f||+1)):c)};a.getDayOfYear=function(){return Math.floor((this-new Date(this.getFullYear(),0,1))/864E5)}; a.getWeekOfYear=function(c){var f=this.getFullYear(),k=this.getMonth(),b=this.getDate();c=c||Date.CultureInfo.firstDayOfWeek;var i=8-(new Date(f,0,1)).getDay();if(i==8)i=1;k=(Date.UTC(f,k,b,0,0,0)-Date.UTC(f,0,1,0,0,0))/864E5+1;k=Math.floor((k-i+7)/7);if(k===c){f--;f=8-(new Date(f,0,1)).getDay();k=f==2||f==8?53:52}return k};a.isDST=function(){console.log("isDST");return this.toString().match(/(E|C|M|P)(S|D)T/)[2]=="D"}; a.getTimezone=function(){return Date.getTimezoneAbbreviation(this.getUTCOffset,this.isDST())};a.setTimezoneOffset=function(c){var f=this.getTimezoneOffset();this.addMinutes(Number(c)*-6/10-f);return this};a.setTimezone=function(c){return this.setTimezoneOffset(Date.getTimezoneOffset(c))};a.getUTCOffset=function(){var c=this.getTimezoneOffset()*-10/6;if(c<0){c=(c-1E4).toString();return c[0]+c.substr(2)}else{c=(c+1E4).toString();return"+"+c.substr(1)}}; a.getDayName=function(c){return c?Date.CultureInfo.abbreviatedDayNames[this.getDay()]:Date.CultureInfo.dayNames[this.getDay()]};a.getMonthName=function(c){return c?Date.CultureInfo.abbreviatedMonthNames[this.getMonth()]:Date.CultureInfo.monthNames[this.getMonth()]};a._toString=Date.prototype.toString; a.toString=function(c){var f=this,k=function(b){return b.toString().length==1?"0"+b:b};return c?c.replace(/dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?/g,function(b){switch(b){case "hh":return k(f.getHours()<13?f.getHours():f.getHours()-12);case "h":return f.getHours()<13?f.getHours():f.getHours()-12;case "HH":return k(f.getHours());case "H":return f.getHours();case "mm":return k(f.getMinutes());case "m":return f.getMinutes();case "ss":return k(f.getSeconds());case "s":return f.getSeconds(); case "yyyy":return f.getFullYear();case "yy":return f.getFullYear().toString().substring(2,4);case "dddd":return f.getDayName();case "ddd":return f.getDayName(true);case "dd":return k(f.getDate());case "d":return f.getDate().toString();case "MMMM":return f.getMonthName();case "MMM":return f.getMonthName(true);case "MM":return k(f.getMonth()+1);case "M":return f.getMonth()+1;case "t":return f.getHours()<12?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return f.getHours()< 12?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "zzz":case "zz":case "z":return""}}):this._toString()};Date.now=function(){return new Date};Date.today=function(){return Date.now().clearTime()};a=Date.prototype;a._orient=+1;a.next=function(){this._orient=+1;return this};a.last=Date.prototype.prev=Date.prototype.previous=function(){this._orient=-1;return this};a._is=false;a.is=function(){this._is=true;return this};Number.prototype._dateElement="day"; Number.prototype.fromNow=function(){var c={};c[this._dateElement]=this;return Date.now().add(c)};Number.prototype.ago=function(){var c={};c[this._dateElement]=this*-1;return Date.now().add(c)}; (function(){for(var c=Date.prototype,f=Number.prototype,k="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),b="january february march april may june july august september october november december".split(/\s/),i="Millisecond Second Minute Hour Day Week Month Year".split(/\s/),e=function(j){return function(){if(this._is){this._is=false;return this.getDay()==j}return this.moveToDayOfWeek(j,this._orient)}},d=0;d0&&!v)try{m=d.call(this,l[1])}catch(K){v=true}else v=true;if(!v&&m[1].length===0)v=true;if(!v){l=[];for(v=0;v0){q[0]=q[0].concat(l[0]);q[1]=l[1]}}if(q[1].length 1)d=Array.prototype.slice.call(arguments);else if(arguments[0]instanceof Array)d=arguments[0];if(d)for(var g=d.shift();02?l:l+(l+2E3Date.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");g=new Date(this.year,this.month, this.day,this.hour,this.minute,this.second);if(this.timezone)g.set({timezone:this.timezone});else this.timezoneOffset&&g.set({timezoneOffset:this.timezoneOffset});return g},finish:function(g){g=g instanceof Array?c(g):[g];if(g.length===0)return null;for(var l=0;lc?1:fb?-1:+1;this.years=b.getFullYear()-k.getFullYear();i.addYears(this.years);if(e==+1)i>b&&this.years!==0&&this.years--;else i b&&k.clone().addDays(-k.getDaysInMonth())>b;){k.addMonths(-1);this.months--}k=b-k;if(k!==0){k=new TimeSpan(k);this.days=k.days;this.hours=k.hours;this.minutes=k.minutes;this.seconds=k.seconds;this.milliseconds=k.milliseconds}return this}};