PageSourceSearch

https://pgajuniorgolfcamps.com/public/javascript/ui/ui.datepicker.js?100024

js pgajuniorgolfcamps.com collected 2026-10-04 05:25:13 UTC 67,881 bytes, 1,556 lines download raw bytes

1/*
2 * jQuery UI Datepicker
3 *
4 * Copyright (c) 2006, 2007, 2008 Marc Grabanski
5 * Dual licensed under the MIT (MIT-LICENSE.txt)
6 * and GPL (GPL-LICENSE.txt) licenses.
7 *
8 * http://docs.jquery.com/UI/Datepicker
9 *
10 * Depends:
11 *	ui.core.js
12 *
13 * Marc Grabanski ([email protected]) and Keith Wood ([email protected]).
14 */
15
16(function($) { // hide the namespace
17
18var PROP_NAME = 'datepicker';
19
20/* Date picker manager.
21   Use the singleton instance of this class, $.datepicker, to interact with the date picker.
22   Settings for (groups of) date pickers are maintained in an instance object,
23   allowing multiple different settings on the same page. */
24
25function Datepicker() {
26	this.debug = false; // Change this to true to start debugging
27	this._curInst = null; // The current instance in use
28	this._disabledInputs = []; // List of date picker inputs that have been disabled
29	this._datepickerShowing = false; // True if the popup picker is showing , false if not
30	this._inDialog = false; // True if showing within a "dialog", false if not
31	this._mainDivId = 'ui-datepicker-div'; // The ID of the main datepicker division
32	this._appendClass = 'ui-datepicker-append'; // The name of the append marker class
33	this._triggerClass = 'ui-datepicker-trigger'; // The name of the trigger marker class
34	this._dialogClass = 'ui-datepicker-dialog'; // The name of the dialog marker class
35	this._promptClass = 'ui-datepicker-prompt'; // The name of the dialog prompt marker class
36	this._unselectableClass = 'ui-datepicker-unselectable'; // The name of the unselectable cell marker class
37	this._currentClass = 'ui-datepicker-current-day'; // The name of the current day marker class
38	this.regional = []; // Available regional settings, indexed by language code
39	this.regional[''] = { // Default regional settings
40		clearText: 'Clear', // Display text for clear link
41		clearStatus: 'Erase the current date', // Status text for clear link
42		closeText: 'Close', // Display text for close link
43		closeStatus: 'Close without change', // Status text for close link
44		prevText: '<Prev', // Display text for previous month link
45		prevStatus: 'Show the previous month', // Status text for previous month link
46		nextText: 'Next>', // Display text for next month link
47		nextStatus: 'Show the next month', // Status text for next month link
48		currentText: 'Today', // Display text for current month link
49		currentStatus: 'Show the current month', // Status text for current month link
50		monthNames: ['January','February','March','April','May','June',
51			'July','August','September','October','November','December'], // Names of months for drop-down and formatting
52		monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], // For formatting
53		monthStatus: 'Show a different month', // Status text for selecting a month
54		yearStatus: 'Show a different year', // Status text for selecting a year
55		weekHeader: 'Wk', // Header for the week of the year column
56		weekStatus: 'Week of the year', // Status text for the week of the year column
57		dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], // For formatting
58		dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], // For formatting
59		dayNamesMin: ['Su','Mo','Tu','We','Th','Fr','Sa'], // Column headings for days starting at Sunday
60		dayStatus: 'Set DD as first week day', // Status text for the day of the week selection
61		dateStatus: 'Select DD, M d', // Status text for the date selection
62		dateFormat: 'mm/dd/yy', // See format options on parseDate
63		firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
64		initStatus: 'Select a date', // Initial Status text on opening
65		isRTL: false // True if right-to-left language, false if left-to-right
66	};
67	this._defaults = { // Global defaults for all the date picker instances
68		showOn: 'focus', // 'focus' for popup on focus,
69			// 'button' for trigger button, or 'both' for either
70		showAnim: 'show', // Name of jQuery animation for popup
71		showOptions: {}, // Options for enhanced animations
72		defaultDate: null, // Used when field is blank: actual date,
73			// +/-number for offset from today, null for today
74		appendText: '', // Display text following the input box, e.g. showing the format
75		buttonText: '...', // Text for trigger button
76		buttonImage: '', // URL for trigger button image
77		buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
78		closeAtTop: true, // True to have the clear/close at the top,
79			// false to have them at the bottom
80		mandatory: false, // True to hide the Clear link, false to include it
81		hideIfNoPrevNext: false, // True to hide next/previous month links
82			// if not applicable, false to just disable them
83		navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
84		gotoCurrent: false, // True if today link goes back to current selection instead
85		changeMonth: true, // True if month can be selected directly, false if only prev/next
86		changeYear: true, // True if year can be selected directly, false if only prev/next
87		yearRange: '-2:+10', // Range of years to display in drop-down,
88			// either relative to current year (-nn:+nn) or absolute (nnnn:nnnn)
89		changeFirstDay: true, // True to click on day name to change, false to remain as set
90		highlightWeek: false, // True to highlight the selected week
91		showOtherMonths: false, // True to show dates in other months, false to leave blank
92		showWeeks: false, // True to show week of the year, false to omit
93		calculateWeek: this.iso8601Week, // How to calculate the week of the year,
94			// takes a Date and returns the number of the week for it
95		shortYearCutoff: '+10', // Short year values < this are in the current century,
96			// > this are in the previous century,
97			// string value starting with '+' for current year + value
98		showStatus: false, // True to show status bar at bottom, false to not show it
99		statusForDate: this.dateStatus, // Function to provide status text for a date -
100			// takes date and instance as parameters, returns display text
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: 'normal', // 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: 3, // Number of months to show at a time
113		stepMonths: 1, // Number of months to step back/forward
114		rangeSelect: false, // Allows for selecting a date range on one date picker
115		rangeSeparator: ' - ', // Text between two dates in a range
116		altField: '', // Selector for an alternate field to store selected dates into
117		altFormat: '' // The date format to use for the alternate field
118	};
119	$.extend(this._defaults, this.regional['']);
120	this.dpDiv = $('<div id="' + this._mainDivId + '" style="display: none;"></div>');
121}
122
123$.extend(Datepicker.prototype, {
124	/* Class name added to elements to indicate already configured with a date picker. */
125	markerClassName: 'hasDatepicker',
126
127	/* Debug logging (if enabled). */
128	log: function () {
129		if (this.debug)
130			console.log.apply('', arguments);
131	},
132
133	/* Override the default settings for all instances of the date picker.
134	   @param  settings  object - the new settings to use as defaults (anonymous object)
135	   @return the manager object */
136	setDefaults: function(settings) {
137		extendRemove(this._defaults, settings || {});
138		return this;
139	},
140
141	/* Attach the date picker to a jQuery selection.
142	   @param  target    element - the target input field or division or span
143	   @param  settings  object - the new settings to use for this date picker instance (anonymous) */
144	_attachDatepicker: function(target, settings) {
145		// check for settings on the control itself - in namespace 'date:'
146		var inlineSettings = null;
147		for (attrName in this._defaults) {
148			var attrValue = target.getAttribute('date:' + attrName);
149			if (attrValue) {
150				inlineSettings = inlineSettings || {};
151				try {
152					inlineSettings[attrName] = eval(attrValue);
153				} catch (err) {
154					inlineSettings[attrName] = attrValue;
155				}
156			}
157		}
158		var nodeName = target.nodeName.toLowerCase();
159		var inline = (nodeName == 'div' || nodeName == 'span');
160		if (!target.id)
161			target.id = target.getAttribute('name') + '-dp' + new Date().getTime();
162		var inst = this._newInst($(target), inline);
163		inst.settings = $.extend({}, settings || {}, inlineSettings || {});
164		if (nodeName == 'input') {
165			this._connectDatepicker(target, inst);
166		} else if (inline) {
167			this._inlineDatepicker(target, inst);
168		}
169	},
170
171	/* Create a new instance object. */
172	_newInst: function(target, inline) {
173		return {id: target[0].id, input: target, // associated target
174			selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
175			drawMonth: 0, drawYear: 0, // month being drawn
176			inline: inline, // is datepicker inline or not
177			dpDiv: (!inline ? this.dpDiv : // presentation div
178			$('<div class="ui-datepicker-inline"></div>'))};
179	},
180
181	/* Attach the date picker to an input field. */
182	_connectDatepicker: function(target, inst) {
183		var input = $(target);
184		if (input.hasClass(this.markerClassName))
185			return;
186		var appendText = this._get(inst, 'appendText');
187		var isRTL = this._get(inst, 'isRTL');
188		if (appendText)
189			input[isRTL ? 'before' : 'after']('<span class="' + this._appendClass + '">' + appendText + '</span>');
190		var showOn = this._get(inst, 'showOn');
191		if (showOn == 'focus' || showOn == 'both') // pop-up date picker when in the marked field
192			input.focus(this._showDatepicker);
193		if (showOn == 'button' || showOn == 'both') { // pop-up date picker when button clicked
194			var buttonText = this._get(inst, 'buttonText');
195			var buttonImage = this._get(inst, 'buttonImage');
196			var trigger = $(this._get(inst, 'buttonImageOnly') ?
197				$('<img/>').addClass(this._triggerClass).
198					attr({ src: buttonImage, alt: buttonText, title: buttonText }) :
199				$('<button type="button"></button>').addClass(this._triggerClass).
200					html(buttonImage == '' ? buttonText : $('<img/>').attr(
201					{ src:buttonImage, alt:buttonText, title:buttonText })));
202			input[isRTL ? 'before' : 'after'](trigger);
203			trigger.click(function() {
204				if ($.datepicker._datepickerShowing && $.datepicker._lastInput == target)
205					$.datepicker._hideDatepicker();
206				else
207					$.datepicker._showDatepicker(target);
208				return false;
209			});
210		}
211		input.addClass(this.markerClassName).keydown(this._doKeyDown).keypress(this._doKeyPress).
212			bind("setData.datepicker", function(event, key, value) {
213				inst.settings[key] = value;
214			}).bind("getData.datepicker", function(event, key) {
215				return this._get(inst, key);
216			});
217		$.data(target, PROP_NAME, inst);
218	},
219
220	/* Attach an inline date picker to a div. */
221	_inlineDatepicker: function(target, inst) {
222		var input = $(target);
223		if (input.hasClass(this.markerClassName))
224			return;
225		input.addClass(this.markerClassName).append(inst.dpDiv).
226			bind("setData.datepicker", function(event, key, value){
227				inst.settings[key] = value;
228			}).bind("getData.datepicker", function(event, key){
229				return this._get(inst, key);
230			});
231		$.data(target, PROP_NAME, inst);
232		this._setDate(inst, this._getDefaultDate(inst));
233		this._updateDatepicker(inst);
234	},
235
236	/* Pop-up the date picker in a "dialog" box.
237	   @param  input     element - ignored
238	   @param  dateText  string - the initial date to display (in the current format)
239	   @param  onSelect  function - the function(dateText) to call when a date is selected
240	   @param  settings  object - update the dialog date picker instance's settings (anonymous object)
241	   @param  pos       int[2] - coordinates for the dialog's position within the screen or
242	                     event - with x/y coordinates or
243	                     leave empty for default (screen centre)
244	   @return the manager object */
245	_dialogDatepicker: function(input, dateText, onSelect, settings, pos) {
246		var inst = this._dialogInst; // internal instance
247		if (!inst) {
248			var id = 'dp' + new Date().getTime();
249			this._dialogInput = $('<input type="text" id="' + id +
250				'" size="1" style="position: absolute; top: -100px;"/>');
251			this._dialogInput.keydown(this._doKeyDown);
252			$('body').append(this._dialogInput);
253			inst = this._dialogInst = this._newInst(this._dialogInput, false);
254			inst.settings = {};
255			$.data(this._dialogInput[0], PROP_NAME, inst);
256		}
257		extendRemove(inst.settings, settings || {});
258		this._dialogInput.val(dateText);
259
260		this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null);
261		if (!this._pos) {
262			var browserWidth = window.innerWidth || document.documentElement.clientWidth ||	document.body.clientWidth;
263			var browserHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
264			var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
265			var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
266			this._pos = // should use actual width/height below
267				[(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY];
268		}
269
270		// move input on screen for focus, but hidden behind dialog
271		this._dialogInput.css('left', this._pos[0] + 'px').css('top', this._pos[1] + 'px');
272		inst.settings.onSelect = onSelect;
273		this._inDialog = true;
274		this.dpDiv.addClass(this._dialogClass);
275		this._showDatepicker(this._dialogInput[0]);
276		if ($.blockUI)
277			$.blockUI(this.dpDiv);
278		$.data(this._dialogInput[0], PROP_NAME, inst);
279		return this;
280	},
281
282	/* Detach a datepicker from its control.
283	   @param  target    element - the target input field or division or span */
284	_destroyDatepicker: function(target) {
285		var nodeName = target.nodeName.toLowerCase();
286		var $target = $(target);
287		$.removeData(target, PROP_NAME);
288		if (nodeName == 'input') {
289			$target.siblings('.' + this._appendClass).remove().end().
290				siblings('.' + this._triggerClass).remove().end().
291				removeClass(this.markerClassName).
292				unbind('focus', this._showDatepicker).
293				unbind('keydown', this._doKeyDown).
294				unbind('keypress', this._doKeyPress);
295		} else if (nodeName == 'div' || nodeName == 'span')
296			$target.removeClass(this.markerClassName).empty();
297	},
298
299	/* Enable the date picker to a jQuery selection.
300	   @param  target    element - the target input field or division or span */
301	_enableDatepicker: function(target) {
302		target.disabled = false;
303		$(target).siblings('button.' + this._triggerClass).each(function() { this.disabled = false; }).end().
304			siblings('img.' + this._triggerClass).css({opacity: '1.0', cursor: ''});
305		this._disabledInputs = $.map(this._disabledInputs,
306			function(value) { return (value == target ? null : value); }); // delete entry
307	},
308
309	/* Disable the date picker to a jQuery selection.
310	   @param  target    element - the target input field or division or span */
311	_disableDatepicker: function(target) {
312		target.disabled = true;
313		$(target).siblings('button.' + this._triggerClass).each(function() { this.disabled = true; }).end().
314			siblings('img.' + this._triggerClass).css({opacity: '0.5', cursor: 'default'});
315		this._disabledInputs = $.map(this._disabledInputs,
316			function(value) { return (value == target ? null : value); }); // delete entry
317		this._disabledInputs[this._disabledInputs.length] = target;
318	},
319
320	/* Is the first field in a jQuery collection disabled as a datepicker?
321	   @param  target    element - the target input field or division or span
322	   @return boolean - true if disabled, false if enabled */
323	_isDisabledDatepicker: function(target) {
324		if (!target)
325			return false;
326		for (var i = 0; i < this._disabledInputs.length; i++) {
327			if (this._disabledInputs[i] == target)
328				return true;
329		}
330		return false;
331	},
332
333	/* Update the settings for a date picker attached to an input field or division.
334	   @param  target  element - the target input field or division or span
335	   @param  name    object - the new settings to update or
336	                   string - the name of the setting to change or
337	   @param  value   any - the new value for the setting (omit if above is an object) */
338	_changeDatepicker: function(target, name, value) {
339		var settings = name || {};
340		if (typeof name == 'string') {
341			settings = {};
342			settings[name] = value;
343		}
344		if (inst = $.data(target, PROP_NAME)) {
345			extendRemove(inst.settings, settings);
346			this._updateDatepicker(inst);
347		}
348	},
349
350	/* Set the dates for a jQuery selection.
351	   @param  target   element - the target input field or division or span
352	   @param  date     Date - the new date
353	   @param  endDate  Date - the new end date for a range (optional) */
354	_setDateDatepicker: function(target, date, endDate) {
355		var inst = $.data(target, PROP_NAME);
356		if (inst) {
357			this._setDate(inst, date, endDate);
358			this._updateDatepicker(inst);
359		}
360	},
361
362	/* Get the date(s) for the first entry in a jQuery selection.
363	   @param  target  element - the target input field or division or span
364	   @return Date - the current date or
365	           Date[2] - the current dates for a range */
366	_getDateDatepicker: function(target) {
367		var inst = $.data(target, PROP_NAME);
368		if (inst)
369			this._setDateFromField(inst);
370		return (inst ? this._getDate(inst) : null);
371	},
372
373	/* Handle keystrokes. */
374	_doKeyDown: function(e) {
375		var inst = $.data(e.target, PROP_NAME);
376		var handled = true;
377		if ($.datepicker._datepickerShowing)
378			switch (e.keyCode) {
379				case 9:  $.datepicker._hideDatepicker(null, '');
380						break; // hide on tab out
381				case 13: $.datepicker._selectDay(e.target, inst.selectedMonth, inst.selectedYear,
382							$('td.ui-datepicker-days-cell-over', inst.dpDiv)[0]);
383						return false; // don't submit the form
384						break; // select the value on enter
385				case 27: $.datepicker._hideDatepicker(null, $.datepicker._get(inst, 'duration'));
386						break; // hide on escape
387				case 33: $.datepicker._adjustDate(e.target, (e.ctrlKey ? -1 :
388							-$.datepicker._get(inst, 'stepMonths')), (e.ctrlKey ? 'Y' : 'M'));
389						break; // previous month/year on page up/+ ctrl
390				case 34: $.datepicker._adjustDate(e.target, (e.ctrlKey ? +1 :
391							+$.datepicker._get(inst, 'stepMonths')), (e.ctrlKey ? 'Y' : 'M'));
392						break; // next month/year on page down/+ ctrl
393				case 35: if (e.ctrlKey) $.datepicker._clearDate(e.target);
394						break; // clear on ctrl+end
395				case 36: if (e.ctrlKey) $.datepicker._gotoToday(e.target);
396						break; // current on ctrl+home
397				case 37: if (e.ctrlKey) $.datepicker._adjustDate(e.target, -1, 'D');
398						break; // -1 day on ctrl+left
399				case 38: if (e.ctrlKey) $.datepicker._adjustDate(e.target, -7, 'D');
400						break; // -1 week on ctrl+up
401				case 39: if (e.ctrlKey) $.datepicker._adjustDate(e.target, +1, 'D');
402						break; // +1 day on ctrl+right
403				case 40: if (e.ctrlKey) $.datepicker._adjustDate(e.target, +7, 'D');
404						break; // +1 week on ctrl+down
405				default: handled = false;
406			}
407		else if (e.keyCode == 36 && e.ctrlKey) // display the date picker on ctrl+home
408			$.datepicker._showDatepicker(this);
409		else
410			handled = false;
411		if (handled) {
412			e.preventDefault();
413			e.stopPropagation();
414		}
415	},
416
417	/* Filter entered characters - based on date format. */
418	_doKeyPress: function(e) {
419		var inst = $.data(e.target, PROP_NAME);
420		var chars = $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat'));
421		var chr = String.fromCharCode(e.charCode == undefined ? e.keyCode : e.charCode);
422		return e.ctrlKey || (chr < ' ' || !chars || chars.indexOf(chr) > -1);
423	},
424
425	/* Pop-up the date picker for a given input field.
426	   @param  input  element - the input field attached to the date picker or
427	                  event - if triggered by focus */
428	_showDatepicker: function(input) {
429		input = input.target || input;
430		if (input.nodeName.toLowerCase() != 'input') // find from button/image trigger
431			input = $('input', input.parentNode)[0];
432		if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput == input) // already here
433			return;
434		var inst = $.data(input, PROP_NAME);
435		var beforeShow = $.datepicker._get(inst, 'beforeShow');
436		extendRemove(inst.settings, (beforeShow ? beforeShow.apply(input, [input, inst]) : {}));
437		$.datepicker._hideDatepicker(null, '');
438		$.datepicker._lastInput = input;
439		$.datepicker._setDateFromField(inst);
440		if ($.datepicker._inDialog) // hide cursor
441			input.value = '';
442		if (!$.datepicker._pos) { // position below input
443			$.datepicker._pos = $.datepicker._findPos(input);
444			$.datepicker._pos[1] += input.offsetHeight; // add the height
445		}
446		var isFixed = false;
447		$(input).parents().each(function() {
448			isFixed |= $(this).css('position') == 'fixed';
449			return !isFixed;
450		});
451		if (isFixed && $.browser.opera) { // correction for Opera when fixed and scrolled
452			$.datepicker._pos[0] -= document.documentElement.scrollLeft;
453			$.datepicker._pos[1] -= document.documentElement.scrollTop;
454		}
455		var offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]};
456		$.datepicker._pos = null;
457		inst.rangeStart = null;
458		// determine sizing offscreen
459		inst.dpDiv.css({position: 'absolute', display: 'block', top: '-1000px'});
460		$.datepicker._updateDatepicker(inst);
461		// fix width for dynamic number of date pickers
462		inst.dpDiv.width($.datepicker._getNumberOfMonths(inst)[1] *
463			$('.ui-datepicker', inst.dpDiv[0])[0].offsetWidth);
464		// and adjust position before showing
465		offset = $.datepicker._checkOffset(inst, offset, isFixed);
466		inst.dpDiv.css({position: ($.datepicker._inDialog && $.blockUI ?
467			'static' : (isFixed ? 'fixed' : 'absolute')), display: 'none',
468			left: offset.left + 'px', top: offset.top + 'px'});
469		if (!inst.inline) {
470			var showAnim = $.datepicker._get(inst, 'showAnim') || 'show';
471			var duration = $.datepicker._get(inst, 'duration');
472			var postProcess = function() {
473				$.datepicker._datepickerShowing = true;
474				if (navigator.userAgent.indexOf('MSIE') > -1 && parseInt($.browser.version) < 7) // fix IE < 7 select problems
475					$('iframe.ui-datepicker-cover').css({width: inst.dpDiv.width() + 4,
476						height: inst.dpDiv.height() + 4});
477			};
478			if ($.effects && $.effects[showAnim])
479				inst.dpDiv.show(showAnim, $.datepicker._get(inst, 'showOptions'), duration, postProcess);
480			else
481				inst.dpDiv[showAnim](duration, postProcess);
482			if (duration == '')
483				postProcess();
484			if (inst.input[0].type != 'hidden')
485				inst.input[0].focus();
486			$.datepicker._curInst = inst;
487		}
488	},
489
490	/* Generate the date picker content. */
491	_updateDatepicker: function(inst) {
492		var dims = {width: inst.dpDiv.width() + 4,
493			height: inst.dpDiv.height() + 4};
494		inst.dpDiv.empty().append(this._generateDatepicker(inst)).
495			find('iframe.ui-datepicker-cover').
496			css({width: dims.width, height: dims.height});
497		var numMonths = this._getNumberOfMonths(inst);
498		inst.dpDiv[(numMonths[0] != 1 || numMonths[1] != 1 ? 'add' : 'remove') +
499			'Class']('ui-datepicker-multi');
500		inst.dpDiv[(this._get(inst, 'isRTL') ? 'add' : 'remove') +
501			'Class']('ui-datepicker-rtl');
502		if (inst.input && inst.input[0].type != 'hidden')
503			$(inst.input[0]).focus();
504	},
505
506	/* Check positioning to remain on screen. */
507	_checkOffset: function(inst, offset, isFixed) {
508		var pos = inst.input ? this._findPos(inst.input[0]) : null;
509		var browserWidth = window.innerWidth || document.documentElement.clientWidth;
510		var browserHeight = window.innerHeight || document.documentElement.clientHeight;
511		var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
512		var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
513		// reposition date picker horizontally if outside the browser window
514		if (this._get(inst, 'isRTL') || (offset.left + inst.dpDiv.width() - scrollX) > browserWidth)
515			offset.left = Math.max((isFixed ? 0 : scrollX),
516				pos[0] + (inst.input ? inst.input.width() : 0) - (isFixed ? scrollX : 0) - inst.dpDiv.width() -
517				(isFixed && $.browser.opera ? document.documentElement.scrollLeft : 0));
518		else
519			offset.left -= (isFixed ? scrollX : 0);
520		// reposition date picker vertically if outside the browser window
521		if ((offset.top + inst.dpDiv.height() - scrollY) > browserHeight)
522			offset.top = Math.max((isFixed ? 0 : scrollY),
523				pos[1] - (isFixed ? scrollY : 0) - (this._inDialog ? 0 : inst.dpDiv.height()) -
524				(isFixed && $.browser.opera ? document.documentElement.scrollTop : 0));
525		else
526			offset.top -= (isFixed ? scrollY : 0);
527		return offset;
528	},
529
530	/* Find an object's position on the screen. */
531	_findPos: function(obj) {
532        while (obj && (obj.type == 'hidden' || obj.nodeType != 1)) {
533            obj = obj.nextSibling;
534        }
535        var position = $(obj).offset();
536	    return [position.left, position.top];
537	},
538
539	/* Hide the date picker from view.
540	   @param  input  element - the input field attached to the date picker
541	   @param  duration  string - the duration over which to close the date picker */
542	_hideDatepicker: function(input, duration) {
543		var inst = this._curInst;
544		if (!inst)
545			return;
546		var rangeSelect = this._get(inst, 'rangeSelect');
547		if (rangeSelect && this._stayOpen)
548			this._selectDate('#' + inst.id, this._formatDate(inst,
549				inst.currentDay, inst.currentMonth, inst.currentYear));
550		this._stayOpen = false;
551		if (this._datepickerShowing) {
552			duration = (duration != null ? duration : this._get(inst, 'duration'));
553			var showAnim = this._get(inst, 'showAnim');
554			var postProcess = function() {
555				$.datepicker._tidyDialog(inst);
556			};
557			if (duration != '' && $.effects && $.effects[showAnim])
558				inst.dpDiv.hide(showAnim, $.datepicker._get(inst, 'showOptions'),
559					duration, postProcess);
560			else
561				inst.dpDiv[(duration == '' ? 'hide' : (showAnim == 'slideDown' ? 'slideUp' :
562					(showAnim == 'fadeIn' ? 'fadeOut' : 'hide')))](duration, postProcess);
563			if (duration == '')
564				this._tidyDialog(inst);
565			var onClose = this._get(inst, 'onClose');
566			if (onClose)
567				onClose.apply((inst.input ? inst.input[0] : null),
568					[this._getDate(inst), inst]);  // trigger custom callback
569			this._datepickerShowing = false;
570			this._lastInput = null;
571			inst.settings.prompt = null;
572			if (this._inDialog) {
573				this._dialogInput.css({ position: 'absolute', left: '0', top: '-100px' });
574				if ($.blockUI) {
575					$.unblockUI();
576					$('body').append(this.dpDiv);
577				}
578			}
579			this._inDialog = false;
580		}
581		this._curInst = null;
582	},
583
584	/* Tidy up after a dialog display. */
585	_tidyDialog: function(inst) {
586		inst.dpDiv.removeClass(this._dialogClass).unbind('.ui-datepicker');
587		$('.' + this._promptClass, inst.dpDiv).remove();
588	},
589
590	/* Close date picker if clicked elsewhere. */
591	_checkExternalClick: function(event) {
592		if (!$.datepicker._curInst)
593			return;
594		var $target = $(event.target);
595		if (($target.parents('#' + $.datepicker._mainDivId).length == 0) &&
596				!$target.hasClass($.datepicker.markerClassName) &&
597				!$target.hasClass($.datepicker._triggerClass) &&
598				$.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI))
599			$.datepicker._hideDatepicker(null, '');
600	},
601
602	/* Adjust one of the date sub-fields. */
603	_adjustDate: function(id, offset, period) {
604		var target = $(id);
605		var inst = $.data(target[0], PROP_NAME);
606		this._adjustInstDate(inst, offset, period);
607		this._updateDatepicker(inst);
608	},
609
610	/* Action for current link. */
611	_gotoToday: function(id) {
612		var target = $(id);
613		var inst = $.data(target[0], PROP_NAME);
614		if (this._get(inst, 'gotoCurrent') && inst.currentDay) {
615			inst.selectedDay = inst.currentDay;
616			inst.drawMonth = inst.selectedMonth = inst.currentMonth;
617			inst.drawYear = inst.selectedYear = inst.currentYear;
618		}
619		else {
620		var date = new Date();
621		inst.selectedDay = date.getDate();
622		inst.drawMonth = inst.selectedMonth = date.getMonth();
623		inst.drawYear = inst.selectedYear = date.getFullYear();
624		}
625		this._adjustDate(target);
626		this._notifyChange(inst);
627	},
628
629	/* Action for selecting a new month/year. */
630	_selectMonthYear: function(id, select, period) {
631		var target = $(id);
632		var inst = $.data(target[0], PROP_NAME);
633		inst._selectingMonthYear = false;
634		inst[period == 'M' ? 'drawMonth' : 'drawYear'] =
635			select.options[select.selectedIndex].value - 0;
636		this._adjustDate(target);
637		this._notifyChange(inst);
638	},
639
640	/* Restore input focus after not changing month/year. */
641	_clickMonthYear: function(id) {
642		var target = $(id);
643		var inst = $.data(target[0], PROP_NAME);
644		if (inst.input && inst._selectingMonthYear && navigator.userAgent.indexOf('MSIE') < 0)
645			inst.input[0].focus();
646		inst._selectingMonthYear = !inst._selectingMonthYear;
647	},
648
649	/* Action for changing the first week day. */
650	_changeFirstDay: function(id, day) {
651		var target = $(id);
652		var inst = $.data(target[0], PROP_NAME);
653		inst.settings.firstDay = day;
654		this._updateDatepicker(inst);
655	},
656
657	/* Action for selecting a day. */
658	_selectDay: function(id, month, year, td) {
659		if ($(td).hasClass(this._unselectableClass))
660			return;
661		var target = $(id);
662		var inst = $.data(target[0], PROP_NAME);
663		var rangeSelect = this._get(inst, 'rangeSelect');
664		if (rangeSelect) {
665			this._stayOpen = !this._stayOpen;
666			if (this._stayOpen) {
667				$('.ui-datepicker td').removeClass(this._currentClass);
668				$(td).addClass(this._currentClass);
669			}
670		}
671		inst.selectedDay = inst.currentDay = $('a', td).html();
672		inst.selectedMonth = inst.currentMonth = month;
673		inst.selectedYear = inst.currentYear = year;
674		if (this._stayOpen) {
675			inst.endDay = inst.endMonth = inst.endYear = null;
676		}
677		else if (rangeSelect) {
678			inst.endDay = inst.currentDay;
679			inst.endMonth = inst.currentMonth;
680			inst.endYear = inst.currentYear;
681		}
682		this._selectDate(id, this._formatDate(inst,
683			inst.currentDay, inst.currentMonth, inst.currentYear));
684		if (this._stayOpen) {
685			inst.rangeStart = this._daylightSavingAdjust(
686				new Date(inst.currentYear, inst.currentMonth, inst.currentDay));
687			this._updateDatepicker(inst);
688		}
689		else if (rangeSelect) {
690			inst.selectedDay = inst.currentDay = inst.rangeStart.getDate();
691			inst.selectedMonth = inst.currentMonth = inst.rangeStart.getMonth();
692			inst.selectedYear = inst.currentYear = inst.rangeStart.getFullYear();
693			inst.rangeStart = null;
694			if (inst.inline)
695				this._updateDatepicker(inst);
696		}
697	},
698
699	/* Erase the input field and hide the date picker. */
700	_clearDate: function(id) {
701		var target = $(id);
702		var inst = $.data(target[0], PROP_NAME);
703		if (this._get(inst, 'mandatory'))
704			return;
705		this._stayOpen = false;
706		inst.endDay = inst.endMonth = inst.endYear = inst.rangeStart = null;
707		this._selectDate(target, '');
708		if (id == '#id_start_date'){
709			target.attr('value','Start');
710		} else if (id == '#id_end_date'){
711			target.attr('value','End');
712		};
713	},
714
715	/* Update the input field with the selected date. */
716	_selectDate: function(id, dateStr) {
717		var target = $(id);
718		var inst = $.data(target[0], PROP_NAME);
719		dateStr = (dateStr != null ? dateStr : this._formatDate(inst));
720		if (this._get(inst, 'rangeSelect') && dateStr)
721			dateStr = (inst.rangeStart ? this._formatDate(inst, inst.rangeStart) :
722				dateStr) + this._get(inst, 'rangeSeparator') + dateStr;
723		if (inst.input)
724			inst.input.val(dateStr);
725		this._updateAlternate(inst);
726		var onSelect = this._get(inst, 'onSelect');
727		if (onSelect)
728			onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]);  // trigger custom callback
729		else if (inst.input)
730			inst.input.trigger('change'); // fire the change event
731		if (inst.inline)
732			this._updateDatepicker(inst);
733		else if (!this._stayOpen) {
734			this._hideDatepicker(null, this._get(inst, 'duration'));
735			this._lastInput = inst.input[0];
736			if (typeof(inst.input[0]) != 'object')
737				inst.input[0].focus(); // restore focus
738			this._lastInput = null;
739		}
740	},
741
742	/* Update any alternate field to synchronise with the main field. */
743	_updateAlternate: function(inst) {
744		var altField = this._get(inst, 'altField');
745		if (altField) { // update alternate field too
746			var altFormat = this._get(inst, 'altFormat');
747			var date = this._getDate(inst);
748			dateStr = (isArray(date) ? (!date[0] && !date[1] ? '' :
749				this.formatDate(altFormat, date[0], this._getFormatConfig(inst)) +
750				this._get(inst, 'rangeSeparator') + this.formatDate(
751				altFormat, date[1] || date[0], this._getFormatConfig(inst))) :
752				this.formatDate(altFormat, date, this._getFormatConfig(inst)));
753			$(altField).each(function() { $(this).val(dateStr); });
754		}
755	},
756
757	/* Set as beforeShowDay function to prevent selection of weekends.
758	   @param  date  Date - the date to customise
759	   @return [boolean, string] - is this date selectable?, what is its CSS class? */
760	noWeekends: function(date) {
761		var day = date.getDay();
762		return [(day > 0 && day < 6), ''];
763	},
764
765	/* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
766	   @param  date  Date - the date to get the week for
767	   @return  number - the number of the week within the year that contains this date */
768	iso8601Week: function(date) {
769		var checkDate = new Date(date.getFullYear(), date.getMonth(), date.getDate());
770		var firstMon = new Date(checkDate.getFullYear(), 1 - 1, 4); // First week always contains 4 Jan
771		var firstDay = firstMon.getDay() || 7; // Day of week: Mon = 1, ..., Sun = 7
772		firstMon.setDate(firstMon.getDate() + 1 - firstDay); // Preceding Monday
773		if (firstDay < 4 && checkDate < firstMon) { // Adjust first three days in year if necessary
774			checkDate.setDate(checkDate.getDate() - 3); // Generate for previous year
775			return $.datepicker.iso8601Week(checkDate);
776		} else if (checkDate > new Date(checkDate.getFullYear(), 12 - 1, 28)) { // Check last three days in year
777			firstDay = new Date(checkDate.getFullYear() + 1, 1 - 1, 4).getDay() || 7;
778			if (firstDay > 4 && (checkDate.getDay() || 7) < firstDay - 3) { // Adjust if necessary
779				checkDate.setDate(checkDate.getDate() + 3); // Generate for next year
780				return $.datepicker.iso8601Week(checkDate);
781			}
782		}
783		return Math.floor(((checkDate - firstMon) / 86400000) / 7) + 1; // Weeks to given date
784	},
785
786	/* Provide status text for a particular date.
787	   @param  date  the date to get the status for
788	   @param  inst  the current datepicker instance
789	   @return  the status display text for this date */
790	dateStatus: function(date, inst) {
791		return $.datepicker.formatDate($.datepicker._get(inst, 'dateStatus'),
792			date, $.datepicker._getFormatConfig(inst));
793	},
794
795	/* Parse a string value into a date object.
796	   See formatDate below for the possible formats.
797
798	   @param  format    string - the expected format of the date
799	   @param  value     string - the date in the above format
800	   @param  settings  Object - attributes include:
801	                     shortYearCutoff  number - the cutoff year for determining the century (optional)
802	                     dayNamesShort    string[7] - abbreviated names of the days from Sunday (optional)
803	                     dayNames         string[7] - names of the days from Sunday (optional)
804	                     monthNamesShort  string[12] - abbreviated names of the months (optional)
805	                     monthNames       string[12] - names of the months (optional)
806	   @return  Date - the extracted date value or null if value is blank */
807	parseDate: function (format, value, settings) {
808		if (format == null || value == null)
809			throw 'Invalid arguments';
810		value = (typeof value == 'object' ? value.toString() : value + '');
811		if (value == '')
812			return null;
813		var shortYearCutoff = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff;
814		var dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort;
815		var dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames;
816		var monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort;
817		var monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames;
818		var year = -1;
819		var month = -1;
820		var day = -1;
821		var literal = false;
822		// Check whether a format character is doubled
823		var lookAhead = function(match) {
824			var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
825			if (matches)
826				iFormat++;
827			return matches;
828		};
829		// Extract a number from the string value
830		var getNumber = function(match) {
831			lookAhead(match);
832			var origSize = (match == '@' ? 14 : (match == 'y' ? 4 : 2));
833			var size = origSize;
834			var num = 0;
835			while (size > 0 && iValue < value.length &&
836					value.charAt(iValue) >= '0' && value.charAt(iValue) <= '9') {
837				num = num * 10 + (value.charAt(iValue++) - 0);
838				size--;
839			}
840			if (size == origSize)
841				throw 'Missing number at position ' + iValue;
842			return num;
843		};
844		// Extract a name from the string value and convert to an index
845		var getName = function(match, shortNames, longNames) {
846			var names = (lookAhead(match) ? longNames : shortNames);
847			var size = 0;
848			for (var j = 0; j < names.length; j++)
849				size = Math.max(size, names[j].length);
850			var name = '';
851			var iInit = iValue;
852			while (size > 0 && iValue < value.length) {
853				name += value.charAt(iValue++);
854				for (var i = 0; i < names.length; i++)
855					if (name == names[i])
856						return i + 1;
857				size--;
858			}
859			throw 'Unknown name at position ' + iInit;
860		};
861		// Confirm that a literal character matches the string value
862		var checkLiteral = function() {
863			if (value.charAt(iValue) != format.charAt(iFormat))
864				throw 'Unexpected literal at position ' + iValue;
865			iValue++;
866		};
867		var iValue = 0;
868		for (var iFormat = 0; iFormat < format.length; iFormat++) {
869			if (literal)
870				if (format.charAt(iFormat) == "'" && !lookAhead("'"))
871					literal = false;
872				else
873					checkLiteral();
874			else
875				switch (format.charAt(iFormat)) {
876					case 'd':
877						day = getNumber('d');
878						break;
879					case 'D':
880						getName('D', dayNamesShort, dayNames);
881						break;
882					case 'm':
883						month = getNumber('m');
884						break;
885					case 'M':
886						month = getName('M', monthNamesShort, monthNames);
887						break;
888					case 'y':
889						year = getNumber('y');
890						break;
891					case '@':
892						var date = new Date(getNumber('@'));
893						year = date.getFullYear();
894						month = date.getMonth() + 1;
895						day = date.getDate();
896						break;
897					case "'":
898						if (lookAhead("'"))
899							checkLiteral();
900						else
901							literal = true;
902						break;
903					default:
904						checkLiteral();
905				}
906		}
907		if (year < 100)
908			year += new Date().getFullYear() - new Date().getFullYear() % 100 +
909				(year <= shortYearCutoff ? 0 : -100);
910		var date = this._daylightSavingAdjust(new Date(year, month - 1, day));
911		if (date.getFullYear() != year || date.getMonth() + 1 != month || date.getDate() != day)
912			throw 'Invalid date'; // E.g. 31/02/*
913		return date;
914	},
915
916	/* Standard date formats. */
917	ATOM: 'yy-mm-dd', // RFC 3339 (ISO 8601)
918	COOKIE: 'D, dd M yy',
919	ISO_8601: 'yy-mm-dd',
920	RFC_822: 'D, d M y',
921	RFC_850: 'DD, dd-M-y',
922	RFC_1036: 'D, d M y',
923	RFC_1123: 'D, d M yy',
924	RFC_2822: 'D, d M yy',
925	RSS: 'D, d M y', // RFC 822
926	TIMESTAMP: '@',
927	W3C: 'yy-mm-dd', // ISO 8601
928
929	/* Format a date object into a string value.
930	   The format can be combinations of the following:
931	   d  - day of month (no leading zero)
932	   dd - day of month (two digit)
933	   D  - day name short
934	   DD - day name long
935	   m  - month of year (no leading zero)
936	   mm - month of year (two digit)
937	   M  - month name short
938	   MM - month name long
939	   y  - year (two digit)
940	   yy - year (four digit)
941	   @ - Unix timestamp (ms since 01/01/1970)
942	   '...' - literal text
943	   '' - single quote
944
945	   @param  format    string - the desired format of the date
946	   @param  date      Date - the date value to format
947	   @param  settings  Object - attributes include:
948	                     dayNamesShort    string[7] - abbreviated names of the days from Sunday (optional)
949	                     dayNames         string[7] - names of the days from Sunday (optional)
950	                     monthNamesShort  string[12] - abbreviated names of the months (optional)
951	                     monthNames       string[12] - names of the months (optional)
952	   @return  string - the date in the above format */
953	formatDate: function (format, date, settings) {
954		if (!date)
955			return '';
956		var dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort;
957		var dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames;
958		var monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort;
959		var monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames;
960		// Check whether a format character is doubled
961		var lookAhead = function(match) {
962			var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
963			if (matches)
964				iFormat++;
965			return matches;
966		};
967		// Format a number, with leading zero if necessary
968		var formatNumber = function(match, value) {
969			return (lookAhead(match) && value < 10 ? '0' : '') + value;
970		};
971		// Format a name, short or long as requested
972		var formatName = function(match, value, shortNames, longNames) {
973			return (lookAhead(match) ? longNames[value] : shortNames[value]);
974		};
975		var output = '';
976		var literal = false;
977		if (date)
978			for (var iFormat = 0; iFormat < format.length; iFormat++) {
979				if (literal)
980					if (format.charAt(iFormat) == "'" && !lookAhead("'"))
981						literal = false;
982					else
983						output += format.charAt(iFormat);
984				else
985					switch (format.charAt(iFormat)) {
986						case 'd':
987							output += formatNumber('d', date.getDate());
988							break;
989						case 'D':
990							output += formatName('D', date.getDay(), dayNamesShort, dayNames);
991							break;
992						case 'm':
993							output += formatNumber('m', date.getMonth() + 1);
994							break;
995						case 'M':
996							output += formatName('M', date.getMonth(), monthNamesShort, monthNames);
997							break;
998						case 'y':
999							output += (lookAhead('y') ? date.getFullYear() :
1000								(date.getYear() % 100 < 10 ? '0' : '') + date.getYear() % 100);
1001							break;
1002						case '@':
1003							output += date.getTime();
1004							break;
1005						case "'":
1006							if (lookAhead("'"))
1007								output += "'";
1008							else
1009								literal = true;
1010							break;
1011						default:
1012							output += format.charAt(iFormat);
1013					}
1014			}
1015		return output;
1016	},
1017
1018	/* Extract all possible characters from the date format. */
1019	_possibleChars: function (format) {
1020		var chars = '';
1021		var literal = false;
1022		for (var iFormat = 0; iFormat < format.length; iFormat++)
1023			if (literal)
1024				if (format.charAt(iFormat) == "'" && !lookAhead("'"))
1025					literal = false;
1026				else
1027					chars += format.charAt(iFormat);
1028			else
1029				switch (format.charAt(iFormat)) {
1030					case 'd': case 'm': case 'y': case '@':
1031						chars += '0123456789';
1032						break;
1033					case 'D': case 'M':
1034						return null; // Accept anything
1035					case "'":
1036						if (lookAhead("'"))
1037							chars += "'";
1038						else
1039							literal = true;
1040						break;
1041					default:
1042						chars += format.charAt(iFormat);
1043				}
1044		return chars;
1045	},
1046
1047	/* Get a setting value, defaulting if necessary. */
1048	_get: function(inst, name) {
1049		return inst.settings[name] !== undefined ?
1050			inst.settings[name] : this._defaults[name];
1051	},
1052
1053	/* Parse existing date and initialise date picker. */
1054	_setDateFromField: function(inst) {
1055		var dateFormat = this._get(inst, 'dateFormat');
1056		var dates = inst.input ? inst.input.val().split(this._get(inst, 'rangeSeparator')) : null;
1057		inst.endDay = inst.endMonth = inst.endYear = null;
1058		var date = defaultDate = this._getDefaultDate(inst);
1059		if (dates.length > 0) {
1060			var settings = this._getFormatConfig(inst);
1061			if (dates.length > 1) {
1062				date = this.parseDate(dateFormat, dates[1], settings) || defaultDate;
1063				inst.endDay = date.getDate();
1064				inst.endMonth = date.getMonth();
1065				inst.endYear = date.getFullYear();
1066			}
1067			try {
1068				date = this.parseDate(dateFormat, dates[0], settings) || defaultDate;
1069			} catch (e) {
1070				this.log(e);
1071				date = defaultDate;
1072			}
1073		}
1074		inst.selectedDay = date.getDate();
1075		inst.drawMonth = inst.selectedMonth = date.getMonth();
1076		inst.drawYear = inst.selectedYear = date.getFullYear();
1077		inst.currentDay = (dates[0] ? date.getDate() : 0);
1078		inst.currentMonth = (dates[0] ? date.getMonth() : 0);
1079		inst.currentYear = (dates[0] ? date.getFullYear() : 0);
1080		this._adjustInstDate(inst);
1081	},
1082
1083	/* Retrieve the default date shown on opening. */
1084	_getDefaultDate: function(inst) {
1085		var date = this._determineDate(this._get(inst, 'defaultDate'), new Date());
1086		var minDate = this._getMinMaxDate(inst, 'min', true);
1087		var maxDate = this._getMinMaxDate(inst, 'max');
1088		date = (minDate && date < minDate ? minDate : date);
1089		date = (maxDate && date > maxDate ? maxDate : date);
1090		return date;
1091	},
1092
1093	/* A date may be specified as an exact value or a relative one. */
1094	_determineDate: function(date, defaultDate) {
1095		var offsetNumeric = function(offset) {
1096			var date = new Date();
1097			date.setDate(date.getDate() + offset);
1098			return date;
1099		};
1100		var offsetString = function(offset, getDaysInMonth) {
1101			var date = new Date();
1102			var year = date.getFullYear();
1103			var month = date.getMonth();
1104			var day = date.getDate();
1105			var pattern = /([+-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g;
1106			var matches = pattern.exec(offset);
1107			while (matches) {
1108				switch (matches[2] || 'd') {
1109					case 'd' : case 'D' :
1110						day += (matches[1] - 0); break;
1111					case 'w' : case 'W' :
1112						day += (matches[1] * 7); break;
1113					case 'm' : case 'M' :
1114						month += (matches[1] - 0);
1115						day = Math.min(day, getDaysInMonth(year, month));
1116						break;
1117					case 'y': case 'Y' :
1118						year += (matches[1] - 0);
1119						day = Math.min(day, getDaysInMonth(year, month));
1120						break;
1121				}
1122				matches = pattern.exec(offset);
1123			}
1124			return new Date(year, month, day);
1125		};
1126		date = (date == null ? defaultDate :
1127			(typeof date == 'string' ? offsetString(date, this._getDaysInMonth) :
1128			(typeof date == 'number' ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : date)));
1129		date = (date && date.toString() == 'Invalid Date' ? defaultDate : date);
1130		if (date) {
1131			date.setHours(0);
1132			date.setMinutes(0);
1133			date.setSeconds(0);
1134			date.setMilliseconds(0);
1135		}
1136		return this._daylightSavingAdjust(date);
1137	},
1138
1139	/* Handle switch to/from daylight saving.
1140	   Hours may be non-zero on daylight saving cut-over:
1141	   > 12 when midnight changeover, but then cannot generate
1142	   midnight datetime, so jump to 1AM, otherwise reset.
1143	   @param  date  (Date) the date to check
1144	   @return  (Date) the corrected date */
1145	_daylightSavingAdjust: function(date) {
1146		if (!date) return null;
1147		date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0);
1148		return date;
1149	},
1150
1151	/* Set the date(s) directly. */
1152	_setDate: function(inst, date, endDate) {
1153		var clear = !(date);
1154		date = this._determineDate(date, new Date());
1155		inst.selectedDay = inst.currentDay = date.getDate();
1156		inst.drawMonth = inst.selectedMonth = inst.currentMonth = date.getMonth();
1157		inst.drawYear = inst.selectedYear = inst.currentYear = date.getFullYear();
1158		if (this._get(inst, 'rangeSelect')) {
1159			if (endDate) {
1160				endDate = this._determineDate(endDate, null);
1161				inst.endDay = endDate.getDate();
1162				inst.endMonth = endDate.getMonth();
1163				inst.endYear = endDate.getFullYear();
1164			} else {
1165				inst.endDay = inst.currentDay;
1166				inst.endMonth = inst.currentMonth;
1167				inst.endYear = inst.currentYear;
1168			}
1169		}
1170		this._adjustInstDate(inst);
1171		if (inst.input)
1172			inst.input.val(clear ? '' : this._formatDate(inst) +
1173				(!this._get(inst, 'rangeSelect') ? '' : this._get(inst, 'rangeSeparator') +
1174				this._formatDate(inst, inst.endDay, inst.endMonth, inst.endYear)));
1175	},
1176
1177	/* Retrieve the date(s) directly. */
1178	_getDate: function(inst) {
1179		var startDate = (!inst.currentYear || (inst.input && inst.input.val() == '') ? null :
1180			this._daylightSavingAdjust(new Date(
1181			inst.currentYear, inst.currentMonth, inst.currentDay)));
1182		if (this._get(inst, 'rangeSelect')) {
1183			return [inst.rangeStart || startDate,
1184				(!inst.endYear ? inst.rangeStart || startDate :
1185				this._daylightSavingAdjust(new Date(inst.endYear, inst.endMonth, inst.endDay)))];
1186		} else
1187			return startDate;
1188	},
1189
1190	/* Generate the HTML for the current state of the date picker. */
1191	_generateDatepicker: function(inst) {
1192		var today = new Date();
1193		today = this._daylightSavingAdjust(
1194			new Date(today.getFullYear(), today.getMonth(), today.getDate())); // clear time
1195		var showStatus = this._get(inst, 'showStatus');
1196		var isRTL = this._get(inst, 'isRTL');
1197		// build the date picker HTML
1198		var clear = (this._get(inst, 'mandatory') ? '' :
1199			'<div class="ui-datepicker-clear"><a onclick="jQuery.datepicker._clearDate(\'#' + inst.id + '\');"' +
1200			(showStatus ? this._addStatus(inst, this._get(inst, 'clearStatus') || '&#xa0;') : '') + '>' +
1201			this._get(inst, 'clearText') + '</a></div>');
1202		var controls = '<div class="ui-datepicker-control">' + (isRTL ? '' : clear) +
1203			'<div class="ui-datepicker-close"><a onclick="jQuery.datepicker._hideDatepicker();"' +
1204			(showStatus ? this._addStatus(inst, this._get(inst, 'closeStatus') || '&#xa0;') : '') + '>' +
1205			this._get(inst, 'closeText') + '</a></div>' + (isRTL ? clear : '')  + '</div>';
1206		var prompt = this._get(inst, 'prompt');
1207		var closeAtTop = this._get(inst, 'closeAtTop');
1208		var hideIfNoPrevNext = this._get(inst, 'hideIfNoPrevNext');
1209		var navigationAsDateFormat = this._get(inst, 'navigationAsDateFormat');
1210		var numMonths = this._getNumberOfMonths(inst);
1211		var stepMonths = this._get(inst, 'stepMonths');
1212		var isMultiMonth = (numMonths[0] != 1 || numMonths[1] != 1);
1213		var currentDate = this._daylightSavingAdjust((!inst.currentDay ? new Date(9999, 9, 9) :
1214			new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
1215		var minDate = this._getMinMaxDate(inst, 'min', true);
1216		var maxDate = this._getMinMaxDate(inst, 'max');
1217		var drawMonth = inst.drawMonth;
1218		var drawYear = inst.drawYear;
1219		if (maxDate) {
1220			var maxDraw = this._daylightSavingAdjust(new Date(maxDate.getFullYear(),
1221				maxDate.getMonth() - numMonths[1] + 1, maxDate.getDate()));
1222			maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw);
1223			while (this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1)) > maxDraw) {
1224				drawMonth--;
1225				if (drawMonth < 0) {
1226					drawMonth = 11;
1227					drawYear--;
1228				}
1229			}
1230		}
1231		// controls and links
1232		var prevText = this._get(inst, 'prevText');
1233		prevText = (!navigationAsDateFormat ? prevText : this.formatDate(prevText,
1234			this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)),
1235			this._getFormatConfig(inst)));
1236		var prev = '<div class="ui-datepicker-prev">' + (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ?
1237			'<a onclick="jQuery.datepicker._adjustDate(\'#' + inst.id + '\', -' + stepMonths + ', \'M\');"' +
1238			(showStatus ? this._addStatus(inst, this._get(inst, 'prevStatus') || '&#xa0;') : '') + '>
1238' + prevText + '</a>' :
1239			(hideIfNoPrevNext ? '' : '<label>' + prevText + '</label>')) + '</div>';
1240		var nextText = this._get(inst, 'nextText');
1241		nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText,
1242			this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)),
1243			this._getFormatConfig(inst)));
1244		var next = '<div class="ui-datepicker-next">' + (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ?
1245			'<a onclick="jQuery.datepicker._adjustDate(\'#' + inst.id + '\', +' + stepMonths + ', \'M\');"' +
1246			(showStatus ? this._addStatus(inst, this._get(inst, 'nextStatus') || '&#xa0;') : '') + '>' + nextText + '</a>' :
1247			(hideIfNoPrevNext ? '' : '<label>' + nextText + '</label>')) + '</div>';
1248		var currentText = this._get(inst, 'currentText');
1249		currentText = (!navigationAsDateFormat ? currentText: this.formatDate(
1250			currentText, today, this._getFormatConfig(inst)));
1251		var html = (prompt ? '<div class="' + this._promptClass + '">' + prompt + '</div>' : '') +
1252			(closeAtTop && !inst.inline ? controls : '') +
1253			'<div class="ui-datepicker-links">' + (isRTL ? next : prev) +
1254			(this._isInRange(inst, (this._get(inst, 'gotoCurrent') && inst.currentDay ?
1255			currentDate : today)) ? '<div class="ui-datepicker-current">' +
1256			'<a onclick="jQuery.datepicker._gotoToday(\'#' + inst.id + '\');"' +
1257			(showStatus ? this._addStatus(inst, this._get(inst, 'currentStatus') || '&#xa0;') : '') + '>' +
1258			currentText + '</a></div>' : '') + (isRTL ? prev : next) + '</div>';
1259		var firstDay = this._get(inst, 'firstDay');
1260		var changeFirstDay = this._get(inst, 'changeFirstDay');
1261		var dayNames = this._get(inst, 'dayNames');
1262		var dayNamesShort = this._get(inst, 'dayNamesShort');
1263		var dayNamesMin = this._get(inst, 'dayNamesMin');
1264		var monthNames = this._get(inst, 'monthNames');
1265		var beforeShowDay = this._get(inst, 'beforeShowDay');
1266		var highlightWeek = this._get(inst, 'highlightWeek');
1267		var showOtherMonths = this._get(inst, 'showOtherMonths');
1268		var showWeeks = this._get(inst, 'showWeeks');
1269		var calculateWeek = this._get(inst, 'calculateWeek') || this.iso8601Week;
1270		var status = (showStatus ? this._get(inst, 'dayStatus') || '&#xa0;' : '');
1271		var dateStatus = this._get(inst, 'statusForDate') || this.dateStatus;
1272		var endDate = inst.endDay ? this._daylightSavingAdjust(
1273			new Date(inst.endYear, inst.endMonth, inst.endDay)) : currentDate;
1274		for (var row = 0; row < numMonths[0]; row++)
1275			for (var col = 0; col < numMonths[1]; col++) {
1276				var selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay));
1277				html += '<div class="ui-datepicker-one-month' + (col == 0 ? ' ui-datepicker-new-row' : '') + '">' +
1278					this._generateMonthYearHeader(inst, drawMonth, drawYear, minDate, maxDate,
1279					selectedDate, row > 0 || col > 0, showStatus, monthNames) + // draw month headers
1280					'<table class="ui-datepicker" cellpadding="0" cellspacing="0"><thead>' +
1281					'<tr class="ui-datepicker-title-row">' +
1282					(showWeeks ? '<td>' + this._get(inst, 'weekHeader') + '</td>' : '');
1283				for (var dow = 0; dow < 7; dow++) { // days of the week
1284					var day = (dow + firstDay) % 7;
1285					var dayStatus = (status.indexOf('DD') > -1 ? status.replace(/DD/, dayNames[day]) :
1286						status.replace(/D/, dayNamesShort[day]));
1287					html += '<td' + ((dow + firstDay + 6) % 7 >= 5 ? ' class="ui-datepicker-week-end-cell"' : '') + '>' +
1288						(!changeFirstDay ? '<span' :
1289						'<a onclick="jQuery.datepicker._changeFirstDay(\'#' + inst.id + '\', ' + day + ');"') +
1290						(showStatus ? this._addStatus(inst, dayStatus) : '') + ' title="' + dayNames[day] + '">' +
1291						dayNamesMin[day] + (changeFirstDay ? '</a>' : '</span>') + '</td>';
1292				}
1293				html += '</tr></thead><tbody>';
1294				var daysInMonth = this._getDaysInMonth(drawYear, drawMonth);
1295				if (drawYear == inst.selectedYear && drawMonth == inst.selectedMonth)
1296					inst.selectedDay = Math.min(inst.selectedDay, daysInMonth);
1297				var leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7;
1298				var numRows = (isMultiMonth ? 6 : Math.ceil((leadDays + daysInMonth) / 7)); // calculate the number of rows to generate
1299				var printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays));
1300				for (var dRow = 0; dRow < numRows; dRow++) { // create date picker rows
1301					html += '<tr class="ui-datepicker-days-row">' +
1302						(showWeeks ? '<td class="ui-datepicker-week-col">' + calculateWeek(printDate) + '</td>' : '');
1303					for (var dow = 0; dow < 7; dow++) { // create date picker days
1304						var daySettings = (beforeShowDay ?
1305							beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, '']);
1306						var otherMonth = (printDate.getMonth() != drawMonth);
1307						var unselectable = otherMonth || !daySettings[0] ||
1308							(minDate && printDate < minDate) || (maxDate && printDate > maxDate);
1309						html += '<td class="ui-datepicker-days-cell' +
1310							((dow + firstDay + 6) % 7 >= 5 ? ' ui-datepicker-week-end-cell' : '') + // highlight weekends
1311							(otherMonth ? ' ui-datepicker-otherMonth' : '') + // highlight days from other months
1312							(printDate.getTime() == selectedDate.getTime() && drawMonth == inst.selectedMonth ?
1313							' ui-datepicker-days-cell-over' : '') + // highlight selected day
1314							(unselectable ? ' ' + this._unselectableClass : '') +  // highlight unselectable days
1315							(otherMonth && !showOtherMonths ? '' : ' ' + daySettings[1] + // highlight custom dates
1316							(printDate.getTime() >= currentDate.getTime() && printDate.getTime() <= endDate.getTime() ?  // in current range
1317							' ' + this._currentClass : '') + // highlight selected day
1318							(printDate.getTime() == today.getTime() ? ' ui-datepicker-today' : '')) + '"' + // highlight today (if different)
1319							((!otherMonth || showOtherMonths) && daySettings[2] ? ' title="' + daySettings[2] + '"' : '') + // cell title
1320							(unselectable ? (highlightWeek ? ' onmouseover="jQuery(this).parent().addClass(\'ui-datepicker-week-over\');"' + // highlight selection week
1321							' onmouseout="jQuery(this).parent().removeClass(\'ui-datepicker-week-over\');"' : '') : // unhighlight selection week
1322							' onmouseover="jQuery(this).addClass(\'ui-datepicker-days-cell-over\')' + // highlight selection
1323							(highlightWeek ? '.parent().addClass(\'ui-datepicker-week-over\')' : '') + ';' + // highlight selection week
1324							(!showStatus || (otherMonth && !showOtherMonths) ? '' : 'jQuery(\'#ui-datepicker-status-' +
1325							inst.id + '\').html(\'' + (dateStatus.apply((inst.input ? inst.input[0] : null),
1326							[printDate, inst]) || '&#xa0;') +'\');') + '"' +
1327							' onmouseout="jQuery(this).removeClass(\'ui-datepicker-days-cell-over\')' + // unhighlight selection
1328							(highlightWeek ? '.parent().removeClass(\'ui-datepicker-week-over\')' : '') + ';' + // unhighlight selection week
1329							(!showStatus || (otherMonth && !showOtherMonths) ? '' : 'jQuery(\'#ui-datepicker-status-' +
1330							inst.id + '\').html(\'&#xa0;\');') + '" onclick="jQuery.datepicker._selectDay(\'#' +
1331							inst.id + '\',' + drawMonth + ',' + drawYear + ', this);"') + '>' + // actions
1332							(otherMonth ? (showOtherMonths ? printDate.getDate() : '&#xa0;') : // display for other months
1333							(unselectable ? printDate.getDate() : '<a>' + printDate.getDate() + '</a>')) + '</td>'; // display for this month
1334						printDate.setDate(printDate.getDate() + 1);
1335						printDate = this._daylightSavingAdjust(printDate);
1336					}
1337					html += '</tr>';
1338				}
1339				drawMonth++;
1340				if (drawMonth > 11) {
1341					drawMonth = 0;
1342					drawYear++;
1343				}
1344				html += '</tbody></table></div>';
1345			}
1346		html += (showStatus ? '<div style="clear: both;"></div><div id="ui-datepicker-status-' + inst.id +
1347			'" class="ui-datepicker-status">' + (this._get(inst, 'initStatus') || '&#xa0;') + '</div>' : '') +
1348			(!closeAtTop && !inst.inline ? controls : '') +
1349			'<div style="clear: both;"></div>' +
1350			(navigator.userAgent.indexOf('MSIE') > -1 && parseInt($.browser.version) < 7 && !inst.inline ?
1351			'<iframe src="javascript:false;" class="ui-datepicker-cover"></iframe>' : '');
1352		return html;
1353	},
1354
1355	/* Generate the month and year header. */
1356	_generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate,
1357			selectedDate, secondary, showStatus, monthNames) {
1358		minDate = (inst.rangeStart && minDate && selectedDate < minDate ? selectedDate : minDate);
1359		var html = '<div class="ui-datepicker-header">';
1360		// month selection
1361		if (secondary || !this._get(inst, 'changeMonth'))
1362			html += monthNames[drawMonth] + '&#xa0;';
1363		else {
1364			var inMinYear = (minDate && minDate.getFullYear() == drawYear);
1365			var inMaxYear = (maxDate && maxDate.getFullYear() == drawYear);
1366			html += '<select class="ui-datepicker-new-month" ' +
1367				'onchange="jQuery.datepicker._selectMonthYear(\'#' + inst.id + '\', this, \'M\');" ' +
1368				'onclick="jQuery.datepicker._clickMonthYear(\'#' + inst.id + '\');"' +
1369				(showStatus ? this._addStatus(inst, this._get(inst, 'monthStatus') || '&#xa0;') : '') + '>';
1370			for (var month = 0; month < 12; month++) {
1371				if ((!inMinYear || month >= minDate.getMonth()) &&
1372						(!inMaxYear || month <= maxDate.getMonth()))
1373					html += '<option value="' + month + '"' +
1374						(month == drawMonth ? ' selected="selected"' : '') +
1375						'>' + monthNames[month] + '</option>';
1376			}
1377			html += '</select>';
1378		}
1379		// year selection
1380		if (secondary || !this._get(inst, 'changeYear'))
1381			html += drawYear;
1382		else {
1383			// determine range of years to display
1384			var years = this._get(inst, 'yearRange').split(':');
1385			var year = 0;
1386			var endYear = 0;
1387			if (years.length != 2) {
1388				year = drawYear - 10;
1389				endYear = drawYear + 10;
1390			} else if (years[0].charAt(0) == '+' || years[0].charAt(0) == '-') {
1391				year = endYear = new Date().getFullYear();
1392				year += parseInt(years[0], 10);
1393				endYear += parseInt(years[1], 10);
1394			} else {
1395				year = parseInt(years[0], 10);
1396				endYear = parseInt(years[1], 10);
1397			}
1398			year = (minDate ? Math.max(year, minDate.getFullYear()) : year);
1399			endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear);
1400			html += '<select class="ui-datepicker-new-year" ' +
1401				'onchange="jQuery.datepicker._selectMonthYear(\'#' + inst.id + '\', this, \'Y\');" ' +
1402				'onclick="jQuery.datepicker._clickMonthYear(\'#' + inst.id + '\');"' +
1403				(showStatus ? this._addStatus(inst, this._get(inst, 'yearStatus') || '&#xa0;') : '') + '>';
1404			for (; year <= endYear; year++) {
1405				html += '<option value="' + year + '"' +
1406					(year == drawYear ? ' selected="selected"' : '') +
1407					'>' + year + '</option>';
1408			}
1409			html += '</select>';
1410		}
1411		html += '</div>'; // Close datepicker_header
1412		return html;
1413	},
1414
1415	/* Provide code to set and clear the status panel. */
1416	_addStatus: function(inst, text) {
1417		return ' onmouseover="jQuery(\'#ui-datepicker-status-' + inst.id + '\').html(\'' + text 
1417+ '\');" ' +
1418			'onmouseout="jQuery(\'#ui-datepicker-status-' + inst.id + '\').html(\'&#xa0;\');"';
1419	},
1420
1421	/* Adjust one of the date sub-fields. */
1422	_adjustInstDate: function(inst, offset, period) {
1423		var year = inst.drawYear + (period == 'Y' ? offset : 0);
1424		var month = inst.drawMonth + (period == 'M' ? offset : 0);
1425		var day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) +
1426			(period == 'D' ? offset : 0);
1427		var date = this._daylightSavingAdjust(new Date(year, month, day));
1428		// ensure it is within the bounds set
1429		var minDate = this._getMinMaxDate(inst, 'min', true);
1430		var maxDate = this._getMinMaxDate(inst, 'max');
1431		date = (minDate && date < minDate ? minDate : date);
1432		date = (maxDate && date > maxDate ? maxDate : date);
1433		inst.selectedDay = date.getDate();
1434		inst.drawMonth = inst.selectedMonth = date.getMonth();
1435		inst.drawYear = inst.selectedYear = date.getFullYear();
1436		if (period == 'M' || period == 'Y')
1437			this._notifyChange(inst);
1438	},
1439
1440	/* Notify change of month/year. */
1441	_notifyChange: function(inst) {
1442		var onChange = this._get(inst, 'onChangeMonthYear');
1443		if (onChange)
1444			onChange.apply((inst.input ? inst.input[0] : null),
1445				[new Date(inst.selectedYear, inst.selectedMonth, 1), inst]);
1446	},
1447
1448	/* Determine the number of months to show. */
1449	_getNumberOfMonths: function(inst) {
1450		var numMonths = this._get(inst, 'numberOfMonths');
1451		return (numMonths == null ? [1, 1] : (typeof numMonths == 'number' ? [1, numMonths] : numMonths));
1452	},
1453
1454	/* Determine the current maximum date - ensure no time components are set - may be overridden for a range. */
1455	_getMinMaxDate: function(inst, minMax, checkRange) {
1456		var date = this._determineDate(this._get(inst, minMax + 'Date'), null);
1457		return (!checkRange || !inst.rangeStart ? date :
1458			(!date || inst.rangeStart > date ? inst.rangeStart : date));
1459	},
1460
1461	/* Find the number of days in a given month. */
1462	_getDaysInMonth: function(year, month) {
1463		return 32 - new Date(year, month, 32).getDate();
1464	},
1465
1466	/* Find the day of the week of the first of a month. */
1467	_getFirstDayOfMonth: function(year, month) {
1468		return new Date(year, month, 1).getDay();
1469	},
1470
1471	/* Determines if we should allow a "next/prev" month display change. */
1472	_canAdjustMonth: function(inst, offset, curYear, curMonth) {
1473		var numMonths = this._getNumberOfMonths(inst);
1474		var date = this._daylightSavingAdjust(new Date(
1475			curYear, curMonth + (offset < 0 ? offset : numMonths[1]), 1));
1476		if (offset < 0)
1477			date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth()));
1478		return this._isInRange(inst, date);
1479	},
1480
1481	/* Is the given date in the accepted range? */
1482	_isInRange: function(inst, date) {
1483		// during range selection, use minimum of selected date and range start
1484		var newMinDate = (!inst.rangeStart ? null : this._daylightSavingAdjust(
1485			new Date(inst.selectedYear, inst.selectedMonth, inst.selectedDay)));
1486		newMinDate = (newMinDate && inst.rangeStart < newMinDate ? inst.rangeStart : newMinDate);
1487		var minDate = newMinDate || this._getMinMaxDate(inst, 'min');
1488		var maxDate = this._getMinMaxDate(inst, 'max');
1489		return ((!minDate || date >= minDate) && (!maxDate || date <= maxDate));
1490	},
1491
1492	/* Provide the configuration settings for formatting/parsing. */
1493	_getFormatConfig: function(inst) {
1494		var shortYearCutoff = this._get(inst, 'shortYearCutoff');
1495		shortYearCutoff = (typeof shortYearCutoff != 'string' ? shortYearCutoff :
1496			new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
1497		return {shortYearCutoff: shortYearCutoff,
1498			dayNamesShort: this._get(inst, 'dayNamesShort'), dayNames: this._get(inst, 'dayNames'),
1499			monthNamesShort: this._get(inst, 'monthNamesShort'), monthNames: this._get(inst, 'monthNames')};
1500	},
1501
1502	/* Format the given date for display. */
1503	_formatDate: function(inst, day, month, year) {
1504		if (!day) {
1505			inst.currentDay = inst.selectedDay;
1506			inst.currentMonth = inst.selectedMonth;
1507			inst.currentYear = inst.selectedYear;
1508		}
1509		var date = (day ? (typeof day == 'object' ? day :
1510			this._daylightSavingAdjust(new Date(year, month, day))) :
1511			this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
1512		return this.formatDate(this._get(inst, 'dateFormat'), date, this._getFormatConfig(inst));
1513	}
1514});
1515
1516/* jQuery extend now ignores nulls! */
1517function extendRemove(target, props) {
1518	$.extend(target, props);
1519	for (var name in props)
1520		if (props[name] == null || props[name] == undefined)
1521			target[name] = props[name];
1522	return target;
1523};
1524
1525/* Determine whether an object is an array. */
1526function isArray(a) {
1527	return (a && (($.browser.safari && typeof a == 'object' && a.length) ||
1528		(a.constructor && a.constructor.toString().match(/\Array\(\)/))));
1529};
1530
1531/* Invoke the datepicker functionality.
1532   @param  options  string - a command, optionally followed by additional parameters or
1533                    Object - settings for attaching new datepicker functionality
1534   @return  jQuery object */
1535$.fn.datepicker = function(options){
1536	var otherArgs = Array.prototype.slice.call(arguments, 1);
1537	if (typeof options == 'string' && (options == 'isDisabled' || options == 'getDate'))
1538		return $.datepicker['_' + options + 'Datepicker'].
1539			apply($.datepicker, [this[0]].concat(otherArgs));
1540	return this.each(function() {
1541		typeof options == 'string' ?
1542			$.datepicker['_' + options + 'Datepicker'].
1543				apply($.datepicker, [this].concat(otherArgs)) :
1544			$.datepicker._attachDatepicker(this, options);
1545	});
1546};
1547
1548$.datepicker = new Datepicker(); // singleton instance
1549
1550/* Initialise the date picker. */
1551$(document).ready(function() {
1552	$(document.body).append($.datepicker.dpDiv).
1553		mousedown($.datepicker._checkExternalClick);
1554});
1555
1556})(jQuery);

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.