Subversion Repositories Sites.obs-saisons.fr

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
40 aurelien 1
/*!
2
 * jQuery UI 1.8.5
3
 *
4
 * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
5
 * Dual licensed under the MIT or GPL Version 2 licenses.
6
 * http://jquery.org/license
7
 *
8
 * http://docs.jquery.com/UI
9
 */
10
(function( $, undefined ) {
11
 
12
// prevent duplicate loading
13
// this is only a problem because we proxy existing functions
14
// and we don't want to double proxy them
15
$.ui = $.ui || {};
16
if ( $.ui.version ) {
17
	return;
18
}
19
 
20
$.extend( $.ui, {
21
	version: "1.8.5",
22
 
23
	keyCode: {
24
		ALT: 18,
25
		BACKSPACE: 8,
26
		CAPS_LOCK: 20,
27
		COMMA: 188,
28
		COMMAND: 91,
29
		COMMAND_LEFT: 91, // COMMAND
30
		COMMAND_RIGHT: 93,
31
		CONTROL: 17,
32
		DELETE: 46,
33
		DOWN: 40,
34
		END: 35,
35
		ENTER: 13,
36
		ESCAPE: 27,
37
		HOME: 36,
38
		INSERT: 45,
39
		LEFT: 37,
40
		MENU: 93, // COMMAND_RIGHT
41
		NUMPAD_ADD: 107,
42
		NUMPAD_DECIMAL: 110,
43
		NUMPAD_DIVIDE: 111,
44
		NUMPAD_ENTER: 108,
45
		NUMPAD_MULTIPLY: 106,
46
		NUMPAD_SUBTRACT: 109,
47
		PAGE_DOWN: 34,
48
		PAGE_UP: 33,
49
		PERIOD: 190,
50
		RIGHT: 39,
51
		SHIFT: 16,
52
		SPACE: 32,
53
		TAB: 9,
54
		UP: 38,
55
		WINDOWS: 91 // COMMAND
56
	}
57
});
58
 
59
// plugins
60
$.fn.extend({
61
	_focus: $.fn.focus,
62
	focus: function( delay, fn ) {
63
		return typeof delay === "number" ?
64
			this.each(function() {
65
				var elem = this;
66
				setTimeout(function() {
67
					$( elem ).focus();
68
					if ( fn ) {
69
						fn.call( elem );
70
					}
71
				}, delay );
72
			}) :
73
			this._focus.apply( this, arguments );
74
	},
75
 
76
	scrollParent: function() {
77
		var scrollParent;
78
		if (($.browser.msie && (/(static|relative)/).test(this.css('position'))) || (/absolute/).test(this.css('position'))) {
79
			scrollParent = this.parents().filter(function() {
80
				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));
81
			}).eq(0);
82
		} else {
83
			scrollParent = this.parents().filter(function() {
84
				return (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));
85
			}).eq(0);
86
		}
87
 
88
		return (/fixed/).test(this.css('position')) || !scrollParent.length ? $(document) : scrollParent;
89
	},
90
 
91
	zIndex: function( zIndex ) {
92
		if ( zIndex !== undefined ) {
93
			return this.css( "zIndex", zIndex );
94
		}
95
 
96
		if ( this.length ) {
97
			var elem = $( this[ 0 ] ), position, value;
98
			while ( elem.length && elem[ 0 ] !== document ) {
99
				// Ignore z-index if position is set to a value where z-index is ignored by the browser
100
				// This makes behavior of this function consistent across browsers
101
				// WebKit always returns auto if the element is positioned
102
				position = elem.css( "position" );
103
				if ( position === "absolute" || position === "relative" || position === "fixed" ) {
104
					// IE returns 0 when zIndex is not specified
105
					// other browsers return a string
106
					// we ignore the case of nested elements with an explicit value of 0
107
					// <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
108
					value = parseInt( elem.css( "zIndex" ) );
109
					if ( !isNaN( value ) && value != 0 ) {
110
						return value;
111
					}
112
				}
113
				elem = elem.parent();
114
			}
115
		}
116
 
117
		return 0;
118
	},
119
 
120
	disableSelection: function() {
121
		return this.bind(
122
			"mousedown.ui-disableSelection selectstart.ui-disableSelection",
123
			function( event ) {
124
				event.preventDefault();
125
			});
126
	},
127
 
128
	enableSelection: function() {
129
		return this.unbind( ".ui-disableSelection" );
130
	}
131
});
132
 
133
$.each( [ "Width", "Height" ], function( i, name ) {
134
	var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
135
		type = name.toLowerCase(),
136
		orig = {
137
			innerWidth: $.fn.innerWidth,
138
			innerHeight: $.fn.innerHeight,
139
			outerWidth: $.fn.outerWidth,
140
			outerHeight: $.fn.outerHeight
141
		};
142
 
143
	function reduce( elem, size, border, margin ) {
144
		$.each( side, function() {
145
			size -= parseFloat( $.curCSS( elem, "padding" + this, true) ) || 0;
146
			if ( border ) {
147
				size -= parseFloat( $.curCSS( elem, "border" + this + "Width", true) ) || 0;
148
			}
149
			if ( margin ) {
150
				size -= parseFloat( $.curCSS( elem, "margin" + this, true) ) || 0;
151
			}
152
		});
153
		return size;
154
	}
155
 
156
	$.fn[ "inner" + name ] = function( size ) {
157
		if ( size === undefined ) {
158
			return orig[ "inner" + name ].call( this );
159
		}
160
 
161
		return this.each(function() {
162
			$.style( this, type, reduce( this, size ) + "px" );
163
		});
164
	};
165
 
166
	$.fn[ "outer" + name] = function( size, margin ) {
167
		if ( typeof size !== "number" ) {
168
			return orig[ "outer" + name ].call( this, size );
169
		}
170
 
171
		return this.each(function() {
172
			$.style( this, type, reduce( this, size, true, margin ) + "px" );
173
		});
174
	};
175
});
176
 
177
// selectors
178
function visible( element ) {
179
	return !$( element ).parents().andSelf().filter(function() {
180
		return $.curCSS( this, "visibility" ) === "hidden" ||
181
			$.expr.filters.hidden( this );
182
	}).length;
183
}
184
 
185
$.extend( $.expr[ ":" ], {
186
	data: function( elem, i, match ) {
187
		return !!$.data( elem, match[ 3 ] );
188
	},
189
 
190
	focusable: function( element ) {
191
		var nodeName = element.nodeName.toLowerCase(),
192
			tabIndex = $.attr( element, "tabindex" );
193
		if ( "area" === nodeName ) {
194
			var map = element.parentNode,
195
				mapName = map.name,
196
				img;
197
			if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
198
				return false;
199
			}
200
			img = $( "img[usemap=#" + mapName + "]" )[0];
201
			return !!img && visible( img );
202
		}
203
		return ( /input|select|textarea|button|object/.test( nodeName )
204
			? !element.disabled
205
			: "a" == nodeName
206
				? element.href || !isNaN( tabIndex )
207
				: !isNaN( tabIndex ))
208
			// the element and all of its ancestors must be visible
209
			&& visible( element );
210
	},
211
 
212
	tabbable: function( element ) {
213
		var tabIndex = $.attr( element, "tabindex" );
214
		return ( isNaN( tabIndex ) || tabIndex >= 0 ) && $( element ).is( ":focusable" );
215
	}
216
});
217
 
218
// support
219
$(function() {
220
	var div = document.createElement( "div" ),
221
		body = document.body;
222
 
223
	$.extend( div.style, {
224
		minHeight: "100px",
225
		height: "auto",
226
		padding: 0,
227
		borderWidth: 0
228
	});
229
 
230
	$.support.minHeight = body.appendChild( div ).offsetHeight === 100;
231
	// set display to none to avoid a layout bug in IE
232
	// http://dev.jquery.com/ticket/4014
233
	body.removeChild( div ).style.display = "none";
234
});
235
 
236
 
237
 
238
 
239
 
240
// deprecated
241
$.extend( $.ui, {
242
	// $.ui.plugin is deprecated.  Use the proxy pattern instead.
243
	plugin: {
244
		add: function( module, option, set ) {
245
			var proto = $.ui[ module ].prototype;
246
			for ( var i in set ) {
247
				proto.plugins[ i ] = proto.plugins[ i ] || [];
248
				proto.plugins[ i ].push( [ option, set[ i ] ] );
249
			}
250
		},
251
		call: function( instance, name, args ) {
252
			var set = instance.plugins[ name ];
253
			if ( !set || !instance.element[ 0 ].parentNode ) {
254
				return;
255
			}
256
 
257
			for ( var i = 0; i < set.length; i++ ) {
258
				if ( instance.options[ set[ i ][ 0 ] ] ) {
259
					set[ i ][ 1 ].apply( instance.element, args );
260
				}
261
			}
262
		}
263
	},
264
 
265
	// will be deprecated when we switch to jQuery 1.4 - use jQuery.contains()
266
	contains: function( a, b ) {
267
		return document.compareDocumentPosition ?
268
			a.compareDocumentPosition( b ) & 16 :
269
			a !== b && a.contains( b );
270
	},
271
 
272
	// only used by resizable
273
	hasScroll: function( el, a ) {
274
 
275
		//If overflow is hidden, the element might have extra content, but the user wants to hide it
276
		if ( $( el ).css( "overflow" ) === "hidden") {
277
			return false;
278
		}
279
 
280
		var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
281
			has = false;
282
 
283
		if ( el[ scroll ] > 0 ) {
284
			return true;
285
		}
286
 
287
		// TODO: determine which cases actually cause this to happen
288
		// if the element doesn't have the scroll set, see if it's possible to
289
		// set the scroll
290
		el[ scroll ] = 1;
291
		has = ( el[ scroll ] > 0 );
292
		el[ scroll ] = 0;
293
		return has;
294
	},
295
 
296
	// these are odd functions, fix the API or move into individual plugins
297
	isOverAxis: function( x, reference, size ) {
298
		//Determines when x coordinate is over "b" element axis
299
		return ( x > reference ) && ( x < ( reference + size ) );
300
	},
301
	isOver: function( y, x, top, left, height, width ) {
302
		//Determines when x, y coordinates is over "b" element
303
		return $.ui.isOverAxis( y, top, height ) && $.ui.isOverAxis( x, left, width );
304
	}
305
});
306
 
307
})( jQuery );
308
/*!
309
 * jQuery UI Widget 1.8.5
310
 *
311
 * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
312
 * Dual licensed under the MIT or GPL Version 2 licenses.
313
 * http://jquery.org/license
314
 *
315
 * http://docs.jquery.com/UI/Widget
316
 */
317
(function( $, undefined ) {
318
 
319
// jQuery 1.4+
320
if ( $.cleanData ) {
321
	var _cleanData = $.cleanData;
322
	$.cleanData = function( elems ) {
323
		for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
324
			$( elem ).triggerHandler( "remove" );
325
		}
326
		_cleanData( elems );
327
	};
328
} else {
329
	var _remove = $.fn.remove;
330
	$.fn.remove = function( selector, keepData ) {
331
		return this.each(function() {
332
			if ( !keepData ) {
333
				if ( !selector || $.filter( selector, [ this ] ).length ) {
334
					$( "*", this ).add( [ this ] ).each(function() {
335
						$( this ).triggerHandler( "remove" );
336
					});
337
				}
338
			}
339
			return _remove.call( $(this), selector, keepData );
340
		});
341
	};
342
}
343
 
344
$.widget = function( name, base, prototype ) {
345
	var namespace = name.split( "." )[ 0 ],
346
		fullName;
347
	name = name.split( "." )[ 1 ];
348
	fullName = namespace + "-" + name;
349
 
350
	if ( !prototype ) {
351
		prototype = base;
352
		base = $.Widget;
353
	}
354
 
355
	// create selector for plugin
356
	$.expr[ ":" ][ fullName ] = function( elem ) {
357
		return !!$.data( elem, name );
358
	};
359
 
360
	$[ namespace ] = $[ namespace ] || {};
361
	$[ namespace ][ name ] = function( options, element ) {
362
		// allow instantiation without initializing for simple inheritance
363
		if ( arguments.length ) {
364
			this._createWidget( options, element );
365
		}
366
	};
367
 
368
	var basePrototype = new base();
369
	// we need to make the options hash a property directly on the new instance
370
	// otherwise we'll modify the options hash on the prototype that we're
371
	// inheriting from
372
//	$.each( basePrototype, function( key, val ) {
373
//		if ( $.isPlainObject(val) ) {
374
//			basePrototype[ key ] = $.extend( {}, val );
375
//		}
376
//	});
377
	basePrototype.options = $.extend( true, {}, basePrototype.options );
378
	$[ namespace ][ name ].prototype = $.extend( true, basePrototype, {
379
		namespace: namespace,
380
		widgetName: name,
381
		widgetEventPrefix: $[ namespace ][ name ].prototype.widgetEventPrefix || name,
382
		widgetBaseClass: fullName
383
	}, prototype );
384
 
385
	$.widget.bridge( name, $[ namespace ][ name ] );
386
};
387
 
388
$.widget.bridge = function( name, object ) {
389
	$.fn[ name ] = function( options ) {
390
		var isMethodCall = typeof options === "string",
391
			args = Array.prototype.slice.call( arguments, 1 ),
392
			returnValue = this;
393
 
394
		// allow multiple hashes to be passed on init
395
		options = !isMethodCall && args.length ?
396
			$.extend.apply( null, [ true, options ].concat(args) ) :
397
			options;
398
 
399
		// prevent calls to internal methods
400
		if ( isMethodCall && options.substring( 0, 1 ) === "_" ) {
401
			return returnValue;
402
		}
403
 
404
		if ( isMethodCall ) {
405
			this.each(function() {
406
				var instance = $.data( this, name );
407
				if ( !instance ) {
408
					throw "cannot call methods on " + name + " prior to initialization; " +
409
						"attempted to call method '" + options + "'";
410
				}
411
				if ( !$.isFunction( instance[options] ) ) {
412
					throw "no such method '" + options + "' for " + name + " widget instance";
413
				}
414
				var methodValue = instance[ options ].apply( instance, args );
415
				if ( methodValue !== instance && methodValue !== undefined ) {
416
					returnValue = methodValue;
417
					return false;
418
				}
419
			});
420
		} else {
421
			this.each(function() {
422
				var instance = $.data( this, name );
423
				if ( instance ) {
424
					instance.option( options || {} )._init();
425
				} else {
426
					$.data( this, name, new object( options, this ) );
427
				}
428
			});
429
		}
430
 
431
		return returnValue;
432
	};
433
};
434
 
435
$.Widget = function( options, element ) {
436
	// allow instantiation without initializing for simple inheritance
437
	if ( arguments.length ) {
438
		this._createWidget( options, element );
439
	}
440
};
441
 
442
$.Widget.prototype = {
443
	widgetName: "widget",
444
	widgetEventPrefix: "",
445
	options: {
446
		disabled: false
447
	},
448
	_createWidget: function( options, element ) {
449
		// $.widget.bridge stores the plugin instance, but we do it anyway
450
		// so that it's stored even before the _create function runs
451
		$.data( element, this.widgetName, this );
452
		this.element = $( element );
453
		this.options = $.extend( true, {},
454
			this.options,
455
			$.metadata && $.metadata.get( element )[ this.widgetName ],
456
			options );
457
 
458
		var self = this;
459
		this.element.bind( "remove." + this.widgetName, function() {
460
			self.destroy();
461
		});
462
 
463
		this._create();
464
		this._init();
465
	},
466
	_create: function() {},
467
	_init: function() {},
468
 
469
	destroy: function() {
470
		this.element
471
			.unbind( "." + this.widgetName )
472
			.removeData( this.widgetName );
473
		this.widget()
474
			.unbind( "." + this.widgetName )
475
			.removeAttr( "aria-disabled" )
476
			.removeClass(
477
				this.widgetBaseClass + "-disabled " +
478
				"ui-state-disabled" );
479
	},
480
 
481
	widget: function() {
482
		return this.element;
483
	},
484
 
485
	option: function( key, value ) {
486
		var options = key,
487
			self = this;
488
 
489
		if ( arguments.length === 0 ) {
490
			// don't return a reference to the internal hash
491
			return $.extend( {}, self.options );
492
		}
493
 
494
		if  (typeof key === "string" ) {
495
			if ( value === undefined ) {
496
				return this.options[ key ];
497
			}
498
			options = {};
499
			options[ key ] = value;
500
		}
501
 
502
		$.each( options, function( key, value ) {
503
			self._setOption( key, value );
504
		});
505
 
506
		return self;
507
	},
508
	_setOption: function( key, value ) {
509
		this.options[ key ] = value;
510
 
511
		if ( key === "disabled" ) {
512
			this.widget()
513
				[ value ? "addClass" : "removeClass"](
514
					this.widgetBaseClass + "-disabled" + " " +
515
					"ui-state-disabled" )
516
				.attr( "aria-disabled", value );
517
		}
518
 
519
		return this;
520
	},
521
 
522
	enable: function() {
523
		return this._setOption( "disabled", false );
524
	},
525
	disable: function() {
526
		return this._setOption( "disabled", true );
527
	},
528
 
529
	_trigger: function( type, event, data ) {
530
		var callback = this.options[ type ];
531
 
532
		event = $.Event( event );
533
		event.type = ( type === this.widgetEventPrefix ?
534
			type :
535
			this.widgetEventPrefix + type ).toLowerCase();
536
		data = data || {};
537
 
538
		// copy original event properties over to the new event
539
		// this would happen if we could call $.event.fix instead of $.Event
540
		// but we don't have a way to force an event to be fixed multiple times
541
		if ( event.originalEvent ) {
542
			for ( var i = $.event.props.length, prop; i; ) {
543
				prop = $.event.props[ --i ];
544
				event[ prop ] = event.originalEvent[ prop ];
545
			}
546
		}
547
 
548
		this.element.trigger( event, data );
549
 
550
		return !( $.isFunction(callback) &&
551
			callback.call( this.element[0], event, data ) === false ||
552
			event.isDefaultPrevented() );
553
	}
554
};
555
 
556
})( jQuery );
557
/*!
558
 * jQuery UI Mouse 1.8.5
559
 *
560
 * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
561
 * Dual licensed under the MIT or GPL Version 2 licenses.
562
 * http://jquery.org/license
563
 *
564
 * http://docs.jquery.com/UI/Mouse
565
 *
566
 * Depends:
567
 *	jquery.ui.widget.js
568
 */
569
(function( $, undefined ) {
570
 
571
$.widget("ui.mouse", {
572
	options: {
573
		cancel: ':input,option',
574
		distance: 1,
575
		delay: 0
576
	},
577
	_mouseInit: function() {
578
		var self = this;
579
 
580
		this.element
581
			.bind('mousedown.'+this.widgetName, function(event) {
582
				return self._mouseDown(event);
583
			})
584
			.bind('click.'+this.widgetName, function(event) {
585
				if(self._preventClickEvent) {
586
					self._preventClickEvent = false;
587
					event.stopImmediatePropagation();
588
					return false;
589
				}
590
			});
591
 
592
		this.started = false;
593
	},
594
 
595
	// TODO: make sure destroying one instance of mouse doesn't mess with
596
	// other instances of mouse
597
	_mouseDestroy: function() {
598
		this.element.unbind('.'+this.widgetName);
599
	},
600
 
601
	_mouseDown: function(event) {
602
		// don't let more than one widget handle mouseStart
603
		// TODO: figure out why we have to use originalEvent
604
		event.originalEvent = event.originalEvent || {};
605
		if (event.originalEvent.mouseHandled) { return; }
606
 
607
		// we may have missed mouseup (out of window)
608
		(this._mouseStarted && this._mouseUp(event));
609
 
610
		this._mouseDownEvent = event;
611
 
612
		var self = this,
613
			btnIsLeft = (event.which == 1),
614
			elIsCancel = (typeof this.options.cancel == "string" ? $(event.target).parents().add(event.target).filter(this.options.cancel).length : false);
615
		if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
616
			return true;
617
		}
618
 
619
		this.mouseDelayMet = !this.options.delay;
620
		if (!this.mouseDelayMet) {
621
			this._mouseDelayTimer = setTimeout(function() {
622
				self.mouseDelayMet = true;
623
			}, this.options.delay);
624
		}
625
 
626
		if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
627
			this._mouseStarted = (this._mouseStart(event) !== false);
628
			if (!this._mouseStarted) {
629
				event.preventDefault();
630
				return true;
631
			}
632
		}
633
 
634
		// these delegates are required to keep context
635
		this._mouseMoveDelegate = function(event) {
636
			return self._mouseMove(event);
637
		};
638
		this._mouseUpDelegate = function(event) {
639
			return self._mouseUp(event);
640
		};
641
		$(document)
642
			.bind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
643
			.bind('mouseup.'+this.widgetName, this._mouseUpDelegate);
644
 
645
		// preventDefault() is used to prevent the selection of text here -
646
		// however, in Safari, this causes select boxes not to be selectable
647
		// anymore, so this fix is needed
648
		($.browser.safari || event.preventDefault());
649
 
650
		event.originalEvent.mouseHandled = true;
651
		return true;
652
	},
653
 
654
	_mouseMove: function(event) {
655
		// IE mouseup check - mouseup happened when mouse was out of window
656
		if ($.browser.msie && !event.button) {
657
			return this._mouseUp(event);
658
		}
659
 
660
		if (this._mouseStarted) {
661
			this._mouseDrag(event);
662
			return event.preventDefault();
663
		}
664
 
665
		if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
666
			this._mouseStarted =
667
				(this._mouseStart(this._mouseDownEvent, event) !== false);
668
			(this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
669
		}
670
 
671
		return !this._mouseStarted;
672
	},
673
 
674
	_mouseUp: function(event) {
675
		$(document)
676
			.unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
677
			.unbind('mouseup.'+this.widgetName, this._mouseUpDelegate);
678
 
679
		if (this._mouseStarted) {
680
			this._mouseStarted = false;
681
			this._preventClickEvent = (event.target == this._mouseDownEvent.target);
682
			this._mouseStop(event);
683
		}
684
 
685
		return false;
686
	},
687
 
688
	_mouseDistanceMet: function(event) {
689
		return (Math.max(
690
				Math.abs(this._mouseDownEvent.pageX - event.pageX),
691
				Math.abs(this._mouseDownEvent.pageY - event.pageY)
692
			) >= this.options.distance
693
		);
694
	},
695
 
696
	_mouseDelayMet: function(event) {
697
		return this.mouseDelayMet;
698
	},
699
 
700
	// These are placeholder methods, to be overriden by extending plugin
701
	_mouseStart: function(event) {},
702
	_mouseDrag: function(event) {},
703
	_mouseStop: function(event) {},
704
	_mouseCapture: function(event) { return true; }
705
});
706
 
707
})(jQuery);
708
/*
709
 * jQuery UI Position 1.8.5
710
 *
711
 * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
712
 * Dual licensed under the MIT or GPL Version 2 licenses.
713
 * http://jquery.org/license
714
 *
715
 * http://docs.jquery.com/UI/Position
716
 */
717
(function( $, undefined ) {
718
 
719
$.ui = $.ui || {};
720
 
721
var horizontalPositions = /left|center|right/,
722
	verticalPositions = /top|center|bottom/,
723
	center = "center",
724
	_position = $.fn.position,
725
	_offset = $.fn.offset;
726
 
727
$.fn.position = function( options ) {
728
	if ( !options || !options.of ) {
729
		return _position.apply( this, arguments );
730
	}
731
 
732
	// make a copy, we don't want to modify arguments
733
	options = $.extend( {}, options );
734
 
735
	var target = $( options.of ),
736
		targetElem = target[0],
737
		collision = ( options.collision || "flip" ).split( " " ),
738
		offset = options.offset ? options.offset.split( " " ) : [ 0, 0 ],
739
		targetWidth,
740
		targetHeight,
741
		basePosition;
742
 
743
	if ( targetElem.nodeType === 9 ) {
744
		targetWidth = target.width();
745
		targetHeight = target.height();
746
		basePosition = { top: 0, left: 0 };
747
	} else if ( targetElem.scrollTo && targetElem.document ) {
748
		targetWidth = target.width();
749
		targetHeight = target.height();
750
		basePosition = { top: target.scrollTop(), left: target.scrollLeft() };
751
	} else if ( targetElem.preventDefault ) {
752
		// force left top to allow flipping
753
		options.at = "left top";
754
		targetWidth = targetHeight = 0;
755
		basePosition = { top: options.of.pageY, left: options.of.pageX };
756
	} else {
757
		targetWidth = target.outerWidth();
758
		targetHeight = target.outerHeight();
759
		basePosition = target.offset();
760
	}
761
 
762
	// force my and at to have valid horizontal and veritcal positions
763
	// if a value is missing or invalid, it will be converted to center
764
	$.each( [ "my", "at" ], function() {
765
		var pos = ( options[this] || "" ).split( " " );
766
		if ( pos.length === 1) {
767
			pos = horizontalPositions.test( pos[0] ) ?
768
				pos.concat( [center] ) :
769
				verticalPositions.test( pos[0] ) ?
770
					[ center ].concat( pos ) :
771
					[ center, center ];
772
		}
773
		pos[ 0 ] = horizontalPositions.test( pos[0] ) ? pos[ 0 ] : center;
774
		pos[ 1 ] = verticalPositions.test( pos[1] ) ? pos[ 1 ] : center;
775
		options[ this ] = pos;
776
	});
777
 
778
	// normalize collision option
779
	if ( collision.length === 1 ) {
780
		collision[ 1 ] = collision[ 0 ];
781
	}
782
 
783
	// normalize offset option
784
	offset[ 0 ] = parseInt( offset[0], 10 ) || 0;
785
	if ( offset.length === 1 ) {
786
		offset[ 1 ] = offset[ 0 ];
787
	}
788
	offset[ 1 ] = parseInt( offset[1], 10 ) || 0;
789
 
790
	if ( options.at[0] === "right" ) {
791
		basePosition.left += targetWidth;
792
	} else if (options.at[0] === center ) {
793
		basePosition.left += targetWidth / 2;
794
	}
795
 
796
	if ( options.at[1] === "bottom" ) {
797
		basePosition.top += targetHeight;
798
	} else if ( options.at[1] === center ) {
799
		basePosition.top += targetHeight / 2;
800
	}
801
 
802
	basePosition.left += offset[ 0 ];
803
	basePosition.top += offset[ 1 ];
804
 
805
	return this.each(function() {
806
		var elem = $( this ),
807
			elemWidth = elem.outerWidth(),
808
			elemHeight = elem.outerHeight(),
809
			marginLeft = parseInt( $.curCSS( this, "marginLeft", true ) ) || 0,
810
			marginTop = parseInt( $.curCSS( this, "marginTop", true ) ) || 0,
811
			collisionWidth = elemWidth + marginLeft +
812
				parseInt( $.curCSS( this, "marginRight", true ) ) || 0,
813
			collisionHeight = elemHeight + marginTop +
814
				parseInt( $.curCSS( this, "marginBottom", true ) ) || 0,
815
			position = $.extend( {}, basePosition ),
816
			collisionPosition;
817
 
818
		if ( options.my[0] === "right" ) {
819
			position.left -= elemWidth;
820
		} else if ( options.my[0] === center ) {
821
			position.left -= elemWidth / 2;
822
		}
823
 
824
		if ( options.my[1] === "bottom" ) {
825
			position.top -= elemHeight;
826
		} else if ( options.my[1] === center ) {
827
			position.top -= elemHeight / 2;
828
		}
829
 
830
		// prevent fractions (see #5280)
831
		position.left = parseInt( position.left );
832
		position.top = parseInt( position.top );
833
 
834
		collisionPosition = {
835
			left: position.left - marginLeft,
836
			top: position.top - marginTop
837
		};
838
 
839
		$.each( [ "left", "top" ], function( i, dir ) {
840
			if ( $.ui.position[ collision[i] ] ) {
841
				$.ui.position[ collision[i] ][ dir ]( position, {
842
					targetWidth: targetWidth,
843
					targetHeight: targetHeight,
844
					elemWidth: elemWidth,
845
					elemHeight: elemHeight,
846
					collisionPosition: collisionPosition,
847
					collisionWidth: collisionWidth,
848
					collisionHeight: collisionHeight,
849
					offset: offset,
850
					my: options.my,
851
					at: options.at
852
				});
853
			}
854
		});
855
 
856
		if ( $.fn.bgiframe ) {
857
			elem.bgiframe();
858
		}
859
		elem.offset( $.extend( position, { using: options.using } ) );
860
	});
861
};
862
 
863
$.ui.position = {
864
	fit: {
865
		left: function( position, data ) {
866
			var win = $( window ),
867
				over = data.collisionPosition.left + data.collisionWidth - win.width() - win.scrollLeft();
868
			position.left = over > 0 ? position.left - over : Math.max( position.left - data.collisionPosition.left, position.left );
869
		},
870
		top: function( position, data ) {
871
			var win = $( window ),
872
				over = data.collisionPosition.top + data.collisionHeight - win.height() - win.scrollTop();
873
			position.top = over > 0 ? position.top - over : Math.max( position.top - data.collisionPosition.top, position.top );
874
		}
875
	},
876
 
877
	flip: {
878
		left: function( position, data ) {
879
			if ( data.at[0] === center ) {
880
				return;
881
			}
882
			var win = $( window ),
883
				over = data.collisionPosition.left + data.collisionWidth - win.width() - win.scrollLeft(),
884
				myOffset = data.my[ 0 ] === "left" ?
885
					-data.elemWidth :
886
					data.my[ 0 ] === "right" ?
887
						data.elemWidth :
888
						0,
889
				atOffset = data.at[ 0 ] === "left" ?
890
					data.targetWidth :
891
					-data.targetWidth,
892
				offset = -2 * data.offset[ 0 ];
893
			position.left += data.collisionPosition.left < 0 ?
894
				myOffset + atOffset + offset :
895
				over > 0 ?
896
					myOffset + atOffset + offset :
897
					0;
898
		},
899
		top: function( position, data ) {
900
			if ( data.at[1] === center ) {
901
				return;
902
			}
903
			var win = $( window ),
904
				over = data.collisionPosition.top + data.collisionHeight - win.height() - win.scrollTop(),
905
				myOffset = data.my[ 1 ] === "top" ?
906
					-data.elemHeight :
907
					data.my[ 1 ] === "bottom" ?
908
						data.elemHeight :
909
						0,
910
				atOffset = data.at[ 1 ] === "top" ?
911
					data.targetHeight :
912
					-data.targetHeight,
913
				offset = -2 * data.offset[ 1 ];
914
			position.top += data.collisionPosition.top < 0 ?
915
				myOffset + atOffset + offset :
916
				over > 0 ?
917
					myOffset + atOffset + offset :
918
					0;
919
		}
920
	}
921
};
922
 
923
// offset setter from jQuery 1.4
924
if ( !$.offset.setOffset ) {
925
	$.offset.setOffset = function( elem, options ) {
926
		// set position first, in-case top/left are set even on static elem
927
		if ( /static/.test( $.curCSS( elem, "position" ) ) ) {
928
			elem.style.position = "relative";
929
		}
930
		var curElem   = $( elem ),
931
			curOffset = curElem.offset(),
932
			curTop    = parseInt( $.curCSS( elem, "top",  true ), 10 ) || 0,
933
			curLeft   = parseInt( $.curCSS( elem, "left", true ), 10)  || 0,
934
			props     = {
935
				top:  (options.top  - curOffset.top)  + curTop,
936
				left: (options.left - curOffset.left) + curLeft
937
			};
938
 
939
		if ( 'using' in options ) {
940
			options.using.call( elem, props );
941
		} else {
942
			curElem.css( props );
943
		}
944
	};
945
 
946
	$.fn.offset = function( options ) {
947
		var elem = this[ 0 ];
948
		if ( !elem || !elem.ownerDocument ) { return null; }
949
		if ( options ) {
950
			return this.each(function() {
951
				$.offset.setOffset( this, options );
952
			});
953
		}
954
		return _offset.call( this );
955
	};
956
}
957
 
958
}( jQuery ));
959
/*
960
 * jQuery UI Draggable 1.8.5
961
 *
962
 * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
963
 * Dual licensed under the MIT or GPL Version 2 licenses.
964
 * http://jquery.org/license
965
 *
966
 * http://docs.jquery.com/UI/Draggables
967
 *
968
 * Depends:
969
 *	jquery.ui.core.js
970
 *	jquery.ui.mouse.js
971
 *	jquery.ui.widget.js
972
 */
973
(function( $, undefined ) {
974
 
975
$.widget("ui.draggable", $.ui.mouse, {
976
	widgetEventPrefix: "drag",
977
	options: {
978
		addClasses: true,
979
		appendTo: "parent",
980
		axis: false,
981
		connectToSortable: false,
982
		containment: false,
983
		cursor: "auto",
984
		cursorAt: false,
985
		grid: false,
986
		handle: false,
987
		helper: "original",
988
		iframeFix: false,
989
		opacity: false,
990
		refreshPositions: false,
991
		revert: false,
992
		revertDuration: 500,
993
		scope: "default",
994
		scroll: true,
995
		scrollSensitivity: 20,
996
		scrollSpeed: 20,
997
		snap: false,
998
		snapMode: "both",
999
		snapTolerance: 20,
1000
		stack: false,
1001
		zIndex: false
1002
	},
1003
	_create: function() {
1004
 
1005
		if (this.options.helper == 'original' && !(/^(?:r|a|f)/).test(this.element.css("position")))
1006
			this.element[0].style.position = 'relative';
1007
 
1008
		(this.options.addClasses && this.element.addClass("ui-draggable"));
1009
		(this.options.disabled && this.element.addClass("ui-draggable-disabled"));
1010
 
1011
		this._mouseInit();
1012
 
1013
	},
1014
 
1015
	destroy: function() {
1016
		if(!this.element.data('draggable')) return;
1017
		this.element
1018
			.removeData("draggable")
1019
			.unbind(".draggable")
1020
			.removeClass("ui-draggable"
1021
				+ " ui-draggable-dragging"
1022
				+ " ui-draggable-disabled");
1023
		this._mouseDestroy();
1024
 
1025
		return this;
1026
	},
1027
 
1028
	_mouseCapture: function(event) {
1029
 
1030
		var o = this.options;
1031
 
1032
		// among others, prevent a drag on a resizable-handle
1033
		if (this.helper || o.disabled || $(event.target).is('.ui-resizable-handle'))
1034
			return false;
1035
 
1036
		//Quit if we're not on a valid handle
1037
		this.handle = this._getHandle(event);
1038
		if (!this.handle)
1039
			return false;
1040
 
1041
		return true;
1042
 
1043
	},
1044
 
1045
	_mouseStart: function(event) {
1046
 
1047
		var o = this.options;
1048
 
1049
		//Create and append the visible helper
1050
		this.helper = this._createHelper(event);
1051
 
1052
		//Cache the helper size
1053
		this._cacheHelperProportions();
1054
 
1055
		//If ddmanager is used for droppables, set the global draggable
1056
		if($.ui.ddmanager)
1057
			$.ui.ddmanager.current = this;
1058
 
1059
		/*
1060
		 * - Position generation -
1061
		 * This block generates everything position related - it's the core of draggables.
1062
		 */
1063
 
1064
		//Cache the margins of the original element
1065
		this._cacheMargins();
1066
 
1067
		//Store the helper's css position
1068
		this.cssPosition = this.helper.css("position");
1069
		this.scrollParent = this.helper.scrollParent();
1070
 
1071
		//The element's absolute position on the page minus margins
1072
		this.offset = this.positionAbs = this.element.offset();
1073
		this.offset = {
1074
			top: this.offset.top - this.margins.top,
1075
			left: this.offset.left - this.margins.left
1076
		};
1077
 
1078
		$.extend(this.offset, {
1079
			click: { //Where the click happened, relative to the element
1080
				left: event.pageX - this.offset.left,
1081
				top: event.pageY - this.offset.top
1082
			},
1083
			parent: this._getParentOffset(),
1084
			relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
1085
		});
1086
 
1087
		//Generate the original position
1088
		this.originalPosition = this.position = this._generatePosition(event);
1089
		this.originalPageX = event.pageX;
1090
		this.originalPageY = event.pageY;
1091
 
1092
		//Adjust the mouse offset relative to the helper if 'cursorAt' is supplied
1093
		(o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
1094
 
1095
		//Set a containment if given in the options
1096
		if(o.containment)
1097
			this._setContainment();
1098
 
1099
		//Trigger event + callbacks
1100
		if(this._trigger("start", event) === false) {
1101
			this._clear();
1102
			return false;
1103
		}
1104
 
1105
		//Recache the helper size
1106
		this._cacheHelperProportions();
1107
 
1108
		//Prepare the droppable offsets
1109
		if ($.ui.ddmanager && !o.dropBehaviour)
1110
			$.ui.ddmanager.prepareOffsets(this, event);
1111
 
1112
		this.helper.addClass("ui-draggable-dragging");
1113
		this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
1114
		return true;
1115
	},
1116
 
1117
	_mouseDrag: function(event, noPropagation) {
1118
 
1119
		//Compute the helpers position
1120
		this.position = this._generatePosition(event);
1121
		this.positionAbs = this._convertPositionTo("absolute");
1122
 
1123
		//Call plugins and callbacks and use the resulting position if something is returned
1124
		if (!noPropagation) {
1125
			var ui = this._uiHash();
1126
			if(this._trigger('drag', event, ui) === false) {
1127
				this._mouseUp({});
1128
				return false;
1129
			}
1130
			this.position = ui.position;
1131
		}
1132
 
1133
		if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px';
1134
		if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px';
1135
		if($.ui.ddmanager) $.ui.ddmanager.drag(this, event);
1136
 
1137
		return false;
1138
	},
1139
 
1140
	_mouseStop: function(event) {
1141
 
1142
		//If we are using droppables, inform the manager about the drop
1143
		var dropped = false;
1144
		if ($.ui.ddmanager && !this.options.dropBehaviour)
1145
			dropped = $.ui.ddmanager.drop(this, event);
1146
 
1147
		//if a drop comes from outside (a sortable)
1148
		if(this.dropped) {
1149
			dropped = this.dropped;
1150
			this.dropped = false;
1151
		}
1152
 
1153
		//if the original element is removed, don't bother to continue
1154
		if(!this.element[0] || !this.element[0].parentNode)
1155
			return false;
1156
 
1157
		if((this.options.revert == "invalid" && !dropped) || (this.options.revert == "valid" && dropped) || this.options.revert === true || ($.isFunction(this.options.revert) && this.options.revert.call(this.element, dropped))) {
1158
			var self = this;
1159
			$(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() {
1160
				if(self._trigger("stop", event) !== false) {
1161
					self._clear();
1162
				}
1163
			});
1164
		} else {
1165
			if(this._trigger("stop", event) !== false) {
1166
				this._clear();
1167
			}
1168
		}
1169
 
1170
		return false;
1171
	},
1172
 
1173
	cancel: function() {
1174
 
1175
		if(this.helper.is(".ui-draggable-dragging")) {
1176
			this._mouseUp({});
1177
		} else {
1178
			this._clear();
1179
		}
1180
 
1181
		return this;
1182
 
1183
	},
1184
 
1185
	_getHandle: function(event) {
1186
 
1187
		var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false;
1188
		$(this.options.handle, this.element)
1189
			.find("*")
1190
			.andSelf()
1191
			.each(function() {
1192
				if(this == event.target) handle = true;
1193
			});
1194
 
1195
		return handle;
1196
 
1197
	},
1198
 
1199
	_createHelper: function(event) {
1200
 
1201
		var o = this.options;
1202
		var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event])) : (o.helper == 'clone' ? this.element.clone() : this.element);
1203
 
1204
		if(!helper.parents('body').length)
1205
			helper.appendTo((o.appendTo == 'parent' ? this.element[0].parentNode : o.appendTo));
1206
 
1207
		if(helper[0] != this.element[0] && !(/(fixed|absolute)/).test(helper.css("position")))
1208
			helper.css("position", "absolute");
1209
 
1210
		return helper;
1211
 
1212
	},
1213
 
1214
	_adjustOffsetFromHelper: function(obj) {
1215
		if (typeof obj == 'string') {
1216
			obj = obj.split(' ');
1217
		}
1218
		if ($.isArray(obj)) {
1219
			obj = {left: +obj[0], top: +obj[1] || 0};
1220
		}
1221
		if ('left' in obj) {
1222
			this.offset.click.left = obj.left + this.margins.left;
1223
		}
1224
		if ('right' in obj) {
1225
			this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
1226
		}
1227
		if ('top' in obj) {
1228
			this.offset.click.top = obj.top + this.margins.top;
1229
		}
1230
		if ('bottom' in obj) {
1231
			this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
1232
		}
1233
	},
1234
 
1235
	_getParentOffset: function() {
1236
 
1237
		//Get the offsetParent and cache its position
1238
		this.offsetParent = this.helper.offsetParent();
1239
		var po = this.offsetParent.offset();
1240
 
1241
		// This is a special case where we need to modify a offset calculated on start, since the following happened:
1242
		// 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
1243
		// 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
1244
		//    the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
1245
		if(this.cssPosition == 'absolute' && this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) {
1246
			po.left += this.scrollParent.scrollLeft();
1247
			po.top += this.scrollParent.scrollTop();
1248
		}
1249
 
1250
		if((this.offsetParent[0] == document.body) //This needs to be actually done for all browsers, since pageX/pageY includes this information
1251
		|| (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.browser.msie)) //Ugly IE fix
1252
			po = { top: 0, left: 0 };
1253
 
1254
		return {
1255
			top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
1256
			left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
1257
		};
1258
 
1259
	},
1260
 
1261
	_getRelativeOffset: function() {
1262
 
1263
		if(this.cssPosition == "relative") {
1264
			var p = this.element.position();
1265
			return {
1266
				top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
1267
				left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
1268
			};
1269
		} else {
1270
			return { top: 0, left: 0 };
1271
		}
1272
 
1273
	},
1274
 
1275
	_cacheMargins: function() {
1276
		this.margins = {
1277
			left: (parseInt(this.element.css("marginLeft"),10) || 0),
1278
			top: (parseInt(this.element.css("marginTop"),10) || 0)
1279
		};
1280
	},
1281
 
1282
	_cacheHelperProportions: function() {
1283
		this.helperProportions = {
1284
			width: this.helper.outerWidth(),
1285
			height: this.helper.outerHeight()
1286
		};
1287
	},
1288
 
1289
	_setContainment: function() {
1290
 
1291
		var o = this.options;
1292
		if(o.containment == 'parent') o.containment = this.helper[0].parentNode;
1293
		if(o.containment == 'document' || o.containment == 'window') this.containment = [
1294
 
1295
 
1296
			$(o.containment == 'document' ? document : window).width() - this.helperProportions.width - this.margins.left,
1297
			($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
1298
		];
1299
 
1300
		if(!(/^(document|window|parent)$/).test(o.containment) && o.containment.constructor != Array) {
1301
			var ce = $(o.containment)[0]; if(!ce) return;
1302
			var co = $(o.containment).offset();
1303
			var over = ($(ce).css("overflow") != 'hidden');
1304
 
1305
			this.containment = [
1306
				co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
1307
				co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
1308
				co.left+(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left,
1309
				co.top+(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top
1310
			];
1311
		} else if(o.containment.constructor == Array) {
1312
			this.containment = o.containment;
1313
		}
1314
 
1315
	},
1316
 
1317
	_convertPositionTo: function(d, pos) {
1318
 
1319
		if(!pos) pos = this.position;
1320
		var mod = d == "absolute" ? 1 : -1;
1321
		var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
1322
 
1323
		return {
1324
			top: (
1325
				pos.top																	// The absolute mouse position
1326
				+ this.offset.relative.top * mod										// Only for relative positioned nodes: Relative offset from element to offset parent
1327
				+ this.offset.parent.top * mod											// The offsetParent's offset without borders (offset + border)
1328
				- ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
1329
			),
1330
			left: (
1331
				pos.left																// The absolute mouse position
1332
				+ this.offset.relative.left * mod										// Only for relative positioned nodes: Relative offset from element to offset parent
1333
				+ this.offset.parent.left * mod											// The offsetParent's offset without borders (offset + border)
1334
				- ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
1335
			)
1336
		};
1337
 
1338
	},
1339
 
1340
	_generatePosition: function(event) {
1341
 
1342
		var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
1343
		var pageX = event.pageX;
1344
		var pageY = event.pageY;
1345
 
1346
		/*
1347
		 * - Position constraining -
1348
		 * Constrain the position to a mix of grid, containment.
1349
		 */
1350
 
1351
		if(this.originalPosition) { //If we are not dragging yet, we won't check for options
1352
 
1353
			if(this.containment) {
1354
				if(event.pageX - this.offset.click.left < this.containment[0]) pageX = this.containment[0] + this.offset.click.left;
1355
				if(event.pageY - this.offset.click.top < this.containment[1]) pageY = this.containment[1] + this.offset.click.top;
1356
				if(event.pageX - this.offset.click.left > this.containment[2]) pageX = this.containment[2] + this.offset.click.left;
1357
				if(event.pageY - this.offset.click.top > this.containment[3]) pageY = this.containment[3] + this.offset.click.top;
1358
			}
1359
 
1360
			if(o.grid) {
1361
				var top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
1362
				pageY = this.containment ? (!(top - this.offset.click.top < this.containment[1] || top - this.offset.click.top > this.containment[3]) ? top : (!(top - this.offset.click.top < this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
1363
 
1364
				var left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
1365
				pageX = this.containment ? (!(left - this.offset.click.left < this.containment[0] || left - this.offset.click.left > this.containment[2]) ? left : (!(left - this.offset.click.left < this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
1366
			}
1367
 
1368
		}
1369
 
1370
		return {
1371
			top: (
1372
				pageY																// The absolute mouse position
1373
				- this.offset.click.top													// Click offset (relative to the element)
1374
				- this.offset.relative.top												// Only for relative positioned nodes: Relative offset from element to offset parent
1375
				- this.offset.parent.top												// The offsetParent's offset without borders (offset + border)
1376
				+ ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
1377
			),
1378
			left: (
1379
				pageX																// The absolute mouse position
1380
				- this.offset.click.left												// Click offset (relative to the element)
1381
				- this.offset.relative.left												// Only for relative positioned nodes: Relative offset from element to offset parent
1382
				- this.offset.parent.left												// The offsetParent's offset without borders (offset + border)
1383
				+ ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
1384
			)
1385
		};
1386
 
1387
	},
1388
 
1389
	_clear: function() {
1390
		this.helper.removeClass("ui-draggable-dragging");
1391
		if(this.helper[0] != this.element[0] && !this.cancelHelperRemoval) this.helper.remove();
1392
		//if($.ui.ddmanager) $.ui.ddmanager.current = null;
1393
		this.helper = null;
1394
		this.cancelHelperRemoval = false;
1395
	},
1396
 
1397
	// From now on bulk stuff - mainly helpers
1398
 
1399
	_trigger: function(type, event, ui) {
1400
		ui = ui || this._uiHash();
1401
		$.ui.plugin.call(this, type, [event, ui]);
1402
		if(type == "drag") this.positionAbs = this._convertPositionTo("absolute"); //The absolute position has to be recalculated after plugins
1403
		return $.Widget.prototype._trigger.call(this, type, event, ui);
1404
	},
1405
 
1406
	plugins: {},
1407
 
1408
	_uiHash: function(event) {
1409
		return {
1410
			helper: this.helper,
1411
			position: this.position,
1412
			originalPosition: this.originalPosition,
1413
			offset: this.positionAbs
1414
		};
1415
	}
1416
 
1417
});
1418
 
1419
$.extend($.ui.draggable, {
1420
	version: "1.8.5"
1421
});
1422
 
1423
$.ui.plugin.add("draggable", "connectToSortable", {
1424
	start: function(event, ui) {
1425
 
1426
		var inst = $(this).data("draggable"), o = inst.options,
1427
			uiSortable = $.extend({}, ui, { item: inst.element });
1428
		inst.sortables = [];
1429
		$(o.connectToSortable).each(function() {
1430
			var sortable = $.data(this, 'sortable');
1431
			if (sortable && !sortable.options.disabled) {
1432
				inst.sortables.push({
1433
					instance: sortable,
1434
					shouldRevert: sortable.options.revert
1435
				});
1436
				sortable._refreshItems();	//Do a one-time refresh at start to refresh the containerCache
1437
				sortable._trigger("activate", event, uiSortable);
1438
			}
1439
		});
1440
 
1441
	},
1442
	stop: function(event, ui) {
1443
 
1444
		//If we are still over the sortable, we fake the stop event of the sortable, but also remove helper
1445
		var inst = $(this).data("draggable"),
1446
			uiSortable = $.extend({}, ui, { item: inst.element });
1447
 
1448
		$.each(inst.sortables, function() {
1449
			if(this.instance.isOver) {
1450
 
1451
				this.instance.isOver = 0;
1452
 
1453
				inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance
1454
				this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work)
1455
 
1456
				//The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: 'valid/invalid'
1457
				if(this.shouldRevert) this.instance.options.revert = true;
1458
 
1459
				//Trigger the stop of the sortable
1460
				this.instance._mouseStop(event);
1461
 
1462
				this.instance.options.helper = this.instance.options._helper;
1463
 
1464
				//If the helper has been the original item, restore properties in the sortable
1465
				if(inst.options.helper == 'original')
1466
					this.instance.currentItem.css({ top: 'auto', left: 'auto' });
1467
 
1468
			} else {
1469
				this.instance.cancelHelperRemoval = false; //Remove the helper in the sortable instance
1470
				this.instance._trigger("deactivate", event, uiSortable);
1471
			}
1472
 
1473
		});
1474
 
1475
	},
1476
	drag: function(event, ui) {
1477
 
1478
		var inst = $(this).data("draggable"), self = this;
1479
 
1480
		var checkPos = function(o) {
1481
			var dyClick = this.offset.click.top, dxClick = this.offset.click.left;
1482
			var helperTop = this.positionAbs.top, helperLeft = this.positionAbs.left;
1483
			var itemHeight = o.height, itemWidth = o.width;
1484
			var itemTop = o.top, itemLeft = o.left;
1485
 
1486
			return $.ui.isOver(helperTop + dyClick, helperLeft + dxClick, itemTop, itemLeft, itemHeight, itemWidth);
1487
		};
1488
 
1489
		$.each(inst.sortables, function(i) {
1490
 
1491
			//Copy over some variables to allow calling the sortable's native _intersectsWith
1492
			this.instance.positionAbs = inst.positionAbs;
1493
			this.instance.helperProportions = inst.helperProportions;
1494
			this.instance.offset.click = inst.offset.click;
1495
 
1496
			if(this.instance._intersectsWith(this.instance.containerCache)) {
1497
 
1498
				//If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once
1499
				if(!this.instance.isOver) {
1500
 
1501
					this.instance.isOver = 1;
1502
					//Now we fake the start of dragging for the sortable instance,
1503
					//by cloning the list group item, appending it to the sortable and using it as inst.currentItem
1504
					//We can then fire the start event of the sortable with our passed browser event, and our own helper (so it doesn't create a new one)
1505
					this.instance.currentItem = $(self).clone().appendTo(this.instance.element).data("sortable-item", true);
1506
					this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it
1507
					this.instance.options.helper = function() { return ui.helper[0]; };
1508
 
1509
					event.target = this.instance.currentItem[0];
1510
					this.instance._mouseCapture(event, true);
1511
					this.instance._mouseStart(event, true, true);
1512
 
1513
					//Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes
1514
					this.instance.offset.click.top = inst.offset.click.top;
1515
					this.instance.offset.click.left = inst.offset.click.left;
1516
					this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left;
1517
					this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top;
1518
 
1519
					inst._trigger("toSortable", event);
1520
					inst.dropped = this.instance.element; //draggable revert needs that
1521
					//hack so receive/update callbacks work (mostly)
1522
					inst.currentItem = inst.element;
1523
					this.instance.fromOutside = inst;
1524
 
1525
				}
1526
 
1527
				//Provided we did all the previous steps, we can fire the drag event of the sortable on every draggable drag, when it intersects with the sortable
1528
				if(this.instance.currentItem) this.instance._mouseDrag(event);
1529
 
1530
			} else {
1531
 
1532
				//If it doesn't intersect with the sortable, and it intersected before,
1533
				//we fake the drag stop of the sortable, but make sure it doesn't remove the helper by using cancelHelperRemoval
1534
				if(this.instance.isOver) {
1535
 
1536
					this.instance.isOver = 0;
1537
					this.instance.cancelHelperRemoval = true;
1538
 
1539
					//Prevent reverting on this forced stop
1540
					this.instance.options.revert = false;
1541
 
1542
					// The out event needs to be triggered independently
1543
					this.instance._trigger('out', event, this.instance._uiHash(this.instance));
1544
 
1545
					this.instance._mouseStop(event, true);
1546
					this.instance.options.helper = this.instance.options._helper;
1547
 
1548
					//Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size
1549
					this.instance.currentItem.remove();
1550
					if(this.instance.placeholder) this.instance.placeholder.remove();
1551
 
1552
					inst._trigger("fromSortable", event);
1553
					inst.dropped = false; //draggable revert needs that
1554
				}
1555
 
1556
			};
1557
 
1558
		});
1559
 
1560
	}
1561
});
1562
 
1563
$.ui.plugin.add("draggable", "cursor", {
1564
	start: function(event, ui) {
1565
		var t = $('body'), o = $(this).data('draggable').options;
1566
		if (t.css("cursor")) o._cursor = t.css("cursor");
1567
		t.css("cursor", o.cursor);
1568
	},
1569
	stop: function(event, ui) {
1570
		var o = $(this).data('draggable').options;
1571
		if (o._cursor) $('body').css("cursor", o._cursor);
1572
	}
1573
});
1574
 
1575
$.ui.plugin.add("draggable", "iframeFix", {
1576
	start: function(event, ui) {
1577
		var o = $(this).data('draggable').options;
1578
		$(o.iframeFix === true ? "iframe" : o.iframeFix).each(function() {
1579
			$('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>')
1580
			.css({
1581
				width: this.offsetWidth+"px", height: this.offsetHeight+"px",
1582
				position: "absolute", opacity: "0.001", zIndex: 1000
1583
			})
1584
			.css($(this).offset())
1585
			.appendTo("body");
1586
		});
1587
	},
1588
	stop: function(event, ui) {
1589
		$("div.ui-draggable-iframeFix").each(function() { this.parentNode.removeChild(this); }); //Remove frame helpers
1590
	}
1591
});
1592
 
1593
$.ui.plugin.add("draggable", "opacity", {
1594
	start: function(event, ui) {
1595
		var t = $(ui.helper), o = $(this).data('draggable').options;
1596
		if(t.css("opacity")) o._opacity = t.css("opacity");
1597
		t.css('opacity', o.opacity);
1598
	},
1599
	stop: function(event, ui) {
1600
		var o = $(this).data('draggable').options;
1601
		if(o._opacity) $(ui.helper).css('opacity', o._opacity);
1602
	}
1603
});
1604
 
1605
$.ui.plugin.add("draggable", "scroll", {
1606
	start: function(event, ui) {
1607
		var i = $(this).data("draggable");
1608
		if(i.scrollParent[0] != document && i.scrollParent[0].tagName != 'HTML') i.overflowOffset = i.scrollParent.offset();
1609
	},
1610
	drag: function(event, ui) {
1611
 
1612
		var i = $(this).data("draggable"), o = i.options, scrolled = false;
1613
 
1614
		if(i.scrollParent[0] != document && i.scrollParent[0].tagName != 'HTML') {
1615
 
1616
			if(!o.axis || o.axis != 'x') {
1617
				if((i.overflowOffset.top + i.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity)
1618
					i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop + o.scrollSpeed;
1619
				else if(event.pageY - i.overflowOffset.top < o.scrollSensitivity)
1620
					i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop - o.scrollSpeed;
1621
			}
1622
 
1623
			if(!o.axis || o.axis != 'y') {
1624
				if((i.overflowOffset.left + i.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity)
1625
					i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft + o.scrollSpeed;
1626
				else if(event.pageX - i.overflowOffset.left < o.scrollSensitivity)
1627
					i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft - o.scrollSpeed;
1628
			}
1629
 
1630
		} else {
1631
 
1632
			if(!o.axis || o.axis != 'x') {
1633
				if(event.pageY - $(document).scrollTop() < o.scrollSensitivity)
1634
					scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
1635
				else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity)
1636
					scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
1637
			}
1638
 
1639
			if(!o.axis || o.axis != 'y') {
1640
				if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity)
1641
					scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
1642
				else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity)
1643
					scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
1644
			}
1645
 
1646
		}
1647
 
1648
		if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour)
1649
			$.ui.ddmanager.prepareOffsets(i, event);
1650
 
1651
	}
1652
});
1653
 
1654
$.ui.plugin.add("draggable", "snap", {
1655
	start: function(event, ui) {
1656
 
1657
		var i = $(this).data("draggable"), o = i.options;
1658
		i.snapElements = [];
1659
 
1660
		$(o.snap.constructor != String ? ( o.snap.items || ':data(draggable)' ) : o.snap).each(function() {
1661
			var $t = $(this); var $o = $t.offset();
1662
			if(this != i.element[0]) i.snapElements.push({
1663
				item: this,
1664
				width: $t.outerWidth(), height: $t.outerHeight(),
1665
				top: $o.top, left: $o.left
1666
			});
1667
		});
1668
 
1669
	},
1670
	drag: function(event, ui) {
1671
 
1672
		var inst = $(this).data("draggable"), o = inst.options;
1673
		var d = o.snapTolerance;
1674
 
1675
		var x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
1676
			y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
1677
 
1678
		for (var i = inst.snapElements.length - 1; i >= 0; i--){
1679
 
1680
			var l = inst.snapElements[i].left, r = l + inst.snapElements[i].width,
1681
				t = inst.snapElements[i].top, b = t + inst.snapElements[i].height;
1682
 
1683
			//Yes, I know, this is insane ;)
1684
			if(!((l-d < x1 && x1 < r+d && t-d < y1 && y1 < b+d) || (l-d < x1 && x1 < r+d && t-d < y2 && y2 < b+d) || (l-d < x2 && x2 < r+d && t-d < y1 && y1 < b+d) || (l-d < x2 && x2 < r+d && t-d < y2 && y2 < b+d))) {
1685
				if(inst.snapElements[i].snapping) (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
1686
				inst.snapElements[i].snapping = false;
1687
				continue;
1688
			}
1689
 
1690
			if(o.snapMode != 'inner') {
1691
				var ts = Math.abs(t - y2) <= d;
1692
				var bs = Math.abs(b - y1) <= d;
1693
				var ls = Math.abs(l - x2) <= d;
1694
				var rs = Math.abs(r - x1) <= d;
1695
				if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
1696
				if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top - inst.margins.top;
1697
				if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left - inst.margins.left;
1698
				if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left - inst.margins.left;
1699
			}
1700
 
1701
			var first = (ts || bs || ls || rs);
1702
 
1703
			if(o.snapMode != 'outer') {
1704
				var ts = Math.abs(t - y1) <= d;
1705
				var bs = Math.abs(b - y2) <= d;
1706
				var ls = Math.abs(l - x1) <= d;
1707
				var rs = Math.abs(r - x2) <= d;
1708
				if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top - inst.margins.top;
1709
				if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
1710
				if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left - inst.margins.left;
1711
				if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left - inst.margins.left;
1712
			}
1713
 
1714
			if(!inst.snapElements[i].snapping && (ts || bs || ls || rs || first))
1715
				(inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
1716
			inst.snapElements[i].snapping = (ts || bs || ls || rs || first);
1717
 
1718
		};
1719
 
1720
	}
1721
});
1722
 
1723
$.ui.plugin.add("draggable", "stack", {
1724
	start: function(event, ui) {
1725
 
1726
		var o = $(this).data("draggable").options;
1727
 
1728
		var group = $.makeArray($(o.stack)).sort(function(a,b) {
1729
			return (parseInt($(a).css("zIndex"),10) || 0) - (parseInt($(b).css("zIndex"),10) || 0);
1730
		});
1731
		if (!group.length) { return; }
1732
 
1733
		var min = parseInt(group[0].style.zIndex) || 0;
1734
		$(group).each(function(i) {
1735
			this.style.zIndex = min + i;
1736
		});
1737
 
1738
		this[0].style.zIndex = min + group.length;
1739
 
1740
	}
1741
});
1742
 
1743
$.ui.plugin.add("draggable", "zIndex", {
1744
	start: function(event, ui) {
1745
		var t = $(ui.helper), o = $(this).data("draggable").options;
1746
		if(t.css("zIndex")) o._zIndex = t.css("zIndex");
1747
		t.css('zIndex', o.zIndex);
1748
	},
1749
	stop: function(event, ui) {
1750
		var o = $(this).data("draggable").options;
1751
		if(o._zIndex) $(ui.helper).css('zIndex', o._zIndex);
1752
	}
1753
});
1754
 
1755
})(jQuery);
1756
/*
1757
 * jQuery UI Droppable 1.8.5
1758
 *
1759
 * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
1760
 * Dual licensed under the MIT or GPL Version 2 licenses.
1761
 * http://jquery.org/license
1762
 *
1763
 * http://docs.jquery.com/UI/Droppables
1764
 *
1765
 * Depends:
1766
 *	jquery.ui.core.js
1767
 *	jquery.ui.widget.js
1768
 *	jquery.ui.mouse.js
1769
 *	jquery.ui.draggable.js
1770
 */
1771
(function( $, undefined ) {
1772
 
1773
$.widget("ui.droppable", {
1774
	widgetEventPrefix: "drop",
1775
	options: {
1776
		accept: '*',
1777
		activeClass: false,
1778
		addClasses: true,
1779
		greedy: false,
1780
		hoverClass: false,
1781
		scope: 'default',
1782
		tolerance: 'intersect'
1783
	},
1784
	_create: function() {
1785
 
1786
		var o = this.options, accept = o.accept;
1787
		this.isover = 0; this.isout = 1;
1788
 
1789
		this.accept = $.isFunction(accept) ? accept : function(d) {
1790
			return d.is(accept);
1791
		};
1792
 
1793
		//Store the droppable's proportions
1794
		this.proportions = { width: this.element[0].offsetWidth, height: this.element[0].offsetHeight };
1795
 
1796
		// Add the reference and positions to the manager
1797
		$.ui.ddmanager.droppables[o.scope] = $.ui.ddmanager.droppables[o.scope] || [];
1798
		$.ui.ddmanager.droppables[o.scope].push(this);
1799
 
1800
		(o.addClasses && this.element.addClass("ui-droppable"));
1801
 
1802
	},
1803
 
1804
	destroy: function() {
1805
		var drop = $.ui.ddmanager.droppables[this.options.scope];
1806
		for ( var i = 0; i < drop.length; i++ )
1807
			if ( drop[i] == this )
1808
				drop.splice(i, 1);
1809
 
1810
		this.element
1811
			.removeClass("ui-droppable ui-droppable-disabled")
1812
			.removeData("droppable")
1813
			.unbind(".droppable");
1814
 
1815
		return this;
1816
	},
1817
 
1818
	_setOption: function(key, value) {
1819
 
1820
		if(key == 'accept') {
1821
			this.accept = $.isFunction(value) ? value : function(d) {
1822
				return d.is(value);
1823
			};
1824
		}
1825
		$.Widget.prototype._setOption.apply(this, arguments);
1826
	},
1827
 
1828
	_activate: function(event) {
1829
		var draggable = $.ui.ddmanager.current;
1830
		if(this.options.activeClass) this.element.addClass(this.options.activeClass);
1831
		(draggable && this._trigger('activate', event, this.ui(draggable)));
1832
	},
1833
 
1834
	_deactivate: function(event) {
1835
		var draggable = $.ui.ddmanager.current;
1836
		if(this.options.activeClass) this.element.removeClass(this.options.activeClass);
1837
		(draggable && this._trigger('deactivate', event, this.ui(draggable)));
1838
	},
1839
 
1840
	_over: function(event) {
1841
 
1842
		var draggable = $.ui.ddmanager.current;
1843
		if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return; // Bail if draggable and droppable are same element
1844
 
1845
		if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
1846
			if(this.options.hoverClass) this.element.addClass(this.options.hoverClass);
1847
			this._trigger('over', event, this.ui(draggable));
1848
		}
1849
 
1850
	},
1851
 
1852
	_out: function(event) {
1853
 
1854
		var draggable = $.ui.ddmanager.current;
1855
		if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return; // Bail if draggable and droppable are same element
1856
 
1857
		if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
1858
			if(this.options.hoverClass) this.element.removeClass(this.options.hoverClass);
1859
			this._trigger('out', event, this.ui(draggable));
1860
		}
1861
 
1862
	},
1863
 
1864
	_drop: function(event,custom) {
1865
 
1866
		var draggable = custom || $.ui.ddmanager.current;
1867
		if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return false; // Bail if draggable and droppable are same element
1868
 
1869
		var childrenIntersection = false;
1870
		this.element.find(":data(droppable)").not(".ui-draggable-dragging").each(function() {
1871
			var inst = $.data(this, 'droppable');
1872
			if(
1873
				inst.options.greedy
1874
				&& !inst.options.disabled
1875
				&& inst.options.scope == draggable.options.scope
1876
				&& inst.accept.call(inst.element[0], (draggable.currentItem || draggable.element))
1877
				&& $.ui.intersect(draggable, $.extend(inst, { offset: inst.element.offset() }), inst.options.tolerance)
1878
			) { childrenIntersection = true; return false; }
1879
		});
1880
		if(childrenIntersection) return false;
1881
 
1882
		if(this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
1883
			if(this.options.activeClass) this.element.removeClass(this.options.activeClass);
1884
			if(this.options.hoverClass) this.element.removeClass(this.options.hoverClass);
1885
			this._trigger('drop', event, this.ui(draggable));
1886
			return this.element;
1887
		}
1888
 
1889
		return false;
1890
 
1891
	},
1892
 
1893
	ui: function(c) {
1894
		return {
1895
			draggable: (c.currentItem || c.element),
1896
			helper: c.helper,
1897
			position: c.position,
1898
			offset: c.positionAbs
1899
		};
1900
	}
1901
 
1902
});
1903
 
1904
$.extend($.ui.droppable, {
1905
	version: "1.8.5"
1906
});
1907
 
1908
$.ui.intersect = function(draggable, droppable, toleranceMode) {
1909
 
1910
	if (!droppable.offset) return false;
1911
 
1912
	var x1 = (draggable.positionAbs || draggable.position.absolute).left, x2 = x1 + draggable.helperProportions.width,
1913
		y1 = (draggable.positionAbs || draggable.position.absolute).top, y2 = y1 + draggable.helperProportions.height;
1914
	var l = droppable.offset.left, r = l + droppable.proportions.width,
1915
		t = droppable.offset.top, b = t + droppable.proportions.height;
1916
 
1917
	switch (toleranceMode) {
1918
		case 'fit':
1919
			return (l <= x1 && x2 <= r
1920
				&& t <= y1 && y2 <= b);
1921
			break;
1922
		case 'intersect':
1923
			return (l < x1 + (draggable.helperProportions.width / 2) // Right Half
1924
				&& x2 - (draggable.helperProportions.width / 2) < r // Left Half
1925
				&& t < y1 + (draggable.helperProportions.height / 2) // Bottom Half
1926
				&& y2 - (draggable.helperProportions.height / 2) < b ); // Top Half
1927
			break;
1928
		case 'pointer':
1929
			var draggableLeft = ((draggable.positionAbs || draggable.position.absolute).left + (draggable.clickOffset || draggable.offset.click).left),
1930
				draggableTop = ((draggable.positionAbs || draggable.position.absolute).top + (draggable.clickOffset || draggable.offset.click).top),
1931
				isOver = $.ui.isOver(draggableTop, draggableLeft, t, l, droppable.proportions.height, droppable.proportions.width);
1932
			return isOver;
1933
			break;
1934
		case 'touch':
1935
			return (
1936
					(y1 >= t && y1 <= b) ||	// Top edge touching
1937
					(y2 >= t && y2 <= b) ||	// Bottom edge touching
1938
					(y1 < t && y2 > b)		// Surrounded vertically
1939
				) && (
1940
					(x1 >= l && x1 <= r) ||	// Left edge touching
1941
					(x2 >= l && x2 <= r) ||	// Right edge touching
1942
					(x1 < l && x2 > r)		// Surrounded horizontally
1943
				);
1944
			break;
1945
		default:
1946
			return false;
1947
			break;
1948
		}
1949
 
1950
};
1951
 
1952
/*
1953
	This manager tracks offsets of draggables and droppables
1954
*/
1955
$.ui.ddmanager = {
1956
	current: null,
1957
	droppables: { 'default': [] },
1958
	prepareOffsets: function(t, event) {
1959
 
1960
		var m = $.ui.ddmanager.droppables[t.options.scope] || [];
1961
		var type = event ? event.type : null; // workaround for #2317
1962
		var list = (t.currentItem || t.element).find(":data(droppable)").andSelf();
1963
 
1964
		droppablesLoop: for (var i = 0; i < m.length; i++) {
1965
 
1966
			if(m[i].options.disabled || (t && !m[i].accept.call(m[i].element[0],(t.currentItem || t.element)))) continue;	//No disabled and non-accepted
1967
			for (var j=0; j < list.length; j++) { if(list[j] == m[i].element[0]) { m[i].proportions.height = 0; continue droppablesLoop; } }; //Filter out elements in the current dragged item
1968
			m[i].visible = m[i].element.css("display") != "none"; if(!m[i].visible) continue; 									//If the element is not visible, continue
1969
 
1970
			m[i].offset = m[i].element.offset();
1971
			m[i].proportions = { width: m[i].element[0].offsetWidth, height: m[i].element[0].offsetHeight };
1972
 
1973
			if(type == "mousedown") m[i]._activate.call(m[i], event); //Activate the droppable if used directly from draggables
1974
 
1975
		}
1976
 
1977
	},
1978
	drop: function(draggable, event) {
1979
 
1980
		var dropped = false;
1981
		$.each($.ui.ddmanager.droppables[draggable.options.scope] || [], function() {
1982
 
1983
			if(!this.options) return;
1984
			if (!this.options.disabled && this.visible && $.ui.intersect(draggable, this, this.options.tolerance))
1985
				dropped = dropped || this._drop.call(this, event);
1986
 
1987
			if (!this.options.disabled && this.visible && this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
1988
				this.isout = 1; this.isover = 0;
1989
				this._deactivate.call(this, event);
1990
			}
1991
 
1992
		});
1993
		return dropped;
1994
 
1995
	},
1996
	drag: function(draggable, event) {
1997
 
1998
		//If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse.
1999
		if(draggable.options.refreshPositions) $.ui.ddmanager.prepareOffsets(draggable, event);
2000
 
2001
		//Run through all droppables and check their positions based on specific tolerance options
2002
		$.each($.ui.ddmanager.droppables[draggable.options.scope] || [], function() {
2003
 
2004
			if(this.options.disabled || this.greedyChild || !this.visible) return;
2005
			var intersects = $.ui.intersect(draggable, this, this.options.tolerance);
2006
 
2007
			var c = !intersects && this.isover == 1 ? 'isout' : (intersects && this.isover == 0 ? 'isover' : null);
2008
			if(!c) return;
2009
 
2010
			var parentInstance;
2011
			if (this.options.greedy) {
2012
				var parent = this.element.parents(':data(droppable):eq(0)');
2013
				if (parent.length) {
2014
					parentInstance = $.data(parent[0], 'droppable');
2015
					parentInstance.greedyChild = (c == 'isover' ? 1 : 0);
2016
				}
2017
			}
2018
 
2019
			// we just moved into a greedy child
2020
			if (parentInstance && c == 'isover') {
2021
				parentInstance['isover'] = 0;
2022
				parentInstance['isout'] = 1;
2023
				parentInstance._out.call(parentInstance, event);
2024
			}
2025
 
2026
			this[c] = 1; this[c == 'isout' ? 'isover' : 'isout'] = 0;
2027
			this[c == "isover" ? "_over" : "_out"].call(this, event);
2028
 
2029
			// we just moved out of a greedy child
2030
			if (parentInstance && c == 'isout') {
2031
				parentInstance['isout'] = 0;
2032
				parentInstance['isover'] = 1;
2033
				parentInstance._over.call(parentInstance, event);
2034
			}
2035
		});
2036
 
2037
	}
2038
};
2039
 
2040
})(jQuery);
2041
/*
2042
 * jQuery UI Resizable 1.8.5
2043
 *
2044
 * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
2045
 * Dual licensed under the MIT or GPL Version 2 licenses.
2046
 * http://jquery.org/license
2047
 *
2048
 * http://docs.jquery.com/UI/Resizables
2049
 *
2050
 * Depends:
2051
 *	jquery.ui.core.js
2052
 *	jquery.ui.mouse.js
2053
 *	jquery.ui.widget.js
2054
 */
2055
(function( $, undefined ) {
2056
 
2057
$.widget("ui.resizable", $.ui.mouse, {
2058
	widgetEventPrefix: "resize",
2059
	options: {
2060
		alsoResize: false,
2061
		animate: false,
2062
		animateDuration: "slow",
2063
		animateEasing: "swing",
2064
		aspectRatio: false,
2065
		autoHide: false,
2066
		containment: false,
2067
		ghost: false,
2068
		grid: false,
2069
		handles: "e,s,se",
2070
		helper: false,
2071
		maxHeight: null,
2072
		maxWidth: null,
2073
		minHeight: 10,
2074
		minWidth: 10,
2075
		zIndex: 1000
2076
	},
2077
	_create: function() {
2078
 
2079
		var self = this, o = this.options;
2080
		this.element.addClass("ui-resizable");
2081
 
2082
		$.extend(this, {
2083
			_aspectRatio: !!(o.aspectRatio),
2084
			aspectRatio: o.aspectRatio,
2085
			originalElement: this.element,
2086
			_proportionallyResizeElements: [],
2087
			_helper: o.helper || o.ghost || o.animate ? o.helper || 'ui-resizable-helper' : null
2088
		});
2089
 
2090
		//Wrap the element if it cannot hold child nodes
2091
		if(this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)) {
2092
 
2093
			//Opera fix for relative positioning
2094
			if (/relative/.test(this.element.css('position')) && $.browser.opera)
2095
				this.element.css({ position: 'relative', top: 'auto', left: 'auto' });
2096
 
2097
			//Create a wrapper element and set the wrapper to the new current internal element
2098
			this.element.wrap(
2099
				$('<div class="ui-wrapper" style="overflow: hidden;"></div>').css({
2100
					position: this.element.css('position'),
2101
					width: this.element.outerWidth(),
2102
					height: this.element.outerHeight(),
2103
					top: this.element.css('top'),
2104
					left: this.element.css('left')
2105
				})
2106
			);
2107
 
2108
			//Overwrite the original this.element
2109
			this.element = this.element.parent().data(
2110
				"resizable", this.element.data('resizable')
2111
			);
2112
 
2113
			this.elementIsWrapper = true;
2114
 
2115
			//Move margins to the wrapper
2116
			this.element.css({ marginLeft: this.originalElement.css("marginLeft"), marginTop: this.originalElement.css("marginTop"), marginRight: this.originalElement.css("marginRight"), marginBottom: this.originalElement.css("marginBottom") });
2117
			this.originalElement.css({ marginLeft: 0, marginTop: 0, marginRight: 0, marginBottom: 0});
2118
 
2119
			//Prevent Safari textarea resize
2120
			this.originalResizeStyle = this.originalElement.css('resize');
2121
			this.originalElement.css('resize', 'none');
2122
 
2123
			//Push the actual element to our proportionallyResize internal array
2124
			this._proportionallyResizeElements.push(this.originalElement.css({ position: 'static', zoom: 1, display: 'block' }));
2125
 
2126
			// avoid IE jump (hard set the margin)
2127
			this.originalElement.css({ margin: this.originalElement.css('margin') });
2128
 
2129
			// fix handlers offset
2130
			this._proportionallyResize();
2131
 
2132
		}
2133
 
2134
		this.handles = o.handles || (!$('.ui-resizable-handle', this.element).length ? "e,s,se" : { n: '.ui-resizable-n', e: '.ui-resizable-e', s: '.ui-resizable-s', w: '.ui-resizable-w', se: '.ui-resizable-se', sw: '.ui-resizable-sw', ne: '.ui-resizable-ne', nw: '.ui-resizable-nw' });
2135
		if(this.handles.constructor == String) {
2136
 
2137
			if(this.handles == 'all') this.handles = 'n,e,s,w,se,sw,ne,nw';
2138
			var n = this.handles.split(","); this.handles = {};
2139
 
2140
			for(var i = 0; i < n.length; i++) {
2141
 
2142
				var handle = $.trim(n[i]), hname = 'ui-resizable-'+handle;
2143
				var axis = $('<div class="ui-resizable-handle ' + hname + '"></div>');
2144
 
2145
				// increase zIndex of sw, se, ne, nw axis
2146
				//TODO : this modifies original option
2147
				if(/sw|se|ne|nw/.test(handle)) axis.css({ zIndex: ++o.zIndex });
2148
 
2149
				//TODO : What's going on here?
2150
				if ('se' == handle) {
2151
					axis.addClass('ui-icon ui-icon-gripsmall-diagonal-se');
2152
				};
2153
 
2154
				//Insert into internal handles object and append to element
2155
				this.handles[handle] = '.ui-resizable-'+handle;
2156
				this.element.append(axis);
2157
			}
2158
 
2159
		}
2160
 
2161
		this._renderAxis = function(target) {
2162
 
2163
			target = target || this.element;
2164
 
2165
			for(var i in this.handles) {
2166
 
2167
				if(this.handles[i].constructor == String)
2168
					this.handles[i] = $(this.handles[i], this.element).show();
2169
 
2170
				//Apply pad to wrapper element, needed to fix axis position (textarea, inputs, scrolls)
2171
				if (this.elementIsWrapper && this.originalElement[0].nodeName.match(/textarea|input|select|button/i)) {
2172
 
2173
					var axis = $(this.handles[i], this.element), padWrapper = 0;
2174
 
2175
					//Checking the correct pad and border
2176
					padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth();
2177
 
2178
					//The padding type i have to apply...
2179
					var padPos = [ 'padding',
2180
						/ne|nw|n/.test(i) ? 'Top' :
2181
						/se|sw|s/.test(i) ? 'Bottom' :
2182
						/^e$/.test(i) ? 'Right' : 'Left' ].join("");
2183
 
2184
					target.css(padPos, padWrapper);
2185
 
2186
					this._proportionallyResize();
2187
 
2188
				}
2189
 
2190
				//TODO: What's that good for? There's not anything to be executed left
2191
				if(!$(this.handles[i]).length)
2192
					continue;
2193
 
2194
			}
2195
		};
2196
 
2197
		//TODO: make renderAxis a prototype function
2198
		this._renderAxis(this.element);
2199
 
2200
		this._handles = $('.ui-resizable-handle', this.element)
2201
			.disableSelection();
2202
 
2203
		//Matching axis name
2204
		this._handles.mouseover(function() {
2205
			if (!self.resizing) {
2206
				if (this.className)
2207
					var axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);
2208
				//Axis, default = se
2209
				self.axis = axis && axis[1] ? axis[1] : 'se';
2210
			}
2211
		});
2212
 
2213
		//If we want to auto hide the elements
2214
		if (o.autoHide) {
2215
			this._handles.hide();
2216
			$(this.element)
2217
				.addClass("ui-resizable-autohide")
2218
				.hover(function() {
2219
					$(this).removeClass("ui-resizable-autohide");
2220
					self._handles.show();
2221
				},
2222
				function(){
2223
					if (!self.resizing) {
2224
						$(this).addClass("ui-resizable-autohide");
2225
						self._handles.hide();
2226
					}
2227
				});
2228
		}
2229
 
2230
		//Initialize the mouse interaction
2231
		this._mouseInit();
2232
 
2233
	},
2234
 
2235
	destroy: function() {
2236
 
2237
		this._mouseDestroy();
2238
 
2239
		var _destroy = function(exp) {
2240
			$(exp).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing")
2241
				.removeData("resizable").unbind(".resizable").find('.ui-resizable-handle').remove();
2242
		};
2243
 
2244
		//TODO: Unwrap at same DOM position
2245
		if (this.elementIsWrapper) {
2246
			_destroy(this.element);
2247
			var wrapper = this.element;
2248
			wrapper.after(
2249
				this.originalElement.css({
2250
					position: wrapper.css('position'),
2251
					width: wrapper.outerWidth(),
2252
					height: wrapper.outerHeight(),
2253
					top: wrapper.css('top'),
2254
					left: wrapper.css('left')
2255
				})
2256
			).remove();
2257
		}
2258
 
2259
		this.originalElement.css('resize', this.originalResizeStyle);
2260
		_destroy(this.originalElement);
2261
 
2262
		return this;
2263
	},
2264
 
2265
	_mouseCapture: function(event) {
2266
		var handle = false;
2267
		for (var i in this.handles) {
2268
			if ($(this.handles[i])[0] == event.target) {
2269
				handle = true;
2270
			}
2271
		}
2272
 
2273
		return !this.options.disabled && handle;
2274
	},
2275
 
2276
	_mouseStart: function(event) {
2277
 
2278
		var o = this.options, iniPos = this.element.position(), el = this.element;
2279
 
2280
		this.resizing = true;
2281
		this.documentScroll = { top: $(document).scrollTop(), left: $(document).scrollLeft() };
2282
 
2283
		// bugfix for http://dev.jquery.com/ticket/1749
2284
		if (el.is('.ui-draggable') || (/absolute/).test(el.css('position'))) {
2285
			el.css({ position: 'absolute', top: iniPos.top, left: iniPos.left });
2286
		}
2287
 
2288
		//Opera fixing relative position
2289
		if ($.browser.opera && (/relative/).test(el.css('position')))
2290
			el.css({ position: 'relative', top: 'auto', left: 'auto' });
2291
 
2292
		this._renderProxy();
2293
 
2294
		var curleft = num(this.helper.css('left')), curtop = num(this.helper.css('top'));
2295
 
2296
		if (o.containment) {
2297
			curleft += $(o.containment).scrollLeft() || 0;
2298
			curtop += $(o.containment).scrollTop() || 0;
2299
		}
2300
 
2301
		//Store needed variables
2302
		this.offset = this.helper.offset();
2303
		this.position = { left: curleft, top: curtop };
2304
		this.size = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
2305
		this.originalSize = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
2306
		this.originalPosition = { left: curleft, top: curtop };
2307
		this.sizeDiff = { width: el.outerWidth() - el.width(), height: el.outerHeight() - el.height() };
2308
		this.originalMousePosition = { left: event.pageX, top: event.pageY };
2309
 
2310
		//Aspect Ratio
2311
		this.aspectRatio = (typeof o.aspectRatio == 'number') ? o.aspectRatio : ((this.originalSize.width / this.originalSize.height) || 1);
2312
 
2313
	    var cursor = $('.ui-resizable-' + this.axis).css('cursor');
2314
	    $('body').css('cursor', cursor == 'auto' ? this.axis + '-resize' : cursor);
2315
 
2316
		el.addClass("ui-resizable-resizing");
2317
		this._propagate("start", event);
2318
		return true;
2319
	},
2320
 
2321
	_mouseDrag: function(event) {
2322
 
2323
		//Increase performance, avoid regex
2324
		var el = this.helper, o = this.options, props = {},
2325
			self = this, smp = this.originalMousePosition, a = this.axis;
2326
 
2327
		var dx = (event.pageX-smp.left)||0, dy = (event.pageY-smp.top)||0;
2328
		var trigger = this._change[a];
2329
		if (!trigger) return false;
2330
 
2331
		// Calculate the attrs that will be change
2332
		var data = trigger.apply(this, [event, dx, dy]), ie6 = $.browser.msie && $.browser.version < 7, csdif = this.sizeDiff;
2333
 
2334
		if (this._aspectRatio || event.shiftKey)
2335
			data = this._updateRatio(data, event);
2336
 
2337
		data = this._respectSize(data, event);
2338
 
2339
		// plugins callbacks need to be called first
2340
		this._propagate("resize", event);
2341
 
2342
		el.css({
2343
			top: this.position.top + "px", left: this.position.left + "px",
2344
			width: this.size.width + "px", height: this.size.height + "px"
2345
		});
2346
 
2347
		if (!this._helper && this._proportionallyResizeElements.length)
2348
			this._proportionallyResize();
2349
 
2350
		this._updateCache(data);
2351
 
2352
		// calling the user callback at the end
2353
		this._trigger('resize', event, this.ui());
2354
 
2355
		return false;
2356
	},
2357
 
2358
	_mouseStop: function(event) {
2359
 
2360
		this.resizing = false;
2361
		var o = this.options, self = this;
2362
 
2363
		if(this._helper) {
2364
			var pr = this._proportionallyResizeElements, ista = pr.length && (/textarea/i).test(pr[0].nodeName),
2365
						soffseth = ista && $.ui.hasScroll(pr[0], 'left') /* TODO - jump height */ ? 0 : self.sizeDiff.height,
2366
							soffsetw = ista ? 0 : self.sizeDiff.width;
2367
 
2368
			var s = { width: (self.size.width - soffsetw), height: (self.size.height - soffseth) },
2369
				left = (parseInt(self.element.css('left'), 10) + (self.position.left - self.originalPosition.left)) || null,
2370
				top = (parseInt(self.element.css('top'), 10) + (self.position.top - self.originalPosition.top)) || null;
2371
 
2372
			if (!o.animate)
2373
				this.element.css($.extend(s, { top: top, left: left }));
2374
 
2375
			self.helper.height(self.size.height);
2376
			self.helper.width(self.size.width);
2377
 
2378
			if (this._helper && !o.animate) this._proportionallyResize();
2379
		}
2380
 
2381
		$('body').css('cursor', 'auto');
2382
 
2383
		this.element.removeClass("ui-resizable-resizing");
2384
 
2385
		this._propagate("stop", event);
2386
 
2387
		if (this._helper) this.helper.remove();
2388
		return false;
2389
 
2390
	},
2391
 
2392
	_updateCache: function(data) {
2393
		var o = this.options;
2394
		this.offset = this.helper.offset();
2395
		if (isNumber(data.left)) this.position.left = data.left;
2396
		if (isNumber(data.top)) this.position.top = data.top;
2397
		if (isNumber(data.height)) this.size.height = data.height;
2398
		if (isNumber(data.width)) this.size.width = data.width;
2399
	},
2400
 
2401
	_updateRatio: function(data, event) {
2402
 
2403
		var o = this.options, cpos = this.position, csize = this.size, a = this.axis;
2404
 
2405
		if (data.height) data.width = (csize.height * this.aspectRatio);
2406
		else if (data.width) data.height = (csize.width / this.aspectRatio);
2407
 
2408
		if (a == 'sw') {
2409
			data.left = cpos.left + (csize.width - data.width);
2410
			data.top = null;
2411
		}
2412
		if (a == 'nw') {
2413
			data.top = cpos.top + (csize.height - data.height);
2414
			data.left = cpos.left + (csize.width - data.width);
2415
		}
2416
 
2417
		return data;
2418
	},
2419
 
2420
	_respectSize: function(data, event) {
2421
 
2422
		var el = this.helper, o = this.options, pRatio = this._aspectRatio || event.shiftKey, a = this.axis,
2423
				ismaxw = isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width), ismaxh = isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height),
2424
					isminw = isNumber(data.width) && o.minWidth && (o.minWidth > data.width), isminh = isNumber(data.height) && o.minHeight && (o.minHeight > data.height);
2425
 
2426
		if (isminw) data.width = o.minWidth;
2427
		if (isminh) data.height = o.minHeight;
2428
		if (ismaxw) data.width = o.maxWidth;
2429
		if (ismaxh) data.height = o.maxHeight;
2430
 
2431
		var dw = this.originalPosition.left + this.originalSize.width, dh = this.position.top + this.size.height;
2432
		var cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a);
2433
 
2434
		if (isminw && cw) data.left = dw - o.minWidth;
2435
		if (ismaxw && cw) data.left = dw - o.maxWidth;
2436
		if (isminh && ch)	data.top = dh - o.minHeight;
2437
		if (ismaxh && ch)	data.top = dh - o.maxHeight;
2438
 
2439
		// fixing jump error on top/left - bug #2330
2440
		var isNotwh = !data.width && !data.height;
2441
		if (isNotwh && !data.left && data.top) data.top = null;
2442
		else if (isNotwh && !data.top && data.left) data.left = null;
2443
 
2444
		return data;
2445
	},
2446
 
2447
	_proportionallyResize: function() {
2448
 
2449
		var o = this.options;
2450
		if (!this._proportionallyResizeElements.length) return;
2451
		var element = this.helper || this.element;
2452
 
2453
		for (var i=0; i < this._proportionallyResizeElements.length; i++) {
2454
 
2455
			var prel = this._proportionallyResizeElements[i];
2456
 
2457
			if (!this.borderDif) {
2458
				var b = [prel.css('borderTopWidth'), prel.css('borderRightWidth'), prel.css('borderBottomWidth'), prel.css('borderLeftWidth')],
2459
					p = [prel.css('paddingTop'), prel.css('paddingRight'), prel.css('paddingBottom'), prel.css('paddingLeft')];
2460
 
2461
				this.borderDif = $.map(b, function(v, i) {
2462
					var border = parseInt(v,10)||0, padding = parseInt(p[i],10)||0;
2463
					return border + padding;
2464
				});
2465
			}
2466
 
2467
			if ($.browser.msie && !(!($(element).is(':hidden') || $(element).parents(':hidden').length)))
2468
				continue;
2469
 
2470
			prel.css({
2471
				height: (element.height() - this.borderDif[0] - this.borderDif[2]) || 0,
2472
				width: (element.width() - this.borderDif[1] - this.borderDif[3]) || 0
2473
			});
2474
 
2475
		};
2476
 
2477
	},
2478
 
2479
	_renderProxy: function() {
2480
 
2481
		var el = this.element, o = this.options;
2482
		this.elementOffset = el.offset();
2483
 
2484
		if(this._helper) {
2485
 
2486
			this.helper = this.helper || $('<div style="overflow:hidden;"></div>');
2487
 
2488
			// fix ie6 offset TODO: This seems broken
2489
			var ie6 = $.browser.msie && $.browser.version < 7, ie6offset = (ie6 ? 1 : 0),
2490
			pxyoffset = ( ie6 ? 2 : -1 );
2491
 
2492
			this.helper.addClass(this._helper).css({
2493
				width: this.element.outerWidth() + pxyoffset,
2494
				height: this.element.outerHeight() + pxyoffset,
2495
				position: 'absolute',
2496
				left: this.elementOffset.left - ie6offset +'px',
2497
				top: this.elementOffset.top - ie6offset +'px',
2498
				zIndex: ++o.zIndex //TODO: Don't modify option
2499
			});
2500
 
2501
			this.helper
2502
				.appendTo("body")
2503
				.disableSelection();
2504
 
2505
		} else {
2506
			this.helper = this.element;
2507
		}
2508
 
2509
	},
2510
 
2511
	_change: {
2512
		e: function(event, dx, dy) {
2513
			return { width: this.originalSize.width + dx };
2514
		},
2515
		w: function(event, dx, dy) {
2516
			var o = this.options, cs = this.originalSize, sp = this.originalPosition;
2517
			return { left: sp.left + dx, width: cs.width - dx };
2518
		},
2519
		n: function(event, dx, dy) {
2520
			var o = this.options, cs = this.originalSize, sp = this.originalPosition;
2521
			return { top: sp.top + dy, height: cs.height - dy };
2522
		},
2523
		s: function(event, dx, dy) {
2524
			return { height: this.originalSize.height + dy };
2525
		},
2526
		se: function(event, dx, dy) {
2527
			return $.extend(this._change.s.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
2528
		},
2529
		sw: function(event, dx, dy) {
2530
			return $.extend(this._change.s.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
2531
		},
2532
		ne: function(event, dx, dy) {
2533
			return $.extend(this._change.n.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
2534
		},
2535
		nw: function(event, dx, dy) {
2536
			return $.extend(this._change.n.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
2537
		}
2538
	},
2539
 
2540
	_propagate: function(n, event) {
2541
		$.ui.plugin.call(this, n, [event, this.ui()]);
2542
		(n != "resize" && this._trigger(n, event, this.ui()));
2543
	},
2544
 
2545
	plugins: {},
2546
 
2547
	ui: function() {
2548
		return {
2549
			originalElement: this.originalElement,
2550
			element: this.element,
2551
			helper: this.helper,
2552
			position: this.position,
2553
			size: this.size,
2554
			originalSize: this.originalSize,
2555
			originalPosition: this.originalPosition
2556
		};
2557
	}
2558
 
2559
});
2560
 
2561
$.extend($.ui.resizable, {
2562
	version: "1.8.5"
2563
});
2564
 
2565
/*
2566
 * Resizable Extensions
2567
 */
2568
 
2569
$.ui.plugin.add("resizable", "alsoResize", {
2570
 
2571
	start: function (event, ui) {
2572
		var self = $(this).data("resizable"), o = self.options;
2573
 
2574
		var _store = function (exp) {
2575
			$(exp).each(function() {
2576
				var el = $(this);
2577
				el.data("resizable-alsoresize", {
2578
					width: parseInt(el.width(), 10), height: parseInt(el.height(), 10),
2579
					left: parseInt(el.css('left'), 10), top: parseInt(el.css('top'), 10),
2580
					position: el.css('position') // to reset Opera on stop()
2581
				});
2582
			});
2583
		};
2584
 
2585
		if (typeof(o.alsoResize) == 'object' && !o.alsoResize.parentNode) {
2586
			if (o.alsoResize.length) { o.alsoResize = o.alsoResize[0]; _store(o.alsoResize); }
2587
			else { $.each(o.alsoResize, function (exp) { _store(exp); }); }
2588
		}else{
2589
			_store(o.alsoResize);
2590
		}
2591
	},
2592
 
2593
	resize: function (event, ui) {
2594
		var self = $(this).data("resizable"), o = self.options, os = self.originalSize, op = self.originalPosition;
2595
 
2596
		var delta = {
2597
			height: (self.size.height - os.height) || 0, width: (self.size.width - os.width) || 0,
2598
			top: (self.position.top - op.top) || 0, left: (self.position.left - op.left) || 0
2599
		},
2600
 
2601
		_alsoResize = function (exp, c) {
2602
			$(exp).each(function() {
2603
				var el = $(this), start = $(this).data("resizable-alsoresize"), style = {},
2604
					css = c && c.length ? c : el.parents(ui.originalElement[0]).length ? ['width', 'height'] : ['width', 'height', 'top', 'left'];
2605
 
2606
				$.each(css, function (i, prop) {
2607
					var sum = (start[prop]||0) + (delta[prop]||0);
2608
					if (sum && sum >= 0)
2609
						style[prop] = sum || null;
2610
				});
2611
 
2612
				// Opera fixing relative position
2613
				if ($.browser.opera && /relative/.test(el.css('position'))) {
2614
					self._revertToRelativePosition = true;
2615
					el.css({ position: 'absolute', top: 'auto', left: 'auto' });
2616
				}
2617
 
2618
				el.css(style);
2619
			});
2620
		};
2621
 
2622
		if (typeof(o.alsoResize) == 'object' && !o.alsoResize.nodeType) {
2623
			$.each(o.alsoResize, function (exp, c) { _alsoResize(exp, c); });
2624
		}else{
2625
			_alsoResize(o.alsoResize);
2626
		}
2627
	},
2628
 
2629
	stop: function (event, ui) {
2630
		var self = $(this).data("resizable"), o = self.options;
2631
 
2632
		var _reset = function (exp) {
2633
			$(exp).each(function() {
2634
				var el = $(this);
2635
				// reset position for Opera - no need to verify it was changed
2636
				el.css({ position: el.data("resizable-alsoresize").position });
2637
			});
2638
		};
2639
 
2640
		if (self._revertToRelativePosition) {
2641
			self._revertToRelativePosition = false;
2642
			if (typeof(o.alsoResize) == 'object' && !o.alsoResize.nodeType) {
2643
				$.each(o.alsoResize, function (exp) { _reset(exp); });
2644
			}else{
2645
				_reset(o.alsoResize);
2646
			}
2647
		}
2648
 
2649
		$(this).removeData("resizable-alsoresize");
2650
	}
2651
});
2652
 
2653
$.ui.plugin.add("resizable", "animate", {
2654
 
2655
	stop: function(event, ui) {
2656
		var self = $(this).data("resizable"), o = self.options;
2657
 
2658
		var pr = self._proportionallyResizeElements, ista = pr.length && (/textarea/i).test(pr[0].nodeName),
2659
					soffseth = ista && $.ui.hasScroll(pr[0], 'left') /* TODO - jump height */ ? 0 : self.sizeDiff.height,
2660
						soffsetw = ista ? 0 : self.sizeDiff.width;
2661
 
2662
		var style = { width: (self.size.width - soffsetw), height: (self.size.height - soffseth) },
2663
					left = (parseInt(self.element.css('left'), 10) + (self.position.left - self.originalPosition.left)) || null,
2664
						top = (parseInt(self.element.css('top'), 10) + (self.position.top - self.originalPosition.top)) || null;
2665
 
2666
		self.element.animate(
2667
			$.extend(style, top && left ? { top: top, left: left } : {}), {
2668
				duration: o.animateDuration,
2669
				easing: o.animateEasing,
2670
				step: function() {
2671
 
2672
					var data = {
2673
						width: parseInt(self.element.css('width'), 10),
2674
						height: parseInt(self.element.css('height'), 10),
2675
						top: parseInt(self.element.css('top'), 10),
2676
						left: parseInt(self.element.css('left'), 10)
2677
					};
2678
 
2679
					if (pr && pr.length) $(pr[0]).css({ width: data.width, height: data.height });
2680
 
2681
					// propagating resize, and updating values for each animation step
2682
					self._updateCache(data);
2683
					self._propagate("resize", event);
2684
 
2685
				}
2686
			}
2687
		);
2688
	}
2689
 
2690
});
2691
 
2692
$.ui.plugin.add("resizable", "containment", {
2693
 
2694
	start: function(event, ui) {
2695
		var self = $(this).data("resizable"), o = self.options, el = self.element;
2696
		var oc = o.containment,	ce = (oc instanceof $) ? oc.get(0) : (/parent/.test(oc)) ? el.parent().get(0) : oc;
2697
		if (!ce) return;
2698
 
2699
		self.containerElement = $(ce);
2700
 
2701
		if (/document/.test(oc) || oc == document) {
2702
			self.containerOffset = { left: 0, top: 0 };
2703
			self.containerPosition = { left: 0, top: 0 };
2704
 
2705
			self.parentData = {
2706
				element: $(document), left: 0, top: 0,
2707
				width: $(document).width(), height: $(document).height() || document.body.parentNode.scrollHeight
2708
			};
2709
		}
2710
 
2711
		// i'm a node, so compute top, left, right, bottom
2712
		else {
2713
			var element = $(ce), p = [];
2714
			$([ "Top", "Right", "Left", "Bottom" ]).each(function(i, name) { p[i] = num(element.css("padding" + name)); });
2715
 
2716
			self.containerOffset = element.offset();
2717
			self.containerPosition = element.position();
2718
			self.containerSize = { height: (element.innerHeight() - p[3]), width: (element.innerWidth() - p[1]) };
2719
 
2720
			var co = self.containerOffset, ch = self.containerSize.height,	cw = self.containerSize.width,
2721
						width = ($.ui.hasScroll(ce, "left") ? ce.scrollWidth : cw ), height = ($.ui.hasScroll(ce) ? ce.scrollHeight : ch);
2722
 
2723
			self.parentData = {
2724
				element: ce, left: co.left, top: co.top, width: width, height: height
2725
			};
2726
		}
2727
	},
2728
 
2729
	resize: function(event, ui) {
2730
		var self = $(this).data("resizable"), o = self.options,
2731
				ps = self.containerSize, co = self.containerOffset, cs = self.size, cp = self.position,
2732
				pRatio = self._aspectRatio || event.shiftKey, cop = { top:0, left:0 }, ce = self.containerElement;
2733
 
2734
		if (ce[0] != document && (/static/).test(ce.css('position'))) cop = co;
2735
 
2736
		if (cp.left < (self._helper ? co.left : 0)) {
2737
			self.size.width = self.size.width + (self._helper ? (self.position.left - co.left) : (self.position.left - cop.left));
2738
			if (pRatio) self.size.height = self.size.width / o.aspectRatio;
2739
			self.position.left = o.helper ? co.left : 0;
2740
		}
2741
 
2742
		if (cp.top < (self._helper ? co.top : 0)) {
2743
			self.size.height = self.size.height + (self._helper ? (self.position.top - co.top) : self.position.top);
2744
			if (pRatio) self.size.width = self.size.height * o.aspectRatio;
2745
			self.position.top = self._helper ? co.top : 0;
2746
		}
2747
 
2748
		self.offset.left = self.parentData.left+self.position.left;
2749
		self.offset.top = self.parentData.top+self.position.top;
2750
 
2751
		var woset = Math.abs( (self._helper ? self.offset.left - cop.left : (self.offset.left - cop.left)) + self.sizeDiff.width ),
2752
					hoset = Math.abs( (self._helper ? self.offset.top - cop.top : (self.offset.top - co.top)) + self.sizeDiff.height );
2753
 
2754
		var isParent = self.containerElement.get(0) == self.element.parent().get(0),
2755
		    isOffsetRelative = /relative|absolute/.test(self.containerElement.css('position'));
2756
 
2757
		if(isParent && isOffsetRelative) woset -= self.parentData.left;
2758
 
2759
		if (woset + self.size.width >= self.parentData.width) {
2760
			self.size.width = self.parentData.width - woset;
2761
			if (pRatio) self.size.height = self.size.width / self.aspectRatio;
2762
		}
2763
 
2764
		if (hoset + self.size.height >= self.parentData.height) {
2765
			self.size.height = self.parentData.height - hoset;
2766
			if (pRatio) self.size.width = self.size.height * self.aspectRatio;
2767
		}
2768
	},
2769
 
2770
	stop: function(event, ui){
2771
		var self = $(this).data("resizable"), o = self.options, cp = self.position,
2772
				co = self.containerOffset, cop = self.containerPosition, ce = self.containerElement;
2773
 
2774
		var helper = $(self.helper), ho = helper.offset(), w = helper.outerWidth() - self.sizeDiff.width, h = helper.outerHeight() - self.sizeDiff.height;
2775
 
2776
		if (self._helper && !o.animate && (/relative/).test(ce.css('position')))
2777
			$(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
2778
 
2779
		if (self._helper && !o.animate && (/static/).test(ce.css('position')))
2780
			$(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
2781
 
2782
	}
2783
});
2784
 
2785
$.ui.plugin.add("resizable", "ghost", {
2786
 
2787
	start: function(event, ui) {
2788
 
2789
		var self = $(this).data("resizable"), o = self.options, cs = self.size;
2790
 
2791
		self.ghost = self.originalElement.clone();
2792
		self.ghost
2793
			.css({ opacity: .25, display: 'block', position: 'relative', height: cs.height, width: cs.width, margin: 0, left: 0, top: 0 })
2794
			.addClass('ui-resizable-ghost')
2795
			.addClass(typeof o.ghost == 'string' ? o.ghost : '');
2796
 
2797
		self.ghost.appendTo(self.helper);
2798
 
2799
	},
2800
 
2801
	resize: function(event, ui){
2802
		var self = $(this).data("resizable"), o = self.options;
2803
		if (self.ghost) self.ghost.css({ position: 'relative', height: self.size.height, width: self.size.width });
2804
	},
2805
 
2806
	stop: function(event, ui){
2807
		var self = $(this).data("resizable"), o = self.options;
2808
		if (self.ghost && self.helper) self.helper.get(0).removeChild(self.ghost.get(0));
2809
	}
2810
 
2811
});
2812
 
2813
$.ui.plugin.add("resizable", "grid", {
2814
 
2815
	resize: function(event, ui) {
2816
		var self = $(this).data("resizable"), o = self.options, cs = self.size, os = self.originalSize, op = self.originalPosition, a = self.axis, ratio = o._aspectRatio || event.shiftKey;
2817
		o.grid = typeof o.grid == "number" ? [o.grid, o.grid] : o.grid;
2818
		var ox = Math.round((cs.width - os.width) / (o.grid[0]||1)) * (o.grid[0]||1), oy = Math.round((cs.height - os.height) / (o.grid[1]||1)) * (o.grid[1]||1);
2819
 
2820
		if (/^(se|s|e)$/.test(a)) {
2821
			self.size.width = os.width + ox;
2822
			self.size.height = os.height + oy;
2823
		}
2824
		else if (/^(ne)$/.test(a)) {
2825
			self.size.width = os.width + ox;
2826
			self.size.height = os.height + oy;
2827
			self.position.top = op.top - oy;
2828
		}
2829
		else if (/^(sw)$/.test(a)) {
2830
			self.size.width = os.width + ox;
2831
			self.size.height = os.height + oy;
2832
			self.position.left = op.left - ox;
2833
		}
2834
		else {
2835
			self.size.width = os.width + ox;
2836
			self.size.height = os.height + oy;
2837
			self.position.top = op.top - oy;
2838
			self.position.left = op.left - ox;
2839
		}
2840
	}
2841
 
2842
});
2843
 
2844
var num = function(v) {
2845
	return parseInt(v, 10) || 0;
2846
};
2847
 
2848
var isNumber = function(value) {
2849
	return !isNaN(parseInt(value, 10));
2850
};
2851
 
2852
})(jQuery);
2853
/*
2854
 * jQuery UI Selectable 1.8.5
2855
 *
2856
 * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
2857
 * Dual licensed under the MIT or GPL Version 2 licenses.
2858
 * http://jquery.org/license
2859
 *
2860
 * http://docs.jquery.com/UI/Selectables
2861
 *
2862
 * Depends:
2863
 *	jquery.ui.core.js
2864
 *	jquery.ui.mouse.js
2865
 *	jquery.ui.widget.js
2866
 */
2867
(function( $, undefined ) {
2868
 
2869
$.widget("ui.selectable", $.ui.mouse, {
2870
	options: {
2871
		appendTo: 'body',
2872
		autoRefresh: true,
2873
		distance: 0,
2874
		filter: '*',
2875
		tolerance: 'touch'
2876
	},
2877
	_create: function() {
2878
		var self = this;
2879
 
2880
		this.element.addClass("ui-selectable");
2881
 
2882
		this.dragged = false;
2883
 
2884
		// cache selectee children based on filter
2885
		var selectees;
2886
		this.refresh = function() {
2887
			selectees = $(self.options.filter, self.element[0]);
2888
			selectees.each(function() {
2889
				var $this = $(this);
2890
				var pos = $this.offset();
2891
				$.data(this, "selectable-item", {
2892
					element: this,
2893
					$element: $this,
2894
					left: pos.left,
2895
					top: pos.top,
2896
					right: pos.left + $this.outerWidth(),
2897
					bottom: pos.top + $this.outerHeight(),
2898
					startselected: false,
2899
					selected: $this.hasClass('ui-selected'),
2900
					selecting: $this.hasClass('ui-selecting'),
2901
					unselecting: $this.hasClass('ui-unselecting')
2902
				});
2903
			});
2904
		};
2905
		this.refresh();
2906
 
2907
		this.selectees = selectees.addClass("ui-selectee");
2908
 
2909
		this._mouseInit();
2910
 
2911
		this.helper = $("<div class='ui-selectable-helper'></div>");
2912
	},
2913
 
2914
	destroy: function() {
2915
		this.selectees
2916
			.removeClass("ui-selectee")
2917
			.removeData("selectable-item");
2918
		this.element
2919
			.removeClass("ui-selectable ui-selectable-disabled")
2920
			.removeData("selectable")
2921
			.unbind(".selectable");
2922
		this._mouseDestroy();
2923
 
2924
		return this;
2925
	},
2926
 
2927
	_mouseStart: function(event) {
2928
		var self = this;
2929
 
2930
		this.opos = [event.pageX, event.pageY];
2931
 
2932
		if (this.options.disabled)
2933
			return;
2934
 
2935
		var options = this.options;
2936
 
2937
		this.selectees = $(options.filter, this.element[0]);
2938
 
2939
		this._trigger("start", event);
2940
 
2941
		$(options.appendTo).append(this.helper);
2942
		// position helper (lasso)
2943
		this.helper.css({
2944
			"left": event.clientX,
2945
			"top": event.clientY,
2946
			"width": 0,
2947
			"height": 0
2948
		});
2949
 
2950
		if (options.autoRefresh) {
2951
			this.refresh();
2952
		}
2953
 
2954
		this.selectees.filter('.ui-selected').each(function() {
2955
			var selectee = $.data(this, "selectable-item");
2956
			selectee.startselected = true;
2957
			if (!event.metaKey) {
2958
				selectee.$element.removeClass('ui-selected');
2959
				selectee.selected = false;
2960
				selectee.$element.addClass('ui-unselecting');
2961
				selectee.unselecting = true;
2962
				// selectable UNSELECTING callback
2963
				self._trigger("unselecting", event, {
2964
					unselecting: selectee.element
2965
				});
2966
			}
2967
		});
2968
 
2969
		$(event.target).parents().andSelf().each(function() {
2970
			var selectee = $.data(this, "selectable-item");
2971
			if (selectee) {
2972
				var doSelect = !event.metaKey || !selectee.$element.hasClass('ui-selected');
2973
				selectee.$element
2974
					.removeClass(doSelect ? "ui-unselecting" : "ui-selected")
2975
					.addClass(doSelect ? "ui-selecting" : "ui-unselecting");
2976
				selectee.unselecting = !doSelect;
2977
				selectee.selecting = doSelect;
2978
				selectee.selected = doSelect;
2979
				// selectable (UN)SELECTING callback
2980
				if (doSelect) {
2981
					self._trigger("selecting", event, {
2982
						selecting: selectee.element
2983
					});
2984
				} else {
2985
					self._trigger("unselecting", event, {
2986
						unselecting: selectee.element
2987
					});
2988
				}
2989
				return false;
2990
			}
2991
		});
2992
 
2993
	},
2994
 
2995
	_mouseDrag: function(event) {
2996
		var self = this;
2997
		this.dragged = true;
2998
 
2999
		if (this.options.disabled)
3000
			return;
3001
 
3002
		var options = this.options;
3003
 
3004
		var x1 = this.opos[0], y1 = this.opos[1], x2 = event.pageX, y2 = event.pageY;
3005
		if (x1 > x2) { var tmp = x2; x2 = x1; x1 = tmp; }
3006
		if (y1 > y2) { var tmp = y2; y2 = y1; y1 = tmp; }
3007
		this.helper.css({left: x1, top: y1, width: x2-x1, height: y2-y1});
3008
 
3009
		this.selectees.each(function() {
3010
			var selectee = $.data(this, "selectable-item");
3011
			//prevent helper from being selected if appendTo: selectable
3012
			if (!selectee || selectee.element == self.element[0])
3013
				return;
3014
			var hit = false;
3015
			if (options.tolerance == 'touch') {
3016
				hit = ( !(selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1) );
3017
			} else if (options.tolerance == 'fit') {
3018
				hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2);
3019
			}
3020
 
3021
			if (hit) {
3022
				// SELECT
3023
				if (selectee.selected) {
3024
					selectee.$element.removeClass('ui-selected');
3025
					selectee.selected = false;
3026
				}
3027
				if (selectee.unselecting) {
3028
					selectee.$element.removeClass('ui-unselecting');
3029
					selectee.unselecting = false;
3030
				}
3031
				if (!selectee.selecting) {
3032
					selectee.$element.addClass('ui-selecting');
3033
					selectee.selecting = true;
3034
					// selectable SELECTING callback
3035
					self._trigger("selecting", event, {
3036
						selecting: selectee.element
3037
					});
3038
				}
3039
			} else {
3040
				// UNSELECT
3041
				if (selectee.selecting) {
3042
					if (event.metaKey && selectee.startselected) {
3043
						selectee.$element.removeClass('ui-selecting');
3044
						selectee.selecting = false;
3045
						selectee.$element.addClass('ui-selected');
3046
						selectee.selected = true;
3047
					} else {
3048
						selectee.$element.removeClass('ui-selecting');
3049
						selectee.selecting = false;
3050
						if (selectee.startselected) {
3051
							selectee.$element.addClass('ui-unselecting');
3052
							selectee.unselecting = true;
3053
						}
3054
						// selectable UNSELECTING callback
3055
						self._trigger("unselecting", event, {
3056
							unselecting: selectee.element
3057
						});
3058
					}
3059
				}
3060
				if (selectee.selected) {
3061
					if (!event.metaKey && !selectee.startselected) {
3062
						selectee.$element.removeClass('ui-selected');
3063
						selectee.selected = false;
3064
 
3065
						selectee.$element.addClass('ui-unselecting');
3066
						selectee.unselecting = true;
3067
						// selectable UNSELECTING callback
3068
						self._trigger("unselecting", event, {
3069
							unselecting: selectee.element
3070
						});
3071
					}
3072
				}
3073
			}
3074
		});
3075
 
3076
		return false;
3077
	},
3078
 
3079
	_mouseStop: function(event) {
3080
		var self = this;
3081
 
3082
		this.dragged = false;
3083
 
3084
		var options = this.options;
3085
 
3086
		$('.ui-unselecting', this.element[0]).each(function() {
3087
			var selectee = $.data(this, "selectable-item");
3088
			selectee.$element.removeClass('ui-unselecting');
3089
			selectee.unselecting = false;
3090
			selectee.startselected = false;
3091
			self._trigger("unselected", event, {
3092
				unselected: selectee.element
3093
			});
3094
		});
3095
		$('.ui-selecting', this.element[0]).each(function() {
3096
			var selectee = $.data(this, "selectable-item");
3097
			selectee.$element.removeClass('ui-selecting').addClass('ui-selected');
3098
			selectee.selecting = false;
3099
			selectee.selected = true;
3100
			selectee.startselected = true;
3101
			self._trigger("selected", event, {
3102
				selected: selectee.element
3103
			});
3104
		});
3105
		this._trigger("stop", event);
3106
 
3107
		this.helper.remove();
3108
 
3109
		return false;
3110
	}
3111
 
3112
});
3113
 
3114
$.extend($.ui.selectable, {
3115
	version: "1.8.5"
3116
});
3117
 
3118
})(jQuery);
3119
/*
3120
 * jQuery UI Sortable 1.8.5
3121
 *
3122
 * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
3123
 * Dual licensed under the MIT or GPL Version 2 licenses.
3124
 * http://jquery.org/license
3125
 *
3126
 * http://docs.jquery.com/UI/Sortables
3127
 *
3128
 * Depends:
3129
 *	jquery.ui.core.js
3130
 *	jquery.ui.mouse.js
3131
 *	jquery.ui.widget.js
3132
 */
3133
(function( $, undefined ) {
3134
 
3135
$.widget("ui.sortable", $.ui.mouse, {
3136
	widgetEventPrefix: "sort",
3137
	options: {
3138
		appendTo: "parent",
3139
		axis: false,
3140
		connectWith: false,
3141
		containment: false,
3142
		cursor: 'auto',
3143
		cursorAt: false,
3144
		dropOnEmpty: true,
3145
		forcePlaceholderSize: false,
3146
		forceHelperSize: false,
3147
		grid: false,
3148
		handle: false,
3149
		helper: "original",
3150
		items: '> *',
3151
		opacity: false,
3152
		placeholder: false,
3153
		revert: false,
3154
		scroll: true,
3155
		scrollSensitivity: 20,
3156
		scrollSpeed: 20,
3157
		scope: "default",
3158
		tolerance: "intersect",
3159
		zIndex: 1000
3160
	},
3161
	_create: function() {
3162
 
3163
		var o = this.options;
3164
		this.containerCache = {};
3165
		this.element.addClass("ui-sortable");
3166
 
3167
		//Get the items
3168
		this.refresh();
3169
 
3170
		//Let's determine if the items are floating
3171
		this.floating = this.items.length ? (/left|right/).test(this.items[0].item.css('float')) : false;
3172
 
3173
		//Let's determine the parent's offset
3174
		this.offset = this.element.offset();
3175
 
3176
		//Initialize mouse events for interaction
3177
		this._mouseInit();
3178
 
3179
	},
3180
 
3181
	destroy: function() {
3182
		this.element
3183
			.removeClass("ui-sortable ui-sortable-disabled")
3184
			.removeData("sortable")
3185
			.unbind(".sortable");
3186
		this._mouseDestroy();
3187
 
3188
		for ( var i = this.items.length - 1; i >= 0; i-- )
3189
			this.items[i].item.removeData("sortable-item");
3190
 
3191
		return this;
3192
	},
3193
 
3194
	_setOption: function(key, value){
3195
		if ( key === "disabled" ) {
3196
			this.options[ key ] = value;
3197
 
3198
			this.widget()
3199
				[ value ? "addClass" : "removeClass"]( "ui-sortable-disabled" );
3200
		} else {
3201
			// Don't call widget base _setOption for disable as it adds ui-state-disabled class
3202
			$.Widget.prototype._setOption.apply(this, arguments);
3203
		}
3204
	},
3205
 
3206
	_mouseCapture: function(event, overrideHandle) {
3207
 
3208
		if (this.reverting) {
3209
			return false;
3210
		}
3211
 
3212
		if(this.options.disabled || this.options.type == 'static') return false;
3213
 
3214
		//We have to refresh the items data once first
3215
		this._refreshItems(event);
3216
 
3217
		//Find out if the clicked node (or one of its parents) is a actual item in this.items
3218
		var currentItem = null, self = this, nodes = $(event.target).parents().each(function() {
3219
			if($.data(this, 'sortable-item') == self) {
3220
				currentItem = $(this);
3221
				return false;
3222
			}
3223
		});
3224
		if($.data(event.target, 'sortable-item') == self) currentItem = $(event.target);
3225
 
3226
		if(!currentItem) return false;
3227
		if(this.options.handle && !overrideHandle) {
3228
			var validHandle = false;
3229
 
3230
			$(this.options.handle, currentItem).find("*").andSelf().each(function() { if(this == event.target) validHandle = true; });
3231
			if(!validHandle) return false;
3232
		}
3233
 
3234
		this.currentItem = currentItem;
3235
		this._removeCurrentsFromItems();
3236
		return true;
3237
 
3238
	},
3239
 
3240
	_mouseStart: function(event, overrideHandle, noActivation) {
3241
 
3242
		var o = this.options, self = this;
3243
		this.currentContainer = this;
3244
 
3245
		//We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture
3246
		this.refreshPositions();
3247
 
3248
		//Create and append the visible helper
3249
		this.helper = this._createHelper(event);
3250
 
3251
		//Cache the helper size
3252
		this._cacheHelperProportions();
3253
 
3254
		/*
3255
		 * - Position generation -
3256
		 * This block generates everything position related - it's the core of draggables.
3257
		 */
3258
 
3259
		//Cache the margins of the original element
3260
		this._cacheMargins();
3261
 
3262
		//Get the next scrolling parent
3263
		this.scrollParent = this.helper.scrollParent();
3264
 
3265
		//The element's absolute position on the page minus margins
3266
		this.offset = this.currentItem.offset();
3267
		this.offset = {
3268
			top: this.offset.top - this.margins.top,
3269
			left: this.offset.left - this.margins.left
3270
		};
3271
 
3272
		// Only after we got the offset, we can change the helper's position to absolute
3273
		// TODO: Still need to figure out a way to make relative sorting possible
3274
		this.helper.css("position", "absolute");
3275
		this.cssPosition = this.helper.css("position");
3276
 
3277
		$.extend(this.offset, {
3278
			click: { //Where the click happened, relative to the element
3279
				left: event.pageX - this.offset.left,
3280
				top: event.pageY - this.offset.top
3281
			},
3282
			parent: this._getParentOffset(),
3283
			relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
3284
		});
3285
 
3286
		//Generate the original position
3287
		this.originalPosition = this._generatePosition(event);
3288
		this.originalPageX = event.pageX;
3289
		this.originalPageY = event.pageY;
3290
 
3291
		//Adjust the mouse offset relative to the helper if 'cursorAt' is supplied
3292
		(o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
3293
 
3294
		//Cache the former DOM position
3295
		this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] };
3296
 
3297
		//If the helper is not the original, hide the original so it's not playing any role during the drag, won't cause anything bad this way
3298
		if(this.helper[0] != this.currentItem[0]) {
3299
			this.currentItem.hide();
3300
		}
3301
 
3302
		//Create the placeholder
3303
		this._createPlaceholder();
3304
 
3305
		//Set a containment if given in the options
3306
		if(o.containment)
3307
			this._setContainment();
3308
 
3309
		if(o.cursor) { // cursor option
3310
			if ($('body').css("cursor")) this._storedCursor = $('body').css("cursor");
3311
			$('body').css("cursor", o.cursor);
3312
		}
3313
 
3314
		if(o.opacity) { // opacity option
3315
			if (this.helper.css("opacity")) this._storedOpacity = this.helper.css("opacity");
3316
			this.helper.css("opacity", o.opacity);
3317
		}
3318
 
3319
		if(o.zIndex) { // zIndex option
3320
			if (this.helper.css("zIndex")) this._storedZIndex = this.helper.css("zIndex");
3321
			this.helper.css("zIndex", o.zIndex);
3322
		}
3323
 
3324
		//Prepare scrolling
3325
		if(this.scrollParent[0] != document && this.scrollParent[0].tagName != 'HTML')
3326
			this.overflowOffset = this.scrollParent.offset();
3327
 
3328
		//Call callbacks
3329
		this._trigger("start", event, this._uiHash());
3330
 
3331
		//Recache the helper size
3332
		if(!this._preserveHelperProportions)
3333
			this._cacheHelperProportions();
3334
 
3335
 
3336
		//Post 'activate' events to possible containers
3337
		if(!noActivation) {
3338
			 for (var i = this.containers.length - 1; i >= 0; i--) { this.containers[i]._trigger("activate", event, self._uiHash(this)); }
3339
		}
3340
 
3341
		//Prepare possible droppables
3342
		if($.ui.ddmanager)
3343
			$.ui.ddmanager.current = this;
3344
 
3345
		if ($.ui.ddmanager && !o.dropBehaviour)
3346
			$.ui.ddmanager.prepareOffsets(this, event);
3347
 
3348
		this.dragging = true;
3349
 
3350
		this.helper.addClass("ui-sortable-helper");
3351
		this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position
3352
		return true;
3353
 
3354
	},
3355
 
3356
	_mouseDrag: function(event) {
3357
 
3358
		//Compute the helpers position
3359
		this.position = this._generatePosition(event);
3360
		this.positionAbs = this._convertPositionTo("absolute");
3361
 
3362
		if (!this.lastPositionAbs) {
3363
			this.lastPositionAbs = this.positionAbs;
3364
		}
3365
 
3366
		//Do scrolling
3367
		if(this.options.scroll) {
3368
			var o = this.options, scrolled = false;
3369
			if(this.scrollParent[0] != document && this.scrollParent[0].tagName != 'HTML') {
3370
 
3371
				if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity)
3372
					this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
3373
				else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity)
3374
					this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
3375
 
3376
				if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity)
3377
					this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
3378
				else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity)
3379
					this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
3380
 
3381
			} else {
3382
 
3383
				if(event.pageY - $(document).scrollTop() < o.scrollSensitivity)
3384
					scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
3385
				else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity)
3386
					scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
3387
 
3388
				if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity)
3389
					scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
3390
				else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity)
3391
					scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
3392
 
3393
			}
3394
 
3395
			if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour)
3396
				$.ui.ddmanager.prepareOffsets(this, event);
3397
		}
3398
 
3399
		//Regenerate the absolute position used for position checks
3400
		this.positionAbs = this._convertPositionTo("absolute");
3401
 
3402
		//Set the helper position
3403
		if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px';
3404
		if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px';
3405
 
3406
		//Rearrange
3407
		for (var i = this.items.length - 1; i >= 0; i--) {
3408
 
3409
			//Cache variables and intersection, continue if no intersection
3410
			var item = this.items[i], itemElement = item.item[0], intersection = this._intersectsWithPointer(item);
3411
			if (!intersection) continue;
3412
 
3413
			if(itemElement != this.currentItem[0] //cannot intersect with itself
3414
				&&	this.placeholder[intersection == 1 ? "next" : "prev"]()[0] != itemElement //no useless actions that have been done before
3415
				&&	!$.ui.contains(this.placeholder[0], itemElement) //no action if the item moved is the parent of the item checked
3416
				&& (this.options.type == 'semi-dynamic' ? !$.ui.contains(this.element[0], itemElement) : true)
3417
				//&& itemElement.parentNode == this.placeholder[0].parentNode // only rearrange items within the same container
3418
			) {
3419
 
3420
				this.direction = intersection == 1 ? "down" : "up";
3421
 
3422
				if (this.options.tolerance == "pointer" || this._intersectsWithSides(item)) {
3423
					this._rearrange(event, item);
3424
				} else {
3425
					break;
3426
				}
3427
 
3428
				this._trigger("change", event, this._uiHash());
3429
				break;
3430
			}
3431
		}
3432
 
3433
		//Post events to containers
3434
		this._contactContainers(event);
3435
 
3436
		//Interconnect with droppables
3437
		if($.ui.ddmanager) $.ui.ddmanager.drag(this, event);
3438
 
3439
		//Call callbacks
3440
		this._trigger('sort', event, this._uiHash());
3441
 
3442
		this.lastPositionAbs = this.positionAbs;
3443
		return false;
3444
 
3445
	},
3446
 
3447
	_mouseStop: function(event, noPropagation) {
3448
 
3449
		if(!event) return;
3450
 
3451
		//If we are using droppables, inform the manager about the drop
3452
		if ($.ui.ddmanager && !this.options.dropBehaviour)
3453
			$.ui.ddmanager.drop(this, event);
3454
 
3455
		if(this.options.revert) {
3456
			var self = this;
3457
			var cur = self.placeholder.offset();
3458
 
3459
			self.reverting = true;
3460
 
3461
			$(this.helper).animate({
3462
				left: cur.left - this.offset.parent.left - self.margins.left + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollLeft),
3463
				top: cur.top - this.offset.parent.top - self.margins.top + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollTop)
3464
			}, parseInt(this.options.revert, 10) || 500, function() {
3465
				self._clear(event);
3466
			});
3467
		} else {
3468
			this._clear(event, noPropagation);
3469
		}
3470
 
3471
		return false;
3472
 
3473
	},
3474
 
3475
	cancel: function() {
3476
 
3477
		var self = this;
3478
 
3479
		if(this.dragging) {
3480
 
3481
			this._mouseUp();
3482
 
3483
			if(this.options.helper == "original")
3484
				this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
3485
			else
3486
				this.currentItem.show();
3487
 
3488
			//Post deactivating events to containers
3489
			for (var i = this.containers.length - 1; i >= 0; i--){
3490
				this.containers[i]._trigger("deactivate", null, self._uiHash(this));
3491
				if(this.containers[i].containerCache.over) {
3492
					this.containers[i]._trigger("out", null, self._uiHash(this));
3493
					this.containers[i].containerCache.over = 0;
3494
				}
3495
			}
3496
 
3497
		}
3498
 
3499
		//$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
3500
		if(this.placeholder[0].parentNode) this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
3501
		if(this.options.helper != "original" && this.helper && this.helper[0].parentNode) this.helper.remove();
3502
 
3503
		$.extend(this, {
3504
			helper: null,
3505
			dragging: false,
3506
			reverting: false,
3507
			_noFinalSort: null
3508
		});
3509
 
3510
		if(this.domPosition.prev) {
3511
			$(this.domPosition.prev).after(this.currentItem);
3512
		} else {
3513
			$(this.domPosition.parent).prepend(this.currentItem);
3514
		}
3515
 
3516
		return this;
3517
 
3518
	},
3519
 
3520
	serialize: function(o) {
3521
 
3522
		var items = this._getItemsAsjQuery(o && o.connected);
3523
		var str = []; o = o || {};
3524
 
3525
		$(items).each(function() {
3526
			var res = ($(o.item || this).attr(o.attribute || 'id') || '').match(o.expression || (/(.+)[-=_](.+)/));
3527
			if(res) str.push((o.key || res[1]+'[]')+'='+(o.key && o.expression ? res[1] : res[2]));
3528
		});
3529
 
3530
		if(!str.length && o.key) {
3531
			str.push(o.key + '=');
3532
		}
3533
 
3534
		return str.join('&');
3535
 
3536
	},
3537
 
3538
	toArray: function(o) {
3539
 
3540
		var items = this._getItemsAsjQuery(o && o.connected);
3541
		var ret = []; o = o || {};
3542
 
3543
		items.each(function() { ret.push($(o.item || this).attr(o.attribute || 'id') || ''); });
3544
		return ret;
3545
 
3546
	},
3547
 
3548
	/* Be careful with the following core functions */
3549
	_intersectsWith: function(item) {
3550
 
3551
		var x1 = this.positionAbs.left,
3552
			x2 = x1 + this.helperProportions.width,
3553
			y1 = this.positionAbs.top,
3554
			y2 = y1 + this.helperProportions.height;
3555
 
3556
		var l = item.left,
3557
			r = l + item.width,
3558
			t = item.top,
3559
			b = t + item.height;
3560
 
3561
		var dyClick = this.offset.click.top,
3562
			dxClick = this.offset.click.left;
3563
 
3564
		var isOverElement = (y1 + dyClick) > t && (y1 + dyClick) < b && (x1 + dxClick) > l && (x1 + dxClick) < r;
3565
 
3566
		if(	   this.options.tolerance == "pointer"
3567
			|| this.options.forcePointerForContainers
3568
			|| (this.options.tolerance != "pointer" && this.helperProportions[this.floating ? 'width' : 'height'] > item[this.floating ? 'width' : 'height'])
3569
		) {
3570
			return isOverElement;
3571
		} else {
3572
 
3573
			return (l < x1 + (this.helperProportions.width / 2) // Right Half
3574
				&& x2 - (this.helperProportions.width / 2) < r // Left Half
3575
				&& t < y1 + (this.helperProportions.height / 2) // Bottom Half
3576
				&& y2 - (this.helperProportions.height / 2) < b ); // Top Half
3577
 
3578
		}
3579
	},
3580
 
3581
	_intersectsWithPointer: function(item) {
3582
 
3583
		var isOverElementHeight = $.ui.isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
3584
			isOverElementWidth = $.ui.isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
3585
			isOverElement = isOverElementHeight && isOverElementWidth,
3586
			verticalDirection = this._getDragVerticalDirection(),
3587
			horizontalDirection = this._getDragHorizontalDirection();
3588
 
3589
		if (!isOverElement)
3590
			return false;
3591
 
3592
		return this.floating ?
3593
			( ((horizontalDirection && horizontalDirection == "right") || verticalDirection == "down") ? 2 : 1 )
3594
			: ( verticalDirection && (verticalDirection == "down" ? 2 : 1) );
3595
 
3596
	},
3597
 
3598
	_intersectsWithSides: function(item) {
3599
 
3600
		var isOverBottomHalf = $.ui.isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height),
3601
			isOverRightHalf = $.ui.isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width),
3602
			verticalDirection = this._getDragVerticalDirection(),
3603
			horizontalDirection = this._getDragHorizontalDirection();
3604
 
3605
		if (this.floating && horizontalDirection) {
3606
			return ((horizontalDirection == "right" && isOverRightHalf) || (horizontalDirection == "left" && !isOverRightHalf));
3607
		} else {
3608
			return verticalDirection && ((verticalDirection == "down" && isOverBottomHalf) || (verticalDirection == "up" && !isOverBottomHalf));
3609
		}
3610
 
3611
	},
3612
 
3613
	_getDragVerticalDirection: function() {
3614
		var delta = this.positionAbs.top - this.lastPositionAbs.top;
3615
		return delta != 0 && (delta > 0 ? "down" : "up");
3616
	},
3617
 
3618
	_getDragHorizontalDirection: function() {
3619
		var delta = this.positionAbs.left - this.lastPositionAbs.left;
3620
		return delta != 0 && (delta > 0 ? "right" : "left");
3621
	},
3622
 
3623
	refresh: function(event) {
3624
		this._refreshItems(event);
3625
		this.refreshPositions();
3626
		return this;
3627
	},
3628
 
3629
	_connectWith: function() {
3630
		var options = this.options;
3631
		return options.connectWith.constructor == String
3632
			? [options.connectWith]
3633
			: options.connectWith;
3634
	},
3635
 
3636
	_getItemsAsjQuery: function(connected) {
3637
 
3638
		var self = this;
3639
		var items = [];
3640
		var queries = [];
3641
		var connectWith = this._connectWith();
3642
 
3643
		if(connectWith && connected) {
3644
			for (var i = connectWith.length - 1; i >= 0; i--){
3645
				var cur = $(connectWith[i]);
3646
				for (var j = cur.length - 1; j >= 0; j--){
3647
					var inst = $.data(cur[j], 'sortable');
3648
					if(inst && inst != this && !inst.options.disabled) {
3649
						queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element) : $(inst.options.items, inst.element).not(".ui-sortable-helper").not('.ui-sortable-placeholder'), inst]);
3650
					}
3651
				};
3652
			};
3653
		}
3654
 
3655
		queries.push([$.isFunction(this.options.items) ? this.options.items.call(this.element, null, { options: this.options, item: this.currentItem }) : $(this.options.items, this.element).not(".ui-sortable-helper").not('.ui-sortable-placeholder'), this]);
3656
 
3657
		for (var i = queries.length - 1; i >= 0; i--){
3658
			queries[i][0].each(function() {
3659
				items.push(this);
3660
			});
3661
		};
3662
 
3663
		return $(items);
3664
 
3665
	},
3666
 
3667
	_removeCurrentsFromItems: function() {
3668
 
3669
		var list = this.currentItem.find(":data(sortable-item)");
3670
 
3671
		for (var i=0; i < this.items.length; i++) {
3672
 
3673
			for (var j=0; j < list.length; j++) {
3674
				if(list[j] == this.items[i].item[0])
3675
					this.items.splice(i,1);
3676
			};
3677
 
3678
		};
3679
 
3680
	},
3681
 
3682
	_refreshItems: function(event) {
3683
 
3684
		this.items = [];
3685
		this.containers = [this];
3686
		var items = this.items;
3687
		var self = this;
3688
		var queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]];
3689
		var connectWith = this._connectWith();
3690
 
3691
		if(connectWith) {
3692
			for (var i = connectWith.length - 1; i >= 0; i--){
3693
				var cur = $(connectWith[i]);
3694
				for (var j = cur.length - 1; j >= 0; j--){
3695
					var inst = $.data(cur[j], 'sortable');
3696
					if(inst && inst != this && !inst.options.disabled) {
3697
						queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]);
3698
						this.containers.push(inst);
3699
					}
3700
				};
3701
			};
3702
		}
3703
 
3704
		for (var i = queries.length - 1; i >= 0; i--) {
3705
			var targetData = queries[i][1];
3706
			var _queries = queries[i][0];
3707
 
3708
			for (var j=0, queriesLength = _queries.length; j < queriesLength; j++) {
3709
				var item = $(_queries[j]);
3710
 
3711
				item.data('sortable-item', targetData); // Data for target checking (mouse manager)
3712
 
3713
				items.push({
3714
					item: item,
3715
					instance: targetData,
3716
					width: 0, height: 0,
3717
					left: 0, top: 0
3718
				});
3719
			};
3720
		};
3721
 
3722
	},
3723
 
3724
	refreshPositions: function(fast) {
3725
 
3726
		//This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change
3727
		if(this.offsetParent && this.helper) {
3728
			this.offset.parent = this._getParentOffset();
3729
		}
3730
 
3731
		for (var i = this.items.length - 1; i >= 0; i--){
3732
			var item = this.items[i];
3733
 
3734
			var t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item;
3735
 
3736
			if (!fast) {
3737
				item.width = t.outerWidth();
3738
				item.height = t.outerHeight();
3739
			}
3740
 
3741
			var p = t.offset();
3742
			item.left = p.left;
3743
			item.top = p.top;
3744
		};
3745
 
3746
		if(this.options.custom && this.options.custom.refreshContainers) {
3747
			this.options.custom.refreshContainers.call(this);
3748
		} else {
3749
			for (var i = this.containers.length - 1; i >= 0; i--){
3750
				var p = this.containers[i].element.offset();
3751
				this.containers[i].containerCache.left = p.left;
3752
				this.containers[i].containerCache.top = p.top;
3753
				this.containers[i].containerCache.width	= this.containers[i].element.outerWidth();
3754
				this.containers[i].containerCache.height = this.containers[i].element.outerHeight();
3755
			};
3756
		}
3757
 
3758
		return this;
3759
	},
3760
 
3761
	_createPlaceholder: function(that) {
3762
 
3763
		var self = that || this, o = self.options;
3764
 
3765
		if(!o.placeholder || o.placeholder.constructor == String) {
3766
			var className = o.placeholder;
3767
			o.placeholder = {
3768
				element: function() {
3769
 
3770
					var el = $(document.createElement(self.currentItem[0].nodeName))
3771
						.addClass(className || self.currentItem[0].className+" ui-sortable-placeholder")
3772
						.removeClass("ui-sortable-helper")[0];
3773
 
3774
					if(!className)
3775
						el.style.visibility = "hidden";
3776
 
3777
					return el;
3778
				},
3779
				update: function(container, p) {
3780
 
3781
					// 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that
3782
					// 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified
3783
					if(className && !o.forcePlaceholderSize) return;
3784
 
3785
					//If the element doesn't have a actual height by itself (without styles coming from a stylesheet), it receives the inline height from the dragged item
3786
					if(!p.height()) { p.height(self.currentItem.innerHeight() - parseInt(self.currentItem.css('paddingTop')||0, 10) - parseInt(self.currentItem.css('paddingBottom')||0, 10)); };
3787
					if(!p.width()) { p.width(self.currentItem.innerWidth() - parseInt(self.currentItem.css('paddingLeft')||0, 10) - parseInt(self.currentItem.css('paddingRight')||0, 10)); };
3788
				}
3789
			};
3790
		}
3791
 
3792
		//Create the placeholder
3793
		self.placeholder = $(o.placeholder.element.call(self.element, self.currentItem));
3794
 
3795
		//Append it after the actual current item
3796
		self.currentItem.after(self.placeholder);
3797
 
3798
		//Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
3799
		o.placeholder.update(self, self.placeholder);
3800
 
3801
	},
3802
 
3803
	_contactContainers: function(event) {
3804
 
3805
		// get innermost container that intersects with item
3806
		var innermostContainer = null, innermostIndex = null;
3807
 
3808
 
3809
		for (var i = this.containers.length - 1; i >= 0; i--){
3810
 
3811
			// never consider a container that's located within the item itself
3812
			if($.ui.contains(this.currentItem[0], this.containers[i].element[0]))
3813
				continue;
3814
 
3815
			if(this._intersectsWith(this.containers[i].containerCache)) {
3816
 
3817
				// if we've already found a container and it's more "inner" than this, then continue
3818
				if(innermostContainer && $.ui.contains(this.containers[i].element[0], innermostContainer.element[0]))
3819
					continue;
3820
 
3821
				innermostContainer = this.containers[i];
3822
				innermostIndex = i;
3823
 
3824
			} else {
3825
				// container doesn't intersect. trigger "out" event if necessary
3826
				if(this.containers[i].containerCache.over) {
3827
					this.containers[i]._trigger("out", event, this._uiHash(this));
3828
					this.containers[i].containerCache.over = 0;
3829
				}
3830
			}
3831
 
3832
		}
3833
 
3834
		// if no intersecting containers found, return
3835
		if(!innermostContainer) return;
3836
 
3837
		// move the item into the container if it's not there already
3838
		if(this.containers.length === 1) {
3839
			this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
3840
			this.containers[innermostIndex].containerCache.over = 1;
3841
		} else if(this.currentContainer != this.containers[innermostIndex]) {
3842
 
3843
			//When entering a new container, we will find the item with the least distance and append our item near it
3844
			var dist = 10000; var itemWithLeastDistance = null; var base = this.positionAbs[this.containers[innermostIndex].floating ? 'left' : 'top'];
3845
			for (var j = this.items.length - 1; j >= 0; j--) {
3846
				if(!$.ui.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) continue;
3847
				var cur = this.items[j][this.containers[innermostIndex].floating ? 'left' : 'top'];
3848
				if(Math.abs(cur - base) < dist) {
3849
					dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j];
3850
				}
3851
			}
3852
 
3853
			if(!itemWithLeastDistance && !this.options.dropOnEmpty) //Check if dropOnEmpty is enabled
3854
				return;
3855
 
3856
			this.currentContainer = this.containers[innermostIndex];
3857
			itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true);
3858
			this._trigger("change", event, this._uiHash());
3859
			this.containers[innermostIndex]._trigger("change", event, this._uiHash(this));
3860
 
3861
			//Update the placeholder
3862
			this.options.placeholder.update(this.currentContainer, this.placeholder);
3863
 
3864
			this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
3865
			this.containers[innermostIndex].containerCache.over = 1;
3866
		}
3867
 
3868
 
3869
	},
3870
 
3871
	_createHelper: function(event) {
3872
 
3873
		var o = this.options;
3874
		var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper == 'clone' ? this.currentItem.clone() : this.currentItem);
3875
 
3876
		if(!helper.parents('body').length) //Add the helper to the DOM if that didn't happen already
3877
			$(o.appendTo != 'parent' ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]);
3878
 
3879
		if(helper[0] == this.currentItem[0])
3880
			this._storedCSS = { width: this.currentItem[0].style.width, height: this.currentItem[0].style.height, position: this.currentItem.css("position"), top: this.currentItem.css("top"), left: this.currentItem.css("left") };
3881
 
3882
		if(helper[0].style.width == '' || o.forceHelperSize) helper.width(this.currentItem.width());
3883
		if(helper[0].style.height == '' || o.forceHelperSize) helper.height(this.currentItem.height());
3884
 
3885
		return helper;
3886
 
3887
	},
3888
 
3889
	_adjustOffsetFromHelper: function(obj) {
3890
		if (typeof obj == 'string') {
3891
			obj = obj.split(' ');
3892
		}
3893
		if ($.isArray(obj)) {
3894
			obj = {left: +obj[0], top: +obj[1] || 0};
3895
		}
3896
		if ('left' in obj) {
3897
			this.offset.click.left = obj.left + this.margins.left;
3898
		}
3899
		if ('right' in obj) {
3900
			this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
3901
		}
3902
		if ('top' in obj) {
3903
			this.offset.click.top = obj.top + this.margins.top;
3904
		}
3905
		if ('bottom' in obj) {
3906
			this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
3907
		}
3908
	},
3909
 
3910
	_getParentOffset: function() {
3911
 
3912
 
3913
		//Get the offsetParent and cache its position
3914
		this.offsetParent = this.helper.offsetParent();
3915
		var po = this.offsetParent.offset();
3916
 
3917
		// This is a special case where we need to modify a offset calculated on start, since the following happened:
3918
		// 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
3919
		// 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
3920
		//    the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
3921
		if(this.cssPosition == 'absolute' && this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) {
3922
			po.left += this.scrollParent.scrollLeft();
3923
			po.top += this.scrollParent.scrollTop();
3924
		}
3925
 
3926
		if((this.offsetParent[0] == document.body) //This needs to be actually done for all browsers, since pageX/pageY includes this information
3927
		|| (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.browser.msie)) //Ugly IE fix
3928
			po = { top: 0, left: 0 };
3929
 
3930
		return {
3931
			top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
3932
			left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
3933
		};
3934
 
3935
	},
3936
 
3937
	_getRelativeOffset: function() {
3938
 
3939
		if(this.cssPosition == "relative") {
3940
			var p = this.currentItem.position();
3941
			return {
3942
				top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
3943
				left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
3944
			};
3945
		} else {
3946
			return { top: 0, left: 0 };
3947
		}
3948
 
3949
	},
3950
 
3951
	_cacheMargins: function() {
3952
		this.margins = {
3953
			left: (parseInt(this.currentItem.css("marginLeft"),10) || 0),
3954
			top: (parseInt(this.currentItem.css("marginTop"),10) || 0)
3955
		};
3956
	},
3957
 
3958
	_cacheHelperProportions: function() {
3959
		this.helperProportions = {
3960
			width: this.helper.outerWidth(),
3961
			height: this.helper.outerHeight()
3962
		};
3963
	},
3964
 
3965
	_setContainment: function() {
3966
 
3967
		var o = this.options;
3968
		if(o.containment == 'parent') o.containment = this.helper[0].parentNode;
3969
		if(o.containment == 'document' || o.containment == 'window') this.containment = [
3970
 
3971
 
3972
			$(o.containment == 'document' ? document : window).width() - this.helperProportions.width - this.margins.left,
3973
			($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
3974
		];
3975
 
3976
		if(!(/^(document|window|parent)$/).test(o.containment)) {
3977
			var ce = $(o.containment)[0];
3978
			var co = $(o.containment).offset();
3979
			var over = ($(ce).css("overflow") != 'hidden');
3980
 
3981
			this.containment = [
3982
				co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
3983
				co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
3984
				co.left+(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left,
3985
				co.top+(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top
3986
			];
3987
		}
3988
 
3989
	},
3990
 
3991
	_convertPositionTo: function(d, pos) {
3992
 
3993
		if(!pos) pos = this.position;
3994
		var mod = d == "absolute" ? 1 : -1;
3995
		var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
3996
 
3997
		return {
3998
			top: (
3999
				pos.top																	// The absolute mouse position
4000
				+ this.offset.relative.top * mod										// Only for relative positioned nodes: Relative offset from element to offset parent
4001
				+ this.offset.parent.top * mod											// The offsetParent's offset without borders (offset + border)
4002
				- ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
4003
			),
4004
			left: (
4005
				pos.left																// The absolute mouse position
4006
				+ this.offset.relative.left * mod										// Only for relative positioned nodes: Relative offset from element to offset parent
4007
				+ this.offset.parent.left * mod											// The offsetParent's offset without borders (offset + border)
4008
				- ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
4009
			)
4010
		};
4011
 
4012
	},
4013
 
4014
	_generatePosition: function(event) {
4015
 
4016
		var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
4017
 
4018
		// This is another very weird special case that only happens for relative elements:
4019
		// 1. If the css position is relative
4020
		// 2. and the scroll parent is the document or similar to the offset parent
4021
		// we have to refresh the relative offset during the scroll so there are no jumps
4022
		if(this.cssPosition == 'relative' && !(this.scrollParent[0] != document && this.scrollParent[0] != this.offsetParent[0])) {
4023
			this.offset.relative = this._getRelativeOffset();
4024
		}
4025
 
4026
		var pageX = event.pageX;
4027
		var pageY = event.pageY;
4028
 
4029
		/*
4030
		 * - Position constraining -
4031
		 * Constrain the position to a mix of grid, containment.
4032
		 */
4033
 
4034
		if(this.originalPosition) { //If we are not dragging yet, we won't check for options
4035
 
4036
			if(this.containment) {
4037
				if(event.pageX - this.offset.click.left < this.containment[0]) pageX = this.containment[0] + this.offset.click.left;
4038
				if(event.pageY - this.offset.click.top < this.containment[1]) pageY = this.containment[1] + this.offset.click.top;
4039
				if(event.pageX - this.offset.click.left > this.containment[2]) pageX = this.containment[2] + this.offset.click.left;
4040
				if(event.pageY - this.offset.click.top > this.containment[3]) pageY = this.containment[3] + this.offset.click.top;
4041
			}
4042
 
4043
			if(o.grid) {
4044
				var top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
4045
				pageY = this.containment ? (!(top - this.offset.click.top < this.containment[1] || top - this.offset.click.top > this.containment[3]) ? top : (!(top - this.offset.click.top < this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
4046
 
4047
				var left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
4048
				pageX = this.containment ? (!(left - this.offset.click.left < this.containment[0] || left - this.offset.click.left > this.containment[2]) ? left : (!(left - this.offset.click.left < this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
4049
			}
4050
 
4051
		}
4052
 
4053
		return {
4054
			top: (
4055
				pageY																// The absolute mouse position
4056
				- this.offset.click.top													// Click offset (relative to the element)
4057
				- this.offset.relative.top												// Only for relative positioned nodes: Relative offset from element to offset parent
4058
				- this.offset.parent.top												// The offsetParent's offset without borders (offset + border)
4059
				+ ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
4060
			),
4061
			left: (
4062
				pageX																// The absolute mouse position
4063
				- this.offset.click.left												// Click offset (relative to the element)
4064
				- this.offset.relative.left												// Only for relative positioned nodes: Relative offset from element to offset parent
4065
				- this.offset.parent.left												// The offsetParent's offset without borders (offset + border)
4066
				+ ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
4067
			)
4068
		};
4069
 
4070
	},
4071
 
4072
	_rearrange: function(event, i, a, hardRefresh) {
4073
 
4074
		a ? a[0].appendChild(this.placeholder[0]) : i.item[0].parentNode.insertBefore(this.placeholder[0], (this.direction == 'down' ? i.item[0] : i.item[0].nextSibling));
4075
 
4076
		//Various things done here to improve the performance:
4077
		// 1. we create a setTimeout, that calls refreshPositions
4078
		// 2. on the instance, we have a counter variable, that get's higher after every append
4079
		// 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same
4080
		// 4. this lets only the last addition to the timeout stack through
4081
		this.counter = this.counter ? ++this.counter : 1;
4082
		var self = this, counter = this.counter;
4083
 
4084
		window.setTimeout(function() {
4085
			if(counter == self.counter) self.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
4086
		},0);
4087
 
4088
	},
4089
 
4090
	_clear: function(event, noPropagation) {
4091
 
4092
		this.reverting = false;
4093
		// We delay all events that have to be triggered to after the point where the placeholder has been removed and
4094
		// everything else normalized again
4095
		var delayedTriggers = [], self = this;
4096
 
4097
		// We first have to update the dom position of the actual currentItem
4098
		// Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088)
4099
		if(!this._noFinalSort && this.currentItem[0].parentNode) this.placeholder.before(this.currentItem);
4100
		this._noFinalSort = null;
4101
 
4102
		if(this.helper[0] == this.currentItem[0]) {
4103
			for(var i in this._storedCSS) {
4104
				if(this._storedCSS[i] == 'auto' || this._storedCSS[i] == 'static') this._storedCSS[i] = '';
4105
			}
4106
			this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
4107
		} else {
4108
			this.currentItem.show();
4109
		}
4110
 
4111
		if(this.fromOutside && !noPropagation) delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); });
4112
		if((this.fromOutside || this.domPosition.prev != this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent != this.currentItem.parent()[0]) && !noPropagation) delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed
4113
		if(!$.ui.contains(this.element[0], this.currentItem[0])) { //Node was moved out of the current element
4114
			if(!noPropagation) delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
4115
			for (var i = this.containers.length - 1; i >= 0; i--){
4116
				if($.ui.contains(this.containers[i].element[0], this.currentItem[0]) && !noPropagation) {
4117
					delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); };  }).call(this, this.containers[i]));
4118
					delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this));  }; }).call(this, this.containers[i]));
4119
				}
4120
			};
4121
		};
4122
 
4123
		//Post events to containers
4124
		for (var i = this.containers.length - 1; i >= 0; i--){
4125
			if(!noPropagation) delayedTriggers.push((function(c) { return function(event) { c._trigger("deactivate", event, this._uiHash(this)); };  }).call(this, this.containers[i]));
4126
			if(this.containers[i].containerCache.over) {
4127
				delayedTriggers.push((function(c) { return function(event) { c._trigger("out", event, this._uiHash(this)); };  }).call(this, this.containers[i]));
4128
				this.containers[i].containerCache.over = 0;
4129
			}
4130
		}
4131
 
4132
		//Do what was originally in plugins
4133
		if(this._storedCursor) $('body').css("cursor", this._storedCursor); //Reset cursor
4134
		if(this._storedOpacity) this.helper.css("opacity", this._storedOpacity); //Reset opacity
4135
		if(this._storedZIndex) this.helper.css("zIndex", this._storedZIndex == 'auto' ? '' : this._storedZIndex); //Reset z-index
4136
 
4137
		this.dragging = false;
4138
		if(this.cancelHelperRemoval) {
4139
			if(!noPropagation) {
4140
				this._trigger("beforeStop", event, this._uiHash());
4141
				for (var i=0; i < delayedTriggers.length; i++) { delayedTriggers[i].call(this, event); }; //Trigger all delayed events
4142
				this._trigger("stop", event, this._uiHash());
4143
			}
4144
			return false;
4145
		}
4146
 
4147
		if(!noPropagation) this._trigger("beforeStop", event, this._uiHash());
4148
 
4149
		//$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
4150
		this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
4151
 
4152
		if(this.helper[0] != this.currentItem[0]) this.helper.remove(); this.helper = null;
4153
 
4154
		if(!noPropagation) {
4155
			for (var i=0; i < delayedTriggers.length; i++) { delayedTriggers[i].call(this, event); }; //Trigger all delayed events
4156
			this._trigger("stop", event, this._uiHash());
4157
		}
4158
 
4159
		this.fromOutside = false;
4160
		return true;
4161
 
4162
	},
4163
 
4164
	_trigger: function() {
4165
		if ($.Widget.prototype._trigger.apply(this, arguments) === false) {
4166
			this.cancel();
4167
		}
4168
	},
4169
 
4170
	_uiHash: function(inst) {
4171
		var self = inst || this;
4172
		return {
4173
			helper: self.helper,
4174
			placeholder: self.placeholder || $([]),
4175
			position: self.position,
4176
			originalPosition: self.originalPosition,
4177
			offset: self.positionAbs,
4178
			item: self.currentItem,
4179
			sender: inst ? inst.element : null
4180
		};
4181
	}
4182
 
4183
});
4184
 
4185
$.extend($.ui.sortable, {
4186
	version: "1.8.5"
4187
});
4188
 
4189
})(jQuery);
4190
/*
4191
 * jQuery UI Accordion 1.8.5
4192
 *
4193
 * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
4194
 * Dual licensed under the MIT or GPL Version 2 licenses.
4195
 * http://jquery.org/license
4196
 *
4197
 * http://docs.jquery.com/UI/Accordion
4198
 *
4199
 * Depends:
4200
 *	jquery.ui.core.js
4201
 *	jquery.ui.widget.js
4202
 */
4203
(function( $, undefined ) {
4204
 
4205
$.widget( "ui.accordion", {
4206
	options: {
4207
		active: 0,
4208
		animated: "slide",
4209
		autoHeight: true,
4210
		clearStyle: false,
4211
		collapsible: false,
4212
		event: "click",
4213
		fillSpace: false,
4214
		header: "> li > :first-child,> :not(li):even",
4215
		icons: {
4216
			header: "ui-icon-triangle-1-e",
4217
			headerSelected: "ui-icon-triangle-1-s"
4218
		},
4219
		navigation: false,
4220
		navigationFilter: function() {
4221
			return this.href.toLowerCase() === location.href.toLowerCase();
4222
		}
4223
	},
4224
 
4225
	_create: function() {
4226
		var self = this,
4227
			options = self.options;
4228
 
4229
		self.running = 0;
4230
 
4231
		self.element
4232
			.addClass( "ui-accordion ui-widget ui-helper-reset" )
4233
			// in lack of child-selectors in CSS
4234
			// we need to mark top-LIs in a UL-accordion for some IE-fix
4235
			.children( "li" )
4236
				.addClass( "ui-accordion-li-fix" );
4237
 
4238
		self.headers = self.element.find( options.header )
4239
			.addClass( "ui-accordion-header ui-helper-reset ui-state-default ui-corner-all" )
4240
			.bind( "mouseenter.accordion", function() {
4241
				if ( options.disabled ) {
4242
					return;
4243
				}
4244
				$( this ).addClass( "ui-state-hover" );
4245
			})
4246
			.bind( "mouseleave.accordion", function() {
4247
				if ( options.disabled ) {
4248
					return;
4249
				}
4250
				$( this ).removeClass( "ui-state-hover" );
4251
			})
4252
			.bind( "focus.accordion", function() {
4253
				if ( options.disabled ) {
4254
					return;
4255
				}
4256
				$( this ).addClass( "ui-state-focus" );
4257
			})
4258
			.bind( "blur.accordion", function() {
4259
				if ( options.disabled ) {
4260
					return;
4261
				}
4262
				$( this ).removeClass( "ui-state-focus" );
4263
			});
4264
 
4265
		self.headers.next()
4266
			.addClass( "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" );
4267
 
4268
		if ( options.navigation ) {
4269
			var current = self.element.find( "a" ).filter( options.navigationFilter ).eq( 0 );
4270
			if ( current.length ) {
4271
				var header = current.closest( ".ui-accordion-header" );
4272
				if ( header.length ) {
4273
					// anchor within header
4274
					self.active = header;
4275
				} else {
4276
					// anchor within content
4277
					self.active = current.closest( ".ui-accordion-content" ).prev();
4278
				}
4279
			}
4280
		}
4281
 
4282
		self.active = self._findActive( self.active || options.active )
4283
			.addClass( "ui-state-default ui-state-active" )
4284
			.toggleClass( "ui-corner-all ui-corner-top" );
4285
		self.active.next().addClass( "ui-accordion-content-active" );
4286
 
4287
		self._createIcons();
4288
		self.resize();
4289
 
4290
		// ARIA
4291
		self.element.attr( "role", "tablist" );
4292
 
4293
		self.headers
4294
			.attr( "role", "tab" )
4295
			.bind( "keydown.accordion", function( event ) {
4296
				return self._keydown( event );
4297
			})
4298
			.next()
4299
				.attr( "role", "tabpanel" );
4300
 
4301
		self.headers
4302
			.not( self.active || "" )
4303
			.attr({
4304
				"aria-expanded": "false",
4305
				tabIndex: -1
4306
			})
4307
			.next()
4308
				.hide();
4309
 
4310
		// make sure at least one header is in the tab order
4311
		if ( !self.active.length ) {
4312
			self.headers.eq( 0 ).attr( "tabIndex", 0 );
4313
		} else {
4314
			self.active
4315
				.attr({
4316
					"aria-expanded": "true",
4317
					tabIndex: 0
4318
				});
4319
		}
4320
 
4321
		// only need links in tab order for Safari
4322
		if ( !$.browser.safari ) {
4323
			self.headers.find( "a" ).attr( "tabIndex", -1 );
4324
		}
4325
 
4326
		if ( options.event ) {
4327
			self.headers.bind( options.event.split(" ").join(".accordion ") + ".accordion", function(event) {
4328
				self._clickHandler.call( self, event, this );
4329
				event.preventDefault();
4330
			});
4331
		}
4332
	},
4333
 
4334
	_createIcons: function() {
4335
		var options = this.options;
4336
		if ( options.icons ) {
4337
			$( "<span></span>" )
4338
				.addClass( "ui-icon " + options.icons.header )
4339
				.prependTo( this.headers );
4340
			this.active.children( ".ui-icon" )
4341
				.toggleClass(options.icons.header)
4342
				.toggleClass(options.icons.headerSelected);
4343
			this.element.addClass( "ui-accordion-icons" );
4344
		}
4345
	},
4346
 
4347
	_destroyIcons: function() {
4348
		this.headers.children( ".ui-icon" ).remove();
4349
		this.element.removeClass( "ui-accordion-icons" );
4350
	},
4351
 
4352
	destroy: function() {
4353
		var options = this.options;
4354
 
4355
		this.element
4356
			.removeClass( "ui-accordion ui-widget ui-helper-reset" )
4357
			.removeAttr( "role" );
4358
 
4359
		this.headers
4360
			.unbind( ".accordion" )
4361
			.removeClass( "ui-accordion-header ui-accordion-disabled ui-helper-reset ui-state-default ui-corner-all ui-state-active ui-state-disabled ui-corner-top" )
4362
			.removeAttr( "role" )
4363
			.removeAttr( "aria-expanded" )
4364
			.removeAttr( "tabIndex" );
4365
 
4366
		this.headers.find( "a" ).removeAttr( "tabIndex" );
4367
		this._destroyIcons();
4368
		var contents = this.headers.next()
4369
			.css( "display", "" )
4370
			.removeAttr( "role" )
4371
			.removeClass( "ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-accordion-disabled ui-state-disabled" );
4372
		if ( options.autoHeight || options.fillHeight ) {
4373
			contents.css( "height", "" );
4374
		}
4375
 
4376
		return $.Widget.prototype.destroy.call( this );
4377
	},
4378
 
4379
	_setOption: function( key, value ) {
4380
		$.Widget.prototype._setOption.apply( this, arguments );
4381
 
4382
		if ( key == "active" ) {
4383
			this.activate( value );
4384
		}
4385
		if ( key == "icons" ) {
4386
			this._destroyIcons();
4387
			if ( value ) {
4388
				this._createIcons();
4389
			}
4390
		}
4391
		// #5332 - opacity doesn't cascade to positioned elements in IE
4392
		// so we need to add the disabled class to the headers and panels
4393
		if ( key == "disabled" ) {
4394
			this.headers.add(this.headers.next())
4395
				[ value ? "addClass" : "removeClass" ](
4396
					"ui-accordion-disabled ui-state-disabled" );
4397
		}
4398
	},
4399
 
4400
	_keydown: function( event ) {
4401
		if ( this.options.disabled || event.altKey || event.ctrlKey ) {
4402
			return;
4403
		}
4404
 
4405
		var keyCode = $.ui.keyCode,
4406
			length = this.headers.length,
4407
			currentIndex = this.headers.index( event.target ),
4408
			toFocus = false;
4409
 
4410
		switch ( event.keyCode ) {
4411
			case keyCode.RIGHT:
4412
			case keyCode.DOWN:
4413
				toFocus = this.headers[ ( currentIndex + 1 ) % length ];
4414
				break;
4415
			case keyCode.LEFT:
4416
			case keyCode.UP:
4417
				toFocus = this.headers[ ( currentIndex - 1 + length ) % length ];
4418
				break;
4419
			case keyCode.SPACE:
4420
			case keyCode.ENTER:
4421
				this._clickHandler( { target: event.target }, event.target );
4422
				event.preventDefault();
4423
		}
4424
 
4425
		if ( toFocus ) {
4426
			$( event.target ).attr( "tabIndex", -1 );
4427
			$( toFocus ).attr( "tabIndex", 0 );
4428
			toFocus.focus();
4429
			return false;
4430
		}
4431
 
4432
		return true;
4433
	},
4434
 
4435
	resize: function() {
4436
		var options = this.options,
4437
			maxHeight;
4438
 
4439
		if ( options.fillSpace ) {
4440
			if ( $.browser.msie ) {
4441
				var defOverflow = this.element.parent().css( "overflow" );
4442
				this.element.parent().css( "overflow", "hidden");
4443
			}
4444
			maxHeight = this.element.parent().height();
4445
			if ($.browser.msie) {
4446
				this.element.parent().css( "overflow", defOverflow );
4447
			}
4448
 
4449
			this.headers.each(function() {
4450
				maxHeight -= $( this ).outerHeight( true );
4451
			});
4452
 
4453
			this.headers.next()
4454
				.each(function() {
4455
					$( this ).height( Math.max( 0, maxHeight -
4456
						$( this ).innerHeight() + $( this ).height() ) );
4457
				})
4458
				.css( "overflow", "auto" );
4459
		} else if ( options.autoHeight ) {
4460
			maxHeight = 0;
4461
			this.headers.next()
4462
				.each(function() {
4463
					maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() );
4464
				})
4465
				.height( maxHeight );
4466
		}
4467
 
4468
		return this;
4469
	},
4470
 
4471
	activate: function( index ) {
4472
		// TODO this gets called on init, changing the option without an explicit call for that
4473
		this.options.active = index;
4474
		// call clickHandler with custom event
4475
		var active = this._findActive( index )[ 0 ];
4476
		this._clickHandler( { target: active }, active );
4477
 
4478
		return this;
4479
	},
4480
 
4481
	_findActive: function( selector ) {
4482
		return selector
4483
			? typeof selector === "number"
4484
				? this.headers.filter( ":eq(" + selector + ")" )
4485
				: this.headers.not( this.headers.not( selector ) )
4486
			: selector === false
4487
				? $( [] )
4488
				: this.headers.filter( ":eq(0)" );
4489
	},
4490
 
4491
	// TODO isn't event.target enough? why the separate target argument?
4492
	_clickHandler: function( event, target ) {
4493
		var options = this.options;
4494
		if ( options.disabled ) {
4495
			return;
4496
		}
4497
 
4498
		// called only when using activate(false) to close all parts programmatically
4499
		if ( !event.target ) {
4500
			if ( !options.collapsible ) {
4501
				return;
4502
			}
4503
			this.active
4504
				.removeClass( "ui-state-active ui-corner-top" )
4505
				.addClass( "ui-state-default ui-corner-all" )
4506
				.children( ".ui-icon" )
4507
					.removeClass( options.icons.headerSelected )
4508
					.addClass( options.icons.header );
4509
			this.active.next().addClass( "ui-accordion-content-active" );
4510
			var toHide = this.active.next(),
4511
				data = {
4512
					options: options,
4513
					newHeader: $( [] ),
4514
					oldHeader: options.active,
4515
					newContent: $( [] ),
4516
					oldContent: toHide
4517
				},
4518
				toShow = ( this.active = $( [] ) );
4519
			this._toggle( toShow, toHide, data );
4520
			return;
4521
		}
4522
 
4523
		// get the click target
4524
		var clicked = $( event.currentTarget || target ),
4525
			clickedIsActive = clicked[0] === this.active[0];
4526
 
4527
		// TODO the option is changed, is that correct?
4528
		// TODO if it is correct, shouldn't that happen after determining that the click is valid?
4529
		options.active = options.collapsible && clickedIsActive ?
4530
			false :
4531
			this.headers.index( clicked );
4532
 
4533
		// if animations are still active, or the active header is the target, ignore click
4534
		if ( this.running || ( !options.collapsible && clickedIsActive ) ) {
4535
			return;
4536
		}
4537
 
4538
		// switch classes
4539
		this.active
4540
			.removeClass( "ui-state-active ui-corner-top" )
4541
			.addClass( "ui-state-default ui-corner-all" )
4542
			.children( ".ui-icon" )
4543
				.removeClass( options.icons.headerSelected )
4544
				.addClass( options.icons.header );
4545
		if ( !clickedIsActive ) {
4546
			clicked
4547
				.removeClass( "ui-state-default ui-corner-all" )
4548
				.addClass( "ui-state-active ui-corner-top" )
4549
				.children( ".ui-icon" )
4550
					.removeClass( options.icons.header )
4551
					.addClass( options.icons.headerSelected );
4552
			clicked
4553
				.next()
4554
				.addClass( "ui-accordion-content-active" );
4555
		}
4556
 
4557
		// find elements to show and hide
4558
		var toShow = clicked.next(),
4559
			toHide = this.active.next(),
4560
			data = {
4561
				options: options,
4562
				newHeader: clickedIsActive && options.collapsible ? $([]) : clicked,
4563
				oldHeader: this.active,
4564
				newContent: clickedIsActive && options.collapsible ? $([]) : toShow,
4565
				oldContent: toHide
4566
			},
4567
			down = this.headers.index( this.active[0] ) > this.headers.index( clicked[0] );
4568
 
4569
		this.active = clickedIsActive ? $([]) : clicked;
4570
		this._toggle( toShow, toHide, data, clickedIsActive, down );
4571
 
4572
		return;
4573
	},
4574
 
4575
	_toggle: function( toShow, toHide, data, clickedIsActive, down ) {
4576
		var self = this,
4577
			options = self.options;
4578
 
4579
		self.toShow = toShow;
4580
		self.toHide = toHide;
4581
		self.data = data;
4582
 
4583
		var complete = function() {
4584
			if ( !self ) {
4585
				return;
4586
			}
4587
			return self._completed.apply( self, arguments );
4588
		};
4589
 
4590
		// trigger changestart event
4591
		self._trigger( "changestart", null, self.data );
4592
 
4593
		// count elements to animate
4594
		self.running = toHide.size() === 0 ? toShow.size() : toHide.size();
4595
 
4596
		if ( options.animated ) {
4597
			var animOptions = {};
4598
 
4599
			if ( options.collapsible && clickedIsActive ) {
4600
				animOptions = {
4601
					toShow: $( [] ),
4602
					toHide: toHide,
4603
					complete: complete,
4604
					down: down,
4605
					autoHeight: options.autoHeight || options.fillSpace
4606
				};
4607
			} else {
4608
				animOptions = {
4609
					toShow: toShow,
4610
					toHide: toHide,
4611
					complete: complete,
4612
					down: down,
4613
					autoHeight: options.autoHeight || options.fillSpace
4614
				};
4615
			}
4616
 
4617
			if ( !options.proxied ) {
4618
				options.proxied = options.animated;
4619
			}
4620
 
4621
			if ( !options.proxiedDuration ) {
4622
				options.proxiedDuration = options.duration;
4623
			}
4624
 
4625
			options.animated = $.isFunction( options.proxied ) ?
4626
				options.proxied( animOptions ) :
4627
				options.proxied;
4628
 
4629
			options.duration = $.isFunction( options.proxiedDuration ) ?
4630
				options.proxiedDuration( animOptions ) :
4631
				options.proxiedDuration;
4632
 
4633
			var animations = $.ui.accordion.animations,
4634
				duration = options.duration,
4635
				easing = options.animated;
4636
 
4637
			if ( easing && !animations[ easing ] && !$.easing[ easing ] ) {
4638
				easing = "slide";
4639
			}
4640
			if ( !animations[ easing ] ) {
4641
				animations[ easing ] = function( options ) {
4642
					this.slide( options, {
4643
						easing: easing,
4644
						duration: duration || 700
4645
					});
4646
				};
4647
			}
4648
 
4649
			animations[ easing ]( animOptions );
4650
		} else {
4651
			if ( options.collapsible && clickedIsActive ) {
4652
				toShow.toggle();
4653
			} else {
4654
				toHide.hide();
4655
				toShow.show();
4656
			}
4657
 
4658
			complete( true );
4659
		}
4660
 
4661
		// TODO assert that the blur and focus triggers are really necessary, remove otherwise
4662
		toHide.prev()
4663
			.attr({
4664
				"aria-expanded": "false",
4665
				tabIndex: -1
4666
			})
4667
			.blur();
4668
		toShow.prev()
4669
			.attr({
4670
				"aria-expanded": "true",
4671
				tabIndex: 0
4672
			})
4673
			.focus();
4674
	},
4675
 
4676
	_completed: function( cancel ) {
4677
		this.running = cancel ? 0 : --this.running;
4678
		if ( this.running ) {
4679
			return;
4680
		}
4681
 
4682
		if ( this.options.clearStyle ) {
4683
			this.toShow.add( this.toHide ).css({
4684
				height: "",
4685
				overflow: ""
4686
			});
4687
		}
4688
 
4689
		// other classes are removed before the animation; this one needs to stay until completed
4690
		this.toHide.removeClass( "ui-accordion-content-active" );
4691
 
4692
		this._trigger( "change", null, this.data );
4693
	}
4694
});
4695
 
4696
$.extend( $.ui.accordion, {
4697
	version: "1.8.5",
4698
	animations: {
4699
		slide: function( options, additions ) {
4700
			options = $.extend({
4701
				easing: "swing",
4702
				duration: 300
4703
			}, options, additions );
4704
			if ( !options.toHide.size() ) {
4705
				options.toShow.animate({
4706
					height: "show",
4707
					paddingTop: "show",
4708
					paddingBottom: "show"
4709
				}, options );
4710
				return;
4711
			}
4712
			if ( !options.toShow.size() ) {
4713
				options.toHide.animate({
4714
					height: "hide",
4715
					paddingTop: "hide",
4716
					paddingBottom: "hide"
4717
				}, options );
4718
				return;
4719
			}
4720
			var overflow = options.toShow.css( "overflow" ),
4721
				percentDone = 0,
4722
				showProps = {},
4723
				hideProps = {},
4724
				fxAttrs = [ "height", "paddingTop", "paddingBottom" ],
4725
				originalWidth;
4726
			// fix width before calculating height of hidden element
4727
			var s = options.toShow;
4728
			originalWidth = s[0].style.width;
4729
			s.width( parseInt( s.parent().width(), 10 )
4730
				- parseInt( s.css( "paddingLeft" ), 10 )
4731
				- parseInt( s.css( "paddingRight" ), 10 )
4732
				- ( parseInt( s.css( "borderLeftWidth" ), 10 ) || 0 )
4733
				- ( parseInt( s.css( "borderRightWidth" ), 10) || 0 ) );
4734
 
4735
			$.each( fxAttrs, function( i, prop ) {
4736
				hideProps[ prop ] = "hide";
4737
 
4738
				var parts = ( "" + $.css( options.toShow[0], prop ) ).match( /^([\d+-.]+)(.*)$/ );
4739
				showProps[ prop ] = {
4740
					value: parts[ 1 ],
4741
					unit: parts[ 2 ] || "px"
4742
				};
4743
			});
4744
			options.toShow.css({ height: 0, overflow: "hidden" }).show();
4745
			options.toHide
4746
				.filter( ":hidden" )
4747
					.each( options.complete )
4748
				.end()
4749
				.filter( ":visible" )
4750
				.animate( hideProps, {
4751
				step: function( now, settings ) {
4752
					// only calculate the percent when animating height
4753
					// IE gets very inconsistent results when animating elements
4754
					// with small values, which is common for padding
4755
					if ( settings.prop == "height" ) {
4756
						percentDone = ( settings.end - settings.start === 0 ) ? 0 :
4757
							( settings.now - settings.start ) / ( settings.end - settings.start );
4758
					}
4759
 
4760
					options.toShow[ 0 ].style[ settings.prop ] =
4761
						( percentDone * showProps[ settings.prop ].value )
4762
						+ showProps[ settings.prop ].unit;
4763
				},
4764
				duration: options.duration,
4765
				easing: options.easing,
4766
				complete: function() {
4767
					if ( !options.autoHeight ) {
4768
						options.toShow.css( "height", "" );
4769
					}
4770
					options.toShow.css({
4771
						width: originalWidth,
4772
						overflow: overflow
4773
					});
4774
					options.complete();
4775
				}
4776
			});
4777
		},
4778
		bounceslide: function( options ) {
4779
			this.slide( options, {
4780
				easing: options.down ? "easeOutBounce" : "swing",
4781
				duration: options.down ? 1000 : 200
4782
			});
4783
		}
4784
	}
4785
});
4786
 
4787
})( jQuery );
4788
/*
4789
 * jQuery UI Autocomplete 1.8.5
4790
 *
4791
 * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
4792
 * Dual licensed under the MIT or GPL Version 2 licenses.
4793
 * http://jquery.org/license
4794
 *
4795
 * http://docs.jquery.com/UI/Autocomplete
4796
 *
4797
 * Depends:
4798
 *	jquery.ui.core.js
4799
 *	jquery.ui.widget.js
4800
 *	jquery.ui.position.js
4801
 */
4802
(function( $, undefined ) {
4803
 
4804
$.widget( "ui.autocomplete", {
4805
	options: {
4806
		appendTo: "body",
4807
		delay: 300,
4808
		minLength: 1,
4809
		position: {
4810
			my: "left top",
4811
			at: "left bottom",
4812
			collision: "none"
4813
		},
4814
		source: null
4815
	},
4816
	_create: function() {
4817
		var self = this,
4818
			doc = this.element[ 0 ].ownerDocument;
4819
		this.element
4820
			.addClass( "ui-autocomplete-input" )
4821
			.attr( "autocomplete", "off" )
4822
			// TODO verify these actually work as intended
4823
			.attr({
4824
				role: "textbox",
4825
				"aria-autocomplete": "list",
4826
				"aria-haspopup": "true"
4827
			})
4828
			.bind( "keydown.autocomplete", function( event ) {
4829
				if ( self.options.disabled ) {
4830
					return;
4831
				}
4832
 
4833
				var keyCode = $.ui.keyCode;
4834
				switch( event.keyCode ) {
4835
				case keyCode.PAGE_UP:
4836
					self._move( "previousPage", event );
4837
					break;
4838
				case keyCode.PAGE_DOWN:
4839
					self._move( "nextPage", event );
4840
					break;
4841
				case keyCode.UP:
4842
					self._move( "previous", event );
4843
					// prevent moving cursor to beginning of text field in some browsers
4844
					event.preventDefault();
4845
					break;
4846
				case keyCode.DOWN:
4847
					self._move( "next", event );
4848
					// prevent moving cursor to end of text field in some browsers
4849
					event.preventDefault();
4850
					break;
4851
				case keyCode.ENTER:
4852
				case keyCode.NUMPAD_ENTER:
4853
					// when menu is open or has focus
4854
					if ( self.menu.element.is( ":visible" ) ) {
4855
						event.preventDefault();
4856
					}
4857
					//passthrough - ENTER and TAB both select the current element
4858
				case keyCode.TAB:
4859
					if ( !self.menu.active ) {
4860
						return;
4861
					}
4862
					self.menu.select( event );
4863
					break;
4864
				case keyCode.ESCAPE:
4865
					self.element.val( self.term );
4866
					self.close( event );
4867
					break;
4868
				default:
4869
					// keypress is triggered before the input value is changed
4870
					clearTimeout( self.searching );
4871
					self.searching = setTimeout(function() {
4872
						// only search if the value has changed
4873
						if ( self.term != self.element.val() ) {
4874
							self.selectedItem = null;
4875
							self.search( null, event );
4876
						}
4877
					}, self.options.delay );
4878
					break;
4879
				}
4880
			})
4881
			.bind( "focus.autocomplete", function() {
4882
				if ( self.options.disabled ) {
4883
					return;
4884
				}
4885
 
4886
				self.selectedItem = null;
4887
				self.previous = self.element.val();
4888
			})
4889
			.bind( "blur.autocomplete", function( event ) {
4890
				if ( self.options.disabled ) {
4891
					return;
4892
				}
4893
 
4894
				clearTimeout( self.searching );
4895
				// clicks on the menu (or a button to trigger a search) will cause a blur event
4896
				self.closing = setTimeout(function() {
4897
					self.close( event );
4898
					self._change( event );
4899
				}, 150 );
4900
			});
4901
		this._initSource();
4902
		this.response = function() {
4903
			return self._response.apply( self, arguments );
4904
		};
4905
		this.menu = $( "<ul></ul>" )
4906
			.addClass( "ui-autocomplete" )
4907
			.appendTo( $( this.options.appendTo || "body", doc )[0] )
4908
			// prevent the close-on-blur in case of a "slow" click on the menu (long mousedown)
4909
			.mousedown(function( event ) {
4910
				// clicking on the scrollbar causes focus to shift to the body
4911
				// but we can't detect a mouseup or a click immediately afterward
4912
				// so we have to track the next mousedown and close the menu if
4913
				// the user clicks somewhere outside of the autocomplete
4914
				var menuElement = self.menu.element[ 0 ];
4915
				if ( event.target === menuElement ) {
4916
					setTimeout(function() {
4917
						$( document ).one( 'mousedown', function( event ) {
4918
							if ( event.target !== self.element[ 0 ] &&
4919
								event.target !== menuElement &&
4920
								!$.ui.contains( menuElement, event.target ) ) {
4921
								self.close();
4922
							}
4923
						});
4924
					}, 1 );
4925
				}
4926
 
4927
				// use another timeout to make sure the blur-event-handler on the input was already triggered
4928
				setTimeout(function() {
4929
					clearTimeout( self.closing );
4930
				}, 13);
4931
			})
4932
			.menu({
4933
				focus: function( event, ui ) {
4934
					var item = ui.item.data( "item.autocomplete" );
4935
					if ( false !== self._trigger( "focus", null, { item: item } ) ) {
4936
						// use value to match what will end up in the input, if it was a key event
4937
						if ( /^key/.test(event.originalEvent.type) ) {
4938
							self.element.val( item.value );
4939
						}
4940
					}
4941
				},
4942
				selected: function( event, ui ) {
4943
					var item = ui.item.data( "item.autocomplete" ),
4944
						previous = self.previous;
4945
 
4946
					// only trigger when focus was lost (click on menu)
4947
					if ( self.element[0] !== doc.activeElement ) {
4948
						self.element.focus();
4949
						self.previous = previous;
4950
					}
4951
 
4952
					if ( false !== self._trigger( "select", event, { item: item } ) ) {
4953
						self.term = item.value;
4954
						self.element.val( item.value );
4955
					}
4956
 
4957
					self.close( event );
4958
					self.selectedItem = item;
4959
				},
4960
				blur: function( event, ui ) {
4961
					// don't set the value of the text field if it's already correct
4962
					// this prevents moving the cursor unnecessarily
4963
					if ( self.menu.element.is(":visible") &&
4964
						( self.element.val() !== self.term ) ) {
4965
						self.element.val( self.term );
4966
					}
4967
				}
4968
			})
4969
			.zIndex( this.element.zIndex() + 1 )
4970
			// workaround for jQuery bug #5781 http://dev.jquery.com/ticket/5781
4971
			.css({ top: 0, left: 0 })
4972
			.hide()
4973
			.data( "menu" );
4974
		if ( $.fn.bgiframe ) {
4975
			 this.menu.element.bgiframe();
4976
		}
4977
	},
4978
 
4979
	destroy: function() {
4980
		this.element
4981
			.removeClass( "ui-autocomplete-input" )
4982
			.removeAttr( "autocomplete" )
4983
			.removeAttr( "role" )
4984
			.removeAttr( "aria-autocomplete" )
4985
			.removeAttr( "aria-haspopup" );
4986
		this.menu.element.remove();
4987
		$.Widget.prototype.destroy.call( this );
4988
	},
4989
 
4990
	_setOption: function( key, value ) {
4991
		$.Widget.prototype._setOption.apply( this, arguments );
4992
		if ( key === "source" ) {
4993
			this._initSource();
4994
		}
4995
		if ( key === "appendTo" ) {
4996
			this.menu.element.appendTo( $( value || "body", this.element[0].ownerDocument )[0] )
4997
		}
4998
	},
4999
 
5000
	_initSource: function() {
5001
		var self = this,
5002
			array,
5003
			url;
5004
		if ( $.isArray(this.options.source) ) {
5005
			array = this.options.source;
5006
			this.source = function( request, response ) {
5007
				response( $.ui.autocomplete.filter(array, request.term) );
5008
			};
5009
		} else if ( typeof this.options.source === "string" ) {
5010
			url = this.options.source;
5011
			this.source = function( request, response ) {
5012
				if (self.xhr) {
5013
					self.xhr.abort();
5014
				}
5015
				self.xhr = $.getJSON( url, request, function( data, status, xhr ) {
5016
					if ( xhr === self.xhr ) {
5017
						response( data );
5018
					}
5019
					self.xhr = null;
5020
				});
5021
			};
5022
		} else {
5023
			this.source = this.options.source;
5024
		}
5025
	},
5026
 
5027
	search: function( value, event ) {
5028
		value = value != null ? value : this.element.val();
5029
 
5030
		// always save the actual value, not the one passed as an argument
5031
		this.term = this.element.val();
5032
 
5033
		if ( value.length < this.options.minLength ) {
5034
			return this.close( event );
5035
		}
5036
 
5037
		clearTimeout( this.closing );
5038
		if ( this._trigger("search") === false ) {
5039
			return;
5040
		}
5041
 
5042
		return this._search( value );
5043
	},
5044
 
5045
	_search: function( value ) {
5046
		this.element.addClass( "ui-autocomplete-loading" );
5047
 
5048
		this.source( { term: value }, this.response );
5049
	},
5050
 
5051
	_response: function( content ) {
5052
		if ( content.length ) {
5053
			content = this._normalize( content );
5054
			this._suggest( content );
5055
			this._trigger( "open" );
5056
		} else {
5057
			this.close();
5058
		}
5059
		this.element.removeClass( "ui-autocomplete-loading" );
5060
	},
5061
 
5062
	close: function( event ) {
5063
		clearTimeout( this.closing );
5064
		if ( this.menu.element.is(":visible") ) {
5065
			this._trigger( "close", event );
5066
			this.menu.element.hide();
5067
			this.menu.deactivate();
5068
		}
5069
	},
5070
 
5071
	_change: function( event ) {
5072
		if ( this.previous !== this.element.val() ) {
5073
			this._trigger( "change", event, { item: this.selectedItem } );
5074
		}
5075
	},
5076
 
5077
	_normalize: function( items ) {
5078
		// assume all items have the right format when the first item is complete
5079
		if ( items.length && items[0].label && items[0].value ) {
5080
			return items;
5081
		}
5082
		return $.map( items, function(item) {
5083
			if ( typeof item === "string" ) {
5084
				return {
5085
					label: item,
5086
					value: item
5087
				};
5088
			}
5089
			return $.extend({
5090
				label: item.label || item.value,
5091
				value: item.value || item.label
5092
			}, item );
5093
		});
5094
	},
5095
 
5096
	_suggest: function( items ) {
5097
		var ul = this.menu.element
5098
				.empty()
5099
				.zIndex( this.element.zIndex() + 1 ),
5100
			menuWidth,
5101
			textWidth;
5102
		this._renderMenu( ul, items );
5103
		// TODO refresh should check if the active item is still in the dom, removing the need for a manual deactivate
5104
		this.menu.deactivate();
5105
		this.menu.refresh();
5106
		this.menu.element.show().position( $.extend({
5107
			of: this.element
5108
		}, this.options.position ));
5109
 
5110
		menuWidth = ul.width( "" ).outerWidth();
5111
		textWidth = this.element.outerWidth();
5112
		ul.outerWidth( Math.max( menuWidth, textWidth ) );
5113
	},
5114
 
5115
	_renderMenu: function( ul, items ) {
5116
		var self = this;
5117
		$.each( items, function( index, item ) {
5118
			self._renderItem( ul, item );
5119
		});
5120
	},
5121
 
5122
	_renderItem: function( ul, item) {
5123
		return $( "<li></li>" )
5124
			.data( "item.autocomplete", item )
5125
			.append( $( "<a></a>" ).text( item.label ) )
5126
			.appendTo( ul );
5127
	},
5128
 
5129
	_move: function( direction, event ) {
5130
		if ( !this.menu.element.is(":visible") ) {
5131
			this.search( null, event );
5132
			return;
5133
		}
5134
		if ( this.menu.first() && /^previous/.test(direction) ||
5135
				this.menu.last() && /^next/.test(direction) ) {
5136
			this.element.val( this.term );
5137
			this.menu.deactivate();
5138
			return;
5139
		}
5140
		this.menu[ direction ]( event );
5141
	},
5142
 
5143
	widget: function() {
5144
		return this.menu.element;
5145
	}
5146
});
5147
 
5148
$.extend( $.ui.autocomplete, {
5149
	escapeRegex: function( value ) {
5150
		return value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
5151
	},
5152
	filter: function(array, term) {
5153
		var matcher = new RegExp( $.ui.autocomplete.escapeRegex(term), "i" );
5154
		return $.grep( array, function(value) {
5155
			return matcher.test( value.label || value.value || value );
5156
		});
5157
	}
5158
});
5159
 
5160
}( jQuery ));
5161
 
5162
/*
5163
 * jQuery UI Menu (not officially released)
5164
 *
5165
 * This widget isn't yet finished and the API is subject to change. We plan to finish
5166
 * it for the next release. You're welcome to give it a try anyway and give us feedback,
5167
 * as long as you're okay with migrating your code later on. We can help with that, too.
5168
 *
5169
 * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
5170
 * Dual licensed under the MIT or GPL Version 2 licenses.
5171
 * http://jquery.org/license
5172
 *
5173
 * http://docs.jquery.com/UI/Menu
5174
 *
5175
 * Depends:
5176
 *	jquery.ui.core.js
5177
 *  jquery.ui.widget.js
5178
 */
5179
(function($) {
5180
 
5181
$.widget("ui.menu", {
5182
	_create: function() {
5183
		var self = this;
5184
		this.element
5185
			.addClass("ui-menu ui-widget ui-widget-content ui-corner-all")
5186
			.attr({
5187
				role: "listbox",
5188
				"aria-activedescendant": "ui-active-menuitem"
5189
			})
5190
			.click(function( event ) {
5191
				if ( !$( event.target ).closest( ".ui-menu-item a" ).length ) {
5192
					return;
5193
				}
5194
				// temporary
5195
				event.preventDefault();
5196
				self.select( event );
5197
			});
5198
		this.refresh();
5199
	},
5200
 
5201
	refresh: function() {
5202
		var self = this;
5203
 
5204
		// don't refresh list items that are already adapted
5205
		var items = this.element.children("li:not(.ui-menu-item):has(a)")
5206
			.addClass("ui-menu-item")
5207
			.attr("role", "menuitem");
5208
 
5209
		items.children("a")
5210
			.addClass("ui-corner-all")
5211
			.attr("tabindex", -1)
5212
			// mouseenter doesn't work with event delegation
5213
			.mouseenter(function( event ) {
5214
				self.activate( event, $(this).parent() );
5215
			})
5216
			.mouseleave(function() {
5217
				self.deactivate();
5218
			});
5219
	},
5220
 
5221
	activate: function( event, item ) {
5222
		this.deactivate();
5223
		if (this.hasScroll()) {
5224
			var offset = item.offset().top - this.element.offset().top,
5225
				scroll = this.element.attr("scrollTop"),
5226
				elementHeight = this.element.height();
5227
			if (offset < 0) {
5228
				this.element.attr("scrollTop", scroll + offset);
5229
			} else if (offset >= elementHeight) {
5230
				this.element.attr("scrollTop", scroll + offset - elementHeight + item.height());
5231
			}
5232
		}
5233
		this.active = item.eq(0)
5234
			.children("a")
5235
				.addClass("ui-state-hover")
5236
				.attr("id", "ui-active-menuitem")
5237
			.end();
5238
		this._trigger("focus", event, { item: item });
5239
	},
5240
 
5241
	deactivate: function() {
5242
		if (!this.active) { return; }
5243
 
5244
		this.active.children("a")
5245
			.removeClass("ui-state-hover")
5246
			.removeAttr("id");
5247
		this._trigger("blur");
5248
		this.active = null;
5249
	},
5250
 
5251
	next: function(event) {
5252
		this.move("next", ".ui-menu-item:first", event);
5253
	},
5254
 
5255
	previous: function(event) {
5256
		this.move("prev", ".ui-menu-item:last", event);
5257
	},
5258
 
5259
	first: function() {
5260
		return this.active && !this.active.prevAll(".ui-menu-item").length;
5261
	},
5262
 
5263
	last: function() {
5264
		return this.active && !this.active.nextAll(".ui-menu-item").length;
5265
	},
5266
 
5267
	move: function(direction, edge, event) {
5268
		if (!this.active) {
5269
			this.activate(event, this.element.children(edge));
5270
			return;
5271
		}
5272
		var next = this.active[direction + "All"](".ui-menu-item").eq(0);
5273
		if (next.length) {
5274
			this.activate(event, next);
5275
		} else {
5276
			this.activate(event, this.element.children(edge));
5277
		}
5278
	},
5279
 
5280
	// TODO merge with previousPage
5281
	nextPage: function(event) {
5282
		if (this.hasScroll()) {
5283
			// TODO merge with no-scroll-else
5284
			if (!this.active || this.last()) {
5285
				this.activate(event, this.element.children(":first"));
5286
				return;
5287
			}
5288
			var base = this.active.offset().top,
5289
				height = this.element.height(),
5290
				result = this.element.children("li").filter(function() {
5291
					var close = $(this).offset().top - base - height + $(this).height();
5292
					// TODO improve approximation
5293
					return close < 10 && close > -10;
5294
				});
5295
 
5296
			// TODO try to catch this earlier when scrollTop indicates the last page anyway
5297
			if (!result.length) {
5298
				result = this.element.children(":last");
5299
			}
5300
			this.activate(event, result);
5301
		} else {
5302
			this.activate(event, this.element.children(!this.active || this.last() ? ":first" : ":last"));
5303
		}
5304
	},
5305
 
5306
	// TODO merge with nextPage
5307
	previousPage: function(event) {
5308
		if (this.hasScroll()) {
5309
			// TODO merge with no-scroll-else
5310
			if (!this.active || this.first()) {
5311
				this.activate(event, this.element.children(":last"));
5312
				return;
5313
			}
5314
 
5315
			var base = this.active.offset().top,
5316
				height = this.element.height();
5317
				result = this.element.children("li").filter(function() {
5318
					var close = $(this).offset().top - base + height - $(this).height();
5319
					// TODO improve approximation
5320
					return close < 10 && close > -10;
5321
				});
5322
 
5323
			// TODO try to catch this earlier when scrollTop indicates the last page anyway
5324
			if (!result.length) {
5325
				result = this.element.children(":first");
5326
			}
5327
			this.activate(event, result);
5328
		} else {
5329
			this.activate(event, this.element.children(!this.active || this.first() ? ":last" : ":first"));
5330
		}
5331
	},
5332
 
5333
	hasScroll: function() {
5334
		return this.element.height() < this.element.attr("scrollHeight");
5335
	},
5336
 
5337
	select: function( event ) {
5338
		this._trigger("selected", event, { item: this.active });
5339
	}
5340
});
5341
 
5342
}(jQuery));
5343
/*
5344
 * jQuery UI Button 1.8.5
5345
 *
5346
 * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
5347
 * Dual licensed under the MIT or GPL Version 2 licenses.
5348
 * http://jquery.org/license
5349
 *
5350
 * http://docs.jquery.com/UI/Button
5351
 *
5352
 * Depends:
5353
 *	jquery.ui.core.js
5354
 *	jquery.ui.widget.js
5355
 */
5356
(function( $, undefined ) {
5357
 
5358
var lastActive,
5359
	baseClasses = "ui-button ui-widget ui-state-default ui-corner-all",
5360
	stateClasses = "ui-state-hover ui-state-active ",
5361
	typeClasses = "ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary ui-button-text-only",
5362
	formResetHandler = function( event ) {
5363
		$( ":ui-button", event.target.form ).each(function() {
5364
			var inst = $( this ).data( "button" );
5365
			setTimeout(function() {
5366
				inst.refresh();
5367
			}, 1 );
5368
		});
5369
	},
5370
	radioGroup = function( radio ) {
5371
		var name = radio.name,
5372
			form = radio.form,
5373
			radios = $( [] );
5374
		if ( name ) {
5375
			if ( form ) {
5376
				radios = $( form ).find( "[name='" + name + "']" );
5377
			} else {
5378
				radios = $( "[name='" + name + "']", radio.ownerDocument )
5379
					.filter(function() {
5380
						return !this.form;
5381
					});
5382
			}
5383
		}
5384
		return radios;
5385
	};
5386
 
5387
$.widget( "ui.button", {
5388
	options: {
5389
		disabled: null,
5390
		text: true,
5391
		label: null,
5392
		icons: {
5393
			primary: null,
5394
			secondary: null
5395
		}
5396
	},
5397
	_create: function() {
5398
		this.element.closest( "form" )
5399
			.unbind( "reset.button" )
5400
			.bind( "reset.button", formResetHandler );
5401
 
5402
		if ( typeof this.options.disabled !== "boolean" ) {
5403
			this.options.disabled = this.element.attr( "disabled" );
5404
		}
5405
 
5406
		this._determineButtonType();
5407
		this.hasTitle = !!this.buttonElement.attr( "title" );
5408
 
5409
		var self = this,
5410
			options = this.options,
5411
			toggleButton = this.type === "checkbox" || this.type === "radio",
5412
			hoverClass = "ui-state-hover" + ( !toggleButton ? " ui-state-active" : "" ),
5413
			focusClass = "ui-state-focus";
5414
 
5415
		if ( options.label === null ) {
5416
			options.label = this.buttonElement.html();
5417
		}
5418
 
5419
		if ( this.element.is( ":disabled" ) ) {
5420
			options.disabled = true;
5421
		}
5422
 
5423
		this.buttonElement
5424
			.addClass( baseClasses )
5425
			.attr( "role", "button" )
5426
			.bind( "mouseenter.button", function() {
5427
				if ( options.disabled ) {
5428
					return;
5429
				}
5430
				$( this ).addClass( "ui-state-hover" );
5431
				if ( this === lastActive ) {
5432
					$( this ).addClass( "ui-state-active" );
5433
				}
5434
			})
5435
			.bind( "mouseleave.button", function() {
5436
				if ( options.disabled ) {
5437
					return;
5438
				}
5439
				$( this ).removeClass( hoverClass );
5440
			})
5441
			.bind( "focus.button", function() {
5442
				// no need to check disabled, focus won't be triggered anyway
5443
				$( this ).addClass( focusClass );
5444
			})
5445
			.bind( "blur.button", function() {
5446
				$( this ).removeClass( focusClass );
5447
			});
5448
 
5449
		if ( toggleButton ) {
5450
			this.element.bind( "change.button", function() {
5451
				self.refresh();
5452
			});
5453
		}
5454
 
5455
		if ( this.type === "checkbox" ) {
5456
			this.buttonElement.bind( "click.button", function() {
5457
				if ( options.disabled ) {
5458
					return false;
5459
				}
5460
				$( this ).toggleClass( "ui-state-active" );
5461
				self.buttonElement.attr( "aria-pressed", self.element[0].checked );
5462
			});
5463
		} else if ( this.type === "radio" ) {
5464
			this.buttonElement.bind( "click.button", function() {
5465
				if ( options.disabled ) {
5466
					return false;
5467
				}
5468
				$( this ).addClass( "ui-state-active" );
5469
				self.buttonElement.attr( "aria-pressed", true );
5470
 
5471
				var radio = self.element[ 0 ];
5472
				radioGroup( radio )
5473
					.not( radio )
5474
					.map(function() {
5475
						return $( this ).button( "widget" )[ 0 ];
5476
					})
5477
					.removeClass( "ui-state-active" )
5478
					.attr( "aria-pressed", false );
5479
			});
5480
		} else {
5481
			this.buttonElement
5482
				.bind( "mousedown.button", function() {
5483
					if ( options.disabled ) {
5484
						return false;
5485
					}
5486
					$( this ).addClass( "ui-state-active" );
5487
					lastActive = this;
5488
					$( document ).one( "mouseup", function() {
5489
						lastActive = null;
5490
					});
5491
				})
5492
				.bind( "mouseup.button", function() {
5493
					if ( options.disabled ) {
5494
						return false;
5495
					}
5496
					$( this ).removeClass( "ui-state-active" );
5497
				})
5498
				.bind( "keydown.button", function(event) {
5499
					if ( options.disabled ) {
5500
						return false;
5501
					}
5502
					if ( event.keyCode == $.ui.keyCode.SPACE || event.keyCode == $.ui.keyCode.ENTER ) {
5503
						$( this ).addClass( "ui-state-active" );
5504
					}
5505
				})
5506
				.bind( "keyup.button", function() {
5507
					$( this ).removeClass( "ui-state-active" );
5508
				});
5509
 
5510
			if ( this.buttonElement.is("a") ) {
5511
				this.buttonElement.keyup(function(event) {
5512
					if ( event.keyCode === $.ui.keyCode.SPACE ) {
5513
						// TODO pass through original event correctly (just as 2nd argument doesn't work)
5514
						$( this ).click();
5515
					}
5516
				});
5517
			}
5518
		}
5519
 
5520
		// TODO: pull out $.Widget's handling for the disabled option into
5521
		// $.Widget.prototype._setOptionDisabled so it's easy to proxy and can
5522
		// be overridden by individual plugins
5523
		this._setOption( "disabled", options.disabled );
5524
	},
5525
 
5526
	_determineButtonType: function() {
5527
 
5528
		if ( this.element.is(":checkbox") ) {
5529
			this.type = "checkbox";
5530
		} else {
5531
			if ( this.element.is(":radio") ) {
5532
				this.type = "radio";
5533
			} else {
5534
				if ( this.element.is("input") ) {
5535
					this.type = "input";
5536
				} else {
5537
					this.type = "button";
5538
				}
5539
			}
5540
		}
5541
 
5542
		if ( this.type === "checkbox" || this.type === "radio" ) {
5543
			// we don't search against the document in case the element
5544
			// is disconnected from the DOM
5545
			this.buttonElement = this.element.parents().last()
5546
				.find( "label[for=" + this.element.attr("id") + "]" );
5547
			this.element.addClass( "ui-helper-hidden-accessible" );
5548
 
5549
			var checked = this.element.is( ":checked" );
5550
			if ( checked ) {
5551
				this.buttonElement.addClass( "ui-state-active" );
5552
			}
5553
			this.buttonElement.attr( "aria-pressed", checked );
5554
		} else {
5555
			this.buttonElement = this.element;
5556
		}
5557
	},
5558
 
5559
	widget: function() {
5560
		return this.buttonElement;
5561
	},
5562
 
5563
	destroy: function() {
5564
		this.element
5565
			.removeClass( "ui-helper-hidden-accessible" );
5566
		this.buttonElement
5567
			.removeClass( baseClasses + " " + stateClasses + " " + typeClasses )
5568
			.removeAttr( "role" )
5569
			.removeAttr( "aria-pressed" )
5570
			.html( this.buttonElement.find(".ui-button-text").html() );
5571
 
5572
		if ( !this.hasTitle ) {
5573
			this.buttonElement.removeAttr( "title" );
5574
		}
5575
 
5576
		$.Widget.prototype.destroy.call( this );
5577
	},
5578
 
5579
	_setOption: function( key, value ) {
5580
		$.Widget.prototype._setOption.apply( this, arguments );
5581
		if ( key === "disabled" ) {
5582
			if ( value ) {
5583
				this.element.attr( "disabled", true );
5584
			} else {
5585
				this.element.removeAttr( "disabled" );
5586
			}
5587
		}
5588
		this._resetButton();
5589
	},
5590
 
5591
	refresh: function() {
5592
		var isDisabled = this.element.is( ":disabled" );
5593
		if ( isDisabled !== this.options.disabled ) {
5594
			this._setOption( "disabled", isDisabled );
5595
		}
5596
		if ( this.type === "radio" ) {
5597
			radioGroup( this.element[0] ).each(function() {
5598
				if ( $( this ).is( ":checked" ) ) {
5599
					$( this ).button( "widget" )
5600
						.addClass( "ui-state-active" )
5601
						.attr( "aria-pressed", true );
5602
				} else {
5603
					$( this ).button( "widget" )
5604
						.removeClass( "ui-state-active" )
5605
						.attr( "aria-pressed", false );
5606
				}
5607
			});
5608
		} else if ( this.type === "checkbox" ) {
5609
			if ( this.element.is( ":checked" ) ) {
5610
				this.buttonElement
5611
					.addClass( "ui-state-active" )
5612
					.attr( "aria-pressed", true );
5613
			} else {
5614
				this.buttonElement
5615
					.removeClass( "ui-state-active" )
5616
					.attr( "aria-pressed", false );
5617
			}
5618
		}
5619
	},
5620
 
5621
	_resetButton: function() {
5622
		if ( this.type === "input" ) {
5623
			if ( this.options.label ) {
5624
				this.element.val( this.options.label );
5625
			}
5626
			return;
5627
		}
5628
		var buttonElement = this.buttonElement.removeClass( typeClasses ),
5629
			buttonText = $( "<span></span>" )
5630
				.addClass( "ui-button-text" )
5631
				.html( this.options.label )
5632
				.appendTo( buttonElement.empty() )
5633
				.text(),
5634
			icons = this.options.icons,
5635
			multipleIcons = icons.primary && icons.secondary;
5636
		if ( icons.primary || icons.secondary ) {
5637
			buttonElement.addClass( "ui-button-text-icon" +
5638
				( multipleIcons ? "s" : ( icons.primary ? "-primary" : "-secondary" ) ) );
5639
			if ( icons.primary ) {
5640
				buttonElement.prepend( "<span class='ui-button-icon-primary ui-icon " + icons.primary + "'></span>" );
5641
			}
5642
			if ( icons.secondary ) {
5643
				buttonElement.append( "<span class='ui-button-icon-secondary ui-icon " + icons.secondary + "'></span>" );
5644
			}
5645
			if ( !this.options.text ) {
5646
				buttonElement
5647
					.addClass( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" )
5648
					.removeClass( "ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary" );
5649
				if ( !this.hasTitle ) {
5650
					buttonElement.attr( "title", buttonText );
5651
				}
5652
			}
5653
		} else {
5654
			buttonElement.addClass( "ui-button-text-only" );
5655
		}
5656
	}
5657
});
5658
 
5659
$.widget( "ui.buttonset", {
5660
	_create: function() {
5661
		this.element.addClass( "ui-buttonset" );
5662
		this._init();
5663
	},
5664
 
5665
	_init: function() {
5666
		this.refresh();
5667
	},
5668
 
5669
	_setOption: function( key, value ) {
5670
		if ( key === "disabled" ) {
5671
			this.buttons.button( "option", key, value );
5672
		}
5673
 
5674
		$.Widget.prototype._setOption.apply( this, arguments );
5675
	},
5676
 
5677
	refresh: function() {
5678
		this.buttons = this.element.find( ":button, :submit, :reset, :checkbox, :radio, a, :data(button)" )
5679
			.filter( ":ui-button" )
5680
				.button( "refresh" )
5681
			.end()
5682
			.not( ":ui-button" )
5683
				.button()
5684
			.end()
5685
			.map(function() {
5686
				return $( this ).button( "widget" )[ 0 ];
5687
			})
5688
				.removeClass( "ui-corner-all ui-corner-left ui-corner-right" )
5689
				.filter( ":visible" )
5690
					.filter( ":first" )
5691
						.addClass( "ui-corner-left" )
5692
					.end()
5693
					.filter( ":last" )
5694
						.addClass( "ui-corner-right" )
5695
					.end()
5696
				.end()
5697
			.end();
5698
	},
5699
 
5700
	destroy: function() {
5701
		this.element.removeClass( "ui-buttonset" );
5702
		this.buttons
5703
			.map(function() {
5704
				return $( this ).button( "widget" )[ 0 ];
5705
			})
5706
				.removeClass( "ui-corner-left ui-corner-right" )
5707
			.end()
5708
			.button( "destroy" );
5709
 
5710
		$.Widget.prototype.destroy.call( this );
5711
	}
5712
});
5713
 
5714
}( jQuery ) );
5715
/*
5716
 * jQuery UI Dialog 1.8.5
5717
 *
5718
 * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
5719
 * Dual licensed under the MIT or GPL Version 2 licenses.
5720
 * http://jquery.org/license
5721
 *
5722
 * http://docs.jquery.com/UI/Dialog
5723
 *
5724
 * Depends:
5725
 *	jquery.ui.core.js
5726
 *	jquery.ui.widget.js
5727
 *  jquery.ui.button.js
5728
 *	jquery.ui.draggable.js
5729
 *	jquery.ui.mouse.js
5730
 *	jquery.ui.position.js
5731
 *	jquery.ui.resizable.js
5732
 */
5733
(function( $, undefined ) {
5734
 
5735
var uiDialogClasses =
5736
	'ui-dialog ' +
5737
	'ui-widget ' +
5738
	'ui-widget-content ' +
5739
	'ui-corner-all ';
5740
 
5741
$.widget("ui.dialog", {
5742
	options: {
5743
		autoOpen: true,
5744
		buttons: {},
5745
		closeOnEscape: true,
5746
		closeText: 'close',
5747
		dialogClass: '',
5748
		draggable: true,
5749
		hide: null,
5750
		height: 'auto',
5751
		maxHeight: false,
5752
		maxWidth: false,
5753
		minHeight: 150,
5754
		minWidth: 150,
5755
		modal: false,
5756
		position: {
5757
			my: 'center',
5758
			at: 'center',
5759
			of: window,
5760
			collision: 'fit',
5761
			// ensure that the titlebar is never outside the document
5762
			using: function(pos) {
5763
				var topOffset = $(this).css(pos).offset().top;
5764
				if (topOffset < 0) {
5765
					$(this).css('top', pos.top - topOffset);
5766
				}
5767
			}
5768
		},
5769
		resizable: true,
5770
		show: null,
5771
		stack: true,
5772
		title: '',
5773
		width: 300,
5774
		zIndex: 1000
5775
	},
5776
 
5777
	_create: function() {
5778
		this.originalTitle = this.element.attr('title');
5779
		// #5742 - .attr() might return a DOMElement
5780
		if ( typeof this.originalTitle !== "string" ) {
5781
			this.originalTitle = "";
5782
		}
5783
 
5784
		this.options.title = this.options.title || this.originalTitle;
5785
		var self = this,
5786
			options = self.options,
5787
 
5788
			title = options.title || '&#160;',
5789
			titleId = $.ui.dialog.getTitleId(self.element),
5790
 
5791
			uiDialog = (self.uiDialog = $('<div></div>'))
5792
				.appendTo(document.body)
5793
				.hide()
5794
				.addClass(uiDialogClasses + options.dialogClass)
5795
				.css({
5796
					zIndex: options.zIndex
5797
				})
5798
				// setting tabIndex makes the div focusable
5799
				// setting outline to 0 prevents a border on focus in Mozilla
5800
				.attr('tabIndex', -1).css('outline', 0).keydown(function(event) {
5801
					if (options.closeOnEscape && event.keyCode &&
5802
						event.keyCode === $.ui.keyCode.ESCAPE) {
5803
 
5804
						self.close(event);
5805
						event.preventDefault();
5806
					}
5807
				})
5808
				.attr({
5809
					role: 'dialog',
5810
					'aria-labelledby': titleId
5811
				})
5812
				.mousedown(function(event) {
5813
					self.moveToTop(false, event);
5814
				}),
5815
 
5816
			uiDialogContent = self.element
5817
				.show()
5818
				.removeAttr('title')
5819
				.addClass(
5820
					'ui-dialog-content ' +
5821
					'ui-widget-content')
5822
				.appendTo(uiDialog),
5823
 
5824
			uiDialogTitlebar = (self.uiDialogTitlebar = $('<div></div>'))
5825
				.addClass(
5826
					'ui-dialog-titlebar ' +
5827
					'ui-widget-header ' +
5828
					'ui-corner-all ' +
5829
					'ui-helper-clearfix'
5830
				)
5831
				.prependTo(uiDialog),
5832
 
5833
			uiDialogTitlebarClose = $('<a href="#"></a>')
5834
				.addClass(
5835
					'ui-dialog-titlebar-close ' +
5836
					'ui-corner-all'
5837
				)
5838
				.attr('role', 'button')
5839
				.hover(
5840
					function() {
5841
						uiDialogTitlebarClose.addClass('ui-state-hover');
5842
					},
5843
					function() {
5844
						uiDialogTitlebarClose.removeClass('ui-state-hover');
5845
					}
5846
				)
5847
				.focus(function() {
5848
					uiDialogTitlebarClose.addClass('ui-state-focus');
5849
				})
5850
				.blur(function() {
5851
					uiDialogTitlebarClose.removeClass('ui-state-focus');
5852
				})
5853
				.click(function(event) {
5854
					self.close(event);
5855
					return false;
5856
				})
5857
				.appendTo(uiDialogTitlebar),
5858
 
5859
			uiDialogTitlebarCloseText = (self.uiDialogTitlebarCloseText = $('<span></span>'))
5860
				.addClass(
5861
					'ui-icon ' +
5862
					'ui-icon-closethick'
5863
				)
5864
				.text(options.closeText)
5865
				.appendTo(uiDialogTitlebarClose),
5866
 
5867
			uiDialogTitle = $('<span></span>')
5868
				.addClass('ui-dialog-title')
5869
				.attr('id', titleId)
5870
				.html(title)
5871
				.prependTo(uiDialogTitlebar);
5872
 
5873
		//handling of deprecated beforeclose (vs beforeClose) option
5874
		//Ticket #4669 http://dev.jqueryui.com/ticket/4669
5875
		//TODO: remove in 1.9pre
5876
		if ($.isFunction(options.beforeclose) && !$.isFunction(options.beforeClose)) {
5877
			options.beforeClose = options.beforeclose;
5878
		}
5879
 
5880
		uiDialogTitlebar.find("*").add(uiDialogTitlebar).disableSelection();
5881
 
5882
		if (options.draggable && $.fn.draggable) {
5883
			self._makeDraggable();
5884
		}
5885
		if (options.resizable && $.fn.resizable) {
5886
			self._makeResizable();
5887
		}
5888
 
5889
		self._createButtons(options.buttons);
5890
		self._isOpen = false;
5891
 
5892
		if ($.fn.bgiframe) {
5893
			uiDialog.bgiframe();
5894
		}
5895
	},
5896
 
5897
	_init: function() {
5898
		if ( this.options.autoOpen ) {
5899
			this.open();
5900
		}
5901
	},
5902
 
5903
	destroy: function() {
5904
		var self = this;
5905
 
5906
		if (self.overlay) {
5907
			self.overlay.destroy();
5908
		}
5909
		self.uiDialog.hide();
5910
		self.element
5911
			.unbind('.dialog')
5912
			.removeData('dialog')
5913
			.removeClass('ui-dialog-content ui-widget-content')
5914
			.hide().appendTo('body');
5915
		self.uiDialog.remove();
5916
 
5917
		if (self.originalTitle) {
5918
			self.element.attr('title', self.originalTitle);
5919
		}
5920
 
5921
		return self;
5922
	},
5923
 
5924
	widget: function() {
5925
		return this.uiDialog;
5926
	},
5927
 
5928
	close: function(event) {
5929
		var self = this,
5930
			maxZ;
5931
 
5932
		if (false === self._trigger('beforeClose', event)) {
5933
			return;
5934
		}
5935
 
5936
		if (self.overlay) {
5937
			self.overlay.destroy();
5938
		}
5939
		self.uiDialog.unbind('keypress.ui-dialog');
5940
 
5941
		self._isOpen = false;
5942
 
5943
		if (self.options.hide) {
5944
			self.uiDialog.hide(self.options.hide, function() {
5945
				self._trigger('close', event);
5946
			});
5947
		} else {
5948
			self.uiDialog.hide();
5949
			self._trigger('close', event);
5950
		}
5951
 
5952
		$.ui.dialog.overlay.resize();
5953
 
5954
		// adjust the maxZ to allow other modal dialogs to continue to work (see #4309)
5955
		if (self.options.modal) {
5956
			maxZ = 0;
5957
			$('.ui-dialog').each(function() {
5958
				if (this !== self.uiDialog[0]) {
5959
					maxZ = Math.max(maxZ, $(this).css('z-index'));
5960
				}
5961
			});
5962
			$.ui.dialog.maxZ = maxZ;
5963
		}
5964
 
5965
		return self;
5966
	},
5967
 
5968
	isOpen: function() {
5969
		return this._isOpen;
5970
	},
5971
 
5972
	// the force parameter allows us to move modal dialogs to their correct
5973
	// position on open
5974
	moveToTop: function(force, event) {
5975
		var self = this,
5976
			options = self.options,
5977
			saveScroll;
5978
 
5979
		if ((options.modal && !force) ||
5980
			(!options.stack && !options.modal)) {
5981
			return self._trigger('focus', event);
5982
		}
5983
 
5984
		if (options.zIndex > $.ui.dialog.maxZ) {
5985
			$.ui.dialog.maxZ = options.zIndex;
5986
		}
5987
		if (self.overlay) {
5988
			$.ui.dialog.maxZ += 1;
5989
			self.overlay.$el.css('z-index', $.ui.dialog.overlay.maxZ = $.ui.dialog.maxZ);
5990
		}
5991
 
5992
		//Save and then restore scroll since Opera 9.5+ resets when parent z-Index is changed.
5993
		//  http://ui.jquery.com/bugs/ticket/3193
5994
		saveScroll = { scrollTop: self.element.attr('scrollTop'), scrollLeft: self.element.attr('scrollLeft') };
5995
		$.ui.dialog.maxZ += 1;
5996
		self.uiDialog.css('z-index', $.ui.dialog.maxZ);
5997
		self.element.attr(saveScroll);
5998
		self._trigger('focus', event);
5999
 
6000
		return self;
6001
	},
6002
 
6003
	open: function() {
6004
		if (this._isOpen) { return; }
6005
 
6006
		var self = this,
6007
			options = self.options,
6008
			uiDialog = self.uiDialog;
6009
 
6010
		self.overlay = options.modal ? new $.ui.dialog.overlay(self) : null;
6011
		if (uiDialog.next().length) {
6012
			uiDialog.appendTo('body');
6013
		}
6014
		self._size();
6015
		self._position(options.position);
6016
		uiDialog.show(options.show);
6017
		self.moveToTop(true);
6018
 
6019
		// prevent tabbing out of modal dialogs
6020
		if (options.modal) {
6021
			uiDialog.bind('keypress.ui-dialog', function(event) {
6022
				if (event.keyCode !== $.ui.keyCode.TAB) {
6023
					return;
6024
				}
6025
 
6026
				var tabbables = $(':tabbable', this),
6027
					first = tabbables.filter(':first'),
6028
					last  = tabbables.filter(':last');
6029
 
6030
				if (event.target === last[0] && !event.shiftKey) {
6031
					first.focus(1);
6032
					return false;
6033
				} else if (event.target === first[0] && event.shiftKey) {
6034
					last.focus(1);
6035
					return false;
6036
				}
6037
			});
6038
		}
6039
 
6040
		// set focus to the first tabbable element in the content area or the first button
6041
		// if there are no tabbable elements, set focus on the dialog itself
6042
		$(self.element.find(':tabbable').get().concat(
6043
			uiDialog.find('.ui-dialog-buttonpane :tabbable').get().concat(
6044
				uiDialog.get()))).eq(0).focus();
6045
 
6046
		self._isOpen = true;
6047
		self._trigger('open');
6048
 
6049
		return self;
6050
	},
6051
 
6052
	_createButtons: function(buttons) {
6053
		var self = this,
6054
			hasButtons = false,
6055
			uiDialogButtonPane = $('<div></div>')
6056
				.addClass(
6057
					'ui-dialog-buttonpane ' +
6058
					'ui-widget-content ' +
6059
					'ui-helper-clearfix'
6060
				),
6061
			uiButtonSet = $( "<div></div>" )
6062
				.addClass( "ui-dialog-buttonset" )
6063
				.appendTo( uiDialogButtonPane );
6064
 
6065
		// if we already have a button pane, remove it
6066
		self.uiDialog.find('.ui-dialog-buttonpane').remove();
6067
 
6068
		if (typeof buttons === 'object' && buttons !== null) {
6069
			$.each(buttons, function() {
6070
				return !(hasButtons = true);
6071
			});
6072
		}
6073
		if (hasButtons) {
6074
			$.each(buttons, function(name, props) {
6075
				props = $.isFunction( props ) ?
6076
					{ click: props, text: name } :
6077
					props;
6078
				var button = $('<button></button>', props)
6079
					.unbind('click')
6080
					.click(function() {
6081
						props.click.apply(self.element[0], arguments);
6082
					})
6083
					.appendTo(uiButtonSet);
6084
				if ($.fn.button) {
6085
					button.button();
6086
				}
6087
			});
6088
			uiDialogButtonPane.appendTo(self.uiDialog);
6089
		}
6090
	},
6091
 
6092
	_makeDraggable: function() {
6093
		var self = this,
6094
			options = self.options,
6095
			doc = $(document),
6096
			heightBeforeDrag;
6097
 
6098
		function filteredUi(ui) {
6099
			return {
6100
				position: ui.position,
6101
				offset: ui.offset
6102
			};
6103
		}
6104
 
6105
		self.uiDialog.draggable({
6106
			cancel: '.ui-dialog-content, .ui-dialog-titlebar-close',
6107
			handle: '.ui-dialog-titlebar',
6108
			containment: 'document',
6109
			start: function(event, ui) {
6110
				heightBeforeDrag = options.height === "auto" ? "auto" : $(this).height();
6111
				$(this).height($(this).height()).addClass("ui-dialog-dragging");
6112
				self._trigger('dragStart', event, filteredUi(ui));
6113
			},
6114
			drag: function(event, ui) {
6115
				self._trigger('drag', event, filteredUi(ui));
6116
			},
6117
			stop: function(event, ui) {
6118
				options.position = [ui.position.left - doc.scrollLeft(),
6119
					ui.position.top - doc.scrollTop()];
6120
				$(this).removeClass("ui-dialog-dragging").height(heightBeforeDrag);
6121
				self._trigger('dragStop', event, filteredUi(ui));
6122
				$.ui.dialog.overlay.resize();
6123
			}
6124
		});
6125
	},
6126
 
6127
	_makeResizable: function(handles) {
6128
		handles = (handles === undefined ? this.options.resizable : handles);
6129
		var self = this,
6130
			options = self.options,
6131
			// .ui-resizable has position: relative defined in the stylesheet
6132
			// but dialogs have to use absolute or fixed positioning
6133
			position = self.uiDialog.css('position'),
6134
			resizeHandles = (typeof handles === 'string' ?
6135
				handles	:
6136
				'n,e,s,w,se,sw,ne,nw'
6137
			);
6138
 
6139
		function filteredUi(ui) {
6140
			return {
6141
				originalPosition: ui.originalPosition,
6142
				originalSize: ui.originalSize,
6143
				position: ui.position,
6144
				size: ui.size
6145
			};
6146
		}
6147
 
6148
		self.uiDialog.resizable({
6149
			cancel: '.ui-dialog-content',
6150
			containment: 'document',
6151
			alsoResize: self.element,
6152
			maxWidth: options.maxWidth,
6153
			maxHeight: options.maxHeight,
6154
			minWidth: options.minWidth,
6155
			minHeight: self._minHeight(),
6156
			handles: resizeHandles,
6157
			start: function(event, ui) {
6158
				$(this).addClass("ui-dialog-resizing");
6159
				self._trigger('resizeStart', event, filteredUi(ui));
6160
			},
6161
			resize: function(event, ui) {
6162
				self._trigger('resize', event, filteredUi(ui));
6163
			},
6164
			stop: function(event, ui) {
6165
				$(this).removeClass("ui-dialog-resizing");
6166
				options.height = $(this).height();
6167
				options.width = $(this).width();
6168
				self._trigger('resizeStop', event, filteredUi(ui));
6169
				$.ui.dialog.overlay.resize();
6170
			}
6171
		})
6172
		.css('position', position)
6173
		.find('.ui-resizable-se').addClass('ui-icon ui-icon-grip-diagonal-se');
6174
	},
6175
 
6176
	_minHeight: function() {
6177
		var options = this.options;
6178
 
6179
		if (options.height === 'auto') {
6180
			return options.minHeight;
6181
		} else {
6182
			return Math.min(options.minHeight, options.height);
6183
		}
6184
	},
6185
 
6186
	_position: function(position) {
6187
		var myAt = [],
6188
			offset = [0, 0],
6189
			isVisible;
6190
 
6191
		if (position) {
6192
			// deep extending converts arrays to objects in jQuery <= 1.3.2 :-(
6193
	//		if (typeof position == 'string' || $.isArray(position)) {
6194
	//			myAt = $.isArray(position) ? position : position.split(' ');
6195
 
6196
			if (typeof position === 'string' || (typeof position === 'object' && '0' in position)) {
6197
				myAt = position.split ? position.split(' ') : [position[0], position[1]];
6198
				if (myAt.length === 1) {
6199
					myAt[1] = myAt[0];
6200
				}
6201
 
6202
				$.each(['left', 'top'], function(i, offsetPosition) {
6203
					if (+myAt[i] === myAt[i]) {
6204
						offset[i] = myAt[i];
6205
						myAt[i] = offsetPosition;
6206
					}
6207
				});
6208
 
6209
				position = {
6210
					my: myAt.join(" "),
6211
					at: myAt.join(" "),
6212
					offset: offset.join(" ")
6213
				};
6214
			}
6215
 
6216
			position = $.extend({}, $.ui.dialog.prototype.options.position, position);
6217
		} else {
6218
			position = $.ui.dialog.prototype.options.position;
6219
		}
6220
 
6221
		// need to show the dialog to get the actual offset in the position plugin
6222
		isVisible = this.uiDialog.is(':visible');
6223
		if (!isVisible) {
6224
			this.uiDialog.show();
6225
		}
6226
		this.uiDialog
6227
			// workaround for jQuery bug #5781 http://dev.jquery.com/ticket/5781
6228
			.css({ top: 0, left: 0 })
6229
			.position(position);
6230
		if (!isVisible) {
6231
			this.uiDialog.hide();
6232
		}
6233
	},
6234
 
6235
	_setOption: function(key, value){
6236
		var self = this,
6237
			uiDialog = self.uiDialog,
6238
			isResizable = uiDialog.is(':data(resizable)'),
6239
			resize = false;
6240
 
6241
		switch (key) {
6242
			//handling of deprecated beforeclose (vs beforeClose) option
6243
			//Ticket #4669 http://dev.jqueryui.com/ticket/4669
6244
			//TODO: remove in 1.9pre
6245
			case "beforeclose":
6246
				key = "beforeClose";
6247
				break;
6248
			case "buttons":
6249
				self._createButtons(value);
6250
				resize = true;
6251
				break;
6252
			case "closeText":
6253
				// convert whatever was passed in to a string, for text() to not throw up
6254
				self.uiDialogTitlebarCloseText.text("" + value);
6255
				break;
6256
			case "dialogClass":
6257
				uiDialog
6258
					.removeClass(self.options.dialogClass)
6259
					.addClass(uiDialogClasses + value);
6260
				break;
6261
			case "disabled":
6262
				if (value) {
6263
					uiDialog.addClass('ui-dialog-disabled');
6264
				} else {
6265
					uiDialog.removeClass('ui-dialog-disabled');
6266
				}
6267
				break;
6268
			case "draggable":
6269
				if (value) {
6270
					self._makeDraggable();
6271
				} else {
6272
					uiDialog.draggable('destroy');
6273
				}
6274
				break;
6275
			case "height":
6276
				resize = true;
6277
				break;
6278
			case "maxHeight":
6279
				if (isResizable) {
6280
					uiDialog.resizable('option', 'maxHeight', value);
6281
				}
6282
				resize = true;
6283
				break;
6284
			case "maxWidth":
6285
				if (isResizable) {
6286
					uiDialog.resizable('option', 'maxWidth', value);
6287
				}
6288
				resize = true;
6289
				break;
6290
			case "minHeight":
6291
				if (isResizable) {
6292
					uiDialog.resizable('option', 'minHeight', value);
6293
				}
6294
				resize = true;
6295
				break;
6296
			case "minWidth":
6297
				if (isResizable) {
6298
					uiDialog.resizable('option', 'minWidth', value);
6299
				}
6300
				resize = true;
6301
				break;
6302
			case "position":
6303
				self._position(value);
6304
				break;
6305
			case "resizable":
6306
				// currently resizable, becoming non-resizable
6307
				if (isResizable && !value) {
6308
					uiDialog.resizable('destroy');
6309
				}
6310
 
6311
				// currently resizable, changing handles
6312
				if (isResizable && typeof value === 'string') {
6313
					uiDialog.resizable('option', 'handles', value);
6314
				}
6315
 
6316
				// currently non-resizable, becoming resizable
6317
				if (!isResizable && value !== false) {
6318
					self._makeResizable(value);
6319
				}
6320
				break;
6321
			case "title":
6322
				// convert whatever was passed in o a string, for html() to not throw up
6323
				$(".ui-dialog-title", self.uiDialogTitlebar).html("" + (value || '&#160;'));
6324
				break;
6325
			case "width":
6326
				resize = true;
6327
				break;
6328
		}
6329
 
6330
		$.Widget.prototype._setOption.apply(self, arguments);
6331
		if (resize) {
6332
			self._size();
6333
		}
6334
	},
6335
 
6336
	_size: function() {
6337
		/* If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
6338
		 * divs will both have width and height set, so we need to reset them
6339
		 */
6340
		var options = this.options,
6341
			nonContentHeight;
6342
 
6343
		// reset content sizing
6344
		// hide for non content measurement because height: 0 doesn't work in IE quirks mode (see #4350)
6345
		this.element.css({
6346
			width: 'auto',
6347
			minHeight: 0,
6348
			height: 0
6349
		});
6350
 
6351
		if (options.minWidth > options.width) {
6352
			options.width = options.minWidth;
6353
		}
6354
 
6355
		// reset wrapper sizing
6356
		// determine the height of all the non-content elements
6357
		nonContentHeight = this.uiDialog.css({
6358
				height: 'auto',
6359
				width: options.width
6360
			})
6361
			.height();
6362
 
6363
		this.element
6364
			.css(options.height === 'auto' ? {
6365
					minHeight: Math.max(options.minHeight - nonContentHeight, 0),
6366
					height: $.support.minHeight ? 'auto' :
6367
						Math.max(options.minHeight - nonContentHeight, 0)
6368
				} : {
6369
					minHeight: 0,
6370
					height: Math.max(options.height - nonContentHeight, 0)
6371
			})
6372
			.show();
6373
 
6374
		if (this.uiDialog.is(':data(resizable)')) {
6375
			this.uiDialog.resizable('option', 'minHeight', this._minHeight());
6376
		}
6377
	}
6378
});
6379
 
6380
$.extend($.ui.dialog, {
6381
	version: "1.8.5",
6382
 
6383
	uuid: 0,
6384
	maxZ: 0,
6385
 
6386
	getTitleId: function($el) {
6387
		var id = $el.attr('id');
6388
		if (!id) {
6389
			this.uuid += 1;
6390
			id = this.uuid;
6391
		}
6392
		return 'ui-dialog-title-' + id;
6393
	},
6394
 
6395
	overlay: function(dialog) {
6396
		this.$el = $.ui.dialog.overlay.create(dialog);
6397
	}
6398
});
6399
 
6400
$.extend($.ui.dialog.overlay, {
6401
	instances: [],
6402
	// reuse old instances due to IE memory leak with alpha transparency (see #5185)
6403
	oldInstances: [],
6404
	maxZ: 0,
6405
	events: $.map('focus,mousedown,mouseup,keydown,keypress,click'.split(','),
6406
		function(event) { return event + '.dialog-overlay'; }).join(' '),
6407
	create: function(dialog) {
6408
		if (this.instances.length === 0) {
6409
			// prevent use of anchors and inputs
6410
			// we use a setTimeout in case the overlay is created from an
6411
			// event that we're going to be cancelling (see #2804)
6412
			setTimeout(function() {
6413
				// handle $(el).dialog().dialog('close') (see #4065)
6414
				if ($.ui.dialog.overlay.instances.length) {
6415
					$(document).bind($.ui.dialog.overlay.events, function(event) {
6416
						// stop events if the z-index of the target is < the z-index of the overlay
6417
						// we cannot return true when we don't want to cancel the event (#3523)
6418
						if ($(event.target).zIndex() < $.ui.dialog.overlay.maxZ) {
6419
							return false;
6420
						}
6421
					});
6422
				}
6423
			}, 1);
6424
 
6425
			// allow closing by pressing the escape key
6426
			$(document).bind('keydown.dialog-overlay', function(event) {
6427
				if (dialog.options.closeOnEscape && event.keyCode &&
6428
					event.keyCode === $.ui.keyCode.ESCAPE) {
6429
 
6430
					dialog.close(event);
6431
					event.preventDefault();
6432
				}
6433
			});
6434
 
6435
			// handle window resize
6436
			$(window).bind('resize.dialog-overlay', $.ui.dialog.overlay.resize);
6437
		}
6438
 
6439
		var $el = (this.oldInstances.pop() || $('<div></div>').addClass('ui-widget-overlay'))
6440
			.appendTo(document.body)
6441
			.css({
6442
				width: this.width(),
6443
				height: this.height()
6444
			});
6445
 
6446
		if ($.fn.bgiframe) {
6447
			$el.bgiframe();
6448
		}
6449
 
6450
		this.instances.push($el);
6451
		return $el;
6452
	},
6453
 
6454
	destroy: function($el) {
6455
		this.oldInstances.push(this.instances.splice($.inArray($el, this.instances), 1)[0]);
6456
 
6457
		if (this.instances.length === 0) {
6458
			$([document, window]).unbind('.dialog-overlay');
6459
		}
6460
 
6461
		$el.remove();
6462
 
6463
		// adjust the maxZ to allow other modal dialogs to continue to work (see #4309)
6464
		var maxZ = 0;
6465
		$.each(this.instances, function() {
6466
			maxZ = Math.max(maxZ, this.css('z-index'));
6467
		});
6468
		this.maxZ = maxZ;
6469
	},
6470
 
6471
	height: function() {
6472
		var scrollHeight,
6473
			offsetHeight;
6474
		// handle IE 6
6475
		if ($.browser.msie && $.browser.version < 7) {
6476
			scrollHeight = Math.max(
6477
				document.documentElement.scrollHeight,
6478
				document.body.scrollHeight
6479
			);
6480
			offsetHeight = Math.max(
6481
				document.documentElement.offsetHeight,
6482
				document.body.offsetHeight
6483
			);
6484
 
6485
			if (scrollHeight < offsetHeight) {
6486
				return $(window).height() + 'px';
6487
			} else {
6488
				return scrollHeight + 'px';
6489
			}
6490
		// handle "good" browsers
6491
		} else {
6492
			return $(document).height() + 'px';
6493
		}
6494
	},
6495
 
6496
	width: function() {
6497
		var scrollWidth,
6498
			offsetWidth;
6499
		// handle IE 6
6500
		if ($.browser.msie && $.browser.version < 7) {
6501
			scrollWidth = Math.max(
6502
				document.documentElement.scrollWidth,
6503
				document.body.scrollWidth
6504
			);
6505
			offsetWidth = Math.max(
6506
				document.documentElement.offsetWidth,
6507
				document.body.offsetWidth
6508
			);
6509
 
6510
			if (scrollWidth < offsetWidth) {
6511
				return $(window).width() + 'px';
6512
			} else {
6513
				return scrollWidth + 'px';
6514
			}
6515
		// handle "good" browsers
6516
		} else {
6517
			return $(document).width() + 'px';
6518
		}
6519
	},
6520
 
6521
	resize: function() {
6522
		/* If the dialog is draggable and the user drags it past the
6523
		 * right edge of the window, the document becomes wider so we
6524
		 * need to stretch the overlay. If the user then drags the
6525
		 * dialog back to the left, the document will become narrower,
6526
		 * so we need to shrink the overlay to the appropriate size.
6527
		 * This is handled by shrinking the overlay before setting it
6528
		 * to the full document size.
6529
		 */
6530
		var $overlays = $([]);
6531
		$.each($.ui.dialog.overlay.instances, function() {
6532
			$overlays = $overlays.add(this);
6533
		});
6534
 
6535
		$overlays.css({
6536
			width: 0,
6537
			height: 0
6538
		}).css({
6539
			width: $.ui.dialog.overlay.width(),
6540
			height: $.ui.dialog.overlay.height()
6541
		});
6542
	}
6543
});
6544
 
6545
$.extend($.ui.dialog.overlay.prototype, {
6546
	destroy: function() {
6547
		$.ui.dialog.overlay.destroy(this.$el);
6548
	}
6549
});
6550
 
6551
}(jQuery));
6552
/*
6553
 * jQuery UI Slider 1.8.5
6554
 *
6555
 * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
6556
 * Dual licensed under the MIT or GPL Version 2 licenses.
6557
 * http://jquery.org/license
6558
 *
6559
 * http://docs.jquery.com/UI/Slider
6560
 *
6561
 * Depends:
6562
 *	jquery.ui.core.js
6563
 *	jquery.ui.mouse.js
6564
 *	jquery.ui.widget.js
6565
 */
6566
(function( $, undefined ) {
6567
 
6568
// number of pages in a slider
6569
// (how many times can you page up/down to go through the whole range)
6570
var numPages = 5;
6571
 
6572
$.widget( "ui.slider", $.ui.mouse, {
6573
 
6574
	widgetEventPrefix: "slide",
6575
 
6576
	options: {
6577
		animate: false,
6578
		distance: 0,
6579
		max: 100,
6580
		min: 0,
6581
		orientation: "horizontal",
6582
		range: false,
6583
		step: 1,
6584
		value: 0,
6585
		values: null
6586
	},
6587
 
6588
	_create: function() {
6589
		var self = this,
6590
			o = this.options;
6591
 
6592
		this._keySliding = false;
6593
		this._mouseSliding = false;
6594
		this._animateOff = true;
6595
		this._handleIndex = null;
6596
		this._detectOrientation();
6597
		this._mouseInit();
6598
 
6599
		this.element
6600
			.addClass( "ui-slider" +
6601
				" ui-slider-" + this.orientation +
6602
				" ui-widget" +
6603
				" ui-widget-content" +
6604
				" ui-corner-all" );
6605
 
6606
		if ( o.disabled ) {
6607
			this.element.addClass( "ui-slider-disabled ui-disabled" );
6608
		}
6609
 
6610
		this.range = $([]);
6611
 
6612
		if ( o.range ) {
6613
			if ( o.range === true ) {
6614
				this.range = $( "<div></div>" );
6615
				if ( !o.values ) {
6616
					o.values = [ this._valueMin(), this._valueMin() ];
6617
				}
6618
				if ( o.values.length && o.values.length !== 2 ) {
6619
					o.values = [ o.values[0], o.values[0] ];
6620
				}
6621
			} else {
6622
				this.range = $( "<div></div>" );
6623
			}
6624
 
6625
			this.range
6626
				.appendTo( this.element )
6627
				.addClass( "ui-slider-range" );
6628
 
6629
			if ( o.range === "min" || o.range === "max" ) {
6630
				this.range.addClass( "ui-slider-range-" + o.range );
6631
			}
6632
 
6633
			// note: this isn't the most fittingly semantic framework class for this element,
6634
			// but worked best visually with a variety of themes
6635
			this.range.addClass( "ui-widget-header" );
6636
		}
6637
 
6638
		if ( $( ".ui-slider-handle", this.element ).length === 0 ) {
6639
			$( "<a href='#'></a>" )
6640
				.appendTo( this.element )
6641
				.addClass( "ui-slider-handle" );
6642
		}
6643
 
6644
		if ( o.values && o.values.length ) {
6645
			while ( $(".ui-slider-handle", this.element).length < o.values.length ) {
6646
				$( "<a href='#'></a>" )
6647
					.appendTo( this.element )
6648
					.addClass( "ui-slider-handle" );
6649
			}
6650
		}
6651
 
6652
		this.handles = $( ".ui-slider-handle", this.element )
6653
			.addClass( "ui-state-default" +
6654
				" ui-corner-all" );
6655
 
6656
		this.handle = this.handles.eq( 0 );
6657
 
6658
		this.handles.add( this.range ).filter( "a" )
6659
			.click(function( event ) {
6660
				event.preventDefault();
6661
			})
6662
			.hover(function() {
6663
				if ( !o.disabled ) {
6664
					$( this ).addClass( "ui-state-hover" );
6665
				}
6666
			}, function() {
6667
				$( this ).removeClass( "ui-state-hover" );
6668
			})
6669
			.focus(function() {
6670
				if ( !o.disabled ) {
6671
					$( ".ui-slider .ui-state-focus" ).removeClass( "ui-state-focus" );
6672
					$( this ).addClass( "ui-state-focus" );
6673
				} else {
6674
					$( this ).blur();
6675
				}
6676
			})
6677
			.blur(function() {
6678
				$( this ).removeClass( "ui-state-focus" );
6679
			});
6680
 
6681
		this.handles.each(function( i ) {
6682
			$( this ).data( "index.ui-slider-handle", i );
6683
		});
6684
 
6685
		this.handles
6686
			.keydown(function( event ) {
6687
				var ret = true,
6688
					index = $( this ).data( "index.ui-slider-handle" ),
6689
					allowed,
6690
					curVal,
6691
					newVal,
6692
					step;
6693
 
6694
				if ( self.options.disabled ) {
6695
					return;
6696
				}
6697
 
6698
				switch ( event.keyCode ) {
6699
					case $.ui.keyCode.HOME:
6700
					case $.ui.keyCode.END:
6701
					case $.ui.keyCode.PAGE_UP:
6702
					case $.ui.keyCode.PAGE_DOWN:
6703
					case $.ui.keyCode.UP:
6704
					case $.ui.keyCode.RIGHT:
6705
					case $.ui.keyCode.DOWN:
6706
					case $.ui.keyCode.LEFT:
6707
						ret = false;
6708
						if ( !self._keySliding ) {
6709
							self._keySliding = true;
6710
							$( this ).addClass( "ui-state-active" );
6711
							allowed = self._start( event, index );
6712
							if ( allowed === false ) {
6713
								return;
6714
							}
6715
						}
6716
						break;
6717
				}
6718
 
6719
				step = self.options.step;
6720
				if ( self.options.values && self.options.values.length ) {
6721
					curVal = newVal = self.values( index );
6722
				} else {
6723
					curVal = newVal = self.value();
6724
				}
6725
 
6726
				switch ( event.keyCode ) {
6727
					case $.ui.keyCode.HOME:
6728
						newVal = self._valueMin();
6729
						break;
6730
					case $.ui.keyCode.END:
6731
						newVal = self._valueMax();
6732
						break;
6733
					case $.ui.keyCode.PAGE_UP:
6734
						newVal = self._trimAlignValue( curVal + ( (self._valueMax() - self._valueMin()) / numPages ) );
6735
						break;
6736
					case $.ui.keyCode.PAGE_DOWN:
6737
						newVal = self._trimAlignValue( curVal - ( (self._valueMax() - self._valueMin()) / numPages ) );
6738
						break;
6739
					case $.ui.keyCode.UP:
6740
					case $.ui.keyCode.RIGHT:
6741
						if ( curVal === self._valueMax() ) {
6742
							return;
6743
						}
6744
						newVal = self._trimAlignValue( curVal + step );
6745
						break;
6746
					case $.ui.keyCode.DOWN:
6747
					case $.ui.keyCode.LEFT:
6748
						if ( curVal === self._valueMin() ) {
6749
							return;
6750
						}
6751
						newVal = self._trimAlignValue( curVal - step );
6752
						break;
6753
				}
6754
 
6755
				self._slide( event, index, newVal );
6756
 
6757
				return ret;
6758
 
6759
			})
6760
			.keyup(function( event ) {
6761
				var index = $( this ).data( "index.ui-slider-handle" );
6762
 
6763
				if ( self._keySliding ) {
6764
					self._keySliding = false;
6765
					self._stop( event, index );
6766
					self._change( event, index );
6767
					$( this ).removeClass( "ui-state-active" );
6768
				}
6769
 
6770
			});
6771
 
6772
		this._refreshValue();
6773
 
6774
		this._animateOff = false;
6775
	},
6776
 
6777
	destroy: function() {
6778
		this.handles.remove();
6779
		this.range.remove();
6780
 
6781
		this.element
6782
			.removeClass( "ui-slider" +
6783
				" ui-slider-horizontal" +
6784
				" ui-slider-vertical" +
6785
				" ui-slider-disabled" +
6786
				" ui-widget" +
6787
				" ui-widget-content" +
6788
				" ui-corner-all" )
6789
			.removeData( "slider" )
6790
			.unbind( ".slider" );
6791
 
6792
		this._mouseDestroy();
6793
 
6794
		return this;
6795
	},
6796
 
6797
	_mouseCapture: function( event ) {
6798
		var o = this.options,
6799
			position,
6800
			normValue,
6801
			distance,
6802
			closestHandle,
6803
			self,
6804
			index,
6805
			allowed,
6806
			offset,
6807
			mouseOverHandle;
6808
 
6809
		if ( o.disabled ) {
6810
			return false;
6811
		}
6812
 
6813
		this.elementSize = {
6814
			width: this.element.outerWidth(),
6815
			height: this.element.outerHeight()
6816
		};
6817
		this.elementOffset = this.element.offset();
6818
 
6819
		position = { x: event.pageX, y: event.pageY };
6820
		normValue = this._normValueFromMouse( position );
6821
		distance = this._valueMax() - this._valueMin() + 1;
6822
		self = this;
6823
		this.handles.each(function( i ) {
6824
			var thisDistance = Math.abs( normValue - self.values(i) );
6825
			if ( distance > thisDistance ) {
6826
				distance = thisDistance;
6827
				closestHandle = $( this );
6828
				index = i;
6829
			}
6830
		});
6831
 
6832
		// workaround for bug #3736 (if both handles of a range are at 0,
6833
		// the first is always used as the one with least distance,
6834
		// and moving it is obviously prevented by preventing negative ranges)
6835
		if( o.range === true && this.values(1) === o.min ) {
6836
			index += 1;
6837
			closestHandle = $( this.handles[index] );
6838
		}
6839
 
6840
		allowed = this._start( event, index );
6841
		if ( allowed === false ) {
6842
			return false;
6843
		}
6844
		this._mouseSliding = true;
6845
 
6846
		self._handleIndex = index;
6847
 
6848
		closestHandle
6849
			.addClass( "ui-state-active" )
6850
			.focus();
6851
 
6852
		offset = closestHandle.offset();
6853
		mouseOverHandle = !$( event.target ).parents().andSelf().is( ".ui-slider-handle" );
6854
		this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
6855
			left: event.pageX - offset.left - ( closestHandle.width() / 2 ),
6856
			top: event.pageY - offset.top -
6857
				( closestHandle.height() / 2 ) -
6858
				( parseInt( closestHandle.css("borderTopWidth"), 10 ) || 0 ) -
6859
				( parseInt( closestHandle.css("borderBottomWidth"), 10 ) || 0) +
6860
				( parseInt( closestHandle.css("marginTop"), 10 ) || 0)
6861
		};
6862
 
6863
		this._slide( event, index, normValue );
6864
		this._animateOff = true;
6865
		return true;
6866
	},
6867
 
6868
	_mouseStart: function( event ) {
6869
		return true;
6870
	},
6871
 
6872
	_mouseDrag: function( event ) {
6873
		var position = { x: event.pageX, y: event.pageY },
6874
			normValue = this._normValueFromMouse( position );
6875
 
6876
		this._slide( event, this._handleIndex, normValue );
6877
 
6878
		return false;
6879
	},
6880
 
6881
	_mouseStop: function( event ) {
6882
		this.handles.removeClass( "ui-state-active" );
6883
		this._mouseSliding = false;
6884
 
6885
		this._stop( event, this._handleIndex );
6886
		this._change( event, this._handleIndex );
6887
 
6888
		this._handleIndex = null;
6889
		this._clickOffset = null;
6890
		this._animateOff = false;
6891
 
6892
		return false;
6893
	},
6894
 
6895
	_detectOrientation: function() {
6896
		this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal";
6897
	},
6898
 
6899
	_normValueFromMouse: function( position ) {
6900
		var pixelTotal,
6901
			pixelMouse,
6902
			percentMouse,
6903
			valueTotal,
6904
			valueMouse;
6905
 
6906
		if ( this.orientation === "horizontal" ) {
6907
			pixelTotal = this.elementSize.width;
6908
			pixelMouse = position.x - this.elementOffset.left - ( this._clickOffset ? this._clickOffset.left : 0 );
6909
		} else {
6910
			pixelTotal = this.elementSize.height;
6911
			pixelMouse = position.y - this.elementOffset.top - ( this._clickOffset ? this._clickOffset.top : 0 );
6912
		}
6913
 
6914
		percentMouse = ( pixelMouse / pixelTotal );
6915
		if ( percentMouse > 1 ) {
6916
			percentMouse = 1;
6917
		}
6918
		if ( percentMouse < 0 ) {
6919
			percentMouse = 0;
6920
		}
6921
		if ( this.orientation === "vertical" ) {
6922
			percentMouse = 1 - percentMouse;
6923
		}
6924
 
6925
		valueTotal = this._valueMax() - this._valueMin();
6926
		valueMouse = this._valueMin() + percentMouse * valueTotal;
6927
 
6928
		return this._trimAlignValue( valueMouse );
6929
	},
6930
 
6931
	_start: function( event, index ) {
6932
		var uiHash = {
6933
			handle: this.handles[ index ],
6934
			value: this.value()
6935
		};
6936
		if ( this.options.values && this.options.values.length ) {
6937
			uiHash.value = this.values( index );
6938
			uiHash.values = this.values();
6939
		}
6940
		return this._trigger( "start", event, uiHash );
6941
	},
6942
 
6943
	_slide: function( event, index, newVal ) {
6944
		var otherVal,
6945
			newValues,
6946
			allowed;
6947
 
6948
		if ( this.options.values && this.options.values.length ) {
6949
			otherVal = this.values( index ? 0 : 1 );
6950
 
6951
			if ( ( this.options.values.length === 2 && this.options.range === true ) &&
6952
					( ( index === 0 && newVal > otherVal) || ( index === 1 && newVal < otherVal ) )
6953
				) {
6954
				newVal = otherVal;
6955
			}
6956
 
6957
			if ( newVal !== this.values( index ) ) {
6958
				newValues = this.values();
6959
				newValues[ index ] = newVal;
6960
				// A slide can be canceled by returning false from the slide callback
6961
				allowed = this._trigger( "slide", event, {
6962
					handle: this.handles[ index ],
6963
					value: newVal,
6964
					values: newValues
6965
				} );
6966
				otherVal = this.values( index ? 0 : 1 );
6967
				if ( allowed !== false ) {
6968
					this.values( index, newVal, true );
6969
				}
6970
			}
6971
		} else {
6972
			if ( newVal !== this.value() ) {
6973
				// A slide can be canceled by returning false from the slide callback
6974
				allowed = this._trigger( "slide", event, {
6975
					handle: this.handles[ index ],
6976
					value: newVal
6977
				} );
6978
				if ( allowed !== false ) {
6979
					this.value( newVal );
6980
				}
6981
			}
6982
		}
6983
	},
6984
 
6985
	_stop: function( event, index ) {
6986
		var uiHash = {
6987
			handle: this.handles[ index ],
6988
			value: this.value()
6989
		};
6990
		if ( this.options.values && this.options.values.length ) {
6991
			uiHash.value = this.values( index );
6992
			uiHash.values = this.values();
6993
		}
6994
 
6995
		this._trigger( "stop", event, uiHash );
6996
	},
6997
 
6998
	_change: function( event, index ) {
6999
		if ( !this._keySliding && !this._mouseSliding ) {
7000
			var uiHash = {
7001
				handle: this.handles[ index ],
7002
				value: this.value()
7003
			};
7004
			if ( this.options.values && this.options.values.length ) {
7005
				uiHash.value = this.values( index );
7006
				uiHash.values = this.values();
7007
			}
7008
 
7009
			this._trigger( "change", event, uiHash );
7010
		}
7011
	},
7012
 
7013
	value: function( newValue ) {
7014
		if ( arguments.length ) {
7015
			this.options.value = this._trimAlignValue( newValue );
7016
			this._refreshValue();
7017
			this._change( null, 0 );
7018
		}
7019
 
7020
		return this._value();
7021
	},
7022
 
7023
	values: function( index, newValue ) {
7024
		var vals,
7025
			newValues,
7026
			i;
7027
 
7028
		if ( arguments.length > 1 ) {
7029
			this.options.values[ index ] = this._trimAlignValue( newValue );
7030
			this._refreshValue();
7031
			this._change( null, index );
7032
		}
7033
 
7034
		if ( arguments.length ) {
7035
			if ( $.isArray( arguments[ 0 ] ) ) {
7036
				vals = this.options.values;
7037
				newValues = arguments[ 0 ];
7038
				for ( i = 0; i < vals.length; i += 1 ) {
7039
					vals[ i ] = this._trimAlignValue( newValues[ i ] );
7040
					this._change( null, i );
7041
				}
7042
				this._refreshValue();
7043
			} else {
7044
				if ( this.options.values && this.options.values.length ) {
7045
					return this._values( index );
7046
				} else {
7047
					return this.value();
7048
				}
7049
			}
7050
		} else {
7051
			return this._values();
7052
		}
7053
	},
7054
 
7055
	_setOption: function( key, value ) {
7056
		var i,
7057
			valsLength = 0;
7058
 
7059
		if ( $.isArray( this.options.values ) ) {
7060
			valsLength = this.options.values.length;
7061
		}
7062
 
7063
		$.Widget.prototype._setOption.apply( this, arguments );
7064
 
7065
		switch ( key ) {
7066
			case "disabled":
7067
				if ( value ) {
7068
					this.handles.filter( ".ui-state-focus" ).blur();
7069
					this.handles.removeClass( "ui-state-hover" );
7070
					this.handles.attr( "disabled", "disabled" );
7071
					this.element.addClass( "ui-disabled" );
7072
				} else {
7073
					this.handles.removeAttr( "disabled" );
7074
					this.element.removeClass( "ui-disabled" );
7075
				}
7076
				break;
7077
			case "orientation":
7078
				this._detectOrientation();
7079
				this.element
7080
					.removeClass( "ui-slider-horizontal ui-slider-vertical" )
7081
					.addClass( "ui-slider-" + this.orientation );
7082
				this._refreshValue();
7083
				break;
7084
			case "value":
7085
				this._animateOff = true;
7086
				this._refreshValue();
7087
				this._change( null, 0 );
7088
				this._animateOff = false;
7089
				break;
7090
			case "values":
7091
				this._animateOff = true;
7092
				this._refreshValue();
7093
				for ( i = 0; i < valsLength; i += 1 ) {
7094
					this._change( null, i );
7095
				}
7096
				this._animateOff = false;
7097
				break;
7098
		}
7099
	},
7100
 
7101
	//internal value getter
7102
	// _value() returns value trimmed by min and max, aligned by step
7103
	_value: function() {
7104
		var val = this.options.value;
7105
		val = this._trimAlignValue( val );
7106
 
7107
		return val;
7108
	},
7109
 
7110
	//internal values getter
7111
	// _values() returns array of values trimmed by min and max, aligned by step
7112
	// _values( index ) returns single value trimmed by min and max, aligned by step
7113
	_values: function( index ) {
7114
		var val,
7115
			vals,
7116
			i;
7117
 
7118
		if ( arguments.length ) {
7119
			val = this.options.values[ index ];
7120
			val = this._trimAlignValue( val );
7121
 
7122
			return val;
7123
		} else {
7124
			// .slice() creates a copy of the array
7125
			// this copy gets trimmed by min and max and then returned
7126
			vals = this.options.values.slice();
7127
			for ( i = 0; i < vals.length; i+= 1) {
7128
				vals[ i ] = this._trimAlignValue( vals[ i ] );
7129
			}
7130
 
7131
			return vals;
7132
		}
7133
	},
7134
 
7135
	// returns the step-aligned value that val is closest to, between (inclusive) min and max
7136
	_trimAlignValue: function( val ) {
7137
		if ( val < this._valueMin() ) {
7138
			return this._valueMin();
7139
		}
7140
		if ( val > this._valueMax() ) {
7141
			return this._valueMax();
7142
		}
7143
		var step = ( this.options.step > 0 ) ? this.options.step : 1,
7144
			valModStep = val % step,
7145
			alignValue = val - valModStep;
7146
 
7147
		if ( Math.abs(valModStep) * 2 >= step ) {
7148
			alignValue += ( valModStep > 0 ) ? step : ( -step );
7149
		}
7150
 
7151
		// Since JavaScript has problems with large floats, round
7152
		// the final value to 5 digits after the decimal point (see #4124)
7153
		return parseFloat( alignValue.toFixed(5) );
7154
	},
7155
 
7156
	_valueMin: function() {
7157
		return this.options.min;
7158
	},
7159
 
7160
	_valueMax: function() {
7161
		return this.options.max;
7162
	},
7163
 
7164
	_refreshValue: function() {
7165
		var oRange = this.options.range,
7166
			o = this.options,
7167
			self = this,
7168
			animate = ( !this._animateOff ) ? o.animate : false,
7169
			valPercent,
7170
			_set = {},
7171
			lastValPercent,
7172
			value,
7173
			valueMin,
7174
			valueMax;
7175
 
7176
		if ( this.options.values && this.options.values.length ) {
7177
			this.handles.each(function( i, j ) {
7178
				valPercent = ( self.values(i) - self._valueMin() ) / ( self._valueMax() - self._valueMin() ) * 100;
7179
				_set[ self.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
7180
				$( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
7181
				if ( self.options.range === true ) {
7182
					if ( self.orientation === "horizontal" ) {
7183
						if ( i === 0 ) {
7184
							self.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { left: valPercent + "%" }, o.animate );
7185
						}
7186
						if ( i === 1 ) {
7187
							self.range[ animate ? "animate" : "css" ]( { width: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
7188
						}
7189
					} else {
7190
						if ( i === 0 ) {
7191
							self.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { bottom: ( valPercent ) + "%" }, o.animate );
7192
						}
7193
						if ( i === 1 ) {
7194
							self.range[ animate ? "animate" : "css" ]( { height: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
7195
						}
7196
					}
7197
				}
7198
				lastValPercent = valPercent;
7199
			});
7200
		} else {
7201
			value = this.value();
7202
			valueMin = this._valueMin();
7203
			valueMax = this._valueMax();
7204
			valPercent = ( valueMax !== valueMin ) ?
7205
					( value - valueMin ) / ( valueMax - valueMin ) * 100 :
7206
					0;
7207
			_set[ self.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
7208
			this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
7209
 
7210
			if ( oRange === "min" && this.orientation === "horizontal" ) {
7211
				this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { width: valPercent + "%" }, o.animate );
7212
			}
7213
			if ( oRange === "max" && this.orientation === "horizontal" ) {
7214
				this.range[ animate ? "animate" : "css" ]( { width: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
7215
			}
7216
			if ( oRange === "min" && this.orientation === "vertical" ) {
7217
				this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { height: valPercent + "%" }, o.animate );
7218
			}
7219
			if ( oRange === "max" && this.orientation === "vertical" ) {
7220
				this.range[ animate ? "animate" : "css" ]( { height: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
7221
			}
7222
		}
7223
	}
7224
 
7225
});
7226
 
7227
$.extend( $.ui.slider, {
7228
	version: "1.8.5"
7229
});
7230
 
7231
}(jQuery));
7232
/*
7233
 * jQuery UI Tabs 1.8.5
7234
 *
7235
 * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
7236
 * Dual licensed under the MIT or GPL Version 2 licenses.
7237
 * http://jquery.org/license
7238
 *
7239
 * http://docs.jquery.com/UI/Tabs
7240
 *
7241
 * Depends:
7242
 *	jquery.ui.core.js
7243
 *	jquery.ui.widget.js
7244
 */
7245
(function( $, undefined ) {
7246
 
7247
var tabId = 0,
7248
	listId = 0;
7249
 
7250
function getNextTabId() {
7251
	return ++tabId;
7252
}
7253
 
7254
function getNextListId() {
7255
	return ++listId;
7256
}
7257
 
7258
$.widget( "ui.tabs", {
7259
	options: {
7260
		add: null,
7261
		ajaxOptions: null,
7262
		cache: false,
7263
		cookie: null, // e.g. { expires: 7, path: '/', domain: 'jquery.com', secure: true }
7264
		collapsible: false,
7265
		disable: null,
7266
		disabled: [],
7267
		enable: null,
7268
		event: "click",
7269
		fx: null, // e.g. { height: 'toggle', opacity: 'toggle', duration: 200 }
7270
		idPrefix: "ui-tabs-",
7271
		load: null,
7272
		panelTemplate: "<div></div>",
7273
		remove: null,
7274
		select: null,
7275
		show: null,
7276
		spinner: "<em>Loading&#8230;</em>",
7277
		tabTemplate: "<li><a href='#{href}'><span>#{label}</span></a></li>"
7278
	},
7279
 
7280
	_create: function() {
7281
		this._tabify( true );
7282
	},
7283
 
7284
	_setOption: function( key, value ) {
7285
		if ( key == "selected" ) {
7286
			if (this.options.collapsible && value == this.options.selected ) {
7287
				return;
7288
			}
7289
			this.select( value );
7290
		} else {
7291
			this.options[ key ] = value;
7292
			this._tabify();
7293
		}
7294
	},
7295
 
7296
	_tabId: function( a ) {
7297
		return a.title && a.title.replace( /\s/g, "_" ).replace( /[^\w\u00c0-\uFFFF-]/g, "" ) ||
7298
			this.options.idPrefix + getNextTabId();
7299
	},
7300
 
7301
	_sanitizeSelector: function( hash ) {
7302
		// we need this because an id may contain a ":"
7303
		return hash.replace( /:/g, "\\:" );
7304
	},
7305
 
7306
	_cookie: function() {
7307
		var cookie = this.cookie ||
7308
			( this.cookie = this.options.cookie.name || "ui-tabs-" + getNextListId() );
7309
		return $.cookie.apply( null, [ cookie ].concat( $.makeArray( arguments ) ) );
7310
	},
7311
 
7312
	_ui: function( tab, panel ) {
7313
		return {
7314
			tab: tab,
7315
			panel: panel,
7316
			index: this.anchors.index( tab )
7317
		};
7318
	},
7319
 
7320
	_cleanup: function() {
7321
		// restore all former loading tabs labels
7322
		this.lis.filter( ".ui-state-processing" )
7323
			.removeClass( "ui-state-processing" )
7324
			.find( "span:data(label.tabs)" )
7325
				.each(function() {
7326
					var el = $( this );
7327
					el.html( el.data( "label.tabs" ) ).removeData( "label.tabs" );
7328
				});
7329
	},
7330
 
7331
	_tabify: function( init ) {
7332
		var self = this,
7333
			o = this.options,
7334
			fragmentId = /^#.+/; // Safari 2 reports '#' for an empty hash
7335
 
7336
		this.list = this.element.find( "ol,ul" ).eq( 0 );
7337
		this.lis = $( " > li:has(a[href])", this.list );
7338
		this.anchors = this.lis.map(function() {
7339
			return $( "a", this )[ 0 ];
7340
		});
7341
		this.panels = $( [] );
7342
 
7343
		this.anchors.each(function( i, a ) {
7344
			var href = $( a ).attr( "href" );
7345
			// For dynamically created HTML that contains a hash as href IE < 8 expands
7346
			// such href to the full page url with hash and then misinterprets tab as ajax.
7347
			// Same consideration applies for an added tab with a fragment identifier
7348
			// since a[href=#fragment-identifier] does unexpectedly not match.
7349
			// Thus normalize href attribute...
7350
			var hrefBase = href.split( "#" )[ 0 ],
7351
				baseEl;
7352
			if ( hrefBase && ( hrefBase === location.toString().split( "#" )[ 0 ] ||
7353
					( baseEl = $( "base" )[ 0 ]) && hrefBase === baseEl.href ) ) {
7354
				href = a.hash;
7355
				a.href = href;
7356
			}
7357
 
7358
			// inline tab
7359
			if ( fragmentId.test( href ) ) {
7360
				self.panels = self.panels.add( self._sanitizeSelector( href ) );
7361
			// remote tab
7362
			// prevent loading the page itself if href is just "#"
7363
			} else if ( href && href !== "#" ) {
7364
				// required for restore on destroy
7365
				$.data( a, "href.tabs", href );
7366
 
7367
				// TODO until #3808 is fixed strip fragment identifier from url
7368
				// (IE fails to load from such url)
7369
				$.data( a, "load.tabs", href.replace( /#.*$/, "" ) );
7370
 
7371
				var id = self._tabId( a );
7372
				a.href = "#" + id;
7373
				var $panel = $( "#" + id );
7374
				if ( !$panel.length ) {
7375
					$panel = $( o.panelTemplate )
7376
						.attr( "id", id )
7377
						.addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
7378
						.insertAfter( self.panels[ i - 1 ] || self.list );
7379
					$panel.data( "destroy.tabs", true );
7380
				}
7381
				self.panels = self.panels.add( $panel );
7382
			// invalid tab href
7383
			} else {
7384
				o.disabled.push( i );
7385
			}
7386
		});
7387
 
7388
		// initialization from scratch
7389
		if ( init ) {
7390
			// attach necessary classes for styling
7391
			this.element.addClass( "ui-tabs ui-widget ui-widget-content ui-corner-all" );
7392
			this.list.addClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" );
7393
			this.lis.addClass( "ui-state-default ui-corner-top" );
7394
			this.panels.addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" );
7395
 
7396
			// Selected tab
7397
			// use "selected" option or try to retrieve:
7398
			// 1. from fragment identifier in url
7399
			// 2. from cookie
7400
			// 3. from selected class attribute on <li>
7401
			if ( o.selected === undefined ) {
7402
				if ( location.hash ) {
7403
					this.anchors.each(function( i, a ) {
7404
						if ( a.hash == location.hash ) {
7405
							o.selected = i;
7406
							return false;
7407
						}
7408
					});
7409
				}
7410
				if ( typeof o.selected !== "number" && o.cookie ) {
7411
					o.selected = parseInt( self._cookie(), 10 );
7412
				}
7413
				if ( typeof o.selected !== "number" && this.lis.filter( ".ui-tabs-selected" ).length ) {
7414
					o.selected = this.lis.index( this.lis.filter( ".ui-tabs-selected" ) );
7415
				}
7416
				o.selected = o.selected || ( this.lis.length ? 0 : -1 );
7417
			} else if ( o.selected === null ) { // usage of null is deprecated, TODO remove in next release
7418
				o.selected = -1;
7419
			}
7420
 
7421
			// sanity check - default to first tab...
7422
			o.selected = ( ( o.selected >= 0 && this.anchors[ o.selected ] ) || o.selected < 0 )
7423
				? o.selected
7424
				: 0;
7425
 
7426
			// Take disabling tabs via class attribute from HTML
7427
			// into account and update option properly.
7428
			// A selected tab cannot become disabled.
7429
			o.disabled = $.unique( o.disabled.concat(
7430
				$.map( this.lis.filter( ".ui-state-disabled" ), function( n, i ) {
7431
					return self.lis.index( n );
7432
				})
7433
			) ).sort();
7434
 
7435
			if ( $.inArray( o.selected, o.disabled ) != -1 ) {
7436
				o.disabled.splice( $.inArray( o.selected, o.disabled ), 1 );
7437
			}
7438
 
7439
			// highlight selected tab
7440
			this.panels.addClass( "ui-tabs-hide" );
7441
			this.lis.removeClass( "ui-tabs-selected ui-state-active" );
7442
			// check for length avoids error when initializing empty list
7443
			if ( o.selected >= 0 && this.anchors.length ) {
7444
				this.panels.eq( o.selected ).removeClass( "ui-tabs-hide" );
7445
				this.lis.eq( o.selected ).addClass( "ui-tabs-selected ui-state-active" );
7446
 
7447
				// seems to be expected behavior that the show callback is fired
7448
				self.element.queue( "tabs", function() {
7449
					self._trigger( "show", null,
7450
						self._ui( self.anchors[ o.selected ], self.panels[ o.selected ] ) );
7451
				});
7452
 
7453
				this.load( o.selected );
7454
			}
7455
 
7456
			// clean up to avoid memory leaks in certain versions of IE 6
7457
			// TODO: namespace this event
7458
			$( window ).bind( "unload", function() {
7459
				self.lis.add( self.anchors ).unbind( ".tabs" );
7460
				self.lis = self.anchors = self.panels = null;
7461
			});
7462
		// update selected after add/remove
7463
		} else {
7464
			o.selected = this.lis.index( this.lis.filter( ".ui-tabs-selected" ) );
7465
		}
7466
 
7467
		// update collapsible
7468
		// TODO: use .toggleClass()
7469
		this.element[ o.collapsible ? "addClass" : "removeClass" ]( "ui-tabs-collapsible" );
7470
 
7471
		// set or update cookie after init and add/remove respectively
7472
		if ( o.cookie ) {
7473
			this._cookie( o.selected, o.cookie );
7474
		}
7475
 
7476
		// disable tabs
7477
		for ( var i = 0, li; ( li = this.lis[ i ] ); i++ ) {
7478
			$( li )[ $.inArray( i, o.disabled ) != -1 &&
7479
				// TODO: use .toggleClass()
7480
				!$( li ).hasClass( "ui-tabs-selected" ) ? "addClass" : "removeClass" ]( "ui-state-disabled" );
7481
		}
7482
 
7483
		// reset cache if switching from cached to not cached
7484
		if ( o.cache === false ) {
7485
			this.anchors.removeData( "cache.tabs" );
7486
		}
7487
 
7488
		// remove all handlers before, tabify may run on existing tabs after add or option change
7489
		this.lis.add( this.anchors ).unbind( ".tabs" );
7490
 
7491
		if ( o.event !== "mouseover" ) {
7492
			var addState = function( state, el ) {
7493
				if ( el.is( ":not(.ui-state-disabled)" ) ) {
7494
					el.addClass( "ui-state-" + state );
7495
				}
7496
			};
7497
			var removeState = function( state, el ) {
7498
				el.removeClass( "ui-state-" + state );
7499
			};
7500
			this.lis.bind( "mouseover.tabs" , function() {
7501
				addState( "hover", $( this ) );
7502
			});
7503
			this.lis.bind( "mouseout.tabs", function() {
7504
				removeState( "hover", $( this ) );
7505
			});
7506
			this.anchors.bind( "focus.tabs", function() {
7507
				addState( "focus", $( this ).closest( "li" ) );
7508
			});
7509
			this.anchors.bind( "blur.tabs", function() {
7510
				removeState( "focus", $( this ).closest( "li" ) );
7511
			});
7512
		}
7513
 
7514
		// set up animations
7515
		var hideFx, showFx;
7516
		if ( o.fx ) {
7517
			if ( $.isArray( o.fx ) ) {
7518
				hideFx = o.fx[ 0 ];
7519
				showFx = o.fx[ 1 ];
7520
			} else {
7521
				hideFx = showFx = o.fx;
7522
			}
7523
		}
7524
 
7525
		// Reset certain styles left over from animation
7526
		// and prevent IE's ClearType bug...
7527
		function resetStyle( $el, fx ) {
7528
			$el.css( "display", "" );
7529
			if ( !$.support.opacity && fx.opacity ) {
7530
				$el[ 0 ].style.removeAttribute( "filter" );
7531
			}
7532
		}
7533
 
7534
		// Show a tab...
7535
		var showTab = showFx
7536
			? function( clicked, $show ) {
7537
				$( clicked ).closest( "li" ).addClass( "ui-tabs-selected ui-state-active" );
7538
				$show.hide().removeClass( "ui-tabs-hide" ) // avoid flicker that way
7539
					.animate( showFx, showFx.duration || "normal", function() {
7540
						resetStyle( $show, showFx );
7541
						self._trigger( "show", null, self._ui( clicked, $show[ 0 ] ) );
7542
					});
7543
			}
7544
			: function( clicked, $show ) {
7545
				$( clicked ).closest( "li" ).addClass( "ui-tabs-selected ui-state-active" );
7546
				$show.removeClass( "ui-tabs-hide" );
7547
				self._trigger( "show", null, self._ui( clicked, $show[ 0 ] ) );
7548
			};
7549
 
7550
		// Hide a tab, $show is optional...
7551
		var hideTab = hideFx
7552
			? function( clicked, $hide ) {
7553
				$hide.animate( hideFx, hideFx.duration || "normal", function() {
7554
					self.lis.removeClass( "ui-tabs-selected ui-state-active" );
7555
					$hide.addClass( "ui-tabs-hide" );
7556
					resetStyle( $hide, hideFx );
7557
					self.element.dequeue( "tabs" );
7558
				});
7559
			}
7560
			: function( clicked, $hide, $show ) {
7561
				self.lis.removeClass( "ui-tabs-selected ui-state-active" );
7562
				$hide.addClass( "ui-tabs-hide" );
7563
				self.element.dequeue( "tabs" );
7564
			};
7565
 
7566
		// attach tab event handler, unbind to avoid duplicates from former tabifying...
7567
		this.anchors.bind( o.event + ".tabs", function() {
7568
			var el = this,
7569
				$li = $(el).closest( "li" ),
7570
				$hide = self.panels.filter( ":not(.ui-tabs-hide)" ),
7571
				$show = $( self._sanitizeSelector( el.hash ) );
7572
 
7573
			// If tab is already selected and not collapsible or tab disabled or
7574
			// or is already loading or click callback returns false stop here.
7575
			// Check if click handler returns false last so that it is not executed
7576
			// for a disabled or loading tab!
7577
			if ( ( $li.hasClass( "ui-tabs-selected" ) && !o.collapsible) ||
7578
				$li.hasClass( "ui-state-disabled" ) ||
7579
				$li.hasClass( "ui-state-processing" ) ||
7580
				self.panels.filter( ":animated" ).length ||
7581
				self._trigger( "select", null, self._ui( this, $show[ 0 ] ) ) === false ) {
7582
				this.blur();
7583
				return false;
7584
			}
7585
 
7586
			o.selected = self.anchors.index( this );
7587
 
7588
			self.abort();
7589
 
7590
			// if tab may be closed
7591
			if ( o.collapsible ) {
7592
				if ( $li.hasClass( "ui-tabs-selected" ) ) {
7593
					o.selected = -1;
7594
 
7595
					if ( o.cookie ) {
7596
						self._cookie( o.selected, o.cookie );
7597
					}
7598
 
7599
					self.element.queue( "tabs", function() {
7600
						hideTab( el, $hide );
7601
					}).dequeue( "tabs" );
7602
 
7603
					this.blur();
7604
					return false;
7605
				} else if ( !$hide.length ) {
7606
					if ( o.cookie ) {
7607
						self._cookie( o.selected, o.cookie );
7608
					}
7609
 
7610
					self.element.queue( "tabs", function() {
7611
						showTab( el, $show );
7612
					});
7613
 
7614
					// TODO make passing in node possible, see also http://dev.jqueryui.com/ticket/3171
7615
					self.load( self.anchors.index( this ) );
7616
 
7617
					this.blur();
7618
					return false;
7619
				}
7620
			}
7621
 
7622
			if ( o.cookie ) {
7623
				self._cookie( o.selected, o.cookie );
7624
			}
7625
 
7626
			// show new tab
7627
			if ( $show.length ) {
7628
				if ( $hide.length ) {
7629
					self.element.queue( "tabs", function() {
7630
						hideTab( el, $hide );
7631
					});
7632
				}
7633
				self.element.queue( "tabs", function() {
7634
					showTab( el, $show );
7635
				});
7636
 
7637
				self.load( self.anchors.index( this ) );
7638
			} else {
7639
				throw "jQuery UI Tabs: Mismatching fragment identifier.";
7640
			}
7641
 
7642
			// Prevent IE from keeping other link focussed when using the back button
7643
			// and remove dotted border from clicked link. This is controlled via CSS
7644
			// in modern browsers; blur() removes focus from address bar in Firefox
7645
			// which can become a usability and annoying problem with tabs('rotate').
7646
			if ( $.browser.msie ) {
7647
				this.blur();
7648
			}
7649
		});
7650
 
7651
		// disable click in any case
7652
		this.anchors.bind( "click.tabs", function(){
7653
			return false;
7654
		});
7655
	},
7656
 
7657
    _getIndex: function( index ) {
7658
		// meta-function to give users option to provide a href string instead of a numerical index.
7659
		// also sanitizes numerical indexes to valid values.
7660
		if ( typeof index == "string" ) {
7661
			index = this.anchors.index( this.anchors.filter( "[href$=" + index + "]" ) );
7662
		}
7663
 
7664
		return index;
7665
	},
7666
 
7667
	destroy: function() {
7668
		var o = this.options;
7669
 
7670
		this.abort();
7671
 
7672
		this.element
7673
			.unbind( ".tabs" )
7674
			.removeClass( "ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible" )
7675
			.removeData( "tabs" );
7676
 
7677
		this.list.removeClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" );
7678
 
7679
		this.anchors.each(function() {
7680
			var href = $.data( this, "href.tabs" );
7681
			if ( href ) {
7682
				this.href = href;
7683
			}
7684
			var $this = $( this ).unbind( ".tabs" );
7685
			$.each( [ "href", "load", "cache" ], function( i, prefix ) {
7686
				$this.removeData( prefix + ".tabs" );
7687
			});
7688
		});
7689
 
7690
		this.lis.unbind( ".tabs" ).add( this.panels ).each(function() {
7691
			if ( $.data( this, "destroy.tabs" ) ) {
7692
				$( this ).remove();
7693
			} else {
7694
				$( this ).removeClass([
7695
					"ui-state-default",
7696
					"ui-corner-top",
7697
					"ui-tabs-selected",
7698
					"ui-state-active",
7699
					"ui-state-hover",
7700
					"ui-state-focus",
7701
					"ui-state-disabled",
7702
					"ui-tabs-panel",
7703
					"ui-widget-content",
7704
					"ui-corner-bottom",
7705
					"ui-tabs-hide"
7706
				].join( " " ) );
7707
			}
7708
		});
7709
 
7710
		if ( o.cookie ) {
7711
			this._cookie( null, o.cookie );
7712
		}
7713
 
7714
		return this;
7715
	},
7716
 
7717
	add: function( url, label, index ) {
7718
		if ( index === undefined ) {
7719
			index = this.anchors.length;
7720
		}
7721
 
7722
		var self = this,
7723
			o = this.options,
7724
			$li = $( o.tabTemplate.replace( /#\{href\}/g, url ).replace( /#\{label\}/g, label ) ),
7725
			id = !url.indexOf( "#" ) ? url.replace( "#", "" ) : this._tabId( $( "a", $li )[ 0 ] );
7726
 
7727
		$li.addClass( "ui-state-default ui-corner-top" ).data( "destroy.tabs", true );
7728
 
7729
		// try to find an existing element before creating a new one
7730
		var $panel = $( "#" + id );
7731
		if ( !$panel.length ) {
7732
			$panel = $( o.panelTemplate )
7733
				.attr( "id", id )
7734
				.data( "destroy.tabs", true );
7735
		}
7736
		$panel.addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" );
7737
 
7738
		if ( index >= this.lis.length ) {
7739
			$li.appendTo( this.list );
7740
			$panel.appendTo( this.list[ 0 ].parentNode );
7741
		} else {
7742
			$li.insertBefore( this.lis[ index ] );
7743
			$panel.insertBefore( this.panels[ index ] );
7744
		}
7745
 
7746
		o.disabled = $.map( o.disabled, function( n, i ) {
7747
			return n >= index ? ++n : n;
7748
		});
7749
 
7750
		this._tabify();
7751
 
7752
		if ( this.anchors.length == 1 ) {
7753
			o.selected = 0;
7754
			$li.addClass( "ui-tabs-selected ui-state-active" );
7755
			$panel.removeClass( "ui-tabs-hide" );
7756
			this.element.queue( "tabs", function() {
7757
				self._trigger( "show", null, self._ui( self.anchors[ 0 ], self.panels[ 0 ] ) );
7758
			});
7759
 
7760
			this.load( 0 );
7761
		}
7762
 
7763
		this._trigger( "add", null, this._ui( this.anchors[ index ], this.panels[ index ] ) );
7764
		return this;
7765
	},
7766
 
7767
	remove: function( index ) {
7768
		index = this._getIndex( index );
7769
		var o = this.options,
7770
			$li = this.lis.eq( index ).remove(),
7771
			$panel = this.panels.eq( index ).remove();
7772
 
7773
		// If selected tab was removed focus tab to the right or
7774
		// in case the last tab was removed the tab to the left.
7775
		if ( $li.hasClass( "ui-tabs-selected" ) && this.anchors.length > 1) {
7776
			this.select( index + ( index + 1 < this.anchors.length ? 1 : -1 ) );
7777
		}
7778
 
7779
		o.disabled = $.map(
7780
			$.grep( o.disabled, function(n, i) {
7781
				return n != index;
7782
			}),
7783
			function( n, i ) {
7784
				return n >= index ? --n : n;
7785
			});
7786
 
7787
		this._tabify();
7788
 
7789
		this._trigger( "remove", null, this._ui( $li.find( "a" )[ 0 ], $panel[ 0 ] ) );
7790
		return this;
7791
	},
7792
 
7793
	enable: function( index ) {
7794
		index = this._getIndex( index );
7795
		var o = this.options;
7796
		if ( $.inArray( index, o.disabled ) == -1 ) {
7797
			return;
7798
		}
7799
 
7800
		this.lis.eq( index ).removeClass( "ui-state-disabled" );
7801
		o.disabled = $.grep( o.disabled, function( n, i ) {
7802
			return n != index;
7803
		});
7804
 
7805
		this._trigger( "enable", null, this._ui( this.anchors[ index ], this.panels[ index ] ) );
7806
		return this;
7807
	},
7808
 
7809
	disable: function( index ) {
7810
		index = this._getIndex( index );
7811
		var self = this, o = this.options;
7812
		// cannot disable already selected tab
7813
		if ( index != o.selected ) {
7814
			this.lis.eq( index ).addClass( "ui-state-disabled" );
7815
 
7816
			o.disabled.push( index );
7817
			o.disabled.sort();
7818
 
7819
			this._trigger( "disable", null, this._ui( this.anchors[ index ], this.panels[ index ] ) );
7820
		}
7821
 
7822
		return this;
7823
	},
7824
 
7825
	select: function( index ) {
7826
		index = this._getIndex( index );
7827
		if ( index == -1 ) {
7828
			if ( this.options.collapsible && this.options.selected != -1 ) {
7829
				index = this.options.selected;
7830
			} else {
7831
				return this;
7832
			}
7833
		}
7834
		this.anchors.eq( index ).trigger( this.options.event + ".tabs" );
7835
		return this;
7836
	},
7837
 
7838
	load: function( index ) {
7839
		index = this._getIndex( index );
7840
		var self = this,
7841
			o = this.options,
7842
			a = this.anchors.eq( index )[ 0 ],
7843
			url = $.data( a, "load.tabs" );
7844
 
7845
		this.abort();
7846
 
7847
		// not remote or from cache
7848
		if ( !url || this.element.queue( "tabs" ).length !== 0 && $.data( a, "cache.tabs" ) ) {
7849
			this.element.dequeue( "tabs" );
7850
			return;
7851
		}
7852
 
7853
		// load remote from here on
7854
		this.lis.eq( index ).addClass( "ui-state-processing" );
7855
 
7856
		if ( o.spinner ) {
7857
			var span = $( "span", a );
7858
			span.data( "label.tabs", span.html() ).html( o.spinner );
7859
		}
7860
 
7861
		this.xhr = $.ajax( $.extend( {}, o.ajaxOptions, {
7862
			url: url,
7863
			success: function( r, s ) {
7864
				$( self._sanitizeSelector( a.hash ) ).html( r );
7865
 
7866
				// take care of tab labels
7867
				self._cleanup();
7868
 
7869
				if ( o.cache ) {
7870
					$.data( a, "cache.tabs", true );
7871
				}
7872
 
7873
				self._trigger( "load", null, self._ui( self.anchors[ index ], self.panels[ index ] ) );
7874
				try {
7875
					o.ajaxOptions.success( r, s );
7876
				}
7877
				catch ( e ) {}
7878
			},
7879
			error: function( xhr, s, e ) {
7880
				// take care of tab labels
7881
				self._cleanup();
7882
 
7883
				self._trigger( "load", null, self._ui( self.anchors[ index ], self.panels[ index ] ) );
7884
				try {
7885
					// Passing index avoid a race condition when this method is
7886
					// called after the user has selected another tab.
7887
					// Pass the anchor that initiated this request allows
7888
					// loadError to manipulate the tab content panel via $(a.hash)
7889
					o.ajaxOptions.error( xhr, s, index, a );
7890
				}
7891
				catch ( e ) {}
7892
			}
7893
		} ) );
7894
 
7895
		// last, so that load event is fired before show...
7896
		self.element.dequeue( "tabs" );
7897
 
7898
		return this;
7899
	},
7900
 
7901
	abort: function() {
7902
		// stop possibly running animations
7903
		this.element.queue( [] );
7904
		this.panels.stop( false, true );
7905
 
7906
		// "tabs" queue must not contain more than two elements,
7907
		// which are the callbacks for the latest clicked tab...
7908
		this.element.queue( "tabs", this.element.queue( "tabs" ).splice( -2, 2 ) );
7909
 
7910
		// terminate pending requests from other tabs
7911
		if ( this.xhr ) {
7912
			this.xhr.abort();
7913
			delete this.xhr;
7914
		}
7915
 
7916
		// take care of tab labels
7917
		this._cleanup();
7918
		return this;
7919
	},
7920
 
7921
	url: function( index, url ) {
7922
		this.anchors.eq( index ).removeData( "cache.tabs" ).data( "load.tabs", url );
7923
		return this;
7924
	},
7925
 
7926
	length: function() {
7927
		return this.anchors.length;
7928
	}
7929
});
7930
 
7931
$.extend( $.ui.tabs, {
7932
	version: "1.8.5"
7933
});
7934
 
7935
/*
7936
 * Tabs Extensions
7937
 */
7938
 
7939
/*
7940
 * Rotate
7941
 */
7942
$.extend( $.ui.tabs.prototype, {
7943
	rotation: null,
7944
	rotate: function( ms, continuing ) {
7945
		var self = this,
7946
			o = this.options;
7947
 
7948
		var rotate = self._rotate || ( self._rotate = function( e ) {
7949
			clearTimeout( self.rotation );
7950
			self.rotation = setTimeout(function() {
7951
				var t = o.selected;
7952
				self.select( ++t < self.anchors.length ? t : 0 );
7953
			}, ms );
7954
 
7955
			if ( e ) {
7956
				e.stopPropagation();
7957
			}
7958
		});
7959
 
7960
		var stop = self._unrotate || ( self._unrotate = !continuing
7961
			? function(e) {
7962
				if (e.clientX) { // in case of a true click
7963
					self.rotate(null);
7964
				}
7965
			}
7966
			: function( e ) {
7967
				t = o.selected;
7968
				rotate();
7969
			});
7970
 
7971
		// start rotation
7972
		if ( ms ) {
7973
			this.element.bind( "tabsshow", rotate );
7974
			this.anchors.bind( o.event + ".tabs", stop );
7975
			rotate();
7976
		// stop rotation
7977
		} else {
7978
			clearTimeout( self.rotation );
7979
			this.element.unbind( "tabsshow", rotate );
7980
			this.anchors.unbind( o.event + ".tabs", stop );
7981
			delete this._rotate;
7982
			delete this._unrotate;
7983
		}
7984
 
7985
		return this;
7986
	}
7987
});
7988
 
7989
})( jQuery );
7990
/*
7991
 * jQuery UI Datepicker 1.8.5
7992
 *
7993
 * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
7994
 * Dual licensed under the MIT or GPL Version 2 licenses.
7995
 * http://jquery.org/license
7996
 *
7997
 * http://docs.jquery.com/UI/Datepicker
7998
 *
7999
 * Depends:
8000
 *	jquery.ui.core.js
8001
 */
8002
(function( $, undefined ) {
8003
 
8004
$.extend($.ui, { datepicker: { version: "1.8.5" } });
8005
 
8006
var PROP_NAME = 'datepicker';
8007
var dpuuid = new Date().getTime();
8008
 
8009
/* Date picker manager.
8010
   Use the singleton instance of this class, $.datepicker, to interact with the date picker.
8011
   Settings for (groups of) date pickers are maintained in an instance object,
8012
   allowing multiple different settings on the same page. */
8013
 
8014
function Datepicker() {
8015
	this.debug = false; // Change this to true to start debugging
8016
	this._curInst = null; // The current instance in use
8017
	this._keyEvent = false; // If the last event was a key event
8018
	this._disabledInputs = []; // List of date picker inputs that have been disabled
8019
	this._datepickerShowing = false; // True if the popup picker is showing , false if not
8020
	this._inDialog = false; // True if showing within a "dialog", false if not
8021
	this._mainDivId = 'ui-datepicker-div'; // The ID of the main datepicker division
8022
	this._inlineClass = 'ui-datepicker-inline'; // The name of the inline marker class
8023
	this._appendClass = 'ui-datepicker-append'; // The name of the append marker class
8024
	this._triggerClass = 'ui-datepicker-trigger'; // The name of the trigger marker class
8025
	this._dialogClass = 'ui-datepicker-dialog'; // The name of the dialog marker class
8026
	this._disableClass = 'ui-datepicker-disabled'; // The name of the disabled covering marker class
8027
	this._unselectableClass = 'ui-datepicker-unselectable'; // The name of the unselectable cell marker class
8028
	this._currentClass = 'ui-datepicker-current-day'; // The name of the current day marker class
8029
	this._dayOverClass = 'ui-datepicker-days-cell-over'; // The name of the day hover marker class
8030
	this.regional = []; // Available regional settings, indexed by language code
8031
	this.regional[''] = { // Default regional settings
8032
		closeText: 'Done', // Display text for close link
8033
		prevText: 'Prev', // Display text for previous month link
8034
		nextText: 'Next', // Display text for next month link
8035
		currentText: 'Today', // Display text for current month link
8036
		monthNames: ['January','February','March','April','May','June',
8037
			'July','August','September','October','November','December'], // Names of months for drop-down and formatting
8038
		monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], // For formatting
8039
		dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], // For formatting
8040
		dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], // For formatting
8041
		dayNamesMin: ['Su','Mo','Tu','We','Th','Fr','Sa'], // Column headings for days starting at Sunday
8042
		weekHeader: 'Wk', // Column header for week of the year
8043
		dateFormat: 'mm/dd/yy', // See format options on parseDate
8044
		firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
8045
		isRTL: false, // True if right-to-left language, false if left-to-right
8046
		showMonthAfterYear: false, // True if the year select precedes month, false for month then year
8047
		yearSuffix: '' // Additional text to append to the year in the month headers
8048
	};
8049
	this._defaults = { // Global defaults for all the date picker instances
8050
		showOn: 'focus', // 'focus' for popup on focus,
8051
			// 'button' for trigger button, or 'both' for either
8052
		showAnim: 'fadeIn', // Name of jQuery animation for popup
8053
		showOptions: {}, // Options for enhanced animations
8054
		defaultDate: null, // Used when field is blank: actual date,
8055
			// +/-number for offset from today, null for today
8056
		appendText: '', // Display text following the input box, e.g. showing the format
8057
		buttonText: '...', // Text for trigger button
8058
		buttonImage: '', // URL for trigger button image
8059
		buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
8060
		hideIfNoPrevNext: false, // True to hide next/previous month links
8061
			// if not applicable, false to just disable them
8062
		navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
8063
		gotoCurrent: false, // True if today link goes back to current selection instead
8064
		changeMonth: false, // True if month can be selected directly, false if only prev/next
8065
		changeYear: false, // True if year can be selected directly, false if only prev/next
8066
		yearRange: 'c-10:c+10', // Range of years to display in drop-down,
8067
			// either relative to today's year (-nn:+nn), relative to currently displayed year
8068
			// (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
8069
		showOtherMonths: false, // True to show dates in other months, false to leave blank
8070
		selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable
8071
		showWeek: false, // True to show week of the year, false to not show it
8072
		calculateWeek: this.iso8601Week, // How to calculate the week of the year,
8073
			// takes a Date and returns the number of the week for it
8074
		shortYearCutoff: '+10', // Short year values < this are in the current century,
8075
			// > this are in the previous century,
8076
			// string value starting with '+' for current year + value
8077
		minDate: null, // The earliest selectable date, or null for no limit
8078
		maxDate: null, // The latest selectable date, or null for no limit
8079
		duration: 'fast', // Duration of display/closure
8080
		beforeShowDay: null, // Function that takes a date and returns an array with
8081
			// [0] = true if selectable, false if not, [1] = custom CSS class name(s) or '',
8082
			// [2] = cell title (optional), e.g. $.datepicker.noWeekends
8083
		beforeShow: null, // Function that takes an input field and
8084
			// returns a set of custom settings for the date picker
8085
		onSelect: null, // Define a callback function when a date is selected
8086
		onChangeMonthYear: null, // Define a callback function when the month or year is changed
8087
		onClose: null, // Define a callback function when the datepicker is closed
8088
		numberOfMonths: 1, // Number of months to show at a time
8089
		showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
8090
		stepMonths: 1, // Number of months to step back/forward
8091
		stepBigMonths: 12, // Number of months to step back/forward for the big links
8092
		altField: '', // Selector for an alternate field to store selected dates into
8093
		altFormat: '', // The date format to use for the alternate field
8094
		constrainInput: true, // The input is constrained by the current date format
8095
		showButtonPanel: false, // True to show button panel, false to not show it
8096
		autoSize: false // True to size the input for the date format, false to leave as is
8097
	};
8098
	$.extend(this._defaults, this.regional['']);
8099
	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>');
8100
}
8101
 
8102
$.extend(Datepicker.prototype, {
8103
	/* Class name added to elements to indicate already configured with a date picker. */
8104
	markerClassName: 'hasDatepicker',
8105
 
8106
	/* Debug logging (if enabled). */
8107
	log: function () {
8108
		if (this.debug)
8109
			console.log.apply('', arguments);
8110
	},
8111
 
8112
	// TODO rename to "widget" when switching to widget factory
8113
	_widgetDatepicker: function() {
8114
		return this.dpDiv;
8115
	},
8116
 
8117
	/* Override the default settings for all instances of the date picker.
8118
	   @param  settings  object - the new settings to use as defaults (anonymous object)
8119
	   @return the manager object */
8120
	setDefaults: function(settings) {
8121
		extendRemove(this._defaults, settings || {});
8122
		return this;
8123
	},
8124
 
8125
	/* Attach the date picker to a jQuery selection.
8126
	   @param  target    element - the target input field or division or span
8127
	   @param  settings  object - the new settings to use for this date picker instance (anonymous) */
8128
	_attachDatepicker: function(target, settings) {
8129
		// check for settings on the control itself - in namespace 'date:'
8130
		var inlineSettings = null;
8131
		for (var attrName in this._defaults) {
8132
			var attrValue = target.getAttribute('date:' + attrName);
8133
			if (attrValue) {
8134
				inlineSettings = inlineSettings || {};
8135
				try {
8136
					inlineSettings[attrName] = eval(attrValue);
8137
				} catch (err) {
8138
					inlineSettings[attrName] = attrValue;
8139
				}
8140
			}
8141
		}
8142
		var nodeName = target.nodeName.toLowerCase();
8143
		var inline = (nodeName == 'div' || nodeName == 'span');
8144
		if (!target.id) {
8145
			this.uuid += 1;
8146
			target.id = 'dp' + this.uuid;
8147
		}
8148
		var inst = this._newInst($(target), inline);
8149
		inst.settings = $.extend({}, settings || {}, inlineSettings || {});
8150
		if (nodeName == 'input') {
8151
			this._connectDatepicker(target, inst);
8152
		} else if (inline) {
8153
			this._inlineDatepicker(target, inst);
8154
		}
8155
	},
8156
 
8157
	/* Create a new instance object. */
8158
	_newInst: function(target, inline) {
8159
		var id = target[0].id.replace(/([^A-Za-z0-9_])/g, '\\\\$1'); // escape jQuery meta chars
8160
		return {id: id, input: target, // associated target
8161
			selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
8162
			drawMonth: 0, drawYear: 0, // month being drawn
8163
			inline: inline, // is datepicker inline or not
8164
			dpDiv: (!inline ? this.dpDiv : // presentation div
8165
			$('<div class="' + this._inlineClass + ' ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>'))};
8166
	},
8167
 
8168
	/* Attach the date picker to an input field. */
8169
	_connectDatepicker: function(target, inst) {
8170
		var input = $(target);
8171
		inst.append = $([]);
8172
		inst.trigger = $([]);
8173
		if (input.hasClass(this.markerClassName))
8174
			return;
8175
		this._attachments(input, inst);
8176
		input.addClass(this.markerClassName).keydown(this._doKeyDown).
8177
			keypress(this._doKeyPress).keyup(this._doKeyUp).
8178
			bind("setData.datepicker", function(event, key, value) {
8179
				inst.settings[key] = value;
8180
			}).bind("getData.datepicker", function(event, key) {
8181
				return this._get(inst, key);
8182
			});
8183
		this._autoSize(inst);
8184
		$.data(target, PROP_NAME, inst);
8185
	},
8186
 
8187
	/* Make attachments based on settings. */
8188
	_attachments: function(input, inst) {
8189
		var appendText = this._get(inst, 'appendText');
8190
		var isRTL = this._get(inst, 'isRTL');
8191
		if (inst.append)
8192
			inst.append.remove();
8193
		if (appendText) {
8194
			inst.append = $('<span class="' + this._appendClass + '">' + appendText + '</span>');
8195
			input[isRTL ? 'before' : 'after'](inst.append);
8196
		}
8197
		input.unbind('focus', this._showDatepicker);
8198
		if (inst.trigger)
8199
			inst.trigger.remove();
8200
		var showOn = this._get(inst, 'showOn');
8201
		if (showOn == 'focus' || showOn == 'both') // pop-up date picker when in the marked field
8202
			input.focus(this._showDatepicker);
8203
		if (showOn == 'button' || showOn == 'both') { // pop-up date picker when button clicked
8204
			var buttonText = this._get(inst, 'buttonText');
8205
			var buttonImage = this._get(inst, 'buttonImage');
8206
			inst.trigger = $(this._get(inst, 'buttonImageOnly') ?
8207
				$('<img/>').addClass(this._triggerClass).
8208
					attr({ src: buttonImage, alt: buttonText, title: buttonText }) :
8209
				$('<button type="button"></button>').addClass(this._triggerClass).
8210
					html(buttonImage == '' ? buttonText : $('<img/>').attr(
8211
					{ src:buttonImage, alt:buttonText, title:buttonText })));
8212
			input[isRTL ? 'before' : 'after'](inst.trigger);
8213
			inst.trigger.click(function() {
8214
				if ($.datepicker._datepickerShowing && $.datepicker._lastInput == input[0])
8215
					$.datepicker._hideDatepicker();
8216
				else
8217
					$.datepicker._showDatepicker(input[0]);
8218
				return false;
8219
			});
8220
		}
8221
	},
8222
 
8223
	/* Apply the maximum length for the date format. */
8224
	_autoSize: function(inst) {
8225
		if (this._get(inst, 'autoSize') && !inst.inline) {
8226
			var date = new Date(2009, 12 - 1, 20); // Ensure double digits
8227
			var dateFormat = this._get(inst, 'dateFormat');
8228
			if (dateFormat.match(/[DM]/)) {
8229
				var findMax = function(names) {
8230
					var max = 0;
8231
					var maxI = 0;
8232
					for (var i = 0; i < names.length; i++) {
8233
						if (names[i].length > max) {
8234
							max = names[i].length;
8235
							maxI = i;
8236
						}
8237
					}
8238
					return maxI;
8239
				};
8240
				date.setMonth(findMax(this._get(inst, (dateFormat.match(/MM/) ?
8241
					'monthNames' : 'monthNamesShort'))));
8242
				date.setDate(findMax(this._get(inst, (dateFormat.match(/DD/) ?
8243
					'dayNames' : 'dayNamesShort'))) + 20 - date.getDay());
8244
			}
8245
			inst.input.attr('size', this._formatDate(inst, date).length);
8246
		}
8247
	},
8248
 
8249
	/* Attach an inline date picker to a div. */
8250
	_inlineDatepicker: function(target, inst) {
8251
		var divSpan = $(target);
8252
		if (divSpan.hasClass(this.markerClassName))
8253
			return;
8254
		divSpan.addClass(this.markerClassName).append(inst.dpDiv).
8255
			bind("setData.datepicker", function(event, key, value){
8256
				inst.settings[key] = value;
8257
			}).bind("getData.datepicker", function(event, key){
8258
				return this._get(inst, key);
8259
			});
8260
		$.data(target, PROP_NAME, inst);
8261
		this._setDate(inst, this._getDefaultDate(inst), true);
8262
		this._updateDatepicker(inst);
8263
		this._updateAlternate(inst);
8264
	},
8265
 
8266
	/* Pop-up the date picker in a "dialog" box.
8267
	   @param  input     element - ignored
8268
	   @param  date      string or Date - the initial date to display
8269
	   @param  onSelect  function - the function to call when a date is selected
8270
	   @param  settings  object - update the dialog date picker instance's settings (anonymous object)
8271
	   @param  pos       int[2] - coordinates for the dialog's position within the screen or
8272
	                     event - with x/y coordinates or
8273
	                     leave empty for default (screen centre)
8274
	   @return the manager object */
8275
	_dialogDatepicker: function(input, date, onSelect, settings, pos) {
8276
		var inst = this._dialogInst; // internal instance
8277
		if (!inst) {
8278
			this.uuid += 1;
8279
			var id = 'dp' + this.uuid;
8280
			this._dialogInput = $('<input type="text" id="' + id +
8281
				'" style="position: absolute; top: -100px; width: 0px; z-index: -10;"/>');
8282
			this._dialogInput.keydown(this._doKeyDown);
8283
			$('body').append(this._dialogInput);
8284
			inst = this._dialogInst = this._newInst(this._dialogInput, false);
8285
			inst.settings = {};
8286
			$.data(this._dialogInput[0], PROP_NAME, inst);
8287
		}
8288
		extendRemove(inst.settings, settings || {});
8289
		date = (date && date.constructor == Date ? this._formatDate(inst, date) : date);
8290
		this._dialogInput.val(date);
8291
 
8292
		this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null);
8293
		if (!this._pos) {
8294
			var browserWidth = document.documentElement.clientWidth;
8295
			var browserHeight = document.documentElement.clientHeight;
8296
			var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
8297
			var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
8298
			this._pos = // should use actual width/height below
8299
				[(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY];
8300
		}
8301
 
8302
		// move input on screen for focus, but hidden behind dialog
8303
		this._dialogInput.css('left', (this._pos[0] + 20) + 'px').css('top', this._pos[1] + 'px');
8304
		inst.settings.onSelect = onSelect;
8305
		this._inDialog = true;
8306
		this.dpDiv.addClass(this._dialogClass);
8307
		this._showDatepicker(this._dialogInput[0]);
8308
		if ($.blockUI)
8309
			$.blockUI(this.dpDiv);
8310
		$.data(this._dialogInput[0], PROP_NAME, inst);
8311
		return this;
8312
	},
8313
 
8314
	/* Detach a datepicker from its control.
8315
	   @param  target    element - the target input field or division or span */
8316
	_destroyDatepicker: function(target) {
8317
		var $target = $(target);
8318
		var inst = $.data(target, PROP_NAME);
8319
		if (!$target.hasClass(this.markerClassName)) {
8320
			return;
8321
		}
8322
		var nodeName = target.nodeName.toLowerCase();
8323
		$.removeData(target, PROP_NAME);
8324
		if (nodeName == 'input') {
8325
			inst.append.remove();
8326
			inst.trigger.remove();
8327
			$target.removeClass(this.markerClassName).
8328
				unbind('focus', this._showDatepicker).
8329
				unbind('keydown', this._doKeyDown).
8330
				unbind('keypress', this._doKeyPress).
8331
				unbind('keyup', this._doKeyUp);
8332
		} else if (nodeName == 'div' || nodeName == 'span')
8333
			$target.removeClass(this.markerClassName).empty();
8334
	},
8335
 
8336
	/* Enable the date picker to a jQuery selection.
8337
	   @param  target    element - the target input field or division or span */
8338
	_enableDatepicker: function(target) {
8339
		var $target = $(target);
8340
		var inst = $.data(target, PROP_NAME);
8341
		if (!$target.hasClass(this.markerClassName)) {
8342
			return;
8343
		}
8344
		var nodeName = target.nodeName.toLowerCase();
8345
		if (nodeName == 'input') {
8346
			target.disabled = false;
8347
			inst.trigger.filter('button').
8348
				each(function() { this.disabled = false; }).end().
8349
				filter('img').css({opacity: '1.0', cursor: ''});
8350
		}
8351
		else if (nodeName == 'div' || nodeName == 'span') {
8352
			var inline = $target.children('.' + this._inlineClass);
8353
			inline.children().removeClass('ui-state-disabled');
8354
		}
8355
		this._disabledInputs = $.map(this._disabledInputs,
8356
			function(value) { return (value == target ? null : value); }); // delete entry
8357
	},
8358
 
8359
	/* Disable the date picker to a jQuery selection.
8360
	   @param  target    element - the target input field or division or span */
8361
	_disableDatepicker: function(target) {
8362
		var $target = $(target);
8363
		var inst = $.data(target, PROP_NAME);
8364
		if (!$target.hasClass(this.markerClassName)) {
8365
			return;
8366
		}
8367
		var nodeName = target.nodeName.toLowerCase();
8368
		if (nodeName == 'input') {
8369
			target.disabled = true;
8370
			inst.trigger.filter('button').
8371
				each(function() { this.disabled = true; }).end().
8372
				filter('img').css({opacity: '0.5', cursor: 'default'});
8373
		}
8374
		else if (nodeName == 'div' || nodeName == 'span') {
8375
			var inline = $target.children('.' + this._inlineClass);
8376
			inline.children().addClass('ui-state-disabled');
8377
		}
8378
		this._disabledInputs = $.map(this._disabledInputs,
8379
			function(value) { return (value == target ? null : value); }); // delete entry
8380
		this._disabledInputs[this._disabledInputs.length] = target;
8381
	},
8382
 
8383
	/* Is the first field in a jQuery collection disabled as a datepicker?
8384
	   @param  target    element - the target input field or division or span
8385
	   @return boolean - true if disabled, false if enabled */
8386
	_isDisabledDatepicker: function(target) {
8387
		if (!target) {
8388
			return false;
8389
		}
8390
		for (var i = 0; i < this._disabledInputs.length; i++) {
8391
			if (this._disabledInputs[i] == target)
8392
				return true;
8393
		}
8394
		return false;
8395
	},
8396
 
8397
	/* Retrieve the instance data for the target control.
8398
	   @param  target  element - the target input field or division or span
8399
	   @return  object - the associated instance data
8400
	   @throws  error if a jQuery problem getting data */
8401
	_getInst: function(target) {
8402
		try {
8403
			return $.data(target, PROP_NAME);
8404
		}
8405
		catch (err) {
8406
			throw 'Missing instance data for this datepicker';
8407
		}
8408
	},
8409
 
8410
	/* Update or retrieve the settings for a date picker attached to an input field or division.
8411
	   @param  target  element - the target input field or division or span
8412
	   @param  name    object - the new settings to update or
8413
	                   string - the name of the setting to change or retrieve,
8414
	                   when retrieving also 'all' for all instance settings or
8415
	                   'defaults' for all global defaults
8416
	   @param  value   any - the new value for the setting
8417
	                   (omit if above is an object or to retrieve a value) */
8418
	_optionDatepicker: function(target, name, value) {
8419
		var inst = this._getInst(target);
8420
		if (arguments.length == 2 && typeof name == 'string') {
8421
			return (name == 'defaults' ? $.extend({}, $.datepicker._defaults) :
8422
				(inst ? (name == 'all' ? $.extend({}, inst.settings) :
8423
				this._get(inst, name)) : null));
8424
		}
8425
		var settings = name || {};
8426
		if (typeof name == 'string') {
8427
			settings = {};
8428
			settings[name] = value;
8429
		}
8430
		if (inst) {
8431
			if (this._curInst == inst) {
8432
				this._hideDatepicker();
8433
			}
8434
			var date = this._getDateDatepicker(target, true);
8435
			extendRemove(inst.settings, settings);
8436
			this._attachments($(target), inst);
8437
			this._autoSize(inst);
8438
			this._setDateDatepicker(target, date);
8439
			this._updateDatepicker(inst);
8440
		}
8441
	},
8442
 
8443
	// change method deprecated
8444
	_changeDatepicker: function(target, name, value) {
8445
		this._optionDatepicker(target, name, value);
8446
	},
8447
 
8448
	/* Redraw the date picker attached to an input field or division.
8449
	   @param  target  element - the target input field or division or span */
8450
	_refreshDatepicker: function(target) {
8451
		var inst = this._getInst(target);
8452
		if (inst) {
8453
			this._updateDatepicker(inst);
8454
		}
8455
	},
8456
 
8457
	/* Set the dates for a jQuery selection.
8458
	   @param  target   element - the target input field or division or span
8459
	   @param  date     Date - the new date */
8460
	_setDateDatepicker: function(target, date) {
8461
		var inst = this._getInst(target);
8462
		if (inst) {
8463
			this._setDate(inst, date);
8464
			this._updateDatepicker(inst);
8465
			this._updateAlternate(inst);
8466
		}
8467
	},
8468
 
8469
	/* Get the date(s) for the first entry in a jQuery selection.
8470
	   @param  target     element - the target input field or division or span
8471
	   @param  noDefault  boolean - true if no default date is to be used
8472
	   @return Date - the current date */
8473
	_getDateDatepicker: function(target, noDefault) {
8474
		var inst = this._getInst(target);
8475
		if (inst && !inst.inline)
8476
			this._setDateFromField(inst, noDefault);
8477
		return (inst ? this._getDate(inst) : null);
8478
	},
8479
 
8480
	/* Handle keystrokes. */
8481
	_doKeyDown: function(event) {
8482
		var inst = $.datepicker._getInst(event.target);
8483
		var handled = true;
8484
		var isRTL = inst.dpDiv.is('.ui-datepicker-rtl');
8485
		inst._keyEvent = true;
8486
		if ($.datepicker._datepickerShowing)
8487
			switch (event.keyCode) {
8488
				case 9: $.datepicker._hideDatepicker();
8489
						handled = false;
8490
						break; // hide on tab out
8491
				case 13: var sel = $('td.' + $.datepicker._dayOverClass, inst.dpDiv).
8492
							add($('td.' + $.datepicker._currentClass, inst.dpDiv));
8493
						if (sel[0])
8494
							$.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]);
8495
						else
8496
							$.datepicker._hideDatepicker();
8497
						return false; // don't submit the form
8498
						break; // select the value on enter
8499
				case 27: $.datepicker._hideDatepicker();
8500
						break; // hide on escape
8501
				case 33: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
8502
							-$.datepicker._get(inst, 'stepBigMonths') :
8503
							-$.datepicker._get(inst, 'stepMonths')), 'M');
8504
						break; // previous month/year on page up/+ ctrl
8505
				case 34: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
8506
							+$.datepicker._get(inst, 'stepBigMonths') :
8507
							+$.datepicker._get(inst, 'stepMonths')), 'M');
8508
						break; // next month/year on page down/+ ctrl
8509
				case 35: if (event.ctrlKey || event.metaKey) $.datepicker._clearDate(event.target);
8510
						handled = event.ctrlKey || event.metaKey;
8511
						break; // clear on ctrl or command +end
8512
				case 36: if (event.ctrlKey || event.metaKey) $.datepicker._gotoToday(event.target);
8513
						handled = event.ctrlKey || event.metaKey;
8514
						break; // current on ctrl or command +home
8515
				case 37: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), 'D');
8516
						handled = event.ctrlKey || event.metaKey;
8517
						// -1 day on ctrl or command +left
8518
						if (event.originalEvent.altKey) $.datepicker._adjustDate(event.target, (event.ctrlKey ?
8519
									-$.datepicker._get(inst, 'stepBigMonths') :
8520
									-$.datepicker._get(inst, 'stepMonths')), 'M');
8521
						// next month/year on alt +left on Mac
8522
						break;
8523
				case 38: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, -7, 'D');
8524
						handled = event.ctrlKey || event.metaKey;
8525
						break; // -1 week on ctrl or command +up
8526
				case 39: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), 'D');
8527
						handled = event.ctrlKey || event.metaKey;
8528
						// +1 day on ctrl or command +right
8529
						if (event.originalEvent.altKey) $.datepicker._adjustDate(event.target, (event.ctrlKey ?
8530
									+$.datepicker._get(inst, 'stepBigMonths') :
8531
									+$.datepicker._get(inst, 'stepMonths')), 'M');
8532
						// next month/year on alt +right
8533
						break;
8534
				case 40: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, +7, 'D');
8535
						handled = event.ctrlKey || event.metaKey;
8536
						break; // +1 week on ctrl or command +down
8537
				default: handled = false;
8538
			}
8539
		else if (event.keyCode == 36 && event.ctrlKey) // display the date picker on ctrl+home
8540
			$.datepicker._showDatepicker(this);
8541
		else {
8542
			handled = false;
8543
		}
8544
		if (handled) {
8545
			event.preventDefault();
8546
			event.stopPropagation();
8547
		}
8548
	},
8549
 
8550
	/* Filter entered characters - based on date format. */
8551
	_doKeyPress: function(event) {
8552
		var inst = $.datepicker._getInst(event.target);
8553
		if ($.datepicker._get(inst, 'constrainInput')) {
8554
			var chars = $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat'));
8555
			var chr = String.fromCharCode(event.charCode == undefined ? event.keyCode : event.charCode);
8556
			return event.ctrlKey || (chr < ' ' || !chars || chars.indexOf(chr) > -1);
8557
		}
8558
	},
8559
 
8560
	/* Synchronise manual entry and field/alternate field. */
8561
	_doKeyUp: function(event) {
8562
		var inst = $.datepicker._getInst(event.target);
8563
		if (inst.input.val() != inst.lastVal) {
8564
			try {
8565
				var date = $.datepicker.parseDate($.datepicker._get(inst, 'dateFormat'),
8566
					(inst.input ? inst.input.val() : null),
8567
					$.datepicker._getFormatConfig(inst));
8568
				if (date) { // only if valid
8569
					$.datepicker._setDateFromField(inst);
8570
					$.datepicker._updateAlternate(inst);
8571
					$.datepicker._updateDatepicker(inst);
8572
				}
8573
			}
8574
			catch (event) {
8575
				$.datepicker.log(event);
8576
			}
8577
		}
8578
		return true;
8579
	},
8580
 
8581
	/* Pop-up the date picker for a given input field.
8582
	   @param  input  element - the input field attached to the date picker or
8583
	                  event - if triggered by focus */
8584
	_showDatepicker: function(input) {
8585
		input = input.target || input;
8586
		if (input.nodeName.toLowerCase() != 'input') // find from button/image trigger
8587
			input = $('input', input.parentNode)[0];
8588
		if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput == input) // already here
8589
			return;
8590
		var inst = $.datepicker._getInst(input);
8591
		if ($.datepicker._curInst && $.datepicker._curInst != inst) {
8592
			$.datepicker._curInst.dpDiv.stop(true, true);
8593
		}
8594
		var beforeShow = $.datepicker._get(inst, 'beforeShow');
8595
		extendRemove(inst.settings, (beforeShow ? beforeShow.apply(input, [input, inst]) : {}));
8596
		inst.lastVal = null;
8597
		$.datepicker._lastInput = input;
8598
		$.datepicker._setDateFromField(inst);
8599
		if ($.datepicker._inDialog) // hide cursor
8600
			input.value = '';
8601
		if (!$.datepicker._pos) { // position below input
8602
			$.datepicker._pos = $.datepicker._findPos(input);
8603
			$.datepicker._pos[1] += input.offsetHeight; // add the height
8604
		}
8605
		var isFixed = false;
8606
		$(input).parents().each(function() {
8607
			isFixed |= $(this).css('position') == 'fixed';
8608
			return !isFixed;
8609
		});
8610
		if (isFixed && $.browser.opera) { // correction for Opera when fixed and scrolled
8611
			$.datepicker._pos[0] -= document.documentElement.scrollLeft;
8612
			$.datepicker._pos[1] -= document.documentElement.scrollTop;
8613
		}
8614
		var offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]};
8615
		$.datepicker._pos = null;
8616
		// determine sizing offscreen
8617
		inst.dpDiv.css({position: 'absolute', display: 'block', top: '-1000px'});
8618
		$.datepicker._updateDatepicker(inst);
8619
		// fix width for dynamic number of date pickers
8620
		// and adjust position before showing
8621
		offset = $.datepicker._checkOffset(inst, offset, isFixed);
8622
		inst.dpDiv.css({position: ($.datepicker._inDialog && $.blockUI ?
8623
			'static' : (isFixed ? 'fixed' : 'absolute')), display: 'none',
8624
			left: offset.left + 'px', top: offset.top + 'px'});
8625
		if (!inst.inline) {
8626
			var showAnim = $.datepicker._get(inst, 'showAnim');
8627
			var duration = $.datepicker._get(inst, 'duration');
8628
			var postProcess = function() {
8629
				$.datepicker._datepickerShowing = true;
8630
				var borders = $.datepicker._getBorders(inst.dpDiv);
8631
				inst.dpDiv.find('iframe.ui-datepicker-cover'). // IE6- only
8632
					css({left: -borders[0], top: -borders[1],
8633
						width: inst.dpDiv.outerWidth(), height: inst.dpDiv.outerHeight()});
8634
			};
8635
			inst.dpDiv.zIndex($(input).zIndex()+1);
8636
			if ($.effects && $.effects[showAnim])
8637
				inst.dpDiv.show(showAnim, $.datepicker._get(inst, 'showOptions'), duration, postProcess);
8638
			else
8639
				inst.dpDiv[showAnim || 'show']((showAnim ? duration : null), postProcess);
8640
			if (!showAnim || !duration)
8641
				postProcess();
8642
			if (inst.input.is(':visible') && !inst.input.is(':disabled'))
8643
				inst.input.focus();
8644
			$.datepicker._curInst = inst;
8645
		}
8646
	},
8647
 
8648
	/* Generate the date picker content. */
8649
	_updateDatepicker: function(inst) {
8650
		var self = this;
8651
		var borders = $.datepicker._getBorders(inst.dpDiv);
8652
		inst.dpDiv.empty().append(this._generateHTML(inst))
8653
			.find('iframe.ui-datepicker-cover') // IE6- only
8654
				.css({left: -borders[0], top: -borders[1],
8655
					width: inst.dpDiv.outerWidth(), height: inst.dpDiv.outerHeight()})
8656
			.end()
8657
			.find('button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a')
8658
				.bind('mouseout', function(){
8659
					$(this).removeClass('ui-state-hover');
8660
					if(this.className.indexOf('ui-datepicker-prev') != -1) $(this).removeClass('ui-datepicker-prev-hover');
8661
					if(this.className.indexOf('ui-datepicker-next') != -1) $(this).removeClass('ui-datepicker-next-hover');
8662
				})
8663
				.bind('mouseover', function(){
8664
					if (!self._isDisabledDatepicker( inst.inline ? inst.dpDiv.parent()[0] : inst.input[0])) {
8665
						$(this).parents('.ui-datepicker-calendar').find('a').removeClass('ui-state-hover');
8666
						$(this).addClass('ui-state-hover');
8667
						if(this.className.indexOf('ui-datepicker-prev') != -1) $(this).addClass('ui-datepicker-prev-hover');
8668
						if(this.className.indexOf('ui-datepicker-next') != -1) $(this).addClass('ui-datepicker-next-hover');
8669
					}
8670
				})
8671
			.end()
8672
			.find('.' + this._dayOverClass + ' a')
8673
				.trigger('mouseover')
8674
			.end();
8675
		var numMonths = this._getNumberOfMonths(inst);
8676
		var cols = numMonths[1];
8677
		var width = 17;
8678
		if (cols > 1)
8679
			inst.dpDiv.addClass('ui-datepicker-multi-' + cols).css('width', (width * cols) + 'em');
8680
		else
8681
			inst.dpDiv.removeClass('ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4').width('');
8682
		inst.dpDiv[(numMonths[0] != 1 || numMonths[1] != 1 ? 'add' : 'remove') +
8683
			'Class']('ui-datepicker-multi');
8684
		inst.dpDiv[(this._get(inst, 'isRTL') ? 'add' : 'remove') +
8685
			'Class']('ui-datepicker-rtl');
8686
		if (inst == $.datepicker._curInst && $.datepicker._datepickerShowing && inst.input &&
8687
				inst.input.is(':visible') && !inst.input.is(':disabled'))
8688
			inst.input.focus();
8689
	},
8690
 
8691
	/* Retrieve the size of left and top borders for an element.
8692
	   @param  elem  (jQuery object) the element of interest
8693
	   @return  (number[2]) the left and top borders */
8694
	_getBorders: function(elem) {
8695
		var convert = function(value) {
8696
			return {thin: 1, medium: 2, thick: 3}[value] || value;
8697
		};
8698
		return [parseFloat(convert(elem.css('border-left-width'))),
8699
			parseFloat(convert(elem.css('border-top-width')))];
8700
	},
8701
 
8702
	/* Check positioning to remain on screen. */
8703
	_checkOffset: function(inst, offset, isFixed) {
8704
		var dpWidth = inst.dpDiv.outerWidth();
8705
		var dpHeight = inst.dpDiv.outerHeight();
8706
		var inputWidth = inst.input ? inst.input.outerWidth() : 0;
8707
		var inputHeight = inst.input ? inst.input.outerHeight() : 0;
8708
		var viewWidth = document.documentElement.clientWidth + $(document).scrollLeft();
8709
		var viewHeight = document.documentElement.clientHeight + $(document).scrollTop();
8710
 
8711
		offset.left -= (this._get(inst, 'isRTL') ? (dpWidth - inputWidth) : 0);
8712
		offset.left -= (isFixed && offset.left == inst.input.offset().left) ? $(document).scrollLeft() : 0;
8713
		offset.top -= (isFixed && offset.top == (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0;
8714
 
8715
		// now check if datepicker is showing outside window viewport - move to a better place if so.
8716
		offset.left -= Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ?
8717
			Math.abs(offset.left + dpWidth - viewWidth) : 0);
8718
		offset.top -= Math.min(offset.top, (offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ?
8719
			Math.abs(dpHeight + inputHeight) : 0);
8720
 
8721
		return offset;
8722
	},
8723
 
8724
	/* Find an object's position on the screen. */
8725
	_findPos: function(obj) {
8726
		var inst = this._getInst(obj);
8727
		var isRTL = this._get(inst, 'isRTL');
8728
        while (obj && (obj.type == 'hidden' || obj.nodeType != 1)) {
8729
            obj = obj[isRTL ? 'previousSibling' : 'nextSibling'];
8730
        }
8731
        var position = $(obj).offset();
8732
	    return [position.left, position.top];
8733
	},
8734
 
8735
	/* Hide the date picker from view.
8736
	   @param  input  element - the input field attached to the date picker */
8737
	_hideDatepicker: function(input) {
8738
		var inst = this._curInst;
8739
		if (!inst || (input && inst != $.data(input, PROP_NAME)))
8740
			return;
8741
		if (this._datepickerShowing) {
8742
			var showAnim = this._get(inst, 'showAnim');
8743
			var duration = this._get(inst, 'duration');
8744
			var postProcess = function() {
8745
				$.datepicker._tidyDialog(inst);
8746
				this._curInst = null;
8747
			};
8748
			if ($.effects && $.effects[showAnim])
8749
				inst.dpDiv.hide(showAnim, $.datepicker._get(inst, 'showOptions'), duration, postProcess);
8750
			else
8751
				inst.dpDiv[(showAnim == 'slideDown' ? 'slideUp' :
8752
					(showAnim == 'fadeIn' ? 'fadeOut' : 'hide'))]((showAnim ? duration : null), postProcess);
8753
			if (!showAnim)
8754
				postProcess();
8755
			var onClose = this._get(inst, 'onClose');
8756
			if (onClose)
8757
				onClose.apply((inst.input ? inst.input[0] : null),
8758
					[(inst.input ? inst.input.val() : ''), inst]);  // trigger custom callback
8759
			this._datepickerShowing = false;
8760
			this._lastInput = null;
8761
			if (this._inDialog) {
8762
				this._dialogInput.css({ position: 'absolute', left: '0', top: '-100px' });
8763
				if ($.blockUI) {
8764
					$.unblockUI();
8765
					$('body').append(this.dpDiv);
8766
				}
8767
			}
8768
			this._inDialog = false;
8769
		}
8770
	},
8771
 
8772
	/* Tidy up after a dialog display. */
8773
	_tidyDialog: function(inst) {
8774
		inst.dpDiv.removeClass(this._dialogClass).unbind('.ui-datepicker-calendar');
8775
	},
8776
 
8777
	/* Close date picker if clicked elsewhere. */
8778
	_checkExternalClick: function(event) {
8779
		if (!$.datepicker._curInst)
8780
			return;
8781
		var $target = $(event.target);
8782
		if ($target[0].id != $.datepicker._mainDivId &&
8783
				$target.parents('#' + $.datepicker._mainDivId).length == 0 &&
8784
				!$target.hasClass($.datepicker.markerClassName) &&
8785
				!$target.hasClass($.datepicker._triggerClass) &&
8786
				$.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI))
8787
			$.datepicker._hideDatepicker();
8788
	},
8789
 
8790
	/* Adjust one of the date sub-fields. */
8791
	_adjustDate: function(id, offset, period) {
8792
		var target = $(id);
8793
		var inst = this._getInst(target[0]);
8794
		if (this._isDisabledDatepicker(target[0])) {
8795
			return;
8796
		}
8797
		this._adjustInstDate(inst, offset +
8798
			(period == 'M' ? this._get(inst, 'showCurrentAtPos') : 0), // undo positioning
8799
			period);
8800
		this._updateDatepicker(inst);
8801
	},
8802
 
8803
	/* Action for current link. */
8804
	_gotoToday: function(id) {
8805
		var target = $(id);
8806
		var inst = this._getInst(target[0]);
8807
		if (this._get(inst, 'gotoCurrent') && inst.currentDay) {
8808
			inst.selectedDay = inst.currentDay;
8809
			inst.drawMonth = inst.selectedMonth = inst.currentMonth;
8810
			inst.drawYear = inst.selectedYear = inst.currentYear;
8811
		}
8812
		else {
8813
			var date = new Date();
8814
			inst.selectedDay = date.getDate();
8815
			inst.drawMonth = inst.selectedMonth = date.getMonth();
8816
			inst.drawYear = inst.selectedYear = date.getFullYear();
8817
		}
8818
		this._notifyChange(inst);
8819
		this._adjustDate(target);
8820
	},
8821
 
8822
	/* Action for selecting a new month/year. */
8823
	_selectMonthYear: function(id, select, period) {
8824
		var target = $(id);
8825
		var inst = this._getInst(target[0]);
8826
		inst._selectingMonthYear = false;
8827
		inst['selected' + (period == 'M' ? 'Month' : 'Year')] =
8828
		inst['draw' + (period == 'M' ? 'Month' : 'Year')] =
8829
			parseInt(select.options[select.selectedIndex].value,10);
8830
		this._notifyChange(inst);
8831
		this._adjustDate(target);
8832
	},
8833
 
8834
	/* Restore input focus after not changing month/year. */
8835
	_clickMonthYear: function(id) {
8836
		var target = $(id);
8837
		var inst = this._getInst(target[0]);
8838
		if (inst.input && inst._selectingMonthYear) {
8839
			setTimeout(function() {
8840
				inst.input.focus();
8841
			}, 0);
8842
		}
8843
		inst._selectingMonthYear = !inst._selectingMonthYear;
8844
	},
8845
 
8846
	/* Action for selecting a day. */
8847
	_selectDay: function(id, month, year, td) {
8848
		var target = $(id);
8849
		if ($(td).hasClass(this._unselectableClass) || this._isDisabledDatepicker(target[0])) {
8850
			return;
8851
		}
8852
		var inst = this._getInst(target[0]);
8853
		inst.selectedDay = inst.currentDay = $('a', td).html();
8854
		inst.selectedMonth = inst.currentMonth = month;
8855
		inst.selectedYear = inst.currentYear = year;
8856
		this._selectDate(id, this._formatDate(inst,
8857
			inst.currentDay, inst.currentMonth, inst.currentYear));
8858
	},
8859
 
8860
	/* Erase the input field and hide the date picker. */
8861
	_clearDate: function(id) {
8862
		var target = $(id);
8863
		var inst = this._getInst(target[0]);
8864
		this._selectDate(target, '');
8865
	},
8866
 
8867
	/* Update the input field with the selected date. */
8868
	_selectDate: function(id, dateStr) {
8869
		var target = $(id);
8870
		var inst = this._getInst(target[0]);
8871
		dateStr = (dateStr != null ? dateStr : this._formatDate(inst));
8872
		if (inst.input)
8873
			inst.input.val(dateStr);
8874
		this._updateAlternate(inst);
8875
		var onSelect = this._get(inst, 'onSelect');
8876
		if (onSelect)
8877
			onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]);  // trigger custom callback
8878
		else if (inst.input)
8879
			inst.input.trigger('change'); // fire the change event
8880
		if (inst.inline)
8881
			this._updateDatepicker(inst);
8882
		else {
8883
			this._hideDatepicker();
8884
			this._lastInput = inst.input[0];
8885
			if (typeof(inst.input[0]) != 'object')
8886
				inst.input.focus(); // restore focus
8887
			this._lastInput = null;
8888
		}
8889
	},
8890
 
8891
	/* Update any alternate field to synchronise with the main field. */
8892
	_updateAlternate: function(inst) {
8893
		var altField = this._get(inst, 'altField');
8894
		if (altField) { // update alternate field too
8895
			var altFormat = this._get(inst, 'altFormat') || this._get(inst, 'dateFormat');
8896
			var date = this._getDate(inst);
8897
			var dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst));
8898
			$(altField).each(function() { $(this).val(dateStr); });
8899
		}
8900
	},
8901
 
8902
	/* Set as beforeShowDay function to prevent selection of weekends.
8903
	   @param  date  Date - the date to customise
8904
	   @return [boolean, string] - is this date selectable?, what is its CSS class? */
8905
	noWeekends: function(date) {
8906
		var day = date.getDay();
8907
		return [(day > 0 && day < 6), ''];
8908
	},
8909
 
8910
	/* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
8911
	   @param  date  Date - the date to get the week for
8912
	   @return  number - the number of the week within the year that contains this date */
8913
	iso8601Week: function(date) {
8914
		var checkDate = new Date(date.getTime());
8915
		// Find Thursday of this week starting on Monday
8916
		checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
8917
		var time = checkDate.getTime();
8918
		checkDate.setMonth(0); // Compare with Jan 1
8919
		checkDate.setDate(1);
8920
		return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
8921
	},
8922
 
8923
	/* Parse a string value into a date object.
8924
	   See formatDate below for the possible formats.
8925
 
8926
	   @param  format    string - the expected format of the date
8927
	   @param  value     string - the date in the above format
8928
	   @param  settings  Object - attributes include:
8929
	                     shortYearCutoff  number - the cutoff year for determining the century (optional)
8930
	                     dayNamesShort    string[7] - abbreviated names of the days from Sunday (optional)
8931
	                     dayNames         string[7] - names of the days from Sunday (optional)
8932
	                     monthNamesShort  string[12] - abbreviated names of the months (optional)
8933
	                     monthNames       string[12] - names of the months (optional)
8934
	   @return  Date - the extracted date value or null if value is blank */
8935
	parseDate: function (format, value, settings) {
8936
		if (format == null || value == null)
8937
			throw 'Invalid arguments';
8938
		value = (typeof value == 'object' ? value.toString() : value + '');
8939
		if (value == '')
8940
			return null;
8941
		var shortYearCutoff = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff;
8942
		var dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort;
8943
		var dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames;
8944
		var monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort;
8945
		var monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames;
8946
		var year = -1;
8947
		var month = -1;
8948
		var day = -1;
8949
		var doy = -1;
8950
		var literal = false;
8951
		// Check whether a format character is doubled
8952
		var lookAhead = function(match) {
8953
			var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
8954
			if (matches)
8955
				iFormat++;
8956
			return matches;
8957
		};
8958
		// Extract a number from the string value
8959
		var getNumber = function(match) {
8960
			lookAhead(match);
8961
			var size = (match == '@' ? 14 : (match == '!' ? 20 :
8962
				(match == 'y' ? 4 : (match == 'o' ? 3 : 2))));
8963
			var digits = new RegExp('^\\d{1,' + size + '}');
8964
			var num = value.substring(iValue).match(digits);
8965
			if (!num)
8966
				throw 'Missing number at position ' + iValue;
8967
			iValue += num[0].length;
8968
			return parseInt(num[0], 10);
8969
		};
8970
		// Extract a name from the string value and convert to an index
8971
		var getName = function(match, shortNames, longNames) {
8972
			var names = (lookAhead(match) ? longNames : shortNames);
8973
			for (var i = 0; i < names.length; i++) {
8974
				if (value.substr(iValue, names[i].length).toLowerCase() == names[i].toLowerCase()) {
8975
					iValue += names[i].length;
8976
					return i + 1;
8977
				}
8978
			}
8979
			throw 'Unknown name at position ' + iValue;
8980
		};
8981
		// Confirm that a literal character matches the string value
8982
		var checkLiteral = function() {
8983
			if (value.charAt(iValue) != format.charAt(iFormat))
8984
				throw 'Unexpected literal at position ' + iValue;
8985
			iValue++;
8986
		};
8987
		var iValue = 0;
8988
		for (var iFormat = 0; iFormat < format.length; iFormat++) {
8989
			if (literal)
8990
				if (format.charAt(iFormat) == "'" && !lookAhead("'"))
8991
					literal = false;
8992
				else
8993
					checkLiteral();
8994
			else
8995
				switch (format.charAt(iFormat)) {
8996
					case 'd':
8997
						day = getNumber('d');
8998
						break;
8999
					case 'D':
9000
						getName('D', dayNamesShort, dayNames);
9001
						break;
9002
					case 'o':
9003
						doy = getNumber('o');
9004
						break;
9005
					case 'm':
9006
						month = getNumber('m');
9007
						break;
9008
					case 'M':
9009
						month = getName('M', monthNamesShort, monthNames);
9010
						break;
9011
					case 'y':
9012
						year = getNumber('y');
9013
						break;
9014
					case '@':
9015
						var date = new Date(getNumber('@'));
9016
						year = date.getFullYear();
9017
						month = date.getMonth() + 1;
9018
						day = date.getDate();
9019
						break;
9020
					case '!':
9021
						var date = new Date((getNumber('!') - this._ticksTo1970) / 10000);
9022
						year = date.getFullYear();
9023
						month = date.getMonth() + 1;
9024
						day = date.getDate();
9025
						break;
9026
					case "'":
9027
						if (lookAhead("'"))
9028
							checkLiteral();
9029
						else
9030
							literal = true;
9031
						break;
9032
					default:
9033
						checkLiteral();
9034
				}
9035
		}
9036
		if (year == -1)
9037
			year = new Date().getFullYear();
9038
		else if (year < 100)
9039
			year += new Date().getFullYear() - new Date().getFullYear() % 100 +
9040
				(year <= shortYearCutoff ? 0 : -100);
9041
		if (doy > -1) {
9042
			month = 1;
9043
			day = doy;
9044
			do {
9045
				var dim = this._getDaysInMonth(year, month - 1);
9046
				if (day <= dim)
9047
					break;
9048
				month++;
9049
				day -= dim;
9050
			} while (true);
9051
		}
9052
		var date = this._daylightSavingAdjust(new Date(year, month - 1, day));
9053
		if (date.getFullYear() != year || date.getMonth() + 1 != month || date.getDate() != day)
9054
			throw 'Invalid date'; // E.g. 31/02/*
9055
		return date;
9056
	},
9057
 
9058
	/* Standard date formats. */
9059
	ATOM: 'yy-mm-dd', // RFC 3339 (ISO 8601)
9060
	COOKIE: 'D, dd M yy',
9061
	ISO_8601: 'yy-mm-dd',
9062
	RFC_822: 'D, d M y',
9063
	RFC_850: 'DD, dd-M-y',
9064
	RFC_1036: 'D, d M y',
9065
	RFC_1123: 'D, d M yy',
9066
	RFC_2822: 'D, d M yy',
9067
	RSS: 'D, d M y', // RFC 822
9068
	TICKS: '!',
9069
	TIMESTAMP: '@',
9070
	W3C: 'yy-mm-dd', // ISO 8601
9071
 
9072
	_ticksTo1970: (((1970 - 1) * 365 + Math.floor(1970 / 4) - Math.floor(1970 / 100) +
9073
		Math.floor(1970 / 400)) * 24 * 60 * 60 * 10000000),
9074
 
9075
	/* Format a date object into a string value.
9076
	   The format can be combinations of the following:
9077
	   d  - day of month (no leading zero)
9078
	   dd - day of month (two digit)
9079
	   o  - day of year (no leading zeros)
9080
	   oo - day of year (three digit)
9081
	   D  - day name short
9082
	   DD - day name long
9083
	   m  - month of year (no leading zero)
9084
	   mm - month of year (two digit)
9085
	   M  - month name short
9086
	   MM - month name long
9087
	   y  - year (two digit)
9088
	   yy - year (four digit)
9089
	   @ - Unix timestamp (ms since 01/01/1970)
9090
	   ! - Windows ticks (100ns since 01/01/0001)
9091
	   '...' - literal text
9092
	   '' - single quote
9093
 
9094
	   @param  format    string - the desired format of the date
9095
	   @param  date      Date - the date value to format
9096
	   @param  settings  Object - attributes include:
9097
	                     dayNamesShort    string[7] - abbreviated names of the days from Sunday (optional)
9098
	                     dayNames         string[7] - names of the days from Sunday (optional)
9099
	                     monthNamesShort  string[12] - abbreviated names of the months (optional)
9100
	                     monthNames       string[12] - names of the months (optional)
9101
	   @return  string - the date in the above format */
9102
	formatDate: function (format, date, settings) {
9103
		if (!date)
9104
			return '';
9105
		var dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort;
9106
		var dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames;
9107
		var monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort;
9108
		var monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames;
9109
		// Check whether a format character is doubled
9110
		var lookAhead = function(match) {
9111
			var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
9112
			if (matches)
9113
				iFormat++;
9114
			return matches;
9115
		};
9116
		// Format a number, with leading zero if necessary
9117
		var formatNumber = function(match, value, len) {
9118
			var num = '' + value;
9119
			if (lookAhead(match))
9120
				while (num.length < len)
9121
					num = '0' + num;
9122
			return num;
9123
		};
9124
		// Format a name, short or long as requested
9125
		var formatName = function(match, value, shortNames, longNames) {
9126
			return (lookAhead(match) ? longNames[value] : shortNames[value]);
9127
		};
9128
		var output = '';
9129
		var literal = false;
9130
		if (date)
9131
			for (var iFormat = 0; iFormat < format.length; iFormat++) {
9132
				if (literal)
9133
					if (format.charAt(iFormat) == "'" && !lookAhead("'"))
9134
						literal = false;
9135
					else
9136
						output += format.charAt(iFormat);
9137
				else
9138
					switch (format.charAt(iFormat)) {
9139
						case 'd':
9140
							output += formatNumber('d', date.getDate(), 2);
9141
							break;
9142
						case 'D':
9143
							output += formatName('D', date.getDay(), dayNamesShort, dayNames);
9144
							break;
9145
						case 'o':
9146
							output += formatNumber('o',
9147
								(date.getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000, 3);
9148
							break;
9149
						case 'm':
9150
							output += formatNumber('m', date.getMonth() + 1, 2);
9151
							break;
9152
						case 'M':
9153
							output += formatName('M', date.getMonth(), monthNamesShort, monthNames);
9154
							break;
9155
						case 'y':
9156
							output += (lookAhead('y') ? date.getFullYear() :
9157
								(date.getYear() % 100 < 10 ? '0' : '') + date.getYear() % 100);
9158
							break;
9159
						case '@':
9160
							output += date.getTime();
9161
							break;
9162
						case '!':
9163
							output += date.getTime() * 10000 + this._ticksTo1970;
9164
							break;
9165
						case "'":
9166
							if (lookAhead("'"))
9167
								output += "'";
9168
							else
9169
								literal = true;
9170
							break;
9171
						default:
9172
							output += format.charAt(iFormat);
9173
					}
9174
			}
9175
		return output;
9176
	},
9177
 
9178
	/* Extract all possible characters from the date format. */
9179
	_possibleChars: function (format) {
9180
		var chars = '';
9181
		var literal = false;
9182
		// Check whether a format character is doubled
9183
		var lookAhead = function(match) {
9184
			var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
9185
			if (matches)
9186
				iFormat++;
9187
			return matches;
9188
		};
9189
		for (var iFormat = 0; iFormat < format.length; iFormat++)
9190
			if (literal)
9191
				if (format.charAt(iFormat) == "'" && !lookAhead("'"))
9192
					literal = false;
9193
				else
9194
					chars += format.charAt(iFormat);
9195
			else
9196
				switch (format.charAt(iFormat)) {
9197
					case 'd': case 'm': case 'y': case '@':
9198
						chars += '0123456789';
9199
						break;
9200
					case 'D': case 'M':
9201
						return null; // Accept anything
9202
					case "'":
9203
						if (lookAhead("'"))
9204
							chars += "'";
9205
						else
9206
							literal = true;
9207
						break;
9208
					default:
9209
						chars += format.charAt(iFormat);
9210
				}
9211
		return chars;
9212
	},
9213
 
9214
	/* Get a setting value, defaulting if necessary. */
9215
	_get: function(inst, name) {
9216
		return inst.settings[name] !== undefined ?
9217
			inst.settings[name] : this._defaults[name];
9218
	},
9219
 
9220
	/* Parse existing date and initialise date picker. */
9221
	_setDateFromField: function(inst, noDefault) {
9222
		if (inst.input.val() == inst.lastVal) {
9223
			return;
9224
		}
9225
		var dateFormat = this._get(inst, 'dateFormat');
9226
		var dates = inst.lastVal = inst.input ? inst.input.val() : null;
9227
		var date, defaultDate;
9228
		date = defaultDate = this._getDefaultDate(inst);
9229
		var settings = this._getFormatConfig(inst);
9230
		try {
9231
			date = this.parseDate(dateFormat, dates, settings) || defaultDate;
9232
		} catch (event) {
9233
			this.log(event);
9234
			dates = (noDefault ? '' : dates);
9235
		}
9236
		inst.selectedDay = date.getDate();
9237
		inst.drawMonth = inst.selectedMonth = date.getMonth();
9238
		inst.drawYear = inst.selectedYear = date.getFullYear();
9239
		inst.currentDay = (dates ? date.getDate() : 0);
9240
		inst.currentMonth = (dates ? date.getMonth() : 0);
9241
		inst.currentYear = (dates ? date.getFullYear() : 0);
9242
		this._adjustInstDate(inst);
9243
	},
9244
 
9245
	/* Retrieve the default date shown on opening. */
9246
	_getDefaultDate: function(inst) {
9247
		return this._restrictMinMax(inst,
9248
			this._determineDate(inst, this._get(inst, 'defaultDate'), new Date()));
9249
	},
9250
 
9251
	/* A date may be specified as an exact value or a relative one. */
9252
	_determineDate: function(inst, date, defaultDate) {
9253
		var offsetNumeric = function(offset) {
9254
			var date = new Date();
9255
			date.setDate(date.getDate() + offset);
9256
			return date;
9257
		};
9258
		var offsetString = function(offset) {
9259
			try {
9260
				return $.datepicker.parseDate($.datepicker._get(inst, 'dateFormat'),
9261
					offset, $.datepicker._getFormatConfig(inst));
9262
			}
9263
			catch (e) {
9264
				// Ignore
9265
			}
9266
			var date = (offset.toLowerCase().match(/^c/) ?
9267
				$.datepicker._getDate(inst) : null) || new Date();
9268
			var year = date.getFullYear();
9269
			var month = date.getMonth();
9270
			var day = date.getDate();
9271
			var pattern = /([+-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g;
9272
			var matches = pattern.exec(offset);
9273
			while (matches) {
9274
				switch (matches[2] || 'd') {
9275
					case 'd' : case 'D' :
9276
						day += parseInt(matches[1],10); break;
9277
					case 'w' : case 'W' :
9278
						day += parseInt(matches[1],10) * 7; break;
9279
					case 'm' : case 'M' :
9280
						month += parseInt(matches[1],10);
9281
						day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
9282
						break;
9283
					case 'y': case 'Y' :
9284
						year += parseInt(matches[1],10);
9285
						day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
9286
						break;
9287
				}
9288
				matches = pattern.exec(offset);
9289
			}
9290
			return new Date(year, month, day);
9291
		};
9292
		date = (date == null ? defaultDate : (typeof date == 'string' ? offsetString(date) :
9293
			(typeof date == 'number' ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : date)));
9294
		date = (date && date.toString() == 'Invalid Date' ? defaultDate : date);
9295
		if (date) {
9296
			date.setHours(0);
9297
			date.setMinutes(0);
9298
			date.setSeconds(0);
9299
			date.setMilliseconds(0);
9300
		}
9301
		return this._daylightSavingAdjust(date);
9302
	},
9303
 
9304
	/* Handle switch to/from daylight saving.
9305
	   Hours may be non-zero on daylight saving cut-over:
9306
	   > 12 when midnight changeover, but then cannot generate
9307
	   midnight datetime, so jump to 1AM, otherwise reset.
9308
	   @param  date  (Date) the date to check
9309
	   @return  (Date) the corrected date */
9310
	_daylightSavingAdjust: function(date) {
9311
		if (!date) return null;
9312
		date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0);
9313
		return date;
9314
	},
9315
 
9316
	/* Set the date(s) directly. */
9317
	_setDate: function(inst, date, noChange) {
9318
		var clear = !(date);
9319
		var origMonth = inst.selectedMonth;
9320
		var origYear = inst.selectedYear;
9321
		date = this._restrictMinMax(inst, this._determineDate(inst, date, new Date()));
9322
		inst.selectedDay = inst.currentDay = date.getDate();
9323
		inst.drawMonth = inst.selectedMonth = inst.currentMonth = date.getMonth();
9324
		inst.drawYear = inst.selectedYear = inst.currentYear = date.getFullYear();
9325
		if ((origMonth != inst.selectedMonth || origYear != inst.selectedYear) && !noChange)
9326
			this._notifyChange(inst);
9327
		this._adjustInstDate(inst);
9328
		if (inst.input) {
9329
			inst.input.val(clear ? '' : this._formatDate(inst));
9330
		}
9331
	},
9332
 
9333
	/* Retrieve the date(s) directly. */
9334
	_getDate: function(inst) {
9335
		var startDate = (!inst.currentYear || (inst.input && inst.input.val() == '') ? null :
9336
			this._daylightSavingAdjust(new Date(
9337
			inst.currentYear, inst.currentMonth, inst.currentDay)));
9338
			return startDate;
9339
	},
9340
 
9341
	/* Generate the HTML for the current state of the date picker. */
9342
	_generateHTML: function(inst) {
9343
		var today = new Date();
9344
		today = this._daylightSavingAdjust(
9345
			new Date(today.getFullYear(), today.getMonth(), today.getDate())); // clear time
9346
		var isRTL = this._get(inst, 'isRTL');
9347
		var showButtonPanel = this._get(inst, 'showButtonPanel');
9348
		var hideIfNoPrevNext = this._get(inst, 'hideIfNoPrevNext');
9349
		var navigationAsDateFormat = this._get(inst, 'navigationAsDateFormat');
9350
		var numMonths = this._getNumberOfMonths(inst);
9351
		var showCurrentAtPos = this._get(inst, 'showCurrentAtPos');
9352
		var stepMonths = this._get(inst, 'stepMonths');
9353
		var isMultiMonth = (numMonths[0] != 1 || numMonths[1] != 1);
9354
		var currentDate = this._daylightSavingAdjust((!inst.currentDay ? new Date(9999, 9, 9) :
9355
			new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
9356
		var minDate = this._getMinMaxDate(inst, 'min');
9357
		var maxDate = this._getMinMaxDate(inst, 'max');
9358
		var drawMonth = inst.drawMonth - showCurrentAtPos;
9359
		var drawYear = inst.drawYear;
9360
		if (drawMonth < 0) {
9361
			drawMonth += 12;
9362
			drawYear--;
9363
		}
9364
		if (maxDate) {
9365
			var maxDraw = this._daylightSavingAdjust(new Date(maxDate.getFullYear(),
9366
				maxDate.getMonth() - (numMonths[0] * numMonths[1]) + 1, maxDate.getDate()));
9367
			maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw);
9368
			while (this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1)) > maxDraw) {
9369
				drawMonth--;
9370
				if (drawMonth < 0) {
9371
					drawMonth = 11;
9372
					drawYear--;
9373
				}
9374
			}
9375
		}
9376
		inst.drawMonth = drawMonth;
9377
		inst.drawYear = drawYear;
9378
		var prevText = this._get(inst, 'prevText');
9379
		prevText = (!navigationAsDateFormat ? prevText : this.formatDate(prevText,
9380
			this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)),
9381
			this._getFormatConfig(inst)));
9382
		var prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ?
9383
			'<a class="ui-datepicker-prev ui-corner-all" onclick="DP_jQuery_' + dpuuid +
9384
			'.datepicker._adjustDate(\'#' + inst.id + '\', -' + stepMonths + ', \'M\');"' +
9385
			' title="' + prevText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'e' : 'w') + '">' + prevText + '</span></a>' :
9386
			(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>'));
9387
		var nextText = this._get(inst, 'nextText');
9388
		nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText,
9389
			this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)),
9390
			this._getFormatConfig(inst)));
9391
		var next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ?
9392
			'<a class="ui-datepicker-next ui-corner-all" onclick="DP_jQuery_' + dpuuid +
9393
			'.datepicker._adjustDate(\'#' + inst.id + '\', +' + stepMonths + ', \'M\');"' +
9394
			' title="' + nextText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'w' : 'e') + '">' + nextText + '</span></a>' :
9395
			(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>'));
9396
		var currentText = this._get(inst, 'currentText');
9397
		var gotoDate = (this._get(inst, 'gotoCurrent') && inst.currentDay ? currentDate : today);
9398
		currentText = (!navigationAsDateFormat ? currentText :
9399
			this.formatDate(currentText, gotoDate, this._getFormatConfig(inst)));
9400
		var controls = (!inst.inline ? '<button type="button" class="ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all" onclick="DP_jQuery_' + dpuuid +
9401
			'.datepicker._hideDatepicker();">' + this._get(inst, 'closeText') + '</button>' : '');
9402
		var buttonPanel = (showButtonPanel) ? '<div class="ui-datepicker-buttonpane ui-widget-content">' + (isRTL ? controls : '') +
9403
			(this._isInRange(inst, gotoDate) ? '<button type="button" class="ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all" onclick="DP_jQuery_' + dpuuid +
9404
			'.datepicker._gotoToday(\'#' + inst.id + '\');"' +
9405
			'>' + currentText + '</button>' : '') + (isRTL ? '' : controls) + '</div>' : '';
9406
		var firstDay = parseInt(this._get(inst, 'firstDay'),10);
9407
		firstDay = (isNaN(firstDay) ? 0 : firstDay);
9408
		var showWeek = this._get(inst, 'showWeek');
9409
		var dayNames = this._get(inst, 'dayNames');
9410
		var dayNamesShort = this._get(inst, 'dayNamesShort');
9411
		var dayNamesMin = this._get(inst, 'dayNamesMin');
9412
		var monthNames = this._get(inst, 'monthNames');
9413
		var monthNamesShort = this._get(inst, 'monthNamesShort');
9414
		var beforeShowDay = this._get(inst, 'beforeShowDay');
9415
		var showOtherMonths = this._get(inst, 'showOtherMonths');
9416
		var selectOtherMonths = this._get(inst, 'selectOtherMonths');
9417
		var calculateWeek = this._get(inst, 'calculateWeek') || this.iso8601Week;
9418
		var defaultDate = this._getDefaultDate(inst);
9419
		var html = '';
9420
		for (var row = 0; row < numMonths[0]; row++) {
9421
			var group = '';
9422
			for (var col = 0; col < numMonths[1]; col++) {
9423
				var selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay));
9424
				var cornerClass = ' ui-corner-all';
9425
				var calender = '';
9426
				if (isMultiMonth) {
9427
					calender += '<div class="ui-datepicker-group';
9428
					if (numMonths[1] > 1)
9429
						switch (col) {
9430
							case 0: calender += ' ui-datepicker-group-first';
9431
								cornerClass = ' ui-corner-' + (isRTL ? 'right' : 'left'); break;
9432
							case numMonths[1]-1: calender += ' ui-datepicker-group-last';
9433
								cornerClass = ' ui-corner-' + (isRTL ? 'left' : 'right'); break;
9434
							default: calender += ' ui-datepicker-group-middle'; cornerClass = ''; break;
9435
						}
9436
					calender += '">';
9437
				}
9438
				calender += '<div class="ui-datepicker-header ui-widget-header ui-helper-clearfix' + cornerClass + '">' +
9439
					(/all|left/.test(cornerClass) && row == 0 ? (isRTL ? next : prev) : '') +
9440
					(/all|right/.test(cornerClass) && row == 0 ? (isRTL ? prev : next) : '') +
9441
					this._generateMonthYearHeader(inst, drawMonth, drawYear, minDate, maxDate,
9442
					row > 0 || col > 0, monthNames, monthNamesShort) + // draw month headers
9443
					'</div><table class="ui-datepicker-calendar"><thead>' +
9444
					'<tr>';
9445
				var thead = (showWeek ? '<th class="ui-datepicker-week-col">' + this._get(inst, 'weekHeader') + '</th>' : '');
9446
				for (var dow = 0; dow < 7; dow++) { // days of the week
9447
					var day = (dow + firstDay) % 7;
9448
					thead += '<th' + ((dow + firstDay + 6) % 7 >= 5 ? ' class="ui-datepicker-week-end"' : '') + '>' +
9449
						'<span title="' + dayNames[day] + '">' + dayNamesMin[day] + '</span></th>';
9450
				}
9451
				calender += thead + '</tr></thead><tbody>';
9452
				var daysInMonth = this._getDaysInMonth(drawYear, drawMonth);
9453
				if (drawYear == inst.selectedYear && drawMonth == inst.selectedMonth)
9454
					inst.selectedDay = Math.min(inst.selectedDay, daysInMonth);
9455
				var leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7;
9456
				var numRows = (isMultiMonth ? 6 : Math.ceil((leadDays + daysInMonth) / 7)); // calculate the number of rows to generate
9457
				var printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays));
9458
				for (var dRow = 0; dRow < numRows; dRow++) { // create date picker rows
9459
					calender += '<tr>';
9460
					var tbody = (!showWeek ? '' : '<td class="ui-datepicker-week-col">' +
9461
						this._get(inst, 'calculateWeek')(printDate) + '</td>');
9462
					for (var dow = 0; dow < 7; dow++) { // create date picker days
9463
						var daySettings = (beforeShowDay ?
9464
							beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, '']);
9465
						var otherMonth = (printDate.getMonth() != drawMonth);
9466
						var unselectable = (otherMonth && !selectOtherMonths) || !daySettings[0] ||
9467
							(minDate && printDate < minDate) || (maxDate && printDate > maxDate);
9468
						tbody += '<td class="' +
9469
							((dow + firstDay + 6) % 7 >= 5 ? ' ui-datepicker-week-end' : '') + // highlight weekends
9470
							(otherMonth ? ' ui-datepicker-other-month' : '') + // highlight days from other months
9471
							((printDate.getTime() == selectedDate.getTime() && drawMonth == inst.selectedMonth && inst._keyEvent) || // user pressed key
9472
							(defaultDate.getTime() == printDate.getTime() && defaultDate.getTime() == selectedDate.getTime()) ?
9473
							// or defaultDate is current printedDate and defaultDate is selectedDate
9474
							' ' + this._dayOverClass : '') + // highlight selected day
9475
							(unselectable ? ' ' + this._unselectableClass + ' ui-state-disabled': '') +  // highlight unselectable days
9476
							(otherMonth && !showOtherMonths ? '' : ' ' + daySettings[1] + // highlight custom dates
9477
							(printDate.getTime() == currentDate.getTime() ? ' ' + this._currentClass : '') + // highlight selected day
9478
							(printDate.getTime() == today.getTime() ? ' ui-datepicker-today' : '')) + '"' + // highlight today (if different)
9479
							((!otherMonth || showOtherMonths) && daySettings[2] ? ' title="' + daySettings[2] + '"' : '') + // cell title
9480
							(unselectable ? '' : ' onclick="DP_jQuery_' + dpuuid + '.datepicker._selectDay(\'#' +
9481
							inst.id + '\',' + printDate.getMonth() + ',' + printDate.getFullYear() + ', this);return false;"') + '>' + // actions
9482
							(otherMonth && !showOtherMonths ? '&#xa0;' : // display for other months
9483
							(unselectable ? '<span class="ui-state-default">' + printDate.getDate() + '</span>' : '<a class="ui-state-default' +
9484
							(printDate.getTime() == today.getTime() ? ' ui-state-highlight' : '') +
9485
							(printDate.getTime() == selectedDate.getTime() ? ' ui-state-active' : '') + // highlight selected day
9486
							(otherMonth ? ' ui-priority-secondary' : '') + // distinguish dates from other months
9487
							'" href="#">' + printDate.getDate() + '</a>')) + '</td>'; // display selectable date
9488
						printDate.setDate(printDate.getDate() + 1);
9489
						printDate = this._daylightSavingAdjust(printDate);
9490
					}
9491
					calender += tbody + '</tr>';
9492
				}
9493
				drawMonth++;
9494
				if (drawMonth > 11) {
9495
					drawMonth = 0;
9496
					drawYear++;
9497
				}
9498
				calender += '</tbody></table>' + (isMultiMonth ? '</div>' +
9499
							((numMonths[0] > 0 && col == numMonths[1]-1) ? '<div class="ui-datepicker-row-break"></div>' : '') : '');
9500
				group += calender;
9501
			}
9502
			html += group;
9503
		}
9504
		html += buttonPanel + ($.browser.msie && parseInt($.browser.version,10) < 7 && !inst.inline ?
9505
			'<iframe src="javascript:false;" class="ui-datepicker-cover" frameborder="0"></iframe>' : '');
9506
		inst._keyEvent = false;
9507
		return html;
9508
	},
9509
 
9510
	/* Generate the month and year header. */
9511
	_generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate,
9512
			secondary, monthNames, monthNamesShort) {
9513
		var changeMonth = this._get(inst, 'changeMonth');
9514
		var changeYear = this._get(inst, 'changeYear');
9515
		var showMonthAfterYear = this._get(inst, 'showMonthAfterYear');
9516
		var html = '<div class="ui-datepicker-title">';
9517
		var monthHtml = '';
9518
		// month selection
9519
		if (secondary || !changeMonth)
9520
			monthHtml += '<span class="ui-datepicker-month">' + monthNames[drawMonth] + '</span>';
9521
		else {
9522
			var inMinYear = (minDate && minDate.getFullYear() == drawYear);
9523
			var inMaxYear = (maxDate && maxDate.getFullYear() == drawYear);
9524
			monthHtml += '<select class="ui-datepicker-month" ' +
9525
				'onchange="DP_jQuery_' + dpuuid + '.datepicker._selectMonthYear(\'#' + inst.id + '\', this, \'M\');" ' +
9526
				'onclick="DP_jQuery_' + dpuuid + '.datepicker._clickMonthYear(\'#' + inst.id + '\');"' +
9527
			 	'>';
9528
			for (var month = 0; month < 12; month++) {
9529
				if ((!inMinYear || month >= minDate.getMonth()) &&
9530
						(!inMaxYear || month <= maxDate.getMonth()))
9531
					monthHtml += '<option value="' + month + '"' +
9532
						(month == drawMonth ? ' selected="selected"' : '') +
9533
						'>' + monthNamesShort[month] + '</option>';
9534
			}
9535
			monthHtml += '</select>';
9536
		}
9537
		if (!showMonthAfterYear)
9538
			html += monthHtml + (secondary || !(changeMonth && changeYear) ? '&#xa0;' : '');
9539
		// year selection
9540
		if (secondary || !changeYear)
9541
			html += '<span class="ui-datepicker-year">' + drawYear + '</span>';
9542
		else {
9543
			// determine range of years to display
9544
			var years = this._get(inst, 'yearRange').split(':');
9545
			var thisYear = new Date().getFullYear();
9546
			var determineYear = function(value) {
9547
				var year = (value.match(/c[+-].*/) ? drawYear + parseInt(value.substring(1), 10) :
9548
					(value.match(/[+-].*/) ? thisYear + parseInt(value, 10) :
9549
					parseInt(value, 10)));
9550
				return (isNaN(year) ? thisYear : year);
9551
			};
9552
			var year = determineYear(years[0]);
9553
			var endYear = Math.max(year, determineYear(years[1] || ''));
9554
			year = (minDate ? Math.max(year, minDate.getFullYear()) : year);
9555
			endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear);
9556
			html += '<select class="ui-datepicker-year" ' +
9557
				'onchange="DP_jQuery_' + dpuuid + '.datepicker._selectMonthYear(\'#' + inst.id + '\', this, \'Y\');" ' +
9558
				'onclick="DP_jQuery_' + dpuuid + '.datepicker._clickMonthYear(\'#' + inst.id + '\');"' +
9559
				'>';
9560
			for (; year <= endYear; year++) {
9561
				html += '<option value="' + year + '"' +
9562
					(year == drawYear ? ' selected="selected"' : '') +
9563
					'>' + year + '</option>';
9564
			}
9565
			html += '</select>';
9566
		}
9567
		html += this._get(inst, 'yearSuffix');
9568
		if (showMonthAfterYear)
9569
			html += (secondary || !(changeMonth && changeYear) ? '&#xa0;' : '') + monthHtml;
9570
		html += '</div>'; // Close datepicker_header
9571
		return html;
9572
	},
9573
 
9574
	/* Adjust one of the date sub-fields. */
9575
	_adjustInstDate: function(inst, offset, period) {
9576
		var year = inst.drawYear + (period == 'Y' ? offset : 0);
9577
		var month = inst.drawMonth + (period == 'M' ? offset : 0);
9578
		var day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) +
9579
			(period == 'D' ? offset : 0);
9580
		var date = this._restrictMinMax(inst,
9581
			this._daylightSavingAdjust(new Date(year, month, day)));
9582
		inst.selectedDay = date.getDate();
9583
		inst.drawMonth = inst.selectedMonth = date.getMonth();
9584
		inst.drawYear = inst.selectedYear = date.getFullYear();
9585
		if (period == 'M' || period == 'Y')
9586
			this._notifyChange(inst);
9587
	},
9588
 
9589
	/* Ensure a date is within any min/max bounds. */
9590
	_restrictMinMax: function(inst, date) {
9591
		var minDate = this._getMinMaxDate(inst, 'min');
9592
		var maxDate = this._getMinMaxDate(inst, 'max');
9593
		date = (minDate && date < minDate ? minDate : date);
9594
		date = (maxDate && date > maxDate ? maxDate : date);
9595
		return date;
9596
	},
9597
 
9598
	/* Notify change of month/year. */
9599
	_notifyChange: function(inst) {
9600
		var onChange = this._get(inst, 'onChangeMonthYear');
9601
		if (onChange)
9602
			onChange.apply((inst.input ? inst.input[0] : null),
9603
				[inst.selectedYear, inst.selectedMonth + 1, inst]);
9604
	},
9605
 
9606
	/* Determine the number of months to show. */
9607
	_getNumberOfMonths: function(inst) {
9608
		var numMonths = this._get(inst, 'numberOfMonths');
9609
		return (numMonths == null ? [1, 1] : (typeof numMonths == 'number' ? [1, numMonths] : numMonths));
9610
	},
9611
 
9612
	/* Determine the current maximum date - ensure no time components are set. */
9613
	_getMinMaxDate: function(inst, minMax) {
9614
		return this._determineDate(inst, this._get(inst, minMax + 'Date'), null);
9615
	},
9616
 
9617
	/* Find the number of days in a given month. */
9618
	_getDaysInMonth: function(year, month) {
9619
		return 32 - new Date(year, month, 32).getDate();
9620
	},
9621
 
9622
	/* Find the day of the week of the first of a month. */
9623
	_getFirstDayOfMonth: function(year, month) {
9624
		return new Date(year, month, 1).getDay();
9625
	},
9626
 
9627
	/* Determines if we should allow a "next/prev" month display change. */
9628
	_canAdjustMonth: function(inst, offset, curYear, curMonth) {
9629
		var numMonths = this._getNumberOfMonths(inst);
9630
		var date = this._daylightSavingAdjust(new Date(curYear,
9631
			curMonth + (offset < 0 ? offset : numMonths[0] * numMonths[1]), 1));
9632
		if (offset < 0)
9633
			date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth()));
9634
		return this._isInRange(inst, date);
9635
	},
9636
 
9637
	/* Is the given date in the accepted range? */
9638
	_isInRange: function(inst, date) {
9639
		var minDate = this._getMinMaxDate(inst, 'min');
9640
		var maxDate = this._getMinMaxDate(inst, 'max');
9641
		return ((!minDate || date.getTime() >= minDate.getTime()) &&
9642
			(!maxDate || date.getTime() <= maxDate.getTime()));
9643
	},
9644
 
9645
	/* Provide the configuration settings for formatting/parsing. */
9646
	_getFormatConfig: function(inst) {
9647
		var shortYearCutoff = this._get(inst, 'shortYearCutoff');
9648
		shortYearCutoff = (typeof shortYearCutoff != 'string' ? shortYearCutoff :
9649
			new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
9650
		return {shortYearCutoff: shortYearCutoff,
9651
			dayNamesShort: this._get(inst, 'dayNamesShort'), dayNames: this._get(inst, 'dayNames'),
9652
			monthNamesShort: this._get(inst, 'monthNamesShort'), monthNames: this._get(inst, 'monthNames')};
9653
	},
9654
 
9655
	/* Format the given date for display. */
9656
	_formatDate: function(inst, day, month, year) {
9657
		if (!day) {
9658
			inst.currentDay = inst.selectedDay;
9659
			inst.currentMonth = inst.selectedMonth;
9660
			inst.currentYear = inst.selectedYear;
9661
		}
9662
		var date = (day ? (typeof day == 'object' ? day :
9663
			this._daylightSavingAdjust(new Date(year, month, day))) :
9664
			this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
9665
		return this.formatDate(this._get(inst, 'dateFormat'), date, this._getFormatConfig(inst));
9666
	}
9667
});
9668
 
9669
/* jQuery extend now ignores nulls! */
9670
function extendRemove(target, props) {
9671
	$.extend(target, props);
9672
	for (var name in props)
9673
		if (props[name] == null || props[name] == undefined)
9674
			target[name] = props[name];
9675
	return target;
9676
};
9677
 
9678
/* Determine whether an object is an array. */
9679
function isArray(a) {
9680
	return (a && (($.browser.safari && typeof a == 'object' && a.length) ||
9681
		(a.constructor && a.constructor.toString().match(/\Array\(\)/))));
9682
};
9683
 
9684
/* Invoke the datepicker functionality.
9685
   @param  options  string - a command, optionally followed by additional parameters or
9686
                    Object - settings for attaching new datepicker functionality
9687
   @return  jQuery object */
9688
$.fn.datepicker = function(options){
9689
 
9690
	/* Initialise the date picker. */
9691
	if (!$.datepicker.initialized) {
9692
		$(document).mousedown($.datepicker._checkExternalClick).
9693
			find('body').append($.datepicker.dpDiv);
9694
		$.datepicker.initialized = true;
9695
	}
9696
 
9697
	var otherArgs = Array.prototype.slice.call(arguments, 1);
9698
	if (typeof options == 'string' && (options == 'isDisabled' || options == 'getDate' || options == 'widget'))
9699
		return $.datepicker['_' + options + 'Datepicker'].
9700
			apply($.datepicker, [this[0]].concat(otherArgs));
9701
	if (options == 'option' && arguments.length == 2 && typeof arguments[1] == 'string')
9702
		return $.datepicker['_' + options + 'Datepicker'].
9703
			apply($.datepicker, [this[0]].concat(otherArgs));
9704
	return this.each(function() {
9705
		typeof options == 'string' ?
9706
			$.datepicker['_' + options + 'Datepicker'].
9707
				apply($.datepicker, [this].concat(otherArgs)) :
9708
			$.datepicker._attachDatepicker(this, options);
9709
	});
9710
};
9711
 
9712
$.datepicker = new Datepicker(); // singleton instance
9713
$.datepicker.initialized = false;
9714
$.datepicker.uuid = new Date().getTime();
9715
$.datepicker.version = "1.8.5";
9716
 
9717
// Workaround for #4055
9718
// Add another global to avoid noConflict issues with inline event handlers
9719
window['DP_jQuery_' + dpuuid] = $;
9720
 
9721
})(jQuery);
9722
/*
9723
 * jQuery UI Progressbar 1.8.5
9724
 *
9725
 * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
9726
 * Dual licensed under the MIT or GPL Version 2 licenses.
9727
 * http://jquery.org/license
9728
 *
9729
 * http://docs.jquery.com/UI/Progressbar
9730
 *
9731
 * Depends:
9732
 *   jquery.ui.core.js
9733
 *   jquery.ui.widget.js
9734
 */
9735
(function( $, undefined ) {
9736
 
9737
$.widget( "ui.progressbar", {
9738
	options: {
9739
		value: 0
9740
	},
9741
 
9742
	min: 0,
9743
	max: 100,
9744
 
9745
	_create: function() {
9746
		this.element
9747
			.addClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
9748
			.attr({
9749
				role: "progressbar",
9750
				"aria-valuemin": this.min,
9751
				"aria-valuemax": this.max,
9752
				"aria-valuenow": this._value()
9753
			});
9754
 
9755
		this.valueDiv = $( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>" )
9756
			.appendTo( this.element );
9757
 
9758
		this._refreshValue();
9759
	},
9760
 
9761
	destroy: function() {
9762
		this.element
9763
			.removeClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
9764
			.removeAttr( "role" )
9765
			.removeAttr( "aria-valuemin" )
9766
			.removeAttr( "aria-valuemax" )
9767
			.removeAttr( "aria-valuenow" );
9768
 
9769
		this.valueDiv.remove();
9770
 
9771
		$.Widget.prototype.destroy.apply( this, arguments );
9772
	},
9773
 
9774
	value: function( newValue ) {
9775
		if ( newValue === undefined ) {
9776
			return this._value();
9777
		}
9778
 
9779
		this._setOption( "value", newValue );
9780
		return this;
9781
	},
9782
 
9783
	_setOption: function( key, value ) {
9784
		if ( key === "value" ) {
9785
			this.options.value = value;
9786
			this._refreshValue();
9787
			this._trigger( "change" );
9788
		}
9789
 
9790
		$.Widget.prototype._setOption.apply( this, arguments );
9791
	},
9792
 
9793
	_value: function() {
9794
		var val = this.options.value;
9795
		// normalize invalid value
9796
		if ( typeof val !== "number" ) {
9797
			val = 0;
9798
		}
9799
		return Math.min( this.max, Math.max( this.min, val ) );
9800
	},
9801
 
9802
	_refreshValue: function() {
9803
		var value = this.value();
9804
		this.valueDiv
9805
			.toggleClass( "ui-corner-right", value === this.max )
9806
			.width( value + "%" );
9807
		this.element.attr( "aria-valuenow", value );
9808
	}
9809
});
9810
 
9811
$.extend( $.ui.progressbar, {
9812
	version: "1.8.5"
9813
});
9814
 
9815
})( jQuery );
9816
/*
9817
 * jQuery UI Effects 1.8.5
9818
 *
9819
 * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
9820
 * Dual licensed under the MIT or GPL Version 2 licenses.
9821
 * http://jquery.org/license
9822
 *
9823
 * http://docs.jquery.com/UI/Effects/
9824
 */
9825
;jQuery.effects || (function($, undefined) {
9826
 
9827
$.effects = {};
9828
 
9829
 
9830
 
9831
/******************************************************************************/
9832
/****************************** COLOR ANIMATIONS ******************************/
9833
/******************************************************************************/
9834
 
9835
// override the animation for color styles
9836
$.each(['backgroundColor', 'borderBottomColor', 'borderLeftColor',
9837
	'borderRightColor', 'borderTopColor', 'color', 'outlineColor'],
9838
function(i, attr) {
9839
	$.fx.step[attr] = function(fx) {
9840
		if (!fx.colorInit) {
9841
			fx.start = getColor(fx.elem, attr);
9842
			fx.end = getRGB(fx.end);
9843
			fx.colorInit = true;
9844
		}
9845
 
9846
		fx.elem.style[attr] = 'rgb(' +
9847
			Math.max(Math.min(parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0], 10), 255), 0) + ',' +
9848
			Math.max(Math.min(parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1], 10), 255), 0) + ',' +
9849
			Math.max(Math.min(parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2], 10), 255), 0) + ')';
9850
	};
9851
});
9852
 
9853
// Color Conversion functions from highlightFade
9854
// By Blair Mitchelmore
9855
// http://jquery.offput.ca/highlightFade/
9856
 
9857
// Parse strings looking for color tuples [255,255,255]
9858
function getRGB(color) {
9859
		var result;
9860
 
9861
		// Check if we're already dealing with an array of colors
9862
		if ( color && color.constructor == Array && color.length == 3 )
9863
				return color;
9864
 
9865
		// Look for rgb(num,num,num)
9866
		if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color))
9867
				return [parseInt(result[1],10), parseInt(result[2],10), parseInt(result[3],10)];
9868
 
9869
		// Look for rgb(num%,num%,num%)
9870
		if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color))
9871
				return [parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55];
9872
 
9873
		// Look for #a0b1c2
9874
		if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color))
9875
				return [parseInt(result[1],16), parseInt(result[2],16), parseInt(result[3],16)];
9876
 
9877
		// Look for #fff
9878
		if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color))
9879
				return [parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16)];
9880
 
9881
		// Look for rgba(0, 0, 0, 0) == transparent in Safari 3
9882
		if (result = /rgba\(0, 0, 0, 0\)/.exec(color))
9883
				return colors['transparent'];
9884
 
9885
		// Otherwise, we're most likely dealing with a named color
9886
		return colors[$.trim(color).toLowerCase()];
9887
}
9888
 
9889
function getColor(elem, attr) {
9890
		var color;
9891
 
9892
		do {
9893
				color = $.curCSS(elem, attr);
9894
 
9895
				// Keep going until we find an element that has color, or we hit the body
9896
				if ( color != '' && color != 'transparent' || $.nodeName(elem, "body") )
9897
						break;
9898
 
9899
				attr = "backgroundColor";
9900
		} while ( elem = elem.parentNode );
9901
 
9902
		return getRGB(color);
9903
};
9904
 
9905
// Some named colors to work with
9906
// From Interface by Stefan Petre
9907
// http://interface.eyecon.ro/
9908
 
9909
var colors = {
9910
	aqua:[0,255,255],
9911
	azure:[240,255,255],
9912
	beige:[245,245,220],
9913
	black:[0,0,0],
9914
	blue:[0,0,255],
9915
	brown:[165,42,42],
9916
	cyan:[0,255,255],
9917
	darkblue:[0,0,139],
9918
	darkcyan:[0,139,139],
9919
	darkgrey:[169,169,169],
9920
	darkgreen:[0,100,0],
9921
	darkkhaki:[189,183,107],
9922
	darkmagenta:[139,0,139],
9923
	darkolivegreen:[85,107,47],
9924
	darkorange:[255,140,0],
9925
	darkorchid:[153,50,204],
9926
	darkred:[139,0,0],
9927
	darksalmon:[233,150,122],
9928
	darkviolet:[148,0,211],
9929
	fuchsia:[255,0,255],
9930
	gold:[255,215,0],
9931
	green:[0,128,0],
9932
	indigo:[75,0,130],
9933
	khaki:[240,230,140],
9934
	lightblue:[173,216,230],
9935
	lightcyan:[224,255,255],
9936
	lightgreen:[144,238,144],
9937
	lightgrey:[211,211,211],
9938
	lightpink:[255,182,193],
9939
	lightyellow:[255,255,224],
9940
	lime:[0,255,0],
9941
	magenta:[255,0,255],
9942
	maroon:[128,0,0],
9943
	navy:[0,0,128],
9944
	olive:[128,128,0],
9945
	orange:[255,165,0],
9946
	pink:[255,192,203],
9947
	purple:[128,0,128],
9948
	violet:[128,0,128],
9949
	red:[255,0,0],
9950
	silver:[192,192,192],
9951
	white:[255,255,255],
9952
	yellow:[255,255,0],
9953
	transparent: [255,255,255]
9954
};
9955
 
9956
 
9957
 
9958
/******************************************************************************/
9959
/****************************** CLASS ANIMATIONS ******************************/
9960
/******************************************************************************/
9961
 
9962
var classAnimationActions = ['add', 'remove', 'toggle'],
9963
	shorthandStyles = {
9964
		border: 1,
9965
		borderBottom: 1,
9966
		borderColor: 1,
9967
		borderLeft: 1,
9968
		borderRight: 1,
9969
		borderTop: 1,
9970
		borderWidth: 1,
9971
		margin: 1,
9972
		padding: 1
9973
	};
9974
 
9975
function getElementStyles() {
9976
	var style = document.defaultView
9977
			? document.defaultView.getComputedStyle(this, null)
9978
			: this.currentStyle,
9979
		newStyle = {},
9980
		key,
9981
		camelCase;
9982
 
9983
	// webkit enumerates style porperties
9984
	if (style && style.length && style[0] && style[style[0]]) {
9985
		var len = style.length;
9986
		while (len--) {
9987
			key = style[len];
9988
			if (typeof style[key] == 'string') {
9989
				camelCase = key.replace(/\-(\w)/g, function(all, letter){
9990
					return letter.toUpperCase();
9991
				});
9992
				newStyle[camelCase] = style[key];
9993
			}
9994
		}
9995
	} else {
9996
		for (key in style) {
9997
			if (typeof style[key] === 'string') {
9998
				newStyle[key] = style[key];
9999
			}
10000
		}
10001
	}
10002
 
10003
	return newStyle;
10004
}
10005
 
10006
function filterStyles(styles) {
10007
	var name, value;
10008
	for (name in styles) {
10009
		value = styles[name];
10010
		if (
10011
			// ignore null and undefined values
10012
			value == null ||
10013
			// ignore functions (when does this occur?)
10014
			$.isFunction(value) ||
10015
			// shorthand styles that need to be expanded
10016
			name in shorthandStyles ||
10017
			// ignore scrollbars (break in IE)
10018
			(/scrollbar/).test(name) ||
10019
 
10020
			// only colors or values that can be converted to numbers
10021
			(!(/color/i).test(name) && isNaN(parseFloat(value)))
10022
		) {
10023
			delete styles[name];
10024
		}
10025
	}
10026
 
10027
	return styles;
10028
}
10029
 
10030
function styleDifference(oldStyle, newStyle) {
10031
	var diff = { _: 0 }, // http://dev.jquery.com/ticket/5459
10032
		name;
10033
 
10034
	for (name in newStyle) {
10035
		if (oldStyle[name] != newStyle[name]) {
10036
			diff[name] = newStyle[name];
10037
		}
10038
	}
10039
 
10040
	return diff;
10041
}
10042
 
10043
$.effects.animateClass = function(value, duration, easing, callback) {
10044
	if ($.isFunction(easing)) {
10045
		callback = easing;
10046
		easing = null;
10047
	}
10048
 
10049
	return this.each(function() {
10050
 
10051
		var that = $(this),
10052
			originalStyleAttr = that.attr('style') || ' ',
10053
			originalStyle = filterStyles(getElementStyles.call(this)),
10054
			newStyle,
10055
			className = that.attr('className');
10056
 
10057
		$.each(classAnimationActions, function(i, action) {
10058
			if (value[action]) {
10059
				that[action + 'Class'](value[action]);
10060
			}
10061
		});
10062
		newStyle = filterStyles(getElementStyles.call(this));
10063
		that.attr('className', className);
10064
 
10065
		that.animate(styleDifference(originalStyle, newStyle), duration, easing, function() {
10066
			$.each(classAnimationActions, function(i, action) {
10067
				if (value[action]) { that[action + 'Class'](value[action]); }
10068
			});
10069
			// work around bug in IE by clearing the cssText before setting it
10070
			if (typeof that.attr('style') == 'object') {
10071
				that.attr('style').cssText = '';
10072
				that.attr('style').cssText = originalStyleAttr;
10073
			} else {
10074
				that.attr('style', originalStyleAttr);
10075
			}
10076
			if (callback) { callback.apply(this, arguments); }
10077
		});
10078
	});
10079
};
10080
 
10081
$.fn.extend({
10082
	_addClass: $.fn.addClass,
10083
	addClass: function(classNames, speed, easing, callback) {
10084
		return speed ? $.effects.animateClass.apply(this, [{ add: classNames },speed,easing,callback]) : this._addClass(classNames);
10085
	},
10086
 
10087
	_removeClass: $.fn.removeClass,
10088
	removeClass: function(classNames,speed,easing,callback) {
10089
		return speed ? $.effects.animateClass.apply(this, [{ remove: classNames },speed,easing,callback]) : this._removeClass(classNames);
10090
	},
10091
 
10092
	_toggleClass: $.fn.toggleClass,
10093
	toggleClass: function(classNames, force, speed, easing, callback) {
10094
		if ( typeof force == "boolean" || force === undefined ) {
10095
			if ( !speed ) {
10096
				// without speed parameter;
10097
				return this._toggleClass(classNames, force);
10098
			} else {
10099
				return $.effects.animateClass.apply(this, [(force?{add:classNames}:{remove:classNames}),speed,easing,callback]);
10100
			}
10101
		} else {
10102
			// without switch parameter;
10103
			return $.effects.animateClass.apply(this, [{ toggle: classNames },force,speed,easing]);
10104
		}
10105
	},
10106
 
10107
	switchClass: function(remove,add,speed,easing,callback) {
10108
		return $.effects.animateClass.apply(this, [{ add: add, remove: remove },speed,easing,callback]);
10109
	}
10110
});
10111
 
10112
 
10113
 
10114
/******************************************************************************/
10115
/*********************************** EFFECTS **********************************/
10116
/******************************************************************************/
10117
 
10118
$.extend($.effects, {
10119
	version: "1.8.5",
10120
 
10121
	// Saves a set of properties in a data storage
10122
	save: function(element, set) {
10123
		for(var i=0; i < set.length; i++) {
10124
			if(set[i] !== null) element.data("ec.storage."+set[i], element[0].style[set[i]]);
10125
		}
10126
	},
10127
 
10128
	// Restores a set of previously saved properties from a data storage
10129
	restore: function(element, set) {
10130
		for(var i=0; i < set.length; i++) {
10131
			if(set[i] !== null) element.css(set[i], element.data("ec.storage."+set[i]));
10132
		}
10133
	},
10134
 
10135
	setMode: function(el, mode) {
10136
		if (mode == 'toggle') mode = el.is(':hidden') ? 'show' : 'hide'; // Set for toggle
10137
		return mode;
10138
	},
10139
 
10140
	getBaseline: function(origin, original) { // Translates a [top,left] array into a baseline value
10141
		// this should be a little more flexible in the future to handle a string & hash
10142
		var y, x;
10143
		switch (origin[0]) {
10144
			case 'top': y = 0; break;
10145
			case 'middle': y = 0.5; break;
10146
			case 'bottom': y = 1; break;
10147
			default: y = origin[0] / original.height;
10148
		};
10149
		switch (origin[1]) {
10150
			case 'left': x = 0; break;
10151
			case 'center': x = 0.5; break;
10152
			case 'right': x = 1; break;
10153
			default: x = origin[1] / original.width;
10154
		};
10155
		return {x: x, y: y};
10156
	},
10157
 
10158
	// Wraps the element around a wrapper that copies position properties
10159
	createWrapper: function(element) {
10160
 
10161
		// if the element is already wrapped, return it
10162
		if (element.parent().is('.ui-effects-wrapper')) {
10163
			return element.parent();
10164
		}
10165
 
10166
		// wrap the element
10167
		var props = {
10168
				width: element.outerWidth(true),
10169
				height: element.outerHeight(true),
10170
				'float': element.css('float')
10171
			},
10172
			wrapper = $('<div></div>')
10173
				.addClass('ui-effects-wrapper')
10174
				.css({
10175
					fontSize: '100%',
10176
					background: 'transparent',
10177
					border: 'none',
10178
					margin: 0,
10179
					padding: 0
10180
				});
10181
 
10182
		element.wrap(wrapper);
10183
		wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually loose the reference to the wrapped element
10184
 
10185
		// transfer positioning properties to the wrapper
10186
		if (element.css('position') == 'static') {
10187
			wrapper.css({ position: 'relative' });
10188
			element.css({ position: 'relative' });
10189
		} else {
10190
			$.extend(props, {
10191
				position: element.css('position'),
10192
				zIndex: element.css('z-index')
10193
			});
10194
			$.each(['top', 'left', 'bottom', 'right'], function(i, pos) {
10195
				props[pos] = element.css(pos);
10196
				if (isNaN(parseInt(props[pos], 10))) {
10197
					props[pos] = 'auto';
10198
				}
10199
			});
10200
			element.css({position: 'relative', top: 0, left: 0 });
10201
		}
10202
 
10203
		return wrapper.css(props).show();
10204
	},
10205
 
10206
	removeWrapper: function(element) {
10207
		if (element.parent().is('.ui-effects-wrapper'))
10208
			return element.parent().replaceWith(element);
10209
		return element;
10210
	},
10211
 
10212
	setTransition: function(element, list, factor, value) {
10213
		value = value || {};
10214
		$.each(list, function(i, x){
10215
			unit = element.cssUnit(x);
10216
			if (unit[0] > 0) value[x] = unit[0] * factor + unit[1];
10217
		});
10218
		return value;
10219
	}
10220
});
10221
 
10222
 
10223
function _normalizeArguments(effect, options, speed, callback) {
10224
	// shift params for method overloading
10225
	if (typeof effect == 'object') {
10226
		callback = options;
10227
		speed = null;
10228
		options = effect;
10229
		effect = options.effect;
10230
	}
10231
	if ($.isFunction(options)) {
10232
		callback = options;
10233
		speed = null;
10234
		options = {};
10235
	}
10236
        if (typeof options == 'number' || $.fx.speeds[options]) {
10237
		callback = speed;
10238
		speed = options;
10239
		options = {};
10240
	}
10241
	if ($.isFunction(speed)) {
10242
		callback = speed;
10243
		speed = null;
10244
	}
10245
 
10246
	options = options || {};
10247
 
10248
	speed = speed || options.duration;
10249
	speed = $.fx.off ? 0 : typeof speed == 'number'
10250
		? speed : $.fx.speeds[speed] || $.fx.speeds._default;
10251
 
10252
	callback = callback || options.complete;
10253
 
10254
	return [effect, options, speed, callback];
10255
}
10256
 
10257
$.fn.extend({
10258
	effect: function(effect, options, speed, callback) {
10259
		var args = _normalizeArguments.apply(this, arguments),
10260
			// TODO: make effects takes actual parameters instead of a hash
10261
			args2 = {
10262
				options: args[1],
10263
				duration: args[2],
10264
				callback: args[3]
10265
			},
10266
			effectMethod = $.effects[effect];
10267
 
10268
		return effectMethod && !$.fx.off ? effectMethod.call(this, args2) : this;
10269
	},
10270
 
10271
	_show: $.fn.show,
10272
	show: function(speed) {
10273
		if (!speed || typeof speed == 'number' || $.fx.speeds[speed] || !$.effects[speed] ) {
10274
			return this._show.apply(this, arguments);
10275
		} else {
10276
			var args = _normalizeArguments.apply(this, arguments);
10277
			args[1].mode = 'show';
10278
			return this.effect.apply(this, args);
10279
		}
10280
	},
10281
 
10282
	_hide: $.fn.hide,
10283
	hide: function(speed) {
10284
		if (!speed || typeof speed == 'number' || $.fx.speeds[speed] || !$.effects[speed] ) {
10285
			return this._hide.apply(this, arguments);
10286
		} else {
10287
			var args = _normalizeArguments.apply(this, arguments);
10288
			args[1].mode = 'hide';
10289
			return this.effect.apply(this, args);
10290
		}
10291
	},
10292
 
10293
	// jQuery core overloads toggle and creates _toggle
10294
	__toggle: $.fn.toggle,
10295
	toggle: function(speed) {
10296
		if (!speed || typeof speed == 'number' || $.fx.speeds[speed] || !$.effects[speed]  ||
10297
			typeof speed == 'boolean' || $.isFunction(speed)) {
10298
			return this.__toggle.apply(this, arguments);
10299
		} else {
10300
			var args = _normalizeArguments.apply(this, arguments);
10301
			args[1].mode = 'toggle';
10302
			return this.effect.apply(this, args);
10303
		}
10304
	},
10305
 
10306
	// helper functions
10307
	cssUnit: function(key) {
10308
		var style = this.css(key), val = [];
10309
		$.each( ['em','px','%','pt'], function(i, unit){
10310
			if(style.indexOf(unit) > 0)
10311
				val = [parseFloat(style), unit];
10312
		});
10313
		return val;
10314
	}
10315
});
10316
 
10317
 
10318
 
10319
/******************************************************************************/
10320
/*********************************** EASING ***********************************/
10321
/******************************************************************************/
10322
 
10323
/*
10324
 * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
10325
 *
10326
 * Uses the built in easing capabilities added In jQuery 1.1
10327
 * to offer multiple easing options
10328
 *
10329
 * TERMS OF USE - jQuery Easing
10330
 *
10331
 * Open source under the BSD License.
10332
 *
10333
 * Copyright 2008 George McGinley Smith
10334
 * All rights reserved.
10335
 *
10336
 * Redistribution and use in source and binary forms, with or without modification,
10337
 * are permitted provided that the following conditions are met:
10338
 *
10339
 * Redistributions of source code must retain the above copyright notice, this list of
10340
 * conditions and the following disclaimer.
10341
 * Redistributions in binary form must reproduce the above copyright notice, this list
10342
 * of conditions and the following disclaimer in the documentation and/or other materials
10343
 * provided with the distribution.
10344
 *
10345
 * Neither the name of the author nor the names of contributors may be used to endorse
10346
 * or promote products derived from this software without specific prior written permission.
10347
 *
10348
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
10349
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
10350
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
10351
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
10352
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
10353
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
10354
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
10355
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
10356
 * OF THE POSSIBILITY OF SUCH DAMAGE.
10357
 *
10358
*/
10359
 
10360
// t: current time, b: begInnIng value, c: change In value, d: duration
10361
$.easing.jswing = $.easing.swing;
10362
 
10363
$.extend($.easing,
10364
{
10365
	def: 'easeOutQuad',
10366
	swing: function (x, t, b, c, d) {
10367
		//alert($.easing.default);
10368
		return $.easing[$.easing.def](x, t, b, c, d);
10369
	},
10370
	easeInQuad: function (x, t, b, c, d) {
10371
		return c*(t/=d)*t + b;
10372
	},
10373
	easeOutQuad: function (x, t, b, c, d) {
10374
		return -c *(t/=d)*(t-2) + b;
10375
	},
10376
	easeInOutQuad: function (x, t, b, c, d) {
10377
		if ((t/=d/2) < 1) return c/2*t*t + b;
10378
		return -c/2 * ((--t)*(t-2) - 1) + b;
10379
	},
10380
	easeInCubic: function (x, t, b, c, d) {
10381
		return c*(t/=d)*t*t + b;
10382
	},
10383
	easeOutCubic: function (x, t, b, c, d) {
10384
		return c*((t=t/d-1)*t*t + 1) + b;
10385
	},
10386
	easeInOutCubic: function (x, t, b, c, d) {
10387
		if ((t/=d/2) < 1) return c/2*t*t*t + b;
10388
		return c/2*((t-=2)*t*t + 2) + b;
10389
	},
10390
	easeInQuart: function (x, t, b, c, d) {
10391
		return c*(t/=d)*t*t*t + b;
10392
	},
10393
	easeOutQuart: function (x, t, b, c, d) {
10394
		return -c * ((t=t/d-1)*t*t*t - 1) + b;
10395
	},
10396
	easeInOutQuart: function (x, t, b, c, d) {
10397
		if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
10398
		return -c/2 * ((t-=2)*t*t*t - 2) + b;
10399
	},
10400
	easeInQuint: function (x, t, b, c, d) {
10401
		return c*(t/=d)*t*t*t*t + b;
10402
	},
10403
	easeOutQuint: function (x, t, b, c, d) {
10404
		return c*((t=t/d-1)*t*t*t*t + 1) + b;
10405
	},
10406
	easeInOutQuint: function (x, t, b, c, d) {
10407
		if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
10408
		return c/2*((t-=2)*t*t*t*t + 2) + b;
10409
	},
10410
	easeInSine: function (x, t, b, c, d) {
10411
		return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
10412
	},
10413
	easeOutSine: function (x, t, b, c, d) {
10414
		return c * Math.sin(t/d * (Math.PI/2)) + b;
10415
	},
10416
	easeInOutSine: function (x, t, b, c, d) {
10417
		return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
10418
	},
10419
	easeInExpo: function (x, t, b, c, d) {
10420
		return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
10421
	},
10422
	easeOutExpo: function (x, t, b, c, d) {
10423
		return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
10424
	},
10425
	easeInOutExpo: function (x, t, b, c, d) {
10426
		if (t==0) return b;
10427
		if (t==d) return b+c;
10428
		if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
10429
		return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
10430
	},
10431
	easeInCirc: function (x, t, b, c, d) {
10432
		return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
10433
	},
10434
	easeOutCirc: function (x, t, b, c, d) {
10435
		return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
10436
	},
10437
	easeInOutCirc: function (x, t, b, c, d) {
10438
		if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
10439
		return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
10440
	},
10441
	easeInElastic: function (x, t, b, c, d) {
10442
		var s=1.70158;var p=0;var a=c;
10443
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
10444
		if (a < Math.abs(c)) { a=c; var s=p/4; }
10445
		else var s = p/(2*Math.PI) * Math.asin (c/a);
10446
		return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
10447
	},
10448
	easeOutElastic: function (x, t, b, c, d) {
10449
		var s=1.70158;var p=0;var a=c;
10450
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
10451
		if (a < Math.abs(c)) { a=c; var s=p/4; }
10452
		else var s = p/(2*Math.PI) * Math.asin (c/a);
10453
		return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
10454
	},
10455
	easeInOutElastic: function (x, t, b, c, d) {
10456
		var s=1.70158;var p=0;var a=c;
10457
		if (t==0) return b;  if ((t/=d/2)==2) return b+c;  if (!p) p=d*(.3*1.5);
10458
		if (a < Math.abs(c)) { a=c; var s=p/4; }
10459
		else var s = p/(2*Math.PI) * Math.asin (c/a);
10460
		if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
10461
		return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
10462
	},
10463
	easeInBack: function (x, t, b, c, d, s) {
10464
		if (s == undefined) s = 1.70158;
10465
		return c*(t/=d)*t*((s+1)*t - s) + b;
10466
	},
10467
	easeOutBack: function (x, t, b, c, d, s) {
10468
		if (s == undefined) s = 1.70158;
10469
		return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
10470
	},
10471
	easeInOutBack: function (x, t, b, c, d, s) {
10472
		if (s == undefined) s = 1.70158;
10473
		if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
10474
		return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
10475
	},
10476
	easeInBounce: function (x, t, b, c, d) {
10477
		return c - $.easing.easeOutBounce (x, d-t, 0, c, d) + b;
10478
	},
10479
	easeOutBounce: function (x, t, b, c, d) {
10480
		if ((t/=d) < (1/2.75)) {
10481
			return c*(7.5625*t*t) + b;
10482
		} else if (t < (2/2.75)) {
10483
			return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
10484
		} else if (t < (2.5/2.75)) {
10485
			return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
10486
		} else {
10487
			return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
10488
		}
10489
	},
10490
	easeInOutBounce: function (x, t, b, c, d) {
10491
		if (t < d/2) return $.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
10492
		return $.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
10493
	}
10494
});
10495
 
10496
/*
10497
 *
10498
 * TERMS OF USE - EASING EQUATIONS
10499
 *
10500
 * Open source under the BSD License.
10501
 *
10502
 * Copyright 2001 Robert Penner
10503
 * All rights reserved.
10504
 *
10505
 * Redistribution and use in source and binary forms, with or without modification,
10506
 * are permitted provided that the following conditions are met:
10507
 *
10508
 * Redistributions of source code must retain the above copyright notice, this list of
10509
 * conditions and the following disclaimer.
10510
 * Redistributions in binary form must reproduce the above copyright notice, this list
10511
 * of conditions and the following disclaimer in the documentation and/or other materials
10512
 * provided with the distribution.
10513
 *
10514
 * Neither the name of the author nor the names of contributors may be used to endorse
10515
 * or promote products derived from this software without specific prior written permission.
10516
 *
10517
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
10518
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
10519
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
10520
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
10521
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
10522
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
10523
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
10524
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
10525
 * OF THE POSSIBILITY OF SUCH DAMAGE.
10526
 *
10527
 */
10528
 
10529
})(jQuery);
10530
/*
10531
 * jQuery UI Effects Blind 1.8.5
10532
 *
10533
 * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
10534
 * Dual licensed under the MIT or GPL Version 2 licenses.
10535
 * http://jquery.org/license
10536
 *
10537
 * http://docs.jquery.com/UI/Effects/Blind
10538
 *
10539
 * Depends:
10540
 *	jquery.effects.core.js
10541
 */
10542
(function( $, undefined ) {
10543
 
10544
$.effects.blind = function(o) {
10545
 
10546
	return this.queue(function() {
10547
 
10548
		// Create element
10549
		var el = $(this), props = ['position','top','left'];
10550
 
10551
		// Set options
10552
		var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode
10553
		var direction = o.options.direction || 'vertical'; // Default direction
10554
 
10555
		// Adjust
10556
		$.effects.save(el, props); el.show(); // Save & Show
10557
		var wrapper = $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper
10558
		var ref = (direction == 'vertical') ? 'height' : 'width';
10559
		var distance = (direction == 'vertical') ? wrapper.height() : wrapper.width();
10560
		if(mode == 'show') wrapper.css(ref, 0); // Shift
10561
 
10562
		// Animation
10563
		var animation = {};
10564
		animation[ref] = mode == 'show' ? distance : 0;
10565
 
10566
		// Animate
10567
		wrapper.animate(animation, o.duration, o.options.easing, function() {
10568
			if(mode == 'hide') el.hide(); // Hide
10569
			$.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
10570
			if(o.callback) o.callback.apply(el[0], arguments); // Callback
10571
			el.dequeue();
10572
		});
10573
 
10574
	});
10575
 
10576
};
10577
 
10578
})(jQuery);
10579
/*
10580
 * jQuery UI Effects Bounce 1.8.5
10581
 *
10582
 * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
10583
 * Dual licensed under the MIT or GPL Version 2 licenses.
10584
 * http://jquery.org/license
10585
 *
10586
 * http://docs.jquery.com/UI/Effects/Bounce
10587
 *
10588
 * Depends:
10589
 *	jquery.effects.core.js
10590
 */
10591
(function( $, undefined ) {
10592
 
10593
$.effects.bounce = function(o) {
10594
 
10595
	return this.queue(function() {
10596
 
10597
		// Create element
10598
		var el = $(this), props = ['position','top','left'];
10599
 
10600
		// Set options
10601
		var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode
10602
		var direction = o.options.direction || 'up'; // Default direction
10603
		var distance = o.options.distance || 20; // Default distance
10604
		var times = o.options.times || 5; // Default # of times
10605
		var speed = o.duration || 250; // Default speed per bounce
10606
		if (/show|hide/.test(mode)) props.push('opacity'); // Avoid touching opacity to prevent clearType and PNG issues in IE
10607
 
10608
		// Adjust
10609
		$.effects.save(el, props); el.show(); // Save & Show
10610
		$.effects.createWrapper(el); // Create Wrapper
10611
		var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left';
10612
		var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg';
10613
		var distance = o.options.distance || (ref == 'top' ? el.outerHeight({margin:true}) / 3 : el.outerWidth({margin:true}) / 3);
10614
		if (mode == 'show') el.css('opacity', 0).css(ref, motion == 'pos' ? -distance : distance); // Shift
10615
		if (mode == 'hide') distance = distance / (times * 2);
10616
		if (mode != 'hide') times--;
10617
 
10618
		// Animate
10619
		if (mode == 'show') { // Show Bounce
10620
			var animation = {opacity: 1};
10621
			animation[ref] = (motion == 'pos' ? '+=' : '-=') + distance;
10622
			el.animate(animation, speed / 2, o.options.easing);
10623
			distance = distance / 2;
10624
			times--;
10625
		};
10626
		for (var i = 0; i < times; i++) { // Bounces
10627
			var animation1 = {}, animation2 = {};
10628
			animation1[ref] = (motion == 'pos' ? '-=' : '+=') + distance;
10629
			animation2[ref] = (motion == 'pos' ? '+=' : '-=') + distance;
10630
			el.animate(animation1, speed / 2, o.options.easing).animate(animation2, speed / 2, o.options.easing);
10631
			distance = (mode == 'hide') ? distance * 2 : distance / 2;
10632
		};
10633
		if (mode == 'hide') { // Last Bounce
10634
			var animation = {opacity: 0};
10635
			animation[ref] = (motion == 'pos' ? '-=' : '+=')  + distance;
10636
			el.animate(animation, speed / 2, o.options.easing, function(){
10637
				el.hide(); // Hide
10638
				$.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
10639
				if(o.callback) o.callback.apply(this, arguments); // Callback
10640
			});
10641
		} else {
10642
			var animation1 = {}, animation2 = {};
10643
			animation1[ref] = (motion == 'pos' ? '-=' : '+=') + distance;
10644
			animation2[ref] = (motion == 'pos' ? '+=' : '-=') + distance;
10645
			el.animate(animation1, speed / 2, o.options.easing).animate(animation2, speed / 2, o.options.easing, function(){
10646
				$.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
10647
				if(o.callback) o.callback.apply(this, arguments); // Callback
10648
			});
10649
		};
10650
		el.queue('fx', function() { el.dequeue(); });
10651
		el.dequeue();
10652
	});
10653
 
10654
};
10655
 
10656
})(jQuery);
10657
/*
10658
 * jQuery UI Effects Clip 1.8.5
10659
 *
10660
 * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
10661
 * Dual licensed under the MIT or GPL Version 2 licenses.
10662
 * http://jquery.org/license
10663
 *
10664
 * http://docs.jquery.com/UI/Effects/Clip
10665
 *
10666
 * Depends:
10667
 *	jquery.effects.core.js
10668
 */
10669
(function( $, undefined ) {
10670
 
10671
$.effects.clip = function(o) {
10672
 
10673
	return this.queue(function() {
10674
 
10675
		// Create element
10676
		var el = $(this), props = ['position','top','left','height','width'];
10677
 
10678
		// Set options
10679
		var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode
10680
		var direction = o.options.direction || 'vertical'; // Default direction
10681
 
10682
		// Adjust
10683
		$.effects.save(el, props); el.show(); // Save & Show
10684
		var wrapper = $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper
10685
		var animate = el[0].tagName == 'IMG' ? wrapper : el;
10686
		var ref = {
10687
			size: (direction == 'vertical') ? 'height' : 'width',
10688
			position: (direction == 'vertical') ? 'top' : 'left'
10689
		};
10690
		var distance = (direction == 'vertical') ? animate.height() : animate.width();
10691
		if(mode == 'show') { animate.css(ref.size, 0); animate.css(ref.position, distance / 2); } // Shift
10692
 
10693
		// Animation
10694
		var animation = {};
10695
		animation[ref.size] = mode == 'show' ? distance : 0;
10696
		animation[ref.position] = mode == 'show' ? 0 : distance / 2;
10697
 
10698
		// Animate
10699
		animate.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() {
10700
			if(mode == 'hide') el.hide(); // Hide
10701
			$.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
10702
			if(o.callback) o.callback.apply(el[0], arguments); // Callback
10703
			el.dequeue();
10704
		}});
10705
 
10706
	});
10707
 
10708
};
10709
 
10710
})(jQuery);
10711
/*
10712
 * jQuery UI Effects Drop 1.8.5
10713
 *
10714
 * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
10715
 * Dual licensed under the MIT or GPL Version 2 licenses.
10716
 * http://jquery.org/license
10717
 *
10718
 * http://docs.jquery.com/UI/Effects/Drop
10719
 *
10720
 * Depends:
10721
 *	jquery.effects.core.js
10722
 */
10723
(function( $, undefined ) {
10724
 
10725
$.effects.drop = function(o) {
10726
 
10727
	return this.queue(function() {
10728
 
10729
		// Create element
10730
		var el = $(this), props = ['position','top','left','opacity'];
10731
 
10732
		// Set options
10733
		var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode
10734
		var direction = o.options.direction || 'left'; // Default Direction
10735
 
10736
		// Adjust
10737
		$.effects.save(el, props); el.show(); // Save & Show
10738
		$.effects.createWrapper(el); // Create Wrapper
10739
		var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left';
10740
		var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg';
10741
		var distance = o.options.distance || (ref == 'top' ? el.outerHeight({margin:true}) / 2 : el.outerWidth({margin:true}) / 2);
10742
		if (mode == 'show') el.css('opacity', 0).css(ref, motion == 'pos' ? -distance : distance); // Shift
10743
 
10744
		// Animation
10745
		var animation = {opacity: mode == 'show' ? 1 : 0};
10746
		animation[ref] = (mode == 'show' ? (motion == 'pos' ? '+=' : '-=') : (motion == 'pos' ? '-=' : '+=')) + distance;
10747
 
10748
		// Animate
10749
		el.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() {
10750
			if(mode == 'hide') el.hide(); // Hide
10751
			$.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
10752
			if(o.callback) o.callback.apply(this, arguments); // Callback
10753
			el.dequeue();
10754
		}});
10755
 
10756
	});
10757
 
10758
};
10759
 
10760
})(jQuery);
10761
/*
10762
 * jQuery UI Effects Explode 1.8.5
10763
 *
10764
 * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
10765
 * Dual licensed under the MIT or GPL Version 2 licenses.
10766
 * http://jquery.org/license
10767
 *
10768
 * http://docs.jquery.com/UI/Effects/Explode
10769
 *
10770
 * Depends:
10771
 *	jquery.effects.core.js
10772
 */
10773
(function( $, undefined ) {
10774
 
10775
$.effects.explode = function(o) {
10776
 
10777
	return this.queue(function() {
10778
 
10779
	var rows = o.options.pieces ? Math.round(Math.sqrt(o.options.pieces)) : 3;
10780
	var cells = o.options.pieces ? Math.round(Math.sqrt(o.options.pieces)) : 3;
10781
 
10782
	o.options.mode = o.options.mode == 'toggle' ? ($(this).is(':visible') ? 'hide' : 'show') : o.options.mode;
10783
	var el = $(this).show().css('visibility', 'hidden');
10784
	var offset = el.offset();
10785
 
10786
	//Substract the margins - not fixing the problem yet.
10787
	offset.top -= parseInt(el.css("marginTop"),10) || 0;
10788
	offset.left -= parseInt(el.css("marginLeft"),10) || 0;
10789
 
10790
	var width = el.outerWidth(true);
10791
	var height = el.outerHeight(true);
10792
 
10793
	for(var i=0;i<rows;i++) { // =
10794
		for(var j=0;j<cells;j++) { // ||
10795
			el
10796
				.clone()
10797
				.appendTo('body')
10798
				.wrap('<div></div>')
10799
				.css({
10800
					position: 'absolute',
10801
					visibility: 'visible',
10802
					left: -j*(width/cells),
10803
					top: -i*(height/rows)
10804
				})
10805
				.parent()
10806
				.addClass('ui-effects-explode')
10807
				.css({
10808
					position: 'absolute',
10809
					overflow: 'hidden',
10810
					width: width/cells,
10811
					height: height/rows,
10812
					left: offset.left + j*(width/cells) + (o.options.mode == 'show' ? (j-Math.floor(cells/2))*(width/cells) : 0),
10813
					top: offset.top + i*(height/rows) + (o.options.mode == 'show' ? (i-Math.floor(rows/2))*(height/rows) : 0),
10814
					opacity: o.options.mode == 'show' ? 0 : 1
10815
				}).animate({
10816
					left: offset.left + j*(width/cells) + (o.options.mode == 'show' ? 0 : (j-Math.floor(cells/2))*(width/cells)),
10817
					top: offset.top + i*(height/rows) + (o.options.mode == 'show' ? 0 : (i-Math.floor(rows/2))*(height/rows)),
10818
					opacity: o.options.mode == 'show' ? 1 : 0
10819
				}, o.duration || 500);
10820
		}
10821
	}
10822
 
10823
	// Set a timeout, to call the callback approx. when the other animations have finished
10824
	setTimeout(function() {
10825
 
10826
		o.options.mode == 'show' ? el.css({ visibility: 'visible' }) : el.css({ visibility: 'visible' }).hide();
10827
				if(o.callback) o.callback.apply(el[0]); // Callback
10828
				el.dequeue();
10829
 
10830
				$('div.ui-effects-explode').remove();
10831
 
10832
	}, o.duration || 500);
10833
 
10834
 
10835
	});
10836
 
10837
};
10838
 
10839
})(jQuery);
10840
/*
10841
 * jQuery UI Effects Fade 1.8.5
10842
 *
10843
 * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
10844
 * Dual licensed under the MIT or GPL Version 2 licenses.
10845
 * http://jquery.org/license
10846
 *
10847
 * http://docs.jquery.com/UI/Effects/Fade
10848
 *
10849
 * Depends:
10850
 *	jquery.effects.core.js
10851
 */
10852
(function( $, undefined ) {
10853
 
10854
$.effects.fade = function(o) {
10855
	return this.queue(function() {
10856
		var elem = $(this),
10857
			mode = $.effects.setMode(elem, o.options.mode || 'hide');
10858
 
10859
		elem.animate({ opacity: mode }, {
10860
			queue: false,
10861
			duration: o.duration,
10862
			easing: o.options.easing,
10863
			complete: function() {
10864
				(o.callback && o.callback.apply(this, arguments));
10865
				elem.dequeue();
10866
			}
10867
		});
10868
	});
10869
};
10870
 
10871
})(jQuery);
10872
/*
10873
 * jQuery UI Effects Fold 1.8.5
10874
 *
10875
 * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
10876
 * Dual licensed under the MIT or GPL Version 2 licenses.
10877
 * http://jquery.org/license
10878
 *
10879
 * http://docs.jquery.com/UI/Effects/Fold
10880
 *
10881
 * Depends:
10882
 *	jquery.effects.core.js
10883
 */
10884
(function( $, undefined ) {
10885
 
10886
$.effects.fold = function(o) {
10887
 
10888
	return this.queue(function() {
10889
 
10890
		// Create element
10891
		var el = $(this), props = ['position','top','left'];
10892
 
10893
		// Set options
10894
		var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode
10895
		var size = o.options.size || 15; // Default fold size
10896
		var horizFirst = !(!o.options.horizFirst); // Ensure a boolean value
10897
		var duration = o.duration ? o.duration / 2 : $.fx.speeds._default / 2;
10898
 
10899
		// Adjust
10900
		$.effects.save(el, props); el.show(); // Save & Show
10901
		var wrapper = $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper
10902
		var widthFirst = ((mode == 'show') != horizFirst);
10903
		var ref = widthFirst ? ['width', 'height'] : ['height', 'width'];
10904
		var distance = widthFirst ? [wrapper.width(), wrapper.height()] : [wrapper.height(), wrapper.width()];
10905
		var percent = /([0-9]+)%/.exec(size);
10906
		if(percent) size = parseInt(percent[1],10) / 100 * distance[mode == 'hide' ? 0 : 1];
10907
		if(mode == 'show') wrapper.css(horizFirst ? {height: 0, width: size} : {height: size, width: 0}); // Shift
10908
 
10909
		// Animation
10910
		var animation1 = {}, animation2 = {};
10911
		animation1[ref[0]] = mode == 'show' ? distance[0] : size;
10912
		animation2[ref[1]] = mode == 'show' ? distance[1] : 0;
10913
 
10914
		// Animate
10915
		wrapper.animate(animation1, duration, o.options.easing)
10916
		.animate(animation2, duration, o.options.easing, function() {
10917
			if(mode == 'hide') el.hide(); // Hide
10918
			$.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
10919
			if(o.callback) o.callback.apply(el[0], arguments); // Callback
10920
			el.dequeue();
10921
		});
10922
 
10923
	});
10924
 
10925
};
10926
 
10927
})(jQuery);
10928
/*
10929
 * jQuery UI Effects Highlight 1.8.5
10930
 *
10931
 * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
10932
 * Dual licensed under the MIT or GPL Version 2 licenses.
10933
 * http://jquery.org/license
10934
 *
10935
 * http://docs.jquery.com/UI/Effects/Highlight
10936
 *
10937
 * Depends:
10938
 *	jquery.effects.core.js
10939
 */
10940
(function( $, undefined ) {
10941
 
10942
$.effects.highlight = function(o) {
10943
	return this.queue(function() {
10944
		var elem = $(this),
10945
			props = ['backgroundImage', 'backgroundColor', 'opacity'],
10946
			mode = $.effects.setMode(elem, o.options.mode || 'show'),
10947
			animation = {
10948
				backgroundColor: elem.css('backgroundColor')
10949
			};
10950
 
10951
		if (mode == 'hide') {
10952
			animation.opacity = 0;
10953
		}
10954
 
10955
		$.effects.save(elem, props);
10956
		elem
10957
			.show()
10958
			.css({
10959
				backgroundImage: 'none',
10960
				backgroundColor: o.options.color || '#ffff99'
10961
			})
10962
			.animate(animation, {
10963
				queue: false,
10964
				duration: o.duration,
10965
				easing: o.options.easing,
10966
				complete: function() {
10967
					(mode == 'hide' && elem.hide());
10968
					$.effects.restore(elem, props);
10969
					(mode == 'show' && !$.support.opacity && this.style.removeAttribute('filter'));
10970
					(o.callback && o.callback.apply(this, arguments));
10971
					elem.dequeue();
10972
				}
10973
			});
10974
	});
10975
};
10976
 
10977
})(jQuery);
10978
/*
10979
 * jQuery UI Effects Pulsate 1.8.5
10980
 *
10981
 * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
10982
 * Dual licensed under the MIT or GPL Version 2 licenses.
10983
 * http://jquery.org/license
10984
 *
10985
 * http://docs.jquery.com/UI/Effects/Pulsate
10986
 *
10987
 * Depends:
10988
 *	jquery.effects.core.js
10989
 */
10990
(function( $, undefined ) {
10991
 
10992
$.effects.pulsate = function(o) {
10993
	return this.queue(function() {
10994
		var elem = $(this),
10995
			mode = $.effects.setMode(elem, o.options.mode || 'show');
10996
			times = ((o.options.times || 5) * 2) - 1;
10997
			duration = o.duration ? o.duration / 2 : $.fx.speeds._default / 2,
10998
			isVisible = elem.is(':visible'),
10999
			animateTo = 0;
11000
 
11001
		if (!isVisible) {
11002
			elem.css('opacity', 0).show();
11003
			animateTo = 1;
11004
		}
11005
 
11006
		if ((mode == 'hide' && isVisible) || (mode == 'show' && !isVisible)) {
11007
			times--;
11008
		}
11009
 
11010
		for (var i = 0; i < times; i++) {
11011
			elem.animate({ opacity: animateTo }, duration, o.options.easing);
11012
			animateTo = (animateTo + 1) % 2;
11013
		}
11014
 
11015
		elem.animate({ opacity: animateTo }, duration, o.options.easing, function() {
11016
			if (animateTo == 0) {
11017
				elem.hide();
11018
			}
11019
			(o.callback && o.callback.apply(this, arguments));
11020
		});
11021
 
11022
		elem
11023
			.queue('fx', function() { elem.dequeue(); })
11024
			.dequeue();
11025
	});
11026
};
11027
 
11028
})(jQuery);
11029
/*
11030
 * jQuery UI Effects Scale 1.8.5
11031
 *
11032
 * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
11033
 * Dual licensed under the MIT or GPL Version 2 licenses.
11034
 * http://jquery.org/license
11035
 *
11036
 * http://docs.jquery.com/UI/Effects/Scale
11037
 *
11038
 * Depends:
11039
 *	jquery.effects.core.js
11040
 */
11041
(function( $, undefined ) {
11042
 
11043
$.effects.puff = function(o) {
11044
	return this.queue(function() {
11045
		var elem = $(this),
11046
			mode = $.effects.setMode(elem, o.options.mode || 'hide'),
11047
			percent = parseInt(o.options.percent, 10) || 150,
11048
			factor = percent / 100,
11049
			original = { height: elem.height(), width: elem.width() };
11050
 
11051
		$.extend(o.options, {
11052
			fade: true,
11053
			mode: mode,
11054
			percent: mode == 'hide' ? percent : 100,
11055
			from: mode == 'hide'
11056
				? original
11057
				: {
11058
					height: original.height * factor,
11059
					width: original.width * factor
11060
				}
11061
		});
11062
 
11063
		elem.effect('scale', o.options, o.duration, o.callback);
11064
		elem.dequeue();
11065
	});
11066
};
11067
 
11068
$.effects.scale = function(o) {
11069
 
11070
	return this.queue(function() {
11071
 
11072
		// Create element
11073
		var el = $(this);
11074
 
11075
		// Set options
11076
		var options = $.extend(true, {}, o.options);
11077
		var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode
11078
		var percent = parseInt(o.options.percent,10) || (parseInt(o.options.percent,10) == 0 ? 0 : (mode == 'hide' ? 0 : 100)); // Set default scaling percent
11079
		var direction = o.options.direction || 'both'; // Set default axis
11080
		var origin = o.options.origin; // The origin of the scaling
11081
		if (mode != 'effect') { // Set default origin and restore for show/hide
11082
			options.origin = origin || ['middle','center'];
11083
			options.restore = true;
11084
		}
11085
		var original = {height: el.height(), width: el.width()}; // Save original
11086
		el.from = o.options.from || (mode == 'show' ? {height: 0, width: 0} : original); // Default from state
11087
 
11088
		// Adjust
11089
		var factor = { // Set scaling factor
11090
			y: direction != 'horizontal' ? (percent / 100) : 1,
11091
			x: direction != 'vertical' ? (percent / 100) : 1
11092
		};
11093
		el.to = {height: original.height * factor.y, width: original.width * factor.x}; // Set to state
11094
 
11095
		if (o.options.fade) { // Fade option to support puff
11096
			if (mode == 'show') {el.from.opacity = 0; el.to.opacity = 1;};
11097
			if (mode == 'hide') {el.from.opacity = 1; el.to.opacity = 0;};
11098
		};
11099
 
11100
		// Animation
11101
		options.from = el.from; options.to = el.to; options.mode = mode;
11102
 
11103
		// Animate
11104
		el.effect('size', options, o.duration, o.callback);
11105
		el.dequeue();
11106
	});
11107
 
11108
};
11109
 
11110
$.effects.size = function(o) {
11111
 
11112
	return this.queue(function() {
11113
 
11114
		// Create element
11115
		var el = $(this), props = ['position','top','left','width','height','overflow','opacity'];
11116
		var props1 = ['position','top','left','overflow','opacity']; // Always restore
11117
		var props2 = ['width','height','overflow']; // Copy for children
11118
		var cProps = ['fontSize'];
11119
		var vProps = ['borderTopWidth', 'borderBottomWidth', 'paddingTop', 'paddingBottom'];
11120
		var hProps = ['borderLeftWidth', 'borderRightWidth', 'paddingLeft', 'paddingRight'];
11121
 
11122
		// Set options
11123
		var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode
11124
		var restore = o.options.restore || false; // Default restore
11125
		var scale = o.options.scale || 'both'; // Default scale mode
11126
		var origin = o.options.origin; // The origin of the sizing
11127
		var original = {height: el.height(), width: el.width()}; // Save original
11128
		el.from = o.options.from || original; // Default from state
11129
		el.to = o.options.to || original; // Default to state
11130
		// Adjust
11131
		if (origin) { // Calculate baseline shifts
11132
			var baseline = $.effects.getBaseline(origin, original);
11133
			el.from.top = (original.height - el.from.height) * baseline.y;
11134
			el.from.left = (original.width - el.from.width) * baseline.x;
11135
			el.to.top = (original.height - el.to.height) * baseline.y;
11136
			el.to.left = (original.width - el.to.width) * baseline.x;
11137
		};
11138
		var factor = { // Set scaling factor
11139
			from: {y: el.from.height / original.height, x: el.from.width / original.width},
11140
			to: {y: el.to.height / original.height, x: el.to.width / original.width}
11141
		};
11142
		if (scale == 'box' || scale == 'both') { // Scale the css box
11143
			if (factor.from.y != factor.to.y) { // Vertical props scaling
11144
				props = props.concat(vProps);
11145
				el.from = $.effects.setTransition(el, vProps, factor.from.y, el.from);
11146
				el.to = $.effects.setTransition(el, vProps, factor.to.y, el.to);
11147
			};
11148
			if (factor.from.x != factor.to.x) { // Horizontal props scaling
11149
				props = props.concat(hProps);
11150
				el.from = $.effects.setTransition(el, hProps, factor.from.x, el.from);
11151
				el.to = $.effects.setTransition(el, hProps, factor.to.x, el.to);
11152
			};
11153
		};
11154
		if (scale == 'content' || scale == 'both') { // Scale the content
11155
			if (factor.from.y != factor.to.y) { // Vertical props scaling
11156
				props = props.concat(cProps);
11157
				el.from = $.effects.setTransition(el, cProps, factor.from.y, el.from);
11158
				el.to = $.effects.setTransition(el, cProps, factor.to.y, el.to);
11159
			};
11160
		};
11161
		$.effects.save(el, restore ? props : props1); el.show(); // Save & Show
11162
		$.effects.createWrapper(el); // Create Wrapper
11163
		el.css('overflow','hidden').css(el.from); // Shift
11164
 
11165
		// Animate
11166
		if (scale == 'content' || scale == 'both') { // Scale the children
11167
			vProps = vProps.concat(['marginTop','marginBottom']).concat(cProps); // Add margins/font-size
11168
			hProps = hProps.concat(['marginLeft','marginRight']); // Add margins
11169
			props2 = props.concat(vProps).concat(hProps); // Concat
11170
			el.find("*[width]").each(function(){
11171
				child = $(this);
11172
				if (restore) $.effects.save(child, props2);
11173
				var c_original = {height: child.height(), width: child.width()}; // Save original
11174
				child.from = {height: c_original.height * factor.from.y, width: c_original.width * factor.from.x};
11175
				child.to = {height: c_original.height * factor.to.y, width: c_original.width * factor.to.x};
11176
				if (factor.from.y != factor.to.y) { // Vertical props scaling
11177
					child.from = $.effects.setTransition(child, vProps, factor.from.y, child.from);
11178
					child.to = $.effects.setTransition(child, vProps, factor.to.y, child.to);
11179
				};
11180
				if (factor.from.x != factor.to.x) { // Horizontal props scaling
11181
					child.from = $.effects.setTransition(child, hProps, factor.from.x, child.from);
11182
					child.to = $.effects.setTransition(child, hProps, factor.to.x, child.to);
11183
				};
11184
				child.css(child.from); // Shift children
11185
				child.animate(child.to, o.duration, o.options.easing, function(){
11186
					if (restore) $.effects.restore(child, props2); // Restore children
11187
				}); // Animate children
11188
			});
11189
		};
11190
 
11191
		// Animate
11192
		el.animate(el.to, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() {
11193
			if (el.to.opacity === 0) {
11194
				el.css('opacity', el.from.opacity);
11195
			}
11196
			if(mode == 'hide') el.hide(); // Hide
11197
			$.effects.restore(el, restore ? props : props1); $.effects.removeWrapper(el); // Restore
11198
			if(o.callback) o.callback.apply(this, arguments); // Callback
11199
			el.dequeue();
11200
		}});
11201
 
11202
	});
11203
 
11204
};
11205
 
11206
})(jQuery);
11207
/*
11208
 * jQuery UI Effects Shake 1.8.5
11209
 *
11210
 * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
11211
 * Dual licensed under the MIT or GPL Version 2 licenses.
11212
 * http://jquery.org/license
11213
 *
11214
 * http://docs.jquery.com/UI/Effects/Shake
11215
 *
11216
 * Depends:
11217
 *	jquery.effects.core.js
11218
 */
11219
(function( $, undefined ) {
11220
 
11221
$.effects.shake = function(o) {
11222
 
11223
	return this.queue(function() {
11224
 
11225
		// Create element
11226
		var el = $(this), props = ['position','top','left'];
11227
 
11228
		// Set options
11229
		var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode
11230
		var direction = o.options.direction || 'left'; // Default direction
11231
		var distance = o.options.distance || 20; // Default distance
11232
		var times = o.options.times || 3; // Default # of times
11233
		var speed = o.duration || o.options.duration || 140; // Default speed per shake
11234
 
11235
		// Adjust
11236
		$.effects.save(el, props); el.show(); // Save & Show
11237
		$.effects.createWrapper(el); // Create Wrapper
11238
		var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left';
11239
		var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg';
11240
 
11241
		// Animation
11242
		var animation = {}, animation1 = {}, animation2 = {};
11243
		animation[ref] = (motion == 'pos' ? '-=' : '+=')  + distance;
11244
		animation1[ref] = (motion == 'pos' ? '+=' : '-=')  + distance * 2;
11245
		animation2[ref] = (motion == 'pos' ? '-=' : '+=')  + distance * 2;
11246
 
11247
		// Animate
11248
		el.animate(animation, speed, o.options.easing);
11249
		for (var i = 1; i < times; i++) { // Shakes
11250
			el.animate(animation1, speed, o.options.easing).animate(animation2, speed, o.options.easing);
11251
		};
11252
		el.animate(animation1, speed, o.options.easing).
11253
		animate(animation, speed / 2, o.options.easing, function(){ // Last shake
11254
			$.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
11255
			if(o.callback) o.callback.apply(this, arguments); // Callback
11256
		});
11257
		el.queue('fx', function() { el.dequeue(); });
11258
		el.dequeue();
11259
	});
11260
 
11261
};
11262
 
11263
})(jQuery);
11264
/*
11265
 * jQuery UI Effects Slide 1.8.5
11266
 *
11267
 * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
11268
 * Dual licensed under the MIT or GPL Version 2 licenses.
11269
 * http://jquery.org/license
11270
 *
11271
 * http://docs.jquery.com/UI/Effects/Slide
11272
 *
11273
 * Depends:
11274
 *	jquery.effects.core.js
11275
 */
11276
(function( $, undefined ) {
11277
 
11278
$.effects.slide = function(o) {
11279
 
11280
	return this.queue(function() {
11281
 
11282
		// Create element
11283
		var el = $(this), props = ['position','top','left'];
11284
 
11285
		// Set options
11286
		var mode = $.effects.setMode(el, o.options.mode || 'show'); // Set Mode
11287
		var direction = o.options.direction || 'left'; // Default Direction
11288
 
11289
		// Adjust
11290
		$.effects.save(el, props); el.show(); // Save & Show
11291
		$.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper
11292
		var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left';
11293
		var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg';
11294
		var distance = o.options.distance || (ref == 'top' ? el.outerHeight({margin:true}) : el.outerWidth({margin:true}));
11295
		if (mode == 'show') el.css(ref, motion == 'pos' ? -distance : distance); // Shift
11296
 
11297
		// Animation
11298
		var animation = {};
11299
		animation[ref] = (mode == 'show' ? (motion == 'pos' ? '+=' : '-=') : (motion == 'pos' ? '-=' : '+=')) + distance;
11300
 
11301
		// Animate
11302
		el.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() {
11303
			if(mode == 'hide') el.hide(); // Hide
11304
			$.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
11305
			if(o.callback) o.callback.apply(this, arguments); // Callback
11306
			el.dequeue();
11307
		}});
11308
 
11309
	});
11310
 
11311
};
11312
 
11313
})(jQuery);
11314
/*
11315
 * jQuery UI Effects Transfer 1.8.5
11316
 *
11317
 * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
11318
 * Dual licensed under the MIT or GPL Version 2 licenses.
11319
 * http://jquery.org/license
11320
 *
11321
 * http://docs.jquery.com/UI/Effects/Transfer
11322
 *
11323
 * Depends:
11324
 *	jquery.effects.core.js
11325
 */
11326
(function( $, undefined ) {
11327
 
11328
$.effects.transfer = function(o) {
11329
	return this.queue(function() {
11330
		var elem = $(this),
11331
			target = $(o.options.to),
11332
			endPosition = target.offset(),
11333
			animation = {
11334
				top: endPosition.top,
11335
				left: endPosition.left,
11336
				height: target.innerHeight(),
11337
				width: target.innerWidth()
11338
			},
11339
			startPosition = elem.offset(),
11340
			transfer = $('<div class="ui-effects-transfer"></div>')
11341
				.appendTo(document.body)
11342
				.addClass(o.options.className)
11343
				.css({
11344
					top: startPosition.top,
11345
					left: startPosition.left,
11346
					height: elem.innerHeight(),
11347
					width: elem.innerWidth(),
11348
					position: 'absolute'
11349
				})
11350
				.animate(animation, o.duration, o.options.easing, function() {
11351
					transfer.remove();
11352
					(o.callback && o.callback.apply(elem[0], arguments));
11353
					elem.dequeue();
11354
				});
11355
	});
11356
};
11357
 
11358
})(jQuery);