/*
* jQuery timepicker addon
* By: Trent Richardson [http://trentrichardson.com]
* Version 1.0.1
* Last Modified: 07/01/2012
*
* Copyright 2012 Trent Richardson
* You may use this project under MIT or GPL licenses.
* http://trentrichardson.com/Impromptu/GPL-LICENSE.txt
* http://trentrichardson.com/Impromptu/MIT-LICENSE.txt
*/
(function(d){function m(){this.regional=[];this.regional[""]={currentText:"Now",closeText:"Done",ampm:!1,amNames:["AM","A"],pmNames:["PM","P"],timeFormat:"hh:mm tt",timeSuffix:"",timeOnlyTitle:"Choose Time",timeText:"Time",hourText:"Hour",minuteText:"Minute",secondText:"Second",millisecText:"Millisecond",timezoneText:"Time Zone"};this._defaults={showButtonPanel:!0,timeOnly:!1,showHour:!0,showMinute:!0,showSecond:!1,showMillisec:!1,showTimezone:!1,showTime:!0,stepHour:1,stepMinute:1,stepSecond:1,stepMillisec:1, hour:0,minute:0,second:0,millisec:0,timezone:null,useLocalTimezone:!1,defaultTimezone:"+0000",hourMin:0,minuteMin:0,secondMin:0,millisecMin:0,hourMax:23,minuteMax:59,secondMax:59,millisecMax:999,minDateTime:null,maxDateTime:null,onSelect:null,hourGrid:0,minuteGrid:0,secondGrid:0,millisecGrid:0,alwaysSetTime:!0,separator:" ",altFieldTimeOnly:!0,showTimepicker:!0,timezoneIso8601:!1,timezoneList:null,addSliderAccess:!1,sliderAccessArgs:null};d.extend(this._defaults,this.regional[""])}function r(b,a){d.extend(b, a);for(var c in a)if(null===a[c]||void 0===a[c])b[c]=a[c];return b}d.ui.timepicker=d.ui.timepicker||{};if(!d.ui.timepicker.version){d.extend(d.ui,{timepicker:{version:"1.0.1"}});d.extend(m.prototype,{$input:null,$altInput:null,$timeObj:null,inst:null,hour_slider:null,minute_slider:null,second_slider:null,millisec_slider:null,timezone_select:null,hour:0,minute:0,second:0,millisec:0,timezone:null,defaultTimezone:"+0000",hourMinOriginal:null,minuteMinOriginal:null,secondMinOriginal:null,millisecMinOriginal:null, hourMaxOriginal:null,minuteMaxOriginal:null,secondMaxOriginal:null,millisecMaxOriginal:null,ampm:"",formattedDate:"",formattedTime:"",formattedDateTime:"",timezoneList:null,setDefaults:function(b){r(this._defaults,b||{});return this},_newInst:function(b,a){var c=new m,e={},f;for(f in this._defaults){var g=b.attr("time:"+f);if(g)try{e[f]=eval(g)}catch(l){e[f]=g}}c._defaults=d.extend({},this._defaults,e,a,{beforeShow:function(b,e){if(d.isFunction(a.beforeShow))return a.beforeShow(b,e,c)},onChangeMonthYear:function(e, f,g){c._updateDateTime(g);d.isFunction(a.onChangeMonthYear)&&a.onChangeMonthYear.call(b[0],e,f,g,c)},onClose:function(e,f){!0===c.timeDefined&&""!==b.val()&&c._updateDateTime(f);d.isFunction(a.onClose)&&a.onClose.call(b[0],e,f,c)},timepicker:c});c.amNames=d.map(c._defaults.amNames,function(a){return a.toUpperCase()});c.pmNames=d.map(c._defaults.pmNames,function(a){return a.toUpperCase()});if(null===c._defaults.timezoneList){e=[];for(f=-11;12>=f;f++)e.push((0<=f?"+":"-")+("0"+Math.abs(f).toString()).slice(-2)+ "00");c._defaults.timezoneIso8601&&(e=d.map(e,function(a){return"+0000"==a?"Z":a.substring(0,3)+":"+a.substring(3)}));c._defaults.timezoneList=e}c.timezone=c._defaults.timezone;c.hour=c._defaults.hour;c.minute=c._defaults.minute;c.second=c._defaults.second;c.millisec=c._defaults.millisec;c.ampm="";c.$input=b;a.altField&&(c.$altInput=d(a.altField).css({cursor:"pointer"}).focus(function(){b.trigger("focus")}));if(0===c._defaults.minDate||0===c._defaults.minDateTime)c._defaults.minDate=new Date;if(0=== c._defaults.maxDate||0===c._defaults.maxDateTime)c._defaults.maxDate=new Date;void 0!==c._defaults.minDate&&c._defaults.minDate instanceof Date&&(c._defaults.minDateTime=new Date(c._defaults.minDate.getTime()));void 0!==c._defaults.minDateTime&&c._defaults.minDateTime instanceof Date&&(c._defaults.minDate=new Date(c._defaults.minDateTime.getTime()));void 0!==c._defaults.maxDate&&c._defaults.maxDate instanceof Date&&(c._defaults.maxDateTime=new Date(c._defaults.maxDate.getTime()));void 0!==c._defaults.maxDateTime&& c._defaults.maxDateTime instanceof Date&&(c._defaults.maxDate=new Date(c._defaults.maxDateTime.getTime()));return c},_addTimePicker:function(b){var a=this.$altInput&&this._defaults.altFieldTimeOnly?this.$input.val()+" "+this.$altInput.val():this.$input.val();this.timeDefined=this._parseTime(a);this._limitMinMaxDateTime(b,!1);this._injectTimePicker()},_parseTime:function(b,a){this.inst||(this.inst=d.datepicker._getInst(this.$input[0]));if(a||!this._defaults.timeOnly){var c=d.datepicker._get(this.inst, "dateFormat");try{var e=u(c,this._defaults.timeFormat,b,d.datepicker._getFormatConfig(this.inst),this._defaults);if(!e.timeObj)return!1;d.extend(this,e.timeObj)}catch(f){return!1}}else{c=d.datepicker.parseTime(this._defaults.timeFormat,b,this._defaults);if(!c)return!1;d.extend(this,c)}return!0},_injectTimePicker:function(){var b=this.inst.dpDiv,a=this._defaults,c=this,e=parseInt(a.hourMax-(a.hourMax-a.hourMin)%a.stepHour,10),f=parseInt(a.minuteMax-(a.minuteMax-a.minuteMin)%a.stepMinute,10),g=parseInt(a.secondMax- (a.secondMax-a.secondMin)%a.stepSecond,10),l=parseInt(a.millisecMax-(a.millisecMax-a.millisecMin)%a.stepMillisec,10),i=this.inst.id.toString().replace(/([^A-Za-z0-9_])/g,"");if(0===b.find("div#ui-timepicker-div-"+i).length&&a.showTimepicker){var h='<div class="ui-timepicker-div" id="ui-timepicker-div-'+i+'"><dl><dt class="ui_tpicker_time_label" id="ui_tpicker_time_label_'+i+'"'+(a.showTime?"":' style="display:none;"')+">"+a.timeText+'</dt><dd class="ui_tpicker_time" id="ui_tpicker_time_'+i+'"'+(a.showTime? "":' style="display:none;"')+'></dd><dt class="ui_tpicker_hour_label" id="ui_tpicker_hour_label_'+i+'"'+(a.showHour?"":' style="display:none;"')+">"+a.hourText+"</dt>",s=0,q=0,o=0,m=0,n=null,h=h+('<dd class="ui_tpicker_hour"><div id="ui_tpicker_hour_'+i+'"'+(a.showHour?"":' style="display:none;"')+"></div>");if(a.showHour&&0<a.hourGrid){for(var h=h+'<div style="padding-left: 1px"><table class="ui-tpicker-grid-label"><tr>',j=a.hourMin;j<=e;j+=parseInt(a.hourGrid,10)){s++;var p=a.ampm&&12<j?j-12:j; 10>p&&(p="0"+p);a.ampm&&(p=0===j?"12a":12>j?p+"a":p+"p");h+="<td>"+p+"</td>"}h+="</tr></table></div>"}h=h+"</dd>"+('<dt class="ui_tpicker_minute_label" id="ui_tpicker_minute_label_'+i+'"'+(a.showMinute?"":' style="display:none;"')+">"+a.minuteText+'</dt><dd class="ui_tpicker_minute"><div id="ui_tpicker_minute_'+i+'"'+(a.showMinute?"":' style="display:none;"')+"></div>");if(a.showMinute&&0<a.minuteGrid){h+='<div style="padding-left: 1px"><table class="ui-tpicker-grid-label"><tr>';for(j=a.minuteMin;j<= f;j+=parseInt(a.minuteGrid,10))q++,h+="<td>"+(10>j?"0":"")+j+"</td>";h+="</tr></table></div>"}h=h+"</dd>"+('<dt class="ui_tpicker_second_label" id="ui_tpicker_second_label_'+i+'"'+(a.showSecond?"":' style="display:none;"')+">"+a.secondText+'</dt><dd class="ui_tpicker_second"><div id="ui_tpicker_second_'+i+'"'+(a.showSecond?"":' style="display:none;"')+"></div>");if(a.showSecond&&0<a.secondGrid){h+='<div style="padding-left: 1px"><table><tr>';for(j=a.secondMin;j<=g;j+=parseInt(a.secondGrid,10))o++, h+="<td>"+(10>j?"0":"")+j+"</td>";h+="</tr></table></div>"}h=h+"</dd>"+('<dt class="ui_tpicker_millisec_label" id="ui_tpicker_millisec_label_'+i+'"'+(a.showMillisec?"":' style="display:none;"')+">"+a.millisecText+'</dt><dd class="ui_tpicker_millisec"><div id="ui_tpicker_millisec_'+i+'"'+(a.showMillisec?"":' style="display:none;"')+"></div>");if(a.showMillisec&&0<a.millisecGrid){h+='<div style="padding-left: 1px"><table><tr>';for(j=a.millisecMin;j<=l;j+=parseInt(a.millisecGrid,10))m++,h+="<td>"+(10> j?"0":"")+j+"</td>";h+="</tr></table></div>"}var h=h+"</dd>"+('<dt class="ui_tpicker_timezone_label" id="ui_tpicker_timezone_label_'+i+'"'+(a.showTimezone?"":' style="display:none;"')+">"+a.timezoneText+"</dt>"),h=h+('<dd class="ui_tpicker_timezone" id="ui_tpicker_timezone_'+i+'"'+(a.showTimezone?"":' style="display:none;"')+"></dd>"),k=d(h+"</dl></div>");!0===a.timeOnly&&(k.prepend('<div class="ui-widget-header ui-helper-clearfix ui-corner-all"><div class="ui-datepicker-title">'+a.timeOnlyTitle+ "</div></div>"),b.find(".ui-datepicker-header, .ui-datepicker-calendar").hide());this.hour_slider=k.find("#ui_tpicker_hour_"+i).slider({orientation:"horizontal",value:this.hour,min:a.hourMin,max:e,step:a.stepHour,slide:function(a,b){c.hour_slider.slider("option","value",b.value);c._onTimeChange()}});this.minute_slider=k.find("#ui_tpicker_minute_"+i).slider({orientation:"horizontal",value:this.minute,min:a.minuteMin,max:f,step:a.stepMinute,slide:function(a,b){c.minute_slider.slider("option","value", b.value);c._onTimeChange()}});this.second_slider=k.find("#ui_tpicker_second_"+i).slider({orientation:"horizontal",value:this.second,min:a.secondMin,max:g,step:a.stepSecond,slide:function(a,b){c.second_slider.slider("option","value",b.value);c._onTimeChange()}});this.millisec_slider=k.find("#ui_tpicker_millisec_"+i).slider({orientation:"horizontal",value:this.millisec,min:a.millisecMin,max:l,step:a.stepMillisec,slide:function(a,b){c.millisec_slider.slider("option","value",b.value);c._onTimeChange()}}); this.timezone_select=k.find("#ui_tpicker_timezone_"+i).append("<select></select>").find("select");d.fn.append.apply(this.timezone_select,d.map(a.timezoneList,function(a){return d("<option />").val(typeof a=="object"?a.value:a).text(typeof a=="object"?a.label:a)}));"undefined"!=typeof this.timezone&&null!==this.timezone&&""!==this.timezone?v(new Date(this.inst.selectedYear,this.inst.selectedMonth,this.inst.selectedDay,12))==this.timezone?t(c):this.timezone_select.val(this.timezone):"undefined"!=typeof this.hour&& null!==this.hour&&""!==this.hour?this.timezone_select.val(a.defaultTimezone):t(c);this.timezone_select.change(function(){c._defaults.useLocalTimezone=false;c._onTimeChange()});a.showHour&&0<a.hourGrid&&(n=100*s*a.hourGrid/(e-a.hourMin),k.find(".ui_tpicker_hour table").css({width:n+"%",marginLeft:n/(-2*s)+"%",borderCollapse:"collapse"}).find("td").each(function(){d(this).click(function(){var b=d(this).html();if(a.ampm)var e=b.substring(2).toLowerCase(),b=parseInt(b.substring(0,2),10),b=e=="a"?b==12? 0:b:b==12?12:b+12;c.hour_slider.slider("option","value",b);c._onTimeChange();c._onSelectHandler()}).css({cursor:"pointer",width:100/s+"%",textAlign:"center",overflow:"hidden"})}));a.showMinute&&0<a.minuteGrid&&(n=100*q*a.minuteGrid/(f-a.minuteMin),k.find(".ui_tpicker_minute table").css({width:n+"%",marginLeft:n/(-2*q)+"%",borderCollapse:"collapse"}).find("td").each(function(){d(this).click(function(){c.minute_slider.slider("option","value",d(this).html());c._onTimeChange();c._onSelectHandler()}).css({cursor:"pointer", width:100/q+"%",textAlign:"center",overflow:"hidden"})}));a.showSecond&&0<a.secondGrid&&k.find(".ui_tpicker_second table").css({width:n+"%",marginLeft:n/(-2*o)+"%",borderCollapse:"collapse"}).find("td").each(function(){d(this).click(function(){c.second_slider.slider("option","value",d(this).html());c._onTimeChange();c._onSelectHandler()}).css({cursor:"pointer",width:100/o+"%",textAlign:"center",overflow:"hidden"})});a.showMillisec&&0<a.millisecGrid&&k.find(".ui_tpicker_millisec table").css({width:n+ "%",marginLeft:n/(-2*m)+"%",borderCollapse:"collapse"}).find("td").each(function(){d(this).click(function(){c.millisec_slider.slider("option","value",d(this).html());c._onTimeChange();c._onSelectHandler()}).css({cursor:"pointer",width:100/m+"%",textAlign:"center",overflow:"hidden"})});e=b.find(".ui-datepicker-buttonpane");e.length?e.before(k):b.append(k);this.$timeObj=k.find("#ui_tpicker_time_"+i);null!==this.inst&&(b=this.timeDefined,this._onTimeChange(),this.timeDefined=b);b=function(){c._onSelectHandler()}; this.hour_slider.bind("slidestop",b);this.minute_slider.bind("slidestop",b);this.second_slider.bind("slidestop",b);this.millisec_slider.bind("slidestop",b);if(this._defaults.addSliderAccess){var r=this._defaults.sliderAccessArgs;setTimeout(function(){if(k.find(".ui-slider-access").length===0){k.find(".ui-slider:visible").sliderAccess(r);var a=k.find(".ui-slider-access:eq(0)").outerWidth(true);a&&k.find("table:visible").each(function(){var b=d(this),c=b.outerWidth(),e=b.css("marginLeft").toString().replace("%", ""),f=c-a;b.css({width:f,marginLeft:e*f/c+"%"})})}},0)}}},_limitMinMaxDateTime:function(b,a){var c=this._defaults,e=new Date(b.selectedYear,b.selectedMonth,b.selectedDay);if(this._defaults.showTimepicker){if(null!==d.datepicker._get(b,"minDateTime")&&void 0!==d.datepicker._get(b,"minDateTime")&&e){var f=d.datepicker._get(b,"minDateTime"),g=new Date(f.getFullYear(),f.getMonth(),f.getDate(),0,0,0,0);if(null===this.hourMinOriginal||null===this.minuteMinOriginal||null===this.secondMinOriginal||null=== this.millisecMinOriginal)this.hourMinOriginal=c.hourMin,this.minuteMinOriginal=c.minuteMin,this.secondMinOriginal=c.secondMin,this.millisecMinOriginal=c.millisecMin;b.settings.timeOnly||g.getTime()==e.getTime()?(this._defaults.hourMin=f.getHours(),this.hour<=this._defaults.hourMin?(this.hour=this._defaults.hourMin,this._defaults.minuteMin=f.getMinutes(),this.minute<=this._defaults.minuteMin?(this.minute=this._defaults.minuteMin,this._defaults.secondMin=f.getSeconds()):this.second<=this._defaults.secondMin? (this.second=this._defaults.secondMin,this._defaults.millisecMin=f.getMilliseconds()):(this.millisec<this._defaults.millisecMin&&(this.millisec=this._defaults.millisecMin),this._defaults.millisecMin=this.millisecMinOriginal)):(this._defaults.minuteMin=this.minuteMinOriginal,this._defaults.secondMin=this.secondMinOriginal,this._defaults.millisecMin=this.millisecMinOriginal)):(this._defaults.hourMin=this.hourMinOriginal,this._defaults.minuteMin=this.minuteMinOriginal,this._defaults.secondMin=this.secondMinOriginal, this._defaults.millisecMin=this.millisecMinOriginal)}if(null!==d.datepicker._get(b,"maxDateTime")&&void 0!==d.datepicker._get(b,"maxDateTime")&&e){f=d.datepicker._get(b,"maxDateTime");g=new Date(f.getFullYear(),f.getMonth(),f.getDate(),0,0,0,0);if(null===this.hourMaxOriginal||null===this.minuteMaxOriginal||null===this.secondMaxOriginal)this.hourMaxOriginal=c.hourMax,this.minuteMaxOriginal=c.minuteMax,this.secondMaxOriginal=c.secondMax,this.millisecMaxOriginal=c.millisecMax;b.settings.timeOnly||g.getTime()== e.getTime()?(this._defaults.hourMax=f.getHours(),this.hour>=this._defaults.hourMax?(this.hour=this._defaults.hourMax,this._defaults.minuteMax=f.getMinutes(),this.minute>=this._defaults.minuteMax?(this.minute=this._defaults.minuteMax,this._defaults.secondMax=f.getSeconds()):this.second>=this._defaults.secondMax?(this.second=this._defaults.secondMax,this._defaults.millisecMax=f.getMilliseconds()):(this.millisec>this._defaults.millisecMax&&(this.millisec=this._defaults.millisecMax),this._defaults.millisecMax= this.millisecMaxOriginal)):(this._defaults.minuteMax=this.minuteMaxOriginal,this._defaults.secondMax=this.secondMaxOriginal,this._defaults.millisecMax=this.millisecMaxOriginal)):(this._defaults.hourMax=this.hourMaxOriginal,this._defaults.minuteMax=this.minuteMaxOriginal,this._defaults.secondMax=this.secondMaxOriginal,this._defaults.millisecMax=this.millisecMaxOriginal)}void 0!==a&&!0===a&&(c=parseInt(this._defaults.hourMax-(this._defaults.hourMax-this._defaults.hourMin)%this._defaults.stepHour,10), e=parseInt(this._defaults.minuteMax-(this._defaults.minuteMax-this._defaults.minuteMin)%this._defaults.stepMinute,10),f=parseInt(this._defaults.secondMax-(this._defaults.secondMax-this._defaults.secondMin)%this._defaults.stepSecond,10),g=parseInt(this._defaults.millisecMax-(this._defaults.millisecMax-this._defaults.millisecMin)%this._defaults.stepMillisec,10),this.hour_slider&&this.hour_slider.slider("option",{min:this._defaults.hourMin,max:c}).slider("value",this.hour),this.minute_slider&&this.minute_slider.slider("option", {min:this._defaults.minuteMin,max:e}).slider("value",this.minute),this.second_slider&&this.second_slider.slider("option",{min:this._defaults.secondMin,max:f}).slider("value",this.second),this.millisec_slider&&this.millisec_slider.slider("option",{min:this._defaults.millisecMin,max:g}).slider("value",this.millisec))}},_onTimeChange:function(){var b=this.hour_slider?this.hour_slider.slider("value"):!1,a=this.minute_slider?this.minute_slider.slider("value"):!1,c=this.second_slider?this.second_slider.slider("value"): !1,e=this.millisec_slider?this.millisec_slider.slider("value"):!1,f=this.timezone_select?this.timezone_select.val():!1,g=this._defaults;"object"==typeof b&&(b=!1);"object"==typeof a&&(a=!1);"object"==typeof c&&(c=!1);"object"==typeof e&&(e=!1);"object"==typeof f&&(f=!1);!1!==b&&(b=parseInt(b,10));!1!==a&&(a=parseInt(a,10));!1!==c&&(c=parseInt(c,10));!1!==e&&(e=parseInt(e,10));var l=g[12>b?"amNames":"pmNames"][0],i=b!=this.hour||a!=this.minute||c!=this.second||e!=this.millisec||0<this.ampm.length&& 12>b!=(-1!==d.inArray(this.ampm.toUpperCase(),this.amNames))||f!=this.timezone;i&&(!1!==b&&(this.hour=b),!1!==a&&(this.minute=a),!1!==c&&(this.second=c),!1!==e&&(this.millisec=e),!1!==f&&(this.timezone=f),this.inst||(this.inst=d.datepicker._getInst(this.$input[0])),this._limitMinMaxDateTime(this.inst,!0));g.ampm&&(this.ampm=l);this.formattedTime=d.datepicker.formatTime(this._defaults.timeFormat,this,this._defaults);this.$timeObj&&this.$timeObj.text(this.formattedTime+g.timeSuffix);this.timeDefined= !0;i&&this._updateDateTime()},_onSelectHandler:function(){var b=this._defaults.onSelect,a=this.$input?this.$input[0]:null;b&&a&&b.apply(a,[this.formattedDateTime,this])},_formatTime:function(b,a){var b=b||{hour:this.hour,minute:this.minute,second:this.second,millisec:this.millisec,ampm:this.ampm,timezone:this.timezone},c=(a||this._defaults.timeFormat).toString(),c=d.datepicker.formatTime(c,b,this._defaults);if(arguments.length)return c;this.formattedTime=c},_updateDateTime:function(b){var b=this.inst|| b,a=d.datepicker._daylightSavingAdjust(new Date(b.selectedYear,b.selectedMonth,b.selectedDay)),c=d.datepicker._get(b,"dateFormat"),e=d.datepicker._getFormatConfig(b),b=null!==a&&this.timeDefined,a=this.formattedDate=d.datepicker.formatDate(c,null===a?new Date:a,e);if(!0===this._defaults.timeOnly)a=this.formattedTime;else if(!0!==this._defaults.timeOnly&&(this._defaults.alwaysSetTime||b))a+=this._defaults.separator+this.formattedTime+this._defaults.timeSuffix;this.formattedDateTime=a;this._defaults.showTimepicker? this.$altInput&&!0===this._defaults.altFieldTimeOnly?(this.$altInput.val(this.formattedTime),this.$input.val(this.formattedDate)):(this.$altInput&&this.$altInput.val(a),this.$input.val(a)):this.$input.val(this.formattedDate);this.$input.trigger("change")}});d.fn.extend({timepicker:function(b){var b=b||{},a=arguments;"object"==typeof b&&(a[0]=d.extend(b,{timeOnly:!0}));return d(this).each(function(){d.fn.datetimepicker.apply(d(this),a)})},datetimepicker:function(b){var b=b||{},a=arguments;return"string"== typeof b?"getDate"==b?d.fn.datepicker.apply(d(this[0]),a):this.each(function(){var b=d(this);b.datepicker.apply(b,a)}):this.each(function(){var a=d(this);a.datepicker(d.timepicker._newInst(a,b)._defaults)})}});d.datepicker.parseDateTime=function(b,a,c,e,d){b=u(b,a,c,e,d);b.timeObj&&(a=b.timeObj,b.date.setHours(a.hour,a.minute,a.second,a.millisec));return b.date};d.datepicker.parseTime=function(b,a,c){var c=r(r({},d.timepicker._defaults),c||{}),e="^"+b.toString().replace(/h{1,2}/ig,"(\\d?\\d)").replace(/m{1,2}/ig, "(\\d?\\d)").replace(/s{1,2}/ig,"(\\d?\\d)").replace(/l{1}/ig,"(\\d?\\d?\\d)").replace(/t{1,2}/ig,function(a,b){var c=[];a&&d.merge(c,a);b&&d.merge(c,b);c=d.map(c,function(a){return a.replace(/[.*+?|()\[\]{}\\]/g,"\\$&")});return"("+c.join("|")+")?"}(c.amNames,c.pmNames)).replace(/z{1}/ig,"(z|[-+]\\d\\d:?\\d\\d)?").replace(/\s/g,"\\s?")+c.timeSuffix+"$",f=b.toLowerCase().match(/(h{1,2}|m{1,2}|s{1,2}|l{1}|t{1,2}|z)/g),b={h:-1,m:-1,s:-1,l:-1,t:-1,z:-1};if(f)for(var g=0;g<f.length;g++)-1==b[f[g].toString().charAt(0)]&& (b[f[g].toString().charAt(0)]=g+1);f="";e=a.match(RegExp(e,"i"));a={hour:0,minute:0,second:0,millisec:0};if(e){-1!==b.t&&(void 0===e[b.t]||0===e[b.t].length?(f="",a.ampm=""):(f=-1!==d.inArray(e[b.t],c.amNames)?"AM":"PM",a.ampm=c["AM"==f?"amNames":"pmNames"][0]));-1!==b.h&&(a.hour="AM"==f&&"12"==e[b.h]?0:"PM"==f&&"12"!=e[b.h]?parseInt(e[b.h],10)+12:Number(e[b.h]));-1!==b.m&&(a.minute=Number(e[b.m]));-1!==b.s&&(a.second=Number(e[b.s]));-1!==b.l&&(a.millisec=Number(e[b.l]));if(-1!==b.z&&void 0!==e[b.z]){b= e[b.z].toUpperCase();switch(b.length){case 1:b=c.timezoneIso8601?"Z":"+0000";break;case 5:c.timezoneIso8601&&(b="0000"==b.substring(1)?"Z":b.substring(0,3)+":"+b.substring(3));break;case 6:c.timezoneIso8601?"00:00"==b.substring(1)&&(b="Z"):b="Z"==b||"00:00"==b.substring(1)?"+0000":b.replace(/:/,"")}a.timezone=b}return a}return!1};d.datepicker.formatTime=function(b,a,c){var c=c||{},c=d.extend(d.timepicker._defaults,c),a=d.extend({hour:0,minute:0,second:0,millisec:0,timezone:"+0000"},a),e=c.amNames[0], f=parseInt(a.hour,10);c.ampm&&(11<f&&(e=c.pmNames[0],12<f&&(f%=12)),0===f&&(f=12));b=b.replace(/(?:hh?|mm?|ss?|[tT]{1,2}|[lz])/g,function(b){switch(b.toLowerCase()){case "hh":return("0"+f).slice(-2);case "h":return f;case "mm":return("0"+a.minute).slice(-2);case "m":return a.minute;case "ss":return("0"+a.second).slice(-2);case "s":return a.second;case "l":return("00"+a.millisec).slice(-3);case "z":return a.timezone;case "t":case "tt":if(c.ampm){b.length==1&&(e=e.charAt(0));return b.charAt(0)=="T"? e.toUpperCase():e.toLowerCase()}return""}});return b=d.trim(b)};d.datepicker._base_selectDate=d.datepicker._selectDate;d.datepicker._selectDate=function(b,a){var c=this._getInst(d(b)[0]),e=this._get(c,"timepicker");e?(e._limitMinMaxDateTime(c,!0),c.inline=c.stay_open=!0,this._base_selectDate(b,a),c.inline=c.stay_open=!1,this._notifyChange(c),this._updateDatepicker(c)):this._base_selectDate(b,a)};d.datepicker._base_updateDatepicker=d.datepicker._updateDatepicker;d.datepicker._updateDatepicker=function(b){var a= b.input[0];if(!d.datepicker._curInst||!(d.datepicker._curInst!=b&&d.datepicker._datepickerShowing&&d.datepicker._lastInput!=a))if("boolean"!==typeof b.stay_open||!1===b.stay_open)if(this._base_updateDatepicker(b),a=this._get(b,"timepicker"))a._addTimePicker(b),a._defaults.useLocalTimezone&&(t(a,new Date(b.selectedYear,b.selectedMonth,b.selectedDay,12)),a._onTimeChange())};d.datepicker._base_doKeyPress=d.datepicker._doKeyPress;d.datepicker._doKeyPress=function(b){var a=d.datepicker._getInst(b.target), c=d.datepicker._get(a,"timepicker");if(c&&d.datepicker._get(a,"constrainInput")){var e=c._defaults.ampm,a=d.datepicker._possibleChars(d.datepicker._get(a,"dateFormat")),c=c._defaults.timeFormat.toString().replace(/[hms]/g,"").replace(/TT/g,e?"APM":"").replace(/Tt/g,e?"AaPpMm":"").replace(/tT/g,e?"AaPpMm":"").replace(/T/g,e?"AP":"").replace(/tt/g,e?"apm":"").replace(/t/g,e?"ap":"")+" "+c._defaults.separator+c._defaults.timeSuffix+(c._defaults.showTimezone?c._defaults.timezoneList.join(""):"")+c._defaults.amNames.join("")+ c._defaults.pmNames.join("")+a,e=String.fromCharCode(void 0===b.charCode?b.keyCode:b.charCode);return b.ctrlKey||" ">e||!a||-1<c.indexOf(e)}return d.datepicker._base_doKeyPress(b)};d.datepicker._base_doKeyUp=d.datepicker._doKeyUp;d.datepicker._doKeyUp=function(b){var a=d.datepicker._getInst(b.target),c=d.datepicker._get(a,"timepicker");if(c&&c._defaults.timeOnly&&a.input.val()!=a.lastVal)try{d.datepicker._updateDatepicker(a)}catch(e){d.datepicker.log(e)}return d.datepicker._base_doKeyUp(b)};d.datepicker._base_gotoToday= d.datepicker._gotoToday;d.datepicker._gotoToday=function(b){var a=this._getInst(d(b)[0]),c=a.dpDiv;this._base_gotoToday(b);b=this._get(a,"timepicker");t(b);this._setTime(a,new Date);d(".ui-datepicker-today",c).click()};d.datepicker._disableTimepickerDatepicker=function(b){var a=this._getInst(b);if(a){var c=this._get(a,"timepicker");d(b).datepicker("getDate");c&&(c._defaults.showTimepicker=!1,c._updateDateTime(a))}};d.datepicker._enableTimepickerDatepicker=function(b){var a=this._getInst(b);if(a){var c= this._get(a,"timepicker");d(b).datepicker("getDate");c&&(c._defaults.showTimepicker=!0,c._addTimePicker(a),c._updateDateTime(a))}};d.datepicker._setTime=function(b,a){var c=this._get(b,"timepicker");if(c){var e=c._defaults,d=a?a.getHours():e.hour,g=a?a.getMinutes():e.minute,l=a?a.getSeconds():e.second,i=a?a.getMilliseconds():e.millisec,h=d===e.hourMin,m=g===e.minuteMin,q=l===e.secondMin,o=!1;if(d<e.hourMin||d>e.hourMax)o=!0;else if((g<e.minuteMin||g>e.minuteMax)&&h)o=!0;else if((l<e.secondMin||l> e.secondMax)&&h&&m)o=!0;else if((i<e.millisecMin||i>e.millisecMax)&&h&&m&&q)o=!0;o&&(d=e.hourMin,g=e.minuteMin,l=e.secondMin,i=e.millisecMin);c.hour=d;c.minute=g;c.second=l;c.millisec=i;c.hour_slider&&c.hour_slider.slider("value",d);c.minute_slider&&c.minute_slider.slider("value",g);c.second_slider&&c.second_slider.slider("value",l);c.millisec_slider&&c.millisec_slider.slider("value",i);c._onTimeChange();c._updateDateTime(b)}};d.datepicker._setTimeDatepicker=function(b,a,c){if(b=this._getInst(b)){var e= this._get(b,"timepicker");e&&(this._setDateFromField(b),a&&("string"==typeof a?(e._parseTime(a,c),a=new Date,a.setHours(e.hour,e.minute,e.second,e.millisec)):a=new Date(a.getTime()),"Invalid Date"==a.toString()&&(a=void 0),this._setTime(b,a)))}};d.datepicker._base_setDateDatepicker=d.datepicker._setDateDatepicker;d.datepicker._setDateDatepicker=function(b,a){var c=this._getInst(b);if(c){var e=a instanceof Date?new Date(a.getTime()):a;this._updateDatepicker(c);this._base_setDateDatepicker.apply(this, arguments);this._setTimeDatepicker(b,e,!0)}};d.datepicker._base_getDateDatepicker=d.datepicker._getDateDatepicker;d.datepicker._getDateDatepicker=function(b,a){var c=this._getInst(b);if(c){var e=this._get(c,"timepicker");return e?(this._setDateFromField(c,a),(c=this._getDate(c))&&e._parseTime(d(b).val(),e.timeOnly)&&c.setHours(e.hour,e.minute,e.second,e.millisec),c):this._base_getDateDatepicker(b,a)}};d.datepicker._base_parseDate=d.datepicker.parseDate;d.datepicker.parseDate=function(b,a,c){a=w(b, a,c);return d.datepicker._base_parseDate(b,a[0],c)};d.datepicker._base_formatDate=d.datepicker._formatDate;d.datepicker._formatDate=function(b){var a=this._get(b,"timepicker");return a?(a._updateDateTime(b),a.$input.val()):this._base_formatDate(b)};d.datepicker._base_optionDatepicker=d.datepicker._optionDatepicker;d.datepicker._optionDatepicker=function(b,a,c){var e=this._getInst(b);if(!e)return null;if(e=this._get(e,"timepicker")){var d=null,g=null,l=null;"string"==typeof a?"minDate"===a||"minDateTime"=== a?d=c:"maxDate"===a||"maxDateTime"===a?g=c:"onSelect"===a&&(l=c):"object"==typeof a&&(a.minDate?d=a.minDate:a.minDateTime?d=a.minDateTime:a.maxDate?g=a.maxDate:a.maxDateTime&&(g=a.maxDateTime));d?(d=0===d?new Date:new Date(d),e._defaults.minDate=d,e._defaults.minDateTime=d):g?(g=0===g?new Date:new Date(g),e._defaults.maxDate=g,e._defaults.maxDateTime=g):l&&(e._defaults.onSelect=l)}return void 0===c?this._base_optionDatepicker(b,a):this._base_optionDatepicker(b,a,c)};var w=function(b,a,c){try{d.datepicker._base_parseDate(b, a,c)}catch(e){if(0<=e.indexOf(":"))return b=a.length-(e.length-e.indexOf(":")-2),a.substring(b),[a.substring(0,b),a.substring(b)];throw e;}return[a,""]},u=function(b,a,c,e,f){c=w(b,c,e);b=d.datepicker._base_parseDate(b,c[0],e);if(""!==c[1]){e=c[1];c=f&&f.separator?f.separator:d.timepicker._defaults.separator;if(0!==e.indexOf(c))throw"Missing time separator";e=e.substring(c.length);a=d.datepicker.parseTime(a,e,f);if(null===a)throw"Wrong time format";return{date:b,timeObj:a}}return{date:b}},t=function(b, a){if(b&&b.timezone_select){b._defaults.useLocalTimezone=!0;var c=v("undefined"!==typeof a?a:new Date);b._defaults.timezoneIso8601&&(c=c.substring(0,3)+":"+c.substring(3));b.timezone_select.val(c)}},v=function(b){b=-10100*b.getTimezoneOffset()/60;return(0<=b?"+":"-")+Math.abs(b).toString().substr(1)};d.timepicker=new m;d.timepicker.version="1.0.1"}})(jQuery);