Documented some more functions.
[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"
1172                                         }).appendTo(e.parentNode)[0];
1173
1174                                         oHeight = e.clientHeight;
1175                                         oWidth = e.clientWidth;
1176                                         
1177                                         e.parentNode.removeChild(e);
1178                                 }
1179                         });
1180         
1181                         return p == "height" ? oHeight : oWidth;
1182                 } else if ( p == "opacity" && jQuery.browser.msie )
1183                         return parseFloat( jQuery.curCSS(e,"filter").replace(/[^0-9.]/,"") ) || 1;
1184
1185                 return jQuery.curCSS( e, p );
1186         },
1187
1188         curCSS: function(elem, prop, force) {
1189                 var ret;
1190         
1191                 if (!force && elem.style[prop]) {
1192
1193                         ret = elem.style[prop];
1194
1195                 } else if (elem.currentStyle) {
1196
1197                         var newProp = prop.replace(/\-(\w)/g,function(m,c){return c.toUpperCase()}); 
1198                         ret = elem.currentStyle[prop] || elem.currentStyle[newProp];
1199
1200                 } else if (document.defaultView && document.defaultView.getComputedStyle) {
1201
1202                         prop = prop.replace(/([A-Z])/g,"-$1").toLowerCase();
1203                         var cur = document.defaultView.getComputedStyle(elem, null);
1204
1205                         if ( cur )
1206                                 ret = cur.getPropertyValue(prop);
1207                         else if ( prop == 'display' )
1208                                 ret = 'none';
1209                         else
1210                                 jQuery.swap(elem, { display: 'block' }, function() {
1211                                         ret = document.defaultView.getComputedStyle(this,null).getPropertyValue(prop);
1212                                 });
1213
1214                 }
1215                 
1216                 return ret;
1217         },
1218         
1219         clean: function(a) {
1220                 var r = [];
1221                 for ( var i = 0; i < a.length; i++ ) {
1222                         if ( a[i].constructor == String ) {
1223
1224                                 var table = "";
1225         
1226                                 if ( !a[i].indexOf("<thead") || !a[i].indexOf("<tbody") ) {
1227                                         table = "thead";
1228                                         a[i] = "<table>" + a[i] + "</table>";
1229                                 } else if ( !a[i].indexOf("<tr") ) {
1230                                         table = "tr";
1231                                         a[i] = "<table>" + a[i] + "</table>";
1232                                 } else if ( !a[i].indexOf("<td") || !a[i].indexOf("<th") ) {
1233                                         table = "td";
1234                                         a[i] = "<table><tbody><tr>" + a[i] + "</tr></tbody></table>";
1235                                 }
1236         
1237                                 var div = document.createElement("div");
1238                                 div.innerHTML = a[i];
1239         
1240                                 if ( table ) {
1241                                         div = div.firstChild;
1242                                         if ( table != "thead" ) div = div.firstChild;
1243                                         if ( table == "td" ) div = div.firstChild;
1244                                 }
1245         
1246                                 for ( var j = 0; j < div.childNodes.length; j++ )
1247                                         r.push( div.childNodes[j] );
1248                                 } else if ( a[i].jquery || a[i].length && !a[i].nodeType )
1249                                         for ( var k = 0; k < a[i].length; k++ )
1250                                                 r.push( a[i][k] );
1251                                 else if ( a[i] !== null )
1252                                         r.push( a[i].nodeType ? a[i] : document.createTextNode(a[i].toString()) );
1253                 }
1254                 return r;
1255         },
1256         
1257         expr: {
1258                 "": "m[2]== '*'||a.nodeName.toUpperCase()==m[2].toUpperCase()",
1259                 "#": "a.getAttribute('id')&&a.getAttribute('id')==m[2]",
1260                 ":": {
1261                         // Position Checks
1262                         lt: "i<m[3]-0",
1263                         gt: "i>m[3]-0",
1264                         nth: "m[3]-0==i",
1265                         eq: "m[3]-0==i",
1266                         first: "i==0",
1267                         last: "i==r.length-1",
1268                         even: "i%2==0",
1269                         odd: "i%2",
1270                         
1271                         // Child Checks
1272                         "nth-child": "jQuery.sibling(a,m[3]).cur",
1273                         "first-child": "jQuery.sibling(a,0).cur",
1274                         "last-child": "jQuery.sibling(a,0).last",
1275                         "only-child": "jQuery.sibling(a).length==1",
1276                         
1277                         // Parent Checks
1278                         parent: "a.childNodes.length",
1279                         empty: "!a.childNodes.length",
1280                         
1281                         // Text Check
1282                         contains: "(a.innerText||a.innerHTML).indexOf(m[3])>=0",
1283                         
1284                         // Visibility
1285                         visible: "a.type!='hidden'&&jQuery.css(a,'display')!='none'&&jQuery.css(a,'visibility')!='hidden'",
1286                         hidden: "a.type=='hidden'||jQuery.css(a,'display')=='none'||jQuery.css(a,'visibility')=='hidden'",
1287                         
1288                         // Form elements
1289                         enabled: "!a.disabled",
1290                         disabled: "a.disabled",
1291                         checked: "a.checked",
1292                         selected: "a.selected"
1293                 },
1294                 ".": "jQuery.className.has(a,m[2])",
1295                 "@": {
1296                         "=": "z==m[4]",
1297                         "!=": "z!=m[4]",
1298                         "^=": "!z.indexOf(m[4])",
1299                         "$=": "z.substr(z.length - m[4].length,m[4].length)==m[4]",
1300                         "*=": "z.indexOf(m[4])>=0",
1301                         "": "z"
1302                 },
1303                 "[": "jQuery.find(m[2],a).length"
1304         },
1305         
1306         token: [
1307                 "\\.\\.|/\\.\\.", "a.parentNode",
1308                 ">|/", "jQuery.sibling(a.firstChild)",
1309                 "\\+", "jQuery.sibling(a).next",
1310                 "~", function(a){
1311                         var r = [];
1312                         var s = jQuery.sibling(a);
1313                         if ( s.n > 0 )
1314                                 for ( var i = s.n; i < s.length; i++ )
1315                                         r.push( s[i] );
1316                         return r;
1317                 }
1318         ],
1319         
1320         /**
1321          *
1322          * @test t( "Element Selector", "div", ["main","foo"] );
1323          * @test t( "Element Selector", "body", ["body"] );
1324          * @test t( "Element Selector", "html", ["html"] );
1325          * @test cmpOK( $("*").size(), ">=", 30, "Element Selector" );
1326          * @test t( "Parent Element", "div div", ["foo"] );
1327          *
1328          * @test t( "ID Selector", "#body", ["body"] );
1329          * @test t( "ID Selector w/ Element", "body#body", ["body"] );
1330          * @test t( "ID Selector w/ Element", "ul#first", [] );
1331          *
1332          * @test t( "Class Selector", ".blog", ["mark","simon"] );
1333          * @test t( "Class Selector", ".blog.link", ["simon"] );
1334          * @test t( "Class Selector w/ Element", "a.blog", ["mark","simon"] );
1335          * @test t( "Parent Class Selector", "p .blog", ["mark","simon"] );
1336          *
1337          * @test t( "Comma Support", "a.blog, div", ["mark","simon","main","foo"] );
1338          * @test t( "Comma Support", "a.blog , div", ["mark","simon","main","foo"] );
1339          * @test t( "Comma Support", "a.blog ,div", ["mark","simon","main","foo"] );
1340          * @test t( "Comma Support", "a.blog,div", ["mark","simon","main","foo"] );
1341          *
1342          * @test t( "Child", "p > a", ["simon1","google","groups","mark","yahoo","simon"] );
1343          * @test t( "Child", "p> a", ["simon1","google","groups","mark","yahoo","simon"] );
1344          * @test t( "Child", "p >a", ["simon1","google","groups","mark","yahoo","simon"] );
1345          * @test t( "Child", "p>a", ["simon1","google","groups","mark","yahoo","simon"] );
1346          * @test t( "Child w/ Class", "p > a.blog", ["mark","simon"] );
1347          * @test t( "All Children", "code > *", ["anchor1","anchor2"] );
1348          * @test t( "All Grandchildren", "p > * > *", ["anchor1","anchor2"] );
1349          * @test t( "Adjacent", "a + a", ["groups"] );
1350          * @test t( "Adjacent", "a +a", ["groups"] );
1351          * @test t( "Adjacent", "a+ a", ["groups"] );
1352          * @test t( "Adjacent", "a+a", ["groups"] );
1353          * @test t( "Adjacent", "p + p", ["ap","en","sap"] );
1354          * @test t( "Comma, Child, and Adjacent", "a + a, code > a", ["groups","anchor1","anchor2"] );
1355          * @test t( "First Child", "p:first-child", ["firstp","sndp"] );
1356          * @test t( "Attribute Exists", "a[@title]", ["google"] );
1357          * @test t( "Attribute Exists", "*[@title]", ["google"] );
1358          * @test t( "Attribute Exists", "[@title]", ["google"] );
1359          * @test t( "Attribute Equals", "a[@rel='bookmark']", ["simon1"] );
1360          * @test t( "Attribute Equals", 'a[@rel="bookmark"]', ["simon1"] );
1361          * @test t( "Attribute Equals", "a[@rel=bookmark]", ["simon1"] );
1362          * @test t( "Multiple Attribute Equals", "input[@type='hidden'],input[@type='radio']", ["hidden1","radio1","radio2"] );
1363          * @test t( "Multiple Attribute Equals", "input[@type=\"hidden\"],input[@type='radio']", ["hidden1","radio1","radio2"] );
1364          * @test t( "Multiple Attribute Equals", "input[@type=hidden],input[@type=radio]", ["hidden1","radio1","radio2"] );
1365          *
1366          * @test t( "Attribute Begins With", "a[@href ^= 'http://www']", ["google","yahoo"] );
1367          * @test t( "Attribute Ends With", "a[@href $= 'org/']", ["mark"] );
1368          * @test t( "Attribute Contains", "a[@href *= 'google']", ["google","groups"] );
1369          * @test t( "First Child", "p:first-child", ["firstp","sndp"] );
1370          * @test t( "Last Child", "p:last-child", ["sap"] );
1371          * @test t( "Only Child", "a:only-child", ["simon1","anchor1","yahoo","anchor2"] );
1372          * @test t( "Empty", "ul:empty", ["firstUL"] );
1373          * @test t( "Enabled UI Element", "input:enabled", ["text1","radio1","radio2","check1","check2","hidden1","hidden2"] );
1374          * @test t( "Disabled UI Element", "input:disabled", ["text2"] );
1375          * @test t( "Checked UI Element", "input:checked", ["radio2","check1"] );
1376          * @test t( "Text Contains", "a:contains('Google')", ["google","groups"] );
1377          * @test t( "Text Contains", "a:contains('Google Groups')", ["groups"] );
1378          * @test t( "Element Preceded By", "p ~ div", ["foo"] );
1379          * @test t( "Not", "a.blog:not(.link)", ["mark"] );
1380          *
1381          * @test cmpOK( jQuery.find("//*").length, ">=", 30, "All Elements (//*)" );
1382          * @test t( "All Div Elements", "//div", ["main","foo"] );
1383          * @test t( "Absolute Path", "/html/body", ["body"] );
1384          * @test t( "Absolute Path w/ *", "/* /body", ["body"] );
1385          * @test t( "Long Absolute Path", "/html/body/dl/div/div/p", ["sndp","en","sap"] );
1386          * @test t( "Absolute and Relative Paths", "/html//div", ["main","foo"] );
1387          * @test t( "All Children, Explicit", "//code/*", ["anchor1","anchor2"] );
1388          * @test t( "All Children, Implicit", "//code/", ["anchor1","anchor2"] );
1389          * @test t( "Attribute Exists", "//a[@title]", ["google"] );
1390          * @test t( "Attribute Equals", "//a[@rel='bookmark']", ["simon1"] );
1391          * @test t( "Parent Axis", "//p/..", ["main","foo"] );
1392          * @test t( "Sibling Axis", "//p/../", ["firstp","ap","foo","first","firstUL","empty","form","sndp","en","sap"] );
1393          * @test t( "Sibling Axis", "//p/../*", ["firstp","ap","foo","first","firstUL","empty","form","sndp","en","sap"] );
1394          * @test t( "Has Children", "//p[a]", ["firstp","ap","en","sap"] );
1395          *
1396          * @test t( "nth Element", "p:nth(1)", ["ap"] );
1397          * @test t( "First Element", "p:first", ["firstp"] );
1398          * @test t( "Last Element", "p:last", ["first"] );
1399          * @test t( "Even Elements", "p:even", ["firstp","sndp","sap"] );
1400          * @test t( "Odd Elements", "p:odd", ["ap","en","first"] );
1401          * @test t( "Position Equals", "p:eq(1)", ["ap"] );
1402          * @test t( "Position Greater Than", "p:gt(0)", ["ap","sndp","en","sap","first"] );
1403          * @test t( "Position Less Than", "p:lt(3)", ["firstp","ap","sndp"] );
1404          * @test t( "Is A Parent", "p:parent", ["firstp","ap","sndp","en","sap","first"] );
1405          * @test t( "Is Visible", "input:visible", ["text1","text2","radio1","radio2","check1","check2"] );
1406          * @test t( "Is Hidden", "input:hidden", ["hidden1","hidden2"] );
1407          *
1408          * @name $.find
1409          * @type Array<Element>
1410          * @private
1411          * @cat Core
1412          */
1413         find: function( t, context ) {
1414                 // Make sure that the context is a DOM Element
1415                 if ( context && context.nodeType == undefined )
1416                         context = null;
1417         
1418                 // Set the correct context (if none is provided)
1419                 context = context || jQuery.context || document;
1420         
1421                 if ( t.constructor != String ) return [t];
1422         
1423                 if ( !t.indexOf("//") ) {
1424                         context = context.documentElement;
1425                         t = t.substr(2,t.length);
1426                 } else if ( !t.indexOf("/") ) {
1427                         context = context.documentElement;
1428                         t = t.substr(1,t.length);
1429                         // FIX Assume the root element is right :(
1430                         if ( t.indexOf("/") >= 1 )
1431                                 t = t.substr(t.indexOf("/"),t.length);
1432                 }
1433         
1434                 var ret = [context];
1435                 var done = [];
1436                 var last = null;
1437         
1438                 while ( t.length > 0 && last != t ) {
1439                         var r = [];
1440                         last = t;
1441         
1442                         t = jQuery.trim(t).replace( /^\/\//i, "" );
1443                         
1444                         var foundToken = false;
1445                         
1446                         for ( var i = 0; i < jQuery.token.length; i += 2 ) {
1447                                 if ( foundToken ) continue;
1448
1449                                 var re = new RegExp("^(" + jQuery.token[i] + ")");
1450                                 var m = re.exec(t);
1451                                 
1452                                 if ( m ) {
1453                                         r = ret = jQuery.map( ret, jQuery.token[i+1] );
1454                                         t = jQuery.trim( t.replace( re, "" ) );
1455                                         foundToken = true;
1456                                 }
1457                         }
1458                         
1459                         if ( !foundToken ) {
1460                                 if ( !t.indexOf(",") || !t.indexOf("|") ) {
1461                                         if ( ret[0] == context ) ret.shift();
1462                                         done = jQuery.merge( done, ret );
1463                                         r = ret = [context];
1464                                         t = " " + t.substr(1,t.length);
1465                                 } else {
1466                                         var re2 = /^([#.]?)([a-z0-9\\*_-]*)/i;
1467                                         var m = re2.exec(t);
1468                 
1469                                         if ( m[1] == "#" ) {
1470                                                 // Ummm, should make this work in all XML docs
1471                                                 var oid = document.getElementById(m[2]);
1472                                                 r = ret = oid ? [oid] : [];
1473                                                 t = t.replace( re2, "" );
1474                                         } else {
1475                                                 if ( !m[2] || m[1] == "." ) m[2] = "*";
1476                 
1477                                                 for ( var i = 0; i < ret.length; i++ )
1478                                                         r = jQuery.merge( r,
1479                                                                 m[2] == "*" ?
1480                                                                         jQuery.getAll(ret[i]) :
1481                                                                         ret[i].getElementsByTagName(m[2])
1482                                                         );
1483                                         }
1484                                 }
1485         
1486                         }
1487
1488                         if ( t ) {
1489                                 var val = jQuery.filter(t,r);
1490                                 ret = r = val.r;
1491                                 t = jQuery.trim(val.t);
1492                         }
1493                 }
1494         
1495                 if ( ret && ret[0] == context ) ret.shift();
1496                 done = jQuery.merge( done, ret );
1497         
1498                 return done;
1499         },
1500         
1501         getAll: function(o,r) {
1502                 r = r || [];
1503                 var s = o.childNodes;
1504                 for ( var i = 0; i < s.length; i++ )
1505                         if ( s[i].nodeType == 1 ) {
1506                                 r.push( s[i] );
1507                                 jQuery.getAll( s[i], r );
1508                         }
1509                 return r;
1510         },
1511         
1512         attr: function(elem, name, value){
1513                 var fix = {
1514                         "for": "htmlFor",
1515                         "class": "className",
1516                         "float": "cssFloat",
1517                         innerHTML: "innerHTML",
1518                         className: "className",
1519                         value: "value",
1520                         disabled: "disabled",
1521                         checked: "checked"
1522                 };
1523
1524                 if ( fix[name] ) {
1525                         if ( value != undefined ) elem[fix[name]] = value;
1526                         return elem[fix[name]];
1527                 } else if ( elem.getAttribute ) {
1528                         if ( value != undefined ) elem.setAttribute( name, value );
1529                         return elem.getAttribute( name, 2 );
1530                 } else {
1531                         name = name.replace(/-([a-z])/ig,function(z,b){return b.toUpperCase();});
1532                         if ( value != undefined ) elem[name] = value;
1533                         return elem[name];
1534                 }
1535         },
1536
1537         // The regular expressions that power the parsing engine
1538         parse: [
1539                 // Match: [@value='test'], [@foo]
1540                 [ "\\[ *(@)S *([!*$^=]*) *Q\\]", 1 ],
1541
1542                 // Match: [div], [div p]
1543                 [ "(\\[)Q\\]", 0 ],
1544
1545                 // Match: :contains('foo')
1546                 [ "(:)S\\(Q\\)", 0 ],
1547
1548                 // Match: :even, :last-chlid
1549                 [ "([:.#]*)S", 0 ]
1550         ],
1551         
1552         filter: function(t,r,not) {
1553                 // Figure out if we're doing regular, or inverse, filtering
1554                 var g = not !== false ? jQuery.grep :
1555                         function(a,f) {return jQuery.grep(a,f,true);};
1556                 
1557                 while ( t && /^[a-z[({<*:.#]/i.test(t) ) {
1558
1559                         var p = jQuery.parse;
1560
1561                         for ( var i = 0; i < p.length; i++ ) {
1562                                 var re = new RegExp( "^" + p[i][0]
1563
1564                                         // Look for a string-like sequence
1565                                         .replace( 'S', "([a-z*_-][a-z0-9_-]*)" )
1566
1567                                         // Look for something (optionally) enclosed with quotes
1568                                         .replace( 'Q', " *'?\"?([^'\"]*?)'?\"? *" ), "i" );
1569
1570                                 var m = re.exec( t );
1571
1572                                 if ( m ) {
1573                                         // Re-organize the match
1574                                         if ( p[i][1] )
1575                                                 m = ["", m[1], m[3], m[2], m[4]];
1576
1577                                         // Remove what we just matched
1578                                         t = t.replace( re, "" );
1579
1580                                         break;
1581                                 }
1582                         }
1583         
1584                         // :not() is a special case that can be optomized by
1585                         // keeping it out of the expression list
1586                         if ( m[1] == ":" && m[2] == "not" )
1587                                 r = jQuery.filter(m[3],r,false).r;
1588                         
1589                         // Otherwise, find the expression to execute
1590                         else {
1591                                 var f = jQuery.expr[m[1]];
1592                                 if ( f.constructor != String )
1593                                         f = jQuery.expr[m[1]][m[2]];
1594                                         
1595                                 // Build a custom macro to enclose it
1596                                 eval("f = function(a,i){" + 
1597                                         ( m[1] == "@" ? "z=jQuery.attr(a,m[3]);" : "" ) + 
1598                                         "return " + f + "}");
1599                                 
1600                                 // Execute it against the current filter
1601                                 r = g( r, f );
1602                         }
1603                 }
1604         
1605                 // Return an array of filtered elements (r)
1606                 // and the modified expression string (t)
1607                 return { r: r, t: t };
1608         },
1609         
1610         /**
1611          * Remove the whitespace from the beginning and end of a string.
1612          *
1613          * @name $.trim
1614          * @type String
1615          * @param String str The string to trim.
1616          * @cat Javascript
1617          */
1618         trim: function(t){
1619                 return t.replace(/^\s+|\s+$/g, "");
1620         },
1621         
1622         /**
1623          * All ancestors of a given element.
1624          *
1625          * @private
1626          * @name $.parents
1627          * @type Array<Element>
1628          * @param Element elem The element to find the ancestors of.
1629          * @cat DOM/Traversing
1630          */
1631         parents: function( elem ){
1632                 var matched = [];
1633                 var cur = elem.parentNode;
1634                 while ( cur && cur != document ) {
1635                         matched.push( cur );
1636                         cur = cur.parentNode;
1637                 }
1638                 return matched;
1639         },
1640         
1641         /**
1642          * All elements on a specified axis.
1643          *
1644          * @private
1645          * @name $.sibling
1646          * @type Array
1647          * @param Element elem The element to find all the siblings of (including itself).
1648          * @cat DOM/Traversing
1649          */
1650         sibling: function(elem, pos, not) {
1651                 var elems = [];
1652
1653                 var siblings = elem.parentNode.childNodes;
1654                 for ( var i = 0; i < siblings.length; i++ ) {
1655                         if ( not === true && siblings[i] == elem ) continue;
1656
1657                         if ( siblings[i].nodeType == 1 )
1658                                 elems.push( siblings[i] );
1659                         if ( siblings[i] == elem )
1660                                 elems.n = elems.length - 1;
1661                 }
1662
1663                 return jQuery.extend( elems, {
1664                         last: elems.n == elems.length - 1,
1665                         cur: pos == "even" && elems.n % 2 == 0 || pos == "odd" && elems.n % 2 || elems[pos] == elem,
1666                         prev: elems[elems.n - 1],
1667                         next: elems[elems.n + 1]
1668                 });
1669         },
1670         
1671         /**
1672          * Merge two arrays together, removing all duplicates.
1673          *
1674          * @name $.merge
1675          * @type Array
1676          * @param Array a The first array to merge.
1677          * @param Array b The second array to merge.
1678          * @cat Javascript
1679          */
1680         merge: function(first, second) {
1681                 var result = [];
1682                 
1683                 // Move b over to the new array (this helps to avoid
1684                 // StaticNodeList instances)
1685                 for ( var k = 0; k < first.length; k++ )
1686                         result[k] = first[k];
1687         
1688                 // Now check for duplicates between a and b and only
1689                 // add the unique items
1690                 for ( var i = 0; i < second.length; i++ ) {
1691                         var noCollision = true;
1692                         
1693                         // The collision-checking process
1694                         for ( var j = 0; j < first.length; j++ )
1695                                 if ( second[i] == first[j] )
1696                                         noCollision = false;
1697                                 
1698                         // If the item is unique, add it
1699                         if ( noCollision )
1700                                 result.push( second[i] );
1701                 }
1702         
1703                 return result;
1704         },
1705         
1706         /**
1707          * Remove items that aren't matched in an array. The function passed
1708          * in to this method will be passed two arguments: 'a' (which is the
1709          * array item) and 'i' (which is the index of the item in the array).
1710          *
1711          * @name $.grep
1712          * @type Array
1713          * @param Array array The Array to find items in.
1714          * @param Function fn The function to process each item against.
1715          * @param Boolean inv Invert the selection - select the opposite of the function.
1716          * @cat Javascript
1717          */
1718         grep: function(elems, fn, inv) {
1719                 // If a string is passed in for the function, make a function
1720                 // for it (a handy shortcut)
1721                 if ( fn.constructor == String )
1722                         fn = new Function("a","i","return " + fn);
1723                         
1724                 var result = [];
1725                 
1726                 // Go through the array, only saving the items
1727                 // that pass the validator function
1728                 for ( var i = 0; i < elems.length; i++ )
1729                         if ( !inv && fn(elems[i],i) || inv && !fn(elems[i],i) )
1730                                 result.push( elems[i] );
1731                 
1732                 return result;
1733         },
1734         
1735         /**
1736          * Translate all items in array to another array of items. The translation function
1737          * that is provided to this method is passed one argument: 'a' (the item to be 
1738          * translated). If an array is returned, that array is mapped out and merged into
1739          * the full array. Additionally, returning 'null' or 'undefined' will delete the item
1740          * from the array. Both of these changes imply that the size of the array may not
1741          * be the same size upon completion, as it was when it started.
1742          *
1743          * @name $.map
1744          * @type Array
1745          * @param Array array The Array to translate.
1746          * @param Function fn The function to process each item against.
1747          * @cat Javascript
1748          */
1749         map: function(elems, fn) {
1750                 // If a string is passed in for the function, make a function
1751                 // for it (a handy shortcut)
1752                 if ( fn.constructor == String )
1753                         fn = new Function("a","return " + fn);
1754                 
1755                 var result = [];
1756                 
1757                 // Go through the array, translating each of the items to their
1758                 // new value (or values).
1759                 for ( var i = 0; i < elems.length; i++ ) {
1760                         var val = fn(elems[i],i);
1761
1762                         if ( val !== null && val != undefined ) {
1763                                 if ( val.constructor != Array ) val = [val];
1764                                 result = jQuery.merge( result, val );
1765                         }
1766                 }
1767
1768                 return result;
1769         },
1770         
1771         /*
1772          * A number of helper functions used for managing events.
1773          * Many of the ideas behind this code orignated from Dean Edwards' addEvent library.
1774          */
1775         event: {
1776         
1777                 // Bind an event to an element
1778                 // Original by Dean Edwards
1779                 add: function(element, type, handler) {
1780                         // For whatever reason, IE has trouble passing the window object
1781                         // around, causing it to be cloned in the process
1782                         if ( jQuery.browser.msie && element.setInterval != undefined )
1783                                 element = window;
1784                 
1785                         // Make sure that the function being executed has a unique ID
1786                         if ( !handler.guid )
1787                                 handler.guid = this.guid++;
1788                                 
1789                         // Init the element's event structure
1790                         if (!element.events)
1791                                 element.events = {};
1792                         
1793                         // Get the current list of functions bound to this event
1794                         var handlers = element.events[type];
1795                         
1796                         // If it hasn't been initialized yet
1797                         if (!handlers) {
1798                                 // Init the event handler queue
1799                                 handlers = element.events[type] = {};
1800                                 
1801                                 // Remember an existing handler, if it's already there
1802                                 if (element["on" + type])
1803                                         handlers[0] = element["on" + type];
1804                         }
1805
1806                         // Add the function to the element's handler list
1807                         handlers[handler.guid] = handler;
1808                         
1809                         // And bind the global event handler to the element
1810                         element["on" + type] = this.handle;
1811         
1812                         // Remember the function in a global list (for triggering)
1813                         if (!this.global[type])
1814                                 this.global[type] = [];
1815                         this.global[type].push( element );
1816                 },
1817                 
1818                 guid: 1,
1819                 global: {},
1820                 
1821                 // Detach an event or set of events from an element
1822                 remove: function(element, type, handler) {
1823                         if (element.events)
1824                                 if (type && element.events[type])
1825                                         if ( handler )
1826                                                 delete element.events[type][handler.guid];
1827                                         else
1828                                                 for ( var i in element.events[type] )
1829                                                         delete element.events[type][i];
1830                                 else
1831                                         for ( var j in element.events )
1832                                                 this.remove( element, j );
1833                 },
1834                 
1835                 trigger: function(type,data,element) {
1836                         // Touch up the incoming data
1837                         data = data || [];
1838         
1839                         // Handle a global trigger
1840                         if ( !element ) {
1841                                 var g = this.global[type];
1842                                 if ( g )
1843                                         for ( var i = 0; i < g.length; i++ )
1844                                                 this.trigger( type, data, g[i] );
1845         
1846                         // Handle triggering a single element
1847                         } else if ( element["on" + type] ) {
1848                                 // Pass along a fake event
1849                                 data.unshift( this.fix({ type: type, target: element }) );
1850         
1851                                 // Trigger the event
1852                                 element["on" + type].apply( element, data );
1853                         }
1854                 },
1855                 
1856                 handle: function(event) {
1857                         if ( typeof jQuery == "undefined" ) return;
1858
1859                         event = event || jQuery.event.fix( window.event );
1860         
1861                         // If no correct event was found, fail
1862                         if ( !event ) return;
1863                 
1864                         var returnValue = true;
1865
1866                         var c = this.events[event.type];
1867                 
1868                         for ( var j in c ) {
1869                                 if ( c[j].apply( this, [event] ) === false ) {
1870                                         event.preventDefault();
1871                                         event.stopPropagation();
1872                                         returnValue = false;
1873                                 }
1874                         }
1875                         
1876                         return returnValue;
1877                 },
1878                 
1879                 fix: function(event) {
1880                         if ( event ) {
1881                                 event.preventDefault = function() {
1882                                         this.returnValue = false;
1883                                 };
1884                         
1885                                 event.stopPropagation = function() {
1886                                         this.cancelBubble = true;
1887                                 };
1888                         }
1889                         
1890                         return event;
1891                 }
1892         
1893         }
1894 });
1895
1896 new function() {
1897         var b = navigator.userAgent.toLowerCase();
1898
1899         // Figure out what browser is being used
1900         jQuery.browser = {
1901                 safari: /webkit/.test(b),
1902                 opera: /opera/.test(b),
1903                 msie: /msie/.test(b) && !/opera/.test(b),
1904                 mozilla: /mozilla/.test(b) && !/(compatible|webkit)/.test(b)
1905         };
1906
1907         // Check to see if the W3C box model is being used
1908         jQuery.boxModel = !jQuery.browser.msie || document.compatMode == "CSS1Compat";
1909 };
1910
1911 jQuery.macros = {
1912         to: {
1913                 /**
1914                  * Append all of the matched elements to another, specified, set of elements.
1915                  * This operation is, essentially, the reverse of doing a regular
1916                  * $(A).append(B), in that instead of appending B to A, you're appending
1917                  * A to B.
1918                  * 
1919                  * @example $("p").appendTo("#foo");
1920                  * @before <p>I would like to say: </p><div id="foo"></div>
1921                  * @result <div id="foo"><p>I would like to say: </p></div>
1922                  *
1923                  * @name appendTo
1924                  * @type jQuery
1925                  * @param String expr A jQuery expression of elements to match.
1926                  * @cat DOM/Manipulation
1927                  */
1928                 appendTo: "append",
1929                 
1930                 /**
1931                  * Prepend all of the matched elements to another, specified, set of elements.
1932                  * This operation is, essentially, the reverse of doing a regular
1933                  * $(A).prepend(B), in that instead of prepending B to A, you're prepending
1934                  * A to B.
1935                  * 
1936                  * @example $("p").prependTo("#foo");
1937                  * @before <p>I would like to say: </p><div id="foo"><b>Hello</b></div>
1938                  * @result <div id="foo"><p>I would like to say: </p><b>Hello</b></div>
1939                  *
1940                  * @name prependTo
1941                  * @type jQuery
1942                  * @param String expr A jQuery expression of elements to match.
1943                  * @cat DOM/Manipulation
1944                  */
1945                 prependTo: "prepend",
1946                 
1947                 /**
1948                  * Insert all of the matched elements before another, specified, set of elements.
1949                  * This operation is, essentially, the reverse of doing a regular
1950                  * $(A).before(B), in that instead of inserting B before A, you're inserting
1951                  * A before B.
1952                  * 
1953                  * @example $("p").insertBefore("#foo");
1954                  * @before <div id="foo">Hello</div><p>I would like to say: </p>
1955                  * @result <p>I would like to say: </p><div id="foo">Hello</div>
1956                  *
1957                  * @name insertBefore
1958                  * @type jQuery
1959                  * @param String expr A jQuery expression of elements to match.
1960                  * @cat DOM/Manipulation
1961                  */
1962                 insertBefore: "before",
1963                 
1964                 /**
1965                  * Insert all of the matched elements after another, specified, set of elements.
1966                  * This operation is, essentially, the reverse of doing a regular
1967                  * $(A).after(B), in that instead of inserting B after A, you're inserting
1968                  * A after B.
1969                  * 
1970                  * @example $("p").insertAfter("#foo");
1971                  * @before <p>I would like to say: </p><div id="foo">Hello</div>
1972                  * @result <div id="foo">Hello</div><p>I would like to say: </p>
1973                  *
1974                  * @name insertAfter
1975                  * @type jQuery
1976                  * @param String expr A jQuery expression of elements to match.
1977                  * @cat DOM/Manipulation
1978                  */
1979                 insertAfter: "after"
1980         },
1981         
1982         /**
1983          * Get the current CSS width of the first matched element.
1984          * 
1985          * @example $("p").width();
1986          * @before <p>This is just a test.</p>
1987          * @result "300px"
1988          *
1989          * @name width
1990          * @type String
1991          * @cat CSS
1992          */
1993          
1994         /**
1995          * Set the CSS width of every matched element. Be sure to include
1996          * the "px" (or other unit of measurement) after the number that you 
1997          * specify, otherwise you might get strange results.
1998          * 
1999          * @example $("p").width("20px");
2000          * @before <p>This is just a test.</p>
2001          * @result <p style="width:20px;">This is just a test.</p>
2002          *
2003          * @name width
2004          * @type jQuery
2005          * @param String val Set the CSS property to the specified value.
2006          * @cat CSS
2007          */
2008         
2009         /**
2010          * Get the current CSS height of the first matched element.
2011          * 
2012          * @example $("p").height();
2013          * @before <p>This is just a test.</p>
2014          * @result "14px"
2015          *
2016          * @name height
2017          * @type String
2018          * @cat CSS
2019          */
2020          
2021         /**
2022          * Set the CSS height of every matched element. Be sure to include
2023          * the "px" (or other unit of measurement) after the number that you 
2024          * specify, otherwise you might get strange results.
2025          * 
2026          * @example $("p").height("20px");
2027          * @before <p>This is just a test.</p>
2028          * @result <p style="height:20px;">This is just a test.</p>
2029          *
2030          * @name height
2031          * @type jQuery
2032          * @param String val Set the CSS property to the specified value.
2033          * @cat CSS
2034          */
2035          
2036         /**
2037          * Get the current CSS top of the first matched element.
2038          * 
2039          * @example $("p").top();
2040          * @before <p>This is just a test.</p>
2041          * @result "0px"
2042          *
2043          * @name top
2044          * @type String
2045          * @cat CSS
2046          */
2047          
2048         /**
2049          * Set the CSS top of every matched element. Be sure to include
2050          * the "px" (or other unit of measurement) after the number that you 
2051          * specify, otherwise you might get strange results.
2052          * 
2053          * @example $("p").top("20px");
2054          * @before <p>This is just a test.</p>
2055          * @result <p style="top:20px;">This is just a test.</p>
2056          *
2057          * @name top
2058          * @type jQuery
2059          * @param String val Set the CSS property to the specified value.
2060          * @cat CSS
2061          */
2062          
2063         /**
2064          * Get the current CSS left of the first matched element.
2065          * 
2066          * @example $("p").left();
2067          * @before <p>This is just a test.</p>
2068          * @result "0px"
2069          *
2070          * @name left
2071          * @type String
2072          * @cat CSS
2073          */
2074          
2075         /**
2076          * Set the CSS left of every matched element. Be sure to include
2077          * the "px" (or other unit of measurement) after the number that you 
2078          * specify, otherwise you might get strange results.
2079          * 
2080          * @example $("p").left("20px");
2081          * @before <p>This is just a test.</p>
2082          * @result <p style="left:20px;">This is just a test.</p>
2083          *
2084          * @name left
2085          * @type jQuery
2086          * @param String val Set the CSS property to the specified value.
2087          * @cat CSS
2088          */
2089          
2090         /**
2091          * Get the current CSS position of the first matched element.
2092          * 
2093          * @example $("p").position();
2094          * @before <p>This is just a test.</p>
2095          * @result "static"
2096          *
2097          * @name position
2098          * @type String
2099          * @cat CSS
2100          */
2101          
2102         /**
2103          * Set the CSS position of every matched element.
2104          * 
2105          * @example $("p").position("relative");
2106          * @before <p>This is just a test.</p>
2107          * @result <p style="position:relative;">This is just a test.</p>
2108          *
2109          * @name position
2110          * @type jQuery
2111          * @param String val Set the CSS property to the specified value.
2112          * @cat CSS
2113          */
2114          
2115         /**
2116          * Get the current CSS float of the first matched element.
2117          * 
2118          * @example $("p").float();
2119          * @before <p>This is just a test.</p>
2120          * @result "none"
2121          *
2122          * @name float
2123          * @type String
2124          * @cat CSS
2125          */
2126          
2127         /**
2128          * Set the CSS float of every matched element.
2129          * 
2130          * @example $("p").float("left");
2131          * @before <p>This is just a test.</p>
2132          * @result <p style="float:left;">This is just a test.</p>
2133          *
2134          * @name float
2135          * @type jQuery
2136          * @param String val Set the CSS property to the specified value.
2137          * @cat CSS
2138          */
2139          
2140         /**
2141          * Get the current CSS overflow of the first matched element.
2142          * 
2143          * @example $("p").overflow();
2144          * @before <p>This is just a test.</p>
2145          * @result "none"
2146          *
2147          * @name overflow
2148          * @type String
2149          * @cat CSS
2150          */
2151          
2152         /**
2153          * Set the CSS overflow of every matched element.
2154          * 
2155          * @example $("p").overflow("auto");
2156          * @before <p>This is just a test.</p>
2157          * @result <p style="overflow:auto;">This is just a test.</p>
2158          *
2159          * @name overflow
2160          * @type jQuery
2161          * @param String val Set the CSS property to the specified value.
2162          * @cat CSS
2163          */
2164          
2165         /**
2166          * Get the current CSS color of the first matched element.
2167          * 
2168          * @example $("p").color();
2169          * @before <p>This is just a test.</p>
2170          * @result "black"
2171          *
2172          * @name color
2173          * @type String
2174          * @cat CSS
2175          */
2176          
2177         /**
2178          * Set the CSS color of every matched element.
2179          * 
2180          * @example $("p").color("blue");
2181          * @before <p>This is just a test.</p>
2182          * @result <p style="color:blue;">This is just a test.</p>
2183          *
2184          * @name color
2185          * @type jQuery
2186          * @param String val Set the CSS property to the specified value.
2187          * @cat CSS
2188          */
2189          
2190         /**
2191          * Get the current CSS background of the first matched element.
2192          * 
2193          * @example $("p").background();
2194          * @before <p style="background:blue;">This is just a test.</p>
2195          * @result "blue"
2196          *
2197          * @name background
2198          * @type String
2199          * @cat CSS
2200          */
2201          
2202         /**
2203          * Set the CSS background of every matched element.
2204          * 
2205          * @example $("p").background("blue");
2206          * @before <p>This is just a test.</p>
2207          * @result <p style="background:blue;">This is just a test.</p>
2208          *
2209          * @name background
2210          * @type jQuery
2211          * @param String val Set the CSS property to the specified value.
2212          * @cat CSS
2213          */
2214         
2215         css: "width,height,top,left,position,float,overflow,color,background".split(","),
2216         
2217         /**
2218          * Reduce the set of matched elements to a single element.
2219          * The position of the element in the set of matched elements
2220          * starts at 0 and goes to length - 1.
2221          * 
2222          * @example $("p").eq(1)
2223          * @before <p>This is just a test.</p><p>So is this</p>
2224          * @result [ <p>So is this</p> ]
2225          *
2226          * @name eq
2227          * @type jQuery
2228          * @param Number pos The index of the element that you wish to limit to.
2229          * @cat Core
2230          */
2231          
2232         /**
2233          * Reduce the set of matched elements to all elements before a given position.
2234          * The position of the element in the set of matched elements
2235          * starts at 0 and goes to length - 1.
2236          * 
2237          * @example $("p").lt(1)
2238          * @before <p>This is just a test.</p><p>So is this</p>
2239          * @result [ <p>This is just a test.</p> ]
2240          *
2241          * @name lt
2242          * @type jQuery
2243          * @param Number pos Reduce the set to all elements below this position.
2244          * @cat Core
2245          */
2246          
2247         /**
2248          * Reduce the set of matched elements to all elements after a given position.
2249          * The position of the element in the set of matched elements
2250          * starts at 0 and goes to length - 1.
2251          * 
2252          * @example $("p").gt(0)
2253          * @before <p>This is just a test.</p><p>So is this</p>
2254          * @result [ <p>So is this</p> ]
2255          *
2256          * @name gt
2257          * @type jQuery
2258          * @param Number pos Reduce the set to all elements after this position.
2259          * @cat Core
2260          */
2261          
2262         /**
2263          * Filter the set of elements to those that contain the specified text.
2264          * 
2265          * @example $("p").contains("test")
2266          * @before <p>This is just a test.</p><p>So is this</p>
2267          * @result [ <p>This is just a test.</p> ]
2268          *
2269          * @name contains
2270          * @type jQuery
2271          * @param String str The string that will be contained within the text of an element.
2272          * @cat DOM/Traversing
2273          */
2274
2275         filter: [ "eq", "lt", "gt", "contains" ],
2276
2277         attr: {
2278                 /**
2279                  * Get the current value of the first matched element.
2280                  * 
2281                  * @example $("input").val();
2282                  * @before <input type="text" value="some text"/>
2283                  * @result "some text"
2284                  *
2285                  * @name val
2286                  * @type String
2287                  * @cat DOM/Attributes
2288                  */
2289                  
2290                 /**
2291                  * Set the value of every matched element.
2292                  * 
2293                  * @example $("input").value("test");
2294                  * @before <input type="text" value="some text"/>
2295                  * @result <input type="text" value="test"/>
2296                  *
2297                  * @name val
2298                  * @type jQuery
2299                  * @param String val Set the property to the specified value.
2300                  * @cat DOM/Attributes
2301                  */
2302                 val: "value",
2303                 
2304                 /**
2305                  * Get the html contents of the first matched element.
2306                  * 
2307                  * @example $("div").html();
2308                  * @before <div><input/></div>
2309                  * @result <input/>
2310                  *
2311                  * @name html
2312                  * @type String
2313                  * @cat DOM/Attributes
2314                  */
2315                  
2316                 /**
2317                  * Set the html contents of every matched element.
2318                  * 
2319                  * @example $("div").html("<b>new stuff</b>");
2320                  * @before <div><input/></div>
2321                  * @result <div><b>new stuff</b></div>
2322                  *
2323                  * @test var div = $("div");
2324                  * div.html("<b>test</b>");
2325                  * var pass = true;
2326                  * for ( var i = 0; i < div.size(); i++ ) {
2327                  *   if ( div.get(i).childNodes.length == 0 ) pass = false;
2328                  * }
2329                  * ok( pass, "Set HTML" );
2330                  *
2331                  * @name html
2332                  * @type jQuery
2333                  * @param String val Set the html contents to the specified value.
2334                  * @cat DOM/Attributes
2335                  */
2336                 html: "innerHTML",
2337                 
2338                 /**
2339                  * Get the current id of the first matched element.
2340                  * 
2341                  * @example $("input").id();
2342                  * @before <input type="text" id="test" value="some text"/>
2343                  * @result "test"
2344                  *
2345                  * @name id
2346                  * @type String
2347                  * @cat DOM/Attributes
2348                  */
2349                  
2350                 /**
2351                  * Set the id of every matched element.
2352                  * 
2353                  * @example $("input").id("newid");
2354                  * @before <input type="text" id="test" value="some text"/>
2355                  * @result <input type="text" id="newid" value="some text"/>
2356                  *
2357                  * @name id
2358                  * @type jQuery
2359                  * @param String val Set the property to the specified value.
2360                  * @cat DOM/Attributes
2361                  */
2362                 id: null,
2363                 
2364                 /**
2365                  * Get the current title of the first matched element.
2366                  * 
2367                  * @example $("img").title();
2368                  * @before <img src="test.jpg" title="my image"/>
2369                  * @result "my image"
2370                  *
2371                  * @name title
2372                  * @type String
2373                  * @cat DOM/Attributes
2374                  */
2375                  
2376                 /**
2377                  * Set the title of every matched element.
2378                  * 
2379                  * @example $("img").title("new title");
2380                  * @before <img src="test.jpg" title="my image"/>
2381                  * @result <img src="test.jpg" title="new image"/>
2382                  *
2383                  * @name title
2384                  * @type jQuery
2385                  * @param String val Set the property to the specified value.
2386                  * @cat DOM/Attributes
2387                  */
2388                 title: null,
2389                 
2390                 /**
2391                  * Get the current name of the first matched element.
2392                  * 
2393                  * @example $("input").name();
2394                  * @before <input type="text" name="username"/>
2395                  * @result "username"
2396                  *
2397                  * @name name
2398                  * @type String
2399                  * @cat DOM/Attributes
2400                  */
2401                  
2402                 /**
2403                  * Set the name of every matched element.
2404                  * 
2405                  * @example $("input").name("user");
2406                  * @before <input type="text" name="username"/>
2407                  * @result <input type="text" name="user"/>
2408                  *
2409                  * @name name
2410                  * @type jQuery
2411                  * @param String val Set the property to the specified value.
2412                  * @cat DOM/Attributes
2413                  */
2414                 name: null,
2415                 
2416                 /**
2417                  * Get the current href of the first matched element.
2418                  * 
2419                  * @example $("a").href();
2420                  * @before <a href="test.html">my link</a>
2421                  * @result "test.html"
2422                  *
2423                  * @name href
2424                  * @type String
2425                  * @cat DOM/Attributes
2426                  */
2427                  
2428                 /**
2429                  * Set the href of every matched element.
2430                  * 
2431                  * @example $("a").href("test2.html");
2432                  * @before <a href="test.html">my link</a>
2433                  * @result <a href="test2.html">my link</a>
2434                  *
2435                  * @name href
2436                  * @type jQuery
2437                  * @param String val Set the property to the specified value.
2438                  * @cat DOM/Attributes
2439                  */
2440                 href: null,
2441                 
2442                 /**
2443                  * Get the current src of the first matched element.
2444                  * 
2445                  * @example $("img").src();
2446                  * @before <img src="test.jpg" title="my image"/>
2447                  * @result "test.jpg"
2448                  *
2449                  * @name src
2450                  * @type String
2451                  * @cat DOM/Attributes
2452                  */
2453                  
2454                 /**
2455                  * Set the src of every matched element.
2456                  * 
2457                  * @example $("img").src("test2.jpg");
2458                  * @before <img src="test.jpg" title="my image"/>
2459                  * @result <img src="test2.jpg" title="my image"/>
2460                  *
2461                  * @name src
2462                  * @type jQuery
2463                  * @param String val Set the property to the specified value.
2464                  * @cat DOM/Attributes
2465                  */
2466                 src: null,
2467                 
2468                 /**
2469                  * Get the current rel of the first matched element.
2470                  * 
2471                  * @example $("a").rel();
2472                  * @before <a href="test.html" rel="nofollow">my link</a>
2473                  * @result "nofollow"
2474                  *
2475                  * @name rel
2476                  * @type String
2477                  * @cat DOM/Attributes
2478                  */
2479                  
2480                 /**
2481                  * Set the rel of every matched element.
2482                  * 
2483                  * @example $("a").rel("nofollow");
2484                  * @before <a href="test.html">my link</a>
2485                  * @result <a href="test.html" rel="nofollow">my link</a>
2486                  *
2487                  * @name rel
2488                  * @type jQuery
2489                  * @param String val Set the property to the specified value.
2490                  * @cat DOM/Attributes
2491                  */
2492                 rel: null
2493         },
2494         
2495         axis: {
2496                 /**
2497                  * Get a set of elements containing the unique parents of the matched
2498                  * set of elements.
2499                  *
2500                  * @example $("p").parent()
2501                  * @before <div><p>Hello</p><p>Hello</p></div>
2502                  * @result [ <div><p>Hello</p><p>Hello</p></div> ]
2503                  *
2504                  * @name parent
2505                  * @type jQuery
2506                  * @cat DOM/Traversing
2507                  */
2508
2509                 /**
2510                  * Get a set of elements containing the unique parents of the matched
2511                  * set of elements, and filtered by an expression.
2512                  *
2513                  * @example $("p").parent(".selected")
2514                  * @before <div><p>Hello</p></div><div class="selected"><p>Hello Again</p></div>
2515                  * @result [ <div class="selected"><p>Hello Again</p></div> ]
2516                  *
2517                  * @name parent
2518                  * @type jQuery
2519                  * @param String expr An expression to filter the parents with
2520                  * @cat DOM/Traversing
2521                  */
2522                 parent: "a.parentNode",
2523
2524                 /**
2525                  * Get a set of elements containing the unique ancestors of the matched
2526                  * set of elements (except for the root element).
2527                  *
2528                  * @example $("span").ancestors()
2529                  * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html>
2530                  * @result [ <body>...</body>, <div>...</div>, <p><span>Hello</span></p> ] 
2531                  *
2532                  * @name ancestors
2533                  * @type jQuery
2534                  * @cat DOM/Traversing
2535                  */
2536
2537                 /**
2538                  * Get a set of elements containing the unique ancestors of the matched
2539                  * set of elements, and filtered by an expression.
2540                  *
2541                  * @example $("span").ancestors("p")
2542                  * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html>
2543                  * @result [ <p><span>Hello</span></p> ] 
2544                  *
2545                  * @name ancestors
2546                  * @type jQuery
2547                  * @param String expr An expression to filter the ancestors with
2548                  * @cat DOM/Traversing
2549                  */
2550                 ancestors: jQuery.parents,
2551                 
2552                 /**
2553                  * Get a set of elements containing the unique ancestors of the matched
2554                  * set of elements (except for the root element).
2555                  *
2556                  * @example $("span").ancestors()
2557                  * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html>
2558                  * @result [ <body>...</body>, <div>...</div>, <p><span>Hello</span></p> ] 
2559                  *
2560                  * @name parents
2561                  * @type jQuery
2562                  * @cat DOM/Traversing
2563                  */
2564
2565                 /**
2566                  * Get a set of elements containing the unique ancestors of the matched
2567                  * set of elements, and filtered by an expression.
2568                  *
2569                  * @example $("span").ancestors("p")
2570                  * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html>
2571                  * @result [ <p><span>Hello</span></p> ] 
2572                  *
2573                  * @name parents
2574                  * @type jQuery
2575                  * @param String expr An expression to filter the ancestors with
2576                  * @cat DOM/Traversing
2577                  */
2578                 parents: jQuery.parents,
2579
2580                 /**
2581                  * Get a set of elements containing the unique next siblings of each of the 
2582                  * matched set of elements.
2583                  * 
2584                  * It only returns the very next sibling, not all next siblings.
2585                  *
2586                  * @example $("p").next()
2587                  * @before <p>Hello</p><p>Hello Again</p><div><span>And Again</span></div>
2588                  * @result [ <p>Hello Again</p>, <div><span>And Again</span></div> ]
2589                  *
2590                  * @name next
2591                  * @type jQuery
2592                  * @cat DOM/Traversing
2593                  */
2594
2595                 /**
2596                  * Get a set of elements containing the unique next siblings of each of the 
2597                  * matched set of elements, and filtered by an expression.
2598                  * 
2599                  * It only returns the very next sibling, not all next siblings.
2600                  *
2601                  * @example $("p").next(".selected")
2602                  * @before <p>Hello</p><p class="selected">Hello Again</p><div><span>And Again</span></div>
2603                  * @result [ <p class="selected">Hello Again</p> ]
2604                  *
2605                  * @name next
2606                  * @type jQuery
2607                  * @param String expr An expression to filter the next Elements with
2608                  * @cat DOM/Traversing
2609                  */
2610                 next: "jQuery.sibling(a).next",
2611
2612                 /**
2613                  * Get a set of elements containing the unique previous siblings of each of the 
2614                  * matched set of elements.
2615                  * 
2616                  * It only returns the immediately previous sibling, not all previous siblings.
2617                  *
2618                  * @example $("p").previous()
2619                  * @before <p>Hello</p><div><span>Hello Again</span></div><p>And Again</p>
2620                  * @result [ <div><span>Hello Again</span></div> ]
2621                  *
2622                  * @name prev
2623                  * @type jQuery
2624                  * @cat DOM/Traversing
2625                  */
2626
2627                 /**
2628                  * Get a set of elements containing the unique previous siblings of each of the 
2629                  * matched set of elements, and filtered by an expression.
2630                  * 
2631                  * It only returns the immediately previous sibling, not all previous siblings.
2632                  *
2633                  * @example $("p").previous(".selected")
2634                  * @before <div><span>Hello</span></div><p class="selected">Hello Again</p><p>And Again</p>
2635                  * @result [ <div><span>Hello</span></div> ]
2636                  *
2637                  * @name prev
2638                  * @type jQuery
2639                  * @param String expr An expression to filter the previous Elements with
2640                  * @cat DOM/Traversing
2641                  */
2642                 prev: "jQuery.sibling(a).prev",
2643
2644                 /**
2645                  * Get a set of elements containing all of the unique siblings of each of the 
2646                  * matched set of elements.
2647                  * 
2648                  * @example $("div").siblings()
2649                  * @before <p>Hello</p><div><span>Hello Again</span></div><p>And Again</p>
2650                  * @result [ <p>Hello</p>, <p>And Again</p> ]
2651                  *
2652                  * @name siblings
2653                  * @type jQuery
2654                  * @cat DOM/Traversing
2655                  */
2656
2657                 /**
2658                  * Get a set of elements containing all of the unique siblings of each of the 
2659                  * matched set of elements, and filtered by an expression.
2660                  *
2661                  * @example $("div").siblings(".selected")
2662                  * @before <div><span>Hello</span></div><p class="selected">Hello Again</p><p>And Again</p>
2663                  * @result [ <p class="selected">Hello Again</p> ]
2664                  *
2665                  * @name siblings
2666                  * @type jQuery
2667                  * @param String expr An expression to filter the sibling Elements with
2668                  * @cat DOM/Traversing
2669                  */
2670                 siblings: jQuery.sibling,
2671                 
2672                 
2673                 /**
2674                  * Get a set of elements containing all of the unique children of each of the 
2675                  * matched set of elements.
2676                  * 
2677                  * @example $("div").children()
2678                  * @before <p>Hello</p><div><span>Hello Again</span></div><p>And Again</p>
2679                  * @result [ <span>Hello Again</span> ]
2680                  *
2681                  * @name children
2682                  * @type jQuery
2683                  * @cat DOM/Traversing
2684                  */
2685
2686                 /**
2687                  * Get a set of elements containing all of the unique children of each of the 
2688                  * matched set of elements, and filtered by an expression.
2689                  *
2690                  * @example $("div").children(".selected")
2691                  * @before <div><span>Hello</span><p class="selected">Hello Again</p><p>And Again</p></div>
2692                  * @result [ <p class="selected">Hello Again</p> ]
2693                  *
2694                  * @name children
2695                  * @type jQuery
2696                  * @param String expr An expression to filter the child Elements with
2697                  * @cat DOM/Traversing
2698                  */
2699                 children: "jQuery.sibling(a.firstChild)"
2700         },
2701
2702         each: {
2703
2704                 /**
2705                  * Remove an attribute from each of the matched elements.
2706                  *
2707                  * @example $("input").removeAttr("disabled")
2708                  * @before <input disabled="disabled"/>
2709                  * @result <input/>
2710                  *
2711                  * @name removeAttr
2712                  * @type jQuery
2713                  * @param String name The name of the attribute to remove.
2714                  * @cat DOM
2715                  */
2716                 removeAttr: function( key ) {
2717                         this.removeAttribute( key );
2718                 },
2719
2720                 /**
2721                  * Displays each of the set of matched elements if they are hidden.
2722                  * 
2723                  * @example $("p").show()
2724                  * @before <p style="display: none">Hello</p>
2725                  * @result [ <p style="display: block">Hello</p> ]
2726                  *
2727                  * @test var pass = true, div = $("div");
2728                  * div.show().each(function(){
2729                  *   if ( this.style.display == "none" ) pass = false;
2730                  * });
2731                  * ok( pass, "Show" );
2732                  *
2733                  * @name show
2734                  * @type jQuery
2735                  * @cat Effects
2736                  */
2737                 show: function(){
2738                         this.style.display = this.oldblock ? this.oldblock : "";
2739                         if ( jQuery.css(this,"display") == "none" )
2740                                 this.style.display = "block";
2741                 },
2742
2743                 /**
2744                  * Hides each of the set of matched elements if they are shown.
2745                  *
2746                  * @example $("p").hide()
2747                  * @before <p>Hello</p>
2748                  * @result [ <p style="display: none">Hello</p> ]
2749                  *
2750                  * var pass = true, div = $("div");
2751                  * div.hide().each(function(){
2752                  *   if ( this.style.display != "none" ) pass = false;
2753                  * });
2754                  * ok( pass, "Hide" );
2755                  *
2756                  * @name hide
2757                  * @type jQuery
2758                  * @cat Effects
2759                  */
2760                 hide: function(){
2761                         this.oldblock = this.oldblock || jQuery.css(this,"display");
2762                         if ( this.oldblock == "none" )
2763                                 this.oldblock = "block";
2764                         this.style.display = "none";
2765                 },
2766                 
2767                 /**
2768                  * Toggles each of the set of matched elements. If they are shown,
2769                  * toggle makes them hidden. If they are hidden, toggle
2770                  * makes them shown.
2771                  *
2772                  * @example $("p").toggle()
2773                  * @before <p>Hello</p><p style="display: none">Hello Again</p>
2774                  * @result [ <p style="display: none">Hello</p>, <p style="display: block">Hello Again</p> ]
2775                  *
2776                  * @name toggle
2777                  * @type jQuery
2778                  * @cat Effects
2779                  */
2780                 toggle: function(){
2781                         jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ].apply( jQuery(this), arguments );
2782                 },
2783                 
2784                 /**
2785                  * Adds the specified class to each of the set of matched elements.
2786                  *
2787                  * @example $("p").addClass("selected")
2788                  * @before <p>Hello</p>
2789                  * @result [ <p class="selected">Hello</p> ]
2790                  *
2791                  * @test var div = $("div");
2792                  * div.addClass("test");
2793                  * var pass = true;
2794                  * for ( var i = 0; i < div.size(); i++ ) {
2795                  *  if ( div.get(i).className.indexOf("test") == -1 ) pass = false;
2796                  * }
2797                  * ok( pass, "Add Class" );
2798                  * 
2799                  * @name addClass
2800                  * @type jQuery
2801                  * @param String class A CSS class to add to the elements
2802                  * @cat DOM
2803                  */
2804                 addClass: function(c){
2805                         jQuery.className.add(this,c);
2806                 },
2807                 
2808                 /**
2809                  * Removes the specified class from the set of matched elements.
2810                  *
2811                  * @example $("p").removeClass("selected")
2812                  * @before <p class="selected">Hello</p>
2813                  * @result [ <p>Hello</p> ]
2814                  *
2815                  * @test var div = $("div").addClass("test");
2816                  * div.removeClass("test");
2817                  * var pass = true;
2818                  * for ( var i = 0; i < div.size(); i++ ) {
2819                  *  if ( div.get(i).className.indexOf("test") != -1 ) pass = false;
2820                  * }
2821                  * ok( pass, "Remove Class" );
2822                  *
2823                  * @name removeClass
2824                  * @type jQuery
2825                  * @param String class A CSS class to remove from the elements
2826                  * @cat DOM
2827                  */
2828                 removeClass: function(c){
2829                         jQuery.className.remove(this,c);
2830                 },
2831         
2832                 /**
2833                  * Adds the specified class if it is present, removes it if it is
2834                  * not present.
2835                  *
2836                  * @example $("p").toggleClass("selected")
2837                  * @before <p>Hello</p><p class="selected">Hello Again</p>
2838                  * @result [ <p class="selected">Hello</p>, <p>Hello Again</p> ]
2839                  *
2840                  * @name toggleClass
2841                  * @type jQuery
2842                  * @param String class A CSS class with which to toggle the elements
2843                  * @cat DOM
2844                  */
2845                 toggleClass: function( c ){
2846                         jQuery.className[ jQuery.className.has(this,c) ? "remove" : "add" ](this,c);
2847                 },
2848                 
2849                 /**
2850                  * Removes all matched elements from the DOM. This does NOT remove them from the
2851                  * jQuery object, allowing you to use the matched elements further.
2852                  *
2853                  * @example $("p").remove();
2854                  * @before <p>Hello</p> how are <p>you?</p>
2855                  * @result how are
2856                  *
2857                  * @name remove
2858                  * @type jQuery
2859                  * @cat DOM/Manipulation
2860                  */
2861                  
2862                 /**
2863                  * Removes only elements (out of the list of matched elements) that match
2864                  * the specified jQuery expression. This does NOT remove them from the
2865                  * jQuery object, allowing you to use the matched elements further.
2866                  *
2867                  * @example $("p").remove(".hello");
2868                  * @before <p class="hello">Hello</p> how are <p>you?</p>
2869                  * @result how are <p>you?</p>
2870                  *
2871                  * @name remove
2872                  * @type jQuery
2873                  * @param String expr A jQuery expression to filter elements by.
2874                  * @cat DOM/Manipulation
2875                  */
2876                 remove: function(a){
2877                         if ( !a || jQuery.filter( a, [this] ).r )
2878                                 this.parentNode.removeChild( this );
2879                 },
2880         
2881                 /**
2882                  * Removes all child nodes from the set of matched elements.
2883                  *
2884                  * @example $("p").empty()
2885                  * @before <p>Hello, <span>Person</span> <a href="#">and person</a></p>
2886                  * @result [ <p></p> ]
2887                  *
2888                  * @name empty
2889                  * @type jQuery
2890                  * @cat DOM/Manipulation
2891                  */
2892                 empty: function(){
2893                         while ( this.firstChild )
2894                                 this.removeChild( this.firstChild );
2895                 },
2896                 
2897                 /**
2898                  * Binds a particular event (like click) to a each of a set of match elements.
2899                  *
2900                  * @example $("p").bind( "click", function() { alert("Hello"); } )
2901                  * @before <p>Hello</p>
2902                  * @result [ <p>Hello</p> ]
2903                  *
2904                  * Cancel a default action and prevent it from bubbling by returning false
2905                  * from your function.
2906                  *
2907                  * @example $("form").bind( "submit", function() { return false; } )
2908                  *
2909                  * Cancel a default action by using the preventDefault method.
2910                  *
2911                  * @example $("form").bind( "submit", function() { e.preventDefault(); } )
2912                  *
2913                  * Stop an event from bubbling by using the stopPropogation method.
2914                  *
2915                  * @example $("form").bind( "submit", function() { e.stopPropogation(); } )
2916                  *
2917                  * @name bind
2918                  * @type jQuery
2919                  * @param String type An event type
2920                  * @param Function fn A function to bind to the event on each of the set of matched elements
2921                  * @cat Events
2922                  */
2923                 bind: function( type, fn ) {
2924                         if ( fn.constructor == String )
2925                                 fn = new Function("e", ( !fn.indexOf(".") ? "jQuery(this)" : "return " ) + fn);
2926                         jQuery.event.add( this, type, fn );
2927                 },
2928                 
2929                 /**
2930                  * The opposite of bind, removes a bound event from each of the matched
2931                  * elements. You must pass the identical function that was used in the original 
2932                  * bind method.
2933                  *
2934                  * @example $("p").unbind( "click", function() { alert("Hello"); } )
2935                  * @before <p onclick="alert('Hello');">Hello</p>
2936                  * @result [ <p>Hello</p> ]
2937                  *
2938                  * @name unbind
2939                  * @type jQuery
2940                  * @param String type An event type
2941                  * @param Function fn A function to unbind from the event on each of the set of matched elements
2942                  * @cat Events
2943                  */
2944                  
2945                 /**
2946                  * Removes all bound events of a particular type from each of the matched
2947                  * elements.
2948                  *
2949                  * @example $("p").unbind( "click" )
2950                  * @before <p onclick="alert('Hello');">Hello</p>
2951                  * @result [ <p>Hello</p> ]
2952                  *
2953                  * @name unbind
2954                  * @type jQuery
2955                  * @param String type An event type
2956                  * @cat Events
2957                  */
2958                  
2959                 /**
2960                  * Removes all bound events from each of the matched elements.
2961                  *
2962                  * @example $("p").unbind()
2963                  * @before <p onclick="alert('Hello');">Hello</p>
2964                  * @result [ <p>Hello</p> ]
2965                  *
2966                  * @name unbind
2967                  * @type jQuery
2968                  * @cat Events
2969                  */
2970                 unbind: function( type, fn ) {
2971                         jQuery.event.remove( this, type, fn );
2972                 },
2973                 
2974                 /**
2975                  * Trigger a type of event on every matched element.
2976                  *
2977                  * @example $("p").trigger("click")
2978                  * @before <p click="alert('hello')">Hello</p>
2979                  * @result alert('hello')
2980                  *
2981                  * @name trigger
2982                  * @type jQuery
2983                  * @param String type An event type to trigger.
2984                  * @cat Events
2985                  */
2986                 trigger: function( type, data ) {
2987                         jQuery.event.trigger( type, data, this );
2988                 }
2989         }
2990 };
2991
2992 jQuery.init();