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