Resources/Web/js/jquery-1.7.2.js
author moel.mich
Sun, 23 Jun 2013 19:10:28 +0000
changeset 405 8eeac521b3b6
permissions -rw-r--r--
Added the NCT6771F and NCT6776F chips to the lm-sensors interface.
moel@348
     1
/*!
moel@348
     2
 * jQuery JavaScript Library v1.7.2
moel@348
     3
 * http://jquery.com/
moel@348
     4
 *
moel@348
     5
 * Copyright 2011, John Resig
moel@348
     6
 * Dual licensed under the MIT or GPL Version 2 licenses.
moel@348
     7
 * http://jquery.org/license
moel@348
     8
 *
moel@348
     9
 * Includes Sizzle.js
moel@348
    10
 * http://sizzlejs.com/
moel@348
    11
 * Copyright 2011, The Dojo Foundation
moel@348
    12
 * Released under the MIT, BSD, and GPL Licenses.
moel@348
    13
 *
moel@348
    14
 * Date: Wed Mar 21 12:46:34 2012 -0700
moel@348
    15
 */
moel@348
    16
(function( window, undefined ) {
moel@348
    17
moel@348
    18
// Use the correct document accordingly with window argument (sandbox)
moel@348
    19
var document = window.document,
moel@348
    20
	navigator = window.navigator,
moel@348
    21
	location = window.location;
moel@348
    22
var jQuery = (function() {
moel@348
    23
moel@348
    24
// Define a local copy of jQuery
moel@348
    25
var jQuery = function( selector, context ) {
moel@348
    26
		// The jQuery object is actually just the init constructor 'enhanced'
moel@348
    27
		return new jQuery.fn.init( selector, context, rootjQuery );
moel@348
    28
	},
moel@348
    29
moel@348
    30
	// Map over jQuery in case of overwrite
moel@348
    31
	_jQuery = window.jQuery,
moel@348
    32
moel@348
    33
	// Map over the $ in case of overwrite
moel@348
    34
	_$ = window.$,
moel@348
    35
moel@348
    36
	// A central reference to the root jQuery(document)
moel@348
    37
	rootjQuery,
moel@348
    38
moel@348
    39
	// A simple way to check for HTML strings or ID strings
moel@348
    40
	// Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
moel@348
    41
	quickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,
moel@348
    42
moel@348
    43
	// Check if a string has a non-whitespace character in it
moel@348
    44
	rnotwhite = /\S/,
moel@348
    45
moel@348
    46
	// Used for trimming whitespace
moel@348
    47
	trimLeft = /^\s+/,
moel@348
    48
	trimRight = /\s+$/,
moel@348
    49
moel@348
    50
	// Match a standalone tag
moel@348
    51
	rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
moel@348
    52
moel@348
    53
	// JSON RegExp
moel@348
    54
	rvalidchars = /^[\],:{}\s]*$/,
moel@348
    55
	rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,
moel@348
    56
	rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
moel@348
    57
	rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
moel@348
    58
moel@348
    59
	// Useragent RegExp
moel@348
    60
	rwebkit = /(webkit)[ \/]([\w.]+)/,
moel@348
    61
	ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/,
moel@348
    62
	rmsie = /(msie) ([\w.]+)/,
moel@348
    63
	rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/,
moel@348
    64
moel@348
    65
	// Matches dashed string for camelizing
moel@348
    66
	rdashAlpha = /-([a-z]|[0-9])/ig,
moel@348
    67
	rmsPrefix = /^-ms-/,
moel@348
    68
moel@348
    69
	// Used by jQuery.camelCase as callback to replace()
moel@348
    70
	fcamelCase = function( all, letter ) {
moel@348
    71
		return ( letter + "" ).toUpperCase();
moel@348
    72
	},
moel@348
    73
moel@348
    74
	// Keep a UserAgent string for use with jQuery.browser
moel@348
    75
	userAgent = navigator.userAgent,
moel@348
    76
moel@348
    77
	// For matching the engine and version of the browser
moel@348
    78
	browserMatch,
moel@348
    79
moel@348
    80
	// The deferred used on DOM ready
moel@348
    81
	readyList,
moel@348
    82
moel@348
    83
	// The ready event handler
moel@348
    84
	DOMContentLoaded,
moel@348
    85
moel@348
    86
	// Save a reference to some core methods
moel@348
    87
	toString = Object.prototype.toString,
moel@348
    88
	hasOwn = Object.prototype.hasOwnProperty,
moel@348
    89
	push = Array.prototype.push,
moel@348
    90
	slice = Array.prototype.slice,
moel@348
    91
	trim = String.prototype.trim,
moel@348
    92
	indexOf = Array.prototype.indexOf,
moel@348
    93
moel@348
    94
	// [[Class]] -> type pairs
moel@348
    95
	class2type = {};
moel@348
    96
moel@348
    97
jQuery.fn = jQuery.prototype = {
moel@348
    98
	constructor: jQuery,
moel@348
    99
	init: function( selector, context, rootjQuery ) {
moel@348
   100
		var match, elem, ret, doc;
moel@348
   101
moel@348
   102
		// Handle $(""), $(null), or $(undefined)
moel@348
   103
		if ( !selector ) {
moel@348
   104
			return this;
moel@348
   105
		}
moel@348
   106
moel@348
   107
		// Handle $(DOMElement)
moel@348
   108
		if ( selector.nodeType ) {
moel@348
   109
			this.context = this[0] = selector;
moel@348
   110
			this.length = 1;
moel@348
   111
			return this;
moel@348
   112
		}
moel@348
   113
moel@348
   114
		// The body element only exists once, optimize finding it
moel@348
   115
		if ( selector === "body" && !context && document.body ) {
moel@348
   116
			this.context = document;
moel@348
   117
			this[0] = document.body;
moel@348
   118
			this.selector = selector;
moel@348
   119
			this.length = 1;
moel@348
   120
			return this;
moel@348
   121
		}
moel@348
   122
moel@348
   123
		// Handle HTML strings
moel@348
   124
		if ( typeof selector === "string" ) {
moel@348
   125
			// Are we dealing with HTML string or an ID?
moel@348
   126
			if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
moel@348
   127
				// Assume that strings that start and end with <> are HTML and skip the regex check
moel@348
   128
				match = [ null, selector, null ];
moel@348
   129
moel@348
   130
			} else {
moel@348
   131
				match = quickExpr.exec( selector );
moel@348
   132
			}
moel@348
   133
moel@348
   134
			// Verify a match, and that no context was specified for #id
moel@348
   135
			if ( match && (match[1] || !context) ) {
moel@348
   136
moel@348
   137
				// HANDLE: $(html) -> $(array)
moel@348
   138
				if ( match[1] ) {
moel@348
   139
					context = context instanceof jQuery ? context[0] : context;
moel@348
   140
					doc = ( context ? context.ownerDocument || context : document );
moel@348
   141
moel@348
   142
					// If a single string is passed in and it's a single tag
moel@348
   143
					// just do a createElement and skip the rest
moel@348
   144
					ret = rsingleTag.exec( selector );
moel@348
   145
moel@348
   146
					if ( ret ) {
moel@348
   147
						if ( jQuery.isPlainObject( context ) ) {
moel@348
   148
							selector = [ document.createElement( ret[1] ) ];
moel@348
   149
							jQuery.fn.attr.call( selector, context, true );
moel@348
   150
moel@348
   151
						} else {
moel@348
   152
							selector = [ doc.createElement( ret[1] ) ];
moel@348
   153
						}
moel@348
   154
moel@348
   155
					} else {
moel@348
   156
						ret = jQuery.buildFragment( [ match[1] ], [ doc ] );
moel@348
   157
						selector = ( ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment ).childNodes;
moel@348
   158
					}
moel@348
   159
moel@348
   160
					return jQuery.merge( this, selector );
moel@348
   161
moel@348
   162
				// HANDLE: $("#id")
moel@348
   163
				} else {
moel@348
   164
					elem = document.getElementById( match[2] );
moel@348
   165
moel@348
   166
					// Check parentNode to catch when Blackberry 4.6 returns
moel@348
   167
					// nodes that are no longer in the document #6963
moel@348
   168
					if ( elem && elem.parentNode ) {
moel@348
   169
						// Handle the case where IE and Opera return items
moel@348
   170
						// by name instead of ID
moel@348
   171
						if ( elem.id !== match[2] ) {
moel@348
   172
							return rootjQuery.find( selector );
moel@348
   173
						}
moel@348
   174
moel@348
   175
						// Otherwise, we inject the element directly into the jQuery object
moel@348
   176
						this.length = 1;
moel@348
   177
						this[0] = elem;
moel@348
   178
					}
moel@348
   179
moel@348
   180
					this.context = document;
moel@348
   181
					this.selector = selector;
moel@348
   182
					return this;
moel@348
   183
				}
moel@348
   184
moel@348
   185
			// HANDLE: $(expr, $(...))
moel@348
   186
			} else if ( !context || context.jquery ) {
moel@348
   187
				return ( context || rootjQuery ).find( selector );
moel@348
   188
moel@348
   189
			// HANDLE: $(expr, context)
moel@348
   190
			// (which is just equivalent to: $(context).find(expr)
moel@348
   191
			} else {
moel@348
   192
				return this.constructor( context ).find( selector );
moel@348
   193
			}
moel@348
   194
moel@348
   195
		// HANDLE: $(function)
moel@348
   196
		// Shortcut for document ready
moel@348
   197
		} else if ( jQuery.isFunction( selector ) ) {
moel@348
   198
			return rootjQuery.ready( selector );
moel@348
   199
		}
moel@348
   200
moel@348
   201
		if ( selector.selector !== undefined ) {
moel@348
   202
			this.selector = selector.selector;
moel@348
   203
			this.context = selector.context;
moel@348
   204
		}
moel@348
   205
moel@348
   206
		return jQuery.makeArray( selector, this );
moel@348
   207
	},
moel@348
   208
moel@348
   209
	// Start with an empty selector
moel@348
   210
	selector: "",
moel@348
   211
moel@348
   212
	// The current version of jQuery being used
moel@348
   213
	jquery: "1.7.2",
moel@348
   214
moel@348
   215
	// The default length of a jQuery object is 0
moel@348
   216
	length: 0,
moel@348
   217
moel@348
   218
	// The number of elements contained in the matched element set
moel@348
   219
	size: function() {
moel@348
   220
		return this.length;
moel@348
   221
	},
moel@348
   222
moel@348
   223
	toArray: function() {
moel@348
   224
		return slice.call( this, 0 );
moel@348
   225
	},
moel@348
   226
moel@348
   227
	// Get the Nth element in the matched element set OR
moel@348
   228
	// Get the whole matched element set as a clean array
moel@348
   229
	get: function( num ) {
moel@348
   230
		return num == null ?
moel@348
   231
moel@348
   232
			// Return a 'clean' array
moel@348
   233
			this.toArray() :
moel@348
   234
moel@348
   235
			// Return just the object
moel@348
   236
			( num < 0 ? this[ this.length + num ] : this[ num ] );
moel@348
   237
	},
moel@348
   238
moel@348
   239
	// Take an array of elements and push it onto the stack
moel@348
   240
	// (returning the new matched element set)
moel@348
   241
	pushStack: function( elems, name, selector ) {
moel@348
   242
		// Build a new jQuery matched element set
moel@348
   243
		var ret = this.constructor();
moel@348
   244
moel@348
   245
		if ( jQuery.isArray( elems ) ) {
moel@348
   246
			push.apply( ret, elems );
moel@348
   247
moel@348
   248
		} else {
moel@348
   249
			jQuery.merge( ret, elems );
moel@348
   250
		}
moel@348
   251
moel@348
   252
		// Add the old object onto the stack (as a reference)
moel@348
   253
		ret.prevObject = this;
moel@348
   254
moel@348
   255
		ret.context = this.context;
moel@348
   256
moel@348
   257
		if ( name === "find" ) {
moel@348
   258
			ret.selector = this.selector + ( this.selector ? " " : "" ) + selector;
moel@348
   259
		} else if ( name ) {
moel@348
   260
			ret.selector = this.selector + "." + name + "(" + selector + ")";
moel@348
   261
		}
moel@348
   262
moel@348
   263
		// Return the newly-formed element set
moel@348
   264
		return ret;
moel@348
   265
	},
moel@348
   266
moel@348
   267
	// Execute a callback for every element in the matched set.
moel@348
   268
	// (You can seed the arguments with an array of args, but this is
moel@348
   269
	// only used internally.)
moel@348
   270
	each: function( callback, args ) {
moel@348
   271
		return jQuery.each( this, callback, args );
moel@348
   272
	},
moel@348
   273
moel@348
   274
	ready: function( fn ) {
moel@348
   275
		// Attach the listeners
moel@348
   276
		jQuery.bindReady();
moel@348
   277
moel@348
   278
		// Add the callback
moel@348
   279
		readyList.add( fn );
moel@348
   280
moel@348
   281
		return this;
moel@348
   282
	},
moel@348
   283
moel@348
   284
	eq: function( i ) {
moel@348
   285
		i = +i;
moel@348
   286
		return i === -1 ?
moel@348
   287
			this.slice( i ) :
moel@348
   288
			this.slice( i, i + 1 );
moel@348
   289
	},
moel@348
   290
moel@348
   291
	first: function() {
moel@348
   292
		return this.eq( 0 );
moel@348
   293
	},
moel@348
   294
moel@348
   295
	last: function() {
moel@348
   296
		return this.eq( -1 );
moel@348
   297
	},
moel@348
   298
moel@348
   299
	slice: function() {
moel@348
   300
		return this.pushStack( slice.apply( this, arguments ),
moel@348
   301
			"slice", slice.call(arguments).join(",") );
moel@348
   302
	},
moel@348
   303
moel@348
   304
	map: function( callback ) {
moel@348
   305
		return this.pushStack( jQuery.map(this, function( elem, i ) {
moel@348
   306
			return callback.call( elem, i, elem );
moel@348
   307
		}));
moel@348
   308
	},
moel@348
   309
moel@348
   310
	end: function() {
moel@348
   311
		return this.prevObject || this.constructor(null);
moel@348
   312
	},
moel@348
   313
moel@348
   314
	// For internal use only.
moel@348
   315
	// Behaves like an Array's method, not like a jQuery method.
moel@348
   316
	push: push,
moel@348
   317
	sort: [].sort,
moel@348
   318
	splice: [].splice
moel@348
   319
};
moel@348
   320
moel@348
   321
// Give the init function the jQuery prototype for later instantiation
moel@348
   322
jQuery.fn.init.prototype = jQuery.fn;
moel@348
   323
moel@348
   324
jQuery.extend = jQuery.fn.extend = function() {
moel@348
   325
	var options, name, src, copy, copyIsArray, clone,
moel@348
   326
		target = arguments[0] || {},
moel@348
   327
		i = 1,
moel@348
   328
		length = arguments.length,
moel@348
   329
		deep = false;
moel@348
   330
moel@348
   331
	// Handle a deep copy situation
moel@348
   332
	if ( typeof target === "boolean" ) {
moel@348
   333
		deep = target;
moel@348
   334
		target = arguments[1] || {};
moel@348
   335
		// skip the boolean and the target
moel@348
   336
		i = 2;
moel@348
   337
	}
moel@348
   338
moel@348
   339
	// Handle case when target is a string or something (possible in deep copy)
moel@348
   340
	if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
moel@348
   341
		target = {};
moel@348
   342
	}
moel@348
   343
moel@348
   344
	// extend jQuery itself if only one argument is passed
moel@348
   345
	if ( length === i ) {
moel@348
   346
		target = this;
moel@348
   347
		--i;
moel@348
   348
	}
moel@348
   349
moel@348
   350
	for ( ; i < length; i++ ) {
moel@348
   351
		// Only deal with non-null/undefined values
moel@348
   352
		if ( (options = arguments[ i ]) != null ) {
moel@348
   353
			// Extend the base object
moel@348
   354
			for ( name in options ) {
moel@348
   355
				src = target[ name ];
moel@348
   356
				copy = options[ name ];
moel@348
   357
moel@348
   358
				// Prevent never-ending loop
moel@348
   359
				if ( target === copy ) {
moel@348
   360
					continue;
moel@348
   361
				}
moel@348
   362
moel@348
   363
				// Recurse if we're merging plain objects or arrays
moel@348
   364
				if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
moel@348
   365
					if ( copyIsArray ) {
moel@348
   366
						copyIsArray = false;
moel@348
   367
						clone = src && jQuery.isArray(src) ? src : [];
moel@348
   368
moel@348
   369
					} else {
moel@348
   370
						clone = src && jQuery.isPlainObject(src) ? src : {};
moel@348
   371
					}
moel@348
   372
moel@348
   373
					// Never move original objects, clone them
moel@348
   374
					target[ name ] = jQuery.extend( deep, clone, copy );
moel@348
   375
moel@348
   376
				// Don't bring in undefined values
moel@348
   377
				} else if ( copy !== undefined ) {
moel@348
   378
					target[ name ] = copy;
moel@348
   379
				}
moel@348
   380
			}
moel@348
   381
		}
moel@348
   382
	}
moel@348
   383
moel@348
   384
	// Return the modified object
moel@348
   385
	return target;
moel@348
   386
};
moel@348
   387
moel@348
   388
jQuery.extend({
moel@348
   389
	noConflict: function( deep ) {
moel@348
   390
		if ( window.$ === jQuery ) {
moel@348
   391
			window.$ = _$;
moel@348
   392
		}
moel@348
   393
moel@348
   394
		if ( deep && window.jQuery === jQuery ) {
moel@348
   395
			window.jQuery = _jQuery;
moel@348
   396
		}
moel@348
   397
moel@348
   398
		return jQuery;
moel@348
   399
	},
moel@348
   400
moel@348
   401
	// Is the DOM ready to be used? Set to true once it occurs.
moel@348
   402
	isReady: false,
moel@348
   403
moel@348
   404
	// A counter to track how many items to wait for before
moel@348
   405
	// the ready event fires. See #6781
moel@348
   406
	readyWait: 1,
moel@348
   407
moel@348
   408
	// Hold (or release) the ready event
moel@348
   409
	holdReady: function( hold ) {
moel@348
   410
		if ( hold ) {
moel@348
   411
			jQuery.readyWait++;
moel@348
   412
		} else {
moel@348
   413
			jQuery.ready( true );
moel@348
   414
		}
moel@348
   415
	},
moel@348
   416
moel@348
   417
	// Handle when the DOM is ready
moel@348
   418
	ready: function( wait ) {
moel@348
   419
		// Either a released hold or an DOMready/load event and not yet ready
moel@348
   420
		if ( (wait === true && !--jQuery.readyWait) || (wait !== true && !jQuery.isReady) ) {
moel@348
   421
			// Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
moel@348
   422
			if ( !document.body ) {
moel@348
   423
				return setTimeout( jQuery.ready, 1 );
moel@348
   424
			}
moel@348
   425
moel@348
   426
			// Remember that the DOM is ready
moel@348
   427
			jQuery.isReady = true;
moel@348
   428
moel@348
   429
			// If a normal DOM Ready event fired, decrement, and wait if need be
moel@348
   430
			if ( wait !== true && --jQuery.readyWait > 0 ) {
moel@348
   431
				return;
moel@348
   432
			}
moel@348
   433
moel@348
   434
			// If there are functions bound, to execute
moel@348
   435
			readyList.fireWith( document, [ jQuery ] );
moel@348
   436
moel@348
   437
			// Trigger any bound ready events
moel@348
   438
			if ( jQuery.fn.trigger ) {
moel@348
   439
				jQuery( document ).trigger( "ready" ).off( "ready" );
moel@348
   440
			}
moel@348
   441
		}
moel@348
   442
	},
moel@348
   443
moel@348
   444
	bindReady: function() {
moel@348
   445
		if ( readyList ) {
moel@348
   446
			return;
moel@348
   447
		}
moel@348
   448
moel@348
   449
		readyList = jQuery.Callbacks( "once memory" );
moel@348
   450
moel@348
   451
		// Catch cases where $(document).ready() is called after the
moel@348
   452
		// browser event has already occurred.
moel@348
   453
		if ( document.readyState === "complete" ) {
moel@348
   454
			// Handle it asynchronously to allow scripts the opportunity to delay ready
moel@348
   455
			return setTimeout( jQuery.ready, 1 );
moel@348
   456
		}
moel@348
   457
moel@348
   458
		// Mozilla, Opera and webkit nightlies currently support this event
moel@348
   459
		if ( document.addEventListener ) {
moel@348
   460
			// Use the handy event callback
moel@348
   461
			document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
moel@348
   462
moel@348
   463
			// A fallback to window.onload, that will always work
moel@348
   464
			window.addEventListener( "load", jQuery.ready, false );
moel@348
   465
moel@348
   466
		// If IE event model is used
moel@348
   467
		} else if ( document.attachEvent ) {
moel@348
   468
			// ensure firing before onload,
moel@348
   469
			// maybe late but safe also for iframes
moel@348
   470
			document.attachEvent( "onreadystatechange", DOMContentLoaded );
moel@348
   471
moel@348
   472
			// A fallback to window.onload, that will always work
moel@348
   473
			window.attachEvent( "onload", jQuery.ready );
moel@348
   474
moel@348
   475
			// If IE and not a frame
moel@348
   476
			// continually check to see if the document is ready
moel@348
   477
			var toplevel = false;
moel@348
   478
moel@348
   479
			try {
moel@348
   480
				toplevel = window.frameElement == null;
moel@348
   481
			} catch(e) {}
moel@348
   482
moel@348
   483
			if ( document.documentElement.doScroll && toplevel ) {
moel@348
   484
				doScrollCheck();
moel@348
   485
			}
moel@348
   486
		}
moel@348
   487
	},
moel@348
   488
moel@348
   489
	// See test/unit/core.js for details concerning isFunction.
moel@348
   490
	// Since version 1.3, DOM methods and functions like alert
moel@348
   491
	// aren't supported. They return false on IE (#2968).
moel@348
   492
	isFunction: function( obj ) {
moel@348
   493
		return jQuery.type(obj) === "function";
moel@348
   494
	},
moel@348
   495
moel@348
   496
	isArray: Array.isArray || function( obj ) {
moel@348
   497
		return jQuery.type(obj) === "array";
moel@348
   498
	},
moel@348
   499
moel@348
   500
	isWindow: function( obj ) {
moel@348
   501
		return obj != null && obj == obj.window;
moel@348
   502
	},
moel@348
   503
moel@348
   504
	isNumeric: function( obj ) {
moel@348
   505
		return !isNaN( parseFloat(obj) ) && isFinite( obj );
moel@348
   506
	},
moel@348
   507
moel@348
   508
	type: function( obj ) {
moel@348
   509
		return obj == null ?
moel@348
   510
			String( obj ) :
moel@348
   511
			class2type[ toString.call(obj) ] || "object";
moel@348
   512
	},
moel@348
   513
moel@348
   514
	isPlainObject: function( obj ) {
moel@348
   515
		// Must be an Object.
moel@348
   516
		// Because of IE, we also have to check the presence of the constructor property.
moel@348
   517
		// Make sure that DOM nodes and window objects don't pass through, as well
moel@348
   518
		if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
moel@348
   519
			return false;
moel@348
   520
		}
moel@348
   521
moel@348
   522
		try {
moel@348
   523
			// Not own constructor property must be Object
moel@348
   524
			if ( obj.constructor &&
moel@348
   525
				!hasOwn.call(obj, "constructor") &&
moel@348
   526
				!hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
moel@348
   527
				return false;
moel@348
   528
			}
moel@348
   529
		} catch ( e ) {
moel@348
   530
			// IE8,9 Will throw exceptions on certain host objects #9897
moel@348
   531
			return false;
moel@348
   532
		}
moel@348
   533
moel@348
   534
		// Own properties are enumerated firstly, so to speed up,
moel@348
   535
		// if last one is own, then all properties are own.
moel@348
   536
moel@348
   537
		var key;
moel@348
   538
		for ( key in obj ) {}
moel@348
   539
moel@348
   540
		return key === undefined || hasOwn.call( obj, key );
moel@348
   541
	},
moel@348
   542
moel@348
   543
	isEmptyObject: function( obj ) {
moel@348
   544
		for ( var name in obj ) {
moel@348
   545
			return false;
moel@348
   546
		}
moel@348
   547
		return true;
moel@348
   548
	},
moel@348
   549
moel@348
   550
	error: function( msg ) {
moel@348
   551
		throw new Error( msg );
moel@348
   552
	},
moel@348
   553
moel@348
   554
	parseJSON: function( data ) {
moel@348
   555
		if ( typeof data !== "string" || !data ) {
moel@348
   556
			return null;
moel@348
   557
		}
moel@348
   558
moel@348
   559
		// Make sure leading/trailing whitespace is removed (IE can't handle it)
moel@348
   560
		data = jQuery.trim( data );
moel@348
   561
moel@348
   562
		// Attempt to parse using the native JSON parser first
moel@348
   563
		if ( window.JSON && window.JSON.parse ) {
moel@348
   564
			return window.JSON.parse( data );
moel@348
   565
		}
moel@348
   566
moel@348
   567
		// Make sure the incoming data is actual JSON
moel@348
   568
		// Logic borrowed from http://json.org/json2.js
moel@348
   569
		if ( rvalidchars.test( data.replace( rvalidescape, "@" )
moel@348
   570
			.replace( rvalidtokens, "]" )
moel@348
   571
			.replace( rvalidbraces, "")) ) {
moel@348
   572
moel@348
   573
			return ( new Function( "return " + data ) )();
moel@348
   574
moel@348
   575
		}
moel@348
   576
		jQuery.error( "Invalid JSON: " + data );
moel@348
   577
	},
moel@348
   578
moel@348
   579
	// Cross-browser xml parsing
moel@348
   580
	parseXML: function( data ) {
moel@348
   581
		if ( typeof data !== "string" || !data ) {
moel@348
   582
			return null;
moel@348
   583
		}
moel@348
   584
		var xml, tmp;
moel@348
   585
		try {
moel@348
   586
			if ( window.DOMParser ) { // Standard
moel@348
   587
				tmp = new DOMParser();
moel@348
   588
				xml = tmp.parseFromString( data , "text/xml" );
moel@348
   589
			} else { // IE
moel@348
   590
				xml = new ActiveXObject( "Microsoft.XMLDOM" );
moel@348
   591
				xml.async = "false";
moel@348
   592
				xml.loadXML( data );
moel@348
   593
			}
moel@348
   594
		} catch( e ) {
moel@348
   595
			xml = undefined;
moel@348
   596
		}
moel@348
   597
		if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
moel@348
   598
			jQuery.error( "Invalid XML: " + data );
moel@348
   599
		}
moel@348
   600
		return xml;
moel@348
   601
	},
moel@348
   602
moel@348
   603
	noop: function() {},
moel@348
   604
moel@348
   605
	// Evaluates a script in a global context
moel@348
   606
	// Workarounds based on findings by Jim Driscoll
moel@348
   607
	// http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
moel@348
   608
	globalEval: function( data ) {
moel@348
   609
		if ( data && rnotwhite.test( data ) ) {
moel@348
   610
			// We use execScript on Internet Explorer
moel@348
   611
			// We use an anonymous function so that context is window
moel@348
   612
			// rather than jQuery in Firefox
moel@348
   613
			( window.execScript || function( data ) {
moel@348
   614
				window[ "eval" ].call( window, data );
moel@348
   615
			} )( data );
moel@348
   616
		}
moel@348
   617
	},
moel@348
   618
moel@348
   619
	// Convert dashed to camelCase; used by the css and data modules
moel@348
   620
	// Microsoft forgot to hump their vendor prefix (#9572)
moel@348
   621
	camelCase: function( string ) {
moel@348
   622
		return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
moel@348
   623
	},
moel@348
   624
moel@348
   625
	nodeName: function( elem, name ) {
moel@348
   626
		return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
moel@348
   627
	},
moel@348
   628
moel@348
   629
	// args is for internal usage only
moel@348
   630
	each: function( object, callback, args ) {
moel@348
   631
		var name, i = 0,
moel@348
   632
			length = object.length,
moel@348
   633
			isObj = length === undefined || jQuery.isFunction( object );
moel@348
   634
moel@348
   635
		if ( args ) {
moel@348
   636
			if ( isObj ) {
moel@348
   637
				for ( name in object ) {
moel@348
   638
					if ( callback.apply( object[ name ], args ) === false ) {
moel@348
   639
						break;
moel@348
   640
					}
moel@348
   641
				}
moel@348
   642
			} else {
moel@348
   643
				for ( ; i < length; ) {
moel@348
   644
					if ( callback.apply( object[ i++ ], args ) === false ) {
moel@348
   645
						break;
moel@348
   646
					}
moel@348
   647
				}
moel@348
   648
			}
moel@348
   649
moel@348
   650
		// A special, fast, case for the most common use of each
moel@348
   651
		} else {
moel@348
   652
			if ( isObj ) {
moel@348
   653
				for ( name in object ) {
moel@348
   654
					if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
moel@348
   655
						break;
moel@348
   656
					}
moel@348
   657
				}
moel@348
   658
			} else {
moel@348
   659
				for ( ; i < length; ) {
moel@348
   660
					if ( callback.call( object[ i ], i, object[ i++ ] ) === false ) {
moel@348
   661
						break;
moel@348
   662
					}
moel@348
   663
				}
moel@348
   664
			}
moel@348
   665
		}
moel@348
   666
moel@348
   667
		return object;
moel@348
   668
	},
moel@348
   669
moel@348
   670
	// Use native String.trim function wherever possible
moel@348
   671
	trim: trim ?
moel@348
   672
		function( text ) {
moel@348
   673
			return text == null ?
moel@348
   674
				"" :
moel@348
   675
				trim.call( text );
moel@348
   676
		} :
moel@348
   677
moel@348
   678
		// Otherwise use our own trimming functionality
moel@348
   679
		function( text ) {
moel@348
   680
			return text == null ?
moel@348
   681
				"" :
moel@348
   682
				text.toString().replace( trimLeft, "" ).replace( trimRight, "" );
moel@348
   683
		},
moel@348
   684
moel@348
   685
	// results is for internal usage only
moel@348
   686
	makeArray: function( array, results ) {
moel@348
   687
		var ret = results || [];
moel@348
   688
moel@348
   689
		if ( array != null ) {
moel@348
   690
			// The window, strings (and functions) also have 'length'
moel@348
   691
			// Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
moel@348
   692
			var type = jQuery.type( array );
moel@348
   693
moel@348
   694
			if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) {
moel@348
   695
				push.call( ret, array );
moel@348
   696
			} else {
moel@348
   697
				jQuery.merge( ret, array );
moel@348
   698
			}
moel@348
   699
		}
moel@348
   700
moel@348
   701
		return ret;
moel@348
   702
	},
moel@348
   703
moel@348
   704
	inArray: function( elem, array, i ) {
moel@348
   705
		var len;
moel@348
   706
moel@348
   707
		if ( array ) {
moel@348
   708
			if ( indexOf ) {
moel@348
   709
				return indexOf.call( array, elem, i );
moel@348
   710
			}
moel@348
   711
moel@348
   712
			len = array.length;
moel@348
   713
			i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
moel@348
   714
moel@348
   715
			for ( ; i < len; i++ ) {
moel@348
   716
				// Skip accessing in sparse arrays
moel@348
   717
				if ( i in array && array[ i ] === elem ) {
moel@348
   718
					return i;
moel@348
   719
				}
moel@348
   720
			}
moel@348
   721
		}
moel@348
   722
moel@348
   723
		return -1;
moel@348
   724
	},
moel@348
   725
moel@348
   726
	merge: function( first, second ) {
moel@348
   727
		var i = first.length,
moel@348
   728
			j = 0;
moel@348
   729
moel@348
   730
		if ( typeof second.length === "number" ) {
moel@348
   731
			for ( var l = second.length; j < l; j++ ) {
moel@348
   732
				first[ i++ ] = second[ j ];
moel@348
   733
			}
moel@348
   734
moel@348
   735
		} else {
moel@348
   736
			while ( second[j] !== undefined ) {
moel@348
   737
				first[ i++ ] = second[ j++ ];
moel@348
   738
			}
moel@348
   739
		}
moel@348
   740
moel@348
   741
		first.length = i;
moel@348
   742
moel@348
   743
		return first;
moel@348
   744
	},
moel@348
   745
moel@348
   746
	grep: function( elems, callback, inv ) {
moel@348
   747
		var ret = [], retVal;
moel@348
   748
		inv = !!inv;
moel@348
   749
moel@348
   750
		// Go through the array, only saving the items
moel@348
   751
		// that pass the validator function
moel@348
   752
		for ( var i = 0, length = elems.length; i < length; i++ ) {
moel@348
   753
			retVal = !!callback( elems[ i ], i );
moel@348
   754
			if ( inv !== retVal ) {
moel@348
   755
				ret.push( elems[ i ] );
moel@348
   756
			}
moel@348
   757
		}
moel@348
   758
moel@348
   759
		return ret;
moel@348
   760
	},
moel@348
   761
moel@348
   762
	// arg is for internal usage only
moel@348
   763
	map: function( elems, callback, arg ) {
moel@348
   764
		var value, key, ret = [],
moel@348
   765
			i = 0,
moel@348
   766
			length = elems.length,
moel@348
   767
			// jquery objects are treated as arrays
moel@348
   768
			isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ;
moel@348
   769
moel@348
   770
		// Go through the array, translating each of the items to their
moel@348
   771
		if ( isArray ) {
moel@348
   772
			for ( ; i < length; i++ ) {
moel@348
   773
				value = callback( elems[ i ], i, arg );
moel@348
   774
moel@348
   775
				if ( value != null ) {
moel@348
   776
					ret[ ret.length ] = value;
moel@348
   777
				}
moel@348
   778
			}
moel@348
   779
moel@348
   780
		// Go through every key on the object,
moel@348
   781
		} else {
moel@348
   782
			for ( key in elems ) {
moel@348
   783
				value = callback( elems[ key ], key, arg );
moel@348
   784
moel@348
   785
				if ( value != null ) {
moel@348
   786
					ret[ ret.length ] = value;
moel@348
   787
				}
moel@348
   788
			}
moel@348
   789
		}
moel@348
   790
moel@348
   791
		// Flatten any nested arrays
moel@348
   792
		return ret.concat.apply( [], ret );
moel@348
   793
	},
moel@348
   794
moel@348
   795
	// A global GUID counter for objects
moel@348
   796
	guid: 1,
moel@348
   797
moel@348
   798
	// Bind a function to a context, optionally partially applying any
moel@348
   799
	// arguments.
moel@348
   800
	proxy: function( fn, context ) {
moel@348
   801
		if ( typeof context === "string" ) {
moel@348
   802
			var tmp = fn[ context ];
moel@348
   803
			context = fn;
moel@348
   804
			fn = tmp;
moel@348
   805
		}
moel@348
   806
moel@348
   807
		// Quick check to determine if target is callable, in the spec
moel@348
   808
		// this throws a TypeError, but we will just return undefined.
moel@348
   809
		if ( !jQuery.isFunction( fn ) ) {
moel@348
   810
			return undefined;
moel@348
   811
		}
moel@348
   812
moel@348
   813
		// Simulated bind
moel@348
   814
		var args = slice.call( arguments, 2 ),
moel@348
   815
			proxy = function() {
moel@348
   816
				return fn.apply( context, args.concat( slice.call( arguments ) ) );
moel@348
   817
			};
moel@348
   818
moel@348
   819
		// Set the guid of unique handler to the same of original handler, so it can be removed
moel@348
   820
		proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
moel@348
   821
moel@348
   822
		return proxy;
moel@348
   823
	},
moel@348
   824
moel@348
   825
	// Mutifunctional method to get and set values to a collection
moel@348
   826
	// The value/s can optionally be executed if it's a function
moel@348
   827
	access: function( elems, fn, key, value, chainable, emptyGet, pass ) {
moel@348
   828
		var exec,
moel@348
   829
			bulk = key == null,
moel@348
   830
			i = 0,
moel@348
   831
			length = elems.length;
moel@348
   832
moel@348
   833
		// Sets many values
moel@348
   834
		if ( key && typeof key === "object" ) {
moel@348
   835
			for ( i in key ) {
moel@348
   836
				jQuery.access( elems, fn, i, key[i], 1, emptyGet, value );
moel@348
   837
			}
moel@348
   838
			chainable = 1;
moel@348
   839
moel@348
   840
		// Sets one value
moel@348
   841
		} else if ( value !== undefined ) {
moel@348
   842
			// Optionally, function values get executed if exec is true
moel@348
   843
			exec = pass === undefined && jQuery.isFunction( value );
moel@348
   844
moel@348
   845
			if ( bulk ) {
moel@348
   846
				// Bulk operations only iterate when executing function values
moel@348
   847
				if ( exec ) {
moel@348
   848
					exec = fn;
moel@348
   849
					fn = function( elem, key, value ) {
moel@348
   850
						return exec.call( jQuery( elem ), value );
moel@348
   851
					};
moel@348
   852
moel@348
   853
				// Otherwise they run against the entire set
moel@348
   854
				} else {
moel@348
   855
					fn.call( elems, value );
moel@348
   856
					fn = null;
moel@348
   857
				}
moel@348
   858
			}
moel@348
   859
moel@348
   860
			if ( fn ) {
moel@348
   861
				for (; i < length; i++ ) {
moel@348
   862
					fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
moel@348
   863
				}
moel@348
   864
			}
moel@348
   865
moel@348
   866
			chainable = 1;
moel@348
   867
		}
moel@348
   868
moel@348
   869
		return chainable ?
moel@348
   870
			elems :
moel@348
   871
moel@348
   872
			// Gets
moel@348
   873
			bulk ?
moel@348
   874
				fn.call( elems ) :
moel@348
   875
				length ? fn( elems[0], key ) : emptyGet;
moel@348
   876
	},
moel@348
   877
moel@348
   878
	now: function() {
moel@348
   879
		return ( new Date() ).getTime();
moel@348
   880
	},
moel@348
   881
moel@348
   882
	// Use of jQuery.browser is frowned upon.
moel@348
   883
	// More details: http://docs.jquery.com/Utilities/jQuery.browser
moel@348
   884
	uaMatch: function( ua ) {
moel@348
   885
		ua = ua.toLowerCase();
moel@348
   886
moel@348
   887
		var match = rwebkit.exec( ua ) ||
moel@348
   888
			ropera.exec( ua ) ||
moel@348
   889
			rmsie.exec( ua ) ||
moel@348
   890
			ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) ||
moel@348
   891
			[];
moel@348
   892
moel@348
   893
		return { browser: match[1] || "", version: match[2] || "0" };
moel@348
   894
	},
moel@348
   895
moel@348
   896
	sub: function() {
moel@348
   897
		function jQuerySub( selector, context ) {
moel@348
   898
			return new jQuerySub.fn.init( selector, context );
moel@348
   899
		}
moel@348
   900
		jQuery.extend( true, jQuerySub, this );
moel@348
   901
		jQuerySub.superclass = this;
moel@348
   902
		jQuerySub.fn = jQuerySub.prototype = this();
moel@348
   903
		jQuerySub.fn.constructor = jQuerySub;
moel@348
   904
		jQuerySub.sub = this.sub;
moel@348
   905
		jQuerySub.fn.init = function init( selector, context ) {
moel@348
   906
			if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) {
moel@348
   907
				context = jQuerySub( context );
moel@348
   908
			}
moel@348
   909
moel@348
   910
			return jQuery.fn.init.call( this, selector, context, rootjQuerySub );
moel@348
   911
		};
moel@348
   912
		jQuerySub.fn.init.prototype = jQuerySub.fn;
moel@348
   913
		var rootjQuerySub = jQuerySub(document);
moel@348
   914
		return jQuerySub;
moel@348
   915
	},
moel@348
   916
moel@348
   917
	browser: {}
moel@348
   918
});
moel@348
   919
moel@348
   920
// Populate the class2type map
moel@348
   921
jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
moel@348
   922
	class2type[ "[object " + name + "]" ] = name.toLowerCase();
moel@348
   923
});
moel@348
   924
moel@348
   925
browserMatch = jQuery.uaMatch( userAgent );
moel@348
   926
if ( browserMatch.browser ) {
moel@348
   927
	jQuery.browser[ browserMatch.browser ] = true;
moel@348
   928
	jQuery.browser.version = browserMatch.version;
moel@348
   929
}
moel@348
   930
moel@348
   931
// Deprecated, use jQuery.browser.webkit instead
moel@348
   932
if ( jQuery.browser.webkit ) {
moel@348
   933
	jQuery.browser.safari = true;
moel@348
   934
}
moel@348
   935
moel@348
   936
// IE doesn't match non-breaking spaces with \s
moel@348
   937
if ( rnotwhite.test( "\xA0" ) ) {
moel@348
   938
	trimLeft = /^[\s\xA0]+/;
moel@348
   939
	trimRight = /[\s\xA0]+$/;
moel@348
   940
}
moel@348
   941
moel@348
   942
// All jQuery objects should point back to these
moel@348
   943
rootjQuery = jQuery(document);
moel@348
   944
moel@348
   945
// Cleanup functions for the document ready method
moel@348
   946
if ( document.addEventListener ) {
moel@348
   947
	DOMContentLoaded = function() {
moel@348
   948
		document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
moel@348
   949
		jQuery.ready();
moel@348
   950
	};
moel@348
   951
moel@348
   952
} else if ( document.attachEvent ) {
moel@348
   953
	DOMContentLoaded = function() {
moel@348
   954
		// Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
moel@348
   955
		if ( document.readyState === "complete" ) {
moel@348
   956
			document.detachEvent( "onreadystatechange", DOMContentLoaded );
moel@348
   957
			jQuery.ready();
moel@348
   958
		}
moel@348
   959
	};
moel@348
   960
}
moel@348
   961
moel@348
   962
// The DOM ready check for Internet Explorer
moel@348
   963
function doScrollCheck() {
moel@348
   964
	if ( jQuery.isReady ) {
moel@348
   965
		return;
moel@348
   966
	}
moel@348
   967
moel@348
   968
	try {
moel@348
   969
		// If IE is used, use the trick by Diego Perini
moel@348
   970
		// http://javascript.nwbox.com/IEContentLoaded/
moel@348
   971
		document.documentElement.doScroll("left");
moel@348
   972
	} catch(e) {
moel@348
   973
		setTimeout( doScrollCheck, 1 );
moel@348
   974
		return;
moel@348
   975
	}
moel@348
   976
moel@348
   977
	// and execute any waiting functions
moel@348
   978
	jQuery.ready();
moel@348
   979
}
moel@348
   980
moel@348
   981
return jQuery;
moel@348
   982
moel@348
   983
})();
moel@348
   984
moel@348
   985
moel@348
   986
// String to Object flags format cache
moel@348
   987
var flagsCache = {};
moel@348
   988
moel@348
   989
// Convert String-formatted flags into Object-formatted ones and store in cache
moel@348
   990
function createFlags( flags ) {
moel@348
   991
	var object = flagsCache[ flags ] = {},
moel@348
   992
		i, length;
moel@348
   993
	flags = flags.split( /\s+/ );
moel@348
   994
	for ( i = 0, length = flags.length; i < length; i++ ) {
moel@348
   995
		object[ flags[i] ] = true;
moel@348
   996
	}
moel@348
   997
	return object;
moel@348
   998
}
moel@348
   999
moel@348
  1000
/*
moel@348
  1001
 * Create a callback list using the following parameters:
moel@348
  1002
 *
moel@348
  1003
 *	flags:	an optional list of space-separated flags that will change how
moel@348
  1004
 *			the callback list behaves
moel@348
  1005
 *
moel@348
  1006
 * By default a callback list will act like an event callback list and can be
moel@348
  1007
 * "fired" multiple times.
moel@348
  1008
 *
moel@348
  1009
 * Possible flags:
moel@348
  1010
 *
moel@348
  1011
 *	once:			will ensure the callback list can only be fired once (like a Deferred)
moel@348
  1012
 *
moel@348
  1013
 *	memory:			will keep track of previous values and will call any callback added
moel@348
  1014
 *					after the list has been fired right away with the latest "memorized"
moel@348
  1015
 *					values (like a Deferred)
moel@348
  1016
 *
moel@348
  1017
 *	unique:			will ensure a callback can only be added once (no duplicate in the list)
moel@348
  1018
 *
moel@348
  1019
 *	stopOnFalse:	interrupt callings when a callback returns false
moel@348
  1020
 *
moel@348
  1021
 */
moel@348
  1022
jQuery.Callbacks = function( flags ) {
moel@348
  1023
moel@348
  1024
	// Convert flags from String-formatted to Object-formatted
moel@348
  1025
	// (we check in cache first)
moel@348
  1026
	flags = flags ? ( flagsCache[ flags ] || createFlags( flags ) ) : {};
moel@348
  1027
moel@348
  1028
	var // Actual callback list
moel@348
  1029
		list = [],
moel@348
  1030
		// Stack of fire calls for repeatable lists
moel@348
  1031
		stack = [],
moel@348
  1032
		// Last fire value (for non-forgettable lists)
moel@348
  1033
		memory,
moel@348
  1034
		// Flag to know if list was already fired
moel@348
  1035
		fired,
moel@348
  1036
		// Flag to know if list is currently firing
moel@348
  1037
		firing,
moel@348
  1038
		// First callback to fire (used internally by add and fireWith)
moel@348
  1039
		firingStart,
moel@348
  1040
		// End of the loop when firing
moel@348
  1041
		firingLength,
moel@348
  1042
		// Index of currently firing callback (modified by remove if needed)
moel@348
  1043
		firingIndex,
moel@348
  1044
		// Add one or several callbacks to the list
moel@348
  1045
		add = function( args ) {
moel@348
  1046
			var i,
moel@348
  1047
				length,
moel@348
  1048
				elem,
moel@348
  1049
				type,
moel@348
  1050
				actual;
moel@348
  1051
			for ( i = 0, length = args.length; i < length; i++ ) {
moel@348
  1052
				elem = args[ i ];
moel@348
  1053
				type = jQuery.type( elem );
moel@348
  1054
				if ( type === "array" ) {
moel@348
  1055
					// Inspect recursively
moel@348
  1056
					add( elem );
moel@348
  1057
				} else if ( type === "function" ) {
moel@348
  1058
					// Add if not in unique mode and callback is not in
moel@348
  1059
					if ( !flags.unique || !self.has( elem ) ) {
moel@348
  1060
						list.push( elem );
moel@348
  1061
					}
moel@348
  1062
				}
moel@348
  1063
			}
moel@348
  1064
		},
moel@348
  1065
		// Fire callbacks
moel@348
  1066
		fire = function( context, args ) {
moel@348
  1067
			args = args || [];
moel@348
  1068
			memory = !flags.memory || [ context, args ];
moel@348
  1069
			fired = true;
moel@348
  1070
			firing = true;
moel@348
  1071
			firingIndex = firingStart || 0;
moel@348
  1072
			firingStart = 0;
moel@348
  1073
			firingLength = list.length;
moel@348
  1074
			for ( ; list && firingIndex < firingLength; firingIndex++ ) {
moel@348
  1075
				if ( list[ firingIndex ].apply( context, args ) === false && flags.stopOnFalse ) {
moel@348
  1076
					memory = true; // Mark as halted
moel@348
  1077
					break;
moel@348
  1078
				}
moel@348
  1079
			}
moel@348
  1080
			firing = false;
moel@348
  1081
			if ( list ) {
moel@348
  1082
				if ( !flags.once ) {
moel@348
  1083
					if ( stack && stack.length ) {
moel@348
  1084
						memory = stack.shift();
moel@348
  1085
						self.fireWith( memory[ 0 ], memory[ 1 ] );
moel@348
  1086
					}
moel@348
  1087
				} else if ( memory === true ) {
moel@348
  1088
					self.disable();
moel@348
  1089
				} else {
moel@348
  1090
					list = [];
moel@348
  1091
				}
moel@348
  1092
			}
moel@348
  1093
		},
moel@348
  1094
		// Actual Callbacks object
moel@348
  1095
		self = {
moel@348
  1096
			// Add a callback or a collection of callbacks to the list
moel@348
  1097
			add: function() {
moel@348
  1098
				if ( list ) {
moel@348
  1099
					var length = list.length;
moel@348
  1100
					add( arguments );
moel@348
  1101
					// Do we need to add the callbacks to the
moel@348
  1102
					// current firing batch?
moel@348
  1103
					if ( firing ) {
moel@348
  1104
						firingLength = list.length;
moel@348
  1105
					// With memory, if we're not firing then
moel@348
  1106
					// we should call right away, unless previous
moel@348
  1107
					// firing was halted (stopOnFalse)
moel@348
  1108
					} else if ( memory && memory !== true ) {
moel@348
  1109
						firingStart = length;
moel@348
  1110
						fire( memory[ 0 ], memory[ 1 ] );
moel@348
  1111
					}
moel@348
  1112
				}
moel@348
  1113
				return this;
moel@348
  1114
			},
moel@348
  1115
			// Remove a callback from the list
moel@348
  1116
			remove: function() {
moel@348
  1117
				if ( list ) {
moel@348
  1118
					var args = arguments,
moel@348
  1119
						argIndex = 0,
moel@348
  1120
						argLength = args.length;
moel@348
  1121
					for ( ; argIndex < argLength ; argIndex++ ) {
moel@348
  1122
						for ( var i = 0; i < list.length; i++ ) {
moel@348
  1123
							if ( args[ argIndex ] === list[ i ] ) {
moel@348
  1124
								// Handle firingIndex and firingLength
moel@348
  1125
								if ( firing ) {
moel@348
  1126
									if ( i <= firingLength ) {
moel@348
  1127
										firingLength--;
moel@348
  1128
										if ( i <= firingIndex ) {
moel@348
  1129
											firingIndex--;
moel@348
  1130
										}
moel@348
  1131
									}
moel@348
  1132
								}
moel@348
  1133
								// Remove the element
moel@348
  1134
								list.splice( i--, 1 );
moel@348
  1135
								// If we have some unicity property then
moel@348
  1136
								// we only need to do this once
moel@348
  1137
								if ( flags.unique ) {
moel@348
  1138
									break;
moel@348
  1139
								}
moel@348
  1140
							}
moel@348
  1141
						}
moel@348
  1142
					}
moel@348
  1143
				}
moel@348
  1144
				return this;
moel@348
  1145
			},
moel@348
  1146
			// Control if a given callback is in the list
moel@348
  1147
			has: function( fn ) {
moel@348
  1148
				if ( list ) {
moel@348
  1149
					var i = 0,
moel@348
  1150
						length = list.length;
moel@348
  1151
					for ( ; i < length; i++ ) {
moel@348
  1152
						if ( fn === list[ i ] ) {
moel@348
  1153
							return true;
moel@348
  1154
						}
moel@348
  1155
					}
moel@348
  1156
				}
moel@348
  1157
				return false;
moel@348
  1158
			},
moel@348
  1159
			// Remove all callbacks from the list
moel@348
  1160
			empty: function() {
moel@348
  1161
				list = [];
moel@348
  1162
				return this;
moel@348
  1163
			},
moel@348
  1164
			// Have the list do nothing anymore
moel@348
  1165
			disable: function() {
moel@348
  1166
				list = stack = memory = undefined;
moel@348
  1167
				return this;
moel@348
  1168
			},
moel@348
  1169
			// Is it disabled?
moel@348
  1170
			disabled: function() {
moel@348
  1171
				return !list;
moel@348
  1172
			},
moel@348
  1173
			// Lock the list in its current state
moel@348
  1174
			lock: function() {
moel@348
  1175
				stack = undefined;
moel@348
  1176
				if ( !memory || memory === true ) {
moel@348
  1177
					self.disable();
moel@348
  1178
				}
moel@348
  1179
				return this;
moel@348
  1180
			},
moel@348
  1181
			// Is it locked?
moel@348
  1182
			locked: function() {
moel@348
  1183
				return !stack;
moel@348
  1184
			},
moel@348
  1185
			// Call all callbacks with the given context and arguments
moel@348
  1186
			fireWith: function( context, args ) {
moel@348
  1187
				if ( stack ) {
moel@348
  1188
					if ( firing ) {
moel@348
  1189
						if ( !flags.once ) {
moel@348
  1190
							stack.push( [ context, args ] );
moel@348
  1191
						}
moel@348
  1192
					} else if ( !( flags.once && memory ) ) {
moel@348
  1193
						fire( context, args );
moel@348
  1194
					}
moel@348
  1195
				}
moel@348
  1196
				return this;
moel@348
  1197
			},
moel@348
  1198
			// Call all the callbacks with the given arguments
moel@348
  1199
			fire: function() {
moel@348
  1200
				self.fireWith( this, arguments );
moel@348
  1201
				return this;
moel@348
  1202
			},
moel@348
  1203
			// To know if the callbacks have already been called at least once
moel@348
  1204
			fired: function() {
moel@348
  1205
				return !!fired;
moel@348
  1206
			}
moel@348
  1207
		};
moel@348
  1208
moel@348
  1209
	return self;
moel@348
  1210
};
moel@348
  1211
moel@348
  1212
moel@348
  1213
moel@348
  1214
moel@348
  1215
var // Static reference to slice
moel@348
  1216
	sliceDeferred = [].slice;
moel@348
  1217
moel@348
  1218
jQuery.extend({
moel@348
  1219
moel@348
  1220
	Deferred: function( func ) {
moel@348
  1221
		var doneList = jQuery.Callbacks( "once memory" ),
moel@348
  1222
			failList = jQuery.Callbacks( "once memory" ),
moel@348
  1223
			progressList = jQuery.Callbacks( "memory" ),
moel@348
  1224
			state = "pending",
moel@348
  1225
			lists = {
moel@348
  1226
				resolve: doneList,
moel@348
  1227
				reject: failList,
moel@348
  1228
				notify: progressList
moel@348
  1229
			},
moel@348
  1230
			promise = {
moel@348
  1231
				done: doneList.add,
moel@348
  1232
				fail: failList.add,
moel@348
  1233
				progress: progressList.add,
moel@348
  1234
moel@348
  1235
				state: function() {
moel@348
  1236
					return state;
moel@348
  1237
				},
moel@348
  1238
moel@348
  1239
				// Deprecated
moel@348
  1240
				isResolved: doneList.fired,
moel@348
  1241
				isRejected: failList.fired,
moel@348
  1242
moel@348
  1243
				then: function( doneCallbacks, failCallbacks, progressCallbacks ) {
moel@348
  1244
					deferred.done( doneCallbacks ).fail( failCallbacks ).progress( progressCallbacks );
moel@348
  1245
					return this;
moel@348
  1246
				},
moel@348
  1247
				always: function() {
moel@348
  1248
					deferred.done.apply( deferred, arguments ).fail.apply( deferred, arguments );
moel@348
  1249
					return this;
moel@348
  1250
				},
moel@348
  1251
				pipe: function( fnDone, fnFail, fnProgress ) {
moel@348
  1252
					return jQuery.Deferred(function( newDefer ) {
moel@348
  1253
						jQuery.each( {
moel@348
  1254
							done: [ fnDone, "resolve" ],
moel@348
  1255
							fail: [ fnFail, "reject" ],
moel@348
  1256
							progress: [ fnProgress, "notify" ]
moel@348
  1257
						}, function( handler, data ) {
moel@348
  1258
							var fn = data[ 0 ],
moel@348
  1259
								action = data[ 1 ],
moel@348
  1260
								returned;
moel@348
  1261
							if ( jQuery.isFunction( fn ) ) {
moel@348
  1262
								deferred[ handler ](function() {
moel@348
  1263
									returned = fn.apply( this, arguments );
moel@348
  1264
									if ( returned && jQuery.isFunction( returned.promise ) ) {
moel@348
  1265
										returned.promise().then( newDefer.resolve, newDefer.reject, newDefer.notify );
moel@348
  1266
									} else {
moel@348
  1267
										newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] );
moel@348
  1268
									}
moel@348
  1269
								});
moel@348
  1270
							} else {
moel@348
  1271
								deferred[ handler ]( newDefer[ action ] );
moel@348
  1272
							}
moel@348
  1273
						});
moel@348
  1274
					}).promise();
moel@348
  1275
				},
moel@348
  1276
				// Get a promise for this deferred
moel@348
  1277
				// If obj is provided, the promise aspect is added to the object
moel@348
  1278
				promise: function( obj ) {
moel@348
  1279
					if ( obj == null ) {
moel@348
  1280
						obj = promise;
moel@348
  1281
					} else {
moel@348
  1282
						for ( var key in promise ) {
moel@348
  1283
							obj[ key ] = promise[ key ];
moel@348
  1284
						}
moel@348
  1285
					}
moel@348
  1286
					return obj;
moel@348
  1287
				}
moel@348
  1288
			},
moel@348
  1289
			deferred = promise.promise({}),
moel@348
  1290
			key;
moel@348
  1291
moel@348
  1292
		for ( key in lists ) {
moel@348
  1293
			deferred[ key ] = lists[ key ].fire;
moel@348
  1294
			deferred[ key + "With" ] = lists[ key ].fireWith;
moel@348
  1295
		}
moel@348
  1296
moel@348
  1297
		// Handle state
moel@348
  1298
		deferred.done( function() {
moel@348
  1299
			state = "resolved";
moel@348
  1300
		}, failList.disable, progressList.lock ).fail( function() {
moel@348
  1301
			state = "rejected";
moel@348
  1302
		}, doneList.disable, progressList.lock );
moel@348
  1303
moel@348
  1304
		// Call given func if any
moel@348
  1305
		if ( func ) {
moel@348
  1306
			func.call( deferred, deferred );
moel@348
  1307
		}
moel@348
  1308
moel@348
  1309
		// All done!
moel@348
  1310
		return deferred;
moel@348
  1311
	},
moel@348
  1312
moel@348
  1313
	// Deferred helper
moel@348
  1314
	when: function( firstParam ) {
moel@348
  1315
		var args = sliceDeferred.call( arguments, 0 ),
moel@348
  1316
			i = 0,
moel@348
  1317
			length = args.length,
moel@348
  1318
			pValues = new Array( length ),
moel@348
  1319
			count = length,
moel@348
  1320
			pCount = length,
moel@348
  1321
			deferred = length <= 1 && firstParam && jQuery.isFunction( firstParam.promise ) ?
moel@348
  1322
				firstParam :
moel@348
  1323
				jQuery.Deferred(),
moel@348
  1324
			promise = deferred.promise();
moel@348
  1325
		function resolveFunc( i ) {
moel@348
  1326
			return function( value ) {
moel@348
  1327
				args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value;
moel@348
  1328
				if ( !( --count ) ) {
moel@348
  1329
					deferred.resolveWith( deferred, args );
moel@348
  1330
				}
moel@348
  1331
			};
moel@348
  1332
		}
moel@348
  1333
		function progressFunc( i ) {
moel@348
  1334
			return function( value ) {
moel@348
  1335
				pValues[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value;
moel@348
  1336
				deferred.notifyWith( promise, pValues );
moel@348
  1337
			};
moel@348
  1338
		}
moel@348
  1339
		if ( length > 1 ) {
moel@348
  1340
			for ( ; i < length; i++ ) {
moel@348
  1341
				if ( args[ i ] && args[ i ].promise && jQuery.isFunction( args[ i ].promise ) ) {
moel@348
  1342
					args[ i ].promise().then( resolveFunc(i), deferred.reject, progressFunc(i) );
moel@348
  1343
				} else {
moel@348
  1344
					--count;
moel@348
  1345
				}
moel@348
  1346
			}
moel@348
  1347
			if ( !count ) {
moel@348
  1348
				deferred.resolveWith( deferred, args );
moel@348
  1349
			}
moel@348
  1350
		} else if ( deferred !== firstParam ) {
moel@348
  1351
			deferred.resolveWith( deferred, length ? [ firstParam ] : [] );
moel@348
  1352
		}
moel@348
  1353
		return promise;
moel@348
  1354
	}
moel@348
  1355
});
moel@348
  1356
moel@348
  1357
moel@348
  1358
moel@348
  1359
moel@348
  1360
jQuery.support = (function() {
moel@348
  1361
moel@348
  1362
	var support,
moel@348
  1363
		all,
moel@348
  1364
		a,
moel@348
  1365
		select,
moel@348
  1366
		opt,
moel@348
  1367
		input,
moel@348
  1368
		fragment,
moel@348
  1369
		tds,
moel@348
  1370
		events,
moel@348
  1371
		eventName,
moel@348
  1372
		i,
moel@348
  1373
		isSupported,
moel@348
  1374
		div = document.createElement( "div" ),
moel@348
  1375
		documentElement = document.documentElement;
moel@348
  1376
moel@348
  1377
	// Preliminary tests
moel@348
  1378
	div.setAttribute("className", "t");
moel@348
  1379
	div.innerHTML = "   <link/><table></table><a href='/a' style='top:1px;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
moel@348
  1380
moel@348
  1381
	all = div.getElementsByTagName( "*" );
moel@348
  1382
	a = div.getElementsByTagName( "a" )[ 0 ];
moel@348
  1383
moel@348
  1384
	// Can't get basic test support
moel@348
  1385
	if ( !all || !all.length || !a ) {
moel@348
  1386
		return {};
moel@348
  1387
	}
moel@348
  1388
moel@348
  1389
	// First batch of supports tests
moel@348
  1390
	select = document.createElement( "select" );
moel@348
  1391
	opt = select.appendChild( document.createElement("option") );
moel@348
  1392
	input = div.getElementsByTagName( "input" )[ 0 ];
moel@348
  1393
moel@348
  1394
	support = {
moel@348
  1395
		// IE strips leading whitespace when .innerHTML is used
moel@348
  1396
		leadingWhitespace: ( div.firstChild.nodeType === 3 ),
moel@348
  1397
moel@348
  1398
		// Make sure that tbody elements aren't automatically inserted
moel@348
  1399
		// IE will insert them into empty tables
moel@348
  1400
		tbody: !div.getElementsByTagName("tbody").length,
moel@348
  1401
moel@348
  1402
		// Make sure that link elements get serialized correctly by innerHTML
moel@348
  1403
		// This requires a wrapper element in IE
moel@348
  1404
		htmlSerialize: !!div.getElementsByTagName("link").length,
moel@348
  1405
moel@348
  1406
		// Get the style information from getAttribute
moel@348
  1407
		// (IE uses .cssText instead)
moel@348
  1408
		style: /top/.test( a.getAttribute("style") ),
moel@348
  1409
moel@348
  1410
		// Make sure that URLs aren't manipulated
moel@348
  1411
		// (IE normalizes it by default)
moel@348
  1412
		hrefNormalized: ( a.getAttribute("href") === "/a" ),
moel@348
  1413
moel@348
  1414
		// Make sure that element opacity exists
moel@348
  1415
		// (IE uses filter instead)
moel@348
  1416
		// Use a regex to work around a WebKit issue. See #5145
moel@348
  1417
		opacity: /^0.55/.test( a.style.opacity ),
moel@348
  1418
moel@348
  1419
		// Verify style float existence
moel@348
  1420
		// (IE uses styleFloat instead of cssFloat)
moel@348
  1421
		cssFloat: !!a.style.cssFloat,
moel@348
  1422
moel@348
  1423
		// Make sure that if no value is specified for a checkbox
moel@348
  1424
		// that it defaults to "on".
moel@348
  1425
		// (WebKit defaults to "" instead)
moel@348
  1426
		checkOn: ( input.value === "on" ),
moel@348
  1427
moel@348
  1428
		// Make sure that a selected-by-default option has a working selected property.
moel@348
  1429
		// (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
moel@348
  1430
		optSelected: opt.selected,
moel@348
  1431
moel@348
  1432
		// Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
moel@348
  1433
		getSetAttribute: div.className !== "t",
moel@348
  1434
moel@348
  1435
		// Tests for enctype support on a form(#6743)
moel@348
  1436
		enctype: !!document.createElement("form").enctype,
moel@348
  1437
moel@348
  1438
		// Makes sure cloning an html5 element does not cause problems
moel@348
  1439
		// Where outerHTML is undefined, this still works
moel@348
  1440
		html5Clone: document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav></:nav>",
moel@348
  1441
moel@348
  1442
		// Will be defined later
moel@348
  1443
		submitBubbles: true,
moel@348
  1444
		changeBubbles: true,
moel@348
  1445
		focusinBubbles: false,
moel@348
  1446
		deleteExpando: true,
moel@348
  1447
		noCloneEvent: true,
moel@348
  1448
		inlineBlockNeedsLayout: false,
moel@348
  1449
		shrinkWrapBlocks: false,
moel@348
  1450
		reliableMarginRight: true,
moel@348
  1451
		pixelMargin: true
moel@348
  1452
	};
moel@348
  1453
moel@348
  1454
	// jQuery.boxModel DEPRECATED in 1.3, use jQuery.support.boxModel instead
moel@348
  1455
	jQuery.boxModel = support.boxModel = (document.compatMode === "CSS1Compat");
moel@348
  1456
moel@348
  1457
	// Make sure checked status is properly cloned
moel@348
  1458
	input.checked = true;
moel@348
  1459
	support.noCloneChecked = input.cloneNode( true ).checked;
moel@348
  1460
moel@348
  1461
	// Make sure that the options inside disabled selects aren't marked as disabled
moel@348
  1462
	// (WebKit marks them as disabled)
moel@348
  1463
	select.disabled = true;
moel@348
  1464
	support.optDisabled = !opt.disabled;
moel@348
  1465
moel@348
  1466
	// Test to see if it's possible to delete an expando from an element
moel@348
  1467
	// Fails in Internet Explorer
moel@348
  1468
	try {
moel@348
  1469
		delete div.test;
moel@348
  1470
	} catch( e ) {
moel@348
  1471
		support.deleteExpando = false;
moel@348
  1472
	}
moel@348
  1473
moel@348
  1474
	if ( !div.addEventListener && div.attachEvent && div.fireEvent ) {
moel@348
  1475
		div.attachEvent( "onclick", function() {
moel@348
  1476
			// Cloning a node shouldn't copy over any
moel@348
  1477
			// bound event handlers (IE does this)
moel@348
  1478
			support.noCloneEvent = false;
moel@348
  1479
		});
moel@348
  1480
		div.cloneNode( true ).fireEvent( "onclick" );
moel@348
  1481
	}
moel@348
  1482
moel@348
  1483
	// Check if a radio maintains its value
moel@348
  1484
	// after being appended to the DOM
moel@348
  1485
	input = document.createElement("input");
moel@348
  1486
	input.value = "t";
moel@348
  1487
	input.setAttribute("type", "radio");
moel@348
  1488
	support.radioValue = input.value === "t";
moel@348
  1489
moel@348
  1490
	input.setAttribute("checked", "checked");
moel@348
  1491
moel@348
  1492
	// #11217 - WebKit loses check when the name is after the checked attribute
moel@348
  1493
	input.setAttribute( "name", "t" );
moel@348
  1494
moel@348
  1495
	div.appendChild( input );
moel@348
  1496
	fragment = document.createDocumentFragment();
moel@348
  1497
	fragment.appendChild( div.lastChild );
moel@348
  1498
moel@348
  1499
	// WebKit doesn't clone checked state correctly in fragments
moel@348
  1500
	support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked;
moel@348
  1501
moel@348
  1502
	// Check if a disconnected checkbox will retain its checked
moel@348
  1503
	// value of true after appended to the DOM (IE6/7)
moel@348
  1504
	support.appendChecked = input.checked;
moel@348
  1505
moel@348
  1506
	fragment.removeChild( input );
moel@348
  1507
	fragment.appendChild( div );
moel@348
  1508
moel@348
  1509
	// Technique from Juriy Zaytsev
moel@348
  1510
	// http://perfectionkills.com/detecting-event-support-without-browser-sniffing/
moel@348
  1511
	// We only care about the case where non-standard event systems
moel@348
  1512
	// are used, namely in IE. Short-circuiting here helps us to
moel@348
  1513
	// avoid an eval call (in setAttribute) which can cause CSP
moel@348
  1514
	// to go haywire. See: https://developer.mozilla.org/en/Security/CSP
moel@348
  1515
	if ( div.attachEvent ) {
moel@348
  1516
		for ( i in {
moel@348
  1517
			submit: 1,
moel@348
  1518
			change: 1,
moel@348
  1519
			focusin: 1
moel@348
  1520
		}) {
moel@348
  1521
			eventName = "on" + i;
moel@348
  1522
			isSupported = ( eventName in div );
moel@348
  1523
			if ( !isSupported ) {
moel@348
  1524
				div.setAttribute( eventName, "return;" );
moel@348
  1525
				isSupported = ( typeof div[ eventName ] === "function" );
moel@348
  1526
			}
moel@348
  1527
			support[ i + "Bubbles" ] = isSupported;
moel@348
  1528
		}
moel@348
  1529
	}
moel@348
  1530
moel@348
  1531
	fragment.removeChild( div );
moel@348
  1532
moel@348
  1533
	// Null elements to avoid leaks in IE
moel@348
  1534
	fragment = select = opt = div = input = null;
moel@348
  1535
moel@348
  1536
	// Run tests that need a body at doc ready
moel@348
  1537
	jQuery(function() {
moel@348
  1538
		var container, outer, inner, table, td, offsetSupport,
moel@348
  1539
			marginDiv, conMarginTop, style, html, positionTopLeftWidthHeight,
moel@348
  1540
			paddingMarginBorderVisibility, paddingMarginBorder,
moel@348
  1541
			body = document.getElementsByTagName("body")[0];
moel@348
  1542
moel@348
  1543
		if ( !body ) {
moel@348
  1544
			// Return for frameset docs that don't have a body
moel@348
  1545
			return;
moel@348
  1546
		}
moel@348
  1547
moel@348
  1548
		conMarginTop = 1;
moel@348
  1549
		paddingMarginBorder = "padding:0;margin:0;border:";
moel@348
  1550
		positionTopLeftWidthHeight = "position:absolute;top:0;left:0;width:1px;height:1px;";
moel@348
  1551
		paddingMarginBorderVisibility = paddingMarginBorder + "0;visibility:hidden;";
moel@348
  1552
		style = "style='" + positionTopLeftWidthHeight + paddingMarginBorder + "5px solid #000;";
moel@348
  1553
		html = "<div " + style + "display:block;'><div style='" + paddingMarginBorder + "0;display:block;overflow:hidden;'></div></div>" +
moel@348
  1554
			"<table " + style + "' cellpadding='0' cellspacing='0'>" +
moel@348
  1555
			"<tr><td></td></tr></table>";
moel@348
  1556
moel@348
  1557
		container = document.createElement("div");
moel@348
  1558
		container.style.cssText = paddingMarginBorderVisibility + "width:0;height:0;position:static;top:0;margin-top:" + conMarginTop + "px";
moel@348
  1559
		body.insertBefore( container, body.firstChild );
moel@348
  1560
moel@348
  1561
		// Construct the test element
moel@348
  1562
		div = document.createElement("div");
moel@348
  1563
		container.appendChild( div );
moel@348
  1564
moel@348
  1565
		// Check if table cells still have offsetWidth/Height when they are set
moel@348
  1566
		// to display:none and there are still other visible table cells in a
moel@348
  1567
		// table row; if so, offsetWidth/Height are not reliable for use when
moel@348
  1568
		// determining if an element has been hidden directly using
moel@348
  1569
		// display:none (it is still safe to use offsets if a parent element is
moel@348
  1570
		// hidden; don safety goggles and see bug #4512 for more information).
moel@348
  1571
		// (only IE 8 fails this test)
moel@348
  1572
		div.innerHTML = "<table><tr><td style='" + paddingMarginBorder + "0;display:none'></td><td>t</td></tr></table>";
moel@348
  1573
		tds = div.getElementsByTagName( "td" );
moel@348
  1574
		isSupported = ( tds[ 0 ].offsetHeight === 0 );
moel@348
  1575
moel@348
  1576
		tds[ 0 ].style.display = "";
moel@348
  1577
		tds[ 1 ].style.display = "none";
moel@348
  1578
moel@348
  1579
		// Check if empty table cells still have offsetWidth/Height
moel@348
  1580
		// (IE <= 8 fail this test)
moel@348
  1581
		support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 );
moel@348
  1582
moel@348
  1583
		// Check if div with explicit width and no margin-right incorrectly
moel@348
  1584
		// gets computed margin-right based on width of container. For more
moel@348
  1585
		// info see bug #3333
moel@348
  1586
		// Fails in WebKit before Feb 2011 nightlies
moel@348
  1587
		// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
moel@348
  1588
		if ( window.getComputedStyle ) {
moel@348
  1589
			div.innerHTML = "";
moel@348
  1590
			marginDiv = document.createElement( "div" );
moel@348
  1591
			marginDiv.style.width = "0";
moel@348
  1592
			marginDiv.style.marginRight = "0";
moel@348
  1593
			div.style.width = "2px";
moel@348
  1594
			div.appendChild( marginDiv );
moel@348
  1595
			support.reliableMarginRight =
moel@348
  1596
				( parseInt( ( window.getComputedStyle( marginDiv, null ) || { marginRight: 0 } ).marginRight, 10 ) || 0 ) === 0;
moel@348
  1597
		}
moel@348
  1598
moel@348
  1599
		if ( typeof div.style.zoom !== "undefined" ) {
moel@348
  1600
			// Check if natively block-level elements act like inline-block
moel@348
  1601
			// elements when setting their display to 'inline' and giving
moel@348
  1602
			// them layout
moel@348
  1603
			// (IE < 8 does this)
moel@348
  1604
			div.innerHTML = "";
moel@348
  1605
			div.style.width = div.style.padding = "1px";
moel@348
  1606
			div.style.border = 0;
moel@348
  1607
			div.style.overflow = "hidden";
moel@348
  1608
			div.style.display = "inline";
moel@348
  1609
			div.style.zoom = 1;
moel@348
  1610
			support.inlineBlockNeedsLayout = ( div.offsetWidth === 3 );
moel@348
  1611
moel@348
  1612
			// Check if elements with layout shrink-wrap their children
moel@348
  1613
			// (IE 6 does this)
moel@348
  1614
			div.style.display = "block";
moel@348
  1615
			div.style.overflow = "visible";
moel@348
  1616
			div.innerHTML = "<div style='width:5px;'></div>";
moel@348
  1617
			support.shrinkWrapBlocks = ( div.offsetWidth !== 3 );
moel@348
  1618
		}
moel@348
  1619
moel@348
  1620
		div.style.cssText = positionTopLeftWidthHeight + paddingMarginBorderVisibility;
moel@348
  1621
		div.innerHTML = html;
moel@348
  1622
moel@348
  1623
		outer = div.firstChild;
moel@348
  1624
		inner = outer.firstChild;
moel@348
  1625
		td = outer.nextSibling.firstChild.firstChild;
moel@348
  1626
moel@348
  1627
		offsetSupport = {
moel@348
  1628
			doesNotAddBorder: ( inner.offsetTop !== 5 ),
moel@348
  1629
			doesAddBorderForTableAndCells: ( td.offsetTop === 5 )
moel@348
  1630
		};
moel@348
  1631
moel@348
  1632
		inner.style.position = "fixed";
moel@348
  1633
		inner.style.top = "20px";
moel@348
  1634
moel@348
  1635
		// safari subtracts parent border width here which is 5px
moel@348
  1636
		offsetSupport.fixedPosition = ( inner.offsetTop === 20 || inner.offsetTop === 15 );
moel@348
  1637
		inner.style.position = inner.style.top = "";
moel@348
  1638
moel@348
  1639
		outer.style.overflow = "hidden";
moel@348
  1640
		outer.style.position = "relative";
moel@348
  1641
moel@348
  1642
		offsetSupport.subtractsBorderForOverflowNotVisible = ( inner.offsetTop === -5 );
moel@348
  1643
		offsetSupport.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== conMarginTop );
moel@348
  1644
moel@348
  1645
		if ( window.getComputedStyle ) {
moel@348
  1646
			div.style.marginTop = "1%";
moel@348
  1647
			support.pixelMargin = ( window.getComputedStyle( div, null ) || { marginTop: 0 } ).marginTop !== "1%";
moel@348
  1648
		}
moel@348
  1649
moel@348
  1650
		if ( typeof container.style.zoom !== "undefined" ) {
moel@348
  1651
			container.style.zoom = 1;
moel@348
  1652
		}
moel@348
  1653
moel@348
  1654
		body.removeChild( container );
moel@348
  1655
		marginDiv = div = container = null;
moel@348
  1656
moel@348
  1657
		jQuery.extend( support, offsetSupport );
moel@348
  1658
	});
moel@348
  1659
moel@348
  1660
	return support;
moel@348
  1661
})();
moel@348
  1662
moel@348
  1663
moel@348
  1664
moel@348
  1665
moel@348
  1666
var rbrace = /^(?:\{.*\}|\[.*\])$/,
moel@348
  1667
	rmultiDash = /([A-Z])/g;
moel@348
  1668
moel@348
  1669
jQuery.extend({
moel@348
  1670
	cache: {},
moel@348
  1671
moel@348
  1672
	// Please use with caution
moel@348
  1673
	uuid: 0,
moel@348
  1674
moel@348
  1675
	// Unique for each copy of jQuery on the page
moel@348
  1676
	// Non-digits removed to match rinlinejQuery
moel@348
  1677
	expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ),
moel@348
  1678
moel@348
  1679
	// The following elements throw uncatchable exceptions if you
moel@348
  1680
	// attempt to add expando properties to them.
moel@348
  1681
	noData: {
moel@348
  1682
		"embed": true,
moel@348
  1683
		// Ban all objects except for Flash (which handle expandos)
moel@348
  1684
		"object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
moel@348
  1685
		"applet": true
moel@348
  1686
	},
moel@348
  1687
moel@348
  1688
	hasData: function( elem ) {
moel@348
  1689
		elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
moel@348
  1690
		return !!elem && !isEmptyDataObject( elem );
moel@348
  1691
	},
moel@348
  1692
moel@348
  1693
	data: function( elem, name, data, pvt /* Internal Use Only */ ) {
moel@348
  1694
		if ( !jQuery.acceptData( elem ) ) {
moel@348
  1695
			return;
moel@348
  1696
		}
moel@348
  1697
moel@348
  1698
		var privateCache, thisCache, ret,
moel@348
  1699
			internalKey = jQuery.expando,
moel@348
  1700
			getByName = typeof name === "string",
moel@348
  1701
moel@348
  1702
			// We have to handle DOM nodes and JS objects differently because IE6-7
moel@348
  1703
			// can't GC object references properly across the DOM-JS boundary
moel@348
  1704
			isNode = elem.nodeType,
moel@348
  1705
moel@348
  1706
			// Only DOM nodes need the global jQuery cache; JS object data is
moel@348
  1707
			// attached directly to the object so GC can occur automatically
moel@348
  1708
			cache = isNode ? jQuery.cache : elem,
moel@348
  1709
moel@348
  1710
			// Only defining an ID for JS objects if its cache already exists allows
moel@348
  1711
			// the code to shortcut on the same path as a DOM node with no cache
moel@348
  1712
			id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey,
moel@348
  1713
			isEvents = name === "events";
moel@348
  1714
moel@348
  1715
		// Avoid doing any more work than we need to when trying to get data on an
moel@348
  1716
		// object that has no data at all
moel@348
  1717
		if ( (!id || !cache[id] || (!isEvents && !pvt && !cache[id].data)) && getByName && data === undefined ) {
moel@348
  1718
			return;
moel@348
  1719
		}
moel@348
  1720
moel@348
  1721
		if ( !id ) {
moel@348
  1722
			// Only DOM nodes need a new unique ID for each element since their data
moel@348
  1723
			// ends up in the global cache
moel@348
  1724
			if ( isNode ) {
moel@348
  1725
				elem[ internalKey ] = id = ++jQuery.uuid;
moel@348
  1726
			} else {
moel@348
  1727
				id = internalKey;
moel@348
  1728
			}
moel@348
  1729
		}
moel@348
  1730
moel@348
  1731
		if ( !cache[ id ] ) {
moel@348
  1732
			cache[ id ] = {};
moel@348
  1733
moel@348
  1734
			// Avoids exposing jQuery metadata on plain JS objects when the object
moel@348
  1735
			// is serialized using JSON.stringify
moel@348
  1736
			if ( !isNode ) {
moel@348
  1737
				cache[ id ].toJSON = jQuery.noop;
moel@348
  1738
			}
moel@348
  1739
		}
moel@348
  1740
moel@348
  1741
		// An object can be passed to jQuery.data instead of a key/value pair; this gets
moel@348
  1742
		// shallow copied over onto the existing cache
moel@348
  1743
		if ( typeof name === "object" || typeof name === "function" ) {
moel@348
  1744
			if ( pvt ) {
moel@348
  1745
				cache[ id ] = jQuery.extend( cache[ id ], name );
moel@348
  1746
			} else {
moel@348
  1747
				cache[ id ].data = jQuery.extend( cache[ id ].data, name );
moel@348
  1748
			}
moel@348
  1749
		}
moel@348
  1750
moel@348
  1751
		privateCache = thisCache = cache[ id ];
moel@348
  1752
moel@348
  1753
		// jQuery data() is stored in a separate object inside the object's internal data
moel@348
  1754
		// cache in order to avoid key collisions between internal data and user-defined
moel@348
  1755
		// data.
moel@348
  1756
		if ( !pvt ) {
moel@348
  1757
			if ( !thisCache.data ) {
moel@348
  1758
				thisCache.data = {};
moel@348
  1759
			}
moel@348
  1760
moel@348
  1761
			thisCache = thisCache.data;
moel@348
  1762
		}
moel@348
  1763
moel@348
  1764
		if ( data !== undefined ) {
moel@348
  1765
			thisCache[ jQuery.camelCase( name ) ] = data;
moel@348
  1766
		}
moel@348
  1767
moel@348
  1768
		// Users should not attempt to inspect the internal events object using jQuery.data,
moel@348
  1769
		// it is undocumented and subject to change. But does anyone listen? No.
moel@348
  1770
		if ( isEvents && !thisCache[ name ] ) {
moel@348
  1771
			return privateCache.events;
moel@348
  1772
		}
moel@348
  1773
moel@348
  1774
		// Check for both converted-to-camel and non-converted data property names
moel@348
  1775
		// If a data property was specified
moel@348
  1776
		if ( getByName ) {
moel@348
  1777
moel@348
  1778
			// First Try to find as-is property data
moel@348
  1779
			ret = thisCache[ name ];
moel@348
  1780
moel@348
  1781
			// Test for null|undefined property data
moel@348
  1782
			if ( ret == null ) {
moel@348
  1783
moel@348
  1784
				// Try to find the camelCased property
moel@348
  1785
				ret = thisCache[ jQuery.camelCase( name ) ];
moel@348
  1786
			}
moel@348
  1787
		} else {
moel@348
  1788
			ret = thisCache;
moel@348
  1789
		}
moel@348
  1790
moel@348
  1791
		return ret;
moel@348
  1792
	},
moel@348
  1793
moel@348
  1794
	removeData: function( elem, name, pvt /* Internal Use Only */ ) {
moel@348
  1795
		if ( !jQuery.acceptData( elem ) ) {
moel@348
  1796
			return;
moel@348
  1797
		}
moel@348
  1798
moel@348
  1799
		var thisCache, i, l,
moel@348
  1800
moel@348
  1801
			// Reference to internal data cache key
moel@348
  1802
			internalKey = jQuery.expando,
moel@348
  1803
moel@348
  1804
			isNode = elem.nodeType,
moel@348
  1805
moel@348
  1806
			// See jQuery.data for more information
moel@348
  1807
			cache = isNode ? jQuery.cache : elem,
moel@348
  1808
moel@348
  1809
			// See jQuery.data for more information
moel@348
  1810
			id = isNode ? elem[ internalKey ] : internalKey;
moel@348
  1811
moel@348
  1812
		// If there is already no cache entry for this object, there is no
moel@348
  1813
		// purpose in continuing
moel@348
  1814
		if ( !cache[ id ] ) {
moel@348
  1815
			return;
moel@348
  1816
		}
moel@348
  1817
moel@348
  1818
		if ( name ) {
moel@348
  1819
moel@348
  1820
			thisCache = pvt ? cache[ id ] : cache[ id ].data;
moel@348
  1821
moel@348
  1822
			if ( thisCache ) {
moel@348
  1823
moel@348
  1824
				// Support array or space separated string names for data keys
moel@348
  1825
				if ( !jQuery.isArray( name ) ) {
moel@348
  1826
moel@348
  1827
					// try the string as a key before any manipulation
moel@348
  1828
					if ( name in thisCache ) {
moel@348
  1829
						name = [ name ];
moel@348
  1830
					} else {
moel@348
  1831
moel@348
  1832
						// split the camel cased version by spaces unless a key with the spaces exists
moel@348
  1833
						name = jQuery.camelCase( name );
moel@348
  1834
						if ( name in thisCache ) {
moel@348
  1835
							name = [ name ];
moel@348
  1836
						} else {
moel@348
  1837
							name = name.split( " " );
moel@348
  1838
						}
moel@348
  1839
					}
moel@348
  1840
				}
moel@348
  1841
moel@348
  1842
				for ( i = 0, l = name.length; i < l; i++ ) {
moel@348
  1843
					delete thisCache[ name[i] ];
moel@348
  1844
				}
moel@348
  1845
moel@348
  1846
				// If there is no data left in the cache, we want to continue
moel@348
  1847
				// and let the cache object itself get destroyed
moel@348
  1848
				if ( !( pvt ? isEmptyDataObject : jQuery.isEmptyObject )( thisCache ) ) {
moel@348
  1849
					return;
moel@348
  1850
				}
moel@348
  1851
			}
moel@348
  1852
		}
moel@348
  1853
moel@348
  1854
		// See jQuery.data for more information
moel@348
  1855
		if ( !pvt ) {
moel@348
  1856
			delete cache[ id ].data;
moel@348
  1857
moel@348
  1858
			// Don't destroy the parent cache unless the internal data object
moel@348
  1859
			// had been the only thing left in it
moel@348
  1860
			if ( !isEmptyDataObject(cache[ id ]) ) {
moel@348
  1861
				return;
moel@348
  1862
			}
moel@348
  1863
		}
moel@348
  1864
moel@348
  1865
		// Browsers that fail expando deletion also refuse to delete expandos on
moel@348
  1866
		// the window, but it will allow it on all other JS objects; other browsers
moel@348
  1867
		// don't care
moel@348
  1868
		// Ensure that `cache` is not a window object #10080
moel@348
  1869
		if ( jQuery.support.deleteExpando || !cache.setInterval ) {
moel@348
  1870
			delete cache[ id ];
moel@348
  1871
		} else {
moel@348
  1872
			cache[ id ] = null;
moel@348
  1873
		}
moel@348
  1874
moel@348
  1875
		// We destroyed the cache and need to eliminate the expando on the node to avoid
moel@348
  1876
		// false lookups in the cache for entries that no longer exist
moel@348
  1877
		if ( isNode ) {
moel@348
  1878
			// IE does not allow us to delete expando properties from nodes,
moel@348
  1879
			// nor does it have a removeAttribute function on Document nodes;
moel@348
  1880
			// we must handle all of these cases
moel@348
  1881
			if ( jQuery.support.deleteExpando ) {
moel@348
  1882
				delete elem[ internalKey ];
moel@348
  1883
			} else if ( elem.removeAttribute ) {
moel@348
  1884
				elem.removeAttribute( internalKey );
moel@348
  1885
			} else {
moel@348
  1886
				elem[ internalKey ] = null;
moel@348
  1887
			}
moel@348
  1888
		}
moel@348
  1889
	},
moel@348
  1890
moel@348
  1891
	// For internal use only.
moel@348
  1892
	_data: function( elem, name, data ) {
moel@348
  1893
		return jQuery.data( elem, name, data, true );
moel@348
  1894
	},
moel@348
  1895
moel@348
  1896
	// A method for determining if a DOM node can handle the data expando
moel@348
  1897
	acceptData: function( elem ) {
moel@348
  1898
		if ( elem.nodeName ) {
moel@348
  1899
			var match = jQuery.noData[ elem.nodeName.toLowerCase() ];
moel@348
  1900
moel@348
  1901
			if ( match ) {
moel@348
  1902
				return !(match === true || elem.getAttribute("classid") !== match);
moel@348
  1903
			}
moel@348
  1904
		}
moel@348
  1905
moel@348
  1906
		return true;
moel@348
  1907
	}
moel@348
  1908
});
moel@348
  1909
moel@348
  1910
jQuery.fn.extend({
moel@348
  1911
	data: function( key, value ) {
moel@348
  1912
		var parts, part, attr, name, l,
moel@348
  1913
			elem = this[0],
moel@348
  1914
			i = 0,
moel@348
  1915
			data = null;
moel@348
  1916
moel@348
  1917
		// Gets all values
moel@348
  1918
		if ( key === undefined ) {
moel@348
  1919
			if ( this.length ) {
moel@348
  1920
				data = jQuery.data( elem );
moel@348
  1921
moel@348
  1922
				if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) {
moel@348
  1923
					attr = elem.attributes;
moel@348
  1924
					for ( l = attr.length; i < l; i++ ) {
moel@348
  1925
						name = attr[i].name;
moel@348
  1926
moel@348
  1927
						if ( name.indexOf( "data-" ) === 0 ) {
moel@348
  1928
							name = jQuery.camelCase( name.substring(5) );
moel@348
  1929
moel@348
  1930
							dataAttr( elem, name, data[ name ] );
moel@348
  1931
						}
moel@348
  1932
					}
moel@348
  1933
					jQuery._data( elem, "parsedAttrs", true );
moel@348
  1934
				}
moel@348
  1935
			}
moel@348
  1936
moel@348
  1937
			return data;
moel@348
  1938
		}
moel@348
  1939
moel@348
  1940
		// Sets multiple values
moel@348
  1941
		if ( typeof key === "object" ) {
moel@348
  1942
			return this.each(function() {
moel@348
  1943
				jQuery.data( this, key );
moel@348
  1944
			});
moel@348
  1945
		}
moel@348
  1946
moel@348
  1947
		parts = key.split( ".", 2 );
moel@348
  1948
		parts[1] = parts[1] ? "." + parts[1] : "";
moel@348
  1949
		part = parts[1] + "!";
moel@348
  1950
moel@348
  1951
		return jQuery.access( this, function( value ) {
moel@348
  1952
moel@348
  1953
			if ( value === undefined ) {
moel@348
  1954
				data = this.triggerHandler( "getData" + part, [ parts[0] ] );
moel@348
  1955
moel@348
  1956
				// Try to fetch any internally stored data first
moel@348
  1957
				if ( data === undefined && elem ) {
moel@348
  1958
					data = jQuery.data( elem, key );
moel@348
  1959
					data = dataAttr( elem, key, data );
moel@348
  1960
				}
moel@348
  1961
moel@348
  1962
				return data === undefined && parts[1] ?
moel@348
  1963
					this.data( parts[0] ) :
moel@348
  1964
					data;
moel@348
  1965
			}
moel@348
  1966
moel@348
  1967
			parts[1] = value;
moel@348
  1968
			this.each(function() {
moel@348
  1969
				var self = jQuery( this );
moel@348
  1970
moel@348
  1971
				self.triggerHandler( "setData" + part, parts );
moel@348
  1972
				jQuery.data( this, key, value );
moel@348
  1973
				self.triggerHandler( "changeData" + part, parts );
moel@348
  1974
			});
moel@348
  1975
		}, null, value, arguments.length > 1, null, false );
moel@348
  1976
	},
moel@348
  1977
moel@348
  1978
	removeData: function( key ) {
moel@348
  1979
		return this.each(function() {
moel@348
  1980
			jQuery.removeData( this, key );
moel@348
  1981
		});
moel@348
  1982
	}
moel@348
  1983
});
moel@348
  1984
moel@348
  1985
function dataAttr( elem, key, data ) {
moel@348
  1986
	// If nothing was found internally, try to fetch any
moel@348
  1987
	// data from the HTML5 data-* attribute
moel@348
  1988
	if ( data === undefined && elem.nodeType === 1 ) {
moel@348
  1989
moel@348
  1990
		var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
moel@348
  1991
moel@348
  1992
		data = elem.getAttribute( name );
moel@348
  1993
moel@348
  1994
		if ( typeof data === "string" ) {
moel@348
  1995
			try {
moel@348
  1996
				data = data === "true" ? true :
moel@348
  1997
				data === "false" ? false :
moel@348
  1998
				data === "null" ? null :
moel@348
  1999
				jQuery.isNumeric( data ) ? +data :
moel@348
  2000
					rbrace.test( data ) ? jQuery.parseJSON( data ) :
moel@348
  2001
					data;
moel@348
  2002
			} catch( e ) {}
moel@348
  2003
moel@348
  2004
			// Make sure we set the data so it isn't changed later
moel@348
  2005
			jQuery.data( elem, key, data );
moel@348
  2006
moel@348
  2007
		} else {
moel@348
  2008
			data = undefined;
moel@348
  2009
		}
moel@348
  2010
	}
moel@348
  2011
moel@348
  2012
	return data;
moel@348
  2013
}
moel@348
  2014
moel@348
  2015
// checks a cache object for emptiness
moel@348
  2016
function isEmptyDataObject( obj ) {
moel@348
  2017
	for ( var name in obj ) {
moel@348
  2018
moel@348
  2019
		// if the public data object is empty, the private is still empty
moel@348
  2020
		if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) {
moel@348
  2021
			continue;
moel@348
  2022
		}
moel@348
  2023
		if ( name !== "toJSON" ) {
moel@348
  2024
			return false;
moel@348
  2025
		}
moel@348
  2026
	}
moel@348
  2027
moel@348
  2028
	return true;
moel@348
  2029
}
moel@348
  2030
moel@348
  2031
moel@348
  2032
moel@348
  2033
moel@348
  2034
function handleQueueMarkDefer( elem, type, src ) {
moel@348
  2035
	var deferDataKey = type + "defer",
moel@348
  2036
		queueDataKey = type + "queue",
moel@348
  2037
		markDataKey = type + "mark",
moel@348
  2038
		defer = jQuery._data( elem, deferDataKey );
moel@348
  2039
	if ( defer &&
moel@348
  2040
		( src === "queue" || !jQuery._data(elem, queueDataKey) ) &&
moel@348
  2041
		( src === "mark" || !jQuery._data(elem, markDataKey) ) ) {
moel@348
  2042
		// Give room for hard-coded callbacks to fire first
moel@348
  2043
		// and eventually mark/queue something else on the element
moel@348
  2044
		setTimeout( function() {
moel@348
  2045
			if ( !jQuery._data( elem, queueDataKey ) &&
moel@348
  2046
				!jQuery._data( elem, markDataKey ) ) {
moel@348
  2047
				jQuery.removeData( elem, deferDataKey, true );
moel@348
  2048
				defer.fire();
moel@348
  2049
			}
moel@348
  2050
		}, 0 );
moel@348
  2051
	}
moel@348
  2052
}
moel@348
  2053
moel@348
  2054
jQuery.extend({
moel@348
  2055
moel@348
  2056
	_mark: function( elem, type ) {
moel@348
  2057
		if ( elem ) {
moel@348
  2058
			type = ( type || "fx" ) + "mark";
moel@348
  2059
			jQuery._data( elem, type, (jQuery._data( elem, type ) || 0) + 1 );
moel@348
  2060
		}
moel@348
  2061
	},
moel@348
  2062
moel@348
  2063
	_unmark: function( force, elem, type ) {
moel@348
  2064
		if ( force !== true ) {
moel@348
  2065
			type = elem;
moel@348
  2066
			elem = force;
moel@348
  2067
			force = false;
moel@348
  2068
		}
moel@348
  2069
		if ( elem ) {
moel@348
  2070
			type = type || "fx";
moel@348
  2071
			var key = type + "mark",
moel@348
  2072
				count = force ? 0 : ( (jQuery._data( elem, key ) || 1) - 1 );
moel@348
  2073
			if ( count ) {
moel@348
  2074
				jQuery._data( elem, key, count );
moel@348
  2075
			} else {
moel@348
  2076
				jQuery.removeData( elem, key, true );
moel@348
  2077
				handleQueueMarkDefer( elem, type, "mark" );
moel@348
  2078
			}
moel@348
  2079
		}
moel@348
  2080
	},
moel@348
  2081
moel@348
  2082
	queue: function( elem, type, data ) {
moel@348
  2083
		var q;
moel@348
  2084
		if ( elem ) {
moel@348
  2085
			type = ( type || "fx" ) + "queue";
moel@348
  2086
			q = jQuery._data( elem, type );
moel@348
  2087
moel@348
  2088
			// Speed up dequeue by getting out quickly if this is just a lookup
moel@348
  2089
			if ( data ) {
moel@348
  2090
				if ( !q || jQuery.isArray(data) ) {
moel@348
  2091
					q = jQuery._data( elem, type, jQuery.makeArray(data) );
moel@348
  2092
				} else {
moel@348
  2093
					q.push( data );
moel@348
  2094
				}
moel@348
  2095
			}
moel@348
  2096
			return q || [];
moel@348
  2097
		}
moel@348
  2098
	},
moel@348
  2099
moel@348
  2100
	dequeue: function( elem, type ) {
moel@348
  2101
		type = type || "fx";
moel@348
  2102
moel@348
  2103
		var queue = jQuery.queue( elem, type ),
moel@348
  2104
			fn = queue.shift(),
moel@348
  2105
			hooks = {};
moel@348
  2106
moel@348
  2107
		// If the fx queue is dequeued, always remove the progress sentinel
moel@348
  2108
		if ( fn === "inprogress" ) {
moel@348
  2109
			fn = queue.shift();
moel@348
  2110
		}
moel@348
  2111
moel@348
  2112
		if ( fn ) {
moel@348
  2113
			// Add a progress sentinel to prevent the fx queue from being
moel@348
  2114
			// automatically dequeued
moel@348
  2115
			if ( type === "fx" ) {
moel@348
  2116
				queue.unshift( "inprogress" );
moel@348
  2117
			}
moel@348
  2118
moel@348
  2119
			jQuery._data( elem, type + ".run", hooks );
moel@348
  2120
			fn.call( elem, function() {
moel@348
  2121
				jQuery.dequeue( elem, type );
moel@348
  2122
			}, hooks );
moel@348
  2123
		}
moel@348
  2124
moel@348
  2125
		if ( !queue.length ) {
moel@348
  2126
			jQuery.removeData( elem, type + "queue " + type + ".run", true );
moel@348
  2127
			handleQueueMarkDefer( elem, type, "queue" );
moel@348
  2128
		}
moel@348
  2129
	}
moel@348
  2130
});
moel@348
  2131
moel@348
  2132
jQuery.fn.extend({
moel@348
  2133
	queue: function( type, data ) {
moel@348
  2134
		var setter = 2;
moel@348
  2135
moel@348
  2136
		if ( typeof type !== "string" ) {
moel@348
  2137
			data = type;
moel@348
  2138
			type = "fx";
moel@348
  2139
			setter--;
moel@348
  2140
		}
moel@348
  2141
moel@348
  2142
		if ( arguments.length < setter ) {
moel@348
  2143
			return jQuery.queue( this[0], type );
moel@348
  2144
		}
moel@348
  2145
moel@348
  2146
		return data === undefined ?
moel@348
  2147
			this :
moel@348
  2148
			this.each(function() {
moel@348
  2149
				var queue = jQuery.queue( this, type, data );
moel@348
  2150
moel@348
  2151
				if ( type === "fx" && queue[0] !== "inprogress" ) {
moel@348
  2152
					jQuery.dequeue( this, type );
moel@348
  2153
				}
moel@348
  2154
			});
moel@348
  2155
	},
moel@348
  2156
	dequeue: function( type ) {
moel@348
  2157
		return this.each(function() {
moel@348
  2158
			jQuery.dequeue( this, type );
moel@348
  2159
		});
moel@348
  2160
	},
moel@348
  2161
	// Based off of the plugin by Clint Helfers, with permission.
moel@348
  2162
	// http://blindsignals.com/index.php/2009/07/jquery-delay/
moel@348
  2163
	delay: function( time, type ) {
moel@348
  2164
		time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
moel@348
  2165
		type = type || "fx";
moel@348
  2166
moel@348
  2167
		return this.queue( type, function( next, hooks ) {
moel@348
  2168
			var timeout = setTimeout( next, time );
moel@348
  2169
			hooks.stop = function() {
moel@348
  2170
				clearTimeout( timeout );
moel@348
  2171
			};
moel@348
  2172
		});
moel@348
  2173
	},
moel@348
  2174
	clearQueue: function( type ) {
moel@348
  2175
		return this.queue( type || "fx", [] );
moel@348
  2176
	},
moel@348
  2177
	// Get a promise resolved when queues of a certain type
moel@348
  2178
	// are emptied (fx is the type by default)
moel@348
  2179
	promise: function( type, object ) {
moel@348
  2180
		if ( typeof type !== "string" ) {
moel@348
  2181
			object = type;
moel@348
  2182
			type = undefined;
moel@348
  2183
		}
moel@348
  2184
		type = type || "fx";
moel@348
  2185
		var defer = jQuery.Deferred(),
moel@348
  2186
			elements = this,
moel@348
  2187
			i = elements.length,
moel@348
  2188
			count = 1,
moel@348
  2189
			deferDataKey = type + "defer",
moel@348
  2190
			queueDataKey = type + "queue",
moel@348
  2191
			markDataKey = type + "mark",
moel@348
  2192
			tmp;
moel@348
  2193
		function resolve() {
moel@348
  2194
			if ( !( --count ) ) {
moel@348
  2195
				defer.resolveWith( elements, [ elements ] );
moel@348
  2196
			}
moel@348
  2197
		}
moel@348
  2198
		while( i-- ) {
moel@348
  2199
			if (( tmp = jQuery.data( elements[ i ], deferDataKey, undefined, true ) ||
moel@348
  2200
					( jQuery.data( elements[ i ], queueDataKey, undefined, true ) ||
moel@348
  2201
						jQuery.data( elements[ i ], markDataKey, undefined, true ) ) &&
moel@348
  2202
					jQuery.data( elements[ i ], deferDataKey, jQuery.Callbacks( "once memory" ), true ) )) {
moel@348
  2203
				count++;
moel@348
  2204
				tmp.add( resolve );
moel@348
  2205
			}
moel@348
  2206
		}
moel@348
  2207
		resolve();
moel@348
  2208
		return defer.promise( object );
moel@348
  2209
	}
moel@348
  2210
});
moel@348
  2211
moel@348
  2212
moel@348
  2213
moel@348
  2214
moel@348
  2215
var rclass = /[\n\t\r]/g,
moel@348
  2216
	rspace = /\s+/,
moel@348
  2217
	rreturn = /\r/g,
moel@348
  2218
	rtype = /^(?:button|input)$/i,
moel@348
  2219
	rfocusable = /^(?:button|input|object|select|textarea)$/i,
moel@348
  2220
	rclickable = /^a(?:rea)?$/i,
moel@348
  2221
	rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
moel@348
  2222
	getSetAttribute = jQuery.support.getSetAttribute,
moel@348
  2223
	nodeHook, boolHook, fixSpecified;
moel@348
  2224
moel@348
  2225
jQuery.fn.extend({
moel@348
  2226
	attr: function( name, value ) {
moel@348
  2227
		return jQuery.access( this, jQuery.attr, name, value, arguments.length > 1 );
moel@348
  2228
	},
moel@348
  2229
moel@348
  2230
	removeAttr: function( name ) {
moel@348
  2231
		return this.each(function() {
moel@348
  2232
			jQuery.removeAttr( this, name );
moel@348
  2233
		});
moel@348
  2234
	},
moel@348
  2235
moel@348
  2236
	prop: function( name, value ) {
moel@348
  2237
		return jQuery.access( this, jQuery.prop, name, value, arguments.length > 1 );
moel@348
  2238
	},
moel@348
  2239
moel@348
  2240
	removeProp: function( name ) {
moel@348
  2241
		name = jQuery.propFix[ name ] || name;
moel@348
  2242
		return this.each(function() {
moel@348
  2243
			// try/catch handles cases where IE balks (such as removing a property on window)
moel@348
  2244
			try {
moel@348
  2245
				this[ name ] = undefined;
moel@348
  2246
				delete this[ name ];
moel@348
  2247
			} catch( e ) {}
moel@348
  2248
		});
moel@348
  2249
	},
moel@348
  2250
moel@348
  2251
	addClass: function( value ) {
moel@348
  2252
		var classNames, i, l, elem,
moel@348
  2253
			setClass, c, cl;
moel@348
  2254
moel@348
  2255
		if ( jQuery.isFunction( value ) ) {
moel@348
  2256
			return this.each(function( j ) {
moel@348
  2257
				jQuery( this ).addClass( value.call(this, j, this.className) );
moel@348
  2258
			});
moel@348
  2259
		}
moel@348
  2260
moel@348
  2261
		if ( value && typeof value === "string" ) {
moel@348
  2262
			classNames = value.split( rspace );
moel@348
  2263
moel@348
  2264
			for ( i = 0, l = this.length; i < l; i++ ) {
moel@348
  2265
				elem = this[ i ];
moel@348
  2266
moel@348
  2267
				if ( elem.nodeType === 1 ) {
moel@348
  2268
					if ( !elem.className && classNames.length === 1 ) {
moel@348
  2269
						elem.className = value;
moel@348
  2270
moel@348
  2271
					} else {
moel@348
  2272
						setClass = " " + elem.className + " ";
moel@348
  2273
moel@348
  2274
						for ( c = 0, cl = classNames.length; c < cl; c++ ) {
moel@348
  2275
							if ( !~setClass.indexOf( " " + classNames[ c ] + " " ) ) {
moel@348
  2276
								setClass += classNames[ c ] + " ";
moel@348
  2277
							}
moel@348
  2278
						}
moel@348
  2279
						elem.className = jQuery.trim( setClass );
moel@348
  2280
					}
moel@348
  2281
				}
moel@348
  2282
			}
moel@348
  2283
		}
moel@348
  2284
moel@348
  2285
		return this;
moel@348
  2286
	},
moel@348
  2287
moel@348
  2288
	removeClass: function( value ) {
moel@348
  2289
		var classNames, i, l, elem, className, c, cl;
moel@348
  2290
moel@348
  2291
		if ( jQuery.isFunction( value ) ) {
moel@348
  2292
			return this.each(function( j ) {
moel@348
  2293
				jQuery( this ).removeClass( value.call(this, j, this.className) );
moel@348
  2294
			});
moel@348
  2295
		}
moel@348
  2296
moel@348
  2297
		if ( (value && typeof value === "string") || value === undefined ) {
moel@348
  2298
			classNames = ( value || "" ).split( rspace );
moel@348
  2299
moel@348
  2300
			for ( i = 0, l = this.length; i < l; i++ ) {
moel@348
  2301
				elem = this[ i ];
moel@348
  2302
moel@348
  2303
				if ( elem.nodeType === 1 && elem.className ) {
moel@348
  2304
					if ( value ) {
moel@348
  2305
						className = (" " + elem.className + " ").replace( rclass, " " );
moel@348
  2306
						for ( c = 0, cl = classNames.length; c < cl; c++ ) {
moel@348
  2307
							className = className.replace(" " + classNames[ c ] + " ", " ");
moel@348
  2308
						}
moel@348
  2309
						elem.className = jQuery.trim( className );
moel@348
  2310
moel@348
  2311
					} else {
moel@348
  2312
						elem.className = "";
moel@348
  2313
					}
moel@348
  2314
				}
moel@348
  2315
			}
moel@348
  2316
		}
moel@348
  2317
moel@348
  2318
		return this;
moel@348
  2319
	},
moel@348
  2320
moel@348
  2321
	toggleClass: function( value, stateVal ) {
moel@348
  2322
		var type = typeof value,
moel@348
  2323
			isBool = typeof stateVal === "boolean";
moel@348
  2324
moel@348
  2325
		if ( jQuery.isFunction( value ) ) {
moel@348
  2326
			return this.each(function( i ) {
moel@348
  2327
				jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
moel@348
  2328
			});
moel@348
  2329
		}
moel@348
  2330
moel@348
  2331
		return this.each(function() {
moel@348
  2332
			if ( type === "string" ) {
moel@348
  2333
				// toggle individual class names
moel@348
  2334
				var className,
moel@348
  2335
					i = 0,
moel@348
  2336
					self = jQuery( this ),
moel@348
  2337
					state = stateVal,
moel@348
  2338
					classNames = value.split( rspace );
moel@348
  2339
moel@348
  2340
				while ( (className = classNames[ i++ ]) ) {
moel@348
  2341
					// check each className given, space seperated list
moel@348
  2342
					state = isBool ? state : !self.hasClass( className );
moel@348
  2343
					self[ state ? "addClass" : "removeClass" ]( className );
moel@348
  2344
				}
moel@348
  2345
moel@348
  2346
			} else if ( type === "undefined" || type === "boolean" ) {
moel@348
  2347
				if ( this.className ) {
moel@348
  2348
					// store className if set
moel@348
  2349
					jQuery._data( this, "__className__", this.className );
moel@348
  2350
				}
moel@348
  2351
moel@348
  2352
				// toggle whole className
moel@348
  2353
				this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
moel@348
  2354
			}
moel@348
  2355
		});
moel@348
  2356
	},
moel@348
  2357
moel@348
  2358
	hasClass: function( selector ) {
moel@348
  2359
		var className = " " + selector + " ",
moel@348
  2360
			i = 0,
moel@348
  2361
			l = this.length;
moel@348
  2362
		for ( ; i < l; i++ ) {
moel@348
  2363
			if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
moel@348
  2364
				return true;
moel@348
  2365
			}
moel@348
  2366
		}
moel@348
  2367
moel@348
  2368
		return false;
moel@348
  2369
	},
moel@348
  2370
moel@348
  2371
	val: function( value ) {
moel@348
  2372
		var hooks, ret, isFunction,
moel@348
  2373
			elem = this[0];
moel@348
  2374
moel@348
  2375
		if ( !arguments.length ) {
moel@348
  2376
			if ( elem ) {
moel@348
  2377
				hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ];
moel@348
  2378
moel@348
  2379
				if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
moel@348
  2380
					return ret;
moel@348
  2381
				}
moel@348
  2382
moel@348
  2383
				ret = elem.value;
moel@348
  2384
moel@348
  2385
				return typeof ret === "string" ?
moel@348
  2386
					// handle most common string cases
moel@348
  2387
					ret.replace(rreturn, "") :
moel@348
  2388
					// handle cases where value is null/undef or number
moel@348
  2389
					ret == null ? "" : ret;
moel@348
  2390
			}
moel@348
  2391
moel@348
  2392
			return;
moel@348
  2393
		}
moel@348
  2394
moel@348
  2395
		isFunction = jQuery.isFunction( value );
moel@348
  2396
moel@348
  2397
		return this.each(function( i ) {
moel@348
  2398
			var self = jQuery(this), val;
moel@348
  2399
moel@348
  2400
			if ( this.nodeType !== 1 ) {
moel@348
  2401
				return;
moel@348
  2402
			}
moel@348
  2403
moel@348
  2404
			if ( isFunction ) {
moel@348
  2405
				val = value.call( this, i, self.val() );
moel@348
  2406
			} else {
moel@348
  2407
				val = value;
moel@348
  2408
			}
moel@348
  2409
moel@348
  2410
			// Treat null/undefined as ""; convert numbers to string
moel@348
  2411
			if ( val == null ) {
moel@348
  2412
				val = "";
moel@348
  2413
			} else if ( typeof val === "number" ) {
moel@348
  2414
				val += "";
moel@348
  2415
			} else if ( jQuery.isArray( val ) ) {
moel@348
  2416
				val = jQuery.map(val, function ( value ) {
moel@348
  2417
					return value == null ? "" : value + "";
moel@348
  2418
				});
moel@348
  2419
			}
moel@348
  2420
moel@348
  2421
			hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
moel@348
  2422
moel@348
  2423
			// If set returns undefined, fall back to normal setting
moel@348
  2424
			if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
moel@348
  2425
				this.value = val;
moel@348
  2426
			}
moel@348
  2427
		});
moel@348
  2428
	}
moel@348
  2429
});
moel@348
  2430
moel@348
  2431
jQuery.extend({
moel@348
  2432
	valHooks: {
moel@348
  2433
		option: {
moel@348
  2434
			get: function( elem ) {
moel@348
  2435
				// attributes.value is undefined in Blackberry 4.7 but
moel@348
  2436
				// uses .value. See #6932
moel@348
  2437
				var val = elem.attributes.value;
moel@348
  2438
				return !val || val.specified ? elem.value : elem.text;
moel@348
  2439
			}
moel@348
  2440
		},
moel@348
  2441
		select: {
moel@348
  2442
			get: function( elem ) {
moel@348
  2443
				var value, i, max, option,
moel@348
  2444
					index = elem.selectedIndex,
moel@348
  2445
					values = [],
moel@348
  2446
					options = elem.options,
moel@348
  2447
					one = elem.type === "select-one";
moel@348
  2448
moel@348
  2449
				// Nothing was selected
moel@348
  2450
				if ( index < 0 ) {
moel@348
  2451
					return null;
moel@348
  2452
				}
moel@348
  2453
moel@348
  2454
				// Loop through all the selected options
moel@348
  2455
				i = one ? index : 0;
moel@348
  2456
				max = one ? index + 1 : options.length;
moel@348
  2457
				for ( ; i < max; i++ ) {
moel@348
  2458
					option = options[ i ];
moel@348
  2459
moel@348
  2460
					// Don't return options that are disabled or in a disabled optgroup
moel@348
  2461
					if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) &&
moel@348
  2462
							(!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) {
moel@348
  2463
moel@348
  2464
						// Get the specific value for the option
moel@348
  2465
						value = jQuery( option ).val();
moel@348
  2466
moel@348
  2467
						// We don't need an array for one selects
moel@348
  2468
						if ( one ) {
moel@348
  2469
							return value;
moel@348
  2470
						}
moel@348
  2471
moel@348
  2472
						// Multi-Selects return an array
moel@348
  2473
						values.push( value );
moel@348
  2474
					}
moel@348
  2475
				}
moel@348
  2476
moel@348
  2477
				// Fixes Bug #2551 -- select.val() broken in IE after form.reset()
moel@348
  2478
				if ( one && !values.length && options.length ) {
moel@348
  2479
					return jQuery( options[ index ] ).val();
moel@348
  2480
				}
moel@348
  2481
moel@348
  2482
				return values;
moel@348
  2483
			},
moel@348
  2484
moel@348
  2485
			set: function( elem, value ) {
moel@348
  2486
				var values = jQuery.makeArray( value );
moel@348
  2487
moel@348
  2488
				jQuery(elem).find("option").each(function() {
moel@348
  2489
					this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
moel@348
  2490
				});
moel@348
  2491
moel@348
  2492
				if ( !values.length ) {
moel@348
  2493
					elem.selectedIndex = -1;
moel@348
  2494
				}
moel@348
  2495
				return values;
moel@348
  2496
			}
moel@348
  2497
		}
moel@348
  2498
	},
moel@348
  2499
moel@348
  2500
	attrFn: {
moel@348
  2501
		val: true,
moel@348
  2502
		css: true,
moel@348
  2503
		html: true,
moel@348
  2504
		text: true,
moel@348
  2505
		data: true,
moel@348
  2506
		width: true,
moel@348
  2507
		height: true,
moel@348
  2508
		offset: true
moel@348
  2509
	},
moel@348
  2510
moel@348
  2511
	attr: function( elem, name, value, pass ) {
moel@348
  2512
		var ret, hooks, notxml,
moel@348
  2513
			nType = elem.nodeType;
moel@348
  2514
moel@348
  2515
		// don't get/set attributes on text, comment and attribute nodes
moel@348
  2516
		if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
moel@348
  2517
			return;
moel@348
  2518
		}
moel@348
  2519
moel@348
  2520
		if ( pass && name in jQuery.attrFn ) {
moel@348
  2521
			return jQuery( elem )[ name ]( value );
moel@348
  2522
		}
moel@348
  2523
moel@348
  2524
		// Fallback to prop when attributes are not supported
moel@348
  2525
		if ( typeof elem.getAttribute === "undefined" ) {
moel@348
  2526
			return jQuery.prop( elem, name, value );
moel@348
  2527
		}
moel@348
  2528
moel@348
  2529
		notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
moel@348
  2530
moel@348
  2531
		// All attributes are lowercase
moel@348
  2532
		// Grab necessary hook if one is defined
moel@348
  2533
		if ( notxml ) {
moel@348
  2534
			name = name.toLowerCase();
moel@348
  2535
			hooks = jQuery.attrHooks[ name ] || ( rboolean.test( name ) ? boolHook : nodeHook );
moel@348
  2536
		}
moel@348
  2537
moel@348
  2538
		if ( value !== undefined ) {
moel@348
  2539
moel@348
  2540
			if ( value === null ) {
moel@348
  2541
				jQuery.removeAttr( elem, name );
moel@348
  2542
				return;
moel@348
  2543
moel@348
  2544
			} else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) {
moel@348
  2545
				return ret;
moel@348
  2546
moel@348
  2547
			} else {
moel@348
  2548
				elem.setAttribute( name, "" + value );
moel@348
  2549
				return value;
moel@348
  2550
			}
moel@348
  2551
moel@348
  2552
		} else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) !== null ) {
moel@348
  2553
			return ret;
moel@348
  2554
moel@348
  2555
		} else {
moel@348
  2556
moel@348
  2557
			ret = elem.getAttribute( name );
moel@348
  2558
moel@348
  2559
			// Non-existent attributes return null, we normalize to undefined
moel@348
  2560
			return ret === null ?
moel@348
  2561
				undefined :
moel@348
  2562
				ret;
moel@348
  2563
		}
moel@348
  2564
	},
moel@348
  2565
moel@348
  2566
	removeAttr: function( elem, value ) {
moel@348
  2567
		var propName, attrNames, name, l, isBool,
moel@348
  2568
			i = 0;
moel@348
  2569
moel@348
  2570
		if ( value && elem.nodeType === 1 ) {
moel@348
  2571
			attrNames = value.toLowerCase().split( rspace );
moel@348
  2572
			l = attrNames.length;
moel@348
  2573
moel@348
  2574
			for ( ; i < l; i++ ) {
moel@348
  2575
				name = attrNames[ i ];
moel@348
  2576
moel@348
  2577
				if ( name ) {
moel@348
  2578
					propName = jQuery.propFix[ name ] || name;
moel@348
  2579
					isBool = rboolean.test( name );
moel@348
  2580
moel@348
  2581
					// See #9699 for explanation of this approach (setting first, then removal)
moel@348
  2582
					// Do not do this for boolean attributes (see #10870)
moel@348
  2583
					if ( !isBool ) {
moel@348
  2584
						jQuery.attr( elem, name, "" );
moel@348
  2585
					}
moel@348
  2586
					elem.removeAttribute( getSetAttribute ? name : propName );
moel@348
  2587
moel@348
  2588
					// Set corresponding property to false for boolean attributes
moel@348
  2589
					if ( isBool && propName in elem ) {
moel@348
  2590
						elem[ propName ] = false;
moel@348
  2591
					}
moel@348
  2592
				}
moel@348
  2593
			}
moel@348
  2594
		}
moel@348
  2595
	},
moel@348
  2596
moel@348
  2597
	attrHooks: {
moel@348
  2598
		type: {
moel@348
  2599
			set: function( elem, value ) {
moel@348
  2600
				// We can't allow the type property to be changed (since it causes problems in IE)
moel@348
  2601
				if ( rtype.test( elem.nodeName ) && elem.parentNode ) {
moel@348
  2602
					jQuery.error( "type property can't be changed" );
moel@348
  2603
				} else if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
moel@348
  2604
					// Setting the type on a radio button after the value resets the value in IE6-9
moel@348
  2605
					// Reset value to it's default in case type is set after value
moel@348
  2606
					// This is for element creation
moel@348
  2607
					var val = elem.value;
moel@348
  2608
					elem.setAttribute( "type", value );
moel@348
  2609
					if ( val ) {
moel@348
  2610
						elem.value = val;
moel@348
  2611
					}
moel@348
  2612
					return value;
moel@348
  2613
				}
moel@348
  2614
			}
moel@348
  2615
		},
moel@348
  2616
		// Use the value property for back compat
moel@348
  2617
		// Use the nodeHook for button elements in IE6/7 (#1954)
moel@348
  2618
		value: {
moel@348
  2619
			get: function( elem, name ) {
moel@348
  2620
				if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
moel@348
  2621
					return nodeHook.get( elem, name );
moel@348
  2622
				}
moel@348
  2623
				return name in elem ?
moel@348
  2624
					elem.value :
moel@348
  2625
					null;
moel@348
  2626
			},
moel@348
  2627
			set: function( elem, value, name ) {
moel@348
  2628
				if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
moel@348
  2629
					return nodeHook.set( elem, value, name );
moel@348
  2630
				}
moel@348
  2631
				// Does not return so that setAttribute is also used
moel@348
  2632
				elem.value = value;
moel@348
  2633
			}
moel@348
  2634
		}
moel@348
  2635
	},
moel@348
  2636
moel@348
  2637
	propFix: {
moel@348
  2638
		tabindex: "tabIndex",
moel@348
  2639
		readonly: "readOnly",
moel@348
  2640
		"for": "htmlFor",
moel@348
  2641
		"class": "className",
moel@348
  2642
		maxlength: "maxLength",
moel@348
  2643
		cellspacing: "cellSpacing",
moel@348
  2644
		cellpadding: "cellPadding",
moel@348
  2645
		rowspan: "rowSpan",
moel@348
  2646
		colspan: "colSpan",
moel@348
  2647
		usemap: "useMap",
moel@348
  2648
		frameborder: "frameBorder",
moel@348
  2649
		contenteditable: "contentEditable"
moel@348
  2650
	},
moel@348
  2651
moel@348
  2652
	prop: function( elem, name, value ) {
moel@348
  2653
		var ret, hooks, notxml,
moel@348
  2654
			nType = elem.nodeType;
moel@348
  2655
moel@348
  2656
		// don't get/set properties on text, comment and attribute nodes
moel@348
  2657
		if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
moel@348
  2658
			return;
moel@348
  2659
		}
moel@348
  2660
moel@348
  2661
		notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
moel@348
  2662
moel@348
  2663
		if ( notxml ) {
moel@348
  2664
			// Fix name and attach hooks
moel@348
  2665
			name = jQuery.propFix[ name ] || name;
moel@348
  2666
			hooks = jQuery.propHooks[ name ];
moel@348
  2667
		}
moel@348
  2668
moel@348
  2669
		if ( value !== undefined ) {
moel@348
  2670
			if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
moel@348
  2671
				return ret;
moel@348
  2672
moel@348
  2673
			} else {
moel@348
  2674
				return ( elem[ name ] = value );
moel@348
  2675
			}
moel@348
  2676
moel@348
  2677
		} else {
moel@348
  2678
			if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
moel@348
  2679
				return ret;
moel@348
  2680
moel@348
  2681
			} else {
moel@348
  2682
				return elem[ name ];
moel@348
  2683
			}
moel@348
  2684
		}
moel@348
  2685
	},
moel@348
  2686
moel@348
  2687
	propHooks: {
moel@348
  2688
		tabIndex: {
moel@348
  2689
			get: function( elem ) {
moel@348
  2690
				// elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
moel@348
  2691
				// http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
moel@348
  2692
				var attributeNode = elem.getAttributeNode("tabindex");
moel@348
  2693
moel@348
  2694
				return attributeNode && attributeNode.specified ?
moel@348
  2695
					parseInt( attributeNode.value, 10 ) :
moel@348
  2696
					rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
moel@348
  2697
						0 :
moel@348
  2698
						undefined;
moel@348
  2699
			}
moel@348
  2700
		}
moel@348
  2701
	}
moel@348
  2702
});
moel@348
  2703
moel@348
  2704
// Add the tabIndex propHook to attrHooks for back-compat (different case is intentional)
moel@348
  2705
jQuery.attrHooks.tabindex = jQuery.propHooks.tabIndex;
moel@348
  2706
moel@348
  2707
// Hook for boolean attributes
moel@348
  2708
boolHook = {
moel@348
  2709
	get: function( elem, name ) {
moel@348
  2710
		// Align boolean attributes with corresponding properties
moel@348
  2711
		// Fall back to attribute presence where some booleans are not supported
moel@348
  2712
		var attrNode,
moel@348
  2713
			property = jQuery.prop( elem, name );
moel@348
  2714
		return property === true || typeof property !== "boolean" && ( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ?
moel@348
  2715
			name.toLowerCase() :
moel@348
  2716
			undefined;
moel@348
  2717
	},
moel@348
  2718
	set: function( elem, value, name ) {
moel@348
  2719
		var propName;
moel@348
  2720
		if ( value === false ) {
moel@348
  2721
			// Remove boolean attributes when set to false
moel@348
  2722
			jQuery.removeAttr( elem, name );
moel@348
  2723
		} else {
moel@348
  2724
			// value is true since we know at this point it's type boolean and not false
moel@348
  2725
			// Set boolean attributes to the same name and set the DOM property
moel@348
  2726
			propName = jQuery.propFix[ name ] || name;
moel@348
  2727
			if ( propName in elem ) {
moel@348
  2728
				// Only set the IDL specifically if it already exists on the element
moel@348
  2729
				elem[ propName ] = true;
moel@348
  2730
			}
moel@348
  2731
moel@348
  2732
			elem.setAttribute( name, name.toLowerCase() );
moel@348
  2733
		}
moel@348
  2734
		return name;
moel@348
  2735
	}
moel@348
  2736
};
moel@348
  2737
moel@348
  2738
// IE6/7 do not support getting/setting some attributes with get/setAttribute
moel@348
  2739
if ( !getSetAttribute ) {
moel@348
  2740
moel@348
  2741
	fixSpecified = {
moel@348
  2742
		name: true,
moel@348
  2743
		id: true,
moel@348
  2744
		coords: true
moel@348
  2745
	};
moel@348
  2746
moel@348
  2747
	// Use this for any attribute in IE6/7
moel@348
  2748
	// This fixes almost every IE6/7 issue
moel@348
  2749
	nodeHook = jQuery.valHooks.button = {
moel@348
  2750
		get: function( elem, name ) {
moel@348
  2751
			var ret;
moel@348
  2752
			ret = elem.getAttributeNode( name );
moel@348
  2753
			return ret && ( fixSpecified[ name ] ? ret.nodeValue !== "" : ret.specified ) ?
moel@348
  2754
				ret.nodeValue :
moel@348
  2755
				undefined;
moel@348
  2756
		},
moel@348
  2757
		set: function( elem, value, name ) {
moel@348
  2758
			// Set the existing or create a new attribute node
moel@348
  2759
			var ret = elem.getAttributeNode( name );
moel@348
  2760
			if ( !ret ) {
moel@348
  2761
				ret = document.createAttribute( name );
moel@348
  2762
				elem.setAttributeNode( ret );
moel@348
  2763
			}
moel@348
  2764
			return ( ret.nodeValue = value + "" );
moel@348
  2765
		}
moel@348
  2766
	};
moel@348
  2767
moel@348
  2768
	// Apply the nodeHook to tabindex
moel@348
  2769
	jQuery.attrHooks.tabindex.set = nodeHook.set;
moel@348
  2770
moel@348
  2771
	// Set width and height to auto instead of 0 on empty string( Bug #8150 )
moel@348
  2772
	// This is for removals
moel@348
  2773
	jQuery.each([ "width", "height" ], function( i, name ) {
moel@348
  2774
		jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
moel@348
  2775
			set: function( elem, value ) {
moel@348
  2776
				if ( value === "" ) {
moel@348
  2777
					elem.setAttribute( name, "auto" );
moel@348
  2778
					return value;
moel@348
  2779
				}
moel@348
  2780
			}
moel@348
  2781
		});
moel@348
  2782
	});
moel@348
  2783
moel@348
  2784
	// Set contenteditable to false on removals(#10429)
moel@348
  2785
	// Setting to empty string throws an error as an invalid value
moel@348
  2786
	jQuery.attrHooks.contenteditable = {
moel@348
  2787
		get: nodeHook.get,
moel@348
  2788
		set: function( elem, value, name ) {
moel@348
  2789
			if ( value === "" ) {
moel@348
  2790
				value = "false";
moel@348
  2791
			}
moel@348
  2792
			nodeHook.set( elem, value, name );
moel@348
  2793
		}
moel@348
  2794
	};
moel@348
  2795
}
moel@348
  2796
moel@348
  2797
moel@348
  2798
// Some attributes require a special call on IE
moel@348
  2799
if ( !jQuery.support.hrefNormalized ) {
moel@348
  2800
	jQuery.each([ "href", "src", "width", "height" ], function( i, name ) {
moel@348
  2801
		jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
moel@348
  2802
			get: function( elem ) {
moel@348
  2803
				var ret = elem.getAttribute( name, 2 );
moel@348
  2804
				return ret === null ? undefined : ret;
moel@348
  2805
			}
moel@348
  2806
		});
moel@348
  2807
	});
moel@348
  2808
}
moel@348
  2809
moel@348
  2810
if ( !jQuery.support.style ) {
moel@348
  2811
	jQuery.attrHooks.style = {
moel@348
  2812
		get: function( elem ) {
moel@348
  2813
			// Return undefined in the case of empty string
moel@348
  2814
			// Normalize to lowercase since IE uppercases css property names
moel@348
  2815
			return elem.style.cssText.toLowerCase() || undefined;
moel@348
  2816
		},
moel@348
  2817
		set: function( elem, value ) {
moel@348
  2818
			return ( elem.style.cssText = "" + value );
moel@348
  2819
		}
moel@348
  2820
	};
moel@348
  2821
}
moel@348
  2822
moel@348
  2823
// Safari mis-reports the default selected property of an option
moel@348
  2824
// Accessing the parent's selectedIndex property fixes it
moel@348
  2825
if ( !jQuery.support.optSelected ) {
moel@348
  2826
	jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, {
moel@348
  2827
		get: function( elem ) {
moel@348
  2828
			var parent = elem.parentNode;
moel@348
  2829
moel@348
  2830
			if ( parent ) {
moel@348
  2831
				parent.selectedIndex;
moel@348
  2832
moel@348
  2833
				// Make sure that it also works with optgroups, see #5701
moel@348
  2834
				if ( parent.parentNode ) {
moel@348
  2835
					parent.parentNode.selectedIndex;
moel@348
  2836
				}
moel@348
  2837
			}
moel@348
  2838
			return null;
moel@348
  2839
		}
moel@348
  2840
	});
moel@348
  2841
}
moel@348
  2842
moel@348
  2843
// IE6/7 call enctype encoding
moel@348
  2844
if ( !jQuery.support.enctype ) {
moel@348
  2845
	jQuery.propFix.enctype = "encoding";
moel@348
  2846
}
moel@348
  2847
moel@348
  2848
// Radios and checkboxes getter/setter
moel@348
  2849
if ( !jQuery.support.checkOn ) {
moel@348
  2850
	jQuery.each([ "radio", "checkbox" ], function() {
moel@348
  2851
		jQuery.valHooks[ this ] = {
moel@348
  2852
			get: function( elem ) {
moel@348
  2853
				// Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
moel@348
  2854
				return elem.getAttribute("value") === null ? "on" : elem.value;
moel@348
  2855
			}
moel@348
  2856
		};
moel@348
  2857
	});
moel@348
  2858
}
moel@348
  2859
jQuery.each([ "radio", "checkbox" ], function() {
moel@348
  2860
	jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], {
moel@348
  2861
		set: function( elem, value ) {
moel@348
  2862
			if ( jQuery.isArray( value ) ) {
moel@348
  2863
				return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );
moel@348
  2864
			}
moel@348
  2865
		}
moel@348
  2866
	});
moel@348
  2867
});
moel@348
  2868
moel@348
  2869
moel@348
  2870
moel@348
  2871
moel@348
  2872
var rformElems = /^(?:textarea|input|select)$/i,
moel@348
  2873
	rtypenamespace = /^([^\.]*)?(?:\.(.+))?$/,
moel@348
  2874
	rhoverHack = /(?:^|\s)hover(\.\S+)?\b/,
moel@348
  2875
	rkeyEvent = /^key/,
moel@348
  2876
	rmouseEvent = /^(?:mouse|contextmenu)|click/,
moel@348
  2877
	rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
moel@348
  2878
	rquickIs = /^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/,
moel@348
  2879
	quickParse = function( selector ) {
moel@348
  2880
		var quick = rquickIs.exec( selector );
moel@348
  2881
		if ( quick ) {
moel@348
  2882
			//   0  1    2   3
moel@348
  2883
			// [ _, tag, id, class ]
moel@348
  2884
			quick[1] = ( quick[1] || "" ).toLowerCase();
moel@348
  2885
			quick[3] = quick[3] && new RegExp( "(?:^|\\s)" + quick[3] + "(?:\\s|$)" );
moel@348
  2886
		}
moel@348
  2887
		return quick;
moel@348
  2888
	},
moel@348
  2889
	quickIs = function( elem, m ) {
moel@348
  2890
		var attrs = elem.attributes || {};
moel@348
  2891
		return (
moel@348
  2892
			(!m[1] || elem.nodeName.toLowerCase() === m[1]) &&
moel@348
  2893
			(!m[2] || (attrs.id || {}).value === m[2]) &&
moel@348
  2894
			(!m[3] || m[3].test( (attrs[ "class" ] || {}).value ))
moel@348
  2895
		);
moel@348
  2896
	},
moel@348
  2897
	hoverHack = function( events ) {
moel@348
  2898
		return jQuery.event.special.hover ? events : events.replace( rhoverHack, "mouseenter$1 mouseleave$1" );
moel@348
  2899
	};
moel@348
  2900
moel@348
  2901
/*
moel@348
  2902
 * Helper functions for managing events -- not part of the public interface.
moel@348
  2903
 * Props to Dean Edwards' addEvent library for many of the ideas.
moel@348
  2904
 */
moel@348
  2905
jQuery.event = {
moel@348
  2906
moel@348
  2907
	add: function( elem, types, handler, data, selector ) {
moel@348
  2908
moel@348
  2909
		var elemData, eventHandle, events,
moel@348
  2910
			t, tns, type, namespaces, handleObj,
moel@348
  2911
			handleObjIn, quick, handlers, special;
moel@348
  2912
moel@348
  2913
		// Don't attach events to noData or text/comment nodes (allow plain objects tho)
moel@348
  2914
		if ( elem.nodeType === 3 || elem.nodeType === 8 || !types || !handler || !(elemData = jQuery._data( elem )) ) {
moel@348
  2915
			return;
moel@348
  2916
		}
moel@348
  2917
moel@348
  2918
		// Caller can pass in an object of custom data in lieu of the handler
moel@348
  2919
		if ( handler.handler ) {
moel@348
  2920
			handleObjIn = handler;
moel@348
  2921
			handler = handleObjIn.handler;
moel@348
  2922
			selector = handleObjIn.selector;
moel@348
  2923
		}
moel@348
  2924
moel@348
  2925
		// Make sure that the handler has a unique ID, used to find/remove it later
moel@348
  2926
		if ( !handler.guid ) {
moel@348
  2927
			handler.guid = jQuery.guid++;
moel@348
  2928
		}
moel@348
  2929
moel@348
  2930
		// Init the element's event structure and main handler, if this is the first
moel@348
  2931
		events = elemData.events;
moel@348
  2932
		if ( !events ) {
moel@348
  2933
			elemData.events = events = {};
moel@348
  2934
		}
moel@348
  2935
		eventHandle = elemData.handle;
moel@348
  2936
		if ( !eventHandle ) {
moel@348
  2937
			elemData.handle = eventHandle = function( e ) {
moel@348
  2938
				// Discard the second event of a jQuery.event.trigger() and
moel@348
  2939
				// when an event is called after a page has unloaded
moel@348
  2940
				return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ?
moel@348
  2941
					jQuery.event.dispatch.apply( eventHandle.elem, arguments ) :
moel@348
  2942
					undefined;
moel@348
  2943
			};
moel@348
  2944
			// Add elem as a property of the handle fn to prevent a memory leak with IE non-native events
moel@348
  2945
			eventHandle.elem = elem;
moel@348
  2946
		}
moel@348
  2947
moel@348
  2948
		// Handle multiple events separated by a space
moel@348
  2949
		// jQuery(...).bind("mouseover mouseout", fn);
moel@348
  2950
		types = jQuery.trim( hoverHack(types) ).split( " " );
moel@348
  2951
		for ( t = 0; t < types.length; t++ ) {
moel@348
  2952
moel@348
  2953
			tns = rtypenamespace.exec( types[t] ) || [];
moel@348
  2954
			type = tns[1];
moel@348
  2955
			namespaces = ( tns[2] || "" ).split( "." ).sort();
moel@348
  2956
moel@348
  2957
			// If event changes its type, use the special event handlers for the changed type
moel@348
  2958
			special = jQuery.event.special[ type ] || {};
moel@348
  2959
moel@348
  2960
			// If selector defined, determine special event api type, otherwise given type
moel@348
  2961
			type = ( selector ? special.delegateType : special.bindType ) || type;
moel@348
  2962
moel@348
  2963
			// Update special based on newly reset type
moel@348
  2964
			special = jQuery.event.special[ type ] || {};
moel@348
  2965
moel@348
  2966
			// handleObj is passed to all event handlers
moel@348
  2967
			handleObj = jQuery.extend({
moel@348
  2968
				type: type,
moel@348
  2969
				origType: tns[1],
moel@348
  2970
				data: data,
moel@348
  2971
				handler: handler,
moel@348
  2972
				guid: handler.guid,
moel@348
  2973
				selector: selector,
moel@348
  2974
				quick: selector && quickParse( selector ),
moel@348
  2975
				namespace: namespaces.join(".")
moel@348
  2976
			}, handleObjIn );
moel@348
  2977
moel@348
  2978
			// Init the event handler queue if we're the first
moel@348
  2979
			handlers = events[ type ];
moel@348
  2980
			if ( !handlers ) {
moel@348
  2981
				handlers = events[ type ] = [];
moel@348
  2982
				handlers.delegateCount = 0;
moel@348
  2983
moel@348
  2984
				// Only use addEventListener/attachEvent if the special events handler returns false
moel@348
  2985
				if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
moel@348
  2986
					// Bind the global event handler to the element
moel@348
  2987
					if ( elem.addEventListener ) {
moel@348
  2988
						elem.addEventListener( type, eventHandle, false );
moel@348
  2989
moel@348
  2990
					} else if ( elem.attachEvent ) {
moel@348
  2991
						elem.attachEvent( "on" + type, eventHandle );
moel@348
  2992
					}
moel@348
  2993
				}
moel@348
  2994
			}
moel@348
  2995
moel@348
  2996
			if ( special.add ) {
moel@348
  2997
				special.add.call( elem, handleObj );
moel@348
  2998
moel@348
  2999
				if ( !handleObj.handler.guid ) {
moel@348
  3000
					handleObj.handler.guid = handler.guid;
moel@348
  3001
				}
moel@348
  3002
			}
moel@348
  3003
moel@348
  3004
			// Add to the element's handler list, delegates in front
moel@348
  3005
			if ( selector ) {
moel@348
  3006
				handlers.splice( handlers.delegateCount++, 0, handleObj );
moel@348
  3007
			} else {
moel@348
  3008
				handlers.push( handleObj );
moel@348
  3009
			}
moel@348
  3010
moel@348
  3011
			// Keep track of which events have ever been used, for event optimization
moel@348
  3012
			jQuery.event.global[ type ] = true;
moel@348
  3013
		}
moel@348
  3014
moel@348
  3015
		// Nullify elem to prevent memory leaks in IE
moel@348
  3016
		elem = null;
moel@348
  3017
	},
moel@348
  3018
moel@348
  3019
	global: {},
moel@348
  3020
moel@348
  3021
	// Detach an event or set of events from an element
moel@348
  3022
	remove: function( elem, types, handler, selector, mappedTypes ) {
moel@348
  3023
moel@348
  3024
		var elemData = jQuery.hasData( elem ) && jQuery._data( elem ),
moel@348
  3025
			t, tns, type, origType, namespaces, origCount,
moel@348
  3026
			j, events, special, handle, eventType, handleObj;
moel@348
  3027
moel@348
  3028
		if ( !elemData || !(events = elemData.events) ) {
moel@348
  3029
			return;
moel@348
  3030
		}
moel@348
  3031
moel@348
  3032
		// Once for each type.namespace in types; type may be omitted
moel@348
  3033
		types = jQuery.trim( hoverHack( types || "" ) ).split(" ");
moel@348
  3034
		for ( t = 0; t < types.length; t++ ) {
moel@348
  3035
			tns = rtypenamespace.exec( types[t] ) || [];
moel@348
  3036
			type = origType = tns[1];
moel@348
  3037
			namespaces = tns[2];
moel@348
  3038
moel@348
  3039
			// Unbind all events (on this namespace, if provided) for the element
moel@348
  3040
			if ( !type ) {
moel@348
  3041
				for ( type in events ) {
moel@348
  3042
					jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
moel@348
  3043
				}
moel@348
  3044
				continue;
moel@348
  3045
			}
moel@348
  3046
moel@348
  3047
			special = jQuery.event.special[ type ] || {};
moel@348
  3048
			type = ( selector? special.delegateType : special.bindType ) || type;
moel@348
  3049
			eventType = events[ type ] || [];
moel@348
  3050
			origCount = eventType.length;
moel@348
  3051
			namespaces = namespaces ? new RegExp("(^|\\.)" + namespaces.split(".").sort().join("\\.(?:.*\\.)?") + "(\\.|$)") : null;
moel@348
  3052
moel@348
  3053
			// Remove matching events
moel@348
  3054
			for ( j = 0; j < eventType.length; j++ ) {
moel@348
  3055
				handleObj = eventType[ j ];
moel@348
  3056
moel@348
  3057
				if ( ( mappedTypes || origType === handleObj.origType ) &&
moel@348
  3058
					 ( !handler || handler.guid === handleObj.guid ) &&
moel@348
  3059
					 ( !namespaces || namespaces.test( handleObj.namespace ) ) &&
moel@348
  3060
					 ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
moel@348
  3061
					eventType.splice( j--, 1 );
moel@348
  3062
moel@348
  3063
					if ( handleObj.selector ) {
moel@348
  3064
						eventType.delegateCount--;
moel@348
  3065
					}
moel@348
  3066
					if ( special.remove ) {
moel@348
  3067
						special.remove.call( elem, handleObj );
moel@348
  3068
					}
moel@348
  3069
				}
moel@348
  3070
			}
moel@348
  3071
moel@348
  3072
			// Remove generic event handler if we removed something and no more handlers exist
moel@348
  3073
			// (avoids potential for endless recursion during removal of special event handlers)
moel@348
  3074
			if ( eventType.length === 0 && origCount !== eventType.length ) {
moel@348
  3075
				if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) {
moel@348
  3076
					jQuery.removeEvent( elem, type, elemData.handle );
moel@348
  3077
				}
moel@348
  3078
moel@348
  3079
				delete events[ type ];
moel@348
  3080
			}
moel@348
  3081
		}
moel@348
  3082
moel@348
  3083
		// Remove the expando if it's no longer used
moel@348
  3084
		if ( jQuery.isEmptyObject( events ) ) {
moel@348
  3085
			handle = elemData.handle;
moel@348
  3086
			if ( handle ) {
moel@348
  3087
				handle.elem = null;
moel@348
  3088
			}
moel@348
  3089
moel@348
  3090
			// removeData also checks for emptiness and clears the expando if empty
moel@348
  3091
			// so use it instead of delete
moel@348
  3092
			jQuery.removeData( elem, [ "events", "handle" ], true );
moel@348
  3093
		}
moel@348
  3094
	},
moel@348
  3095
moel@348
  3096
	// Events that are safe to short-circuit if no handlers are attached.
moel@348
  3097
	// Native DOM events should not be added, they may have inline handlers.
moel@348
  3098
	customEvent: {
moel@348
  3099
		"getData": true,
moel@348
  3100
		"setData": true,
moel@348
  3101
		"changeData": true
moel@348
  3102
	},
moel@348
  3103
moel@348
  3104
	trigger: function( event, data, elem, onlyHandlers ) {
moel@348
  3105
		// Don't do events on text and comment nodes
moel@348
  3106
		if ( elem && (elem.nodeType === 3 || elem.nodeType === 8) ) {
moel@348
  3107
			return;
moel@348
  3108
		}
moel@348
  3109
moel@348
  3110
		// Event object or event type
moel@348
  3111
		var type = event.type || event,
moel@348
  3112
			namespaces = [],
moel@348
  3113
			cache, exclusive, i, cur, old, ontype, special, handle, eventPath, bubbleType;
moel@348
  3114
moel@348
  3115
		// focus/blur morphs to focusin/out; ensure we're not firing them right now
moel@348
  3116
		if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
moel@348
  3117
			return;
moel@348
  3118
		}
moel@348
  3119
moel@348
  3120
		if ( type.indexOf( "!" ) >= 0 ) {
moel@348
  3121
			// Exclusive events trigger only for the exact event (no namespaces)
moel@348
  3122
			type = type.slice(0, -1);
moel@348
  3123
			exclusive = true;
moel@348
  3124
		}
moel@348
  3125
moel@348
  3126
		if ( type.indexOf( "." ) >= 0 ) {
moel@348
  3127
			// Namespaced trigger; create a regexp to match event type in handle()
moel@348
  3128
			namespaces = type.split(".");
moel@348
  3129
			type = namespaces.shift();
moel@348
  3130
			namespaces.sort();
moel@348
  3131
		}
moel@348
  3132
moel@348
  3133
		if ( (!elem || jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ] ) {
moel@348
  3134
			// No jQuery handlers for this event type, and it can't have inline handlers
moel@348
  3135
			return;
moel@348
  3136
		}
moel@348
  3137
moel@348
  3138
		// Caller can pass in an Event, Object, or just an event type string
moel@348
  3139
		event = typeof event === "object" ?
moel@348
  3140
			// jQuery.Event object
moel@348
  3141
			event[ jQuery.expando ] ? event :
moel@348
  3142
			// Object literal
moel@348
  3143
			new jQuery.Event( type, event ) :
moel@348
  3144
			// Just the event type (string)
moel@348
  3145
			new jQuery.Event( type );
moel@348
  3146
moel@348
  3147
		event.type = type;
moel@348
  3148
		event.isTrigger = true;
moel@348
  3149
		event.exclusive = exclusive;
moel@348
  3150
		event.namespace = namespaces.join( "." );
moel@348
  3151
		event.namespace_re = event.namespace? new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)") : null;
moel@348
  3152
		ontype = type.indexOf( ":" ) < 0 ? "on" + type : "";
moel@348
  3153
moel@348
  3154
		// Handle a global trigger
moel@348
  3155
		if ( !elem ) {
moel@348
  3156
moel@348
  3157
			// TODO: Stop taunting the data cache; remove global events and always attach to document
moel@348
  3158
			cache = jQuery.cache;
moel@348
  3159
			for ( i in cache ) {
moel@348
  3160
				if ( cache[ i ].events && cache[ i ].events[ type ] ) {
moel@348
  3161
					jQuery.event.trigger( event, data, cache[ i ].handle.elem, true );
moel@348
  3162
				}
moel@348
  3163
			}
moel@348
  3164
			return;
moel@348
  3165
		}
moel@348
  3166
moel@348
  3167
		// Clean up the event in case it is being reused
moel@348
  3168
		event.result = undefined;
moel@348
  3169
		if ( !event.target ) {
moel@348
  3170
			event.target = elem;
moel@348
  3171
		}
moel@348
  3172
moel@348
  3173
		// Clone any incoming data and prepend the event, creating the handler arg list
moel@348
  3174
		data = data != null ? jQuery.makeArray( data ) : [];
moel@348
  3175
		data.unshift( event );
moel@348
  3176
moel@348
  3177
		// Allow special events to draw outside the lines
moel@348
  3178
		special = jQuery.event.special[ type ] || {};
moel@348
  3179
		if ( special.trigger && special.trigger.apply( elem, data ) === false ) {
moel@348
  3180
			return;
moel@348
  3181
		}
moel@348
  3182
moel@348
  3183
		// Determine event propagation path in advance, per W3C events spec (#9951)
moel@348
  3184
		// Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
moel@348
  3185
		eventPath = [[ elem, special.bindType || type ]];
moel@348
  3186
		if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
moel@348
  3187
moel@348
  3188
			bubbleType = special.delegateType || type;
moel@348
  3189
			cur = rfocusMorph.test( bubbleType + type ) ? elem : elem.parentNode;
moel@348
  3190
			old = null;
moel@348
  3191
			for ( ; cur; cur = cur.parentNode ) {
moel@348
  3192
				eventPath.push([ cur, bubbleType ]);
moel@348
  3193
				old = cur;
moel@348
  3194
			}
moel@348
  3195
moel@348
  3196
			// Only add window if we got to document (e.g., not plain obj or detached DOM)
moel@348
  3197
			if ( old && old === elem.ownerDocument ) {
moel@348
  3198
				eventPath.push([ old.defaultView || old.parentWindow || window, bubbleType ]);
moel@348
  3199
			}
moel@348
  3200
		}
moel@348
  3201
moel@348
  3202
		// Fire handlers on the event path
moel@348
  3203
		for ( i = 0; i < eventPath.length && !event.isPropagationStopped(); i++ ) {
moel@348
  3204
moel@348
  3205
			cur = eventPath[i][0];
moel@348
  3206
			event.type = eventPath[i][1];
moel@348
  3207
moel@348
  3208
			handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" );
moel@348
  3209
			if ( handle ) {
moel@348
  3210
				handle.apply( cur, data );
moel@348
  3211
			}
moel@348
  3212
			// Note that this is a bare JS function and not a jQuery handler
moel@348
  3213
			handle = ontype && cur[ ontype ];
moel@348
  3214
			if ( handle && jQuery.acceptData( cur ) && handle.apply( cur, data ) === false ) {
moel@348
  3215
				event.preventDefault();
moel@348
  3216
			}
moel@348
  3217
		}
moel@348
  3218
		event.type = type;
moel@348
  3219
moel@348
  3220
		// If nobody prevented the default action, do it now
moel@348
  3221
		if ( !onlyHandlers && !event.isDefaultPrevented() ) {
moel@348
  3222
moel@348
  3223
			if ( (!special._default || special._default.apply( elem.ownerDocument, data ) === false) &&
moel@348
  3224
				!(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) {
moel@348
  3225
moel@348
  3226
				// Call a native DOM method on the target with the same name name as the event.
moel@348
  3227
				// Can't use an .isFunction() check here because IE6/7 fails that test.
moel@348
  3228
				// Don't do default actions on window, that's where global variables be (#6170)
moel@348
  3229
				// IE<9 dies on focus/blur to hidden element (#1486)
moel@348
  3230
				if ( ontype && elem[ type ] && ((type !== "focus" && type !== "blur") || event.target.offsetWidth !== 0) && !jQuery.isWindow( elem ) ) {
moel@348
  3231
moel@348
  3232
					// Don't re-trigger an onFOO event when we call its FOO() method
moel@348
  3233
					old = elem[ ontype ];
moel@348
  3234
moel@348
  3235
					if ( old ) {
moel@348
  3236
						elem[ ontype ] = null;
moel@348
  3237
					}
moel@348
  3238
moel@348
  3239
					// Prevent re-triggering of the same event, since we already bubbled it above
moel@348
  3240
					jQuery.event.triggered = type;
moel@348
  3241
					elem[ type ]();
moel@348
  3242
					jQuery.event.triggered = undefined;
moel@348
  3243
moel@348
  3244
					if ( old ) {
moel@348
  3245
						elem[ ontype ] = old;
moel@348
  3246
					}
moel@348
  3247
				}
moel@348
  3248
			}
moel@348
  3249
		}
moel@348
  3250
moel@348
  3251
		return event.result;
moel@348
  3252
	},
moel@348
  3253
moel@348
  3254
	dispatch: function( event ) {
moel@348
  3255
moel@348
  3256
		// Make a writable jQuery.Event from the native event object
moel@348
  3257
		event = jQuery.event.fix( event || window.event );
moel@348
  3258
moel@348
  3259
		var handlers = ( (jQuery._data( this, "events" ) || {} )[ event.type ] || []),
moel@348
  3260
			delegateCount = handlers.delegateCount,
moel@348
  3261
			args = [].slice.call( arguments, 0 ),
moel@348
  3262
			run_all = !event.exclusive && !event.namespace,
moel@348
  3263
			special = jQuery.event.special[ event.type ] || {},
moel@348
  3264
			handlerQueue = [],
moel@348
  3265
			i, j, cur, jqcur, ret, selMatch, matched, matches, handleObj, sel, related;
moel@348
  3266
moel@348
  3267
		// Use the fix-ed jQuery.Event rather than the (read-only) native event
moel@348
  3268
		args[0] = event;
moel@348
  3269
		event.delegateTarget = this;
moel@348
  3270
moel@348
  3271
		// Call the preDispatch hook for the mapped type, and let it bail if desired
moel@348
  3272
		if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
moel@348
  3273
			return;
moel@348
  3274
		}
moel@348
  3275
moel@348
  3276
		// Determine handlers that should run if there are delegated events
moel@348
  3277
		// Avoid non-left-click bubbling in Firefox (#3861)
moel@348
  3278
		if ( delegateCount && !(event.button && event.type === "click") ) {
moel@348
  3279
moel@348
  3280
			// Pregenerate a single jQuery object for reuse with .is()
moel@348
  3281
			jqcur = jQuery(this);
moel@348
  3282
			jqcur.context = this.ownerDocument || this;
moel@348
  3283
moel@348
  3284
			for ( cur = event.target; cur != this; cur = cur.parentNode || this ) {
moel@348
  3285
moel@348
  3286
				// Don't process events on disabled elements (#6911, #8165)
moel@348
  3287
				if ( cur.disabled !== true ) {
moel@348
  3288
					selMatch = {};
moel@348
  3289
					matches = [];
moel@348
  3290
					jqcur[0] = cur;
moel@348
  3291
					for ( i = 0; i < delegateCount; i++ ) {
moel@348
  3292
						handleObj = handlers[ i ];
moel@348
  3293
						sel = handleObj.selector;
moel@348
  3294
moel@348
  3295
						if ( selMatch[ sel ] === undefined ) {
moel@348
  3296
							selMatch[ sel ] = (
moel@348
  3297
								handleObj.quick ? quickIs( cur, handleObj.quick ) : jqcur.is( sel )
moel@348
  3298
							);
moel@348
  3299
						}
moel@348
  3300
						if ( selMatch[ sel ] ) {
moel@348
  3301
							matches.push( handleObj );
moel@348
  3302
						}
moel@348
  3303
					}
moel@348
  3304
					if ( matches.length ) {
moel@348
  3305
						handlerQueue.push({ elem: cur, matches: matches });
moel@348
  3306
					}
moel@348
  3307
				}
moel@348
  3308
			}
moel@348
  3309
		}
moel@348
  3310
moel@348
  3311
		// Add the remaining (directly-bound) handlers
moel@348
  3312
		if ( handlers.length > delegateCount ) {
moel@348
  3313
			handlerQueue.push({ elem: this, matches: handlers.slice( delegateCount ) });
moel@348
  3314
		}
moel@348
  3315
moel@348
  3316
		// Run delegates first; they may want to stop propagation beneath us
moel@348
  3317
		for ( i = 0; i < handlerQueue.length && !event.isPropagationStopped(); i++ ) {
moel@348
  3318
			matched = handlerQueue[ i ];
moel@348
  3319
			event.currentTarget = matched.elem;
moel@348
  3320
moel@348
  3321
			for ( j = 0; j < matched.matches.length && !event.isImmediatePropagationStopped(); j++ ) {
moel@348
  3322
				handleObj = matched.matches[ j ];
moel@348
  3323
moel@348
  3324
				// Triggered event must either 1) be non-exclusive and have no namespace, or
moel@348
  3325
				// 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
moel@348
  3326
				if ( run_all || (!event.namespace && !handleObj.namespace) || event.namespace_re && event.namespace_re.test( handleObj.namespace ) ) {
moel@348
  3327
moel@348
  3328
					event.data = handleObj.data;
moel@348
  3329
					event.handleObj = handleObj;
moel@348
  3330
moel@348
  3331
					ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
moel@348
  3332
							.apply( matched.elem, args );
moel@348
  3333
moel@348
  3334
					if ( ret !== undefined ) {
moel@348
  3335
						event.result = ret;
moel@348
  3336
						if ( ret === false ) {
moel@348
  3337
							event.preventDefault();
moel@348
  3338
							event.stopPropagation();
moel@348
  3339
						}
moel@348
  3340
					}
moel@348
  3341
				}
moel@348
  3342
			}
moel@348
  3343
		}
moel@348
  3344
moel@348
  3345
		// Call the postDispatch hook for the mapped type
moel@348
  3346
		if ( special.postDispatch ) {
moel@348
  3347
			special.postDispatch.call( this, event );
moel@348
  3348
		}
moel@348
  3349
moel@348
  3350
		return event.result;
moel@348
  3351
	},
moel@348
  3352
moel@348
  3353
	// Includes some event props shared by KeyEvent and MouseEvent
moel@348
  3354
	// *** attrChange attrName relatedNode srcElement  are not normalized, non-W3C, deprecated, will be removed in 1.8 ***
moel@348
  3355
	props: "attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
moel@348
  3356
moel@348
  3357
	fixHooks: {},
moel@348
  3358
moel@348
  3359
	keyHooks: {
moel@348
  3360
		props: "char charCode key keyCode".split(" "),
moel@348
  3361
		filter: function( event, original ) {
moel@348
  3362
moel@348
  3363
			// Add which for key events
moel@348
  3364
			if ( event.which == null ) {
moel@348
  3365
				event.which = original.charCode != null ? original.charCode : original.keyCode;
moel@348
  3366
			}
moel@348
  3367
moel@348
  3368
			return event;
moel@348
  3369
		}
moel@348
  3370
	},
moel@348
  3371
moel@348
  3372
	mouseHooks: {
moel@348
  3373
		props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
moel@348
  3374
		filter: function( event, original ) {
moel@348
  3375
			var eventDoc, doc, body,
moel@348
  3376
				button = original.button,
moel@348
  3377
				fromElement = original.fromElement;
moel@348
  3378
moel@348
  3379
			// Calculate pageX/Y if missing and clientX/Y available
moel@348
  3380
			if ( event.pageX == null && original.clientX != null ) {
moel@348
  3381
				eventDoc = event.target.ownerDocument || document;
moel@348
  3382
				doc = eventDoc.documentElement;
moel@348
  3383
				body = eventDoc.body;
moel@348
  3384
moel@348
  3385
				event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 );
moel@348
  3386
				event.pageY = original.clientY + ( doc && doc.scrollTop  || body && body.scrollTop  || 0 ) - ( doc && doc.clientTop  || body && body.clientTop  || 0 );
moel@348
  3387
			}
moel@348
  3388
moel@348
  3389
			// Add relatedTarget, if necessary
moel@348
  3390
			if ( !event.relatedTarget && fromElement ) {
moel@348
  3391
				event.relatedTarget = fromElement === event.target ? original.toElement : fromElement;
moel@348
  3392
			}
moel@348
  3393
moel@348
  3394
			// Add which for click: 1 === left; 2 === middle; 3 === right
moel@348
  3395
			// Note: button is not normalized, so don't use it
moel@348
  3396
			if ( !event.which && button !== undefined ) {
moel@348
  3397
				event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
moel@348
  3398
			}
moel@348
  3399
moel@348
  3400
			return event;
moel@348
  3401
		}
moel@348
  3402
	},
moel@348
  3403
moel@348
  3404
	fix: function( event ) {
moel@348
  3405
		if ( event[ jQuery.expando ] ) {
moel@348
  3406
			return event;
moel@348
  3407
		}
moel@348
  3408
moel@348
  3409
		// Create a writable copy of the event object and normalize some properties
moel@348
  3410
		var i, prop,
moel@348
  3411
			originalEvent = event,
moel@348
  3412
			fixHook = jQuery.event.fixHooks[ event.type ] || {},
moel@348
  3413
			copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
moel@348
  3414
moel@348
  3415
		event = jQuery.Event( originalEvent );
moel@348
  3416
moel@348
  3417
		for ( i = copy.length; i; ) {
moel@348
  3418
			prop = copy[ --i ];
moel@348
  3419
			event[ prop ] = originalEvent[ prop ];
moel@348
  3420
		}
moel@348
  3421
moel@348
  3422
		// Fix target property, if necessary (#1925, IE 6/7/8 & Safari2)
moel@348
  3423
		if ( !event.target ) {
moel@348
  3424
			event.target = originalEvent.srcElement || document;
moel@348
  3425
		}
moel@348
  3426
moel@348
  3427
		// Target should not be a text node (#504, Safari)
moel@348
  3428
		if ( event.target.nodeType === 3 ) {
moel@348
  3429
			event.target = event.target.parentNode;
moel@348
  3430
		}
moel@348
  3431
moel@348
  3432
		// For mouse/key events; add metaKey if it's not there (#3368, IE6/7/8)
moel@348
  3433
		if ( event.metaKey === undefined ) {
moel@348
  3434
			event.metaKey = event.ctrlKey;
moel@348
  3435
		}
moel@348
  3436
moel@348
  3437
		return fixHook.filter? fixHook.filter( event, originalEvent ) : event;
moel@348
  3438
	},
moel@348
  3439
moel@348
  3440
	special: {
moel@348
  3441
		ready: {
moel@348
  3442
			// Make sure the ready event is setup
moel@348
  3443
			setup: jQuery.bindReady
moel@348
  3444
		},
moel@348
  3445
moel@348
  3446
		load: {
moel@348
  3447
			// Prevent triggered image.load events from bubbling to window.load
moel@348
  3448
			noBubble: true
moel@348
  3449
		},
moel@348
  3450
moel@348
  3451
		focus: {
moel@348
  3452
			delegateType: "focusin"
moel@348
  3453
		},
moel@348
  3454
		blur: {
moel@348
  3455
			delegateType: "focusout"
moel@348
  3456
		},
moel@348
  3457
moel@348
  3458
		beforeunload: {
moel@348
  3459
			setup: function( data, namespaces, eventHandle ) {
moel@348
  3460
				// We only want to do this special case on windows
moel@348
  3461
				if ( jQuery.isWindow( this ) ) {
moel@348
  3462
					this.onbeforeunload = eventHandle;
moel@348
  3463
				}
moel@348
  3464
			},
moel@348
  3465
moel@348
  3466
			teardown: function( namespaces, eventHandle ) {
moel@348
  3467
				if ( this.onbeforeunload === eventHandle ) {
moel@348
  3468
					this.onbeforeunload = null;
moel@348
  3469
				}
moel@348
  3470
			}
moel@348
  3471
		}
moel@348
  3472
	},
moel@348
  3473
moel@348
  3474
	simulate: function( type, elem, event, bubble ) {
moel@348
  3475
		// Piggyback on a donor event to simulate a different one.
moel@348
  3476
		// Fake originalEvent to avoid donor's stopPropagation, but if the
moel@348
  3477
		// simulated event prevents default then we do the same on the donor.
moel@348
  3478
		var e = jQuery.extend(
moel@348
  3479
			new jQuery.Event(),
moel@348
  3480
			event,
moel@348
  3481
			{ type: type,
moel@348
  3482
				isSimulated: true,
moel@348
  3483
				originalEvent: {}
moel@348
  3484
			}
moel@348
  3485
		);
moel@348
  3486
		if ( bubble ) {
moel@348
  3487
			jQuery.event.trigger( e, null, elem );
moel@348
  3488
		} else {
moel@348
  3489
			jQuery.event.dispatch.call( elem, e );
moel@348
  3490
		}
moel@348
  3491
		if ( e.isDefaultPrevented() ) {
moel@348
  3492
			event.preventDefault();
moel@348
  3493
		}
moel@348
  3494
	}
moel@348
  3495
};
moel@348
  3496
moel@348
  3497
// Some plugins are using, but it's undocumented/deprecated and will be removed.
moel@348
  3498
// The 1.7 special event interface should provide all the hooks needed now.
moel@348
  3499
jQuery.event.handle = jQuery.event.dispatch;
moel@348
  3500
moel@348
  3501
jQuery.removeEvent = document.removeEventListener ?
moel@348
  3502
	function( elem, type, handle ) {
moel@348
  3503
		if ( elem.removeEventListener ) {
moel@348
  3504
			elem.removeEventListener( type, handle, false );
moel@348
  3505
		}
moel@348
  3506
	} :
moel@348
  3507
	function( elem, type, handle ) {
moel@348
  3508
		if ( elem.detachEvent ) {
moel@348
  3509
			elem.detachEvent( "on" + type, handle );
moel@348
  3510
		}
moel@348
  3511
	};
moel@348
  3512
moel@348
  3513
jQuery.Event = function( src, props ) {
moel@348
  3514
	// Allow instantiation without the 'new' keyword
moel@348
  3515
	if ( !(this instanceof jQuery.Event) ) {
moel@348
  3516
		return new jQuery.Event( src, props );
moel@348
  3517
	}
moel@348
  3518
moel@348
  3519
	// Event object
moel@348
  3520
	if ( src && src.type ) {
moel@348
  3521
		this.originalEvent = src;
moel@348
  3522
		this.type = src.type;
moel@348
  3523
moel@348
  3524
		// Events bubbling up the document may have been marked as prevented
moel@348
  3525
		// by a handler lower down the tree; reflect the correct value.
moel@348
  3526
		this.isDefaultPrevented = ( src.defaultPrevented || src.returnValue === false ||
moel@348
  3527
			src.getPreventDefault && src.getPreventDefault() ) ? returnTrue : returnFalse;
moel@348
  3528
moel@348
  3529
	// Event type
moel@348
  3530
	} else {
moel@348
  3531
		this.type = src;
moel@348
  3532
	}
moel@348
  3533
moel@348
  3534
	// Put explicitly provided properties onto the event object
moel@348
  3535
	if ( props ) {
moel@348
  3536
		jQuery.extend( this, props );
moel@348
  3537
	}
moel@348
  3538
moel@348
  3539
	// Create a timestamp if incoming event doesn't have one
moel@348
  3540
	this.timeStamp = src && src.timeStamp || jQuery.now();
moel@348
  3541
moel@348
  3542
	// Mark it as fixed
moel@348
  3543
	this[ jQuery.expando ] = true;
moel@348
  3544
};
moel@348
  3545
moel@348
  3546
function returnFalse() {
moel@348
  3547
	return false;
moel@348
  3548
}
moel@348
  3549
function returnTrue() {
moel@348
  3550
	return true;
moel@348
  3551
}
moel@348
  3552
moel@348
  3553
// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
moel@348
  3554
// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
moel@348
  3555
jQuery.Event.prototype = {
moel@348
  3556
	preventDefault: function() {
moel@348
  3557
		this.isDefaultPrevented = returnTrue;
moel@348
  3558
moel@348
  3559
		var e = this.originalEvent;
moel@348
  3560
		if ( !e ) {
moel@348
  3561
			return;
moel@348
  3562
		}
moel@348
  3563
moel@348
  3564
		// if preventDefault exists run it on the original event
moel@348
  3565
		if ( e.preventDefault ) {
moel@348
  3566
			e.preventDefault();
moel@348
  3567
moel@348
  3568
		// otherwise set the returnValue property of the original event to false (IE)
moel@348
  3569
		} else {
moel@348
  3570
			e.returnValue = false;
moel@348
  3571
		}
moel@348
  3572
	},
moel@348
  3573
	stopPropagation: function() {
moel@348
  3574
		this.isPropagationStopped = returnTrue;
moel@348
  3575
moel@348
  3576
		var e = this.originalEvent;
moel@348
  3577
		if ( !e ) {
moel@348
  3578
			return;
moel@348
  3579
		}
moel@348
  3580
		// if stopPropagation exists run it on the original event
moel@348
  3581
		if ( e.stopPropagation ) {
moel@348
  3582
			e.stopPropagation();
moel@348
  3583
		}
moel@348
  3584
		// otherwise set the cancelBubble property of the original event to true (IE)
moel@348
  3585
		e.cancelBubble = true;
moel@348
  3586
	},
moel@348
  3587
	stopImmediatePropagation: function() {
moel@348
  3588
		this.isImmediatePropagationStopped = returnTrue;
moel@348
  3589
		this.stopPropagation();
moel@348
  3590
	},
moel@348
  3591
	isDefaultPrevented: returnFalse,
moel@348
  3592
	isPropagationStopped: returnFalse,
moel@348
  3593
	isImmediatePropagationStopped: returnFalse
moel@348
  3594
};
moel@348
  3595
moel@348
  3596
// Create mouseenter/leave events using mouseover/out and event-time checks
moel@348
  3597
jQuery.each({
moel@348
  3598
	mouseenter: "mouseover",
moel@348
  3599
	mouseleave: "mouseout"
moel@348
  3600
}, function( orig, fix ) {
moel@348
  3601
	jQuery.event.special[ orig ] = {
moel@348
  3602
		delegateType: fix,
moel@348
  3603
		bindType: fix,
moel@348
  3604
moel@348
  3605
		handle: function( event ) {
moel@348
  3606
			var target = this,
moel@348
  3607
				related = event.relatedTarget,
moel@348
  3608
				handleObj = event.handleObj,
moel@348
  3609
				selector = handleObj.selector,
moel@348
  3610
				ret;
moel@348
  3611
moel@348
  3612
			// For mousenter/leave call the handler if related is outside the target.
moel@348
  3613
			// NB: No relatedTarget if the mouse left/entered the browser window
moel@348
  3614
			if ( !related || (related !== target && !jQuery.contains( target, related )) ) {
moel@348
  3615
				event.type = handleObj.origType;
moel@348
  3616
				ret = handleObj.handler.apply( this, arguments );
moel@348
  3617
				event.type = fix;
moel@348
  3618
			}
moel@348
  3619
			return ret;
moel@348
  3620
		}
moel@348
  3621
	};
moel@348
  3622
});
moel@348
  3623
moel@348
  3624
// IE submit delegation
moel@348
  3625
if ( !jQuery.support.submitBubbles ) {
moel@348
  3626
moel@348
  3627
	jQuery.event.special.submit = {
moel@348
  3628
		setup: function() {
moel@348
  3629
			// Only need this for delegated form submit events
moel@348
  3630
			if ( jQuery.nodeName( this, "form" ) ) {
moel@348
  3631
				return false;
moel@348
  3632
			}
moel@348
  3633
moel@348
  3634
			// Lazy-add a submit handler when a descendant form may potentially be submitted
moel@348
  3635
			jQuery.event.add( this, "click._submit keypress._submit", function( e ) {
moel@348
  3636
				// Node name check avoids a VML-related crash in IE (#9807)
moel@348
  3637
				var elem = e.target,
moel@348
  3638
					form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined;
moel@348
  3639
				if ( form && !form._submit_attached ) {
moel@348
  3640
					jQuery.event.add( form, "submit._submit", function( event ) {
moel@348
  3641
						event._submit_bubble = true;
moel@348
  3642
					});
moel@348
  3643
					form._submit_attached = true;
moel@348
  3644
				}
moel@348
  3645
			});
moel@348
  3646
			// return undefined since we don't need an event listener
moel@348
  3647
		},
moel@348
  3648
		
moel@348
  3649
		postDispatch: function( event ) {
moel@348
  3650
			// If form was submitted by the user, bubble the event up the tree
moel@348
  3651
			if ( event._submit_bubble ) {
moel@348
  3652
				delete event._submit_bubble;
moel@348
  3653
				if ( this.parentNode && !event.isTrigger ) {
moel@348
  3654
					jQuery.event.simulate( "submit", this.parentNode, event, true );
moel@348
  3655
				}
moel@348
  3656
			}
moel@348
  3657
		},
moel@348
  3658
moel@348
  3659
		teardown: function() {
moel@348
  3660
			// Only need this for delegated form submit events
moel@348
  3661
			if ( jQuery.nodeName( this, "form" ) ) {
moel@348
  3662
				return false;
moel@348
  3663
			}
moel@348
  3664
moel@348
  3665
			// Remove delegated handlers; cleanData eventually reaps submit handlers attached above
moel@348
  3666
			jQuery.event.remove( this, "._submit" );
moel@348
  3667
		}
moel@348
  3668
	};
moel@348
  3669
}
moel@348
  3670
moel@348
  3671
// IE change delegation and checkbox/radio fix
moel@348
  3672
if ( !jQuery.support.changeBubbles ) {
moel@348
  3673
moel@348
  3674
	jQuery.event.special.change = {
moel@348
  3675
moel@348
  3676
		setup: function() {
moel@348
  3677
moel@348
  3678
			if ( rformElems.test( this.nodeName ) ) {
moel@348
  3679
				// IE doesn't fire change on a check/radio until blur; trigger it on click
moel@348
  3680
				// after a propertychange. Eat the blur-change in special.change.handle.
moel@348
  3681
				// This still fires onchange a second time for check/radio after blur.
moel@348
  3682
				if ( this.type === "checkbox" || this.type === "radio" ) {
moel@348
  3683
					jQuery.event.add( this, "propertychange._change", function( event ) {
moel@348
  3684
						if ( event.originalEvent.propertyName === "checked" ) {
moel@348
  3685
							this._just_changed = true;
moel@348
  3686
						}
moel@348
  3687
					});
moel@348
  3688
					jQuery.event.add( this, "click._change", function( event ) {
moel@348
  3689
						if ( this._just_changed && !event.isTrigger ) {
moel@348
  3690
							this._just_changed = false;
moel@348
  3691
							jQuery.event.simulate( "change", this, event, true );
moel@348
  3692
						}
moel@348
  3693
					});
moel@348
  3694
				}
moel@348
  3695
				return false;
moel@348
  3696
			}
moel@348
  3697
			// Delegated event; lazy-add a change handler on descendant inputs
moel@348
  3698
			jQuery.event.add( this, "beforeactivate._change", function( e ) {
moel@348
  3699
				var elem = e.target;
moel@348
  3700
moel@348
  3701
				if ( rformElems.test( elem.nodeName ) && !elem._change_attached ) {
moel@348
  3702
					jQuery.event.add( elem, "change._change", function( event ) {
moel@348
  3703
						if ( this.parentNode && !event.isSimulated && !event.isTrigger ) {
moel@348
  3704
							jQuery.event.simulate( "change", this.parentNode, event, true );
moel@348
  3705
						}
moel@348
  3706
					});
moel@348
  3707
					elem._change_attached = true;
moel@348
  3708
				}
moel@348
  3709
			});
moel@348
  3710
		},
moel@348
  3711
moel@348
  3712
		handle: function( event ) {
moel@348
  3713
			var elem = event.target;
moel@348
  3714
moel@348
  3715
			// Swallow native change events from checkbox/radio, we already triggered them above
moel@348
  3716
			if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) {
moel@348
  3717
				return event.handleObj.handler.apply( this, arguments );
moel@348
  3718
			}
moel@348
  3719
		},
moel@348
  3720
moel@348
  3721
		teardown: function() {
moel@348
  3722
			jQuery.event.remove( this, "._change" );
moel@348
  3723
moel@348
  3724
			return rformElems.test( this.nodeName );
moel@348
  3725
		}
moel@348
  3726
	};
moel@348
  3727
}
moel@348
  3728
moel@348
  3729
// Create "bubbling" focus and blur events
moel@348
  3730
if ( !jQuery.support.focusinBubbles ) {
moel@348
  3731
	jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
moel@348
  3732
moel@348
  3733
		// Attach a single capturing handler while someone wants focusin/focusout
moel@348
  3734
		var attaches = 0,
moel@348
  3735
			handler = function( event ) {
moel@348
  3736
				jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
moel@348
  3737
			};
moel@348
  3738
moel@348
  3739
		jQuery.event.special[ fix ] = {
moel@348
  3740
			setup: function() {
moel@348
  3741
				if ( attaches++ === 0 ) {
moel@348
  3742
					document.addEventListener( orig, handler, true );
moel@348
  3743
				}
moel@348
  3744
			},
moel@348
  3745
			teardown: function() {
moel@348
  3746
				if ( --attaches === 0 ) {
moel@348
  3747
					document.removeEventListener( orig, handler, true );
moel@348
  3748
				}
moel@348
  3749
			}
moel@348
  3750
		};
moel@348
  3751
	});
moel@348
  3752
}
moel@348
  3753
moel@348
  3754
jQuery.fn.extend({
moel@348
  3755
moel@348
  3756
	on: function( types, selector, data, fn, /*INTERNAL*/ one ) {
moel@348
  3757
		var origFn, type;
moel@348
  3758
moel@348
  3759
		// Types can be a map of types/handlers
moel@348
  3760
		if ( typeof types === "object" ) {
moel@348
  3761
			// ( types-Object, selector, data )
moel@348
  3762
			if ( typeof selector !== "string" ) { // && selector != null
moel@348
  3763
				// ( types-Object, data )
moel@348
  3764
				data = data || selector;
moel@348
  3765
				selector = undefined;
moel@348
  3766
			}
moel@348
  3767
			for ( type in types ) {
moel@348
  3768
				this.on( type, selector, data, types[ type ], one );
moel@348
  3769
			}
moel@348
  3770
			return this;
moel@348
  3771
		}
moel@348
  3772
moel@348
  3773
		if ( data == null && fn == null ) {
moel@348
  3774
			// ( types, fn )
moel@348
  3775
			fn = selector;
moel@348
  3776
			data = selector = undefined;
moel@348
  3777
		} else if ( fn == null ) {
moel@348
  3778
			if ( typeof selector === "string" ) {
moel@348
  3779
				// ( types, selector, fn )
moel@348
  3780
				fn = data;
moel@348
  3781
				data = undefined;
moel@348
  3782
			} else {
moel@348
  3783
				// ( types, data, fn )
moel@348
  3784
				fn = data;
moel@348
  3785
				data = selector;
moel@348
  3786
				selector = undefined;
moel@348
  3787
			}
moel@348
  3788
		}
moel@348
  3789
		if ( fn === false ) {
moel@348
  3790
			fn = returnFalse;
moel@348
  3791
		} else if ( !fn ) {
moel@348
  3792
			return this;
moel@348
  3793
		}
moel@348
  3794
moel@348
  3795
		if ( one === 1 ) {
moel@348
  3796
			origFn = fn;
moel@348
  3797
			fn = function( event ) {
moel@348
  3798
				// Can use an empty set, since event contains the info
moel@348
  3799
				jQuery().off( event );
moel@348
  3800
				return origFn.apply( this, arguments );
moel@348
  3801
			};
moel@348
  3802
			// Use same guid so caller can remove using origFn
moel@348
  3803
			fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
moel@348
  3804
		}
moel@348
  3805
		return this.each( function() {
moel@348
  3806
			jQuery.event.add( this, types, fn, data, selector );
moel@348
  3807
		});
moel@348
  3808
	},
moel@348
  3809
	one: function( types, selector, data, fn ) {
moel@348
  3810
		return this.on( types, selector, data, fn, 1 );
moel@348
  3811
	},
moel@348
  3812
	off: function( types, selector, fn ) {
moel@348
  3813
		if ( types && types.preventDefault && types.handleObj ) {
moel@348
  3814
			// ( event )  dispatched jQuery.Event
moel@348
  3815
			var handleObj = types.handleObj;
moel@348
  3816
			jQuery( types.delegateTarget ).off(
moel@348
  3817
				handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType,
moel@348
  3818
				handleObj.selector,
moel@348
  3819
				handleObj.handler
moel@348
  3820
			);
moel@348
  3821
			return this;
moel@348
  3822
		}
moel@348
  3823
		if ( typeof types === "object" ) {
moel@348
  3824
			// ( types-object [, selector] )
moel@348
  3825
			for ( var type in types ) {
moel@348
  3826
				this.off( type, selector, types[ type ] );
moel@348
  3827
			}
moel@348
  3828
			return this;
moel@348
  3829
		}
moel@348
  3830
		if ( selector === false || typeof selector === "function" ) {
moel@348
  3831
			// ( types [, fn] )
moel@348
  3832
			fn = selector;
moel@348
  3833
			selector = undefined;
moel@348
  3834
		}
moel@348
  3835
		if ( fn === false ) {
moel@348
  3836
			fn = returnFalse;
moel@348
  3837
		}
moel@348
  3838
		return this.each(function() {
moel@348
  3839
			jQuery.event.remove( this, types, fn, selector );
moel@348
  3840
		});
moel@348
  3841
	},
moel@348
  3842
moel@348
  3843
	bind: function( types, data, fn ) {
moel@348
  3844
		return this.on( types, null, data, fn );
moel@348
  3845
	},
moel@348
  3846
	unbind: function( types, fn ) {
moel@348
  3847
		return this.off( types, null, fn );
moel@348
  3848
	},
moel@348
  3849
moel@348
  3850
	live: function( types, data, fn ) {
moel@348
  3851
		jQuery( this.context ).on( types, this.selector, data, fn );
moel@348
  3852
		return this;
moel@348
  3853
	},
moel@348
  3854
	die: function( types, fn ) {
moel@348
  3855
		jQuery( this.context ).off( types, this.selector || "**", fn );
moel@348
  3856
		return this;
moel@348
  3857
	},
moel@348
  3858
moel@348
  3859
	delegate: function( selector, types, data, fn ) {
moel@348
  3860
		return this.on( types, selector, data, fn );
moel@348
  3861
	},
moel@348
  3862
	undelegate: function( selector, types, fn ) {
moel@348
  3863
		// ( namespace ) or ( selector, types [, fn] )
moel@348
  3864
		return arguments.length == 1? this.off( selector, "**" ) : this.off( types, selector, fn );
moel@348
  3865
	},
moel@348
  3866
moel@348
  3867
	trigger: function( type, data ) {
moel@348
  3868
		return this.each(function() {
moel@348
  3869
			jQuery.event.trigger( type, data, this );
moel@348
  3870
		});
moel@348
  3871
	},
moel@348
  3872
	triggerHandler: function( type, data ) {
moel@348
  3873
		if ( this[0] ) {
moel@348
  3874
			return jQuery.event.trigger( type, data, this[0], true );
moel@348
  3875
		}
moel@348
  3876
	},
moel@348
  3877
moel@348
  3878
	toggle: function( fn ) {
moel@348
  3879
		// Save reference to arguments for access in closure
moel@348
  3880
		var args = arguments,
moel@348
  3881
			guid = fn.guid || jQuery.guid++,
moel@348
  3882
			i = 0,
moel@348
  3883
			toggler = function( event ) {
moel@348
  3884
				// Figure out which function to execute
moel@348
  3885
				var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i;
moel@348
  3886
				jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 );
moel@348
  3887
moel@348
  3888
				// Make sure that clicks stop
moel@348
  3889
				event.preventDefault();
moel@348
  3890
moel@348
  3891
				// and execute the function
moel@348
  3892
				return args[ lastToggle ].apply( this, arguments ) || false;
moel@348
  3893
			};
moel@348
  3894
moel@348
  3895
		// link all the functions, so any of them can unbind this click handler
moel@348
  3896
		toggler.guid = guid;
moel@348
  3897
		while ( i < args.length ) {
moel@348
  3898
			args[ i++ ].guid = guid;
moel@348
  3899
		}
moel@348
  3900
moel@348
  3901
		return this.click( toggler );
moel@348
  3902
	},
moel@348
  3903
moel@348
  3904
	hover: function( fnOver, fnOut ) {
moel@348
  3905
		return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
moel@348
  3906
	}
moel@348
  3907
});
moel@348
  3908
moel@348
  3909
jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
moel@348
  3910
	"mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
moel@348
  3911
	"change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) {
moel@348
  3912
moel@348
  3913
	// Handle event binding
moel@348
  3914
	jQuery.fn[ name ] = function( data, fn ) {
moel@348
  3915
		if ( fn == null ) {
moel@348
  3916
			fn = data;
moel@348
  3917
			data = null;
moel@348
  3918
		}
moel@348
  3919
moel@348
  3920
		return arguments.length > 0 ?
moel@348
  3921
			this.on( name, null, data, fn ) :
moel@348
  3922
			this.trigger( name );
moel@348
  3923
	};
moel@348
  3924
moel@348
  3925
	if ( jQuery.attrFn ) {
moel@348
  3926
		jQuery.attrFn[ name ] = true;
moel@348
  3927
	}
moel@348
  3928
moel@348
  3929
	if ( rkeyEvent.test( name ) ) {
moel@348
  3930
		jQuery.event.fixHooks[ name ] = jQuery.event.keyHooks;
moel@348
  3931
	}
moel@348
  3932
moel@348
  3933
	if ( rmouseEvent.test( name ) ) {
moel@348
  3934
		jQuery.event.fixHooks[ name ] = jQuery.event.mouseHooks;
moel@348
  3935
	}
moel@348
  3936
});
moel@348
  3937
moel@348
  3938
moel@348
  3939
moel@348
  3940
/*!
moel@348
  3941
 * Sizzle CSS Selector Engine
moel@348
  3942
 *  Copyright 2011, The Dojo Foundation
moel@348
  3943
 *  Released under the MIT, BSD, and GPL Licenses.
moel@348
  3944
 *  More information: http://sizzlejs.com/
moel@348
  3945
 */
moel@348
  3946
(function(){
moel@348
  3947
moel@348
  3948
var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
moel@348
  3949
	expando = "sizcache" + (Math.random() + '').replace('.', ''),
moel@348
  3950
	done = 0,
moel@348
  3951
	toString = Object.prototype.toString,
moel@348
  3952
	hasDuplicate = false,
moel@348
  3953
	baseHasDuplicate = true,
moel@348
  3954
	rBackslash = /\\/g,
moel@348
  3955
	rReturn = /\r\n/g,
moel@348
  3956
	rNonWord = /\W/;
moel@348
  3957
moel@348
  3958
// Here we check if the JavaScript engine is using some sort of
moel@348
  3959
// optimization where it does not always call our comparision
moel@348
  3960
// function. If that is the case, discard the hasDuplicate value.
moel@348
  3961
//   Thus far that includes Google Chrome.
moel@348
  3962
[0, 0].sort(function() {
moel@348
  3963
	baseHasDuplicate = false;
moel@348
  3964
	return 0;
moel@348
  3965
});
moel@348
  3966
moel@348
  3967
var Sizzle = function( selector, context, results, seed ) {
moel@348
  3968
	results = results || [];
moel@348
  3969
	context = context || document;
moel@348
  3970
moel@348
  3971
	var origContext = context;
moel@348
  3972
moel@348
  3973
	if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
moel@348
  3974
		return [];
moel@348
  3975
	}
moel@348
  3976
moel@348
  3977
	if ( !selector || typeof selector !== "string" ) {
moel@348
  3978
		return results;
moel@348
  3979
	}
moel@348
  3980
moel@348
  3981
	var m, set, checkSet, extra, ret, cur, pop, i,
moel@348
  3982
		prune = true,
moel@348
  3983
		contextXML = Sizzle.isXML( context ),
moel@348
  3984
		parts = [],
moel@348
  3985
		soFar = selector;
moel@348
  3986
moel@348
  3987
	// Reset the position of the chunker regexp (start from head)
moel@348
  3988
	do {
moel@348
  3989
		chunker.exec( "" );
moel@348
  3990
		m = chunker.exec( soFar );
moel@348
  3991
moel@348
  3992
		if ( m ) {
moel@348
  3993
			soFar = m[3];
moel@348
  3994
moel@348
  3995
			parts.push( m[1] );
moel@348
  3996
moel@348
  3997
			if ( m[2] ) {
moel@348
  3998
				extra = m[3];
moel@348
  3999
				break;
moel@348
  4000
			}
moel@348
  4001
		}
moel@348
  4002
	} while ( m );
moel@348
  4003
moel@348
  4004
	if ( parts.length > 1 && origPOS.exec( selector ) ) {
moel@348
  4005
moel@348
  4006
		if ( parts.length === 2 && Expr.relative[ parts[0] ] ) {
moel@348
  4007
			set = posProcess( parts[0] + parts[1], context, seed );
moel@348
  4008
moel@348
  4009
		} else {
moel@348
  4010
			set = Expr.relative[ parts[0] ] ?
moel@348
  4011
				[ context ] :
moel@348
  4012
				Sizzle( parts.shift(), context );
moel@348
  4013
moel@348
  4014
			while ( parts.length ) {
moel@348
  4015
				selector = parts.shift();
moel@348
  4016
moel@348
  4017
				if ( Expr.relative[ selector ] ) {
moel@348
  4018
					selector += parts.shift();
moel@348
  4019
				}
moel@348
  4020
moel@348
  4021
				set = posProcess( selector, set, seed );
moel@348
  4022
			}
moel@348
  4023
		}
moel@348
  4024
moel@348
  4025
	} else {
moel@348
  4026
		// Take a shortcut and set the context if the root selector is an ID
moel@348
  4027
		// (but not if it'll be faster if the inner selector is an ID)
moel@348
  4028
		if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML &&
moel@348
  4029
				Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) {
moel@348
  4030
moel@348
  4031
			ret = Sizzle.find( parts.shift(), context, contextXML );
moel@348
  4032
			context = ret.expr ?
moel@348
  4033
				Sizzle.filter( ret.expr, ret.set )[0] :
moel@348
  4034
				ret.set[0];
moel@348
  4035
		}
moel@348
  4036
moel@348
  4037
		if ( context ) {
moel@348
  4038
			ret = seed ?
moel@348
  4039
				{ expr: parts.pop(), set: makeArray(seed) } :
moel@348
  4040
				Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML );
moel@348
  4041
moel@348
  4042
			set = ret.expr ?
moel@348
  4043
				Sizzle.filter( ret.expr, ret.set ) :
moel@348
  4044
				ret.set;
moel@348
  4045
moel@348
  4046
			if ( parts.length > 0 ) {
moel@348
  4047
				checkSet = makeArray( set );
moel@348
  4048
moel@348
  4049
			} else {
moel@348
  4050
				prune = false;
moel@348
  4051
			}
moel@348
  4052
moel@348
  4053
			while ( parts.length ) {
moel@348
  4054
				cur = parts.pop();
moel@348
  4055
				pop = cur;
moel@348
  4056
moel@348
  4057
				if ( !Expr.relative[ cur ] ) {
moel@348
  4058
					cur = "";
moel@348
  4059
				} else {
moel@348
  4060
					pop = parts.pop();
moel@348
  4061
				}
moel@348
  4062
moel@348
  4063
				if ( pop == null ) {
moel@348
  4064
					pop = context;
moel@348
  4065
				}
moel@348
  4066
moel@348
  4067
				Expr.relative[ cur ]( checkSet, pop, contextXML );
moel@348
  4068
			}
moel@348
  4069
moel@348
  4070
		} else {
moel@348
  4071
			checkSet = parts = [];
moel@348
  4072
		}
moel@348
  4073
	}
moel@348
  4074
moel@348
  4075
	if ( !checkSet ) {
moel@348
  4076
		checkSet = set;
moel@348
  4077
	}
moel@348
  4078
moel@348
  4079
	if ( !checkSet ) {
moel@348
  4080
		Sizzle.error( cur || selector );
moel@348
  4081
	}
moel@348
  4082
moel@348
  4083
	if ( toString.call(checkSet) === "[object Array]" ) {
moel@348
  4084
		if ( !prune ) {
moel@348
  4085
			results.push.apply( results, checkSet );
moel@348
  4086
moel@348
  4087
		} else if ( context && context.nodeType === 1 ) {
moel@348
  4088
			for ( i = 0; checkSet[i] != null; i++ ) {
moel@348
  4089
				if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i])) ) {
moel@348
  4090
					results.push( set[i] );
moel@348
  4091
				}
moel@348
  4092
			}
moel@348
  4093
moel@348
  4094
		} else {
moel@348
  4095
			for ( i = 0; checkSet[i] != null; i++ ) {
moel@348
  4096
				if ( checkSet[i] && checkSet[i].nodeType === 1 ) {
moel@348
  4097
					results.push( set[i] );
moel@348
  4098
				}
moel@348
  4099
			}
moel@348
  4100
		}
moel@348
  4101
moel@348
  4102
	} else {
moel@348
  4103
		makeArray( checkSet, results );
moel@348
  4104
	}
moel@348
  4105
moel@348
  4106
	if ( extra ) {
moel@348
  4107
		Sizzle( extra, origContext, results, seed );
moel@348
  4108
		Sizzle.uniqueSort( results );
moel@348
  4109
	}
moel@348
  4110
moel@348
  4111
	return results;
moel@348
  4112
};
moel@348
  4113
moel@348
  4114
Sizzle.uniqueSort = function( results ) {
moel@348
  4115
	if ( sortOrder ) {
moel@348
  4116
		hasDuplicate = baseHasDuplicate;
moel@348
  4117
		results.sort( sortOrder );
moel@348
  4118
moel@348
  4119
		if ( hasDuplicate ) {
moel@348
  4120
			for ( var i = 1; i < results.length; i++ ) {
moel@348
  4121
				if ( results[i] === results[ i - 1 ] ) {
moel@348
  4122
					results.splice( i--, 1 );
moel@348
  4123
				}
moel@348
  4124
			}
moel@348
  4125
		}
moel@348
  4126
	}
moel@348
  4127
moel@348
  4128
	return results;
moel@348
  4129
};
moel@348
  4130
moel@348
  4131
Sizzle.matches = function( expr, set ) {
moel@348
  4132
	return Sizzle( expr, null, null, set );
moel@348
  4133
};
moel@348
  4134
moel@348
  4135
Sizzle.matchesSelector = function( node, expr ) {
moel@348
  4136
	return Sizzle( expr, null, null, [node] ).length > 0;
moel@348
  4137
};
moel@348
  4138
moel@348
  4139
Sizzle.find = function( expr, context, isXML ) {
moel@348
  4140
	var set, i, len, match, type, left;
moel@348
  4141
moel@348
  4142
	if ( !expr ) {
moel@348
  4143
		return [];
moel@348
  4144
	}
moel@348
  4145
moel@348
  4146
	for ( i = 0, len = Expr.order.length; i < len; i++ ) {
moel@348
  4147
		type = Expr.order[i];
moel@348
  4148
moel@348
  4149
		if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
moel@348
  4150
			left = match[1];
moel@348
  4151
			match.splice( 1, 1 );
moel@348
  4152
moel@348
  4153
			if ( left.substr( left.length - 1 ) !== "\\" ) {
moel@348
  4154
				match[1] = (match[1] || "").replace( rBackslash, "" );
moel@348
  4155
				set = Expr.find[ type ]( match, context, isXML );
moel@348
  4156
moel@348
  4157
				if ( set != null ) {
moel@348
  4158
					expr = expr.replace( Expr.match[ type ], "" );
moel@348
  4159
					break;
moel@348
  4160
				}
moel@348
  4161
			}
moel@348
  4162
		}
moel@348
  4163
	}
moel@348
  4164
moel@348
  4165
	if ( !set ) {
moel@348
  4166
		set = typeof context.getElementsByTagName !== "undefined" ?
moel@348
  4167
			context.getElementsByTagName( "*" ) :
moel@348
  4168
			[];
moel@348
  4169
	}
moel@348
  4170
moel@348
  4171
	return { set: set, expr: expr };
moel@348
  4172
};
moel@348
  4173
moel@348
  4174
Sizzle.filter = function( expr, set, inplace, not ) {
moel@348
  4175
	var match, anyFound,
moel@348
  4176
		type, found, item, filter, left,
moel@348
  4177
		i, pass,
moel@348
  4178
		old = expr,
moel@348
  4179
		result = [],
moel@348
  4180
		curLoop = set,
moel@348
  4181
		isXMLFilter = set && set[0] && Sizzle.isXML( set[0] );
moel@348
  4182
moel@348
  4183
	while ( expr && set.length ) {
moel@348
  4184
		for ( type in Expr.filter ) {
moel@348
  4185
			if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) {
moel@348
  4186
				filter = Expr.filter[ type ];
moel@348
  4187
				left = match[1];
moel@348
  4188
moel@348
  4189
				anyFound = false;
moel@348
  4190
moel@348
  4191
				match.splice(1,1);
moel@348
  4192
moel@348
  4193
				if ( left.substr( left.length - 1 ) === "\\" ) {
moel@348
  4194
					continue;
moel@348
  4195
				}
moel@348
  4196
moel@348
  4197
				if ( curLoop === result ) {
moel@348
  4198
					result = [];
moel@348
  4199
				}
moel@348
  4200
moel@348
  4201
				if ( Expr.preFilter[ type ] ) {
moel@348
  4202
					match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter );
moel@348
  4203
moel@348
  4204
					if ( !match ) {
moel@348
  4205
						anyFound = found = true;
moel@348
  4206
moel@348
  4207
					} else if ( match === true ) {
moel@348
  4208
						continue;
moel@348
  4209
					}
moel@348
  4210
				}
moel@348
  4211
moel@348
  4212
				if ( match ) {
moel@348
  4213
					for ( i = 0; (item = curLoop[i]) != null; i++ ) {
moel@348
  4214
						if ( item ) {
moel@348
  4215
							found = filter( item, match, i, curLoop );
moel@348
  4216
							pass = not ^ found;
moel@348
  4217
moel@348
  4218
							if ( inplace && found != null ) {
moel@348
  4219
								if ( pass ) {
moel@348
  4220
									anyFound = true;
moel@348
  4221
moel@348
  4222
								} else {
moel@348
  4223
									curLoop[i] = false;
moel@348
  4224
								}
moel@348
  4225
moel@348
  4226
							} else if ( pass ) {
moel@348
  4227
								result.push( item );
moel@348
  4228
								anyFound = true;
moel@348
  4229
							}
moel@348
  4230
						}
moel@348
  4231
					}
moel@348
  4232
				}
moel@348
  4233
moel@348
  4234
				if ( found !== undefined ) {
moel@348
  4235
					if ( !inplace ) {
moel@348
  4236
						curLoop = result;
moel@348
  4237
					}
moel@348
  4238
moel@348
  4239
					expr = expr.replace( Expr.match[ type ], "" );
moel@348
  4240
moel@348
  4241
					if ( !anyFound ) {
moel@348
  4242
						return [];
moel@348
  4243
					}
moel@348
  4244
moel@348
  4245
					break;
moel@348
  4246
				}
moel@348
  4247
			}
moel@348
  4248
		}
moel@348
  4249
moel@348
  4250
		// Improper expression
moel@348
  4251
		if ( expr === old ) {
moel@348
  4252
			if ( anyFound == null ) {
moel@348
  4253
				Sizzle.error( expr );
moel@348
  4254
moel@348
  4255
			} else {
moel@348
  4256
				break;
moel@348
  4257
			}
moel@348
  4258
		}
moel@348
  4259
moel@348
  4260
		old = expr;
moel@348
  4261
	}
moel@348
  4262
moel@348
  4263
	return curLoop;
moel@348
  4264
};
moel@348
  4265
moel@348
  4266
Sizzle.error = function( msg ) {
moel@348
  4267
	throw new Error( "Syntax error, unrecognized expression: " + msg );
moel@348
  4268
};
moel@348
  4269
moel@348
  4270
/**
moel@348
  4271
 * Utility function for retreiving the text value of an array of DOM nodes
moel@348
  4272
 * @param {Array|Element} elem
moel@348
  4273
 */
moel@348
  4274
var getText = Sizzle.getText = function( elem ) {
moel@348
  4275
    var i, node,
moel@348
  4276
		nodeType = elem.nodeType,
moel@348
  4277
		ret = "";
moel@348
  4278
moel@348
  4279
	if ( nodeType ) {
moel@348
  4280
		if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
moel@348
  4281
			// Use textContent || innerText for elements
moel@348
  4282
			if ( typeof elem.textContent === 'string' ) {
moel@348
  4283
				return elem.textContent;
moel@348
  4284
			} else if ( typeof elem.innerText === 'string' ) {
moel@348
  4285
				// Replace IE's carriage returns
moel@348
  4286
				return elem.innerText.replace( rReturn, '' );
moel@348
  4287
			} else {
moel@348
  4288
				// Traverse it's children
moel@348
  4289
				for ( elem = elem.firstChild; elem; elem = elem.nextSibling) {
moel@348
  4290
					ret += getText( elem );
moel@348
  4291
				}
moel@348
  4292
			}
moel@348
  4293
		} else if ( nodeType === 3 || nodeType === 4 ) {
moel@348
  4294
			return elem.nodeValue;
moel@348
  4295
		}
moel@348
  4296
	} else {
moel@348
  4297
moel@348
  4298
		// If no nodeType, this is expected to be an array
moel@348
  4299
		for ( i = 0; (node = elem[i]); i++ ) {
moel@348
  4300
			// Do not traverse comment nodes
moel@348
  4301
			if ( node.nodeType !== 8 ) {
moel@348
  4302
				ret += getText( node );
moel@348
  4303
			}
moel@348
  4304
		}
moel@348
  4305
	}
moel@348
  4306
	return ret;
moel@348
  4307
};
moel@348
  4308
moel@348
  4309
var Expr = Sizzle.selectors = {
moel@348
  4310
	order: [ "ID", "NAME", "TAG" ],
moel@348
  4311
moel@348
  4312
	match: {
moel@348
  4313
		ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
moel@348
  4314
		CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
moel@348
  4315
		NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,
moel@348
  4316
		ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/,
moel@348
  4317
		TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,
moel@348
  4318
		CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/,
moel@348
  4319
		POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,
moel@348
  4320
		PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/
moel@348
  4321
	},
moel@348
  4322
moel@348
  4323
	leftMatch: {},
moel@348
  4324
moel@348
  4325
	attrMap: {
moel@348
  4326
		"class": "className",
moel@348
  4327
		"for": "htmlFor"
moel@348
  4328
	},
moel@348
  4329
moel@348
  4330
	attrHandle: {
moel@348
  4331
		href: function( elem ) {
moel@348
  4332
			return elem.getAttribute( "href" );
moel@348
  4333
		},
moel@348
  4334
		type: function( elem ) {
moel@348
  4335
			return elem.getAttribute( "type" );
moel@348
  4336
		}
moel@348
  4337
	},
moel@348
  4338
moel@348
  4339
	relative: {
moel@348
  4340
		"+": function(checkSet, part){
moel@348
  4341
			var isPartStr = typeof part === "string",
moel@348
  4342
				isTag = isPartStr && !rNonWord.test( part ),
moel@348
  4343
				isPartStrNotTag = isPartStr && !isTag;
moel@348
  4344
moel@348
  4345
			if ( isTag ) {
moel@348
  4346
				part = part.toLowerCase();
moel@348
  4347
			}
moel@348
  4348
moel@348
  4349
			for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) {
moel@348
  4350
				if ( (elem = checkSet[i]) ) {
moel@348
  4351
					while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {}
moel@348
  4352
moel@348
  4353
					checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ?
moel@348
  4354
						elem || false :
moel@348
  4355
						elem === part;
moel@348
  4356
				}
moel@348
  4357
			}
moel@348
  4358
moel@348
  4359
			if ( isPartStrNotTag ) {
moel@348
  4360
				Sizzle.filter( part, checkSet, true );
moel@348
  4361
			}
moel@348
  4362
		},
moel@348
  4363
moel@348
  4364
		">": function( checkSet, part ) {
moel@348
  4365
			var elem,
moel@348
  4366
				isPartStr = typeof part === "string",
moel@348
  4367
				i = 0,
moel@348
  4368
				l = checkSet.length;
moel@348
  4369
moel@348
  4370
			if ( isPartStr && !rNonWord.test( part ) ) {
moel@348
  4371
				part = part.toLowerCase();
moel@348
  4372
moel@348
  4373
				for ( ; i < l; i++ ) {
moel@348
  4374
					elem = checkSet[i];
moel@348
  4375
moel@348
  4376
					if ( elem ) {
moel@348
  4377
						var parent = elem.parentNode;
moel@348
  4378
						checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false;
moel@348
  4379
					}
moel@348
  4380
				}
moel@348
  4381
moel@348
  4382
			} else {
moel@348
  4383
				for ( ; i < l; i++ ) {
moel@348
  4384
					elem = checkSet[i];
moel@348
  4385
moel@348
  4386
					if ( elem ) {
moel@348
  4387
						checkSet[i] = isPartStr ?
moel@348
  4388
							elem.parentNode :
moel@348
  4389
							elem.parentNode === part;
moel@348
  4390
					}
moel@348
  4391
				}
moel@348
  4392
moel@348
  4393
				if ( isPartStr ) {
moel@348
  4394
					Sizzle.filter( part, checkSet, true );
moel@348
  4395
				}
moel@348
  4396
			}
moel@348
  4397
		},
moel@348
  4398
moel@348
  4399
		"": function(checkSet, part, isXML){
moel@348
  4400
			var nodeCheck,
moel@348
  4401
				doneName = done++,
moel@348
  4402
				checkFn = dirCheck;
moel@348
  4403
moel@348
  4404
			if ( typeof part === "string" && !rNonWord.test( part ) ) {
moel@348
  4405
				part = part.toLowerCase();
moel@348
  4406
				nodeCheck = part;
moel@348
  4407
				checkFn = dirNodeCheck;
moel@348
  4408
			}
moel@348
  4409
moel@348
  4410
			checkFn( "parentNode", part, doneName, checkSet, nodeCheck, isXML );
moel@348
  4411
		},
moel@348
  4412
moel@348
  4413
		"~": function( checkSet, part, isXML ) {
moel@348
  4414
			var nodeCheck,
moel@348
  4415
				doneName = done++,
moel@348
  4416
				checkFn = dirCheck;
moel@348
  4417
moel@348
  4418
			if ( typeof part === "string" && !rNonWord.test( part ) ) {
moel@348
  4419
				part = part.toLowerCase();
moel@348
  4420
				nodeCheck = part;
moel@348
  4421
				checkFn = dirNodeCheck;
moel@348
  4422
			}
moel@348
  4423
moel@348
  4424
			checkFn( "previousSibling", part, doneName, checkSet, nodeCheck, isXML );
moel@348
  4425
		}
moel@348
  4426
	},
moel@348
  4427
moel@348
  4428
	find: {
moel@348
  4429
		ID: function( match, context, isXML ) {
moel@348
  4430
			if ( typeof context.getElementById !== "undefined" && !isXML ) {
moel@348
  4431
				var m = context.getElementById(match[1]);
moel@348
  4432
				// Check parentNode to catch when Blackberry 4.6 returns
moel@348
  4433
				// nodes that are no longer in the document #6963
moel@348
  4434
				return m && m.parentNode ? [m] : [];
moel@348
  4435
			}
moel@348
  4436
		},
moel@348
  4437
moel@348
  4438
		NAME: function( match, context ) {
moel@348
  4439
			if ( typeof context.getElementsByName !== "undefined" ) {
moel@348
  4440
				var ret = [],
moel@348
  4441
					results = context.getElementsByName( match[1] );
moel@348
  4442
moel@348
  4443
				for ( var i = 0, l = results.length; i < l; i++ ) {
moel@348
  4444
					if ( results[i].getAttribute("name") === match[1] ) {
moel@348
  4445
						ret.push( results[i] );
moel@348
  4446
					}
moel@348
  4447
				}
moel@348
  4448
moel@348
  4449
				return ret.length === 0 ? null : ret;
moel@348
  4450
			}
moel@348
  4451
		},
moel@348
  4452
moel@348
  4453
		TAG: function( match, context ) {
moel@348
  4454
			if ( typeof context.getElementsByTagName !== "undefined" ) {
moel@348
  4455
				return context.getElementsByTagName( match[1] );
moel@348
  4456
			}
moel@348
  4457
		}
moel@348
  4458
	},
moel@348
  4459
	preFilter: {
moel@348
  4460
		CLASS: function( match, curLoop, inplace, result, not, isXML ) {
moel@348
  4461
			match = " " + match[1].replace( rBackslash, "" ) + " ";
moel@348
  4462
moel@348
  4463
			if ( isXML ) {
moel@348
  4464
				return match;
moel@348
  4465
			}
moel@348
  4466
moel@348
  4467
			for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) {
moel@348
  4468
				if ( elem ) {
moel@348
  4469
					if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n\r]/g, " ").indexOf(match) >= 0) ) {
moel@348
  4470
						if ( !inplace ) {
moel@348
  4471
							result.push( elem );
moel@348
  4472
						}
moel@348
  4473
moel@348
  4474
					} else if ( inplace ) {
moel@348
  4475
						curLoop[i] = false;
moel@348
  4476
					}
moel@348
  4477
				}
moel@348
  4478
			}
moel@348
  4479
moel@348
  4480
			return false;
moel@348
  4481
		},
moel@348
  4482
moel@348
  4483
		ID: function( match ) {
moel@348
  4484
			return match[1].replace( rBackslash, "" );
moel@348
  4485
		},
moel@348
  4486
moel@348
  4487
		TAG: function( match, curLoop ) {
moel@348
  4488
			return match[1].replace( rBackslash, "" ).toLowerCase();
moel@348
  4489
		},
moel@348
  4490
moel@348
  4491
		CHILD: function( match ) {
moel@348
  4492
			if ( match[1] === "nth" ) {
moel@348
  4493
				if ( !match[2] ) {
moel@348
  4494
					Sizzle.error( match[0] );
moel@348
  4495
				}
moel@348
  4496
moel@348
  4497
				match[2] = match[2].replace(/^\+|\s*/g, '');
moel@348
  4498
moel@348
  4499
				// parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
moel@348
  4500
				var test = /(-?)(\d*)(?:n([+\-]?\d*))?/.exec(
moel@348
  4501
					match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" ||
moel@348
  4502
					!/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);
moel@348
  4503
moel@348
  4504
				// calculate the numbers (first)n+(last) including if they are negative
moel@348
  4505
				match[2] = (test[1] + (test[2] || 1)) - 0;
moel@348
  4506
				match[3] = test[3] - 0;
moel@348
  4507
			}
moel@348
  4508
			else if ( match[2] ) {
moel@348
  4509
				Sizzle.error( match[0] );
moel@348
  4510
			}
moel@348
  4511
moel@348
  4512
			// TODO: Move to normal caching system
moel@348
  4513
			match[0] = done++;
moel@348
  4514
moel@348
  4515
			return match;
moel@348
  4516
		},
moel@348
  4517
moel@348
  4518
		ATTR: function( match, curLoop, inplace, result, not, isXML ) {
moel@348
  4519
			var name = match[1] = match[1].replace( rBackslash, "" );
moel@348
  4520
moel@348
  4521
			if ( !isXML && Expr.attrMap[name] ) {
moel@348
  4522
				match[1] = Expr.attrMap[name];
moel@348
  4523
			}
moel@348
  4524
moel@348
  4525
			// Handle if an un-quoted value was used
moel@348
  4526
			match[4] = ( match[4] || match[5] || "" ).replace( rBackslash, "" );
moel@348
  4527
moel@348
  4528
			if ( match[2] === "~=" ) {
moel@348
  4529
				match[4] = " " + match[4] + " ";
moel@348
  4530
			}
moel@348
  4531
moel@348
  4532
			return match;
moel@348
  4533
		},
moel@348
  4534
moel@348
  4535
		PSEUDO: function( match, curLoop, inplace, result, not ) {
moel@348
  4536
			if ( match[1] === "not" ) {
moel@348
  4537
				// If we're dealing with a complex expression, or a simple one
moel@348
  4538
				if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) {
moel@348
  4539
					match[3] = Sizzle(match[3], null, null, curLoop);
moel@348
  4540
moel@348
  4541
				} else {
moel@348
  4542
					var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);
moel@348
  4543
moel@348
  4544
					if ( !inplace ) {
moel@348
  4545
						result.push.apply( result, ret );
moel@348
  4546
					}
moel@348
  4547
moel@348
  4548
					return false;
moel@348
  4549
				}
moel@348
  4550
moel@348
  4551
			} else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
moel@348
  4552
				return true;
moel@348
  4553
			}
moel@348
  4554
moel@348
  4555
			return match;
moel@348
  4556
		},
moel@348
  4557
moel@348
  4558
		POS: function( match ) {
moel@348
  4559
			match.unshift( true );
moel@348
  4560
moel@348
  4561
			return match;
moel@348
  4562
		}
moel@348
  4563
	},
moel@348
  4564
moel@348
  4565
	filters: {
moel@348
  4566
		enabled: function( elem ) {
moel@348
  4567
			return elem.disabled === false && elem.type !== "hidden";
moel@348
  4568
		},
moel@348
  4569
moel@348
  4570
		disabled: function( elem ) {
moel@348
  4571
			return elem.disabled === true;
moel@348
  4572
		},
moel@348
  4573
moel@348
  4574
		checked: function( elem ) {
moel@348
  4575
			return elem.checked === true;
moel@348
  4576
		},
moel@348
  4577
moel@348
  4578
		selected: function( elem ) {
moel@348
  4579
			// Accessing this property makes selected-by-default
moel@348
  4580
			// options in Safari work properly
moel@348
  4581
			if ( elem.parentNode ) {
moel@348
  4582
				elem.parentNode.selectedIndex;
moel@348
  4583
			}
moel@348
  4584
moel@348
  4585
			return elem.selected === true;
moel@348
  4586
		},
moel@348
  4587
moel@348
  4588
		parent: function( elem ) {
moel@348
  4589
			return !!elem.firstChild;
moel@348
  4590
		},
moel@348
  4591
moel@348
  4592
		empty: function( elem ) {
moel@348
  4593
			return !elem.firstChild;
moel@348
  4594
		},
moel@348
  4595
moel@348
  4596
		has: function( elem, i, match ) {
moel@348
  4597
			return !!Sizzle( match[3], elem ).length;
moel@348
  4598
		},
moel@348
  4599
moel@348
  4600
		header: function( elem ) {
moel@348
  4601
			return (/h\d/i).test( elem.nodeName );
moel@348
  4602
		},
moel@348
  4603
moel@348
  4604
		text: function( elem ) {
moel@348
  4605
			var attr = elem.getAttribute( "type" ), type = elem.type;
moel@348
  4606
			// IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
moel@348
  4607
			// use getAttribute instead to test this case
moel@348
  4608
			return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null );
moel@348
  4609
		},
moel@348
  4610
moel@348
  4611
		radio: function( elem ) {
moel@348
  4612
			return elem.nodeName.toLowerCase() === "input" && "radio" === elem.type;
moel@348
  4613
		},
moel@348
  4614
moel@348
  4615
		checkbox: function( elem ) {
moel@348
  4616
			return elem.nodeName.toLowerCase() === "input" && "checkbox" === elem.type;
moel@348
  4617
		},
moel@348
  4618
moel@348
  4619
		file: function( elem ) {
moel@348
  4620
			return elem.nodeName.toLowerCase() === "input" && "file" === elem.type;
moel@348
  4621
		},
moel@348
  4622
moel@348
  4623
		password: function( elem ) {
moel@348
  4624
			return elem.nodeName.toLowerCase() === "input" && "password" === elem.type;
moel@348
  4625
		},
moel@348
  4626
moel@348
  4627
		submit: function( elem ) {
moel@348
  4628
			var name = elem.nodeName.toLowerCase();
moel@348
  4629
			return (name === "input" || name === "button") && "submit" === elem.type;
moel@348
  4630
		},
moel@348
  4631
moel@348
  4632
		image: function( elem ) {
moel@348
  4633
			return elem.nodeName.toLowerCase() === "input" && "image" === elem.type;
moel@348
  4634
		},
moel@348
  4635
moel@348
  4636
		reset: function( elem ) {
moel@348
  4637
			var name = elem.nodeName.toLowerCase();
moel@348
  4638
			return (name === "input" || name === "button") && "reset" === elem.type;
moel@348
  4639
		},
moel@348
  4640
moel@348
  4641
		button: function( elem ) {
moel@348
  4642
			var name = elem.nodeName.toLowerCase();
moel@348
  4643
			return name === "input" && "button" === elem.type || name === "button";
moel@348
  4644
		},
moel@348
  4645
moel@348
  4646
		input: function( elem ) {
moel@348
  4647
			return (/input|select|textarea|button/i).test( elem.nodeName );
moel@348
  4648
		},
moel@348
  4649
moel@348
  4650
		focus: function( elem ) {
moel@348
  4651
			return elem === elem.ownerDocument.activeElement;
moel@348
  4652
		}
moel@348
  4653
	},
moel@348
  4654
	setFilters: {
moel@348
  4655
		first: function( elem, i ) {
moel@348
  4656
			return i === 0;
moel@348
  4657
		},
moel@348
  4658
moel@348
  4659
		last: function( elem, i, match, array ) {
moel@348
  4660
			return i === array.length - 1;
moel@348
  4661
		},
moel@348
  4662
moel@348
  4663
		even: function( elem, i ) {
moel@348
  4664
			return i % 2 === 0;
moel@348
  4665
		},
moel@348
  4666
moel@348
  4667
		odd: function( elem, i ) {
moel@348
  4668
			return i % 2 === 1;
moel@348
  4669
		},
moel@348
  4670
moel@348
  4671
		lt: function( elem, i, match ) {
moel@348
  4672
			return i < match[3] - 0;
moel@348
  4673
		},
moel@348
  4674
moel@348
  4675
		gt: function( elem, i, match ) {
moel@348
  4676
			return i > match[3] - 0;
moel@348
  4677
		},
moel@348
  4678
moel@348
  4679
		nth: function( elem, i, match ) {
moel@348
  4680
			return match[3] - 0 === i;
moel@348
  4681
		},
moel@348
  4682
moel@348
  4683
		eq: function( elem, i, match ) {
moel@348
  4684
			return match[3] - 0 === i;
moel@348
  4685
		}
moel@348
  4686
	},
moel@348
  4687
	filter: {
moel@348
  4688
		PSEUDO: function( elem, match, i, array ) {
moel@348
  4689
			var name = match[1],
moel@348
  4690
				filter = Expr.filters[ name ];
moel@348
  4691
moel@348
  4692
			if ( filter ) {
moel@348
  4693
				return filter( elem, i, match, array );
moel@348
  4694
moel@348
  4695
			} else if ( name === "contains" ) {
moel@348
  4696
				return (elem.textContent || elem.innerText || getText([ elem ]) || "").indexOf(match[3]) >= 0;
moel@348
  4697
moel@348
  4698
			} else if ( name === "not" ) {
moel@348
  4699
				var not = match[3];
moel@348
  4700
moel@348
  4701
				for ( var j = 0, l = not.length; j < l; j++ ) {
moel@348
  4702
					if ( not[j] === elem ) {
moel@348
  4703
						return false;
moel@348
  4704
					}
moel@348
  4705
				}
moel@348
  4706
moel@348
  4707
				return true;
moel@348
  4708
moel@348
  4709
			} else {
moel@348
  4710
				Sizzle.error( name );
moel@348
  4711
			}
moel@348
  4712
		},
moel@348
  4713
moel@348
  4714
		CHILD: function( elem, match ) {
moel@348
  4715
			var first, last,
moel@348
  4716
				doneName, parent, cache,
moel@348
  4717
				count, diff,
moel@348
  4718
				type = match[1],
moel@348
  4719
				node = elem;
moel@348
  4720
moel@348
  4721
			switch ( type ) {
moel@348
  4722
				case "only":
moel@348
  4723
				case "first":
moel@348
  4724
					while ( (node = node.previousSibling) ) {
moel@348
  4725
						if ( node.nodeType === 1 ) {
moel@348
  4726
							return false;
moel@348
  4727
						}
moel@348
  4728
					}
moel@348
  4729
moel@348
  4730
					if ( type === "first" ) {
moel@348
  4731
						return true;
moel@348
  4732
					}
moel@348
  4733
moel@348
  4734
					node = elem;
moel@348
  4735
moel@348
  4736
					/* falls through */
moel@348
  4737
				case "last":
moel@348
  4738
					while ( (node = node.nextSibling) ) {
moel@348
  4739
						if ( node.nodeType === 1 ) {
moel@348
  4740
							return false;
moel@348
  4741
						}
moel@348
  4742
					}
moel@348
  4743
moel@348
  4744
					return true;
moel@348
  4745
moel@348
  4746
				case "nth":
moel@348
  4747
					first = match[2];
moel@348
  4748
					last = match[3];
moel@348
  4749
moel@348
  4750
					if ( first === 1 && last === 0 ) {
moel@348
  4751
						return true;
moel@348
  4752
					}
moel@348
  4753
moel@348
  4754
					doneName = match[0];
moel@348
  4755
					parent = elem.parentNode;
moel@348
  4756
moel@348
  4757
					if ( parent && (parent[ expando ] !== doneName || !elem.nodeIndex) ) {
moel@348
  4758
						count = 0;
moel@348
  4759
moel@348
  4760
						for ( node = parent.firstChild; node; node = node.nextSibling ) {
moel@348
  4761
							if ( node.nodeType === 1 ) {
moel@348
  4762
								node.nodeIndex = ++count;
moel@348
  4763
							}
moel@348
  4764
						}
moel@348
  4765
moel@348
  4766
						parent[ expando ] = doneName;
moel@348
  4767
					}
moel@348
  4768
moel@348
  4769
					diff = elem.nodeIndex - last;
moel@348
  4770
moel@348
  4771
					if ( first === 0 ) {
moel@348
  4772
						return diff === 0;
moel@348
  4773
moel@348
  4774
					} else {
moel@348
  4775
						return ( diff % first === 0 && diff / first >= 0 );
moel@348
  4776
					}
moel@348
  4777
			}
moel@348
  4778
		},
moel@348
  4779
moel@348
  4780
		ID: function( elem, match ) {
moel@348
  4781
			return elem.nodeType === 1 && elem.getAttribute("id") === match;
moel@348
  4782
		},
moel@348
  4783
moel@348
  4784
		TAG: function( elem, match ) {
moel@348
  4785
			return (match === "*" && elem.nodeType === 1) || !!elem.nodeName && elem.nodeName.toLowerCase() === match;
moel@348
  4786
		},
moel@348
  4787
moel@348
  4788
		CLASS: function( elem, match ) {
moel@348
  4789
			return (" " + (elem.className || elem.getAttribute("class")) + " ")
moel@348
  4790
				.indexOf( match ) > -1;
moel@348
  4791
		},
moel@348
  4792
moel@348
  4793
		ATTR: function( elem, match ) {
moel@348
  4794
			var name = match[1],
moel@348
  4795
				result = Sizzle.attr ?
moel@348
  4796
					Sizzle.attr( elem, name ) :
moel@348
  4797
					Expr.attrHandle[ name ] ?
moel@348
  4798
					Expr.attrHandle[ name ]( elem ) :
moel@348
  4799
					elem[ name ] != null ?
moel@348
  4800
						elem[ name ] :
moel@348
  4801
						elem.getAttribute( name ),
moel@348
  4802
				value = result + "",
moel@348
  4803
				type = match[2],
moel@348
  4804
				check = match[4];
moel@348
  4805
moel@348
  4806
			return result == null ?
moel@348
  4807
				type === "!=" :
moel@348
  4808
				!type && Sizzle.attr ?
moel@348
  4809
				result != null :
moel@348
  4810
				type === "=" ?
moel@348
  4811
				value === check :
moel@348
  4812
				type === "*=" ?
moel@348
  4813
				value.indexOf(check) >= 0 :
moel@348
  4814
				type === "~=" ?
moel@348
  4815
				(" " + value + " ").indexOf(check) >= 0 :
moel@348
  4816
				!check ?
moel@348
  4817
				value && result !== false :
moel@348
  4818
				type === "!=" ?
moel@348
  4819
				value !== check :
moel@348
  4820
				type === "^=" ?
moel@348
  4821
				value.indexOf(check) === 0 :
moel@348
  4822
				type === "$=" ?
moel@348
  4823
				value.substr(value.length - check.length) === check :
moel@348
  4824
				type === "|=" ?
moel@348
  4825
				value === check || value.substr(0, check.length + 1) === check + "-" :
moel@348
  4826
				false;
moel@348
  4827
		},
moel@348
  4828
moel@348
  4829
		POS: function( elem, match, i, array ) {
moel@348
  4830
			var name = match[2],
moel@348
  4831
				filter = Expr.setFilters[ name ];
moel@348
  4832
moel@348
  4833
			if ( filter ) {
moel@348
  4834
				return filter( elem, i, match, array );
moel@348
  4835
			}
moel@348
  4836
		}
moel@348
  4837
	}
moel@348
  4838
};
moel@348
  4839
moel@348
  4840
var origPOS = Expr.match.POS,
moel@348
  4841
	fescape = function(all, num){
moel@348
  4842
		return "\\" + (num - 0 + 1);
moel@348
  4843
	};
moel@348
  4844
moel@348
  4845
for ( var type in Expr.match ) {
moel@348
  4846
	Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) );
moel@348
  4847
	Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) );
moel@348
  4848
}
moel@348
  4849
// Expose origPOS
moel@348
  4850
// "global" as in regardless of relation to brackets/parens
moel@348
  4851
Expr.match.globalPOS = origPOS;
moel@348
  4852
moel@348
  4853
var makeArray = function( array, results ) {
moel@348
  4854
	array = Array.prototype.slice.call( array, 0 );
moel@348
  4855
moel@348
  4856
	if ( results ) {
moel@348
  4857
		results.push.apply( results, array );
moel@348
  4858
		return results;
moel@348
  4859
	}
moel@348
  4860
moel@348
  4861
	return array;
moel@348
  4862
};
moel@348
  4863
moel@348
  4864
// Perform a simple check to determine if the browser is capable of
moel@348
  4865
// converting a NodeList to an array using builtin methods.
moel@348
  4866
// Also verifies that the returned array holds DOM nodes
moel@348
  4867
// (which is not the case in the Blackberry browser)
moel@348
  4868
try {
moel@348
  4869
	Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType;
moel@348
  4870
moel@348
  4871
// Provide a fallback method if it does not work
moel@348
  4872
} catch( e ) {
moel@348
  4873
	makeArray = function( array, results ) {
moel@348
  4874
		var i = 0,
moel@348
  4875
			ret = results || [];
moel@348
  4876
moel@348
  4877
		if ( toString.call(array) === "[object Array]" ) {
moel@348
  4878
			Array.prototype.push.apply( ret, array );
moel@348
  4879
moel@348
  4880
		} else {
moel@348
  4881
			if ( typeof array.length === "number" ) {
moel@348
  4882
				for ( var l = array.length; i < l; i++ ) {
moel@348
  4883
					ret.push( array[i] );
moel@348
  4884
				}
moel@348
  4885
moel@348
  4886
			} else {
moel@348
  4887
				for ( ; array[i]; i++ ) {
moel@348
  4888
					ret.push( array[i] );
moel@348
  4889
				}
moel@348
  4890
			}
moel@348
  4891
		}
moel@348
  4892
moel@348
  4893
		return ret;
moel@348
  4894
	};
moel@348
  4895
}
moel@348
  4896
moel@348
  4897
var sortOrder, siblingCheck;
moel@348
  4898
moel@348
  4899
if ( document.documentElement.compareDocumentPosition ) {
moel@348
  4900
	sortOrder = function( a, b ) {
moel@348
  4901
		if ( a === b ) {
moel@348
  4902
			hasDuplicate = true;
moel@348
  4903
			return 0;
moel@348
  4904
		}
moel@348
  4905
moel@348
  4906
		if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) {
moel@348
  4907
			return a.compareDocumentPosition ? -1 : 1;
moel@348
  4908
		}
moel@348
  4909
moel@348
  4910
		return a.compareDocumentPosition(b) & 4 ? -1 : 1;
moel@348
  4911
	};
moel@348
  4912
moel@348
  4913
} else {
moel@348
  4914
	sortOrder = function( a, b ) {
moel@348
  4915
		// The nodes are identical, we can exit early
moel@348
  4916
		if ( a === b ) {
moel@348
  4917
			hasDuplicate = true;
moel@348
  4918
			return 0;
moel@348
  4919
moel@348
  4920
		// Fallback to using sourceIndex (in IE) if it's available on both nodes
moel@348
  4921
		} else if ( a.sourceIndex && b.sourceIndex ) {
moel@348
  4922
			return a.sourceIndex - b.sourceIndex;
moel@348
  4923
		}
moel@348
  4924
moel@348
  4925
		var al, bl,
moel@348
  4926
			ap = [],
moel@348
  4927
			bp = [],
moel@348
  4928
			aup = a.parentNode,
moel@348
  4929
			bup = b.parentNode,
moel@348
  4930
			cur = aup;
moel@348
  4931
moel@348
  4932
		// If the nodes are siblings (or identical) we can do a quick check
moel@348
  4933
		if ( aup === bup ) {
moel@348
  4934
			return siblingCheck( a, b );
moel@348
  4935
moel@348
  4936
		// If no parents were found then the nodes are disconnected
moel@348
  4937
		} else if ( !aup ) {
moel@348
  4938
			return -1;
moel@348
  4939
moel@348
  4940
		} else if ( !bup ) {
moel@348
  4941
			return 1;
moel@348
  4942
		}
moel@348
  4943
moel@348
  4944
		// Otherwise they're somewhere else in the tree so we need
moel@348
  4945
		// to build up a full list of the parentNodes for comparison
moel@348
  4946
		while ( cur ) {
moel@348
  4947
			ap.unshift( cur );
moel@348
  4948
			cur = cur.parentNode;
moel@348
  4949
		}
moel@348
  4950
moel@348
  4951
		cur = bup;
moel@348
  4952
moel@348
  4953
		while ( cur ) {
moel@348
  4954
			bp.unshift( cur );
moel@348
  4955
			cur = cur.parentNode;
moel@348
  4956
		}
moel@348
  4957
moel@348
  4958
		al = ap.length;
moel@348
  4959
		bl = bp.length;
moel@348
  4960
moel@348
  4961
		// Start walking down the tree looking for a discrepancy
moel@348
  4962
		for ( var i = 0; i < al && i < bl; i++ ) {
moel@348
  4963
			if ( ap[i] !== bp[i] ) {
moel@348
  4964
				return siblingCheck( ap[i], bp[i] );
moel@348
  4965
			}
moel@348
  4966
		}
moel@348
  4967
moel@348
  4968
		// We ended someplace up the tree so do a sibling check
moel@348
  4969
		return i === al ?
moel@348
  4970
			siblingCheck( a, bp[i], -1 ) :
moel@348
  4971
			siblingCheck( ap[i], b, 1 );
moel@348
  4972
	};
moel@348
  4973
moel@348
  4974
	siblingCheck = function( a, b, ret ) {
moel@348
  4975
		if ( a === b ) {
moel@348
  4976
			return ret;
moel@348
  4977
		}
moel@348
  4978
moel@348
  4979
		var cur = a.nextSibling;
moel@348
  4980
moel@348
  4981
		while ( cur ) {
moel@348
  4982
			if ( cur === b ) {
moel@348
  4983
				return -1;
moel@348
  4984
			}
moel@348
  4985
moel@348
  4986
			cur = cur.nextSibling;
moel@348
  4987
		}
moel@348
  4988
moel@348
  4989
		return 1;
moel@348
  4990
	};
moel@348
  4991
}
moel@348
  4992
moel@348
  4993
// Check to see if the browser returns elements by name when
moel@348
  4994
// querying by getElementById (and provide a workaround)
moel@348
  4995
(function(){
moel@348
  4996
	// We're going to inject a fake input element with a specified name
moel@348
  4997
	var form = document.createElement("div"),
moel@348
  4998
		id = "script" + (new Date()).getTime(),
moel@348
  4999
		root = document.documentElement;
moel@348
  5000
moel@348
  5001
	form.innerHTML = "<a name='" + id + "'/>";
moel@348
  5002
moel@348
  5003
	// Inject it into the root element, check its status, and remove it quickly
moel@348
  5004
	root.insertBefore( form, root.firstChild );
moel@348
  5005
moel@348
  5006
	// The workaround has to do additional checks after a getElementById
moel@348
  5007
	// Which slows things down for other browsers (hence the branching)
moel@348
  5008
	if ( document.getElementById( id ) ) {
moel@348
  5009
		Expr.find.ID = function( match, context, isXML ) {
moel@348
  5010
			if ( typeof context.getElementById !== "undefined" && !isXML ) {
moel@348
  5011
				var m = context.getElementById(match[1]);
moel@348
  5012
moel@348
  5013
				return m ?
moel@348
  5014
					m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ?
moel@348
  5015
						[m] :
moel@348
  5016
						undefined :
moel@348
  5017
					[];
moel@348
  5018
			}
moel@348
  5019
		};
moel@348
  5020
moel@348
  5021
		Expr.filter.ID = function( elem, match ) {
moel@348
  5022
			var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
moel@348
  5023
moel@348
  5024
			return elem.nodeType === 1 && node && node.nodeValue === match;
moel@348
  5025
		};
moel@348
  5026
	}
moel@348
  5027
moel@348
  5028
	root.removeChild( form );
moel@348
  5029
moel@348
  5030
	// release memory in IE
moel@348
  5031
	root = form = null;
moel@348
  5032
})();
moel@348
  5033
moel@348
  5034
(function(){
moel@348
  5035
	// Check to see if the browser returns only elements
moel@348
  5036
	// when doing getElementsByTagName("*")
moel@348
  5037
moel@348
  5038
	// Create a fake element
moel@348
  5039
	var div = document.createElement("div");
moel@348
  5040
	div.appendChild( document.createComment("") );
moel@348
  5041
moel@348
  5042
	// Make sure no comments are found
moel@348
  5043
	if ( div.getElementsByTagName("*").length > 0 ) {
moel@348
  5044
		Expr.find.TAG = function( match, context ) {
moel@348
  5045
			var results = context.getElementsByTagName( match[1] );
moel@348
  5046
moel@348
  5047
			// Filter out possible comments
moel@348
  5048
			if ( match[1] === "*" ) {
moel@348
  5049
				var tmp = [];
moel@348
  5050
moel@348
  5051
				for ( var i = 0; results[i]; i++ ) {
moel@348
  5052
					if ( results[i].nodeType === 1 ) {
moel@348
  5053
						tmp.push( results[i] );
moel@348
  5054
					}
moel@348
  5055
				}
moel@348
  5056
moel@348
  5057
				results = tmp;
moel@348
  5058
			}
moel@348
  5059
moel@348
  5060
			return results;
moel@348
  5061
		};
moel@348
  5062
	}
moel@348
  5063
moel@348
  5064
	// Check to see if an attribute returns normalized href attributes
moel@348
  5065
	div.innerHTML = "<a href='#'></a>";
moel@348
  5066
moel@348
  5067
	if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" &&
moel@348
  5068
			div.firstChild.getAttribute("href") !== "#" ) {
moel@348
  5069
moel@348
  5070
		Expr.attrHandle.href = function( elem ) {
moel@348
  5071
			return elem.getAttribute( "href", 2 );
moel@348
  5072
		};
moel@348
  5073
	}
moel@348
  5074
moel@348
  5075
	// release memory in IE
moel@348
  5076
	div = null;
moel@348
  5077
})();
moel@348
  5078
moel@348
  5079
if ( document.querySelectorAll ) {
moel@348
  5080
	(function(){
moel@348
  5081
		var oldSizzle = Sizzle,
moel@348
  5082
			div = document.createElement("div"),
moel@348
  5083
			id = "__sizzle__";
moel@348
  5084
moel@348
  5085
		div.innerHTML = "<p class='TEST'></p>";
moel@348
  5086
moel@348
  5087
		// Safari can't handle uppercase or unicode characters when
moel@348
  5088
		// in quirks mode.
moel@348
  5089
		if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
moel@348
  5090
			return;
moel@348
  5091
		}
moel@348
  5092
moel@348
  5093
		Sizzle = function( query, context, extra, seed ) {
moel@348
  5094
			context = context || document;
moel@348
  5095
moel@348
  5096
			// Only use querySelectorAll on non-XML documents
moel@348
  5097
			// (ID selectors don't work in non-HTML documents)
moel@348
  5098
			if ( !seed && !Sizzle.isXML(context) ) {
moel@348
  5099
				// See if we find a selector to speed up
moel@348
  5100
				var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query );
moel@348
  5101
moel@348
  5102
				if ( match && (context.nodeType === 1 || context.nodeType === 9) ) {
moel@348
  5103
					// Speed-up: Sizzle("TAG")
moel@348
  5104
					if ( match[1] ) {
moel@348
  5105
						return makeArray( context.getElementsByTagName( query ), extra );
moel@348
  5106
moel@348
  5107
					// Speed-up: Sizzle(".CLASS")
moel@348
  5108
					} else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) {
moel@348
  5109
						return makeArray( context.getElementsByClassName( match[2] ), extra );
moel@348
  5110
					}
moel@348
  5111
				}
moel@348
  5112
moel@348
  5113
				if ( context.nodeType === 9 ) {
moel@348
  5114
					// Speed-up: Sizzle("body")
moel@348
  5115
					// The body element only exists once, optimize finding it
moel@348
  5116
					if ( query === "body" && context.body ) {
moel@348
  5117
						return makeArray( [ context.body ], extra );
moel@348
  5118
moel@348
  5119
					// Speed-up: Sizzle("#ID")
moel@348
  5120
					} else if ( match && match[3] ) {
moel@348
  5121
						var elem = context.getElementById( match[3] );
moel@348
  5122
moel@348
  5123
						// Check parentNode to catch when Blackberry 4.6 returns
moel@348
  5124
						// nodes that are no longer in the document #6963
moel@348
  5125
						if ( elem && elem.parentNode ) {
moel@348
  5126
							// Handle the case where IE and Opera return items
moel@348
  5127
							// by name instead of ID
moel@348
  5128
							if ( elem.id === match[3] ) {
moel@348
  5129
								return makeArray( [ elem ], extra );
moel@348
  5130
							}
moel@348
  5131
moel@348
  5132
						} else {
moel@348
  5133
							return makeArray( [], extra );
moel@348
  5134
						}
moel@348
  5135
					}
moel@348
  5136
moel@348
  5137
					try {
moel@348
  5138
						return makeArray( context.querySelectorAll(query), extra );
moel@348
  5139
					} catch(qsaError) {}
moel@348
  5140
moel@348
  5141
				// qSA works strangely on Element-rooted queries
moel@348
  5142
				// We can work around this by specifying an extra ID on the root
moel@348
  5143
				// and working up from there (Thanks to Andrew Dupont for the technique)
moel@348
  5144
				// IE 8 doesn't work on object elements
moel@348
  5145
				} else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
moel@348
  5146
					var oldContext = context,
moel@348
  5147
						old = context.getAttribute( "id" ),
moel@348
  5148
						nid = old || id,
moel@348
  5149
						hasParent = context.parentNode,
moel@348
  5150
						relativeHierarchySelector = /^\s*[+~]/.test( query );
moel@348
  5151
moel@348
  5152
					if ( !old ) {
moel@348
  5153
						context.setAttribute( "id", nid );
moel@348
  5154
					} else {
moel@348
  5155
						nid = nid.replace( /'/g, "\\$&" );
moel@348
  5156
					}
moel@348
  5157
					if ( relativeHierarchySelector && hasParent ) {
moel@348
  5158
						context = context.parentNode;
moel@348
  5159
					}
moel@348
  5160
moel@348
  5161
					try {
moel@348
  5162
						if ( !relativeHierarchySelector || hasParent ) {
moel@348
  5163
							return makeArray( context.querySelectorAll( "[id='" + nid + "'] " + query ), extra );
moel@348
  5164
						}
moel@348
  5165
moel@348
  5166
					} catch(pseudoError) {
moel@348
  5167
					} finally {
moel@348
  5168
						if ( !old ) {
moel@348
  5169
							oldContext.removeAttribute( "id" );
moel@348
  5170
						}
moel@348
  5171
					}
moel@348
  5172
				}
moel@348
  5173
			}
moel@348
  5174
moel@348
  5175
			return oldSizzle(query, context, extra, seed);
moel@348
  5176
		};
moel@348
  5177
moel@348
  5178
		for ( var prop in oldSizzle ) {
moel@348
  5179
			Sizzle[ prop ] = oldSizzle[ prop ];
moel@348
  5180
		}
moel@348
  5181
moel@348
  5182
		// release memory in IE
moel@348
  5183
		div = null;
moel@348
  5184
	})();
moel@348
  5185
}
moel@348
  5186
moel@348
  5187
(function(){
moel@348
  5188
	var html = document.documentElement,
moel@348
  5189
		matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector;
moel@348
  5190
moel@348
  5191
	if ( matches ) {
moel@348
  5192
		// Check to see if it's possible to do matchesSelector
moel@348
  5193
		// on a disconnected node (IE 9 fails this)
moel@348
  5194
		var disconnectedMatch = !matches.call( document.createElement( "div" ), "div" ),
moel@348
  5195
			pseudoWorks = false;
moel@348
  5196
moel@348
  5197
		try {
moel@348
  5198
			// This should fail with an exception
moel@348
  5199
			// Gecko does not error, returns false instead
moel@348
  5200
			matches.call( document.documentElement, "[test!='']:sizzle" );
moel@348
  5201
moel@348
  5202
		} catch( pseudoError ) {
moel@348
  5203
			pseudoWorks = true;
moel@348
  5204
		}
moel@348
  5205
moel@348
  5206
		Sizzle.matchesSelector = function( node, expr ) {
moel@348
  5207
			// Make sure that attribute selectors are quoted
moel@348
  5208
			expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']");
moel@348
  5209
moel@348
  5210
			if ( !Sizzle.isXML( node ) ) {
moel@348
  5211
				try {
moel@348
  5212
					if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) {
moel@348
  5213
						var ret = matches.call( node, expr );
moel@348
  5214
moel@348
  5215
						// IE 9's matchesSelector returns false on disconnected nodes
moel@348
  5216
						if ( ret || !disconnectedMatch ||
moel@348
  5217
								// As well, disconnected nodes are said to be in a document
moel@348
  5218
								// fragment in IE 9, so check for that
moel@348
  5219
								node.document && node.document.nodeType !== 11 ) {
moel@348
  5220
							return ret;
moel@348
  5221
						}
moel@348
  5222
					}
moel@348
  5223
				} catch(e) {}
moel@348
  5224
			}
moel@348
  5225
moel@348
  5226
			return Sizzle(expr, null, null, [node]).length > 0;
moel@348
  5227
		};
moel@348
  5228
	}
moel@348
  5229
})();
moel@348
  5230
moel@348
  5231
(function(){
moel@348
  5232
	var div = document.createElement("div");
moel@348
  5233
moel@348
  5234
	div.innerHTML = "<div class='test e'></div><div class='test'></div>";
moel@348
  5235
moel@348
  5236
	// Opera can't find a second classname (in 9.6)
moel@348
  5237
	// Also, make sure that getElementsByClassName actually exists
moel@348
  5238
	if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) {
moel@348
  5239
		return;
moel@348
  5240
	}
moel@348
  5241
moel@348
  5242
	// Safari caches class attributes, doesn't catch changes (in 3.2)
moel@348
  5243
	div.lastChild.className = "e";
moel@348
  5244
moel@348
  5245
	if ( div.getElementsByClassName("e").length === 1 ) {
moel@348
  5246
		return;
moel@348
  5247
	}
moel@348
  5248
moel@348
  5249
	Expr.order.splice(1, 0, "CLASS");
moel@348
  5250
	Expr.find.CLASS = function( match, context, isXML ) {
moel@348
  5251
		if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
moel@348
  5252
			return context.getElementsByClassName(match[1]);
moel@348
  5253
		}
moel@348
  5254
	};
moel@348
  5255
moel@348
  5256
	// release memory in IE
moel@348
  5257
	div = null;
moel@348
  5258
})();
moel@348
  5259
moel@348
  5260
function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
moel@348
  5261
	for ( var i = 0, l = checkSet.length; i < l; i++ ) {
moel@348
  5262
		var elem = checkSet[i];
moel@348
  5263
moel@348
  5264
		if ( elem ) {
moel@348
  5265
			var match = false;
moel@348
  5266
moel@348
  5267
			elem = elem[dir];
moel@348
  5268
moel@348
  5269
			while ( elem ) {
moel@348
  5270
				if ( elem[ expando ] === doneName ) {
moel@348
  5271
					match = checkSet[elem.sizset];
moel@348
  5272
					break;
moel@348
  5273
				}
moel@348
  5274
moel@348
  5275
				if ( elem.nodeType === 1 && !isXML ){
moel@348
  5276
					elem[ expando ] = doneName;
moel@348
  5277
					elem.sizset = i;
moel@348
  5278
				}
moel@348
  5279
moel@348
  5280
				if ( elem.nodeName.toLowerCase() === cur ) {
moel@348
  5281
					match = elem;
moel@348
  5282
					break;
moel@348
  5283
				}
moel@348
  5284
moel@348
  5285
				elem = elem[dir];
moel@348
  5286
			}
moel@348
  5287
moel@348
  5288
			checkSet[i] = match;
moel@348
  5289
		}
moel@348
  5290
	}
moel@348
  5291
}
moel@348
  5292
moel@348
  5293
function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
moel@348
  5294
	for ( var i = 0, l = checkSet.length; i < l; i++ ) {
moel@348
  5295
		var elem = checkSet[i];
moel@348
  5296
moel@348
  5297
		if ( elem ) {
moel@348
  5298
			var match = false;
moel@348
  5299
moel@348
  5300
			elem = elem[dir];
moel@348
  5301
moel@348
  5302
			while ( elem ) {
moel@348
  5303
				if ( elem[ expando ] === doneName ) {
moel@348
  5304
					match = checkSet[elem.sizset];
moel@348
  5305
					break;
moel@348
  5306
				}
moel@348
  5307
moel@348
  5308
				if ( elem.nodeType === 1 ) {
moel@348
  5309
					if ( !isXML ) {
moel@348
  5310
						elem[ expando ] = doneName;
moel@348
  5311
						elem.sizset = i;
moel@348
  5312
					}
moel@348
  5313
moel@348
  5314
					if ( typeof cur !== "string" ) {
moel@348
  5315
						if ( elem === cur ) {
moel@348
  5316
							match = true;
moel@348
  5317
							break;
moel@348
  5318
						}
moel@348
  5319
moel@348
  5320
					} else if ( Sizzle.filter( cur, [elem] ).length > 0 ) {
moel@348
  5321
						match = elem;
moel@348
  5322
						break;
moel@348
  5323
					}
moel@348
  5324
				}
moel@348
  5325
moel@348
  5326
				elem = elem[dir];
moel@348
  5327
			}
moel@348
  5328
moel@348
  5329
			checkSet[i] = match;
moel@348
  5330
		}
moel@348
  5331
	}
moel@348
  5332
}
moel@348
  5333
moel@348
  5334
if ( document.documentElement.contains ) {
moel@348
  5335
	Sizzle.contains = function( a, b ) {
moel@348
  5336
		return a !== b && (a.contains ? a.contains(b) : true);
moel@348
  5337
	};
moel@348
  5338
moel@348
  5339
} else if ( document.documentElement.compareDocumentPosition ) {
moel@348
  5340
	Sizzle.contains = function( a, b ) {
moel@348
  5341
		return !!(a.compareDocumentPosition(b) & 16);
moel@348
  5342
	};
moel@348
  5343
moel@348
  5344
} else {
moel@348
  5345
	Sizzle.contains = function() {
moel@348
  5346
		return false;
moel@348
  5347
	};
moel@348
  5348
}
moel@348
  5349
moel@348
  5350
Sizzle.isXML = function( elem ) {
moel@348
  5351
	// documentElement is verified for cases where it doesn't yet exist
moel@348
  5352
	// (such as loading iframes in IE - #4833)
moel@348
  5353
	var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;
moel@348
  5354
moel@348
  5355
	return documentElement ? documentElement.nodeName !== "HTML" : false;
moel@348
  5356
};
moel@348
  5357
moel@348
  5358
var posProcess = function( selector, context, seed ) {
moel@348
  5359
	var match,
moel@348
  5360
		tmpSet = [],
moel@348
  5361
		later = "",
moel@348
  5362
		root = context.nodeType ? [context] : context;
moel@348
  5363
moel@348
  5364
	// Position selectors must be done after the filter
moel@348
  5365
	// And so must :not(positional) so we move all PSEUDOs to the end
moel@348
  5366
	while ( (match = Expr.match.PSEUDO.exec( selector )) ) {
moel@348
  5367
		later += match[0];
moel@348
  5368
		selector = selector.replace( Expr.match.PSEUDO, "" );
moel@348
  5369
	}
moel@348
  5370
moel@348
  5371
	selector = Expr.relative[selector] ? selector + "*" : selector;
moel@348
  5372
moel@348
  5373
	for ( var i = 0, l = root.length; i < l; i++ ) {
moel@348
  5374
		Sizzle( selector, root[i], tmpSet, seed );
moel@348
  5375
	}
moel@348
  5376
moel@348
  5377
	return Sizzle.filter( later, tmpSet );
moel@348
  5378
};
moel@348
  5379
moel@348
  5380
// EXPOSE
moel@348
  5381
// Override sizzle attribute retrieval
moel@348
  5382
Sizzle.attr = jQuery.attr;
moel@348
  5383
Sizzle.selectors.attrMap = {};
moel@348
  5384
jQuery.find = Sizzle;
moel@348
  5385
jQuery.expr = Sizzle.selectors;
moel@348
  5386
jQuery.expr[":"] = jQuery.expr.filters;
moel@348
  5387
jQuery.unique = Sizzle.uniqueSort;
moel@348
  5388
jQuery.text = Sizzle.getText;
moel@348
  5389
jQuery.isXMLDoc = Sizzle.isXML;
moel@348
  5390
jQuery.contains = Sizzle.contains;
moel@348
  5391
moel@348
  5392
moel@348
  5393
})();
moel@348
  5394
moel@348
  5395
moel@348
  5396
var runtil = /Until$/,
moel@348
  5397
	rparentsprev = /^(?:parents|prevUntil|prevAll)/,
moel@348
  5398
	// Note: This RegExp should be improved, or likely pulled from Sizzle
moel@348
  5399
	rmultiselector = /,/,
moel@348
  5400
	isSimple = /^.[^:#\[\.,]*$/,
moel@348
  5401
	slice = Array.prototype.slice,
moel@348
  5402
	POS = jQuery.expr.match.globalPOS,
moel@348
  5403
	// methods guaranteed to produce a unique set when starting from a unique set
moel@348
  5404
	guaranteedUnique = {
moel@348
  5405
		children: true,
moel@348
  5406
		contents: true,
moel@348
  5407
		next: true,
moel@348
  5408
		prev: true
moel@348
  5409
	};
moel@348
  5410
moel@348
  5411
jQuery.fn.extend({
moel@348
  5412
	find: function( selector ) {
moel@348
  5413
		var self = this,
moel@348
  5414
			i, l;
moel@348
  5415
moel@348
  5416
		if ( typeof selector !== "string" ) {
moel@348
  5417
			return jQuery( selector ).filter(function() {
moel@348
  5418
				for ( i = 0, l = self.length; i < l; i++ ) {
moel@348
  5419
					if ( jQuery.contains( self[ i ], this ) ) {
moel@348
  5420
						return true;
moel@348
  5421
					}
moel@348
  5422
				}
moel@348
  5423
			});
moel@348
  5424
		}
moel@348
  5425
moel@348
  5426
		var ret = this.pushStack( "", "find", selector ),
moel@348
  5427
			length, n, r;
moel@348
  5428
moel@348
  5429
		for ( i = 0, l = this.length; i < l; i++ ) {
moel@348
  5430
			length = ret.length;
moel@348
  5431
			jQuery.find( selector, this[i], ret );
moel@348
  5432
moel@348
  5433
			if ( i > 0 ) {
moel@348
  5434
				// Make sure that the results are unique
moel@348
  5435
				for ( n = length; n < ret.length; n++ ) {
moel@348
  5436
					for ( r = 0; r < length; r++ ) {
moel@348
  5437
						if ( ret[r] === ret[n] ) {
moel@348
  5438
							ret.splice(n--, 1);
moel@348
  5439
							break;
moel@348
  5440
						}
moel@348
  5441
					}
moel@348
  5442
				}
moel@348
  5443
			}
moel@348
  5444
		}
moel@348
  5445
moel@348
  5446
		return ret;
moel@348
  5447
	},
moel@348
  5448
moel@348
  5449
	has: function( target ) {
moel@348
  5450
		var targets = jQuery( target );
moel@348
  5451
		return this.filter(function() {
moel@348
  5452
			for ( var i = 0, l = targets.length; i < l; i++ ) {
moel@348
  5453
				if ( jQuery.contains( this, targets[i] ) ) {
moel@348
  5454
					return true;
moel@348
  5455
				}
moel@348
  5456
			}
moel@348
  5457
		});
moel@348
  5458
	},
moel@348
  5459
moel@348
  5460
	not: function( selector ) {
moel@348
  5461
		return this.pushStack( winnow(this, selector, false), "not", selector);
moel@348
  5462
	},
moel@348
  5463
moel@348
  5464
	filter: function( selector ) {
moel@348
  5465
		return this.pushStack( winnow(this, selector, true), "filter", selector );
moel@348
  5466
	},
moel@348
  5467
moel@348
  5468
	is: function( selector ) {
moel@348
  5469
		return !!selector && (
moel@348
  5470
			typeof selector === "string" ?
moel@348
  5471
				// If this is a positional selector, check membership in the returned set
moel@348
  5472
				// so $("p:first").is("p:last") won't return true for a doc with two "p".
moel@348
  5473
				POS.test( selector ) ?
moel@348
  5474
					jQuery( selector, this.context ).index( this[0] ) >= 0 :
moel@348
  5475
					jQuery.filter( selector, this ).length > 0 :
moel@348
  5476
				this.filter( selector ).length > 0 );
moel@348
  5477
	},
moel@348
  5478
moel@348
  5479
	closest: function( selectors, context ) {
moel@348
  5480
		var ret = [], i, l, cur = this[0];
moel@348
  5481
moel@348
  5482
		// Array (deprecated as of jQuery 1.7)
moel@348
  5483
		if ( jQuery.isArray( selectors ) ) {
moel@348
  5484
			var level = 1;
moel@348
  5485
moel@348
  5486
			while ( cur && cur.ownerDocument && cur !== context ) {
moel@348
  5487
				for ( i = 0; i < selectors.length; i++ ) {
moel@348
  5488
moel@348
  5489
					if ( jQuery( cur ).is( selectors[ i ] ) ) {
moel@348
  5490
						ret.push({ selector: selectors[ i ], elem: cur, level: level });
moel@348
  5491
					}
moel@348
  5492
				}
moel@348
  5493
moel@348
  5494
				cur = cur.parentNode;
moel@348
  5495
				level++;
moel@348
  5496
			}
moel@348
  5497
moel@348
  5498
			return ret;
moel@348
  5499
		}
moel@348
  5500
moel@348
  5501
		// String
moel@348
  5502
		var pos = POS.test( selectors ) || typeof selectors !== "string" ?
moel@348
  5503
				jQuery( selectors, context || this.context ) :
moel@348
  5504
				0;
moel@348
  5505
moel@348
  5506
		for ( i = 0, l = this.length; i < l; i++ ) {
moel@348
  5507
			cur = this[i];
moel@348
  5508
moel@348
  5509
			while ( cur ) {
moel@348
  5510
				if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) {
moel@348
  5511
					ret.push( cur );
moel@348
  5512
					break;
moel@348
  5513
moel@348
  5514
				} else {
moel@348
  5515
					cur = cur.parentNode;
moel@348
  5516
					if ( !cur || !cur.ownerDocument || cur === context || cur.nodeType === 11 ) {
moel@348
  5517
						break;
moel@348
  5518
					}
moel@348
  5519
				}
moel@348
  5520
			}
moel@348
  5521
		}
moel@348
  5522
moel@348
  5523
		ret = ret.length > 1 ? jQuery.unique( ret ) : ret;
moel@348
  5524
moel@348
  5525
		return this.pushStack( ret, "closest", selectors );
moel@348
  5526
	},
moel@348
  5527
moel@348
  5528
	// Determine the position of an element within
moel@348
  5529
	// the matched set of elements
moel@348
  5530
	index: function( elem ) {
moel@348
  5531
moel@348
  5532
		// No argument, return index in parent
moel@348
  5533
		if ( !elem ) {
moel@348
  5534
			return ( this[0] && this[0].parentNode ) ? this.prevAll().length : -1;
moel@348
  5535
		}
moel@348
  5536
moel@348
  5537
		// index in selector
moel@348
  5538
		if ( typeof elem === "string" ) {
moel@348
  5539
			return jQuery.inArray( this[0], jQuery( elem ) );
moel@348
  5540
		}
moel@348
  5541
moel@348
  5542
		// Locate the position of the desired element
moel@348
  5543
		return jQuery.inArray(
moel@348
  5544
			// If it receives a jQuery object, the first element is used
moel@348
  5545
			elem.jquery ? elem[0] : elem, this );
moel@348
  5546
	},
moel@348
  5547
moel@348
  5548
	add: function( selector, context ) {
moel@348
  5549
		var set = typeof selector === "string" ?
moel@348
  5550
				jQuery( selector, context ) :
moel@348
  5551
				jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ),
moel@348
  5552
			all = jQuery.merge( this.get(), set );
moel@348
  5553
moel@348
  5554
		return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?
moel@348
  5555
			all :
moel@348
  5556
			jQuery.unique( all ) );
moel@348
  5557
	},
moel@348
  5558
moel@348
  5559
	andSelf: function() {
moel@348
  5560
		return this.add( this.prevObject );
moel@348
  5561
	}
moel@348
  5562
});
moel@348
  5563
moel@348
  5564
// A painfully simple check to see if an element is disconnected
moel@348
  5565
// from a document (should be improved, where feasible).
moel@348
  5566
function isDisconnected( node ) {
moel@348
  5567
	return !node || !node.parentNode || node.parentNode.nodeType === 11;
moel@348
  5568
}
moel@348
  5569
moel@348
  5570
jQuery.each({
moel@348
  5571
	parent: function( elem ) {
moel@348
  5572
		var parent = elem.parentNode;
moel@348
  5573
		return parent && parent.nodeType !== 11 ? parent : null;
moel@348
  5574
	},
moel@348
  5575
	parents: function( elem ) {
moel@348
  5576
		return jQuery.dir( elem, "parentNode" );
moel@348
  5577
	},
moel@348
  5578
	parentsUntil: function( elem, i, until ) {
moel@348
  5579
		return jQuery.dir( elem, "parentNode", until );
moel@348
  5580
	},
moel@348
  5581
	next: function( elem ) {
moel@348
  5582
		return jQuery.nth( elem, 2, "nextSibling" );
moel@348
  5583
	},
moel@348
  5584
	prev: function( elem ) {
moel@348
  5585
		return jQuery.nth( elem, 2, "previousSibling" );
moel@348
  5586
	},
moel@348
  5587
	nextAll: function( elem ) {
moel@348
  5588
		return jQuery.dir( elem, "nextSibling" );
moel@348
  5589
	},
moel@348
  5590
	prevAll: function( elem ) {
moel@348
  5591
		return jQuery.dir( elem, "previousSibling" );
moel@348
  5592
	},
moel@348
  5593
	nextUntil: function( elem, i, until ) {
moel@348
  5594
		return jQuery.dir( elem, "nextSibling", until );
moel@348
  5595
	},
moel@348
  5596
	prevUntil: function( elem, i, until ) {
moel@348
  5597
		return jQuery.dir( elem, "previousSibling", until );
moel@348
  5598
	},
moel@348
  5599
	siblings: function( elem ) {
moel@348
  5600
		return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem );
moel@348
  5601
	},
moel@348
  5602
	children: function( elem ) {
moel@348
  5603
		return jQuery.sibling( elem.firstChild );
moel@348
  5604
	},
moel@348
  5605
	contents: function( elem ) {
moel@348
  5606
		return jQuery.nodeName( elem, "iframe" ) ?
moel@348
  5607
			elem.contentDocument || elem.contentWindow.document :
moel@348
  5608
			jQuery.makeArray( elem.childNodes );
moel@348
  5609
	}
moel@348
  5610
}, function( name, fn ) {
moel@348
  5611
	jQuery.fn[ name ] = function( until, selector ) {
moel@348
  5612
		var ret = jQuery.map( this, fn, until );
moel@348
  5613
moel@348
  5614
		if ( !runtil.test( name ) ) {
moel@348
  5615
			selector = until;
moel@348
  5616
		}
moel@348
  5617
moel@348
  5618
		if ( selector && typeof selector === "string" ) {
moel@348
  5619
			ret = jQuery.filter( selector, ret );
moel@348
  5620
		}
moel@348
  5621
moel@348
  5622
		ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret;
moel@348
  5623
moel@348
  5624
		if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) {
moel@348
  5625
			ret = ret.reverse();
moel@348
  5626
		}
moel@348
  5627
moel@348
  5628
		return this.pushStack( ret, name, slice.call( arguments ).join(",") );
moel@348
  5629
	};
moel@348
  5630
});
moel@348
  5631
moel@348
  5632
jQuery.extend({
moel@348
  5633
	filter: function( expr, elems, not ) {
moel@348
  5634
		if ( not ) {
moel@348
  5635
			expr = ":not(" + expr + ")";
moel@348
  5636
		}
moel@348
  5637
moel@348
  5638
		return elems.length === 1 ?
moel@348
  5639
			jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] :
moel@348
  5640
			jQuery.find.matches(expr, elems);
moel@348
  5641
	},
moel@348
  5642
moel@348
  5643
	dir: function( elem, dir, until ) {
moel@348
  5644
		var matched = [],
moel@348
  5645
			cur = elem[ dir ];
moel@348
  5646
moel@348
  5647
		while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
moel@348
  5648
			if ( cur.nodeType === 1 ) {
moel@348
  5649
				matched.push( cur );
moel@348
  5650
			}
moel@348
  5651
			cur = cur[dir];
moel@348
  5652
		}
moel@348
  5653
		return matched;
moel@348
  5654
	},
moel@348
  5655
moel@348
  5656
	nth: function( cur, result, dir, elem ) {
moel@348
  5657
		result = result || 1;
moel@348
  5658
		var num = 0;
moel@348
  5659
moel@348
  5660
		for ( ; cur; cur = cur[dir] ) {
moel@348
  5661
			if ( cur.nodeType === 1 && ++num === result ) {
moel@348
  5662
				break;
moel@348
  5663
			}
moel@348
  5664
		}
moel@348
  5665
moel@348
  5666
		return cur;
moel@348
  5667
	},
moel@348
  5668
moel@348
  5669
	sibling: function( n, elem ) {
moel@348
  5670
		var r = [];
moel@348
  5671
moel@348
  5672
		for ( ; n; n = n.nextSibling ) {
moel@348
  5673
			if ( n.nodeType === 1 && n !== elem ) {
moel@348
  5674
				r.push( n );
moel@348
  5675
			}
moel@348
  5676
		}
moel@348
  5677
moel@348
  5678
		return r;
moel@348
  5679
	}
moel@348
  5680
});
moel@348
  5681
moel@348
  5682
// Implement the identical functionality for filter and not
moel@348
  5683
function winnow( elements, qualifier, keep ) {
moel@348
  5684
moel@348
  5685
	// Can't pass null or undefined to indexOf in Firefox 4
moel@348
  5686
	// Set to 0 to skip string check
moel@348
  5687
	qualifier = qualifier || 0;
moel@348
  5688
moel@348
  5689
	if ( jQuery.isFunction( qualifier ) ) {
moel@348
  5690
		return jQuery.grep(elements, function( elem, i ) {
moel@348
  5691
			var retVal = !!qualifier.call( elem, i, elem );
moel@348
  5692
			return retVal === keep;
moel@348
  5693
		});
moel@348
  5694
moel@348
  5695
	} else if ( qualifier.nodeType ) {
moel@348
  5696
		return jQuery.grep(elements, function( elem, i ) {
moel@348
  5697
			return ( elem === qualifier ) === keep;
moel@348
  5698
		});
moel@348
  5699
moel@348
  5700
	} else if ( typeof qualifier === "string" ) {
moel@348
  5701
		var filtered = jQuery.grep(elements, function( elem ) {
moel@348
  5702
			return elem.nodeType === 1;
moel@348
  5703
		});
moel@348
  5704
moel@348
  5705
		if ( isSimple.test( qualifier ) ) {
moel@348
  5706
			return jQuery.filter(qualifier, filtered, !keep);
moel@348
  5707
		} else {
moel@348
  5708
			qualifier = jQuery.filter( qualifier, filtered );
moel@348
  5709
		}
moel@348
  5710
	}
moel@348
  5711
moel@348
  5712
	return jQuery.grep(elements, function( elem, i ) {
moel@348
  5713
		return ( jQuery.inArray( elem, qualifier ) >= 0 ) === keep;
moel@348
  5714
	});
moel@348
  5715
}
moel@348
  5716
moel@348
  5717
moel@348
  5718
moel@348
  5719
moel@348
  5720
function createSafeFragment( document ) {
moel@348
  5721
	var list = nodeNames.split( "|" ),
moel@348
  5722
	safeFrag = document.createDocumentFragment();
moel@348
  5723
moel@348
  5724
	if ( safeFrag.createElement ) {
moel@348
  5725
		while ( list.length ) {
moel@348
  5726
			safeFrag.createElement(
moel@348
  5727
				list.pop()
moel@348
  5728
			);
moel@348
  5729
		}
moel@348
  5730
	}
moel@348
  5731
	return safeFrag;
moel@348
  5732
}
moel@348
  5733
moel@348
  5734
var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" +
moel@348
  5735
		"header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",
moel@348
  5736
	rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
moel@348
  5737
	rleadingWhitespace = /^\s+/,
moel@348
  5738
	rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,
moel@348
  5739
	rtagName = /<([\w:]+)/,
moel@348
  5740
	rtbody = /<tbody/i,
moel@348
  5741
	rhtml = /<|&#?\w+;/,
moel@348
  5742
	rnoInnerhtml = /<(?:script|style)/i,
moel@348
  5743
	rnocache = /<(?:script|object|embed|option|style)/i,
moel@348
  5744
	rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"),
moel@348
  5745
	// checked="checked" or checked
moel@348
  5746
	rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
moel@348
  5747
	rscriptType = /\/(java|ecma)script/i,
moel@348
  5748
	rcleanScript = /^\s*<!(?:\[CDATA\[|\-\-)/,
moel@348
  5749
	wrapMap = {
moel@348
  5750
		option: [ 1, "<select multiple='multiple'>", "</select>" ],
moel@348
  5751
		legend: [ 1, "<fieldset>", "</fieldset>" ],
moel@348
  5752
		thead: [ 1, "<table>", "</table>" ],
moel@348
  5753
		tr: [ 2, "<table><tbody>", "</tbody></table>" ],
moel@348
  5754
		td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
moel@348
  5755
		col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
moel@348
  5756
		area: [ 1, "<map>", "</map>" ],
moel@348
  5757
		_default: [ 0, "", "" ]
moel@348
  5758
	},
moel@348
  5759
	safeFragment = createSafeFragment( document );
moel@348
  5760
moel@348
  5761
wrapMap.optgroup = wrapMap.option;
moel@348
  5762
wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
moel@348
  5763
wrapMap.th = wrapMap.td;
moel@348
  5764
moel@348
  5765
// IE can't serialize <link> and <script> tags normally
moel@348
  5766
if ( !jQuery.support.htmlSerialize ) {
moel@348
  5767
	wrapMap._default = [ 1, "div<div>", "</div>" ];
moel@348
  5768
}
moel@348
  5769
moel@348
  5770
jQuery.fn.extend({
moel@348
  5771
	text: function( value ) {
moel@348
  5772
		return jQuery.access( this, function( value ) {
moel@348
  5773
			return value === undefined ?
moel@348
  5774
				jQuery.text( this ) :
moel@348
  5775
				this.empty().append( ( this[0] && this[0].ownerDocument || document ).createTextNode( value ) );
moel@348
  5776
		}, null, value, arguments.length );
moel@348
  5777
	},
moel@348
  5778
moel@348
  5779
	wrapAll: function( html ) {
moel@348
  5780
		if ( jQuery.isFunction( html ) ) {
moel@348
  5781
			return this.each(function(i) {
moel@348
  5782
				jQuery(this).wrapAll( html.call(this, i) );
moel@348
  5783
			});
moel@348
  5784
		}
moel@348
  5785
moel@348
  5786
		if ( this[0] ) {
moel@348
  5787
			// The elements to wrap the target around
moel@348
  5788
			var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
moel@348
  5789
moel@348
  5790
			if ( this[0].parentNode ) {
moel@348
  5791
				wrap.insertBefore( this[0] );
moel@348
  5792
			}
moel@348
  5793
moel@348
  5794
			wrap.map(function() {
moel@348
  5795
				var elem = this;
moel@348
  5796
moel@348
  5797
				while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
moel@348
  5798
					elem = elem.firstChild;
moel@348
  5799
				}
moel@348
  5800
moel@348
  5801
				return elem;
moel@348
  5802
			}).append( this );
moel@348
  5803
		}
moel@348
  5804
moel@348
  5805
		return this;
moel@348
  5806
	},
moel@348
  5807
moel@348
  5808
	wrapInner: function( html ) {
moel@348
  5809
		if ( jQuery.isFunction( html ) ) {
moel@348
  5810
			return this.each(function(i) {
moel@348
  5811
				jQuery(this).wrapInner( html.call(this, i) );
moel@348
  5812
			});
moel@348
  5813
		}
moel@348
  5814
moel@348
  5815
		return this.each(function() {
moel@348
  5816
			var self = jQuery( this ),
moel@348
  5817
				contents = self.contents();
moel@348
  5818
moel@348
  5819
			if ( contents.length ) {
moel@348
  5820
				contents.wrapAll( html );
moel@348
  5821
moel@348
  5822
			} else {
moel@348
  5823
				self.append( html );
moel@348
  5824
			}
moel@348
  5825
		});
moel@348
  5826
	},
moel@348
  5827
moel@348
  5828
	wrap: function( html ) {
moel@348
  5829
		var isFunction = jQuery.isFunction( html );
moel@348
  5830
moel@348
  5831
		return this.each(function(i) {
moel@348
  5832
			jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html );
moel@348
  5833
		});
moel@348
  5834
	},
moel@348
  5835
moel@348
  5836
	unwrap: function() {
moel@348
  5837
		return this.parent().each(function() {
moel@348
  5838
			if ( !jQuery.nodeName( this, "body" ) ) {
moel@348
  5839
				jQuery( this ).replaceWith( this.childNodes );
moel@348
  5840
			}
moel@348
  5841
		}).end();
moel@348
  5842
	},
moel@348
  5843
moel@348
  5844
	append: function() {
moel@348
  5845
		return this.domManip(arguments, true, function( elem ) {
moel@348
  5846
			if ( this.nodeType === 1 ) {
moel@348
  5847
				this.appendChild( elem );
moel@348
  5848
			}
moel@348
  5849
		});
moel@348
  5850
	},
moel@348
  5851
moel@348
  5852
	prepend: function() {
moel@348
  5853
		return this.domManip(arguments, true, function( elem ) {
moel@348
  5854
			if ( this.nodeType === 1 ) {
moel@348
  5855
				this.insertBefore( elem, this.firstChild );
moel@348
  5856
			}
moel@348
  5857
		});
moel@348
  5858
	},
moel@348
  5859
moel@348
  5860
	before: function() {
moel@348
  5861
		if ( this[0] && this[0].parentNode ) {
moel@348
  5862
			return this.domManip(arguments, false, function( elem ) {
moel@348
  5863
				this.parentNode.insertBefore( elem, this );
moel@348
  5864
			});
moel@348
  5865
		} else if ( arguments.length ) {
moel@348
  5866
			var set = jQuery.clean( arguments );
moel@348
  5867
			set.push.apply( set, this.toArray() );
moel@348
  5868
			return this.pushStack( set, "before", arguments );
moel@348
  5869
		}
moel@348
  5870
	},
moel@348
  5871
moel@348
  5872
	after: function() {
moel@348
  5873
		if ( this[0] && this[0].parentNode ) {
moel@348
  5874
			return this.domManip(arguments, false, function( elem ) {
moel@348
  5875
				this.parentNode.insertBefore( elem, this.nextSibling );
moel@348
  5876
			});
moel@348
  5877
		} else if ( arguments.length ) {
moel@348
  5878
			var set = this.pushStack( this, "after", arguments );
moel@348
  5879
			set.push.apply( set, jQuery.clean(arguments) );
moel@348
  5880
			return set;
moel@348
  5881
		}
moel@348
  5882
	},
moel@348
  5883
moel@348
  5884
	// keepData is for internal use only--do not document
moel@348
  5885
	remove: function( selector, keepData ) {
moel@348
  5886
		for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
moel@348
  5887
			if ( !selector || jQuery.filter( selector, [ elem ] ).length ) {
moel@348
  5888
				if ( !keepData && elem.nodeType === 1 ) {
moel@348
  5889
					jQuery.cleanData( elem.getElementsByTagName("*") );
moel@348
  5890
					jQuery.cleanData( [ elem ] );
moel@348
  5891
				}
moel@348
  5892
moel@348
  5893
				if ( elem.parentNode ) {
moel@348
  5894
					elem.parentNode.removeChild( elem );
moel@348
  5895
				}
moel@348
  5896
			}
moel@348
  5897
		}
moel@348
  5898
moel@348
  5899
		return this;
moel@348
  5900
	},
moel@348
  5901
moel@348
  5902
	empty: function() {
moel@348
  5903
		for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
moel@348
  5904
			// Remove element nodes and prevent memory leaks
moel@348
  5905
			if ( elem.nodeType === 1 ) {
moel@348
  5906
				jQuery.cleanData( elem.getElementsByTagName("*") );
moel@348
  5907
			}
moel@348
  5908
moel@348
  5909
			// Remove any remaining nodes
moel@348
  5910
			while ( elem.firstChild ) {
moel@348
  5911
				elem.removeChild( elem.firstChild );
moel@348
  5912
			}
moel@348
  5913
		}
moel@348
  5914
moel@348
  5915
		return this;
moel@348
  5916
	},
moel@348
  5917
moel@348
  5918
	clone: function( dataAndEvents, deepDataAndEvents ) {
moel@348
  5919
		dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
moel@348
  5920
		deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
moel@348
  5921
moel@348
  5922
		return this.map( function () {
moel@348
  5923
			return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
moel@348
  5924
		});
moel@348
  5925
	},
moel@348
  5926
moel@348
  5927
	html: function( value ) {
moel@348
  5928
		return jQuery.access( this, function( value ) {
moel@348
  5929
			var elem = this[0] || {},
moel@348
  5930
				i = 0,
moel@348
  5931
				l = this.length;
moel@348
  5932
moel@348
  5933
			if ( value === undefined ) {
moel@348
  5934
				return elem.nodeType === 1 ?
moel@348
  5935
					elem.innerHTML.replace( rinlinejQuery, "" ) :
moel@348
  5936
					null;
moel@348
  5937
			}
moel@348
  5938
moel@348
  5939
moel@348
  5940
			if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
moel@348
  5941
				( jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value ) ) &&
moel@348
  5942
				!wrapMap[ ( rtagName.exec( value ) || ["", ""] )[1].toLowerCase() ] ) {
moel@348
  5943
moel@348
  5944
				value = value.replace( rxhtmlTag, "<$1></$2>" );
moel@348
  5945
moel@348
  5946
				try {
moel@348
  5947
					for (; i < l; i++ ) {
moel@348
  5948
						// Remove element nodes and prevent memory leaks
moel@348
  5949
						elem = this[i] || {};
moel@348
  5950
						if ( elem.nodeType === 1 ) {
moel@348
  5951
							jQuery.cleanData( elem.getElementsByTagName( "*" ) );
moel@348
  5952
							elem.innerHTML = value;
moel@348
  5953
						}
moel@348
  5954
					}
moel@348
  5955
moel@348
  5956
					elem = 0;
moel@348
  5957
moel@348
  5958
				// If using innerHTML throws an exception, use the fallback method
moel@348
  5959
				} catch(e) {}
moel@348
  5960
			}
moel@348
  5961
moel@348
  5962
			if ( elem ) {
moel@348
  5963
				this.empty().append( value );
moel@348
  5964
			}
moel@348
  5965
		}, null, value, arguments.length );
moel@348
  5966
	},
moel@348
  5967
moel@348
  5968
	replaceWith: function( value ) {
moel@348
  5969
		if ( this[0] && this[0].parentNode ) {
moel@348
  5970
			// Make sure that the elements are removed from the DOM before they are inserted
moel@348
  5971
			// this can help fix replacing a parent with child elements
moel@348
  5972
			if ( jQuery.isFunction( value ) ) {
moel@348
  5973
				return this.each(function(i) {
moel@348
  5974
					var self = jQuery(this), old = self.html();
moel@348
  5975
					self.replaceWith( value.call( this, i, old ) );
moel@348
  5976
				});
moel@348
  5977
			}
moel@348
  5978
moel@348
  5979
			if ( typeof value !== "string" ) {
moel@348
  5980
				value = jQuery( value ).detach();
moel@348
  5981
			}
moel@348
  5982
moel@348
  5983
			return this.each(function() {
moel@348
  5984
				var next = this.nextSibling,
moel@348
  5985
					parent = this.parentNode;
moel@348
  5986
moel@348
  5987
				jQuery( this ).remove();
moel@348
  5988
moel@348
  5989
				if ( next ) {
moel@348
  5990
					jQuery(next).before( value );
moel@348
  5991
				} else {
moel@348
  5992
					jQuery(parent).append( value );
moel@348
  5993
				}
moel@348
  5994
			});
moel@348
  5995
		} else {
moel@348
  5996
			return this.length ?
moel@348
  5997
				this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ) :
moel@348
  5998
				this;
moel@348
  5999
		}
moel@348
  6000
	},
moel@348
  6001
moel@348
  6002
	detach: function( selector ) {
moel@348
  6003
		return this.remove( selector, true );
moel@348
  6004
	},
moel@348
  6005
moel@348
  6006
	domManip: function( args, table, callback ) {
moel@348
  6007
		var results, first, fragment, parent,
moel@348
  6008
			value = args[0],
moel@348
  6009
			scripts = [];
moel@348
  6010
moel@348
  6011
		// We can't cloneNode fragments that contain checked, in WebKit
moel@348
  6012
		if ( !jQuery.support.checkClone && arguments.length === 3 && typeof value === "string" && rchecked.test( value ) ) {
moel@348
  6013
			return this.each(function() {
moel@348
  6014
				jQuery(this).domManip( args, table, callback, true );
moel@348
  6015
			});
moel@348
  6016
		}
moel@348
  6017
moel@348
  6018
		if ( jQuery.isFunction(value) ) {
moel@348
  6019
			return this.each(function(i) {
moel@348
  6020
				var self = jQuery(this);
moel@348
  6021
				args[0] = value.call(this, i, table ? self.html() : undefined);
moel@348
  6022
				self.domManip( args, table, callback );
moel@348
  6023
			});
moel@348
  6024
		}
moel@348
  6025
moel@348
  6026
		if ( this[0] ) {
moel@348
  6027
			parent = value && value.parentNode;
moel@348
  6028
moel@348
  6029
			// If we're in a fragment, just use that instead of building a new one
moel@348
  6030
			if ( jQuery.support.parentNode && parent && parent.nodeType === 11 && parent.childNodes.length === this.length ) {
moel@348
  6031
				results = { fragment: parent };
moel@348
  6032
moel@348
  6033
			} else {
moel@348
  6034
				results = jQuery.buildFragment( args, this, scripts );
moel@348
  6035
			}
moel@348
  6036
moel@348
  6037
			fragment = results.fragment;
moel@348
  6038
moel@348
  6039
			if ( fragment.childNodes.length === 1 ) {
moel@348
  6040
				first = fragment = fragment.firstChild;
moel@348
  6041
			} else {
moel@348
  6042
				first = fragment.firstChild;
moel@348
  6043
			}
moel@348
  6044
moel@348
  6045
			if ( first ) {
moel@348
  6046
				table = table && jQuery.nodeName( first, "tr" );
moel@348
  6047
moel@348
  6048
				for ( var i = 0, l = this.length, lastIndex = l - 1; i < l; i++ ) {
moel@348
  6049
					callback.call(
moel@348
  6050
						table ?
moel@348
  6051
							root(this[i], first) :
moel@348
  6052
							this[i],
moel@348
  6053
						// Make sure that we do not leak memory by inadvertently discarding
moel@348
  6054
						// the original fragment (which might have attached data) instead of
moel@348
  6055
						// using it; in addition, use the original fragment object for the last
moel@348
  6056
						// item instead of first because it can end up being emptied incorrectly
moel@348
  6057
						// in certain situations (Bug #8070).
moel@348
  6058
						// Fragments from the fragment cache must always be cloned and never used
moel@348
  6059
						// in place.
moel@348
  6060
						results.cacheable || ( l > 1 && i < lastIndex ) ?
moel@348
  6061
							jQuery.clone( fragment, true, true ) :
moel@348
  6062
							fragment
moel@348
  6063
					);
moel@348
  6064
				}
moel@348
  6065
			}
moel@348
  6066
moel@348
  6067
			if ( scripts.length ) {
moel@348
  6068
				jQuery.each( scripts, function( i, elem ) {
moel@348
  6069
					if ( elem.src ) {
moel@348
  6070
						jQuery.ajax({
moel@348
  6071
							type: "GET",
moel@348
  6072
							global: false,
moel@348
  6073
							url: elem.src,
moel@348
  6074
							async: false,
moel@348
  6075
							dataType: "script"
moel@348
  6076
						});
moel@348
  6077
					} else {
moel@348
  6078
						jQuery.globalEval( ( elem.text || elem.textContent || elem.innerHTML || "" ).replace( rcleanScript, "/*$0*/" ) );
moel@348
  6079
					}
moel@348
  6080
moel@348
  6081
					if ( elem.parentNode ) {
moel@348
  6082
						elem.parentNode.removeChild( elem );
moel@348
  6083
					}
moel@348
  6084
				});
moel@348
  6085
			}
moel@348
  6086
		}
moel@348
  6087
moel@348
  6088
		return this;
moel@348
  6089
	}
moel@348
  6090
});
moel@348
  6091
moel@348
  6092
function root( elem, cur ) {
moel@348
  6093
	return jQuery.nodeName(elem, "table") ?
moel@348
  6094
		(elem.getElementsByTagName("tbody")[0] ||
moel@348
  6095
		elem.appendChild(elem.ownerDocument.createElement("tbody"))) :
moel@348
  6096
		elem;
moel@348
  6097
}
moel@348
  6098
moel@348
  6099
function cloneCopyEvent( src, dest ) {
moel@348
  6100
moel@348
  6101
	if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
moel@348
  6102
		return;
moel@348
  6103
	}
moel@348
  6104
moel@348
  6105
	var type, i, l,
moel@348
  6106
		oldData = jQuery._data( src ),
moel@348
  6107
		curData = jQuery._data( dest, oldData ),
moel@348
  6108
		events = oldData.events;
moel@348
  6109
moel@348
  6110
	if ( events ) {
moel@348
  6111
		delete curData.handle;
moel@348
  6112
		curData.events = {};
moel@348
  6113
moel@348
  6114
		for ( type in events ) {
moel@348
  6115
			for ( i = 0, l = events[ type ].length; i < l; i++ ) {
moel@348
  6116
				jQuery.event.add( dest, type, events[ type ][ i ] );
moel@348
  6117
			}
moel@348
  6118
		}
moel@348
  6119
	}
moel@348
  6120
moel@348
  6121
	// make the cloned public data object a copy from the original
moel@348
  6122
	if ( curData.data ) {
moel@348
  6123
		curData.data = jQuery.extend( {}, curData.data );
moel@348
  6124
	}
moel@348
  6125
}
moel@348
  6126
moel@348
  6127
function cloneFixAttributes( src, dest ) {
moel@348
  6128
	var nodeName;
moel@348
  6129
moel@348
  6130
	// We do not need to do anything for non-Elements
moel@348
  6131
	if ( dest.nodeType !== 1 ) {
moel@348
  6132
		return;
moel@348
  6133
	}
moel@348
  6134
moel@348
  6135
	// clearAttributes removes the attributes, which we don't want,
moel@348
  6136
	// but also removes the attachEvent events, which we *do* want
moel@348
  6137
	if ( dest.clearAttributes ) {
moel@348
  6138
		dest.clearAttributes();
moel@348
  6139
	}
moel@348
  6140
moel@348
  6141
	// mergeAttributes, in contrast, only merges back on the
moel@348
  6142
	// original attributes, not the events
moel@348
  6143
	if ( dest.mergeAttributes ) {
moel@348
  6144
		dest.mergeAttributes( src );
moel@348
  6145
	}
moel@348
  6146
moel@348
  6147
	nodeName = dest.nodeName.toLowerCase();
moel@348
  6148
moel@348
  6149
	// IE6-8 fail to clone children inside object elements that use
moel@348
  6150
	// the proprietary classid attribute value (rather than the type
moel@348
  6151
	// attribute) to identify the type of content to display
moel@348
  6152
	if ( nodeName === "object" ) {
moel@348
  6153
		dest.outerHTML = src.outerHTML;
moel@348
  6154
moel@348
  6155
	} else if ( nodeName === "input" && (src.type === "checkbox" || src.type === "radio") ) {
moel@348
  6156
		// IE6-8 fails to persist the checked state of a cloned checkbox
moel@348
  6157
		// or radio button. Worse, IE6-7 fail to give the cloned element
moel@348
  6158
		// a checked appearance if the defaultChecked value isn't also set
moel@348
  6159
		if ( src.checked ) {
moel@348
  6160
			dest.defaultChecked = dest.checked = src.checked;
moel@348
  6161
		}
moel@348
  6162
moel@348
  6163
		// IE6-7 get confused and end up setting the value of a cloned
moel@348
  6164
		// checkbox/radio button to an empty string instead of "on"
moel@348
  6165
		if ( dest.value !== src.value ) {
moel@348
  6166
			dest.value = src.value;
moel@348
  6167
		}
moel@348
  6168
moel@348
  6169
	// IE6-8 fails to return the selected option to the default selected
moel@348
  6170
	// state when cloning options
moel@348
  6171
	} else if ( nodeName === "option" ) {
moel@348
  6172
		dest.selected = src.defaultSelected;
moel@348
  6173
moel@348
  6174
	// IE6-8 fails to set the defaultValue to the correct value when
moel@348
  6175
	// cloning other types of input fields
moel@348
  6176
	} else if ( nodeName === "input" || nodeName === "textarea" ) {
moel@348
  6177
		dest.defaultValue = src.defaultValue;
moel@348
  6178
moel@348
  6179
	// IE blanks contents when cloning scripts
moel@348
  6180
	} else if ( nodeName === "script" && dest.text !== src.text ) {
moel@348
  6181
		dest.text = src.text;
moel@348
  6182
	}
moel@348
  6183
moel@348
  6184
	// Event data gets referenced instead of copied if the expando
moel@348
  6185
	// gets copied too
moel@348
  6186
	dest.removeAttribute( jQuery.expando );
moel@348
  6187
moel@348
  6188
	// Clear flags for bubbling special change/submit events, they must
moel@348
  6189
	// be reattached when the newly cloned events are first activated
moel@348
  6190
	dest.removeAttribute( "_submit_attached" );
moel@348
  6191
	dest.removeAttribute( "_change_attached" );
moel@348
  6192
}
moel@348
  6193
moel@348
  6194
jQuery.buildFragment = function( args, nodes, scripts ) {
moel@348
  6195
	var fragment, cacheable, cacheresults, doc,
moel@348
  6196
	first = args[ 0 ];
moel@348
  6197
moel@348
  6198
	// nodes may contain either an explicit document object,
moel@348
  6199
	// a jQuery collection or context object.
moel@348
  6200
	// If nodes[0] contains a valid object to assign to doc
moel@348
  6201
	if ( nodes && nodes[0] ) {
moel@348
  6202
		doc = nodes[0].ownerDocument || nodes[0];
moel@348
  6203
	}
moel@348
  6204
moel@348
  6205
	// Ensure that an attr object doesn't incorrectly stand in as a document object
moel@348
  6206
	// Chrome and Firefox seem to allow this to occur and will throw exception
moel@348
  6207
	// Fixes #8950
moel@348
  6208
	if ( !doc.createDocumentFragment ) {
moel@348
  6209
		doc = document;
moel@348
  6210
	}
moel@348
  6211
moel@348
  6212
	// Only cache "small" (1/2 KB) HTML strings that are associated with the main document
moel@348
  6213
	// Cloning options loses the selected state, so don't cache them
moel@348
  6214
	// IE 6 doesn't like it when you put <object> or <embed> elements in a fragment
moel@348
  6215
	// Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache
moel@348
  6216
	// Lastly, IE6,7,8 will not correctly reuse cached fragments that were created from unknown elems #10501
moel@348
  6217
	if ( args.length === 1 && typeof first === "string" && first.length < 512 && doc === document &&
moel@348
  6218
		first.charAt(0) === "<" && !rnocache.test( first ) &&
moel@348
  6219
		(jQuery.support.checkClone || !rchecked.test( first )) &&
moel@348
  6220
		(jQuery.support.html5Clone || !rnoshimcache.test( first )) ) {
moel@348
  6221
moel@348
  6222
		cacheable = true;
moel@348
  6223
moel@348
  6224
		cacheresults = jQuery.fragments[ first ];
moel@348
  6225
		if ( cacheresults && cacheresults !== 1 ) {
moel@348
  6226
			fragment = cacheresults;
moel@348
  6227
		}
moel@348
  6228
	}
moel@348
  6229
moel@348
  6230
	if ( !fragment ) {
moel@348
  6231
		fragment = doc.createDocumentFragment();
moel@348
  6232
		jQuery.clean( args, doc, fragment, scripts );
moel@348
  6233
	}
moel@348
  6234
moel@348
  6235
	if ( cacheable ) {
moel@348
  6236
		jQuery.fragments[ first ] = cacheresults ? fragment : 1;
moel@348
  6237
	}
moel@348
  6238
moel@348
  6239
	return { fragment: fragment, cacheable: cacheable };
moel@348
  6240
};
moel@348
  6241
moel@348
  6242
jQuery.fragments = {};
moel@348
  6243
moel@348
  6244
jQuery.each({
moel@348
  6245
	appendTo: "append",
moel@348
  6246
	prependTo: "prepend",
moel@348
  6247
	insertBefore: "before",
moel@348
  6248
	insertAfter: "after",
moel@348
  6249
	replaceAll: "replaceWith"
moel@348
  6250
}, function( name, original ) {
moel@348
  6251
	jQuery.fn[ name ] = function( selector ) {
moel@348
  6252
		var ret = [],
moel@348
  6253
			insert = jQuery( selector ),
moel@348
  6254
			parent = this.length === 1 && this[0].parentNode;
moel@348
  6255
moel@348
  6256
		if ( parent && parent.nodeType === 11 && parent.childNodes.length === 1 && insert.length === 1 ) {
moel@348
  6257
			insert[ original ]( this[0] );
moel@348
  6258
			return this;
moel@348
  6259
moel@348
  6260
		} else {
moel@348
  6261
			for ( var i = 0, l = insert.length; i < l; i++ ) {
moel@348
  6262
				var elems = ( i > 0 ? this.clone(true) : this ).get();
moel@348
  6263
				jQuery( insert[i] )[ original ]( elems );
moel@348
  6264
				ret = ret.concat( elems );
moel@348
  6265
			}
moel@348
  6266
moel@348
  6267
			return this.pushStack( ret, name, insert.selector );
moel@348
  6268
		}
moel@348
  6269
	};
moel@348
  6270
});
moel@348
  6271
moel@348
  6272
function getAll( elem ) {
moel@348
  6273
	if ( typeof elem.getElementsByTagName !== "undefined" ) {
moel@348
  6274
		return elem.getElementsByTagName( "*" );
moel@348
  6275
moel@348
  6276
	} else if ( typeof elem.querySelectorAll !== "undefined" ) {
moel@348
  6277
		return elem.querySelectorAll( "*" );
moel@348
  6278
moel@348
  6279
	} else {
moel@348
  6280
		return [];
moel@348
  6281
	}
moel@348
  6282
}
moel@348
  6283
moel@348
  6284
// Used in clean, fixes the defaultChecked property
moel@348
  6285
function fixDefaultChecked( elem ) {
moel@348
  6286
	if ( elem.type === "checkbox" || elem.type === "radio" ) {
moel@348
  6287
		elem.defaultChecked = elem.checked;
moel@348
  6288
	}
moel@348
  6289
}
moel@348
  6290
// Finds all inputs and passes them to fixDefaultChecked
moel@348
  6291
function findInputs( elem ) {
moel@348
  6292
	var nodeName = ( elem.nodeName || "" ).toLowerCase();
moel@348
  6293
	if ( nodeName === "input" ) {
moel@348
  6294
		fixDefaultChecked( elem );
moel@348
  6295
	// Skip scripts, get other children
moel@348
  6296
	} else if ( nodeName !== "script" && typeof elem.getElementsByTagName !== "undefined" ) {
moel@348
  6297
		jQuery.grep( elem.getElementsByTagName("input"), fixDefaultChecked );
moel@348
  6298
	}
moel@348
  6299
}
moel@348
  6300
moel@348
  6301
// Derived From: http://www.iecss.com/shimprove/javascript/shimprove.1-0-1.js
moel@348
  6302
function shimCloneNode( elem ) {
moel@348
  6303
	var div = document.createElement( "div" );
moel@348
  6304
	safeFragment.appendChild( div );
moel@348
  6305
moel@348
  6306
	div.innerHTML = elem.outerHTML;
moel@348
  6307
	return div.firstChild;
moel@348
  6308
}
moel@348
  6309
moel@348
  6310
jQuery.extend({
moel@348
  6311
	clone: function( elem, dataAndEvents, deepDataAndEvents ) {
moel@348
  6312
		var srcElements,
moel@348
  6313
			destElements,
moel@348
  6314
			i,
moel@348
  6315
			// IE<=8 does not properly clone detached, unknown element nodes
moel@348
  6316
			clone = jQuery.support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ?
moel@348
  6317
				elem.cloneNode( true ) :
moel@348
  6318
				shimCloneNode( elem );
moel@348
  6319
moel@348
  6320
		if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) &&
moel@348
  6321
				(elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
moel@348
  6322
			// IE copies events bound via attachEvent when using cloneNode.
moel@348
  6323
			// Calling detachEvent on the clone will also remove the events
moel@348
  6324
			// from the original. In order to get around this, we use some
moel@348
  6325
			// proprietary methods to clear the events. Thanks to MooTools
moel@348
  6326
			// guys for this hotness.
moel@348
  6327
moel@348
  6328
			cloneFixAttributes( elem, clone );
moel@348
  6329
moel@348
  6330
			// Using Sizzle here is crazy slow, so we use getElementsByTagName instead
moel@348
  6331
			srcElements = getAll( elem );
moel@348
  6332
			destElements = getAll( clone );
moel@348
  6333
moel@348
  6334
			// Weird iteration because IE will replace the length property
moel@348
  6335
			// with an element if you are cloning the body and one of the
moel@348
  6336
			// elements on the page has a name or id of "length"
moel@348
  6337
			for ( i = 0; srcElements[i]; ++i ) {
moel@348
  6338
				// Ensure that the destination node is not null; Fixes #9587
moel@348
  6339
				if ( destElements[i] ) {
moel@348
  6340
					cloneFixAttributes( srcElements[i], destElements[i] );
moel@348
  6341
				}
moel@348
  6342
			}
moel@348
  6343
		}
moel@348
  6344
moel@348
  6345
		// Copy the events from the original to the clone
moel@348
  6346
		if ( dataAndEvents ) {
moel@348
  6347
			cloneCopyEvent( elem, clone );
moel@348
  6348
moel@348
  6349
			if ( deepDataAndEvents ) {
moel@348
  6350
				srcElements = getAll( elem );
moel@348
  6351
				destElements = getAll( clone );
moel@348
  6352
moel@348
  6353
				for ( i = 0; srcElements[i]; ++i ) {
moel@348
  6354
					cloneCopyEvent( srcElements[i], destElements[i] );
moel@348
  6355
				}
moel@348
  6356
			}
moel@348
  6357
		}
moel@348
  6358
moel@348
  6359
		srcElements = destElements = null;
moel@348
  6360
moel@348
  6361
		// Return the cloned set
moel@348
  6362
		return clone;
moel@348
  6363
	},
moel@348
  6364
moel@348
  6365
	clean: function( elems, context, fragment, scripts ) {
moel@348
  6366
		var checkScriptType, script, j,
moel@348
  6367
				ret = [];
moel@348
  6368
moel@348
  6369
		context = context || document;
moel@348
  6370
moel@348
  6371
		// !context.createElement fails in IE with an error but returns typeof 'object'
moel@348
  6372
		if ( typeof context.createElement === "undefined" ) {
moel@348
  6373
			context = context.ownerDocument || context[0] && context[0].ownerDocument || document;
moel@348
  6374
		}
moel@348
  6375
moel@348
  6376
		for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
moel@348
  6377
			if ( typeof elem === "number" ) {
moel@348
  6378
				elem += "";
moel@348
  6379
			}
moel@348
  6380
moel@348
  6381
			if ( !elem ) {
moel@348
  6382
				continue;
moel@348
  6383
			}
moel@348
  6384
moel@348
  6385
			// Convert html string into DOM nodes
moel@348
  6386
			if ( typeof elem === "string" ) {
moel@348
  6387
				if ( !rhtml.test( elem ) ) {
moel@348
  6388
					elem = context.createTextNode( elem );
moel@348
  6389
				} else {
moel@348
  6390
					// Fix "XHTML"-style tags in all browsers
moel@348
  6391
					elem = elem.replace(rxhtmlTag, "<$1></$2>");
moel@348
  6392
moel@348
  6393
					// Trim whitespace, otherwise indexOf won't work as expected
moel@348
  6394
					var tag = ( rtagName.exec( elem ) || ["", ""] )[1].toLowerCase(),
moel@348
  6395
						wrap = wrapMap[ tag ] || wrapMap._default,
moel@348
  6396
						depth = wrap[0],
moel@348
  6397
						div = context.createElement("div"),
moel@348
  6398
						safeChildNodes = safeFragment.childNodes,
moel@348
  6399
						remove;
moel@348
  6400
moel@348
  6401
					// Append wrapper element to unknown element safe doc fragment
moel@348
  6402
					if ( context === document ) {
moel@348
  6403
						// Use the fragment we've already created for this document
moel@348
  6404
						safeFragment.appendChild( div );
moel@348
  6405
					} else {
moel@348
  6406
						// Use a fragment created with the owner document
moel@348
  6407
						createSafeFragment( context ).appendChild( div );
moel@348
  6408
					}
moel@348
  6409
moel@348
  6410
					// Go to html and back, then peel off extra wrappers
moel@348
  6411
					div.innerHTML = wrap[1] + elem + wrap[2];
moel@348
  6412
moel@348
  6413
					// Move to the right depth
moel@348
  6414
					while ( depth-- ) {
moel@348
  6415
						div = div.lastChild;
moel@348
  6416
					}
moel@348
  6417
moel@348
  6418
					// Remove IE's autoinserted <tbody> from table fragments
moel@348
  6419
					if ( !jQuery.support.tbody ) {
moel@348
  6420
moel@348
  6421
						// String was a <table>, *may* have spurious <tbody>
moel@348
  6422
						var hasBody = rtbody.test(elem),
moel@348
  6423
							tbody = tag === "table" && !hasBody ?
moel@348
  6424
								div.firstChild && div.firstChild.childNodes :
moel@348
  6425
moel@348
  6426
								// String was a bare <thead> or <tfoot>
moel@348
  6427
								wrap[1] === "<table>" && !hasBody ?
moel@348
  6428
									div.childNodes :
moel@348
  6429
									[];
moel@348
  6430
moel@348
  6431
						for ( j = tbody.length - 1; j >= 0 ; --j ) {
moel@348
  6432
							if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) {
moel@348
  6433
								tbody[ j ].parentNode.removeChild( tbody[ j ] );
moel@348
  6434
							}
moel@348
  6435
						}
moel@348
  6436
					}
moel@348
  6437
moel@348
  6438
					// IE completely kills leading whitespace when innerHTML is used
moel@348
  6439
					if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
moel@348
  6440
						div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );
moel@348
  6441
					}
moel@348
  6442
moel@348
  6443
					elem = div.childNodes;
moel@348
  6444
moel@348
  6445
					// Clear elements from DocumentFragment (safeFragment or otherwise)
moel@348
  6446
					// to avoid hoarding elements. Fixes #11356
moel@348
  6447
					if ( div ) {
moel@348
  6448
						div.parentNode.removeChild( div );
moel@348
  6449
moel@348
  6450
						// Guard against -1 index exceptions in FF3.6
moel@348
  6451
						if ( safeChildNodes.length > 0 ) {
moel@348
  6452
							remove = safeChildNodes[ safeChildNodes.length - 1 ];
moel@348
  6453
moel@348
  6454
							if ( remove && remove.parentNode ) {
moel@348
  6455
								remove.parentNode.removeChild( remove );
moel@348
  6456
							}
moel@348
  6457
						}
moel@348
  6458
					}
moel@348
  6459
				}
moel@348
  6460
			}
moel@348
  6461
moel@348
  6462
			// Resets defaultChecked for any radios and checkboxes
moel@348
  6463
			// about to be appended to the DOM in IE 6/7 (#8060)
moel@348
  6464
			var len;
moel@348
  6465
			if ( !jQuery.support.appendChecked ) {
moel@348
  6466
				if ( elem[0] && typeof (len = elem.length) === "number" ) {
moel@348
  6467
					for ( j = 0; j < len; j++ ) {
moel@348
  6468
						findInputs( elem[j] );
moel@348
  6469
					}
moel@348
  6470
				} else {
moel@348
  6471
					findInputs( elem );
moel@348
  6472
				}
moel@348
  6473
			}
moel@348
  6474
moel@348
  6475
			if ( elem.nodeType ) {
moel@348
  6476
				ret.push( elem );
moel@348
  6477
			} else {
moel@348
  6478
				ret = jQuery.merge( ret, elem );
moel@348
  6479
			}
moel@348
  6480
		}
moel@348
  6481
moel@348
  6482
		if ( fragment ) {
moel@348
  6483
			checkScriptType = function( elem ) {
moel@348
  6484
				return !elem.type || rscriptType.test( elem.type );
moel@348
  6485
			};
moel@348
  6486
			for ( i = 0; ret[i]; i++ ) {
moel@348
  6487
				script = ret[i];
moel@348
  6488
				if ( scripts && jQuery.nodeName( script, "script" ) && (!script.type || rscriptType.test( script.type )) ) {
moel@348
  6489
					scripts.push( script.parentNode ? script.parentNode.removeChild( script ) : script );
moel@348
  6490
moel@348
  6491
				} else {
moel@348
  6492
					if ( script.nodeType === 1 ) {
moel@348
  6493
						var jsTags = jQuery.grep( script.getElementsByTagName( "script" ), checkScriptType );
moel@348
  6494
moel@348
  6495
						ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) );
moel@348
  6496
					}
moel@348
  6497
					fragment.appendChild( script );
moel@348
  6498
				}
moel@348
  6499
			}
moel@348
  6500
		}
moel@348
  6501
moel@348
  6502
		return ret;
moel@348
  6503
	},
moel@348
  6504
moel@348
  6505
	cleanData: function( elems ) {
moel@348
  6506
		var data, id,
moel@348
  6507
			cache = jQuery.cache,
moel@348
  6508
			special = jQuery.event.special,
moel@348
  6509
			deleteExpando = jQuery.support.deleteExpando;
moel@348
  6510
moel@348
  6511
		for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
moel@348
  6512
			if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) {
moel@348
  6513
				continue;
moel@348
  6514
			}
moel@348
  6515
moel@348
  6516
			id = elem[ jQuery.expando ];
moel@348
  6517
moel@348
  6518
			if ( id ) {
moel@348
  6519
				data = cache[ id ];
moel@348
  6520
moel@348
  6521
				if ( data && data.events ) {
moel@348
  6522
					for ( var type in data.events ) {
moel@348
  6523
						if ( special[ type ] ) {
moel@348
  6524
							jQuery.event.remove( elem, type );
moel@348
  6525
moel@348
  6526
						// This is a shortcut to avoid jQuery.event.remove's overhead
moel@348
  6527
						} else {
moel@348
  6528
							jQuery.removeEvent( elem, type, data.handle );
moel@348
  6529
						}
moel@348
  6530
					}
moel@348
  6531
moel@348
  6532
					// Null the DOM reference to avoid IE6/7/8 leak (#7054)
moel@348
  6533
					if ( data.handle ) {
moel@348
  6534
						data.handle.elem = null;
moel@348
  6535
					}
moel@348
  6536
				}
moel@348
  6537
moel@348
  6538
				if ( deleteExpando ) {
moel@348
  6539
					delete elem[ jQuery.expando ];
moel@348
  6540
moel@348
  6541
				} else if ( elem.removeAttribute ) {
moel@348
  6542
					elem.removeAttribute( jQuery.expando );
moel@348
  6543
				}
moel@348
  6544
moel@348
  6545
				delete cache[ id ];
moel@348
  6546
			}
moel@348
  6547
		}
moel@348
  6548
	}
moel@348
  6549
});
moel@348
  6550
moel@348
  6551
moel@348
  6552
moel@348
  6553
moel@348
  6554
var ralpha = /alpha\([^)]*\)/i,
moel@348
  6555
	ropacity = /opacity=([^)]*)/,
moel@348
  6556
	// fixed for IE9, see #8346
moel@348
  6557
	rupper = /([A-Z]|^ms)/g,
moel@348
  6558
	rnum = /^[\-+]?(?:\d*\.)?\d+$/i,
moel@348
  6559
	rnumnonpx = /^-?(?:\d*\.)?\d+(?!px)[^\d\s]+$/i,
moel@348
  6560
	rrelNum = /^([\-+])=([\-+.\de]+)/,
moel@348
  6561
	rmargin = /^margin/,
moel@348
  6562
moel@348
  6563
	cssShow = { position: "absolute", visibility: "hidden", display: "block" },
moel@348
  6564
moel@348
  6565
	// order is important!
moel@348
  6566
	cssExpand = [ "Top", "Right", "Bottom", "Left" ],
moel@348
  6567
moel@348
  6568
	curCSS,
moel@348
  6569
moel@348
  6570
	getComputedStyle,
moel@348
  6571
	currentStyle;
moel@348
  6572
moel@348
  6573
jQuery.fn.css = function( name, value ) {
moel@348
  6574
	return jQuery.access( this, function( elem, name, value ) {
moel@348
  6575
		return value !== undefined ?
moel@348
  6576
			jQuery.style( elem, name, value ) :
moel@348
  6577
			jQuery.css( elem, name );
moel@348
  6578
	}, name, value, arguments.length > 1 );
moel@348
  6579
};
moel@348
  6580
moel@348
  6581
jQuery.extend({
moel@348
  6582
	// Add in style property hooks for overriding the default
moel@348
  6583
	// behavior of getting and setting a style property
moel@348
  6584
	cssHooks: {
moel@348
  6585
		opacity: {
moel@348
  6586
			get: function( elem, computed ) {
moel@348
  6587
				if ( computed ) {
moel@348
  6588
					// We should always get a number back from opacity
moel@348
  6589
					var ret = curCSS( elem, "opacity" );
moel@348
  6590
					return ret === "" ? "1" : ret;
moel@348
  6591
moel@348
  6592
				} else {
moel@348
  6593
					return elem.style.opacity;
moel@348
  6594
				}
moel@348
  6595
			}
moel@348
  6596
		}
moel@348
  6597
	},
moel@348
  6598
moel@348
  6599
	// Exclude the following css properties to add px
moel@348
  6600
	cssNumber: {
moel@348
  6601
		"fillOpacity": true,
moel@348
  6602
		"fontWeight": true,
moel@348
  6603
		"lineHeight": true,
moel@348
  6604
		"opacity": true,
moel@348
  6605
		"orphans": true,
moel@348
  6606
		"widows": true,
moel@348
  6607
		"zIndex": true,
moel@348
  6608
		"zoom": true
moel@348
  6609
	},
moel@348
  6610
moel@348
  6611
	// Add in properties whose names you wish to fix before
moel@348
  6612
	// setting or getting the value
moel@348
  6613
	cssProps: {
moel@348
  6614
		// normalize float css property
moel@348
  6615
		"float": jQuery.support.cssFloat ? "cssFloat" : "styleFloat"
moel@348
  6616
	},
moel@348
  6617
moel@348
  6618
	// Get and set the style property on a DOM Node
moel@348
  6619
	style: function( elem, name, value, extra ) {
moel@348
  6620
		// Don't set styles on text and comment nodes
moel@348
  6621
		if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
moel@348
  6622
			return;
moel@348
  6623
		}
moel@348
  6624
moel@348
  6625
		// Make sure that we're working with the right name
moel@348
  6626
		var ret, type, origName = jQuery.camelCase( name ),
moel@348
  6627
			style = elem.style, hooks = jQuery.cssHooks[ origName ];
moel@348
  6628
moel@348
  6629
		name = jQuery.cssProps[ origName ] || origName;
moel@348
  6630
moel@348
  6631
		// Check if we're setting a value
moel@348
  6632
		if ( value !== undefined ) {
moel@348
  6633
			type = typeof value;
moel@348
  6634
moel@348
  6635
			// convert relative number strings (+= or -=) to relative numbers. #7345
moel@348
  6636
			if ( type === "string" && (ret = rrelNum.exec( value )) ) {
moel@348
  6637
				value = ( +( ret[1] + 1) * +ret[2] ) + parseFloat( jQuery.css( elem, name ) );
moel@348
  6638
				// Fixes bug #9237
moel@348
  6639
				type = "number";
moel@348
  6640
			}
moel@348
  6641
moel@348
  6642
			// Make sure that NaN and null values aren't set. See: #7116
moel@348
  6643
			if ( value == null || type === "number" && isNaN( value ) ) {
moel@348
  6644
				return;
moel@348
  6645
			}
moel@348
  6646
moel@348
  6647
			// If a number was passed in, add 'px' to the (except for certain CSS properties)
moel@348
  6648
			if ( type === "number" && !jQuery.cssNumber[ origName ] ) {
moel@348
  6649
				value += "px";
moel@348
  6650
			}
moel@348
  6651
moel@348
  6652
			// If a hook was provided, use that value, otherwise just set the specified value
moel@348
  6653
			if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value )) !== undefined ) {
moel@348
  6654
				// Wrapped to prevent IE from throwing errors when 'invalid' values are provided
moel@348
  6655
				// Fixes bug #5509
moel@348
  6656
				try {
moel@348
  6657
					style[ name ] = value;
moel@348
  6658
				} catch(e) {}
moel@348
  6659
			}
moel@348
  6660
moel@348
  6661
		} else {
moel@348
  6662
			// If a hook was provided get the non-computed value from there
moel@348
  6663
			if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
moel@348
  6664
				return ret;
moel@348
  6665
			}
moel@348
  6666
moel@348
  6667
			// Otherwise just get the value from the style object
moel@348
  6668
			return style[ name ];
moel@348
  6669
		}
moel@348
  6670
	},
moel@348
  6671
moel@348
  6672
	css: function( elem, name, extra ) {
moel@348
  6673
		var ret, hooks;
moel@348
  6674
moel@348
  6675
		// Make sure that we're working with the right name
moel@348
  6676
		name = jQuery.camelCase( name );
moel@348
  6677
		hooks = jQuery.cssHooks[ name ];
moel@348
  6678
		name = jQuery.cssProps[ name ] || name;
moel@348
  6679
moel@348
  6680
		// cssFloat needs a special treatment
moel@348
  6681
		if ( name === "cssFloat" ) {
moel@348
  6682
			name = "float";
moel@348
  6683
		}
moel@348
  6684
moel@348
  6685
		// If a hook was provided get the computed value from there
moel@348
  6686
		if ( hooks && "get" in hooks && (ret = hooks.get( elem, true, extra )) !== undefined ) {
moel@348
  6687
			return ret;
moel@348
  6688
moel@348
  6689
		// Otherwise, if a way to get the computed value exists, use that
moel@348
  6690
		} else if ( curCSS ) {
moel@348
  6691
			return curCSS( elem, name );
moel@348
  6692
		}
moel@348
  6693
	},
moel@348
  6694
moel@348
  6695
	// A method for quickly swapping in/out CSS properties to get correct calculations
moel@348
  6696
	swap: function( elem, options, callback ) {
moel@348
  6697
		var old = {},
moel@348
  6698
			ret, name;
moel@348
  6699
moel@348
  6700
		// Remember the old values, and insert the new ones
moel@348
  6701
		for ( name in options ) {
moel@348
  6702
			old[ name ] = elem.style[ name ];
moel@348
  6703
			elem.style[ name ] = options[ name ];
moel@348
  6704
		}
moel@348
  6705
moel@348
  6706
		ret = callback.call( elem );
moel@348
  6707
moel@348
  6708
		// Revert the old values
moel@348
  6709
		for ( name in options ) {
moel@348
  6710
			elem.style[ name ] = old[ name ];
moel@348
  6711
		}
moel@348
  6712
moel@348
  6713
		return ret;
moel@348
  6714
	}
moel@348
  6715
});
moel@348
  6716
moel@348
  6717
// DEPRECATED in 1.3, Use jQuery.css() instead
moel@348
  6718
jQuery.curCSS = jQuery.css;
moel@348
  6719
moel@348
  6720
if ( document.defaultView && document.defaultView.getComputedStyle ) {
moel@348
  6721
	getComputedStyle = function( elem, name ) {
moel@348
  6722
		var ret, defaultView, computedStyle, width,
moel@348
  6723
			style = elem.style;
moel@348
  6724
moel@348
  6725
		name = name.replace( rupper, "-$1" ).toLowerCase();
moel@348
  6726
moel@348
  6727
		if ( (defaultView = elem.ownerDocument.defaultView) &&
moel@348
  6728
				(computedStyle = defaultView.getComputedStyle( elem, null )) ) {
moel@348
  6729
moel@348
  6730
			ret = computedStyle.getPropertyValue( name );
moel@348
  6731
			if ( ret === "" && !jQuery.contains( elem.ownerDocument.documentElement, elem ) ) {
moel@348
  6732
				ret = jQuery.style( elem, name );
moel@348
  6733
			}
moel@348
  6734
		}
moel@348
  6735
moel@348
  6736
		// A tribute to the "awesome hack by Dean Edwards"
moel@348
  6737
		// WebKit uses "computed value (percentage if specified)" instead of "used value" for margins
moel@348
  6738
		// which is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
moel@348
  6739
		if ( !jQuery.support.pixelMargin && computedStyle && rmargin.test( name ) && rnumnonpx.test( ret ) ) {
moel@348
  6740
			width = style.width;
moel@348
  6741
			style.width = ret;
moel@348
  6742
			ret = computedStyle.width;
moel@348
  6743
			style.width = width;
moel@348
  6744
		}
moel@348
  6745
moel@348
  6746
		return ret;
moel@348
  6747
	};
moel@348
  6748
}
moel@348
  6749
moel@348
  6750
if ( document.documentElement.currentStyle ) {
moel@348
  6751
	currentStyle = function( elem, name ) {
moel@348
  6752
		var left, rsLeft, uncomputed,
moel@348
  6753
			ret = elem.currentStyle && elem.currentStyle[ name ],
moel@348
  6754
			style = elem.style;
moel@348
  6755
moel@348
  6756
		// Avoid setting ret to empty string here
moel@348
  6757
		// so we don't default to auto
moel@348
  6758
		if ( ret == null && style && (uncomputed = style[ name ]) ) {
moel@348
  6759
			ret = uncomputed;
moel@348
  6760
		}
moel@348
  6761
moel@348
  6762
		// From the awesome hack by Dean Edwards
moel@348
  6763
		// http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
moel@348
  6764
moel@348
  6765
		// If we're not dealing with a regular pixel number
moel@348
  6766
		// but a number that has a weird ending, we need to convert it to pixels
moel@348
  6767
		if ( rnumnonpx.test( ret ) ) {
moel@348
  6768
moel@348
  6769
			// Remember the original values
moel@348
  6770
			left = style.left;
moel@348
  6771
			rsLeft = elem.runtimeStyle && elem.runtimeStyle.left;
moel@348
  6772
moel@348
  6773
			// Put in the new values to get a computed value out
moel@348
  6774
			if ( rsLeft ) {
moel@348
  6775
				elem.runtimeStyle.left = elem.currentStyle.left;
moel@348
  6776
			}
moel@348
  6777
			style.left = name === "fontSize" ? "1em" : ret;
moel@348
  6778
			ret = style.pixelLeft + "px";
moel@348
  6779
moel@348
  6780
			// Revert the changed values
moel@348
  6781
			style.left = left;
moel@348
  6782
			if ( rsLeft ) {
moel@348
  6783
				elem.runtimeStyle.left = rsLeft;
moel@348
  6784
			}
moel@348
  6785
		}
moel@348
  6786
moel@348
  6787
		return ret === "" ? "auto" : ret;
moel@348
  6788
	};
moel@348
  6789
}
moel@348
  6790
moel@348
  6791
curCSS = getComputedStyle || currentStyle;
moel@348
  6792
moel@348
  6793
function getWidthOrHeight( elem, name, extra ) {
moel@348
  6794
moel@348
  6795
	// Start with offset property
moel@348
  6796
	var val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
moel@348
  6797
		i = name === "width" ? 1 : 0,
moel@348
  6798
		len = 4;
moel@348
  6799
moel@348
  6800
	if ( val > 0 ) {
moel@348
  6801
		if ( extra !== "border" ) {
moel@348
  6802
			for ( ; i < len; i += 2 ) {
moel@348
  6803
				if ( !extra ) {
moel@348
  6804
					val -= parseFloat( jQuery.css( elem, "padding" + cssExpand[ i ] ) ) || 0;
moel@348
  6805
				}
moel@348
  6806
				if ( extra === "margin" ) {
moel@348
  6807
					val += parseFloat( jQuery.css( elem, extra + cssExpand[ i ] ) ) || 0;
moel@348
  6808
				} else {
moel@348
  6809
					val -= parseFloat( jQuery.css( elem, "border" + cssExpand[ i ] + "Width" ) ) || 0;
moel@348
  6810
				}
moel@348
  6811
			}
moel@348
  6812
		}
moel@348
  6813
moel@348
  6814
		return val + "px";
moel@348
  6815
	}
moel@348
  6816
moel@348
  6817
	// Fall back to computed then uncomputed css if necessary
moel@348
  6818
	val = curCSS( elem, name );
moel@348
  6819
	if ( val < 0 || val == null ) {
moel@348
  6820
		val = elem.style[ name ];
moel@348
  6821
	}
moel@348
  6822
moel@348
  6823
	// Computed unit is not pixels. Stop here and return.
moel@348
  6824
	if ( rnumnonpx.test(val) ) {
moel@348
  6825
		return val;
moel@348
  6826
	}
moel@348
  6827
moel@348
  6828
	// Normalize "", auto, and prepare for extra
moel@348
  6829
	val = parseFloat( val ) || 0;
moel@348
  6830
moel@348
  6831
	// Add padding, border, margin
moel@348
  6832
	if ( extra ) {
moel@348
  6833
		for ( ; i < len; i += 2 ) {
moel@348
  6834
			val += parseFloat( jQuery.css( elem, "padding" + cssExpand[ i ] ) ) || 0;
moel@348
  6835
			if ( extra !== "padding" ) {
moel@348
  6836
				val += parseFloat( jQuery.css( elem, "border" + cssExpand[ i ] + "Width" ) ) || 0;
moel@348
  6837
			}
moel@348
  6838
			if ( extra === "margin" ) {
moel@348
  6839
				val += parseFloat( jQuery.css( elem, extra + cssExpand[ i ]) ) || 0;
moel@348
  6840
			}
moel@348
  6841
		}
moel@348
  6842
	}
moel@348
  6843
moel@348
  6844
	return val + "px";
moel@348
  6845
}
moel@348
  6846
moel@348
  6847
jQuery.each([ "height", "width" ], function( i, name ) {
moel@348
  6848
	jQuery.cssHooks[ name ] = {
moel@348
  6849
		get: function( elem, computed, extra ) {
moel@348
  6850
			if ( computed ) {
moel@348
  6851
				if ( elem.offsetWidth !== 0 ) {
moel@348
  6852
					return getWidthOrHeight( elem, name, extra );
moel@348
  6853
				} else {
moel@348
  6854
					return jQuery.swap( elem, cssShow, function() {
moel@348
  6855
						return getWidthOrHeight( elem, name, extra );
moel@348
  6856
					});
moel@348
  6857
				}
moel@348
  6858
			}
moel@348
  6859
		},
moel@348
  6860
moel@348
  6861
		set: function( elem, value ) {
moel@348
  6862
			return rnum.test( value ) ?
moel@348
  6863
				value + "px" :
moel@348
  6864
				value;
moel@348
  6865
		}
moel@348
  6866
	};
moel@348
  6867
});
moel@348
  6868
moel@348
  6869
if ( !jQuery.support.opacity ) {
moel@348
  6870
	jQuery.cssHooks.opacity = {
moel@348
  6871
		get: function( elem, computed ) {
moel@348
  6872
			// IE uses filters for opacity
moel@348
  6873
			return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ?
moel@348
  6874
				( parseFloat( RegExp.$1 ) / 100 ) + "" :
moel@348
  6875
				computed ? "1" : "";
moel@348
  6876
		},
moel@348
  6877
moel@348
  6878
		set: function( elem, value ) {
moel@348
  6879
			var style = elem.style,
moel@348
  6880
				currentStyle = elem.currentStyle,
moel@348
  6881
				opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "",
moel@348
  6882
				filter = currentStyle && currentStyle.filter || style.filter || "";
moel@348
  6883
moel@348
  6884
			// IE has trouble with opacity if it does not have layout
moel@348
  6885
			// Force it by setting the zoom level
moel@348
  6886
			style.zoom = 1;
moel@348
  6887
moel@348
  6888
			// if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652
moel@348
  6889
			if ( value >= 1 && jQuery.trim( filter.replace( ralpha, "" ) ) === "" ) {
moel@348
  6890
moel@348
  6891
				// Setting style.filter to null, "" & " " still leave "filter:" in the cssText
moel@348
  6892
				// if "filter:" is present at all, clearType is disabled, we want to avoid this
moel@348
  6893
				// style.removeAttribute is IE Only, but so apparently is this code path...
moel@348
  6894
				style.removeAttribute( "filter" );
moel@348
  6895
moel@348
  6896
				// if there there is no filter style applied in a css rule, we are done
moel@348
  6897
				if ( currentStyle && !currentStyle.filter ) {
moel@348
  6898
					return;
moel@348
  6899
				}
moel@348
  6900
			}
moel@348
  6901
moel@348
  6902
			// otherwise, set new filter values
moel@348
  6903
			style.filter = ralpha.test( filter ) ?
moel@348
  6904
				filter.replace( ralpha, opacity ) :
moel@348
  6905
				filter + " " + opacity;
moel@348
  6906
		}
moel@348
  6907
	};
moel@348
  6908
}
moel@348
  6909
moel@348
  6910
jQuery(function() {
moel@348
  6911
	// This hook cannot be added until DOM ready because the support test
moel@348
  6912
	// for it is not run until after DOM ready
moel@348
  6913
	if ( !jQuery.support.reliableMarginRight ) {
moel@348
  6914
		jQuery.cssHooks.marginRight = {
moel@348
  6915
			get: function( elem, computed ) {
moel@348
  6916
				// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
moel@348
  6917
				// Work around by temporarily setting element display to inline-block
moel@348
  6918
				return jQuery.swap( elem, { "display": "inline-block" }, function() {
moel@348
  6919
					if ( computed ) {
moel@348
  6920
						return curCSS( elem, "margin-right" );
moel@348
  6921
					} else {
moel@348
  6922
						return elem.style.marginRight;
moel@348
  6923
					}
moel@348
  6924
				});
moel@348
  6925
			}
moel@348
  6926
		};
moel@348
  6927
	}
moel@348
  6928
});
moel@348
  6929
moel@348
  6930
if ( jQuery.expr && jQuery.expr.filters ) {
moel@348
  6931
	jQuery.expr.filters.hidden = function( elem ) {
moel@348
  6932
		var width = elem.offsetWidth,
moel@348
  6933
			height = elem.offsetHeight;
moel@348
  6934
moel@348
  6935
		return ( width === 0 && height === 0 ) || (!jQuery.support.reliableHiddenOffsets && ((elem.style && elem.style.display) || jQuery.css( elem, "display" )) === "none");
moel@348
  6936
	};
moel@348
  6937
moel@348
  6938
	jQuery.expr.filters.visible = function( elem ) {
moel@348
  6939
		return !jQuery.expr.filters.hidden( elem );
moel@348
  6940
	};
moel@348
  6941
}
moel@348
  6942
moel@348
  6943
// These hooks are used by animate to expand properties
moel@348
  6944
jQuery.each({
moel@348
  6945
	margin: "",
moel@348
  6946
	padding: "",
moel@348
  6947
	border: "Width"
moel@348
  6948
}, function( prefix, suffix ) {
moel@348
  6949
moel@348
  6950
	jQuery.cssHooks[ prefix + suffix ] = {
moel@348
  6951
		expand: function( value ) {
moel@348
  6952
			var i,
moel@348
  6953
moel@348
  6954
				// assumes a single number if not a string
moel@348
  6955
				parts = typeof value === "string" ? value.split(" ") : [ value ],
moel@348
  6956
				expanded = {};
moel@348
  6957
moel@348
  6958
			for ( i = 0; i < 4; i++ ) {
moel@348
  6959
				expanded[ prefix + cssExpand[ i ] + suffix ] =
moel@348
  6960
					parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
moel@348
  6961
			}
moel@348
  6962
moel@348
  6963
			return expanded;
moel@348
  6964
		}
moel@348
  6965
	};
moel@348
  6966
});
moel@348
  6967
moel@348
  6968
moel@348
  6969
moel@348
  6970
moel@348
  6971
var r20 = /%20/g,
moel@348
  6972
	rbracket = /\[\]$/,
moel@348
  6973
	rCRLF = /\r?\n/g,
moel@348
  6974
	rhash = /#.*$/,
moel@348
  6975
	rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
moel@348
  6976
	rinput = /^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
moel@348
  6977
	// #7653, #8125, #8152: local protocol detection
moel@348
  6978
	rlocalProtocol = /^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,
moel@348
  6979
	rnoContent = /^(?:GET|HEAD)$/,
moel@348
  6980
	rprotocol = /^\/\//,
moel@348
  6981
	rquery = /\?/,
moel@348
  6982
	rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
moel@348
  6983
	rselectTextarea = /^(?:select|textarea)/i,
moel@348
  6984
	rspacesAjax = /\s+/,
moel@348
  6985
	rts = /([?&])_=[^&]*/,
moel@348
  6986
	rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,
moel@348
  6987
moel@348
  6988
	// Keep a copy of the old load method
moel@348
  6989
	_load = jQuery.fn.load,
moel@348
  6990
moel@348
  6991
	/* Prefilters
moel@348
  6992
	 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
moel@348
  6993
	 * 2) These are called:
moel@348
  6994
	 *    - BEFORE asking for a transport
moel@348
  6995
	 *    - AFTER param serialization (s.data is a string if s.processData is true)
moel@348
  6996
	 * 3) key is the dataType
moel@348
  6997
	 * 4) the catchall symbol "*" can be used
moel@348
  6998
	 * 5) execution will start with transport dataType and THEN continue down to "*" if needed
moel@348
  6999
	 */
moel@348
  7000
	prefilters = {},
moel@348
  7001
moel@348
  7002
	/* Transports bindings
moel@348
  7003
	 * 1) key is the dataType
moel@348
  7004
	 * 2) the catchall symbol "*" can be used
moel@348
  7005
	 * 3) selection will start with transport dataType and THEN go to "*" if needed
moel@348
  7006
	 */
moel@348
  7007
	transports = {},
moel@348
  7008
moel@348
  7009
	// Document location
moel@348
  7010
	ajaxLocation,
moel@348
  7011
moel@348
  7012
	// Document location segments
moel@348
  7013
	ajaxLocParts,
moel@348
  7014
moel@348
  7015
	// Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
moel@348
  7016
	allTypes = ["*/"] + ["*"];
moel@348
  7017
moel@348
  7018
// #8138, IE may throw an exception when accessing
moel@348
  7019
// a field from window.location if document.domain has been set
moel@348
  7020
try {
moel@348
  7021
	ajaxLocation = location.href;
moel@348
  7022
} catch( e ) {
moel@348
  7023
	// Use the href attribute of an A element
moel@348
  7024
	// since IE will modify it given document.location
moel@348
  7025
	ajaxLocation = document.createElement( "a" );
moel@348
  7026
	ajaxLocation.href = "";
moel@348
  7027
	ajaxLocation = ajaxLocation.href;
moel@348
  7028
}
moel@348
  7029
moel@348
  7030
// Segment location into parts
moel@348
  7031
ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
moel@348
  7032
moel@348
  7033
// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
moel@348
  7034
function addToPrefiltersOrTransports( structure ) {
moel@348
  7035
moel@348
  7036
	// dataTypeExpression is optional and defaults to "*"
moel@348
  7037
	return function( dataTypeExpression, func ) {
moel@348
  7038
moel@348
  7039
		if ( typeof dataTypeExpression !== "string" ) {
moel@348
  7040
			func = dataTypeExpression;
moel@348
  7041
			dataTypeExpression = "*";
moel@348
  7042
		}
moel@348
  7043
moel@348
  7044
		if ( jQuery.isFunction( func ) ) {
moel@348
  7045
			var dataTypes = dataTypeExpression.toLowerCase().split( rspacesAjax ),
moel@348
  7046
				i = 0,
moel@348
  7047
				length = dataTypes.length,
moel@348
  7048
				dataType,
moel@348
  7049
				list,
moel@348
  7050
				placeBefore;
moel@348
  7051
moel@348
  7052
			// For each dataType in the dataTypeExpression
moel@348
  7053
			for ( ; i < length; i++ ) {
moel@348
  7054
				dataType = dataTypes[ i ];
moel@348
  7055
				// We control if we're asked to add before
moel@348
  7056
				// any existing element
moel@348
  7057
				placeBefore = /^\+/.test( dataType );
moel@348
  7058
				if ( placeBefore ) {
moel@348
  7059
					dataType = dataType.substr( 1 ) || "*";
moel@348
  7060
				}
moel@348
  7061
				list = structure[ dataType ] = structure[ dataType ] || [];
moel@348
  7062
				// then we add to the structure accordingly
moel@348
  7063
				list[ placeBefore ? "unshift" : "push" ]( func );
moel@348
  7064
			}
moel@348
  7065
		}
moel@348
  7066
	};
moel@348
  7067
}
moel@348
  7068
moel@348
  7069
// Base inspection function for prefilters and transports
moel@348
  7070
function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR,
moel@348
  7071
		dataType /* internal */, inspected /* internal */ ) {
moel@348
  7072
moel@348
  7073
	dataType = dataType || options.dataTypes[ 0 ];
moel@348
  7074
	inspected = inspected || {};
moel@348
  7075
moel@348
  7076
	inspected[ dataType ] = true;
moel@348
  7077
moel@348
  7078
	var list = structure[ dataType ],
moel@348
  7079
		i = 0,
moel@348
  7080
		length = list ? list.length : 0,
moel@348
  7081
		executeOnly = ( structure === prefilters ),
moel@348
  7082
		selection;
moel@348
  7083
moel@348
  7084
	for ( ; i < length && ( executeOnly || !selection ); i++ ) {
moel@348
  7085
		selection = list[ i ]( options, originalOptions, jqXHR );
moel@348
  7086
		// If we got redirected to another dataType
moel@348
  7087
		// we try there if executing only and not done already
moel@348
  7088
		if ( typeof selection === "string" ) {
moel@348
  7089
			if ( !executeOnly || inspected[ selection ] ) {
moel@348
  7090
				selection = undefined;
moel@348
  7091
			} else {
moel@348
  7092
				options.dataTypes.unshift( selection );
moel@348
  7093
				selection = inspectPrefiltersOrTransports(
moel@348
  7094
						structure, options, originalOptions, jqXHR, selection, inspected );
moel@348
  7095
			}
moel@348
  7096
		}
moel@348
  7097
	}
moel@348
  7098
	// If we're only executing or nothing was selected
moel@348
  7099
	// we try the catchall dataType if not done already
moel@348
  7100
	if ( ( executeOnly || !selection ) && !inspected[ "*" ] ) {
moel@348
  7101
		selection = inspectPrefiltersOrTransports(
moel@348
  7102
				structure, options, originalOptions, jqXHR, "*", inspected );
moel@348
  7103
	}
moel@348
  7104
	// unnecessary when only executing (prefilters)
moel@348
  7105
	// but it'll be ignored by the caller in that case
moel@348
  7106
	return selection;
moel@348
  7107
}
moel@348
  7108
moel@348
  7109
// A special extend for ajax options
moel@348
  7110
// that takes "flat" options (not to be deep extended)
moel@348
  7111
// Fixes #9887
moel@348
  7112
function ajaxExtend( target, src ) {
moel@348
  7113
	var key, deep,
moel@348
  7114
		flatOptions = jQuery.ajaxSettings.flatOptions || {};
moel@348
  7115
	for ( key in src ) {
moel@348
  7116
		if ( src[ key ] !== undefined ) {
moel@348
  7117
			( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
moel@348
  7118
		}
moel@348
  7119
	}
moel@348
  7120
	if ( deep ) {
moel@348
  7121
		jQuery.extend( true, target, deep );
moel@348
  7122
	}
moel@348
  7123
}
moel@348
  7124
moel@348
  7125
jQuery.fn.extend({
moel@348
  7126
	load: function( url, params, callback ) {
moel@348
  7127
		if ( typeof url !== "string" && _load ) {
moel@348
  7128
			return _load.apply( this, arguments );
moel@348
  7129
moel@348
  7130
		// Don't do a request if no elements are being requested
moel@348
  7131
		} else if ( !this.length ) {
moel@348
  7132
			return this;
moel@348
  7133
		}
moel@348
  7134
moel@348
  7135
		var off = url.indexOf( " " );
moel@348
  7136
		if ( off >= 0 ) {
moel@348
  7137
			var selector = url.slice( off, url.length );
moel@348
  7138
			url = url.slice( 0, off );
moel@348
  7139
		}
moel@348
  7140
moel@348
  7141
		// Default to a GET request
moel@348
  7142
		var type = "GET";
moel@348
  7143
moel@348
  7144
		// If the second parameter was provided
moel@348
  7145
		if ( params ) {
moel@348
  7146
			// If it's a function
moel@348
  7147
			if ( jQuery.isFunction( params ) ) {
moel@348
  7148
				// We assume that it's the callback
moel@348
  7149
				callback = params;
moel@348
  7150
				params = undefined;
moel@348
  7151
moel@348
  7152
			// Otherwise, build a param string
moel@348
  7153
			} else if ( typeof params === "object" ) {
moel@348
  7154
				params = jQuery.param( params, jQuery.ajaxSettings.traditional );
moel@348
  7155
				type = "POST";
moel@348
  7156
			}
moel@348
  7157
		}
moel@348
  7158
moel@348
  7159
		var self = this;
moel@348
  7160
moel@348
  7161
		// Request the remote document
moel@348
  7162
		jQuery.ajax({
moel@348
  7163
			url: url,
moel@348
  7164
			type: type,
moel@348
  7165
			dataType: "html",
moel@348
  7166
			data: params,
moel@348
  7167
			// Complete callback (responseText is used internally)
moel@348
  7168
			complete: function( jqXHR, status, responseText ) {
moel@348
  7169
				// Store the response as specified by the jqXHR object
moel@348
  7170
				responseText = jqXHR.responseText;
moel@348
  7171
				// If successful, inject the HTML into all the matched elements
moel@348
  7172
				if ( jqXHR.isResolved() ) {
moel@348
  7173
					// #4825: Get the actual response in case
moel@348
  7174
					// a dataFilter is present in ajaxSettings
moel@348
  7175
					jqXHR.done(function( r ) {
moel@348
  7176
						responseText = r;
moel@348
  7177
					});
moel@348
  7178
					// See if a selector was specified
moel@348
  7179
					self.html( selector ?
moel@348
  7180
						// Create a dummy div to hold the results
moel@348
  7181
						jQuery("<div>")
moel@348
  7182
							// inject the contents of the document in, removing the scripts
moel@348
  7183
							// to avoid any 'Permission Denied' errors in IE
moel@348
  7184
							.append(responseText.replace(rscript, ""))
moel@348
  7185
moel@348
  7186
							// Locate the specified elements
moel@348
  7187
							.find(selector) :
moel@348
  7188
moel@348
  7189
						// If not, just inject the full result
moel@348
  7190
						responseText );
moel@348
  7191
				}
moel@348
  7192
moel@348
  7193
				if ( callback ) {
moel@348
  7194
					self.each( callback, [ responseText, status, jqXHR ] );
moel@348
  7195
				}
moel@348
  7196
			}
moel@348
  7197
		});
moel@348
  7198
moel@348
  7199
		return this;
moel@348
  7200
	},
moel@348
  7201
moel@348
  7202
	serialize: function() {
moel@348
  7203
		return jQuery.param( this.serializeArray() );
moel@348
  7204
	},
moel@348
  7205
moel@348
  7206
	serializeArray: function() {
moel@348
  7207
		return this.map(function(){
moel@348
  7208
			return this.elements ? jQuery.makeArray( this.elements ) : this;
moel@348
  7209
		})
moel@348
  7210
		.filter(function(){
moel@348
  7211
			return this.name && !this.disabled &&
moel@348
  7212
				( this.checked || rselectTextarea.test( this.nodeName ) ||
moel@348
  7213
					rinput.test( this.type ) );
moel@348
  7214
		})
moel@348
  7215
		.map(function( i, elem ){
moel@348
  7216
			var val = jQuery( this ).val();
moel@348
  7217
moel@348
  7218
			return val == null ?
moel@348
  7219
				null :
moel@348
  7220
				jQuery.isArray( val ) ?
moel@348
  7221
					jQuery.map( val, function( val, i ){
moel@348
  7222
						return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
moel@348
  7223
					}) :
moel@348
  7224
					{ name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
moel@348
  7225
		}).get();
moel@348
  7226
	}
moel@348
  7227
});
moel@348
  7228
moel@348
  7229
// Attach a bunch of functions for handling common AJAX events
moel@348
  7230
jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split( " " ), function( i, o ){
moel@348
  7231
	jQuery.fn[ o ] = function( f ){
moel@348
  7232
		return this.on( o, f );
moel@348
  7233
	};
moel@348
  7234
});
moel@348
  7235
moel@348
  7236
jQuery.each( [ "get", "post" ], function( i, method ) {
moel@348
  7237
	jQuery[ method ] = function( url, data, callback, type ) {
moel@348
  7238
		// shift arguments if data argument was omitted
moel@348
  7239
		if ( jQuery.isFunction( data ) ) {
moel@348
  7240
			type = type || callback;
moel@348
  7241
			callback = data;
moel@348
  7242
			data = undefined;
moel@348
  7243
		}
moel@348
  7244
moel@348
  7245
		return jQuery.ajax({
moel@348
  7246
			type: method,
moel@348
  7247
			url: url,
moel@348
  7248
			data: data,
moel@348
  7249
			success: callback,
moel@348
  7250
			dataType: type
moel@348
  7251
		});
moel@348
  7252
	};
moel@348
  7253
});
moel@348
  7254
moel@348
  7255
jQuery.extend({
moel@348
  7256
moel@348
  7257
	getScript: function( url, callback ) {
moel@348
  7258
		return jQuery.get( url, undefined, callback, "script" );
moel@348
  7259
	},
moel@348
  7260
moel@348
  7261
	getJSON: function( url, data, callback ) {
moel@348
  7262
		return jQuery.get( url, data, callback, "json" );
moel@348
  7263
	},
moel@348
  7264
moel@348
  7265
	// Creates a full fledged settings object into target
moel@348
  7266
	// with both ajaxSettings and settings fields.
moel@348
  7267
	// If target is omitted, writes into ajaxSettings.
moel@348
  7268
	ajaxSetup: function( target, settings ) {
moel@348
  7269
		if ( settings ) {
moel@348
  7270
			// Building a settings object
moel@348
  7271
			ajaxExtend( target, jQuery.ajaxSettings );
moel@348
  7272
		} else {
moel@348
  7273
			// Extending ajaxSettings
moel@348
  7274
			settings = target;
moel@348
  7275
			target = jQuery.ajaxSettings;
moel@348
  7276
		}
moel@348
  7277
		ajaxExtend( target, settings );
moel@348
  7278
		return target;
moel@348
  7279
	},
moel@348
  7280
moel@348
  7281
	ajaxSettings: {
moel@348
  7282
		url: ajaxLocation,
moel@348
  7283
		isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
moel@348
  7284
		global: true,
moel@348
  7285
		type: "GET",
moel@348
  7286
		contentType: "application/x-www-form-urlencoded; charset=UTF-8",
moel@348
  7287
		processData: true,
moel@348
  7288
		async: true,
moel@348
  7289
		/*
moel@348
  7290
		timeout: 0,
moel@348
  7291
		data: null,
moel@348
  7292
		dataType: null,
moel@348
  7293
		username: null,
moel@348
  7294
		password: null,
moel@348
  7295
		cache: null,
moel@348
  7296
		traditional: false,
moel@348
  7297
		headers: {},
moel@348
  7298
		*/
moel@348
  7299
moel@348
  7300
		accepts: {
moel@348
  7301
			xml: "application/xml, text/xml",
moel@348
  7302
			html: "text/html",
moel@348
  7303
			text: "text/plain",
moel@348
  7304
			json: "application/json, text/javascript",
moel@348
  7305
			"*": allTypes
moel@348
  7306
		},
moel@348
  7307
moel@348
  7308
		contents: {
moel@348
  7309
			xml: /xml/,
moel@348
  7310
			html: /html/,
moel@348
  7311
			json: /json/
moel@348
  7312
		},
moel@348
  7313
moel@348
  7314
		responseFields: {
moel@348
  7315
			xml: "responseXML",
moel@348
  7316
			text: "responseText"
moel@348
  7317
		},
moel@348
  7318
moel@348
  7319
		// List of data converters
moel@348
  7320
		// 1) key format is "source_type destination_type" (a single space in-between)
moel@348
  7321
		// 2) the catchall symbol "*" can be used for source_type
moel@348
  7322
		converters: {
moel@348
  7323
moel@348
  7324
			// Convert anything to text
moel@348
  7325
			"* text": window.String,
moel@348
  7326
moel@348
  7327
			// Text to html (true = no transformation)
moel@348
  7328
			"text html": true,
moel@348
  7329
moel@348
  7330
			// Evaluate text as a json expression
moel@348
  7331
			"text json": jQuery.parseJSON,
moel@348
  7332
moel@348
  7333
			// Parse text as xml
moel@348
  7334
			"text xml": jQuery.parseXML
moel@348
  7335
		},
moel@348
  7336
moel@348
  7337
		// For options that shouldn't be deep extended:
moel@348
  7338
		// you can add your own custom options here if
moel@348
  7339
		// and when you create one that shouldn't be
moel@348
  7340
		// deep extended (see ajaxExtend)
moel@348
  7341
		flatOptions: {
moel@348
  7342
			context: true,
moel@348
  7343
			url: true
moel@348
  7344
		}
moel@348
  7345
	},
moel@348
  7346
moel@348
  7347
	ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
moel@348
  7348
	ajaxTransport: addToPrefiltersOrTransports( transports ),
moel@348
  7349
moel@348
  7350
	// Main method
moel@348
  7351
	ajax: function( url, options ) {
moel@348
  7352
moel@348
  7353
		// If url is an object, simulate pre-1.5 signature
moel@348
  7354
		if ( typeof url === "object" ) {
moel@348
  7355
			options = url;
moel@348
  7356
			url = undefined;
moel@348
  7357
		}
moel@348
  7358
moel@348
  7359
		// Force options to be an object
moel@348
  7360
		options = options || {};
moel@348
  7361
moel@348
  7362
		var // Create the final options object
moel@348
  7363
			s = jQuery.ajaxSetup( {}, options ),
moel@348
  7364
			// Callbacks context
moel@348
  7365
			callbackContext = s.context || s,
moel@348
  7366
			// Context for global events
moel@348
  7367
			// It's the callbackContext if one was provided in the options
moel@348
  7368
			// and if it's a DOM node or a jQuery collection
moel@348
  7369
			globalEventContext = callbackContext !== s &&
moel@348
  7370
				( callbackContext.nodeType || callbackContext instanceof jQuery ) ?
moel@348
  7371
						jQuery( callbackContext ) : jQuery.event,
moel@348
  7372
			// Deferreds
moel@348
  7373
			deferred = jQuery.Deferred(),
moel@348
  7374
			completeDeferred = jQuery.Callbacks( "once memory" ),
moel@348
  7375
			// Status-dependent callbacks
moel@348
  7376
			statusCode = s.statusCode || {},
moel@348
  7377
			// ifModified key
moel@348
  7378
			ifModifiedKey,
moel@348
  7379
			// Headers (they are sent all at once)
moel@348
  7380
			requestHeaders = {},
moel@348
  7381
			requestHeadersNames = {},
moel@348
  7382
			// Response headers
moel@348
  7383
			responseHeadersString,
moel@348
  7384
			responseHeaders,
moel@348
  7385
			// transport
moel@348
  7386
			transport,
moel@348
  7387
			// timeout handle
moel@348
  7388
			timeoutTimer,
moel@348
  7389
			// Cross-domain detection vars
moel@348
  7390
			parts,
moel@348
  7391
			// The jqXHR state
moel@348
  7392
			state = 0,
moel@348
  7393
			// To know if global events are to be dispatched
moel@348
  7394
			fireGlobals,
moel@348
  7395
			// Loop variable
moel@348
  7396
			i,
moel@348
  7397
			// Fake xhr
moel@348
  7398
			jqXHR = {
moel@348
  7399
moel@348
  7400
				readyState: 0,
moel@348
  7401
moel@348
  7402
				// Caches the header
moel@348
  7403
				setRequestHeader: function( name, value ) {
moel@348
  7404
					if ( !state ) {
moel@348
  7405
						var lname = name.toLowerCase();
moel@348
  7406
						name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
moel@348
  7407
						requestHeaders[ name ] = value;
moel@348
  7408
					}
moel@348
  7409
					return this;
moel@348
  7410
				},
moel@348
  7411
moel@348
  7412
				// Raw string
moel@348
  7413
				getAllResponseHeaders: function() {
moel@348
  7414
					return state === 2 ? responseHeadersString : null;
moel@348
  7415
				},
moel@348
  7416
moel@348
  7417
				// Builds headers hashtable if needed
moel@348
  7418
				getResponseHeader: function( key ) {
moel@348
  7419
					var match;
moel@348
  7420
					if ( state === 2 ) {
moel@348
  7421
						if ( !responseHeaders ) {
moel@348
  7422
							responseHeaders = {};
moel@348
  7423
							while( ( match = rheaders.exec( responseHeadersString ) ) ) {
moel@348
  7424
								responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
moel@348
  7425
							}
moel@348
  7426
						}
moel@348
  7427
						match = responseHeaders[ key.toLowerCase() ];
moel@348
  7428
					}
moel@348
  7429
					return match === undefined ? null : match;
moel@348
  7430
				},
moel@348
  7431
moel@348
  7432
				// Overrides response content-type header
moel@348
  7433
				overrideMimeType: function( type ) {
moel@348
  7434
					if ( !state ) {
moel@348
  7435
						s.mimeType = type;
moel@348
  7436
					}
moel@348
  7437
					return this;
moel@348
  7438
				},
moel@348
  7439
moel@348
  7440
				// Cancel the request
moel@348
  7441
				abort: function( statusText ) {
moel@348
  7442
					statusText = statusText || "abort";
moel@348
  7443
					if ( transport ) {
moel@348
  7444
						transport.abort( statusText );
moel@348
  7445
					}
moel@348
  7446
					done( 0, statusText );
moel@348
  7447
					return this;
moel@348
  7448
				}
moel@348
  7449
			};
moel@348
  7450
moel@348
  7451
		// Callback for when everything is done
moel@348
  7452
		// It is defined here because jslint complains if it is declared
moel@348
  7453
		// at the end of the function (which would be more logical and readable)
moel@348
  7454
		function done( status, nativeStatusText, responses, headers ) {
moel@348
  7455
moel@348
  7456
			// Called once
moel@348
  7457
			if ( state === 2 ) {
moel@348
  7458
				return;
moel@348
  7459
			}
moel@348
  7460
moel@348
  7461
			// State is "done" now
moel@348
  7462
			state = 2;
moel@348
  7463
moel@348
  7464
			// Clear timeout if it exists
moel@348
  7465
			if ( timeoutTimer ) {
moel@348
  7466
				clearTimeout( timeoutTimer );
moel@348
  7467
			}
moel@348
  7468
moel@348
  7469
			// Dereference transport for early garbage collection
moel@348
  7470
			// (no matter how long the jqXHR object will be used)
moel@348
  7471
			transport = undefined;
moel@348
  7472
moel@348
  7473
			// Cache response headers
moel@348
  7474
			responseHeadersString = headers || "";
moel@348
  7475
moel@348
  7476
			// Set readyState
moel@348
  7477
			jqXHR.readyState = status > 0 ? 4 : 0;
moel@348
  7478
moel@348
  7479
			var isSuccess,
moel@348
  7480
				success,
moel@348
  7481
				error,
moel@348
  7482
				statusText = nativeStatusText,
moel@348
  7483
				response = responses ? ajaxHandleResponses( s, jqXHR, responses ) : undefined,
moel@348
  7484
				lastModified,
moel@348
  7485
				etag;
moel@348
  7486
moel@348
  7487
			// If successful, handle type chaining
moel@348
  7488
			if ( status >= 200 && status < 300 || status === 304 ) {
moel@348
  7489
moel@348
  7490
				// Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
moel@348
  7491
				if ( s.ifModified ) {
moel@348
  7492
moel@348
  7493
					if ( ( lastModified = jqXHR.getResponseHeader( "Last-Modified" ) ) ) {
moel@348
  7494
						jQuery.lastModified[ ifModifiedKey ] = lastModified;
moel@348
  7495
					}
moel@348
  7496
					if ( ( etag = jqXHR.getResponseHeader( "Etag" ) ) ) {
moel@348
  7497
						jQuery.etag[ ifModifiedKey ] = etag;
moel@348
  7498
					}
moel@348
  7499
				}
moel@348
  7500
moel@348
  7501
				// If not modified
moel@348
  7502
				if ( status === 304 ) {
moel@348
  7503
moel@348
  7504
					statusText = "notmodified";
moel@348
  7505
					isSuccess = true;
moel@348
  7506
moel@348
  7507
				// If we have data
moel@348
  7508
				} else {
moel@348
  7509
moel@348
  7510
					try {
moel@348
  7511
						success = ajaxConvert( s, response );
moel@348
  7512
						statusText = "success";
moel@348
  7513
						isSuccess = true;
moel@348
  7514
					} catch(e) {
moel@348
  7515
						// We have a parsererror
moel@348
  7516
						statusText = "parsererror";
moel@348
  7517
						error = e;
moel@348
  7518
					}
moel@348
  7519
				}
moel@348
  7520
			} else {
moel@348
  7521
				// We extract error from statusText
moel@348
  7522
				// then normalize statusText and status for non-aborts
moel@348
  7523
				error = statusText;
moel@348
  7524
				if ( !statusText || status ) {
moel@348
  7525
					statusText = "error";
moel@348
  7526
					if ( status < 0 ) {
moel@348
  7527
						status = 0;
moel@348
  7528
					}
moel@348
  7529
				}
moel@348
  7530
			}
moel@348
  7531
moel@348
  7532
			// Set data for the fake xhr object
moel@348
  7533
			jqXHR.status = status;
moel@348
  7534
			jqXHR.statusText = "" + ( nativeStatusText || statusText );
moel@348
  7535
moel@348
  7536
			// Success/Error
moel@348
  7537
			if ( isSuccess ) {
moel@348
  7538
				deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
moel@348
  7539
			} else {
moel@348
  7540
				deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
moel@348
  7541
			}
moel@348
  7542
moel@348
  7543
			// Status-dependent callbacks
moel@348
  7544
			jqXHR.statusCode( statusCode );
moel@348
  7545
			statusCode = undefined;
moel@348
  7546
moel@348
  7547
			if ( fireGlobals ) {
moel@348
  7548
				globalEventContext.trigger( "ajax" + ( isSuccess ? "Success" : "Error" ),
moel@348
  7549
						[ jqXHR, s, isSuccess ? success : error ] );
moel@348
  7550
			}
moel@348
  7551
moel@348
  7552
			// Complete
moel@348
  7553
			completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
moel@348
  7554
moel@348
  7555
			if ( fireGlobals ) {
moel@348
  7556
				globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
moel@348
  7557
				// Handle the global AJAX counter
moel@348
  7558
				if ( !( --jQuery.active ) ) {
moel@348
  7559
					jQuery.event.trigger( "ajaxStop" );
moel@348
  7560
				}
moel@348
  7561
			}
moel@348
  7562
		}
moel@348
  7563
moel@348
  7564
		// Attach deferreds
moel@348
  7565
		deferred.promise( jqXHR );
moel@348
  7566
		jqXHR.success = jqXHR.done;
moel@348
  7567
		jqXHR.error = jqXHR.fail;
moel@348
  7568
		jqXHR.complete = completeDeferred.add;
moel@348
  7569
moel@348
  7570
		// Status-dependent callbacks
moel@348
  7571
		jqXHR.statusCode = function( map ) {
moel@348
  7572
			if ( map ) {
moel@348
  7573
				var tmp;
moel@348
  7574
				if ( state < 2 ) {
moel@348
  7575
					for ( tmp in map ) {
moel@348
  7576
						statusCode[ tmp ] = [ statusCode[tmp], map[tmp] ];
moel@348
  7577
					}
moel@348
  7578
				} else {
moel@348
  7579
					tmp = map[ jqXHR.status ];
moel@348
  7580
					jqXHR.then( tmp, tmp );
moel@348
  7581
				}
moel@348
  7582
			}
moel@348
  7583
			return this;
moel@348
  7584
		};
moel@348
  7585
moel@348
  7586
		// Remove hash character (#7531: and string promotion)
moel@348
  7587
		// Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
moel@348
  7588
		// We also use the url parameter if available
moel@348
  7589
		s.url = ( ( url || s.url ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
moel@348
  7590
moel@348
  7591
		// Extract dataTypes list
moel@348
  7592
		s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( rspacesAjax );
moel@348
  7593
moel@348
  7594
		// Determine if a cross-domain request is in order
moel@348
  7595
		if ( s.crossDomain == null ) {
moel@348
  7596
			parts = rurl.exec( s.url.toLowerCase() );
moel@348
  7597
			s.crossDomain = !!( parts &&
moel@348
  7598
				( parts[ 1 ] != ajaxLocParts[ 1 ] || parts[ 2 ] != ajaxLocParts[ 2 ] ||
moel@348
  7599
					( parts[ 3 ] || ( parts[ 1 ] === "http:" ? 80 : 443 ) ) !=
moel@348
  7600
						( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) ) )
moel@348
  7601
			);
moel@348
  7602
		}
moel@348
  7603
moel@348
  7604
		// Convert data if not already a string
moel@348
  7605
		if ( s.data && s.processData && typeof s.data !== "string" ) {
moel@348
  7606
			s.data = jQuery.param( s.data, s.traditional );
moel@348
  7607
		}
moel@348
  7608
moel@348
  7609
		// Apply prefilters
moel@348
  7610
		inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
moel@348
  7611
moel@348
  7612
		// If request was aborted inside a prefilter, stop there
moel@348
  7613
		if ( state === 2 ) {
moel@348
  7614
			return false;
moel@348
  7615
		}
moel@348
  7616
moel@348
  7617
		// We can fire global events as of now if asked to
moel@348
  7618
		fireGlobals = s.global;
moel@348
  7619
moel@348
  7620
		// Uppercase the type
moel@348
  7621
		s.type = s.type.toUpperCase();
moel@348
  7622
moel@348
  7623
		// Determine if request has content
moel@348
  7624
		s.hasContent = !rnoContent.test( s.type );
moel@348
  7625
moel@348
  7626
		// Watch for a new set of requests
moel@348
  7627
		if ( fireGlobals && jQuery.active++ === 0 ) {
moel@348
  7628
			jQuery.event.trigger( "ajaxStart" );
moel@348
  7629
		}
moel@348
  7630
moel@348
  7631
		// More options handling for requests with no content
moel@348
  7632
		if ( !s.hasContent ) {
moel@348
  7633
moel@348
  7634
			// If data is available, append data to url
moel@348
  7635
			if ( s.data ) {
moel@348
  7636
				s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.data;
moel@348
  7637
				// #9682: remove data so that it's not used in an eventual retry
moel@348
  7638
				delete s.data;
moel@348
  7639
			}
moel@348
  7640
moel@348
  7641
			// Get ifModifiedKey before adding the anti-cache parameter
moel@348
  7642
			ifModifiedKey = s.url;
moel@348
  7643
moel@348
  7644
			// Add anti-cache in url if needed
moel@348
  7645
			if ( s.cache === false ) {
moel@348
  7646
moel@348
  7647
				var ts = jQuery.now(),
moel@348
  7648
					// try replacing _= if it is there
moel@348
  7649
					ret = s.url.replace( rts, "$1_=" + ts );
moel@348
  7650
moel@348
  7651
				// if nothing was replaced, add timestamp to the end
moel@348
  7652
				s.url = ret + ( ( ret === s.url ) ? ( rquery.test( s.url ) ? "&" : "?" ) + "_=" + ts : "" );
moel@348
  7653
			}
moel@348
  7654
		}
moel@348
  7655
moel@348
  7656
		// Set the correct header, if data is being sent
moel@348
  7657
		if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
moel@348
  7658
			jqXHR.setRequestHeader( "Content-Type", s.contentType );
moel@348
  7659
		}
moel@348
  7660
moel@348
  7661
		// Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
moel@348
  7662
		if ( s.ifModified ) {
moel@348
  7663
			ifModifiedKey = ifModifiedKey || s.url;
moel@348
  7664
			if ( jQuery.lastModified[ ifModifiedKey ] ) {
moel@348
  7665
				jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ ifModifiedKey ] );
moel@348
  7666
			}
moel@348
  7667
			if ( jQuery.etag[ ifModifiedKey ] ) {
moel@348
  7668
				jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ ifModifiedKey ] );
moel@348
  7669
			}
moel@348
  7670
		}
moel@348
  7671
moel@348
  7672
		// Set the Accepts header for the server, depending on the dataType
moel@348
  7673
		jqXHR.setRequestHeader(
moel@348
  7674
			"Accept",
moel@348
  7675
			s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
moel@348
  7676
				s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
moel@348
  7677
				s.accepts[ "*" ]
moel@348
  7678
		);
moel@348
  7679
moel@348
  7680
		// Check for headers option
moel@348
  7681
		for ( i in s.headers ) {
moel@348
  7682
			jqXHR.setRequestHeader( i, s.headers[ i ] );
moel@348
  7683
		}
moel@348
  7684
moel@348
  7685
		// Allow custom headers/mimetypes and early abort
moel@348
  7686
		if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
moel@348
  7687
				// Abort if not done already
moel@348
  7688
				jqXHR.abort();
moel@348
  7689
				return false;
moel@348
  7690
moel@348
  7691
		}
moel@348
  7692
moel@348
  7693
		// Install callbacks on deferreds
moel@348
  7694
		for ( i in { success: 1, error: 1, complete: 1 } ) {
moel@348
  7695
			jqXHR[ i ]( s[ i ] );
moel@348
  7696
		}
moel@348
  7697
moel@348
  7698
		// Get transport
moel@348
  7699
		transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
moel@348
  7700
moel@348
  7701
		// If no transport, we auto-abort
moel@348
  7702
		if ( !transport ) {
moel@348
  7703
			done( -1, "No Transport" );
moel@348
  7704
		} else {
moel@348
  7705
			jqXHR.readyState = 1;
moel@348
  7706
			// Send global event
moel@348
  7707
			if ( fireGlobals ) {
moel@348
  7708
				globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
moel@348
  7709
			}
moel@348
  7710
			// Timeout
moel@348
  7711
			if ( s.async && s.timeout > 0 ) {
moel@348
  7712
				timeoutTimer = setTimeout( function(){
moel@348
  7713
					jqXHR.abort( "timeout" );
moel@348
  7714
				}, s.timeout );
moel@348
  7715
			}
moel@348
  7716
moel@348
  7717
			try {
moel@348
  7718
				state = 1;
moel@348
  7719
				transport.send( requestHeaders, done );
moel@348
  7720
			} catch (e) {
moel@348
  7721
				// Propagate exception as error if not done
moel@348
  7722
				if ( state < 2 ) {
moel@348
  7723
					done( -1, e );
moel@348
  7724
				// Simply rethrow otherwise
moel@348
  7725
				} else {
moel@348
  7726
					throw e;
moel@348
  7727
				}
moel@348
  7728
			}
moel@348
  7729
		}
moel@348
  7730
moel@348
  7731
		return jqXHR;
moel@348
  7732
	},
moel@348
  7733
moel@348
  7734
	// Serialize an array of form elements or a set of
moel@348
  7735
	// key/values into a query string
moel@348
  7736
	param: function( a, traditional ) {
moel@348
  7737
		var s = [],
moel@348
  7738
			add = function( key, value ) {
moel@348
  7739
				// If value is a function, invoke it and return its value
moel@348
  7740
				value = jQuery.isFunction( value ) ? value() : value;
moel@348
  7741
				s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
moel@348
  7742
			};
moel@348
  7743
moel@348
  7744
		// Set traditional to true for jQuery <= 1.3.2 behavior.
moel@348
  7745
		if ( traditional === undefined ) {
moel@348
  7746
			traditional = jQuery.ajaxSettings.traditional;
moel@348
  7747
		}
moel@348
  7748
moel@348
  7749
		// If an array was passed in, assume that it is an array of form elements.
moel@348
  7750
		if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
moel@348
  7751
			// Serialize the form elements
moel@348
  7752
			jQuery.each( a, function() {
moel@348
  7753
				add( this.name, this.value );
moel@348
  7754
			});
moel@348
  7755
moel@348
  7756
		} else {
moel@348
  7757
			// If traditional, encode the "old" way (the way 1.3.2 or older
moel@348
  7758
			// did it), otherwise encode params recursively.
moel@348
  7759
			for ( var prefix in a ) {
moel@348
  7760
				buildParams( prefix, a[ prefix ], traditional, add );
moel@348
  7761
			}
moel@348
  7762
		}
moel@348
  7763
moel@348
  7764
		// Return the resulting serialization
moel@348
  7765
		return s.join( "&" ).replace( r20, "+" );
moel@348
  7766
	}
moel@348
  7767
});
moel@348
  7768
moel@348
  7769
function buildParams( prefix, obj, traditional, add ) {
moel@348
  7770
	if ( jQuery.isArray( obj ) ) {
moel@348
  7771
		// Serialize array item.
moel@348
  7772
		jQuery.each( obj, function( i, v ) {
moel@348
  7773
			if ( traditional || rbracket.test( prefix ) ) {
moel@348
  7774
				// Treat each array item as a scalar.
moel@348
  7775
				add( prefix, v );
moel@348
  7776
moel@348
  7777
			} else {
moel@348
  7778
				// If array item is non-scalar (array or object), encode its
moel@348
  7779
				// numeric index to resolve deserialization ambiguity issues.
moel@348
  7780
				// Note that rack (as of 1.0.0) can't currently deserialize
moel@348
  7781
				// nested arrays properly, and attempting to do so may cause
moel@348
  7782
				// a server error. Possible fixes are to modify rack's
moel@348
  7783
				// deserialization algorithm or to provide an option or flag
moel@348
  7784
				// to force array serialization to be shallow.
moel@348
  7785
				buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add );
moel@348
  7786
			}
moel@348
  7787
		});
moel@348
  7788
moel@348
  7789
	} else if ( !traditional && jQuery.type( obj ) === "object" ) {
moel@348
  7790
		// Serialize object item.
moel@348
  7791
		for ( var name in obj ) {
moel@348
  7792
			buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
moel@348
  7793
		}
moel@348
  7794
moel@348
  7795
	} else {
moel@348
  7796
		// Serialize scalar item.
moel@348
  7797
		add( prefix, obj );
moel@348
  7798
	}
moel@348
  7799
}
moel@348
  7800
moel@348
  7801
// This is still on the jQuery object... for now
moel@348
  7802
// Want to move this to jQuery.ajax some day
moel@348
  7803
jQuery.extend({
moel@348
  7804
moel@348
  7805
	// Counter for holding the number of active queries
moel@348
  7806
	active: 0,
moel@348
  7807
moel@348
  7808
	// Last-Modified header cache for next request
moel@348
  7809
	lastModified: {},
moel@348
  7810
	etag: {}
moel@348
  7811
moel@348
  7812
});
moel@348
  7813
moel@348
  7814
/* Handles responses to an ajax request:
moel@348
  7815
 * - sets all responseXXX fields accordingly
moel@348
  7816
 * - finds the right dataType (mediates between content-type and expected dataType)
moel@348
  7817
 * - returns the corresponding response
moel@348
  7818
 */
moel@348
  7819
function ajaxHandleResponses( s, jqXHR, responses ) {
moel@348
  7820
moel@348
  7821
	var contents = s.contents,
moel@348
  7822
		dataTypes = s.dataTypes,
moel@348
  7823
		responseFields = s.responseFields,
moel@348
  7824
		ct,
moel@348
  7825
		type,
moel@348
  7826
		finalDataType,
moel@348
  7827
		firstDataType;
moel@348
  7828
moel@348
  7829
	// Fill responseXXX fields
moel@348
  7830
	for ( type in responseFields ) {
moel@348
  7831
		if ( type in responses ) {
moel@348
  7832
			jqXHR[ responseFields[type] ] = responses[ type ];
moel@348
  7833
		}
moel@348
  7834
	}
moel@348
  7835
moel@348
  7836
	// Remove auto dataType and get content-type in the process
moel@348
  7837
	while( dataTypes[ 0 ] === "*" ) {
moel@348
  7838
		dataTypes.shift();
moel@348
  7839
		if ( ct === undefined ) {
moel@348
  7840
			ct = s.mimeType || jqXHR.getResponseHeader( "content-type" );
moel@348
  7841
		}
moel@348
  7842
	}
moel@348
  7843
moel@348
  7844
	// Check if we're dealing with a known content-type
moel@348
  7845
	if ( ct ) {
moel@348
  7846
		for ( type in contents ) {
moel@348
  7847
			if ( contents[ type ] && contents[ type ].test( ct ) ) {
moel@348
  7848
				dataTypes.unshift( type );
moel@348
  7849
				break;
moel@348
  7850
			}
moel@348
  7851
		}
moel@348
  7852
	}
moel@348
  7853
moel@348
  7854
	// Check to see if we have a response for the expected dataType
moel@348
  7855
	if ( dataTypes[ 0 ] in responses ) {
moel@348
  7856
		finalDataType = dataTypes[ 0 ];
moel@348
  7857
	} else {
moel@348
  7858
		// Try convertible dataTypes
moel@348
  7859
		for ( type in responses ) {
moel@348
  7860
			if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
moel@348
  7861
				finalDataType = type;
moel@348
  7862
				break;
moel@348
  7863
			}
moel@348
  7864
			if ( !firstDataType ) {
moel@348
  7865
				firstDataType = type;
moel@348
  7866
			}
moel@348
  7867
		}
moel@348
  7868
		// Or just use first one
moel@348
  7869
		finalDataType = finalDataType || firstDataType;
moel@348
  7870
	}
moel@348
  7871
moel@348
  7872
	// If we found a dataType
moel@348
  7873
	// We add the dataType to the list if needed
moel@348
  7874
	// and return the corresponding response
moel@348
  7875
	if ( finalDataType ) {
moel@348
  7876
		if ( finalDataType !== dataTypes[ 0 ] ) {
moel@348
  7877
			dataTypes.unshift( finalDataType );
moel@348
  7878
		}
moel@348
  7879
		return responses[ finalDataType ];
moel@348
  7880
	}
moel@348
  7881
}
moel@348
  7882
moel@348
  7883
// Chain conversions given the request and the original response
moel@348
  7884
function ajaxConvert( s, response ) {
moel@348
  7885
moel@348
  7886
	// Apply the dataFilter if provided
moel@348
  7887
	if ( s.dataFilter ) {
moel@348
  7888
		response = s.dataFilter( response, s.dataType );
moel@348
  7889
	}
moel@348
  7890
moel@348
  7891
	var dataTypes = s.dataTypes,
moel@348
  7892
		converters = {},
moel@348
  7893
		i,
moel@348
  7894
		key,
moel@348
  7895
		length = dataTypes.length,
moel@348
  7896
		tmp,
moel@348
  7897
		// Current and previous dataTypes
moel@348
  7898
		current = dataTypes[ 0 ],
moel@348
  7899
		prev,
moel@348
  7900
		// Conversion expression
moel@348
  7901
		conversion,
moel@348
  7902
		// Conversion function
moel@348
  7903
		conv,
moel@348
  7904
		// Conversion functions (transitive conversion)
moel@348
  7905
		conv1,
moel@348
  7906
		conv2;
moel@348
  7907
moel@348
  7908
	// For each dataType in the chain
moel@348
  7909
	for ( i = 1; i < length; i++ ) {
moel@348
  7910
moel@348
  7911
		// Create converters map
moel@348
  7912
		// with lowercased keys
moel@348
  7913
		if ( i === 1 ) {
moel@348
  7914
			for ( key in s.converters ) {
moel@348
  7915
				if ( typeof key === "string" ) {
moel@348
  7916
					converters[ key.toLowerCase() ] = s.converters[ key ];
moel@348
  7917
				}
moel@348
  7918
			}
moel@348
  7919
		}
moel@348
  7920
moel@348
  7921
		// Get the dataTypes
moel@348
  7922
		prev = current;
moel@348
  7923
		current = dataTypes[ i ];
moel@348
  7924
moel@348
  7925
		// If current is auto dataType, update it to prev
moel@348
  7926
		if ( current === "*" ) {
moel@348
  7927
			current = prev;
moel@348
  7928
		// If no auto and dataTypes are actually different
moel@348
  7929
		} else if ( prev !== "*" && prev !== current ) {
moel@348
  7930
moel@348
  7931
			// Get the converter
moel@348
  7932
			conversion = prev + " " + current;
moel@348
  7933
			conv = converters[ conversion ] || converters[ "* " + current ];
moel@348
  7934
moel@348
  7935
			// If there is no direct converter, search transitively
moel@348
  7936
			if ( !conv ) {
moel@348
  7937
				conv2 = undefined;
moel@348
  7938
				for ( conv1 in converters ) {
moel@348
  7939
					tmp = conv1.split( " " );
moel@348
  7940
					if ( tmp[ 0 ] === prev || tmp[ 0 ] === "*" ) {
moel@348
  7941
						conv2 = converters[ tmp[1] + " " + current ];
moel@348
  7942
						if ( conv2 ) {
moel@348
  7943
							conv1 = converters[ conv1 ];
moel@348
  7944
							if ( conv1 === true ) {
moel@348
  7945
								conv = conv2;
moel@348
  7946
							} else if ( conv2 === true ) {
moel@348
  7947
								conv = conv1;
moel@348
  7948
							}
moel@348
  7949
							break;
moel@348
  7950
						}
moel@348
  7951
					}
moel@348
  7952
				}
moel@348
  7953
			}
moel@348
  7954
			// If we found no converter, dispatch an error
moel@348
  7955
			if ( !( conv || conv2 ) ) {
moel@348
  7956
				jQuery.error( "No conversion from " + conversion.replace(" "," to ") );
moel@348
  7957
			}
moel@348
  7958
			// If found converter is not an equivalence
moel@348
  7959
			if ( conv !== true ) {
moel@348
  7960
				// Convert with 1 or 2 converters accordingly
moel@348
  7961
				response = conv ? conv( response ) : conv2( conv1(response) );
moel@348
  7962
			}
moel@348
  7963
		}
moel@348
  7964
	}
moel@348
  7965
	return response;
moel@348
  7966
}
moel@348
  7967
moel@348
  7968
moel@348
  7969
moel@348
  7970
moel@348
  7971
var jsc = jQuery.now(),
moel@348
  7972
	jsre = /(\=)\?(&|$)|\?\?/i;
moel@348
  7973
moel@348
  7974
// Default jsonp settings
moel@348
  7975
jQuery.ajaxSetup({
moel@348
  7976
	jsonp: "callback",
moel@348
  7977
	jsonpCallback: function() {
moel@348
  7978
		return jQuery.expando + "_" + ( jsc++ );
moel@348
  7979
	}
moel@348
  7980
});
moel@348
  7981
moel@348
  7982
// Detect, normalize options and install callbacks for jsonp requests
moel@348
  7983
jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
moel@348
  7984
moel@348
  7985
	var inspectData = ( typeof s.data === "string" ) && /^application\/x\-www\-form\-urlencoded/.test( s.contentType );
moel@348
  7986
moel@348
  7987
	if ( s.dataTypes[ 0 ] === "jsonp" ||
moel@348
  7988
		s.jsonp !== false && ( jsre.test( s.url ) ||
moel@348
  7989
				inspectData && jsre.test( s.data ) ) ) {
moel@348
  7990
moel@348
  7991
		var responseContainer,
moel@348
  7992
			jsonpCallback = s.jsonpCallback =
moel@348
  7993
				jQuery.isFunction( s.jsonpCallback ) ? s.jsonpCallback() : s.jsonpCallback,
moel@348
  7994
			previous = window[ jsonpCallback ],
moel@348
  7995
			url = s.url,
moel@348
  7996
			data = s.data,
moel@348
  7997
			replace = "$1" + jsonpCallback + "$2";
moel@348
  7998
moel@348
  7999
		if ( s.jsonp !== false ) {
moel@348
  8000
			url = url.replace( jsre, replace );
moel@348
  8001
			if ( s.url === url ) {
moel@348
  8002
				if ( inspectData ) {
moel@348
  8003
					data = data.replace( jsre, replace );
moel@348
  8004
				}
moel@348
  8005
				if ( s.data === data ) {
moel@348
  8006
					// Add callback manually
moel@348
  8007
					url += (/\?/.test( url ) ? "&" : "?") + s.jsonp + "=" + jsonpCallback;
moel@348
  8008
				}
moel@348
  8009
			}
moel@348
  8010
		}
moel@348
  8011
moel@348
  8012
		s.url = url;
moel@348
  8013
		s.data = data;
moel@348
  8014
moel@348
  8015
		// Install callback
moel@348
  8016
		window[ jsonpCallback ] = function( response ) {
moel@348
  8017
			responseContainer = [ response ];
moel@348
  8018
		};
moel@348
  8019
moel@348
  8020
		// Clean-up function
moel@348
  8021
		jqXHR.always(function() {
moel@348
  8022
			// Set callback back to previous value
moel@348
  8023
			window[ jsonpCallback ] = previous;
moel@348
  8024
			// Call if it was a function and we have a response
moel@348
  8025
			if ( responseContainer && jQuery.isFunction( previous ) ) {
moel@348
  8026
				window[ jsonpCallback ]( responseContainer[ 0 ] );
moel@348
  8027
			}
moel@348
  8028
		});
moel@348
  8029
moel@348
  8030
		// Use data converter to retrieve json after script execution
moel@348
  8031
		s.converters["script json"] = function() {
moel@348
  8032
			if ( !responseContainer ) {
moel@348
  8033
				jQuery.error( jsonpCallback + " was not called" );
moel@348
  8034
			}
moel@348
  8035
			return responseContainer[ 0 ];
moel@348
  8036
		};
moel@348
  8037
moel@348
  8038
		// force json dataType
moel@348
  8039
		s.dataTypes[ 0 ] = "json";
moel@348
  8040
moel@348
  8041
		// Delegate to script
moel@348
  8042
		return "script";
moel@348
  8043
	}
moel@348
  8044
});
moel@348
  8045
moel@348
  8046
moel@348
  8047
moel@348
  8048
moel@348
  8049
// Install script dataType
moel@348
  8050
jQuery.ajaxSetup({
moel@348
  8051
	accepts: {
moel@348
  8052
		script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
moel@348
  8053
	},
moel@348
  8054
	contents: {
moel@348
  8055
		script: /javascript|ecmascript/
moel@348
  8056
	},
moel@348
  8057
	converters: {
moel@348
  8058
		"text script": function( text ) {
moel@348
  8059
			jQuery.globalEval( text );
moel@348
  8060
			return text;
moel@348
  8061
		}
moel@348
  8062
	}
moel@348
  8063
});
moel@348
  8064
moel@348
  8065
// Handle cache's special case and global
moel@348
  8066
jQuery.ajaxPrefilter( "script", function( s ) {
moel@348
  8067
	if ( s.cache === undefined ) {
moel@348
  8068
		s.cache = false;
moel@348
  8069
	}
moel@348
  8070
	if ( s.crossDomain ) {
moel@348
  8071
		s.type = "GET";
moel@348
  8072
		s.global = false;
moel@348
  8073
	}
moel@348
  8074
});
moel@348
  8075
moel@348
  8076
// Bind script tag hack transport
moel@348
  8077
jQuery.ajaxTransport( "script", function(s) {
moel@348
  8078
moel@348
  8079
	// This transport only deals with cross domain requests
moel@348
  8080
	if ( s.crossDomain ) {
moel@348
  8081
moel@348
  8082
		var script,
moel@348
  8083
			head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement;
moel@348
  8084
moel@348
  8085
		return {
moel@348
  8086
moel@348
  8087
			send: function( _, callback ) {
moel@348
  8088
moel@348
  8089
				script = document.createElement( "script" );
moel@348
  8090
moel@348
  8091
				script.async = "async";
moel@348
  8092
moel@348
  8093
				if ( s.scriptCharset ) {
moel@348
  8094
					script.charset = s.scriptCharset;
moel@348
  8095
				}
moel@348
  8096
moel@348
  8097
				script.src = s.url;
moel@348
  8098
moel@348
  8099
				// Attach handlers for all browsers
moel@348
  8100
				script.onload = script.onreadystatechange = function( _, isAbort ) {
moel@348
  8101
moel@348
  8102
					if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) {
moel@348
  8103
moel@348
  8104
						// Handle memory leak in IE
moel@348
  8105
						script.onload = script.onreadystatechange = null;
moel@348
  8106
moel@348
  8107
						// Remove the script
moel@348
  8108
						if ( head && script.parentNode ) {
moel@348
  8109
							head.removeChild( script );
moel@348
  8110
						}
moel@348
  8111
moel@348
  8112
						// Dereference the script
moel@348
  8113
						script = undefined;
moel@348
  8114
moel@348
  8115
						// Callback if not abort
moel@348
  8116
						if ( !isAbort ) {
moel@348
  8117
							callback( 200, "success" );
moel@348
  8118
						}
moel@348
  8119
					}
moel@348
  8120
				};
moel@348
  8121
				// Use insertBefore instead of appendChild  to circumvent an IE6 bug.
moel@348
  8122
				// This arises when a base node is used (#2709 and #4378).
moel@348
  8123
				head.insertBefore( script, head.firstChild );
moel@348
  8124
			},
moel@348
  8125
moel@348
  8126
			abort: function() {
moel@348
  8127
				if ( script ) {
moel@348
  8128
					script.onload( 0, 1 );
moel@348
  8129
				}
moel@348
  8130
			}
moel@348
  8131
		};
moel@348
  8132
	}
moel@348
  8133
});
moel@348
  8134
moel@348
  8135
moel@348
  8136
moel@348
  8137
moel@348
  8138
var // #5280: Internet Explorer will keep connections alive if we don't abort on unload
moel@348
  8139
	xhrOnUnloadAbort = window.ActiveXObject ? function() {
moel@348
  8140
		// Abort all pending requests
moel@348
  8141
		for ( var key in xhrCallbacks ) {
moel@348
  8142
			xhrCallbacks[ key ]( 0, 1 );
moel@348
  8143
		}
moel@348
  8144
	} : false,
moel@348
  8145
	xhrId = 0,
moel@348
  8146
	xhrCallbacks;
moel@348
  8147
moel@348
  8148
// Functions to create xhrs
moel@348
  8149
function createStandardXHR() {
moel@348
  8150
	try {
moel@348
  8151
		return new window.XMLHttpRequest();
moel@348
  8152
	} catch( e ) {}
moel@348
  8153
}
moel@348
  8154
moel@348
  8155
function createActiveXHR() {
moel@348
  8156
	try {
moel@348
  8157
		return new window.ActiveXObject( "Microsoft.XMLHTTP" );
moel@348
  8158
	} catch( e ) {}
moel@348
  8159
}
moel@348
  8160
moel@348
  8161
// Create the request object
moel@348
  8162
// (This is still attached to ajaxSettings for backward compatibility)
moel@348
  8163
jQuery.ajaxSettings.xhr = window.ActiveXObject ?
moel@348
  8164
	/* Microsoft failed to properly
moel@348
  8165
	 * implement the XMLHttpRequest in IE7 (can't request local files),
moel@348
  8166
	 * so we use the ActiveXObject when it is available
moel@348
  8167
	 * Additionally XMLHttpRequest can be disabled in IE7/IE8 so
moel@348
  8168
	 * we need a fallback.
moel@348
  8169
	 */
moel@348
  8170
	function() {
moel@348
  8171
		return !this.isLocal && createStandardXHR() || createActiveXHR();
moel@348
  8172
	} :
moel@348
  8173
	// For all other browsers, use the standard XMLHttpRequest object
moel@348
  8174
	createStandardXHR;
moel@348
  8175
moel@348
  8176
// Determine support properties
moel@348
  8177
(function( xhr ) {
moel@348
  8178
	jQuery.extend( jQuery.support, {
moel@348
  8179
		ajax: !!xhr,
moel@348
  8180
		cors: !!xhr && ( "withCredentials" in xhr )
moel@348
  8181
	});
moel@348
  8182
})( jQuery.ajaxSettings.xhr() );
moel@348
  8183
moel@348
  8184
// Create transport if the browser can provide an xhr
moel@348
  8185
if ( jQuery.support.ajax ) {
moel@348
  8186
moel@348
  8187
	jQuery.ajaxTransport(function( s ) {
moel@348
  8188
		// Cross domain only allowed if supported through XMLHttpRequest
moel@348
  8189
		if ( !s.crossDomain || jQuery.support.cors ) {
moel@348
  8190
moel@348
  8191
			var callback;
moel@348
  8192
moel@348
  8193
			return {
moel@348
  8194
				send: function( headers, complete ) {
moel@348
  8195
moel@348
  8196
					// Get a new xhr
moel@348
  8197
					var xhr = s.xhr(),
moel@348
  8198
						handle,
moel@348
  8199
						i;
moel@348
  8200
moel@348
  8201
					// Open the socket
moel@348
  8202
					// Passing null username, generates a login popup on Opera (#2865)
moel@348
  8203
					if ( s.username ) {
moel@348
  8204
						xhr.open( s.type, s.url, s.async, s.username, s.password );
moel@348
  8205
					} else {
moel@348
  8206
						xhr.open( s.type, s.url, s.async );
moel@348
  8207
					}
moel@348
  8208
moel@348
  8209
					// Apply custom fields if provided
moel@348
  8210
					if ( s.xhrFields ) {
moel@348
  8211
						for ( i in s.xhrFields ) {
moel@348
  8212
							xhr[ i ] = s.xhrFields[ i ];
moel@348
  8213
						}
moel@348
  8214
					}
moel@348
  8215
moel@348
  8216
					// Override mime type if needed
moel@348
  8217
					if ( s.mimeType && xhr.overrideMimeType ) {
moel@348
  8218
						xhr.overrideMimeType( s.mimeType );
moel@348
  8219
					}
moel@348
  8220
moel@348
  8221
					// X-Requested-With header
moel@348
  8222
					// For cross-domain requests, seeing as conditions for a preflight are
moel@348
  8223
					// akin to a jigsaw puzzle, we simply never set it to be sure.
moel@348
  8224
					// (it can always be set on a per-request basis or even using ajaxSetup)
moel@348
  8225
					// For same-domain requests, won't change header if already provided.
moel@348
  8226
					if ( !s.crossDomain && !headers["X-Requested-With"] ) {
moel@348
  8227
						headers[ "X-Requested-With" ] = "XMLHttpRequest";
moel@348
  8228
					}
moel@348
  8229
moel@348
  8230
					// Need an extra try/catch for cross domain requests in Firefox 3
moel@348
  8231
					try {
moel@348
  8232
						for ( i in headers ) {
moel@348
  8233
							xhr.setRequestHeader( i, headers[ i ] );
moel@348
  8234
						}
moel@348
  8235
					} catch( _ ) {}
moel@348
  8236
moel@348
  8237
					// Do send the request
moel@348
  8238
					// This may raise an exception which is actually
moel@348
  8239
					// handled in jQuery.ajax (so no try/catch here)
moel@348
  8240
					xhr.send( ( s.hasContent && s.data ) || null );
moel@348
  8241
moel@348
  8242
					// Listener
moel@348
  8243
					callback = function( _, isAbort ) {
moel@348
  8244
moel@348
  8245
						var status,
moel@348
  8246
							statusText,
moel@348
  8247
							responseHeaders,
moel@348
  8248
							responses,
moel@348
  8249
							xml;
moel@348
  8250
moel@348
  8251
						// Firefox throws exceptions when accessing properties
moel@348
  8252
						// of an xhr when a network error occured
moel@348
  8253
						// http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE)
moel@348
  8254
						try {
moel@348
  8255
moel@348
  8256
							// Was never called and is aborted or complete
moel@348
  8257
							if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
moel@348
  8258
moel@348
  8259
								// Only called once
moel@348
  8260
								callback = undefined;
moel@348
  8261
moel@348
  8262
								// Do not keep as active anymore
moel@348
  8263
								if ( handle ) {
moel@348
  8264
									xhr.onreadystatechange = jQuery.noop;
moel@348
  8265
									if ( xhrOnUnloadAbort ) {
moel@348
  8266
										delete xhrCallbacks[ handle ];
moel@348
  8267
									}
moel@348
  8268
								}
moel@348
  8269
moel@348
  8270
								// If it's an abort
moel@348
  8271
								if ( isAbort ) {
moel@348
  8272
									// Abort it manually if needed
moel@348
  8273
									if ( xhr.readyState !== 4 ) {
moel@348
  8274
										xhr.abort();
moel@348
  8275
									}
moel@348
  8276
								} else {
moel@348
  8277
									status = xhr.status;
moel@348
  8278
									responseHeaders = xhr.getAllResponseHeaders();
moel@348
  8279
									responses = {};
moel@348
  8280
									xml = xhr.responseXML;
moel@348
  8281
moel@348
  8282
									// Construct response list
moel@348
  8283
									if ( xml && xml.documentElement /* #4958 */ ) {
moel@348
  8284
										responses.xml = xml;
moel@348
  8285
									}
moel@348
  8286
moel@348
  8287
									// When requesting binary data, IE6-9 will throw an exception
moel@348
  8288
									// on any attempt to access responseText (#11426)
moel@348
  8289
									try {
moel@348
  8290
										responses.text = xhr.responseText;
moel@348
  8291
									} catch( _ ) {
moel@348
  8292
									}
moel@348
  8293
moel@348
  8294
									// Firefox throws an exception when accessing
moel@348
  8295
									// statusText for faulty cross-domain requests
moel@348
  8296
									try {
moel@348
  8297
										statusText = xhr.statusText;
moel@348
  8298
									} catch( e ) {
moel@348
  8299
										// We normalize with Webkit giving an empty statusText
moel@348
  8300
										statusText = "";
moel@348
  8301
									}
moel@348
  8302
moel@348
  8303
									// Filter status for non standard behaviors
moel@348
  8304
moel@348
  8305
									// If the request is local and we have data: assume a success
moel@348
  8306
									// (success with no data won't get notified, that's the best we
moel@348
  8307
									// can do given current implementations)
moel@348
  8308
									if ( !status && s.isLocal && !s.crossDomain ) {
moel@348
  8309
										status = responses.text ? 200 : 404;
moel@348
  8310
									// IE - #1450: sometimes returns 1223 when it should be 204
moel@348
  8311
									} else if ( status === 1223 ) {
moel@348
  8312
										status = 204;
moel@348
  8313
									}
moel@348
  8314
								}
moel@348
  8315
							}
moel@348
  8316
						} catch( firefoxAccessException ) {
moel@348
  8317
							if ( !isAbort ) {
moel@348
  8318
								complete( -1, firefoxAccessException );
moel@348
  8319
							}
moel@348
  8320
						}
moel@348
  8321
moel@348
  8322
						// Call complete if needed
moel@348
  8323
						if ( responses ) {
moel@348
  8324
							complete( status, statusText, responses, responseHeaders );
moel@348
  8325
						}
moel@348
  8326
					};
moel@348
  8327
moel@348
  8328
					// if we're in sync mode or it's in cache
moel@348
  8329
					// and has been retrieved directly (IE6 & IE7)
moel@348
  8330
					// we need to manually fire the callback
moel@348
  8331
					if ( !s.async || xhr.readyState === 4 ) {
moel@348
  8332
						callback();
moel@348
  8333
					} else {
moel@348
  8334
						handle = ++xhrId;
moel@348
  8335
						if ( xhrOnUnloadAbort ) {
moel@348
  8336
							// Create the active xhrs callbacks list if needed
moel@348
  8337
							// and attach the unload handler
moel@348
  8338
							if ( !xhrCallbacks ) {
moel@348
  8339
								xhrCallbacks = {};
moel@348
  8340
								jQuery( window ).unload( xhrOnUnloadAbort );
moel@348
  8341
							}
moel@348
  8342
							// Add to list of active xhrs callbacks
moel@348
  8343
							xhrCallbacks[ handle ] = callback;
moel@348
  8344
						}
moel@348
  8345
						xhr.onreadystatechange = callback;
moel@348
  8346
					}
moel@348
  8347
				},
moel@348
  8348
moel@348
  8349
				abort: function() {
moel@348
  8350
					if ( callback ) {
moel@348
  8351
						callback(0,1);
moel@348
  8352
					}
moel@348
  8353
				}
moel@348
  8354
			};
moel@348
  8355
		}
moel@348
  8356
	});
moel@348
  8357
}
moel@348
  8358
moel@348
  8359
moel@348
  8360
moel@348
  8361
moel@348
  8362
var elemdisplay = {},
moel@348
  8363
	iframe, iframeDoc,
moel@348
  8364
	rfxtypes = /^(?:toggle|show|hide)$/,
moel@348
  8365
	rfxnum = /^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,
moel@348
  8366
	timerId,
moel@348
  8367
	fxAttrs = [
moel@348
  8368
		// height animations
moel@348
  8369
		[ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom" ],
moel@348
  8370
		// width animations
moel@348
  8371
		[ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ],
moel@348
  8372
		// opacity animations
moel@348
  8373
		[ "opacity" ]
moel@348
  8374
	],
moel@348
  8375
	fxNow;
moel@348
  8376
moel@348
  8377
jQuery.fn.extend({
moel@348
  8378
	show: function( speed, easing, callback ) {
moel@348
  8379
		var elem, display;
moel@348
  8380
moel@348
  8381
		if ( speed || speed === 0 ) {
moel@348
  8382
			return this.animate( genFx("show", 3), speed, easing, callback );
moel@348
  8383
moel@348
  8384
		} else {
moel@348
  8385
			for ( var i = 0, j = this.length; i < j; i++ ) {
moel@348
  8386
				elem = this[ i ];
moel@348
  8387
moel@348
  8388
				if ( elem.style ) {
moel@348
  8389
					display = elem.style.display;
moel@348
  8390
moel@348
  8391
					// Reset the inline display of this element to learn if it is
moel@348
  8392
					// being hidden by cascaded rules or not
moel@348
  8393
					if ( !jQuery._data(elem, "olddisplay") && display === "none" ) {
moel@348
  8394
						display = elem.style.display = "";
moel@348
  8395
					}
moel@348
  8396
moel@348
  8397
					// Set elements which have been overridden with display: none
moel@348
  8398
					// in a stylesheet to whatever the default browser style is
moel@348
  8399
					// for such an element
moel@348
  8400
					if ( (display === "" && jQuery.css(elem, "display") === "none") ||
moel@348
  8401
						!jQuery.contains( elem.ownerDocument.documentElement, elem ) ) {
moel@348
  8402
						jQuery._data( elem, "olddisplay", defaultDisplay(elem.nodeName) );
moel@348
  8403
					}
moel@348
  8404
				}
moel@348
  8405
			}
moel@348
  8406
moel@348
  8407
			// Set the display of most of the elements in a second loop
moel@348
  8408
			// to avoid the constant reflow
moel@348
  8409
			for ( i = 0; i < j; i++ ) {
moel@348
  8410
				elem = this[ i ];
moel@348
  8411
moel@348
  8412
				if ( elem.style ) {
moel@348
  8413
					display = elem.style.display;
moel@348
  8414
moel@348
  8415
					if ( display === "" || display === "none" ) {
moel@348
  8416
						elem.style.display = jQuery._data( elem, "olddisplay" ) || "";
moel@348
  8417
					}
moel@348
  8418
				}
moel@348
  8419
			}
moel@348
  8420
moel@348
  8421
			return this;
moel@348
  8422
		}
moel@348
  8423
	},
moel@348
  8424
moel@348
  8425
	hide: function( speed, easing, callback ) {
moel@348
  8426
		if ( speed || speed === 0 ) {
moel@348
  8427
			return this.animate( genFx("hide", 3), speed, easing, callback);
moel@348
  8428
moel@348
  8429
		} else {
moel@348
  8430
			var elem, display,
moel@348
  8431
				i = 0,
moel@348
  8432
				j = this.length;
moel@348
  8433
moel@348
  8434
			for ( ; i < j; i++ ) {
moel@348
  8435
				elem = this[i];
moel@348
  8436
				if ( elem.style ) {
moel@348
  8437
					display = jQuery.css( elem, "display" );
moel@348
  8438
moel@348
  8439
					if ( display !== "none" && !jQuery._data( elem, "olddisplay" ) ) {
moel@348
  8440
						jQuery._data( elem, "olddisplay", display );
moel@348
  8441
					}
moel@348
  8442
				}
moel@348
  8443
			}
moel@348
  8444
moel@348
  8445
			// Set the display of the elements in a second loop
moel@348
  8446
			// to avoid the constant reflow
moel@348
  8447
			for ( i = 0; i < j; i++ ) {
moel@348
  8448
				if ( this[i].style ) {
moel@348
  8449
					this[i].style.display = "none";
moel@348
  8450
				}
moel@348
  8451
			}
moel@348
  8452
moel@348
  8453
			return this;
moel@348
  8454
		}
moel@348
  8455
	},
moel@348
  8456
moel@348
  8457
	// Save the old toggle function
moel@348
  8458
	_toggle: jQuery.fn.toggle,
moel@348
  8459
moel@348
  8460
	toggle: function( fn, fn2, callback ) {
moel@348
  8461
		var bool = typeof fn === "boolean";
moel@348
  8462
moel@348
  8463
		if ( jQuery.isFunction(fn) && jQuery.isFunction(fn2) ) {
moel@348
  8464
			this._toggle.apply( this, arguments );
moel@348
  8465
moel@348
  8466
		} else if ( fn == null || bool ) {
moel@348
  8467
			this.each(function() {
moel@348
  8468
				var state = bool ? fn : jQuery(this).is(":hidden");
moel@348
  8469
				jQuery(this)[ state ? "show" : "hide" ]();
moel@348
  8470
			});
moel@348
  8471
moel@348
  8472
		} else {
moel@348
  8473
			this.animate(genFx("toggle", 3), fn, fn2, callback);
moel@348
  8474
		}
moel@348
  8475
moel@348
  8476
		return this;
moel@348
  8477
	},
moel@348
  8478
moel@348
  8479
	fadeTo: function( speed, to, easing, callback ) {
moel@348
  8480
		return this.filter(":hidden").css("opacity", 0).show().end()
moel@348
  8481
					.animate({opacity: to}, speed, easing, callback);
moel@348
  8482
	},
moel@348
  8483
moel@348
  8484
	animate: function( prop, speed, easing, callback ) {
moel@348
  8485
		var optall = jQuery.speed( speed, easing, callback );
moel@348
  8486
moel@348
  8487
		if ( jQuery.isEmptyObject( prop ) ) {
moel@348
  8488
			return this.each( optall.complete, [ false ] );
moel@348
  8489
		}
moel@348
  8490
moel@348
  8491
		// Do not change referenced properties as per-property easing will be lost
moel@348
  8492
		prop = jQuery.extend( {}, prop );
moel@348
  8493
moel@348
  8494
		function doAnimation() {
moel@348
  8495
			// XXX 'this' does not always have a nodeName when running the
moel@348
  8496
			// test suite
moel@348
  8497
moel@348
  8498
			if ( optall.queue === false ) {
moel@348
  8499
				jQuery._mark( this );
moel@348
  8500
			}
moel@348
  8501
moel@348
  8502
			var opt = jQuery.extend( {}, optall ),
moel@348
  8503
				isElement = this.nodeType === 1,
moel@348
  8504
				hidden = isElement && jQuery(this).is(":hidden"),
moel@348
  8505
				name, val, p, e, hooks, replace,
moel@348
  8506
				parts, start, end, unit,
moel@348
  8507
				method;
moel@348
  8508
moel@348
  8509
			// will store per property easing and be used to determine when an animation is complete
moel@348
  8510
			opt.animatedProperties = {};
moel@348
  8511
moel@348
  8512
			// first pass over propertys to expand / normalize
moel@348
  8513
			for ( p in prop ) {
moel@348
  8514
				name = jQuery.camelCase( p );
moel@348
  8515
				if ( p !== name ) {
moel@348
  8516
					prop[ name ] = prop[ p ];
moel@348
  8517
					delete prop[ p ];
moel@348
  8518
				}
moel@348
  8519
moel@348
  8520
				if ( ( hooks = jQuery.cssHooks[ name ] ) && "expand" in hooks ) {
moel@348
  8521
					replace = hooks.expand( prop[ name ] );
moel@348
  8522
					delete prop[ name ];
moel@348
  8523
moel@348
  8524
					// not quite $.extend, this wont overwrite keys already present.
moel@348
  8525
					// also - reusing 'p' from above because we have the correct "name"
moel@348
  8526
					for ( p in replace ) {
moel@348
  8527
						if ( ! ( p in prop ) ) {
moel@348
  8528
							prop[ p ] = replace[ p ];
moel@348
  8529
						}
moel@348
  8530
					}
moel@348
  8531
				}
moel@348
  8532
			}
moel@348
  8533
moel@348
  8534
			for ( name in prop ) {
moel@348
  8535
				val = prop[ name ];
moel@348
  8536
				// easing resolution: per property > opt.specialEasing > opt.easing > 'swing' (default)
moel@348
  8537
				if ( jQuery.isArray( val ) ) {
moel@348
  8538
					opt.animatedProperties[ name ] = val[ 1 ];
moel@348
  8539
					val = prop[ name ] = val[ 0 ];
moel@348
  8540
				} else {
moel@348
  8541
					opt.animatedProperties[ name ] = opt.specialEasing && opt.specialEasing[ name ] || opt.easing || 'swing';
moel@348
  8542
				}
moel@348
  8543
moel@348
  8544
				if ( val === "hide" && hidden || val === "show" && !hidden ) {
moel@348
  8545
					return opt.complete.call( this );
moel@348
  8546
				}
moel@348
  8547
moel@348
  8548
				if ( isElement && ( name === "height" || name === "width" ) ) {
moel@348
  8549
					// Make sure that nothing sneaks out
moel@348
  8550
					// Record all 3 overflow attributes because IE does not
moel@348
  8551
					// change the overflow attribute when overflowX and
moel@348
  8552
					// overflowY are set to the same value
moel@348
  8553
					opt.overflow = [ this.style.overflow, this.style.overflowX, this.style.overflowY ];
moel@348
  8554
moel@348
  8555
					// Set display property to inline-block for height/width
moel@348
  8556
					// animations on inline elements that are having width/height animated
moel@348
  8557
					if ( jQuery.css( this, "display" ) === "inline" &&
moel@348
  8558
							jQuery.css( this, "float" ) === "none" ) {
moel@348
  8559
moel@348
  8560
						// inline-level elements accept inline-block;
moel@348
  8561
						// block-level elements need to be inline with layout
moel@348
  8562
						if ( !jQuery.support.inlineBlockNeedsLayout || defaultDisplay( this.nodeName ) === "inline" ) {
moel@348
  8563
							this.style.display = "inline-block";
moel@348
  8564
moel@348
  8565
						} else {
moel@348
  8566
							this.style.zoom = 1;
moel@348
  8567
						}
moel@348
  8568
					}
moel@348
  8569
				}
moel@348
  8570
			}
moel@348
  8571
moel@348
  8572
			if ( opt.overflow != null ) {
moel@348
  8573
				this.style.overflow = "hidden";
moel@348
  8574
			}
moel@348
  8575
moel@348
  8576
			for ( p in prop ) {
moel@348
  8577
				e = new jQuery.fx( this, opt, p );
moel@348
  8578
				val = prop[ p ];
moel@348
  8579
moel@348
  8580
				if ( rfxtypes.test( val ) ) {
moel@348
  8581
moel@348
  8582
					// Tracks whether to show or hide based on private
moel@348
  8583
					// data attached to the element
moel@348
  8584
					method = jQuery._data( this, "toggle" + p ) || ( val === "toggle" ? hidden ? "show" : "hide" : 0 );
moel@348
  8585
					if ( method ) {
moel@348
  8586
						jQuery._data( this, "toggle" + p, method === "show" ? "hide" : "show" );
moel@348
  8587
						e[ method ]();
moel@348
  8588
					} else {
moel@348
  8589
						e[ val ]();
moel@348
  8590
					}
moel@348
  8591
moel@348
  8592
				} else {
moel@348
  8593
					parts = rfxnum.exec( val );
moel@348
  8594
					start = e.cur();
moel@348
  8595
moel@348
  8596
					if ( parts ) {
moel@348
  8597
						end = parseFloat( parts[2] );
moel@348
  8598
						unit = parts[3] || ( jQuery.cssNumber[ p ] ? "" : "px" );
moel@348
  8599
moel@348
  8600
						// We need to compute starting value
moel@348
  8601
						if ( unit !== "px" ) {
moel@348
  8602
							jQuery.style( this, p, (end || 1) + unit);
moel@348
  8603
							start = ( (end || 1) / e.cur() ) * start;
moel@348
  8604
							jQuery.style( this, p, start + unit);
moel@348
  8605
						}
moel@348
  8606
moel@348
  8607
						// If a +=/-= token was provided, we're doing a relative animation
moel@348
  8608
						if ( parts[1] ) {
moel@348
  8609
							end = ( (parts[ 1 ] === "-=" ? -1 : 1) * end ) + start;
moel@348
  8610
						}
moel@348
  8611
moel@348
  8612
						e.custom( start, end, unit );
moel@348
  8613
moel@348
  8614
					} else {
moel@348
  8615
						e.custom( start, val, "" );
moel@348
  8616
					}
moel@348
  8617
				}
moel@348
  8618
			}
moel@348
  8619
moel@348
  8620
			// For JS strict compliance
moel@348
  8621
			return true;
moel@348
  8622
		}
moel@348
  8623
moel@348
  8624
		return optall.queue === false ?
moel@348
  8625
			this.each( doAnimation ) :
moel@348
  8626
			this.queue( optall.queue, doAnimation );
moel@348
  8627
	},
moel@348
  8628
moel@348
  8629
	stop: function( type, clearQueue, gotoEnd ) {
moel@348
  8630
		if ( typeof type !== "string" ) {
moel@348
  8631
			gotoEnd = clearQueue;
moel@348
  8632
			clearQueue = type;
moel@348
  8633
			type = undefined;
moel@348
  8634
		}
moel@348
  8635
		if ( clearQueue && type !== false ) {
moel@348
  8636
			this.queue( type || "fx", [] );
moel@348
  8637
		}
moel@348
  8638
moel@348
  8639
		return this.each(function() {
moel@348
  8640
			var index,
moel@348
  8641
				hadTimers = false,
moel@348
  8642
				timers = jQuery.timers,
moel@348
  8643
				data = jQuery._data( this );
moel@348
  8644
moel@348
  8645
			// clear marker counters if we know they won't be
moel@348
  8646
			if ( !gotoEnd ) {
moel@348
  8647
				jQuery._unmark( true, this );
moel@348
  8648
			}
moel@348
  8649
moel@348
  8650
			function stopQueue( elem, data, index ) {
moel@348
  8651
				var hooks = data[ index ];
moel@348
  8652
				jQuery.removeData( elem, index, true );
moel@348
  8653
				hooks.stop( gotoEnd );
moel@348
  8654
			}
moel@348
  8655
moel@348
  8656
			if ( type == null ) {
moel@348
  8657
				for ( index in data ) {
moel@348
  8658
					if ( data[ index ] && data[ index ].stop && index.indexOf(".run") === index.length - 4 ) {
moel@348
  8659
						stopQueue( this, data, index );
moel@348
  8660
					}
moel@348
  8661
				}
moel@348
  8662
			} else if ( data[ index = type + ".run" ] && data[ index ].stop ){
moel@348
  8663
				stopQueue( this, data, index );
moel@348
  8664
			}
moel@348
  8665
moel@348
  8666
			for ( index = timers.length; index--; ) {
moel@348
  8667
				if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) {
moel@348
  8668
					if ( gotoEnd ) {
moel@348
  8669
moel@348
  8670
						// force the next step to be the last
moel@348
  8671
						timers[ index ]( true );
moel@348
  8672
					} else {
moel@348
  8673
						timers[ index ].saveState();
moel@348
  8674
					}
moel@348
  8675
					hadTimers = true;
moel@348
  8676
					timers.splice( index, 1 );
moel@348
  8677
				}
moel@348
  8678
			}
moel@348
  8679
moel@348
  8680
			// start the next in the queue if the last step wasn't forced
moel@348
  8681
			// timers currently will call their complete callbacks, which will dequeue
moel@348
  8682
			// but only if they were gotoEnd
moel@348
  8683
			if ( !( gotoEnd && hadTimers ) ) {
moel@348
  8684
				jQuery.dequeue( this, type );
moel@348
  8685
			}
moel@348
  8686
		});
moel@348
  8687
	}
moel@348
  8688
moel@348
  8689
});
moel@348
  8690
moel@348
  8691
// Animations created synchronously will run synchronously
moel@348
  8692
function createFxNow() {
moel@348
  8693
	setTimeout( clearFxNow, 0 );
moel@348
  8694
	return ( fxNow = jQuery.now() );
moel@348
  8695
}
moel@348
  8696
moel@348
  8697
function clearFxNow() {
moel@348
  8698
	fxNow = undefined;
moel@348
  8699
}
moel@348
  8700
moel@348
  8701
// Generate parameters to create a standard animation
moel@348
  8702
function genFx( type, num ) {
moel@348
  8703
	var obj = {};
moel@348
  8704
moel@348
  8705
	jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice( 0, num )), function() {
moel@348
  8706
		obj[ this ] = type;
moel@348
  8707
	});
moel@348
  8708
moel@348
  8709
	return obj;
moel@348
  8710
}
moel@348
  8711
moel@348
  8712
// Generate shortcuts for custom animations
moel@348
  8713
jQuery.each({
moel@348
  8714
	slideDown: genFx( "show", 1 ),
moel@348
  8715
	slideUp: genFx( "hide", 1 ),
moel@348
  8716
	slideToggle: genFx( "toggle", 1 ),
moel@348
  8717
	fadeIn: { opacity: "show" },
moel@348
  8718
	fadeOut: { opacity: "hide" },
moel@348
  8719
	fadeToggle: { opacity: "toggle" }
moel@348
  8720
}, function( name, props ) {
moel@348
  8721
	jQuery.fn[ name ] = function( speed, easing, callback ) {
moel@348
  8722
		return this.animate( props, speed, easing, callback );
moel@348
  8723
	};
moel@348
  8724
});
moel@348
  8725
moel@348
  8726
jQuery.extend({
moel@348
  8727
	speed: function( speed, easing, fn ) {
moel@348
  8728
		var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
moel@348
  8729
			complete: fn || !fn && easing ||
moel@348
  8730
				jQuery.isFunction( speed ) && speed,
moel@348
  8731
			duration: speed,
moel@348
  8732
			easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
moel@348
  8733
		};
moel@348
  8734
moel@348
  8735
		opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
moel@348
  8736
			opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
moel@348
  8737
moel@348
  8738
		// normalize opt.queue - true/undefined/null -> "fx"
moel@348
  8739
		if ( opt.queue == null || opt.queue === true ) {
moel@348
  8740
			opt.queue = "fx";
moel@348
  8741
		}
moel@348
  8742
moel@348
  8743
		// Queueing
moel@348
  8744
		opt.old = opt.complete;
moel@348
  8745
moel@348
  8746
		opt.complete = function( noUnmark ) {
moel@348
  8747
			if ( jQuery.isFunction( opt.old ) ) {
moel@348
  8748
				opt.old.call( this );
moel@348
  8749
			}
moel@348
  8750
moel@348
  8751
			if ( opt.queue ) {
moel@348
  8752
				jQuery.dequeue( this, opt.queue );
moel@348
  8753
			} else if ( noUnmark !== false ) {
moel@348
  8754
				jQuery._unmark( this );
moel@348
  8755
			}
moel@348
  8756
		};
moel@348
  8757
moel@348
  8758
		return opt;
moel@348
  8759
	},
moel@348
  8760
moel@348
  8761
	easing: {
moel@348
  8762
		linear: function( p ) {
moel@348
  8763
			return p;
moel@348
  8764
		},
moel@348
  8765
		swing: function( p ) {
moel@348
  8766
			return ( -Math.cos( p*Math.PI ) / 2 ) + 0.5;
moel@348
  8767
		}
moel@348
  8768
	},
moel@348
  8769
moel@348
  8770
	timers: [],
moel@348
  8771
moel@348
  8772
	fx: function( elem, options, prop ) {
moel@348
  8773
		this.options = options;
moel@348
  8774
		this.elem = elem;
moel@348
  8775
		this.prop = prop;
moel@348
  8776
moel@348
  8777
		options.orig = options.orig || {};
moel@348
  8778
	}
moel@348
  8779
moel@348
  8780
});
moel@348
  8781
moel@348
  8782
jQuery.fx.prototype = {
moel@348
  8783
	// Simple function for setting a style value
moel@348
  8784
	update: function() {
moel@348
  8785
		if ( this.options.step ) {
moel@348
  8786
			this.options.step.call( this.elem, this.now, this );
moel@348
  8787
		}
moel@348
  8788
moel@348
  8789
		( jQuery.fx.step[ this.prop ] || jQuery.fx.step._default )( this );
moel@348
  8790
	},
moel@348
  8791
moel@348
  8792
	// Get the current size
moel@348
  8793
	cur: function() {
moel@348
  8794
		if ( this.elem[ this.prop ] != null && (!this.elem.style || this.elem.style[ this.prop ] == null) ) {
moel@348
  8795
			return this.elem[ this.prop ];
moel@348
  8796
		}
moel@348
  8797
moel@348
  8798
		var parsed,
moel@348
  8799
			r = jQuery.css( this.elem, this.prop );
moel@348
  8800
		// Empty strings, null, undefined and "auto" are converted to 0,
moel@348
  8801
		// complex values such as "rotate(1rad)" are returned as is,
moel@348
  8802
		// simple values such as "10px" are parsed to Float.
moel@348
  8803
		return isNaN( parsed = parseFloat( r ) ) ? !r || r === "auto" ? 0 : r : parsed;
moel@348
  8804
	},
moel@348
  8805
moel@348
  8806
	// Start an animation from one number to another
moel@348
  8807
	custom: function( from, to, unit ) {
moel@348
  8808
		var self = this,
moel@348
  8809
			fx = jQuery.fx;
moel@348
  8810
moel@348
  8811
		this.startTime = fxNow || createFxNow();
moel@348
  8812
		this.end = to;
moel@348
  8813
		this.now = this.start = from;
moel@348
  8814
		this.pos = this.state = 0;
moel@348
  8815
		this.unit = unit || this.unit || ( jQuery.cssNumber[ this.prop ] ? "" : "px" );
moel@348
  8816
moel@348
  8817
		function t( gotoEnd ) {
moel@348
  8818
			return self.step( gotoEnd );
moel@348
  8819
		}
moel@348
  8820
moel@348
  8821
		t.queue = this.options.queue;
moel@348
  8822
		t.elem = this.elem;
moel@348
  8823
		t.saveState = function() {
moel@348
  8824
			if ( jQuery._data( self.elem, "fxshow" + self.prop ) === undefined ) {
moel@348
  8825
				if ( self.options.hide ) {
moel@348
  8826
					jQuery._data( self.elem, "fxshow" + self.prop, self.start );
moel@348
  8827
				} else if ( self.options.show ) {
moel@348
  8828
					jQuery._data( self.elem, "fxshow" + self.prop, self.end );
moel@348
  8829
				}
moel@348
  8830
			}
moel@348
  8831
		};
moel@348
  8832
moel@348
  8833
		if ( t() && jQuery.timers.push(t) && !timerId ) {
moel@348
  8834
			timerId = setInterval( fx.tick, fx.interval );
moel@348
  8835
		}
moel@348
  8836
	},
moel@348
  8837
moel@348
  8838
	// Simple 'show' function
moel@348
  8839
	show: function() {
moel@348
  8840
		var dataShow = jQuery._data( this.elem, "fxshow" + this.prop );
moel@348
  8841
moel@348
  8842
		// Remember where we started, so that we can go back to it later
moel@348
  8843
		this.options.orig[ this.prop ] = dataShow || jQuery.style( this.elem, this.prop );
moel@348
  8844
		this.options.show = true;
moel@348
  8845
moel@348
  8846
		// Begin the animation
moel@348
  8847
		// Make sure that we start at a small width/height to avoid any flash of content
moel@348
  8848
		if ( dataShow !== undefined ) {
moel@348
  8849
			// This show is picking up where a previous hide or show left off
moel@348
  8850
			this.custom( this.cur(), dataShow );
moel@348
  8851
		} else {
moel@348
  8852
			this.custom( this.prop === "width" || this.prop === "height" ? 1 : 0, this.cur() );
moel@348
  8853
		}
moel@348
  8854
moel@348
  8855
		// Start by showing the element
moel@348
  8856
		jQuery( this.elem ).show();
moel@348
  8857
	},
moel@348
  8858
moel@348
  8859
	// Simple 'hide' function
moel@348
  8860
	hide: function() {
moel@348
  8861
		// Remember where we started, so that we can go back to it later
moel@348
  8862
		this.options.orig[ this.prop ] = jQuery._data( this.elem, "fxshow" + this.prop ) || jQuery.style( this.elem, this.prop );
moel@348
  8863
		this.options.hide = true;
moel@348
  8864
moel@348
  8865
		// Begin the animation
moel@348
  8866
		this.custom( this.cur(), 0 );
moel@348
  8867
	},
moel@348
  8868
moel@348
  8869
	// Each step of an animation
moel@348
  8870
	step: function( gotoEnd ) {
moel@348
  8871
		var p, n, complete,
moel@348
  8872
			t = fxNow || createFxNow(),
moel@348
  8873
			done = true,
moel@348
  8874
			elem = this.elem,
moel@348
  8875
			options = this.options;
moel@348
  8876
moel@348
  8877
		if ( gotoEnd || t >= options.duration + this.startTime ) {
moel@348
  8878
			this.now = this.end;
moel@348
  8879
			this.pos = this.state = 1;
moel@348
  8880
			this.update();
moel@348
  8881
moel@348
  8882
			options.animatedProperties[ this.prop ] = true;
moel@348
  8883
moel@348
  8884
			for ( p in options.animatedProperties ) {
moel@348
  8885
				if ( options.animatedProperties[ p ] !== true ) {
moel@348
  8886
					done = false;
moel@348
  8887
				}
moel@348
  8888
			}
moel@348
  8889
moel@348
  8890
			if ( done ) {
moel@348
  8891
				// Reset the overflow
moel@348
  8892
				if ( options.overflow != null && !jQuery.support.shrinkWrapBlocks ) {
moel@348
  8893
moel@348
  8894
					jQuery.each( [ "", "X", "Y" ], function( index, value ) {
moel@348
  8895
						elem.style[ "overflow" + value ] = options.overflow[ index ];
moel@348
  8896
					});
moel@348
  8897
				}
moel@348
  8898
moel@348
  8899
				// Hide the element if the "hide" operation was done
moel@348
  8900
				if ( options.hide ) {
moel@348
  8901
					jQuery( elem ).hide();
moel@348
  8902
				}
moel@348
  8903
moel@348
  8904
				// Reset the properties, if the item has been hidden or shown
moel@348
  8905
				if ( options.hide || options.show ) {
moel@348
  8906
					for ( p in options.animatedProperties ) {
moel@348
  8907
						jQuery.style( elem, p, options.orig[ p ] );
moel@348
  8908
						jQuery.removeData( elem, "fxshow" + p, true );
moel@348
  8909
						// Toggle data is no longer needed
moel@348
  8910
						jQuery.removeData( elem, "toggle" + p, true );
moel@348
  8911
					}
moel@348
  8912
				}
moel@348
  8913
moel@348
  8914
				// Execute the complete function
moel@348
  8915
				// in the event that the complete function throws an exception
moel@348
  8916
				// we must ensure it won't be called twice. #5684
moel@348
  8917
moel@348
  8918
				complete = options.complete;
moel@348
  8919
				if ( complete ) {
moel@348
  8920
moel@348
  8921
					options.complete = false;
moel@348
  8922
					complete.call( elem );
moel@348
  8923
				}
moel@348
  8924
			}
moel@348
  8925
moel@348
  8926
			return false;
moel@348
  8927
moel@348
  8928
		} else {
moel@348
  8929
			// classical easing cannot be used with an Infinity duration
moel@348
  8930
			if ( options.duration == Infinity ) {
moel@348
  8931
				this.now = t;
moel@348
  8932
			} else {
moel@348
  8933
				n = t - this.startTime;
moel@348
  8934
				this.state = n / options.duration;
moel@348
  8935
moel@348
  8936
				// Perform the easing function, defaults to swing
moel@348
  8937
				this.pos = jQuery.easing[ options.animatedProperties[this.prop] ]( this.state, n, 0, 1, options.duration );
moel@348
  8938
				this.now = this.start + ( (this.end - this.start) * this.pos );
moel@348
  8939
			}
moel@348
  8940
			// Perform the next step of the animation
moel@348
  8941
			this.update();
moel@348
  8942
		}
moel@348
  8943
moel@348
  8944
		return true;
moel@348
  8945
	}
moel@348
  8946
};
moel@348
  8947
moel@348
  8948
jQuery.extend( jQuery.fx, {
moel@348
  8949
	tick: function() {
moel@348
  8950
		var timer,
moel@348
  8951
			timers = jQuery.timers,
moel@348
  8952
			i = 0;
moel@348
  8953
moel@348
  8954
		for ( ; i < timers.length; i++ ) {
moel@348
  8955
			timer = timers[ i ];
moel@348
  8956
			// Checks the timer has not already been removed
moel@348
  8957
			if ( !timer() && timers[ i ] === timer ) {
moel@348
  8958
				timers.splice( i--, 1 );
moel@348
  8959
			}
moel@348
  8960
		}
moel@348
  8961
moel@348
  8962
		if ( !timers.length ) {
moel@348
  8963
			jQuery.fx.stop();
moel@348
  8964
		}
moel@348
  8965
	},
moel@348
  8966
moel@348
  8967
	interval: 13,
moel@348
  8968
moel@348
  8969
	stop: function() {
moel@348
  8970
		clearInterval( timerId );
moel@348
  8971
		timerId = null;
moel@348
  8972
	},
moel@348
  8973
moel@348
  8974
	speeds: {
moel@348
  8975
		slow: 600,
moel@348
  8976
		fast: 200,
moel@348
  8977
		// Default speed
moel@348
  8978
		_default: 400
moel@348
  8979
	},
moel@348
  8980
moel@348
  8981
	step: {
moel@348
  8982
		opacity: function( fx ) {
moel@348
  8983
			jQuery.style( fx.elem, "opacity", fx.now );
moel@348
  8984
		},
moel@348
  8985
moel@348
  8986
		_default: function( fx ) {
moel@348
  8987
			if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) {
moel@348
  8988
				fx.elem.style[ fx.prop ] = fx.now + fx.unit;
moel@348
  8989
			} else {
moel@348
  8990
				fx.elem[ fx.prop ] = fx.now;
moel@348
  8991
			}
moel@348
  8992
		}
moel@348
  8993
	}
moel@348
  8994
});
moel@348
  8995
moel@348
  8996
// Ensure props that can't be negative don't go there on undershoot easing
moel@348
  8997
jQuery.each( fxAttrs.concat.apply( [], fxAttrs ), function( i, prop ) {
moel@348
  8998
	// exclude marginTop, marginLeft, marginBottom and marginRight from this list
moel@348
  8999
	if ( prop.indexOf( "margin" ) ) {
moel@348
  9000
		jQuery.fx.step[ prop ] = function( fx ) {
moel@348
  9001
			jQuery.style( fx.elem, prop, Math.max(0, fx.now) + fx.unit );
moel@348
  9002
		};
moel@348
  9003
	}
moel@348
  9004
});
moel@348
  9005
moel@348
  9006
if ( jQuery.expr && jQuery.expr.filters ) {
moel@348
  9007
	jQuery.expr.filters.animated = function( elem ) {
moel@348
  9008
		return jQuery.grep(jQuery.timers, function( fn ) {
moel@348
  9009
			return elem === fn.elem;
moel@348
  9010
		}).length;
moel@348
  9011
	};
moel@348
  9012
}
moel@348
  9013
moel@348
  9014
// Try to restore the default display value of an element
moel@348
  9015
function defaultDisplay( nodeName ) {
moel@348
  9016
moel@348
  9017
	if ( !elemdisplay[ nodeName ] ) {
moel@348
  9018
moel@348
  9019
		var body = document.body,
moel@348
  9020
			elem = jQuery( "<" + nodeName + ">" ).appendTo( body ),
moel@348
  9021
			display = elem.css( "display" );
moel@348
  9022
		elem.remove();
moel@348
  9023
moel@348
  9024
		// If the simple way fails,
moel@348
  9025
		// get element's real default display by attaching it to a temp iframe
moel@348
  9026
		if ( display === "none" || display === "" ) {
moel@348
  9027
			// No iframe to use yet, so create it
moel@348
  9028
			if ( !iframe ) {
moel@348
  9029
				iframe = document.createElement( "iframe" );
moel@348
  9030
				iframe.frameBorder = iframe.width = iframe.height = 0;
moel@348
  9031
			}
moel@348
  9032
moel@348
  9033
			body.appendChild( iframe );
moel@348
  9034
moel@348
  9035
			// Create a cacheable copy of the iframe document on first call.
moel@348
  9036
			// IE and Opera will allow us to reuse the iframeDoc without re-writing the fake HTML
moel@348
  9037
			// document to it; WebKit & Firefox won't allow reusing the iframe document.
moel@348
  9038
			if ( !iframeDoc || !iframe.createElement ) {
moel@348
  9039
				iframeDoc = ( iframe.contentWindow || iframe.contentDocument ).document;
moel@348
  9040
				iframeDoc.write( ( jQuery.support.boxModel ? "<!doctype html>" : "" ) + "<html><body>" );
moel@348
  9041
				iframeDoc.close();
moel@348
  9042
			}
moel@348
  9043
moel@348
  9044
			elem = iframeDoc.createElement( nodeName );
moel@348
  9045
moel@348
  9046
			iframeDoc.body.appendChild( elem );
moel@348
  9047
moel@348
  9048
			display = jQuery.css( elem, "display" );
moel@348
  9049
			body.removeChild( iframe );
moel@348
  9050
		}
moel@348
  9051
moel@348
  9052
		// Store the correct default display
moel@348
  9053
		elemdisplay[ nodeName ] = display;
moel@348
  9054
	}
moel@348
  9055
moel@348
  9056
	return elemdisplay[ nodeName ];
moel@348
  9057
}
moel@348
  9058
moel@348
  9059
moel@348
  9060
moel@348
  9061
moel@348
  9062
var getOffset,
moel@348
  9063
	rtable = /^t(?:able|d|h)$/i,
moel@348
  9064
	rroot = /^(?:body|html)$/i;
moel@348
  9065
moel@348
  9066
if ( "getBoundingClientRect" in document.documentElement ) {
moel@348
  9067
	getOffset = function( elem, doc, docElem, box ) {
moel@348
  9068
		try {
moel@348
  9069
			box = elem.getBoundingClientRect();
moel@348
  9070
		} catch(e) {}
moel@348
  9071
moel@348
  9072
		// Make sure we're not dealing with a disconnected DOM node
moel@348
  9073
		if ( !box || !jQuery.contains( docElem, elem ) ) {
moel@348
  9074
			return box ? { top: box.top, left: box.left } : { top: 0, left: 0 };
moel@348
  9075
		}
moel@348
  9076
moel@348
  9077
		var body = doc.body,
moel@348
  9078
			win = getWindow( doc ),
moel@348
  9079
			clientTop  = docElem.clientTop  || body.clientTop  || 0,
moel@348
  9080
			clientLeft = docElem.clientLeft || body.clientLeft || 0,
moel@348
  9081
			scrollTop  = win.pageYOffset || jQuery.support.boxModel && docElem.scrollTop  || body.scrollTop,
moel@348
  9082
			scrollLeft = win.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft,
moel@348
  9083
			top  = box.top  + scrollTop  - clientTop,
moel@348
  9084
			left = box.left + scrollLeft - clientLeft;
moel@348
  9085
moel@348
  9086
		return { top: top, left: left };
moel@348
  9087
	};
moel@348
  9088
moel@348
  9089
} else {
moel@348
  9090
	getOffset = function( elem, doc, docElem ) {
moel@348
  9091
		var computedStyle,
moel@348
  9092
			offsetParent = elem.offsetParent,
moel@348
  9093
			prevOffsetParent = elem,
moel@348
  9094
			body = doc.body,
moel@348
  9095
			defaultView = doc.defaultView,
moel@348
  9096
			prevComputedStyle = defaultView ? defaultView.getComputedStyle( elem, null ) : elem.currentStyle,
moel@348
  9097
			top = elem.offsetTop,
moel@348
  9098
			left = elem.offsetLeft;
moel@348
  9099
moel@348
  9100
		while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) {
moel@348
  9101
			if ( jQuery.support.fixedPosition && prevComputedStyle.position === "fixed" ) {
moel@348
  9102
				break;
moel@348
  9103
			}
moel@348
  9104
moel@348
  9105
			computedStyle = defaultView ? defaultView.getComputedStyle(elem, null) : elem.currentStyle;
moel@348
  9106
			top  -= elem.scrollTop;
moel@348
  9107
			left -= elem.scrollLeft;
moel@348
  9108
moel@348
  9109
			if ( elem === offsetParent ) {
moel@348
  9110
				top  += elem.offsetTop;
moel@348
  9111
				left += elem.offsetLeft;
moel@348
  9112
moel@348
  9113
				if ( jQuery.support.doesNotAddBorder && !(jQuery.support.doesAddBorderForTableAndCells && rtable.test(elem.nodeName)) ) {
moel@348
  9114
					top  += parseFloat( computedStyle.borderTopWidth  ) || 0;
moel@348
  9115
					left += parseFloat( computedStyle.borderLeftWidth ) || 0;
moel@348
  9116
				}
moel@348
  9117
moel@348
  9118
				prevOffsetParent = offsetParent;
moel@348
  9119
				offsetParent = elem.offsetParent;
moel@348
  9120
			}
moel@348
  9121
moel@348
  9122
			if ( jQuery.support.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) {
moel@348
  9123
				top  += parseFloat( computedStyle.borderTopWidth  ) || 0;
moel@348
  9124
				left += parseFloat( computedStyle.borderLeftWidth ) || 0;
moel@348
  9125
			}
moel@348
  9126
moel@348
  9127
			prevComputedStyle = computedStyle;
moel@348
  9128
		}
moel@348
  9129
moel@348
  9130
		if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" ) {
moel@348
  9131
			top  += body.offsetTop;
moel@348
  9132
			left += body.offsetLeft;
moel@348
  9133
		}
moel@348
  9134
moel@348
  9135
		if ( jQuery.support.fixedPosition && prevComputedStyle.position === "fixed" ) {
moel@348
  9136
			top  += Math.max( docElem.scrollTop, body.scrollTop );
moel@348
  9137
			left += Math.max( docElem.scrollLeft, body.scrollLeft );
moel@348
  9138
		}
moel@348
  9139
moel@348
  9140
		return { top: top, left: left };
moel@348
  9141
	};
moel@348
  9142
}
moel@348
  9143
moel@348
  9144
jQuery.fn.offset = function( options ) {
moel@348
  9145
	if ( arguments.length ) {
moel@348
  9146
		return options === undefined ?
moel@348
  9147
			this :
moel@348
  9148
			this.each(function( i ) {
moel@348
  9149
				jQuery.offset.setOffset( this, options, i );
moel@348
  9150
			});
moel@348
  9151
	}
moel@348
  9152
moel@348
  9153
	var elem = this[0],
moel@348
  9154
		doc = elem && elem.ownerDocument;
moel@348
  9155
moel@348
  9156
	if ( !doc ) {
moel@348
  9157
		return null;
moel@348
  9158
	}
moel@348
  9159
moel@348
  9160
	if ( elem === doc.body ) {
moel@348
  9161
		return jQuery.offset.bodyOffset( elem );
moel@348
  9162
	}
moel@348
  9163
moel@348
  9164
	return getOffset( elem, doc, doc.documentElement );
moel@348
  9165
};
moel@348
  9166
moel@348
  9167
jQuery.offset = {
moel@348
  9168
moel@348
  9169
	bodyOffset: function( body ) {
moel@348
  9170
		var top = body.offsetTop,
moel@348
  9171
			left = body.offsetLeft;
moel@348
  9172
moel@348
  9173
		if ( jQuery.support.doesNotIncludeMarginInBodyOffset ) {
moel@348
  9174
			top  += parseFloat( jQuery.css(body, "marginTop") ) || 0;
moel@348
  9175
			left += parseFloat( jQuery.css(body, "marginLeft") ) || 0;
moel@348
  9176
		}
moel@348
  9177
moel@348
  9178
		return { top: top, left: left };
moel@348
  9179
	},
moel@348
  9180
moel@348
  9181
	setOffset: function( elem, options, i ) {
moel@348
  9182
		var position = jQuery.css( elem, "position" );
moel@348
  9183
moel@348
  9184
		// set position first, in-case top/left are set even on static elem
moel@348
  9185
		if ( position === "static" ) {
moel@348
  9186
			elem.style.position = "relative";
moel@348
  9187
		}
moel@348
  9188
moel@348
  9189
		var curElem = jQuery( elem ),
moel@348
  9190
			curOffset = curElem.offset(),
moel@348
  9191
			curCSSTop = jQuery.css( elem, "top" ),
moel@348
  9192
			curCSSLeft = jQuery.css( elem, "left" ),
moel@348
  9193
			calculatePosition = ( position === "absolute" || position === "fixed" ) && jQuery.inArray("auto", [curCSSTop, curCSSLeft]) > -1,
moel@348
  9194
			props = {}, curPosition = {}, curTop, curLeft;
moel@348
  9195
moel@348
  9196
		// need to be able to calculate position if either top or left is auto and position is either absolute or fixed
moel@348
  9197
		if ( calculatePosition ) {
moel@348
  9198
			curPosition = curElem.position();
moel@348
  9199
			curTop = curPosition.top;
moel@348
  9200
			curLeft = curPosition.left;
moel@348
  9201
		} else {
moel@348
  9202
			curTop = parseFloat( curCSSTop ) || 0;
moel@348
  9203
			curLeft = parseFloat( curCSSLeft ) || 0;
moel@348
  9204
		}
moel@348
  9205
moel@348
  9206
		if ( jQuery.isFunction( options ) ) {
moel@348
  9207
			options = options.call( elem, i, curOffset );
moel@348
  9208
		}
moel@348
  9209
moel@348
  9210
		if ( options.top != null ) {
moel@348
  9211
			props.top = ( options.top - curOffset.top ) + curTop;
moel@348
  9212
		}
moel@348
  9213
		if ( options.left != null ) {
moel@348
  9214
			props.left = ( options.left - curOffset.left ) + curLeft;
moel@348
  9215
		}
moel@348
  9216
moel@348
  9217
		if ( "using" in options ) {
moel@348
  9218
			options.using.call( elem, props );
moel@348
  9219
		} else {
moel@348
  9220
			curElem.css( props );
moel@348
  9221
		}
moel@348
  9222
	}
moel@348
  9223
};
moel@348
  9224
moel@348
  9225
moel@348
  9226
jQuery.fn.extend({
moel@348
  9227
moel@348
  9228
	position: function() {
moel@348
  9229
		if ( !this[0] ) {
moel@348
  9230
			return null;
moel@348
  9231
		}
moel@348
  9232
moel@348
  9233
		var elem = this[0],
moel@348
  9234
moel@348
  9235
		// Get *real* offsetParent
moel@348
  9236
		offsetParent = this.offsetParent(),
moel@348
  9237
moel@348
  9238
		// Get correct offsets
moel@348
  9239
		offset       = this.offset(),
moel@348
  9240
		parentOffset = rroot.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset();
moel@348
  9241
moel@348
  9242
		// Subtract element margins
moel@348
  9243
		// note: when an element has margin: auto the offsetLeft and marginLeft
moel@348
  9244
		// are the same in Safari causing offset.left to incorrectly be 0
moel@348
  9245
		offset.top  -= parseFloat( jQuery.css(elem, "marginTop") ) || 0;
moel@348
  9246
		offset.left -= parseFloat( jQuery.css(elem, "marginLeft") ) || 0;
moel@348
  9247
moel@348
  9248
		// Add offsetParent borders
moel@348
  9249
		parentOffset.top  += parseFloat( jQuery.css(offsetParent[0], "borderTopWidth") ) || 0;
moel@348
  9250
		parentOffset.left += parseFloat( jQuery.css(offsetParent[0], "borderLeftWidth") ) || 0;
moel@348
  9251
moel@348
  9252
		// Subtract the two offsets
moel@348
  9253
		return {
moel@348
  9254
			top:  offset.top  - parentOffset.top,
moel@348
  9255
			left: offset.left - parentOffset.left
moel@348
  9256
		};
moel@348
  9257
	},
moel@348
  9258
moel@348
  9259
	offsetParent: function() {
moel@348
  9260
		return this.map(function() {
moel@348
  9261
			var offsetParent = this.offsetParent || document.body;
moel@348
  9262
			while ( offsetParent && (!rroot.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) {
moel@348
  9263
				offsetParent = offsetParent.offsetParent;
moel@348
  9264
			}
moel@348
  9265
			return offsetParent;
moel@348
  9266
		});
moel@348
  9267
	}
moel@348
  9268
});
moel@348
  9269
moel@348
  9270
moel@348
  9271
// Create scrollLeft and scrollTop methods
moel@348
  9272
jQuery.each( {scrollLeft: "pageXOffset", scrollTop: "pageYOffset"}, function( method, prop ) {
moel@348
  9273
	var top = /Y/.test( prop );
moel@348
  9274
moel@348
  9275
	jQuery.fn[ method ] = function( val ) {
moel@348
  9276
		return jQuery.access( this, function( elem, method, val ) {
moel@348
  9277
			var win = getWindow( elem );
moel@348
  9278
moel@348
  9279
			if ( val === undefined ) {
moel@348
  9280
				return win ? (prop in win) ? win[ prop ] :
moel@348
  9281
					jQuery.support.boxModel && win.document.documentElement[ method ] ||
moel@348
  9282
						win.document.body[ method ] :
moel@348
  9283
					elem[ method ];
moel@348
  9284
			}
moel@348
  9285
moel@348
  9286
			if ( win ) {
moel@348
  9287
				win.scrollTo(
moel@348
  9288
					!top ? val : jQuery( win ).scrollLeft(),
moel@348
  9289
					 top ? val : jQuery( win ).scrollTop()
moel@348
  9290
				);
moel@348
  9291
moel@348
  9292
			} else {
moel@348
  9293
				elem[ method ] = val;
moel@348
  9294
			}
moel@348
  9295
		}, method, val, arguments.length, null );
moel@348
  9296
	};
moel@348
  9297
});
moel@348
  9298
moel@348
  9299
function getWindow( elem ) {
moel@348
  9300
	return jQuery.isWindow( elem ) ?
moel@348
  9301
		elem :
moel@348
  9302
		elem.nodeType === 9 ?
moel@348
  9303
			elem.defaultView || elem.parentWindow :
moel@348
  9304
			false;
moel@348
  9305
}
moel@348
  9306
moel@348
  9307
moel@348
  9308
moel@348
  9309
moel@348
  9310
// Create width, height, innerHeight, innerWidth, outerHeight and outerWidth methods
moel@348
  9311
jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
moel@348
  9312
	var clientProp = "client" + name,
moel@348
  9313
		scrollProp = "scroll" + name,
moel@348
  9314
		offsetProp = "offset" + name;
moel@348
  9315
moel@348
  9316
	// innerHeight and innerWidth
moel@348
  9317
	jQuery.fn[ "inner" + name ] = function() {
moel@348
  9318
		var elem = this[0];
moel@348
  9319
		return elem ?
moel@348
  9320
			elem.style ?
moel@348
  9321
			parseFloat( jQuery.css( elem, type, "padding" ) ) :
moel@348
  9322
			this[ type ]() :
moel@348
  9323
			null;
moel@348
  9324
	};
moel@348
  9325
moel@348
  9326
	// outerHeight and outerWidth
moel@348
  9327
	jQuery.fn[ "outer" + name ] = function( margin ) {
moel@348
  9328
		var elem = this[0];
moel@348
  9329
		return elem ?
moel@348
  9330
			elem.style ?
moel@348
  9331
			parseFloat( jQuery.css( elem, type, margin ? "margin" : "border" ) ) :
moel@348
  9332
			this[ type ]() :
moel@348
  9333
			null;
moel@348
  9334
	};
moel@348
  9335
moel@348
  9336
	jQuery.fn[ type ] = function( value ) {
moel@348
  9337
		return jQuery.access( this, function( elem, type, value ) {
moel@348
  9338
			var doc, docElemProp, orig, ret;
moel@348
  9339
moel@348
  9340
			if ( jQuery.isWindow( elem ) ) {
moel@348
  9341
				// 3rd condition allows Nokia support, as it supports the docElem prop but not CSS1Compat
moel@348
  9342
				doc = elem.document;
moel@348
  9343
				docElemProp = doc.documentElement[ clientProp ];
moel@348
  9344
				return jQuery.support.boxModel && docElemProp ||
moel@348
  9345
					doc.body && doc.body[ clientProp ] || docElemProp;
moel@348
  9346
			}
moel@348
  9347
moel@348
  9348
			// Get document width or height
moel@348
  9349
			if ( elem.nodeType === 9 ) {
moel@348
  9350
				// Either scroll[Width/Height] or offset[Width/Height], whichever is greater
moel@348
  9351
				doc = elem.documentElement;
moel@348
  9352
moel@348
  9353
				// when a window > document, IE6 reports a offset[Width/Height] > client[Width/Height]
moel@348
  9354
				// so we can't use max, as it'll choose the incorrect offset[Width/Height]
moel@348
  9355
				// instead we use the correct client[Width/Height]
moel@348
  9356
				// support:IE6
moel@348
  9357
				if ( doc[ clientProp ] >= doc[ scrollProp ] ) {
moel@348
  9358
					return doc[ clientProp ];
moel@348
  9359
				}
moel@348
  9360
moel@348
  9361
				return Math.max(
moel@348
  9362
					elem.body[ scrollProp ], doc[ scrollProp ],
moel@348
  9363
					elem.body[ offsetProp ], doc[ offsetProp ]
moel@348
  9364
				);
moel@348
  9365
			}
moel@348
  9366
moel@348
  9367
			// Get width or height on the element
moel@348
  9368
			if ( value === undefined ) {
moel@348
  9369
				orig = jQuery.css( elem, type );
moel@348
  9370
				ret = parseFloat( orig );
moel@348
  9371
				return jQuery.isNumeric( ret ) ? ret : orig;
moel@348
  9372
			}
moel@348
  9373
moel@348
  9374
			// Set the width or height on the element
moel@348
  9375
			jQuery( elem ).css( type, value );
moel@348
  9376
		}, type, value, arguments.length, null );
moel@348
  9377
	};
moel@348
  9378
});
moel@348
  9379
moel@348
  9380
moel@348
  9381
moel@348
  9382
moel@348
  9383
// Expose jQuery to the global object
moel@348
  9384
window.jQuery = window.$ = jQuery;
moel@348
  9385
moel@348
  9386
// Expose jQuery as an AMD module, but only for AMD loaders that
moel@348
  9387
// understand the issues with loading multiple versions of jQuery
moel@348
  9388
// in a page that all might call define(). The loader will indicate
moel@348
  9389
// they have special allowances for multiple jQuery versions by
moel@348
  9390
// specifying define.amd.jQuery = true. Register as a named module,
moel@348
  9391
// since jQuery can be concatenated with other files that may use define,
moel@348
  9392
// but not use a proper concatenation script that understands anonymous
moel@348
  9393
// AMD modules. A named AMD is safest and most robust way to register.
moel@348
  9394
// Lowercase jquery is used because AMD module names are derived from
moel@348
  9395
// file names, and jQuery is normally delivered in a lowercase file name.
moel@348
  9396
// Do this after creating the global so that if an AMD module wants to call
moel@348
  9397
// noConflict to hide this version of jQuery, it will work.
moel@348
  9398
if ( typeof define === "function" && define.amd && define.amd.jQuery ) {
moel@348
  9399
	define( "jquery", [], function () { return jQuery; } );
moel@348
  9400
}
moel@348
  9401
moel@348
  9402
moel@348
  9403
moel@348
  9404
})( window );