Added test and documentation for filter(Function)
[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 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          * pass the specified filter. This method is used to narrow down
866          * the results of a search.
867          *
868          * The elements to filter are passed as the first argument, their
869          * index inside the set as the second.
870          *
871          * @example $("p").filter(function(element, index) {
872          *   return $("ol", element).length == 0;
873          * })
874          * @before <p><ol><li>Hello</li></ol></p><p>How are you?</p>
875          * @result [ <p>How are you?</p> ]
876          * @desc Remove all elements that have a child ol element
877          *
878          * @name filter
879          * @type jQuery
880          * @param Function filter A function to use for filtering
881          * @cat DOM/Traversing
882          */
883
884         /**
885          * Removes all elements from the set of matched elements that do not
886          * match at least one of the expressions passed to the function. This
887          * method is used when you want to filter the set of matched elements
888          * through more than one expression.
889          *
890          * Elements will be retained in the jQuery object if they match at
891          * least one of the expressions passed.
892          *
893          * @example $("p").filter([".selected", ":first"])
894          * @before <p>Hello</p><p>Hello Again</p><p class="selected">And Again</p>
895          * @result [ <p>Hello</p>, <p class="selected">And Again</p> ]
896          *
897          * @name filter
898          * @type jQuery
899          * @param Array<String> exprs A set of expressions to evaluate against
900          * @cat DOM/Traversing
901          */
902         filter: function(t) {
903                 return this.pushStack(
904                         t.constructor == Array &&
905                         jQuery.map(this,function(a){
906                                 for ( var i = 0, tl = t.length; i < tl; i++ )
907                                         if ( jQuery.filter(t[i],[a]).r.length )
908                                                 return a;
909                                 return null;
910                         }) ||
911
912                         t.constructor == Boolean &&
913                         ( t ? this.get() : [] ) ||
914
915                         typeof t == "function" &&
916                         jQuery.grep( this, t ) ||
917
918                         jQuery.filter(t,this).r, arguments );
919         },
920
921         /**
922          * Removes the specified Element from the set of matched elements. This
923          * method is used to remove a single Element from a jQuery object.
924          *
925          * @example $("p").not( document.getElementById("selected") )
926          * @before <p>Hello</p><p id="selected">Hello Again</p>
927          * @result [ <p>Hello</p> ]
928          *
929          * @name not
930          * @type jQuery
931          * @param Element el An element to remove from the set
932          * @cat DOM/Traversing
933          */
934
935         /**
936          * Removes elements matching the specified expression from the set
937          * of matched elements. This method is used to remove one or more
938          * elements from a jQuery object.
939          *
940          * @example $("p").not("#selected")
941          * @before <p>Hello</p><p id="selected">Hello Again</p>
942          * @result [ <p>Hello</p> ]
943          *
944          * @name not
945          * @type jQuery
946          * @param String expr An expression with which to remove matching elements
947          * @cat DOM/Traversing
948          */
949         not: function(t) {
950                 return this.pushStack( typeof t == "string" ?
951                         jQuery.filter(t,this,true).r :
952                         jQuery.grep(this,function(a){ return a != t; }), arguments );
953         },
954
955         /**
956          * Adds the elements matched by the expression to the jQuery object. This
957          * can be used to concatenate the result sets of two expressions.
958          *
959          * @example $("p").add("span")
960          * @before <p>Hello</p><p><span>Hello Again</span></p>
961          * @result [ <p>Hello</p>, <span>Hello Again</span> ]
962          *
963          * @name add
964          * @type jQuery
965          * @param String expr An expression whose matched elements are added
966          * @cat DOM/Traversing
967          */
968
969         /**
970          * Adds each of the Elements in the array to the set of matched elements.
971          * This is used to add a set of Elements to a jQuery object.
972          *
973          * @example $("p").add([document.getElementById("a"), document.getElementById("b")])
974          * @before <p>Hello</p><p><span id="a">Hello Again</span><span id="b">And Again</span></p>
975          * @result [ <p>Hello</p>, <span id="a">Hello Again</span>, <span id="b">And Again</span> ]
976          *
977          * @name add
978          * @type jQuery
979          * @param Array<Element> els An array of Elements to add
980          * @cat DOM/Traversing
981          */
982
983         /**
984          * Adds a single Element to the set of matched elements. This is used to
985          * add a single Element to a jQuery object.
986          *
987          * @example $("p").add( document.getElementById("a") )
988          * @before <p>Hello</p><p><span id="a">Hello Again</span></p>
989          * @result [ <p>Hello</p>, <span id="a">Hello Again</span> ]
990          *
991          * @name add
992          * @type jQuery
993          * @param Element el An Element to add
994          * @cat DOM/Traversing
995          */
996         add: function(t) {
997                 return this.pushStack( jQuery.merge(
998                         this.get(), typeof t == "string" ?
999                                 jQuery.find(t) :
1000                                 t.constructor == Array ? t : [t] ), arguments );
1001         },
1002
1003         /**
1004          * Checks the current selection against an expression and returns true,
1005          * if at least one element of the selection fits the given expression.
1006          * Does return false, if no element fits or the expression is not valid.
1007          *
1008          * @example $("input[@type='checkbox']").parent().is("form")
1009          * @before <form><input type="checkbox" /></form>
1010          * @result true
1011          * @desc Returns true, because the parent of the input is a form element
1012          * 
1013          * @example $("input[@type='checkbox']").parent().is("form")
1014          * @before <form><p><input type="checkbox" /></p></form>
1015          * @result false
1016          * @desc Returns false, because the parent of the input is a p element
1017          *
1018          * @example $("form").is(null)
1019          * @before <form></form>
1020          * @result false
1021          * @desc An invalid expression always returns false.
1022          *
1023          * @name is
1024          * @type Boolean
1025          * @param String expr The expression with which to filter
1026          * @cat DOM/Traversing
1027          */
1028         is: function(expr) {
1029                 return expr ? jQuery.filter(expr,this).r.length > 0 : false;
1030         },
1031         
1032         /**
1033          * @private
1034          * @name domManip
1035          * @param Array args
1036          * @param Boolean table Insert TBODY in TABLEs if one is not found.
1037          * @param Number dir If dir<0, process args in reverse order.
1038          * @param Function fn The function doing the DOM manipulation.
1039          * @type jQuery
1040          * @cat Core
1041          */
1042         domManip: function(args, table, dir, fn){
1043                 var clone = this.length > 1; 
1044                 var a = jQuery.clean(args);
1045                 if ( dir < 0 )
1046                         a.reverse();
1047
1048                 return this.each(function(){
1049                         var obj = this;
1050
1051                         if ( table && this.nodeName.toUpperCase() == "TABLE" && a[0].nodeName.toUpperCase() == "TR" )
1052                                 obj = this.getElementsByTagName("tbody")[0] || this.appendChild(document.createElement("tbody"));
1053
1054                         for ( var i = 0, al = a.length; i < al; i++ )
1055                                 fn.apply( obj, [ clone ? a[i].cloneNode(true) : a[i] ] );
1056
1057                 });
1058         },
1059
1060         /**
1061          *
1062          *
1063          * @private
1064          * @name pushStack
1065          * @param Array a
1066          * @param Array args
1067          * @type jQuery
1068          * @cat Core
1069          */
1070         pushStack: function(a,args) {
1071                 var fn = args && args.length > 1 && args[args.length-1];
1072                 var fn2 = args && args.length > 2 && args[args.length-2];
1073                 
1074                 if ( fn && fn.constructor != Function ) fn = null;
1075                 if ( fn2 && fn2.constructor != Function ) fn2 = null;
1076
1077                 if ( !fn ) {
1078                         if ( !this.stack ) this.stack = [];
1079                         this.stack.push( this.get() );
1080                         this.set( a );
1081                 } else {
1082                         var old = this.get();
1083                         this.set( a );
1084
1085                         if ( fn2 && a.length || !fn2 )
1086                                 this.each( fn2 || fn ).set( old );
1087                         else
1088                                 this.set( old ).each( fn );
1089                 }
1090
1091                 return this;
1092         }
1093 };
1094
1095 /**
1096  * Extends the jQuery object itself. Can be used to add functions into
1097  * the jQuery namespace and to add plugin methods (plugins).
1098  * 
1099  * @example jQuery.fn.extend({
1100  *   check: function() {
1101  *     return this.each(function() { this.checked = true; });
1102  *   ),
1103  *   uncheck: function() {
1104  *     return this.each(function() { this.checked = false; });
1105  *   }
1106  * });
1107  * $("input[@type=checkbox]").check();
1108  * $("input[@type=radio]").uncheck();
1109  * @desc Adds two plugin methods.
1110  *
1111  * @example jQuery.extend({
1112  *   min: function(a, b) { return a < b ? a : b; },
1113  *   max: function(a, b) { return a > b ? a : b; }
1114  * });
1115  * @desc Adds two functions into the jQuery namespace
1116  *
1117  * @name $.extend
1118  * @param Object prop The object that will be merged into the jQuery object
1119  * @type Object
1120  * @cat Core
1121  */
1122
1123 /**
1124  * Extend one object with one or more others, returning the original,
1125  * modified, object. This is a great utility for simple inheritance.
1126  * 
1127  * @example var settings = { validate: false, limit: 5, name: "foo" };
1128  * var options = { validate: true, name: "bar" };
1129  * jQuery.extend(settings, options);
1130  * @result settings == { validate: true, limit: 5, name: "bar" }
1131  * @desc Merge settings and options, modifying settings
1132  *
1133  * @example var defaults = { validate: false, limit: 5, name: "foo" };
1134  * var options = { validate: true, name: "bar" };
1135  * var settings = jQuery.extend({}, defaults, options);
1136  * @result settings == { validate: true, limit: 5, name: "bar" }
1137  * @desc Merge defaults and options, without modifying the defaults
1138  *
1139  * @name $.extend
1140  * @param Object target The object to extend
1141  * @param Object prop1 The object that will be merged into the first.
1142  * @param Object propN (optional) More objects to merge into the first
1143  * @type Object
1144  * @cat Javascript
1145  */
1146 jQuery.extend = jQuery.fn.extend = function() {
1147         // copy reference to target object
1148         var target = arguments[0],
1149                 a = 1;
1150
1151         // extend jQuery itself if only one argument is passed
1152         if ( arguments.length == 1 ) {
1153                 target = this;
1154                 a = 0;
1155         }
1156         var prop;
1157         while (prop = arguments[a++])
1158                 // Extend the base object
1159                 for ( var i in prop ) target[i] = prop[i];
1160
1161         // Return the modified object
1162         return target;
1163 };
1164
1165 jQuery.extend({
1166         /**
1167          * @private
1168          * @name init
1169          * @type undefined
1170          * @cat Core
1171          */
1172         init: function(){
1173                 jQuery.initDone = true;
1174
1175                 jQuery.each( jQuery.macros.axis, function(i,n){
1176                         jQuery.fn[ i ] = function(a) {
1177                                 var ret = jQuery.map(this,n);
1178                                 if ( a && typeof a == "string" )
1179                                         ret = jQuery.filter(a,ret).r;
1180                                 return this.pushStack( ret, arguments );
1181                         };
1182                 });
1183
1184                 jQuery.each( jQuery.macros.to, function(i,n){
1185                         jQuery.fn[ i ] = function(){
1186                                 var a = arguments;
1187                                 return this.each(function(){
1188                                         for ( var j = 0, al = a.length; j < al; j++ )
1189                                                 jQuery(a[j])[n]( this );
1190                                 });
1191                         };
1192                 });
1193
1194                 jQuery.each( jQuery.macros.each, function(i,n){
1195                         jQuery.fn[ i ] = function() {
1196                                 return this.each( n, arguments );
1197                         };
1198                 });
1199
1200                 jQuery.each( jQuery.macros.filter, function(i,n){
1201                         jQuery.fn[ n ] = function(num,fn) {
1202                                 return this.filter( ":" + n + "(" + num + ")", fn );
1203                         };
1204                 });
1205
1206                 jQuery.each( jQuery.macros.attr, function(i,n){
1207                         n = n || i;
1208                         jQuery.fn[ i ] = function(h) {
1209                                 return h == undefined ?
1210                                         this.length ? this[0][n] : null :
1211                                         this.attr( n, h );
1212                         };
1213                 });
1214
1215                 jQuery.each( jQuery.macros.css, function(i,n){
1216                         jQuery.fn[ n ] = function(h) {
1217                                 return h == undefined ?
1218                                         ( this.length ? jQuery.css( this[0], n ) : null ) :
1219                                         this.css( n, h );
1220                         };
1221                 });
1222
1223         },
1224
1225         /**
1226          * A generic iterator function, which can be used to seemlessly
1227          * iterate over both objects and arrays. This function is not the same
1228          * as $().each() - which is used to iterate, exclusively, over a jQuery
1229          * object. This function can be used to iterate over anything.
1230          *
1231          * @example $.each( [0,1,2], function(i){
1232          *   alert( "Item #" + i + ": " + this );
1233          * });
1234          * @desc This is an example of iterating over the items in an array, accessing both the current item and its index.
1235          *
1236          * @example $.each( { name: "John", lang: "JS" }, function(i){
1237          *   alert( "Name: " + i + ", Value: " + this );
1238          * });
1239          * @desc This is an example of iterating over the properties in an Object, accessing both the current item and its key.
1240          *
1241          * @name $.each
1242          * @param Object obj The object, or array, to iterate over.
1243          * @param Function fn The function that will be executed on every object.
1244          * @type Object
1245          * @cat Javascript
1246          */
1247         // args is for internal usage only
1248         each: function( obj, fn, args ) {
1249                 if ( obj.length == undefined )
1250                         for ( var i in obj )
1251                                 fn.apply( obj[i], args || [i, obj[i]] );
1252                 else
1253                         for ( var i = 0, ol = obj.length; i < ol; i++ )
1254                                 if ( fn.apply( obj[i], args || [i, obj[i]] ) === false ) break;
1255                 return obj;
1256         },
1257
1258         className: {
1259                 add: function( elem, c ){
1260                         jQuery.each( c.split(/\s+/), function(i, cur){
1261                                 if ( !jQuery.className.has( elem.className, cur ) )
1262                                         elem.className += ( elem.className ? " " : "" ) + cur;
1263                         });
1264                 },
1265                 remove: function( elem, c ){
1266             elem.className = c ?
1267                 jQuery.grep( elem.className.split(/\s+/), function(cur){
1268                                     return !jQuery.className.has( c, cur );     
1269                 }).join(' ') : "";
1270                 },
1271                 has: function( classes, c ){
1272                         return classes && new RegExp("(^|\\s)" + c + "(\\s|$)").test( classes );
1273                 }
1274         },
1275
1276         /**
1277          * Swap in/out style options.
1278          * @private
1279          */
1280         swap: function(e,o,f) {
1281                 for ( var i in o ) {
1282                         e.style["old"+i] = e.style[i];
1283                         e.style[i] = o[i];
1284                 }
1285                 f.apply( e, [] );
1286                 for ( var i in o )
1287                         e.style[i] = e.style["old"+i];
1288         },
1289
1290         css: function(e,p) {
1291                 if ( p == "height" || p == "width" ) {
1292                         var old = {}, oHeight, oWidth, d = ["Top","Bottom","Right","Left"];
1293
1294                         for ( var i = 0, dl = d.length; i < dl; i++ ) {
1295                                 old["padding" + d[i]] = 0;
1296                                 old["border" + d[i] + "Width"] = 0;
1297                         }
1298
1299                         jQuery.swap( e, old, function() {
1300                                 if (jQuery.css(e,"display") != "none") {
1301                                         oHeight = e.offsetHeight;
1302                                         oWidth = e.offsetWidth;
1303                                 } else {
1304                                         e = jQuery(e.cloneNode(true))
1305                                                 .find(":radio").removeAttr("checked").end()
1306                                                 .css({
1307                                                         visibility: "hidden", position: "absolute", display: "block", right: "0", left: "0"
1308                                                 }).appendTo(e.parentNode)[0];
1309
1310                                         var parPos = jQuery.css(e.parentNode,"position");
1311                                         if ( parPos == "" || parPos == "static" )
1312                                                 e.parentNode.style.position = "relative";
1313
1314                                         oHeight = e.clientHeight;
1315                                         oWidth = e.clientWidth;
1316
1317                                         if ( parPos == "" || parPos == "static" )
1318                                                 e.parentNode.style.position = "static";
1319
1320                                         e.parentNode.removeChild(e);
1321                                 }
1322                         });
1323
1324                         return p == "height" ? oHeight : oWidth;
1325                 }
1326
1327                 return jQuery.curCSS( e, p );
1328         },
1329
1330         curCSS: function(elem, prop, force) {
1331                 var ret;
1332                 
1333                 if (prop == 'opacity' && jQuery.browser.msie)
1334                         return jQuery.attr(elem.style, 'opacity');
1335                         
1336                 if (prop == "float" || prop == "cssFloat")
1337                     prop = jQuery.browser.msie ? "styleFloat" : "cssFloat";
1338
1339                 if (!force && elem.style[prop]) {
1340
1341                         ret = elem.style[prop];
1342
1343                 } else if (document.defaultView && document.defaultView.getComputedStyle) {
1344
1345                         if (prop == "cssFloat" || prop == "styleFloat")
1346                                 prop = "float";
1347
1348                         prop = prop.replace(/([A-Z])/g,"-$1").toLowerCase();
1349                         var cur = document.defaultView.getComputedStyle(elem, null);
1350
1351                         if ( cur )
1352                                 ret = cur.getPropertyValue(prop);
1353                         else if ( prop == 'display' )
1354                                 ret = 'none';
1355                         else
1356                                 jQuery.swap(elem, { display: 'block' }, function() {
1357                                     var c = document.defaultView.getComputedStyle(this, '');
1358                                     ret = c && c.getPropertyValue(prop) || '';
1359                                 });
1360
1361                 } else if (elem.currentStyle) {
1362
1363                         var newProp = prop.replace(/\-(\w)/g,function(m,c){return c.toUpperCase();});
1364                         ret = elem.currentStyle[prop] || elem.currentStyle[newProp];
1365                         
1366                 }
1367
1368                 return ret;
1369         },
1370         
1371         clean: function(a) {
1372                 var r = [];
1373                 for ( var i = 0, al = a.length; i < al; i++ ) {
1374                         var arg = a[i];
1375                         if ( typeof arg == "string" ) { // Convert html string into DOM nodes
1376                                 // Trim whitespace, otherwise indexOf won't work as expected
1377                                 var s = jQuery.trim(arg), s3 = s.substring(0,3), s6 = s.substring(0,6),
1378                                         div = document.createElement("div"), wrap = [0,"",""];
1379
1380                                 if ( s.substring(0,4) == "<opt" ) // option or optgroup
1381                                         wrap = [1, "<select>", "</select>"];
1382                                 else if ( s6 == "<thead" || s6 == "<tbody" || s6 == "<tfoot" )
1383                                         wrap = [1, "<table>", "</table>"];
1384                                 else if ( s3 == "<tr" )
1385                                         wrap = [2, "<table><tbody>", "</tbody></table>"];
1386                                 else if ( s3 == "<td" || s3 == "<th" ) // <thead> matched above
1387                                         wrap = [3, "<table><tbody><tr>", "</tr></tbody></table>"];
1388
1389                                 // Go to html and back, then peel off extra wrappers
1390                                 div.innerHTML = wrap[1] + s + wrap[2];
1391                                 while ( wrap[0]-- ) div = div.firstChild;
1392                                 
1393                                 // Remove IE's autoinserted <tbody> from table fragments
1394                                 if ( jQuery.browser.msie ) {
1395                                         var tb = null;
1396                                         // String was a <table>, *may* have spurious <tbody>
1397                                         if ( s6 == "<table" && s.indexOf("<tbody") < 0 ) 
1398                                                 tb = div.firstChild && div.firstChild.childNodes;
1399                                         // String was a bare <thead> or <tfoot>
1400                                         else if ( wrap[1] == "<table>" && s.indexOf("<tbody") < 0 )
1401                                                 tb = div.childNodes;
1402                                         if ( tb ) {
1403                                                 for ( var n = tb.length-1; n >= 0 ; --n )
1404                                                         if ( tb[n].nodeName.toUpperCase() == "TBODY" && !tb[n].childNodes.length )
1405                                                                 tb[n].parentNode.removeChild(tb[n]);
1406                                         }
1407                                 }
1408                                 
1409                                 arg = div.childNodes;
1410                         } 
1411                         
1412                         
1413                         if ( arg.length != undefined && ( (jQuery.browser.safari && typeof arg == 'function') || !arg.nodeType ) ) // Safari reports typeof on a DOM NodeList to be a function
1414                                 for ( var n = 0, argl = arg.length; n < argl; n++ ) // Handles Array, jQuery, DOM NodeList collections
1415                                         r.push(arg[n]);
1416                         else
1417                                 r.push( arg.nodeType ? arg : document.createTextNode(arg.toString()) );
1418                 }
1419
1420                 return r;
1421         },
1422         
1423         attr: function(elem, name, value){
1424                 var fix = {
1425                         "for": "htmlFor",
1426                         "class": "className",
1427                         "float": jQuery.browser.msie ? "styleFloat" : "cssFloat",
1428                         cssFloat: jQuery.browser.msie ? "styleFloat" : "cssFloat",
1429                         innerHTML: "innerHTML",
1430                         className: "className",
1431                         value: "value",
1432                         disabled: "disabled",
1433                         checked: "checked",
1434                         readonly: "readOnly",
1435                         selected: "selected"
1436                 };
1437                 
1438                 // IE actually uses filters for opacity ... elem is actually elem.style
1439                 if ( name == "opacity" && jQuery.browser.msie && value != undefined ) {
1440                         // IE has trouble with opacity if it does not have layout
1441                         // Force it by setting the zoom level
1442                         elem.zoom = 1; 
1443
1444                         // Set the alpha filter to set the opacity
1445                         return elem.filter = elem.filter.replace(/alpha\([^\)]*\)/gi,"") +
1446                                 ( value == 1 ? "" : "alpha(opacity=" + value * 100 + ")" );
1447
1448                 } else if ( name == "opacity" && jQuery.browser.msie ) {
1449                         return elem.filter ? 
1450                                 parseFloat( elem.filter.match(/alpha\(opacity=(.*)\)/)[1] ) / 100 : 1;
1451                 }
1452                 
1453                 // Mozilla doesn't play well with opacity 1
1454                 if ( name == "opacity" && jQuery.browser.mozilla && value == 1 )
1455                         value = 0.9999;
1456
1457                 // Certain attributes only work when accessed via the old DOM 0 way
1458                 if ( fix[name] ) {
1459                         if ( value != undefined ) elem[fix[name]] = value;
1460                         return elem[fix[name]];
1461
1462                 } else if ( value == undefined && jQuery.browser.msie && elem.nodeName && elem.nodeName.toUpperCase() == 'FORM' && (name == 'action' || name == 'method') ) {
1463                         return elem.getAttributeNode(name).nodeValue;
1464
1465                 // IE elem.getAttribute passes even for style
1466                 } else if ( elem.tagName ) {
1467                         if ( value != undefined ) elem.setAttribute( name, value );
1468                         return elem.getAttribute( name );
1469
1470                 } else {
1471                         name = name.replace(/-([a-z])/ig,function(z,b){return b.toUpperCase();});
1472                         if ( value != undefined ) elem[name] = value;
1473                         return elem[name];
1474                 }
1475         },
1476         
1477         /**
1478          * Remove the whitespace from the beginning and end of a string.
1479          *
1480          * @example $.trim("  hello, how are you?  ");
1481          * @result "hello, how are you?"
1482          *
1483          * @name $.trim
1484          * @type String
1485          * @param String str The string to trim.
1486          * @cat Javascript
1487          */
1488         trim: function(t){
1489                 return t.replace(/^\s+|\s+$/g, "");
1490         },
1491
1492         makeArray: function( a ) {
1493                 var r = [];
1494
1495                 if ( a.constructor != Array ) {
1496                         for ( var i = 0, al = a.length; i < al; i++ )
1497                                 r.push( a[i] );
1498                 } else
1499                         r = a.slice( 0 );
1500
1501                 return r;
1502         },
1503
1504         inArray: function( b, a ) {
1505                 for ( var i = 0, al = a.length; i < al; i++ )
1506                         if ( a[i] == b )
1507                                 return i;
1508                 return -1;
1509         },
1510
1511         /**
1512          * Merge two arrays together, removing all duplicates. The final order
1513          * or the new array is: All the results from the first array, followed
1514          * by the unique results from the second array.
1515          *
1516          * @example $.merge( [0,1,2], [2,3,4] )
1517          * @result [0,1,2,3,4]
1518          *
1519          * @example $.merge( [3,2,1], [4,3,2] )
1520          * @result [3,2,1,4]
1521          *
1522          * @name $.merge
1523          * @type Array
1524          * @param Array first The first array to merge.
1525          * @param Array second The second array to merge.
1526          * @cat Javascript
1527          */
1528         merge: function(first, second) {
1529                 var r = [].slice.call( first, 0 );
1530
1531                 // Now check for duplicates between the two arrays
1532                 // and only add the unique items
1533                 for ( var i = 0, sl = second.length; i < sl; i++ ) {
1534                         // Check for duplicates
1535                         if ( jQuery.inArray( second[i], r ) == -1 )
1536                                 // The item is unique, add it
1537                                 first.push( second[i] );
1538                 }
1539
1540                 return first;
1541         },
1542
1543         /**
1544          * Filter items out of an array, by using a filter function.
1545          * The specified function will be passed two arguments: The
1546          * current array item and the index of the item in the array. The
1547          * function should return 'true' if you wish to keep the item in
1548          * the array, false if it should be removed.
1549          *
1550          * @example $.grep( [0,1,2], function(i){
1551          *   return i > 0;
1552          * });
1553          * @result [1, 2]
1554          *
1555          * @name $.grep
1556          * @type Array
1557          * @param Array array The Array to find items in.
1558          * @param Function fn The function to process each item against.
1559          * @param Boolean inv Invert the selection - select the opposite of the function.
1560          * @cat Javascript
1561          */
1562         grep: function(elems, fn, inv) {
1563                 // If a string is passed in for the function, make a function
1564                 // for it (a handy shortcut)
1565                 if ( typeof fn == "string" )
1566                         fn = new Function("a","i","return " + fn);
1567
1568                 var result = [];
1569
1570                 // Go through the array, only saving the items
1571                 // that pass the validator function
1572                 for ( var i = 0, el = elems.length; i < el; i++ )
1573                         if ( !inv && fn(elems[i],i) || inv && !fn(elems[i],i) )
1574                                 result.push( elems[i] );
1575
1576                 return result;
1577         },
1578
1579         /**
1580          * Translate all items in an array to another array of items. 
1581          * The translation function that is provided to this method is 
1582          * called for each item in the array and is passed one argument: 
1583          * The item to be translated. The function can then return:
1584          * The translated value, 'null' (to remove the item), or 
1585          * an array of values - which will be flattened into the full array.
1586          *
1587          * @example $.map( [0,1,2], function(i){
1588          *   return i + 4;
1589          * });
1590          * @result [4, 5, 6]
1591          *
1592          * @example $.map( [0,1,2], function(i){
1593          *   return i > 0 ? i + 1 : null;
1594          * });
1595          * @result [2, 3]
1596          * 
1597          * @example $.map( [0,1,2], function(i){
1598          *   return [ i, i + 1 ];
1599          * });
1600          * @result [0, 1, 1, 2, 2, 3]
1601          *
1602          * @name $.map
1603          * @type Array
1604          * @param Array array The Array to translate.
1605          * @param Function fn The function to process each item against.
1606          * @cat Javascript
1607          */
1608         map: function(elems, fn) {
1609                 // If a string is passed in for the function, make a function
1610                 // for it (a handy shortcut)
1611                 if ( typeof fn == "string" )
1612                         fn = new Function("a","return " + fn);
1613
1614                 var result = [], r = [];
1615
1616                 // Go through the array, translating each of the items to their
1617                 // new value (or values).
1618                 for ( var i = 0, el = elems.length; i < el; i++ ) {
1619                         var val = fn(elems[i],i);
1620
1621                         if ( val !== null && val != undefined ) {
1622                                 if ( val.constructor != Array ) val = [val];
1623                                 result = result.concat( val );
1624                         }
1625                 }
1626
1627                 var r = [ result[0] ];
1628
1629                 check: for ( var i = 1, rl = result.length; i < rl; i++ ) {
1630                         for ( var j = 0; j < i; j++ )
1631                                 if ( result[i] == r[j] )
1632                                         continue check;
1633
1634                         r.push( result[i] );
1635                 }
1636
1637                 return r;
1638         }
1639 });
1640
1641 /**
1642  * Contains flags for the useragent, read from navigator.userAgent.
1643  * Available flags are: safari, opera, msie, mozilla
1644  * This property is available before the DOM is ready, therefore you can
1645  * use it to add ready events only for certain browsers.
1646  *
1647  * There are situations where object detections is not reliable enough, in that
1648  * cases it makes sense to use browser detection. Simply try to avoid both!
1649  *
1650  * A combination of browser and object detection yields quite reliable results.
1651  *
1652  * @example $.browser.msie
1653  * @desc Returns true if the current useragent is some version of microsoft's internet explorer
1654  *
1655  * @example if($.browser.safari) { $( function() { alert("this is safari!"); } ); }
1656  * @desc Alerts "this is safari!" only for safari browsers
1657  *
1658  * @property
1659  * @name $.browser
1660  * @type Boolean
1661  * @cat Javascript
1662  */
1663  
1664 /*
1665  * Wheather the W3C compliant box model is being used.
1666  *
1667  * @property
1668  * @name $.boxModel
1669  * @type Boolean
1670  * @cat Javascript
1671  */
1672 new function() {
1673         var b = navigator.userAgent.toLowerCase();
1674
1675         // Figure out what browser is being used
1676         jQuery.browser = {
1677                 safari: /webkit/.test(b),
1678                 opera: /opera/.test(b),
1679                 msie: /msie/.test(b) && !/opera/.test(b),
1680                 mozilla: /mozilla/.test(b) && !/(compatible|webkit)/.test(b)
1681         };
1682
1683         // Check to see if the W3C box model is being used
1684         jQuery.boxModel = !jQuery.browser.msie || document.compatMode == "CSS1Compat";
1685 };
1686
1687 jQuery.macros = {
1688         to: {
1689                 /**
1690                  * Append all of the matched elements to another, specified, set of elements.
1691                  * This operation is, essentially, the reverse of doing a regular
1692                  * $(A).append(B), in that instead of appending B to A, you're appending
1693                  * A to B.
1694                  *
1695                  * @example $("p").appendTo("#foo");
1696                  * @before <p>I would like to say: </p><div id="foo"></div>
1697                  * @result <div id="foo"><p>I would like to say: </p></div>
1698                  *
1699                  * @name appendTo
1700                  * @type jQuery
1701                  * @param String expr A jQuery expression of elements to match.
1702                  * @cat DOM/Manipulation
1703                  */
1704                 appendTo: "append",
1705
1706                 /**
1707                  * Prepend all of the matched elements to another, specified, set of elements.
1708                  * This operation is, essentially, the reverse of doing a regular
1709                  * $(A).prepend(B), in that instead of prepending B to A, you're prepending
1710                  * A to B.
1711                  *
1712                  * @example $("p").prependTo("#foo");
1713                  * @before <p>I would like to say: </p><div id="foo"><b>Hello</b></div>
1714                  * @result <div id="foo"><p>I would like to say: </p><b>Hello</b></div>
1715                  *
1716                  * @name prependTo
1717                  * @type jQuery
1718                  * @param String expr A jQuery expression of elements to match.
1719                  * @cat DOM/Manipulation
1720                  */
1721                 prependTo: "prepend",
1722
1723                 /**
1724                  * Insert all of the matched elements before another, specified, set of elements.
1725                  * This operation is, essentially, the reverse of doing a regular
1726                  * $(A).before(B), in that instead of inserting B before A, you're inserting
1727                  * A before B.
1728                  *
1729                  * @example $("p").insertBefore("#foo");
1730                  * @before <div id="foo">Hello</div><p>I would like to say: </p>
1731                  * @result <p>I would like to say: </p><div id="foo">Hello</div>
1732                  *
1733                  * @name insertBefore
1734                  * @type jQuery
1735                  * @param String expr A jQuery expression of elements to match.
1736                  * @cat DOM/Manipulation
1737                  */
1738                 insertBefore: "before",
1739
1740                 /**
1741                  * Insert all of the matched elements after another, specified, set of elements.
1742                  * This operation is, essentially, the reverse of doing a regular
1743                  * $(A).after(B), in that instead of inserting B after A, you're inserting
1744                  * A after B.
1745                  *
1746                  * @example $("p").insertAfter("#foo");
1747                  * @before <p>I would like to say: </p><div id="foo">Hello</div>
1748                  * @result <div id="foo">Hello</div><p>I would like to say: </p>
1749                  *
1750                  * @name insertAfter
1751                  * @type jQuery
1752                  * @param String expr A jQuery expression of elements to match.
1753                  * @cat DOM/Manipulation
1754                  */
1755                 insertAfter: "after"
1756         },
1757
1758         /**
1759          * Get the current CSS width of the first matched element.
1760          *
1761          * @example $("p").width();
1762          * @before <p>This is just a test.</p>
1763          * @result "300px"
1764          *
1765          * @name width
1766          * @type String
1767          * @cat CSS
1768          */
1769
1770         /**
1771          * Set the CSS width of every matched element. Be sure to include
1772          * the "px" (or other unit of measurement) after the number that you
1773          * specify, otherwise you might get strange results.
1774          *
1775          * @example $("p").width("20px");
1776          * @before <p>This is just a test.</p>
1777          * @result <p style="width:20px;">This is just a test.</p>
1778          *
1779          * @name width
1780          * @type jQuery
1781          * @param String val Set the CSS property to the specified value.
1782          * @cat CSS
1783          */
1784
1785         /**
1786          * Get the current CSS height of the first matched element.
1787          *
1788          * @example $("p").height();
1789          * @before <p>This is just a test.</p>
1790          * @result "14px"
1791          *
1792          * @name height
1793          * @type String
1794          * @cat CSS
1795          */
1796
1797         /**
1798          * Set the CSS height of every matched element. Be sure to include
1799          * the "px" (or other unit of measurement) after the number that you
1800          * specify, otherwise you might get strange results.
1801          *
1802          * @example $("p").height("20px");
1803          * @before <p>This is just a test.</p>
1804          * @result <p style="height:20px;">This is just a test.</p>
1805          *
1806          * @name height
1807          * @type jQuery
1808          * @param String val Set the CSS property to the specified value.
1809          * @cat CSS
1810          */
1811
1812         /**
1813          * Get the current CSS top of the first matched element.
1814          *
1815          * @example $("p").top();
1816          * @before <p>This is just a test.</p>
1817          * @result "0px"
1818          *
1819          * @name top
1820          * @type String
1821          * @cat CSS
1822          */
1823
1824         /**
1825          * Set the CSS top of every matched element. Be sure to include
1826          * the "px" (or other unit of measurement) after the number that you
1827          * specify, otherwise you might get strange results.
1828          *
1829          * @example $("p").top("20px");
1830          * @before <p>This is just a test.</p>
1831          * @result <p style="top:20px;">This is just a test.</p>
1832          *
1833          * @name top
1834          * @type jQuery
1835          * @param String val Set the CSS property to the specified value.
1836          * @cat CSS
1837          */
1838
1839         /**
1840          * Get the current CSS left of the first matched element.
1841          *
1842          * @example $("p").left();
1843          * @before <p>This is just a test.</p>
1844          * @result "0px"
1845          *
1846          * @name left
1847          * @type String
1848          * @cat CSS
1849          */
1850
1851         /**
1852          * Set the CSS left of every matched element. Be sure to include
1853          * the "px" (or other unit of measurement) after the number that you
1854          * specify, otherwise you might get strange results.
1855          *
1856          * @example $("p").left("20px");
1857          * @before <p>This is just a test.</p>
1858          * @result <p style="left:20px;">This is just a test.</p>
1859          *
1860          * @name left
1861          * @type jQuery
1862          * @param String val Set the CSS property to the specified value.
1863          * @cat CSS
1864          */
1865
1866         /**
1867          * Get the current CSS position of the first matched element.
1868          *
1869          * @example $("p").position();
1870          * @before <p>This is just a test.</p>
1871          * @result "static"
1872          *
1873          * @name position
1874          * @type String
1875          * @cat CSS
1876          */
1877
1878         /**
1879          * Set the CSS position of every matched element.
1880          *
1881          * @example $("p").position("relative");
1882          * @before <p>This is just a test.</p>
1883          * @result <p style="position:relative;">This is just a test.</p>
1884          *
1885          * @name position
1886          * @type jQuery
1887          * @param String val Set the CSS property to the specified value.
1888          * @cat CSS
1889          */
1890
1891         /**
1892          * Get the current CSS float of the first matched element.
1893          *
1894          * @example $("p").float();
1895          * @before <p>This is just a test.</p>
1896          * @result "none"
1897          *
1898          * @name float
1899          * @type String
1900          * @cat CSS
1901          */
1902
1903         /**
1904          * Set the CSS float of every matched element.
1905          *
1906          * @example $("p").float("left");
1907          * @before <p>This is just a test.</p>
1908          * @result <p style="float:left;">This is just a test.</p>
1909          *
1910          * @name float
1911          * @type jQuery
1912          * @param String val Set the CSS property to the specified value.
1913          * @cat CSS
1914          */
1915
1916         /**
1917          * Get the current CSS overflow of the first matched element.
1918          *
1919          * @example $("p").overflow();
1920          * @before <p>This is just a test.</p>
1921          * @result "none"
1922          *
1923          * @name overflow
1924          * @type String
1925          * @cat CSS
1926          */
1927
1928         /**
1929          * Set the CSS overflow of every matched element.
1930          *
1931          * @example $("p").overflow("auto");
1932          * @before <p>This is just a test.</p>
1933          * @result <p style="overflow:auto;">This is just a test.</p>
1934          *
1935          * @name overflow
1936          * @type jQuery
1937          * @param String val Set the CSS property to the specified value.
1938          * @cat CSS
1939          */
1940
1941         /**
1942          * Get the current CSS color of the first matched element.
1943          *
1944          * @example $("p").color();
1945          * @before <p>This is just a test.</p>
1946          * @result "black"
1947          *
1948          * @name color
1949          * @type String
1950          * @cat CSS
1951          */
1952
1953         /**
1954          * Set the CSS color of every matched element.
1955          *
1956          * @example $("p").color("blue");
1957          * @before <p>This is just a test.</p>
1958          * @result <p style="color:blue;">This is just a test.</p>
1959          *
1960          * @name color
1961          * @type jQuery
1962          * @param String val Set the CSS property to the specified value.
1963          * @cat CSS
1964          */
1965
1966         /**
1967          * Get the current CSS background of the first matched element.
1968          *
1969          * @example $("p").background();
1970          * @before <p style="background:blue;">This is just a test.</p>
1971          * @result "blue"
1972          *
1973          * @name background
1974          * @type String
1975          * @cat CSS
1976          */
1977
1978         /**
1979          * Set the CSS background of every matched element.
1980          *
1981          * @example $("p").background("blue");
1982          * @before <p>This is just a test.</p>
1983          * @result <p style="background:blue;">This is just a test.</p>
1984          *
1985          * @name background
1986          * @type jQuery
1987          * @param String val Set the CSS property to the specified value.
1988          * @cat CSS
1989          */
1990
1991         css: "width,height,top,left,position,float,overflow,color,background".split(","),
1992
1993         /**
1994          * Reduce the set of matched elements to a single element.
1995          * The position of the element in the set of matched elements
1996          * starts at 0 and goes to length - 1.
1997          *
1998          * @example $("p").eq(1)
1999          * @before <p>This is just a test.</p><p>So is this</p>
2000          * @result [ <p>So is this</p> ]
2001          *
2002          * @name eq
2003          * @type jQuery
2004          * @param Number pos The index of the element that you wish to limit to.
2005          * @cat Core
2006          */
2007
2008         /**
2009          * Reduce the set of matched elements to all elements before a given position.
2010          * The position of the element in the set of matched elements
2011          * starts at 0 and goes to length - 1.
2012          *
2013          * @example $("p").lt(1)
2014          * @before <p>This is just a test.</p><p>So is this</p>
2015          * @result [ <p>This is just a test.</p> ]
2016          *
2017          * @name lt
2018          * @type jQuery
2019          * @param Number pos Reduce the set to all elements below this position.
2020          * @cat Core
2021          */
2022
2023         /**
2024          * Reduce the set of matched elements to all elements after a given position.
2025          * The position of the element in the set of matched elements
2026          * starts at 0 and goes to length - 1.
2027          *
2028          * @example $("p").gt(0)
2029          * @before <p>This is just a test.</p><p>So is this</p>
2030          * @result [ <p>So is this</p> ]
2031          *
2032          * @name gt
2033          * @type jQuery
2034          * @param Number pos Reduce the set to all elements after this position.
2035          * @cat Core
2036          */
2037
2038         /**
2039          * Filter the set of elements to those that contain the specified text.
2040          *
2041          * @example $("p").contains("test")
2042          * @before <p>This is just a test.</p><p>So is this</p>
2043          * @result [ <p>This is just a test.</p> ]
2044          *
2045          * @name contains
2046          * @type jQuery
2047          * @param String str The string that will be contained within the text of an element.
2048          * @cat DOM/Traversing
2049          */
2050
2051         filter: [ "eq", "lt", "gt", "contains" ],
2052
2053         attr: {
2054                 /**
2055                  * Get the current value of the first matched element.
2056                  *
2057                  * @example $("input").val();
2058                  * @before <input type="text" value="some text"/>
2059                  * @result "some text"
2060                  *
2061                  * @name val
2062                  * @type String
2063                  * @cat DOM/Attributes
2064                  */
2065
2066                 /**
2067                  * Set the value of every matched element.
2068                  *
2069                  * @example $("input").val("test");
2070                  * @before <input type="text" value="some text"/>
2071                  * @result <input type="text" value="test"/>
2072                  *
2073                  * @name val
2074                  * @type jQuery
2075                  * @param String val Set the property to the specified value.
2076                  * @cat DOM/Attributes
2077                  */
2078                 val: "value",
2079
2080                 /**
2081                  * Get the html contents of the first matched element.
2082                  * This property is not available on XML documents.
2083                  *
2084                  * @example $("div").html();
2085                  * @before <div><input/></div>
2086                  * @result <input/>
2087                  *
2088                  * @name html
2089                  * @type String
2090                  * @cat DOM/Attributes
2091                  */
2092
2093                 /**
2094                  * Set the html contents of every matched element.
2095                  * This property is not available on XML documents.
2096                  *
2097                  * @example $("div").html("<b>new stuff</b>");
2098                  * @before <div><input/></div>
2099                  * @result <div><b>new stuff</b></div>
2100                  *
2101                  * @name html
2102                  * @type jQuery
2103                  * @param String val Set the html contents to the specified value.
2104                  * @cat DOM/Attributes
2105                  */
2106                 html: "innerHTML",
2107
2108                 /**
2109                  * Get the current id of the first matched element.
2110                  *
2111                  * @example $("input").id();
2112                  * @before <input type="text" id="test" value="some text"/>
2113                  * @result "test"
2114                  *
2115                  * @name id
2116                  * @type String
2117                  * @cat DOM/Attributes
2118                  */
2119
2120                 /**
2121                  * Set the id of every matched element.
2122                  *
2123                  * @example $("input").id("newid");
2124                  * @before <input type="text" id="test" value="some text"/>
2125                  * @result <input type="text" id="newid" value="some text"/>
2126                  *
2127                  * @name id
2128                  * @type jQuery
2129                  * @param String val Set the property to the specified value.
2130                  * @cat DOM/Attributes
2131                  */
2132                 id: null,
2133
2134                 /**
2135                  * Get the current title of the first matched element.
2136                  *
2137                  * @example $("img").title();
2138                  * @before <img src="test.jpg" title="my image"/>
2139                  * @result "my image"
2140                  *
2141                  * @name title
2142                  * @type String
2143                  * @cat DOM/Attributes
2144                  */
2145
2146                 /**
2147                  * Set the title of every matched element.
2148                  *
2149                  * @example $("img").title("new title");
2150                  * @before <img src="test.jpg" title="my image"/>
2151                  * @result <img src="test.jpg" title="new image"/>
2152                  *
2153                  * @name title
2154                  * @type jQuery
2155                  * @param String val Set the property to the specified value.
2156                  * @cat DOM/Attributes
2157                  */
2158                 title: null,
2159
2160                 /**
2161                  * Get the current name of the first matched element.
2162                  *
2163                  * @example $("input").name();
2164                  * @before <input type="text" name="username"/>
2165                  * @result "username"
2166                  *
2167                  * @name name
2168                  * @type String
2169                  * @cat DOM/Attributes
2170                  */
2171
2172                 /**
2173                  * Set the name of every matched element.
2174                  *
2175                  * @example $("input").name("user");
2176                  * @before <input type="text" name="username"/>
2177                  * @result <input type="text" name="user"/>
2178                  *
2179                  * @name name
2180                  * @type jQuery
2181                  * @param String val Set the property to the specified value.
2182                  * @cat DOM/Attributes
2183                  */
2184                 name: null,
2185
2186                 /**
2187                  * Get the current href of the first matched element.
2188                  *
2189                  * @example $("a").href();
2190                  * @before <a href="test.html">my link</a>
2191                  * @result "test.html"
2192                  *
2193                  * @name href
2194                  * @type String
2195                  * @cat DOM/Attributes
2196                  */
2197
2198                 /**
2199                  * Set the href of every matched element.
2200                  *
2201                  * @example $("a").href("test2.html");
2202                  * @before <a href="test.html">my link</a>
2203                  * @result <a href="test2.html">my link</a>
2204                  *
2205                  * @name href
2206                  * @type jQuery
2207                  * @param String val Set the property to the specified value.
2208                  * @cat DOM/Attributes
2209                  */
2210                 href: null,
2211
2212                 /**
2213                  * Get the current src of the first matched element.
2214                  *
2215                  * @example $("img").src();
2216                  * @before <img src="test.jpg" title="my image"/>
2217                  * @result "test.jpg"
2218                  *
2219                  * @name src
2220                  * @type String
2221                  * @cat DOM/Attributes
2222                  */
2223
2224                 /**
2225                  * Set the src of every matched element.
2226                  *
2227                  * @example $("img").src("test2.jpg");
2228                  * @before <img src="test.jpg" title="my image"/>
2229                  * @result <img src="test2.jpg" title="my image"/>
2230                  *
2231                  * @name src
2232                  * @type jQuery
2233                  * @param String val Set the property to the specified value.
2234                  * @cat DOM/Attributes
2235                  */
2236                 src: null,
2237
2238                 /**
2239                  * Get the current rel of the first matched element.
2240                  *
2241                  * @example $("a").rel();
2242                  * @before <a href="test.html" rel="nofollow">my link</a>
2243                  * @result "nofollow"
2244                  *
2245                  * @name rel
2246                  * @type String
2247                  * @cat DOM/Attributes
2248                  */
2249
2250                 /**
2251                  * Set the rel of every matched element.
2252                  *
2253                  * @example $("a").rel("nofollow");
2254                  * @before <a href="test.html">my link</a>
2255                  * @result <a href="test.html" rel="nofollow">my link</a>
2256                  *
2257                  * @name rel
2258                  * @type jQuery
2259                  * @param String val Set the property to the specified value.
2260                  * @cat DOM/Attributes
2261                  */
2262                 rel: null
2263         },
2264
2265         axis: {
2266                 /**
2267                  * Get a set of elements containing the unique parents of the matched
2268                  * set of elements.
2269                  *
2270                  * @example $("p").parent()
2271                  * @before <div><p>Hello</p><p>Hello</p></div>
2272                  * @result [ <div><p>Hello</p><p>Hello</p></div> ]
2273                  *
2274                  * @name parent
2275                  * @type jQuery
2276                  * @cat DOM/Traversing
2277                  */
2278
2279                 /**
2280                  * Get a set of elements containing the unique parents of the matched
2281                  * set of elements, and filtered by an expression.
2282                  *
2283                  * @example $("p").parent(".selected")
2284                  * @before <div><p>Hello</p></div><div class="selected"><p>Hello Again</p></div>
2285                  * @result [ <div class="selected"><p>Hello Again</p></div> ]
2286                  *
2287                  * @name parent
2288                  * @type jQuery
2289                  * @param String expr An expression to filter the parents with
2290                  * @cat DOM/Traversing
2291                  */
2292                 parent: "a.parentNode",
2293
2294                 /**
2295                  * Get a set of elements containing the unique ancestors of the matched
2296                  * set of elements (except for the root element).
2297                  *
2298                  * @example $("span").parents()
2299                  * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html>
2300                  * @result [ <body>...</body>, <div>...</div>, <p><span>Hello</span></p> ]
2301                  *
2302                  * @name parents
2303                  * @type jQuery
2304                  * @cat DOM/Traversing
2305                  */
2306
2307                 /**
2308                  * Get a set of elements containing the unique ancestors of the matched
2309                  * set of elements, and filtered by an expression.
2310                  *
2311                  * @example $("span").parents("p")
2312                  * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html>
2313                  * @result [ <p><span>Hello</span></p> ]
2314                  *
2315                  * @name parents
2316                  * @type jQuery
2317                  * @param String expr An expression to filter the ancestors with
2318                  * @cat DOM/Traversing
2319                  */
2320                 parents: jQuery.parents,
2321
2322                 /**
2323                  * Get a set of elements containing the unique next siblings of each of the
2324                  * matched set of elements.
2325                  *
2326                  * It only returns the very next sibling, not all next siblings.
2327                  *
2328                  * @example $("p").next()
2329                  * @before <p>Hello</p><p>Hello Again</p><div><span>And Again</span></div>
2330                  * @result [ <p>Hello Again</p>, <div><span>And Again</span></div> ]
2331                  *
2332                  * @name next
2333                  * @type jQuery
2334                  * @cat DOM/Traversing
2335                  */
2336
2337                 /**
2338                  * Get a set of elements containing the unique next siblings of each of the
2339                  * matched set of elements, and filtered by an expression.
2340                  *
2341                  * It only returns the very next sibling, not all next siblings.
2342                  *
2343                  * @example $("p").next(".selected")
2344                  * @before <p>Hello</p><p class="selected">Hello Again</p><div><span>And Again</span></div>
2345                  * @result [ <p class="selected">Hello Again</p> ]
2346                  *
2347                  * @name next
2348                  * @type jQuery
2349                  * @param String expr An expression to filter the next Elements with
2350                  * @cat DOM/Traversing
2351                  */
2352                 next: "jQuery.nth(a,1,'nextSibling')",
2353
2354                 /**
2355                  * Get a set of elements containing the unique previous siblings of each of the
2356                  * matched set of elements.
2357                  *
2358                  * It only returns the immediately previous sibling, not all previous siblings.
2359                  *
2360                  * @example $("p").prev()
2361                  * @before <p>Hello</p><div><span>Hello Again</span></div><p>And Again</p>
2362                  * @result [ <div><span>Hello Again</span></div> ]
2363                  *
2364                  * @name prev
2365                  * @type jQuery
2366                  * @cat DOM/Traversing
2367                  */
2368
2369                 /**
2370                  * Get a set of elements containing the unique previous siblings of each of the
2371                  * matched set of elements, and filtered by an expression.
2372                  *
2373                  * It only returns the immediately previous sibling, not all previous siblings.
2374                  *
2375                  * @example $("p").prev(".selected")
2376                  * @before <div><span>Hello</span></div><p class="selected">Hello Again</p><p>And Again</p>
2377                  * @result [ <div><span>Hello</span></div> ]
2378                  *
2379                  * @name prev
2380                  * @type jQuery
2381                  * @param String expr An expression to filter the previous Elements with
2382                  * @cat DOM/Traversing
2383                  */
2384                 prev: "jQuery.nth(a,1,'previousSibling')",
2385
2386                 /**
2387                  * Get a set of elements containing all of the unique siblings of each of the
2388                  * matched set of elements.
2389                  *
2390                  * @example $("div").siblings()
2391                  * @before <p>Hello</p><div><span>Hello Again</span></div><p>And Again</p>
2392                  * @result [ <p>Hello</p>, <p>And Again</p> ]
2393                  *
2394                  * @name siblings
2395                  * @type jQuery
2396                  * @cat DOM/Traversing
2397                  */
2398
2399                 /**
2400                  * Get a set of elements containing all of the unique siblings of each of the
2401                  * matched set of elements, and filtered by an expression.
2402                  *
2403                  * @example $("div").siblings(".selected")
2404                  * @before <div><span>Hello</span></div><p class="selected">Hello Again</p><p>And Again</p>
2405                  * @result [ <p class="selected">Hello Again</p> ]
2406                  *
2407                  * @name siblings
2408                  * @type jQuery
2409                  * @param String expr An expression to filter the sibling Elements with
2410                  * @cat DOM/Traversing
2411                  */
2412                 siblings: "jQuery.sibling(a.parentNode.firstChild,a)",
2413
2414                 /**
2415                  * Get a set of elements containing all of the unique children of each of the
2416                  * matched set of elements.
2417                  *
2418                  * @example $("div").children()
2419                  * @before <p>Hello</p><div><span>Hello Again</span></div><p>And Again</p>
2420                  * @result [ <span>Hello Again</span> ]
2421                  *
2422                  * @name children
2423                  * @type jQuery
2424                  * @cat DOM/Traversing
2425                  */
2426
2427                 /**
2428                  * Get a set of elements containing all of the unique children of each of the
2429                  * matched set of elements, and filtered by an expression.
2430                  *
2431                  * @example $("div").children(".selected")
2432                  * @before <div><span>Hello</span><p class="selected">Hello Again</p><p>And Again</p></div>
2433                  * @result [ <p class="selected">Hello Again</p> ]
2434                  *
2435                  * @name children
2436                  * @type jQuery
2437                  * @param String expr An expression to filter the child Elements with
2438                  * @cat DOM/Traversing
2439                  */
2440                 children: "jQuery.sibling(a.firstChild)"
2441         },
2442
2443         each: {
2444
2445                 /**
2446                  * Remove an attribute from each of the matched elements.
2447                  *
2448                  * @example $("input").removeAttr("disabled")
2449                  * @before <input disabled="disabled"/>
2450                  * @result <input/>
2451                  *
2452                  * @name removeAttr
2453                  * @type jQuery
2454                  * @param String name The name of the attribute to remove.
2455                  * @cat DOM
2456                  */
2457                 removeAttr: function( key ) {
2458                         jQuery.attr( this, key, "" );
2459                         this.removeAttribute( key );
2460                 },
2461
2462                 /**
2463                  * Displays each of the set of matched elements if they are hidden.
2464                  *
2465                  * @example $("p").show()
2466                  * @before <p style="display: none">Hello</p>
2467                  * @result [ <p style="display: block">Hello</p> ]
2468                  *
2469                  * @name show
2470                  * @type jQuery
2471                  * @cat Effects
2472                  */
2473                 show: function(){
2474                         this.style.display = this.oldblock ? this.oldblock : "";
2475                         if ( jQuery.css(this,"display") == "none" )
2476                                 this.style.display = "block";
2477                 },
2478
2479                 /**
2480                  * Hides each of the set of matched elements if they are shown.
2481                  *
2482                  * @example $("p").hide()
2483                  * @before <p>Hello</p>
2484                  * @result [ <p style="display: none">Hello</p> ]
2485                  *
2486                  * var pass = true, div = $("div");
2487                  * div.hide().each(function(){
2488                  *   if ( this.style.display != "none" ) pass = false;
2489                  * });
2490                  * ok( pass, "Hide" );
2491                  *
2492                  * @name hide
2493                  * @type jQuery
2494                  * @cat Effects
2495                  */
2496                 hide: function(){
2497                         this.oldblock = this.oldblock || jQuery.css(this,"display");
2498                         if ( this.oldblock == "none" )
2499                                 this.oldblock = "block";
2500                         this.style.display = "none";
2501                 },
2502
2503                 /**
2504                  * Toggles each of the set of matched elements. If they are shown,
2505                  * toggle makes them hidden. If they are hidden, toggle
2506                  * makes them shown.
2507                  *
2508                  * @example $("p").toggle()
2509                  * @before <p>Hello</p><p style="display: none">Hello Again</p>
2510                  * @result [ <p style="display: none">Hello</p>, <p style="display: block">Hello Again</p> ]
2511                  *
2512                  * @name toggle
2513                  * @type jQuery
2514                  * @cat Effects
2515                  */
2516                 toggle: function(){
2517                         jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ].apply( jQuery(this), arguments );
2518                 },
2519
2520                 /**
2521                  * Adds the specified class to each of the set of matched elements.
2522                  *
2523                  * @example $("p").addClass("selected")
2524                  * @before <p>Hello</p>
2525                  * @result [ <p class="selected">Hello</p> ]
2526                  *
2527                  * @name addClass
2528                  * @type jQuery
2529                  * @param String class A CSS class to add to the elements
2530                  * @cat DOM
2531                  */
2532                 addClass: function(c){
2533                         jQuery.className.add(this,c);
2534                 },
2535
2536                 /**
2537                  * Removes all or the specified class from the set of matched elements.
2538                  *
2539                  * @example $("p").removeClass()
2540                  * @before <p class="selected">Hello</p>
2541                  * @result [ <p>Hello</p> ]
2542                  *
2543                  * @example $("p").removeClass("selected")
2544                  * @before <p class="selected first">Hello</p>
2545                  * @result [ <p class="first">Hello</p> ]
2546                  *
2547                  * @name removeClass
2548                  * @type jQuery
2549                  * @param String class (optional) A CSS class to remove from the elements
2550                  * @cat DOM
2551                  */
2552                 removeClass: function(c){
2553                         jQuery.className.remove(this,c);
2554                 },
2555
2556                 /**
2557                  * Adds the specified class if it is not present, removes it if it is
2558                  * present.
2559                  *
2560                  * @example $("p").toggleClass("selected")
2561                  * @before <p>Hello</p><p class="selected">Hello Again</p>
2562                  * @result [ <p class="selected">Hello</p>, <p>Hello Again</p> ]
2563                  *
2564                  * @name toggleClass
2565                  * @type jQuery
2566                  * @param String class A CSS class with which to toggle the elements
2567                  * @cat DOM
2568                  */
2569                 toggleClass: function( c ){
2570                         jQuery.className[ jQuery.className.has(this,c) ? "remove" : "add" ](this, c);
2571                 },
2572
2573                 /**
2574                  * Removes all matched elements from the DOM. This does NOT remove them from the
2575                  * jQuery object, allowing you to use the matched elements further.
2576                  *
2577                  * @example $("p").remove();
2578                  * @before <p>Hello</p> how are <p>you?</p>
2579                  * @result how are
2580                  *
2581                  * @name remove
2582                  * @type jQuery
2583                  * @cat DOM/Manipulation
2584                  */
2585
2586                 /**
2587                  * Removes only elements (out of the list of matched elements) that match
2588                  * the specified jQuery expression. This does NOT remove them from the
2589                  * jQuery object, allowing you to use the matched elements further.
2590                  *
2591                  * @example $("p").remove(".hello");
2592                  * @before <p class="hello">Hello</p> how are <p>you?</p>
2593                  * @result how are <p>you?</p>
2594                  *
2595                  * @name remove
2596                  * @type jQuery
2597                  * @param String expr A jQuery expression to filter elements by.
2598                  * @cat DOM/Manipulation
2599                  */
2600                 remove: function(a){
2601                         if ( !a || jQuery.filter( a, [this] ).r )
2602                                 this.parentNode.removeChild( this );
2603                 },
2604
2605                 /**
2606                  * Removes all child nodes from the set of matched elements.
2607                  *
2608                  * @example $("p").empty()
2609                  * @before <p>Hello, <span>Person</span> <a href="#">and person</a></p>
2610                  * @result [ <p></p> ]
2611                  *
2612                  * @name empty
2613                  * @type jQuery
2614                  * @cat DOM/Manipulation
2615                  */
2616                 empty: function(){
2617                         while ( this.firstChild )
2618                                 this.removeChild( this.firstChild );
2619                 }
2620         }
2621 };
2622
2623 jQuery.init();