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