!function(){$.fn.glDatePicker=function(e){var t=this.data("glDatePicker");return t?!0===e?t:this:this.each((function(){return $(this).data("glDatePicker",new glDatePicker(this,e))}))},$.fn.glDatePicker.defaults={format:"yyyy-mm-dd",cssName:"default",zIndex:1e3,borderSize:1,calendarOffset:{x:0,y:1},showAlways:!1,hideOnClick:!0,allowMonthSelect:!0,allowYearSelect:!0,todayDate:new Date,selectedDate:null,prevArrow:"◄",nextArrow:"►",selectableDates:null,selectableDateRange:null,specialDates:null,selectableMonths:null,selectableYears:null,selectableDOW:null,monthNames:null,dowNames:null,dowOffset:0,onClick:function(e,t,a,l){e.val(a.format(this.format))},onHover:function(e,t,a,l){},onShow:function(e){e.show()},onHide:function(e){e.hide()},firstDate:null};var glDatePicker=function(){function glDatePicker(e,t){var a=this;a.el=$(e);var l=a.el;a.options=$.extend(!0,{},$.fn.glDatePicker.defaults,t);var o=a.options;a.calendar=$($.find("[gldp-el="+l.attr("gldp-id")+" ]")),o.selectedDate=o.selectedDate||o.todayDate,o.firstDate=new Date(o.firstDate||o.selectedDate)._first(),(l.attr("gldp-id")||"").length||l.attr("gldp-id","gldp-"+Math.round(1e10*Math.random())),l.addClass("gldp-el").on("click",(function(e){a.show(e)})).on("focus",(function(e){a.show(e)})),a.calendar.length&&!o.showAlways&&a.calendar.hide(),$(document).on("mouseup",(function(e){var t=e.target,o=a.calendar;l.is(t)||o.is(t)||0!==o.has(t).length||!o.is(":visible")||a.hide()})),a.render()}return glDatePicker.prototype={show:function(){$.each($(".gldp-el").not(this.el),(function(e,t){t.length&&t.options.onHide(t.calendar)})),this.options.onShow(this.calendar)},hide:function(){this.options&&!this.options.showAlways&&this.options.onHide(this.calendar)},render:function(renderCalback){var self=this,el=self.el,options=self.options,calendar=self.calendar,coreClass=" core border ",cssName="gldp-"+options.cssName,todayVal=options.todayDate._val(),todayTime=todayVal.time,maxRow=6,maxCol=7,borderSize=options.borderSize+"px",getSelectableList=function(e,t,a){for(var l=[],o=e;o<=t;o++)l.push(o);if(a){var n=[];$.each(a,(function(a,l){l>=e&&l<=t&&n.indexOf(l)<0&&n.push(l)})),l=n.length?n:l}return l.sort(),l},selectableMonths=getSelectableList(0,11,options.selectableMonths),selectableYears=getSelectableList(todayVal.year-5,todayVal.year+5,options.selectableYears),selectableDOW=getSelectableList(0,6,options.selectableDOW),dowNames=options.dowNames||["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],monthNames=options.monthNames||["January","February","March","April","May","June","July","August","September","October","November","December"],containerWidth=el.outerWidth(),containerHeight=containerWidth,getCellSize=function(e,t){return e/t+options.borderSize/t*(t-1)},cellWidth=getCellSize(containerWidth,maxCol),cellHeight=getCellSize(containerHeight,maxRow+2);calendar.length?eval(calendar.data("is"))||(containerWidth=calendar.outerWidth(),containerHeight=calendar.outerHeight(),cellWidth=getCellSize(containerWidth,maxCol),cellHeight=getCellSize(containerHeight,maxRow+2)):(self.calendar=calendar=$("
").attr("gldp-el",el.attr("gldp-id")).data("is",!0).css({display:options.showAlways?void 0:"none",zIndex:options.zIndex,width:cellWidth*maxCol+"px"}),$("body").append(calendar)),el.is(":visible")||calendar.hide(),calendar.removeClass().addClass(cssName).children().remove();var onResize=function(){var e=el.offset();calendar.css({top:e.top+el.outerHeight()+options.calendarOffset.y+"px",left:e.left+options.calendarOffset.x+"px"})};$(window).on("resize",onResize),onResize();var cellCSS={width:cellWidth+"px",height:cellHeight+"px",lineHeight:cellHeight+"px"},setFirstDate=function(e){e&&(options.firstDate=e,self.render())},getFirstDate=function(e){var t=new Date(options.firstDate);for(e=e||0;t.setMonth(t.getMonth()+e),t.setDate(Math.min(1,t._max())),0!=e;){var a=t._val(),l=a.month,o=a.year;if(-1!=selectableMonths.indexOf(l)){if(-1!=selectableYears.indexOf(o))break;if(oselectableYears[selectableYears.length-1])return null}}return t},prevFirstDate=getFirstDate(-1),nextFirstDate=getFirstDate(1),firstDate=options.firstDate=getFirstDate(),firstDateVal=firstDate._val(),firstDateMonth=firstDateVal.month,firstDateYear=firstDateVal.year,startDate=new Date(firstDate),dowOffset=Math.abs(Math.min(6,Math.max(0,options.dowOffset))),startOffset=startDate.getDay()-dowOffset;startOffset=startOffset<1?-7-startOffset:-startOffset,dowNames=dowNames.concat(dowNames).slice(dowOffset,dowOffset+7),startDate._add(startOffset);var showPrev=prevFirstDate,showNext=nextFirstDate,monyearClass=coreClass+"monyear ",prevCell=$("").addClass(monyearClass).css($.extend({},cellCSS,{borderWidth:borderSize+" 0 0 "+borderSize})).append($("").addClass("prev-arrow"+(showPrev?"":"-off")).html(options.prevArrow)).on("mousedown",(function(){return!1})).on("click",(function(e){""!=options.prevArrow&&showPrev&&(e.stopPropagation(),setFirstDate(prevFirstDate))})),titleCellCount=maxCol-2,titleWidth=cellWidth*titleCellCount-titleCellCount*options.borderSize+options.borderSize,titleCell=$("").addClass(monyearClass+"title").css($.extend({},cellCSS,{width:titleWidth+"px",borderTopWidth:borderSize,marginLeft:"-"+borderSize})),nextCell=$("").addClass(monyearClass).css($.extend({},cellCSS,{marginLeft:"-"+borderSize,borderWidth:borderSize+" "+borderSize+" 0 0"})).append($("").addClass("next-arrow"+(showNext?"":"-off")).html(options.nextArrow)).on("mousedown",(function(){return!1})).on("click",(function(e){""!=options.nextArrow&&showNext&&(e.stopPropagation(),setFirstDate(nextFirstDate))}));calendar.append(prevCell).append(titleCell).append(nextCell);for(var row=0,cellIndex=0;row");if(row){cellDate._add(col+(row-1)*maxCol);var cellDateVal=cellDate._val(),cellDateTime=cellDateVal.time,specialData=null,isSelectable=!0,getRepeatDate=function(e,t){return!0===e.repeatYear&&t.setYear(cellDateVal.year),!0===e.repeatMonth&&t.setMonth(cellDateVal.month),t._val()};cell.html(cellDateVal.date),options.selectableDateRange&&(isSelectable=!1,$.each(options.selectableDateRange,(function(e,t){var a=t.from,l=t.to||null;if(l=l||new Date(t.from.getFullYear(),t.from.getMonth(),t.from._max()),a=getRepeatDate(t,a),l=getRepeatDate(t,l),cellDateTime>=a.time&&cellDateTime<=l.time)return isSelectable=!0,!0}))),options.selectableDates&&((options.selectableDateRange&&!isSelectable||isSelectable&&!options.selectableDateRange)&&(isSelectable=!1),$.each(options.selectableDates,(function(e,t){if(getRepeatDate(t,t.date).time==cellDateTime)return isSelectable=!0}))),!isSelectable||selectableYears.indexOf(cellDateVal.year)<0||selectableMonths.indexOf(cellDateVal.month)<0||selectableDOW.indexOf(cellDateVal.day)<0?cellClass="noday":(cellClass=["sun","mon","tue","wed","thu","fri","sat"][cellDateVal.day],firstDateMonth!=cellDateVal.month&&(cellClass+=" outday"),todayTime==cellDateTime&&(cellClass="today",cellZIndex+=50),options.selectedDate._time()==cellDateTime&&(cellClass="selected",cellZIndex+=51),options.specialDates&&$.each(options.specialDates,(function(e,t){getRepeatDate(t,t.date).time==cellDateTime&&(cellClass=t.cssClass||"special",cellZIndex+=52,specialData=t.data)})),cell.on("mousedown",(function(){return!1})).on("mouseenter",(function(e){e.stopPropagation();var t=$(this).data("data");options.onHover(el,cell,t.date,t.data)})).on("click",(function(e){e.stopPropagation();var t=$(this).data("data");options.selectedDate=options.firstDate=t.date,self.render((function(){!options.showAlways&&options.hideOnClick&&self.hide()})),options.onClick(el,$(this),t.date,t.data)})))}else cellClass="dow",cell.html(dowNames[col]),cellDate=null;$.extend(cellCSS,{borderTopWidth:borderSize,borderBottomWidth:borderSize,borderLeftWidth:row>0||!row&&!col?borderSize:0,borderRightWidth:row>0||!row&&6==col?borderSize:0,marginLeft:col>0?"-"+borderSize:0,marginTop:row>0?"-"+borderSize:0,zIndex:cellZIndex}),cell.data("data",{date:cellDate,data:specialData}).addClass(coreClass+cellClass).css(cellCSS),calendar.append(cell)}var toggleYearMonthSelect=function(e){var t="inline-block";options.allowMonthSelect&&(monthText.css({display:e?t:"none"}),monthSelect.css({display:e?"none":t})),options.allowYearSelect&&(yearText.css({display:e?"none":t}),yearSelect.css({display:e?t:"none"}))},onYearMonthSelect=function(){options.firstDate=new Date(yearSelect.val(),monthSelect.val(),1),self.render()},monthSelect=$("").hide().on("change",onYearMonthSelect),yearSelect=$("").hide().on("change",onYearMonthSelect),monthText=$("").html(monthNames[firstDateMonth]).on("mousedown",(function(){return!1})).on("click",(function(e){e.stopPropagation(),toggleYearMonthSelect(!1)})),yearText=$("").html(firstDateYear).on("mousedown",(function(){return!1})).on("click",(function(e){e.stopPropagation(),toggleYearMonthSelect(!0)}));$.each(monthNames,(function(e,t){if(options.allowMonthSelect&&-1!=selectableMonths.indexOf(e)){var a=$("").html(t).attr("value",e);e==firstDateMonth&&a.attr("selected","selected"),monthSelect.append(a)}})),$.each(selectableYears,(function(e,t){if(options.allowYearSelect){var a=$("").html(t).attr("value",t);t==firstDateYear&&a.attr("selected","selected"),yearSelect.append(a)}}));var titleYearMonth=$("").append(monthText).append(monthSelect).append(yearText).append(yearSelect);titleCell.children().remove(),titleCell.append(titleYearMonth),renderCalback=renderCalback||function(){},renderCalback()}},glDatePicker}(),dateFormat=(token=/d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g,timezone=/\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,timezoneClip=/[^-+\dA-Z]/g,pad=function(e,t){for(e=String(e),t=t||2;e.length99?Math.round(p/10):p),t:d<12?"a":"p",tt:d<12?"am":"pm",T:d<12?"A":"P",TT:d<12?"AM":"PM",Z:a?"UTC":(String(e).match(timezone)||[""]).pop().replace(timezoneClip,""),o:(m>0?"-":"+")+pad(100*Math.floor(Math.abs(m)/60)+Math.abs(m)%60,4),S:["th","st","nd","rd"][n%10>3?0:(n%100-n%10!=10)*n%10]};return t.replace(token,(function(e){return e in f?f[e]:e.slice(1,e.length-1)}))}),token,timezone,timezoneClip,pad;dateFormat.masks={default:"ddd mmm dd yyyy HH:MM:ss",shortDate:"m/d/yy",mediumDate:"mmm d, yyyy",longDate:"mmmm d, yyyy",fullDate:"dddd, mmmm d, yyyy",shortTime:"h:MM TT",mediumTime:"h:MM:ss TT",longTime:"h:MM:ss TT Z",isoDate:"yyyy-mm-dd",isoTime:"HH:MM:ss",isoDateTime:"yyyy-mm-dd'T'HH:MM:ss",isoUtcDateTime:"UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"},dateFormat.i18n={dayNames:["Sun","Mon","Tue","Wed","Thu","Fri","Sat","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],monthNames:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec","January","February","March","April","May","June","July","August","September","October","November","December"]},Date.prototype._clear=function(){return this.setHours(0),this.setMinutes(0),this.setSeconds(0),this.setMilliseconds(0),this},Date.prototype.format=function(e,t){return dateFormat(this,e,t)},Date.prototype._time=function(){return this._clear().getTime()},Date.prototype._max=function(){return[31,28+(1==new Date(this.getYear(),1,29).getMonth()?1:0),31,30,31,30,31,31,30,31,30,31][this.getMonth()]},Date.prototype._add=function(e){this.setDate(this.getDate()+e)},Date.prototype._first=function(){var e=new Date(this);return e.setDate(1),e},Date.prototype._val=function(){return this._clear(),{year:this.getFullYear(),month:this.getMonth(),date:this.getDate(),time:this.getTime(),day:this.getDay()}}}();