JAL-1807 update
[jalviewjs.git] / site / jquery / jquery.js
1 /*!
2  * jQuery JavaScript Library v1.11.0
3  * http://jquery.com/
4  *
5  * Includes Sizzle.js
6  * http://sizzlejs.com/
7  *
8  * Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors
9  * Released under the MIT license
10  * http://jquery.org/license
11  *
12  * Date: 2014-01-23T21:02Z
13  */
14
15 // modified by Bob Hanson for local MSIE 11 reading remote files
16
17 (function( global, factory ) {
18
19         if ( typeof module === "object" && typeof module.exports === "object" ) {
20                 // For CommonJS and CommonJS-like environments where a proper window is present,
21                 // execute the factory and get jQuery
22                 // For environments that do not inherently posses a window with a document
23                 // (such as Node.js), expose a jQuery-making factory as module.exports
24                 // This accentuates the need for the creation of a real window
25                 // e.g. var jQuery = require("jquery")(window);
26                 // See ticket #14549 for more info
27                 module.exports = global.document ?
28                         factory( global, true ) :
29                         function( w ) {
30                                 if ( !w.document ) {
31                                         throw new Error( "jQuery requires a window with a document" );
32                                 }
33                                 return factory( w );
34                         };
35         } else {
36                 factory( global );
37         }
38
39 // Pass this if window is not defined yet
40 }(typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
41
42 // Can't do this because several apps including ASP.NET trace
43 // the stack via arguments.caller.callee and Firefox dies if
44 // you try to trace through "use strict" call chains. (#13335)
45 // Support: Firefox 18+
46 //
47
48 var deletedIds = [];
49
50 var slice = deletedIds.slice;
51
52 var concat = deletedIds.concat;
53
54 var push = deletedIds.push;
55
56 var indexOf = deletedIds.indexOf;
57
58 var class2type = {};
59
60 var toString = class2type.toString;
61
62 var hasOwn = class2type.hasOwnProperty;
63
64 var trim = "".trim;
65
66 var support = {};
67
68
69
70 var
71         version = "1.11.0",
72
73         // Define a local copy of jQuery
74         jQuery = function( selector, context ) {
75                 // The jQuery object is actually just the init constructor 'enhanced'
76                 // Need init if jQuery is called (just allow error to be thrown if not included)
77                 return new jQuery.fn.init( selector, context );
78         },
79
80         // Make sure we trim BOM and NBSP (here's looking at you, Safari 5.0 and IE)
81         rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
82
83         // Matches dashed string for camelizing
84         rmsPrefix = /^-ms-/,
85         rdashAlpha = /-([\da-z])/gi,
86
87         // Used by jQuery.camelCase as callback to replace()
88         fcamelCase = function( all, letter ) {
89                 return letter.toUpperCase();
90         };
91
92 jQuery.fn = jQuery.prototype = {
93         // The current version of jQuery being used
94         jquery: version,
95
96         constructor: jQuery,
97
98         // Start with an empty selector
99         selector: "",
100
101         // The default length of a jQuery object is 0
102         length: 0,
103
104         toArray: function() {
105                 return slice.call( this );
106         },
107
108         // Get the Nth element in the matched element set OR
109         // Get the whole matched element set as a clean array
110         get: function( num ) {
111                 return num != null ?
112
113                         // Return a 'clean' array
114                         ( num < 0 ? this[ num + this.length ] : this[ num ] ) :
115
116                         // Return just the object
117                         slice.call( this );
118         },
119
120         // Take an array of elements and push it onto the stack
121         // (returning the new matched element set)
122         pushStack: function( elems ) {
123
124                 // Build a new jQuery matched element set
125                 var ret = jQuery.merge( this.constructor(), elems );
126
127                 // Add the old object onto the stack (as a reference)
128                 ret.prevObject = this;
129                 ret.context = this.context;
130
131                 // Return the newly-formed element set
132                 return ret;
133         },
134
135         // Execute a callback for every element in the matched set.
136         // (You can seed the arguments with an array of args, but this is
137         // only used internally.)
138         each: function( callback, args ) {
139                 return jQuery.each( this, callback, args );
140         },
141
142         map: function( callback ) {
143                 return this.pushStack( jQuery.map(this, function( elem, i ) {
144                         return callback.call( elem, i, elem );
145                 }));
146         },
147
148         slice: function() {
149                 return this.pushStack( slice.apply( this, arguments ) );
150         },
151
152         first: function() {
153                 return this.eq( 0 );
154         },
155
156         last: function() {
157                 return this.eq( -1 );
158         },
159
160         eq: function( i ) {
161                 var len = this.length,
162                         j = +i + ( i < 0 ? len : 0 );
163                 return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] );
164         },
165
166         end: function() {
167                 return this.prevObject || this.constructor(null);
168         },
169
170         // For internal use only.
171         // Behaves like an Array's method, not like a jQuery method.
172         push: push,
173         sort: deletedIds.sort,
174         splice: deletedIds.splice
175 };
176
177 jQuery.extend = jQuery.fn.extend = function() {
178         var src, copyIsArray, copy, name, options, clone,
179                 target = arguments[0] || {},
180                 i = 1,
181                 length = arguments.length,
182                 deep = false;
183
184         // Handle a deep copy situation
185         if ( typeof target === "boolean" ) {
186                 deep = target;
187
188                 // skip the boolean and the target
189                 target = arguments[ i ] || {};
190                 i++;
191         }
192
193         // Handle case when target is a string or something (possible in deep copy)
194         if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
195                 target = {};
196         }
197
198         // extend jQuery itself if only one argument is passed
199         if ( i === length ) {
200                 target = this;
201                 i--;
202         }
203
204         for ( ; i < length; i++ ) {
205                 // Only deal with non-null/undefined values
206                 if ( (options = arguments[ i ]) != null ) {
207                         // Extend the base object
208                         for ( name in options ) {
209                                 src = target[ name ];
210                                 copy = options[ name ];
211
212                                 // Prevent never-ending loop
213                                 if ( target === copy ) {
214                                         continue;
215                                 }
216
217                                 // Recurse if we're merging plain objects or arrays
218                                 if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
219                                         if ( copyIsArray ) {
220                                                 copyIsArray = false;
221                                                 clone = src && jQuery.isArray(src) ? src : [];
222
223                                         } else {
224                                                 clone = src && jQuery.isPlainObject(src) ? src : {};
225                                         }
226
227                                         // Never move original objects, clone them
228                                         target[ name ] = jQuery.extend( deep, clone, copy );
229
230                                 // Don't bring in undefined values
231                                 } else if ( copy !== undefined ) {
232                                         target[ name ] = copy;
233                                 }
234                         }
235                 }
236         }
237
238         // Return the modified object
239         return target;
240 };
241
242 jQuery.extend({
243         // Unique for each copy of jQuery on the page
244         expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
245
246         // Assume jQuery is ready without the ready module
247         isReady: true,
248
249         error: function( msg ) {
250                 throw new Error( msg );
251         },
252
253         noop: function() {},
254
255         // See test/unit/core.js for details concerning isFunction.
256         // Since version 1.3, DOM methods and functions like alert
257         // aren't supported. They return false on IE (#2968).
258         isFunction: function( obj ) {
259                 return jQuery.type(obj) === "function";
260         },
261
262         isArray: Array.isArray || function( obj ) {
263                 return jQuery.type(obj) === "array";
264         },
265
266         isWindow: function( obj ) {
267                 /* jshint eqeqeq: false */
268                 return obj != null && obj == obj.window;
269         },
270
271         isNumeric: function( obj ) {
272                 // parseFloat NaNs numeric-cast false positives (null|true|false|"")
273                 // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
274                 // subtraction forces infinities to NaN
275                 return obj - parseFloat( obj ) >= 0;
276         },
277
278         isEmptyObject: function( obj ) {
279                 var name;
280                 for ( name in obj ) {
281                         return false;
282                 }
283                 return true;
284         },
285
286         isPlainObject: function( obj ) {
287                 var key;
288
289                 // Must be an Object.
290                 // Because of IE, we also have to check the presence of the constructor property.
291                 // Make sure that DOM nodes and window objects don't pass through, as well
292                 if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
293                         return false;
294                 }
295
296                 try {
297                         // Not own constructor property must be Object
298                         if ( obj.constructor &&
299                                 !hasOwn.call(obj, "constructor") &&
300                                 !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
301                                 return false;
302                         }
303                 } catch ( e ) {
304                         // IE8,9 Will throw exceptions on certain host objects #9897
305                         return false;
306                 }
307
308                 // Support: IE<9
309                 // Handle iteration over inherited properties before own properties.
310                 if ( support.ownLast ) {
311                         for ( key in obj ) {
312                                 return hasOwn.call( obj, key );
313                         }
314                 }
315
316                 // Own properties are enumerated firstly, so to speed up,
317                 // if last one is own, then all properties are own.
318                 for ( key in obj ) {}
319
320                 return key === undefined || hasOwn.call( obj, key );
321         },
322
323         type: function( obj ) {
324                 if ( obj == null ) {
325                         return obj + "";
326                 }
327                 return typeof obj === "object" || typeof obj === "function" ?
328                         class2type[ toString.call(obj) ] || "object" :
329                         typeof obj;
330         },
331
332         // Evaluates a script in a global context
333         // Workarounds based on findings by Jim Driscoll
334         // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
335         globalEval: function( data ) {
336                 if ( data && jQuery.trim( data ) ) {
337                         // We use execScript on Internet Explorer
338                         // We use an anonymous function so that context is window
339                         // rather than jQuery in Firefox
340                         ( window.execScript || function( data ) {
341                                 window[ "eval" ].call( window, data );
342                         } )( data );
343                 }
344         },
345
346         // Convert dashed to camelCase; used by the css and data modules
347         // Microsoft forgot to hump their vendor prefix (#9572)
348         camelCase: function( string ) {
349                 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
350         },
351
352         nodeName: function( elem, name ) {
353                 return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
354         },
355
356         // args is for internal usage only
357         each: function( obj, callback, args ) {
358                 var value,
359                         i = 0,
360                         length = obj.length,
361                         isArray = isArraylike( obj );
362
363                 if ( args ) {
364                         if ( isArray ) {
365                                 for ( ; i < length; i++ ) {
366                                         value = callback.apply( obj[ i ], args );
367
368                                         if ( value === false ) {
369                                                 break;
370                                         }
371                                 }
372                         } else {
373                                 for ( i in obj ) {
374                                         value = callback.apply( obj[ i ], args );
375
376                                         if ( value === false ) {
377                                                 break;
378                                         }
379                                 }
380                         }
381
382                 // A special, fast, case for the most common use of each
383                 } else {
384                         if ( isArray ) {
385                                 for ( ; i < length; i++ ) {
386                                         value = callback.call( obj[ i ], i, obj[ i ] );
387
388                                         if ( value === false ) {
389                                                 break;
390                                         }
391                                 }
392                         } else {
393                                 for ( i in obj ) {
394                                         value = callback.call( obj[ i ], i, obj[ i ] );
395
396                                         if ( value === false ) {
397                                                 break;
398                                         }
399                                 }
400                         }
401                 }
402
403                 return obj;
404         },
405
406         // Use native String.trim function wherever possible
407         trim: trim && !trim.call("\uFEFF\xA0") ?
408                 function( text ) {
409                         return text == null ?
410                                 "" :
411                                 trim.call( text );
412                 } :
413
414                 // Otherwise use our own trimming functionality
415                 function( text ) {
416                         return text == null ?
417                                 "" :
418                                 ( text + "" ).replace( rtrim, "" );
419                 },
420
421         // results is for internal usage only
422         makeArray: function( arr, results ) {
423                 var ret = results || [];
424
425                 if ( arr != null ) {
426                         if ( isArraylike( Object(arr) ) ) {
427                                 jQuery.merge( ret,
428                                         typeof arr === "string" ?
429                                         [ arr ] : arr
430                                 );
431                         } else {
432                                 push.call( ret, arr );
433                         }
434                 }
435
436                 return ret;
437         },
438
439         inArray: function( elem, arr, i ) {
440                 var len;
441
442                 if ( arr ) {
443                         if ( indexOf ) {
444                                 return indexOf.call( arr, elem, i );
445                         }
446
447                         len = arr.length;
448                         i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
449
450                         for ( ; i < len; i++ ) {
451                                 // Skip accessing in sparse arrays
452                                 if ( i in arr && arr[ i ] === elem ) {
453                                         return i;
454                                 }
455                         }
456                 }
457
458                 return -1;
459         },
460
461         merge: function( first, second ) {
462                 var len = +second.length,
463                         j = 0,
464                         i = first.length;
465
466                 while ( j < len ) {
467                         first[ i++ ] = second[ j++ ];
468                 }
469
470                 // Support: IE<9
471                 // Workaround casting of .length to NaN on otherwise arraylike objects (e.g., NodeLists)
472                 if ( len !== len ) {
473                         while ( second[j] !== undefined ) {
474                                 first[ i++ ] = second[ j++ ];
475                         }
476                 }
477
478                 first.length = i;
479
480                 return first;
481         },
482
483         grep: function( elems, callback, invert ) {
484                 var callbackInverse,
485                         matches = [],
486                         i = 0,
487                         length = elems.length,
488                         callbackExpect = !invert;
489
490                 // Go through the array, only saving the items
491                 // that pass the validator function
492                 for ( ; i < length; i++ ) {
493                         callbackInverse = !callback( elems[ i ], i );
494                         if ( callbackInverse !== callbackExpect ) {
495                                 matches.push( elems[ i ] );
496                         }
497                 }
498
499                 return matches;
500         },
501
502         // arg is for internal usage only
503         map: function( elems, callback, arg ) {
504                 var value,
505                         i = 0,
506                         length = elems.length,
507                         isArray = isArraylike( elems ),
508                         ret = [];
509
510                 // Go through the array, translating each of the items to their new values
511                 if ( isArray ) {
512                         for ( ; i < length; i++ ) {
513                                 value = callback( elems[ i ], i, arg );
514
515                                 if ( value != null ) {
516                                         ret.push( value );
517                                 }
518                         }
519
520                 // Go through every key on the object,
521                 } else {
522                         for ( i in elems ) {
523                                 value = callback( elems[ i ], i, arg );
524
525                                 if ( value != null ) {
526                                         ret.push( value );
527                                 }
528                         }
529                 }
530
531                 // Flatten any nested arrays
532                 return concat.apply( [], ret );
533         },
534
535         // A global GUID counter for objects
536         guid: 1,
537
538         // Bind a function to a context, optionally partially applying any
539         // arguments.
540         proxy: function( fn, context ) {
541                 var args, proxy, tmp;
542
543                 if ( typeof context === "string" ) {
544                         tmp = fn[ context ];
545                         context = fn;
546                         fn = tmp;
547                 }
548
549                 // Quick check to determine if target is callable, in the spec
550                 // this throws a TypeError, but we will just return undefined.
551                 if ( !jQuery.isFunction( fn ) ) {
552                         return undefined;
553                 }
554
555                 // Simulated bind
556                 args = slice.call( arguments, 2 );
557                 proxy = function() {
558                         return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
559                 };
560
561                 // Set the guid of unique handler to the same of original handler, so it can be removed
562                 proxy.guid = fn.guid = fn.guid || jQuery.guid++;
563
564                 return proxy;
565         },
566
567         now: function() {
568                 return +( new Date() );
569         },
570
571         // jQuery.support is not used in Core but other projects attach their
572         // properties to it so it needs to exist.
573         support: support
574 });
575
576 // Populate the class2type map
577 jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) {
578         class2type[ "[object " + name + "]" ] = name.toLowerCase();
579 });
580
581 function isArraylike( obj ) {
582         var length = obj.length,
583                 type = jQuery.type( obj );
584
585         if ( type === "function" || jQuery.isWindow( obj ) ) {
586                 return false;
587         }
588
589         if ( obj.nodeType === 1 && length ) {
590                 return true;
591         }
592
593         return type === "array" || length === 0 ||
594                 typeof length === "number" && length > 0 && ( length - 1 ) in obj;
595 }
596 var Sizzle =
597 /*!
598  * Sizzle CSS Selector Engine v1.10.16
599  * http://sizzlejs.com/
600  *
601  * Copyright 2013 jQuery Foundation, Inc. and other contributors
602  * Released under the MIT license
603  * http://jquery.org/license
604  *
605  * Date: 2014-01-13
606  */
607 (function( window ) {
608
609 var i,
610         support,
611         Expr,
612         getText,
613         isXML,
614         compile,
615         outermostContext,
616         sortInput,
617         hasDuplicate,
618
619         // Local document vars
620         setDocument,
621         document,
622         docElem,
623         documentIsHTML,
624         rbuggyQSA,
625         rbuggyMatches,
626         matches,
627         contains,
628
629         // Instance-specific data
630         expando = "sizzle" + -(new Date()),
631         preferredDoc = window.document,
632         dirruns = 0,
633         done = 0,
634         classCache = createCache(),
635         tokenCache = createCache(),
636         compilerCache = createCache(),
637         sortOrder = function( a, b ) {
638                 if ( a === b ) {
639                         hasDuplicate = true;
640                 }
641                 return 0;
642         },
643
644         // General-purpose constants
645         strundefined = typeof undefined,
646         MAX_NEGATIVE = 1 << 31,
647
648         // Instance methods
649         hasOwn = ({}).hasOwnProperty,
650         arr = [],
651         pop = arr.pop,
652         push_native = arr.push,
653         push = arr.push,
654         slice = arr.slice,
655         // Use a stripped-down indexOf if we can't use a native one
656         indexOf = arr.indexOf || function( elem ) {
657                 var i = 0,
658                         len = this.length;
659                 for ( ; i < len; i++ ) {
660                         if ( this[i] === elem ) {
661                                 return i;
662                         }
663                 }
664                 return -1;
665         },
666
667         booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
668
669         // Regular expressions
670
671         // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace
672         whitespace = "[\\x20\\t\\r\\n\\f]",
673         // http://www.w3.org/TR/css3-syntax/#characters
674         characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",
675
676         // Loosely modeled on CSS identifier characters
677         // An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors
678         // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
679         identifier = characterEncoding.replace( "w", "w#" ),
680
681         // Acceptable operators http://www.w3.org/TR/selectors/#attribute-selectors
682         attributes = "\\[" + whitespace + "*(" + characterEncoding + ")" + whitespace +
683                 "*(?:([*^$|!~]?=)" + whitespace + "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + identifier + ")|)|)" + whitespace + "*\\]",
684
685         // Prefer arguments quoted,
686         //   then not containing pseudos/brackets,
687         //   then attribute selectors/non-parenthetical expressions,
688         //   then anything else
689         // These preferences are here to reduce the number of selectors
690         //   needing tokenize in the PSEUDO preFilter
691         pseudos = ":(" + characterEncoding + ")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|" + attributes.replace( 3, 8 ) + ")*)|.*)\\)|)",
692
693         // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
694         rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
695
696         rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
697         rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
698
699         rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ),
700
701         rpseudo = new RegExp( pseudos ),
702         ridentifier = new RegExp( "^" + identifier + "$" ),
703
704         matchExpr = {
705                 "ID": new RegExp( "^#(" + characterEncoding + ")" ),
706                 "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ),
707                 "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ),
708                 "ATTR": new RegExp( "^" + attributes ),
709                 "PSEUDO": new RegExp( "^" + pseudos ),
710                 "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
711                         "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
712                         "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
713                 "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
714                 // For use in libraries implementing .is()
715                 // We use this for POS matching in `select`
716                 "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
717                         whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
718         },
719
720         rinputs = /^(?:input|select|textarea|button)$/i,
721         rheader = /^h\d$/i,
722
723         rnative = /^[^{]+\{\s*\[native \w/,
724
725         // Easily-parseable/retrievable ID or TAG or CLASS selectors
726         rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
727
728         rsibling = /[+~]/,
729         rescape = /'|\\/g,
730
731         // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
732         runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
733         funescape = function( _, escaped, escapedWhitespace ) {
734                 var high = "0x" + escaped - 0x10000;
735                 // NaN means non-codepoint
736                 // Support: Firefox
737                 // Workaround erroneous numeric interpretation of +"0x"
738                 return high !== high || escapedWhitespace ?
739                         escaped :
740                         high < 0 ?
741                                 // BMP codepoint
742                                 String.fromCharCode( high + 0x10000 ) :
743                                 // Supplemental Plane codepoint (surrogate pair)
744                                 String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
745         };
746
747 // Optimize for push.apply( _, NodeList )
748 try {
749         push.apply(
750                 (arr = slice.call( preferredDoc.childNodes )),
751                 preferredDoc.childNodes
752         );
753         // Support: Android<4.0
754         // Detect silently failing push.apply
755         arr[ preferredDoc.childNodes.length ].nodeType;
756 } catch ( e ) {
757         push = { apply: arr.length ?
758
759                 // Leverage slice if possible
760                 function( target, els ) {
761                         push_native.apply( target, slice.call(els) );
762                 } :
763
764                 // Support: IE<9
765                 // Otherwise append directly
766                 function( target, els ) {
767                         var j = target.length,
768                                 i = 0;
769                         // Can't trust NodeList.length
770                         while ( (target[j++] = els[i++]) ) {}
771                         target.length = j - 1;
772                 }
773         };
774 }
775
776 function Sizzle( selector, context, results, seed ) {
777         var match, elem, m, nodeType,
778                 // QSA vars
779                 i, groups, old, nid, newContext, newSelector;
780
781         if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
782                 setDocument( context );
783         }
784
785         context = context || document;
786         results = results || [];
787
788         if ( !selector || typeof selector !== "string" ) {
789                 return results;
790         }
791
792         if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) {
793                 return [];
794         }
795
796         if ( documentIsHTML && !seed ) {
797
798                 // Shortcuts
799                 if ( (match = rquickExpr.exec( selector )) ) {
800                         // Speed-up: Sizzle("#ID")
801                         if ( (m = match[1]) ) {
802                                 if ( nodeType === 9 ) {
803                                         elem = context.getElementById( m );
804                                         // Check parentNode to catch when Blackberry 4.6 returns
805                                         // nodes that are no longer in the document (jQuery #6963)
806                                         if ( elem && elem.parentNode ) {
807                                                 // Handle the case where IE, Opera, and Webkit return items
808                                                 // by name instead of ID
809                                                 if ( elem.id === m ) {
810                                                         results.push( elem );
811                                                         return results;
812                                                 }
813                                         } else {
814                                                 return results;
815                                         }
816                                 } else {
817                                         // Context is not a document
818                                         if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) &&
819                                                 contains( context, elem ) && elem.id === m ) {
820                                                 results.push( elem );
821                                                 return results;
822                                         }
823                                 }
824
825                         // Speed-up: Sizzle("TAG")
826                         } else if ( match[2] ) {
827                                 push.apply( results, context.getElementsByTagName( selector ) );
828                                 return results;
829
830                         // Speed-up: Sizzle(".CLASS")
831                         } else if ( (m = match[3]) && support.getElementsByClassName && context.getElementsByClassName ) {
832                                 push.apply( results, context.getElementsByClassName( m ) );
833                                 return results;
834                         }
835                 }
836
837                 // QSA path
838                 if ( support.qsa && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
839                         nid = old = expando;
840                         newContext = context;
841                         newSelector = nodeType === 9 && selector;
842
843                         // qSA works strangely on Element-rooted queries
844                         // We can work around this by specifying an extra ID on the root
845                         // and working up from there (Thanks to Andrew Dupont for the technique)
846                         // IE 8 doesn't work on object elements
847                         if ( nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
848                                 groups = tokenize( selector );
849
850                                 if ( (old = context.getAttribute("id")) ) {
851                                         nid = old.replace( rescape, "\\$&" );
852                                 } else {
853                                         context.setAttribute( "id", nid );
854                                 }
855                                 nid = "[id='" + nid + "'] ";
856
857                                 i = groups.length;
858                                 while ( i-- ) {
859                                         groups[i] = nid + toSelector( groups[i] );
860                                 }
861                                 newContext = rsibling.test( selector ) && testContext( context.parentNode ) || context;
862                                 newSelector = groups.join(",");
863                         }
864
865                         if ( newSelector ) {
866                                 try {
867                                         push.apply( results,
868                                                 newContext.querySelectorAll( newSelector )
869                                         );
870                                         return results;
871                                 } catch(qsaError) {
872                                 } finally {
873                                         if ( !old ) {
874                                                 context.removeAttribute("id");
875                                         }
876                                 }
877                         }
878                 }
879         }
880
881         // All others
882         return select( selector.replace( rtrim, "$1" ), context, results, seed );
883 }
884
885 /**
886  * Create key-value caches of limited size
887  * @returns {Function(string, Object)} Returns the Object data after storing it on itself with
888  *      property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
889  *      deleting the oldest entry
890  */
891 function createCache() {
892         var keys = [];
893
894         function cache( key, value ) {
895                 // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
896                 if ( keys.push( key + " " ) > Expr.cacheLength ) {
897                         // Only keep the most recent entries
898                         delete cache[ keys.shift() ];
899                 }
900                 return (cache[ key + " " ] = value);
901         }
902         return cache;
903 }
904
905 /**
906  * Mark a function for special use by Sizzle
907  * @param {Function} fn The function to mark
908  */
909 function markFunction( fn ) {
910         fn[ expando ] = true;
911         return fn;
912 }
913
914 /**
915  * Support testing using an element
916  * @param {Function} fn Passed the created div and expects a boolean result
917  */
918 function assert( fn ) {
919         var div = document.createElement("div");
920
921         try {
922                 return !!fn( div );
923         } catch (e) {
924                 return false;
925         } finally {
926                 // Remove from its parent by default
927                 if ( div.parentNode ) {
928                         div.parentNode.removeChild( div );
929                 }
930                 // release memory in IE
931                 div = null;
932         }
933 }
934
935 /**
936  * Adds the same handler for all of the specified attrs
937  * @param {String} attrs Pipe-separated list of attributes
938  * @param {Function} handler The method that will be applied
939  */
940 function addHandle( attrs, handler ) {
941         var arr = attrs.split("|"),
942                 i = attrs.length;
943
944         while ( i-- ) {
945                 Expr.attrHandle[ arr[i] ] = handler;
946         }
947 }
948
949 /**
950  * Checks document order of two siblings
951  * @param {Element} a
952  * @param {Element} b
953  * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
954  */
955 function siblingCheck( a, b ) {
956         var cur = b && a,
957                 diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
958                         ( ~b.sourceIndex || MAX_NEGATIVE ) -
959                         ( ~a.sourceIndex || MAX_NEGATIVE );
960
961         // Use IE sourceIndex if available on both nodes
962         if ( diff ) {
963                 return diff;
964         }
965
966         // Check if b follows a
967         if ( cur ) {
968                 while ( (cur = cur.nextSibling) ) {
969                         if ( cur === b ) {
970                                 return -1;
971                         }
972                 }
973         }
974
975         return a ? 1 : -1;
976 }
977
978 /**
979  * Returns a function to use in pseudos for input types
980  * @param {String} type
981  */
982 function createInputPseudo( type ) {
983         return function( elem ) {
984                 var name = elem.nodeName.toLowerCase();
985                 return name === "input" && elem.type === type;
986         };
987 }
988
989 /**
990  * Returns a function to use in pseudos for buttons
991  * @param {String} type
992  */
993 function createButtonPseudo( type ) {
994         return function( elem ) {
995                 var name = elem.nodeName.toLowerCase();
996                 return (name === "input" || name === "button") && elem.type === type;
997         };
998 }
999
1000 /**
1001  * Returns a function to use in pseudos for positionals
1002  * @param {Function} fn
1003  */
1004 function createPositionalPseudo( fn ) {
1005         return markFunction(function( argument ) {
1006                 argument = +argument;
1007                 return markFunction(function( seed, matches ) {
1008                         var j,
1009                                 matchIndexes = fn( [], seed.length, argument ),
1010                                 i = matchIndexes.length;
1011
1012                         // Match elements found at the specified indexes
1013                         while ( i-- ) {
1014                                 if ( seed[ (j = matchIndexes[i]) ] ) {
1015                                         seed[j] = !(matches[j] = seed[j]);
1016                                 }
1017                         }
1018                 });
1019         });
1020 }
1021
1022 /**
1023  * Checks a node for validity as a Sizzle context
1024  * @param {Element|Object=} context
1025  * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
1026  */
1027 function testContext( context ) {
1028         return context && typeof context.getElementsByTagName !== strundefined && context;
1029 }
1030
1031 // Expose support vars for convenience
1032 support = Sizzle.support = {};
1033
1034 /**
1035  * Detects XML nodes
1036  * @param {Element|Object} elem An element or a document
1037  * @returns {Boolean} True iff elem is a non-HTML XML node
1038  */
1039 isXML = Sizzle.isXML = function( elem ) {
1040         // documentElement is verified for cases where it doesn't yet exist
1041         // (such as loading iframes in IE - #4833)
1042         var documentElement = elem && (elem.ownerDocument || elem).documentElement;
1043         return documentElement ? documentElement.nodeName !== "HTML" : false;
1044 };
1045
1046 /**
1047  * Sets document-related variables once based on the current document
1048  * @param {Element|Object} [doc] An element or document object to use to set the document
1049  * @returns {Object} Returns the current document
1050  */
1051 setDocument = Sizzle.setDocument = function( node ) {
1052         var hasCompare,
1053                 doc = node ? node.ownerDocument || node : preferredDoc,
1054                 parent = doc.defaultView;
1055
1056         // If no document and documentElement is available, return
1057         if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
1058                 return document;
1059         }
1060
1061         // Set our document
1062         document = doc;
1063         docElem = doc.documentElement;
1064
1065         // Support tests
1066         documentIsHTML = !isXML( doc );
1067
1068         // Support: IE>8
1069         // If iframe document is assigned to "document" variable and if iframe has been reloaded,
1070         // IE will throw "permission denied" error when accessing "document" variable, see jQuery #13936
1071         // IE6-8 do not support the defaultView property so parent will be undefined
1072         if ( parent && parent !== parent.top ) {
1073                 // IE11 does not have attachEvent, so all must suffer
1074                 if ( parent.addEventListener ) {
1075                         parent.addEventListener( "unload", function() {
1076                                 setDocument();
1077                         }, false );
1078                 } else if ( parent.attachEvent ) {
1079                         parent.attachEvent( "onunload", function() {
1080                                 setDocument();
1081                         });
1082                 }
1083         }
1084
1085         /* Attributes
1086         ---------------------------------------------------------------------- */
1087
1088         // Support: IE<8
1089         // Verify that getAttribute really returns attributes and not properties (excepting IE8 booleans)
1090         support.attributes = assert(function( div ) {
1091                 div.className = "i";
1092                 return !div.getAttribute("className");
1093         });
1094
1095         /* getElement(s)By*
1096         ---------------------------------------------------------------------- */
1097
1098         // Check if getElementsByTagName("*") returns only elements
1099         support.getElementsByTagName = assert(function( div ) {
1100                 div.appendChild( doc.createComment("") );
1101                 return !div.getElementsByTagName("*").length;
1102         });
1103
1104         // Check if getElementsByClassName can be trusted
1105         support.getElementsByClassName = rnative.test( doc.getElementsByClassName ) && assert(function( div ) {
1106                 div.innerHTML = "<div class='a'></div><div class='a i'></div>";
1107
1108                 // Support: Safari<4
1109                 // Catch class over-caching
1110                 div.firstChild.className = "i";
1111                 // Support: Opera<10
1112                 // Catch gEBCN failure to find non-leading classes
1113                 return div.getElementsByClassName("i").length === 2;
1114         });
1115
1116         // Support: IE<10
1117         // Check if getElementById returns elements by name
1118         // The broken getElementById methods don't pick up programatically-set names,
1119         // so use a roundabout getElementsByName test
1120         support.getById = assert(function( div ) {
1121                 docElem.appendChild( div ).id = expando;
1122                 return !doc.getElementsByName || !doc.getElementsByName( expando ).length;
1123         });
1124
1125         // ID find and filter
1126         if ( support.getById ) {
1127                 Expr.find["ID"] = function( id, context ) {
1128                         if ( typeof context.getElementById !== strundefined && documentIsHTML ) {
1129                                 var m = context.getElementById( id );
1130                                 // Check parentNode to catch when Blackberry 4.6 returns
1131                                 // nodes that are no longer in the document #6963
1132                                 return m && m.parentNode ? [m] : [];
1133                         }
1134                 };
1135                 Expr.filter["ID"] = function( id ) {
1136                         var attrId = id.replace( runescape, funescape );
1137                         return function( elem ) {
1138                                 return elem.getAttribute("id") === attrId;
1139                         };
1140                 };
1141         } else {
1142                 // Support: IE6/7
1143                 // getElementById is not reliable as a find shortcut
1144                 delete Expr.find["ID"];
1145
1146                 Expr.filter["ID"] =  function( id ) {
1147                         var attrId = id.replace( runescape, funescape );
1148                         return function( elem ) {
1149                                 var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id");
1150                                 return node && node.value === attrId;
1151                         };
1152                 };
1153         }
1154
1155         // Tag
1156         Expr.find["TAG"] = support.getElementsByTagName ?
1157                 function( tag, context ) {
1158                         if ( typeof context.getElementsByTagName !== strundefined ) {
1159                                 return context.getElementsByTagName( tag );
1160                         }
1161                 } :
1162                 function( tag, context ) {
1163                         var elem,
1164                                 tmp = [],
1165                                 i = 0,
1166                                 results = context.getElementsByTagName( tag );
1167
1168                         // Filter out possible comments
1169                         if ( tag === "*" ) {
1170                                 while ( (elem = results[i++]) ) {
1171                                         if ( elem.nodeType === 1 ) {
1172                                                 tmp.push( elem );
1173                                         }
1174                                 }
1175
1176                                 return tmp;
1177                         }
1178                         return results;
1179                 };
1180
1181         // Class
1182         Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
1183                 if ( typeof context.getElementsByClassName !== strundefined && documentIsHTML ) {
1184                         return context.getElementsByClassName( className );
1185                 }
1186         };
1187
1188         /* QSA/matchesSelector
1189         ---------------------------------------------------------------------- */
1190
1191         // QSA and matchesSelector support
1192
1193         // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
1194         rbuggyMatches = [];
1195
1196         // qSa(:focus) reports false when true (Chrome 21)
1197         // We allow this because of a bug in IE8/9 that throws an error
1198         // whenever `document.activeElement` is accessed on an iframe
1199         // So, we allow :focus to pass through QSA all the time to avoid the IE error
1200         // See http://bugs.jquery.com/ticket/13378
1201         rbuggyQSA = [];
1202
1203         if ( (support.qsa = rnative.test( doc.querySelectorAll )) ) {
1204                 // Build QSA regex
1205                 // Regex strategy adopted from Diego Perini
1206                 assert(function( div ) {
1207                         // Select is set to empty string on purpose
1208                         // This is to test IE's treatment of not explicitly
1209                         // setting a boolean content attribute,
1210                         // since its presence should be enough
1211                         // http://bugs.jquery.com/ticket/12359
1212                         div.innerHTML = "<select t=''><option selected=''></option></select>";
1213
1214                         // Support: IE8, Opera 10-12
1215                         // Nothing should be selected when empty strings follow ^= or $= or *=
1216                         if ( div.querySelectorAll("[t^='']").length ) {
1217                                 rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
1218                         }
1219
1220                         // Support: IE8
1221                         // Boolean attributes and "value" are not treated correctly
1222                         if ( !div.querySelectorAll("[selected]").length ) {
1223                                 rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
1224                         }
1225
1226                         // Webkit/Opera - :checked should return selected option elements
1227                         // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
1228                         // IE8 throws error here and will not see later tests
1229                         if ( !div.querySelectorAll(":checked").length ) {
1230                                 rbuggyQSA.push(":checked");
1231                         }
1232                 });
1233
1234                 assert(function( div ) {
1235                         // Support: Windows 8 Native Apps
1236                         // The type and name attributes are restricted during .innerHTML assignment
1237                         var input = doc.createElement("input");
1238                         input.setAttribute( "type", "hidden" );
1239                         div.appendChild( input ).setAttribute( "name", "D" );
1240
1241                         // Support: IE8
1242                         // Enforce case-sensitivity of name attribute
1243                         if ( div.querySelectorAll("[name=d]").length ) {
1244                                 rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
1245                         }
1246
1247                         // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
1248                         // IE8 throws error here and will not see later tests
1249                         if ( !div.querySelectorAll(":enabled").length ) {
1250                                 rbuggyQSA.push( ":enabled", ":disabled" );
1251                         }
1252
1253                         // Opera 10-11 does not throw on post-comma invalid pseudos
1254                         div.querySelectorAll("*,:x");
1255                         rbuggyQSA.push(",.*:");
1256                 });
1257         }
1258
1259         if ( (support.matchesSelector = rnative.test( (matches = docElem.webkitMatchesSelector ||
1260                 docElem.mozMatchesSelector ||
1261                 docElem.oMatchesSelector ||
1262                 docElem.msMatchesSelector) )) ) {
1263
1264                 assert(function( div ) {
1265                         // Check to see if it's possible to do matchesSelector
1266                         // on a disconnected node (IE 9)
1267                         support.disconnectedMatch = matches.call( div, "div" );
1268
1269                         // This should fail with an exception
1270                         // Gecko does not error, returns false instead
1271                         matches.call( div, "[s!='']:x" );
1272                         rbuggyMatches.push( "!=", pseudos );
1273                 });
1274         }
1275
1276         rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
1277         rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
1278
1279         /* Contains
1280         ---------------------------------------------------------------------- */
1281         hasCompare = rnative.test( docElem.compareDocumentPosition );
1282
1283         // Element contains another
1284         // Purposefully does not implement inclusive descendent
1285         // As in, an element does not contain itself
1286         contains = hasCompare || rnative.test( docElem.contains ) ?
1287                 function( a, b ) {
1288                         var adown = a.nodeType === 9 ? a.documentElement : a,
1289                                 bup = b && b.parentNode;
1290                         return a === bup || !!( bup && bup.nodeType === 1 && (
1291                                 adown.contains ?
1292                                         adown.contains( bup ) :
1293                                         a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
1294                         ));
1295                 } :
1296                 function( a, b ) {
1297                         if ( b ) {
1298                                 while ( (b = b.parentNode) ) {
1299                                         if ( b === a ) {
1300                                                 return true;
1301                                         }
1302                                 }
1303                         }
1304                         return false;
1305                 };
1306
1307         /* Sorting
1308         ---------------------------------------------------------------------- */
1309
1310         // Document order sorting
1311         sortOrder = hasCompare ?
1312         function( a, b ) {
1313
1314                 // Flag for duplicate removal
1315                 if ( a === b ) {
1316                         hasDuplicate = true;
1317                         return 0;
1318                 }
1319
1320                 // Sort on method existence if only one input has compareDocumentPosition
1321                 var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
1322                 if ( compare ) {
1323                         return compare;
1324                 }
1325
1326                 // Calculate position if both inputs belong to the same document
1327                 compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
1328                         a.compareDocumentPosition( b ) :
1329
1330                         // Otherwise we know they are disconnected
1331                         1;
1332
1333                 // Disconnected nodes
1334                 if ( compare & 1 ||
1335                         (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
1336
1337                         // Choose the first element that is related to our preferred document
1338                         if ( a === doc || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
1339                                 return -1;
1340                         }
1341                         if ( b === doc || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
1342                                 return 1;
1343                         }
1344
1345                         // Maintain original order
1346                         return sortInput ?
1347                                 ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
1348                                 0;
1349                 }
1350
1351                 return compare & 4 ? -1 : 1;
1352         } :
1353         function( a, b ) {
1354                 // Exit early if the nodes are identical
1355                 if ( a === b ) {
1356                         hasDuplicate = true;
1357                         return 0;
1358                 }
1359
1360                 var cur,
1361                         i = 0,
1362                         aup = a.parentNode,
1363                         bup = b.parentNode,
1364                         ap = [ a ],
1365                         bp = [ b ];
1366
1367                 // Parentless nodes are either documents or disconnected
1368                 if ( !aup || !bup ) {
1369                         return a === doc ? -1 :
1370                                 b === doc ? 1 :
1371                                 aup ? -1 :
1372                                 bup ? 1 :
1373                                 sortInput ?
1374                                 ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
1375                                 0;
1376
1377                 // If the nodes are siblings, we can do a quick check
1378                 } else if ( aup === bup ) {
1379                         return siblingCheck( a, b );
1380                 }
1381
1382                 // Otherwise we need full lists of their ancestors for comparison
1383                 cur = a;
1384                 while ( (cur = cur.parentNode) ) {
1385                         ap.unshift( cur );
1386                 }
1387                 cur = b;
1388                 while ( (cur = cur.parentNode) ) {
1389                         bp.unshift( cur );
1390                 }
1391
1392                 // Walk down the tree looking for a discrepancy
1393                 while ( ap[i] === bp[i] ) {
1394                         i++;
1395                 }
1396
1397                 return i ?
1398                         // Do a sibling check if the nodes have a common ancestor
1399                         siblingCheck( ap[i], bp[i] ) :
1400
1401                         // Otherwise nodes in our document sort first
1402                         ap[i] === preferredDoc ? -1 :
1403                         bp[i] === preferredDoc ? 1 :
1404                         0;
1405         };
1406
1407         return doc;
1408 };
1409
1410 Sizzle.matches = function( expr, elements ) {
1411         return Sizzle( expr, null, null, elements );
1412 };
1413
1414 Sizzle.matchesSelector = function( elem, expr ) {
1415         // Set document vars if needed
1416         if ( ( elem.ownerDocument || elem ) !== document ) {
1417                 setDocument( elem );
1418         }
1419
1420         // Make sure that attribute selectors are quoted
1421         expr = expr.replace( rattributeQuotes, "='$1']" );
1422
1423         if ( support.matchesSelector && documentIsHTML &&
1424                 ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
1425                 ( !rbuggyQSA     || !rbuggyQSA.test( expr ) ) ) {
1426
1427                 try {
1428                         var ret = matches.call( elem, expr );
1429
1430                         // IE 9's matchesSelector returns false on disconnected nodes
1431                         if ( ret || support.disconnectedMatch ||
1432                                         // As well, disconnected nodes are said to be in a document
1433                                         // fragment in IE 9
1434                                         elem.document && elem.document.nodeType !== 11 ) {
1435                                 return ret;
1436                         }
1437                 } catch(e) {}
1438         }
1439
1440         return Sizzle( expr, document, null, [elem] ).length > 0;
1441 };
1442
1443 Sizzle.contains = function( context, elem ) {
1444         // Set document vars if needed
1445         if ( ( context.ownerDocument || context ) !== document ) {
1446                 setDocument( context );
1447         }
1448         return contains( context, elem );
1449 };
1450
1451 Sizzle.attr = function( elem, name ) {
1452         // Set document vars if needed
1453         if ( ( elem.ownerDocument || elem ) !== document ) {
1454                 setDocument( elem );
1455         }
1456
1457         var fn = Expr.attrHandle[ name.toLowerCase() ],
1458                 // Don't get fooled by Object.prototype properties (jQuery #13807)
1459                 val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
1460                         fn( elem, name, !documentIsHTML ) :
1461                         undefined;
1462
1463         return val !== undefined ?
1464                 val :
1465                 support.attributes || !documentIsHTML ?
1466                         elem.getAttribute( name ) :
1467                         (val = elem.getAttributeNode(name)) && val.specified ?
1468                                 val.value :
1469                                 null;
1470 };
1471
1472 Sizzle.error = function( msg ) {
1473         throw new Error( "Syntax error, unrecognized expression: " + msg );
1474 };
1475
1476 /**
1477  * Document sorting and removing duplicates
1478  * @param {ArrayLike} results
1479  */
1480 Sizzle.uniqueSort = function( results ) {
1481         var elem,
1482                 duplicates = [],
1483                 j = 0,
1484                 i = 0;
1485
1486         // Unless we *know* we can detect duplicates, assume their presence
1487         hasDuplicate = !support.detectDuplicates;
1488         sortInput = !support.sortStable && results.slice( 0 );
1489         results.sort( sortOrder );
1490
1491         if ( hasDuplicate ) {
1492                 while ( (elem = results[i++]) ) {
1493                         if ( elem === results[ i ] ) {
1494                                 j = duplicates.push( i );
1495                         }
1496                 }
1497                 while ( j-- ) {
1498                         results.splice( duplicates[ j ], 1 );
1499                 }
1500         }
1501
1502         // Clear input after sorting to release objects
1503         // See https://github.com/jquery/sizzle/pull/225
1504         sortInput = null;
1505
1506         return results;
1507 };
1508
1509 /**
1510  * Utility function for retrieving the text value of an array of DOM nodes
1511  * @param {Array|Element} elem
1512  */
1513 getText = Sizzle.getText = function( elem ) {
1514         var node,
1515                 ret = "",
1516                 i = 0,
1517                 nodeType = elem.nodeType;
1518
1519         if ( !nodeType ) {
1520                 // If no nodeType, this is expected to be an array
1521                 while ( (node = elem[i++]) ) {
1522                         // Do not traverse comment nodes
1523                         ret += getText( node );
1524                 }
1525         } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
1526                 // Use textContent for elements
1527                 // innerText usage removed for consistency of new lines (jQuery #11153)
1528                 if ( typeof elem.textContent === "string" ) {
1529                         return elem.textContent;
1530                 } else {
1531                         // Traverse its children
1532                         for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
1533                                 ret += getText( elem );
1534                         }
1535                 }
1536         } else if ( nodeType === 3 || nodeType === 4 ) {
1537                 return elem.nodeValue;
1538         }
1539         // Do not include comment or processing instruction nodes
1540
1541         return ret;
1542 };
1543
1544 Expr = Sizzle.selectors = {
1545
1546         // Can be adjusted by the user
1547         cacheLength: 50,
1548
1549         createPseudo: markFunction,
1550
1551         match: matchExpr,
1552
1553         attrHandle: {},
1554
1555         find: {},
1556
1557         relative: {
1558                 ">": { dir: "parentNode", first: true },
1559                 " ": { dir: "parentNode" },
1560                 "+": { dir: "previousSibling", first: true },
1561                 "~": { dir: "previousSibling" }
1562         },
1563
1564         preFilter: {
1565                 "ATTR": function( match ) {
1566                         match[1] = match[1].replace( runescape, funescape );
1567
1568                         // Move the given value to match[3] whether quoted or unquoted
1569                         match[3] = ( match[4] || match[5] || "" ).replace( runescape, funescape );
1570
1571                         if ( match[2] === "~=" ) {
1572                                 match[3] = " " + match[3] + " ";
1573                         }
1574
1575                         return match.slice( 0, 4 );
1576                 },
1577
1578                 "CHILD": function( match ) {
1579                         /* matches from matchExpr["CHILD"]
1580                                 1 type (only|nth|...)
1581                                 2 what (child|of-type)
1582                                 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
1583                                 4 xn-component of xn+y argument ([+-]?\d*n|)
1584                                 5 sign of xn-component
1585                                 6 x of xn-component
1586                                 7 sign of y-component
1587                                 8 y of y-component
1588                         */
1589                         match[1] = match[1].toLowerCase();
1590
1591                         if ( match[1].slice( 0, 3 ) === "nth" ) {
1592                                 // nth-* requires argument
1593                                 if ( !match[3] ) {
1594                                         Sizzle.error( match[0] );
1595                                 }
1596
1597                                 // numeric x and y parameters for Expr.filter.CHILD
1598                                 // remember that false/true cast respectively to 0/1
1599                                 match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
1600                                 match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
1601
1602                         // other types prohibit arguments
1603                         } else if ( match[3] ) {
1604                                 Sizzle.error( match[0] );
1605                         }
1606
1607                         return match;
1608                 },
1609
1610                 "PSEUDO": function( match ) {
1611                         var excess,
1612                                 unquoted = !match[5] && match[2];
1613
1614                         if ( matchExpr["CHILD"].test( match[0] ) ) {
1615                                 return null;
1616                         }
1617
1618                         // Accept quoted arguments as-is
1619                         if ( match[3] && match[4] !== undefined ) {
1620                                 match[2] = match[4];
1621
1622                         // Strip excess characters from unquoted arguments
1623                         } else if ( unquoted && rpseudo.test( unquoted ) &&
1624                                 // Get excess from tokenize (recursively)
1625                                 (excess = tokenize( unquoted, true )) &&
1626                                 // advance to the next closing parenthesis
1627                                 (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
1628
1629                                 // excess is a negative index
1630                                 match[0] = match[0].slice( 0, excess );
1631                                 match[2] = unquoted.slice( 0, excess );
1632                         }
1633
1634                         // Return only captures needed by the pseudo filter method (type and argument)
1635                         return match.slice( 0, 3 );
1636                 }
1637         },
1638
1639         filter: {
1640
1641                 "TAG": function( nodeNameSelector ) {
1642                         var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
1643                         return nodeNameSelector === "*" ?
1644                                 function() { return true; } :
1645                                 function( elem ) {
1646                                         return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
1647                                 };
1648                 },
1649
1650                 "CLASS": function( className ) {
1651                         var pattern = classCache[ className + " " ];
1652
1653                         return pattern ||
1654                                 (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
1655                                 classCache( className, function( elem ) {
1656                                         return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== strundefined && elem.getAttribute("class") || "" );
1657                                 });
1658                 },
1659
1660                 "ATTR": function( name, operator, check ) {
1661                         return function( elem ) {
1662                                 var result = Sizzle.attr( elem, name );
1663
1664                                 if ( result == null ) {
1665                                         return operator === "!=";
1666                                 }
1667                                 if ( !operator ) {
1668                                         return true;
1669                                 }
1670
1671                                 result += "";
1672
1673                                 return operator === "=" ? result === check :
1674                                         operator === "!=" ? result !== check :
1675                                         operator === "^=" ? check && result.indexOf( check ) === 0 :
1676                                         operator === "*=" ? check && result.indexOf( check ) > -1 :
1677                                         operator === "$=" ? check && result.slice( -check.length ) === check :
1678                                         operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 :
1679                                         operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
1680                                         false;
1681                         };
1682                 },
1683
1684                 "CHILD": function( type, what, argument, first, last ) {
1685                         var simple = type.slice( 0, 3 ) !== "nth",
1686                                 forward = type.slice( -4 ) !== "last",
1687                                 ofType = what === "of-type";
1688
1689                         return first === 1 && last === 0 ?
1690
1691                                 // Shortcut for :nth-*(n)
1692                                 function( elem ) {
1693                                         return !!elem.parentNode;
1694                                 } :
1695
1696                                 function( elem, context, xml ) {
1697                                         var cache, outerCache, node, diff, nodeIndex, start,
1698                                                 dir = simple !== forward ? "nextSibling" : "previousSibling",
1699                                                 parent = elem.parentNode,
1700                                                 name = ofType && elem.nodeName.toLowerCase(),
1701                                                 useCache = !xml && !ofType;
1702
1703                                         if ( parent ) {
1704
1705                                                 // :(first|last|only)-(child|of-type)
1706                                                 if ( simple ) {
1707                                                         while ( dir ) {
1708                                                                 node = elem;
1709                                                                 while ( (node = node[ dir ]) ) {
1710                                                                         if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) {
1711                                                                                 return false;
1712                                                                         }
1713                                                                 }
1714                                                                 // Reverse direction for :only-* (if we haven't yet done so)
1715                                                                 start = dir = type === "only" && !start && "nextSibling";
1716                                                         }
1717                                                         return true;
1718                                                 }
1719
1720                                                 start = [ forward ? parent.firstChild : parent.lastChild ];
1721
1722                                                 // non-xml :nth-child(...) stores cache data on `parent`
1723                                                 if ( forward && useCache ) {
1724                                                         // Seek `elem` from a previously-cached index
1725                                                         outerCache = parent[ expando ] || (parent[ expando ] = {});
1726                                                         cache = outerCache[ type ] || [];
1727                                                         nodeIndex = cache[0] === dirruns && cache[1];
1728                                                         diff = cache[0] === dirruns && cache[2];
1729                                                         node = nodeIndex && parent.childNodes[ nodeIndex ];
1730
1731                                                         while ( (node = ++nodeIndex && node && node[ dir ] ||
1732
1733                                                                 // Fallback to seeking `elem` from the start
1734                                                                 (diff = nodeIndex = 0) || start.pop()) ) {
1735
1736                                                                 // When found, cache indexes on `parent` and break
1737                                                                 if ( node.nodeType === 1 && ++diff && node === elem ) {
1738                                                                         outerCache[ type ] = [ dirruns, nodeIndex, diff ];
1739                                                                         break;
1740                                                                 }
1741                                                         }
1742
1743                                                 // Use previously-cached element index if available
1744                                                 } else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) {
1745                                                         diff = cache[1];
1746
1747                                                 // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...)
1748                                                 } else {
1749                                                         // Use the same loop as above to seek `elem` from the start
1750                                                         while ( (node = ++nodeIndex && node && node[ dir ] ||
1751                                                                 (diff = nodeIndex = 0) || start.pop()) ) {
1752
1753                                                                 if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) {
1754                                                                         // Cache the index of each encountered element
1755                                                                         if ( useCache ) {
1756                                                                                 (node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ];
1757                                                                         }
1758
1759                                                                         if ( node === elem ) {
1760                                                                                 break;
1761                                                                         }
1762                                                                 }
1763                                                         }
1764                                                 }
1765
1766                                                 // Incorporate the offset, then check against cycle size
1767                                                 diff -= last;
1768                                                 return diff === first || ( diff % first === 0 && diff / first >= 0 );
1769                                         }
1770                                 };
1771                 },
1772
1773                 "PSEUDO": function( pseudo, argument ) {
1774                         // pseudo-class names are case-insensitive
1775                         // http://www.w3.org/TR/selectors/#pseudo-classes
1776                         // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
1777                         // Remember that setFilters inherits from pseudos
1778                         var args,
1779                                 fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
1780                                         Sizzle.error( "unsupported pseudo: " + pseudo );
1781
1782                         // The user may use createPseudo to indicate that
1783                         // arguments are needed to create the filter function
1784                         // just as Sizzle does
1785                         if ( fn[ expando ] ) {
1786                                 return fn( argument );
1787                         }
1788
1789                         // But maintain support for old signatures
1790                         if ( fn.length > 1 ) {
1791                                 args = [ pseudo, pseudo, "", argument ];
1792                                 return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
1793                                         markFunction(function( seed, matches ) {
1794                                                 var idx,
1795                                                         matched = fn( seed, argument ),
1796                                                         i = matched.length;
1797                                                 while ( i-- ) {
1798                                                         idx = indexOf.call( seed, matched[i] );
1799                                                         seed[ idx ] = !( matches[ idx ] = matched[i] );
1800                                                 }
1801                                         }) :
1802                                         function( elem ) {
1803                                                 return fn( elem, 0, args );
1804                                         };
1805                         }
1806
1807                         return fn;
1808                 }
1809         },
1810
1811         pseudos: {
1812                 // Potentially complex pseudos
1813                 "not": markFunction(function( selector ) {
1814                         // Trim the selector passed to compile
1815                         // to avoid treating leading and trailing
1816                         // spaces as combinators
1817                         var input = [],
1818                                 results = [],
1819                                 matcher = compile( selector.replace( rtrim, "$1" ) );
1820
1821                         return matcher[ expando ] ?
1822                                 markFunction(function( seed, matches, context, xml ) {
1823                                         var elem,
1824                                                 unmatched = matcher( seed, null, xml, [] ),
1825                                                 i = seed.length;
1826
1827                                         // Match elements unmatched by `matcher`
1828                                         while ( i-- ) {
1829                                                 if ( (elem = unmatched[i]) ) {
1830                                                         seed[i] = !(matches[i] = elem);
1831                                                 }
1832                                         }
1833                                 }) :
1834                                 function( elem, context, xml ) {
1835                                         input[0] = elem;
1836                                         matcher( input, null, xml, results );
1837                                         return !results.pop();
1838                                 };
1839                 }),
1840
1841                 "has": markFunction(function( selector ) {
1842                         return function( elem ) {
1843                                 return Sizzle( selector, elem ).length > 0;
1844                         };
1845                 }),
1846
1847                 "contains": markFunction(function( text ) {
1848                         return function( elem ) {
1849                                 return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
1850                         };
1851                 }),
1852
1853                 // "Whether an element is represented by a :lang() selector
1854                 // is based solely on the element's language value
1855                 // being equal to the identifier C,
1856                 // or beginning with the identifier C immediately followed by "-".
1857                 // The matching of C against the element's language value is performed case-insensitively.
1858                 // The identifier C does not have to be a valid language name."
1859                 // http://www.w3.org/TR/selectors/#lang-pseudo
1860                 "lang": markFunction( function( lang ) {
1861                         // lang value must be a valid identifier
1862                         if ( !ridentifier.test(lang || "") ) {
1863                                 Sizzle.error( "unsupported lang: " + lang );
1864                         }
1865                         lang = lang.replace( runescape, funescape ).toLowerCase();
1866                         return function( elem ) {
1867                                 var elemLang;
1868                                 do {
1869                                         if ( (elemLang = documentIsHTML ?
1870                                                 elem.lang :
1871                                                 elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
1872
1873                                                 elemLang = elemLang.toLowerCase();
1874                                                 return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
1875                                         }
1876                                 } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
1877                                 return false;
1878                         };
1879                 }),
1880
1881                 // Miscellaneous
1882                 "target": function( elem ) {
1883                         var hash = window.location && window.location.hash;
1884                         return hash && hash.slice( 1 ) === elem.id;
1885                 },
1886
1887                 "root": function( elem ) {
1888                         return elem === docElem;
1889                 },
1890
1891                 "focus": function( elem ) {
1892                         return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
1893                 },
1894
1895                 // Boolean properties
1896                 "enabled": function( elem ) {
1897                         return elem.disabled === false;
1898                 },
1899
1900                 "disabled": function( elem ) {
1901                         return elem.disabled === true;
1902                 },
1903
1904                 "checked": function( elem ) {
1905                         // In CSS3, :checked should return both checked and selected elements
1906                         // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
1907                         var nodeName = elem.nodeName.toLowerCase();
1908                         return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
1909                 },
1910
1911                 "selected": function( elem ) {
1912                         // Accessing this property makes selected-by-default
1913                         // options in Safari work properly
1914                         if ( elem.parentNode ) {
1915                                 elem.parentNode.selectedIndex;
1916                         }
1917
1918                         return elem.selected === true;
1919                 },
1920
1921                 // Contents
1922                 "empty": function( elem ) {
1923                         // http://www.w3.org/TR/selectors/#empty-pseudo
1924                         // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
1925                         //   but not by others (comment: 8; processing instruction: 7; etc.)
1926                         // nodeType < 6 works because attributes (2) do not appear as children
1927                         for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
1928                                 if ( elem.nodeType < 6 ) {
1929                                         return false;
1930                                 }
1931                         }
1932                         return true;
1933                 },
1934
1935                 "parent": function( elem ) {
1936                         return !Expr.pseudos["empty"]( elem );
1937                 },
1938
1939                 // Element/input types
1940                 "header": function( elem ) {
1941                         return rheader.test( elem.nodeName );
1942                 },
1943
1944                 "input": function( elem ) {
1945                         return rinputs.test( elem.nodeName );
1946                 },
1947
1948                 "button": function( elem ) {
1949                         var name = elem.nodeName.toLowerCase();
1950                         return name === "input" && elem.type === "button" || name === "button";
1951                 },
1952
1953                 "text": function( elem ) {
1954                         var attr;
1955                         return elem.nodeName.toLowerCase() === "input" &&
1956                                 elem.type === "text" &&
1957
1958                                 // Support: IE<8
1959                                 // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
1960                                 ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
1961                 },
1962
1963                 // Position-in-collection
1964                 "first": createPositionalPseudo(function() {
1965                         return [ 0 ];
1966                 }),
1967
1968                 "last": createPositionalPseudo(function( matchIndexes, length ) {
1969                         return [ length - 1 ];
1970                 }),
1971
1972                 "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
1973                         return [ argument < 0 ? argument + length : argument ];
1974                 }),
1975
1976                 "even": createPositionalPseudo(function( matchIndexes, length ) {
1977                         var i = 0;
1978                         for ( ; i < length; i += 2 ) {
1979                                 matchIndexes.push( i );
1980                         }
1981                         return matchIndexes;
1982                 }),
1983
1984                 "odd": createPositionalPseudo(function( matchIndexes, length ) {
1985                         var i = 1;
1986                         for ( ; i < length; i += 2 ) {
1987                                 matchIndexes.push( i );
1988                         }
1989                         return matchIndexes;
1990                 }),
1991
1992                 "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
1993                         var i = argument < 0 ? argument + length : argument;
1994                         for ( ; --i >= 0; ) {
1995                                 matchIndexes.push( i );
1996                         }
1997                         return matchIndexes;
1998                 }),
1999
2000                 "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
2001                         var i = argument < 0 ? argument + length : argument;
2002                         for ( ; ++i < length; ) {
2003                                 matchIndexes.push( i );
2004                         }
2005                         return matchIndexes;
2006                 })
2007         }
2008 };
2009
2010 Expr.pseudos["nth"] = Expr.pseudos["eq"];
2011
2012 // Add button/input type pseudos
2013 for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
2014         Expr.pseudos[ i ] = createInputPseudo( i );
2015 }
2016 for ( i in { submit: true, reset: true } ) {
2017         Expr.pseudos[ i ] = createButtonPseudo( i );
2018 }
2019
2020 // Easy API for creating new setFilters
2021 function setFilters() {}
2022 setFilters.prototype = Expr.filters = Expr.pseudos;
2023 Expr.setFilters = new setFilters();
2024
2025 function tokenize( selector, parseOnly ) {
2026         var matched, match, tokens, type,
2027                 soFar, groups, preFilters,
2028                 cached = tokenCache[ selector + " " ];
2029
2030         if ( cached ) {
2031                 return parseOnly ? 0 : cached.slice( 0 );
2032         }
2033
2034         soFar = selector;
2035         groups = [];
2036         preFilters = Expr.preFilter;
2037
2038         while ( soFar ) {
2039
2040                 // Comma and first run
2041                 if ( !matched || (match = rcomma.exec( soFar )) ) {
2042                         if ( match ) {
2043                                 // Don't consume trailing commas as valid
2044                                 soFar = soFar.slice( match[0].length ) || soFar;
2045                         }
2046                         groups.push( (tokens = []) );
2047                 }
2048
2049                 matched = false;
2050
2051                 // Combinators
2052                 if ( (match = rcombinators.exec( soFar )) ) {
2053                         matched = match.shift();
2054                         tokens.push({
2055                                 value: matched,
2056                                 // Cast descendant combinators to space
2057                                 type: match[0].replace( rtrim, " " )
2058                         });
2059                         soFar = soFar.slice( matched.length );
2060                 }
2061
2062                 // Filters
2063                 for ( type in Expr.filter ) {
2064                         if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
2065                                 (match = preFilters[ type ]( match ))) ) {
2066                                 matched = match.shift();
2067                                 tokens.push({
2068                                         value: matched,
2069                                         type: type,
2070                                         matches: match
2071                                 });
2072                                 soFar = soFar.slice( matched.length );
2073                         }
2074                 }
2075
2076                 if ( !matched ) {
2077                         break;
2078                 }
2079         }
2080
2081         // Return the length of the invalid excess
2082         // if we're just parsing
2083         // Otherwise, throw an error or return tokens
2084         return parseOnly ?
2085                 soFar.length :
2086                 soFar ?
2087                         Sizzle.error( selector ) :
2088                         // Cache the tokens
2089                         tokenCache( selector, groups ).slice( 0 );
2090 }
2091
2092 function toSelector( tokens ) {
2093         var i = 0,
2094                 len = tokens.length,
2095                 selector = "";
2096         for ( ; i < len; i++ ) {
2097                 selector += tokens[i].value;
2098         }
2099         return selector;
2100 }
2101
2102 function addCombinator( matcher, combinator, base ) {
2103         var dir = combinator.dir,
2104                 checkNonElements = base && dir === "parentNode",
2105                 doneName = done++;
2106
2107         return combinator.first ?
2108                 // Check against closest ancestor/preceding element
2109                 function( elem, context, xml ) {
2110                         while ( (elem = elem[ dir ]) ) {
2111                                 if ( elem.nodeType === 1 || checkNonElements ) {
2112                                         return matcher( elem, context, xml );
2113                                 }
2114                         }
2115                 } :
2116
2117                 // Check against all ancestor/preceding elements
2118                 function( elem, context, xml ) {
2119                         var oldCache, outerCache,
2120                                 newCache = [ dirruns, doneName ];
2121
2122                         // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching
2123                         if ( xml ) {
2124                                 while ( (elem = elem[ dir ]) ) {
2125                                         if ( elem.nodeType === 1 || checkNonElements ) {
2126                                                 if ( matcher( elem, context, xml ) ) {
2127                                                         return true;
2128                                                 }
2129                                         }
2130                                 }
2131                         } else {
2132                                 while ( (elem = elem[ dir ]) ) {
2133                                         if ( elem.nodeType === 1 || checkNonElements ) {
2134                                                 outerCache = elem[ expando ] || (elem[ expando ] = {});
2135                                                 if ( (oldCache = outerCache[ dir ]) &&
2136                                                         oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
2137
2138                                                         // Assign to newCache so results back-propagate to previous elements
2139                                                         return (newCache[ 2 ] = oldCache[ 2 ]);
2140                                                 } else {
2141                                                         // Reuse newcache so results back-propagate to previous elements
2142                                                         outerCache[ dir ] = newCache;
2143
2144                                                         // A match means we're done; a fail means we have to keep checking
2145                                                         if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
2146                                                                 return true;
2147                                                         }
2148                                                 }
2149                                         }
2150                                 }
2151                         }
2152                 };
2153 }
2154
2155 function elementMatcher( matchers ) {
2156         return matchers.length > 1 ?
2157                 function( elem, context, xml ) {
2158                         var i = matchers.length;
2159                         while ( i-- ) {
2160                                 if ( !matchers[i]( elem, context, xml ) ) {
2161                                         return false;
2162                                 }
2163                         }
2164                         return true;
2165                 } :
2166                 matchers[0];
2167 }
2168
2169 function condense( unmatched, map, filter, context, xml ) {
2170         var elem,
2171                 newUnmatched = [],
2172                 i = 0,
2173                 len = unmatched.length,
2174                 mapped = map != null;
2175
2176         for ( ; i < len; i++ ) {
2177                 if ( (elem = unmatched[i]) ) {
2178                         if ( !filter || filter( elem, context, xml ) ) {
2179                                 newUnmatched.push( elem );
2180                                 if ( mapped ) {
2181                                         map.push( i );
2182                                 }
2183                         }
2184                 }
2185         }
2186
2187         return newUnmatched;
2188 }
2189
2190 function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
2191         if ( postFilter && !postFilter[ expando ] ) {
2192                 postFilter = setMatcher( postFilter );
2193         }
2194         if ( postFinder && !postFinder[ expando ] ) {
2195                 postFinder = setMatcher( postFinder, postSelector );
2196         }
2197         return markFunction(function( seed, results, context, xml ) {
2198                 var temp, i, elem,
2199                         preMap = [],
2200                         postMap = [],
2201                         preexisting = results.length,
2202
2203                         // Get initial elements from seed or context
2204                         elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
2205
2206                         // Prefilter to get matcher input, preserving a map for seed-results synchronization
2207                         matcherIn = preFilter && ( seed || !selector ) ?
2208                                 condense( elems, preMap, preFilter, context, xml ) :
2209                                 elems,
2210
2211                         matcherOut = matcher ?
2212                                 // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
2213                                 postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
2214
2215                                         // ...intermediate processing is necessary
2216                                         [] :
2217
2218                                         // ...otherwise use results directly
2219                                         results :
2220                                 matcherIn;
2221
2222                 // Find primary matches
2223                 if ( matcher ) {
2224                         matcher( matcherIn, matcherOut, context, xml );
2225                 }
2226
2227                 // Apply postFilter
2228                 if ( postFilter ) {
2229                         temp = condense( matcherOut, postMap );
2230                         postFilter( temp, [], context, xml );
2231
2232                         // Un-match failing elements by moving them back to matcherIn
2233                         i = temp.length;
2234                         while ( i-- ) {
2235                                 if ( (elem = temp[i]) ) {
2236                                         matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
2237                                 }
2238                         }
2239                 }
2240
2241                 if ( seed ) {
2242                         if ( postFinder || preFilter ) {
2243                                 if ( postFinder ) {
2244                                         // Get the final matcherOut by condensing this intermediate into postFinder contexts
2245                                         temp = [];
2246                                         i = matcherOut.length;
2247                                         while ( i-- ) {
2248                                                 if ( (elem = matcherOut[i]) ) {
2249                                                         // Restore matcherIn since elem is not yet a final match
2250                                                         temp.push( (matcherIn[i] = elem) );
2251                                                 }
2252                                         }
2253                                         postFinder( null, (matcherOut = []), temp, xml );
2254                                 }
2255
2256                                 // Move matched elements from seed to results to keep them synchronized
2257                                 i = matcherOut.length;
2258                                 while ( i-- ) {
2259                                         if ( (elem = matcherOut[i]) &&
2260                                                 (temp = postFinder ? indexOf.call( seed, elem ) : preMap[i]) > -1 ) {
2261
2262                                                 seed[temp] = !(results[temp] = elem);
2263                                         }
2264                                 }
2265                         }
2266
2267                 // Add elements to results, through postFinder if defined
2268                 } else {
2269                         matcherOut = condense(
2270                                 matcherOut === results ?
2271                                         matcherOut.splice( preexisting, matcherOut.length ) :
2272                                         matcherOut
2273                         );
2274                         if ( postFinder ) {
2275                                 postFinder( null, results, matcherOut, xml );
2276                         } else {
2277                                 push.apply( results, matcherOut );
2278                         }
2279                 }
2280         });
2281 }
2282
2283 function matcherFromTokens( tokens ) {
2284         var checkContext, matcher, j,
2285                 len = tokens.length,
2286                 leadingRelative = Expr.relative[ tokens[0].type ],
2287                 implicitRelative = leadingRelative || Expr.relative[" "],
2288                 i = leadingRelative ? 1 : 0,
2289
2290                 // The foundational matcher ensures that elements are reachable from top-level context(s)
2291                 matchContext = addCombinator( function( elem ) {
2292                         return elem === checkContext;
2293                 }, implicitRelative, true ),
2294                 matchAnyContext = addCombinator( function( elem ) {
2295                         return indexOf.call( checkContext, elem ) > -1;
2296                 }, implicitRelative, true ),
2297                 matchers = [ function( elem, context, xml ) {
2298                         return ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
2299                                 (checkContext = context).nodeType ?
2300                                         matchContext( elem, context, xml ) :
2301                                         matchAnyContext( elem, context, xml ) );
2302                 } ];
2303
2304         for ( ; i < len; i++ ) {
2305                 if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
2306                         matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
2307                 } else {
2308                         matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
2309
2310                         // Return special upon seeing a positional matcher
2311                         if ( matcher[ expando ] ) {
2312                                 // Find the next relative operator (if any) for proper handling
2313                                 j = ++i;
2314                                 for ( ; j < len; j++ ) {
2315                                         if ( Expr.relative[ tokens[j].type ] ) {
2316                                                 break;
2317                                         }
2318                                 }
2319                                 return setMatcher(
2320                                         i > 1 && elementMatcher( matchers ),
2321                                         i > 1 && toSelector(
2322                                                 // If the preceding token was a descendant combinator, insert an implicit any-element `*`
2323                                                 tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
2324                                         ).replace( rtrim, "$1" ),
2325                                         matcher,
2326                                         i < j && matcherFromTokens( tokens.slice( i, j ) ),
2327                                         j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
2328                                         j < len && toSelector( tokens )
2329                                 );
2330                         }
2331                         matchers.push( matcher );
2332                 }
2333         }
2334
2335         return elementMatcher( matchers );
2336 }
2337
2338 function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
2339         var bySet = setMatchers.length > 0,
2340                 byElement = elementMatchers.length > 0,
2341                 superMatcher = function( seed, context, xml, results, outermost ) {
2342                         var elem, j, matcher,
2343                                 matchedCount = 0,
2344                                 i = "0",
2345                                 unmatched = seed && [],
2346                                 setMatched = [],
2347                                 contextBackup = outermostContext,
2348                                 // We must always have either seed elements or outermost context
2349                                 elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
2350                                 // Use integer dirruns iff this is the outermost matcher
2351                                 dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
2352                                 len = elems.length;
2353
2354                         if ( outermost ) {
2355                                 outermostContext = context !== document && context;
2356                         }
2357
2358                         // Add elements passing elementMatchers directly to results
2359                         // Keep `i` a string if there are no elements so `matchedCount` will be "00" below
2360                         // Support: IE<9, Safari
2361                         // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
2362                         for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
2363                                 if ( byElement && elem ) {
2364                                         j = 0;
2365                                         while ( (matcher = elementMatchers[j++]) ) {
2366                                                 if ( matcher( elem, context, xml ) ) {
2367                                                         results.push( elem );
2368                                                         break;
2369                                                 }
2370                                         }
2371                                         if ( outermost ) {
2372                                                 dirruns = dirrunsUnique;
2373                                         }
2374                                 }
2375
2376                                 // Track unmatched elements for set filters
2377                                 if ( bySet ) {
2378                                         // They will have gone through all possible matchers
2379                                         if ( (elem = !matcher && elem) ) {
2380                                                 matchedCount--;
2381                                         }
2382
2383                                         // Lengthen the array for every element, matched or not
2384                                         if ( seed ) {
2385                                                 unmatched.push( elem );
2386                                         }
2387                                 }
2388                         }
2389
2390                         // Apply set filters to unmatched elements
2391                         matchedCount += i;
2392                         if ( bySet && i !== matchedCount ) {
2393                                 j = 0;
2394                                 while ( (matcher = setMatchers[j++]) ) {
2395                                         matcher( unmatched, setMatched, context, xml );
2396                                 }
2397
2398                                 if ( seed ) {
2399                                         // Reintegrate element matches to eliminate the need for sorting
2400                                         if ( matchedCount > 0 ) {
2401                                                 while ( i-- ) {
2402                                                         if ( !(unmatched[i] || setMatched[i]) ) {
2403                                                                 setMatched[i] = pop.call( results );
2404                                                         }
2405                                                 }
2406                                         }
2407
2408                                         // Discard index placeholder values to get only actual matches
2409                                         setMatched = condense( setMatched );
2410                                 }
2411
2412                                 // Add matches to results
2413                                 push.apply( results, setMatched );
2414
2415                                 // Seedless set matches succeeding multiple successful matchers stipulate sorting
2416                                 if ( outermost && !seed && setMatched.length > 0 &&
2417                                         ( matchedCount + setMatchers.length ) > 1 ) {
2418
2419                                         Sizzle.uniqueSort( results );
2420                                 }
2421                         }
2422
2423                         // Override manipulation of globals by nested matchers
2424                         if ( outermost ) {
2425                                 dirruns = dirrunsUnique;
2426                                 outermostContext = contextBackup;
2427                         }
2428
2429                         return unmatched;
2430                 };
2431
2432         return bySet ?
2433                 markFunction( superMatcher ) :
2434                 superMatcher;
2435 }
2436
2437 compile = Sizzle.compile = function( selector, group /* Internal Use Only */ ) {
2438         var i,
2439                 setMatchers = [],
2440                 elementMatchers = [],
2441                 cached = compilerCache[ selector + " " ];
2442
2443         if ( !cached ) {
2444                 // Generate a function of recursive functions that can be used to check each element
2445                 if ( !group ) {
2446                         group = tokenize( selector );
2447                 }
2448                 i = group.length;
2449                 while ( i-- ) {
2450                         cached = matcherFromTokens( group[i] );
2451                         if ( cached[ expando ] ) {
2452                                 setMatchers.push( cached );
2453                         } else {
2454                                 elementMatchers.push( cached );
2455                         }
2456                 }
2457
2458                 // Cache the compiled function
2459                 cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
2460         }
2461         return cached;
2462 };
2463
2464 function multipleContexts( selector, contexts, results ) {
2465         var i = 0,
2466                 len = contexts.length;
2467         for ( ; i < len; i++ ) {
2468                 Sizzle( selector, contexts[i], results );
2469         }
2470         return results;
2471 }
2472
2473 function select( selector, context, results, seed ) {
2474         var i, tokens, token, type, find,
2475                 match = tokenize( selector );
2476
2477         if ( !seed ) {
2478                 // Try to minimize operations if there is only one group
2479                 if ( match.length === 1 ) {
2480
2481                         // Take a shortcut and set the context if the root selector is an ID
2482                         tokens = match[0] = match[0].slice( 0 );
2483                         if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
2484                                         support.getById && context.nodeType === 9 && documentIsHTML &&
2485                                         Expr.relative[ tokens[1].type ] ) {
2486
2487                                 context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
2488                                 if ( !context ) {
2489                                         return results;
2490                                 }
2491                                 selector = selector.slice( tokens.shift().value.length );
2492                         }
2493
2494                         // Fetch a seed set for right-to-left matching
2495                         i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
2496                         while ( i-- ) {
2497                                 token = tokens[i];
2498
2499                                 // Abort if we hit a combinator
2500                                 if ( Expr.relative[ (type = token.type) ] ) {
2501                                         break;
2502                                 }
2503                                 if ( (find = Expr.find[ type ]) ) {
2504                                         // Search, expanding context for leading sibling combinators
2505                                         if ( (seed = find(
2506                                                 token.matches[0].replace( runescape, funescape ),
2507                                                 rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
2508                                         )) ) {
2509
2510                                                 // If seed is empty or no tokens remain, we can return early
2511                                                 tokens.splice( i, 1 );
2512                                                 selector = seed.length && toSelector( tokens );
2513                                                 if ( !selector ) {
2514                                                         push.apply( results, seed );
2515                                                         return results;
2516                                                 }
2517
2518                                                 break;
2519                                         }
2520                                 }
2521                         }
2522                 }
2523         }
2524
2525         // Compile and execute a filtering function
2526         // Provide `match` to avoid retokenization if we modified the selector above
2527         compile( selector, match )(
2528                 seed,
2529                 context,
2530                 !documentIsHTML,
2531                 results,
2532                 rsibling.test( selector ) && testContext( context.parentNode ) || context
2533         );
2534         return results;
2535 }
2536
2537 // One-time assignments
2538
2539 // Sort stability
2540 support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
2541
2542 // Support: Chrome<14
2543 // Always assume duplicates if they aren't passed to the comparison function
2544 support.detectDuplicates = !!hasDuplicate;
2545
2546 // Initialize against the default document
2547 setDocument();
2548
2549 // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
2550 // Detached nodes confoundingly follow *each other*
2551 support.sortDetached = assert(function( div1 ) {
2552         // Should return 1, but returns 4 (following)
2553         return div1.compareDocumentPosition( document.createElement("div") ) & 1;
2554 });
2555
2556 // Support: IE<8
2557 // Prevent attribute/property "interpolation"
2558 // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
2559 if ( !assert(function( div ) {
2560         div.innerHTML = "<a href='#'></a>";
2561         return div.firstChild.getAttribute("href") === "#" ;
2562 }) ) {
2563         addHandle( "type|href|height|width", function( elem, name, isXML ) {
2564                 if ( !isXML ) {
2565                         return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
2566                 }
2567         });
2568 }
2569
2570 // Support: IE<9
2571 // Use defaultValue in place of getAttribute("value")
2572 if ( !support.attributes || !assert(function( div ) {
2573         div.innerHTML = "<input/>";
2574         div.firstChild.setAttribute( "value", "" );
2575         return div.firstChild.getAttribute( "value" ) === "";
2576 }) ) {
2577         addHandle( "value", function( elem, name, isXML ) {
2578                 if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
2579                         return elem.defaultValue;
2580                 }
2581         });
2582 }
2583
2584 // Support: IE<9
2585 // Use getAttributeNode to fetch booleans when getAttribute lies
2586 if ( !assert(function( div ) {
2587         return div.getAttribute("disabled") == null;
2588 }) ) {
2589         addHandle( booleans, function( elem, name, isXML ) {
2590                 var val;
2591                 if ( !isXML ) {
2592                         return elem[ name ] === true ? name.toLowerCase() :
2593                                         (val = elem.getAttributeNode( name )) && val.specified ?
2594                                         val.value :
2595                                 null;
2596                 }
2597         });
2598 }
2599
2600 return Sizzle;
2601
2602 })( window );
2603
2604
2605
2606 jQuery.find = Sizzle;
2607 jQuery.expr = Sizzle.selectors;
2608 jQuery.expr[":"] = jQuery.expr.pseudos;
2609 jQuery.unique = Sizzle.uniqueSort;
2610 jQuery.text = Sizzle.getText;
2611 jQuery.isXMLDoc = Sizzle.isXML;
2612 jQuery.contains = Sizzle.contains;
2613
2614
2615
2616 var rneedsContext = jQuery.expr.match.needsContext;
2617
2618 var rsingleTag = (/^<(\w+)\s*\/?>(?:<\/\1>|)$/);
2619
2620
2621
2622 var risSimple = /^.[^:#\[\.,]*$/;
2623
2624 // Implement the identical functionality for filter and not
2625 function winnow( elements, qualifier, not ) {
2626         if ( jQuery.isFunction( qualifier ) ) {
2627                 return jQuery.grep( elements, function( elem, i ) {
2628                         /* jshint -W018 */
2629                         return !!qualifier.call( elem, i, elem ) !== not;
2630                 });
2631
2632         }
2633
2634         if ( qualifier.nodeType ) {
2635                 return jQuery.grep( elements, function( elem ) {
2636                         return ( elem === qualifier ) !== not;
2637                 });
2638
2639         }
2640
2641         if ( typeof qualifier === "string" ) {
2642                 if ( risSimple.test( qualifier ) ) {
2643                         return jQuery.filter( qualifier, elements, not );
2644                 }
2645
2646                 qualifier = jQuery.filter( qualifier, elements );
2647         }
2648
2649         return jQuery.grep( elements, function( elem ) {
2650                 return ( jQuery.inArray( elem, qualifier ) >= 0 ) !== not;
2651         });
2652 }
2653
2654 jQuery.filter = function( expr, elems, not ) {
2655         var elem = elems[ 0 ];
2656
2657         if ( not ) {
2658                 expr = ":not(" + expr + ")";
2659         }
2660
2661         return elems.length === 1 && elem.nodeType === 1 ?
2662                 jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] :
2663                 jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
2664                         return elem.nodeType === 1;
2665                 }));
2666 };
2667
2668 jQuery.fn.extend({
2669         find: function( selector ) {
2670                 var i,
2671                         ret = [],
2672                         self = this,
2673                         len = self.length;
2674
2675                 if ( typeof selector !== "string" ) {
2676                         return this.pushStack( jQuery( selector ).filter(function() {
2677                                 for ( i = 0; i < len; i++ ) {
2678                                         if ( jQuery.contains( self[ i ], this ) ) {
2679                                                 return true;
2680                                         }
2681                                 }
2682                         }) );
2683                 }
2684
2685                 for ( i = 0; i < len; i++ ) {
2686                         jQuery.find( selector, self[ i ], ret );
2687                 }
2688
2689                 // Needed because $( selector, context ) becomes $( context ).find( selector )
2690                 ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret );
2691                 ret.selector = this.selector ? this.selector + " " + selector : selector;
2692                 return ret;
2693         },
2694         filter: function( selector ) {
2695                 return this.pushStack( winnow(this, selector || [], false) );
2696         },
2697         not: function( selector ) {
2698                 return this.pushStack( winnow(this, selector || [], true) );
2699         },
2700         is: function( selector ) {
2701                 return !!winnow(
2702                         this,
2703
2704                         // If this is a positional/relative selector, check membership in the returned set
2705                         // so $("p:first").is("p:last") won't return true for a doc with two "p".
2706                         typeof selector === "string" && rneedsContext.test( selector ) ?
2707                                 jQuery( selector ) :
2708                                 selector || [],
2709                         false
2710                 ).length;
2711         }
2712 });
2713
2714
2715 // Initialize a jQuery object
2716
2717
2718 // A central reference to the root jQuery(document)
2719 var rootjQuery,
2720
2721         // Use the correct document accordingly with window argument (sandbox)
2722         document = window.document,
2723
2724         // A simple way to check for HTML strings
2725         // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
2726         // Strict HTML recognition (#11290: must start with <)
2727         rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,
2728
2729         init = jQuery.fn.init = function( selector, context ) {
2730                 var match, elem;
2731
2732                 // HANDLE: $(""), $(null), $(undefined), $(false)
2733                 if ( !selector ) {
2734                         return this;
2735                 }
2736
2737                 // Handle HTML strings
2738                 if ( typeof selector === "string" ) {
2739                         if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
2740                                 // Assume that strings that start and end with <> are HTML and skip the regex check
2741                                 match = [ null, selector, null ];
2742
2743                         } else {
2744                                 match = rquickExpr.exec( selector );
2745                         }
2746
2747                         // Match html or make sure no context is specified for #id
2748                         if ( match && (match[1] || !context) ) {
2749
2750                                 // HANDLE: $(html) -> $(array)
2751                                 if ( match[1] ) {
2752                                         context = context instanceof jQuery ? context[0] : context;
2753
2754                                         // scripts is true for back-compat
2755                                         // Intentionally let the error be thrown if parseHTML is not present
2756                                         jQuery.merge( this, jQuery.parseHTML(
2757                                                 match[1],
2758                                                 context && context.nodeType ? context.ownerDocument || context : document,
2759                                                 true
2760                                         ) );
2761
2762                                         // HANDLE: $(html, props)
2763                                         if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) {
2764                                                 for ( match in context ) {
2765                                                         // Properties of context are called as methods if possible
2766                                                         if ( jQuery.isFunction( this[ match ] ) ) {
2767                                                                 this[ match ]( context[ match ] );
2768
2769                                                         // ...and otherwise set as attributes
2770                                                         } else {
2771                                                                 this.attr( match, context[ match ] );
2772                                                         }
2773                                                 }
2774                                         }
2775
2776                                         return this;
2777
2778                                 // HANDLE: $(#id)
2779                                 } else {
2780                                         elem = document.getElementById( match[2] );
2781
2782                                         // Check parentNode to catch when Blackberry 4.6 returns
2783                                         // nodes that are no longer in the document #6963
2784                                         if ( elem && elem.parentNode ) {
2785                                                 // Handle the case where IE and Opera return items
2786                                                 // by name instead of ID
2787                                                 if ( elem.id !== match[2] ) {
2788                                                         return rootjQuery.find( selector );
2789                                                 }
2790
2791                                                 // Otherwise, we inject the element directly into the jQuery object
2792                                                 this.length = 1;
2793                                                 this[0] = elem;
2794                                         }
2795
2796                                         this.context = document;
2797                                         this.selector = selector;
2798                                         return this;
2799                                 }
2800
2801                         // HANDLE: $(expr, $(...))
2802                         } else if ( !context || context.jquery ) {
2803                                 return ( context || rootjQuery ).find( selector );
2804
2805                         // HANDLE: $(expr, context)
2806                         // (which is just equivalent to: $(context).find(expr)
2807                         } else {
2808                                 return this.constructor( context ).find( selector );
2809                         }
2810
2811                 // HANDLE: $(DOMElement)
2812                 } else if ( selector.nodeType ) {
2813                         this.context = this[0] = selector;
2814                         this.length = 1;
2815                         return this;
2816
2817                 // HANDLE: $(function)
2818                 // Shortcut for document ready
2819                 } else if ( jQuery.isFunction( selector ) ) {
2820                         return typeof rootjQuery.ready !== "undefined" ?
2821                                 rootjQuery.ready( selector ) :
2822                                 // Execute immediately if ready is not present
2823                                 selector( jQuery );
2824                 }
2825
2826                 if ( selector.selector !== undefined ) {
2827                         this.selector = selector.selector;
2828                         this.context = selector.context;
2829                 }
2830
2831                 return jQuery.makeArray( selector, this );
2832         };
2833
2834 // Give the init function the jQuery prototype for later instantiation
2835 init.prototype = jQuery.fn;
2836
2837 // Initialize central reference
2838 rootjQuery = jQuery( document );
2839
2840
2841 var rparentsprev = /^(?:parents|prev(?:Until|All))/,
2842         // methods guaranteed to produce a unique set when starting from a unique set
2843         guaranteedUnique = {
2844                 children: true,
2845                 contents: true,
2846                 next: true,
2847                 prev: true
2848         };
2849
2850 jQuery.extend({
2851         dir: function( elem, dir, until ) {
2852                 var matched = [],
2853                         cur = elem[ dir ];
2854
2855                 while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
2856                         if ( cur.nodeType === 1 ) {
2857                                 matched.push( cur );
2858                         }
2859                         cur = cur[dir];
2860                 }
2861                 return matched;
2862         },
2863
2864         sibling: function( n, elem ) {
2865                 var r = [];
2866
2867                 for ( ; n; n = n.nextSibling ) {
2868                         if ( n.nodeType === 1 && n !== elem ) {
2869                                 r.push( n );
2870                         }
2871                 }
2872
2873                 return r;
2874         }
2875 });
2876
2877 jQuery.fn.extend({
2878         has: function( target ) {
2879                 var i,
2880                         targets = jQuery( target, this ),