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