Use the native isArray whenever possible. See perf test by jdalton here: http://jsper...
[jquery.git] / src / core.js
1 (function() {
2
3 // Define a local copy of jQuery
4 var jQuery = function( selector, context ) {
5                 // The jQuery object is actually just the init constructor 'enhanced'
6                 return new jQuery.fn.init( selector, context );
7         },
8
9         // Map over jQuery in case of overwrite
10         _jQuery = window.jQuery,
11
12         // Map over the $ in case of overwrite
13         _$ = window.$,
14
15         // Use the correct document accordingly with window argument (sandbox)
16         //document = window.document,
17
18         // A central reference to the root jQuery(document)
19         rootjQuery,
20
21         // A simple way to check for HTML strings or ID strings
22         // (both of which we optimize for)
23         quickExpr = /^[^<]*(<[\w\W]+>)[^>]*$|^#([\w\-]+)$/,
24
25         // Is it a simple selector
26         isSimple = /^.[^:#\[\.,]*$/,
27
28         // Check if a string has a non-whitespace character in it
29         rnotwhite = /\S/,
30
31         // Used for trimming whitespace
32         trimLeft = /^\s+/,
33         trimRight = /\s+$/,
34
35         // Match a standalone tag
36         rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
37
38         // Keep a UserAgent string for use with jQuery.browser
39         userAgent = navigator.userAgent,
40
41         // For matching the engine and version of the browser
42         browserMatch,
43         
44         // Has the ready events already been bound?
45         readyBound = false,
46         
47         // The functions to execute on DOM ready
48         readyList = [],
49
50         // The ready event handler
51         DOMContentLoaded,
52
53         // Save a reference to some core methods
54         toString = Object.prototype.toString,
55         hasOwn = Object.prototype.hasOwnProperty,
56         push = Array.prototype.push,
57         slice = Array.prototype.slice,
58         trim = String.prototype.trim,
59         indexOf = Array.prototype.indexOf;
60
61 jQuery.fn = jQuery.prototype = {
62         init: function( selector, context ) {
63                 var match, elem, ret, doc;
64
65                 // Handle $(""), $(null), or $(undefined)
66                 if ( !selector ) {
67                         return this;
68                 }
69
70                 // Handle $(DOMElement)
71                 if ( selector.nodeType ) {
72                         this.context = this[0] = selector;
73                         this.length = 1;
74                         return this;
75                 }
76                 
77                 // The body element only exists once, optimize finding it
78                 if ( selector === "body" && !context ) {
79                         this.context = document;
80                         this[0] = document.body;
81                         this.selector = "body";
82                         this.length = 1;
83                         return this;
84                 }
85
86                 // Handle HTML strings
87                 if ( typeof selector === "string" ) {
88                         // Are we dealing with HTML string or an ID?
89                         match = quickExpr.exec( selector );
90
91                         // Verify a match, and that no context was specified for #id
92                         if ( match && (match[1] || !context) ) {
93
94                                 // HANDLE: $(html) -> $(array)
95                                 if ( match[1] ) {
96                                         doc = (context ? context.ownerDocument || context : document);
97
98                                         // If a single string is passed in and it's a single tag
99                                         // just do a createElement and skip the rest
100                                         ret = rsingleTag.exec( selector );
101
102                                         if ( ret ) {
103                                                 if ( jQuery.isPlainObject( context ) ) {
104                                                         selector = [ document.createElement( ret[1] ) ];
105                                                         jQuery.fn.attr.call( selector, context, true );
106
107                                                 } else {
108                                                         selector = [ doc.createElement( ret[1] ) ];
109                                                 }
110
111                                         } else {
112                                                 ret = buildFragment( [ match[1] ], [ doc ] );
113                                                 selector = (ret.cacheable ? ret.fragment.cloneNode(true) : ret.fragment).childNodes;
114                                         }
115                                         
116                                         return jQuery.merge( this, selector );
117                                         
118                                 // HANDLE: $("#id")
119                                 } else {
120                                         elem = document.getElementById( match[2] );
121
122                                         if ( elem ) {
123                                                 // Handle the case where IE and Opera return items
124                                                 // by name instead of ID
125                                                 if ( elem.id !== match[2] ) {
126                                                         return rootjQuery.find( selector );
127                                                 }
128
129                                                 // Otherwise, we inject the element directly into the jQuery object
130                                                 this.length = 1;
131                                                 this[0] = elem;
132                                         }
133
134                                         this.context = document;
135                                         this.selector = selector;
136                                         return this;
137                                 }
138
139                         // HANDLE: $("TAG")
140                         } else if ( !context && /^\w+$/.test( selector ) ) {
141                                 this.selector = selector;
142                                 this.context = document;
143                                 selector = document.getElementsByTagName( selector );
144                                 return jQuery.merge( this, selector );
145
146                         // HANDLE: $(expr, $(...))
147                         } else if ( !context || context.jquery ) {
148                                 return (context || rootjQuery).find( selector );
149
150                         // HANDLE: $(expr, context)
151                         // (which is just equivalent to: $(context).find(expr)
152                         } else {
153                                 return jQuery( context ).find( selector );
154                         }
155
156                 // HANDLE: $(function)
157                 // Shortcut for document ready
158                 } else if ( jQuery.isFunction( selector ) ) {
159                         return rootjQuery.ready( selector );
160                 }
161
162                 if (selector.selector !== undefined) {
163                         this.selector = selector.selector;
164                         this.context = selector.context;
165                 }
166
167                 return jQuery.makeArray( selector, this );
168         },
169
170         // Start with an empty selector
171         selector: "",
172
173         // The current version of jQuery being used
174         jquery: "@VERSION",
175
176         // The default length of a jQuery object is 0
177         length: 0,
178
179         // The number of elements contained in the matched element set
180         size: function() {
181                 return this.length;
182         },
183
184         toArray: function() {
185                 return slice.call( this, 0 );
186         },
187
188         // Get the Nth element in the matched element set OR
189         // Get the whole matched element set as a clean array
190         get: function( num ) {
191                 return num == null ?
192
193                         // Return a 'clean' array
194                         this.toArray() :
195
196                         // Return just the object
197                         ( num < 0 ? this.slice(num)[ 0 ] : this[ num ] );
198         },
199
200         // Take an array of elements and push it onto the stack
201         // (returning the new matched element set)
202         pushStack: function( elems, name, selector ) {
203                 // Build a new jQuery matched element set
204                 var ret = jQuery();
205
206                 if ( jQuery.isArray( elems ) ) {
207                         push.apply( ret, elems );
208                 
209                 } else {
210                         jQuery.merge( ret, elems );
211                 }
212
213                 // Add the old object onto the stack (as a reference)
214                 ret.prevObject = this;
215
216                 ret.context = this.context;
217
218                 if ( name === "find" ) {
219                         ret.selector = this.selector + (this.selector ? " " : "") + selector;
220                 } else if ( name ) {
221                         ret.selector = this.selector + "." + name + "(" + selector + ")";
222                 }
223
224                 // Return the newly-formed element set
225                 return ret;
226         },
227
228         // Execute a callback for every element in the matched set.
229         // (You can seed the arguments with an array of args, but this is
230         // only used internally.)
231         each: function( callback, args ) {
232                 return jQuery.each( this, callback, args );
233         },
234         
235         ready: function( fn ) {
236                 // Attach the listeners
237                 jQuery.bindReady();
238
239                 // If the DOM is already ready
240                 if ( jQuery.isReady ) {
241                         // Execute the function immediately
242                         fn.call( document, jQuery );
243
244                 // Otherwise, remember the function for later
245                 } else if ( readyList ) {
246                         // Add the function to the wait list
247                         readyList.push( fn );
248                 }
249
250                 return this;
251         },
252         
253         eq: function( i ) {
254                 return i === -1 ?
255                         this.slice( i ) :
256                         this.slice( i, +i + 1 );
257         },
258
259         first: function() {
260                 return this.eq( 0 );
261         },
262
263         last: function() {
264                 return this.eq( -1 );
265         },
266
267         slice: function() {
268                 return this.pushStack( slice.apply( this, arguments ),
269                         "slice", slice.call(arguments).join(",") );
270         },
271
272         map: function( callback ) {
273                 return this.pushStack( jQuery.map(this, function( elem, i ) {
274                         return callback.call( elem, i, elem );
275                 }));
276         },
277         
278         end: function() {
279                 return this.prevObject || jQuery(null);
280         },
281
282         // For internal use only.
283         // Behaves like an Array's method, not like a jQuery method.
284         push: push,
285         sort: [].sort,
286         splice: [].splice
287 };
288
289 // Give the init function the jQuery prototype for later instantiation
290 jQuery.fn.init.prototype = jQuery.fn;
291
292 jQuery.extend = jQuery.fn.extend = function() {
293         // copy reference to target object
294         var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options, name, src, copy;
295
296         // Handle a deep copy situation
297         if ( typeof target === "boolean" ) {
298                 deep = target;
299                 target = arguments[1] || {};
300                 // skip the boolean and the target
301                 i = 2;
302         }
303
304         // Handle case when target is a string or something (possible in deep copy)
305         if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
306                 target = {};
307         }
308
309         // extend jQuery itself if only one argument is passed
310         if ( length === i ) {
311                 target = this;
312                 --i;
313         }
314
315         for ( ; i < length; i++ ) {
316                 // Only deal with non-null/undefined values
317                 if ( (options = arguments[ i ]) != null ) {
318                         // Extend the base object
319                         for ( name in options ) {
320                                 src = target[ name ];
321                                 copy = options[ name ];
322
323                                 // Prevent never-ending loop
324                                 if ( target === copy ) {
325                                         continue;
326                                 }
327
328                                 // Recurse if we're merging object literal values or arrays
329                                 if ( deep && copy && ( jQuery.isPlainObject(copy) || jQuery.isArray(copy) ) ) {
330                                         var clone = src && ( jQuery.isPlainObject(src) || jQuery.isArray(src) ) ? src
331                                                 : jQuery.isArray(copy) ? [] : {};
332
333                                         // Never move original objects, clone them
334                                         target[ name ] = jQuery.extend( deep, clone, copy );
335
336                                 // Don't bring in undefined values
337                                 } else if ( copy !== undefined ) {
338                                         target[ name ] = copy;
339                                 }
340                         }
341                 }
342         }
343
344         // Return the modified object
345         return target;
346 };
347
348 jQuery.extend({
349         noConflict: function( deep ) {
350                 window.$ = _$;
351
352                 if ( deep ) {
353                         window.jQuery = _jQuery;
354                 }
355
356                 return jQuery;
357         },
358         
359         // Is the DOM ready to be used? Set to true once it occurs.
360         isReady: false,
361         
362         // Handle when the DOM is ready
363         ready: function() {
364                 // Make sure that the DOM is not already loaded
365                 if ( !jQuery.isReady ) {
366                         // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
367                         if ( !document.body ) {
368                                 return setTimeout( jQuery.ready, 13 );
369                         }
370
371                         // Remember that the DOM is ready
372                         jQuery.isReady = true;
373
374                         // If there are functions bound, to execute
375                         if ( readyList ) {
376                                 // Execute all of them
377                                 var fn, i = 0;
378                                 while ( (fn = readyList[ i++ ]) ) {
379                                         fn.call( document, jQuery );
380                                 }
381
382                                 // Reset the list of functions
383                                 readyList = null;
384                         }
385
386                         // Trigger any bound ready events
387                         if ( jQuery.fn.triggerHandler ) {
388                                 jQuery( document ).triggerHandler( "ready" );
389                         }
390                 }
391         },
392         
393         bindReady: function() {
394                 if ( readyBound ) {
395                         return;
396                 }
397
398                 readyBound = true;
399
400                 // Catch cases where $(document).ready() is called after the
401                 // browser event has already occurred.
402                 if ( document.readyState === "complete" ) {
403                         return jQuery.ready();
404                 }
405
406                 // Mozilla, Opera and webkit nightlies currently support this event
407                 if ( document.addEventListener ) {
408                         // Use the handy event callback
409                         document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
410                         
411                         // A fallback to window.onload, that will always work
412                         window.addEventListener( "load", jQuery.ready, false );
413
414                 // If IE event model is used
415                 } else if ( document.attachEvent ) {
416                         // ensure firing before onload,
417                         // maybe late but safe also for iframes
418                         document.attachEvent("onreadystatechange", DOMContentLoaded);
419                         
420                         // A fallback to window.onload, that will always work
421                         window.attachEvent( "onload", jQuery.ready );
422
423                         // If IE and not a frame
424                         // continually check to see if the document is ready
425                         var toplevel = false;
426
427                         try {
428                                 toplevel = window.frameElement == null;
429                         } catch(e) {}
430
431                         if ( document.documentElement.doScroll && toplevel ) {
432                                 doScrollCheck();
433                         }
434                 }
435         },
436
437         // See test/unit/core.js for details concerning isFunction.
438         // Since version 1.3, DOM methods and functions like alert
439         // aren't supported. They return false on IE (#2968).
440         isFunction: function( obj ) {
441                 return jQuery.type(obj) === "function";
442         },
443
444         isArray: Array.isArray || function( obj ) {
445                 return jQuery.type(obj) === "array";
446         },
447
448         type: function( obj ) {
449                 return obj == null ?
450                         String( obj ) :
451                         toString.call(obj).slice(8, -1).toLowerCase();
452         },
453
454         isPlainObject: function( obj ) {
455                 // Must be an Object.
456                 // Because of IE, we also have to check the presence of the constructor property.
457                 // Make sure that DOM nodes and window objects don't pass through, as well
458                 if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || obj.setInterval ) {
459                         return false;
460                 }
461                 
462                 // Not own constructor property must be Object
463                 if ( obj.constructor &&
464                         !hasOwn.call(obj, "constructor") &&
465                         !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
466                         return false;
467                 }
468                 
469                 // Own properties are enumerated firstly, so to speed up,
470                 // if last one is own, then all properties are own.
471         
472                 var key;
473                 for ( key in obj ) {}
474                 
475                 return key === undefined || hasOwn.call( obj, key );
476         },
477
478         isEmptyObject: function( obj ) {
479                 for ( var name in obj ) {
480                         return false;
481                 }
482                 return true;
483         },
484         
485         error: function( msg ) {
486                 throw msg;
487         },
488         
489         parseJSON: function( data ) {
490                 if ( typeof data !== "string" || !data ) {
491                         return null;
492                 }
493
494                 // Make sure leading/trailing whitespace is removed (IE can't handle it)
495                 data = jQuery.trim( data );
496                 
497                 // Make sure the incoming data is actual JSON
498                 // Logic borrowed from http://json.org/json2.js
499                 if ( /^[\],:{}\s]*$/.test(data.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, "@")
500                         .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, "]")
501                         .replace(/(?:^|:|,)(?:\s*\[)+/g, "")) ) {
502
503                         // Try to use the native JSON parser first
504                         return window.JSON && window.JSON.parse ?
505                                 window.JSON.parse( data ) :
506                                 (new Function("return " + data))();
507
508                 } else {
509                         jQuery.error( "Invalid JSON: " + data );
510                 }
511         },
512
513         noop: function() {},
514
515         // Evalulates a script in a global context
516         globalEval: function( data ) {
517                 if ( data && rnotwhite.test(data) ) {
518                         // Inspired by code by Andrea Giammarchi
519                         // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
520                         var head = document.getElementsByTagName("head")[0] || document.documentElement,
521                                 script = document.createElement("script");
522
523                         script.type = "text/javascript";
524
525                         if ( jQuery.support.scriptEval ) {
526                                 script.appendChild( document.createTextNode( data ) );
527                         } else {
528                                 script.text = data;
529                         }
530
531                         // Use insertBefore instead of appendChild to circumvent an IE6 bug.
532                         // This arises when a base node is used (#2709).
533                         head.insertBefore( script, head.firstChild );
534                         head.removeChild( script );
535                 }
536         },
537
538         nodeName: function( elem, name ) {
539                 return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
540         },
541
542         // args is for internal usage only
543         each: function( object, callback, args ) {
544                 var name, i = 0,
545                         length = object.length,
546                         isObj = length === undefined || jQuery.isFunction(object);
547
548                 if ( args ) {
549                         if ( isObj ) {
550                                 for ( name in object ) {
551                                         if ( callback.apply( object[ name ], args ) === false ) {
552                                                 break;
553                                         }
554                                 }
555                         } else {
556                                 for ( ; i < length; ) {
557                                         if ( callback.apply( object[ i++ ], args ) === false ) {
558                                                 break;
559                                         }
560                                 }
561                         }
562
563                 // A special, fast, case for the most common use of each
564                 } else {
565                         if ( isObj ) {
566                                 for ( name in object ) {
567                                         if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
568                                                 break;
569                                         }
570                                 }
571                         } else {
572                                 for ( var value = object[0];
573                                         i < length && callback.call( value, i, value ) !== false; value = object[++i] ) {}
574                         }
575                 }
576
577                 return object;
578         },
579
580         // Use native String.trim function wherever possible
581         trim: trim ?
582                 function( text ) {
583                         return text == null ?
584                                 "" :
585                                 trim.call( text );
586                 } :
587
588                 // Otherwise use our own trimming functionality
589                 function( text ) {
590                         return text == null ?
591                                 "" :
592                                 text.toString().replace( trimLeft, "" ).replace( trimRight, "" );
593                 },
594
595         // results is for internal usage only
596         makeArray: function( array, results ) {
597                 var ret = results || [];
598
599                 if ( array != null ) {
600                         // The window, strings (and functions) also have 'length'
601                         // The extra typeof function check is to prevent crashes
602                         // in Safari 2 (See: #3039)
603                         // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
604                         var type = jQuery.type(array);
605
606                         if ( array.length == null || type === "string" || type === "function" || type === "regexp" || (typeof type !== "function" && array.setInterval) ) {
607                                 push.call( ret, array );
608                         } else {
609                                 jQuery.merge( ret, array );
610                         }
611                 }
612
613                 return ret;
614         },
615
616         inArray: function( elem, array ) {
617                 if ( array.indexOf ) {
618                         return array.indexOf( elem );
619                 }
620
621                 for ( var i = 0, length = array.length; i < length; i++ ) {
622                         if ( array[ i ] === elem ) {
623                                 return i;
624                         }
625                 }
626
627                 return -1;
628         },
629
630         merge: function( first, second ) {
631                 var i = first.length, j = 0;
632
633                 if ( typeof second.length === "number" ) {
634                         for ( var l = second.length; j < l; j++ ) {
635                                 first[ i++ ] = second[ j ];
636                         }
637                 
638                 } else {
639                         while ( second[j] !== undefined ) {
640                                 first[ i++ ] = second[ j++ ];
641                         }
642                 }
643
644                 first.length = i;
645
646                 return first;
647         },
648
649         grep: function( elems, callback, inv ) {
650                 var ret = [], retVal;
651                 inv = !!inv;
652
653                 // Go through the array, only saving the items
654                 // that pass the validator function
655                 for ( var i = 0, length = elems.length; i < length; i++ ) {
656                         retVal = !!callback( elems[ i ], i );
657                         if ( inv !== retVal ) {
658                                 ret.push( elems[ i ] );
659                         }
660                 }
661
662                 return ret;
663         },
664
665         // arg is for internal usage only
666         map: function( elems, callback, arg ) {
667                 var ret = [], value;
668
669                 // Go through the array, translating each of the items to their
670                 // new value (or values).
671                 for ( var i = 0, length = elems.length; i < length; i++ ) {
672                         value = callback( elems[ i ], i, arg );
673
674                         if ( value != null ) {
675                                 ret[ ret.length ] = value;
676                         }
677                 }
678
679                 return ret.concat.apply( [], ret );
680         },
681
682         // A global GUID counter for objects
683         guid: 1,
684
685         proxy: function( fn, proxy, thisObject ) {
686                 if ( arguments.length === 2 ) {
687                         if ( typeof proxy === "string" ) {
688                                 thisObject = fn;
689                                 fn = thisObject[ proxy ];
690                                 proxy = undefined;
691
692                         } else if ( proxy && !jQuery.isFunction( proxy ) ) {
693                                 thisObject = proxy;
694                                 proxy = undefined;
695                         }
696                 }
697
698                 if ( !proxy && fn ) {
699                         proxy = function() {
700                                 return fn.apply( thisObject || this, arguments );
701                         };
702                 }
703
704                 // Set the guid of unique handler to the same of original handler, so it can be removed
705                 if ( fn ) {
706                         proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
707                 }
708
709                 // So proxy can be declared as an argument
710                 return proxy;
711         },
712
713         // Mutifunctional method to get and set values to a collection
714         // The value/s can be optionally by executed if its a function
715         access: function( elems, key, value, exec, fn, pass ) {
716                 var length = elems.length;
717         
718                 // Setting many attributes
719                 if ( typeof key === "object" ) {
720                         for ( var k in key ) {
721                                 jQuery.access( elems, k, key[k], exec, fn, value );
722                         }
723                         return elems;
724                 }
725         
726                 // Setting one attribute
727                 if ( value !== undefined ) {
728                         // Optionally, function values get executed if exec is true
729                         exec = !pass && exec && jQuery.isFunction(value);
730                 
731                         for ( var i = 0; i < length; i++ ) {
732                                 fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
733                         }
734                 
735                         return elems;
736                 }
737         
738                 // Getting an attribute
739                 return length ? fn( elems[0], key ) : undefined;
740         },
741
742         now: function() {
743                 return (new Date()).getTime();
744         },
745
746         // Use of jQuery.browser is frowned upon.
747         // More details: http://docs.jquery.com/Utilities/jQuery.browser
748         uaMatch: function( ua ) {
749                 ua = ua.toLowerCase();
750
751                 var match = /(webkit)[ \/]([\w.]+)/.exec( ua ) ||
752                         /(opera)(?:.*version)?[ \/]([\w.]+)/.exec( ua ) ||
753                         /(msie) ([\w.]+)/.exec( ua ) ||
754                         !/compatible/.test( ua ) && /(mozilla)(?:.*? rv:([\w.]+))?/.exec( ua ) ||
755                         [];
756
757                 return { browser: match[1] || "", version: match[2] || "0" };
758         },
759
760         browser: {}
761 });
762
763 browserMatch = jQuery.uaMatch( userAgent );
764 if ( browserMatch.browser ) {
765         jQuery.browser[ browserMatch.browser ] = true;
766         jQuery.browser.version = browserMatch.version;
767 }
768
769 // Deprecated, use jQuery.browser.webkit instead
770 if ( jQuery.browser.webkit ) {
771         jQuery.browser.safari = true;
772 }
773
774 if ( indexOf ) {
775         jQuery.inArray = function( elem, array ) {
776                 return indexOf.call( array, elem );
777         };
778 }
779
780 // Verify that \s matches non-breaking spaces
781 // (IE fails on this test)
782 if ( !/\s/.test( "\xA0" ) ) {
783         trimLeft = /^[\s\xA0]+/;
784         trimRight = /[\s\xA0]+$/;
785 }
786
787 // All jQuery objects should point back to these
788 rootjQuery = jQuery(document);
789
790 // Cleanup functions for the document ready method
791 if ( document.addEventListener ) {
792         DOMContentLoaded = function() {
793                 document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
794                 jQuery.ready();
795         };
796
797 } else if ( document.attachEvent ) {
798         DOMContentLoaded = function() {
799                 // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
800                 if ( document.readyState === "complete" ) {
801                         document.detachEvent( "onreadystatechange", DOMContentLoaded );
802                         jQuery.ready();
803                 }
804         };
805 }
806
807 // The DOM ready check for Internet Explorer
808 function doScrollCheck() {
809         if ( jQuery.isReady ) {
810                 return;
811         }
812
813         try {
814                 // If IE is used, use the trick by Diego Perini
815                 // http://javascript.nwbox.com/IEContentLoaded/
816                 document.documentElement.doScroll("left");
817         } catch(e) {
818                 setTimeout( doScrollCheck, 1 );
819                 return;
820         }
821
822         // and execute any waiting functions
823         jQuery.ready();
824 }
825
826 // Expose jQuery to the global object
827 window.jQuery = window.$ = jQuery;
828
829 })();