Added a fix for $("#noexist").attr("id") breaking.
[jquery.git] / src / jquery / jquery.js
1 /*
2  * jQuery @VERSION - New Wave Javascript
3  *
4  * Copyright (c) 2007 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  * @param String|Function|Element|Array<Element>|jQuery a selector
22  * @param jQuery|Element|Array<Element> c context
23  * @cat Core
24  */
25 var jQuery = function(a,c) {
26         // If the context is global, return a new object
27         if ( window == this )
28                 return new jQuery(a,c);
29
30         // Make sure that a selection was provided
31         a = a || document;
32         
33         // HANDLE: $(function)
34         // Shortcut for document ready
35         // Safari reports typeof on DOM NodeLists as a function
36         if ( jQuery.isFunction(a) && !a.nodeType && a[0] == undefined )
37                 return new jQuery(document)[ jQuery.fn.ready ? "ready" : "load" ]( a );
38         
39         // Handle HTML strings
40         if ( typeof a  == "string" ) {
41                 // HANDLE: $(html) -> $(array)
42                 var m = /^[^<]*(<.+>)[^>]*$/.exec(a);
43                 if ( m )
44                         a = jQuery.clean( [ m[1] ] );
45                 
46                 // HANDLE: $(expr)
47                 else
48                         return new jQuery( c ).find( a );
49         }
50         
51         return this.setArray(
52                 // HANDLE: $(array)
53                 a.constructor == Array && a ||
54
55                 // HANDLE: $(arraylike)
56                 // Watch for when an array-like object is passed as the selector
57                 (a.jquery || a.length && a != window && !a.nodeType && a[0] != undefined && a[0].nodeType) && jQuery.makeArray( a ) ||
58
59                 // HANDLE: $(*)
60                 [ a ] );
61 };
62
63 // Map over the $ in case of overwrite
64 if ( typeof $ != "undefined" )
65         jQuery._$ = $;
66         
67 // Map the jQuery namespace to the '$' one
68 var $ = jQuery;
69
70 /**
71  * This function accepts a string containing a CSS or
72  * basic XPath selector which is then used to match a set of elements.
73  *
74  * The core functionality of jQuery centers around this function.
75  * Everything in jQuery is based upon this, or uses this in some way.
76  * The most basic use of this function is to pass in an expression
77  * (usually consisting of CSS or XPath), which then finds all matching
78  * elements.
79  *
80  * By default, $() looks for DOM elements within the context of the
81  * current HTML document.
82  *
83  * @example $("div > p")
84  * @desc Finds all p elements that are children of a div element.
85  * @before <p>one</p> <div><p>two</p></div> <p>three</p>
86  * @result [ <p>two</p> ]
87  *
88  * @example $("input:radio", document.forms[0])
89  * @desc Searches for all inputs of type radio within the first form in the document
90  *
91  * @example $("div", xml.responseXML)
92  * @desc This finds all div elements within the specified XML document.
93  *
94  * @name $
95  * @param String expr An expression to search with
96  * @param Element|jQuery context (optional) A DOM Element, Document or jQuery to use as context
97  * @cat Core
98  * @type jQuery
99  * @see $(Element)
100  * @see $(Element<Array>)
101  */
102  
103 /**
104  * Create DOM elements on-the-fly from the provided String of raw HTML.
105  *
106  * @example $("<div><p>Hello</p></div>").appendTo("#body")
107  * @desc Creates a div element (and all of its contents) dynamically, 
108  * and appends it to the element with the ID of body. Internally, an
109  * element is created and it's innerHTML property set to the given markup.
110  * It is therefore both quite flexible and limited. 
111  *
112  * @name $
113  * @param String html A string of HTML to create on the fly.
114  * @cat Core
115  * @type jQuery
116  * @see appendTo(String)
117  */
118
119 /**
120  * Wrap jQuery functionality around a single or multiple DOM Element(s).
121  *
122  * This function also accepts XML Documents and Window objects
123  * as valid arguments (even though they are not DOM Elements).
124  *
125  * @example $(document.body).background( "black" );
126  * @desc Sets the background color of the page to black.
127  *
128  * @example $( myForm.elements ).hide()
129  * @desc Hides all the input elements within a form
130  *
131  * @name $
132  * @param Element|Array<Element> elems DOM element(s) to be encapsulated by a jQuery object.
133  * @cat Core
134  * @type jQuery
135  */
136
137 /**
138  * A shorthand for $(document).ready(), allowing you to bind a function
139  * to be executed when the DOM document has finished loading. This function
140  * behaves just like $(document).ready(), in that it should be used to wrap
141  * all of the other $() operations on your page. While this function is,
142  * technically, chainable - there really isn't much use for chaining against it.
143  * You can have as many $(document).ready events on your page as you like.
144  *
145  * See ready(Function) for details about the ready event. 
146  * 
147  * @example $(function(){
148  *   // Document is ready
149  * });
150  * @desc Executes the function when the DOM is ready to be used.
151  *
152  * @example jQuery(function($) {
153  *   // Your code using failsafe $ alias here...
154  * });
155  * @desc Uses both the shortcut for $(document).ready() and the argument
156  * to write failsafe jQuery code using the $ alias, without relying on the
157  * global alias.
158  *
159  * @name $
160  * @param Function fn The function to execute when the DOM is ready.
161  * @cat Core
162  * @type jQuery
163  * @see ready(Function)
164  */
165
166 jQuery.fn = jQuery.prototype = {
167         /**
168          * The current version of jQuery.
169          *
170          * @private
171          * @property
172          * @name jquery
173          * @type String
174          * @cat Core
175          */
176         jquery: "@VERSION",
177
178         /**
179          * The number of elements currently matched.
180          *
181          * @example $("img").length;
182          * @before <img src="test1.jpg"/> <img src="test2.jpg"/>
183          * @result 2
184          *
185          * @property
186          * @name length
187          * @type Number
188          * @cat Core
189          */
190
191         /**
192          * The number of elements currently matched.
193          *
194          * @example $("img").size();
195          * @before <img src="test1.jpg"/> <img src="test2.jpg"/>
196          * @result 2
197          *
198          * @name size
199          * @type Number
200          * @cat Core
201          */
202         size: function() {
203                 return this.length;
204         },
205         
206         length: 0,
207
208         /**
209          * Access all matched elements. This serves as a backwards-compatible
210          * way of accessing all matched elements (other than the jQuery object
211          * itself, which is, in fact, an array of elements).
212          *
213          * @example $("img").get();
214          * @before <img src="test1.jpg"/> <img src="test2.jpg"/>
215          * @result [ <img src="test1.jpg"/> <img src="test2.jpg"/> ]
216          * @desc Selects all images in the document and returns the DOM Elements as an Array
217          *
218          * @name get
219          * @type Array<Element>
220          * @cat Core
221          */
222
223         /**
224          * Access a single matched element. num is used to access the
225          * Nth element matched.
226          *
227          * @example $("img").get(0);
228          * @before <img src="test1.jpg"/> <img src="test2.jpg"/>
229          * @result [ <img src="test1.jpg"/> ]
230          * @desc Selects all images in the document and returns the first one
231          *
232          * @name get
233          * @type Element
234          * @param Number num Access the element in the Nth position.
235          * @cat Core
236          */
237         get: function( num ) {
238                 return num == undefined ?
239
240                         // Return a 'clean' array
241                         jQuery.makeArray( this ) :
242
243                         // Return just the object
244                         this[num];
245         },
246         
247         /**
248          * Set the jQuery object to an array of elements, while maintaining
249          * the stack.
250          *
251          * @example $("img").pushStack([ document.body ]);
252          * @result $("img").pushStack() == [ document.body ]
253          *
254          * @private
255          * @name pushStack
256          * @type jQuery
257          * @param Elements elems An array of elements
258          * @cat Core
259          */
260         pushStack: function( a ) {
261                 var ret = jQuery(this);
262                 ret.prevObject = this;
263                 return ret.setArray( a );
264         },
265         
266         /**
267          * Set the jQuery object to an array of elements. This operation is
268          * completely destructive - be sure to use .pushStack() if you wish to maintain
269          * the jQuery stack.
270          *
271          * @example $("img").setArray([ document.body ]);
272          * @result $("img").setArray() == [ document.body ]
273          *
274          * @private
275          * @name setArray
276          * @type jQuery
277          * @param Elements elems An array of elements
278          * @cat Core
279          */
280         setArray: function( a ) {
281                 this.length = 0;
282                 [].push.apply( this, a );
283                 return this;
284         },
285
286         /**
287          * Execute a function within the context of every matched element.
288          * This means that every time the passed-in function is executed
289          * (which is once for every element matched) the 'this' keyword
290          * points to the specific element.
291          *
292          * Additionally, the function, when executed, is passed a single
293          * argument representing the position of the element in the matched
294          * set.
295          *
296          * @example $("img").each(function(i){
297          *   this.src = "test" + i + ".jpg";
298          * });
299          * @before <img/><img/>
300          * @result <img src="test0.jpg"/><img src="test1.jpg"/>
301          * @desc Iterates over two images and sets their src property
302          *
303          * @name each
304          * @type jQuery
305          * @param Function fn A function to execute
306          * @cat Core
307          */
308         each: function( fn, args ) {
309                 return jQuery.each( this, fn, args );
310         },
311
312         /**
313          * Searches every matched element for the object and returns
314          * the index of the element, if found, starting with zero. 
315          * Returns -1 if the object wasn't found.
316          *
317          * @example $("*").index( $('#foobar')[0] ) 
318          * @before <div id="foobar"><b></b><span id="foo"></span></div>
319          * @result 0
320          * @desc Returns the index for the element with ID foobar
321          *
322          * @example $("*").index( $('#foo')[0] ) 
323          * @before <div id="foobar"><b></b><span id="foo"></span></div>
324          * @result 2
325          * @desc Returns the index for the element with ID foo within another element
326          *
327          * @example $("*").index( $('#bar')[0] ) 
328          * @before <div id="foobar"><b></b><span id="foo"></span></div>
329          * @result -1
330          * @desc Returns -1, as there is no element with ID bar
331          *
332          * @name index
333          * @type Number
334          * @param Element subject Object to search for
335          * @cat Core
336          */
337         index: function( obj ) {
338                 var pos = -1;
339                 this.each(function(i){
340                         if ( this == obj ) pos = i;
341                 });
342                 return pos;
343         },
344
345         /**
346          * Access a property on the first matched element.
347          * This method makes it easy to retrieve a property value
348          * from the first matched element.
349          *
350          * @example $("img").attr("src");
351          * @before <img src="test.jpg"/>
352          * @result test.jpg
353          * @desc Returns the src attribute from the first image in the document.
354          *
355          * @name attr
356          * @type Object
357          * @param String name The name of the property to access.
358          * @cat DOM/Attributes
359          */
360
361         /**
362          * Set a key/value object as properties to all matched elements.
363          *
364          * This serves as the best way to set a large number of properties
365          * on all matched elements.
366          *
367          * @example $("img").attr({ src: "test.jpg", alt: "Test Image" });
368          * @before <img/>
369          * @result <img src="test.jpg" alt="Test Image"/>
370          * @desc Sets src and alt attributes to all images.
371          *
372          * @name attr
373          * @type jQuery
374          * @param Map properties Key/value pairs to set as object properties.
375          * @cat DOM/Attributes
376          */
377
378         /**
379          * Set a single property to a value, on all matched elements.
380          *
381          * Can compute values provided as ${formula}, see second example.
382          *
383          * Note that you can't set the name property of input elements in IE.
384          * Use $(html) or .append(html) or .html(html) to create elements
385          * on the fly including the name property.
386          *
387          * @example $("img").attr("src","test.jpg");
388          * @before <img/>
389          * @result <img src="test.jpg"/>
390          * @desc Sets src attribute to all images.
391          *
392          * @example $("img").attr("title", "${this.src}");
393          * @before <img src="test.jpg" />
394          * @result <img src="test.jpg" title="test.jpg" />
395          * @desc Sets title attribute from src attribute, a shortcut for attr(String,Function)
396          *
397          * @name attr
398          * @type jQuery
399          * @param String key The name of the property to set.
400          * @param Object value The value to set the property to.
401          * @cat DOM/Attributes
402          */
403          
404         /**
405          * Set a single property to a computed value, on all matched elements.
406          *
407          * Instead of a value, a function is provided, that computes the value.
408          *
409          * @example $("img").attr("title", function() { return this.src });
410          * @before <img src="test.jpg" />
411          * @result <img src="test.jpg" title="test.jpg" />
412          * @desc Sets title attribute from src attribute.
413          *
414          * @example $("img").attr("title", function(index) { return this.title + (i + 1); });
415          * @before <img title="pic" /><img title="pic" /><img title="pic" />
416          * @result <img title="pic1" /><img title="pic2" /><img title="pic3" />
417          * @desc Enumerate title attribute.
418          *
419          * @name attr
420          * @type jQuery
421          * @param String key The name of the property to set.
422          * @param Function value A function returning the value to set.
423          *                Scope: Current element, argument: Index of current element
424          * @cat DOM/Attributes
425          */
426         attr: function( key, value, type ) {
427                 var obj = key;
428                 
429                 // Look for the case where we're accessing a style value
430                 if ( key.constructor == String )
431                         if ( value == undefined )
432                                 return this.length && jQuery[ type || "attr" ]( this[0], key ) || undefined;
433                         else {
434                                 obj = {};
435                                 obj[ key ] = value;
436                         }
437                 
438                 // Check to see if we're setting style values
439                 return this.each(function(index){
440                         // Set all the styles
441                         for ( var prop in obj )
442                                 jQuery.attr(
443                                         type ? this.style : this,
444                                         prop, jQuery.prop(this, obj[prop], type, index, prop)
445                                 );
446                 });
447         },
448
449         /**
450          * Access a style property on the first matched element.
451          * This method makes it easy to retrieve a style property value
452          * from the first matched element.
453          *
454          * @example $("p").css("color");
455          * @before <p style="color:red;">Test Paragraph.</p>
456          * @result "red"
457          * @desc Retrieves the color style of the first paragraph
458          *
459          * @example $("p").css("font-weight");
460          * @before <p style="font-weight: bold;">Test Paragraph.</p>
461          * @result "bold"
462          * @desc Retrieves the font-weight style of the first paragraph.
463          *
464          * @name css
465          * @type String
466          * @param String name The name of the property to access.
467          * @cat CSS
468          */
469
470         /**
471          * Set a key/value object as style properties to all matched elements.
472          *
473          * This serves as the best way to set a large number of style properties
474          * on all matched elements.
475          *
476          * @example $("p").css({ color: "red", background: "blue" });
477          * @before <p>Test Paragraph.</p>
478          * @result <p style="color:red; background:blue;">Test Paragraph.</p>
479          * @desc Sets color and background styles to all p elements.
480          *
481          * @name css
482          * @type jQuery
483          * @param Map properties Key/value pairs to set as style properties.
484          * @cat CSS
485          */
486
487         /**
488          * Set a single style property to a value, on all matched elements.
489          * If a number is provided, it is automatically converted into a pixel value.
490          *
491          * @example $("p").css("color","red");
492          * @before <p>Test Paragraph.</p>
493          * @result <p style="color:red;">Test Paragraph.</p>
494          * @desc Changes the color of all paragraphs to red
495          *
496          * @example $("p").css("left",30);
497          * @before <p>Test Paragraph.</p>
498          * @result <p style="left:30px;">Test Paragraph.</p>
499          * @desc Changes the left of all paragraphs to "30px"
500          *
501          * @name css
502          * @type jQuery
503          * @param String key The name of the property to set.
504          * @param String|Number value The value to set the property to.
505          * @cat CSS
506          */
507         css: function( key, value ) {
508                 return this.attr( key, value, "curCSS" );
509         },
510
511         /**
512          * Get the text contents of all matched elements. The result is
513          * a string that contains the combined text contents of all matched
514          * elements. This method works on both HTML and XML documents.
515          *
516          * @example $("p").text();
517          * @before <p><b>Test</b> Paragraph.</p><p>Paraparagraph</p>
518          * @result Test Paragraph.Paraparagraph
519          * @desc Gets the concatenated text of all paragraphs
520          *
521          * @name text
522          * @type String
523          * @cat DOM/Attributes
524          */
525
526         /**
527          * Set the text contents of all matched elements.
528          *
529          * Similar to html(), but escapes HTML (replace "<" and ">" with their
530          * HTML entities).
531          *
532          * @example $("p").text("<b>Some</b> new text.");
533          * @before <p>Test Paragraph.</p>
534          * @result <p>&lt;b&gt;Some&lt;/b&gt; new text.</p>
535          * @desc Sets the text of all paragraphs.
536          *
537          * @example $("p").text("<b>Some</b> new text.", true);
538          * @before <p>Test Paragraph.</p>
539          * @result <p>Some new text.</p>
540          * @desc Sets the text of all paragraphs.
541          *
542          * @name text
543          * @type String
544          * @param String val The text value to set the contents of the element to.
545          * @cat DOM/Attributes
546          */
547         text: function(e) {
548                 if ( typeof e == "string" )
549                         return this.empty().append( document.createTextNode( e ) );
550
551                 var t = "";
552                 jQuery.each( e || this, function(){
553                         jQuery.each( this.childNodes, function(){
554                                 if ( this.nodeType != 8 )
555                                         t += this.nodeType != 1 ?
556                                                 this.nodeValue : jQuery.fn.text([ this ]);
557                         });
558                 });
559                 return t;
560         },
561
562         /**
563          * Wrap all matched elements with a structure of other elements.
564          * This wrapping process is most useful for injecting additional
565          * stucture into a document, without ruining the original semantic
566          * qualities of a document.
567          *
568          * This works by going through the first element
569          * provided (which is generated, on the fly, from the provided HTML)
570          * and finds the deepest ancestor element within its
571          * structure - it is that element that will en-wrap everything else.
572          *
573          * This does not work with elements that contain text. Any necessary text
574          * must be added after the wrapping is done.
575          *
576          * @example $("p").wrap("<div class='wrap'></div>");
577          * @before <p>Test Paragraph.</p>
578          * @result <div class='wrap'><p>Test Paragraph.</p></div>
579          * 
580          * @name wrap
581          * @type jQuery
582          * @param String html A string of HTML, that will be created on the fly and wrapped around the target.
583          * @cat DOM/Manipulation
584          */
585
586         /**
587          * Wrap all matched elements with a structure of other elements.
588          * This wrapping process is most useful for injecting additional
589          * stucture into a document, without ruining the original semantic
590          * qualities of a document.
591          *
592          * This works by going through the first element
593          * provided and finding the deepest ancestor element within its
594          * structure - it is that element that will en-wrap everything else.
595          *
596          * This does not work with elements that contain text. Any necessary text
597          * must be added after the wrapping is done.
598          *
599          * @example $("p").wrap( document.getElementById('content') );
600          * @before <p>Test Paragraph.</p><div id="content"></div>
601          * @result <div id="content"><p>Test Paragraph.</p></div>
602          *
603          * @name wrap
604          * @type jQuery
605          * @param Element elem A DOM element that will be wrapped around the target.
606          * @cat DOM/Manipulation
607          */
608         wrap: function() {
609                 // The elements to wrap the target around
610                 var a = jQuery.clean(arguments);
611
612                 // Wrap each of the matched elements individually
613                 return this.each(function(){
614                         // Clone the structure that we're using to wrap
615                         var b = a[0].cloneNode(true);
616
617                         // Insert it before the element to be wrapped
618                         this.parentNode.insertBefore( b, this );
619
620                         // Find the deepest point in the wrap structure
621                         while ( b.firstChild )
622                                 b = b.firstChild;
623
624                         // Move the matched element to within the wrap structure
625                         b.appendChild( this );
626                 });
627         },
628
629         /**
630          * Append content to the inside of every matched element.
631          *
632          * This operation is similar to doing an appendChild to all the
633          * specified elements, adding them into the document.
634          *
635          * @example $("p").append("<b>Hello</b>");
636          * @before <p>I would like to say: </p>
637          * @result <p>I would like to say: <b>Hello</b></p>
638          * @desc Appends some HTML to all paragraphs.
639          *
640          * @example $("p").append( $("#foo")[0] );
641          * @before <p>I would like to say: </p><b id="foo">Hello</b>
642          * @result <p>I would like to say: <b id="foo">Hello</b></p>
643          * @desc Appends an Element to all paragraphs.
644          *
645          * @example $("p").append( $("b") );
646          * @before <p>I would like to say: </p><b>Hello</b>
647          * @result <p>I would like to say: <b>Hello</b></p>
648          * @desc Appends a jQuery object (similar to an Array of DOM Elements) to all paragraphs.
649          *
650          * @name append
651          * @type jQuery
652          * @param <Content> content Content to append to the target
653          * @cat DOM/Manipulation
654          * @see prepend(<Content>)
655          * @see before(<Content>)
656          * @see after(<Content>)
657          */
658         append: function() {
659                 return this.domManip(arguments, true, 1, function(a){
660                         this.appendChild( a );
661                 });
662         },
663
664         /**
665          * Prepend content to the inside of every matched element.
666          *
667          * This operation is the best way to insert elements
668          * inside, at the beginning, of all matched elements.
669          *
670          * @example $("p").prepend("<b>Hello</b>");
671          * @before <p>I would like to say: </p>
672          * @result <p><b>Hello</b>I would like to say: </p>
673          * @desc Prepends some HTML to all paragraphs.
674          *
675          * @example $("p").prepend( $("#foo")[0] );
676          * @before <p>I would like to say: </p><b id="foo">Hello</b>
677          * @result <p><b id="foo">Hello</b>I would like to say: </p>
678          * @desc Prepends an Element to all paragraphs.
679          *      
680          * @example $("p").prepend( $("b") );
681          * @before <p>I would like to say: </p><b>Hello</b>
682          * @result <p><b>Hello</b>I would like to say: </p>
683          * @desc Prepends a jQuery object (similar to an Array of DOM Elements) to all paragraphs.
684          *
685          * @name prepend
686          * @type jQuery
687          * @param <Content> content Content to prepend to the target.
688          * @cat DOM/Manipulation
689          * @see append(<Content>)
690          * @see before(<Content>)
691          * @see after(<Content>)
692          */
693         prepend: function() {
694                 return this.domManip(arguments, true, -1, function(a){
695                         this.insertBefore( a, this.firstChild );
696                 });
697         },
698         
699         /**
700          * Insert content before each of the matched elements.
701          *
702          * @example $("p").before("<b>Hello</b>");
703          * @before <p>I would like to say: </p>
704          * @result <b>Hello</b><p>I would like to say: </p>
705          * @desc Inserts some HTML before all paragraphs.
706          *
707          * @example $("p").before( $("#foo")[0] );
708          * @before <p>I would like to say: </p><b id="foo">Hello</b>
709          * @result <b id="foo">Hello</b><p>I would like to say: </p>
710          * @desc Inserts an Element before all paragraphs.
711          *
712          * @example $("p").before( $("b") );
713          * @before <p>I would like to say: </p><b>Hello</b>
714          * @result <b>Hello</b><p>I would like to say: </p>
715          * @desc Inserts a jQuery object (similar to an Array of DOM Elements) before all paragraphs.
716          *
717          * @name before
718          * @type jQuery
719          * @param <Content> content Content to insert before each target.
720          * @cat DOM/Manipulation
721          * @see append(<Content>)
722          * @see prepend(<Content>)
723          * @see after(<Content>)
724          */
725         before: function() {
726                 return this.domManip(arguments, false, 1, function(a){
727                         this.parentNode.insertBefore( a, this );
728                 });
729         },
730
731         /**
732          * Insert content after each of the matched elements.
733          *
734          * @example $("p").after("<b>Hello</b>");
735          * @before <p>I would like to say: </p>
736          * @result <p>I would like to say: </p><b>Hello</b>
737          * @desc Inserts some HTML after all paragraphs.
738          *
739          * @example $("p").after( $("#foo")[0] );
740          * @before <b id="foo">Hello</b><p>I would like to say: </p>
741          * @result <p>I would like to say: </p><b id="foo">Hello</b>
742          * @desc Inserts an Element after all paragraphs.
743          *
744          * @example $("p").after( $("b") );
745          * @before <b>Hello</b><p>I would like to say: </p>
746          * @result <p>I would like to say: </p><b>Hello</b>
747          * @desc Inserts a jQuery object (similar to an Array of DOM Elements) after all paragraphs.
748          *
749          * @name after
750          * @type jQuery
751          * @param <Content> content Content to insert after each target.
752          * @cat DOM/Manipulation
753          * @see append(<Content>)
754          * @see prepend(<Content>)
755          * @see before(<Content>)
756          */
757         after: function() {
758                 return this.domManip(arguments, false, -1, function(a){
759                         this.parentNode.insertBefore( a, this.nextSibling );
760                 });
761         },
762
763         /**
764          * End the most recent 'destructive' operation, reverting the list of matched elements
765          * back to its previous state. After an end operation, the list of matched elements will
766          * revert to the last state of matched elements.
767          *
768          * If there was no destructive operation before, an empty set is returned.
769          *
770          * @example $("p").find("span").end();
771          * @before <p><span>Hello</span>, how are you?</p>
772          * @result [ <p>...</p> ]
773          * @desc Selects all paragraphs, finds span elements inside these, and reverts the
774          * selection back to the paragraphs.
775          *
776          * @name end
777          * @type jQuery
778          * @cat DOM/Traversing
779          */
780         end: function() {
781                 return this.prevObject || jQuery([]);
782         },
783
784         /**
785          * Searches for all elements that match the specified expression.
786          
787          * This method is a good way to find additional descendant
788          * elements with which to process.
789          *
790          * All searching is done using a jQuery expression. The expression can be
791          * written using CSS 1-3 Selector syntax, or basic XPath.
792          *
793          * @example $("p").find("span");
794          * @before <p><span>Hello</span>, how are you?</p>
795          * @result [ <span>Hello</span> ]
796          * @desc Starts with all paragraphs and searches for descendant span
797          * elements, same as $("p span")
798          *
799          * @name find
800          * @type jQuery
801          * @param String expr An expression to search with.
802          * @cat DOM/Traversing
803          */
804         find: function(t) {
805                 return this.pushStack( jQuery.map( this, function(a){
806                         return jQuery.find(t,a);
807                 }) );
808         },
809
810         /**
811          * Clone matched DOM Elements and select the clones. 
812          *
813          * This is useful for moving copies of the elements to another
814          * location in the DOM.
815          *
816          * @example $("b").clone().prependTo("p");
817          * @before <b>Hello</b><p>, how are you?</p>
818          * @result <b>Hello</b><p><b>Hello</b>, how are you?</p>
819          * @desc Clones all b elements (and selects the clones) and prepends them to all paragraphs.
820          *
821          * @name clone
822          * @type jQuery
823          * @param Boolean deep (Optional) Set to false if you don't want to clone all descendant nodes, in addition to the element itself.
824          * @cat DOM/Manipulation
825          */
826         clone: function(deep) {
827                 return this.pushStack( jQuery.map( this, function(a){
828                         return a.cloneNode( deep != undefined ? deep : true );
829                 }) );
830         },
831
832         /**
833          * Removes all elements from the set of matched elements that do not
834          * match the specified expression(s). This method is used to narrow down
835          * the results of a search.
836          *
837          * Provide a comma-separated list of expressions to apply multiple filters at once.
838          *
839          * @example $("p").filter(".selected")
840          * @before <p class="selected">Hello</p><p>How are you?</p>
841          * @result [ <p class="selected">Hello</p> ]
842          * @desc Selects all paragraphs and removes those without a class "selected".
843          *
844          * @example $("p").filter(".selected, :first")
845          * @before <p>Hello</p><p>Hello Again</p><p class="selected">And Again</p>
846          * @result [ <p>Hello</p>, <p class="selected">And Again</p> ]
847          * @desc Selects all paragraphs and removes those without class "selected" and being the first one.
848          *
849          * @name filter
850          * @type jQuery
851          * @param String expression Expression(s) to search with.
852          * @cat DOM/Traversing
853          */
854          
855         /**
856          * Removes all elements from the set of matched elements that do not
857          * pass the specified filter. This method is used to narrow down
858          * the results of a search.
859          *
860          * @example $("p").filter(function(index) {
861          *   return $("ol", this).length == 0;
862          * })
863          * @before <p><ol><li>Hello</li></ol></p><p>How are you?</p>
864          * @result [ <p>How are you?</p> ]
865          * @desc Remove all elements that have a child ol element
866          *
867          * @name filter
868          * @type jQuery
869          * @param Function filter A function to use for filtering
870          * @cat DOM/Traversing
871          */
872         filter: function(t) {
873                 return this.pushStack(
874                         jQuery.isFunction( t ) &&
875                         jQuery.grep(this, function(el, index){
876                                 return t.apply(el, [index])
877                         }) ||
878
879                         jQuery.multiFilter(t,this) );
880         },
881
882         /**
883          * Removes the specified Element from the set of matched elements. This
884          * method is used to remove a single Element from a jQuery object.
885          *
886          * @example $("p").not( $("#selected")[0] )
887          * @before <p>Hello</p><p id="selected">Hello Again</p>
888          * @result [ <p>Hello</p> ]
889          * @desc Removes the element with the ID "selected" from the set of all paragraphs.
890          *
891          * @name not
892          * @type jQuery
893          * @param Element el An element to remove from the set
894          * @cat DOM/Traversing
895          */
896
897         /**
898          * Removes elements matching the specified expression from the set
899          * of matched elements. This method is used to remove one or more
900          * elements from a jQuery object.
901          *
902          * @example $("p").not("#selected")
903          * @before <p>Hello</p><p id="selected">Hello Again</p>
904          * @result [ <p>Hello</p> ]
905          * @desc Removes the element with the ID "selected" from the set of all paragraphs.
906          *
907          * @name not
908          * @type jQuery
909          * @param String expr An expression with which to remove matching elements
910          * @cat DOM/Traversing
911          */
912
913         /**
914          * Removes any elements inside the array of elements from the set
915          * of matched elements. This method is used to remove one or more
916          * elements from a jQuery object.
917          *
918          * @example $("p").not( $("div p.selected") )
919          * @before <div><p>Hello</p><p class="selected">Hello Again</p></div>
920          * @result [ <p>Hello</p> ]
921          * @desc Removes all elements that match "div p.selected" from the total set of all paragraphs.
922          *
923          * @name not
924          * @type jQuery
925          * @param jQuery elems A set of elements to remove from the jQuery set of matched elements.
926          * @cat DOM/Traversing
927          */
928         not: function(t) {
929                 return this.pushStack(
930                         t.constructor == String &&
931                         jQuery.multiFilter(t,this,true) ||
932
933                         jQuery.grep(this,function(a){
934                                         if ( t.constructor == Array || t.jquery )
935                                                 return jQuery.inArray( t, a ) < 0;
936                                         else
937                                                 return a != t;
938                         }) );
939         },
940
941         /**
942          * Adds more elements, matched by the given expression,
943          * to the set of matched elements.
944          *
945          * @example $("p").add("span")
946          * @before <p>Hello</p><span>Hello Again</span>
947          * @result [ <p>Hello</p>, <span>Hello Again</span> ]
948          *
949          * @name add
950          * @type jQuery
951          * @param String expr An expression whose matched elements are added
952          * @cat DOM/Traversing
953          */
954          
955         /**
956          * Adds more elements, created on the fly, to the set of
957          * matched elements.
958          *
959          * @example $("p").add("<span>Again</span>")
960          * @before <p>Hello</p>
961          * @result [ <p>Hello</p>, <span>Again</span> ]
962          *
963          * @name add
964          * @type jQuery
965          * @param String html A string of HTML to create on the fly.
966          * @cat DOM/Traversing
967          */
968
969         /**
970          * Adds one or more Elements to the set of matched elements.
971          *
972          * @example $("p").add( document.getElementById("a") )
973          * @before <p>Hello</p><p><span id="a">Hello Again</span></p>
974          * @result [ <p>Hello</p>, <span id="a">Hello Again</span> ]
975          *
976          * @example $("p").add( document.forms[0].elements )
977          * @before <p>Hello</p><p><form><input/><button/></form>
978          * @result [ <p>Hello</p>, <input/>, <button/> ]
979          *
980          * @name add
981          * @type jQuery
982          * @param Element|Array<Element> elements One or more Elements to add
983          * @cat DOM/Traversing
984          */
985         add: function(t) {
986                 return this.pushStack( jQuery.merge(
987                         this.get(),
988                         typeof t == "string" ? jQuery(t).get() : t.length ? t : [t] )
989                 );
990         },
991
992         /**
993          * Checks the current selection against an expression and returns true,
994          * if at least one element of the selection fits the given expression.
995          *
996          * Does return false, if no element fits or the expression is not valid.
997          *
998          * filter(String) is used internally, therefore all rules that apply there
999          * apply here, too.
1000          *
1001          * @example $("input[@type='checkbox']").parent().is("form")
1002          * @before <form><input type="checkbox" /></form>
1003          * @result true
1004          * @desc Returns true, because the parent of the input is a form element
1005          * 
1006          * @example $("input[@type='checkbox']").parent().is("form")
1007          * @before <form><p><input type="checkbox" /></p></form>
1008          * @result false
1009          * @desc Returns false, because the parent of the input is a p element
1010          *
1011          * @name is
1012          * @type Boolean
1013          * @param String expr The expression with which to filter
1014          * @cat DOM/Traversing
1015          */
1016         is: function(expr) {
1017                 return expr ? jQuery.filter(expr,this).r.length > 0 : false;
1018         },
1019         
1020         /**
1021          * Get the current value of the first matched element.
1022          *
1023          * @example $("input").val();
1024          * @before <input type="text" value="some text"/>
1025          * @result "some text"
1026          *
1027          * @name val
1028          * @type String
1029          * @cat DOM/Attributes
1030          */
1031         
1032         /**
1033          * Set the value of every matched element.
1034          *
1035          * @example $("input").val("test");
1036          * @before <input type="text" value="some text"/>
1037          * @result <input type="text" value="test"/>
1038          *
1039          * @name val
1040          * @type jQuery
1041          * @param String val Set the property to the specified value.
1042          * @cat DOM/Attributes
1043          */
1044         val: function( val ) {
1045                 return val == undefined ?
1046                         ( this.length ? this[0].value : null ) :
1047                         this.attr( "value", val );
1048         },
1049         
1050         /**
1051          * Get the html contents of the first matched element.
1052          * This property is not available on XML documents.
1053          *
1054          * @example $("div").html();
1055          * @before <div><input/></div>
1056          * @result <input/>
1057          *
1058          * @name html
1059          * @type String
1060          * @cat DOM/Attributes
1061          */
1062         
1063         /**
1064          * Set the html contents of every matched element.
1065          * This property is not available on XML documents.
1066          *
1067          * @example $("div").html("<b>new stuff</b>");
1068          * @before <div><input/></div>
1069          * @result <div><b>new stuff</b></div>
1070          *
1071          * @name html
1072          * @type jQuery
1073          * @param String val Set the html contents to the specified value.
1074          * @cat DOM/Attributes
1075          */
1076         html: function( val ) {
1077                 return val == undefined ?
1078                         ( this.length ? this[0].innerHTML : null ) :
1079                         this.empty().append( val );
1080         },
1081         
1082         /**
1083          * @private
1084          * @name domManip
1085          * @param Array args
1086          * @param Boolean table Insert TBODY in TABLEs if one is not found.
1087          * @param Number dir If dir<0, process args in reverse order.
1088          * @param Function fn The function doing the DOM manipulation.
1089          * @type jQuery
1090          * @cat Core
1091          */
1092         domManip: function(args, table, dir, fn){
1093                 var clone = this.length > 1; 
1094                 var a = jQuery.clean(args);
1095                 if ( dir < 0 )
1096                         a.reverse();
1097
1098                 return this.each(function(){
1099                         var obj = this;
1100
1101                         if ( table && this.nodeName.toUpperCase() == "TABLE" && a[0].nodeName.toUpperCase() == "TR" )
1102                                 obj = this.getElementsByTagName("tbody")[0] || this.appendChild(document.createElement("tbody"));
1103
1104                         jQuery.each( a, function(){
1105                                 fn.apply( obj, [ clone ? this.cloneNode(true) : this ] );
1106                         });
1107
1108                 });
1109         }
1110 };
1111
1112 /**
1113  * Extends the jQuery object itself. Can be used to add functions into
1114  * the jQuery namespace and to add plugin methods (plugins).
1115  * 
1116  * @example jQuery.fn.extend({
1117  *   check: function() {
1118  *     return this.each(function() { this.checked = true; });
1119  *   },
1120  *   uncheck: function() {
1121  *     return this.each(function() { this.checked = false; });
1122  *   }
1123  * });
1124  * $("input[@type=checkbox]").check();
1125  * $("input[@type=radio]").uncheck();
1126  * @desc Adds two plugin methods.
1127  *
1128  * @example jQuery.extend({
1129  *   min: function(a, b) { return a < b ? a : b; },
1130  *   max: function(a, b) { return a > b ? a : b; }
1131  * });
1132  * @desc Adds two functions into the jQuery namespace
1133  *
1134  * @name $.extend
1135  * @param Object prop The object that will be merged into the jQuery object
1136  * @type Object
1137  * @cat Core
1138  */
1139
1140 /**
1141  * Extend one object with one or more others, returning the original,
1142  * modified, object. This is a great utility for simple inheritance.
1143  * 
1144  * @example var settings = { validate: false, limit: 5, name: "foo" };
1145  * var options = { validate: true, name: "bar" };
1146  * jQuery.extend(settings, options);
1147  * @result settings == { validate: true, limit: 5, name: "bar" }
1148  * @desc Merge settings and options, modifying settings
1149  *
1150  * @example var defaults = { validate: false, limit: 5, name: "foo" };
1151  * var options = { validate: true, name: "bar" };
1152  * var settings = jQuery.extend({}, defaults, options);
1153  * @result settings == { validate: true, limit: 5, name: "bar" }
1154  * @desc Merge defaults and options, without modifying the defaults
1155  *
1156  * @name $.extend
1157  * @param Object target The object to extend
1158  * @param Object prop1 The object that will be merged into the first.
1159  * @param Object propN (optional) More objects to merge into the first
1160  * @type Object
1161  * @cat JavaScript
1162  */
1163 jQuery.extend = jQuery.fn.extend = function() {
1164         // copy reference to target object
1165         var target = arguments[0],
1166                 a = 1;
1167
1168         // extend jQuery itself if only one argument is passed
1169         if ( arguments.length == 1 ) {
1170                 target = this;
1171                 a = 0;
1172         }
1173         var prop;
1174         while (prop = arguments[a++])
1175                 // Extend the base object
1176                 for ( var i in prop ) target[i] = prop[i];
1177
1178         // Return the modified object
1179         return target;
1180 };
1181
1182 jQuery.extend({
1183         /**
1184          * Run this function to give control of the $ variable back
1185          * to whichever library first implemented it. This helps to make 
1186          * sure that jQuery doesn't conflict with the $ object
1187          * of other libraries.
1188          *
1189          * By using this function, you will only be able to access jQuery
1190          * using the 'jQuery' variable. For example, where you used to do
1191          * $("div p"), you now must do jQuery("div p").
1192          *
1193          * @example jQuery.noConflict();
1194          * // Do something with jQuery
1195          * jQuery("div p").hide();
1196          * // Do something with another library's $()
1197          * $("content").style.display = 'none';
1198          * @desc Maps the original object that was referenced by $ back to $
1199          *
1200          * @example jQuery.noConflict();
1201          * (function($) { 
1202          *   $(function() {
1203          *     // more code using $ as alias to jQuery
1204          *   });
1205          * })(jQuery);
1206          * // other code using $ as an alias to the other library
1207          * @desc Reverts the $ alias and then creates and executes a
1208          * function to provide the $ as a jQuery alias inside the functions
1209          * scope. Inside the function the original $ object is not available.
1210          * This works well for most plugins that don't rely on any other library.
1211          * 
1212          *
1213          * @name $.noConflict
1214          * @type undefined
1215          * @cat Core 
1216          */
1217         noConflict: function() {
1218                 if ( jQuery._$ )
1219                         $ = jQuery._$;
1220         },
1221
1222         isFunction: function( fn ) {
1223                 return fn && typeof fn == "function";
1224         },
1225
1226         /**
1227          * A generic iterator function, which can be used to seemlessly
1228          * iterate over both objects and arrays. This function is not the same
1229          * as $().each() - which is used to iterate, exclusively, over a jQuery
1230          * object. This function can be used to iterate over anything.
1231          *
1232          * The callback has two arguments:the key (objects) or index (arrays) as first
1233          * the first, and the value as the second.
1234          *
1235          * @example $.each( [0,1,2], function(i, n){
1236          *   alert( "Item #" + i + ": " + n );
1237          * });
1238          * @desc This is an example of iterating over the items in an array,
1239          * accessing both the current item and its index.
1240          *
1241          * @example $.each( { name: "John", lang: "JS" }, function(i, n){
1242          *   alert( "Name: " + i + ", Value: " + n );
1243          * });
1244          *
1245          * @desc This is an example of iterating over the properties in an
1246          * Object, accessing both the current item and its key.
1247          *
1248          * @name $.each
1249          * @param Object obj The object, or array, to iterate over.
1250          * @param Function fn The function that will be executed on every object.
1251          * @type Object
1252          * @cat JavaScript
1253          */
1254         // args is for internal usage only
1255         each: function( obj, fn, args ) {
1256                 if ( obj.length == undefined )
1257                         for ( var i in obj )
1258                                 fn.apply( obj[i], args || [i, obj[i]] );
1259                 else
1260                         for ( var i = 0, ol = obj.length; i < ol; i++ )
1261                                 if ( fn.apply( obj[i], args || [i, obj[i]] ) === false ) break;
1262                 return obj;
1263         },
1264         
1265         prop: function(elem, value, type, index, prop){
1266                         // Handle executable functions
1267                         if ( jQuery.isFunction( value ) )
1268                                 return value.call( elem, [index] );
1269                                 
1270                         // exclude the following css properties to add px
1271                         var exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i;
1272
1273                         // Handle passing in a number to a CSS property
1274                         if ( value.constructor == Number && type == "curCSS" && !exclude.test(prop) )
1275                                 return value + "px";
1276
1277                         return value;
1278         },
1279
1280         className: {
1281                 // internal only, use addClass("class")
1282                 add: function( elem, c ){
1283                         jQuery.each( c.split(/\s+/), function(i, cur){
1284                                 if ( !jQuery.className.has( elem.className, cur ) )
1285                                         elem.className += ( elem.className ? " " : "" ) + cur;
1286                         });
1287                 },
1288
1289                 // internal only, use removeClass("class")
1290                 remove: function( elem, c ){
1291                         elem.className = c ?
1292                                 jQuery.grep( elem.className.split(/\s+/), function(cur){
1293                                         return !jQuery.className.has( c, cur ); 
1294                                 }).join(" ") : "";
1295                 },
1296
1297                 // internal only, use is(".class")
1298                 has: function( t, c ) {
1299                         t = t.className || t;
1300                         return t && new RegExp("(^|\\s)" + c + "(\\s|$)").test( t );
1301                 }
1302         },
1303
1304         /**
1305          * Swap in/out style options.
1306          * @private
1307          */
1308         swap: function(e,o,f) {
1309                 for ( var i in o ) {
1310                         e.style["old"+i] = e.style[i];
1311                         e.style[i] = o[i];
1312                 }
1313                 f.apply( e, [] );
1314                 for ( var i in o )
1315                         e.style[i] = e.style["old"+i];
1316         },
1317
1318         css: function(e,p) {
1319                 if ( p == "height" || p == "width" ) {
1320                         var old = {}, oHeight, oWidth, d = ["Top","Bottom","Right","Left"];
1321
1322                         jQuery.each( d, function(){
1323                                 old["padding" + this] = 0;
1324                                 old["border" + this + "Width"] = 0;
1325                         });
1326
1327                         jQuery.swap( e, old, function() {
1328                                 if (jQuery.css(e,"display") != "none") {
1329                                         oHeight = e.offsetHeight;
1330                                         oWidth = e.offsetWidth;
1331                                 } else {
1332                                         e = jQuery(e.cloneNode(true))
1333                                                 .find(":radio").removeAttr("checked").end()
1334                                                 .css({
1335                                                         visibility: "hidden", position: "absolute", display: "block", right: "0", left: "0"
1336                                                 }).appendTo(e.parentNode)[0];
1337
1338                                         var parPos = jQuery.css(e.parentNode,"position");
1339                                         if ( parPos == "" || parPos == "static" )
1340                                                 e.parentNode.style.position = "relative";
1341
1342                                         oHeight = e.clientHeight;
1343                                         oWidth = e.clientWidth;
1344
1345                                         if ( parPos == "" || parPos == "static" )
1346                                                 e.parentNode.style.position = "static";
1347
1348                                         e.parentNode.removeChild(e);
1349                                 }
1350                         });
1351
1352                         return p == "height" ? oHeight : oWidth;
1353                 }
1354
1355                 return jQuery.curCSS( e, p );
1356         },
1357
1358         curCSS: function(elem, prop, force) {
1359                 var ret;
1360                 
1361                 if (prop == "opacity" && jQuery.browser.msie)
1362                         return jQuery.attr(elem.style, "opacity");
1363                         
1364                 if (prop == "float" || prop == "cssFloat")
1365                     prop = jQuery.browser.msie ? "styleFloat" : "cssFloat";
1366
1367                 if (!force && elem.style[prop])
1368                         ret = elem.style[prop];
1369
1370                 else if (document.defaultView && document.defaultView.getComputedStyle) {
1371
1372                         if (prop == "cssFloat" || prop == "styleFloat")
1373                                 prop = "float";
1374
1375                         prop = prop.replace(/([A-Z])/g,"-$1").toLowerCase();
1376                         var cur = document.defaultView.getComputedStyle(elem, null);
1377
1378                         if ( cur )
1379                                 ret = cur.getPropertyValue(prop);
1380                         else if ( prop == "display" )
1381                                 ret = "none";
1382                         else
1383                                 jQuery.swap(elem, { display: "block" }, function() {
1384                                     var c = document.defaultView.getComputedStyle(this, "");
1385                                     ret = c && c.getPropertyValue(prop) || "";
1386                                 });
1387
1388                 } else if (elem.currentStyle) {
1389
1390                         var newProp = prop.replace(/\-(\w)/g,function(m,c){return c.toUpperCase();});
1391                         ret = elem.currentStyle[prop] || elem.currentStyle[newProp];
1392                         
1393                 }
1394
1395                 return ret;
1396         },
1397         
1398         clean: function(a) {
1399                 var r = [];
1400
1401                 jQuery.each( a, function(i,arg){
1402                         if ( !arg ) return;
1403
1404                         if ( arg.constructor == Number )
1405                                 arg = arg.toString();
1406                         
1407                          // Convert html string into DOM nodes
1408                         if ( typeof arg == "string" ) {
1409                                 // Trim whitespace, otherwise indexOf won't work as expected
1410                                 var s = jQuery.trim(arg), div = document.createElement("div"), tb = [];
1411
1412                                 var wrap =
1413                                          // option or optgroup
1414                                         !s.indexOf("<opt") &&
1415                                         [1, "<select>", "</select>"] ||
1416                                         
1417                                         (!s.indexOf("<thead") || !s.indexOf("<tbody") || !s.indexOf("<tfoot")) &&
1418                                         [1, "<table>", "</table>"] ||
1419                                         
1420                                         !s.indexOf("<tr") &&
1421                                         [2, "<table><tbody>", "</tbody></table>"] ||
1422                                         
1423                                         // <thead> matched above
1424                                         (!s.indexOf("<td") || !s.indexOf("<th")) &&
1425                                         [3, "<table><tbody><tr>", "</tr></tbody></table>"] ||
1426                                         
1427                                         [0,"",""];
1428
1429                                 // Go to html and back, then peel off extra wrappers
1430                                 div.innerHTML = wrap[1] + s + wrap[2];
1431                                 
1432                                 // Move to the right depth
1433                                 while ( wrap[0]-- )
1434                                         div = div.firstChild;
1435                                 
1436                                 // Remove IE's autoinserted <tbody> from table fragments
1437                                 if ( jQuery.browser.msie ) {
1438                                         
1439                                         // String was a <table>, *may* have spurious <tbody>
1440                                         if ( !s.indexOf("<table") && s.indexOf("<tbody") < 0 ) 
1441                                                 tb = div.firstChild && div.firstChild.childNodes;
1442                                                 
1443                                         // String was a bare <thead> or <tfoot>
1444                                         else if ( wrap[1] == "<table>" && s.indexOf("<tbody") < 0 )
1445                                                 tb = div.childNodes;
1446
1447                                         for ( var n = tb.length-1; n >= 0 ; --n )
1448                                                 if ( tb[n].nodeName.toUpperCase() == "TBODY" && !tb[n].childNodes.length )
1449                                                         tb[n].parentNode.removeChild(tb[n]);
1450                                         
1451                                 }
1452                                 
1453                                 arg = div.childNodes;
1454                         }
1455
1456                         if ( arg.length === 0 )
1457                                 return;
1458                         
1459                         if ( arg[0] == undefined )
1460                                 r.push( arg );
1461                         else
1462                                 r = jQuery.merge( r, arg );
1463
1464                 });
1465
1466                 return r;
1467         },
1468         
1469         attr: function(elem, name, value){
1470                 var fix = {
1471                         "for": "htmlFor",
1472                         "class": "className",
1473                         "float": jQuery.browser.msie ? "styleFloat" : "cssFloat",
1474                         cssFloat: jQuery.browser.msie ? "styleFloat" : "cssFloat",
1475                         innerHTML: "innerHTML",
1476                         className: "className",
1477                         value: "value",
1478                         disabled: "disabled",
1479                         checked: "checked",
1480                         readonly: "readOnly",
1481                         selected: "selected"
1482                 };
1483                 
1484                 // IE actually uses filters for opacity ... elem is actually elem.style
1485                 if ( name == "opacity" && jQuery.browser.msie && value != undefined ) {
1486                         // IE has trouble with opacity if it does not have layout
1487                         // Force it by setting the zoom level
1488                         elem.zoom = 1; 
1489
1490                         // Set the alpha filter to set the opacity
1491                         return elem.filter = elem.filter.replace(/alpha\([^\)]*\)/gi,"") +
1492                                 ( value == 1 ? "" : "alpha(opacity=" + value * 100 + ")" );
1493
1494                 } else if ( name == "opacity" && jQuery.browser.msie )
1495                         return elem.filter ? 
1496                                 parseFloat( elem.filter.match(/alpha\(opacity=(.*)\)/)[1] ) / 100 : 1;
1497                 
1498                 // Mozilla doesn't play well with opacity 1
1499                 if ( name == "opacity" && jQuery.browser.mozilla && value == 1 )
1500                         value = 0.9999;
1501
1502                 // Certain attributes only work when accessed via the old DOM 0 way
1503                 if ( fix[name] ) {
1504                         if ( value != undefined ) elem[fix[name]] = value;
1505                         return elem[fix[name]];
1506
1507                 } else if ( value == undefined && jQuery.browser.msie && elem.nodeName && elem.nodeName.toUpperCase() == "FORM" && (name == "action" || name == "method") )
1508                         return elem.getAttributeNode(name).nodeValue;
1509
1510                 // IE elem.getAttribute passes even for style
1511                 else if ( elem.tagName ) {
1512                         if ( value != undefined ) elem.setAttribute( name, value );
1513                         return elem.getAttribute( name );
1514
1515                 } else {
1516                         name = name.replace(/-([a-z])/ig,function(z,b){return b.toUpperCase();});
1517                         if ( value != undefined ) elem[name] = value;
1518                         return elem[name];
1519                 }
1520         },
1521         
1522         /**
1523          * Remove the whitespace from the beginning and end of a string.
1524          *
1525          * @example $.trim("  hello, how are you?  ");
1526          * @result "hello, how are you?"
1527          *
1528          * @name $.trim
1529          * @type String
1530          * @param String str The string to trim.
1531          * @cat JavaScript
1532          */
1533         trim: function(t){
1534                 return t.replace(/^\s+|\s+$/g, "");
1535         },
1536
1537         makeArray: function( a ) {
1538                 var r = [];
1539
1540                 if ( a.constructor != Array )
1541                         for ( var i = 0, al = a.length; i < al; i++ )
1542                                 r.push( a[i] );
1543                 else
1544                         r = a.slice( 0 );
1545
1546                 return r;
1547         },
1548
1549         inArray: function( b, a ) {
1550                 for ( var i = 0, al = a.length; i < al; i++ )
1551                         if ( a[i] == b )
1552                                 return i;
1553                 return -1;
1554         },
1555
1556         /**
1557          * Merge two arrays together, removing all duplicates.
1558          *
1559          * The result is the altered first argument with
1560          * the unique elements from the second array added.
1561          *
1562          * @example $.merge( [0,1,2], [2,3,4] )
1563          * @result [0,1,2,3,4]
1564          * @desc Merges two arrays, removing the duplicate 2
1565          *
1566          * @example var array = [3,2,1];
1567          * $.merge( array, [4,3,2] )
1568          * @result array == [3,2,1,4]
1569          * @desc Merges two arrays, removing the duplicates 3 and 2
1570          *
1571          * @name $.merge
1572          * @type Array
1573          * @param Array first The first array to merge, the unique elements of second added.
1574          * @param Array second The second array to merge into the first, unaltered.
1575          * @cat JavaScript
1576          */
1577         merge: function(first, second) {
1578                 var r = [].slice.call( first, 0 );
1579
1580                 // Now check for duplicates between the two arrays
1581                 // and only add the unique items
1582                 for ( var i = 0, sl = second.length; i < sl; i++ )
1583                         // Check for duplicates
1584                         if ( jQuery.inArray( second[i], r ) == -1 )
1585                                 // The item is unique, add it
1586                                 first.push( second[i] );
1587
1588                 return first;
1589         },
1590
1591         /**
1592          * Filter items out of an array, by using a filter function.
1593          *
1594          * The specified function will be passed two arguments: The
1595          * current array item and the index of the item in the array. The
1596          * function must return 'true' to keep the item in the array, 
1597          * false to remove it.
1598          *
1599          * @example $.grep( [0,1,2], function(i){
1600          *   return i > 0;
1601          * });
1602          * @result [1, 2]
1603          *
1604          * @name $.grep
1605          * @type Array
1606          * @param Array array The Array to find items in.
1607          * @param Function fn The function to process each item against.
1608          * @param Boolean inv Invert the selection - select the opposite of the function.
1609          * @cat JavaScript
1610          */
1611         grep: function(elems, fn, inv) {
1612                 // If a string is passed in for the function, make a function
1613                 // for it (a handy shortcut)
1614                 if ( typeof fn == "string" )
1615                         fn = new Function("a","i","return " + fn);
1616
1617                 var result = [];
1618
1619                 // Go through the array, only saving the items
1620                 // that pass the validator function
1621                 for ( var i = 0, el = elems.length; i < el; i++ )
1622                         if ( !inv && fn(elems[i],i) || inv && !fn(elems[i],i) )
1623                                 result.push( elems[i] );
1624
1625                 return result;
1626         },
1627
1628         /**
1629          * Translate all items in an array to another array of items.
1630          *
1631          * The translation function that is provided to this method is 
1632          * called for each item in the array and is passed one argument: 
1633          * The item to be translated.
1634          *
1635          * The function can then return the translated value, 'null'
1636          * (to remove the item), or  an array of values - which will
1637          * be flattened into the full array.
1638          *
1639          * @example $.map( [0,1,2], function(i){
1640          *   return i + 4;
1641          * });
1642          * @result [4, 5, 6]
1643          * @desc Maps the original array to a new one and adds 4 to each value.
1644          *
1645          * @example $.map( [0,1,2], function(i){
1646          *   return i > 0 ? i + 1 : null;
1647          * });
1648          * @result [2, 3]
1649          * @desc Maps the original array to a new one and adds 1 to each
1650          * value if it is bigger then zero, otherwise it's removed-
1651          * 
1652          * @example $.map( [0,1,2], function(i){
1653          *   return [ i, i + 1 ];
1654          * });
1655          * @result [0, 1, 1, 2, 2, 3]
1656          * @desc Maps the original array to a new one, each element is added
1657          * with it's original value and the value plus one.
1658          *
1659          * @name $.map
1660          * @type Array
1661          * @param Array array The Array to translate.
1662          * @param Function fn The function to process each item against.
1663          * @cat JavaScript
1664          */
1665         map: function(elems, fn) {
1666                 // If a string is passed in for the function, make a function
1667                 // for it (a handy shortcut)
1668                 if ( typeof fn == "string" )
1669                         fn = new Function("a","return " + fn);
1670
1671                 var result = [], r = [];
1672
1673                 // Go through the array, translating each of the items to their
1674                 // new value (or values).
1675                 for ( var i = 0, el = elems.length; i < el; i++ ) {
1676                         var val = fn(elems[i],i);
1677
1678                         if ( val !== null && val != undefined ) {
1679                                 if ( val.constructor != Array ) val = [val];
1680                                 result = result.concat( val );
1681                         }
1682                 }
1683
1684                 var r = result.length ? [ result[0] ] : [];
1685
1686                 check: for ( var i = 1, rl = result.length; i < rl; i++ ) {
1687                         for ( var j = 0; j < i; j++ )
1688                                 if ( result[i] == r[j] )
1689                                         continue check;
1690
1691                         r.push( result[i] );
1692                 }
1693
1694                 return r;
1695         }
1696 });
1697
1698 /**
1699  * Contains flags for the useragent, read from navigator.userAgent.
1700  * Available flags are: safari, opera, msie, mozilla
1701  *
1702  * This property is available before the DOM is ready, therefore you can
1703  * use it to add ready events only for certain browsers.
1704  *
1705  * There are situations where object detections is not reliable enough, in that
1706  * cases it makes sense to use browser detection. Simply try to avoid both!
1707  *
1708  * A combination of browser and object detection yields quite reliable results.
1709  *
1710  * @example $.browser.msie
1711  * @desc Returns true if the current useragent is some version of microsoft's internet explorer
1712  *
1713  * @example if($.browser.safari) { $( function() { alert("this is safari!"); } ); }
1714  * @desc Alerts "this is safari!" only for safari browsers
1715  *
1716  * @property
1717  * @name $.browser
1718  * @type Boolean
1719  * @cat JavaScript
1720  */
1721  
1722 /*
1723  * Whether the W3C compliant box model is being used.
1724  *
1725  * @property
1726  * @name $.boxModel
1727  * @type Boolean
1728  * @cat JavaScript
1729  */
1730 new function() {
1731         var b = navigator.userAgent.toLowerCase();
1732
1733         // Figure out what browser is being used
1734         jQuery.browser = {
1735                 safari: /webkit/.test(b),
1736                 opera: /opera/.test(b),
1737                 msie: /msie/.test(b) && !/opera/.test(b),
1738                 mozilla: /mozilla/.test(b) && !/(compatible|webkit)/.test(b)
1739         };
1740
1741         // Check to see if the W3C box model is being used
1742         jQuery.boxModel = !jQuery.browser.msie || document.compatMode == "CSS1Compat";
1743 };
1744
1745 /**
1746  * Get a set of elements containing the unique parents of the matched
1747  * set of elements.
1748  *
1749  * Can be filtered with an optional expressions.
1750  *
1751  * @example $("p").parent()
1752  * @before <div><p>Hello</p><p>Hello</p></div>
1753  * @result [ <div><p>Hello</p><p>Hello</p></div> ]
1754  * @desc Find the parent element of each paragraph.
1755  *
1756  * @example $("p").parent(".selected")
1757  * @before <div><p>Hello</p></div><div class="selected"><p>Hello Again</p></div>
1758  * @result [ <div class="selected"><p>Hello Again</p></div> ]
1759  * @desc Find the parent element of each paragraph with a class "selected".
1760  *
1761  * @name parent
1762  * @type jQuery
1763  * @param String expr (optional) An expression to filter the parents with
1764  * @cat DOM/Traversing
1765  */
1766
1767 /**
1768  * Get a set of elements containing the unique ancestors of the matched
1769  * set of elements (except for the root element).
1770  *
1771  * Can be filtered with an optional expressions.
1772  *
1773  * @example $("span").parents()
1774  * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html>
1775  * @result [ <body>...</body>, <div>...</div>, <p><span>Hello</span></p> ]
1776  * @desc Find all parent elements of each span.
1777  *
1778  * @example $("span").parents("p")
1779  * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html>
1780  * @result [ <p><span>Hello</span></p> ]
1781  * @desc Find all parent elements of each span that is a paragraph.
1782  *
1783  * @name parents
1784  * @type jQuery
1785  * @param String expr (optional) An expression to filter the ancestors with
1786  * @cat DOM/Traversing
1787  */
1788
1789 /**
1790  * Get a set of elements containing the unique next siblings of each of the
1791  * matched set of elements.
1792  *
1793  * It only returns the very next sibling, not all next siblings.
1794  *
1795  * Can be filtered with an optional expressions.
1796  *
1797  * @example $("p").next()
1798  * @before <p>Hello</p><p>Hello Again</p><div><span>And Again</span></div>
1799  * @result [ <p>Hello Again</p>, <div><span>And Again</span></div> ]
1800  * @desc Find the very next sibling of each paragraph.
1801  *
1802  * @example $("p").next(".selected")
1803  * @before <p>Hello</p><p class="selected">Hello Again</p><div><span>And Again</span></div>
1804  * @result [ <p class="selected">Hello Again</p> ]
1805  * @desc Find the very next sibling of each paragraph that has a class "selected".
1806  *
1807  * @name next
1808  * @type jQuery
1809  * @param String expr (optional) An expression to filter the next Elements with
1810  * @cat DOM/Traversing
1811  */
1812
1813 /**
1814  * Get a set of elements containing the unique previous siblings of each of the
1815  * matched set of elements.
1816  *
1817  * Can be filtered with an optional expressions.
1818  *
1819  * It only returns the immediately previous sibling, not all previous siblings.
1820  *
1821  * @example $("p").prev()
1822  * @before <p>Hello</p><div><span>Hello Again</span></div><p>And Again</p>
1823  * @result [ <div><span>Hello Again</span></div> ]
1824  * @desc Find the very previous sibling of each paragraph.
1825  *
1826  * @example $("p").prev(".selected")
1827  * @before <div><span>Hello</span></div><p class="selected">Hello Again</p><p>And Again</p>
1828  * @result [ <div><span>Hello</span></div> ]
1829  * @desc Find the very previous sibling of each paragraph that has a class "selected".
1830  *
1831  * @name prev
1832  * @type jQuery
1833  * @param String expr (optional) An expression to filter the previous Elements with
1834  * @cat DOM/Traversing
1835  */
1836
1837 /**
1838  * Get a set of elements containing all of the unique siblings of each of the
1839  * matched set of elements.
1840  *
1841  * Can be filtered with an optional expressions.
1842  *
1843  * @example $("div").siblings()
1844  * @before <p>Hello</p><div><span>Hello Again</span></div><p>And Again</p>
1845  * @result [ <p>Hello</p>, <p>And Again</p> ]
1846  * @desc Find all siblings of each div.
1847  *
1848  * @example $("div").siblings(".selected")
1849  * @before <div><span>Hello</span></div><p class="selected">Hello Again</p><p>And Again</p>
1850  * @result [ <p class="selected">Hello Again</p> ]
1851  * @desc Find all siblings with a class "selected" of each div.
1852  *
1853  * @name siblings
1854  * @type jQuery
1855  * @param String expr (optional) An expression to filter the sibling Elements with
1856  * @cat DOM/Traversing
1857  */
1858
1859 /**
1860  * Get a set of elements containing all of the unique children of each of the
1861  * matched set of elements.
1862  *
1863  * Can be filtered with an optional expressions.
1864  *
1865  * @example $("div").children()
1866  * @before <p>Hello</p><div><span>Hello Again</span></div><p>And Again</p>
1867  * @result [ <span>Hello Again</span> ]
1868  * @desc Find all children of each div.
1869  *
1870  * @example $("div").children(".selected")
1871  * @before <div><span>Hello</span><p class="selected">Hello Again</p><p>And Again</p></div>
1872  * @result [ <p class="selected">Hello Again</p> ]
1873  * @desc Find all children with a class "selected" of each div.
1874  *
1875  * @name children
1876  * @type jQuery
1877  * @param String expr (optional) An expression to filter the child Elements with
1878  * @cat DOM/Traversing
1879  */
1880 jQuery.each({
1881         parent: "a.parentNode",
1882         parents: "jQuery.parents(a)",
1883         next: "jQuery.nth(a,2,'nextSibling')",
1884         prev: "jQuery.nth(a,2,'previousSibling')",
1885         siblings: "jQuery.sibling(a.parentNode.firstChild,a)",
1886         children: "jQuery.sibling(a.firstChild)"
1887 }, function(i,n){
1888         jQuery.fn[ i ] = function(a) {
1889                 var ret = jQuery.map(this,n);
1890                 if ( a && typeof a == "string" )
1891                         ret = jQuery.multiFilter(a,ret);
1892                 return this.pushStack( ret );
1893         };
1894 });
1895
1896 /**
1897  * Append all of the matched elements to another, specified, set of elements.
1898  * This operation is, essentially, the reverse of doing a regular
1899  * $(A).append(B), in that instead of appending B to A, you're appending
1900  * A to B.
1901  *
1902  * @example $("p").appendTo("#foo");
1903  * @before <p>I would like to say: </p><div id="foo"></div>
1904  * @result <div id="foo"><p>I would like to say: </p></div>
1905  * @desc Appends all paragraphs to the element with the ID "foo"
1906  *
1907  * @name appendTo
1908  * @type jQuery
1909  * @param <Content> content Content to append to the selected element to.
1910  * @cat DOM/Manipulation
1911  * @see append(<Content>)
1912  */
1913
1914 /**
1915  * Prepend all of the matched elements to another, specified, set of elements.
1916  * This operation is, essentially, the reverse of doing a regular
1917  * $(A).prepend(B), in that instead of prepending B to A, you're prepending
1918  * A to B.
1919  *
1920  * @example $("p").prependTo("#foo");
1921  * @before <p>I would like to say: </p><div id="foo"><b>Hello</b></div>
1922  * @result <div id="foo"><p>I would like to say: </p><b>Hello</b></div>
1923  * @desc Prepends all paragraphs to the element with the ID "foo"
1924  *
1925  * @name prependTo
1926  * @type jQuery
1927  * @param <Content> content Content to prepend to the selected element to.
1928  * @cat DOM/Manipulation
1929  * @see prepend(<Content>)
1930  */
1931
1932 /**
1933  * Insert all of the matched elements before another, specified, set of elements.
1934  * This operation is, essentially, the reverse of doing a regular
1935  * $(A).before(B), in that instead of inserting B before A, you're inserting
1936  * A before B.
1937  *
1938  * @example $("p").insertBefore("#foo");
1939  * @before <div id="foo">Hello</div><p>I would like to say: </p>
1940  * @result <p>I would like to say: </p><div id="foo">Hello</div>
1941  * @desc Same as $("#foo").before("p")
1942  *
1943  * @name insertBefore
1944  * @type jQuery
1945  * @param <Content> content Content to insert the selected element before.
1946  * @cat DOM/Manipulation
1947  * @see before(<Content>)
1948  */
1949
1950 /**
1951  * Insert all of the matched elements after another, specified, set of elements.
1952  * This operation is, essentially, the reverse of doing a regular
1953  * $(A).after(B), in that instead of inserting B after A, you're inserting
1954  * A after B.
1955  *
1956  * @example $("p").insertAfter("#foo");
1957  * @before <p>I would like to say: </p><div id="foo">Hello</div>
1958  * @result <div id="foo">Hello</div><p>I would like to say: </p>
1959  * @desc Same as $("#foo").after("p")
1960  *
1961  * @name insertAfter
1962  * @type jQuery
1963  * @param <Content> content Content to insert the selected element after.
1964  * @cat DOM/Manipulation
1965  * @see after(<Content>)
1966  */
1967
1968 jQuery.each({
1969         appendTo: "append",
1970         prependTo: "prepend",
1971         insertBefore: "before",
1972         insertAfter: "after"
1973 }, function(i,n){
1974         jQuery.fn[ i ] = function(){
1975                 var a = arguments;
1976                 return this.each(function(){
1977                         for ( var j = 0, al = a.length; j < al; j++ )
1978                                 jQuery(a[j])[n]( this );
1979                 });
1980         };
1981 });
1982
1983 /**
1984  * Remove an attribute from each of the matched elements.
1985  *
1986  * @example $("input").removeAttr("disabled")
1987  * @before <input disabled="disabled"/>
1988  * @result <input/>
1989  *
1990  * @name removeAttr
1991  * @type jQuery
1992  * @param String name The name of the attribute to remove.
1993  * @cat DOM/Attributes
1994  */
1995
1996 /**
1997  * Adds the specified class(es) to each of the set of matched elements.
1998  *
1999  * @example $("p").addClass("selected")
2000  * @before <p>Hello</p>
2001  * @result [ <p class="selected">Hello</p> ]
2002  *
2003  * @example $("p").addClass("selected highlight")
2004  * @before <p>Hello</p>
2005  * @result [ <p class="selected highlight">Hello</p> ]
2006  *
2007  * @name addClass
2008  * @type jQuery
2009  * @param String class One or more CSS classes to add to the elements
2010  * @cat DOM/Attributes
2011  * @see removeClass(String)
2012  */
2013
2014 /**
2015  * Removes all or the specified class(es) from the set of matched elements.
2016  *
2017  * @example $("p").removeClass()
2018  * @before <p class="selected">Hello</p>
2019  * @result [ <p>Hello</p> ]
2020  *
2021  * @example $("p").removeClass("selected")
2022  * @before <p class="selected first">Hello</p>
2023  * @result [ <p class="first">Hello</p> ]
2024  *
2025  * @example $("p").removeClass("selected highlight")
2026  * @before <p class="highlight selected first">Hello</p>
2027  * @result [ <p class="first">Hello</p> ]
2028  *
2029  * @name removeClass
2030  * @type jQuery
2031  * @param String class (optional) One or more CSS classes to remove from the elements
2032  * @cat DOM/Attributes
2033  * @see addClass(String)
2034  */
2035
2036 /**
2037  * Adds the specified class if it is not present, removes it if it is
2038  * present.
2039  *
2040  * @example $("p").toggleClass("selected")
2041  * @before <p>Hello</p><p class="selected">Hello Again</p>
2042  * @result [ <p class="selected">Hello</p>, <p>Hello Again</p> ]
2043  *
2044  * @name toggleClass
2045  * @type jQuery
2046  * @param String class A CSS class with which to toggle the elements
2047  * @cat DOM/Attributes
2048  */
2049
2050 /**
2051  * Removes all matched elements from the DOM. This does NOT remove them from the
2052  * jQuery object, allowing you to use the matched elements further.
2053  *
2054  * Can be filtered with an optional expressions.
2055  *
2056  * @example $("p").remove();
2057  * @before <p>Hello</p> how are <p>you?</p>
2058  * @result how are
2059  *
2060  * @example $("p").remove(".hello");
2061  * @before <p class="hello">Hello</p> how are <p>you?</p>
2062  * @result how are <p>you?</p>
2063  *
2064  * @name remove
2065  * @type jQuery
2066  * @param String expr (optional) A jQuery expression to filter elements by.
2067  * @cat DOM/Manipulation
2068  */
2069
2070 /**
2071  * Removes all child nodes from the set of matched elements.
2072  *
2073  * @example $("p").empty()
2074  * @before <p>Hello, <span>Person</span> <a href="#">and person</a></p>
2075  * @result [ <p></p> ]
2076  *
2077  * @name empty
2078  * @type jQuery
2079  * @cat DOM/Manipulation
2080  */
2081
2082 jQuery.each( {
2083         removeAttr: function( key ) {
2084                 jQuery.attr( this, key, "" );
2085                 this.removeAttribute( key );
2086         },
2087         addClass: function(c){
2088                 jQuery.className.add(this,c);
2089         },
2090         removeClass: function(c){
2091                 jQuery.className.remove(this,c);
2092         },
2093         toggleClass: function( c ){
2094                 jQuery.className[ jQuery.className.has(this,c) ? "remove" : "add" ](this, c);
2095         },
2096         remove: function(a){
2097                 if ( !a || jQuery.filter( a, [this] ).r.length )
2098                         this.parentNode.removeChild( this );
2099         },
2100         empty: function() {
2101                 while ( this.firstChild )
2102                         this.removeChild( this.firstChild );
2103         }
2104 }, function(i,n){
2105         jQuery.fn[ i ] = function() {
2106                 return this.each( n, arguments );
2107         };
2108 });
2109
2110 /**
2111  * Reduce the set of matched elements to a single element.
2112  * The position of the element in the set of matched elements
2113  * starts at 0 and goes to length - 1.
2114  *
2115  * @example $("p").eq(1)
2116  * @before <p>This is just a test.</p><p>So is this</p>
2117  * @result [ <p>So is this</p> ]
2118  *
2119  * @name eq
2120  * @type jQuery
2121  * @param Number pos The index of the element that you wish to limit to.
2122  * @cat Core
2123  */
2124
2125 /**
2126  * Reduce the set of matched elements to all elements before a given position.
2127  * The position of the element in the set of matched elements
2128  * starts at 0 and goes to length - 1.
2129  *
2130  * @example $("p").lt(1)
2131  * @before <p>This is just a test.</p><p>So is this</p>
2132  * @result [ <p>This is just a test.</p> ]
2133  *
2134  * @name lt
2135  * @type jQuery
2136  * @param Number pos Reduce the set to all elements below this position.
2137  * @cat Core
2138  */
2139
2140 /**
2141  * Reduce the set of matched elements to all elements after a given position.
2142  * The position of the element in the set of matched elements
2143  * starts at 0 and goes to length - 1.
2144  *
2145  * @example $("p").gt(0)
2146  * @before <p>This is just a test.</p><p>So is this</p>
2147  * @result [ <p>So is this</p> ]
2148  *
2149  * @name gt
2150  * @type jQuery
2151  * @param Number pos Reduce the set to all elements after this position.
2152  * @cat Core
2153  */
2154
2155 /**
2156  * Filter the set of elements to those that contain the specified text.
2157  *
2158  * @example $("p").contains("test")
2159  * @before <p>This is just a test.</p><p>So is this</p>
2160  * @result [ <p>This is just a test.</p> ]
2161  *
2162  * @name contains
2163  * @type jQuery
2164  * @param String str The string that will be contained within the text of an element.
2165  * @cat DOM/Traversing
2166  */
2167 jQuery.each( [ "eq", "lt", "gt", "contains" ], function(i,n){
2168         jQuery.fn[ n ] = function(num,fn) {
2169                 return this.filter( ":" + n + "(" + num + ")", fn );
2170         };
2171 });
2172
2173 /**
2174  * Get the current computed, pixel, width of the first matched element.
2175  *
2176  * @example $("p").width();
2177  * @before <p>This is just a test.</p>
2178  * @result 300
2179  *
2180  * @name width
2181  * @type String
2182  * @cat CSS
2183  */
2184
2185 /**
2186  * Set the CSS width of every matched element. If no explicit unit
2187  * was specified (like 'em' or '%') then "px" is added to the width.
2188  *
2189  * @example $("p").width(20);
2190  * @before <p>This is just a test.</p>
2191  * @result <p style="width:20px;">This is just a test.</p>
2192  *
2193  * @example $("p").width("20em");
2194  * @before <p>This is just a test.</p>
2195  * @result <p style="width:20em;">This is just a test.</p>
2196  *
2197  * @name width
2198  * @type jQuery
2199  * @param String|Number val Set the CSS property to the specified value.
2200  * @cat CSS
2201  */
2202  
2203 /**
2204  * Get the current computed, pixel, height of the first matched element.
2205  *
2206  * @example $("p").height();
2207  * @before <p>This is just a test.</p>
2208  * @result 300
2209  *
2210  * @name height
2211  * @type String
2212  * @cat CSS
2213  */
2214
2215 /**
2216  * Set the CSS width of every matched element. If no explicit unit
2217  * was specified (like 'em' or '%') then "px" is added to the width.
2218  *
2219  * @example $("p").height(20);
2220  * @before <p>This is just a test.</p>
2221  * @result <p style="height:20px;">This is just a test.</p>
2222  *
2223  * @example $("p").height("20em");
2224  * @before <p>This is just a test.</p>
2225  * @result <p style="height:20em;">This is just a test.</p>
2226  *
2227  * @name height
2228  * @type jQuery
2229  * @param String|Number val Set the CSS property to the specified value.
2230  * @cat CSS
2231  */
2232
2233 jQuery.each( [ "height", "width" ], function(i,n){
2234         jQuery.fn[ n ] = function(h) {
2235                 return h == undefined ?
2236                         ( this.length ? jQuery.css( this[0], n ) : null ) :
2237                         this.css( n, h.constructor == String ? h : h + "px" );
2238         };
2239 });