jQuery.fn.daterangepicker=function(a){function n(){if(i.data("state")=="open"){m()}else{l()}}function m(){if(i.data("state")=="open"){i.data("state","closed");i.fadeOut(300);c.onClose()}}function l(){if(i.data("state")=="closed"){i.data("state","open");i.fadeIn(300);c.onOpen()}}function k(a){if(!a.getDate()){return""}var b=a.getDate();var d=a.getMonth();var e=a.getFullYear();d++;var f=c.dateFormat;return jQuery.datepicker.formatDate(f,a)}var b=jQuery(this);var c=jQuery.extend({presetRanges:[{text:"Today",dateStart:"today",dateEnd:"today"},{text:"Tomorrow",dateStart:"Tomorrow",dateEnd:"Tomorrow"},{text:"This Weekend",dateStart:"Friday",dateEnd:"NextSunday"},{text:"Next Week",dateStart:"today+7days",dateEnd:"today+14days"}],presets:{specificDate:"Specific Date",dateRange:"Date Range"},rangeStartTitle:"Start date",rangeEndTitle:"End date",nextLinkText:"Next",prevLinkText:"Prev",doneButtonText:"Done",earliestDate:Date.parse("-1days"),latestDate:Date.parse("+5years"),rangeSplitter:"-",dateFormat:"d/m/yy",closeOnSelect:true,arrows:false,posX:b.offset().left,posY:b.offset().top+b.outerHeight(),appendTo:"body",onClose:function(){},onOpen:function(){},onChange:function(){},datepickerOptions:null},a);var d={onSelect:function(){if(i.find(".ui-daterangepicker-specificDate").is(".ui-state-active")){i.find(".range-end").datepicker("setDate",i.find(".range-start").datepicker("getDate"))}var a=k(i.find(".range-start").datepicker("getDate"));var d=k(i.find(".range-end").datepicker("getDate"));if(b.length==2){b.eq(0).val(a);b.eq(1).val(d)}else{b.val(a!=d?a+" "+c.rangeSplitter+" "+d:a)}if(c.closeOnSelect){if(!i.find("li.ui-state-active").is(".ui-daterangepicker-dateRange")&&!i.is(":animated")){m()}}c.onChange()},defaultDate:+0};b.change(c.onChange);c.datepickerOptions=a?jQuery.extend(d,a.datepickerOptions):d;var e,f=Date.parse("today");var g,h;if(b.size()==2){g=Date.parse(b.eq(0).val());h=Date.parse(b.eq(1).val());if(g==null){g=h}if(h==null){h=g}}else{g=Date.parse(b.val().split(c.rangeSplitter)[0]);h=Date.parse(b.val().split(c.rangeSplitter)[1]);if(h==null){h=g}}if(g!=null){e=g}if(h!=null){f=h}var i=jQuery('<div class="ui-daterangepicker ui-widget ui-helper-clearfix ui-widget-content ui-corner-all"></div>');var j=function(){var a=jQuery('<ul class="ui-widget-content"></ul>').appendTo(i);jQuery.each(c.presetRanges,function(){jQuery('<li class="ui-daterangepicker-'+this.text.replace(/ /g,"")+' ui-corner-all"><a href="#">'+this.text+"</a></li>").data("dateStart",this.dateStart).data("dateEnd",this.dateEnd).appendTo(a)});var b=0;jQuery.each(c.presets,function(c,d){jQuery('<li class="ui-daterangepicker-'+c+" preset_"+b+' ui-helper-clearfix ui-corner-all"><span class="ui-icon ui-icon-triangle-1-e"></span><a href="#">'+d+"</a></li>").appendTo(a);b++});a.find("li").hover(function(){jQuery(this).addClass("ui-state-hover")},function(){jQuery(this).removeClass("ui-state-hover")}).click(function(){i.find(".ui-state-active").removeClass("ui-state-active");jQuery(this).addClass("ui-state-active").clickActions(i,o,p);return false});return a}();jQuery.fn.restoreDateFromData=function(){if(jQuery(this).data("saveDate")){jQuery(this).datepicker("setDate",jQuery(this).data("saveDate")).removeData("saveDate")}return this};jQuery.fn.saveDateToData=function(){if(!jQuery(this).data("saveDate")){jQuery(this).data("saveDate",jQuery(this).datepicker("getDate"))}return this};i.data("state","closed");jQuery.fn.clickActions=function(a,b,d){if(jQuery(this).is(".ui-daterangepicker-specificDate")){d.hide();b.show();a.find(".title-start").text(c.presets.specificDate);a.find(".range-start").restoreDateFromData().show(400);a.find(".range-end").restoreDateFromData().hide(400);setTimeout(function(){d.fadeIn()},400)}else if(jQuery(this).is(".ui-daterangepicker-allDatesBefore")){d.hide();b.show();a.find(".title-end").text(c.presets.allDatesBefore);a.find(".range-start").saveDateToData().datepicker("setDate",c.earliestDate).hide(400);a.find(".range-end").restoreDateFromData().show(400);setTimeout(function(){d.fadeIn()},400)}else if(jQuery(this).is(".ui-daterangepicker-allDatesAfter")){d.hide();b.show();a.find(".title-start").text(c.presets.allDatesAfter);a.find(".range-start").restoreDateFromData().show(400);a.find(".range-end").saveDateToData().datepicker("setDate",c.latestDate).hide(400);setTimeout(function(){d.fadeIn()},400)}else if(jQuery(this).is(".ui-daterangepicker-dateRange")){d.hide();b.show();a.find(".title-start").text(c.rangeStartTitle);a.find(".title-end").text(c.rangeEndTitle);a.find(".range-start").restoreDateFromData().show(400);a.find(".range-end").restoreDateFromData().show(400);setTimeout(function(){d.fadeIn()},400)}else{d.hide();a.find(".range-start, .range-end").hide(400,function(){b.hide()});var e=typeof jQuery(this).data("dateStart")=="string"?Date.parse(jQuery(this).data("dateStart")):jQuery(this).data("dateStart")();var f=typeof jQuery(this).data("dateEnd")=="string"?Date.parse(jQuery(this).data("dateEnd")):jQuery(this).data("dateEnd")();a.find(".range-start").datepicker("setDate",e).find(".ui-datepicker-current-day").trigger("click");a.find(".range-end").datepicker("setDate",f).find(".ui-datepicker-current-day").trigger("click")}return false};var o=jQuery('<div class="ranges ui-widget-header ui-corner-all ui-helper-clearfix"><div class="range-start"><span class="title-start">Start Date</span></div><div class="range-end"><span class="title-end">End Date</span></div></div>').appendTo(i);o.find(".range-start, .range-end").datepicker(c.datepickerOptions);o.find(".range-start").datepicker("setDate",e);o.find(".range-end").datepicker("setDate",f);var p=jQuery('<button class="btnDone ui-state-default ui-corner-all">'+c.doneButtonText+"</button>").click(function(){i.find(".ui-datepicker-current-day").trigger("click");m()}).hover(function(){jQuery(this).addClass("ui-state-hover")},function(){jQuery(this).removeClass("ui-state-hover")}).appendTo(o);jQuery(this).click(function(){n();return false});o.css("display","none").find(".range-start, .range-end, .btnDone").css("display","none");jQuery(c.appendTo).append(i);i.wrap('<div class="ui-daterangepickercontain"></div>');if(c.posX){i.parent().css("left",c.posX)}if(c.posY){i.parent().css("top",c.posY)}if(c.arrows&&b.size()==1){var q=jQuery('<a href="#" class="ui-daterangepicker-prev ui-corner-all" title="'+c.prevLinkText+'"><span class="ui-icon ui-icon-circle-triangle-w">'+c.prevLinkText+"</span></a>");var r=jQuery('<a href="#" class="ui-daterangepicker-next ui-corner-all" title="'+c.nextLinkText+'"><span class="ui-icon ui-icon-circle-triangle-e">'+c.nextLinkText+"</span></a>");jQuery(this).addClass("ui-rangepicker-input ui-widget-content").wrap('<div class="ui-daterangepicker-arrows ui-widget ui-widget-header ui-helper-clearfix ui-corner-all"></div>').before(q).before(r).parent().find("a").click(function(){var a=o.find(".range-start").datepicker("getDate");var b=o.find(".range-end").datepicker("getDate");var c=Math.abs((new TimeSpan(a-b)).getTotalMilliseconds())+864e5;if(jQuery(this).is(".ui-daterangepicker-prev")){c=-c}o.find(".range-start, .range-end ").each(function(){var a=jQuery(this).datepicker("getDate");if(a==null){return false}jQuery(this).datepicker("setDate",a.add({milliseconds:c})).find(".ui-datepicker-current-day").trigger("click")});return false}).hover(function(){jQuery(this).addClass("ui-state-hover")},function(){jQuery(this).removeClass("ui-state-hover")})}jQuery(document).click(function(){if(i.is(":visible")){m()}});i.click(function(){return false}).hide();return this};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:1,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(a){var b=Date.CultureInfo.monthNames,c=Date.CultureInfo.abbreviatedMonthNames,d=a.toLowerCase();for(var e=0;e<b.length;e++){if(b[e].toLowerCase()==d||c[e].toLowerCase()==d){return e}}return-1};Date.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,c=Date.CultureInfo.abbreviatedDayNames,d=Date.CultureInfo.shortestDayNames,e=a.toLowerCase();for(var f=0;f<b.length;f++){if(b[f].toLowerCase()==e||c[f].toLowerCase()==e){return f}}return-1};Date.isLeapYear=function(a){return a%4===0&&a%100!==0||a%400===0};Date.getDaysInMonth=function(a,b){return[31,Date.isLeapYear(a)?29:28,31,30,31,30,31,31,30,31,30,31][b]};Date.getTimezoneOffset=function(a,b){return b||false?Date.CultureInfo.abbreviatedTimeZoneDST[a.toUpperCase()]:Date.CultureInfo.abbreviatedTimeZoneStandard[a.toUpperCase()]};Date.getTimezoneAbbreviation=function(a,b){var c=b||false?Date.CultureInfo.abbreviatedTimeZoneDST:Date.CultureInfo.abbreviatedTimeZoneStandard,d;for(d in c){if(c[d]===a){return d}}return null};Date.prototype.clone=function(){return new Date(this.getTime())};Date.prototype.compareTo=function(a){if(isNaN(this)){throw new Error(this)}if(a instanceof Date&&!isNaN(a)){return this>a?1:this<a?-1:0}else{throw new TypeError(a)}};Date.prototype.equals=function(a){return this.compareTo(a)===0};Date.prototype.between=function(a,b){var c=this.getTime();return c>=a.getTime()&&c<=b.getTime()};Date.prototype.addMilliseconds=function(a){this.setMilliseconds(this.getMilliseconds()+a);return this};Date.prototype.addSeconds=function(a){return this.addMilliseconds(a*1e3)};Date.prototype.addMinutes=function(a){return this.addMilliseconds(a*6e4)};Date.prototype.addHours=function(a){return this.addMilliseconds(a*36e5)};Date.prototype.addDays=function(a){return this.addMilliseconds(a*864e5)};Date.prototype.addWeeks=function(a){return this.addMilliseconds(a*6048e5)};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(a){if(typeof a=="number"){this._orient=a;return this}var b=a;if(b.millisecond||b.milliseconds){this.addMilliseconds(b.millisecond||b.milliseconds)}if(b.second||b.seconds){this.addSeconds(b.second||b.seconds)}if(b.minute||b.minutes){this.addMinutes(b.minute||b.minutes)}if(b.hour||b.hours){this.addHours(b.hour||b.hours)}if(b.month||b.months){this.addMonths(b.month||b.months)}if(b.year||b.years){this.addYears(b.year||b.years)}if(b.day||b.days){this.addDays(b.day||b.days)}return this};Date._validate=function(a,b,c,d){if(typeof a!="number"){throw new TypeError(a+" is not a Number.")}else if(a<b||a>c){throw new RangeError(a+" is not a valid value for "+d+".")}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(a,b,c){return Date._validate(a,1,Date.getDaysInMonth(b,c),"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(a){var b=a;if(!b.millisecond&&b.millisecond!==0){b.millisecond=-1}if(!b.second&&b.second!==0){b.second=-1}if(!b.minute&&b.minute!==0){b.minute=-1}if(!b.hour&&b.hour!==0){b.hour=-1}if(!b.day&&b.day!==0){b.day=-1}if(!b.month&&b.month!==0){b.month=-1}if(!b.year&&b.year!==0){b.year=-1}if(b.millisecond!=-1&&Date.validateMillisecond(b.millisecond)){this.addMilliseconds(b.millisecond-this.getMilliseconds())}if(b.second!=-1&&Date.validateSecond(b.second)){this.addSeconds(b.second-this.getSeconds())}if(b.minute!=-1&&Date.validateMinute(b.minute)){this.addMinutes(b.minute-this.getMinutes())}if(b.hour!=-1&&Date.validateHour(b.hour)){this.addHours(b.hour-this.getHours())}if(b.month!==-1&&Date.validateMonth(b.month)){this.addMonths(b.month-this.getMonth())}if(b.year!=-1&&Date.validateYear(b.year)){this.addYears(b.year-this.getFullYear())}if(b.day!=-1&&Date.validateDay(b.day,this.getFullYear(),this.getMonth())){this.addDays(b.day-this.getDate())}if(b.timezone){this.setTimezone(b.timezone)}if(b.timezoneOffset){this.setTimezoneOffset(b.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(a,b){var c=(a-this.getMonth()+12*(b||+1))%12;return this.addMonths(c===0?c+=12*(b||+1):c)};Date.prototype.getDayOfYear=function(){return Math.floor((this-new Date(this.getFullYear(),0,1))/864e5)};Date.prototype.getWeekOfYear=function(a){var b=this.getFullYear(),c=this.getMonth(),d=this.getDate();var e=a||Date.CultureInfo.firstDayOfWeek;var f=7+1-(new Date(b,0,1)).getDay();if(f==8){f=1}var g=(Date.UTC(b,c,d,0,0,0)-Date.UTC(b,0,1,0,0,0))/864e5+1;var h=Math.floor((g-f+7)/7);if(h===e){b--;var i=7+1-(new Date(b,0,1)).getDay();if(i==2||i==8){h=53}else{h=52}}return h};Date.prototype.isDST=function(){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(a){var b=this.getTimezoneOffset(),c=Number(a)*-6/10;this.addMinutes(c-b);return this};Date.prototype.setTimezone=function(a){return this.setTimezoneOffset(Date.getTimezoneOffset(a))};Date.prototype.getUTCOffset=function(){var a=this.getTimezoneOffset()*-10/6,b;if(a<0){b=(a-1e4).toString();return b[0]+b.substr(2)}else{b=(a+1e4).toString();return"+"+b.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(a){var b=this;var c=function d(a){return a.toString().length==1?"0"+a:a};return a?a.replace(/dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?/g,function(a){switch(a){case"hh":return c(b.getHours()<13?b.getHours():b.getHours()-12);case"h":return b.getHours()<13?b.getHours():b.getHours()-12;case"HH":return c(b.getHours());case"H":return b.getHours();case"mm":return c(b.getMinutes());case"m":return b.getMinutes();case"ss":return c(b.getSeconds());case"s":return b.getSeconds();case"yyyy":return b.getFullYear();case"yy":return b.getFullYear().toString().substring(2,4);case"dddd":return b.getDayName();case"ddd":return b.getDayName(true);case"dd":return c(b.getDate());case"d":return b.getDate().toString();case"MMMM":return b.getMonthName();case"MMM":return b.getMonthName(true);case"MM":return c(b.getMonth()+1);case"M":return b.getMonth()+1;case"t":return b.getHours()<12?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case"tt":return b.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 a=Date.prototype,b=Number.prototype;var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),d="january february march april may june july august september october november december".split(/\s/),e="Millisecond Second Minute Hour Day Week Month Year".split(/\s/),f;var g=function(a){return function(){if(this._is){this._is=false;return this.getDay()==a}return this.moveToDayOfWeek(a,this._orient)}};for(var h=0;h<c.length;h++){a[c[h]]=a[c[h].substring(0,3)]=g(h)}var i=function(a){return function(){if(this._is){this._is=false;return this.getMonth()===a}return this.moveToMonth(a,this._orient)}};for(var j=0;j<d.length;j++){a[d[j]]=a[d[j].substring(0,3)]=i(j)}var k=function(a){return function(){if(a.substring(a.length-1)!="s"){a+="s"}return this["add"+a](this._orient)}};var l=function(a){return function(){this._dateElement=a;return this}};for(var m=0;m<e.length;m++){f=e[m].toLowerCase();a[f]=a[f+"s"]=k(e[m]);b[f]=b[f+"s"]=l(f)}})();Date.prototype.toJSONString=function(){return this.toString("yyyy-MM-ddThh:mm:ssZ")};Date.prototype.toShortDateString=function(){return this.toString(Date.CultureInfo.formatPatterns.shortDatePattern)};Date.prototype.toLongDateString=function(){return this.toString(Date.CultureInfo.formatPatterns.longDatePattern)};Date.prototype.toShortTimeString=function(){return this.toString(Date.CultureInfo.formatPatterns.shortTimePattern)};Date.prototype.toLongTimeString=function(){return this.toString(Date.CultureInfo.formatPatterns.longTimePattern)};Date.prototype.getOrdinal=function(){switch(this.getDate()){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}};(function(){Date.Parsing={Exception:function(a){this.message="Parse error at '"+a.substring(0,10)+" ...'"}};var a=Date.Parsing;var b=a.Operators={rtoken:function(b){return function(c){var d=c.match(b);if(d){return[d[0],c.substring(d[0].length)]}else{throw new a.Exception(c)}}},token:function(a){return function(a){return b.rtoken(new RegExp("^s*"+a+"s*"))(a)}},stoken:function(a){return b.rtoken(new RegExp("^"+a))},until:function(a){return function(b){var c=[],d=null;while(b.length){try{d=a.call(this,b)}catch(e){c.push(d[0]);b=d[1];continue}break}return[c,b]}},many:function(a){return function(b){var c=[],d=null;while(b.length){try{d=a.call(this,b)}catch(e){return[c,b]}c.push(d[0]);b=d[1]}return[c,b]}},optional:function(a){return function(b){var c=null;try{c=a.call(this,b)}catch(d){return[null,b]}return[c[0],c[1]]}},not:function(b){return function(c){try{b.call(this,c)}catch(d){return[null,c]}throw new a.Exception(c)}},ignore:function(a){return a?function(b){var c=null;c=a.call(this,b);return[null,c[1]]}:null},product:function(){var a=arguments[0],c=Array.prototype.slice.call(arguments,1),d=[];for(var e=0;e<a.length;e++){d.push(b.each(a[e],c))}return d},cache:function(b){var c={},d=null;return function(e){try{d=c[e]=c[e]||b.call(this,e)}catch(f){d=c[e]=f}if(d instanceof a.Exception){throw d}else{return d}}},any:function(){var b=arguments;return function(c){var d=null;for(var e=0;e<b.length;e++){if(b[e]==null){continue}try{d=b[e].call(this,c)}catch(f){d=null}if(d){return d}}throw new a.Exception(c)}},each:function(){var b=arguments;return function(c){var d=[],e=null;for(var f=0;f<b.length;f++){if(b[f]==null){continue}try{e=b[f].call(this,c)}catch(g){throw new a.Exception(c)}d.push(e[0]);c=e[1]}return[d,c]}},all:function(){var a=arguments,b=b;return b.each(b.optional(a))},sequence:function(c,d,e){d=d||b.rtoken(/^\s*/);e=e||null;if(c.length==1){return c[0]}return function(b){var f=null,g=null;var h=[];for(var i=0;i<c.length;i++){try{f=c[i].call(this,b)}catch(j){break}h.push(f[0]);try{g=d.call(this,f[1])}catch(k){g=null;break}b=g[1]}if(!f){throw new a.Exception(b)}if(g){throw new a.Exception(g[1])}if(e){try{f=e.call(this,f[1])}catch(l){throw new a.Exception(f[1])}}return[h,f?f[1]:b]}},between:function(a,c,d){d=d||a;var e=b.each(b.ignore(a),c,b.ignore(d));return function(a){var b=e.call(this,a);return[[b[0][0],r[0][2]],b[1]]}},list:function(a,c,d){c=c||b.rtoken(/^\s*/);d=d||null;return a instanceof Array?b.each(b.product(a.slice(0,-1),b.ignore(c)),a.slice(-1),b.ignore(d)):b.each(b.many(b.each(a,b.ignore(c))),px,b.ignore(d))},set:function(c,d,e){d=d||b.rtoken(/^\s*/);e=e||null;return function(f){var g=null,h=null,i=null,j=null,k=[[],f],l=false;for(var m=0;m<c.length;m++){i=null;h=null;g=null;l=c.length==1;try{g=c[m].call(this,f)}catch(n){continue}j=[[g[0]],g[1]];if(g[1].length>0&&!l){try{i=d.call(this,g[1])}catch(o){l=true}}else{l=true}if(!l&&i[1].length===0){l=true}if(!l){var p=[];for(var q=0;q<c.length;q++){if(m!=q){p.push(c[q])}}h=b.set(p,d).call(this,i[1]);if(h[0].length>0){j[0]=j[0].concat(h[0]);j[1]=h[1]}}if(j[1].length<k[1].length){k=j}if(k[1].length===0){break}}if(k[0].length===0){return k}if(e){try{i=e.call(this,k[1])}catch(r){throw new a.Exception(k[1])}k[1]=i[1]}return k}},forward:function(a,b){return function(c){return a[b].call(this,c)}},replace:function(a,b){return function(c){var d=a.call(this,c);return[b,d[1]]}},process:function(a,b){return function(c){var d=a.call(this,c);return[b.call(this,d[0]),d[1]]}},min:function(b,c){return function(d){var e=c.call(this,d);if(e[0].length<b){throw new a.Exception(d)}return e}}};var c=function(a){return function(){var b=null,c=[];if(arguments.length>1){b=Array.prototype.slice.call(arguments)}else if(arguments[0]instanceof Array){b=arguments[0]}if(b){for(var d=0,e=b.shift();d<e.length;d++){b.unshift(e[d]);c.push(a.apply(null,b));b.shift();return c}}else{return a.apply(null,arguments)}}};var d="optional not ignore cache".split(/\s/);for(var e=0;e<d.length;e++){b[d[e]]=c(b[d[e]])}var f=function(a){return function(){if(arguments[0]instanceof Array){return a.apply(null,arguments[0])}else{return a.apply(null,arguments)}}};var g="each any all".split(/\s/);for(var h=0;h<g.length;h++){b[g[h]]=f(b[g[h]])}})();(function(){var a=function(b){var c=[];for(var d=0;d<b.length;d++){if(b[d]instanceof Array){c=c.concat(a(b[d]))}else{if(b[d]){c.push(b[d])}}}return c};Date.Grammar={};Date.Translator={hour:function(a){return function(){this.hour=Number(a)}},minute:function(a){return function(){this.minute=Number(a)}},second:function(a){return function(){this.second=Number(a)}},meridian:function(a){return function(){this.meridian=a.slice(0,1).toLowerCase()}},timezone:function(a){return function(){var b=a.replace(/[^\d\+\-]/g,"");if(b.length){this.timezoneOffset=Number(b)}else{this.timezone=a.toLowerCase()}}},day:function(a){var b=a[0];return function(){this.day=Number(b.match(/\d+/)[0])}},month:function(a){return function(){this.month=a.length==3?Date.getMonthNumberFromName(a):Number(a)-1}},year:function(a){return function(){var b=Number(a);this.year=a.length>2?b:b+(b+2e3<Date.CultureInfo.twoDigitYearMax?2e3:1900)}},rday:function(a){return function(){switch(a){case"yesterday":this.days=-1;break;case"tomorrow":this.days=1;break;case"today":this.days=0;break;case"now":this.days=0;this.now=true;break}}},finishExact:function(a){a=a instanceof Array?a:[a];var b=new Date;this.year=b.getFullYear();this.month=b.getMonth();this.day=1;this.hour=0;this.minute=0;this.second=0;for(var c=0;c<a.length;c++){if(a[c]){a[c].call(this)}}this.hour=this.meridian=="p"&&this.hour<13?this.hour+12:this.hour;if(this.day>Date.getDaysInMonth(this.year,this.month)){throw new RangeError(this.day+" is not a valid value for days.")}var d=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second);if(this.timezone){d.set({timezone:this.timezone})}else if(this.timezoneOffset){d.set({timezoneOffset:this.timezoneOffset})}return d},finish:function(b){b=b instanceof Array?a(b):[b];if(b.length===0){return null}for(var c=0;c<b.length;c++){if(typeof b[c]=="function"){b[c].call(this)}}if(this.now){return new Date}var d=Date.today();var e=null;var f=!!(this.days!=null||this.orient||this.operator);if(f){var g,h,i;i=this.orient=="past"||this.operator=="subtract"?-1:1;if(this.weekday){this.unit="day";g=Date.getDayNumberFromName(this.weekday)-d.getDay();h=7;this.days=g?(g+i*h)%h:i*h}if(this.month){this.unit="month";g=this.month-d.getMonth();h=12;this.months=g?(g+i*h)%h:i*h;this.month=null}if(!this.unit){this.unit="day"}if(this[this.unit+"s"]==null||this.operator!=null){if(!this.value){this.value=1}if(this.unit=="week"){this.unit="day";this.value=this.value*7}this[this.unit+"s"]=this.value*i}return d.add(this)}else{if(this.meridian&&this.hour){this.hour=this.hour<13&&this.meridian=="p"?this.hour+12:this.hour}if(this.weekday&&!this.day){this.day=d.addDays(Date.getDayNumberFromName(this.weekday)-d.getDay()).getDate()}if(this.month&&!this.day){this.day=1}return d.set(this)}}};var b=Date.Parsing.Operators,c=Date.Grammar,d=Date.Translator,e;c.datePartDelimiter=b.rtoken(/^([\s\-\.\,\/\x27]+)/);c.timePartDelimiter=b.stoken(":");c.whiteSpace=b.rtoken(/^\s*/);c.generalDelimiter=b.rtoken(/^(([\s\,]|at|on)+)/);var f={};c.ctoken=function(a){var c=f[a];if(!c){var d=Date.CultureInfo.regexPatterns;var e=a.split(/\s+/),g=[];for(var h=0;h<e.length;h++){g.push(b.replace(b.rtoken(d[e[h]]),e[h]))}c=f[a]=b.any.apply(null,g)}return c};c.ctoken2=function(a){return b.rtoken(Date.CultureInfo.regexPatterns[a])};c.h=b.cache(b.process(b.rtoken(/^(0[0-9]|1[0-2]|[1-9])/),d.hour));c.hh=b.cache(b.process(b.rtoken(/^(0[0-9]|1[0-2])/),d.hour));c.H=b.cache(b.process(b.rtoken(/^([0-1][0-9]|2[0-3]|[0-9])/),d.hour));c.HH=b.cache(b.process(b.rtoken(/^([0-1][0-9]|2[0-3])/),d.hour));c.m=b.cache(b.process(b.rtoken(/^([0-5][0-9]|[0-9])/),d.minute));c.mm=b.cache(b.process(b.rtoken(/^[0-5][0-9]/),d.minute));c.s=b.cache(b.process(b.rtoken(/^([0-5][0-9]|[0-9])/),d.second));c.ss=b.cache(b.process(b.rtoken(/^[0-5][0-9]/),d.second));c.hms=b.cache(b.sequence([c.H,c.mm,c.ss],c.timePartDelimiter));c.t=b.cache(b.process(c.ctoken2("shortMeridian"),d.meridian));c.tt=b.cache(b.process(c.ctoken2("longMeridian"),d.meridian));c.z=b.cache(b.process(b.rtoken(/^(\+|\-)?\s*\d\d\d\d?/),d.timezone));c.zz=b.cache(b.process(b.rtoken(/^(\+|\-)\s*\d\d\d\d/),d.timezone));c.zzz=b.cache(b.process(c.ctoken2("timezone"),d.timezone));c.timeSuffix=b.each(b.ignore(c.whiteSpace),b.set([c.tt,c.zzz]));c.time=b.each(b.optional(b.ignore(b.stoken("T"))),c.hms,c.timeSuffix);c.d=b.cache(b.process(b.each(b.rtoken(/^([0-2]\d|3[0-1]|\d)/),b.optional(c.ctoken2("ordinalSuffix"))),d.day));c.dd=b.cache(b.process(b.each(b.rtoken(/^([0-2]\d|3[0-1])/),b.optional(c.ctoken2("ordinalSuffix"))),d.day));c.ddd=c.dddd=b.cache(b.process(c.ctoken("sun mon tue wed thu fri sat"),function(a){return function(){this.weekday=a}}));c.M=b.cache(b.process(b.rtoken(/^(1[0-2]|0\d|\d)/),d.month));c.MM=b.cache(b.process(b.rtoken(/^(1[0-2]|0\d)/),d.month));c.MMM=c.MMMM=b.cache(b.process(c.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"),d.month));c.y=b.cache(b.process(b.rtoken(/^(\d\d?)/),d.year));c.yy=b.cache(b.process(b.rtoken(/^(\d\d)/),d.year));c.yyy=b.cache(b.process(b.rtoken(/^(\d\d?\d?\d?)/),d.year));c.yyyy=b.cache(b.process(b.rtoken(/^(\d\d\d\d)/),d.year));e=function(){return b.each(b.any.apply(null,arguments),b.not(c.ctoken2("timeContext")))};c.day=e(c.d,c.dd);c.month=e(c.M,c.MMM);c.year=e(c.yyyy,c.yy);c.orientation=b.process(c.ctoken("past future"),function(a){return function(){this.orient=a}});c.operator=b.process(c.ctoken("add subtract"),function(a){return function(){this.operator=a}});c.rday=b.process(c.ctoken("yesterday tomorrow today now"),d.rday);c.unit=b.process(c.ctoken("minute hour day week month year"),function(a){return function(){this.unit=a}});c.value=b.process(b.rtoken(/^\d\d?(st|nd|rd|th)?/),function(a){return function(){this.value=a.replace(/\D/g,"")}});c.expression=b.set([c.rday,c.operator,c.value,c.unit,c.orientation,c.ddd,c.MMM]);e=function(){return b.set(arguments,c.datePartDelimiter)};c.mdy=e(c.ddd,c.month,c.day,c.year);c.ymd=e(c.ddd,c.year,c.month,c.day);c.dmy=e(c.ddd,c.day,c.month,c.year);c.date=function(a){return(c[Date.CultureInfo.dateElementOrder]||c.mdy).call(this,a)};c.format=b.process(b.many(b.any(b.process(b.rtoken(/^(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/),function(a){if(c[a]){return c[a]}else{throw Date.Parsing.Exception(a)}}),b.process(b.rtoken(/^[^dMyhHmstz]+/),function(a){return b.ignore(b.stoken(a))}))),function(a){return b.process(b.each.apply(null,a),d.finishExact)});var g={};var h=function(a){return g[a]=g[a]||c.format(a)[0]};c.formats=function(a){if(a instanceof Array){var c=[];for(var d=0;d<a.length;d++){c.push(h(a[d]))}return b.any.apply(null,c)}else{return h(a)}};c._formats=c.formats(["yyyy-MM-ddTHH:mm:ss","ddd, MMM dd, yyyy H:mm:ss tt","ddd MMM d yyyy HH:mm:ss zzz","d"]);c._start=b.process(b.set([c.date,c.time,c.expression],c.generalDelimiter,c.whiteSpace),d.finish);c.start=function(a){try{var b=c._formats.call({},a);if(b[1].length===0){return b}}catch(d){}return c._start.call({},a)}})();Date._parse=Date.parse;Date.parse=function(a){var b=null;if(!a){return null}try{b=Date.Grammar.start.call({},a)}catch(c){return null}return b[1].length===0?b[0]:null};Date.getParseFunction=function(a){var b=Date.Grammar.formats(a);return function(a){var c=null;try{c=b.call({},a)}catch(d){return null}return c[1].length===0?c[0]:null}};Date.parseExact=function(a,b){return Date.getParseFunction(b)(a)};var TimeSpan=function(a,b,c,d,e){var f="days hours minutes seconds milliseconds".split(/\s+/);var g=function(a){return function(){return this[a]}};var h=function(a){return function(b){this[a]=b;return this}};for(var i=0;i<f.length;i++){var j=f[i],k=j.slice(0,1).toUpperCase()+j.slice(1);TimeSpan.prototype[j]=0;TimeSpan.prototype["get"+k]=g(j);TimeSpan.prototype["set"+k]=h(j)}if(arguments.length==4){this.setDays(a);this.setHours(b);this.setMinutes(c);this.setSeconds(d)}else if(arguments.length==5){this.setDays(a);this.setHours(b);this.setMinutes(c);this.setSeconds(d);this.setMilliseconds(e)}else if(arguments.length==1&&typeof a=="number"){var l=a<0?-1:+1;this.setMilliseconds(Math.abs(a));this.setDays(Math.floor(this.getMilliseconds()/864e5)*l);this.setMilliseconds(this.getMilliseconds()%864e5);this.setHours(Math.floor(this.getMilliseconds()/36e5)*l);this.setMilliseconds(this.getMilliseconds()%36e5);this.setMinutes(Math.floor(this.getMilliseconds()/6e4)*l);this.setMilliseconds(this.getMilliseconds()%6e4);this.setSeconds(Math.floor(this.getMilliseconds()/1e3)*l);this.setMilliseconds(this.getMilliseconds()%1e3);this.setMilliseconds(this.getMilliseconds()*l)}this.getTotalMilliseconds=function(){return this.getDays()*864e5+this.getHours()*36e5+this.getMinutes()*6e4+this.getSeconds()*1e3};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds()),c;if(a===null){c=new Date(1970,1,1,0,0,0)}else{c=new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds())}return b<c?-1:b>c?1:0};this.equals=function(a){return this.compareTo(a)===0};this.add=function(a){return a===null?this:this.addSeconds(a.getTotalMilliseconds()/1e3)};this.subtract=function(a){return a===null?this:this.addSeconds(-a.getTotalMilliseconds()/1e3)};this.addDays=function(a){return new TimeSpan(this.getTotalMilliseconds()+a*864e5)};this.addHours=function(a){return new TimeSpan(this.getTotalMilliseconds()+a*36e5)};this.addMinutes=function(a){return new TimeSpan(this.getTotalMilliseconds()+a*6e4)};this.addSeconds=function(a){return new TimeSpan(this.getTotalMilliseconds()+a*1e3)};this.addMilliseconds=function(a){return new TimeSpan(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return this.getHours()>12?this.getHours()-12:this.getHours()===0?12:this.getHours()};this.getDesignator=function(){return this.getHours()<12?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){if(this.getDays()!==null&&this.getDays()>0){return this.getDays()+"."+this.getHours()+":"+this.p(this.getMinutes())+":"+this.p(this.getSeconds())}else{return this.getHours()+":"+this.p(this.getMinutes())+":"+this.p(this.getSeconds())}};this.p=function(a){return a.toString().length<2?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g,function(a){switch(a){case"d":return b.getDays();case"dd":return b.p(b.getDays());case"H":return b.getHours();case"HH":return b.p(b.getHours());case"h":return b.get12HourHour();case"hh":return b.p(b.get12HourHour());case"m":return b.getMinutes();case"mm":return b.p(b.getMinutes());case"s":return b.getSeconds();case"ss":return b.p(b.getSeconds());case"t":return(b.getHours()<12?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case"tt":return b.getHours()<12?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator}}):this._toString()};return this};Date.prototype.getTimeOfDay=function(){return new TimeSpan(0,this.getHours(),this.getMinutes(),this.getSeconds(),this.getMilliseconds())};var TimePeriod=function(a,b,c,d,e,f,g){var h="years months days hours minutes seconds milliseconds".split(/\s+/);var i=function(a){return function(){return this[a]}};var j=function(a){return function(b){this[a]=b;return this}};for(var k=0;k<h.length;k++){var l=h[k],m=l.slice(0,1).toUpperCase()+l.slice(1);TimePeriod.prototype[l]=0;TimePeriod.prototype["get"+m]=i(l);TimePeriod.prototype["set"+m]=j(l)}if(arguments.length==7){this.years=a;this.months=b;this.setDays(c);this.setHours(d);this.setMinutes(e);this.setSeconds(f);this.setMilliseconds(g)}else if(arguments.length==2&&arguments[0]instanceof Date&&arguments[1]instanceof Date){var n=a.clone();var o=b.clone();var p=n.clone();var q=n>o?-1:+1;this.years=o.getFullYear()-n.getFullYear();p.addYears(this.years);if(q==+1){if(p>o){if(this.years!==0){this.years--}}}else{if(p<o){if(this.years!==0){this.years++}}}n.addYears(this.years);if(q==+1){while(n<o&&n.clone().addDays(Date.getDaysInMonth(n.getYear(),n.getMonth()))<o){n.addMonths(1);this.months++}}else{while(n>o&&n.clone().addDays(-n.getDaysInMonth())>o){n.addMonths(-1);this.months--}}var r=o-n;if(r!==0){var s=new TimeSpan(r);this.setDays(s.getDays());this.setHours(s.getHours());this.setMinutes(s.getMinutes());this.setSeconds(s.getSeconds());this.setMilliseconds(s.getMilliseconds())}}return this}
