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