PageSourceSearch

https://www.cm-covilha.pt/includes/site2016/jQuery/jquery.datePicker.js

js cm-covilha.pt collected 2026-10-02 05:52:22 UTC 76,102 bytes, 1,776 lines download raw bytes

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

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