Fixed two bugs with jQuery: One with height computation, one with .find(expr,fn)...
[jquery.git] / src / jquery / jquery.js
1 /*
2  * jQuery - New Wave Javascript
3  *
4  * Copyright (c) 2006 John Resig (jquery.com)
5  * Dual licensed under the MIT (MIT-LICENSE.txt) 
6  * and GPL (GPL-LICENSE.txt) licenses.
7  *
8  * $Date$
9  * $Rev$
10  */
11
12 // Global undefined variable
13 window.undefined = window.undefined;
14
15 /**
16  * Create a new jQuery Object
17  *
18  * @test ok( Array.prototype.push, "Array.push()" );
19  * @test ok( Function.prototype.apply, "Function.apply()" );
20  * @test ok( document.getElementById, "getElementById" );
21  * @test ok( document.getElementsByTagName, "getElementsByTagName" );
22  * @test ok( RegExp, "RegExp" );
23  * @test ok( jQuery, "jQuery" );
24  * @test ok( $, "$()" );
25  *
26  * @constructor
27  * @private
28  * @name jQuery
29  */
30 function jQuery(a,c) {
31
32         // Shortcut for document ready (because $(document).each() is silly)
33         if ( a && a.constructor == Function && jQuery.fn.ready )
34                 return jQuery(document).ready(a);
35
36         // Make sure that a selection was provided
37         a = a || jQuery.context || document;
38
39         // Watch for when a jQuery object is passed as the selector
40         if ( a.jquery )
41                 return jQuery( jQuery.merge( a, [] ) );
42
43         // Watch for when a jQuery object is passed at the context
44         if ( c && c.jquery )
45                 return jQuery( c ).find(a);
46         
47         // If the context is global, return a new object
48         if ( window == this )
49                 return new jQuery(a,c);
50
51         // Handle HTML strings
52         var m = /^[^<]*(<.+>)[^>]*$/.exec(a);
53         if ( m ) a = jQuery.clean( [ m[1] ] );
54
55         // Watch for when an array is passed in
56         this.get( a.constructor == Array || a.length && !a.nodeType && a[0] != undefined && a[0].nodeType ?
57                 // Assume that it is an array of DOM Elements
58                 jQuery.merge( a, [] ) :
59
60                 // Find the matching elements and save them for later
61                 jQuery.find( a, c ) );
62
63   // See if an extra function was provided
64         var fn = arguments[ arguments.length - 1 ];
65         
66         // If so, execute it in context
67         if ( fn && fn.constructor == Function )
68                 this.each(fn);
69 }
70
71 // Map over the $ in case of overwrite
72 if ( typeof $ != "undefined" )
73         jQuery._$ = $;
74         
75 /**
76  * This function accepts a string containing a CSS selector, 
77  * basic XPath, or raw HTML, which is then used to match a set of elements.
78  * The HTML string is different from the traditional selectors in that
79  * it creates the DOM elements representing that HTML string, on the fly,
80  * to be (assumedly) inserted into the document later.
81  *
82  * The core functionality of jQuery centers around this function. 
83  * Everything in jQuery is based upon this, or uses this in some way. 
84  * The most basic use of this function is to pass in an expression 
85  * (usually consisting of CSS or XPath), which then finds all matching 
86  * elements and remembers them for later use.
87  *
88  * By default, $() looks for DOM elements within the context of the 
89  * current HTML document.
90  *
91  * @example $("div > p")
92  * @desc This finds all p elements that are children of a div element.
93  * @before <p>one</p> <div><p>two</p></div> <p>three</p>
94  * @result [ <p>two</p> ]
95  *
96  * @example $("<div><p>Hello</p></div>").appendTo("#body")
97  * @desc Creates a div element (and all of its contents) dynamically, and appends it to the element with the ID of body.
98  *
99  * @name $
100  * @param String expr An expression to search with, or a string of HTML to create on the fly.
101  * @cat Core
102  * @type jQuery
103  */
104  
105 /**
106  * This function accepts a string containing a CSS selector, or
107  * basic XPath, which is then used to match a set of elements with the
108  * context of the specified DOM element, or document
109  *
110  * @example $("div", xml.responseXML)
111  * @desc This finds all div elements within the specified XML document.
112  *
113  * @name $
114  * @param String expr An expression to search with.
115  * @param DOMElement context A DOM Element, or Document, representing the base context.
116  * @cat Core
117  * @type jQuery
118  */
119  
120 /**
121  * Wrap jQuery functionality around a specific DOM Element.
122  * This function also accepts XML Documents and Window objects
123  * as valid arguments (even though they are not DOM Elements).
124  *
125  * @example $(document).find("div > p")
126  * @before <p>one</p> <div><p>two</p></div> <p>three</p>
127  * @result [ <p>two</p> ]
128  *
129  * @example $(document).ready( loaded );
130  * @desc Executes the "loaded" function when the DOM is ready to
131  * be manipulated.
132  *
133  * @name $
134  * @param DOMElement elem A DOM element to be encapsulated by a jQuery object.
135  * @cat Core
136  * @type jQuery
137  */
138  
139 /**
140  * Wrap jQuery functionality around a set of DOM Elements.
141  *
142  * @example $( myForm.elements ).hide()
143  * @desc Hides all the input elements within a form
144  *
145  * @name $
146  * @param Array<DOMElement> elems An array of DOM elements to be encapsulated by a jQuery object.
147  * @cat Core
148  * @type jQuery
149  */
150  
151 /**
152  * A shorthand for $(document).ready(), allowing you to bind a function
153  * to be executed when the DOM document has finished loading.
154  *
155  * @example $( loaded )
156  * @desc Executes the function "loaded" when the DOM is ready to be used.
157  *
158  * @name $
159  * @param Function fn The function to execute when the DOM is ready.
160  * @cat Core
161  * @type jQuery
162  */
163  
164 /**
165  * A means of creating a duplicate copy of a jQuery object.
166  *
167  * @example var div = $("div");
168  * $( div ).find("p")
169  * @desc Locates all p elements with all div elements, without disrupting the original jQuery object contained in 'div'.
170  *
171  * @name $
172  * @param jQuery obj The jQuery object to be cloned.
173  * @cat Core
174  * @type jQuery
175  */
176
177 // Map the jQuery namespace to the '$' one
178 var $ = jQuery;
179
180 jQuery.fn = jQuery.prototype = {
181         /**
182          * The current SVN version of jQuery.
183          *
184          * @private
185          * @property
186          * @name jquery
187          * @type String
188          * @cat Core
189          */
190         jquery: "$Rev$",
191         
192         /**
193          * The number of elements currently matched.
194          *
195          * @example $("img").length;
196          * @before <img src="test1.jpg"/> <img src="test2.jpg"/>
197          * @result 2
198          *
199          * @test cmpOK( $("div").length, "==", 2, "Get Number of Elements Found" );
200          *
201          * @property
202          * @name length
203          * @type Number
204          * @cat Core
205          */
206         
207         /**
208          * The number of elements currently matched.
209          *
210          * @example $("img").size();
211          * @before <img src="test1.jpg"/> <img src="test2.jpg"/>
212          * @result 2
213          *
214          * @test cmpOK( $("div").size(), "==", 2, "Get Number of Elements Found" );
215          *
216          * @name size
217          * @type Number
218          * @cat Core
219          */
220         size: function() {
221                 return this.length;
222         },
223         
224         /**
225          * Access all matched elements. This serves as a backwards-compatible
226          * way of accessing all matched elements (other than the jQuery object
227          * itself, which is, in fact, an array of elements).
228          *
229          * @example $("img").get();
230          * @before <img src="test1.jpg"/> <img src="test2.jpg"/>
231          * @result [ <img src="test1.jpg"/> <img src="test2.jpg"/> ]
232          *
233          * @test isSet( $("div").get(), q("main","foo"), "Get All Elements" );
234          *
235          * @name get
236          * @type Array<Element>
237          * @cat Core
238          */
239          
240         /**
241          * Access a single matched element. num is used to access the 
242          * Nth element matched.
243          *
244          * @example $("img").get(1);
245          * @before <img src="test1.jpg"/> <img src="test2.jpg"/>
246          * @result [ <img src="test1.jpg"/> ]
247          *
248          * @test cmpOK( $("div").get(0), "==", document.getElementById("main"), "Get A Single Element" );
249          *
250          * @name get
251          * @type Element
252          * @param Number num Access the element in the Nth position.
253          * @cat Core
254          */
255          
256         /**
257          * Set the jQuery object to an array of elements.
258          *
259          * @example $("img").get([ document.body ]);
260          * @result $("img").get() == [ document.body ]
261          *
262          * @private
263          * @name get
264          * @type jQuery
265          * @param Elements elems An array of elements
266          * @cat Core
267          */
268         get: function( num ) {
269                 // Watch for when an array (of elements) is passed in
270                 if ( num && num.constructor == Array ) {
271
272                         // Use a tricky hack to make the jQuery object
273                         // look and feel like an array
274                         this.length = 0;
275                         [].push.apply( this, num );
276                         
277                         return this;
278                 } else
279                         return num == undefined ?
280
281                                 // Return a 'clean' array
282                                 jQuery.map( this, function(a){ return a } ) :
283
284                                 // Return just the object
285                                 this[num];
286         },
287
288         /**
289          * Execute a function within the context of every matched element.
290          * This means that every time the passed-in function is executed
291          * (which is once for every element matched) the 'this' keyword
292          * points to the specific element.
293          *
294          * Additionally, the function, when executed, is passed a single
295          * argument representing the position of the element in the matched
296          * set.
297          *
298          * @example $("img").each(function(){
299          *   this.src = "test.jpg";
300          * });
301          * @before <img/> <img/>
302          * @result <img src="test.jpg"/> <img src="test.jpg"/>
303          *
304          * @example $("img").each(function(i){
305          *   alert( "Image #" + i + " is " + this );
306          * });
307          * @before <img/> <img/>
308          * @result <img src="test.jpg"/> <img src="test.jpg"/>
309          *
310          * @test var div = $("div");
311          * div.each(function(){this.foo = 'zoo';});
312          * var pass = true;
313          * for ( var i = 0; i < div.size(); i++ ) {
314          *   if ( div.get(i).foo != "zoo" ) pass = false;
315          * }
316          * ok( pass, "Execute a function, Relative" );
317          *
318          * @name each
319          * @type jQuery
320          * @param Function fn A function to execute
321          * @cat Core
322          */
323         each: function( fn, args ) {
324                 return jQuery.each( this, fn, args );
325         },
326
327         index: function( obj ) {
328                 var pos = -1;
329                 this.each(function(i){
330                         if ( this == obj ) pos = i;
331                 });
332                 return pos;
333         },
334         
335         /**
336          * Access a property on the first matched element.
337          * This method makes it easy to retreive a property value
338          * from the first matched element.
339          *
340          * @example $("img").attr("src");
341          * @before <img src="test.jpg"/>
342          * @result test.jpg
343          *
344          * @name attr
345          * @type Object
346          * @param String name The name of the property to access.
347          * @cat DOM
348          */
349          
350         /**
351          * Set a hash of key/value object properties to all matched elements.
352          * This serves as the best way to set a large number of properties
353          * on all matched elements.
354          *
355          * @example $("img").attr({ src: "test.jpg", alt: "Test Image" });
356          * @before <img/>
357          * @result <img src="test.jpg" alt="Test Image"/>
358          *
359          * @test var pass = true;
360          * $("div").attr({foo: 'baz', zoo: 'ping'}).each(function(){
361          *   if ( this.getAttribute('foo') != "baz" && this.getAttribute('zoo') != "ping" ) pass = false;
362          * });
363          * ok( pass, "Set Multiple Attributes" );
364          *
365          * @name attr
366          * @type jQuery
367          * @param Hash prop A set of key/value pairs to set as object properties.
368          * @cat DOM
369          */
370          
371         /**
372          * Set a single property to a value, on all matched elements.
373          *
374          * @example $("img").attr("src","test.jpg");
375          * @before <img/>
376          * @result <img src="test.jpg"/>
377          *
378          * @test var div = $("div");
379          * div.attr("foo", "bar");
380          * var pass = true;
381          * for ( var i = 0; i < div.size(); i++ ) {
382          *   if ( div.get(i).getAttribute('foo') != "bar" ) pass = false;
383          * }
384          * ok( pass, "Set Attribute" );
385          *
386          * @name attr
387          * @type jQuery
388          * @param String key The name of the property to set.
389          * @param Object value The value to set the property to.
390          * @cat DOM
391          */
392         attr: function( key, value, type ) {
393                 // Check to see if we're setting style values
394                 return key.constructor != String || value != undefined ?
395                         this.each(function(){
396                                 // See if we're setting a hash of styles
397                                 if ( value == undefined )
398                                         // Set all the styles
399                                         for ( var prop in key )
400                                                 jQuery.attr(
401                                                         type ? this.style : this,
402                                                         prop, key[prop]
403                                                 );
404                                 
405                                 // See if we're setting a single key/value style
406                                 else
407                                         jQuery.attr(
408                                                 type ? this.style : this,
409                                                 key, value
410                                         );
411                         }) :
412                         
413                         // Look for the case where we're accessing a style value
414                         jQuery[ type || "attr" ]( this[0], key );
415         },
416
417         /**
418          * Access a style property on the first matched element.
419          * This method makes it easy to retreive a style property value
420          * from the first matched element.
421          *
422          * @example $("p").css("red");
423          * @before <p style="color:red;">Test Paragraph.</p>
424          * @result red
425          *
426          * @name css
427          * @type Object
428          * @param String name The name of the property to access.
429          * @cat CSS
430          */
431          
432         /**
433          * Set a hash of key/value style properties to all matched elements.
434          * This serves as the best way to set a large number of style properties
435          * on all matched elements.
436          *
437          * @example $("p").css({ color: "red", background: "blue" });
438          * @before <p>Test Paragraph.</p>
439          * @result <p style="color:red; background:blue;">Test Paragraph.</p>
440          *
441          * @name css
442          * @type jQuery
443          * @param Hash prop A set of key/value pairs to set as style properties.
444          * @cat CSS
445          */
446          
447         /**
448          * Set a single style property to a value, on all matched elements.
449          *
450          * @example $("p").css("color","red");
451          * @before <p>Test Paragraph.</p>
452          * @result <p style="color:red;">Test Paragraph.</p>
453          *
454          * @name css
455          * @type jQuery
456          * @param String key The name of the property to set.
457          * @param Object value The value to set the property to.
458          * @cat CSS
459          */
460         css: function( key, value ) {
461                 return this.attr( key, value, "curCSS" );
462         },
463         
464         /**
465          * Retreive the text contents of all matched elements. The result is
466          * a string that contains the combined text contents of all matched
467          * elements. This method works on both HTML and XML documents.
468          *
469          * @example $("p").text();
470          * @before <p>Test Paragraph.</p>
471          * @result Test Paragraph.
472          *
473          * @name text
474          * @type String
475          * @cat DOM
476          */
477         text: function(e) {
478                 e = e || this;
479                 var t = "";
480                 for ( var j = 0; j < e.length; j++ ) {
481                         var r = e[j].childNodes;
482                         for ( var i = 0; i < r.length; i++ )
483                                 if ( r[i].nodeType != 8 )
484                                         t += r[i].nodeType != 1 ?
485                                                 r[i].nodeValue : jQuery.fn.text([ r[i] ]);
486                 }
487                 return t;
488         },
489         
490         /**
491          * Wrap all matched elements with a structure of other elements.
492          * This wrapping process is most useful for injecting additional
493          * stucture into a document, without ruining the original semantic
494          * qualities of a document.
495          *
496          * The way that is works is that it goes through the first element argument
497          * provided and finds the deepest element within the structure - it is that
498          * element that will en-wrap everything else.
499          *
500          * @example $("p").wrap("<div class='wrap'></div>");
501          * @before <p>Test Paragraph.</p>
502          * @result <div class='wrap'><p>Test Paragraph.</p></div>
503          *
504          * @name wrap
505          * @type jQuery
506          * @any String html A string of HTML, that will be created on the fly and wrapped around the target.
507          * @any Element elem A DOM element that will be wrapped.
508          * @any Array<Element> elems An array of elements, the first of which will be wrapped.
509          * @any Object obj Any object, converted to a string, then a text node.
510          * @cat DOM/Manipulation
511          */
512         wrap: function() {
513                 // The elements to wrap the target around
514                 var a = jQuery.clean(arguments);
515                 
516                 // Wrap each of the matched elements individually
517                 return this.each(function(){
518                         // Clone the structure that we're using to wrap
519                         var b = a[0].cloneNode(true);
520                         
521                         // Insert it before the element to be wrapped
522                         this.parentNode.insertBefore( b, this );
523                         
524                         // Find he deepest point in the wrap structure
525                         while ( b.firstChild )
526                                 b = b.firstChild;
527                         
528                         // Move the matched element to within the wrap structure
529                         b.appendChild( this );
530                 });
531         },
532         
533         /**
534          * Append any number of elements to the inside of all matched elements.
535          * This operation is similar to doing an appendChild to all the 
536          * specified elements, adding them into the document.
537          * 
538          * @example $("p").append("<b>Hello</b>");
539          * @before <p>I would like to say: </p>
540          * @result <p>I would like to say: <b>Hello</b></p>
541          *
542          * @name append
543          * @type jQuery
544          * @any String html A string of HTML, that will be created on the fly and appended to the target.
545          * @any Element elem A DOM element that will be appended.
546          * @any Array<Element> elems An array of elements, all of which will be appended.
547          * @any Object obj Any object, converted to a string, then a text node.
548          * @cat DOM/Manipulation
549          */
550         append: function() {
551                 return this.domManip(arguments, true, 1, function(a){
552                         this.appendChild( a );
553                 });
554         },
555         
556         /**
557          * Prepend any number of elements to the inside of all matched elements.
558          * This operation is the best way to insert a set of elements inside, at the 
559          * beginning, of all the matched element.
560          * 
561          * @example $("p").prepend("<b>Hello</b>");
562          * @before <p>, how are you?</p>
563          * @result <p><b>Hello</b>, how are you?</p>
564          *
565          * @name prepend
566          * @type jQuery
567          * @any String html A string of HTML, that will be created on the fly and prepended to the target.
568          * @any Element elem A DOM element that will be prepended.
569          * @any Array<Element> elems An array of elements, all of which will be prepended.
570          * @any Object obj Any object, converted to a string, then a text node.
571          * @cat DOM/Manipulation
572          */
573         prepend: function() {
574                 return this.domManip(arguments, true, -1, function(a){
575                         this.insertBefore( a, this.firstChild );
576                 });
577         },
578         
579         /**
580          * Insert any number of elements before each of the matched elements.
581          * 
582          * @example $("p").before("<b>Hello</b>");
583          * @before <p>how are you?</p>
584          * @result <b>Hello</b><p>how are you?</p>
585          *
586          * @name before
587          * @type jQuery
588          * @any String html A string of HTML, that will be created on the fly and inserted.
589          * @any Element elem A DOM element that will beinserted.
590          * @any Array<Element> elems An array of elements, all of which will be inserted.
591          * @any Object obj Any object, converted to a string, then a text node.
592          * @cat DOM/Manipulation
593          */
594         before: function() {
595                 return this.domManip(arguments, false, 1, function(a){
596                         this.parentNode.insertBefore( a, this );
597                 });
598         },
599         
600         /**
601          * Insert any number of elements after each of the matched elements.
602          * 
603          * @example $("p").after("<p>I'm doing fine.</p>");
604          * @before <p>How are you?</p>
605          * @result <p>How are you?</p><p>I'm doing fine.</p>
606          *
607          * @name after
608          * @type jQuery
609          * @any String html A string of HTML, that will be created on the fly and inserted.
610          * @any Element elem A DOM element that will beinserted.
611          * @any Array<Element> elems An array of elements, all of which will be inserted.
612          * @any Object obj Any object, converted to a string, then a text node.
613          * @cat DOM/Manipulation
614          */
615         after: function() {
616                 return this.domManip(arguments, false, -1, function(a){
617                         this.parentNode.insertBefore( a, this.nextSibling );
618                 });
619         },
620         
621         /**
622          * End the most recent 'destructive' operation, reverting the list of matched elements
623          * back to its previous state. After an end operation, the list of matched elements will 
624          * revert to the last state of matched elements.
625          *
626          * @example $("p").find("span").end();
627          * @before <p><span>Hello</span>, how are you?</p>
628          * @result $("p").find("span").end() == [ <p>...</p> ]
629          *
630          * @name end
631          * @type jQuery
632          * @cat DOM/Traversing
633          */
634         end: function() {
635                 return this.get( this.stack.pop() );
636         },
637         
638         /**
639          * Searches for all elements that match the specified expression.
640          * This method is the optimal way of finding additional descendant
641          * elements with which to process.
642          *
643          * All searching is done using a jQuery expression. The expression can be 
644          * written using CSS 1-3 Selector syntax, or basic XPath.
645          *
646          * @example $("p").find("span");
647          * @before <p><span>Hello</span>, how are you?</p>
648          * @result $("p").find("span") == [ <span>Hello</span> ]
649          *
650          * @name find
651          * @type jQuery
652          * @param String expr An expression to search with.
653          * @cat DOM/Traversing
654          */
655         find: function(t) {
656                 return this.pushStack( jQuery.map( this, function(a){
657                         return jQuery.find(t,a);
658                 }), arguments );
659         },
660
661         clone: function(deep) {
662                 return this.pushStack( jQuery.map( this, function(a){
663                         return a.cloneNode( deep != undefined ? deep : true );
664                 }), arguments );
665         },
666         
667         /**
668          * Removes all elements from the set of matched elements that do not 
669          * match the specified expression. This method is used to narrow down
670          * the results of a search.
671          *
672          * All searching is done using a jQuery expression. The expression
673          * can be written using CSS 1-3 Selector syntax, or basic XPath.
674          * 
675          * @example $("p").filter(".selected")
676          * @before <p class="selected">Hello</p><p>How are you?</p>
677          * @result $("p").filter(".selected") == [ <p class="selected">Hello</p> ]
678          *
679          * @name filter
680          * @type jQuery
681          * @param String expr An expression to search with.
682          * @cat DOM/Traversing
683          */
684
685         /**
686          * Removes all elements from the set of matched elements that do not
687          * match at least one of the expressions passed to the function. This 
688          * method is used when you want to filter the set of matched elements 
689          * through more than one expression.
690          *
691          * Elements will be retained in the jQuery object if they match at
692          * least one of the expressions passed.
693          *
694          * @example $("p").filter([".selected", ":first"])
695          * @before <p>Hello</p><p>Hello Again</p><p class="selected">And Again</p>
696          * @result $("p").filter([".selected", ":first"]) == [ <p>Hello</p>, <p class="selected">And Again</p> ]
697          *
698          * @name filter
699          * @type jQuery
700          * @param Array<String> exprs A set of expressions to evaluate against
701          * @cat DOM/Traversing
702          */
703         filter: function(t) {
704                 return this.pushStack(
705                         t.constructor == Array &&
706                         jQuery.map(this,function(a){
707                                 for ( var i = 0; i < t.length; i++ )
708                                         if ( jQuery.filter(t[i],[a]).r.length )
709                                                 return a;
710                         }) ||
711
712                         t.constructor == Boolean &&
713                         ( t ? this.get() : [] ) ||
714
715                         t.constructor == Function &&
716                         jQuery.grep( this, t ) ||
717
718                         jQuery.filter(t,this).r, arguments );
719         },
720         
721         /**
722          * Removes the specified Element from the set of matched elements. This
723          * method is used to remove a single Element from a jQuery object.
724          *
725          * @example $("p").not( document.getElementById("selected") )
726          * @before <p>Hello</p><p id="selected">Hello Again</p>
727          * @result [ <p>Hello</p> ]
728          *
729          * @name not
730          * @type jQuery
731          * @param Element el An element to remove from the set
732          * @cat DOM/Traversing
733          */
734
735         /**
736          * Removes elements matching the specified expression from the set
737          * of matched elements. This method is used to remove one or more
738          * elements from a jQuery object.
739          * 
740          * @example $("p").not("#selected")
741          * @before <p>Hello</p><p id="selected">Hello Again</p>
742          * @result [ <p>Hello</p> ]
743          * @test cmpOK($("#main > p#ap > a").not("#google").length, "==", 2, ".not")
744          *
745          * @name not
746          * @type jQuery
747          * @param String expr An expression with which to remove matching elements
748          * @cat DOM/Traversing
749          */
750         not: function(t) {
751                 return this.pushStack( t.constructor == String ?
752                         jQuery.filter(t,this,false).r :
753                         jQuery.grep(this,function(a){ return a != t; }), arguments );
754         },
755
756         /**
757          * Adds the elements matched by the expression to the jQuery object. This
758          * can be used to concatenate the result sets of two expressions.
759          *
760          * @example $("p").add("span")
761          * @before <p>Hello</p><p><span>Hello Again</span></p>
762          * @result [ <p>Hello</p>, <span>Hello Again</span> ]
763          *
764          * @name add
765          * @type jQuery
766          * @param String expr An expression whose matched elements are added
767          * @cat DOM/Traversing
768          */
769
770         /**
771          * Adds each of the Elements in the array to the set of matched elements.
772          * This is used to add a set of Elements to a jQuery object.
773          *
774          * @example $("p").add([document.getElementById("a"), document.getElementById("b")])
775          * @before <p>Hello</p><p><span id="a">Hello Again</span><span id="b">And Again</span></p>
776          * @result [ <p>Hello</p>, <span id="a">Hello Again</span>, <span id="b">And Again</span> ]
777          *
778          * @name add
779          * @type jQuery
780          * @param Array<Element> els An array of Elements to add
781          * @cat DOM/Traversing
782          */
783
784         /**
785          * Adds a single Element to the set of matched elements. This is used to
786          * add a single Element to a jQuery object.
787          *
788          * @example $("p").add( document.getElementById("a") )
789          * @before <p>Hello</p><p><span id="a">Hello Again</span></p>
790          * @result [ <p>Hello</p>, <span id="a">Hello Again</span> ]
791          *
792          * @name add
793          * @type jQuery
794          * @param Element el An Element to add
795          * @cat DOM/Traversing
796          */
797         add: function(t) {
798                 return this.pushStack( jQuery.merge( this, t.constructor == String ?
799                         jQuery.find(t) : t.constructor == Array ? t : [t] ), arguments );
800         },
801         
802         /**
803          * A wrapper function for each() to be used by append and prepend.
804          * Handles cases where you're trying to modify the inner contents of
805          * a table, when you actually need to work with the tbody.
806          *
807          * @member jQuery
808          * @param {String} expr The expression with which to filter
809          * @type Boolean
810          * @cat DOM/Traversing
811          */
812         is: function(expr) {
813                 return expr ? jQuery.filter(expr,this).r.length > 0 : this.length > 0;
814         },
815         
816         /**
817          * 
818          *
819          * @private
820          * @name domManip
821          * @param Array args
822          * @param Boolean table
823          * @param Number int
824          * @param Function fn The function doing the DOM manipulation.
825          * @type jQuery
826          */
827         domManip: function(args, table, dir, fn){
828                 var clone = this.size() > 1;
829                 var a = jQuery.clean(args);
830                 
831                 return this.each(function(){
832                         var obj = this;
833                         
834                         if ( table && this.nodeName == "TABLE" && a[0].nodeName != "THEAD" ) {
835                                 var tbody = this.getElementsByTagName("tbody");
836
837                                 if ( !tbody.length ) {
838                                         obj = document.createElement("tbody");
839                                         this.appendChild( obj );
840                                 } else
841                                         obj = tbody[0];
842                         }
843
844                         for ( var i = ( dir < 0 ? a.length - 1 : 0 );
845                                 i != ( dir < 0 ? dir : a.length ); i += dir ) {
846                                         fn.apply( obj, [ clone ? a[i].cloneNode(true) : a[i] ] );
847                         }
848                 });
849         },
850         
851         /**
852          * 
853          *
854          * @private
855          * @name pushStack
856          * @param Array a
857          * @param Array args
858          * @type jQuery
859          */
860         pushStack: function(a,args) {
861                 var fn = args && args[args.length-1];
862
863                 if ( !fn || fn.constructor != Function ) {
864                         if ( !this.stack ) this.stack = [];
865                         this.stack.push( this.get() );
866                         this.get( a );
867                 } else {
868                         var old = this.get();
869                         this.get( a );
870                         if ( fn.constructor == Function )
871                                 this.each( fn );
872                         this.get( old );
873                 }
874
875                 return this;
876         }
877 };
878
879 /**
880  * 
881  *
882  * @private
883  * @name extend
884  * @param Object obj
885  * @param Object prop
886  * @type Object
887  */
888  
889 /**
890  * Extend one object with another, returning the original,
891  * modified, object. This is a great utility for simple inheritance.
892  *
893  * @name jQuery.extend
894  * @param Object obj The object to extend
895  * @param Object prop The object that will be merged into the first.
896  * @type Object
897  * @cat Javascript
898  */
899 jQuery.extend = jQuery.fn.extend = function(obj,prop) {
900         if ( !prop ) { prop = obj; obj = this; }
901         for ( var i in prop ) obj[i] = prop[i];
902         return obj;
903 };
904
905 jQuery.extend({
906         /**
907          * @private
908          * @name init
909          * @type undefined
910          */
911         init: function(){
912                 jQuery.initDone = true;
913                 
914                 jQuery.each( jQuery.macros.axis, function(i,n){
915                         jQuery.fn[ i ] = function(a) {
916                                 var ret = jQuery.map(this,n);
917                                 if ( a && a.constructor == String )
918                                         ret = jQuery.filter(a,ret).r;
919                                 return this.pushStack( ret, arguments );
920                         };
921                 });
922                 
923                 jQuery.each( jQuery.macros.to, function(i,n){
924                         jQuery.fn[ i ] = function(){
925                                 var a = arguments;
926                                 return this.each(function(){
927                                         for ( var j = 0; j < a.length; j++ )
928                                                 jQuery(a[j])[n]( this );
929                                 });
930                         };
931                 });
932                 
933                 jQuery.each( jQuery.macros.each, function(i,n){
934                         jQuery.fn[ i ] = function() {
935                                 return this.each( n, arguments );
936                         };
937                 });
938
939                 jQuery.each( jQuery.macros.filter, function(i,n){
940                         jQuery.fn[ n ] = function(num,fn) {
941                                 return this.filter( ":" + n + "(" + num + ")", fn );
942                         };
943                 });
944                 
945                 jQuery.each( jQuery.macros.attr, function(i,n){
946                         n = n || i;
947                         jQuery.fn[ i ] = function(h) {
948                                 return h == undefined ?
949                                         this.length ? this[0][n] : null :
950                                         this.attr( n, h );
951                         };
952                 });
953         
954                 jQuery.each( jQuery.macros.css, function(i,n){
955                         jQuery.fn[ n ] = function(h) {
956                                 return h == undefined ?
957                                         ( this.length ? jQuery.css( this[0], n ) : null ) :
958                                         this.css( n, h );
959                         };
960                 });
961         
962         },
963         
964         /**
965          * A generic iterator function, which can be used to seemlessly
966          * iterate over both objects and arrays.
967          *
968          * @name jQuery.each
969          * @param Object obj The object, or array, to iterate over.
970          * @param Object fn The function that will be executed on every object.
971          * @type Object
972          * @cat Javascript
973          */
974         each: function( obj, fn, args ) {
975                 if ( obj.length == undefined )
976                         for ( var i in obj )
977                                 fn.apply( obj[i], args || [i, obj[i]] );
978                 else
979                         for ( var i = 0; i < obj.length; i++ )
980                                 fn.apply( obj[i], args || [i, obj[i]] );
981                 return obj;
982         },
983         
984         className: {
985                 add: function(o,c){
986                         if (jQuery.className.has(o,c)) return;
987                         o.className += ( o.className ? " " : "" ) + c;
988                 },
989                 remove: function(o,c){
990                         o.className = !c ? "" :
991                                 o.className.replace(
992                                         new RegExp("(^|\\s*\\b[^-])"+c+"($|\\b(?=[^-]))", "g"), "");
993                 },
994                 has: function(e,a) {
995                         if ( e.className != undefined )
996                                 e = e.className;
997                         return new RegExp("(^|\\s)" + a + "(\\s|$)").test(e);
998                 }
999         },
1000         
1001         /**
1002          * Swap in/out style options.
1003          * @private
1004          */
1005         swap: function(e,o,f) {
1006                 for ( var i in o ) {
1007                         e.style["old"+i] = e.style[i];
1008                         e.style[i] = o[i];
1009                 }
1010                 f.apply( e, [] );
1011                 for ( var i in o )
1012                         e.style[i] = e.style["old"+i];
1013         },
1014         
1015         css: function(e,p) {
1016                 if ( p == "height" || p == "width" ) {
1017                         var old = {}, oHeight, oWidth, d = ["Top","Bottom","Right","Left"];
1018         
1019                         for ( var i in d ) {
1020                                 old["padding" + d[i]] = 0;
1021                                 old["border" + d[i] + "Width"] = 0;
1022                         }
1023         
1024                         jQuery.swap( e, old, function() {
1025                                 if (jQuery.css(e,"display") != "none") {
1026                                         oHeight = e.offsetHeight;
1027                                         oWidth = e.offsetWidth;
1028                                 } else {
1029                                         e = jQuery(e.cloneNode(true)).css({
1030                                                 visibility: "hidden", position: "absolute", display: "block"
1031                                         }).appendTo(e.parentNode)[0];
1032
1033                                         oHeight = e.clientHeight;
1034                                         oWidth = e.clientWidth;
1035                                         
1036                                         e.parentNode.removeChild(e);
1037                                 }
1038                         });
1039         
1040                         return p == "height" ? oHeight : oWidth;
1041                 } else if ( p == "opacity" && jQuery.browser.msie )
1042                         return parseFloat( jQuery.curCSS(e,"filter").replace(/[^0-9.]/,"") ) || 1;
1043
1044                 return jQuery.curCSS( e, p );
1045         },
1046
1047         curCSS: function(elem, prop, force) {
1048                 var ret;
1049         
1050                 if (!force && elem.style[prop]) {
1051
1052                         ret = elem.style[prop];
1053
1054                 } else if (elem.currentStyle) {
1055
1056                         var newProp = prop.replace(/\-(\w)/g,function(m,c){return c.toUpperCase()}); 
1057                         ret = elem.currentStyle[prop] || elem.currentStyle[newProp];
1058
1059                 } else if (document.defaultView && document.defaultView.getComputedStyle) {
1060
1061                         prop = prop.replace(/([A-Z])/g,"-$1").toLowerCase();
1062                         var cur = document.defaultView.getComputedStyle(elem, null);
1063
1064                         if ( cur )
1065                                 ret = cur.getPropertyValue(prop);
1066                         else if ( prop == 'display' )
1067                                 ret = 'none';
1068                         else
1069                                 jQuery.swap(elem, { display: 'block' }, function() {
1070                                         ret = document.defaultView.getComputedStyle(this,null).getPropertyValue(prop);
1071                                 });
1072
1073                 }
1074                 
1075                 return ret;
1076         },
1077         
1078         clean: function(a) {
1079                 var r = [];
1080                 for ( var i = 0; i < a.length; i++ ) {
1081                         if ( a[i].constructor == String ) {
1082
1083                                 var table = "";
1084         
1085                                 if ( !a[i].indexOf("<thead") || !a[i].indexOf("<tbody") ) {
1086                                         table = "thead";
1087                                         a[i] = "<table>" + a[i] + "</table>";
1088                                 } else if ( !a[i].indexOf("<tr") ) {
1089                                         table = "tr";
1090                                         a[i] = "<table>" + a[i] + "</table>";
1091                                 } else if ( !a[i].indexOf("<td") || !a[i].indexOf("<th") ) {
1092                                         table = "td";
1093                                         a[i] = "<table><tbody><tr>" + a[i] + "</tr></tbody></table>";
1094                                 }
1095         
1096                                 var div = document.createElement("div");
1097                                 div.innerHTML = a[i];
1098         
1099                                 if ( table ) {
1100                                         div = div.firstChild;
1101                                         if ( table != "thead" ) div = div.firstChild;
1102                                         if ( table == "td" ) div = div.firstChild;
1103                                 }
1104         
1105                                 for ( var j = 0; j < div.childNodes.length; j++ )
1106                                         r.push( div.childNodes[j] );
1107                                 } else if ( a[i].jquery || a[i].length && !a[i].nodeType )
1108                                         for ( var k = 0; k < a[i].length; k++ )
1109                                                 r.push( a[i][k] );
1110                                 else if ( a[i] !== null )
1111                                         r.push( a[i].nodeType ? a[i] : document.createTextNode(a[i].toString()) );
1112                 }
1113                 return r;
1114         },
1115         
1116         expr: {
1117                 "": "m[2]== '*'||a.nodeName.toUpperCase()==m[2].toUpperCase()",
1118                 "#": "a.getAttribute('id')&&a.getAttribute('id')==m[2]",
1119                 ":": {
1120                         // Position Checks
1121                         lt: "i<m[3]-0",
1122                         gt: "i>m[3]-0",
1123                         nth: "m[3]-0==i",
1124                         eq: "m[3]-0==i",
1125                         first: "i==0",
1126                         last: "i==r.length-1",
1127                         even: "i%2==0",
1128                         odd: "i%2",
1129                         
1130                         // Child Checks
1131                         "nth-child": "jQuery.sibling(a,m[3]).cur",
1132                         "first-child": "jQuery.sibling(a,0).cur",
1133                         "last-child": "jQuery.sibling(a,0).last",
1134                         "only-child": "jQuery.sibling(a).length==1",
1135                         
1136                         // Parent Checks
1137                         parent: "a.childNodes.length",
1138                         empty: "!a.childNodes.length",
1139                         
1140                         // Text Check
1141                         contains: "(a.innerText||a.innerHTML).indexOf(m[3])>=0",
1142                         
1143                         // Visibility
1144                         visible: "a.type!='hidden'&&jQuery.css(a,'display')!='none'&&jQuery.css(a,'visibility')!='hidden'",
1145                         hidden: "a.type=='hidden'||jQuery.css(a,'display')=='none'||jQuery.css(a,'visibility')=='hidden'",
1146                         
1147                         // Form elements
1148                         enabled: "!a.disabled",
1149                         disabled: "a.disabled",
1150                         checked: "a.checked",
1151                         selected: "a.selected"
1152                 },
1153                 ".": "jQuery.className.has(a,m[2])",
1154                 "@": {
1155                         "=": "z==m[4]",
1156                         "!=": "z!=m[4]",
1157                         "^=": "!z.indexOf(m[4])",
1158                         "$=": "z.substr(z.length - m[4].length,m[4].length)==m[4]",
1159                         "*=": "z.indexOf(m[4])>=0",
1160                         "": "z"
1161                 },
1162                 "[": "jQuery.find(m[2],a).length"
1163         },
1164         
1165         token: [
1166                 "\\.\\.|/\\.\\.", "a.parentNode",
1167                 ">|/", "jQuery.sibling(a.firstChild)",
1168                 "\\+", "jQuery.sibling(a).next",
1169                 "~", function(a){
1170                         var r = [];
1171                         var s = jQuery.sibling(a);
1172                         if ( s.n > 0 )
1173                                 for ( var i = s.n; i < s.length; i++ )
1174                                         r.push( s[i] );
1175                         return r;
1176                 }
1177         ],
1178         
1179         /**
1180          *
1181          * @test t( "Element Selector", "div", ["main","foo"] );
1182          * @test t( "Element Selector", "body", ["body"] );
1183          * @test t( "Element Selector", "html", ["html"] );
1184          * @test cmpOK( $("*").size(), ">=", 30, "Element Selector" );
1185          * @test t( "Parent Element", "div div", ["foo"] );
1186          *
1187          * @test t( "ID Selector", "#body", ["body"] );
1188          * @test t( "ID Selector w/ Element", "body#body", ["body"] );
1189          * @test t( "ID Selector w/ Element", "ul#first", [] );
1190          *
1191          * @test t( "Class Selector", ".blog", ["mark","simon"] );
1192          * @test t( "Class Selector", ".blog.link", ["simon"] );
1193          * @test t( "Class Selector w/ Element", "a.blog", ["mark","simon"] );
1194          * @test t( "Parent Class Selector", "p .blog", ["mark","simon"] );
1195          *
1196          * @test t( "Comma Support", "a.blog, div", ["mark","simon","main","foo"] );
1197          * @test t( "Comma Support", "a.blog , div", ["mark","simon","main","foo"] );
1198          * @test t( "Comma Support", "a.blog ,div", ["mark","simon","main","foo"] );
1199          * @test t( "Comma Support", "a.blog,div", ["mark","simon","main","foo"] );
1200          *
1201          * @test t( "Child", "p > a", ["simon1","google","groups","mark","yahoo","simon"] );
1202          * @test t( "Child", "p> a", ["simon1","google","groups","mark","yahoo","simon"] );
1203          * @test t( "Child", "p >a", ["simon1","google","groups","mark","yahoo","simon"] );
1204          * @test t( "Child", "p>a", ["simon1","google","groups","mark","yahoo","simon"] );
1205          * @test t( "Child w/ Class", "p > a.blog", ["mark","simon"] );
1206          * @test t( "All Children", "code > *", ["anchor1","anchor2"] );
1207          * @test t( "All Grandchildren", "p > * > *", ["anchor1","anchor2"] );
1208          * @test t( "Adjacent", "a + a", ["groups"] );
1209          * @test t( "Adjacent", "a +a", ["groups"] );
1210          * @test t( "Adjacent", "a+ a", ["groups"] );
1211          * @test t( "Adjacent", "a+a", ["groups"] );
1212          * @test t( "Adjacent", "p + p", ["ap","en","sap"] );
1213          * @test t( "Comma, Child, and Adjacent", "a + a, code > a", ["groups","anchor1","anchor2"] );
1214          * @test t( "First Child", "p:first-child", ["firstp","sndp"] );
1215          * @test t( "Attribute Exists", "a[@title]", ["google"] );
1216          * @test t( "Attribute Exists", "*[@title]", ["google"] );
1217          * @test t( "Attribute Exists", "[@title]", ["google"] );
1218          * @test t( "Attribute Equals", "a[@rel='bookmark']", ["simon1"] );
1219          * @test t( "Attribute Equals", 'a[@rel="bookmark"]', ["simon1"] );
1220          * @test t( "Attribute Equals", "a[@rel=bookmark]", ["simon1"] );
1221          * @test t( "Multiple Attribute Equals", "input[@type='hidden'],input[@type='radio']", ["hidden1","radio1","radio2"] );
1222          * @test t( "Multiple Attribute Equals", "input[@type=\"hidden\"],input[@type='radio']", ["hidden1","radio1","radio2"] );
1223          * @test t( "Multiple Attribute Equals", "input[@type=hidden],input[@type=radio]", ["hidden1","radio1","radio2"] );
1224          *
1225          * @test t( "Attribute Begins With", "a[@href ^= 'http://www']", ["google","yahoo"] );
1226          * @test t( "Attribute Ends With", "a[@href $= 'org/']", ["mark"] );
1227          * @test t( "Attribute Contains", "a[@href *= 'google']", ["google","groups"] );
1228          * @test t( "First Child", "p:first-child", ["firstp","sndp"] );
1229          * @test t( "Last Child", "p:last-child", ["sap"] );
1230          * @test t( "Only Child", "a:only-child", ["simon1","anchor1","yahoo","anchor2"] );
1231          * @test t( "Empty", "ul:empty", ["firstUL"] );
1232          * @test t( "Enabled UI Element", "input:enabled", ["text1","radio1","radio2","check1","check2","hidden1","hidden2"] );
1233          * @test t( "Disabled UI Element", "input:disabled", ["text2"] );
1234          * @test t( "Checked UI Element", "input:checked", ["radio2","check1"] );
1235          * @test t( "Text Contains", "a:contains('Google')", ["google","groups"] );
1236          * @test t( "Text Contains", "a:contains('Google Groups')", ["groups"] );
1237          * @test t( "Element Preceded By", "p ~ div", ["foo"] );
1238          * @test t( "Not", "a.blog:not(.link)", ["mark"] );
1239          *
1240          * @test cmpOK( jQuery.find("//*").length, ">=", 30, "All Elements (//*)" );
1241          * @test t( "All Div Elements", "//div", ["main","foo"] );
1242          * @test t( "Absolute Path", "/html/body", ["body"] );
1243          * @test t( "Absolute Path w/ *", "/* /body", ["body"] );
1244          * @test t( "Long Absolute Path", "/html/body/dl/div/div/p", ["sndp","en","sap"] );
1245          * @test t( "Absolute and Relative Paths", "/html//div", ["main","foo"] );
1246          * @test t( "All Children, Explicit", "//code/*", ["anchor1","anchor2"] );
1247          * @test t( "All Children, Implicit", "//code/", ["anchor1","anchor2"] );
1248          * @test t( "Attribute Exists", "//a[@title]", ["google"] );
1249          * @test t( "Attribute Equals", "//a[@rel='bookmark']", ["simon1"] );
1250          * @test t( "Parent Axis", "//p/..", ["main","foo"] );
1251          * @test t( "Sibling Axis", "//p/../", ["firstp","ap","foo","first","firstUL","empty","form","sndp","en","sap"] );
1252          * @test t( "Sibling Axis", "//p/../*", ["firstp","ap","foo","first","firstUL","empty","form","sndp","en","sap"] );
1253          * @test t( "Has Children", "//p[a]", ["firstp","ap","en","sap"] );
1254          *
1255          * @test t( "nth Element", "p:nth(1)", ["ap"] );
1256          * @test t( "First Element", "p:first", ["firstp"] );
1257          * @test t( "Last Element", "p:last", ["first"] );
1258          * @test t( "Even Elements", "p:even", ["firstp","sndp","sap"] );
1259          * @test t( "Odd Elements", "p:odd", ["ap","en","first"] );
1260          * @test t( "Position Equals", "p:eq(1)", ["ap"] );
1261          * @test t( "Position Greater Than", "p:gt(0)", ["ap","sndp","en","sap","first"] );
1262          * @test t( "Position Less Than", "p:lt(3)", ["firstp","ap","sndp"] );
1263          * @test t( "Is A Parent", "p:parent", ["firstp","ap","sndp","en","sap","first"] );
1264          * @test t( "Is Visible", "input:visible", ["text1","text2","radio1","radio2","check1","check2"] );
1265          * @test t( "Is Hidden", "input:hidden", ["hidden1","hidden2"] );
1266          *
1267          * @name jQuery.find
1268          * @private
1269          */
1270         find: function( t, context ) {
1271                 // Make sure that the context is a DOM Element
1272                 if ( context && context.nodeType == undefined )
1273                         context = null;
1274         
1275                 // Set the correct context (if none is provided)
1276                 context = context || jQuery.context || document;
1277         
1278                 if ( t.constructor != String ) return [t];
1279         
1280                 if ( !t.indexOf("//") ) {
1281                         context = context.documentElement;
1282                         t = t.substr(2,t.length);
1283                 } else if ( !t.indexOf("/") ) {
1284                         context = context.documentElement;
1285                         t = t.substr(1,t.length);
1286                         // FIX Assume the root element is right :(
1287                         if ( t.indexOf("/") >= 1 )
1288                                 t = t.substr(t.indexOf("/"),t.length);
1289                 }
1290         
1291                 var ret = [context];
1292                 var done = [];
1293                 var last = null;
1294         
1295                 while ( t.length > 0 && last != t ) {
1296                         var r = [];
1297                         last = t;
1298         
1299                         t = jQuery.trim(t).replace( /^\/\//i, "" );
1300                         
1301                         var foundToken = false;
1302                         
1303                         for ( var i = 0; i < jQuery.token.length; i += 2 ) {
1304                                 if ( foundToken ) continue;
1305
1306                                 var re = new RegExp("^(" + jQuery.token[i] + ")");
1307                                 var m = re.exec(t);
1308                                 
1309                                 if ( m ) {
1310                                         r = ret = jQuery.map( ret, jQuery.token[i+1] );
1311                                         t = jQuery.trim( t.replace( re, "" ) );
1312                                         foundToken = true;
1313                                 }
1314                         }
1315                         
1316                         if ( !foundToken ) {
1317                                 if ( !t.indexOf(",") || !t.indexOf("|") ) {
1318                                         if ( ret[0] == context ) ret.shift();
1319                                         done = jQuery.merge( done, ret );
1320                                         r = ret = [context];
1321                                         t = " " + t.substr(1,t.length);
1322                                 } else {
1323                                         var re2 = /^([#.]?)([a-z0-9\\*_-]*)/i;
1324                                         var m = re2.exec(t);
1325                 
1326                                         if ( m[1] == "#" ) {
1327                                                 // Ummm, should make this work in all XML docs
1328                                                 var oid = document.getElementById(m[2]);
1329                                                 r = ret = oid ? [oid] : [];
1330                                                 t = t.replace( re2, "" );
1331                                         } else {
1332                                                 if ( !m[2] || m[1] == "." ) m[2] = "*";
1333                 
1334                                                 for ( var i = 0; i < ret.length; i++ )
1335                                                         r = jQuery.merge( r,
1336                                                                 m[2] == "*" ?
1337                                                                         jQuery.getAll(ret[i]) :
1338                                                                         ret[i].getElementsByTagName(m[2])
1339                                                         );
1340                                         }
1341                                 }
1342         
1343                         }
1344
1345                         if ( t ) {
1346                                 var val = jQuery.filter(t,r);
1347                                 ret = r = val.r;
1348                                 t = jQuery.trim(val.t);
1349                         }
1350                 }
1351         
1352                 if ( ret && ret[0] == context ) ret.shift();
1353                 done = jQuery.merge( done, ret );
1354         
1355                 return done;
1356         },
1357         
1358         getAll: function(o,r) {
1359                 r = r || [];
1360                 var s = o.childNodes;
1361                 for ( var i = 0; i < s.length; i++ )
1362                         if ( s[i].nodeType == 1 ) {
1363                                 r.push( s[i] );
1364                                 jQuery.getAll( s[i], r );
1365                         }
1366                 return r;
1367         },
1368         
1369         attr: function(elem, name, value){
1370                 var fix = {
1371                         "for": "htmlFor",
1372                         "class": "className",
1373                         "float": "cssFloat",
1374                         innerHTML: "innerHTML",
1375                         className: "className",
1376                         value: "value",
1377                         disabled: "disabled"
1378                 };
1379
1380                 if ( fix[name] ) {
1381                         if ( value != undefined ) elem[fix[name]] = value;
1382                         return elem[fix[name]];
1383                 } else if ( elem.getAttribute ) {
1384                         if ( value != undefined ) elem.setAttribute( name, value );
1385                         return elem.getAttribute( name, 2 );
1386                 } else {
1387                         name = name.replace(/-([a-z])/ig,function(z,b){return b.toUpperCase();});
1388                         if ( value != undefined ) elem[name] = value;
1389                         return elem[name];
1390                 }
1391         },
1392
1393         // The regular expressions that power the parsing engine
1394         parse: [
1395                 // Match: [@value='test'], [@foo]
1396                 [ "\\[ *(@)S *([!*$^=]*) *Q\\]", 1 ],
1397
1398                 // Match: [div], [div p]
1399                 [ "(\\[)Q\\]", 0 ],
1400
1401                 // Match: :contains('foo')
1402                 [ "(:)S\\(Q\\)", 0 ],
1403
1404                 // Match: :even, :last-chlid
1405                 [ "([:.#]*)S", 0 ]
1406         ],
1407         
1408         filter: function(t,r,not) {
1409                 // Figure out if we're doing regular, or inverse, filtering
1410                 var g = not !== false ? jQuery.grep :
1411                         function(a,f) {return jQuery.grep(a,f,true);};
1412                 
1413                 while ( t && /^[a-z[({<*:.#]/i.test(t) ) {
1414
1415                         var p = jQuery.parse;
1416
1417                         for ( var i = 0; i < p.length; i++ ) {
1418                                 var re = new RegExp( "^" + p[i][0]
1419
1420                                         // Look for a string-like sequence
1421                                         .replace( 'S', "([a-z*_-][a-z0-9_-]*)" )
1422
1423                                         // Look for something (optionally) enclosed with quotes
1424                                         .replace( 'Q', " *'?\"?([^'\"]*?)'?\"? *" ), "i" );
1425
1426                                 var m = re.exec( t );
1427
1428                                 if ( m ) {
1429                                         // Re-organize the match
1430                                         if ( p[i][1] )
1431                                                 m = ["", m[1], m[3], m[2], m[4]];
1432
1433                                         // Remove what we just matched
1434                                         t = t.replace( re, "" );
1435
1436                                         break;
1437                                 }
1438                         }
1439         
1440                         // :not() is a special case that can be optomized by
1441                         // keeping it out of the expression list
1442                         if ( m[1] == ":" && m[2] == "not" )
1443                                 r = jQuery.filter(m[3],r,false).r;
1444                         
1445                         // Otherwise, find the expression to execute
1446                         else {
1447                                 var f = jQuery.expr[m[1]];
1448                                 if ( f.constructor != String )
1449                                         f = jQuery.expr[m[1]][m[2]];
1450                                         
1451                                 // Build a custom macro to enclose it
1452                                 eval("f = function(a,i){" + 
1453                                         ( m[1] == "@" ? "z=jQuery.attr(a,m[3]);" : "" ) + 
1454                                         "return " + f + "}");
1455                                 
1456                                 // Execute it against the current filter
1457                                 r = g( r, f );
1458                         }
1459                 }
1460         
1461                 // Return an array of filtered elements (r)
1462                 // and the modified expression string (t)
1463                 return { r: r, t: t };
1464         },
1465         
1466         /**
1467          * Remove the whitespace from the beginning and end of a string.
1468          *
1469          * @private
1470          * @name jQuery.trim
1471          * @type String
1472          * @param String str The string to trim.
1473          */
1474         trim: function(t){
1475                 return t.replace(/^\s+|\s+$/g, "");
1476         },
1477         
1478         /**
1479          * All ancestors of a given element.
1480          *
1481          * @private
1482          * @name jQuery.parents
1483          * @type Array<Element>
1484          * @param Element elem The element to find the ancestors of.
1485          */
1486         parents: function( elem ){
1487                 var matched = [];
1488                 var cur = elem.parentNode;
1489                 while ( cur && cur != document ) {
1490                         matched.push( cur );
1491                         cur = cur.parentNode;
1492                 }
1493                 return matched;
1494         },
1495         
1496         /**
1497          * All elements on a specified axis.
1498          *
1499          * @private
1500          * @name jQuery.sibling
1501          * @type Array
1502          * @param Element elem The element to find all the siblings of (including itself).
1503          */
1504         sibling: function(elem, pos, not) {
1505                 var elems = [];
1506
1507                 var siblings = elem.parentNode.childNodes;
1508                 for ( var i = 0; i < siblings.length; i++ ) {
1509                         if ( not === true && siblings[i] == elem ) continue;
1510
1511                         if ( siblings[i].nodeType == 1 )
1512                                 elems.push( siblings[i] );
1513                         if ( siblings[i] == elem )
1514                                 elems.n = elems.length - 1;
1515                 }
1516
1517                 return jQuery.extend( elems, {
1518                         last: elems.n == elems.length - 1,
1519                         cur: pos == "even" && elems.n % 2 == 0 || pos == "odd" && elems.n % 2 || elems[pos] == elem,
1520                         prev: elems[elems.n - 1],
1521                         next: elems[elems.n + 1]
1522                 });
1523         },
1524         
1525         /**
1526          * Merge two arrays together, removing all duplicates.
1527          *
1528          * @private
1529          * @name jQuery.merge
1530          * @type Array
1531          * @param Array a The first array to merge.
1532          * @param Array b The second array to merge.
1533          */
1534         merge: function(first, second) {
1535                 var result = [];
1536                 
1537                 // Move b over to the new array (this helps to avoid
1538                 // StaticNodeList instances)
1539                 for ( var k = 0; k < first.length; k++ )
1540                         result[k] = first[k];
1541         
1542                 // Now check for duplicates between a and b and only
1543                 // add the unique items
1544                 for ( var i = 0; i < second.length; i++ ) {
1545                         var noCollision = true;
1546                         
1547                         // The collision-checking process
1548                         for ( var j = 0; j < first.length; j++ )
1549                                 if ( second[i] == first[j] )
1550                                         noCollision = false;
1551                                 
1552                         // If the item is unique, add it
1553                         if ( noCollision )
1554                                 result.push( second[i] );
1555                 }
1556         
1557                 return result;
1558         },
1559         
1560         /**
1561          * Remove items that aren't matched in an array. The function passed
1562          * in to this method will be passed two arguments: 'a' (which is the
1563          * array item) and 'i' (which is the index of the item in the array).
1564          *
1565          * @private
1566          * @name jQuery.grep
1567          * @type Array
1568          * @param Array array The Array to find items in.
1569          * @param Function fn The function to process each item against.
1570          * @param Boolean inv Invert the selection - select the opposite of the function.
1571          */
1572         grep: function(elems, fn, inv) {
1573                 // If a string is passed in for the function, make a function
1574                 // for it (a handy shortcut)
1575                 if ( fn.constructor == String )
1576                         fn = new Function("a","i","return " + fn);
1577                         
1578                 var result = [];
1579                 
1580                 // Go through the array, only saving the items
1581                 // that pass the validator function
1582                 for ( var i = 0; i < elems.length; i++ )
1583                         if ( !inv && fn(elems[i],i) || inv && !fn(elems[i],i) )
1584                                 result.push( elems[i] );
1585                 
1586                 return result;
1587         },
1588         
1589         /**
1590          * Translate all items in array to another array of items. The translation function
1591          * that is provided to this method is passed one argument: 'a' (the item to be 
1592          * translated). If an array is returned, that array is mapped out and merged into
1593          * the full array. Additionally, returning 'null' or 'undefined' will delete the item
1594          * from the array. Both of these changes imply that the size of the array may not
1595          * be the same size upon completion, as it was when it started.
1596          *
1597          * @private
1598          * @name jQuery.map
1599          * @type Array
1600          * @param Array array The Array to translate.
1601          * @param Function fn The function to process each item against.
1602          */
1603         map: function(elems, fn) {
1604                 // If a string is passed in for the function, make a function
1605                 // for it (a handy shortcut)
1606                 if ( fn.constructor == String )
1607                         fn = new Function("a","return " + fn);
1608                 
1609                 var result = [];
1610                 
1611                 // Go through the array, translating each of the items to their
1612                 // new value (or values).
1613                 for ( var i = 0; i < elems.length; i++ ) {
1614                         var val = fn(elems[i],i);
1615
1616                         if ( val !== null && val != undefined ) {
1617                                 if ( val.constructor != Array ) val = [val];
1618                                 result = jQuery.merge( result, val );
1619                         }
1620                 }
1621
1622                 return result;
1623         },
1624         
1625         /*
1626          * A number of helper functions used for managing events.
1627          * Many of the ideas behind this code orignated from Dean Edwards' addEvent library.
1628          */
1629         event: {
1630         
1631                 // Bind an event to an element
1632                 // Original by Dean Edwards
1633                 add: function(element, type, handler) {
1634                         // For whatever reason, IE has trouble passing the window object
1635                         // around, causing it to be cloned in the process
1636                         if ( jQuery.browser.msie && element.setInterval != undefined )
1637                                 element = window;
1638                 
1639                         // Make sure that the function being executed has a unique ID
1640                         if ( !handler.guid )
1641                                 handler.guid = this.guid++;
1642                                 
1643                         // Init the element's event structure
1644                         if (!element.events)
1645                                 element.events = {};
1646                         
1647                         // Get the current list of functions bound to this event
1648                         var handlers = element.events[type];
1649                         
1650                         // If it hasn't been initialized yet
1651                         if (!handlers) {
1652                                 // Init the event handler queue
1653                                 handlers = element.events[type] = {};
1654                                 
1655                                 // Remember an existing handler, if it's already there
1656                                 if (element["on" + type])
1657                                         handlers[0] = element["on" + type];
1658                         }
1659
1660                         // Add the function to the element's handler list
1661                         handlers[handler.guid] = handler;
1662                         
1663                         // And bind the global event handler to the element
1664                         element["on" + type] = this.handle;
1665         
1666                         // Remember the function in a global list (for triggering)
1667                         if (!this.global[type])
1668                                 this.global[type] = [];
1669                         this.global[type].push( element );
1670                 },
1671                 
1672                 guid: 1,
1673                 global: {},
1674                 
1675                 // Detach an event or set of events from an element
1676                 remove: function(element, type, handler) {
1677                         if (element.events)
1678                                 if (type && element.events[type])
1679                                         if ( handler )
1680                                                 delete element.events[type][handler.guid];
1681                                         else
1682                                                 for ( var i in element.events[type] )
1683                                                         delete element.events[type][i];
1684                                 else
1685                                         for ( var j in element.events )
1686                                                 this.remove( element, j );
1687                 },
1688                 
1689                 trigger: function(type,data,element) {
1690                         // Touch up the incoming data
1691                         data = data || [];
1692         
1693                         // Handle a global trigger
1694                         if ( !element ) {
1695                                 var g = this.global[type];
1696                                 if ( g )
1697                                         for ( var i = 0; i < g.length; i++ )
1698                                                 this.trigger( type, data, g[i] );
1699         
1700                         // Handle triggering a single element
1701                         } else if ( element["on" + type] ) {
1702                                 // Pass along a fake event
1703                                 data.unshift( this.fix({ type: type, target: element }) );
1704         
1705                                 // Trigger the event
1706                                 element["on" + type].apply( element, data );
1707                         }
1708                 },
1709                 
1710                 handle: function(event) {
1711                         if ( typeof jQuery == "undefined" ) return;
1712
1713                         event = event || jQuery.event.fix( window.event );
1714         
1715                         // If no correct event was found, fail
1716                         if ( !event ) return;
1717                 
1718                         var returnValue = true;
1719
1720                         var c = this.events[event.type];
1721                 
1722                         for ( var j in c ) {
1723                                 if ( c[j].apply( this, [event] ) === false ) {
1724                                         event.preventDefault();
1725                                         event.stopPropagation();
1726                                         returnValue = false;
1727                                 }
1728                         }
1729                         
1730                         return returnValue;
1731                 },
1732                 
1733                 fix: function(event) {
1734                         if ( event ) {
1735                                 event.preventDefault = function() {
1736                                         this.returnValue = false;
1737                                 };
1738                         
1739                                 event.stopPropagation = function() {
1740                                         this.cancelBubble = true;
1741                                 };
1742                         }
1743                         
1744                         return event;
1745                 }
1746         
1747         }
1748 });
1749
1750 new function() {
1751         var b = navigator.userAgent.toLowerCase();
1752
1753         // Figure out what browser is being used
1754         jQuery.browser = {
1755                 safari: /webkit/.test(b),
1756                 opera: /opera/.test(b),
1757                 msie: /msie/.test(b) && !/opera/.test(b),
1758                 mozilla: /mozilla/.test(b) && !/(compatible|webkit)/.test(b)
1759         };
1760
1761         // Check to see if the W3C box model is being used
1762         jQuery.boxModel = !jQuery.browser.msie || document.compatMode == "CSS1Compat";
1763 };
1764
1765 jQuery.macros = {
1766         to: {
1767                 /**
1768                  * Append all of the matched elements to another, specified, set of elements.
1769                  * This operation is, essentially, the reverse of doing a regular
1770                  * $(A).append(B), in that instead of appending B to A, you're appending
1771                  * A to B.
1772                  * 
1773                  * @example $("p").appendTo("#foo");
1774                  * @before <p>I would like to say: </p><div id="foo"></div>
1775                  * @result <div id="foo"><p>I would like to say: </p></div>
1776                  *
1777                  * @name appendTo
1778                  * @type jQuery
1779                  * @param String expr A jQuery expression of elements to match.
1780                  * @cat DOM/Manipulation
1781                  */
1782                 appendTo: "append",
1783                 
1784                 /**
1785                  * Prepend all of the matched elements to another, specified, set of elements.
1786                  * This operation is, essentially, the reverse of doing a regular
1787                  * $(A).prepend(B), in that instead of prepending B to A, you're prepending
1788                  * A to B.
1789                  * 
1790                  * @example $("p").prependTo("#foo");
1791                  * @before <p>I would like to say: </p><div id="foo"><b>Hello</b></div>
1792                  * @result <div id="foo"><p>I would like to say: </p><b>Hello</b></div>
1793                  *
1794                  * @name prependTo
1795                  * @type jQuery
1796                  * @param String expr A jQuery expression of elements to match.
1797                  * @cat DOM/Manipulation
1798                  */
1799                 prependTo: "prepend",
1800                 
1801                 /**
1802                  * Insert all of the matched elements before another, specified, set of elements.
1803                  * This operation is, essentially, the reverse of doing a regular
1804                  * $(A).before(B), in that instead of inserting B before A, you're inserting
1805                  * A before B.
1806                  * 
1807                  * @example $("p").insertBefore("#foo");
1808                  * @before <div id="foo">Hello</div><p>I would like to say: </p>
1809                  * @result <p>I would like to say: </p><div id="foo">Hello</div>
1810                  *
1811                  * @name insertBefore
1812                  * @type jQuery
1813                  * @param String expr A jQuery expression of elements to match.
1814                  * @cat DOM/Manipulation
1815                  */
1816                 insertBefore: "before",
1817                 
1818                 /**
1819                  * Insert all of the matched elements after another, specified, set of elements.
1820                  * This operation is, essentially, the reverse of doing a regular
1821                  * $(A).after(B), in that instead of inserting B after A, you're inserting
1822                  * A after B.
1823                  * 
1824                  * @example $("p").insertAfter("#foo");
1825                  * @before <p>I would like to say: </p><div id="foo">Hello</div>
1826                  * @result <div id="foo">Hello</div><p>I would like to say: </p>
1827                  *
1828                  * @name insertAfter
1829                  * @type jQuery
1830                  * @param String expr A jQuery expression of elements to match.
1831                  * @cat DOM/Manipulation
1832                  */
1833                 insertAfter: "after"
1834         },
1835         
1836         /**
1837          * Get the current CSS width of the first matched element.
1838          * 
1839          * @example $("p").width();
1840          * @before <p>This is just a test.</p>
1841          * @result "300px"
1842          *
1843          * @name width
1844          * @type String
1845          * @cat CSS
1846          */
1847          
1848         /**
1849          * Set the CSS width of every matched element. Be sure to include
1850          * the "px" (or other unit of measurement) after the number that you 
1851          * specify, otherwise you might get strange results.
1852          * 
1853          * @example $("p").width("20px");
1854          * @before <p>This is just a test.</p>
1855          * @result <p style="width:20px;">This is just a test.</p>
1856          *
1857          * @name width
1858          * @type jQuery
1859          * @param String val Set the CSS property to the specified value.
1860          * @cat CSS
1861          */
1862         
1863         /**
1864          * Get the current CSS height of the first matched element.
1865          * 
1866          * @example $("p").height();
1867          * @before <p>This is just a test.</p>
1868          * @result "14px"
1869          *
1870          * @name height
1871          * @type String
1872          * @cat CSS
1873          */
1874          
1875         /**
1876          * Set the CSS height of every matched element. Be sure to include
1877          * the "px" (or other unit of measurement) after the number that you 
1878          * specify, otherwise you might get strange results.
1879          * 
1880          * @example $("p").height("20px");
1881          * @before <p>This is just a test.</p>
1882          * @result <p style="height:20px;">This is just a test.</p>
1883          *
1884          * @name height
1885          * @type jQuery
1886          * @param String val Set the CSS property to the specified value.
1887          * @cat CSS
1888          */
1889          
1890         /**
1891          * Get the current CSS top of the first matched element.
1892          * 
1893          * @example $("p").top();
1894          * @before <p>This is just a test.</p>
1895          * @result "0px"
1896          *
1897          * @name top
1898          * @type String
1899          * @cat CSS
1900          */
1901          
1902         /**
1903          * Set the CSS top of every matched element. Be sure to include
1904          * the "px" (or other unit of measurement) after the number that you 
1905          * specify, otherwise you might get strange results.
1906          * 
1907          * @example $("p").top("20px");
1908          * @before <p>This is just a test.</p>
1909          * @result <p style="top:20px;">This is just a test.</p>
1910          *
1911          * @name top
1912          * @type jQuery
1913          * @param String val Set the CSS property to the specified value.
1914          * @cat CSS
1915          */
1916          
1917         /**
1918          * Get the current CSS left of the first matched element.
1919          * 
1920          * @example $("p").left();
1921          * @before <p>This is just a test.</p>
1922          * @result "0px"
1923          *
1924          * @name left
1925          * @type String
1926          * @cat CSS
1927          */
1928          
1929         /**
1930          * Set the CSS left of every matched element. Be sure to include
1931          * the "px" (or other unit of measurement) after the number that you 
1932          * specify, otherwise you might get strange results.
1933          * 
1934          * @example $("p").left("20px");
1935          * @before <p>This is just a test.</p>
1936          * @result <p style="left:20px;">This is just a test.</p>
1937          *
1938          * @name left
1939          * @type jQuery
1940          * @param String val Set the CSS property to the specified value.
1941          * @cat CSS
1942          */
1943          
1944         /**
1945          * Get the current CSS position of the first matched element.
1946          * 
1947          * @example $("p").position();
1948          * @before <p>This is just a test.</p>
1949          * @result "static"
1950          *
1951          * @name position
1952          * @type String
1953          * @cat CSS
1954          */
1955          
1956         /**
1957          * Set the CSS position of every matched element.
1958          * 
1959          * @example $("p").position("relative");
1960          * @before <p>This is just a test.</p>
1961          * @result <p style="position:relative;">This is just a test.</p>
1962          *
1963          * @name position
1964          * @type jQuery
1965          * @param String val Set the CSS property to the specified value.
1966          * @cat CSS
1967          */
1968          
1969         /**
1970          * Get the current CSS float of the first matched element.
1971          * 
1972          * @example $("p").float();
1973          * @before <p>This is just a test.</p>
1974          * @result "none"
1975          *
1976          * @name float
1977          * @type String
1978          * @cat CSS
1979          */
1980          
1981         /**
1982          * Set the CSS float of every matched element.
1983          * 
1984          * @example $("p").float("left");
1985          * @before <p>This is just a test.</p>
1986          * @result <p style="float:left;">This is just a test.</p>
1987          *
1988          * @name float
1989          * @type jQuery
1990          * @param String val Set the CSS property to the specified value.
1991          * @cat CSS
1992          */
1993          
1994         /**
1995          * Get the current CSS overflow of the first matched element.
1996          * 
1997          * @example $("p").overflow();
1998          * @before <p>This is just a test.</p>
1999          * @result "none"
2000          *
2001          * @name overflow
2002          * @type String
2003          * @cat CSS
2004          */
2005          
2006         /**
2007          * Set the CSS overflow of every matched element.
2008          * 
2009          * @example $("p").overflow("auto");
2010          * @before <p>This is just a test.</p>
2011          * @result <p style="overflow:auto;">This is just a test.</p>
2012          *
2013          * @name overflow
2014          * @type jQuery
2015          * @param String val Set the CSS property to the specified value.
2016          * @cat CSS
2017          */
2018          
2019         /**
2020          * Get the current CSS color of the first matched element.
2021          * 
2022          * @example $("p").color();
2023          * @before <p>This is just a test.</p>
2024          * @result "black"
2025          *
2026          * @name color
2027          * @type String
2028          * @cat CSS
2029          */
2030          
2031         /**
2032          * Set the CSS color of every matched element.
2033          * 
2034          * @example $("p").color("blue");
2035          * @before <p>This is just a test.</p>
2036          * @result <p style="color:blue;">This is just a test.</p>
2037          *
2038          * @name color
2039          * @type jQuery
2040          * @param String val Set the CSS property to the specified value.
2041          * @cat CSS
2042          */
2043          
2044         /**
2045          * Get the current CSS background of the first matched element.
2046          * 
2047          * @example $("p").background();
2048          * @before <p>This is just a test.</p>
2049          * @result ""
2050          *
2051          * @name background
2052          * @type String
2053          * @cat CSS
2054          */
2055          
2056         /**
2057          * Set the CSS background of every matched element.
2058          * 
2059          * @example $("p").background("blue");
2060          * @before <p>This is just a test.</p>
2061          * @result <p style="background:blue;">This is just a test.</p>
2062          *
2063          * @name background
2064          * @type jQuery
2065          * @param String val Set the CSS property to the specified value.
2066          * @cat CSS
2067          */
2068         
2069         css: "width,height,top,left,position,float,overflow,color,background".split(","),
2070
2071         filter: [ "eq", "lt", "gt", "contains" ],
2072
2073         attr: {
2074                 /**
2075                  * Get the current value of the first matched element.
2076                  * 
2077                  * @example $("input").val();
2078                  * @before <input type="text" value="some text"/>
2079                  * @result "some text"
2080                  *
2081                  * @name val
2082                  * @type String
2083                  * @cat DOM/Attributes
2084                  */
2085                  
2086                 /**
2087                  * Set the value of every matched element.
2088                  * 
2089                  * @example $("input").value("test");
2090                  * @before <input type="text" value="some text"/>
2091                  * @result <input type="text" value="test"/>
2092                  *
2093                  * @name val
2094                  * @type jQuery
2095                  * @param String val Set the property to the specified value.
2096                  * @cat DOM/Attributes
2097                  */
2098                 val: "value",
2099                 
2100                 /**
2101                  * Get the html contents of the first matched element.
2102                  * 
2103                  * @example $("div").html();
2104                  * @before <div><input/></div>
2105                  * @result <input/>
2106                  *
2107                  * @name html
2108                  * @type String
2109                  * @cat DOM/Attributes
2110                  */
2111                  
2112                 /**
2113                  * Set the html contents of every matched element.
2114                  * 
2115                  * @example $("div").html("<b>new stuff</b>");
2116                  * @before <div><input/></div>
2117                  * @result <div><b>new stuff</b></div>
2118                  *
2119                  * @test var div = $("div");
2120                  * div.html("<b>test</b>");
2121                  * var pass = true;
2122                  * for ( var i = 0; i < div.size(); i++ ) {
2123                  *   if ( div.get(i).childNodes.length == 0 ) pass = false;
2124                  * }
2125                  * ok( pass, "Set HTML" );
2126                  *
2127                  * @name html
2128                  * @type jQuery
2129                  * @param String val Set the html contents to the specified value.
2130                  * @cat DOM/Attributes
2131                  */
2132                 html: "innerHTML",
2133                 
2134                 /**
2135                  * Get the current id of the first matched element.
2136                  * 
2137                  * @example $("input").id();
2138                  * @before <input type="text" id="test" value="some text"/>
2139                  * @result "test"
2140                  *
2141                  * @name id
2142                  * @type String
2143                  * @cat DOM/Attributes
2144                  */
2145                  
2146                 /**
2147                  * Set the id of every matched element.
2148                  * 
2149                  * @example $("input").id("newid");
2150                  * @before <input type="text" id="test" value="some text"/>
2151                  * @result <input type="text" id="newid" value="some text"/>
2152                  *
2153                  * @name id
2154                  * @type jQuery
2155                  * @param String val Set the property to the specified value.
2156                  * @cat DOM/Attributes
2157                  */
2158                 id: null,
2159                 
2160                 /**
2161                  * Get the current title of the first matched element.
2162                  * 
2163                  * @example $("img").title();
2164                  * @before <img src="test.jpg" title="my image"/>
2165                  * @result "my image"
2166                  *
2167                  * @name title
2168                  * @type String
2169                  * @cat DOM/Attributes
2170                  */
2171                  
2172                 /**
2173                  * Set the title of every matched element.
2174                  * 
2175                  * @example $("img").title("new title");
2176                  * @before <img src="test.jpg" title="my image"/>
2177                  * @result <img src="test.jpg" title="new image"/>
2178                  *
2179                  * @name title
2180                  * @type jQuery
2181                  * @param String val Set the property to the specified value.
2182                  * @cat DOM/Attributes
2183                  */
2184                 title: null,
2185                 
2186                 /**
2187                  * Get the current name of the first matched element.
2188                  * 
2189                  * @example $("input").name();
2190                  * @before <input type="text" name="username"/>
2191                  * @result "username"
2192                  *
2193                  * @name name
2194                  * @type String
2195                  * @cat DOM/Attributes
2196                  */
2197                  
2198                 /**
2199                  * Set the name of every matched element.
2200                  * 
2201                  * @example $("input").name("user");
2202                  * @before <input type="text" name="username"/>
2203                  * @result <input type="text" name="user"/>
2204                  *
2205                  * @name name
2206                  * @type jQuery
2207                  * @param String val Set the property to the specified value.
2208                  * @cat DOM/Attributes
2209                  */
2210                 name: null,
2211                 
2212                 /**
2213                  * Get the current href of the first matched element.
2214                  * 
2215                  * @example $("a").href();
2216                  * @before <a href="test.html">my link</a>
2217                  * @result "test.html"
2218                  *
2219                  * @name href
2220                  * @type String
2221                  * @cat DOM/Attributes
2222                  */
2223                  
2224                 /**
2225                  * Set the href of every matched element.
2226                  * 
2227                  * @example $("a").href("test2.html");
2228                  * @before <a href="test.html">my link</a>
2229                  * @result <a href="test2.html">my link</a>
2230                  *
2231                  * @name href
2232                  * @type jQuery
2233                  * @param String val Set the property to the specified value.
2234                  * @cat DOM/Attributes
2235                  */
2236                 href: null,
2237                 
2238                 /**
2239                  * Get the current src of the first matched element.
2240                  * 
2241                  * @example $("img").src();
2242                  * @before <img src="test.jpg" title="my image"/>
2243                  * @result "test.jpg"
2244                  *
2245                  * @name src
2246                  * @type String
2247                  * @cat DOM/Attributes
2248                  */
2249                  
2250                 /**
2251                  * Set the src of every matched element.
2252                  * 
2253                  * @example $("img").src("test2.jpg");
2254                  * @before <img src="test.jpg" title="my image"/>
2255                  * @result <img src="test2.jpg" title="my image"/>
2256                  *
2257                  * @name src
2258                  * @type jQuery
2259                  * @param String val Set the property to the specified value.
2260                  * @cat DOM/Attributes
2261                  */
2262                 src: null,
2263                 
2264                 /**
2265                  * Get the current rel of the first matched element.
2266                  * 
2267                  * @example $("a").rel();
2268                  * @before <a href="test.html" rel="nofollow">my link</a>
2269                  * @result "nofollow"
2270                  *
2271                  * @name rel
2272                  * @type String
2273                  * @cat DOM/Attributes
2274                  */
2275                  
2276                 /**
2277                  * Set the rel of every matched element.
2278                  * 
2279                  * @example $("a").rel("nofollow");
2280                  * @before <a href="test.html">my link</a>
2281                  * @result <a href="test.html" rel="nofollow">my link</a>
2282                  *
2283                  * @name rel
2284                  * @type jQuery
2285                  * @param String val Set the property to the specified value.
2286                  * @cat DOM/Attributes
2287                  */
2288                 rel: null
2289         },
2290         
2291         axis: {
2292                 /**
2293                  * Get a set of elements containing the unique parents of the matched
2294                  * set of elements.
2295                  *
2296                  * @example $("p").parent()
2297                  * @before <div><p>Hello</p><p>Hello</p></div>
2298                  * @result [ <div><p>Hello</p><p>Hello</p></div> ]
2299                  *
2300                  * @name parent
2301                  * @type jQuery
2302                  * @cat DOM/Traversing
2303                  */
2304
2305                 /**
2306                  * Get a set of elements containing the unique parents of the matched
2307                  * set of elements, and filtered by an expression.
2308                  *
2309                  * @example $("p").parent(".selected")
2310                  * @before <div><p>Hello</p></div><div class="selected"><p>Hello Again</p></div>
2311                  * @result [ <div class="selected"><p>Hello Again</p></div> ]
2312                  *
2313                  * @name parent
2314                  * @type jQuery
2315                  * @param String expr An expression to filter the parents with
2316                  * @cat DOM/Traversing
2317                  */
2318                 parent: "a.parentNode",
2319
2320                 /**
2321                  * Get a set of elements containing the unique ancestors of the matched
2322                  * set of elements (except for the root element).
2323                  *
2324                  * @example $("span").ancestors()
2325                  * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html>
2326                  * @result [ <body>...</body>, <div>...</div>, <p><span>Hello</span></p> ] 
2327                  *
2328                  * @name ancestors
2329                  * @type jQuery
2330                  * @cat DOM/Traversing
2331                  */
2332
2333                 /**
2334                  * Get a set of elements containing the unique ancestors of the matched
2335                  * set of elements, and filtered by an expression.
2336                  *
2337                  * @example $("span").ancestors("p")
2338                  * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html>
2339                  * @result [ <p><span>Hello</span></p> ] 
2340                  *
2341                  * @name ancestors
2342                  * @type jQuery
2343                  * @param String expr An expression to filter the ancestors with
2344                  * @cat DOM/Traversing
2345                  */
2346                 ancestors: jQuery.parents,
2347                 
2348                 /**
2349                  * Get a set of elements containing the unique ancestors of the matched
2350                  * set of elements (except for the root element).
2351                  *
2352                  * @example $("span").ancestors()
2353                  * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html>
2354                  * @result [ <body>...</body>, <div>...</div>, <p><span>Hello</span></p> ] 
2355                  *
2356                  * @name parents
2357                  * @type jQuery
2358                  * @cat DOM/Traversing
2359                  */
2360
2361                 /**
2362                  * Get a set of elements containing the unique ancestors of the matched
2363                  * set of elements, and filtered by an expression.
2364                  *
2365                  * @example $("span").ancestors("p")
2366                  * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html>
2367                  * @result [ <p><span>Hello</span></p> ] 
2368                  *
2369                  * @name parents
2370                  * @type jQuery
2371                  * @param String expr An expression to filter the ancestors with
2372                  * @cat DOM/Traversing
2373                  */
2374                 parents: jQuery.parents,
2375
2376                 /**
2377                  * Get a set of elements containing the unique next siblings of each of the 
2378                  * matched set of elements.
2379                  * 
2380                  * It only returns the very next sibling, not all next siblings.
2381                  *
2382                  * @example $("p").next()
2383                  * @before <p>Hello</p><p>Hello Again</p><div><span>And Again</span></div>
2384                  * @result [ <p>Hello Again</p>, <div><span>And Again</span></div> ]
2385                  *
2386                  * @name next
2387                  * @type jQuery
2388                  * @cat DOM/Traversing
2389                  */
2390
2391                 /**
2392                  * Get a set of elements containing the unique next siblings of each of the 
2393                  * matched set of elements, and filtered by an expression.
2394                  * 
2395                  * It only returns the very next sibling, not all next siblings.
2396                  *
2397                  * @example $("p").next(".selected")
2398                  * @before <p>Hello</p><p class="selected">Hello Again</p><div><span>And Again</span></div>
2399                  * @result [ <p class="selected">Hello Again</p> ]
2400                  *
2401                  * @name next
2402                  * @type jQuery
2403                  * @param String expr An expression to filter the next Elements with
2404                  * @cat DOM/Traversing
2405                  */
2406                 next: "jQuery.sibling(a).next",
2407
2408                 /**
2409                  * Get a set of elements containing the unique previous siblings of each of the 
2410                  * matched set of elements.
2411                  * 
2412                  * It only returns the immediately previous sibling, not all previous siblings.
2413                  *
2414                  * @example $("p").previous()
2415                  * @before <p>Hello</p><div><span>Hello Again</span></div><p>And Again</p>
2416                  * @result [ <div><span>Hello Again</span></div> ]
2417                  *
2418                  * @name prev
2419                  * @type jQuery
2420                  * @cat DOM/Traversing
2421                  */
2422
2423                 /**
2424                  * Get a set of elements containing the unique previous siblings of each of the 
2425                  * matched set of elements, and filtered by an expression.
2426                  * 
2427                  * It only returns the immediately previous sibling, not all previous siblings.
2428                  *
2429                  * @example $("p").previous(".selected")
2430                  * @before <div><span>Hello</span></div><p class="selected">Hello Again</p><p>And Again</p>
2431                  * @result [ <div><span>Hello</span></div> ]
2432                  *
2433                  * @name prev
2434                  * @type jQuery
2435                  * @param String expr An expression to filter the previous Elements with
2436                  * @cat DOM/Traversing
2437                  */
2438                 prev: "jQuery.sibling(a).prev",
2439
2440                 /**
2441                  * Get a set of elements containing all of the unique siblings of each of the 
2442                  * matched set of elements.
2443                  * 
2444                  * @example $("div").siblings()
2445                  * @before <p>Hello</p><div><span>Hello Again</span></div><p>And Again</p>
2446                  * @result [ <p>Hello</p>, <p>And Again</p> ]
2447                  *
2448                  * @name siblings
2449                  * @type jQuery
2450                  * @cat DOM/Traversing
2451                  */
2452
2453                 /**
2454                  * Get a set of elements containing all of the unique siblings of each of the 
2455                  * matched set of elements, and filtered by an expression.
2456                  *
2457                  * @example $("div").siblings(".selected")
2458                  * @before <div><span>Hello</span></div><p class="selected">Hello Again</p><p>And Again</p>
2459                  * @result [ <p class="selected">Hello Again</p> ]
2460                  *
2461                  * @name siblings
2462                  * @type jQuery
2463                  * @param String expr An expression to filter the sibling Elements with
2464                  * @cat DOM/Traversing
2465                  */
2466                 siblings: jQuery.sibling,
2467                 
2468                 
2469                 /**
2470                  * Get a set of elements containing all of the unique children of each of the 
2471                  * matched set of elements.
2472                  * 
2473                  * @example $("div").children()
2474                  * @before <p>Hello</p><div><span>Hello Again</span></div><p>And Again</p>
2475                  * @result [ <span>Hello Again</span> ]
2476                  *
2477                  * @name children
2478                  * @type jQuery
2479                  * @cat DOM/Traversing
2480                  */
2481
2482                 /**
2483                  * Get a set of elements containing all of the unique children of each of the 
2484                  * matched set of elements, and filtered by an expression.
2485                  *
2486                  * @example $("div").children(".selected")
2487                  * @before <div><span>Hello</span><p class="selected">Hello Again</p><p>And Again</p></div>
2488                  * @result [ <p class="selected">Hello Again</p> ]
2489                  *
2490                  * @name children
2491                  * @type jQuery
2492                  * @param String expr An expression to filter the child Elements with
2493                  * @cat DOM/Traversing
2494                  */
2495                 children: "jQuery.sibling(a.firstChild)"
2496         },
2497
2498         each: {
2499
2500                 removeAttr: function( key ) {
2501                         this.removeAttribute( key );
2502                 },
2503
2504                 /**
2505                  * Displays each of the set of matched elements if they are hidden.
2506                  * 
2507                  * @example $("p").show()
2508                  * @before <p style="display: none">Hello</p>
2509                  * @result [ <p style="display: block">Hello</p> ]
2510                  *
2511                  * @test var pass = true, div = $("div");
2512                  * div.show().each(function(){
2513                  *   if ( this.style.display == "none" ) pass = false;
2514                  * });
2515                  * ok( pass, "Show" );
2516                  *
2517                  * @name show
2518                  * @type jQuery
2519                  * @cat Effects
2520                  */
2521                 show: function(){
2522                         this.style.display = this.oldblock ? this.oldblock : "";
2523                         if ( jQuery.css(this,"display") == "none" )
2524                                 this.style.display = "block";
2525                 },
2526
2527                 /**
2528                  * Hides each of the set of matched elements if they are shown.
2529                  *
2530                  * @example $("p").hide()
2531                  * @before <p>Hello</p>
2532                  * @result [ <p style="display: none">Hello</p> ]
2533                  *
2534                  * var pass = true, div = $("div");
2535                  * div.hide().each(function(){
2536                  *   if ( this.style.display != "none" ) pass = false;
2537                  * });
2538                  * ok( pass, "Hide" );
2539                  *
2540                  * @name hide
2541                  * @type jQuery
2542                  * @cat Effects
2543                  */
2544                 hide: function(){
2545                         this.oldblock = this.oldblock || jQuery.css(this,"display");
2546                         if ( this.oldblock == "none" )
2547                                 this.oldblock = "block";
2548                         this.style.display = "none";
2549                 },
2550                 
2551                 /**
2552                  * Toggles each of the set of matched elements. If they are shown,
2553                  * toggle makes them hidden. If they are hidden, toggle
2554                  * makes them shown.
2555                  *
2556                  * @example $("p").toggle()
2557                  * @before <p>Hello</p><p style="display: none">Hello Again</p>
2558                  * @result [ <p style="display: none">Hello</p>, <p style="display: block">Hello Again</p> ]
2559                  *
2560                  * @name toggle
2561                  * @type jQuery
2562                  * @cat Effects
2563                  */
2564                 toggle: function(){
2565                         jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ].apply( jQuery(this), arguments );
2566                 },
2567                 
2568                 /**
2569                  * Adds the specified class to each of the set of matched elements.
2570                  *
2571                  * @example $("p").addClass("selected")
2572                  * @before <p>Hello</p>
2573                  * @result [ <p class="selected">Hello</p> ]
2574                  *
2575                  * @test var div = $("div");
2576                  * div.addClass("test");
2577                  * var pass = true;
2578                  * for ( var i = 0; i < div.size(); i++ ) {
2579                  *  if ( div.get(i).className.indexOf("test") == -1 ) pass = false;
2580                  * }
2581                  * ok( pass, "Add Class" );
2582                  * 
2583                  * @name addClass
2584                  * @type jQuery
2585                  * @param String class A CSS class to add to the elements
2586                  * @cat DOM
2587                  */
2588                 addClass: function(c){
2589                         jQuery.className.add(this,c);
2590                 },
2591                 
2592                 /**
2593                  * Removes the specified class from the set of matched elements.
2594                  *
2595                  * @example $("p").removeClass("selected")
2596                  * @before <p class="selected">Hello</p>
2597                  * @result [ <p>Hello</p> ]
2598                  *
2599                  * @test var div = $("div").addClass("test");
2600                  * div.removeClass("test");
2601                  * var pass = true;
2602                  * for ( var i = 0; i < div.size(); i++ ) {
2603                  *  if ( div.get(i).className.indexOf("test") != -1 ) pass = false;
2604                  * }
2605                  * ok( pass, "Remove Class" );
2606                  *
2607                  * @name removeClass
2608                  * @type jQuery
2609                  * @param String class A CSS class to remove from the elements
2610                  * @cat DOM
2611                  */
2612                 removeClass: function(c){
2613                         jQuery.className.remove(this,c);
2614                 },
2615         
2616                 /**
2617                  * Adds the specified class if it is present, removes it if it is
2618                  * not present.
2619                  *
2620                  * @example $("p").toggleClass("selected")
2621                  * @before <p>Hello</p><p class="selected">Hello Again</p>
2622                  * @result [ <p class="selected">Hello</p>, <p>Hello Again</p> ]
2623                  *
2624                  * @name toggleClass
2625                  * @type jQuery
2626                  * @param String class A CSS class with which to toggle the elements
2627                  * @cat DOM
2628                  */
2629                 toggleClass: function( c ){
2630                         jQuery.className[ jQuery.className.has(this,c) ? "remove" : "add" ](this,c);
2631                 },
2632                 
2633                 /**
2634                  * Removes all matched elements from the DOM. This does NOT remove them from the
2635                  * jQuery object, allowing you to use the matched elements further.
2636                  *
2637                  * @example $("p").remove();
2638                  * @before <p>Hello</p> how are <p>you?</p>
2639                  * @result how are
2640                  *
2641                  * @name remove
2642                  * @type jQuery
2643                  * @cat DOM/Manipulation
2644                  */
2645                  
2646                 /**
2647                  * Removes only elements (out of the list of matched elements) that match
2648                  * the specified jQuery expression. This does NOT remove them from the
2649                  * jQuery object, allowing you to use the matched elements further.
2650                  *
2651                  * @example $("p").remove(".hello");
2652                  * @before <p class="hello">Hello</p> how are <p>you?</p>
2653                  * @result how are <p>you?</p>
2654                  *
2655                  * @name remove
2656                  * @type jQuery
2657                  * @param String expr A jQuery expression to filter elements by.
2658                  * @cat DOM/Manipulation
2659                  */
2660                 remove: function(a){
2661                         if ( !a || jQuery.filter( a, [this] ).r )
2662                                 this.parentNode.removeChild( this );
2663                 },
2664         
2665                 /**
2666                  * Removes all child nodes from the set of matched elements.
2667                  *
2668                  * @example $("p").empty()
2669                  * @before <p>Hello, <span>Person</span> <a href="#">and person</a></p>
2670                  * @result [ <p></p> ]
2671                  *
2672                  * @name empty
2673                  * @type jQuery
2674                  * @cat DOM/Manipulation
2675                  */
2676                 empty: function(){
2677                         while ( this.firstChild )
2678                                 this.removeChild( this.firstChild );
2679                 },
2680                 
2681                 /**
2682                  * Binds a particular event (like click) to a each of a set of match elements.
2683                  *
2684                  * @example $("p").bind( "click", function() { alert("Hello"); } )
2685                  * @before <p>Hello</p>
2686                  * @result [ <p>Hello</p> ]
2687                  *
2688                  * Cancel a default action and prevent it from bubbling by returning false
2689                  * from your function.
2690                  *
2691                  * @example $("form").bind( "submit", function() { return false; } )
2692                  *
2693                  * Cancel a default action by using the preventDefault method.
2694                  *
2695                  * @example $("form").bind( "submit", function() { e.preventDefault(); } )
2696                  *
2697                  * Stop an event from bubbling by using the stopPropogation method.
2698                  *
2699                  * @example $("form").bind( "submit", function() { e.stopPropogation(); } )
2700                  *
2701                  * @name bind
2702                  * @type jQuery
2703                  * @param String type An event type
2704                  * @param Function fn A function to bind to the event on each of the set of matched elements
2705                  * @cat Events
2706                  */
2707                 bind: function( type, fn ) {
2708                         if ( fn.constructor == String )
2709                                 fn = new Function("e", ( !fn.indexOf(".") ? "jQuery(this)" : "return " ) + fn);
2710                         jQuery.event.add( this, type, fn );
2711                 },
2712                 
2713                 /**
2714                  * The opposite of bind, removes a bound event from each of the matched
2715                  * elements. You must pass the identical function that was used in the original 
2716                  * bind method.
2717                  *
2718                  * @example $("p").unbind( "click", function() { alert("Hello"); } )
2719                  * @before <p onclick="alert('Hello');">Hello</p>
2720                  * @result [ <p>Hello</p> ]
2721                  *
2722                  * @name unbind
2723                  * @type jQuery
2724                  * @param String type An event type
2725                  * @param Function fn A function to unbind from the event on each of the set of matched elements
2726                  * @cat Events
2727                  */
2728                  
2729                 /**
2730                  * Removes all bound events of a particular type from each of the matched
2731                  * elements.
2732                  *
2733                  * @example $("p").unbind( "click" )
2734                  * @before <p onclick="alert('Hello');">Hello</p>
2735                  * @result [ <p>Hello</p> ]
2736                  *
2737                  * @name unbind
2738                  * @type jQuery
2739                  * @param String type An event type
2740                  * @cat Events
2741                  */
2742                  
2743                 /**
2744                  * Removes all bound events from each of the matched elements.
2745                  *
2746                  * @example $("p").unbind()
2747                  * @before <p onclick="alert('Hello');">Hello</p>
2748                  * @result [ <p>Hello</p> ]
2749                  *
2750                  * @name unbind
2751                  * @type jQuery
2752                  * @cat Events
2753                  */
2754                 unbind: function( type, fn ) {
2755                         jQuery.event.remove( this, type, fn );
2756                 },
2757                 
2758                 /**
2759                  * Trigger a type of event on every matched element.
2760                  *
2761                  * @example $("p").trigger("click")
2762                  * @before <p click="alert('hello')">Hello</p>
2763                  * @result alert('hello')
2764                  *
2765                  * @name trigger
2766                  * @type jQuery
2767                  * @param String type An event type to trigger.
2768                  * @cat Events
2769                  */
2770                 trigger: function( type, data ) {
2771                         jQuery.event.trigger( type, data, this );
2772                 }
2773         }
2774 };
2775
2776 jQuery.init();