1/**
2 * @preserve jQuery DateTimePicker plugin v2.4.5
3 * @homepage http://xdsoft.net/jqplugins/datetimepicker/
4 * (c) 2014, Chupurnov Valeriy.
5 */
6/*global document,window,jQuery,setTimeout,clearTimeout,HighlightedDate,getCurrentValue*/
7(function ($) {
8	'use strict';
9	var default_options  = {
10		i18n: {
11			ar: { // Arabic
12				months: [
13					"كانون الثاني", "شباط", "آذار", "نيسان", "مايو", "حزيران", "تموز", "آب", "أيلول", "تشرين الأول", "تشرين الثاني", "كانون الأول"
14				],
15				dayOfWeek: [
16					"ن", "ث", "ع", "خ", "ج", "س", "ح"
17				]
18			},
19			ro: { // Romanian
20				months: [
21					"ianuarie", "februarie", "martie", "aprilie", "mai", "iunie", "iulie", "august", "septembrie", "octombrie", "noiembrie", "decembrie"
22				],
23				dayOfWeek: [
24					"l", "ma", "mi", "j", "v", "s", "d"
25				]
26			},
27			id: { // Indonesian
28				months: [
29					"Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember"
30				],
31				dayOfWeek: [
32					"Min", "Sen", "Sel", "Rab", "Kam", "Jum", "Sab"
33				]
34			},
35			is: { // Icelandic
36				months: [
37					"Janúar", "Febrúar", "Mars", "Apríl", "Maí", "Júní", "Júlí", "Ágúst", "September", "Október", "Nóvember", "Desember"
38				],
39				dayOfWeek: [
40					"Sun", "Mán", "Þrið", "Mið", "Fim", "Fös", "Lau"
41				]
42			},
43			bg: { // Bulgarian
44				months: [
45					"Януари", "Февруари", "Март", "Април", "Май", "Юни", "Юли", "Август", "Септември", "Октомври", "Ноември", "Декември"
46				],
47				dayOfWeek: [
48					"Нд", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб"
49				]
50			},
51			fa: { // Persian/Farsi
52				months: [
53					'فروردین', 'اردیبهشت', 'خرداد', 'تیر', 'مرداد', 'شهریور', 'مهر', 'آبان', 'آذر', 'دی', 'بهمن', 'اسفند'
54				],
55				dayOfWeek: [
56					'یکشنبه', 'دوشنبه', 'سه شنبه', 'چهارشنبه', 'پنجشنبه', 'جمعه', 'شنبه'
57				]
58			},
59			ru: { // Russian
60				months: [
61					'Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь'
62				],
63				dayOfWeek: [
64					"Вск", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб"
65				]
66			},
67			uk: { // Ukrainian
68				months: [
69					'Січень', 'Лютий', 'Березень', 'Квітень', 'Травень', 'Червень', 'Липень', 'Серпень', 'Вересень', 'Жовтень', 'Листопад', 'Грудень'
70				],
71				dayOfWeek: [
72					"Ндл", "Пнд", "Втр", "Срд", "Чтв", "Птн", "Сбт"
73				]
74			},
75			en: { // English
76				months: [
77					"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
78				],
79				dayOfWeek: [
80					"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
81				]
82			},
83			el: { // Ελληνικά
84				months: [
85					"Ιανουάριος", "Φεβρουάριος", "Μάρτιος", "Απρίλιος", "Μάιος", "Ιούνιος", "Ιούλιος", "Αύγουστος", "Σεπτέμβριος", "Οκτώβριος", "Νοέμβριος", "Δεκέμβριος"
86				],
87				dayOfWeek: [
88					"Κυρ", "Δευ", "Τρι", "Τετ", "Πεμ", "Παρ", "Σαβ"
89				]
90			},
91			de: { // German
92				months: [
93					'Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'
94				],
95				dayOfWeek: [
96					"So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"
97				]
98			},
99			nl: { // Dutch
100				months: [
101					"januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus", "september", "oktober", "november", "december"
102				],
103				dayOfWeek: [
104					"zo", "ma", "di", "wo", "do", "vr", "za"
105				]
106			},
107			tr: { // Turkish
108				months: [
109					"Ocak", "Şubat", "Mart", "Nisan", "Mayıs", "Haziran", "Temmuz", "Ağustos", "Eylül", "Ekim", "Kasım", "Aralık"
110				],
111				dayOfWeek: [
112					"Paz", "Pts", "Sal", "Çar", "Per", "Cum", "Cts"
113				]
114			},
115			fr: { //French
116				months: [
117					"Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre"
118				],
119				dayOfWeek: [
120					"Dim", "Lun", "Mar", "Mer", "Jeu", "Ven", "Sam"
121				]
122			},
123			es: { // Spanish
124				months: [
125					"Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"
126				],
127				dayOfWeek: [
128					"Dom", "Lun", "Mar", "Mié", "Jue", "Vie", "Sáb"
129				]
130			},
131			th: { // Thai
132				months: [
133					'มกราคม', 'กุมภาพันธ์', 'มีนาคม', 'เมษายน', 'พฤษภาคม', 'มิถุนายน', 'กรกฎาคม', 'สิงหาคม', 'กันยายน', 'ตุลาคม', 'พฤศจิกายน', 'ธันวาคม'
134				],
135				dayOfWeek: [
136					'อา.', 'จ.', 'อ.', 'พ.', 'พฤ.', 'ศ.', 'ส.'
137				]
138			},
139			pl: { // Polish
140				months: [
141					"styczeń", "luty", "marzec", "kwiecień", "maj", "czerwiec", "lipiec", "sierpień", "wrzesień", "październik", "listopad", "grudzień"
142				],
143				dayOfWeek: [
144					"nd", "pn", "wt", "śr", "cz", "pt", "sb"
145				]
146			},
147			pt: { // Portuguese
148				months: [
149					"Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"
150				],
151				dayOfWeek: [
152					"Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sab"
153				]
154			},
155			ch: { // Simplified Chinese
156				months: [
157					"一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"
158				],
159				dayOfWeek: [
160					"日", "一", "二", "三", "四", "五", "六"
161				]
162			},
163			se: { // Swedish
164				months: [
165					"Januari", "Februari", "Mars", "April", "Maj", "Juni", "Juli", "Augusti", "September",  "Oktober", "November", "December"
166				],
167				dayOfWeek: [
168					"Sön", "Mån", "Tis", "Ons", "Tor", "Fre", "Lör"
169				]
170			},
171			kr: { // Korean
172				months: [
173					"1월", "2월", "3월", "4월", "5월", "6월", "7월", "8월", "9월", "10월", "11월", "12월"
174				],
175				dayOfWeek: [
176					"일", "월", "화", "수", "목", "금", "토"
177				]
178			},
179			it: { // Italian
180				months: [
181					"Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre"
182				],
183				dayOfWeek: [
184					"Dom", "Lun", "Mar", "Mer", "Gio", "Ven", "Sab"
185				]
186			},
187			da: { // Dansk
188				months: [
189					"January", "Februar", "Marts", "April", "Maj", "Juni", "July", "August", "September", "Oktober", "November", "December"
190				],
191				dayOfWeek: [
192					"Søn", "Man", "Tir", "Ons", "Tor", "Fre", "Lør"
193				]
194			},
195			no: { // Norwegian
196				months: [
197					"Januar", "Februar", "Mars", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Desember"
198				],
199				dayOfWeek: [
200					"Søn", "Man", "Tir", "Ons", "Tor", "Fre", "Lør"
201				]
202			},
203			ja: { // Japanese
204				months: [
205					"1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"
206				],
207				dayOfWeek: [
208					"日", "月", "火", "水", "木", "金", "土"
209				]
210			},
211			vi: { // Vietnamese
212				months: [
213					"Tháng 1", "Tháng 2", "Tháng 3", "Tháng 4", "Tháng 5", "Tháng 6", "Tháng 7", "Tháng 8", "Tháng 9", "Tháng 10", "Tháng 11", "Tháng 12"
214				],
215				dayOfWeek: [
216					"CN", "T2", "T3", "T4", "T5", "T6", "T7"
217				]
218			},
219			sl: { // Slovenščina
220				months: [
221					"Januar", "Februar", "Marec", "April", "Maj", "Junij", "Julij", "Avgust", "September", "Oktober", "November", "December"
222				],
223				dayOfWeek: [
224					"Ned", "Pon", "Tor", "Sre", "Čet", "Pet", "Sob"
225				]
226			},
227			cs: { // Čeština
228				months: [
229					"Leden", "Únor", "Březen", "Duben", "Květen", "Červen", "Červenec", "Srpen", "Září", "Říjen", "Listopad", "Prosinec"
230				],
231				dayOfWeek: [
232					"Ne", "Po", "Út", "St", "Čt", "Pá", "So"
233				]
234			},
235			hu: { // Hungarian
236				months: [
237					"Január", "Február", "Március", "Április", "Május", "Június", "Július", "Augusztus", "Szeptember", "Október", "November", "December"
238				],
239				dayOfWeek: [
240					"Va", "Hé", "Ke", "Sze", "Cs", "Pé", "Szo"
241				]
242			},
243			az: { //Azerbaijanian (Azeri)
244				months: [
245					"Yanvar", "Fevral", "Mart", "Aprel", "May", "Iyun", "Iyul", "Avqust", "Sentyabr", "Oktyabr", "Noyabr", "Dekabr"
246				],
247				dayOfWeek: [
248					"B", "Be", "Ça", "Ç", "Ca", "C", "Ş"
249				]
250			},
251			bs: { //Bosanski
252				months: [
253					"Januar", "Februar", "Mart", "April", "Maj", "Jun", "Jul", "Avgust", "Septembar", "Oktobar", "Novembar", "Decembar"
254				],
255				dayOfWeek: [
256					"Ned", "Pon", "Uto", "Sri", "Čet", "Pet", "Sub"
257				]
258			},
259			ca: { //Català
260				months: [
261					"Gener", "Febrer", "Març", "Abril", "Maig", "Juny", "Juliol", "Agost", "Setembre", "Octubre", "Novembre", "Desembre"
262				],
263				dayOfWeek: [
264					"Dg", "Dl", "Dt", "Dc", "Dj", "Dv", "Ds"
265				]
266			},
267			'en-GB': { //English (British)
268				months: [
269					"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
270				],
271				dayOfWeek: [
272					"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
273				]
274			},
275			et: { //"Eesti"
276				months: [
277					"Jaanuar", "Veebruar", "Märts", "Aprill", "Mai", "Juuni", "Juuli", "August", "September", "Oktoober", "November", "Detsember"
278				],
279				dayOfWeek: [
280					"P", "E", "T", "K", "N", "R", "L"
281				]
282			},
283			eu: { //Euskara
284				months: [
285					"Urtarrila", "Otsaila", "Martxoa", "Apirila", "Maiatza", "Ekaina", "Uztaila", "Abuztua", "Iraila", "Urria", "Azaroa", "Abendua"
286				],
287				dayOfWeek: [
288					"Ig.", "Al.", "Ar.", "Az.", "Og.", "Or.", "La."
289				]
290			},
291			fi: { //Finnish (Suomi)
292				months: [
293					"Tammikuu", "Helmikuu", "Maaliskuu", "Huhtikuu", "Toukokuu", "Kesäkuu", "Heinäkuu", "Elokuu", "Syyskuu", "Lokakuu", "Marraskuu", "Joulukuu"
294				],
295				dayOfWeek: [
296					"Su", "Ma", "Ti", "Ke", "To", "Pe", "La"
297				]
298			},
299			gl: { //Galego
300				months: [
301					"Xan", "Feb", "Maz", "Abr", "Mai", "Xun", "Xul", "Ago", "Set", "Out", "Nov", "Dec"
302				],
303				dayOfWeek: [
304					"Dom", "Lun", "Mar", "Mer", "Xov", "Ven", "Sab"
305				]
306			},
307			hr: { //Hrvatski
308				months: [
309					"Siječanj", "Veljača", "Ožujak", "Travanj", "Svibanj", "Lipanj", "Srpanj", "Kolovoz", "Rujan", "Listopad", "Studeni", "Prosinac"
310				],
311				dayOfWeek: [
312					"Ned", "Pon", "Uto", "Sri", "Čet", "Pet", "Sub"
313				]
314			},
315			ko: { //Korean (한국어)
316				months: [
317					"1월", "2월", "3월", "4월", "5월", "6월", "7월", "8월", "9월", "10월", "11월", "12월"
318				],
319				dayOfWeek: [
320					"일", "월", "화", "수", "목", "금", "토"
321				]
322			},
323			lt: { //Lithuanian (lietuvių)
324				months: [
325					"Sausio", "Vasario", "Kovo", "Balandžio", "Gegužės", "Birželio", "Liepos", "Rugpjūčio", "Rugsėjo", "Spalio", "Lapkričio", "Gruodžio"
326				],
327				dayOfWeek: [
328					"Sek", "Pir", "Ant", "Tre", "Ket", "Pen", "Šeš"
329				]
330			},
331			lv: { //Latvian (Latviešu)
332				months: [
333					"Janvāris", "Februāris", "Marts", "Aprīlis ", "Maijs", "Jūnijs", "Jūlijs", "Augusts", "Septembris", "Oktobris", "Novembris", "Decembris"
334				],
335				dayOfWeek: [
336					"Sv", "Pr", "Ot", "Tr", "Ct", "Pk", "St"
337				]
338			},
339			mk: { //Macedonian (Македонски)
340				months: [
341					"јануари", "февруари", "март", "април", "мај", "јуни", "јули", "август", "септември", "октомври", "ноември", "декември"
342				],
343				dayOfWeek: [
344					"нед", "пон", "вто", "сре", "чет", "пет", "саб"
345				]
346			},
347			mn: { //Mongolian (Монгол)
348				months: [
349					"1-р сар", "2-р сар", "3-р сар", "4-р сар", "5-р сар", "6-р сар", "7-р сар", "8-р сар", "9-р сар", "10-р сар", "11-р сар", "12-р сар"
350				],
351				dayOfWeek: [
352					"Дав", "Мяг", "Лха", "Пүр", "Бсн", "Бям", "Ням"
353				]
354			},
355			'pt-BR': { //Português(Brasil)
356				months: [
357					"Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"
358				],
359				dayOfWeek: [
360					"Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sáb"
361				]
362			},
363			sk: { //Slovenčina
364				months: [
365					"Január", "Február", "Marec", "Apríl", "Máj", "Jún", "Júl", "August", "September", "Október", "November", "December"
366				],
367				dayOfWeek: [
368					"Ne", "Po", "Ut", "St", "Št", "Pi", "So"
369				]
370			},
371			sq: { //Albanian (Shqip)
372				months: [
373					"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
374				],
375				dayOfWeek: [
376					"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
377				]
378			},
379			'sr-YU': { //Serbian (Srpski)
380				months: [
381					"Januar", "Februar", "Mart", "April", "Maj", "Jun", "Jul", "Avgust", "Septembar", "Oktobar", "Novembar", "Decembar"
382				],
383				dayOfWeek: [
384					"Ned", "Pon", "Uto", "Sre", "čet", "Pet", "Sub"
385				]
386			},
387			sr: { //Serbian Cyrillic (Српски)
388				months: [
389					"јануар", "фебруар", "март", "април", "мај", "јун", "јул", "август", "септембар", "октобар", "новембар", "децембар"
390				],
391				dayOfWeek: [
392					"нед", "пон", "уто", "сре", "чет", "пет", "суб"
393				]
394			},
395			sv: { //Svenska
396				months: [
397					"Januari", "Februari", "Mars", "April", "Maj", "Juni", "Juli", "Augusti", "September", "Oktober", "November", "December"
398				],
399				dayOfWeek: [
400					"Sön", "Mån", "Tis", "Ons", "Tor", "Fre", "Lör"
401				]
402			},
403			'zh-TW': { //Traditional Chinese (繁體中文)
404				months: [
405					"一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"
406				],
407				dayOfWeek: [
408					"日", "一", "二", "三", "四", "五", "六"
409				]
410			},
411			zh: { //Simplified Chinese (简体中文)
412				months: [
413					"一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"
414				],
415				dayOfWeek: [
416					"日", "一", "二", "三", "四", "五", "六"
417				]
418			},
419			he: { //Hebrew (עברית)
420				months: [
421					'ינואר', 'פברואר', 'מרץ', 'אפריל', 'מאי', 'יוני', 'יולי', 'אוגוסט', 'ספטמבר', 'אוקטובר', 'נובמבר', 'דצמבר'
422				],
423				dayOfWeek: [
424					'א\'', 'ב\'', 'ג\'', 'ד\'', 'ה\'', 'ו\'', 'שבת'
425				]
426			},
427			hy: { // Armenian
428				months: [
429					"Հունվար", "Փետրվար", "Մարտ", "Ապրիլ", "Մայիս", "Հունիս", "Հուլիս", "Օգոստոս", "Սեպտեմբեր", "Հոկտեմբեր", "Նոյեմբեր", "Դեկտեմբեր"
430				],
431				dayOfWeek: [
432					"Կի", "Երկ", "Երք", "Չոր", "Հնգ", "Ուրբ", "Շբթ"
433				]
434			},
435            kg: { // Kyrgyz
436                months: [
437                    'Үчтүн айы', 'Бирдин айы', 'Жалган Куран', 'Чын Куран', 'Бугу', 'Кулжа', 'Теке', 'Баш Оона', 'Аяк Оона', 'Тогуздун айы', 'Жетинин айы', 'Бештин айы'
438                ],
439                dayOfWeek: [
440                    "Жек", "Дүй", "Шей", "Шар", "Бей", "Жум", "Ише"
441                ]
442            }
443		},
444		value: '',
445		lang: 'en',
446
447		format:	'Y/m/d H:i',
448		formatTime:	'H:i',
449		formatDate:	'Y/m/d',
450
451		startDate:	false, // new Date(), '1986/12/08', '-1970/01/05','-1970/01/05',
452		step: 60,
453		monthChangeSpinner: true,
454
455		closeOnDateSelect: false,
456		closeOnTimeSelect: true,
457		closeOnWithoutClick: true,
458		closeOnInputClick: true,
459
460		timepicker: true,
461		datepicker: true,
462		weeks: false,
463
464		defaultTime: false,	// use formatTime format (ex. '10:00' for formatTime:	'H:i')
465		defaultDate: false,	// use formatDate format (ex new Date() or '1986/12/08' or '-1970/01/05' or '-1970/01/05')
466
467		minDate: false,
468		maxDate: false,
469		minTime: false,
470		maxTime: false,
471		disabledMinTime: false,
472		disabledMaxTime: false,
473
474		allowTimes: [],
475		opened: false,
476		initTime: true,
477		inline: false,
478		theme: '',
479
480		onSelectDate: function () {},
481		onSelectTime: function () {},
482		onChangeMonth: function () {},
483		onChangeYear: function () {},
484		onChangeDateTime: function () {},
485		onShow: function () {},
486		onClose: function () {},
487		onGenerate: function () {},
488
489		withoutCopyright: true,
490		inverseButton: false,
491		hours12: false,
492		next: 'xdsoft_next',
493		prev : 'xdsoft_prev',
494		dayOfWeekStart: 0,
495		parentID: 'body',
496		timeHeightInTimePicker: 25,
497		timepickerScrollbar: true,
498		todayButton: true,
499		prevButton: true,
500		nextButton: true,
501		defaultSelect: true,
502
503		scrollMonth: true,
504		scrollTime: true,
505		scrollInput: true,
506
507		lazyInit: false,
508		mask: false,
509		validateOnBlur: true,
510		allowBlank: true,
511		yearStart: 1950,
512		yearEnd: 2050,
513		monthStart: 0,
514		monthEnd: 11,
515		style: '',
516		id: '',
517		fixed: false,
518		roundTime: 'round', // ceil, floor
519		className: '',
520		weekends: [],
521		highlightedDates: [],
522		highlightedPeriods: [],
523		disabledDates : [],
524		disabledWeekDays: [],
525		yearOffset: 0,
526		beforeShowDay: null,
527
528		enterLikeTab: true,
529        showApplyButton: false
530	};
531	// fix for ie8
532	if (!window.getComputedStyle) {
533		window.getComputedStyle = function (el, pseudo) {
534			this.el = el;
535			this.getPropertyValue = function (prop) {
536				var re = /(\-([a-z]){1})/g;
537				if (prop === 'float') {
538					prop = 'styleFloat';
539				}
540				if (re.test(prop)) {
541					prop = prop.replace(re, function (a, b, c) {
542						return c.toUpperCase();
543					});
544				}
545				return el.currentStyle[prop] || null;
546			};
547			return this;
548		};
549	}
550	if (!Array.prototype.indexOf) {
551		Array.prototype.indexOf = function (obj, start) {
552			var i, j;
553			for (i = (start || 0), j = this.length; i < j; i += 1) {
554				if (this[i] === obj) { return i; }
555			}
556			return -1;
557		};
558	}
559	Date.prototype.countDaysInMonth = function () {
560		return new Date(this.getFullYear(), this.getMonth() + 1, 0).getDate();
561	};
562	$.fn.xdsoftScroller = function (percent) {
563		return this.each(function () {
564			var timeboxparent = $(this),
565				pointerEventToXY = function (e) {
566					var out = {x: 0, y: 0},
567						touch;
568					if (e.type === 'touchstart' || e.type === 'touchmove' || e.type === 'touchend' || e.type === 'touchcancel') {
569						touch  = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0];
570						out.x = touch.clientX;
571						out.y = touch.clientY;
572					} else if (e.type === 'mousedown' || e.type === 'mouseup' || e.type === 'mousemove' || e.type === 'mouseover' || e.type === 'mouseout' || e.type === 'mouseenter' || e.type === 'mouseleave') {
573						out.x = e.clientX;
574						out.y = e.clientY;
575					}
576					return out;
577				},
578				move = 0,
579				timebox,
580				parentHeight,
581				height,
582				scrollbar,
583				scroller,
584				maximumOffset = 100,
585				start = false,
586				startY = 0,
587				startTop = 0,
588				h1 = 0,
589				touchStart = false,
590				startTopScroll = 0,
591				calcOffset = function () {};
592			if (percent === 'hide') {
593				timeboxparent.find('.xdsoft_scrollbar').hide();
594				return;
595			}
596			if (!$(this).hasClass('xdsoft_scroller_box')) {
597				timebox = timeboxparent.children().eq(0);
598				parentHeight = timeboxparent[0].clientHeight;
599				height = timebox[0].offsetHeight;
600				scrollbar = $('<div class="xdsoft_scrollbar"></div>');
601				scroller = $('<div class="xdsoft_scroller"></div>');
602				scrollbar.append(scroller);
603
604				timeboxparent.addClass('xdsoft_scroller_box').append(scrollbar);
605				calcOffset = function calcOffset(event) {
606					var offset = pointerEventToXY(event).y - startY + startTopScroll;
607					if (offset < 0) {
608						offset = 0;
609					}
610					if (offset + scroller[0].offsetHeight > h1) {
611						offset = h1 - scroller[0].offsetHeight;
612					}
613					timeboxparent.trigger('scroll_element.xdsoft_scroller', [maximumOffset ? offset / maximumOffset : 0]);
614				};
615
616				scroller
617					.on('touchstart.xdsoft_scroller mousedown.xdsoft_scroller', function (event) {
618						if (!parentHeight) {
619							timeboxparent.trigger('resize_scroll.xdsoft_scroller', [percent]);
620						}
621
622						startY = pointerEventToXY(event).y;
623						startTopScroll = parseInt(scroller.css('margin-top'), 10);
624						h1 = scrollbar[0].offsetHeight;
625
626						if (event.type === 'mousedown') {
627							if (document) {
628								$(document.body).addClass('xdsoft_noselect');
629							}
630							$([document.body, window]).on('mouseup.xdsoft_scroller', function arguments_callee() {
631								$([document.body, window]).off('mouseup.xdsoft_scroller', arguments_callee)
632									.off('mousemove.xdsoft_scroller', calcOffset)
633									.removeClass('xdsoft_noselect');
634							});
635							$(document.body).on('mousemove.xdsoft_scroller', calcOffset);
636						} else {
637							touchStart = true;
638							event.stopPropagation();
639							event.preventDefault();
640						}
641					})
642					.on('touchmove', function (event) {
643						if (touchStart) {
644							event.preventDefault();
645							calcOffset(event);
646						}
647					})
648					.on('touchend touchcancel', function (event) {
649						touchStart =  false;
650						startTopScroll = 0;
651					});
652
653				timeboxparent
654					.on('scroll_element.xdsoft_scroller', function (event, percentage) {
655						if (!parentHeight) {
656							timeboxparent.trigger('resize_scroll.xdsoft_scroller', [percentage, true]);
657						}
658						percentage = percentage > 1 ? 1 : (percentage < 0 || isNaN(percentage)) ? 0 : percentage;
659
660						scroller.css('margin-top', maximumOffset * percentage);
661
662						setTimeout(function () {
663							timebox.css('marginTop', -parseInt((timebox[0].offsetHeight - parentHeight) * percentage, 10));
664						}, 10);
665					})
666					.on('resize_scroll.xdsoft_scroller', function (event, percentage, noTriggerScroll) {
667						var percent, sh;
668						parentHeight = timeboxparent[0].clientHeight;
669						height = timebox[0].offsetHeight;
670						percent = parentHeight / height;
671						sh = percent * scrollbar[0].offsetHeight;
672						if (percent > 1) {
673							scroller.hide();
674						} else {
675							scroller.show();
676							scroller.css('height', parseInt(sh > 10 ? sh : 10, 10));
677							maximumOffset = scrollbar[0].offsetHeight - scroller[0].offsetHeight;
678							if (noTriggerScroll !== true) {
679								timeboxparent.trigger('scroll_element.xdsoft_scroller', [percentage || Math.abs(parseInt(timebox.css('marginTop'), 10)) / (height - parentHeight)]);
680							}
681						}
682					});
683
684				timeboxparent.on('mousewheel', function (event) {
685					var top = Math.abs(parseInt(timebox.css('marginTop'), 10));
686
687					top = top - (event.deltaY * 20);
688					if (top < 0) {
689						top = 0;
690					}
691
692					timeboxparent.trigger('scroll_element.xdsoft_scroller', [top / (height - parentHeight)]);
693					event.stopPropagation();
694					return false;
695				});
696
697				timeboxparent.on('touchstart', function (event) {
698					start = pointerEventToXY(event);
699					startTop = Math.abs(parseInt(timebox.css('marginTop'), 10));
700				});
701
702				timeboxparent.on('touchmove', function (event) {
703					if (start) {
704						event.preventDefault();
705						var coord = pointerEventToXY(event);
706						timeboxparent.trigger('scroll_element.xdsoft_scroller', [(startTop - (coord.y - start.y)) / (height - parentHeight)]);
707					}
708				});
709
710				timeboxparent.on('touchend touchcancel', function (event) {
711					start = false;
712					startTop = 0;
713				});
714			}
715			timeboxparent.trigger('resize_scroll.xdsoft_scroller', [percent]);
716		});
717	};
718
719	$.fn.datetimepicker = function (opt) {
720		var KEY0 = 48,
721			KEY9 = 57,
722			_KEY0 = 96,
723			_KEY9 = 105,
724			CTRLKEY = 17,
725			DEL = 46,
726			ENTER = 13,
727			ESC = 27,
728			BACKSPACE = 8,
729			ARROWLEFT = 37,
730			ARROWUP = 38,
731			ARROWRIGHT = 39,
732			ARROWDOWN = 40,
733			TAB = 9,
734			F5 = 116,
735			AKEY = 65,
736			CKEY = 67,
737			VKEY = 86,
738			ZKEY = 90,
739			YKEY = 89,
740			ctrlDown	=	false,
741			options = ($.isPlainObject(opt) || !opt) ? $.extend(true, {}, default_options, opt) : $.extend(true, {}, default_options),
742
743			lazyInitTimer = 0,
744			createDateTimePicker,
745			destroyDateTimePicker,
746
747			lazyInit = function (input) {
748				input
749					.on('open.xdsoft focusin.xdsoft mousedown.xdsoft', function initOnActionCallback(event) {
750						if (input.is(':disabled') || input.data('xdsoft_datetimepicker')) {
751							return;
752						}
753						clearTimeout(lazyInitTimer);
754						lazyInitTimer = setTimeout(function () {
755
756							if (!input.data('xdsoft_datetimepicker')) {
757								createDateTimePicker(input);
758							}
759							input
760								.off('open.xdsoft focusin.xdsoft mousedown.xdsoft', initOnActionCallback)
761								.trigger('open.xdsoft');
762						}, 100);
763					});
764			};
765
766		createDateTimePicker = function (input) {
767			var datetimepicker = $('<div class="xdsoft_datetimepicker xdsoft_noselect"></div>'),
768				xdsoft_copyright = $('<div class="xdsoft_copyright"><a target="_blank" href="http://xdsoft.net/jqplugins/datetimepicker/">xdsoft.net</a></div>'),
769				datepicker = $('<div class="xdsoft_datepicker active"></div>'),
770				mounth_picker = $('<div class="xdsoft_mounthpicker"><button type="button" class="xdsoft_prev"></button><button type="button" class="xdsoft_today_button"></button>' +
771					'<div class="xdsoft_label xdsoft_month"><span></span><i></i></div>' +
772					'<div class="xdsoft_label xdsoft_year"><span></span><i></i></div>' +
773					'<button type="button" class="xdsoft_next"></button></div>'),
774				calendar = $('<div class="xdsoft_calendar"></div>'),
775				timepicker = $('<div class="xdsoft_timepicker active"><button type="button" class="xdsoft_prev"></button><div class="xdsoft_time_box"></div><button type="button" class="xdsoft_next"></button></div>'),
776				timeboxparent = timepicker.find('.xdsoft_time_box').eq(0),
777				timebox = $('<div class="xdsoft_time_variant"></div>'),
778                applyButton = $('<button type="button" class="xdsoft_save_selected blue-gradient-button">Save Selected</button>'),
779				/*scrollbar = $('<div class="xdsoft_scrollbar"></div>'),
780				scroller = $('<div class="xdsoft_scroller"></div>'),*/
781				monthselect = $('<div class="xdsoft_select xdsoft_monthselect"><div></div></div>'),
782				yearselect = $('<div class="xdsoft_select xdsoft_yearselect"><div></div></div>'),
783				triggerAfterOpen = false,
784				XDSoft_datetime,
785				//scroll_element,
786				xchangeTimer,
787				timerclick,
788				current_time_index,
789				setPos,
790				timer = 0,
791				timer1 = 0,
792				_xdsoft_datetime;
793
794			if (options.id) {
795				datetimepicker.attr('id', options.id);
796			}
797			if (options.style) {
798				datetimepicker.attr('style', options.style);
799			}
800			if (options.weeks) {
801				datetimepicker.addClass('xdsoft_showweeks');
802			}
803
804			datetimepicker.addClass('xdsoft_' + options.theme);
805			datetimepicker.addClass(options.className);
806
807			mounth_picker
808				.find('.xdsoft_month span')
809					.after(monthselect);
810			mounth_picker
811				.find('.xdsoft_year span')
812					.after(yearselect);
813
814			mounth_picker
815				.find('.xdsoft_month,.xdsoft_year')
816					.on('mousedown.xdsoft', function (event) {
817					var select = $(this).find('.xdsoft_select').eq(0),
818						val = 0,
819						top = 0,
820						visible = select.is(':visible'),
821						items,
822						i;
823
824					mounth_picker
825						.find('.xdsoft_select')
826							.hide();
827					if (_xdsoft_datetime.currentTime) {
828						val = _xdsoft_datetime.currentTime[$(this).hasClass('xdsoft_month') ? 'getMonth' : 'getFullYear']();
829					}
830
831					select[visible ? 'hide' : 'show']();
832					for (items = select.find('div.xdsoft_option'), i = 0; i < items.length; i += 1) {
833						if (items.eq(i).data('value') === val) {
834							break;
835						} else {
836							top += items[0].offsetHeight;
837						}
838					}
839
840					select.xdsoftScroller(top / (select.children()[0].offsetHeight - (select[0].clientHeight)));
841					event.stopPropagation();
842					return false;
843				});
844
845			mounth_picker
846				.find('.xdsoft_select')
847					.xdsoftScroller()
848				.on('mousedown.xdsoft', function (event) {
849					event.stopPropagation();
850					event.preventDefault();
851				})
852				.on('mousedown.xdsoft', '.xdsoft_option', function (event) {
853
854					if (_xdsoft_datetime.currentTime === undefined || _xdsoft_datetime.currentTime === null) {
855						_xdsoft_datetime.currentTime = _xdsoft_datetime.now();
856					}
857
858					var year = _xdsoft_datetime.currentTime.getFullYear();
859					if (_xdsoft_datetime && _xdsoft_datetime.currentTime) {
860						_xdsoft_datetime.currentTime[$(this).parent().parent().hasClass('xdsoft_monthselect') ? 'setMonth' : 'setFullYear']($(this).data('value'));
861					}
862
863					$(this).parent().parent().hide();
864
865					datetimepicker.trigger('xchange.xdsoft');
866					if (options.onChangeMonth && $.isFunction(options.onChangeMonth)) {
867						options.onChangeMonth.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
868					}
869
870					if (year !== _xdsoft_datetime.currentTime.getFullYear() && $.isFunction(options.onChangeYear)) {
871						options.onChangeYear.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
872					}
873				});
874
875			datetimepicker.setOptions = function (_options) {
876				var highlightedDates = {},
877					getCaretPos = function (input) {
878						try {
879							if (document.selection && document.selection.createRange) {
880								var range = document.selection.createRange();
881								return range.getBookmark().charCodeAt(2) - 2;
882							}
883							if (input.setSelectionRange) {
884								return input.selectionStart;
885							}
886						} catch (e) {
887							return 0;
888						}
889					},
890					setCaretPos = function (node, pos) {
891						node = (typeof node === "string" || node instanceof String) ? document.getElementById(node) : node;
892						if (!node) {
893							return false;
894						}
895						if (node.createTextRange) {
896							var textRange = node.createTextRange();
897							textRange.collapse(true);
898							textRange.moveEnd('character', pos);
899							textRange.moveStart('character', pos);
900							textRange.select();
901							return true;
902						}
903						if (node.setSelectionRange) {
904							node.setSelectionRange(pos, pos);
905							return true;
906						}
907						return false;
908					},
909					isValidValue = function (mask, value) {
910						var reg = mask
911							.replace(/([\[\]\/\{\}\(\)\-\.\+]{1})/g, '\\$1')
912							.replace(/_/g, '{digit+}')
913							.replace(/([0-9]{1})/g, '{digit$1}')
914							.replace(/\{digit([0-9]{1})\}/g, '[0-$1_]{1}')
915							.replace(/\{digit[\+]\}/g, '[0-9_]{1}');
916						return (new RegExp(reg)).test(value);
917					};
918				options = $.extend(true, {}, options, _options);
919
920				if (_options.allowTimes && $.isArray(_options.allowTimes) && _options.allowTimes.length) {
921					options.allowTimes = $.extend(true, [], _options.allowTimes);
922				}
923
924				if (_options.weekends && $.isArray(_options.weekends) && _options.weekends.length) {
925					options.weekends = $.extend(true, [], _options.weekends);
926				}
927
928				if (_options.highlightedDates && $.isArray(_options.highlightedDates) && _options.highlightedDates.length) {
929					$.each(_options.highlightedDates, function (index, value) {
930						var splitData = $.map(value.split(','), $.trim),
931							exDesc,
932							hDate = new HighlightedDate(Date.parseDate(splitData[0], options.formatDate), splitData[1], splitData[2]), // date, desc, style
933							keyDate = hDate.date.dateFormat(options.formatDate);
934						if (highlightedDates[keyDate] !== undefined) {
935							exDesc = highlightedDates[keyDate].desc;
936							if (exDesc && exDesc.length && hDate.desc && hDate.desc.length) {
937								highlightedDates[keyDate].desc = exDesc + "\n" + hDate.desc;
938							}
939						} else {
940							highlightedDates[keyDate] = hDate;
941						}
942					});
943
944					options.highlightedDates = $.extend(true, [], highlightedDates);
945				}
946
947				if (_options.highlightedPeriods && $.isArray(_options.highlightedPeriods) && _options.highlightedPeriods.length) {
948					highlightedDates = $.extend(true, [], options.highlightedDates);
949					$.each(_options.highlightedPeriods, function (index, value) {
950						var splitData = $.map(value.split(','), $.trim),
951							dateTest = Date.parseDate(splitData[0], options.formatDate), // start date
952							dateEnd = Date.parseDate(splitData[1], options.formatDate),
953							desc = splitData[2],
954							hDate,
955							keyDate,
956							exDesc,
957							style = splitData[3];
958
959						while (dateTest <= dateEnd) {
960							hDate = new HighlightedDate(dateTest, desc, style);
961							keyDate = dateTest.dateFormat(options.formatDate);
962							dateTest.setDate(dateTest.getDate() + 1);
963							if (highlightedDates[keyDate] !== undefined) {
964								exDesc = highlightedDates[keyDate].desc;
965								if (exDesc && exDesc.length && hDate.desc && hDate.desc.length) {
966									highlightedDates[keyDate].desc = exDesc + "\n" + hDate.desc;
967								}
968							} else {
969								highlightedDates[keyDate] = hDate;
970							}
971						}
972					});
973
974					options.highlightedDates = $.extend(true, [], highlightedDates);
975				}
976
977				if (_options.disabledDates && $.isArray(_options.disabledDates) && _options.disabledDates.length) {
978					options.disabledDates = $.extend(true, [], _options.disabledDates);
979				}
980
981				if (_options.disabledWeekDays && $.isArray(_options.disabledWeekDays) && _options.disabledWeekDays.length) {
982				    options.disabledWeekDays = $.extend(true, [], _options.disabledWeekDays);
983				}
984
985				if ((options.open || options.opened) && (!options.inline)) {
986					input.trigger('open.xdsoft');
987				}
988
989				if (options.inline) {
990					triggerAfterOpen = true;
991					datetimepicker.addClass('xdsoft_inline');
992					input.after(datetimepicker).hide();
993				}
994
995				if (options.inverseButton) {
996					options.next = 'xdsoft_prev';
997					options.prev = 'xdsoft_next';
998				}
999
1000				if (options.datepicker) {
1001					datepicker.addClass('active');
1002				} else {
1003					datepicker.removeClass('active');
1004				}
1005
1006				if (options.timepicker) {
1007					timepicker.addClass('active');
1008				} else {
1009					timepicker.removeClass('active');
1010				}
1011
1012				if (options.value) {
1013					_xdsoft_datetime.setCurrentTime(options.value);
1014					if (input && input.val) {
1015						input.val(_xdsoft_datetime.str);
1016					}
1017				}
1018
1019				if (isNaN(options.dayOfWeekStart)) {
1020					options.dayOfWeekStart = 0;
1021				} else {
1022					options.dayOfWeekStart = parseInt(options.dayOfWeekStart, 10) % 7;
1023				}
1024
1025				if (!options.timepickerScrollbar) {
1026					timeboxparent.xdsoftScroller('hide');
1027				}
1028
1029				if (options.minDate && /^-(.*)$/.test(options.minDate)) {
1030					options.minDate = _xdsoft_datetime.strToDateTime(options.minDate).dateFormat(options.formatDate);
1031				}
1032
1033				if (options.maxDate &&  /^\+(.*)$/.test(options.maxDate)) {
1034					options.maxDate = _xdsoft_datetime.strToDateTime(options.maxDate).dateFormat(options.formatDate);
1035				}
1036
1037				applyButton.toggle(options.showApplyButton);
1038
1039				mounth_picker
1040					.find('.xdsoft_today_button')
1041						.css('visibility', !options.todayButton ? 'hidden' : 'visible');
1042
1043				mounth_picker
1044					.find('.' + options.prev)
1045						.css('visibility', !options.prevButton ? 'hidden' : 'visible');
1046
1047				mounth_picker
1048					.find('.' + options.next)
1049						.css('visibility', !options.nextButton ? 'hidden' : 'visible');
1050
1051				if (options.mask) {
1052					input.off('keydown.xdsoft');
1053
1054					if (options.mask === true) {
1055						options.mask = options.format
1056							.replace(/Y/g, '9999')
1057							.replace(/F/g, '9999')
1058							.replace(/m/g, '19')
1059							.replace(/d/g, '39')
1060							.replace(/H/g, '29')
1061							.replace(/i/g, '59')
1062							.replace(/s/g, '59');
1063					}
1064
1065					if ($.type(options.mask) === 'string') {
1066						if (!isValidValue(options.mask, input.val())) {
1067							input.val(options.mask.replace(/[0-9]/g, '_'));
1068						}
1069
1070						input.on('keydown.xdsoft', function (event) {
1071							var val = this.value,
1072								key = event.which,
1073								pos,
1074								digit;
1075
1076							if (((key >= KEY0 && key <= KEY9) || (key >= _KEY0 && key <= _KEY9)) || (key === BACKSPACE || key === DEL)) {
1077								pos = getCaretPos(this);
1078								digit = (key !== BACKSPACE && key !== DEL) ? String.fromCharCode((_KEY0 <= key && key <= _KEY9) ? key - KEY0 : key) : '_';
1079
1080								if ((key === BACKSPACE || key === DEL) && pos) {
1081									pos -= 1;
1082									digit = '_';
1083								}
1084
1085								while (/[^0-9_]/.test(options.mask.substr(pos, 1)) && pos < options.mask.length && pos > 0) {
1086									pos += (key === BACKSPACE || key === DEL) ? -1 : 1;
1087								}
1088
1089								val = val.substr(0, pos) + digit + val.substr(pos + 1);
1090								if ($.trim(val) === '') {
1091									val = options.mask.replace(/[0-9]/g, '_');
1092								} else {
1093									if (pos === options.mask.length) {
1094										event.preventDefault();
1095										return false;
1096									}
1097								}
1098
1099								pos += (key === BACKSPACE || key === DEL) ? 0 : 1;
1100								while (/[^0-9_]/.test(options.mask.substr(pos, 1)) && pos < options.mask.length && pos > 0) {
1101									pos += (key === BACKSPACE || key === DEL) ? -1 : 1;
1102								}
1103
1104								if (isValidValue(options.mask, val)) {
1105									this.value = val;
1106									setCaretPos(this, pos);
1107								} else if ($.trim(val) === '') {
1108									this.value = options.mask.replace(/[0-9]/g, '_');
1109								} else {
1110									input.trigger('error_input.xdsoft');
1111								}
1112							} else {
1113								if (([AKEY, CKEY, VKEY, ZKEY, YKEY].indexOf(key) !== -1 && ctrlDown) || [ESC, ARROWUP, ARROWDOWN, ARROWLEFT, ARROWRIGHT, F5, CTRLKEY, TAB, ENTER].indexOf(key) !== -1) {
1114									return true;
1115								}
1116							}
1117
1118							event.preventDefault();
1119							return false;
1120						});
1121					}
1122				}
1123				if (options.validateOnBlur) {
1124					input
1125						.off('blur.xdsoft')
1126						.on('blur.xdsoft', function () {
1127							if (options.allowBlank && !$.trim($(this).val()).length) {
1128								$(this).val(null);
1129								datetimepicker.data('xdsoft_datetime').empty();
1130							} else if (!Date.parseDate($(this).val(), options.format)) {
1131								var splittedHours   = +([$(this).val()[0], $(this).val()[1]].join('')),
1132									splittedMinutes = +([$(this).val()[2], $(this).val()[3]].join(''));
1133
1134								// parse the numbers as 0312 => 03:12
1135								if (!options.datepicker && options.timepicker && splittedHours >= 0 && splittedHours < 24 && splittedMinutes >= 0 && splittedMinutes < 60) {
1136									$(this).val([splittedHours, splittedMinutes].map(function (item) {
1137										return item > 9 ? item : '0' + item;
1138									}).join(':'));
1139								} else {
1140									$(this).val((_xdsoft_datetime.now()).dateFormat(options.format));
1141								}
1142
1143								datetimepicker.data('xdsoft_datetime').setCurrentTime($(this).val());
1144							} else {
1145								datetimepicker.data('xdsoft_datetime').setCurrentTime($(this).val());
1146							}
1147
1148							datetimepicker.trigger('changedatetime.xdsoft');
1149						});
1150				}
1151				options.dayOfWeekStartPrev = (options.dayOfWeekStart === 0) ? 6 : options.dayOfWeekStart - 1;
1152
1153				datetimepicker
1154					.trigger('xchange.xdsoft')
1155					.trigger('afterOpen.xdsoft');
1156			};
1157
1158			datetimepicker
1159				.data('options', options)
1160				.on('mousedown.xdsoft', function (event) {
1161					event.stopPropagation();
1162					event.preventDefault();
1163					yearselect.hide();
1164					monthselect.hide();
1165					return false;
1166				});
1167
1168			//scroll_element = timepicker.find('.xdsoft_time_box');
1169			timeboxparent.append(timebox);
1170			timeboxparent.xdsoftScroller();
1171
1172			datetimepicker.on('afterOpen.xdsoft', function () {
1173				timeboxparent.xdsoftScroller();
1174			});
1175
1176			datetimepicker
1177				.append(datepicker)
1178				.append(timepicker);
1179
1180			if (options.withoutCopyright !== true) {
1181				datetimepicker
1182					.append(xdsoft_copyright);
1183			}
1184
1185			datepicker
1186				.append(mounth_picker)
1187				.append(calendar)
1188				.append(applyButton);
1189
1190			$(options.parentID)
1191				.append(datetimepicker);
1192
1193			XDSoft_datetime = function () {
1194				var _this = this;
1195				_this.now = function (norecursion) {
1196					var d = new Date(),
1197						date,
1198						time;
1199
1200					if (!norecursion && options.defaultDate) {
1201						date = _this.strToDateTime(options.defaultDate);
1202						d.setFullYear(date.getFullYear());
1203						d.setMonth(date.getMonth());
1204						d.setDate(date.getDate());
1205					}
1206
1207					if (options.yearOffset) {
1208						d.setFullYear(d.getFullYear() + options.yearOffset);
1209					}
1210
1211					if (!norecursion && options.defaultTime) {
1212						time = _this.strtotime(options.defaultTime);
1213						d.setHours(time.getHours());
1214						d.setMinutes(time.getMinutes());
1215					}
1216					return d;
1217				};
1218
1219				_this.isValidDate = function (d) {
1220					if (Object.prototype.toString.call(d) !== "[object Date]") {
1221						return false;
1222					}
1223					return !isNaN(d.getTime());
1224				};
1225
1226				_this.setCurrentTime = function (dTime) {
1227					_this.currentTime = (typeof dTime === 'string') ? _this.strToDateTime(dTime) : _this.isValidDate(dTime) ? dTime : _this.now();
1228					datetimepicker.trigger('xchange.xdsoft');
1229				};
1230
1231				_this.empty = function () {
1232					_this.currentTime = null;
1233				};
1234
1235				_this.getCurrentTime = function (dTime) {
1236					return _this.currentTime;
1237				};
1238
1239				_this.nextMonth = function () {
1240
1241					if (_this.currentTime === undefined || _this.currentTime === null) {
1242						_this.currentTime = _this.now();
1243					}
1244
1245					var month = _this.currentTime.getMonth() + 1,
1246						year;
1247					if (month === 12) {
1248						_this.currentTime.setFullYear(_this.currentTime.getFullYear() + 1);
1249						month = 0;
1250					}
1251
1252					year = _this.currentTime.getFullYear();
1253
1254					_this.currentTime.setDate(
1255						Math.min(
1256							new Date(_this.currentTime.getFullYear(), month + 1, 0).getDate(),
1257							_this.currentTime.getDate()
1258						)
1259					);
1260					_this.currentTime.setMonth(month);
1261
1262					if (options.onChangeMonth && $.isFunction(options.onChangeMonth)) {
1263						options.onChangeMonth.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
1264					}
1265
1266					if (year !== _this.currentTime.getFullYear() && $.isFunction(options.onChangeYear)) {
1267						options.onChangeYear.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
1268					}
1269
1270					datetimepicker.trigger('xchange.xdsoft');
1271					return month;
1272				};
1273
1274				_this.prevMonth = function () {
1275
1276					if (_this.currentTime === undefined || _this.currentTime === null) {
1277						_this.currentTime = _this.now();
1278					}
1279
1280					var month = _this.currentTime.getMonth() - 1;
1281					if (month === -1) {
1282						_this.currentTime.setFullYear(_this.currentTime.getFullYear() - 1);
1283						month = 11;
1284					}
1285					_this.currentTime.setDate(
1286						Math.min(
1287							new Date(_this.currentTime.getFullYear(), month + 1, 0).getDate(),
1288							_this.currentTime.getDate()
1289						)
1290					);
1291					_this.currentTime.setMonth(month);
1292					if (options.onChangeMonth && $.isFunction(options.onChangeMonth)) {
1293						options.onChangeMonth.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
1294					}
1295					datetimepicker.trigger('xchange.xdsoft');
1296					return month;
1297				};
1298
1299				_this.getWeekOfYear = function (datetime) {
1300					var onejan = new Date(datetime.getFullYear(), 0, 1);
1301					return Math.ceil((((datetime - onejan) / 86400000) + onejan.getDay() + 1) / 7);
1302				};
1303
1304				_this.strToDateTime = function (sDateTime) {
1305					var tmpDate = [], timeOffset, currentTime;
1306
1307					if (sDateTime && sDateTime instanceof Date && _this.isValidDate(sDateTime)) {
1308						return sDateTime;
1309					}
1310
1311					tmpDate = /^(\+|\-)(.*)$/.exec(sDateTime);
1312					if (tmpDate) {
1313						tmpDate[2] = Date.parseDate(tmpDate[2], options.formatDate);
1314					}
1315					if (tmpDate  && tmpDate[2]) {
1316						timeOffset = tmpDate[2].getTime() - (tmpDate[2].getTimezoneOffset()) * 60000;
1317						currentTime = new Date((_this.now(true)).getTime() + parseInt(tmpDate[1] + '1', 10) * timeOffset);
1318					} else {
1319						currentTime = sDateTime ? Date.parseDate(sDateTime, options.format) : _this.now();
1320					}
1321
1322					if (!_this.isValidDate(currentTime)) {
1323						currentTime = _this.now();
1324					}
1325
1326					return currentTime;
1327				};
1328
1329				_this.strToDate = function (sDate) {
1330					if (sDate && sDate instanceof Date && _this.isValidDate(sDate)) {
1331						return sDate;
1332					}
1333
1334					var currentTime = sDate ? Date.parseDate(sDate, options.formatDate) : _this.now(true);
1335					if (!_this.isValidDate(currentTime)) {
1336						currentTime = _this.now(true);
1337					}
1338					return currentTime;
1339				};
1340
1341				_this.strtotime = function (sTime) {
1342					if (sTime && sTime instanceof Date && _this.isValidDate(sTime)) {
1343						return sTime;
1344					}
1345					var currentTime = sTime ? Date.parseDate(sTime, options.formatTime) : _this.now(true);
1346					if (!_this.isValidDate(currentTime)) {
1347						currentTime = _this.now(true);
1348					}
1349					return currentTime;
1350				};
1351
1352				_this.str = function () {
1353					return _this.currentTime.dateFormat(options.format);
1354				};
1355				_this.currentTime = this.now();
1356			};
1357
1358			_xdsoft_datetime = new XDSoft_datetime();
1359
1360			applyButton.on('click', function (e) {//pathbrite
1361                e.preventDefault();
1362                datetimepicker.data('changed', true);
1363                _xdsoft_datetime.setCurrentTime(getCurrentValue());
1364                input.val(_xdsoft_datetime.str());
1365                datetimepicker.trigger('close.xdsoft');
1366            });
1367			mounth_picker
1368				.find('.xdsoft_today_button')
1369				.on('mousedown.xdsoft', function () {
1370					datetimepicker.data('changed', true);
1371					_xdsoft_datetime.setCurrentTime(0);
1372					datetimepicker.trigger('afterOpen.xdsoft');
1373				}).on('dblclick.xdsoft', function () {
1374					var currentDate = _xdsoft_datetime.getCurrentTime(), minDate, maxDate;
1375					currentDate = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate());
1376					minDate = _xdsoft_datetime.strToDate(options.minDate);
1377					minDate = new Date(minDate.getFullYear(), minDate.getMonth(), minDate.getDate());
1378					if (currentDate < minDate) {
1379						return;
1380					}
1381					maxDate = _xdsoft_datetime.strToDate(options.maxDate);
1382					maxDate = new Date(maxDate.getFullYear(), maxDate.getMonth(), maxDate.getDate());
1383					if (currentDate > maxDate) {
1384						return;
1385					}
1386					input.val(_xdsoft_datetime.str());
1387					datetimepicker.trigger('close.xdsoft');
1388				});
1389			mounth_picker
1390				.find('.xdsoft_prev,.xdsoft_next')
1391				.on('mousedown.xdsoft', function () {
1392					var $this = $(this),
1393						timer = 0,
1394						stop = false;
1395
1396					(function arguments_callee1(v) {
1397						if ($this.hasClass(options.next)) {
1398							_xdsoft_datetime.nextMonth();
1399						} else if ($this.hasClass(options.prev)) {
1400							_xdsoft_datetime.prevMonth();
1401						}
1402						if (options.monthChangeSpinner) {
1403							if (!stop) {
1404								timer = setTimeout(arguments_callee1, v || 100);
1405							}
1406						}
1407					}(500));
1408
1409					$([document.body, window]).on('mouseup.xdsoft', function arguments_callee2() {
1410						clearTimeout(timer);
1411						stop = true;
1412						$([document.body, window]).off('mouseup.xdsoft', arguments_callee2);
1413					});
1414				});
1415
1416			timepicker
1417				.find('.xdsoft_prev,.xdsoft_next')
1418				.on('mousedown.xdsoft', function () {
1419					var $this = $(this),
1420						timer = 0,
1421						stop = false,
1422						period = 110;
1423					(function arguments_callee4(v) {
1424						var pheight = timeboxparent[0].clientHeight,
1425							height = timebox[0].offsetHeight,
1426							top = Math.abs(parseInt(timebox.css('marginTop'), 10));
1427						if ($this.hasClass(options.next) && (height - pheight) - options.timeHeightInTimePicker >= top) {
1428							timebox.css('marginTop', '-' + (top + options.timeHeightInTimePicker) + 'px');
1429						} else if ($this.hasClass(options.prev) && top - options.timeHeightInTimePicker >= 0) {
1430							timebox.css('marginTop', '-' + (top - options.timeHeightInTimePicker) + 'px');
1431						}
1432						timeboxparent.trigger('scroll_element.xdsoft_scroller', [Math.abs(parseInt(timebox.css('marginTop'), 10) / (height - pheight))]);
1433						period = (period > 10) ? 10 : period - 10;
1434						if (!stop) {
1435							timer = setTimeout(arguments_callee4, v || period);
1436						}
1437					}(500));
1438					$([document.body, window]).on('mouseup.xdsoft', function arguments_callee5() {
1439						clearTimeout(timer);
1440						stop = true;
1441						$([document.body, window])
1442							.off('mouseup.xdsoft', arguments_callee5);
1443					});
1444				});
1445
1446			xchangeTimer = 0;
1447			// base handler - generating a calendar and timepicker
1448			datetimepicker
1449				.on('xchange.xdsoft', function (event) {
1450					clearTimeout(xchangeTimer);
1451					xchangeTimer = setTimeout(function () {
1452
1453						if (_xdsoft_datetime.currentTime === undefined || _xdsoft_datetime.currentTime === null) {
1454							_xdsoft_datetime.currentTime = _xdsoft_datetime.now();
1455						}
1456
1457						var table =	'',
1458							start = new Date(_xdsoft_datetime.currentTime.getFullYear(), _xdsoft_datetime.currentTime.getMonth(), 1, 12, 0, 0),
1459							i = 0,
1460							j,
1461							today = _xdsoft_datetime.now(),
1462							maxDate = false,
1463							minDate = false,
1464							hDate,
1465							day,
1466							d,
1467							y,
1468							m,
1469							w,
1470							classes = [],
1471							customDateSettings,
1472							newRow = true,
1473							time = '',
1474							h = '',
1475							line_time,
1476							description;
1477
1478						while (start.getDay() !== options.dayOfWeekStart) {
1479							start.setDate(start.getDate() - 1);
1480						}
1481
1482						table += '<table><thead><tr>';
1483
1484						if (options.weeks) {
1485							table += '<th></th>';
1486						}
1487
1488						for (j = 0; j < 7; j += 1) {
1489							table += '<th>' + options.i18n[options.lang].dayOfWeek[(j + options.dayOfWeekStart) % 7] + '</th>';
1490						}
1491
1492						table += '</tr></thead>';
1493						table += '<tbody>';
1494
1495						if (options.maxDate !== false) {
1496							maxDate = _xdsoft_datetime.strToDate(options.maxDate);
1497							maxDate = new Date(maxDate.getFullYear(), maxDate.getMonth(), maxDate.getDate(), 23, 59, 59, 999);
1498						}
1499
1500						if (options.minDate !== false) {
1501							minDate = _xdsoft_datetime.strToDate(options.minDate);
1502							minDate = new Date(minDate.getFullYear(), minDate.getMonth(), minDate.getDate());
1503						}
1504
1505						while (i < _xdsoft_datetime.currentTime.countDaysInMonth() || start.getDay() !== options.dayOfWeekStart || _xdsoft_datetime.currentTime.getMonth() === start.getMonth()) {
1506							classes = [];
1507							i += 1;
1508
1509							day = start.getDay();
1510							d = start.getDate();
1511							y = start.getFullYear();
1512							m = start.getMonth();
1513							w = _xdsoft_datetime.getWeekOfYear(start);
1514							description = '';
1515
1516							classes.push('xdsoft_date');
1517
1518							if (options.beforeShowDay && $.isFunction(options.beforeShowDay.call)) {
1519								customDateSettings = options.beforeShowDay.call(datetimepicker, start);
1520							} else {
1521								customDateSettings = null;
1522							}
1523
1524							if ((maxDate !== false && start > maxDate) || (minDate !== false && start < minDate) || (customDateSettings && customDateSettings[0] === false)) {
1525								classes.push('xdsoft_disabled');
1526							} else if (options.disabledDates.indexOf(start.dateFormat(options.formatDate)) !== -1) {
1527								classes.push('xdsoft_disabled');
1528							} else if (options.disabledWeekDays.indexOf(day) !== -1) {
1529							    classes.push('xdsoft_disabled');
1530							}
1531
1532							if (customDateSettings && customDateSettings[1] !== "") {
1533								classes.push(customDateSettings[1]);
1534							}
1535
1536							if (_xdsoft_datetime.currentTime.getMonth() !== m) {
1537								classes.push('xdsoft_other_month');
1538							}
1539
1540							if ((options.defaultSelect || datetimepicker.data('changed')) && _xdsoft_datetime.currentTime.dateFormat(options.formatDate) === start.dateFormat(options.formatDate)) {
1541								classes.push('xdsoft_current');
1542							}
1543
1544							if (today.dateFormat(options.formatDate) === start.dateFormat(options.formatDate)) {
1545								classes.push('xdsoft_today');
1546							}
1547
1548							if (start.getDay() === 0 || start.getDay() === 6 || options.weekends.indexOf(start.dateFormat(options.formatDate)) !== -1) {
1549								classes.push('xdsoft_weekend');
1550							}
1551
1552							if (options.highlightedDates[start.dateFormat(options.formatDate)] !== undefined) {
1553								hDate = options.highlightedDates[start.dateFormat(options.formatDate)];
1554								classes.push(hDate.style === undefined ? 'xdsoft_highlighted_default' : hDate.style);
1555								description = hDate.desc === undefined ? '' : hDate.desc;
1556							}
1557
1558							if (options.beforeShowDay && $.isFunction(options.beforeShowDay)) {
1559								classes.push(options.beforeShowDay(start));
1560							}
1561
1562							if (newRow) {
1563								table += '<tr>';
1564								newRow = false;
1565								if (options.weeks) {
1566									table += '<th>' + w + '</th>';
1567								}
1568							}
1569
1570							table += '<td data-date="' + d + '" data-month="' + m + '" data-year="' + y + '"' + ' class="xdsoft_date xdsoft_day_of_week' + start.getDay() + ' ' + classes.join(' ') + '" title="' + description + '">' +
1571										'<div>' + d + '</div>' +
1572									'</td>';
1573
1574							if (start.getDay() === options.dayOfWeekStartPrev) {
1575								table += '</tr>';
1576								newRow = true;
1577							}
1578
1579							start.setDate(d + 1);
1580						}
1581						table += '</tbody></table>';
1582
1583						calendar.html(table);
1584
1585						mounth_picker.find('.xdsoft_label span').eq(0).text(options.i18n[options.lang].months[_xdsoft_datetime.currentTime.getMonth()]);
1586						mounth_picker.find('.xdsoft_label span').eq(1).text(_xdsoft_datetime.currentTime.getFullYear());
1587
1588						// generate timebox
1589						time = '';
1590						h = '';
1591						m = '';
1592						line_time = function line_time(h, m) {
1593							var now = _xdsoft_datetime.now(), optionDateTime, current_time;
1594							now.setHours(h);
1595							h = parseInt(now.getHours(), 10);
1596							now.setMinutes(m);
1597							m = parseInt(now.getMinutes(), 10);
1598							optionDateTime = new Date(_xdsoft_datetime.currentTime);
1599							optionDateTime.setHours(h);
1600							optionDateTime.setMinutes(m);
1601							classes = [];
1602							if ((options.minDateTime !== false && options.minDateTime > optionDateTime) || (options.maxTime !== false && _xdsoft_datetime.strtotime(options.maxTime).getTime() < now.getTime()) || (options.minTime !== false && _xdsoft_datetime.strtotime(options.minTime).getTime() > now.getTime())) {
1603								classes.push('xdsoft_disabled');
1604							}
1605							if ((options.minDateTime !== false && options.minDateTime > optionDateTime) || ((options.disabledMinTime !== false && now.getTime() > _xdsoft_datetime.strtotime(options.disabledMinTime).getTime()) && (options.disabledMaxTime !== false && now.getTime() < _xdsoft_datetime.strtotime(options.disabledMaxTime).getTime()))) {
1606								classes.push('xdsoft_disabled');
1607							}
1608
1609							current_time = new Date(_xdsoft_datetime.currentTime);
1610							current_time.setHours(parseInt(_xdsoft_datetime.currentTime.getHours(), 10));
1611							current_time.setMinutes(Math[options.roundTime](_xdsoft_datetime.currentTime.getMinutes() / options.step) * options.step);
1612
1613							if ((options.initTime || options.defaultSelect || datetimepicker.data('changed')) && current_time.getHours() === parseInt(h, 10) && (options.step > 59 || current_time.getMinutes() === parseInt(m, 10))) {
1614								if (options.defaultSelect || datetimepicker.data('changed')) {
1615									classes.push('xdsoft_current');
1616								} else if (options.initTime) {
1617									classes.push('xdsoft_init_time');
1618								}
1619							}
1620							if (parseInt(today.getHours(), 10) === parseInt(h, 10) && parseInt(today.getMinutes(), 10) === parseInt(m, 10)) {
1621								classes.push('xdsoft_today');
1622							}
1623							time += '<div class="xdsoft_time ' + classes.join(' ') + '" data-hour="' + h + '" data-minute="' + m + '">' + now.dateFormat(options.formatTime) + '</div>';
1624						};
1625
1626						if (!options.allowTimes || !$.isArray(options.allowTimes) || !options.allowTimes.length) {
1627							for (i = 0, j = 0; i < (options.hours12 ? 12 : 24); i += 1) {
1628								for (j = 0; j < 60; j += options.step) {
1629									h = (i < 10 ? '0' : '') + i;
1630									m = (j < 10 ? '0' : '') + j;
1631									line_time(h, m);
1632								}
1633							}
1634						} else {
1635							for (i = 0; i < options.allowTimes.length; i += 1) {
1636								h = _xdsoft_datetime.strtotime(options.allowTimes[i]).getHours();
1637								m = _xdsoft_datetime.strtotime(options.allowTimes[i]).getMinutes();
1638								line_time(h, m);
1639							}
1640						}
1641
1642						timebox.html(time);
1643
1644						opt = '';
1645						i = 0;
1646
1647						for (i = parseInt(options.yearStart, 10) + options.yearOffset; i <= parseInt(options.yearEnd, 10) + options.yearOffset; i += 1) {
1648							opt += '<div class="xdsoft_option ' + (_xdsoft_datetime.currentTime.getFullYear() === i ? 'xdsoft_current' : '') + '" data-value="' + i + '">' + i + '</div>';
1649						}
1650						yearselect.children().eq(0)
1651												.html(opt);
1652
1653						for (i = parseInt(options.monthStart, 10), opt = ''; i <= parseInt(options.monthEnd, 10); i += 1) {
1654							opt += '<div class="xdsoft_option ' + (_xdsoft_datetime.currentTime.getMonth() === i ? 'xdsoft_current' : '') + '" data-value="' + i + '">' + options.i18n[options.lang].months[i] + '</div>';
1655						}
1656						monthselect.children().eq(0).html(opt);
1657						$(datetimepicker)
1658							.trigger('generate.xdsoft');
1659					}, 10);
1660					event.stopPropagation();
1661				})
1662				.on('afterOpen.xdsoft', function () {
1663					if (options.timepicker) {
1664						var classType, pheight, height, top;
1665						if (timebox.find('.xdsoft_current').length) {
1666							classType = '.xdsoft_current';
1667						} else if (timebox.find('.xdsoft_init_time').length) {
1668							classType = '.xdsoft_init_time';
1669						}
1670						if (classType) {
1671							pheight = timeboxparent[0].clientHeight;
1672							height = timebox[0].offsetHeight;
1673							top = timebox.find(classType).index() * options.timeHeightInTimePicker + 1;
1674							if ((height - pheight) < top) {
1675								top = height - pheight;
1676							}
1677							timeboxparent.trigger('scroll_element.xdsoft_scroller', [parseInt(top, 10) / (height - pheight)]);
1678						} else {
1679							timeboxparent.trigger('scroll_element.xdsoft_scroller', [0]);
1680						}
1681					}
1682				});
1683
1684			timerclick = 0;
1685			calendar
1686				.on('click.xdsoft', 'td', function (xdevent) {
1687					xdevent.stopPropagation();  // Prevents closing of Pop-ups, Modals and Flyouts in Bootstrap
1688					timerclick += 1;
1689					var $this = $(this),
1690						currentTime = _xdsoft_datetime.currentTime;
1691
1692					if (currentTime === undefined || currentTime === null) {
1693						_xdsoft_datetime.currentTime = _xdsoft_datetime.now();
1694						currentTime = _xdsoft_datetime.currentTime;
1695					}
1696
1697					if ($this.hasClass('xdsoft_disabled')) {
1698						return false;
1699					}
1700
1701					currentTime.setDate(1);
1702					currentTime.setFullYear($this.data('year'));
1703					currentTime.setMonth($this.data('month'));
1704					currentTime.setDate($this.data('date'));
1705
1706					datetimepicker.trigger('select.xdsoft', [currentTime]);
1707
1708					input.val(_xdsoft_datetime.str());
1709					if ((timerclick > 1 || (options.closeOnDateSelect === true || (options.closeOnDateSelect === false && !options.timepicker))) && !options.inline) {
1710						datetimepicker.trigger('close.xdsoft');
1711					}
1712
1713					if (options.onSelectDate &&	$.isFunction(options.onSelectDate)) {
1714						options.onSelectDate.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), xdevent);
1715					}
1716
1717					datetimepicker.data('changed', true);
1718					datetimepicker.trigger('xchange.xdsoft');
1719					datetimepicker.trigger('changedatetime.xdsoft');
1720					setTimeout(function () {
1721						timerclick = 0;
1722					}, 200);
1723				});
1724
1725			timebox
1726				.on('click.xdsoft', 'div', function (xdevent) {
1727					xdevent.stopPropagation();
1728					var $this = $(this),
1729						currentTime = _xdsoft_datetime.currentTime;
1730
1731					if (currentTime === undefined || currentTime === null) {
1732						_xdsoft_datetime.currentTime = _xdsoft_datetime.now();
1733						currentTime = _xdsoft_datetime.currentTime;
1734					}
1735
1736					if ($this.hasClass('xdsoft_disabled')) {
1737						return false;
1738					}
1739					currentTime.setHours($this.data('hour'));
1740					currentTime.setMinutes($this.data('minute'));
1741					datetimepicker.trigger('select.xdsoft', [currentTime]);
1742
1743					datetimepicker.data('input').val(_xdsoft_datetime.str());
1744
1745                    if (options.inline !== true && options.closeOnTimeSelect === true) {
1746                        datetimepicker.trigger('close.xdsoft');
1747                    }
1748
1749					if (options.onSelectTime && $.isFunction(options.onSelectTime)) {
1750						options.onSelectTime.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), xdevent);
1751					}
1752					datetimepicker.data('changed', true);
1753					datetimepicker.trigger('xchange.xdsoft');
1754					datetimepicker.trigger('changedatetime.xdsoft');
1755				});
1756
1757
1758			datepicker
1759				.on('mousewheel.xdsoft', function (event) {
1760					if (!options.scrollMonth) {
1761						return true;
1762					}
1763					if (event.deltaY < 0) {
1764						_xdsoft_datetime.nextMonth();
1765					} else {
1766						_xdsoft_datetime.prevMonth();
1767					}
1768					return false;
1769				});
1770
1771			input
1772				.on('mousewheel.xdsoft', function (event) {
1773					if (!options.scrollInput) {
1774						return true;
1775					}
1776					if (!options.datepicker && options.timepicker) {
1777						current_time_index = timebox.find('.xdsoft_current').length ? timebox.find('.xdsoft_current').eq(0).index() : 0;
1778						if (current_time_index + event.deltaY >= 0 && current_time_index + event.deltaY < timebox.children().length) {
1779							current_time_index += event.deltaY;
1780						}
1781						if (timebox.children().eq(current_time_index).length) {
1782							timebox.children().eq(current_time_index).trigger('mousedown');
1783						}
1784						return false;
1785					}
1786					if (options.datepicker && !options.timepicker) {
1787						datepicker.trigger(event, [event.deltaY, event.deltaX, event.deltaY]);
1788						if (input.val) {
1789							input.val(_xdsoft_datetime.str());
1790						}
1791						datetimepicker.trigger('changedatetime.xdsoft');
1792						return false;
1793					}
1794				});
1795
1796			datetimepicker
1797				.on('changedatetime.xdsoft', function (event) {
1798					if (options.onChangeDateTime && $.isFunction(options.onChangeDateTime)) {
1799						var $input = datetimepicker.data('input');
1800						options.onChangeDateTime.call(datetimepicker, _xdsoft_datetime.currentTime, $input, event);
1801						delete options.value;
1802						$input.trigger('change');
1803					}
1804				})
1805				.on('generate.xdsoft', function () {
1806					if (options.onGenerate && $.isFunction(options.onGenerate)) {
1807						options.onGenerate.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
1808					}
1809					if (triggerAfterOpen) {
1810						datetimepicker.trigger('afterOpen.xdsoft');
1811						triggerAfterOpen = false;
1812					}
1813				})
1814				.on('click.xdsoft', function (xdevent) {
1815					xdevent.stopPropagation();
1816				});
1817
1818			current_time_index = 0;
1819
1820			setPos = function () {
1821				var offset = datetimepicker.data('input').offset(), top = offset.top + datetimepicker.data('input')[0].offsetHeight - 1, left = offset.left, position = "absolute", node;
1822				if (options.fixed) {
1823					top -= $(window).scrollTop();
1824					left -= $(window).scrollLeft();
1825					position = "fixed";
1826				} else {
1827					if (top + datetimepicker[0].offsetHeight > $(window).height() + $(window).scrollTop()) {
1828						top = offset.top - datetimepicker[0].offsetHeight + 1;
1829					}
1830					if (top < 0) {
1831						top = 0;
1832					}
1833					if (left + datetimepicker[0].offsetWidth > $(window).width()) {
1834						left = $(window).width() - datetimepicker[0].offsetWidth;
1835					}
1836				}
1837
1838				node = datetimepicker[0];
1839				do {
1840					node = node.parentNode;
1841					if (window.getComputedStyle(node).getPropertyValue('position') === 'relative' && $(window).width() >= node.offsetWidth) {
1842						left = left - (($(window).width() - node.offsetWidth) / 2);
1843						break;
1844					}
1845				} while (node.nodeName !== 'HTML');
1846				datetimepicker.css({
1847					left: left,
1848					top: top,
1849					position: position
1850				});
1851			};
1852			datetimepicker
1853				.on('open.xdsoft', function (event) {
1854					var onShow = true;
1855					if (options.onShow && $.isFunction(options.onShow)) {
1856						onShow = options.onShow.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), event);
1857					}
1858					if (onShow !== false) {
1859						datetimepicker.show();
1860						setPos();
1861						$(window)
1862							.off('resize.xdsoft', setPos)
1863							.on('resize.xdsoft', setPos);
1864
1865						if (options.closeOnWithoutClick) {
1866							$([document.body, window]).on('mousedown.xdsoft', function arguments_callee6() {
1867								datetimepicker.trigger('close.xdsoft');
1868								$([document.body, window]).off('mousedown.xdsoft', arguments_callee6);
1869							});
1870						}
1871					}
1872				})
1873				.on('close.xdsoft', function (event) {
1874					var onClose = true;
1875					mounth_picker
1876						.find('.xdsoft_month,.xdsoft_year')
1877							.find('.xdsoft_select')
1878								.hide();
1879					if (options.onClose && $.isFunction(options.onClose)) {
1880						onClose = options.onClose.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), event);
1881					}
1882					if (onClose !== false && !options.opened && !options.inline) {
1883						datetimepicker.hide();
1884					}
1885					event.stopPropagation();
1886				})
1887				.on('toggle.xdsoft', function (event) {
1888					if (datetimepicker.is(':visible')) {
1889						datetimepicker.trigger('close.xdsoft');
1890					} else {
1891						datetimepicker.trigger('open.xdsoft');
1892					}
1893				})
1894				.data('input', input);
1895
1896			timer = 0;
1897			timer1 = 0;
1898
1899			datetimepicker.data('xdsoft_datetime', _xdsoft_datetime);
1900			datetimepicker.setOptions(options);
1901
1902			function getCurrentValue() {
1903				var ct = false, time;
1904
1905				if (options.startDate) {
1906					ct = _xdsoft_datetime.strToDate(options.startDate);
1907				} else {
1908					ct = options.value || ((input && input.val && input.val()) ? input.val() : '');
1909					if (ct) {
1910						ct = _xdsoft_datetime.strToDateTime(ct);
1911					} else if (options.defaultDate) {
1912						ct = _xdsoft_datetime.strToDateTime(options.defaultDate);
1913						if (options.defaultTime) {
1914							time = _xdsoft_datetime.strtotime(options.defaultTime);
1915							ct.setHours(time.getHours());
1916							ct.setMinutes(time.getMinutes());
1917						}
1918					}
1919				}
1920
1921				if (ct && _xdsoft_datetime.isValidDate(ct)) {
1922					datetimepicker.data('changed', true);
1923				} else {
1924					ct = '';
1925				}
1926
1927				return ct || 0;
1928			}
1929
1930			_xdsoft_datetime.setCurrentTime(getCurrentValue());
1931
1932			input
1933				.data('xdsoft_datetimepicker', datetimepicker)
1934				.on('open.xdsoft focusin.xdsoft mousedown.xdsoft', function (event) {
1935					if (input.is(':disabled') || (input.data('xdsoft_datetimepicker').is(':visible') && options.closeOnInputClick)) {
1936						return;
1937					}
1938					clearTimeout(timer);
1939					timer = setTimeout(function () {
1940						if (input.is(':disabled')) {
1941							return;
1942						}
1943
1944						triggerAfterOpen = true;
1945						_xdsoft_datetime.setCurrentTime(getCurrentValue());
1946
1947						datetimepicker.trigger('open.xdsoft');
1948					}, 100);
1949				})
1950				.on('keydown.xdsoft', function (event) {
1951					var val = this.value, elementSelector,
1952						key = event.which;
1953					if ([ENTER].indexOf(key) !== -1 && options.enterLikeTab) {
1954						elementSelector = $("input:visible,textarea:visible");
1955						datetimepicker.trigger('close.xdsoft');
1956						elementSelector.eq(elementSelector.index(this) + 1).focus();
1957						return false;
1958					}
1959					if ([TAB].indexOf(key) !== -1) {
1960						datetimepicker.trigger('close.xdsoft');
1961						return true;
1962					}
1963				});
1964		};
1965		destroyDateTimePicker = function (input) {
1966			var datetimepicker = input.data('xdsoft_datetimepicker');
1967			if (datetimepicker) {
1968				datetimepicker.data('xdsoft_datetime', null);
1969				datetimepicker.remove();
1970				input
1971					.data('xdsoft_datetimepicker', null)
1972					.off('.xdsoft');
1973				$(window).off('resize.xdsoft');
1974				$([window, document.body]).off('mousedown.xdsoft');
1975				if (input.unmousewheel) {
1976					input.unmousewheel();
1977				}
1978			}
1979		};
1980		$(document)
1981			.off('keydown.xdsoftctrl keyup.xdsoftctrl')
1982			.on('keydown.xdsoftctrl', function (e) {
1983				if (e.keyCode === CTRLKEY) {
1984					ctrlDown = true;
1985				}
1986			})
1987			.on('keyup.xdsoftctrl', function (e) {
1988				if (e.keyCode === CTRLKEY) {
1989					ctrlDown = false;
1990				}
1991			});
1992		return this.each(function () {
1993			var datetimepicker = $(this).data('xdsoft_datetimepicker'), $input;
1994			if (datetimepicker) {
1995				if ($.type(opt) === 'string') {
1996					switch (opt) {
1997					case 'show':
1998						$(this).select().focus();
1999						datetimepicker.trigger('open.xdsoft');
2000						break;
2001					case 'hide':
2002						datetimepicker.trigger('close.xdsoft');
2003						break;
2004					case 'toggle':
2005						datetimepicker.trigger('toggle.xdsoft');
2006						break;
2007					case 'destroy':
2008						destroyDateTimePicker($(this));
2009						break;
2010					case 'reset':
2011						this.value = this.defaultValue;
2012						if (!this.value || !datetimepicker.data('xdsoft_datetime').isValidDate(Date.parseDate(this.value, options.format))) {
2013							datetimepicker.data('changed', false);
2014						}
2015						datetimepicker.data('xdsoft_datetime').setCurrentTime(this.value);
2016						break;
2017					case 'validate':
2018						$input = datetimepicker.data('input');
2019						$input.trigger('blur.xdsoft');
2020						break;
2021					}
2022				} else {
2023					datetimepicker
2024						.setOptions(opt);
2025				}
2026				return 0;
2027			}
2028			if ($.type(opt) !== 'string') {
2029				if (!options.lazyInit || options.open || options.inline) {
2030					createDateTimePicker($(this));
2031				} else {
2032					lazyInit($(this));
2033				}
2034			}
2035		});
2036	};
2037	$.fn.datetimepicker.defaults = default_options;
2038}(jQuery));
2039
2040function HighlightedDate(date, desc, style) {
2041	"use strict";
2042	this.date = date;
2043	this.desc = desc;
2044	this.style = style;
2045}
2046
2047(function () {
2048
2049/*! Copyright (c) 2013 Brandon Aaron (http://brandon.aaron.sh)
2050 * Licensed under the MIT License (LICENSE.txt).
2051 *
2052 * Version: 3.1.12
2053 *
2054 * Requires: jQuery 1.2.2+
2055 */
2056!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a:a(jQuery)}(function(a){function b(b){var g=b||window.event,h=i.call(arguments,1),j=0,l=0,m=0,n=0,o=0,p=0;if(b=a.event.fix(g),b.type="mousewheel","detail"in g&&(m=-1*g.detail),"wheelDelta"in g&&(m=g.wheelDelta),"wheelDeltaY"in g&&(m=g.wheelDeltaY),"wheelDeltaX"in g&&(l=-1*g.wheelDeltaX),"axis"in g&&g.axis===g.HORIZONTAL_AXIS&&(l=-1*m,m=0),j=0===m?l:m,"deltaY"in g&&(m=-1*g.deltaY,j=m),"deltaX"in g&&(l=g.deltaX,0===m&&(j=-1*l)),0!==m||0!==l){if(1===g.deltaMode){var q=a.data(this,"mousewheel-line-height");j*=q,m*=q,l*=q}else if(2===g.deltaMode){var r=a.data(this,"mousewheel-page-height");j*=r,m*=r,l*=r}if(n=Math.max(Math.abs(m),Math.abs(l)),(!f||f>n)&&(f=n,d(g,n)&&(f/=40)),d(g,n)&&(j/=40,l/=40,m/=40),j=Math[j>=1?"floor":"ceil"](j/f),l=Math[l>=1?"floor":"ceil"](l/f),m=Math[m>=1?"floor":"ceil"](m/f),k.settings.normalizeOffset&&this.getBoundingClientRect){var s=this.getBoundingClientRect();o=b.clientX-s.left,p=b.clientY-s.top}return b.deltaX=l,b.deltaY=m,b.deltaFactor=f,b.offsetX=o,b.offsetY=p,b.deltaMode=0,h.unshift(b,j,l,m),e&&clearTimeout(e),e=setTimeout(c,200),(a.event.dispatch||a.event.handle).apply(this,h)}}function c(){f=null}function d(a,b){return k.settings.adjustOldDeltas&&"mousewheel"===a.type&&b%120===0}var e,f,g=["wheel","mousewheel","DOMMouseScroll","MozMousePixelScroll"],h="onwheel"in document||document.documentMode>=9?["wheel"]:["mousewheel","DomMouseScroll","MozMousePixelScroll"],i=Array.prototype.slice;if(a.event.fixHooks)for(var j=g.length;j;)a.event.fixHooks[g[--j]]=a.event.mouseHooks;var k=a.event.special.mousewheel={version:"3.1.12",setup:function(){if(this.addEventListener)for(var c=h.length;c;)this.addEventListener(h[--c],b,!1);else this.onmousewheel=b;a.data(this,"mousewheel-line-height",k.getLineHeight(this)),a.data(this,"mousewheel-page-height",k.getPageHeight(this))},teardown:function(){if(this.removeEventListener)for(var c=h.length;c;)this.removeEventListener(h[--c],b,!1);else this.onmousewheel=null;a.removeData(this,"mousewheel-line-height"),a.removeData(this,"mousewheel-page-height")},getLineHeight:function(b){var c=a(b),d=c["offsetParent"in a.fn?"offsetParent":"parent"]();return d.length||(d=a("body")),parseInt(d.css("fontSize"),10)||parseInt(c.css("fontSize"),10)||16},getPageHeight:function(b){return a(b).height()},settings:{adjustOldDeltas:!0,normalizeOffset:!0}};a.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})});
2057
2058// Parse and Format Library
2059//http://www.xaprb.com/blog/2005/12/12/javascript-closures-for-runtime-efficiency/
2060/*
2061 * Copyright (C) 2004 Baron Schwartz <baron at sequent dot org>
2062 *
2063 * This program is free software; you can redistribute it and/or modify it
2064 * under the terms of the GNU Lesser General Public License as published by the
2065 * Free Software Foundation, version 2.1.
2066 *
2067 * This program is distributed in the hope that it will be useful, but WITHOUT
2068 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
2069 * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
2070 * details.
2071 */
2072Date.parseFunctions={count:0};Date.parseRegexes=[];Date.formatFunctions={count:0};Date.prototype.dateFormat=function(b){if(b=="unixtime"){return parseInt(this.getTime()/1000);}if(Date.formatFunctions[b]==null){Date.createNewFormat(b);}var a=Date.formatFunctions[b];return this[a]();};Date.createNewFormat=function(format){var funcName="format"+Date.formatFunctions.count++;Date.formatFunctions[format]=funcName;var codePrefix="Date.prototype."+funcName+" = function() {return ";var code="";var special=false;var ch="";for(var i=0;i<format.length;++i){ch=format.charAt(i);if(!special&&ch=="\\"){special=true;}else{if(special){special=false;code+="'"+String.escape(ch)+"' + ";}else{code+=Date.getFormatCode(ch);}}}if(code.length==0){code="\"\"";}else{code=code.substring(0,code.length-3);}eval(codePrefix+code+";}");};Date.getFormatCode=function(a){switch(a){case"d":return"String.leftPad(this.getDate(), 2, '0') + ";case"D":return"Date.dayNames[this.getDay()].substring(0, 3) + ";case"j":return"this.getDate() + ";case"l":return"Date.dayNames[this.getDay()] + ";case"S":return"this.getSuffix() + ";case"w":return"this.getDay() + ";case"z":return"this.getDayOfYear() + ";case"W":return"this.getWeekOfYear() + ";case"F":return"Date.monthNames[this.getMonth()] + ";case"m":return"String.leftPad(this.getMonth() + 1, 2, '0') + ";case"M":return"Date.monthNames[this.getMonth()].substring(0, 3) + ";case"n":return"(this.getMonth() + 1) + ";case"t":return"this.getDaysInMonth() + ";case"L":return"(this.isLeapYear() ? 1 : 0) + ";case"Y":return"this.getFullYear() + ";case"y":return"('' + this.getFullYear()).substring(2, 4) + ";case"a":return"(this.getHours() < 12 ? 'am' : 'pm') + ";case"A":return"(this.getHours() < 12 ? 'AM' : 'PM') + ";case"g":return"((this.getHours() %12) ? this.getHours() % 12 : 12) + ";case"G":return"this.getHours() + ";case"h":return"String.leftPad((this.getHours() %12) ? this.getHours() % 12 : 12, 2, '0') + ";case"H":return"String.leftPad(this.getHours(), 2, '0') + ";case"i":return"String.leftPad(this.getMinutes(), 2, '0') + ";case"s":return"String.leftPad(this.getSeconds(), 2, '0') + ";case"O":return"this.getGMTOffset() + ";case"T":return"this.getTimezone() + ";case"Z":return"(this.getTimezoneOffset() * -60) + ";default:return"'"+String.escape(a)+"' + ";}};Date.parseDate=function(a,c){if(c=="unixtime"){return new Date(!isNaN(parseInt(a))?parseInt(a)*1000:0);}if(Date.parseFunctions[c]==null){Date.createParser(c);}var b=Date.parseFunctions[c];return Date[b](a);};Date.createParser=function(format){var funcName="parse"+Date.parseFunctions.count++;var regexNum=Date.parseRegexes.length;var currentGroup=1;Date.parseFunctions[format]=funcName;var code="Date."+funcName+" = function(input) {\nvar y = -1, m = -1, d = -1, h = -1, i = -1, s = -1, z = -1;\nvar d = new Date();\ny = d.getFullYear();\nm = d.getMonth();\nd = d.getDate();\nvar results = input.match(Date.parseRegexes["+regexNum+"]);\nif (results && results.length > 0) {";var regex="";var special=false;var ch="";for(var i=0;i<format.length;++i){ch=format.charAt(i);if(!special&&ch=="\\"){special=true;}else{if(special){special=false;regex+=String.escape(ch);}else{obj=Date.formatCodeToRegex(ch,currentGroup);currentGroup+=obj.g;regex+=obj.s;if(obj.g&&obj.c){code+=obj.c;}}}}code+="if (y > 0 && z > 0){\nvar doyDate = new Date(y,0);\ndoyDate.setDate(z);\nm = doyDate.getMonth();\nd = doyDate.getDate();\n}";code+="if (y > 0 && m >= 0 && d > 0 && h >= 0 && i >= 0 && s >= 0)\n{return new Date(y, m, d, h, i, s);}\nelse if (y > 0 && m >= 0 && d > 0 && h >= 0 && i >= 0)\n{return new Date(y, m, d, h, i);}\nelse if (y > 0 && m >= 0 && d > 0 && h >= 0)\n{return new Date(y, m, d, h);}\nelse if (y > 0 && m >= 0 && d > 0)\n{return new Date(y, m, d);}\nelse if (y > 0 && m >= 0)\n{return new Date(y, m);}\nelse if (y > 0)\n{return new Date(y);}\n}return null;}";Date.parseRegexes[regexNum]=new RegExp("^"+regex+"$",'i');eval(code);};Date.formatCodeToRegex=function(b,a){switch(b){case"D":return{g:0,c:null,s:"(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)"};case"j":case"d":return{g:1,c:"d = parseInt(results["+a+"], 10);\n",s:"(\\d{1,2})"};case"l":return{g:0,c:null,s:"(?:"+Date.dayNames.join("|")+")"};case"S":return{g:0,c:null,s:"(?:st|nd|rd|th)"};case"w":return{g:0,c:null,s:"\\d"};case"z":return{g:1,c:"z = parseInt(results["+a+"], 10);\n",s:"(\\d{1,3})"};case"W":return{g:0,c:null,s:"(?:\\d{2})"};case"F":return{g:1,c:"m = parseInt(Date.monthNumbers[results["+a+"].substring(0, 3)], 10);\n",s:"("+Date.monthNames.join("|")+")"};case"M":return{g:1,c:"m = parseInt(Date.monthNumbers[results["+a+"]], 10);\n",s:"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)"};case"n":case"m":return{g:1,c:"m = parseInt(results["+a+"], 10) - 1;\n",s:"(\\d{1,2})"};case"t":return{g:0,c:null,s:"\\d{1,2}"};case"L":return{g:0,c:null,s:"(?:1|0)"};case"Y":return{g:1,c:"y = parseInt(results["+a+"], 10);\n",s:"(\\d{4})"};case"y":return{g:1,c:"var ty = parseInt(results["+a+"], 10);\ny = ty > Date.y2kYear ? 1900 + ty : 2000 + ty;\n",s:"(\\d{1,2})"};case"a":return{g:1,c:"if (results["+a+"] == 'am') {\nif (h == 12) { h = 0; }\n} else { if (h < 12) { h += 12; }}",s:"(am|pm)"};case"A":return{g:1,c:"if (results["+a+"] == 'AM') {\nif (h == 12) { h = 0; }\n} else { if (h < 12) { h += 12; }}",s:"(AM|PM)"};case"g":case"G":case"h":case"H":return{g:1,c:"h = parseInt(results["+a+"], 10);\n",s:"(\\d{1,2})"};case"i":return{g:1,c:"i = parseInt(results["+a+"], 10);\n",s:"(\\d{2})"};case"s":return{g:1,c:"s = parseInt(results["+a+"], 10);\n",s:"(\\d{2})"};case"O":return{g:0,c:null,s:"[+-]\\d{4}"};case"T":return{g:0,c:null,s:"[A-Z]{3}"};case"Z":return{g:0,c:null,s:"[+-]\\d{1,5}"};default:return{g:0,c:null,s:String.escape(b)};}};Date.prototype.getTimezone=function(){return this.toString().replace(/^.*? ([A-Z]{3}) [0-9]{4}.*$/,"$1").replace(/^.*?\(([A-Z])[a-z]+ ([A-Z])[a-z]+ ([A-Z])[a-z]+\)$/,"$1$2$3");};Date.prototype.getGMTOffset=function(){return(this.getTimezoneOffset()>0?"-":"+")+String.leftPad(Math.floor(Math.abs(this.getTimezoneOffset())/60),2,"0")+String.leftPad(Math.abs(this.getTimezoneOffset())%60,2,"0");};Date.prototype.getDayOfYear=function(){var a=0;Date.daysInMonth[1]=this.isLeapYear()?29:28;for(var b=0;b<this.getMonth();++b){a+=Date.daysInMonth[b];}return a+this.getDate();};Date.prototype.getWeekOfYear=function(){var b=this.getDayOfYear()+(4-this.getDay());var a=new Date(this.getFullYear(),0,1);var c=(7-a.getDay()+4);return String.leftPad(Math.ceil((b-c)/7)+1,2,"0");};Date.prototype.isLeapYear=function(){var a=this.getFullYear();return((a&3)==0&&(a%100||(a%400==0&&a)));};Date.prototype.getFirstDayOfMonth=function(){var a=(this.getDay()-(this.getDate()-1))%7;return(a<0)?(a+7):a;};Date.prototype.getLastDayOfMonth=function(){var a=(this.getDay()+(Date.daysInMonth[this.getMonth()]-this.getDate()))%7;return(a<0)?(a+7):a;};Date.prototype.getDaysInMonth=function(){Date.daysInMonth[1]=this.isLeapYear()?29:28;return Date.daysInMonth[this.getMonth()];};Date.prototype.getSuffix=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";}};String.escape=function(a){return a.replace(/('|\\)/g,"\\$1");};String.leftPad=function(d,b,c){var a=new String(d);if(c==null){c=" ";}while(a.length<b){a=c+a;}return a;};Date.daysInMonth=[31,28,31,30,31,30,31,31,30,31,30,31];Date.monthNames=["January","February","March","April","May","June","July","August","September","October","November","December"];Date.dayNames=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];Date.y2kYear=50;Date.monthNumbers={Jan:0,Feb:1,Mar:2,Apr:3,May:4,Jun:5,Jul:6,Aug:7,Sep:8,Oct:9,Nov:10,Dec:11};Date.patterns={ISO8601LongPattern:"Y-m-d H:i:s",ISO8601ShortPattern:"Y-m-d",ShortDatePattern:"n/j/Y",LongDatePattern:"l, F d, Y",FullDateTimePattern:"l, F d, Y g:i:s A",MonthDayPattern:"F d",ShortTimePattern:"g:i A",LongTimePattern:"g:i:s A",SortableDateTimePattern:"Y-m-d\\TH:i:s",UniversalSortableDateTimePattern:"Y-m-d H:i:sO",YearMonthPattern:"F, Y"};
2073}());
2074