/*
* Kendo UI Web v2012.2.710 (http://kendoui.com)
* Copyright 2012 Telerik AD. All rights reserved.
*
* Kendo UI Web commercial licenses may be obtained at http://kendoui.com/web-license
* If you do not own a commercial license, this file shall be governed by the
* GNU General Public License (GPL) version 3.
* For GPL requirements, please review: http://www.gnu.org/copyleft/gpl.html
*/
;(function(a,b){function K(a){var b=c.getCulture(a.culture).calendars.standard.patterns;a.format=g(a.format||b.g),a.timeFormat=g(a.timeFormat||b.t),c.DateView.normalize(a),a.parseFormats.splice(1,0,a.timeFormat)}function J(a){a.preventDefault()}var c=window.kendo,d=c.TimeView,e=c.support.touch,f=c.parseDate,g=c._extractFormat,h=c.calendar,i=h.isInRange,j=h.restrictValue,k=h.isEqualDatePart,l=d.getMilliseconds,m=c.ui,n=m.Widget,o="open",p="close",q="change",r=e?"touchend":"click",s="disabled",t="k-state-default",u="k-state-focused",v="k-state-hover",w="k-state-disabled",x="mouseenter mouseleave",y=e?"touchstart":"mousedown",z=r+" "+y,A="month",B="",C=Date,D=new C(1900,0,1),E=new C(2099,11,31),F={view:"date"},G={view:"time"},H=a.extend,I=n.extend({init:function(b,d){var f=this;n.fn.init.call(f,b,d),b=f.element,d=f.options,K(d),f._wrapper(),f._icons(),f._views(),e||(b[0].type="text"),b.addClass("k-input").bind({keydown:a.proxy(f._keydown,f),focus:function(){f._inputWrapper.addClass(u)},blur:function(){f._inputWrapper.removeClass(u),f._change(b.val()),f.close("date"),f.close("time")}}).closest("form").bind("reset",function(){f.value(b[0].defaultValue)}),f._midnight=l(d.min)+l(d.max)===0,f.enable(!b.is("[disabled]")),f.value(d.value||b.val()),c.notify(f)},options:{name:"DateTimePicker",value:null,format:"",timeFormat:"",culture:"",parseFormats:[],dates:[],min:new C(D),max:new C(E),interval:30,height:200,footer:"",start:A,depth:A,animation:{},month:{}},events:[o,p,q],setOptions:function(a){var b=this;n.fn.setOptions.call(b,a),K(b.options),H(b.dateView.options,b.options),H(b.timeView.options,b.options),b.timeView.ul[0].innerHTML=""},enable:function(a){var b=this,c=b._dateIcon.unbind(z),d=b._timeIcon.unbind(z),f=b._inputWrapper.unbind(x),g=b.element;a===!1?(f.removeClass(t).addClass(w),g.attr(s,s)):(f.addClass(t).removeClass(w).bind(x,b._toggleHover),g.removeAttr(s),c.bind({click:function(){b.toggle("date"),!e&&g[0]!==document.activeElement&&g.focus()},mousedown:J}),d.bind({click:function(){b.toggle("time"),!e&&g[0]!==document.activeElement&&g.focus()},mousedown:J}))},close:function(a){a!=="time"&&(a="date"),this[a+"View"].close()},open:function(a){a!=="time"&&(a="date"),this[a+"View"].open()},min:function(a){return this._option("min",a)},max:function(a){return this._option("max",a)},toggle:function(a){var b="timeView";a!=="time"?a="date":b="dateView",this[a+"View"].toggle(),this[b].close()},value:function(a){var c=this;if(a===b)return c._value;c._old=c._update(a)},_change:function(a){var b=this;a=b._update(a),+b._old!=+a&&(b._old=a,b.trigger(q),b.element.trigger(q))},_option:function(a,c){var d=this,e=d.options,g=d.timeView,h=g.options,i=d._value||d._old;if(c===b)return e[a];c=f(c,e.parseFormats,e.culture);if(!!c){e[a]=new C(c),d.dateView[a](c),d._midnight=l(e.min)+l(e.max)===0;if(i&&k(c,i)){if(d._midnight&&a=="max"){h[a]=E,g.dataBind([E]);return}h[a]=c}else h.max=E,h.min=D;g.bind()}},_toggleHover:function(b){e||a(b.currentTarget).toggleClass(v,b.type==="mouseenter")},_update:function(a){var b=this,d=b.options,e=d.min,g=d.max,h=b.timeView,l=f(a,d.parseFormats,d.culture),m,n,o,p;if(+l===+b._value)return l;l!==null&&k(l,e)?l=j(l,e,g):i(l,e,g)||(l=null),b._value=l,h.value(l),b.dateView.value(l),l&&(o=b._old,n=h.options,k(l,e)&&(n.min=e,n.max=E,m=!0),k(l,g)&&(b._midnight?(h.dataBind([E]),p=!0):(n.max=g,m||(n.min=D),m=!0)),!p&&(!o&&m||o&&!k(o,l))&&(m||(n.max=E,n.min=D),h.bind())),b.element.val(l?c.toString(l,d.format,d.culture):a);return l},_keydown:function(a){var b=this,d=b.dateView,e=b.timeView,f=d.popup.visible();a.altKey&&a.keyCode===c.keys.DOWN?b.toggle(f?"time":"date"):f?d.move(a):e.popup.visible()?e.move(a):a.keyCode===c.keys.ENTER&&b._change(b.element.val())},_views:function(){var a=this,b=a.options;a.dateView=new c.DateView(H({},b,{anchor:a.wrapper,change:function(){var c=this.value(),d=+c,e=+b.min,f=+b.max,g;if(d===e||d===f)g=new C(a._value),g.setFullYear(c.getFullYear()),g.setMonth(c.getMonth()),g.setDate(c.getDate()),i(g,e,f)&&(c=g);a._change(c),a.close("date")},close:function(b){a.trigger(p,F)&&b.preventDefault()},open:function(b){a.trigger(o,F)&&b.preventDefault()}})),a.timeView=new d({anchor:a.wrapper,animation:b.animation,dates:b.dates,format:b.timeFormat,culture:b.culture,height:b.height,interval:b.interval,min:new C(D),max:new C(E),parseFormats:b.parseFormats,value:b.value,change:function(d,e){d=a.timeView._parse(d),db.max&&(d=new C(b.max),a.timeView.options.max=d),e?(a._timeSelected=!0,a._change(d)):a.element.val(c.toString(d,b.format,b.culture))},close:function(b){a.trigger(p,G)&&b.preventDefault()},open:function(b){a.trigger(o,G)&&b.preventDefault()}})},_icons:function(){var b=this,c=b.element,d;d=c.next("span.k-select"),d[0]||(d=a('selectselect').insertAfter(c),d=d.children()),b._dateIcon=d.eq(0),b._timeIcon=d.eq(1)},_wrapper:function(){var b=this,c=b.element,d;d=c.parents(".k-datetimepicker"),d[0]||(d=c.wrap(B).parent().addClass("k-picker-wrap k-state-default"),d=d.wrap(B).parent()),d[0].style.cssText=c[0].style.cssText,c.css({width:"100%",height:c[0].style.height}),b.wrapper=d.addClass("k-widget k-datetimepicker k-header"),b._inputWrapper=a(d[0].firstChild)}});m.plugin(I)})(jQuery);