text: (function(factory){'use strict';if(typeof define==='function'&&define.amd)define(['jquery'],factory);else if(typeof exports==='object')factory(require('jquery'));else factory(jQuery)}(function($){'use strict';$.Zebra_DatePicker=function(element,options){this.version='1.9.12';var defaults={always_visible:!1,container:$('body'),current_date:!1,custom_classes:!1,days:['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],days_abbr:!1,default_position:'above',direction:0,disable_time_picker:!1,disabled_dates:!1,enabled_dates:!1,enabled_hours:!1,enabled_minutes:!1,enabled_seconds:!1,fast_navigation:!0,first_day_of_week:1,format:'Y-m-d',header_captions:{days:'F, Y',months:'Y',years:'Y1 - Y2'},icon_margin:!1,icon_position:'right',inside:!0,lang_clear_date:'Clear date',months:['January','February','March','April','May','June','July','August','September','October','November','December'],months_abbr:!1,navigation:['&#9664;','&#9654;','&#9650;','&#9660;'],offset:[5,-5],open_icon_only:!1,open_on_focus:!1,pair:!1,readonly_element:!0,rtl:!1,select_other_months:!1,show_clear_date:0,show_icon:!0,show_other_months:!0,show_select_today:'Today',show_week_number:!1,start_date:!1,strict:!1,view:'days',weekend_days:[0,6],zero_pad:!1,onChange:null,onClear:null,onOpen:null,onClose:null,onSelect:null},cleardate,clickables,confirm_selection,current_system_day,current_system_month,current_system_year,custom_class_names,custom_classes={},datepicker,daypicker,daypicker_cells,default_day,default_month,default_year,disabled_dates,enabled_dates,end_date,first_selectable_day,first_selectable_month,first_selectable_year,footer,header,icon,last_selectable_day,last_selectable_month,last_selectable_year,monthpicker,monthpicker_cells,original_attributes={},selected_hour,selected_minute,selected_second,selected_ampm,view_toggler,selected_month,selected_year,selecttoday,shim,show_select_today,start_date,timeout,timepicker,timepicker_config,touchmove=!1,uniqueid='',yearpicker,yearpicker_cells,view,views,is_touch=!1,is_iOS=!!navigator.platform&&/iPad|iPhone|iPod/.test(navigator.platform),plugin=this,$element=$(element),init=function(update){var
  date_chars={days:['d','j','D'],months:['F','m','M','n','t'],years:['o','Y','y'],hours:['G','g','H','h'],minutes:['i'],seconds:['s'],ampm:['A','a']},type=null,data,dates,k,l,format_is_valid=!1;for(k=0;k<3;k++)uniqueid+=Math.floor((1+Math.random())*0x10000).toString(16);disabled_dates=[];enabled_dates=[];if(!update){plugin.settings=$.extend({},defaults,$.fn.Zebra_DatePicker.defaults,options);original_attributes.readonly=$element.attr('readonly');original_attributes.style=$element.attr('style');original_attributes.padding_left=parseInt($element.css('paddingLeft'),10)||0;original_attributes.padding_right=parseInt($element.css('paddingRight'),10)||0;for(data in $element.data())
  if(data.indexOf('zdp_')===0){data=data.replace(/^zdp\_/,'');if(undefined!==defaults[data])
  plugin.settings[data]=(data==='pair'?$($element.data('zdp_'+data)):$element.data('zdp_'+data))}}
  if(plugin.settings.readonly_element)$element.attr('readonly','readonly');else $element.removeAttr('readonly');timepicker_config=!1;views=[];while(!format_is_valid){for(type in date_chars)
  $.each(date_chars[type],function(index,character){var i,max;if(plugin.settings.format.indexOf(character)>-1)
  if(type==='days')views.push('days');else if(type==='months')views.push('months');else if(type==='years')views.push('years');else if((type==='hours'||type==='minutes'||type==='seconds'||type==='ampm')&&!plugin.settings.disable_time_picker){if(!timepicker_config){timepicker_config={is12hour:!1};views.push('time')}
  if(type==='hours'){timepicker_config.hour_format=character;if(character==='g'||character==='h'){max=12;timepicker_config.is12hour=!0}else max=24;timepicker_config.hours=[];for(i=(max===12?1:0);i<(max===12?13:max);i++)
  if(!$.isArray(plugin.settings.enabled_hours)||$.inArray(i,plugin.settings.enabled_hours)>-1)timepicker_config.hours.push(i);}else if(type==='minutes'){timepicker_config.minutes=[];for(i=0;i<60;i++)
  if(!$.isArray(plugin.settings.enabled_minutes)||$.inArray(i,plugin.settings.enabled_minutes)>-1)timepicker_config.minutes.push(i);}else if(type==='seconds'){timepicker_config.seconds=[];for(i=0;i<60;i++)
  if(!$.isArray(plugin.settings.enabled_seconds)||$.inArray(i,plugin.settings.enabled_seconds)>-1)timepicker_config.seconds.push(i);}else timepicker_config.ampm=['am','pm']}});if(timepicker_config.hour_format&&timepicker_config.ampm&&timepicker_config.is12hour===!1)
  plugin.settings.format=plugin.settings.format.replace(timepicker_config.hour_format,timepicker_config.hour_format.toLowerCase());else format_is_valid=!0}
  if(views.length===0)views=['years','months','days'];if($.inArray(plugin.settings.view,views)===-1)plugin.settings.view=views[views.length-1];custom_class_names=[];for(k in plugin.settings.custom_classes)if(plugin.settings.custom_classes.hasOwnProperty(k)&&custom_class_names.indexOf(k)===-1)custom_class_names.push(k);for(l=0;l<2+custom_class_names.length;l++){if(l===0)dates=plugin.settings.disabled_dates;else if(l===1)dates=plugin.settings.enabled_dates;else dates=plugin.settings.custom_classes[custom_class_names[l-2]];if($.isArray(dates)&&dates.length>0)
  $.each(dates,function(){var rules=this.split(' '),i,j,k,limits;for(i=0;i<4;i++){if(!rules[i])rules[i]='*';rules[i]=(rules[i].indexOf(',')>-1?rules[i].split(','):new Array(rules[i]));for(j=0;j<rules[i].length;j++)
  if(rules[i][j].indexOf('-')>-1){limits=rules[i][j].match(/^([0-9]+)\-([0-9]+)/);if(null!==limits){for(k=to_int(limits[1]);k<=to_int(limits[2]);k++)
  if($.inArray(k,rules[i])===-1)rules[i].push(k+'');rules[i].splice(j,1)}}
  for(j=0;j<rules[i].length;j++)rules[i][j]=(isNaN(to_int(rules[i][j]))?rules[i][j]:to_int(rules[i][j]));}
  if(l===0)disabled_dates.push(rules);else if(l===1)enabled_dates.push(rules);else{if(undefined===custom_classes[custom_class_names[l-2]])custom_classes[custom_class_names[l-2]]=[];custom_classes[custom_class_names[l-2]].push(rules)}})}
  var date=plugin.settings.current_date!==!1?new Date(plugin.settings.current_date):new Date(),reference_date=(!plugin.settings.reference_date?($element.data('zdp_reference_date')&&undefined!==$element.data('zdp_reference_date')?$element.data('zdp_reference_date'):date):plugin.settings.reference_date),tmp_start_date,tmp_end_date;start_date=undefined;end_date=undefined;first_selectable_month=reference_date.getMonth();current_system_month=date.getMonth();first_selectable_year=reference_date.getFullYear();current_system_year=date.getFullYear();first_selectable_day=reference_date.getDate();current_system_day=date.getDate();if(plugin.settings.direction===!0)start_date=reference_date;else if(plugin.settings.direction===!1){end_date=reference_date;last_selectable_month=end_date.getMonth();last_selectable_year=end_date.getFullYear();last_selectable_day=end_date.getDate()}else if((!$.isArray(plugin.settings.direction)&&is_integer(plugin.settings.direction)&&to_int(plugin.settings.direction)>0)||($.isArray(plugin.settings.direction)&&((tmp_start_date=check_date(plugin.settings.direction[0]))||plugin.settings.direction[0]===!0||(is_integer(plugin.settings.direction[0])&&plugin.settings.direction[0]>0))&&((tmp_end_date=check_date(plugin.settings.direction[1]))||plugin.settings.direction[1]===!1||(is_integer(plugin.settings.direction[1])&&plugin.settings.direction[1]>=0)))){if(tmp_start_date)start_date=tmp_start_date;else start_date=new Date(first_selectable_year,first_selectable_month,first_selectable_day+(!$.isArray(plugin.settings.direction)?to_int(plugin.settings.direction):to_int(plugin.settings.direction[0]===!0?0:plugin.settings.direction[0])));first_selectable_month=start_date.getMonth();first_selectable_year=start_date.getFullYear();first_selectable_day=start_date.getDate();if(tmp_end_date&&+tmp_end_date>=+start_date)end_date=tmp_end_date;else if(!tmp_end_date&&plugin.settings.direction[1]!==!1&&$.isArray(plugin.settings.direction))
  end_date=new Date(first_selectable_year,first_selectable_month,first_selectable_day+to_int(plugin.settings.direction[1]));if(end_date){last_selectable_month=end_date.getMonth();last_selectable_year=end_date.getFullYear();last_selectable_day=end_date.getDate()}}else if((!$.isArray(plugin.settings.direction)&&is_integer(plugin.settings.direction)&&to_int(plugin.settings.direction)<0)||($.isArray(plugin.settings.direction)&&(plugin.settings.direction[0]===!1||(is_integer(plugin.settings.direction[0])&&plugin.settings.direction[0]<0))&&((tmp_start_date=check_date(plugin.settings.direction[1]))||(is_integer(plugin.settings.direction[1])&&plugin.settings.direction[1]>=0)))){end_date=new Date(first_selectable_year,first_selectable_month,first_selectable_day+(!$.isArray(plugin.settings.direction)?to_int(plugin.settings.direction):to_int(plugin.settings.direction[0]===!1?0:plugin.settings.direction[0])));last_selectable_month=end_date.getMonth();last_selectable_year=end_date.getFullYear();last_selectable_day=end_date.getDate();if(tmp_start_date&&+tmp_start_date<+end_date)start_date=tmp_start_date;else if(!tmp_start_date&&$.isArray(plugin.settings.direction))
  start_date=new Date(last_selectable_year,last_selectable_month,last_selectable_day-to_int(plugin.settings.direction[1]));if(start_date){first_selectable_month=start_date.getMonth();first_selectable_year=start_date.getFullYear();first_selectable_day=start_date.getDate()}}else if($.isArray(plugin.settings.disabled_dates)&&plugin.settings.disabled_dates.length>0)
  for(var interval in disabled_dates)
  if($.inArray('*',disabled_dates[interval][0])>-1&&$.inArray('*',disabled_dates[interval][1])>-1&&$.inArray('*',disabled_dates[interval][2])>-1&&$.inArray('*',disabled_dates[interval][3])>-1){var tmpDates=[];$.each(enabled_dates,function(){var rule=this;if(rule[2][0]!=='*')
  tmpDates.push(parseInt(rule[2][0]+(rule[1][0]==='*'?'12':str_pad(rule[1][0],2))+(rule[0][0]==='*'?(rule[1][0]==='*'?'31':new Date(rule[2][0],rule[1][0],0).getDate()):str_pad(rule[0][0],2)),10))});tmpDates.sort();if(tmpDates.length>0){var matches=(tmpDates[0]+'').match(/([0-9]{4})([0-9]{2})([0-9]{2})/);first_selectable_year=parseInt(matches[1],10);first_selectable_month=parseInt(matches[2],10)-1;first_selectable_day=parseInt(matches[3],10)}
  break}
  if(is_disabled(first_selectable_year,first_selectable_month,first_selectable_day)){while(is_disabled(first_selectable_year))
  if(!start_date){first_selectable_year--;first_selectable_month=11}else{first_selectable_year++;first_selectable_month=0}
  while(is_disabled(first_selectable_year,first_selectable_month)){if(!start_date){first_selectable_month--;first_selectable_day=new Date(first_selectable_year,first_selectable_month+1,0).getDate()}else{first_selectable_month++;first_selectable_day=1}
  if(first_selectable_month>11){first_selectable_year++;first_selectable_month=0;first_selectable_day=1}else if(first_selectable_month<0){first_selectable_year--;first_selectable_month=11;first_selectable_day=new Date(first_selectable_year,first_selectable_month+1,0).getDate()}}
  while(is_disabled(first_selectable_year,first_selectable_month,first_selectable_day)){if(!start_date)first_selectable_day--;else first_selectable_day++;date=new Date(first_selectable_year,first_selectable_month,first_selectable_day);first_selectable_year=date.getFullYear();first_selectable_month=date.getMonth();first_selectable_day=date.getDate()}
  date=new Date(first_selectable_year,first_selectable_month,first_selectable_day);first_selectable_year=date.getFullYear();first_selectable_month=date.getMonth();first_selectable_day=date.getDate()}
  if(plugin.settings.start_date&&typeof plugin.settings.start_date==='object'&&plugin.settings.start_date instanceof Date)
  plugin.settings.start_date=format(plugin.settings.start_date)
  var default_date=check_date($element.val()||(plugin.settings.start_date?plugin.settings.start_date:''));if(default_date&&plugin.settings.strict&&is_disabled(default_date.getFullYear(),default_date.getMonth(),default_date.getDate()))
  $element.val('');if(!update&&(undefined!==start_date||undefined!==default_date))
  update_dependent(undefined!==default_date?default_date:start_date);if(!(plugin.settings.always_visible instanceof jQuery)){if(!update){if(plugin.settings.show_icon){if(browser.name==='firefox'&&$element.is('input[type="text"]')&&$element.css('display')==='inline')$element.css('display','inline-block');var marginTop=parseInt($element.css('marginTop'),10)||0,marginRight=parseInt($element.css('marginRight'),10)||0,marginBottom=parseInt($element.css('marginBottom'),10)||0,marginLeft=parseInt($element.css('marginLeft'),10)||0,icon_wrapper=$('<span class="Zebra_DatePicker_Icon_Wrapper"></span>').css({display:$element.css('display'),position:$element.css('position')==='static'?'relative':$element.css('position'),float:$element.css('float'),top:$element.css('top'),right:$element.css('right'),bottom:$element.css('bottom'),left:$element.css('left'),marginTop:marginTop<0?marginTop:0,marginRight:marginRight<0?marginRight:0,marginBottom:marginBottom<0?marginBottom:0,marginLeft:marginLeft<0?marginLeft:0,paddingTop:marginTop,paddingRight:marginRight,paddingBottom:marginBottom,paddingLeft:marginLeft});if($element.css('display')==='block')icon_wrapper.css('width',$element.outerWidth(!0));$element.wrap(icon_wrapper).css({position:'relative',float:'none',top:'auto',right:'auto',bottom:'auto',left:'auto',marginTop:0,marginRight:0,marginBottom:0,marginLeft:0});icon=$('<button type="button" class="Zebra_DatePicker_Icon'+($element.attr('disabled')==='disabled'?' Zebra_DatePicker_Icon_Disabled':'')+'">Pick a date</button>');plugin.icon=icon;clickables=plugin.settings.open_icon_only?icon:icon.add($element)}else clickables=$element;clickables.on('click.Zebra_DatePicker_'+uniqueid+(plugin.settings.open_on_focus?' focus.Zebra_DatePicker_'+uniqueid:''),function(){if(datepicker.hasClass('dp_hidden')&&!$element.attr('disabled'))
  if(!(is_touch&&!plugin.settings.readonly_element))plugin.show();else{clearTimeout(timeout);timeout=setTimeout(function(){plugin.show()},600)}});clickables.on('keydown.Zebra_DatePicker_'+uniqueid,function(e){if(e.keyCode===9&&!datepicker.hasClass('dp_hidden'))
  plugin.hide()});if(!plugin.settings.readonly_element&&plugin.settings.pair)
  $element.on('blur.Zebra_DatePicker_'+uniqueid,function(){var date;if((date=check_date($(this).val()))&&!is_disabled(date.getFullYear(),date.getMonth(),date.getDate()))update_dependent(date)});if(undefined!==icon)icon.insertAfter($element)}
  if(undefined!==icon){icon.attr('style','');var element_width=$element.outerWidth(),element_height=$element.outerHeight(),icon_width=icon.outerWidth(),icon_height=icon.outerHeight();icon.css('top',(element_height-icon_height)/2);if(plugin.settings.inside)
  if(plugin.settings.icon_position==='right'){icon.css('right',plugin.settings.icon_margin!==!1?plugin.settings.icon_margin:original_attributes.padding_right);$element.css('paddingRight',((plugin.settings.icon_margin!==!1?plugin.settings.icon_margin:original_attributes.padding_right)*2)+icon_width)}else{icon.css('left',plugin.settings.icon_margin!==!1?plugin.settings.icon_margin:original_attributes.padding_left);$element.css('paddingLeft',((plugin.settings.icon_margin!==!1?plugin.settings.icon_margin:original_attributes.padding_left)*2)+icon_width)}
  else icon.css('left',element_width+(plugin.settings.icon_margin!==!1?plugin.settings.icon_margin:original_attributes.padding_left));icon.removeClass('Zebra_DatePicker_Icon_Disabled');if($element.attr('disabled')==='disabled')icon.addClass('Zebra_DatePicker_Icon_Disabled')}}
  show_select_today=(plugin.settings.show_select_today!==!1&&$.inArray('days',views)>-1&&!is_disabled(current_system_year,current_system_month,current_system_day)?plugin.settings.show_select_today:!1);if(update){$('.dp_previous',datepicker).html(plugin.settings.navigation[0]);$('.dp_next',datepicker).html(plugin.settings.navigation[1]);$('.dp_time_controls_increase .dp_time_control',datepicker).html(plugin.settings.navigation[2]);$('.dp_time_controls_decrease .dp_time_control',datepicker).html(plugin.settings.navigation[3]);$('.dp_clear',datepicker).html(plugin.settings.lang_clear_date);$('.dp_today',datepicker).html(plugin.settings.show_select_today);return}
  $(window).on('resize.Zebra_DatePicker_'+uniqueid+', orientationchange.Zebra_DatePicker_'+uniqueid,function(){plugin.hide()});var html=''+'<div class="Zebra_DatePicker">'+'<table class="dp_header dp_actions">'+'<tr>'+'<td class="dp_previous">'+plugin.settings.navigation[0]+(is_iOS?'&#xFE0E;':'')+'</td>'+'<td class="dp_caption"></td>'+'<td class="dp_next">'+plugin.settings.navigation[1]+(is_iOS?'&#xFE0E;':'')+'</td>'+'</tr>'+'</table>'+'<table class="dp_daypicker'+(plugin.settings.show_week_number?' dp_week_numbers':'')+' dp_body"></table>'+'<table class="dp_monthpicker dp_body"></table>'+'<table class="dp_yearpicker dp_body"></table>'+'<table class="dp_timepicker dp_body"></table>'+'<table class="dp_footer dp_actions"><tr>'+'<td class="dp_today">'+show_select_today+'</td>'+'<td class="dp_clear">'+plugin.settings.lang_clear_date+'</td>'+'<td class="dp_view_toggler dp_icon">&nbsp;&nbsp;&nbsp;&nbsp;</td>'+'<td class="dp_confirm dp_icon"></td>'+'</tr></table>'+'</div>';datepicker=$(html);header=$('table.dp_header',datepicker);daypicker=$('table.dp_daypicker',datepicker);monthpicker=$('table.dp_monthpicker',datepicker);yearpicker=$('table.dp_yearpicker',datepicker);timepicker=$('table.dp_timepicker',datepicker);footer=$('table.dp_footer',datepicker);selecttoday=$('td.dp_today',footer);cleardate=$('td.dp_clear',footer);view_toggler=$('td.dp_view_toggler',footer);confirm_selection=$('td.dp_confirm',footer);if(!(plugin.settings.always_visible instanceof jQuery))
  plugin.settings.container.append(datepicker);else if(!$element.attr('disabled')){plugin.settings.always_visible.append(datepicker);plugin.show()}
  datepicker.on('mouseover','td:not(.dp_disabled)',function(){$(this).addClass('dp_hover')}).on('mouseout','td:not(.dp_disabled)',function(){$(this).removeClass('dp_hover')});disable_text_select(datepicker);$(plugin.settings.rtl?'.dp_next':'.dp_previous',header).on('click',function(){if(view==='months')selected_year--;else if(view==='years')selected_year-=12;else if(--selected_month<0){selected_month=11;selected_year--}
  manage_views()});if(plugin.settings.fast_navigation)
  $('.dp_caption',header).on('click',function(){if(view==='days')view=($.inArray('months',views)>-1?'months':($.inArray('years',views)>-1?'years':'days'));else if(view==='months')view=($.inArray('years',views)>-1?'years':($.inArray('days',views)>-1?'days':'months'));else view=($.inArray('days',views)>-1?'days':($.inArray('months',views)>-1?'months':'years'));manage_views()});$(plugin.settings.rtl?'.dp_previous':'.dp_next',header).on('click',function(){if(view==='months')selected_year++;else if(view==='years')selected_year+=12;else if(++selected_month===12){selected_month=0;selected_year++}
  manage_views()});daypicker.on('click','td:not(.dp_disabled)',function(){var matches;if(plugin.settings.select_other_months&&$(this).attr('class')&&null!==(matches=$(this).attr('class').match(/date\_([0-9]{4})(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])/)))
  select_date(matches[1],matches[2]-1,matches[3],'days',$(this));else select_date(selected_year,selected_month,to_int($(this).html()),'days',$(this))});monthpicker.on('click','td:not(.dp_disabled)',function(){var matches=$(this).attr('class').match(/dp\_month\_([0-9]+)/);selected_month=to_int(matches[1]);if($.inArray('days',views)===-1)
  select_date(selected_year,selected_month,1,'months',$(this));else{view='days';if(plugin.settings.always_visible)$element.val('');manage_views()}});yearpicker.on('click','td:not(.dp_disabled)',function(){selected_year=to_int($(this).html());if($.inArray('months',views)===-1)
  select_date(selected_year,1,1,'years',$(this));else{view='months';if(plugin.settings.always_visible)$element.val('');manage_views()}});selecttoday.on('click',function(e){var date=plugin.settings.current_date!==!1?new Date(plugin.settings.current_date):new Date();e.preventDefault();select_date(date.getFullYear(),date.getMonth(),date.getDate(),'days',$('.dp_current',daypicker))});cleardate.on('click',function(e){e.preventDefault();$element.val('');default_day=null;default_month=null;default_year=null;if(!plugin.settings.always_visible){selected_month=null;selected_year=null}else $('td.dp_selected',datepicker).removeClass('dp_selected');$element.focus();plugin.hide();if(plugin.settings.onClear&&typeof plugin.settings.onClear==='function')
  plugin.settings.onClear.call($element)});view_toggler.on('click',function(){if(view!=='time'){view='time';manage_views()}else $('.dp_caption',header).trigger('click')});confirm_selection.on('click',function(){$('.dp_time_controls_increase td',timepicker).trigger('click');$('.dp_time_controls_decrease td',timepicker).trigger('click');if(plugin.settings.onSelect&&typeof plugin.settings.onSelect==='function'){var js_date=new Date(selected_year,selected_month,default_day,(timepicker_config&&timepicker_config.hours?selected_hour+(timepicker_config.ampm&&((selected_ampm==='pm'&&selected_hour<12)||(selected_ampm==='am'&&selected_hour===12))?12:0):0),(timepicker_config&&timepicker_config.minutes?selected_minute:0),(timepicker_config&&timepicker_config.seconds?selected_second:0));plugin.settings.onSelect.call($element,format(js_date),selected_year+'-'+str_pad(selected_month+1,2)+'-'+str_pad(default_day,2)+(timepicker_config?' '+str_pad(js_date.getHours(),2)+':'+str_pad(js_date.getMinutes(),2)+':'+str_pad(js_date.getSeconds(),2):''),js_date)}
  plugin.hide()});datepicker.on('click','.dp_time_controls_increase td, .dp_time_controls_decrease td',function(){var
  increase=$(this).parent('.dp_time_controls_increase').length>0,matches=$(this).attr('class').match(/dp\_time\_([^\s]+)/i),value_container=$('.dp_time_segments .dp_time_'+matches[1]+(matches[1]!=='ampm'?'s':''),timepicker),value=value_container.text().toLowerCase(),lookup=timepicker_config[matches[1]+(matches[1]!=='ampm'?'s':'')],current_value_position=$.inArray(matches[1]!=='ampm'?parseInt(value,10):value,lookup),next_value_position=current_value_position===-1?0:(increase?(current_value_position+1>=lookup.length?0:current_value_position+1):(current_value_position-1<0?lookup.length-1:current_value_position-1)),default_date;if(matches[1]==='hour')selected_hour=lookup[next_value_position];else if(matches[1]==='minute')selected_minute=lookup[next_value_position];else if(matches[1]==='second')selected_second=lookup[next_value_position];else selected_ampm=lookup[next_value_position];if(!default_day&&plugin.settings.start_date){default_date=check_date(plugin.settings.start_date);if(default_date)default_day=default_date.getDate()}
  if(!default_day)default_day=first_selectable_day;value_container.text(str_pad(lookup[next_value_position],2).toUpperCase());select_date(selected_year,selected_month,default_day)});if(!(plugin.settings.always_visible instanceof jQuery)){$(document).on('touchmove.Zebra_DatePicker_'+uniqueid,function(){touchmove=!0});$(document).on('mousedown.Zebra_DatePicker_'+uniqueid+' touchend.Zebra_DatePicker_'+uniqueid,function(e){if(e.type==='touchend'&&touchmove){is_touch=!0;return(touchmove=!1)}
  touchmove=!1;if(!datepicker.hasClass('dp_hidden')&&((plugin.settings.open_icon_only&&plugin.icon&&$(e.target).get(0)!==plugin.icon.get(0))||(!plugin.settings.open_icon_only&&$(e.target).get(0)!==$element.get(0)&&(!plugin.icon||$(e.target).get(0)!==plugin.icon.get(0))))&&$(e.target).parents().filter('.Zebra_DatePicker').length===0)plugin.hide(!0)});$(document).on('keyup.Zebra_DatePicker_'+uniqueid,function(e){if(!datepicker.hasClass('dp_hidden')&&e.which===27)plugin.hide()})}
  manage_views()},check_date=function(str_date){str_date+='';if($.trim(str_date)!==''){var
  format=escape_regexp(plugin.settings.format),format_chars=['d','D','j','l','N','S','w','F','m','M','n','Y','y','G','g','H','h','i','s','a','A'],matches=[],regexp=[],position=null,segments=null,date,i;for(i=0;i<format_chars.length;i++)
  if((position=format.indexOf(format_chars[i]))>-1)
  matches.push({character:format_chars[i],position:position});matches.sort(function(a,b){return a.position-b.position});$.each(matches,function(index,match){switch(match.character){case 'd':regexp.push('0[1-9]|[12][0-9]|3[01]');break;case 'D':regexp.push('[a-z]{3}');break;case 'j':regexp.push('[1-9]|[12][0-9]|3[01]');break;case 'l':regexp.push('[a-z\u00C0-\u024F]+');break;case 'N':regexp.push('[1-7]');break;case 'S':regexp.push('st|nd|rd|th');break;case 'w':regexp.push('[0-6]');break;case 'F':regexp.push('[a-z]+');break;case 'm':regexp.push('0[1-9]|1[012]');break;case 'M':regexp.push('[a-z]{3}');break;case 'n':regexp.push('[1-9]|1[012]');break;case 'Y':regexp.push('[0-9]{4}');break;case 'y':regexp.push('[0-9]{2}');break;case 'G':regexp.push('[1-9]|1[0-9]|2[0123]');break;case 'g':regexp.push('[0-9]|1[012]');break;case 'H':regexp.push('0[0-9]|1[0-9]|2[0123]');break;case 'h':regexp.push('0[0-9]|1[012]');break;case 'i':regexp.push('0[0-9]|[12345][0-9]');break;case 's':regexp.push('0[0-9]|[12345][0-9]');break;case 'a':regexp.push('am|pm');break;case 'A':regexp.push('AM|PM');break}});if(regexp.length){matches.reverse();$.each(matches,function(index,match){format=format.replace(match.character,'('+regexp[regexp.length-index-1]+')')});regexp=new RegExp('^'+format+'$','ig');if((segments=regexp.exec(str_date))){var tmpdate=new Date(),original_day=1,original_month=tmpdate.getMonth()+1,original_year=tmpdate.getFullYear(),original_hours=tmpdate.getHours(),original_minutes=tmpdate.getMinutes(),original_seconds=tmpdate.getSeconds(),original_ampm,english_days=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],english_months=['January','February','March','April','May','June','July','August','September','October','November','December'],iterable,valid=!0;matches.reverse();$.each(matches,function(index,match){if(!valid)return!0;switch(match.character){case 'm':case 'n':original_month=to_int(segments[index+1]);break;case 'd':case 'j':original_day=to_int(segments[index+1]);break;case 'D':case 'l':case 'F':case 'M':if(match.character==='D'||match.character==='l')iterable=plugin.settings.days;else iterable=plugin.settings.months;valid=!1;$.each(iterable,function(key,value){if(valid)return!0;if(segments[index+1].toLowerCase()===value.substring(0,(match.character==='D'||match.character==='M'?3:value.length)).toLowerCase()){switch(match.character){case 'D':segments[index+1]=english_days[key].substring(0,3);break;case 'l':segments[index+1]=english_days[key];break;case 'F':segments[index+1]=english_months[key];original_month=key+1;break;case 'M':segments[index+1]=english_months[key].substring(0,3);original_month=key+1;break}
  valid=!0}});break;case 'Y':original_year=to_int(segments[index+1]);break;case 'y':original_year='19'+to_int(segments[index+1]);break;case 'G':case 'H':case 'g':case 'h':original_hours=to_int(segments[index+1]);break;case 'i':original_minutes=to_int(segments[index+1]);break;case 's':original_seconds=to_int(segments[index+1]);break;case 'a':case 'A':original_ampm=segments[index+1].toLowerCase();break}});if(valid){date=new Date(original_year,(original_month||1)-1,original_day||1,original_hours+(original_ampm==='pm'&&original_hours!==12?12:(original_ampm==='am'&&original_hours===12?-12:0)),original_minutes,original_seconds);if(date.getFullYear()===original_year&&date.getDate()===(original_day||1)&&date.getMonth()===((original_month||1)-1))
  return date}}}
  return!1}},disable_text_select=function(el){if(browser.name==='firefox')el.css('MozUserSelect','none');else if(browser.name==='explorer')$(document).on('selectstart',el,function(){return!1});else el.mousedown(function(){return!1})},escape_regexp=function(str){return str.replace(/([-.,*+?^${}()|[\]\/\\])/g,'\\$1')},format=function(date){var result='',j=date.getDate(),w=date.getDay(),l=plugin.settings.days[w],n=date.getMonth()+1,f=plugin.settings.months[n-1],y=date.getFullYear()+'',h=date.getHours(),h12=h%12===0?12:h%12,m=date.getMinutes(),s=date.getSeconds(),a=(h>=12?'pm':'am'),i,chr;for(i=0;i<plugin.settings.format.length;i++){chr=plugin.settings.format.charAt(i);switch(chr){case 'y':y=y.substr(2);case 'Y':result+=y;break;case 'm':n=str_pad(n,2);case 'n':result+=n;break;case 'M':f=($.isArray(plugin.settings.months_abbr)&&undefined!==plugin.settings.months_abbr[n-1]?plugin.settings.months_abbr[n-1]:plugin.settings.months[n-1].substr(0,3));case 'F':result+=f;break;case 'd':j=str_pad(j,2);case 'j':result+=j;break;case 'D':l=($.isArray(plugin.settings.days_abbr)&&undefined!==plugin.settings.days_abbr[w]?plugin.settings.days_abbr[w]:plugin.settings.days[w].substr(0,3));case 'l':result+=l;break;case 'N':w++;case 'w':result+=w;break;case 'S':if(j%10===1&&j!=='11')result+='st';else if(j%10===2&&j!=='12')result+='nd';else if(j%10===3&&j!=='13')result+='rd';else result+='th';break;case 'g':result+=h12;break;case 'h':result+=str_pad(h12,2);break;case 'G':result+=h;break;case 'H':result+=str_pad(h,2);break;case 'i':result+=str_pad(m,2);break;case 's':result+=str_pad(s,2);break;case 'a':result+=a;break;case 'A':result+=a.toUpperCase();break;default:result+=chr}}
  return result},generate_daypicker=function(){var
  days_in_month=new Date(selected_year,selected_month+1,0).getDate(),first_day=new Date(selected_year,selected_month,1).getDay(),days_in_previous_month=new Date(selected_year,selected_month,0).getDate(),days_from_previous_month=first_day-plugin.settings.first_day_of_week,i,html,day,real_date,real_year,real_month,real_day,weekday,class_name,custom_class_name,is_weekend,rtl_offset;days_from_previous_month=days_from_previous_month<0?7+days_from_previous_month:days_from_previous_month;manage_header(plugin.settings.header_captions.days);html='<tr>';if(plugin.settings.show_week_number)
  html+='<th>'+plugin.settings.show_week_number+'</th>';for(i=0;i<7;i++){day=(plugin.settings.first_day_of_week+(plugin.settings.rtl?6-i:i))%7;html+='<th>'+($.isArray(plugin.settings.days_abbr)&&undefined!==plugin.settings.days_abbr[day]?plugin.settings.days_abbr[day]:plugin.settings.days[day].substr(0,2))+'</th>'}
  html+='</tr><tr>';for(i=0;i<42;i++){rtl_offset=(plugin.settings.rtl?6-((i%7)*2):0);if(i>0&&i%7===0)html+='</tr><tr>';if(i%7===0&&plugin.settings.show_week_number)
  html+='<th>'+get_week_number(new Date(selected_year,selected_month,(i-days_from_previous_month+1)))+'</th>';day=rtl_offset+(i-days_from_previous_month+1);if(plugin.settings.select_other_months&&(i<days_from_previous_month||day>days_in_month)){real_date=new Date(selected_year,selected_month,day);real_year=real_date.getFullYear();real_month=real_date.getMonth();real_day=real_date.getDate();real_date=real_year+str_pad(real_month+1,2)+str_pad(real_day,2)}
  weekday=(plugin.settings.first_day_of_week+i)%7;is_weekend=($.inArray(weekday,plugin.settings.weekend_days)>-1);if((plugin.settings.rtl&&day<1)||(!plugin.settings.rtl&&i<days_from_previous_month))
  html+='<td class="dp_not_in_month '+(is_weekend?'dp_weekend ':'')+(plugin.settings.select_other_months&&!is_disabled(real_year,real_month,real_day)?'date_'+real_date:'dp_disabled')+'">'+(plugin.settings.select_other_months||plugin.settings.show_other_months?str_pad(rtl_offset+days_in_previous_month-days_from_previous_month+i+1,plugin.settings.zero_pad?2:0):'&nbsp;')+'</td>';else if(day>days_in_month)
  html+='<td class="dp_not_in_month '+(is_weekend?'dp_weekend ':'')+(plugin.settings.select_other_months&&!is_disabled(real_year,real_month,real_day)?'date_'+real_date:'dp_disabled')+'">'+(plugin.settings.select_other_months||plugin.settings.show_other_months?str_pad(day-days_in_month,plugin.settings.zero_pad?2:0):'&nbsp;')+'</td>';else{class_name='';custom_class_name=get_custom_class(selected_year,selected_month,day);if(is_weekend)class_name=' dp_weekend';if(selected_month===current_system_month&&selected_year===current_system_year&&current_system_day===day)class_name+=' dp_current';if(custom_class_name!=='')class_name+=' '+custom_class_name;if(selected_month===default_month&&selected_year===default_year&&default_day===day)class_name+=' dp_selected';if(is_disabled(selected_year,selected_month,day))class_name+=' dp_disabled';html+='<td'+(class_name!==''?' class="'+$.trim(class_name)+'"':'')+'>'+((plugin.settings.zero_pad?str_pad(day,2):day)||'&nbsp;')+'</td>'}}
  html+='</tr>';daypicker.html($(html));if(plugin.settings.always_visible)
  daypicker_cells=$('td:not(.dp_disabled)',daypicker);daypicker.show()},generate_monthpicker=function(){manage_header(plugin.settings.header_captions.months);var html='<tr>',i,class_name,month;for(i=0;i<12;i++){if(i>0&&i%3===0)html+='</tr><tr>';month=plugin.settings.rtl?2+i-(2*(i%3)):i;class_name='dp_month_'+month;if(is_disabled(selected_year,month))class_name+=' dp_disabled';else if(default_month!==!1&&default_month===month&&selected_year===default_year)class_name+=' dp_selected';else if(current_system_month===month&&current_system_year===selected_year)class_name+=' dp_current';html+='<td class="'+$.trim(class_name)+'">'+($.isArray(plugin.settings.months_abbr)&&undefined!==plugin.settings.months_abbr[month]?plugin.settings.months_abbr[month]:plugin.settings.months[month].substr(0,3))+'</td>'}
  html+='</tr>';monthpicker.html($(html));if(plugin.settings.always_visible)
  monthpicker_cells=$('td:not(.dp_disabled)',monthpicker);monthpicker.show()},generate_timepicker=function(){var html,condensed=(timepicker_config.hours&&timepicker_config.minutes&&timepicker_config.seconds&&timepicker_config.ampm);html='<tr class="dp_time_controls_increase'+(condensed?' dp_time_controls_condensed':'')+'">'+(plugin.settings.rtl&&timepicker_config.ampm?'<td class="dp_time_ampm dp_time_control">'+plugin.settings.navigation[2]+'</td>':'')+(timepicker_config.hours?'<td class="dp_time_hour dp_time_control">'+plugin.settings.navigation[2]+'</td>':'')+(timepicker_config.minutes?'<td class="dp_time_minute dp_time_control">'+plugin.settings.navigation[2]+'</td>':'')+(timepicker_config.seconds?'<td class="dp_time_second dp_time_control">'+plugin.settings.navigation[2]+'</td>':'')+(!plugin.settings.rtl&&timepicker_config.ampm?'<td class="dp_time_ampm dp_time_control">'+plugin.settings.navigation[2]+'</td>':'')+'</tr>';html+='<tr class="dp_time_segments'+(condensed?' dp_time_controls_condensed':'')+'">';if(plugin.settings.rtl&&timepicker_config.ampm)html+='<td class="dp_time_ampm dp_disabled'+(timepicker_config.hours||timepicker_config.minutes||timepicker_config.seconds?' dp_time_separator':'')+'"><div>'+selected_ampm.toUpperCase()+'</div></td>';if(timepicker_config.hours)html+='<td class="dp_time_hours dp_disabled'+(timepicker_config.minutes||timepicker_config.seconds||(!plugin.settings.rtl&&timepicker_config.ampm)?' dp_time_separator':'')+'"><div>'+(timepicker_config.hour_format==='h'||timepicker_config.hour_format==='H'?str_pad(selected_hour,2):selected_hour)+'</div></td>';if(timepicker_config.minutes)html+='<td class="dp_time_minutes dp_disabled'+(timepicker_config.seconds||(!plugin.settings.rtl&&timepicker_config.ampm)?' dp_time_separator':'')+'"><div>'+str_pad(selected_minute,2)+'</div></td>';if(timepicker_config.seconds)html+='<td class="dp_time_seconds dp_disabled'+(!plugin.settings.rtl&&timepicker_config.ampm?' dp_time_separator':'')+'"><div>'+str_pad(selected_second,2)+'</div></td>';if(!plugin.settings.rtl&&timepicker_config.ampm)html+='<td class="dp_time_ampm dp_disabled">'+selected_ampm.toUpperCase()+'</td>';html+='</tr>';html+='<tr class="dp_time_controls_decrease'+(condensed?' dp_time_controls_condensed':'')+'">'+(plugin.settings.rtl&&timepicker_config.ampm?'<td class="dp_time_ampm dp_time_control">'+plugin.settings.navigation[3]+'</td>':'')+(timepicker_config.hours?'<td class="dp_time_hour dp_time_control">'+plugin.settings.navigation[3]+'</td>':'')+(timepicker_config.minutes?'<td class="dp_time_minute dp_time_control">'+plugin.settings.navigation[3]+'</td>':'')+(timepicker_config.seconds?'<td class="dp_time_second dp_time_control">'+plugin.settings.navigation[3]+'</td>':'')+(!plugin.settings.rtl&&timepicker_config.ampm?'<td class="dp_time_ampm dp_time_control">'+plugin.settings.navigation[3]+'</td>':'')+'</tr>';timepicker.html($(html));timepicker.show()},generate_yearpicker=function(){manage_header(plugin.settings.header_captions.years);var html='<tr>',i,class_name,year;for(i=0;i<12;i++){if(i>0&&i%3===0)html+='</tr><tr>';year=plugin.settings.rtl?2+i-(2*(i%3)):i;class_name='';if(is_disabled(selected_year-7+year))class_name+=' dp_disabled';else if(default_year&&default_year===selected_year-7+year)class_name+=' dp_selected';else if(current_system_year===(selected_year-7+year))class_name+=' dp_current';html+='<td'+($.trim(class_name)!==''?' class="'+$.trim(class_name)+'"':'')+'>'+(selected_year-7+year)+'</td>'}
  html+='</tr>';yearpicker.html($(html));if(plugin.settings.always_visible)
  yearpicker_cells=$('td:not(.dp_disabled)',yearpicker);yearpicker.show()},get_custom_class=function(year,month,day){var class_name,i,found;if(typeof month!=='undefined')month=month+1;for(i in custom_class_names){class_name=custom_class_names[i];found=!1;if($.isArray(custom_classes[class_name]))
  $.each(custom_classes[class_name],function(){if(found)return;var rule=this,weekday;if($.inArray(year,rule[2])>-1||$.inArray('*',rule[2])>-1)
  if((typeof month!=='undefined'&&$.inArray(month,rule[1])>-1)||$.inArray('*',rule[1])>-1)
  if((typeof day!=='undefined'&&$.inArray(day,rule[0])>-1)||$.inArray('*',rule[0])>-1){if($.inArray('*',rule[3])>-1)return(found=class_name);weekday=new Date(year,month-1,day).getDay();if($.inArray(weekday,rule[3])>-1)return(found=class_name)}});if(found)return found}
  return found||''},get_week_number=function(date){var y=date.getFullYear(),m=date.getMonth()+1,d=date.getDate(),a,b,c,s,e,f,g,n,w;if(m<3){a=y-1;b=(a/4|0)-(a/100|0)+(a/400|0);c=((a-1)/4|0)-((a-1)/100|0)+((a-1)/400|0);s=b-c;e=0;f=d-1+31*(m-1)}else{a=y;b=(a/4|0)-(a/100|0)+(a/400|0);c=((a-1)/4|0)-((a-1)/100|0)+((a-1)/400|0);s=b-c;e=s+1;f=d+((153*(m-3)+2)/5|0)+58+s}
  g=(a+b)%7;d=(f+g-e)%7;n=f+3-d;if(n<0)w=53-((g-s)/5|0);else if(n>364+s)w=1;else w=(n/7|0)+1;return w},iframeShim=function(action){var zIndex,offset;if(browser.name==='explorer'&&browser.version===6){if(!shim){zIndex=to_int(datepicker.css('zIndex'))-1;shim=$('<iframe>',{src:'javascript:document.write("")',scrolling:'no',frameborder:0,css:{zIndex:zIndex,position:'absolute',top:-1000,left:-1000,width:datepicker.outerWidth(),height:datepicker.outerHeight(),filter:'progid:DXImageTransform.Microsoft.Alpha(opacity=0)',display:'none'}});$('body').append(shim)}
  switch(action){case 'hide':shim.hide();break;default:offset=datepicker.offset();shim.css({top:offset.top,left:offset.left,display:'block'})}}},is_disabled=function(year,month,day){var now,len,disabled,enabled;if((undefined===year||isNaN(year))&&(undefined===month||isNaN(month))&&(undefined===day||isNaN(day)))return!1;else if(year<1000)return!0;if(!(!$.isArray(plugin.settings.direction)&&to_int(plugin.settings.direction)===0)){now=to_int(str_concat(year,(typeof month!=='undefined'?str_pad(month,2):''),(typeof day!=='undefined'?str_pad(day,2):'')));len=(now+'').length;if(len===8&&((typeof start_date!=='undefined'&&now<to_int(str_concat(first_selectable_year,str_pad(first_selectable_month,2),str_pad(first_selectable_day,2))))||(typeof end_date!=='undefined'&&now>to_int(str_concat(last_selectable_year,str_pad(last_selectable_month,2),str_pad(last_selectable_day,2))))))return!0;else if(len===6&&((typeof start_date!=='undefined'&&now<to_int(str_concat(first_selectable_year,str_pad(first_selectable_month,2))))||(typeof end_date!=='undefined'&&now>to_int(str_concat(last_selectable_year,str_pad(last_selectable_month,2))))))return!0;else if(len===4&&((typeof start_date!=='undefined'&&now<first_selectable_year)||(typeof end_date!=='undefined'&&now>last_selectable_year)))return!0}
  if(typeof month!=='undefined')month=month+1;disabled=!1;enabled=!1;if($.isArray(disabled_dates)&&disabled_dates.length)
  $.each(disabled_dates,function(){if(disabled)return;var rule=this,weekday;if($.inArray(year,rule[2])>-1||$.inArray('*',rule[2])>-1)
  if((typeof month!=='undefined'&&$.inArray(month,rule[1])>-1)||$.inArray('*',rule[1])>-1)
  if((typeof day!=='undefined'&&$.inArray(day,rule[0])>-1)||$.inArray('*',rule[0])>-1){if($.inArray('*',rule[3])>-1)return(disabled=!0);weekday=new Date(year,month-1,day).getDay();if($.inArray(weekday,rule[3])>-1)return(disabled=!0)}});if(enabled_dates)
  $.each(enabled_dates,function(){if(enabled)return;var rule=this,weekday;if($.inArray(year,rule[2])>-1||$.inArray('*',rule[2])>-1){enabled=!0;if(typeof month!=='undefined'){enabled=!0;if($.inArray(month,rule[1])>-1||$.inArray('*',rule[1])>-1){if(typeof day!=='undefined'){enabled=!0;if($.inArray(day,rule[0])>-1||$.inArray('*',rule[0])>-1){if($.inArray('*',rule[3])>-1)return(enabled=!0);weekday=new Date(year,month-1,day).getDay();if($.inArray(weekday,rule[3])>-1)return(enabled=!0);enabled=!1}else enabled=!1}}else enabled=!1}}});if(enabled_dates&&enabled)return!1;else if(disabled_dates&&disabled)return!0;return!1},is_integer=function(value){return(value+'').match(/^\-?[0-9]+$/)},manage_header=function(caption){if(!isNaN(parseFloat(selected_month))&&isFinite(selected_month))
  caption=caption.replace(/\bm\b|\bn\b|\bF\b|\bM\b/,function(match){switch(match){case 'm':return str_pad(selected_month+1,2);case 'n':return selected_month+1;case 'F':return plugin.settings.months[selected_month];case 'M':return($.isArray(plugin.settings.months_abbr)&&undefined!==plugin.settings.months_abbr[selected_month]?plugin.settings.months_abbr[selected_month]:plugin.settings.months[selected_month].substr(0,3));default:return match}});if(!isNaN(parseFloat(selected_year))&&isFinite(selected_year))
  caption=caption.replace(/\bY\b/,selected_year).replace(/\by\b/,(selected_year+'').substr(2)).replace(/\bY1\b/i,selected_year-7).replace(/\bY2\b/i,selected_year+4);$('.dp_caption',header).html(caption)},manage_views=function(){var height,elements;if(daypicker.text()===''||view==='days'){if(daypicker.text()===''){if(!(plugin.settings.always_visible instanceof jQuery))
  datepicker.css('left',-1000);datepicker.removeClass('hidden');generate_daypicker();if(typeof daypicker[0].getBoundingClientRect!=='undefined'&&typeof daypicker[0].getBoundingClientRect().height!=='undefined')height=daypicker[0].getBoundingClientRect().height;else height=daypicker.outerHeight(!0);monthpicker.css('height',height);yearpicker.css('height',height);timepicker.css('height',height+header.outerHeight(!0));datepicker.css('width',datepicker.outerWidth());datepicker.addClass('dp_hidden')}else generate_daypicker();header.show();monthpicker.hide();yearpicker.hide();timepicker.hide();view_toggler.hide();confirm_selection.hide();if(timepicker_config)view_toggler.show().removeClass('dp_calendar')}else if(view==='months'){generate_monthpicker();daypicker.hide();yearpicker.hide();timepicker.hide();view_toggler.hide();confirm_selection.hide()}else if(view==='years'){generate_yearpicker();daypicker.hide();monthpicker.hide();timepicker.hide();view_toggler.hide();confirm_selection.hide()}else if(view==='time'){generate_timepicker();if(views.length===1){view_toggler.hide();confirm_selection.show()}else{view_toggler.show().addClass('dp_calendar');if($element.val()==='')confirm_selection.hide();else confirm_selection.show()}
  header.hide();daypicker.hide();monthpicker.hide();yearpicker.hide()}
  if(view!=='time'&&plugin.settings.onChange&&typeof plugin.settings.onChange==='function'&&undefined!==view){elements=(view==='days'?daypicker.find('td:not(.dp_disabled)'):(view==='months'?monthpicker.find('td:not(.dp_disabled)'):yearpicker.find('td:not(.dp_disabled)')));elements.each(function(){var matches;if(view==='days')
  if($(this).hasClass('dp_not_in_month')&&!$(this).hasClass('dp_disabled')){matches=$(this).attr('class').match(/date\_([0-9]{4})(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])/);$(this).data('date',matches[1]+'-'+matches[2]+'-'+matches[3])}else $(this).data('date',selected_year+'-'+str_pad(selected_month+1,2)+'-'+str_pad(to_int($(this).text()),2));else if(view==='months'){matches=$(this).attr('class').match(/dp\_month\_([0-9]+)/);$(this).data('date',selected_year+'-'+str_pad(to_int(matches[1])+1,2))}else $(this).data('date',to_int($(this).text()))});plugin.settings.onChange.call($element,view,elements)}
  footer.show();if(view==='time'&&views.length>1){selecttoday.hide();cleardate.hide();view_toggler.css('width',$element.val()===''?'100%':'50%')}else{selecttoday.show();cleardate.show();if(plugin.settings.show_clear_date===!0||(plugin.settings.show_clear_date===0&&$element.val()!=='')||(plugin.settings.always_visible&&plugin.settings.show_clear_date!==!1))
  if(show_select_today){selecttoday.css('width','50%');cleardate.css('width','50%')}else{selecttoday.hide();cleardate.css('width',$.inArray(views,'time')>-1?'50%':'100%')}
  else{cleardate.hide();if(show_select_today)selecttoday.css('width','100%');else{selecttoday.hide();if(!timepicker_config||(view!=='time'&&view!=='days'))footer.hide()}}}},select_date=function(year,month,day,rview,cell){var
  default_date=new Date(year,month,day,(timepicker_config&&timepicker_config.hours?selected_hour+(timepicker_config.ampm?(selected_ampm==='pm'&&selected_hour!==12?12:(selected_ampm==='am'&&selected_hour===12?-12:0)):0):12),(timepicker_config&&timepicker_config.minutes?selected_minute:0),(timepicker_config&&timepicker_config.seconds?selected_second:0)),view_cells=(rview==='days'?daypicker_cells:(rview==='months'?monthpicker_cells:yearpicker_cells)),selected_value=format(default_date);$element.val(selected_value);if(plugin.settings.always_visible||timepicker_config){default_month=default_date.getMonth();selected_month=default_date.getMonth();default_year=default_date.getFullYear();selected_year=default_date.getFullYear();default_day=default_date.getDate();if(cell&&view_cells){view_cells.removeClass('dp_selected');cell.addClass('dp_selected');if(rview==='days'&&cell.hasClass('dp_not_in_month')&&!cell.hasClass('dp_disabled'))plugin.show()}}
  if(timepicker_config){view='time';manage_views()}else{$element.focus();plugin.hide()}
  update_dependent(default_date);if(!timepicker_config&&plugin.settings.onSelect&&typeof plugin.settings.onSelect==='function')
  plugin.settings.onSelect.call($element,selected_value,year+'-'+str_pad(month+1,2)+'-'+str_pad(day,2),default_date)},str_concat=function(){var str='',i;for(i=0;i<arguments.length;i++)str+=(arguments[i]+'');return str},str_pad=function(str,len){str+='';while(str.length<len)str='0'+str;return str},to_int=function(str){return parseInt(str,10)},update_dependent=function(date){if(plugin.settings.pair)
  $.each(plugin.settings.pair,function(){var $pair=$(this),dp;if(!($pair.data&&$pair.data('Zebra_DatePicker')))
  $pair.data('zdp_reference_date',date);else{dp=$pair.data('Zebra_DatePicker');dp.update({reference_date:date,direction:dp.settings.direction===0?1:dp.settings.direction});if(dp.settings.always_visible)dp.show()}})},browser={init:function(){this.name=this.searchString(this.dataBrowser)||'';this.version=this.searchVersion(navigator.userAgent)||this.searchVersion(navigator.appVersion)||''},searchString:function(data){var i,dataString,dataProp;for(i=0;i<data.length;i++){dataString=data[i].string;dataProp=data[i].prop;this.versionSearchString=data[i].versionSearch||data[i].identity;if(dataString){if(dataString.indexOf(data[i].subString)!==-1)
  return data[i].identity}else if(dataProp)
  return data[i].identity}},searchVersion:function(dataString){var index=dataString.indexOf(this.versionSearchString);if(index===-1)return;return parseFloat(dataString.substring(index+this.versionSearchString.length+1))},dataBrowser:[{string:navigator.userAgent,subString:'Firefox',identity:'firefox'},{string:navigator.userAgent,subString:'MSIE',identity:'explorer',versionSearch:'MSIE'}]};plugin.settings={};plugin.clear_date=function(){$(cleardate).trigger('click')};plugin.destroy=function(){if(undefined!==plugin.icon){plugin.icon.off('click.Zebra_DatePicker_'+uniqueid);plugin.icon.off('focus.Zebra_DatePicker_'+uniqueid);plugin.icon.off('keydown.Zebra_DatePicker_'+uniqueid);plugin.icon.remove()}
  datepicker.off();datepicker.remove();if(plugin.settings.show_icon&&!(plugin.settings.always_visible instanceof jQuery))$element.unwrap();$element.off('blur.Zebra_DatePicker_'+uniqueid);$element.off('click.Zebra_DatePicker_'+uniqueid);$element.off('focus.Zebra_DatePicker_'+uniqueid);$element.off('keydown.Zebra_DatePicker_'+uniqueid);$element.off('mousedown.Zebra_DatePicker_'+uniqueid);$(document).off('keyup.Zebra_DatePicker_'+uniqueid);$(document).off('mousedown.Zebra_DatePicker_'+uniqueid);$(document).off('touchend.Zebra_DatePicker_'+uniqueid);$(window).off('resize.Zebra_DatePicker_'+uniqueid);$(window).off('orientationchange.Zebra_DatePicker_'+uniqueid);$element.removeData('Zebra_DatePicker');$element.attr('readonly',original_attributes.readonly);$element.attr('style',original_attributes.style?original_attributes.style:'');$element.css('paddingLeft',original_attributes.padding_left);$element.css('paddingRight',original_attributes.padding_right)};plugin.hide=function(outside){if(!datepicker.hasClass('dp_hidden')&&(!plugin.settings.always_visible||outside)){iframeShim('hide');datepicker.addClass('dp_hidden');if(plugin.settings.onClose&&typeof plugin.settings.onClose==='function')
  plugin.settings.onClose.call($element)}};plugin.set_date=function(date){var dateObj;if(typeof date==='object'&&date instanceof Date)date=format(date);$element.val(date);update_dependent(dateObj)};plugin.show=function(){view=plugin.settings.view;var default_date=check_date($element.val()||(plugin.settings.start_date?plugin.settings.start_date:'')),current_date;if(default_date){default_month=default_date.getMonth();selected_month=default_date.getMonth();default_year=default_date.getFullYear();selected_year=default_date.getFullYear();default_day=default_date.getDate();if(is_disabled(default_year,default_month,default_day)){if(plugin.settings.strict)$element.val('');selected_month=first_selectable_month;selected_year=first_selectable_year}}else{selected_month=first_selectable_month;selected_year=first_selectable_year}
  if(timepicker_config){if(default_date)current_date=default_date;else current_date=new Date();selected_hour=current_date.getHours();selected_minute=current_date.getMinutes();selected_second=current_date.getSeconds();selected_ampm=(selected_hour>=12?'pm':'am');if(timepicker_config.is12hour)
  selected_hour=(selected_hour%12===0?12:selected_hour%12);if($.isArray(plugin.settings.enabled_hours)&&$.inArray(selected_hour,plugin.settings.enabled_hours)===-1)selected_hour=plugin.settings.enabled_hours[0];if($.isArray(plugin.settings.enabled_minutes)&&$.inArray(selected_minute,plugin.settings.enabled_minutes)===-1)selected_minute=plugin.settings.enabled_minutes[0];if($.isArray(plugin.settings.enabled_seconds)&&$.inArray(selected_second,plugin.settings.enabled_seconds)===-1)selected_second=plugin.settings.enabled_seconds[0]}
  manage_views();if(!(plugin.settings.always_visible instanceof jQuery)){if(plugin.settings.container.is('body')){var
  datepicker_width=datepicker.outerWidth(),datepicker_height=datepicker.outerHeight(),left=(undefined!==icon?icon.offset().left+icon.outerWidth(!0):$element.offset().left+$element.outerWidth(!0))+plugin.settings.offset[0],top=(undefined!==icon?icon.offset().top:$element.offset().top)-datepicker_height+plugin.settings.offset[1],window_width=$(window).width(),window_height=$(window).height(),window_scroll_top=$(window).scrollTop(),window_scroll_left=$(window).scrollLeft();if(plugin.settings.default_position==='below')
  top=(undefined!==icon?icon.offset().top:$element.offset().top)+plugin.settings.offset[1];if(left+datepicker_width>window_scroll_left+window_width)left=window_scroll_left+window_width-datepicker_width;if(left<window_scroll_left)left=window_scroll_left;if(top+datepicker_height>window_scroll_top+window_height)top=window_scroll_top+window_height-datepicker_height;if(top<window_scroll_top)top=window_scroll_top;datepicker.css({left:left,top:top})}else datepicker.css({left:0,top:0});datepicker.removeClass('dp_hidden');iframeShim()}else datepicker.removeClass('dp_hidden');if(plugin.settings.onOpen&&typeof plugin.settings.onOpen==='function')
  plugin.settings.onOpen.call($element)};plugin.update=function(values){if(plugin.original_direction)plugin.original_direction=plugin.direction;plugin.settings=$.extend(plugin.settings,values);init(!0)};browser.init();init()};$.fn.Zebra_DatePicker=function(options){return this.each(function(){if(undefined!==$(this).data('Zebra_DatePicker'))
  $(this).data('Zebra_DatePicker').destroy();var plugin=new $.Zebra_DatePicker(this,options);$(this).data('Zebra_DatePicker',plugin)})};$.fn.Zebra_DatePicker.defaults={}}))