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