(function(c){c.widget("ui.weekCalendar",{_init:function(){var d=this;d._computeOptions();d._setupEventDelegation();d._renderCalendar();d._loadCalEvents();d._resizeCalendar();d._scrollToHour(d.options.date.getHours());c(window).unbind("resize.weekcalendar");c(window).bind("resize.weekcalendar",function(){d._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 d=new Date(this.element.data("startDate").getTime()-(b/6));this._clearCalendar();this._loadCalEvents(d)},nextWeek:function(){var d=new Date(this.element.data("startDate").getTime()+b+(b/7));this._clearCalendar();this._loadCalEvents(d)},gotoWeek:function(d){this._clearCalendar();this._loadCalEvents(d)},removeEvent:function(d){this.element.find(".cal-event").each(function(){if(c(this).data("calEvent").id===d){c(this).fadeOut(function(){c(this).remove()});return false}})},removeUnsavedEvents:function(){this.element.find(".new-cal-event").fadeOut(function(){c(this).remove()})},updateEvent:function(d){this._updateEventInCalendar(d)},getTimeslotTimes:function(g){var f=this.options;var e=f.businessHours.limitDisplay?f.businessHours.start:0;var d=new Date(g.getFullYear(),g.getMonth(),g.getDate(),e);var m=[];var k=d.getTime();for(var j=0;j').appendTo(o.element);if(q.buttons){s='
";c(s).appendTo(m);m.find(".calendar-nav .today").click(function(){o.element.weekCalendar("today");return false});m.find(".calendar-nav .prev").click(function(){o.element.weekCalendar("prevWeek");return false});m.find(".calendar-nav .next").click(function(){o.element.weekCalendar("nextWeek");return false})}p='';for(var k=1;k<=7;k++){p+=''}p+='
';l='
";for(var k=1;k<=7;k++){l+=''}l+="
';var e=q.businessHours.limitDisplay?q.businessHours.start:0;var f=q.businessHours.limitDisplay?q.businessHours.end:24;for(var k=e;k
'}l+='
'}l+='
';for(var k=e;kk)?"business-hours":"";l+='
';if(q.use24Hour){l+='
'+o._24HourForIndex(k)+"
"}else{l+='
'+o._hourForIndex(k)+''+o._amOrPm(k)+"
"}l+="
"}l+="
";c(p+l).appendTo(m);n=m.find(".day-column-inner");n.each(function(j,t){c(this).height(q.timeslotHeight*q.timeslotsPerDay);if(!q.readonly){o._addDroppableToWeekDay(c(this));o._setupEventCreationForWeekDay(c(this))}});m.find(".time-slot").height(q.timeslotHeight-1);m.find(".time-header-cell").css({height:(q.timeslotHeight*q.timeslotsPerHour)-11,padding:5})},_setupEventCreationForWeekDay:function(d){var e=this;var f=this.options;d.mousedown(function(m){var g=c(m.target);if(g.hasClass("day-column-inner")){var k=c('
');k.css({lineHeight:(f.timeslotHeight-2)+"px",fontSize:(f.timeslotHeight/2)+"px"});g.append(k);var l=g.offset().top;var n=m.pageY-l;var i=(n-(n%f.timeslotHeight))/f.timeslotHeight;var j=i*f.timeslotHeight;k.css({top:j});g.bind("mousemove.newevent",function(q){k.show();k.addClass("ui-resizable-resizing");var o=Math.round(q.pageY-l-j);var s=o%f.timeslotHeight;if(s<(o/2)){var p=o-s;k.css("height",p"+e._formatDate(g,f.dateFormat));if(e._isToday(g)){c(this).addClass("today")}else{c(this).removeClass("today")}g=e._addDays(g,1)});g=e._dateFirstDayOfWeek(e._cloneDate(e.element.data("startDate")));d.each(function(j,k){c(this).data("startDate",e._cloneDate(g));c(this).data("endDate",new Date(g.getTime()+(a-1)));if(e._isToday(g)){c(this).parent().addClass("today")}else{c(this).parent().removeClass("today")}g=e._addDays(g,1)})},_renderEvents:function(i,d){var e=this;var g=this.options;var f;if(c.isArray(i)){f=e._cleanEvents(i)}else{if(i.events){f=e._cleanEvents(i.events)}}if(i.options){var j=false;c.each(i.options,function(k,l){if(l!==g[k]){g[k]=l;j=true}});e._computeOptions();if(j){e.element.empty();e._renderCalendar();d=e.element.find(".week-calendar-time-slots .day-column-inner");e._updateDayColumnHeader(d);e._resizeCalendar()}}c.each(f,function(l,m){var k=e._findWeekDayForEvent(m,d);if(k){e._renderEvent(m,k)}});d.each(function(){e._adjustOverlappingEvents(c(this))});g.calendarAfterLoad(e.element);if(!f.length){g.noEvents()}},_renderEvent:function(l,d){var e=this;var g=this.options;if(l.start.getTime()>l.end.getTime()){return}var j,f,i,k;j=l.id?"cal-event":"cal-event new-cal-event";f='
';i=c(f);k=g.eventRender(l,i);i=k?k.appendTo(d):i.appendTo(d);i.css({lineHeight:(g.timeslotHeight-2)+"px",fontSize:(g.timeslotHeight/2)+"px"});e._refreshEventDetails(l,i);e._positionEvent(d,i);i.show();if(!g.readonly&&g.resizable(l,i)){e._addResizableToCalEvent(l,i,d)}if(!g.readonly&&g.draggable(l,i)){e._addDraggableToCalEvent(l,i)}g.eventAfterRender(l,i);return i},_adjustOverlappingEvents:function(e){var f=this;if(f.options.allowCalEventOverlap){var d=f._groupOverlappingEventElements(e);c.each(d,function(){var j=this.length;var k=this;if(f.options.overlapEventsSeparate){var g=100/j;var i=g}else{var g=(100-(j*10));var i=(100-g)/(j-1)}c.each(this,function(l){var m=(l*i);if(!f.options.overlapEventsSeparate){c(this).bind("mouseover.z-index",function(){var n=c(this);c.each(k,function(){c(this).css({"z-index":"1"})});n.css({"z-index":"3"})})}c(this).css({width:g+"%",left:m+"%",right:0})})})}},_groupOverlappingEventElements:function(e){var m=this;var j=e.find(".cal-event");var d=j.sort(function(q,p){return c(q).data("calEvent").start.getTime()-c(p).data("calEvent").start.getTime()});var k;var f=[];var l=[];var o;var g=0;var n=0;var i=0;c.each(d,function(){o=c(this);g=o.data("calEvent").start.getTime();n=o.data("calEvent").end.getTime();o.css({width:"100%",left:"0%",right:"","z-index":"1"});o.unbind("mouseover.z-index");if(o.data("calEvent").start.getTime()c(this).data("calEvent").start.getTime()+1||nn){n=c(this).data("calEvent").end.getTime()}if(c.inArray(c(this),l)==-1){l.push(c(this))}if(c.inArray(o,l)==-1){l.push(o)}});if(l.length){l.sort(function(q,p){if(c(q).data("calEvent").start.getTime()>c(p).data("calEvent").start.getTime()){return 1}else{if(c(q).data("calEvent").start.getTime()=f.end.getTime()){d=c(this);return false}});return d},_updateEventInCalendar:function(g){var e=this;var f=this.options;e._cleanEvent(g);if(g.id){e.element.find(".cal-event").each(function(){if(c(this).data("calEvent").id===g.id||c(this).hasClass("new-cal-event")){c(this).remove();return false}})}var d=e._findWeekDayForEvent(g,e.element.find(".week-calendar-time-slots .day-column-inner"));if(d){e._renderEvent(g,d);e._adjustOverlappingEvents(d)}},_positionEvent:function(f,j){var n=this.options;var m=j.data("calEvent");var k=f.height()/n.millisToDisplay;var g=n.businessHours.limitDisplay?n.businessHours.start:0;var i=m.start.getTime()-new Date(m.start.getFullYear(),m.start.getMonth(),m.start.getDate(),g).getTime();var e=m.end.getTime()-m.start.getTime();var l=k*i;var d=k*e;j.css({top:l,height:d})},_getEventDurationFromPositionedEventElement:function(e,j,i){var g=this.options;var d=g.businessHours.limitDisplay?g.businessHours.start*60*60*1000:0;var k=new Date(e.data("startDate").getTime()+d+Math.round(i/g.timeslotHeight)*g.millisPerTimeslot);var f=new Date(k.getTime()+(j.height()/g.timeslotHeight)*g.millisPerTimeslot);return{start:k,end:f}},_adjustForEventCollisions:function(e,i,j,g,f){var m=this.options;if(m.allowCalEventOverlap){return}var l,d;var k=this;e.find(".cal-event").not(i).each(function(){var n=c(this).data("calEvent");if(j.start.getTime()=n.end.getTime()){l=n.end}if(j.end.getTime()>n.start.getTime()&&j.start.getTime()<=n.start.getTime()){d=n.start}if(j.end.getTime()<=n.end.getTime()&&j.start.getTime()>=n.start.getTime()){l=g.start;d=g.end;return false}});j.start=l||j.start;if(l&&f){j.end=new Date(l.getTime()+(g.end.getTime()-g.start.getTime()));k._adjustForEventCollisions(e,i,j,g)}else{j.end=d||j.end}if(j.start.getTime()>=j.end.getTime()){j.start=g.start;j.end=g.end}i.data("calEvent",j)},_addDraggableToCalEvent:function(i,g){var e=this;var f=this.options;var d=e._findWeekDayForEvent(i,e.element.find(".week-calendar-time-slots .day-column-inner"));g.draggable({handle:".time",containment:".calendar-scrollable-grid",revert:"valid",opacity:0.5,grid:[g.outerWidth()+1,f.timeslotHeight],start:function(j,k){var l=k.draggable;f.eventDrag(i,l)}})},_addDroppableToWeekDay:function(d){var e=this;var f=this.options;d.droppable({accept:".cal-event",drop:function(i,n){var k=n.draggable;var m=Math.round(parseInt(n.position.top));var j=e._getEventDurationFromPositionedEventElement(d,k,m);var l=k.data("calEvent");var o=c.extend(true,{start:j.start,end:j.end},l);e._adjustForEventCollisions(d,k,o,l,true);var p=e.element.find(".day-column-inner");var g=e._renderEvent(o,e._findWeekDayForEvent(o,p));k.hide();f.eventDrop(o,l,g);k.data("preventClick",true);setTimeout(function(){var q=e._findWeekDayForEvent(k.data("calEvent"),e.element.find(".week-calendar-time-slots .day-column-inner"));k.remove();if(q.data("startDate")!=d.data("startDate")){e._adjustOverlappingEvents(q)}e._adjustOverlappingEvents(d)},500)}})},_addResizableToCalEvent:function(i,g,d){var e=this;var f=this.options;g.resizable({grid:f.timeslotHeight,containment:d,handles:"s",minHeight:f.timeslotHeight,stop:function(l,m){var n=m.element;var k=new Date(n.data("calEvent").start.getTime()+(n.height()/f.timeslotHeight)*f.millisPerTimeslot);var j=c.extend(true,{start:i.start,end:k},i);e._adjustForEventCollisions(d,n,j,i);e._refreshEventDetails(j,n);e._positionEvent(d,n);f.eventResize(j,i,n);n.data("preventClick",true);setTimeout(function(){n.removeData("preventClick")},500)}})},_refreshEventDetails:function(g,f){var d=this;var e=this.options;f.find(".time").text(d._formatDate(g.start,e.timeFormat)+e.timeSeparator+d._formatDate(g.end,e.timeFormat));f.find(".title").text(g.title);f.data("calEvent",g)},_clearCalendar:function(){this.element.find(".day-column-inner div").remove()},_scrollToHour:function(e){var f=this;var g=this.options;var i=this.element.find(".calendar-scrollable-grid");var j=e;if(f.options.businessHours.limitDisplay){if(ef.options.businessHours.end){j=f.options.businessHours.end-f.options.businessHours.start-1}}}var d=this.element.find(".grid-timeslot-header .hour-header:eq("+j+")");i.animate({scrollTop:0},0,function(){var l=d.offset().top;var k=l-i.offset().top-d.outerHeight();i.animate({scrollTop:k},g.scrollToHourMillis)})},_hourForIndex:function(d){if(d===0){return 12}else{if(d<13){return d}else{return d-12}}},_24HourForIndex:function(d){if(d===0){return"00:00"}else{if(d<10){return"0"+d+":00"}else{return d+":00"}}},_amOrPm:function(d){return d<12?"AM":"PM"},_isToday:function(e){var f=this._cloneDate(e);this._clearTime(f);var d=new Date();this._clearTime(d);return d.getTime()===f.getTime()},_cleanEvents:function(e){var d=this;c.each(e,function(f,g){d._cleanEvent(g)});return e},_cleanEvent:function(d){if(d.date){d.start=d.date}d.start=this._cleanDate(d.start);d.end=this._cleanDate(d.end);if(!d.end){d.end=this._addDays(this._cloneDate(d.start),1)}},_disableTextSelect:function(d){d.each(function(){if(c.browser.mozilla){c(this).css("MozUserSelect","none")}else{if(c.browser.msie){c(this).bind("selectstart",function(){return false})}else{c(this).mousedown(function(){return false})}}})},_dateFirstDayOfWeek:function(e){var d=this;var f=new Date(e.getFullYear(),e.getMonth(),e.getDate());var g=d._getAdjustedDayIndex(f)*86400000;return new Date(f.getTime()-g)},_dateLastDayOfWeek:function(e){var d=this;var f=new Date(e.getFullYear(),e.getMonth(),e.getDate());var g=(6-d._getAdjustedDayIndex(f))*a;return new Date(f.getTime()+g)},_getAdjustedDayIndex:function(e){var f=new Date(e.getFullYear(),e.getMonth(),e.getDate());var d=f.getDay();var g=[0,1,2,3,4,5,6];this._rotate(g,this.options.firstDayOfWeek);return g[d]},_dateLastMilliOfWeek:function(d){var e=this._dateLastDayOfWeek(d);return new Date(e.getTime()+(a-1))},_clearTime:function(e){e.setHours(0);e.setMinutes(0);e.setSeconds(0);e.setMilliseconds(0);return e},_addDays:function(f,g,e){f.setDate(f.getDate()+g);if(e){return f}return this._clearTime(f)},_rotate:function(f,j){for(var e=f.length,j=(Math.abs(j)>=e&&(j%=e),j<0&&(j+=e),j),g,d;j;j=(Math.ceil(e/j)-1)*j-e+(e=j)){for(g=e;g>j;d=f[--g],f[g]=f[g-j],f[g-j]=d){}}return f},_cloneDate:function(e){return new Date(+e)},_cleanDate:function(e){if(typeof e=="string"){return c.weekCalendar.parseISO8601(e,true)||Date.parse(e)||new Date(parseInt(e))}if(typeof e=="number"){return new Date(e)}return e},_formatDate:function(f,k){var e=this.options;var j="";for(var g=0;g0){var multi=[];var single=[];$.each(cEvents,function(){var ev=this;if(ev.StartDateTime){if(typeof ev.StartDateTime=="object"&&ev.StartDateTime.getDate){this.StartDateTime=ev.StartDateTime}if(typeof ev.StartDateTime=="string"&&ev.StartDateTime.split){this.StartDateTime=_getJSONDate(ev.StartDateTime)}}else{if(ev.Date){if(typeof ev.Date=="object"&&ev.Date.getDate){this.StartDateTime=ev.Date}if(typeof ev.Date=="string"&&ev.Date.split){this.StartDateTime=_getJSONDate(ev.Date)}}else{return}}if(ev.EndDateTime){if(typeof ev.EndDateTime=="object"&&ev.EndDateTime.getDate){this.EndDateTime=ev.EndDateTime}if(typeof ev.EndDateTime=="string"&&ev.EndDateTime.split){this.EndDateTime=_getJSONDate(ev.EndDateTime)}}else{this.EndDateTime=this.StartDateTime.clone()}if(this.StartDateTime.clone().clearTime().compareTo(this.EndDateTime.clone().clearTime())==0){single.push(this)}else{if(this.StartDateTime.clone().clearTime().compareTo(this.EndDateTime.clone().clearTime())==-1){multi.push(this)}}});multi.sort(_eventSort);single.sort(_eventSort);cEvents=[];$.merge(cEvents,multi);$.merge(cEvents,single)}};var _eventSort=function(a,b){return a.StartDateTime.compareTo(b.StartDateTime)};var _clearBoxes=function(){_clearBoxEvents();_boxes=[]};var _clearBoxEvents=function(){for(var i=0;i<_boxes.length;i++){_boxes[i].clear()}_eventObj={}};var _initDates=function(dateIn){var today=def.calendarStartDate;if(dateIn==undefined){_workingDate=new Date(today.getFullYear(),today.getMonth(),1)}else{_workingDate=dateIn;_workingDate.setDate(1)}_daysInMonth=_workingDate.getDaysInMonth();_firstOfMonth=_workingDate.clone().moveToFirstDayOfMonth();_lastOfMonth=_workingDate.clone().moveToLastDayOfMonth();_gridOffset=_firstOfMonth.getDay()-def.firstDayOfWeek;_totalDates=_gridOffset+_daysInMonth;_gridRows=Math.ceil(_totalDates/7);_totalBoxes=_gridRows*7;_dateRange.startDate=_firstOfMonth.clone().addDays((-1)*_gridOffset);_dateRange.endDate=_lastOfMonth.clone().addDays(_totalBoxes-(_daysInMonth+_gridOffset))};var _initHeaders=function(){var prevMonth=_workingDate.clone().addMonths(-1);var prevMLink=$('").click(function(){$.J.ChangeMonth(prevMonth);return false});var nextMonth=_workingDate.clone().addMonths(1);var nextMLink=$('").click(function(){$.J.ChangeMonth(nextMonth);return false});var prevYear=_workingDate.clone().addYears(-1);var prevYLink;if(def.navLinks.enablePrevYear){prevYLink=$('").click(function(){$.J.ChangeMonth(prevYear);return false})}var nextYear=_workingDate.clone().addYears(1);var nextYLink;if(def.navLinks.enableNextYear){nextYLink=$('").click(function(){$.J.ChangeMonth(nextYear);return false})}var todayLink;if(def.navLinks.enableToday){todayLink=$('").click(function(){$.J.ChangeMonth(new Date());return false})}var navRow=$('
');var navHead=$(".MonthNavigation",navRow);navHead.append(prevMLink,nextMLink);if(def.navLinks.enableToday){navHead.append(todayLink)}navHead.append($('
').append(Date.CultureInfo.monthNames[_workingDate.getMonth()]+" "+_workingDate.getFullYear()));if(def.navLinks.enablePrevYear){navHead.append(prevYLink)}if(def.navLinks.enableNextYear){navHead.append(nextYLink)}var headRow=$("");for(var i=def.firstDayOfWeek;i'+wordday+"")}headRow=$('').css({height:def.headerHeight+"px"}).append(headRow);headRow=headRow.prepend(navRow);return headRow};$.J.DrawCalendar=function(dateIn){var now=new Date();now.clearTime();var today=def.calendarStartDate;_clearBoxes();_initDates(dateIn);var headerRow=_initHeaders();var isCurrentMonth=(_workingDate.getMonth()==today.getMonth()&&_workingDate.getFullYear()==today.getFullYear());var containerHeight=$(def.containerId).outerHeight();var rowHeight=(containerHeight-def.headerHeight)/_gridRows;var row=null;var tBody=$('');for(var i=0;i<_totalBoxes;i++){var currentDate=_dateRange.startDate.clone().addDays(i);if(i%7==0||i==0){row=$("");row.css({height:rowHeight+"px"});tBody.append(row)}var weekday=(def.firstDayOfWeek+i)%7;var atts={"class":"DateBox"+(weekday==0||weekday==6?" Weekend ":""),date:currentDate.toString("M/d/yyyy")};if(currentDate.compareTo(_firstOfMonth)==-1||currentDate.compareTo(_lastOfMonth)==1){atts["class"]+=" Inactive"}if(currentDate.compareTo(now)==0){atts["class"]+=" Today"}var dateLink=$('");dateLink.bind("click",{Date:currentDate.clone()},def.onDayLinkClick);var dateBox=$("").attr(atts).append(dateLink);dateBox.bind("dblclick",{Date:currentDate.clone()},def.onDayCellDblClick);dateBox.bind("click",{Date:currentDate.clone()},def.onDayCellClick);if(def.dragableEvents){dateBox.droppable({hoverClass:def.dragHoverClass,tolerance:"pointer",drop:function(ev,ui){var eventId=ui.draggable.attr("eventid");var newDate=new Date($(this).attr("date")).clearTime();var event;$.each(cEvents,function(){if(this.EventID==eventId){var days=new TimeSpan(newDate-this.StartDateTime).days;this.StartDateTime.addDays(days);this.EndDateTime.addDays(days);event=this}});$.J.ClearEventsOnCalendar();_drawEventsOnCalendar();def.onEventDropped.call(this,event,newDate)}})}_boxes.push(new CalendarBox(i,currentDate,dateBox,dateLink));row.append(dateBox)}tBody.append(row);var a=$(def.containerId);var cal=$('
').append(headerRow,tBody);a.hide();a.html(cal);a.fadeIn("normal");_drawEventsOnCalendar()};var _drawEventsOnCalendar=function(){_filterEventCollection();_clearBoxEvents();if(cEvents&&cEvents.length>0){var container=$(def.containerId);$.each(cEvents,function(){var ev=this;var tempStartDT=ev.StartDateTime.clone().clearTime();var tempEndDT=ev.EndDateTime.clone().clearTime();var startI=new TimeSpan(tempStartDT-_dateRange.startDate).days;var endI=new TimeSpan(tempEndDT-_dateRange.startDate).days;var istart=(startI<0)?0:startI;var iend=(endI>_boxes.length-1)?_boxes.length-1:endI;for(var i=istart;i<=iend;i++){var b=_boxes[i];var startBoxCompare=tempStartDT.compareTo(b.date);var endBoxCompare=tempEndDT.compareTo(b.date);var continueEvent=((i!=0&&startBoxCompare==-1&&endBoxCompare>=0&&b.weekNumber!=_boxes[i-1].weekNumber)||(i==0&&startBoxCompare==-1));var toManyEvents=(startBoxCompare==0||(i==0&&startBoxCompare==-1)||continueEvent||(startBoxCompare==-1&&endBoxCompare>=0))&&b.vOffset>=(b.getCellBox().height()-b.getLabelHeight()-32);if(toManyEvents){if(!b.isTooManySet){var moreDiv=$('
'+def.navLinks.showMore+"
");var pos=b.getCellPosition();var index=i;moreDiv.css({top:(pos.top+(b.getCellBox().height()-b.getLabelHeight())),left:pos.left,width:(b.getLabelWidth()-7),position:"absolute"});moreDiv.click(function(e){_showMoreClick(e,index)});_eventObj[moreDiv.attr("id")]=moreDiv;b.isTooManySet=true}b.events.push(ev)}else{if(startBoxCompare==0||(i==0&&startBoxCompare==-1)||continueEvent){var block=_buildEventBlock(ev,b.weekNumber);var pos=b.getCellPosition();block.css({top:(pos.top+b.getLabelHeight()+b.vOffset),left:pos.left,width:(b.getLabelWidth()-7),position:"absolute"});b.vOffset+=19;if(continueEvent){block.prepend($("").addClass("ui-icon").addClass("ui-icon-triangle-1-w"));var e=_eventObj["Event_"+ev.EventID+"_"+(b.weekNumber-1)];if(e){e.prepend($("").addClass("ui-icon").addClass("ui-icon-triangle-1-e"))}}_eventObj[block.attr("id")]=block;b.events.push(ev)}else{if(startBoxCompare==-1&&endBoxCompare>=0){var e=_eventObj["Event_"+ev.EventID+"_"+b.weekNumber];if(e){var w=e.css("width");e.css({width:(parseInt(w)+b.getLabelWidth()+1)});b.vOffset+=19;b.events.push(ev)}}}}if(i==iend&&endBoxCompare>0){var e=_eventObj["Event_"+ev.EventID+"_"+b.weekNumber];if(e){e.prepend($("").addClass("ui-icon").addClass("ui-icon-triangle-1-e"))}}}});for(var o in _eventObj){_eventObj[o].hide();container.append(_eventObj[o]);_eventObj[o].show()}}};var _buildEventBlock=function(ev,weekNumber){var block=$('
');if(ev.CssClass){block.addClass(ev.CssClass)}block.bind("click",{Event:ev},def.onEventBlockClick);block.bind("mouseover",{Event:ev},def.onEventBlockOver);block.bind("mouseout",{Event:ev},def.onEventBlockOut);if(def.dragableEvents){_dragableEvent(ev,block,weekNumber)}var link;if(ev.URL&&ev.URL.length>0){link=$(''+ev.Title+"")}else{link=$(""+ev.Title+"")}link.bind("click",{Event:ev},def.onEventLinkClick);block.append(link);return block};var _dragableEvent=function(event,block,weekNumber){block.draggable({zIndex:4,delay:50,opacity:0.5,revertDuration:1000,cursorAt:{left:5},start:function(ev,ui){for(var i=0;i<=_gridRows;i++){if(i==weekNumber){continue}var e=_eventObj["Event_"+event.EventID+"_"+i];if(e){e.hide()}}}})};var _showMoreClick=function(e,boxIndex){var box=_boxes[boxIndex];def.onShowMoreClick.call(this,box.events);e.stopPropagation()};$.J.ClearEventsOnCalendar=function(){_clearBoxEvents();$(".Event",$(def.containerId)).remove();$(".MoreEvents",$(def.containerId)).remove()};$.J.AddEvents=function(eventCollection){if(eventCollection){if(eventCollection.length>0){$.merge(cEvents,eventCollection)}else{cEvents.push(eventCollection)}$.J.ClearEventsOnCalendar();_drawEventsOnCalendar()}};$.J.ReplaceEventCollection=function(eventCollection){if(eventCollection){cEvents=[];cEvents=eventCollection}$.J.ClearEventsOnCalendar();_drawEventsOnCalendar()};$.J.ChangeMonth=function(dateIn){var returned=def.onMonthChanging.call(this,dateIn);if(!returned){$.J.DrawCalendar(dateIn);def.onMonthChanged.call(this,dateIn)}};$.J.Initialize=function(options,events){var today=new Date();options=$.extend(def,options);if(events){$.J.ClearEventsOnCalendar();cEvents=events}$.J.DrawCalendar()};function CalendarBox(id,boxDate,cell,label){this.id=id;this.date=boxDate;this.cell=cell;this.label=label;this.weekNumber=Math.floor(id/7);this.events=[];this.isTooManySet=false;this.vOffset=0;this.echo=function(){alert("Date: "+this.date+" WeekNumber: "+this.weekNumber+" ID: "+this.id)};this.clear=function(){this.events=[];this.isTooManySet=false;this.vOffset=0};this.getCellPosition=function(){if(this.cell){return this.cell.position()}return};this.getCellBox=function(){if(this.cell){return this.cell}return};this.getLabelWidth=function(){if(this.label){return this.label.innerWidth()}return};this.getLabelHeight=function(){if(this.label){return this.label.height()}return};this.getDate=function(){return this.date}}})(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(b){var e=Date.CultureInfo.monthNames,a=Date.CultureInfo.abbreviatedMonthNames,d=b.toLowerCase();for(var c=0;ca)?1:(this=c.getTime()&&b<=a.getTime()};Date.prototype.addMilliseconds=function(a){this.setMilliseconds(this.getMilliseconds()+a);return this};Date.prototype.addSeconds=function(a){return this.addMilliseconds(a*1000)};Date.prototype.addMinutes=function(a){return this.addMilliseconds(a*60000)};Date.prototype.addHours=function(a){return this.addMilliseconds(a*3600000)};Date.prototype.addDays=function(a){return this.addMilliseconds(a*86400000)};Date.prototype.addWeeks=function(a){return this.addMilliseconds(a*604800000)};Date.prototype.addMonths=function(a){var b=this.getDate();this.setDate(1);this.setMonth(this.getMonth()+a);this.setDate(Math.min(b,this.getDaysInMonth()));return this};Date.prototype.addYears=function(a){return this.addMonths(a*12)};Date.prototype.add=function(b){if(typeof b=="number"){this._orient=b;return this}var a=b;if(a.millisecond||a.milliseconds){this.addMilliseconds(a.millisecond||a.milliseconds)}if(a.second||a.seconds){this.addSeconds(a.second||a.seconds)}if(a.minute||a.minutes){this.addMinutes(a.minute||a.minutes)}if(a.hour||a.hours){this.addHours(a.hour||a.hours)}if(a.month||a.months){this.addMonths(a.month||a.months)}if(a.year||a.years){this.addYears(a.year||a.years)}if(a.day||a.days){this.addDays(a.day||a.days)}return this};Date._validate=function(d,c,a,b){if(typeof d!="number"){throw new TypeError(d+" is not a Number.")}else{if(da){throw new RangeError(d+" is not a valid value for "+b+".")}}return true};Date.validateMillisecond=function(a){return Date._validate(a,0,999,"milliseconds")};Date.validateSecond=function(a){return Date._validate(a,0,59,"seconds")};Date.validateMinute=function(a){return Date._validate(a,0,59,"minutes")};Date.validateHour=function(a){return Date._validate(a,0,23,"hours")};Date.validateDay=function(c,a,b){return Date._validate(c,1,Date.getDaysInMonth(a,b),"days")};Date.validateMonth=function(a){return Date._validate(a,0,11,"months")};Date.validateYear=function(a){return Date._validate(a,1,9999,"seconds")};Date.prototype.set=function(b){var a=b;if(!a.millisecond&&a.millisecond!==0){a.millisecond=-1}if(!a.second&&a.second!==0){a.second=-1}if(!a.minute&&a.minute!==0){a.minute=-1}if(!a.hour&&a.hour!==0){a.hour=-1}if(!a.day&&a.day!==0){a.day=-1}if(!a.month&&a.month!==0){a.month=-1}if(!a.year&&a.year!==0){a.year=-1}if(a.millisecond!=-1&&Date.validateMillisecond(a.millisecond)){this.addMilliseconds(a.millisecond-this.getMilliseconds())}if(a.second!=-1&&Date.validateSecond(a.second)){this.addSeconds(a.second-this.getSeconds())}if(a.minute!=-1&&Date.validateMinute(a.minute)){this.addMinutes(a.minute-this.getMinutes())}if(a.hour!=-1&&Date.validateHour(a.hour)){this.addHours(a.hour-this.getHours())}if(a.month!==-1&&Date.validateMonth(a.month)){this.addMonths(a.month-this.getMonth())}if(a.year!=-1&&Date.validateYear(a.year)){this.addYears(a.year-this.getFullYear())}if(a.day!=-1&&Date.validateDay(a.day,this.getFullYear(),this.getMonth())){this.addDays(a.day-this.getDate())}if(a.timezone){this.setTimezone(a.timezone)}if(a.timezoneOffset){this.setTimezoneOffset(a.timezoneOffset)}return this};Date.prototype.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0);this.setMilliseconds(0);return this};Date.prototype.isLeapYear=function(){var a=this.getFullYear();return(((a%4===0)&&(a%100!==0))||(a%400===0))};Date.prototype.isWeekday=function(){return !(this.is().sat()||this.is().sun())};Date.prototype.getDaysInMonth=function(){return Date.getDaysInMonth(this.getFullYear(),this.getMonth())};Date.prototype.moveToFirstDayOfMonth=function(){return this.set({day:1})};Date.prototype.moveToLastDayOfMonth=function(){return this.set({day:this.getDaysInMonth()})};Date.prototype.moveToDayOfWeek=function(a,b){var c=(a-this.getDay()+7*(b||+1))%7;return this.addDays((c===0)?c+=7*(b||+1):c)};Date.prototype.moveToMonth=function(c,a){var b=(c-this.getMonth()+12*(a||+1))%12;return this.addMonths((b===0)?b+=12*(a||+1):b)};Date.prototype.getDayOfYear=function(){return Math.floor((this-new Date(this.getFullYear(),0,1))/86400000)};Date.prototype.getWeekOfYear=function(a){var i=this.getFullYear(),c=this.getMonth(),f=this.getDate();var k=a||Date.CultureInfo.firstDayOfWeek;var e=7+1-new Date(i,0,1).getDay();if(e==8){e=1}var b=((Date.UTC(i,c,f,0,0,0)-Date.UTC(i,0,1,0,0,0))/86400000)+1;var j=Math.floor((b-e+7)/7);if(j===k){i--;var g=7+1-new Date(i,0,1).getDay();if(g==2||g==8){j=53}else{j=52}}return j};Date.prototype.isDST=function(){console.log("isDST");return this.toString().match(/(E|C|M|P)(S|D)T/)[2]=="D"};Date.prototype.getTimezone=function(){return Date.getTimezoneAbbreviation(this.getUTCOffset,this.isDST())};Date.prototype.setTimezoneOffset=function(b){var a=this.getTimezoneOffset(),c=Number(b)*-6/10;this.addMinutes(c-a);return this};Date.prototype.setTimezone=function(a){return this.setTimezoneOffset(Date.getTimezoneOffset(a))};Date.prototype.getUTCOffset=function(){var b=this.getTimezoneOffset()*-10/6,a;if(b<0){a=(b-10000).toString();return a[0]+a.substr(2)}else{a=(b+10000).toString();return"+"+a.substr(1)}};Date.prototype.getDayName=function(a){return a?Date.CultureInfo.abbreviatedDayNames[this.getDay()]:Date.CultureInfo.dayNames[this.getDay()]};Date.prototype.getMonthName=function(a){return a?Date.CultureInfo.abbreviatedMonthNames[this.getMonth()]:Date.CultureInfo.monthNames[this.getMonth()]};Date.prototype._toString=Date.prototype.toString;Date.prototype.toString=function(c){var a=this;var b=function b(d){return(d.toString().length==1)?"0"+d:d};return c?c.replace(/dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?/g,function(d){switch(d){case"hh":return b(a.getHours()<13?a.getHours():(a.getHours()-12));case"h":return a.getHours()<13?a.getHours():(a.getHours()-12);case"HH":return b(a.getHours());case"H":return a.getHours();case"mm":return b(a.getMinutes());case"m":return a.getMinutes();case"ss":return b(a.getSeconds());case"s":return a.getSeconds();case"yyyy":return a.getFullYear();case"yy":return a.getFullYear().toString().substring(2,4);case"dddd":return a.getDayName();case"ddd":return a.getDayName(true);case"dd":return b(a.getDate());case"d":return a.getDate().toString();case"MMMM":return a.getMonthName();case"MMM":return a.getMonthName(true);case"MM":return b((a.getMonth()+1));case"M":return a.getMonth()+1;case"t":return a.getHours()<12?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case"tt":return a.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()};Date.prototype._orient=+1;Date.prototype.next=function(){this._orient=+1;return this};Date.prototype.last=Date.prototype.prev=Date.prototype.previous=function(){this._orient=-1;return this};Date.prototype._is=false;Date.prototype.is=function(){this._is=true;return this};Number.prototype._dateElement="day";Number.prototype.fromNow=function(){var a={};a[this._dateElement]=this;return Date.now().add(a)};Number.prototype.ago=function(){var a={};a[this._dateElement]=this*-1;return Date.now().add(a)};(function(){var g=Date.prototype,a=Number.prototype;var q=("sunday monday tuesday wednesday thursday friday saturday").split(/\s/),p=("january february march april may june july august september october november december").split(/\s/),o=("Millisecond Second Minute Hour Day Week Month Year").split(/\s/),n;var m=function(i){return function(){if(this._is){this._is=false;return this.getDay()==i}return this.moveToDayOfWeek(i,this._orient)}};for(var f=0;f0&&!B){try{n=j.call(this,m[1])}catch(A){B=true}}else{B=true}if(!B&&n[1].length===0){B=true}if(!B){var x=[];for(var v=0;v0){t[0]=t[0].concat(o[0]);t[1]=o[1]}}if(t[1].length1){j=Array.prototype.slice.call(arguments)}else{if(arguments[0] instanceof Array){j=arguments[0]}}if(j){for(var m=0,l=j.shift();m2)?k:(k+(((k+2000)Date.getDaysInMonth(this.year,this.month)){throw new RangeError(this.day+" is not a valid value for days.")}var m=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second);if(this.timezone){m.set({timezone:this.timezone})}else{if(this.timezoneOffset){m.set({timezoneOffset:this.timezoneOffset})}}return m},finish:function(g){g=(g instanceof Array)?f(g):[g];if(g.length===0){return null}for(var n=0;na)?1:(b0){return this.days()+"."+this.hours()+":"+b(this.minutes())+":"+b(this.seconds())}else{return this.hours()+":"+b(this.minutes())+":"+b(this.seconds())}}function b(e){return(e.toString().length<2)?"0"+e:e}var a=this;return c?c.replace(/d|dd|HH|H|hh|h|mm|m|ss|s|tt|t/g,function(e){switch(e){case"d":return a.days();case"dd":return b(a.days());case"H":return a.hours();case"HH":return b(a.hours());case"h":return a.get12HourHour();case"hh":return b(a.get12HourHour());case"m":return a.minutes();case"mm":return b(a.minutes());case"s":return a.seconds();case"ss":return b(a.seconds());case"t":return((this.hours()<12)?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case"tt":return(this.hours()<12)?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator}}):this._toString()};var TimePeriod=function(e,a,m,g,c,j,b){this.years=0;this.months=0;this.days=0;this.hours=0;this.minutes=0;this.seconds=0;this.milliseconds=0;if(arguments.length==2&&arguments[0] instanceof Date&&arguments[1] instanceof Date){var n=e.clone();var l=a.clone();var k=n.clone();var d=(n>l)?-1:+1;this.years=l.getFullYear()-n.getFullYear();k.addYears(this.years);if(d==+1){if(k>l){if(this.years!==0){this.years--}}}else{if(kl&&n.clone().addDays(-n.getDaysInMonth())>l){n.addMonths(-1);this.months--}}var i=l-n;if(i!==0){var f=new TimeSpan(i);this.days=f.days;this.hours=f.hours;this.minutes=f.minutes;this.seconds=f.seconds;this.milliseconds=f.milliseconds}return this}};