PageSourceSearch

http://www.lifeologia.com/wp-content/plugins/mailchimp/js/datepicker.js

js lifeologia.com collected 2026-10-04 17:52:13 UTC 76,638 bytes, 1,830 lines download raw bytes

1var _____WB$wombat$assign$function_____ = function(name) {return (self._wb_wombat && self._wb_wombat.local_init && self._wb_wombat.local_init(name)) || self[name]; };
2if (!self.__WB_pmw) { self.__WB_pmw = function(obj) { this.__WB_source = obj; return this; } }
3{
4  let window = _____WB$wombat$assign$function_____("window");
5  let self = _____WB$wombat$assign$function_____("self");
6  let document = _____WB$wombat$assign$function_____("document");
7  let location = _____WB$wombat$assign$function_____("location");
8  let top = _____WB$wombat$assign$function_____("top");
9  let parent = _____WB$wombat$assign$function_____("parent");
10  let frames = _____WB$wombat$assign$function_____("frames");
11  let opener = _____WB$wombat$assign$function_____("opener");
12
13/*
14 * jQuery UI Datepicker 1.8.14
15 *
16 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
17 * Dual licensed under the MIT or GPL Version 2 licenses.
18 * http://jquery.org/license
19 *
20 * http://docs.jquery.com/UI/Datepicker
21 *
22 * Depends:
23 *	jquery.ui.core.js
24 */
25(function( $, undefined ) {
26
27$.extend($.ui, { datepicker: { version: "1.8.14" } });
28
29var PROP_NAME = 'datepicker';
30var dpuuid = new Date().getTime();
31var instActive;
32
33/* Date picker manager.
34   Use the singleton instance of this class, $.datepicker, to interact with the date picker.
35   Settings for (groups of) date pickers are maintained in an instance object,
36   allowing multiple different settings on the same page. */
37
38function Datepicker() {
39	this.debug = false; // Change this to true to start debugging
40	this._curInst = null; // The current instance in use
41	this._keyEvent = false; // If the last event was a key event
42	this._disabledInputs = []; // List of date picker inputs that have been disabled
43	this._datepickerShowing = false; // True if the popup picker is showing , false if not
44	this._inDialog = false; // True if showing within a "dialog", false if not
45	this._mainDivId = 'ui-datepicker-div'; // The ID of the main datepicker division
46	this._inlineClass = 'ui-datepicker-inline'; // The name of the inline marker class
47	this._appendClass = 'ui-datepicker-append'; // The name of the append marker class
48	this._triggerClass = 'ui-datepicker-trigger'; // The name of the trigger marker class
49	this._dialogClass = 'ui-datepicker-dialog'; // The name of the dialog marker class
50	this._disableClass = 'ui-datepicker-disabled'; // The name of the disabled covering marker class
51	this._unselectableClass = 'ui-datepicker-unselectable'; // The name of the unselectable cell marker class
52	this._currentClass = 'ui-datepicker-current-day'; // The name of the current day marker class
53	this._dayOverClass = 'ui-datepicker-days-cell-over'; // The name of the day hover marker class
54	this.regional = []; // Available regional settings, indexed by language code
55	this.regional[''] = { // Default regional settings
56		closeText: 'Done', // Display text for close link
57		prevText: 'Prev', // Display text for previous month link
58		nextText: 'Next', // Display text for next month link
59		currentText: 'Today', // Display text for current month link
60		monthNames: ['January','February','March','April','May','June',
61			'July','August','September','October','November','December'], // Names of months for drop-down and formatting
62		monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], // For formatting
63		dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], // For formatting
64		dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], // For formatting
65		dayNamesMin: ['Su','Mo','Tu','We','Th','Fr','Sa'], // Column headings for days starting at Sunday
66		weekHeader: 'Wk', // Column header for week of the year
67		dateFormat: 'mm/dd/yy', // See format options on parseDate
68		firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
69		isRTL: false, // True if right-to-left language, false if left-to-right
70		showMonthAfterYear: false, // True if the year select precedes month, false for month then year
71		yearSuffix: '' // Additional text to append to the year in the month headers
72	};
73	this._defaults = { // Global defaults for all the date picker instances
74		showOn: 'focus', // 'focus' for popup on focus,
75			// 'button' for trigger button, or 'both' for either
vendor: 4,789 bytes, lines 76-161
76		showAnim: 'fadeIn', // Name of jQuery animation for popup
77		showOptions: {}, // Options for enhanced animations
78		defaultDate: null, // Used when field is blank: actual date,
79			// +/-number for offset from today, null for today
80		appendText: '', // Display text following the input box, e.g. showing the format
81		buttonText: '...', // Text for trigger button
82		buttonImage: '', // URL for trigger button image
83		buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
84		hideIfNoPrevNext: false, // True to hide next/previous month links
85			// if not applicable, false to just disable them
86		navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
87		gotoCurrent: false, // True if today link goes back to current selection instead
88		changeMonth: false, // True if month can be selected directly, false if only prev/next
89		changeYear: false, // True if year can be selected directly, false if only prev/next
90		yearRange: 'c-10:c+10', // Range of years to display in drop-down,
91			// either relative to today's year (-nn:+nn), relative to currently displayed year
92			// (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
93		showOtherMonths: false, // True to show dates in other months, false to leave blank
94		selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable
95		showWeek: false, // True to show week of the year, false to not show it
96		calculateWeek: this.iso8601Week, // How to calculate the week of the year,
97			// takes a Date and returns the number of the week for it
98		shortYearCutoff: '+10', // Short year values < this are in the current century,
99			// > this are in the previous century,
100			// string value starting with '+' for current year + value
101		minDate: null, // The earliest selectable date, or null for no limit
102		maxDate: null, // The latest selectable date, or null for no limit
103		duration: 'fast', // Duration of display/closure
104		beforeShowDay: null, // Function that takes a date and returns an array with
105			// [0] = true if selectable, false if not, [1] = custom CSS class name(s) or '',
106			// [2] = cell title (optional), e.g. $.datepicker.noWeekends
107		beforeShow: null, // Function that takes an input field and
108			// returns a set of custom settings for the date picker
109		onSelect: null, // Define a callback function when a date is selected
110		onChangeMonthYear: null, // Define a callback function when the month or year is changed
111		onClose: null, // Define a callback function when the datepicker is closed
112		numberOfMonths: 1, // Number of months to show at a time
113		showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
114		stepMonths: 1, // Number of months to step back/forward
115		stepBigMonths: 12, // Number of months to step back/forward for the big links
116		altField: '', // Selector for an alternate field to store selected dates into
117		altFormat: '', // The date format to use for the alternate field
118		constrainInput: true, // The input is constrained by the current date format
119		showButtonPanel: false, // True to show button panel, false to not show it
120		autoSize: false // True to size the input for the date format, false to leave as is
121	};
122	$.extend(this._defaults, this.regional['']);
123	this.dpDiv = bindHover($('<div id="' + this._mainDivId + '" class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>'));
124}
125
126$.extend(Datepicker.prototype, {
127	/* Class name added to elements to indicate already configured with a date picker. */
128	markerClassName: 'hasDatepicker',
129	
130	//Keep track of the maximum number of rows displayed (see #7043)
131	maxRows: 4,
132
133	/* Debug logging (if enabled). */
134	log: function () {
135		if (this.debug)
136			console.log.apply('', arguments);
137	},
138	
139	// TODO rename to "widget" when switching to widget factory
140	_widgetDatepicker: function() {
141		return this.dpDiv;
142	},
143
144	/* Override the default settings for all instances of the date picker.
145	   @param  settings  object - the new settings to use as defaults (anonymous object)
146	   @return the manager object */
147	setDefaults: function(settings) {
148		extendRemove(this._defaults, settings || {});
149		return this;
150	},
151
152	/* Attach the date picker to a jQuery selection.
153	   @param  target    element - the target input field or division or span
154	   @param  settings  object - the new settings to use for this date picker instance (anonymous) */
155	_attachDatepicker: function(target, settings) {
156		// check for settings on the control itself - in namespace 'date:'
157		var inlineSettings = null;
158		for (var attrName in this._defaults) {
159			var attrValue = target.getAttribute('date:' + attrName);
160			if (attrValue) {
161				inlineSettings = inlineSettings || {};
162				try {
163					inlineSettings[attrName] = eval(attrValue);
164				} catch (err) {
165					inlineSettings[attrName] = attrValue;
166				}
167			}
168		}
169		var nodeName = target.nodeName.toLowerCase();
170		var inline = (nodeName == 'div' || nodeName == 'span');
171		if (!target.id) {
172			this.uuid += 1;
173			target.id = 'dp' + this.uuid;
174		}
175		var inst = this._newInst($(target), inline);
176		inst.settings = $.extend({}, settings || {}, inlineSettings || {});
177		if (nodeName == 'input') {
178			this._connectDatepicker(target, inst);
179		} else if (inline) {
180			this._inlineDatepicker(target, inst);
181		}
182	},
183
184	/* Create a new instance object. */
185	_newInst: function(target, inline) {
186		var id = target[0].id.replace(/([^A-Za-z0-9_-])/g, '\\\\$1'); // escape jQuery meta chars
187		return {id: id, input: target, // associated target
188			selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
189			drawMonth: 0, drawYear: 0, // month being drawn
190			inline: inline, // is datepicker inline or not
191			dpDiv: (!inline ? this.dpDiv : // presentation div
192			bindHover($('<div class="' + this._inlineClass + ' ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>')))};
193	},
194
195	/* Attach the date picker to an input field. */
196	_connectDatepicker: function(target, inst) {
197		var input = $(target);
198		inst.append = $([]);
199		inst.trigger = $([]);
200		if (input.hasClass(this.markerClassName))
201			return;
202		this._attachments(input, inst);
203		input.addClass(this.markerClassName).keydown(this._doKeyDown).
204			keypress(this._doKeyPress).keyup(this._doKeyUp).
205			bind("setData.datepicker", function(event, key, value) {
206				inst.settings[key] = value;
207			}).bind("getData.datepicker", function(event, key) {
208				return this._get(inst, key);
209			});
210		this._autoSize(inst);
211		$.data(target, PROP_NAME, inst);
212	},
213
214	/* Make attachments based on settings. */
215	_attachments: function(input, inst) {
216		var appendText = this._get(inst, 'appendText');
217		var isRTL = this._get(inst, 'isRTL');
218		if (inst.append)
219			inst.append.remove();
220		if (appendText) {
221			inst.append = $('<span class="' + this._appendClass + '">' + appendText + '</span>');
222			input[isRTL ? 'before' : 'after'](inst.append);
223		}
224		input.unbind('focus', this._showDatepicker);
225		if (inst.trigger)
226			inst.trigger.remove();
227		var showOn = this._get(inst, 'showOn');
228		if (showOn == 'focus' || showOn == 'both') // pop-up date picker when in the marked field
229			input.focus(this._showDatepicker);
230		if (showOn == 'button' || showOn == 'both') { // pop-up date picker when button clicked
231			var buttonText = this._get(inst, 'buttonText');
232			var buttonImage = this._get(inst, 'buttonImage');
233			inst.trigger = $(this._get(inst, 'buttonImageOnly') ?
234				$('<img/>').addClass(this._triggerClass).
235					attr({ src: buttonImage, alt: buttonText, title: buttonText }) :
236				$('<button type="button"></button>').addClass(this._triggerClass).
237					html(buttonImage == '' ? buttonText : $('<img/>').attr(
238					{ src:buttonImage, alt:buttonText, title:buttonText })));
239			input[isRTL ? 'before' : 'after'](inst.trigger);
240			inst.trigger.click(function() {
241				if ($.datepicker._datepickerShowing && $.datepicker._lastInput == input[0])
242					$.datepicker._hideDatepicker();
243				else
244					$.datepicker._showDatepicker(input[0]);
245				return false;
246			});
247		}
248	},
249
250	/* Apply the maximum length for the date format. */
251	_autoSize: function(inst) {
252		if (this._get(inst, 'autoSize') && !inst.inline) {
253			var date = new Date(2009, 12 - 1, 20); // Ensure double digits
254			var dateFormat = this._get(inst, 'dateFormat');
255			if (dateFormat.match(/[DM]/)) {
256				var findMax = function(names) {
257					var max = 0;
258					var maxI = 0;
259					for (var i = 0; i < names.length; i++) {
260						if (names[i].length > max) {
261							max = names[i].length;
262							maxI = i;
263						}
264					}
265					return maxI;
266				};
267				date.setMonth(findMax(this._get(inst, (dateFormat.match(/MM/) ?
268					'monthNames' : 'monthNamesShort'))));
269				date.setDate(findMax(this._get(inst, (dateFormat.match(/DD/) ?
270					'dayNames' : 'dayNamesShort'))) + 20 - date.getDay());
271			}
272			inst.input.attr('size', this._formatDate(inst, date).length);
273		}
274	},
275
276	/* Attach an inline date picker to a div. */
277	_inlineDatepicker: function(target, inst) {
278		var divSpan = $(target);
279		if (divSpan.hasClass(this.markerClassName))
280			return;
281		divSpan.addClass(this.markerClassName).append(inst.dpDiv).
282			bind("setData.datepicker", function(event, key, value){
283				inst.settings[key] = value;
284			}).bind("getData.datepicker", function(event, key){
285				return this._get(inst, key);
286			});
287		$.data(target, PROP_NAME, inst);
288		this._setDate(inst, this._getDefaultDate(inst), true);
289		this._updateDatepicker(inst);
290		this._updateAlternate(inst);
291		inst.dpDiv.show();
292	},
293
294	/* Pop-up the date picker in a "dialog" box.
295	   @param  input     element - ignored
296	   @param  date      string or Date - the initial date to display
297	   @param  onSelect  function - the function to call when a date is selected
298	   @param  settings  object - update the dialog date picker instance's settings (anonymous object)
299	   @param  pos       int[2] - coordinates for the dialog's position within the screen or
300	                     event - with x/y coordinates or
301	                     leave empty for default (screen centre)
302	   @return the manager object */
303	_dialogDatepicker: function(input, date, onSelect, settings, pos) {
304		var inst = this._dialogInst; // internal instance
305		if (!inst) {
306			this.uuid += 1;
307			var id = 'dp' + this.uuid;
308			this._dialogInput = $('<input type="text" id="' + id +
309				'" style="position: absolute; top: -100px; width: 0px; z-index: -10;"/>');
310			this._dialogInput.keydown(this._doKeyDown);
311			$('body').append(this._dialogInput);
312			inst = this._dialogInst = this._newInst(this._dialogInput, false);
313			inst.settings = {};
314			$.data(this._dialogInput[0], PROP_NAME, inst);
315		}
316		extendRemove(inst.settings, settings || {});
317		date = (date && date.constructor == Date ? this._formatDate(inst, date) : date);
318		this._dialogInput.val(date);
319
320		this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null);
321		if (!this._pos) {
322			var browserWidth = document.documentElement.clientWidth;
323			var browserHeight = document.documentElement.clientHeight;
324			var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
325			var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
326			this._pos = // should use actual width/height below
327				[(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY];
328		}
329
330		// move input on screen for focus, but hidden behind dialog
331		this._dialogInput.css('left', (this._pos[0] + 20) + 'px').css('top', this._pos[1] + 'px');
332		inst.settings.onSelect = onSelect;
333		this._inDialog = true;
334		this.dpDiv.addClass(this._dialogClass);
335		this._showDatepicker(this._dialogInput[0]);
336		if ($.blockUI)
337			$.blockUI(this.dpDiv);
338		$.data(this._dialogInput[0], PROP_NAME, inst);
339		return this;
340	},
341
342	/* Detach a datepicker from its control.
343	   @param  target    element - the target input field or division or span */
344	_destroyDatepicker: function(target) {
345		var $target = $(target);
346		var inst = $.data(target, PROP_NAME);
347		if (!$target.hasClass(this.markerClassName)) {
348			return;
349		}
350		var nodeName = target.nodeName.toLowerCase();
351		$.removeData(target, PROP_NAME);
352		if (nodeName == 'input') {
353			inst.append.remove();
354			inst.trigger.remove();
355			$target.removeClass(this.markerClassName).
356				unbind('focus', this._showDatepicker).
357				unbind('keydown', this._doKeyDown).
358				unbind('keypress', this._doKeyPress).
359				unbind('keyup', this._doKeyUp);
360		} else if (nodeName == 'div' || nodeName == 'span')
361			$target.removeClass(this.markerClassName).empty();
362	},
363
364	/* Enable the date picker to a jQuery selection.
365	   @param  target    element - the target input field or division or span */
366	_enableDatepicker: function(target) {
367		var $target = $(target);
368		var inst = $.data(target, PROP_NAME);
369		if (!$target.hasClass(this.markerClassName)) {
370			return;
371		}
372		var nodeName = target.nodeName.toLowerCase();
373		if (nodeName == 'input') {
374			target.disabled = false;
375			inst.trigger.filter('button').
376				each(function() { this.disabled = false; }).end().
377				filter('img').css({opacity: '1.0', cursor: ''});
378		}
379		else if (nodeName == 'div' || nodeName == 'span') {
380			var inline = $target.children('.' + this._inlineClass);
381			inline.children().removeClass('ui-state-disabled');
382			inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
383				removeAttr("disabled");
384		}
385		this._disabledInputs = $.map(this._disabledInputs,
386			function(value) { return (value == target ? null : value); }); // delete entry
387	},
388
389	/* Disable the date picker to a jQuery selection.
390	   @param  target    element - the target input field or division or span */
391	_disableDatepicker: function(target) {
392		var $target = $(target);
393		var inst = $.data(target, PROP_NAME);
394		if (!$target.hasClass(this.markerClassName)) {
395			return;
396		}
397		var nodeName = target.nodeName.toLowerCase();
398		if (nodeName == 'input') {
399			target.disabled = true;
400			inst.trigger.filter('button').
401				each(function() { this.disabled = true; }).end().
402				filter('img').css({opacity: '0.5', cursor: 'default'});
403		}
404		else if (nodeName == 'div' || nodeName == 'span') {
405			var inline = $target.children('.' + this._inlineClass);
406			inline.children().addClass('ui-state-disabled');
407			inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
408				attr("disabled", "disabled");
409		}
410		this._disabledInputs = $.map(this._disabledInputs,
411			function(value) { return (value == target ? null : value); }); // delete entry
412		this._disabledInputs[this._disabledInputs.length] = target;
413	},
414
415	/* Is the first field in a jQuery collection disabled as a datepicker?
416	   @param  target    element - the target input field or division or span
417	   @return boolean - true if disabled, false if enabled */
418	_isDisabledDatepicker: function(target) {
419		if (!target) {
420			return false;
421		}
422		for (var i = 0; i < this._disabledInputs.length; i++) {
423			if (this._disabledInputs[i] == target)
424				return true;
425		}
426		return false;
427	},
428
429	/* Retrieve the instance data for the target control.
430	   @param  target  element - the target input field or division or span
431	   @return  object - the associated instance data
432	   @throws  error if a jQuery problem getting data */
433	_getInst: function(target) {
434		try {
435			return $.data(target, PROP_NAME);
436		}
437		catch (err) {
438			throw 'Missing instance data for this datepicker';
439		}
440	},
441
442	/* Update or retrieve the settings for a date picker attached to an input field or division.
443	   @param  target  element - the target input field or division or span
444	   @param  name    object - the new settings to update or
445	                   string - the name of the setting to change or retrieve,
446	                   when retrieving also 'all' for all instance settings or
447	                   'defaults' for all global defaults
448	   @param  value   any - the new value for the setting
449	                   (omit if above is an object or to retrieve a value) */
450	_optionDatepicker: function(target, name, value) {
451		var inst = this._getInst(target);
452		if (arguments.length == 2 && typeof name == 'string') {
453			return (name == 'defaults' ? $.extend({}, $.datepicker._defaults) :
454				(inst ? (name == 'all' ? $.extend({}, inst.settings) :
455				this._get(inst, name)) : null));
456		}
457		var settings = name || {};
458		if (typeof name == 'string') {
459			settings = {};
460			settings[name] = value;
461		}
462		if (inst) {
463			if (this._curInst == inst) {
464				this._hideDatepicker();
465			}
466			var date = this._getDateDatepicker(target, true);
467			var minDate = this._getMinMaxDate(inst, 'min');
468			var maxDate = this._getMinMaxDate(inst, 'max');
469			extendRemove(inst.settings, settings);
470			// reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided
471			if (minDate !== null && settings['dateFormat'] !== undefined && settings['minDate'] === undefined)
472				inst.settings.minDate = this._formatDate(inst, minDate);
473			if (maxDate !== null && settings['dateFormat'] !== undefined && settings['maxDate'] === undefined)
474				inst.settings.maxDate = this._formatDate(inst, maxDate);
475			this._attachments($(target), inst);
476			this._autoSize(inst);
477			this._setDate(inst, date);
478			this._updateAlternate(inst);
479			this._updateDatepicker(inst);
480		}
481	},
482
483	// change method deprecated
484	_changeDatepicker: function(target, name, value) {
485		this._optionDatepicker(target, name, value);
486	},
487
488	/* Redraw the date picker attached to an input field or division.
489	   @param  target  element - the target input field or division or span */
490	_refreshDatepicker: function(target) {
491		var inst = this._getInst(target);
492		if (inst) {
493			this._updateDatepicker(inst);
494		}
495	},
496
497	/* Set the dates for a jQuery selection.
498	   @param  target   element - the target input field or division or span
499	   @param  date     Date - the new date */
500	_setDateDatepicker: function(target, date) {
501		var inst = this._getInst(target);
502		if (inst) {
503			this._setDate(inst, date);
504			this._updateDatepicker(inst);
505			this._updateAlternate(inst);
506		}
507	},
508
509	/* Get the date(s) for the first entry in a jQuery selection.
510	   @param  target     element - the target input field or division or span
511	   @param  noDefault  boolean - true if no default date is to be used
512	   @return Date - the current date */
513	_getDateDatepicker: function(target, noDefault) {
514		var inst = this._getInst(target);
515		if (inst && !inst.inline)
516			this._setDateFromField(inst, noDefault);
517		return (inst ? this._getDate(inst) : null);
518	},
519
520	/* Handle keystrokes. */
521	_doKeyDown: function(event) {
522		var inst = $.datepicker._getInst(event.target);
523		var handled = true;
524		var isRTL = inst.dpDiv.is('.ui-datepicker-rtl');
525		inst._keyEvent = true;
526		if ($.datepicker._datepickerShowing)
527			switch (event.keyCode) {
528				case 9: $.datepicker._hideDatepicker();
529						handled = false;
530						break; // hide on tab out
531				case 13: var sel = $('td.' + $.datepicker._dayOverClass + ':not(.' + 
532									$.datepicker._currentClass + ')', inst.dpDiv);
533						if (sel[0])
534							$.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]);
535						else
536							$.datepicker._hideDatepicker();
537						return false; // don't submit the form
538						break; // select the value on enter
539				case 27: $.datepicker._hideDatepicker();
540						break; // hide on escape
541				case 33: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
542							-$.datepicker._get(inst, 'stepBigMonths') :
543							-$.datepicker._get(inst, 'stepMonths')), 'M');
544						break; // previous month/year on page up/+ ctrl
545				case 34: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
546							+$.datepicker._get(inst, 'stepBigMonths') :
547							+$.datepicker._get(inst, 'stepMonths')), 'M');
548						break; // next month/year on page down/+ ctrl
549				case 35: if (event.ctrlKey || event.metaKey) $.datepicker._clearDate(event.target);
550						handled = event.ctrlKey || event.metaKey;
551						break; // clear on ctrl or command +end
552				case 36: if (event.ctrlKey || event.metaKey) $.datepicker._gotoToday(event.target);
553						handled = event.ctrlKey || event.metaKey;
554						break; // current on ctrl or command +home
555				case 37: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), 'D');
556						handled = event.ctrlKey || event.metaKey;
557						// -1 day on ctrl or command +left
558						if (event.originalEvent.altKey) $.datepicker._adjustDate(event.target, (event.ctrlKey ?
559									-$.datepicker._get(inst, 'stepBigMonths') :
560									-$.datepicker._get(inst, 'stepMonths')), 'M');
561						// next month/year on alt +left on Mac
562						break;
563				case 38: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, -7, 'D');
564						handled = event.ctrlKey || event.metaKey;
565						break; // -1 week on ctrl or command +up
566				case 39: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), 'D');
567						handled = event.ctrlKey || event.metaKey;
568						// +1 day on ctrl or command +right
569						if (event.originalEvent.altKey) $.datepicker._adjustDate(event.target, (event.ctrlKey ?
570									+$.datepicker._get(inst, 'stepBigMonths') :
571									+$.datepicker._get(inst, 'stepMonths')), 'M');
572						// next month/year on alt +right
573						break;
574				case 40: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, +7, 'D');
575						handled = event.ctrlKey || event.metaKey;
576						break; // +1 week on ctrl or command +down
577				default: handled = false;
578			}
579		else if (event.keyCode == 36 && event.ctrlKey) // display the date picker on ctrl+home
580			$.datepicker._showDatepicker(this);
581		else {
582			handled = false;
583		}
584		if (handled) {
585			event.preventDefault();
586			event.stopPropagation();
587		}
588	},
589
590	/* Filter entered characters - based on date format. */
591	_doKeyPress: function(event) {
592		var inst = $.datepicker._getInst(event.target);
593		if ($.datepicker._get(inst, 'constrainInput')) {
594			var chars = $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat'));
595			var chr = String.fromCharCode(event.charCode == undefined ? event.keyCode : event.charCode);
596			return event.ctrlKey || event.metaKey || (chr < ' ' || !chars || chars.indexOf(chr) > -1);
597		}
598	},
599
600	/* Synchronise manual entry and field/alternate field. */
601	_doKeyUp: function(event) {
602		var inst = $.datepicker._getInst(event.target);
603		if (inst.input.val() != inst.lastVal) {
604			try {
605				var date = $.datepicker.parseDate($.datepicker._get(inst, 'dateFormat'),
606					(inst.input ? inst.input.val() : null),
607					$.datepicker._getFormatConfig(inst));
608				if (date) { // only if valid
609					$.datepicker._setDateFromField(inst);
610					$.datepicker._updateAlternate(inst);
611					$.datepicker._updateDatepicker(inst);
612				}
613			}
614			catch (event) {
615				$.datepicker.log(event);
616			}
617		}
618		return true;
619	},
620
621	/* Pop-up the date picker for a given input field.
622	   @param  input  element - the input field attached to the date picker or
623	                  event - if triggered by focus */
624	_showDatepicker: function(input) {
625		input = input.target || input;
626		if (input.nodeName.toLowerCase() != 'input') // find from button/image trigger
627			input = $('input', input.parentNode)[0];
628		if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput == input) // already here
629			return;
630		var inst = $.datepicker._getInst(input);
631		if ($.datepicker._curInst && $.datepicker._curInst != inst) {
632			if ( $.datepicker._datepickerShowing ) {
633				$.datepicker._triggerOnClose($.datepicker._curInst);
634			}
635			$.datepicker._curInst.dpDiv.stop(true, true);
636		}
637		var beforeShow = $.datepicker._get(inst, 'beforeShow');
638		extendRemove(inst.settings, (beforeShow ? beforeShow.apply(input, [input, inst]) : {}));
639		inst.lastVal = null;
640		$.datepicker._lastInput = input;
641		$.datepicker._setDateFromField(inst);
642		if ($.datepicker._inDialog) // hide cursor
643			input.value = '';
644		if (!$.datepicker._pos) { // position below input
645			$.datepicker._pos = $.datepicker._findPos(input);
646			$.datepicker._pos[1] += input.offsetHeight; // add the height
647		}
648		var isFixed = false;
649		$(input).parents().each(function() {
650			isFixed |= $(this).css('position') == 'fixed';
651			return !isFixed;
652		});
653		if (isFixed && $.browser.opera) { // correction for Opera when fixed and scrolled
654			$.datepicker._pos[0] -= document.documentElement.scrollLeft;
655			$.datepicker._pos[1] -= document.documentElement.scrollTop;
656		}
657		var offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]};
658		$.datepicker._pos = null;
659		//to avoid flashes on Firefox
660		inst.dpDiv.empty();
661		// determine sizing offscreen
662		inst.dpDiv.css({position: 'absolute', display: 'block', top: '-1000px'});
663		$.datepicker._updateDatepicker(inst);
664		// fix width for dynamic number of date pickers
665		// and adjust position before showing
666		offset = $.datepicker._checkOffset(inst, offset, isFixed);
667		inst.dpDiv.css({position: ($.datepicker._inDialog && $.blockUI ?
668			'static' : (isFixed ? 'fixed' : 'absolute')), display: 'none',
669			left: offset.left + 'px', top: offset.top + 'px'});
670		if (!inst.inline) {
671			var showAnim = $.datepicker._get(inst, 'showAnim');
672			var duration = $.datepicker._get(inst, 'duration');
673			var postProcess = function() {
674				var cover = inst.dpDiv.find('iframe.ui-datepicker-cover'); // IE6- only
675				if( !! cover.length ){
676					var borders = $.datepicker._getBorders(inst.dpDiv);
677					cover.css({left: -borders[0], top: -borders[1],
678						width: inst.dpDiv.outerWidth(), height: inst.dpDiv.outerHeight()});
679				}
680			};
681			inst.dpDiv.zIndex($(input).zIndex()+1);
682			$.datepicker._datepickerShowing = true;
683			if ($.effects && $.effects[showAnim])
684				inst.dpDiv.show(showAnim, $.datepicker._get(inst, 'showOptions'), duration, postProcess);
685			else
686				inst.dpDiv[showAnim || 'show']((showAnim ? duration : null), postProcess);
687			if (!showAnim || !duration)
688				postProcess();
689			if (inst.input.is(':visible') && !inst.input.is(':disabled'))
690				inst.input.focus();
691			$.datepicker._curInst = inst;
692		}
693	},
694
695	/* Generate the date picker content. */
696	_updateDatepicker: function(inst) {
697		var self = this;
698		self.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
699		var borders = $.datepicker._getBorders(inst.dpDiv);
700		instActive = inst; // for delegate hover events
701		inst.dpDiv.empty().append(this._generateHTML(inst));
vendor: 4,725 bytes, lines 702-808
702		var cover = inst.dpDiv.find('iframe.ui-datepicker-cover'); // IE6- only
703		if( !!cover.length ){ //avoid call to outerXXXX() when not in IE6
704			cover.css({left: -borders[0], top: -borders[1], width: inst.dpDiv.outerWidth(), height: inst.dpDiv.outerHeight()})
705		}
706		inst.dpDiv.find('.' + this._dayOverClass + ' a').mouseover();
707		var numMonths = this._getNumberOfMonths(inst);
708		var cols = numMonths[1];
709		var width = 17;
710		inst.dpDiv.removeClass('ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4').width('');
711		if (cols > 1)
712			inst.dpDiv.addClass('ui-datepicker-multi-' + cols).css('width', (width * cols) + 'em');
713		inst.dpDiv[(numMonths[0] != 1 || numMonths[1] != 1 ? 'add' : 'remove') +
714			'Class']('ui-datepicker-multi');
715		inst.dpDiv[(this._get(inst, 'isRTL') ? 'add' : 'remove') +
716			'Class']('ui-datepicker-rtl');
717		if (inst == $.datepicker._curInst && $.datepicker._datepickerShowing && inst.input &&
718				// #6694 - don't focus the input if it's already focused
719				// this breaks the change event in IE
720				inst.input.is(':visible') && !inst.input.is(':disabled') && inst.input[0] != document.activeElement)
721			inst.input.focus();
722		// deffered render of the years select (to avoid flashes on Firefox) 
723		if( inst.yearshtml ){
724			var origyearshtml = inst.yearshtml;
725			setTimeout(function(){
726				//assure that inst.yearshtml didn't change.
727				if( origyearshtml === inst.yearshtml && inst.yearshtml ){
728					inst.dpDiv.find('select.ui-datepicker-year:first').replaceWith(inst.yearshtml);
729				}
730				origyearshtml = inst.yearshtml = null;
731			}, 0);
732		}
733	},
734
735	/* Retrieve the size of left and top borders for an element.
736	   @param  elem  (jQuery object) the element of interest
737	   @return  (number[2]) the left and top borders */
738	_getBorders: function(elem) {
739		var convert = function(value) {
740			return {thin: 1, medium: 2, thick: 3}[value] || value;
741		};
742		return [parseFloat(convert(elem.css('border-left-width'))),
743			parseFloat(convert(elem.css('border-top-width')))];
744	},
745
746	/* Check positioning to remain on screen. */
747	_checkOffset: function(inst, offset, isFixed) {
748		var dpWidth = inst.dpDiv.outerWidth();
749		var dpHeight = inst.dpDiv.outerHeight();
750		var inputWidth = inst.input ? inst.input.outerWidth() : 0;
751		var inputHeight = inst.input ? inst.input.outerHeight() : 0;
752		var viewWidth = document.documentElement.clientWidth + $(document).scrollLeft();
753		var viewHeight = document.documentElement.clientHeight + $(document).scrollTop();
754
755		offset.left -= (this._get(inst, 'isRTL') ? (dpWidth - inputWidth) : 0);
756		offset.left -= (isFixed && offset.left == inst.input.offset().left) ? $(document).scrollLeft() : 0;
757		offset.top -= (isFixed && offset.top == (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0;
758
759		// now check if datepicker is showing outside window viewport - move to a better place if so.
760		offset.left -= Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ?
761			Math.abs(offset.left + dpWidth - viewWidth) : 0);
762		offset.top -= Math.min(offset.top, (offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ?
763			Math.abs(dpHeight + inputHeight) : 0);
764
765		return offset;
766	},
767
768	/* Find an object's position on the screen. */
769	_findPos: function(obj) {
770		var inst = this._getInst(obj);
771		var isRTL = this._get(inst, 'isRTL');
772        while (obj && (obj.type == 'hidden' || obj.nodeType != 1 || $.expr.filters.hidden(obj))) {
773            obj = obj[isRTL ? 'previousSibling' : 'nextSibling'];
774        }
775        var position = $(obj).offset();
776	    return [position.left, position.top];
777	},
778
779	/* Trigger custom callback of onClose. */
780	_triggerOnClose: function(inst) {
781		var onClose = this._get(inst, 'onClose');
782		if (onClose)
783			onClose.apply((inst.input ? inst.input[0] : null),
784						  [(inst.input ? inst.input.val() : ''), inst]);
785	},
786
787	/* Hide the date picker from view.
788	   @param  input  element - the input field attached to the date picker */
789	_hideDatepicker: function(input) {
790		var inst = this._curInst;
791		if (!inst || (input && inst != $.data(input, PROP_NAME)))
792			return;
793		if (this._datepickerShowing) {
794			var showAnim = this._get(inst, 'showAnim');
795			var duration = this._get(inst, 'duration');
796			var postProcess = function() {
797				$.datepicker._tidyDialog(inst);
798				this._curInst = null;
799			};
800			if ($.effects && $.effects[showAnim])
801				inst.dpDiv.hide(showAnim, $.datepicker._get(inst, 'showOptions'), duration, postProcess);
802			else
803				inst.dpDiv[(showAnim == 'slideDown' ? 'slideUp' :
804					(showAnim == 'fadeIn' ? 'fadeOut' : 'hide'))]((showAnim ? duration : null), postProcess);
805			if (!showAnim)
806				postProcess();
807			$.datepicker._triggerOnClose(inst);
808			this._datepickerShowing = false;
809			this._lastInput = null;
810			if (this._inDialog) {
811				this._dialogInput.css({ position: 'absolute', left: '0', top: '-100px' });
812				if ($.blockUI) {
813					$.unblockUI();
814					$('body').append(this.dpDiv);
815				}
816			}
817			this._inDialog = false;
818		}
819	},
820
821	/* Tidy up after a dialog display. */
822	_tidyDialog: function(inst) {
823		inst.dpDiv.removeClass(this._dialogClass).unbind('.ui-datepicker-calendar');
824	},
825
826	/* Close date picker if clicked elsewhere. */
827	_checkExternalClick: function(event) {
828		if (!$.datepicker._curInst)
829			return;
830		var $target = $(event.target);
831		if ($target[0].id != $.datepicker._mainDivId &&
832				$target.parents('#' + $.datepicker._mainDivId).length == 0 &&
833				!$target.hasClass($.datepicker.markerClassName) &&
834				!$target.hasClass($.datepicker._triggerClass) &&
835				$.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI))
836			$.datepicker._hideDatepicker();
837	},
838
839	/* Adjust one of the date sub-fields. */
840	_adjustDate: function(id, offset, period) {
841		var target = $(id);
842		var inst = this._getInst(target[0]);
843		if (this._isDisabledDatepicker(target[0])) {
844			return;
845		}
846		this._adjustInstDate(inst, offset +
847			(period == 'M' ? this._get(inst, 'showCurrentAtPos') : 0), // undo positioning
848			period);
849		this._updateDatepicker(inst);
850	},
851
852	/* Action for current link. */
853	_gotoToday: function(id) {
854		var target = $(id);
855		var inst = this._getInst(target[0]);
856		if (this._get(inst, 'gotoCurrent') && inst.currentDay) {
857			inst.selectedDay = inst.currentDay;
858			inst.drawMonth = inst.selectedMonth = inst.currentMonth;
859			inst.drawYear = inst.selectedYear = inst.currentYear;
860		}
861		else {
862			var date = new Date();
863			inst.selectedDay = date.getDate();
864			inst.drawMonth = inst.selectedMonth = date.getMonth();
865			inst.drawYear = inst.selectedYear = date.getFullYear();
866		}
867		this._notifyChange(inst);
868		this._adjustDate(target);
869	},
870
871	/* Action for selecting a new month/year. */
872	_selectMonthYear: function(id, select, period) {
873		var target = $(id);
874		var inst = this._getInst(target[0]);
875		inst._selectingMonthYear = false;
876		inst['selected' + (period == 'M' ? 'Month' : 'Year')] =
877		inst['draw' + (period == 'M' ? 'Month' : 'Year')] =
878			parseInt(select.options[select.selectedIndex].value,10);
879		this._notifyChange(inst);
880		this._adjustDate(target);
881	},
882
883	/* Restore input focus after not changing month/year. */
884	_clickMonthYear: function(id) {
885		var target = $(id);
886		var inst = this._getInst(target[0]);
887		if (inst.input && inst._selectingMonthYear) {
888			setTimeout(function() {
889				inst.input.focus();
890			}, 0);
891		}
892		inst._selectingMonthYear = !inst._selectingMonthYear;
893	},
894
895	/* Action for selecting a day. */
896	_selectDay: function(id, month, year, td) {
897		var target = $(id);
898		if ($(td).hasClass(this._unselectableClass) || this._isDisabledDatepicker(target[0])) {
899			return;
900		}
901		var inst = this._getInst(target[0]);
902		inst.selectedDay = inst.currentDay = $('a', td).html();
903		inst.selectedMonth = inst.currentMonth = month;
904		inst.selectedYear = inst.currentYear = year;
905		this._selectDate(id, this._formatDate(inst,
906			inst.currentDay, inst.currentMonth, inst.currentYear));
907	},
908
909	/* Erase the input field and hide the date picker. */
910	_clearDate: function(id) {
911		var target = $(id);
912		var inst = this._getInst(target[0]);
913		this._selectDate(target, '');
914	},
915
916	/* Update the input field with the selected date. */
917	_selectDate: function(id, dateStr) {
918		var target = $(id);
919		var inst = this._getInst(target[0]);
920		dateStr = (dateStr != null ? dateStr : this._formatDate(inst));
921		if (inst.input)
922			inst.input.val(dateStr);
923		this._updateAlternate(inst);
924		var onSelect = this._get(inst, 'onSelect');
925		if (onSelect)
926			onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]);  // trigger custom callback
927		else if (inst.input)
928			inst.input.trigger('change'); // fire the change event
929		if (inst.inline)
930			this._updateDatepicker(inst);
931		else {
932			this._hideDatepicker();
933			this._lastInput = inst.input[0];
934			if (typeof(inst.input[0]) != 'object')
935				inst.input.focus(); // restore focus
936			this._lastInput = null;
937		}
938	},
939
940	/* Update any alternate field to synchronise with the main field. */
941	_updateAlternate: function(inst) {
942		var altField = this._get(inst, 'altField');
943		if (altField) { // update alternate field too
944			var altFormat = this._get(inst, 'altFormat') || this._get(inst, 'dateFormat');
945			var date = this._getDate(inst);
946			var dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst));
947			$(altField).each(function() { $(this).val(dateStr); });
948		}
949	},
950
951	/* Set as beforeShowDay function to prevent selection of weekends.
952	   @param  date  Date - the date to customise
953	   @return [boolean, string] - is this date selectable?, what is its CSS class? */
954	noWeekends: function(date) {
955		var day = date.getDay();
956		return [(day > 0 && day < 6), ''];
957	},
958
959	/* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
960	   @param  date  Date - the date to get the week for
961	   @return  number - the number of the week within the year that contains this date */
962	iso8601Week: function(date) {
963		var checkDate = new Date(date.getTime());
964		// Find Thursday of this week starting on Monday
965		checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
966		var time = checkDate.getTime();
967		checkDate.setMonth(0); // Compare with Jan 1
968		checkDate.setDate(1);
969		return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
970	},
971
972	/* Parse a string value into a date object.
973	   See formatDate below for the possible formats.
974
vendor: 4,158 bytes, lines 975-1083
975	   @param  format    string - the expected format of the date
976	   @param  value     string - the date in the above format
977	   @param  settings  Object - attributes include:
978	                     shortYearCutoff  number - the cutoff year for determining the century (optional)
979	                     dayNamesShort    string[7] - abbreviated names of the days from Sunday (optional)
980	                     dayNames         string[7] - names of the days from Sunday (optional)
981	                     monthNamesShort  string[12] - abbreviated names of the months (optional)
982	                     monthNames       string[12] - names of the months (optional)
983	   @return  Date - the extracted date value or null if value is blank */
984	parseDate: function (format, value, settings) {
985		if (format == null || value == null)
986			throw 'Invalid arguments';
987		value = (typeof value == 'object' ? value.toString() : value + '');
988		if (value == '')
989			return null;
990		var shortYearCutoff = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff;
991		shortYearCutoff = (typeof shortYearCutoff != 'string' ? shortYearCutoff :
992				new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
993		var dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort;
994		var dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames;
995		var monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort;
996		var monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames;
997		var year = -1;
998		var month = -1;
999		var day = -1;
1000		var doy = -1;
1001		var literal = false;
1002		// Check whether a format character is doubled
1003		var lookAhead = function(match) {
1004			var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
1005			if (matches)
1006				iFormat++;
1007			return matches;
1008		};
1009		// Extract a number from the string value
1010		var getNumber = function(match) {
1011			var isDoubled = lookAhead(match);
1012			var size = (match == '@' ? 14 : (match == '!' ? 20 :
1013				(match == 'y' && isDoubled ? 4 : (match == 'o' ? 3 : 2))));
1014			var digits = new RegExp('^\\d{1,' + size + '}');
1015			var num = value.substring(iValue).match(digits);
1016			if (!num)
1017				throw 'Missing number at position ' + iValue;
1018			iValue += num[0].length;
1019			return parseInt(num[0], 10);
1020		};
1021		// Extract a name from the string value and convert to an index
1022		var getName = function(match, shortNames, longNames) {
1023			var names = $.map(lookAhead(match) ? longNames : shortNames, function (v, k) {
1024				return [ [k, v] ];
1025			}).sort(function (a, b) {
1026				return -(a[1].length - b[1].length);
1027			});
1028			var index = -1;
1029			$.each(names, function (i, pair) {
1030				var name = pair[1];
1031				if (value.substr(iValue, name.length).toLowerCase() == name.toLowerCase()) {
1032					index = pair[0];
1033					iValue += name.length;
1034					return false;
1035				}
1036			});
1037			if (index != -1)
1038				return index + 1;
1039			else
1040				throw 'Unknown name at position ' + iValue;
1041		};
1042		// Confirm that a literal character matches the string value
1043		var checkLiteral = function() {
1044			if (value.charAt(iValue) != format.charAt(iFormat))
1045				throw 'Unexpected literal at position ' + iValue;
1046			iValue++;
1047		};
1048		var iValue = 0;
1049		for (var iFormat = 0; iFormat < format.length; iFormat++) {
1050			if (literal)
1051				if (format.charAt(iFormat) == "'" && !lookAhead("'"))
1052					literal = false;
1053				else
1054					checkLiteral();
1055			else
1056				switch (format.charAt(iFormat)) {
1057					case 'd':
1058						day = getNumber('d');
1059						break;
1060					case 'D':
1061						getName('D', dayNamesShort, dayNames);
1062						break;
1063					case 'o':
1064						doy = getNumber('o');
1065						break;
1066					case 'm':
1067						month = getNumber('m');
1068						break;
1069					case 'M':
1070						month = getName('M', monthNamesShort, monthNames);
1071						break;
1072					case 'y':
1073						year = getNumber('y');
1074						break;
1075					case '@':
1076						var date = new Date(getNumber('@'));
1077						year = date.getFullYear();
1078						month = date.getMonth() + 1;
1079						day = date.getDate();
1080						break;
1081					case '!':
1082						var date = new Date((getNumber('!') - this._ticksTo1970) / 10000);
1083						year = date.getFullYear();
1084						month = date.getMonth() + 1;
1085						day = date.getDate();
1086						break;
1087					case "'":
1088						if (lookAhead("'"))
1089							checkLiteral();
1090						else
1091							literal = true;
1092						break;
1093					default:
1094						checkLiteral();
1095				}
1096		}
1097		if (iValue < value.length){
1098			throw "Extra/unparsed characters found in date: " + value.substring(iValue);
1099		}
1100		if (year == -1)
1101			year = new Date().getFullYear();
1102		else if (year < 100)
1103			year += new Date().getFullYear() - new Date().getFullYear() % 100 +
1104				(year <= shortYearCutoff ? 0 : -100);
1105		if (doy > -1) {
1106			month = 1;
1107			day = doy;
1108			do {
1109				var dim = this._getDaysInMonth(year, month - 1);
1110				if (day <= dim)
1111					break;
1112				month++;
1113				day -= dim;
1114			} while (true);
1115		}
1116		var date = this._daylightSavingAdjust(new Date(year, month - 1, day));
1117		if (date.getFullYear() != year || date.getMonth() + 1 != month || date.getDate() != day)
1118			throw 'Invalid date'; // E.g. 31/02/00
1119		return date;
1120	},
1121
1122	/* Standard date formats. */
1123	ATOM: 'yy-mm-dd', // RFC 3339 (ISO 8601)
1124	COOKIE: 'D, dd M yy',
1125	ISO_8601: 'yy-mm-dd',
1126	RFC_822: 'D, d M y',
1127	RFC_850: 'DD, dd-M-y',
1128	RFC_1036: 'D, d M y',
1129	RFC_1123: 'D, d M yy',
1130	RFC_2822: 'D, d M yy',
1131	RSS: 'D, d M y', // RFC 822
1132	TICKS: '!',
1133	TIMESTAMP: '@',
1134	W3C: 'yy-mm-dd', // ISO 8601
1135
1136	_ticksTo1970: (((1970 - 1) * 365 + Math.floor(1970 / 4) - Math.floor(1970 / 100) +
1137		Math.floor(1970 / 400)) * 24 * 60 * 60 * 10000000),
1138
1139	/* Format a date object into a string value.
1140	   The format can be combinations of the following:
1141	   d  - day of month (no leading zero)
1142	   dd - day of month (two digit)
1143	   o  - day of year (no leading zeros)
1144	   oo - day of year (three digit)
1145	   D  - day name short
1146	   DD - day name long
1147	   m  - month of year (no leading zero)
1148	   mm - month of year (two digit)
1149	   M  - month name short
1150	   MM - month name long
1151	   y  - year (two digit)
1152	   yy - year (four digit)
1153	   @ - Unix timestamp (ms since 01/01/1970)
1154	   ! - Windows ticks (100ns since 01/01/0001)
1155	   '...' - literal text
1156	   '' - single quote
1157
1158	   @param  format    string - the desired format of the date
1159	   @param  date      Date - the date value to format
1160	   @param  settings  Object - attributes include:
1161	                     dayNamesShort    string[7] - abbreviated names of the days from Sunday (optional)
1162	                     dayNames         string[7] - names of the days from Sunday (optional)
1163	                     monthNamesShort  string[12] - abbreviated names of the months (optional)
1164	                     monthNames       string[12] - names of the months (optional)
1165	   @return  string - the date in the above format */
1166	formatDate: function (format, date, settings) {
1167		if (!date)
1168			return '';
1169		var dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort;
1170		var dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames;
1171		var monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort;
1172		var monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames;
1173		// Check whether a format character is doubled
1174		var lookAhead = function(match) {
1175			var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
1176			if (matches)
1177				iFormat++;
1178			return matches;
1179		};
1180		// Format a number, with leading zero if necessary
1181		var formatNumber = function(match, value, len) {
1182			var num = '' + value;
1183			if (lookAhead(match))
1184				while (num.length < len)
1185					num = '0' + num;
1186			return num;
1187		};
1188		// Format a name, short or long as requested
1189		var formatName = function(match, value, shortNames, longNames) {
1190			return (lookAhead(match) ? longNames[value] : shortNames[value]);
1191		};
1192		var output = '';
1193		var literal = false;
1194		if (date)
1195			for (var iFormat = 0; iFormat < format.length; iFormat++) {
1196				if (literal)
1197					if (format.charAt(iFormat) == "'" && !lookAhead("'"))
1198						literal = false;
1199					else
1200						output += format.charAt(iFormat);
1201				else
1202					switch (format.charAt(iFormat)) {
1203						case 'd':
1204							output += formatNumber('d', date.getDate(), 2);
1205							break;
1206						case 'D':
1207							output += formatName('D', date.getDay(), dayNamesShort, dayNames);
1208							break;
1209						case 'o':
1210							output += formatNumber('o',
1211								Math.round((new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000), 3);
1212							break;
1213						case 'm':
1214							output += formatNumber('m', date.getMonth() + 1, 2);
1215							break;
1216						case 'M':
1217							output += formatName('M', date.getMonth(), monthNamesShort, monthNames);
1218							break;
1219						case 'y':
1220							output += (lookAhead('y') ? date.getFullYear() :
1221								(date.getYear() % 100 < 10 ? '0' : '') + date.getYear() % 100);
1222							break;
1223						case '@':
1224							output += date.getTime();
1225							break;
1226						case '!':
1227							output += date.getTime() * 10000 + this._ticksTo1970;
1228							break;
1229						case "'":
1230							if (lookAhead("'"))
1231								output += "'";
1232							else
1233								literal = true;
1234							break;
1235						default:
1236							output += format.charAt(iFormat);
1237					}
1238			}
1239		return output;
1240	},
1241
1242	/* Extract all possible characters from the date format. */
1243	_possibleChars: function (format) {
1244		var chars = '';
1245		var literal = false;
1246		// Check whether a format character is doubled
1247		var lookAhead = function(match) {
1248			var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
1249			if (matches)
1250				iFormat++;
1251			return matches;
1252		};
1253		for (var iFormat = 0; iFormat < format.length; iFormat++)
1254			if (literal)
1255				if (format.charAt(iFormat) == "'" && !lookAhead("'"))
1256					literal = false;
1257				else
1258					chars += format.charAt(iFormat);
1259			else
1260				switch (format.charAt(iFormat)) {
1261					case 'd': case 'm': case 'y': case '@':
1262						chars += '0123456789';
1263						break;
1264					case 'D': case 'M':
1265						return null; // Accept anything
1266					case "'":
1267						if (lookAhead("'"))
1268							chars += "'";
1269						else
1270							literal = true;
1271						break;
1272					default:
1273						chars += format.charAt(iFormat);
1274				}
1275		return chars;
1276	},
1277
1278	/* Get a setting value, defaulting if necessary. */
1279	_get: function(inst, name) {
1280		return inst.settings[name] !== undefined ?
1281			inst.settings[name] : this._defaults[name];
1282	},
1283
1284	/* Parse existing date and initialise date picker. */
1285	_setDateFromField: function(inst, noDefault) {
1286		if (inst.input.val() == inst.lastVal) {
1287			return;
1288		}
1289		var dateFormat = this._get(inst, 'dateFormat');
1290		var dates = inst.lastVal = inst.input ? inst.input.val() : null;
1291		var date, defaultDate;
1292		date = defaultDate = this._getDefaultDate(inst);
1293		var settings = this._getFormatConfig(inst);
1294		try {
1295			date = this.parseDate(dateFormat, dates, settings) || defaultDate;
1296		} catch (event) {
1297			this.log(event);
1298			dates = (noDefault ? '' : dates);
1299		}
1300		inst.selectedDay = date.getDate();
1301		inst.drawMonth = inst.selectedMonth = date.getMonth();
1302		inst.drawYear = inst.selectedYear = date.getFullYear();
1303		inst.currentDay = (dates ? date.getDate() : 0);
1304		inst.currentMonth = (dates ? date.getMonth() : 0);
1305		inst.currentYear = (dates ? date.getFullYear() : 0);
1306		this._adjustInstDate(inst);
1307	},
1308
1309	/* Retrieve the default date shown on opening. */
1310	_getDefaultDate: function(inst) {
1311		return this._restrictMinMax(inst,
1312			this._determineDate(inst, this._get(inst, 'defaultDate'), new Date()));
1313	},
1314
1315	/* A date may be specified as an exact value or a relative one. */
1316	_determineDate: function(inst, date, defaultDate) {
1317		var offsetNumeric = function(offset) {
1318			var date = new Date();
1319			date.setDate(date.getDate() + offset);
1320			return date;
1321		};
1322		var offsetString = function(offset) {
1323			try {
1324				return $.datepicker.parseDate($.datepicker._get(inst, 'dateFormat'),
1325					offset, $.datepicker._getFormatConfig(inst));
1326			}
1327			catch (e) {
1328				// Ignore
1329			}
1330			var date = (offset.toLowerCase().match(/^c/) ?
1331				$.datepicker._getDate(inst) : null) || new Date();
1332			var year = date.getFullYear();
1333			var month = date.getMonth();
1334			var day = date.getDate();
1335			var pattern = /([+-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g;
1336			var matches = pattern.exec(offset);
1337			while (matches) {
1338				switch (matches[2] || 'd') {
1339					case 'd' : case 'D' :
1340						day += parseInt(matches[1],10); break;
1341					case 'w' : case 'W' :
1342						day += parseInt(matches[1],10) * 7; break;
1343					case 'm' : case 'M' :
1344						month += parseInt(matches[1],10);
1345						day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
1346						break;
1347					case 'y': case 'Y' :
1348						year += parseInt(matches[1],10);
1349						day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
1350						break;
1351				}
1352				matches = pattern.exec(offset);
1353			}
1354			return new Date(year, month, day);
1355		};
1356		var newDate = (date == null || date === '' ? defaultDate : (typeof date == 'string' ? offsetString(date) :
1357			(typeof date == 'number' ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : new Date(date.getTime()))));
1358		newDate = (newDate && newDate.toString() == 'Invalid Date' ? defaultDate : newDate);
1359		if (newDate) {
1360			newDate.setHours(0);
1361			newDate.setMinutes(0);
1362			newDate.setSeconds(0);
1363			newDate.setMilliseconds(0);
1364		}
1365		return this._daylightSavingAdjust(newDate);
1366	},
1367
1368	/* Handle switch to/from daylight saving.
1369	   Hours may be non-zero on daylight saving cut-over:
1370	   > 12 when midnight changeover, but then cannot generate
1371	   midnight datetime, so jump to 1AM, otherwise reset.
1372	   @param  date  (Date) the date to check
1373	   @return  (Date) the corrected date */
1374	_daylightSavingAdjust: function(date) {
1375		if (!date) return null;
1376		date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0);
1377		return date;
1378	},
1379
1380	/* Set the date(s) directly. */
1381	_setDate: function(inst, date, noChange) {
1382		var clear = !date;
1383		var origMonth = inst.selectedMonth;
1384		var origYear = inst.selectedYear;
1385		var newDate = this._restrictMinMax(inst, this._determineDate(inst, date, new Date()));
1386		inst.selectedDay = inst.currentDay = newDate.getDate();
1387		inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth();
1388		inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear();
1389		if ((origMonth != inst.selectedMonth || origYear != inst.selectedYear) && !noChange)
1390			this._notifyChange(inst);
1391		this._adjustInstDate(inst);
1392		if (inst.input) {
1393			inst.input.val(clear ? '' : this._formatDate(inst));
1394		}
1395	},
1396
1397	/* Retrieve the date(s) directly. */
1398	_getDate: function(inst) {
1399		var startDate = (!inst.currentYear || (inst.input && inst.input.val() == '') ? null :
1400			this._daylightSavingAdjust(new Date(
1401			inst.currentYear, inst.currentMonth, inst.currentDay)));
1402			return startDate;
1403	},
1404
1405	/* Generate the HTML for the current state of the date picker. */
1406	_generateHTML: function(inst) {
1407		var today = new Date();
1408		today = this._daylightSavingAdjust(
1409			new Date(today.getFullYear(), today.getMonth(), today.getDate())); // clear time
1410		var isRTL = this._get(inst, 'isRTL');
1411		var showButtonPanel = this._get(inst, 'showButtonPanel');
1412		var hideIfNoPrevNext = this._get(inst, 'hideIfNoPrevNext');
1413		var navigationAsDateFormat = this._get(inst, 'navigationAsDateFormat');
1414		var numMonths = this._getNumberOfMonths(inst);
1415		var showCurrentAtPos = this._get(inst, 'showCurrentAtPos');
1416		var stepMonths = this._get(inst, 'stepMonths');
1417		var isMultiMonth = (numMonths[0] != 1 || numMonths[1] != 1);
1418		var currentDate = this._daylightSavingAdjust((!inst.currentDay ? new Date(9999, 9, 9) :
1419			new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
1420		var minDate = this._getMinMaxDate(inst, 'min');
1421		var maxDate = this._getMinMaxDate(inst, 'max');
1422		var drawMonth = inst.drawMonth - showCurrentAtPos;
1423		var drawYear = inst.drawYear;
1424		if (drawMonth < 0) {
1425			drawMonth += 12;
1426			drawYear--;
1427		}
1428		if (maxDate) {
1429			var maxDraw = this._daylightSavingAdjust(new Date(maxDate.getFullYear(),
1430				maxDate.getMonth() - (numMonths[0] * numMonths[1]) + 1, maxDate.getDate()));
1431			maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw);
1432			while (this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1)) > maxDraw) {
1433				drawMonth--;
1434				if (drawMonth < 0) {
1435					drawMonth = 11;
1436					drawYear--;
1437				}
1438			}
1439		}
1440		inst.drawMonth = drawMonth;
1441		inst.drawYear = drawYear;
1442		var prevText = this._get(inst, 'prevText');
1443		prevText = (!navigationAsDateFormat ? prevText : this.formatDate(prevText,
1444			this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)),
1445			this._getFormatConfig(inst)));
1446		var prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ?
1447			'<a class="ui-datepicker-prev ui-corner-all" onclick="DP_jQuery_' + dpuuid +
1448			'.datepicker._adjustDate(\'#' + inst.id + '\', -' + stepMonths + ', \'M\');"' +
1449			' title="' + prevText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'e' : 'w') + '">' + prevText + '</span></a>' :
1450			(hideIfNoPrevNext ? '' : '<a class="ui-datepicker-prev ui-corner-all ui-state-disabled" title="'+ prevText +'"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'e' : 'w') + '">' + prevText + '</span></a>'));
1451		var nextText = this._get(inst, 'nextText');
1452		nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText,
1453			this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)),
1454			this._getFormatConfig(inst)));
1455		var next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ?
1456			'<a class="ui-datepicker-next ui-corner-all" onclick="DP_jQuery_' + dpuuid +
1457			'.datepicker._adjustDate(\'#' + inst.id + '\', +' + stepMonths + ', \'M\');"' +
1458			' title="' + nextText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'w' : 'e') + '">' + nextText + '</span></a>' :
1459			(hideIfNoPrevNext ? '' : '<a class="ui-datepicker-next ui-corner-all ui-state-disabled" title="'+ nextText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'w' : 'e') + '">' + nextText + '</span></a>'));
1460		var currentText = this._get(inst, 'currentText');
1461		var gotoDate = (this._get(inst, 'gotoCurrent') && inst.currentDay ? currentDate : today);
1462		currentText = (!navigationAsDateFormat ? currentText :
1463			this.formatDate(currentText, gotoDate, this._getFormatConfig(inst)));
1464		var controls = (!inst.inline ? '<button type="button" class="ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all" onclick="DP_jQuery_' + dpuuid +
1465			'.datepicker._hideDatepicker();">' + this._get(inst, 'closeText') + '</button>' : '');
1466		var buttonPanel = (showButtonPanel) ? '<div class="ui-datepicker-buttonpane ui-widget-content">' + (isRTL ? controls : '') +
1467			(this._isInRange(inst, gotoDate) ? '<button type="button" class="ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all" onclick="DP_jQuery_' + dpuuid +
1468			'.datepicker._gotoToday(\'#' + inst.id + '\');"' +
1469			'>' + currentText + '</button>' : '') + (isRTL ? '' : controls) + '</div>' : '';
1470		var firstDay = parseInt(this._get(inst, 'firstDay'),10);
1471		firstDay = (isNaN(firstDay) ? 0 : firstDay);
1472		var showWeek = this._get(inst, 'showWeek');
1473		var dayNames = this._get(inst, 'dayNames');
1474		var dayNamesShort = this._get(inst, 'dayNamesShort');
1475		var dayNamesMin = this._get(inst, 'dayNamesMin');
1476		var monthNames = this._get(inst, 'monthNames');
1477		var monthNamesShort = this._get(inst, 'monthNamesShort');
1478		var beforeShowDay = this._get(inst, 'beforeShowDay');
1479		var showOtherMonths = this._get(inst, 'showOtherMonths');
1480		var selectOtherMonths = this._get(inst, 'selectOtherMonths');
1481		var calculateWeek = this._get(inst, 'calculateWeek') || this.iso8601Week;
1482		var defaultDate = this._getDefaultDate(inst);
1483		var html = '';
1484		for (var row = 0; row < numMonths[0]; row++) {
1485			var group = '';
1486			this.maxRows = 4;
1487			for (var col = 0; col < numMonths[1]; col++) {
1488				var selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay));
1489				var cornerClass = ' ui-corner-all';
1490				var calender = '';
1491				if (isMultiMonth) {
1492					calender += '<div class="ui-datepicker-group';
1493					if (numMonths[1] > 1)
1494						switch (col) {
1495							case 0: calender += ' ui-datepicker-group-first';
1496								cornerClass = ' ui-corner-' + (isRTL ? 'right' : 'left'); break;
1497							case numMonths[1]-1: calender += ' ui-datepicker-group-last';
1498								cornerClass = ' ui-corner-' + (isRTL ? 'left' : 'right'); break;
1499							default: calender += ' ui-datepicker-group-middle'; cornerClass = ''; break;
1500						}
1501					calender += '">';
1502				}
1503				calender += '<div class="ui-datepicker-header ui-widget-header ui-helper-clearfix' + cornerClass + '">' +
1504					(/all|left/.test(cornerClass) && row == 0 ? (isRTL ? next : prev) : '') +
1505					(/all|right/.test(cornerClass) && row == 0 ? (isRTL ? prev : next) : '') +
1506					this._generateMonthYearHeader(inst, drawMonth, drawYear, minDate, maxDate,
1507					row > 0 || col > 0, monthNames, monthNamesShort) + // draw month headers
1508					'</div><table class="ui-datepicker-calendar"><thead>' +
1509					'<tr>';
1510				var thead = (showWeek ? '<th class="ui-datepicker-week-col">' + this._get(inst, 'weekHeader') + '</th>' : '');
1511				for (var dow = 0; dow < 7; dow++) { // days of the week
1512					var day = (dow + firstDay) % 7;
1513					thead += '<th' + ((dow + firstDay + 6) % 7 >= 5 ? ' class="ui-datepicker-week-end"' : '') + '>
1513' +
1514						'<span title="' + dayNames[day] + '">' + dayNamesMin[day] + '</span></th>';
1515				}
1516				calender += thead + '</tr></thead><tbody>';
1517				var daysInMonth = this._getDaysInMonth(drawYear, drawMonth);
1518				if (drawYear == inst.selectedYear && drawMonth == inst.selectedMonth)
1519					inst.selectedDay = Math.min(inst.selectedDay, daysInMonth);
1520				var leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7;
1521				var curRows = Math.ceil((leadDays + daysInMonth) / 7); // calculate the number of rows to generate
1522				var numRows = (isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows); //If multiple months, use the higher number of rows (see #7043)
1523				this.maxRows = numRows;
1524				var printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays));
1525				for (var dRow = 0; dRow < numRows; dRow++) { // create date picker rows
1526					calender += '<tr>';
1527					var tbody = (!showWeek ? '' : '<td class="ui-datepicker-week-col">' +
1528						this._get(inst, 'calculateWeek')(printDate) + '</td>');
1529					for (var dow = 0; dow < 7; dow++) { // create date picker days
1530						var daySettings = (beforeShowDay ?
1531							beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, '']);
1532						var otherMonth = (printDate.getMonth() != drawMonth);
1533						var unselectable = (otherMonth && !selectOtherMonths) || !daySettings[0] ||
1534							(minDate && printDate < minDate) || (maxDate && printDate > maxDate);
1535						tbody += '<td class="' +
1536							((dow + firstDay + 6) % 7 >= 5 ? ' ui-datepicker-week-end' : '') + // highlight weekends
1537							(otherMonth ? ' ui-datepicker-other-month' : '') + // highlight days from other months
1538							((printDate.getTime() == selectedDate.getTime() && drawMonth == inst.selectedMonth && inst._keyEvent) || // user pressed key
1539							(defaultDate.getTime() == printDate.getTime() && defaultDate.getTime() == selectedDate.getTime()) ?
1540							// or defaultDate is current printedDate and defaultDate is selectedDate
1541							' ' + this._dayOverClass : '') + // highlight selected day
1542							(unselectable ? ' ' + this._unselectableClass + ' ui-state-disabled': '') +  // highlight unselectable days
1543							(otherMonth && !showOtherMonths ? '' : ' ' + daySettings[1] + // highlight custom dates
1544							(printDate.getTime() == currentDate.getTime() ? ' ' + this._currentClass : '') + // highlight selected day
1545							(printDate.getTime() == today.getTime() ? ' ui-datepicker-today' : '')) + '"' + // highlight today (if different)
1546							((!otherMonth || showOtherMonths) && daySettings[2] ? ' title="' + daySettings[2] + '"' : '') + // cell title
1547							(unselectable ? '' : ' onclick="DP_jQuery_' + dpuuid + '.datepicker._selectDay(\'#' +
1548							inst.id + '\',' + printDate.getMonth() + ',' + printDate.getFullYear() + ', this);return false;"') + '>' + // actions
1549							(otherMonth && !showOtherMonths ? '&#xa0;' : // display for other months
1550							(unselectable ? '<span class="ui-state-default">' + printDate.getDate() + '</span>' : '<a class="ui-state-default' +
1551							(printDate.getTime() == today.getTime() ? ' ui-state-highlight' : '') +
1552							(printDate.getTime() == currentDate.getTime() ? ' ui-state-active' : '') + // highlight selected day
1553							(otherMonth ? ' ui-priority-secondary' : '') + // distinguish dates from other months
1554							'" href="#">' + printDate.getDate() + '</a>')) + '</td>'; // display selectable date
1555						printDate.setDate(printDate.getDate() + 1);
1556						printDate = this._daylightSavingAdjust(printDate);
1557					}
1558					calender += tbody + '</tr>';
1559				}
1560				drawMonth++;
1561				if (drawMonth > 11) {
1562					drawMonth = 0;
1563					drawYear++;
1564				}
1565				calender += '</tbody></table>' + (isMultiMonth ? '</div>' + 
1566							((numMonths[0] > 0 && col == numMonths[1]-1) ? '<div class="ui-datepicker-row-break"></div>' : '') : '');
1567				group += calender;
1568			}
1569			html += group;
1570		}
1571		html += buttonPanel + ($.browser.msie && parseInt($.browser.version,10) < 7 && !inst.inline ?
1572			'<iframe src="javascript:false;" class="ui-datepicker-cover" frameborder="0"></iframe>' : '');
1573		inst._keyEvent = false;
1574		return html;
1575	},
1576
1577	/* Generate the month and year header. */
1578	_generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate,
1579			secondary, monthNames, monthNamesShort) {
1580		var changeMonth = this._get(inst, 'changeMonth');
1581		var changeYear = this._get(inst, 'changeYear');
1582		var showMonthAfterYear = this._get(inst, 'showMonthAfterYear');
1583		var html = '<div class="ui-datepicker-title">';
1584		var monthHtml = '';
1585		// month selection
1586		if (secondary || !changeMonth)
1587			monthHtml += '<span class="ui-datepicker-month">' + monthNames[drawMonth] + '</span>';
1588		else {
1589			var inMinYear = (minDate && minDate.getFullYear() == drawYear);
1590			var inMaxYear = (maxDate && maxDate.getFullYear() == drawYear);
1591			monthHtml += '<select class="ui-datepicker-month" ' +
1592				'onchange="DP_jQuery_' + dpuuid + '.datepicker._selectMonthYear(\'#' + inst.id + '\', this, \'M\');" ' +
1593				'onclick="DP_jQuery_' + dpuuid + '.datepicker._clickMonthYear(\'#' + inst.id + '\');"' +
1594			 	'>';
1595			for (var month = 0; month < 12; month++) {
1596				if ((!inMinYear || month >= minDate.getMonth()) &&
1597						(!inMaxYear || month <= maxDate.getMonth()))
1598					monthHtml += '<option value="' + month + '"' +
1599						(month == drawMonth ? ' selected="selected"' : '') +
1600						'>' + monthNamesShort[month] + '</option>';
1601			}
1602			monthHtml += '</select>';
1603		}
1604		if (!showMonthAfterYear)
1605			html += monthHtml + (secondary || !(changeMonth && changeYear) ? '&#xa0;' : '');
1606		// year selection
1607		if ( !inst.yearshtml ) {
1608			inst.yearshtml = '';
1609			if (secondary || !changeYear)
1610				html += '<span class="ui-datepicker-year">' + drawYear + '</span>';
1611			else {
1612				// determine range of years to display
1613				var years = this._get(inst, 'yearRange').split(':');
1614				var thisYear = new Date().getFullYear();
1615				var determineYear = function(value) {
1616					var year = (value.match(/c[+-].*/) ? drawYear + parseInt(value.substring(1), 10) :
1617						(value.match(/[+-].*/) ? thisYear + parseInt(value, 10) :
1618						parseInt(value, 10)));
1619					return (isNaN(year) ? thisYear : year);
1620				};
1621				var year = determineYear(years[0]);
1622				var endYear = Math.max(year, determineYear(years[1] || ''));
1623				year = (minDate ? Math.max(year, minDate.getFullYear()) : year);
1624				endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear);
1625				inst.yearshtml += '<select class="ui-datepicker-year" ' +
1626					'onchange="DP_jQuery_' + dpuuid + '.datepicker._selectMonthYear(\'#' + inst.id + '\', this, \'Y\');" ' +
1627					'onclick="DP_jQuery_' + dpuuid + '.datepicker._clickMonthYear(\'#' + inst.id + '\');"' +
1628					'>';
1629				for (; year <= endYear; year++) {
1630					inst.yearshtml += '<option value="' + year + '"' +
1631						(year == drawYear ? ' selected="selected"' : '') +
1632						'>' + year + '</option>';
1633				}
1634				inst.yearshtml += '</select>';
1635				
1636				html += inst.yearshtml;
1637				inst.yearshtml = null;
1638			}
1639		}
1640		html += this._get(inst, 'yearSuffix');
1641		if (showMonthAfterYear)
1642			html += (secondary || !(changeMonth && changeYear) ? '&#xa0;' : '') + monthHtml;
1643		html += '</div>'; // Close datepicker_header
1644		return html;
1645	},
1646
1647	/* Adjust one of the date sub-fields. */
1648	_adjustInstDate: function(inst, offset, period) {
1649		var year = inst.drawYear + (period == 'Y' ? offset : 0);
1650		var month = inst.drawMonth + (period == 'M' ? offset : 0);
1651		var day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) +
1652			(period == 'D' ? offset : 0);
1653		var date = this._restrictMinMax(inst,
1654			this._daylightSavingAdjust(new Date(year, month, day)));
1655		inst.selectedDay = date.getDate();
1656		inst.drawMonth = inst.selectedMonth = date.getMonth();
1657		inst.drawYear = inst.selectedYear = date.getFullYear();
1658		if (period == 'M' || period == 'Y')
1659			this._notifyChange(inst);
1660	},
1661
1662	/* Ensure a date is within any min/max bounds. */
1663	_restrictMinMax: function(inst, date) {
1664		var minDate = this._getMinMaxDate(inst, 'min');
1665		var maxDate = this._getMinMaxDate(inst, 'max');
1666		var newDate = (minDate && date < minDate ? minDate : date);
1667		newDate = (maxDate && newDate > maxDate ? maxDate : newDate);
1668		return newDate;
1669	},
1670
1671	/* Notify change of month/year. */
1672	_notifyChange: function(inst) {
1673		var onChange = this._get(inst, 'onChangeMonthYear');
1674		if (onChange)
1675			onChange.apply((inst.input ? inst.input[0] : null),
1676				[inst.selectedYear, inst.selectedMonth + 1, inst]);
1677	},
1678
1679	/* Determine the number of months to show. */
1680	_getNumberOfMonths: function(inst) {
1681		var numMonths = this._get(inst, 'numberOfMonths');
1682		return (numMonths == null ? [1, 1] : (typeof numMonths == 'number' ? [1, numMonths] : numMonths));
1683	},
1684
1685	/* Determine the current maximum date - ensure no time components are set. */
1686	_getMinMaxDate: function(inst, minMax) {
1687		return this._determineDate(inst, this._get(inst, minMax + 'Date'), null);
1688	},
1689
1690	/* Find the number of days in a given month. */
1691	_getDaysInMonth: function(year, month) {
1692		return 32 - this._daylightSavingAdjust(new Date(year, month, 32)).getDate();
1693	},
1694
1695	/* Find the day of the week of the first of a month. */
1696	_getFirstDayOfMonth: function(year, month) {
1697		return new Date(year, month, 1).getDay();
1698	},
1699
1700	/* Determines if we should allow a "next/prev" month display change. */
1701	_canAdjustMonth: function(inst, offset, curYear, curMonth) {
1702		var numMonths = this._getNumberOfMonths(inst);
1703		var date = this._daylightSavingAdjust(new Date(curYear,
1704			curMonth + (offset < 0 ? offset : numMonths[0] * numMonths[1]), 1));
1705		if (offset < 0)
1706			date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth()));
1707		return this._isInRange(inst, date);
1708	},
1709
1710	/* Is the given date in the accepted range? */
1711	_isInRange: function(inst, date) {
1712		var minDate = this._getMinMaxDate(inst, 'min');
1713		var maxDate = this._getMinMaxDate(inst, 'max');
1714		return ((!minDate || date.getTime() >= minDate.getTime()) &&
1715			(!maxDate || date.getTime() <= maxDate.getTime()));
1716	},
1717
1718	/* Provide the configuration settings for formatting/parsing. */
1719	_getFormatConfig: function(inst) {
1720		var shortYearCutoff = this._get(inst, 'shortYearCutoff');
1721		shortYearCutoff = (typeof shortYearCutoff != 'string' ? shortYearCutoff :
1722			new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
1723		return {shortYearCutoff: shortYearCutoff,
1724			dayNamesShort: this._get(inst, 'dayNamesShort'), dayNames: this._get(inst, 'dayNames'),
1725			monthNamesShort: this._get(inst, 'monthNamesShort'), monthNames: this._get(inst, 'monthNames')};
1726	},
1727
1728	/* Format the given date for display. */
1729	_formatDate: function(inst, day, month, year) {
1730		if (!day) {
1731			inst.currentDay = inst.selectedDay;
1732			inst.currentMonth = inst.selectedMonth;
1733			inst.currentYear = inst.selectedYear;
1734		}
1735		var date = (day ? (typeof day == 'object' ? day :
1736			this._daylightSavingAdjust(new Date(year, month, day))) :
1737			this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
1738		return this.formatDate(this._get(inst, 'dateFormat'), date, this._getFormatConfig(inst));
1739	}
1740});
1741
1742/*
1743 * Bind hover events for datepicker elements.
1744 * Done via delegate so the binding only occurs once in the lifetime of the parent div.
1745 * Global instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker.
1746 */ 
1747function bindHover(dpDiv) {
1748	var selector = 'button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a';
1749	return dpDiv.bind('mouseout', function(event) {
1750			var elem = $( event.target ).closest( selector );
1751			if ( !elem.length ) {
1752				return;
1753			}
1754			elem.removeClass( "ui-state-hover ui-datepicker-prev-hover ui-datepicker-next-hover" );
1755		})
1756		.bind('mouseover', function(event) {
1757			var elem = $( event.target ).closest( selector );
1758			if ($.datepicker._isDisabledDatepicker( instActive.inline ? dpDiv.parent()[0] : instActive.input[0]) ||
1759					!elem.length ) {
1760				return;
1761			}
1762			elem.parents('.ui-datepicker-calendar').find('a').removeClass('ui-state-hover');
1763			elem.addClass('ui-state-hover');
1764			if (elem.hasClass('ui-datepicker-prev')) elem.addClass('ui-datepicker-prev-hover');
1765			if (elem.hasClass('ui-datepicker-next')) elem.addClass('ui-datepicker-next-hover');
1766		});
1767}
1768
1769/* jQuery extend now ignores nulls! */
1770function extendRemove(target, props) {
1771	$.extend(target, props);
1772	for (var name in props)
1773		if (props[name] == null || props[name] == undefined)
1774			target[name] = props[name];
1775	return target;
1776};
1777
1778/* Determine whether an object is an array. */
1779function isArray(a) {
1780	return (a && (($.browser.safari && typeof a == 'object' && a.length) ||
1781		(a.constructor && a.constructor.toString().match(/\Array\(\)/))));
1782};
1783
1784/* Invoke the datepicker functionality.
1785   @param  options  string - a command, optionally followed by additional parameters or
1786                    Object - settings for attaching new datepicker functionality
1787   @return  jQuery object */
1788$.fn.datepicker = function(options){
1789	
1790	/* Verify an empty collection wasn't passed - Fixes #6976 */
1791	if ( !this.length ) {
1792		return this;
1793	}
1794	
1795	/* Initialise the date picker. */
1796	if (!$.datepicker.initialized) {
1797		$(document).mousedown($.datepicker._checkExternalClick).
1798			find('body').append($.datepicker.dpDiv);
1799		$.datepicker.initialized = true;
1800	}
1801
1802	var otherArgs = Array.prototype.slice.call(arguments, 1);
1803	if (typeof options == 'string' && (options == 'isDisabled' || options == 'getDate' || options == 'widget'))
1804		return $.datepicker['_' + options + 'Datepicker'].
1805			apply($.datepicker, [this[0]].concat(otherArgs));
1806	if (options == 'option' && arguments.length == 2 && typeof arguments[1] == 'string')
1807		return $.datepicker['_' + options + 'Datepicker'].
1808			apply($.datepicker, [this[0]].concat(otherArgs));
1809	return this.each(function() {
1810		typeof options == 'string' ?
1811			$.datepicker['_' + options + 'Datepicker'].
1812				apply($.datepicker, [this].concat(otherArgs)) :
1813			$.datepicker._attachDatepicker(this, options);
1814	});
1815};
1816
1817$.datepicker = new Datepicker(); // singleton instance
1818$.datepicker.initialized = false;
1819$.datepicker.uuid = new Date().getTime();
1820$.datepicker.version = "1.8.14";
1821
1822// Workaround for #4055
1823// Add another global to avoid noConflict issues with inline event handlers
1824window['DP_jQuery_' + dpuuid] = $;
1825
1826$('.date-pick').datepicker({autoFocusNextInput: true});
1827})(jQuery);
1828
1829
1830}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.