Fix/test for #861
[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         if ( jQuery.isFunction(a) )
36                 return new jQuery(document)[ jQuery.fn.ready ? "ready" : "load" ]( a );
37         
38         // Handle HTML strings
39         if ( typeof a  == "string" ) {
40                 // HANDLE: $(html) -> $(array)
41                 var m = /^[^<]*(<(.|\n)+>)[^>]*$/.exec(a);
42                 if ( m )
43                         a = jQuery.clean( [ m[1] ] );
44                 
45                 // HANDLE: $(expr)
46                 else
47                         return new jQuery( c ).find( a );
48         }
49         
50         return this.setArray(
51                 // HANDLE: $(array)
52                 a.constructor == Array && a ||
53
54                 // HANDLE: $(arraylike)
55                 // Watch for when an array-like object is passed as the selector
56                 (a.jquery || a.length && a != window && !a.nodeType && a[0] != undefined && a[0].nodeType) && jQuery.makeArray( a ) ||
57
58                 // HANDLE: $(*)
59                 [ a ] );
60 };
61
62 // Map over the $ in case of overwrite
63 if ( typeof $ != "undefined" )
64         jQuery._$ = $;
65         
66 // Map the jQuery namespace to the '$' one
67 var $ = jQuery;
68
69 /**
70  * This function accepts a string containing a CSS or
71  * basic XPath selector which is then used to match a set of elements.
72  *
73  * The core functionality of jQuery centers around this function.
74  * Everything in jQuery is based upon this, or uses this in some way.
75  * The most basic use of this function is to pass in an expression
76  * (usually consisting of CSS or XPath), which then finds all matching
77  * elements.
78  *
79  * By default, $() looks for DOM elements within the context of the
80  * current HTML document.
81  *
82  * @example $("div > p")
83  * @desc Finds all p elements that are children of a div element.
84  * @before <p>one</p> <div><p>two</p></div> <p>three</p>
85  * @result [ <p>two</p> ]
86  *
87  * @example $("input:radio", document.forms[0])
88  * @desc Searches for all inputs of type radio within the first form in the document
89  *
90  * @example $("div", xml.responseXML)
91  * @desc This finds all div elements within the specified XML document.
92  *
93  * @name $
94  * @param String expr An expression to search with
95  * @param Element|jQuery context (optional) A DOM Element, Document or jQuery to use as context
96  * @cat Core
97  * @type jQuery
98  * @see $(Element)
99  * @see $(Element<Array>)
100  */
101  
102 /**
103  * Create DOM elements on-the-fly from the provided String of raw HTML.
104  *
105  * @example $("<div><p>Hello</p></div>").appendTo("#body")
106  * @desc Creates a div element (and all of its contents) dynamically, 
107  * and appends it to the element with the ID of body. Internally, an
108  * element is created and it's innerHTML property set to the given markup.
109  * It is therefore both quite flexible and limited. 
110  *
111  * @name $
112  * @param String html A string of HTML to create on the fly.
113  * @cat Core
114  * @type jQuery
115  * @see appendTo(String)
116  */
117
118 /**
119  * Wrap jQuery functionality around a single or multiple DOM Element(s).
120  *
121  * This function also accepts XML Documents and Window objects
122  * as valid arguments (even though they are not DOM Elements).
123  *
124  * @example $(document.body).background( "black" );
125  * @desc Sets the background color of the page to black.
126  *
127  * @example $( myForm.elements ).hide()
128  * @desc Hides all the input elements within a form
129  *
130  * @name $
131  * @param Element|Array<Element> elems DOM element(s) to be encapsulated by a jQuery object.
132  * @cat Core
133  * @type jQuery
134  */
135
136 /**
137  * A shorthand for $(document).ready(), allowing you to bind a function
138  * to be executed when the DOM document has finished loading. This function
139  * behaves just like $(document).ready(), in that it should be used to wrap
140  * all of the other $() operations on your page. While this function is,
141  * technically, chainable - there really isn't much use for chaining against it.
142  * You can have as many $(document).ready events on your page as you like.
143  *
144  * See ready(Function) for details about the ready event. 
145  * 
146  * @example $(function(){
147  *   // Document is ready
148  * });
149  * @desc Executes the function when the DOM is ready to be used.
150  *
151  * @example jQuery(function($) {
152  *   // Your code using failsafe $ alias here...
153  * });
154  * @desc Uses both the shortcut for $(document).ready() and the argument
155  * to write failsafe jQuery code using the $ alias, without relying on the
156  * global alias.
157  *
158  * @name $
159  * @param Function fn The function to execute when the DOM is ready.
160  * @cat Core
161  * @type jQuery
162  * @see ready(Function)
163  */
164
165 jQuery.fn = jQuery.prototype = {
166         /**
167          * The current version of jQuery.
168          *
169          * @private
170          * @property
171          * @name jquery
172          * @type String
173          * @cat Core
174          */
175         jquery: "@VERSION",
176
177         /**
178          * The number of elements currently matched.
179          *
180          * @example $("img").length;
181          * @before <img src="test1.jpg"/> <img src="test2.jpg"/>
182          * @result 2
183          *
184          * @property
185          * @name length
186          * @type Number
187          * @cat Core
188          */
189
190         /**
191          * The number of elements currently matched.
192          *
193          * @example $("img").size();
194          * @before <img src="test1.jpg"/> <img src="test2.jpg"/>
195          * @result 2
196          *
197          * @name size
198          * @type Number
199          * @cat Core
200          */
201         size: function() {
202                 return this.length;
203         },
204         
205         length: 0,
206
207         /**
208          * Access all matched elements. This serves as a backwards-compatible
209          * way of accessing all matched elements (other than the jQuery object
210          * itself, which is, in fact, an array of elements).
211          *
212          * @example $("img").get();
213          * @before <img src="test1.jpg"/> <img src="test2.jpg"/>
214          * @result [ <img src="test1.jpg"/> <img src="test2.jpg"/> ]
215          * @desc Selects all images in the document and returns the DOM Elements as an Array
216          *
217          * @name get
218          * @type Array<Element>
219          * @cat Core
220          */
221
222         /**
223          * Access a single matched element. num is used to access the
224          * Nth element matched.
225          *
226          * @example $("img").get(0);
227          * @before <img src="test1.jpg"/> <img src="test2.jpg"/>
228          * @result [ <img src="test1.jpg"/> ]
229          * @desc Selects all images in the document and returns the first one
230          *
231          * @name get
232          * @type Element
233          * @param Number num Access the element in the Nth position.
234          * @cat Core
235          */
236         get: function( num ) {
237                 return num == undefined ?
238
239                         // Return a 'clean' array
240                         jQuery.makeArray( this ) :
241
242                         // Return just the object
243                         this[num];
244         },
245         
246         /**
247          * Set the jQuery object to an array of elements, while maintaining
248          * the stack.
249          *
250          * @example $("img").pushStack([ document.body ]);
251          * @result $("img").pushStack() == [ document.body ]
252          *
253          * @private
254          * @name pushStack
255          * @type jQuery
256          * @param Elements elems An array of elements
257          * @cat Core
258          */
259         pushStack: function( a ) {
260                 var ret = jQuery(a);
261                 ret.prevObject = this;
262                 //return ret.setArray( a );
263                 return ret;
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                 }), t );
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                                 return ( t.constructor == Array || t.jquery )
935                                         ? jQuery.inArray( a, t ) < 0
936                                         : a != t;
937                         })
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                         t.constructor == String ?
989                                 jQuery(t).get() :
990                                 t.length != undefined && (!t.nodeName || t.nodeName == "FORM") ?
991                                         t : [t] )
992                 );
993         },
994
995         /**
996          * Checks the current selection against an expression and returns true,
997          * if at least one element of the selection fits the given expression.
998          *
999          * Does return false, if no element fits or the expression is not valid.
1000          *
1001          * filter(String) is used internally, therefore all rules that apply there
1002          * apply here, too.
1003          *
1004          * @example $("input[@type='checkbox']").parent().is("form")
1005          * @before <form><input type="checkbox" /></form>
1006          * @result true
1007          * @desc Returns true, because the parent of the input is a form element
1008          * 
1009          * @example $("input[@type='checkbox']").parent().is("form")
1010          * @before <form><p><input type="checkbox" /></p></form>
1011          * @result false
1012          * @desc Returns false, because the parent of the input is a p element
1013          *
1014          * @name is
1015          * @type Boolean
1016          * @param String expr The expression with which to filter
1017          * @cat DOM/Traversing
1018          */
1019         is: function(expr) {
1020                 return expr ? jQuery.filter(expr,this).r.length > 0 : false;
1021         },
1022         
1023         /**
1024          * Get the current value of the first matched element.
1025          *
1026          * @example $("input").val();
1027          * @before <input type="text" value="some text"/>
1028          * @result "some text"
1029          *
1030          * @name val
1031          * @type String
1032          * @cat DOM/Attributes
1033          */
1034         
1035         /**
1036          * Set the value of every matched element.
1037          *
1038          * @example $("input").val("test");
1039          * @before <input type="text" value="some text"/>
1040          * @result <input type="text" value="test"/>
1041          *
1042          * @name val
1043          * @type jQuery
1044          * @param String val Set the property to the specified value.
1045          * @cat DOM/Attributes
1046          */
1047         val: function( val ) {
1048                 return val == undefined ?
1049                         ( this.length ? this[0].value : null ) :
1050                         this.attr( "value", val );
1051         },
1052         
1053         /**
1054          * Get the html contents of the first matched element.
1055          * This property is not available on XML documents.
1056          *
1057          * @example $("div").html();
1058          * @before <div><input/></div>
1059          * @result <input/>
1060          *
1061          * @name html
1062          * @type String
1063          * @cat DOM/Attributes
1064          */
1065         
1066         /**
1067          * Set the html contents of every matched element.
1068          * This property is not available on XML documents.
1069          *
1070          * @example $("div").html("<b>new stuff</b>");
1071          * @before <div><input/></div>
1072          * @result <div><b>new stuff</b></div>
1073          *
1074          * @name html
1075          * @type jQuery
1076          * @param String val Set the html contents to the specified value.
1077          * @cat DOM/Attributes
1078          */
1079         html: function( val ) {
1080                 return val == undefined ?
1081                         ( this.length ? this[0].innerHTML : null ) :
1082                         this.empty().append( val );
1083         },
1084         
1085         /**
1086          * @private
1087          * @name domManip
1088          * @param Array args
1089          * @param Boolean table Insert TBODY in TABLEs if one is not found.
1090          * @param Number dir If dir<0, process args in reverse order.
1091          * @param Function fn The function doing the DOM manipulation.
1092          * @type jQuery
1093          * @cat Core
1094          */
1095         domManip: function(args, table, dir, fn){
1096                 var clone = this.length > 1; 
1097                 var a = jQuery.clean(args);
1098                 if ( dir < 0 )
1099                         a.reverse();
1100
1101                 return this.each(function(){
1102                         var obj = this;
1103
1104                         if ( table && jQuery.nodeName(this, "table") && jQuery.nodeName(a[0], "tr") )
1105                                 obj = this.getElementsByTagName("tbody")[0] || this.appendChild(document.createElement("tbody"));
1106
1107                         jQuery.each( a, function(){
1108                                 fn.apply( obj, [ clone ? this.cloneNode(true) : this ] );
1109                         });
1110
1111                 });
1112         }
1113 };
1114
1115 /**
1116  * Extends the jQuery object itself. Can be used to add functions into
1117  * the jQuery namespace and to add plugin methods (plugins).
1118  * 
1119  * @example jQuery.fn.extend({
1120  *   check: function() {
1121  *     return this.each(function() { this.checked = true; });
1122  *   },
1123  *   uncheck: function() {
1124  *     return this.each(function() { this.checked = false; });
1125  *   }
1126  * });
1127  * $("input[@type=checkbox]").check();
1128  * $("input[@type=radio]").uncheck();
1129  * @desc Adds two plugin methods.
1130  *
1131  * @example jQuery.extend({
1132  *   min: function(a, b) { return a < b ? a : b; },
1133  *   max: function(a, b) { return a > b ? a : b; }
1134  * });
1135  * @desc Adds two functions into the jQuery namespace
1136  *
1137  * @name $.extend
1138  * @param Object prop The object that will be merged into the jQuery object
1139  * @type Object
1140  * @cat Core
1141  */
1142
1143 /**
1144  * Extend one object with one or more others, returning the original,
1145  * modified, object. This is a great utility for simple inheritance.
1146  * 
1147  * @example var settings = { validate: false, limit: 5, name: "foo" };
1148  * var options = { validate: true, name: "bar" };
1149  * jQuery.extend(settings, options);
1150  * @result settings == { validate: true, limit: 5, name: "bar" }
1151  * @desc Merge settings and options, modifying settings
1152  *
1153  * @example var defaults = { validate: false, limit: 5, name: "foo" };
1154  * var options = { validate: true, name: "bar" };
1155  * var settings = jQuery.extend({}, defaults, options);
1156  * @result settings == { validate: true, limit: 5, name: "bar" }
1157  * @desc Merge defaults and options, without modifying the defaults
1158  *
1159  * @name $.extend
1160  * @param Object target The object to extend
1161  * @param Object prop1 The object that will be merged into the first.
1162  * @param Object propN (optional) More objects to merge into the first
1163  * @type Object
1164  * @cat JavaScript
1165  */
1166 jQuery.extend = jQuery.fn.extend = function() {
1167         // copy reference to target object
1168         var target = arguments[0],
1169                 a = 1;
1170
1171         // extend jQuery itself if only one argument is passed
1172         if ( arguments.length == 1 ) {
1173                 target = this;
1174                 a = 0;
1175         }
1176         var prop;
1177         while (prop = arguments[a++])
1178                 // Extend the base object
1179                 for ( var i in prop ) target[i] = prop[i];
1180
1181         // Return the modified object
1182         return target;
1183 };
1184
1185 jQuery.extend({
1186         /**
1187          * Run this function to give control of the $ variable back
1188          * to whichever library first implemented it. This helps to make 
1189          * sure that jQuery doesn't conflict with the $ object
1190          * of other libraries.
1191          *
1192          * By using this function, you will only be able to access jQuery
1193          * using the 'jQuery' variable. For example, where you used to do
1194          * $("div p"), you now must do jQuery("div p").
1195          *
1196          * @example jQuery.noConflict();
1197          * // Do something with jQuery
1198          * jQuery("div p").hide();
1199          * // Do something with another library's $()
1200          * $("content").style.display = 'none';
1201          * @desc Maps the original object that was referenced by $ back to $
1202          *
1203          * @example jQuery.noConflict();
1204          * (function($) { 
1205          *   $(function() {
1206          *     // more code using $ as alias to jQuery
1207          *   });
1208          * })(jQuery);
1209          * // other code using $ as an alias to the other library
1210          * @desc Reverts the $ alias and then creates and executes a
1211          * function to provide the $ as a jQuery alias inside the functions
1212          * scope. Inside the function the original $ object is not available.
1213          * This works well for most plugins that don't rely on any other library.
1214          * 
1215          *
1216          * @name $.noConflict
1217          * @type undefined
1218          * @cat Core 
1219          */
1220         noConflict: function() {
1221                 if ( jQuery._$ )
1222                         $ = jQuery._$;
1223                 return jQuery;
1224         },
1225
1226         // This may seem like some crazy code, but trust me when I say that this
1227         // is the only cross-browser way to do this. --John
1228         isFunction: function( fn ) {
1229                 return !!fn && typeof fn != "string" &&
1230                         typeof fn[0] == "undefined" && /function/i.test( fn + "" );
1231         },
1232
1233         nodeName: function( elem, name ) {
1234                 return elem.nodeName && elem.nodeName.toUpperCase() == name.toUpperCase();
1235         },
1236
1237         /**
1238          * A generic iterator function, which can be used to seemlessly
1239          * iterate over both objects and arrays. This function is not the same
1240          * as $().each() - which is used to iterate, exclusively, over a jQuery
1241          * object. This function can be used to iterate over anything.
1242          *
1243          * The callback has two arguments:the key (objects) or index (arrays) as first
1244          * the first, and the value as the second.
1245          *
1246          * @example $.each( [0,1,2], function(i, n){
1247          *   alert( "Item #" + i + ": " + n );
1248          * });
1249          * @desc This is an example of iterating over the items in an array,
1250          * accessing both the current item and its index.
1251          *
1252          * @example $.each( { name: "John", lang: "JS" }, function(i, n){
1253          *   alert( "Name: " + i + ", Value: " + n );
1254          * });
1255          *
1256          * @desc This is an example of iterating over the properties in an
1257          * Object, accessing both the current item and its key.
1258          *
1259          * @name $.each
1260          * @param Object obj The object, or array, to iterate over.
1261          * @param Function fn The function that will be executed on every object.
1262          * @type Object
1263          * @cat JavaScript
1264          */
1265         // args is for internal usage only
1266         each: function( obj, fn, args ) {
1267                 if ( obj.length == undefined )
1268                         for ( var i in obj )
1269                                 fn.apply( obj[i], args || [i, obj[i]] );
1270                 else
1271                         for ( var i = 0, ol = obj.length; i < ol; i++ )
1272                                 if ( fn.apply( obj[i], args || [i, obj[i]] ) === false ) break;
1273                 return obj;
1274         },
1275         
1276         prop: function(elem, value, type, index, prop){
1277                         // Handle executable functions
1278                         if ( jQuery.isFunction( value ) )
1279                                 return value.call( elem, [index] );
1280                                 
1281                         // exclude the following css properties to add px
1282                         var exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i;
1283
1284                         // Handle passing in a number to a CSS property
1285                         if ( value.constructor == Number && type == "curCSS" && !exclude.test(prop) )
1286                                 return value + "px";
1287
1288                         return value;
1289         },
1290
1291         className: {
1292                 // internal only, use addClass("class")
1293                 add: function( elem, c ){
1294                         jQuery.each( c.split(/\s+/), function(i, cur){
1295                                 if ( !jQuery.className.has( elem.className, cur ) )
1296                                         elem.className += ( elem.className ? " " : "" ) + cur;
1297                         });
1298                 },
1299
1300                 // internal only, use removeClass("class")
1301                 remove: function( elem, c ){
1302                         elem.className = c ?
1303                                 jQuery.grep( elem.className.split(/\s+/), function(cur){
1304                                         return !jQuery.className.has( c, cur ); 
1305                                 }).join(" ") : "";
1306                 },
1307
1308                 // internal only, use is(".class")
1309                 has: function( t, c ) {
1310                         t = t.className || t;
1311                         return t && new RegExp("(^|\\s)" + c + "(\\s|$)").test( t );
1312                 }
1313         },
1314
1315         /**
1316          * Swap in/out style options.
1317          * @private
1318          */
1319         swap: function(e,o,f) {
1320                 for ( var i in o ) {
1321                         e.style["old"+i] = e.style[i];
1322                         e.style[i] = o[i];
1323                 }
1324                 f.apply( e, [] );
1325                 for ( var i in o )
1326                         e.style[i] = e.style["old"+i];
1327         },
1328
1329         css: function(e,p) {
1330                 if ( p == "height" || p == "width" ) {
1331                         var old = {}, oHeight, oWidth, d = ["Top","Bottom","Right","Left"];
1332
1333                         jQuery.each( d, function(){
1334                                 old["padding" + this] = 0;
1335                                 old["border" + this + "Width"] = 0;
1336                         });
1337
1338                         jQuery.swap( e, old, function() {
1339                                 if (jQuery.css(e,"display") != "none") {
1340                                         oHeight = e.offsetHeight;
1341                                         oWidth = e.offsetWidth;
1342                                 } else {
1343                                         e = jQuery(e.cloneNode(true))
1344                                                 .find(":radio").removeAttr("checked").end()
1345                                                 .css({
1346                                                         visibility: "hidden", position: "absolute", display: "block", right: "0", left: "0"
1347                                                 }).appendTo(e.parentNode)[0];
1348
1349                                         var parPos = jQuery.css(e.parentNode,"position");
1350                                         if ( parPos == "" || parPos == "static" )
1351                                                 e.parentNode.style.position = "relative";
1352
1353                                         oHeight = e.clientHeight;
1354                                         oWidth = e.clientWidth;
1355
1356                                         if ( parPos == "" || parPos == "static" )
1357                                                 e.parentNode.style.position = "static";
1358
1359                                         e.parentNode.removeChild(e);
1360                                 }
1361                         });
1362
1363                         return p == "height" ? oHeight : oWidth;
1364                 }
1365
1366                 return jQuery.curCSS( e, p );
1367         },
1368
1369         curCSS: function(elem, prop, force) {
1370                 var ret;
1371                 
1372                 if (prop == "opacity" && jQuery.browser.msie)
1373                         return jQuery.attr(elem.style, "opacity");
1374                         
1375                 if (prop == "float" || prop == "cssFloat")
1376                     prop = jQuery.browser.msie ? "styleFloat" : "cssFloat";
1377
1378                 if (!force && elem.style[prop])
1379                         ret = elem.style[prop];
1380
1381                 else if (document.defaultView && document.defaultView.getComputedStyle) {
1382
1383                         if (prop == "cssFloat" || prop == "styleFloat")
1384                                 prop = "float";
1385
1386                         prop = prop.replace(/([A-Z])/g,"-$1").toLowerCase();
1387                         var cur = document.defaultView.getComputedStyle(elem, null);
1388
1389                         if ( cur )
1390                                 ret = cur.getPropertyValue(prop);
1391                         else if ( prop == "display" )
1392                                 ret = "none";
1393                         else
1394                                 jQuery.swap(elem, { display: "block" }, function() {
1395                                     var c = document.defaultView.getComputedStyle(this, "");
1396                                     ret = c && c.getPropertyValue(prop) || "";
1397                                 });
1398
1399                 } else if (elem.currentStyle) {
1400
1401                         var newProp = prop.replace(/\-(\w)/g,function(m,c){return c.toUpperCase();});
1402                         ret = elem.currentStyle[prop] || elem.currentStyle[newProp];
1403                         
1404                 }
1405
1406                 return ret;
1407         },
1408         
1409         clean: function(a) {
1410                 var r = [];
1411
1412                 jQuery.each( a, function(i,arg){
1413                         if ( !arg ) return;
1414
1415                         if ( arg.constructor == Number )
1416                                 arg = arg.toString();
1417                         
1418                          // Convert html string into DOM nodes
1419                         if ( typeof arg == "string" ) {
1420                                 // Trim whitespace, otherwise indexOf won't work as expected
1421                                 var s = jQuery.trim(arg), div = document.createElement("div"), tb = [];
1422
1423                                 var wrap =
1424                                          // option or optgroup
1425                                         !s.indexOf("<opt") &&
1426                                         [1, "<select>", "</select>"] ||
1427                                         
1428                                         (!s.indexOf("<thead") || !s.indexOf("<tbody") || !s.indexOf("<tfoot")) &&
1429                                         [1, "<table>", "</table>"] ||
1430                                         
1431                                         !s.indexOf("<tr") &&
1432                                         [2, "<table><tbody>", "</tbody></table>"] ||
1433                                         
1434                                         // <thead> matched above
1435                                         (!s.indexOf("<td") || !s.indexOf("<th")) &&
1436                                         [3, "<table><tbody><tr>", "</tr></tbody></table>"] ||
1437                                         
1438                                         [0,"",""];
1439
1440                                 // Go to html and back, then peel off extra wrappers
1441                                 div.innerHTML = wrap[1] + s + wrap[2];
1442                                 
1443                                 // Move to the right depth
1444                                 while ( wrap[0]-- )
1445                                         div = div.firstChild;
1446                                 
1447                                 // Remove IE's autoinserted <tbody> from table fragments
1448                                 if ( jQuery.browser.msie ) {
1449                                         
1450                                         // String was a <table>, *may* have spurious <tbody>
1451                                         if ( !s.indexOf("<table") && s.indexOf("<tbody") < 0 ) 
1452                                                 tb = div.firstChild && div.firstChild.childNodes;
1453                                                 
1454                                         // String was a bare <thead> or <tfoot>
1455                                         else if ( wrap[1] == "<table>" && s.indexOf("<tbody") < 0 )
1456                                                 tb = div.childNodes;
1457
1458                                         for ( var n = tb.length-1; n >= 0 ; --n )
1459                                                 if ( jQuery.nodeName(tb[n], "tbody") && !tb[n].childNodes.length )
1460                                                         tb[n].parentNode.removeChild(tb[n]);
1461                                         
1462                                 }
1463                                 
1464                                 arg = div.childNodes;
1465                         }
1466
1467                         if ( arg.length === 0 )
1468                                 return;
1469                         
1470                         if ( arg[0] == undefined )
1471                                 r.push( arg );
1472                         else
1473                                 r = jQuery.merge( r, arg );
1474
1475                 });
1476
1477                 return r;
1478         },
1479         
1480         attr: function(elem, name, value){
1481                 var fix = {
1482                         "for": "htmlFor",
1483                         "class": "className",
1484                         "float": jQuery.browser.msie ? "styleFloat" : "cssFloat",
1485                         cssFloat: jQuery.browser.msie ? "styleFloat" : "cssFloat",
1486                         innerHTML: "innerHTML",
1487                         className: "className",
1488                         value: "value",
1489                         disabled: "disabled",
1490                         checked: "checked",
1491                         readonly: "readOnly",
1492                         selected: "selected"
1493                 };
1494                 
1495                 // IE actually uses filters for opacity ... elem is actually elem.style
1496                 if ( name == "opacity" && jQuery.browser.msie && value != undefined ) {
1497                         // IE has trouble with opacity if it does not have layout
1498                         // Force it by setting the zoom level
1499                         elem.zoom = 1; 
1500
1501                         // Set the alpha filter to set the opacity
1502                         return elem.filter = elem.filter.replace(/alpha\([^\)]*\)/gi,"") +
1503                                 ( value == 1 ? "" : "alpha(opacity=" + value * 100 + ")" );
1504
1505                 } else if ( name == "opacity" && jQuery.browser.msie )
1506                         return elem.filter ? 
1507                                 parseFloat( elem.filter.match(/alpha\(opacity=(.*)\)/)[1] ) / 100 : 1;
1508                 
1509                 // Mozilla doesn't play well with opacity 1
1510                 if ( name == "opacity" && jQuery.browser.mozilla && value == 1 )
1511                         value = 0.9999;
1512
1513                 // Certain attributes only work when accessed via the old DOM 0 way
1514                 if ( fix[name] ) {
1515                         if ( value != undefined ) elem[fix[name]] = value;
1516                         return elem[fix[name]];
1517
1518                 } else if ( value == undefined && jQuery.browser.msie && jQuery.nodeName(elem, "form") && (name == "action" || name == "method") )
1519                         return elem.getAttributeNode(name).nodeValue;
1520
1521                 // IE elem.getAttribute passes even for style
1522                 else if ( elem.tagName ) {
1523                         if ( value != undefined ) elem.setAttribute( name, value );
1524                         return elem.getAttribute( name );
1525
1526                 } else {
1527                         name = name.replace(/-([a-z])/ig,function(z,b){return b.toUpperCase();});
1528                         if ( value != undefined ) elem[name] = value;
1529                         return elem[name];
1530                 }
1531         },
1532         
1533         /**
1534          * Remove the whitespace from the beginning and end of a string.
1535          *
1536          * @example $.trim("  hello, how are you?  ");
1537          * @result "hello, how are you?"
1538          *
1539          * @name $.trim
1540          * @type String
1541          * @param String str The string to trim.
1542          * @cat JavaScript
1543          */
1544         trim: function(t){
1545                 return t.replace(/^\s+|\s+$/g, "");
1546         },
1547
1548         makeArray: function( a ) {
1549                 var r = [];
1550
1551                 if ( a.constructor != Array )
1552                         for ( var i = 0, al = a.length; i < al; i++ )
1553                                 r.push( a[i] );
1554                 else
1555                         r = a.slice( 0 );
1556
1557                 return r;
1558         },
1559
1560         inArray: function( b, a ) {
1561                 for ( var i = 0, al = a.length; i < al; i++ )
1562                         if ( a[i] == b )
1563                                 return i;
1564                 return -1;
1565         },
1566
1567         /**
1568          * Merge two arrays together, removing all duplicates.
1569          *
1570          * The result is the altered first argument with
1571          * the unique elements from the second array added.
1572          *
1573          * @example $.merge( [0,1,2], [2,3,4] )
1574          * @result [0,1,2,3,4]
1575          * @desc Merges two arrays, removing the duplicate 2
1576          *
1577          * @example var array = [3,2,1];
1578          * $.merge( array, [4,3,2] )
1579          * @result array == [3,2,1,4]
1580          * @desc Merges two arrays, removing the duplicates 3 and 2
1581          *
1582          * @name $.merge
1583          * @type Array
1584          * @param Array first The first array to merge, the unique elements of second added.
1585          * @param Array second The second array to merge into the first, unaltered.
1586          * @cat JavaScript
1587          */
1588         merge: function(first, second) {
1589                 var r = [].slice.call( first, 0 );
1590
1591                 // Now check for duplicates between the two arrays
1592                 // and only add the unique items
1593                 for ( var i = 0, sl = second.length; i < sl; i++ )
1594                         // Check for duplicates
1595                         if ( jQuery.inArray( second[i], r ) == -1 )
1596                                 // The item is unique, add it
1597                                 first.push( second[i] );
1598
1599                 return first;
1600         },
1601
1602         /**
1603          * Filter items out of an array, by using a filter function.
1604          *
1605          * The specified function will be passed two arguments: The
1606          * current array item and the index of the item in the array. The
1607          * function must return 'true' to keep the item in the array, 
1608          * false to remove it.
1609          *
1610          * @example $.grep( [0,1,2], function(i){
1611          *   return i > 0;
1612          * });
1613          * @result [1, 2]
1614          *
1615          * @name $.grep
1616          * @type Array
1617          * @param Array array The Array to find items in.
1618          * @param Function fn The function to process each item against.
1619          * @param Boolean inv Invert the selection - select the opposite of the function.
1620          * @cat JavaScript
1621          */
1622         grep: function(elems, fn, inv) {
1623                 // If a string is passed in for the function, make a function
1624                 // for it (a handy shortcut)
1625                 if ( typeof fn == "string" )
1626                         fn = new Function("a","i","return " + fn);
1627
1628                 var result = [];
1629
1630                 // Go through the array, only saving the items
1631                 // that pass the validator function
1632                 for ( var i = 0, el = elems.length; i < el; i++ )
1633                         if ( !inv && fn(elems[i],i) || inv && !fn(elems[i],i) )
1634                                 result.push( elems[i] );
1635
1636                 return result;
1637         },
1638
1639         /**
1640          * Translate all items in an array to another array of items.
1641          *
1642          * The translation function that is provided to this method is 
1643          * called for each item in the array and is passed one argument: 
1644          * The item to be translated.
1645          *
1646          * The function can then return the translated value, 'null'
1647          * (to remove the item), or  an array of values - which will
1648          * be flattened into the full array.
1649          *
1650          * @example $.map( [0,1,2], function(i){
1651          *   return i + 4;
1652          * });
1653          * @result [4, 5, 6]
1654          * @desc Maps the original array to a new one and adds 4 to each value.
1655          *
1656          * @example $.map( [0,1,2], function(i){
1657          *   return i > 0 ? i + 1 : null;
1658          * });
1659          * @result [2, 3]
1660          * @desc Maps the original array to a new one and adds 1 to each
1661          * value if it is bigger then zero, otherwise it's removed-
1662          * 
1663          * @example $.map( [0,1,2], function(i){
1664          *   return [ i, i + 1 ];
1665          * });
1666          * @result [0, 1, 1, 2, 2, 3]
1667          * @desc Maps the original array to a new one, each element is added
1668          * with it's original value and the value plus one.
1669          *
1670          * @name $.map
1671          * @type Array
1672          * @param Array array The Array to translate.
1673          * @param Function fn The function to process each item against.
1674          * @cat JavaScript
1675          */
1676         map: function(elems, fn) {
1677                 // If a string is passed in for the function, make a function
1678                 // for it (a handy shortcut)
1679                 if ( typeof fn == "string" )
1680                         fn = new Function("a","return " + fn);
1681
1682                 var result = [], r = [];
1683
1684                 // Go through the array, translating each of the items to their
1685                 // new value (or values).
1686                 for ( var i = 0, el = elems.length; i < el; i++ ) {
1687                         var val = fn(elems[i],i);
1688
1689                         if ( val !== null && val != undefined ) {
1690                                 if ( val.constructor != Array ) val = [val];
1691                                 result = result.concat( val );
1692                         }
1693                 }
1694
1695                 var r = result.length ? [ result[0] ] : [];
1696
1697                 check: for ( var i = 1, rl = result.length; i < rl; i++ ) {
1698                         for ( var j = 0; j < i; j++ )
1699                                 if ( result[i] == r[j] )
1700                                         continue check;
1701
1702                         r.push( result[i] );
1703                 }
1704
1705                 return r;
1706         }
1707 });
1708
1709 /**
1710  * Contains flags for the useragent, read from navigator.userAgent.
1711  * Available flags are: safari, opera, msie, mozilla
1712  *
1713  * This property is available before the DOM is ready, therefore you can
1714  * use it to add ready events only for certain browsers.
1715  *
1716  * There are situations where object detections is not reliable enough, in that
1717  * cases it makes sense to use browser detection. Simply try to avoid both!
1718  *
1719  * A combination of browser and object detection yields quite reliable results.
1720  *
1721  * @example $.browser.msie
1722  * @desc Returns true if the current useragent is some version of microsoft's internet explorer
1723  *
1724  * @example if($.browser.safari) { $( function() { alert("this is safari!"); } ); }
1725  * @desc Alerts "this is safari!" only for safari browsers
1726  *
1727  * @property
1728  * @name $.browser
1729  * @type Boolean
1730  * @cat JavaScript
1731  */
1732  
1733 /*
1734  * Whether the W3C compliant box model is being used.
1735  *
1736  * @property
1737  * @name $.boxModel
1738  * @type Boolean
1739  * @cat JavaScript
1740  */
1741 new function() {
1742         var b = navigator.userAgent.toLowerCase();
1743
1744         // Figure out what browser is being used
1745         jQuery.browser = {
1746                 safari: /webkit/.test(b),
1747                 opera: /opera/.test(b),
1748                 msie: /msie/.test(b) && !/opera/.test(b),
1749                 mozilla: /mozilla/.test(b) && !/(compatible|webkit)/.test(b)
1750         };
1751
1752         // Check to see if the W3C box model is being used
1753         jQuery.boxModel = !jQuery.browser.msie || document.compatMode == "CSS1Compat";
1754 };
1755
1756 /**
1757  * Get a set of elements containing the unique parents of the matched
1758  * set of elements.
1759  *
1760  * Can be filtered with an optional expressions.
1761  *
1762  * @example $("p").parent()
1763  * @before <div><p>Hello</p><p>Hello</p></div>
1764  * @result [ <div><p>Hello</p><p>Hello</p></div> ]
1765  * @desc Find the parent element of each paragraph.
1766  *
1767  * @example $("p").parent(".selected")
1768  * @before <div><p>Hello</p></div><div class="selected"><p>Hello Again</p></div>
1769  * @result [ <div class="selected"><p>Hello Again</p></div> ]
1770  * @desc Find the parent element of each paragraph with a class "selected".
1771  *
1772  * @name parent
1773  * @type jQuery
1774  * @param String expr (optional) An expression to filter the parents with
1775  * @cat DOM/Traversing
1776  */
1777
1778 /**
1779  * Get a set of elements containing the unique ancestors of the matched
1780  * set of elements (except for the root element).
1781  *
1782  * Can be filtered with an optional expressions.
1783  *
1784  * @example $("span").parents()
1785  * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html>
1786  * @result [ <body>...</body>, <div>...</div>, <p><span>Hello</span></p> ]
1787  * @desc Find all parent elements of each span.
1788  *
1789  * @example $("span").parents("p")
1790  * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html>
1791  * @result [ <p><span>Hello</span></p> ]
1792  * @desc Find all parent elements of each span that is a paragraph.
1793  *
1794  * @name parents
1795  * @type jQuery
1796  * @param String expr (optional) An expression to filter the ancestors with
1797  * @cat DOM/Traversing
1798  */
1799
1800 /**
1801  * Get a set of elements containing the unique next siblings of each of the
1802  * matched set of elements.
1803  *
1804  * It only returns the very next sibling, not all next siblings.
1805  *
1806  * Can be filtered with an optional expressions.
1807  *
1808  * @example $("p").next()
1809  * @before <p>Hello</p><p>Hello Again</p><div><span>And Again</span></div>
1810  * @result [ <p>Hello Again</p>, <div><span>And Again</span></div> ]
1811  * @desc Find the very next sibling of each paragraph.
1812  *
1813  * @example $("p").next(".selected")
1814  * @before <p>Hello</p><p class="selected">Hello Again</p><div><span>And Again</span></div>
1815  * @result [ <p class="selected">Hello Again</p> ]
1816  * @desc Find the very next sibling of each paragraph that has a class "selected".
1817  *
1818  * @name next
1819  * @type jQuery
1820  * @param String expr (optional) An expression to filter the next Elements with
1821  * @cat DOM/Traversing
1822  */
1823
1824 /**
1825  * Get a set of elements containing the unique previous siblings of each of the
1826  * matched set of elements.
1827  *
1828  * Can be filtered with an optional expressions.
1829  *
1830  * It only returns the immediately previous sibling, not all previous siblings.
1831  *
1832  * @example $("p").prev()
1833  * @before <p>Hello</p><div><span>Hello Again</span></div><p>And Again</p>
1834  * @result [ <div><span>Hello Again</span></div> ]
1835  * @desc Find the very previous sibling of each paragraph.
1836  *
1837  * @example $("p").prev(".selected")
1838  * @before <div><span>Hello</span></div><p class="selected">Hello Again</p><p>And Again</p>
1839  * @result [ <div><span>Hello</span></div> ]
1840  * @desc Find the very previous sibling of each paragraph that has a class "selected".
1841  *
1842  * @name prev
1843  * @type jQuery
1844  * @param String expr (optional) An expression to filter the previous Elements with
1845  * @cat DOM/Traversing
1846  */
1847
1848 /**
1849  * Get a set of elements containing all of the unique siblings of each of the
1850  * matched set of elements.
1851  *
1852  * Can be filtered with an optional expressions.
1853  *
1854  * @example $("div").siblings()
1855  * @before <p>Hello</p><div><span>Hello Again</span></div><p>And Again</p>
1856  * @result [ <p>Hello</p>, <p>And Again</p> ]
1857  * @desc Find all siblings of each div.
1858  *
1859  * @example $("div").siblings(".selected")
1860  * @before <div><span>Hello</span></div><p class="selected">Hello Again</p><p>And Again</p>
1861  * @result [ <p class="selected">Hello Again</p> ]
1862  * @desc Find all siblings with a class "selected" of each div.
1863  *
1864  * @name siblings
1865  * @type jQuery
1866  * @param String expr (optional) An expression to filter the sibling Elements with
1867  * @cat DOM/Traversing
1868  */
1869
1870 /**
1871  * Get a set of elements containing all of the unique children of each of the
1872  * matched set of elements.
1873  *
1874  * Can be filtered with an optional expressions.
1875  *
1876  * @example $("div").children()
1877  * @before <p>Hello</p><div><span>Hello Again</span></div><p>And Again</p>
1878  * @result [ <span>Hello Again</span> ]
1879  * @desc Find all children of each div.
1880  *
1881  * @example $("div").children(".selected")
1882  * @before <div><span>Hello</span><p class="selected">Hello Again</p><p>And Again</p></div>
1883  * @result [ <p class="selected">Hello Again</p> ]
1884  * @desc Find all children with a class "selected" of each div.
1885  *
1886  * @name children
1887  * @type jQuery
1888  * @param String expr (optional) An expression to filter the child Elements with
1889  * @cat DOM/Traversing
1890  */
1891 jQuery.each({
1892         parent: "a.parentNode",
1893         parents: "jQuery.parents(a)",
1894         next: "jQuery.nth(a,2,'nextSibling')",
1895         prev: "jQuery.nth(a,2,'previousSibling')",
1896         siblings: "jQuery.sibling(a.parentNode.firstChild,a)",
1897         children: "jQuery.sibling(a.firstChild)"
1898 }, function(i,n){
1899         jQuery.fn[ i ] = function(a) {
1900                 var ret = jQuery.map(this,n);
1901                 if ( a && typeof a == "string" )
1902                         ret = jQuery.multiFilter(a,ret);
1903                 return this.pushStack( ret );
1904         };
1905 });
1906
1907 /**
1908  * Append all of the matched elements to another, specified, set of elements.
1909  * This operation is, essentially, the reverse of doing a regular
1910  * $(A).append(B), in that instead of appending B to A, you're appending
1911  * A to B.
1912  *
1913  * @example $("p").appendTo("#foo");
1914  * @before <p>I would like to say: </p><div id="foo"></div>
1915  * @result <div id="foo"><p>I would like to say: </p></div>
1916  * @desc Appends all paragraphs to the element with the ID "foo"
1917  *
1918  * @name appendTo
1919  * @type jQuery
1920  * @param <Content> content Content to append to the selected element to.
1921  * @cat DOM/Manipulation
1922  * @see append(<Content>)
1923  */
1924
1925 /**
1926  * Prepend all of the matched elements to another, specified, set of elements.
1927  * This operation is, essentially, the reverse of doing a regular
1928  * $(A).prepend(B), in that instead of prepending B to A, you're prepending
1929  * A to B.
1930  *
1931  * @example $("p").prependTo("#foo");
1932  * @before <p>I would like to say: </p><div id="foo"><b>Hello</b></div>
1933  * @result <div id="foo"><p>I would like to say: </p><b>Hello</b></div>
1934  * @desc Prepends all paragraphs to the element with the ID "foo"
1935  *
1936  * @name prependTo
1937  * @type jQuery
1938  * @param <Content> content Content to prepend to the selected element to.
1939  * @cat DOM/Manipulation
1940  * @see prepend(<Content>)
1941  */
1942
1943 /**
1944  * Insert all of the matched elements before another, specified, set of elements.
1945  * This operation is, essentially, the reverse of doing a regular
1946  * $(A).before(B), in that instead of inserting B before A, you're inserting
1947  * A before B.
1948  *
1949  * @example $("p").insertBefore("#foo");
1950  * @before <div id="foo">Hello</div><p>I would like to say: </p>
1951  * @result <p>I would like to say: </p><div id="foo">Hello</div>
1952  * @desc Same as $("#foo").before("p")
1953  *
1954  * @name insertBefore
1955  * @type jQuery
1956  * @param <Content> content Content to insert the selected element before.
1957  * @cat DOM/Manipulation
1958  * @see before(<Content>)
1959  */
1960
1961 /**
1962  * Insert all of the matched elements after another, specified, set of elements.
1963  * This operation is, essentially, the reverse of doing a regular
1964  * $(A).after(B), in that instead of inserting B after A, you're inserting
1965  * A after B.
1966  *
1967  * @example $("p").insertAfter("#foo");
1968  * @before <p>I would like to say: </p><div id="foo">Hello</div>
1969  * @result <div id="foo">Hello</div><p>I would like to say: </p>
1970  * @desc Same as $("#foo").after("p")
1971  *
1972  * @name insertAfter
1973  * @type jQuery
1974  * @param <Content> content Content to insert the selected element after.
1975  * @cat DOM/Manipulation
1976  * @see after(<Content>)
1977  */
1978
1979 jQuery.each({
1980         appendTo: "append",
1981         prependTo: "prepend",
1982         insertBefore: "before",
1983         insertAfter: "after"
1984 }, function(i,n){
1985         jQuery.fn[ i ] = function(){
1986                 var a = arguments;
1987                 return this.each(function(){
1988                         for ( var j = 0, al = a.length; j < al; j++ )
1989                                 jQuery(a[j])[n]( this );
1990                 });
1991         };
1992 });
1993
1994 /**
1995  * Remove an attribute from each of the matched elements.
1996  *
1997  * @example $("input").removeAttr("disabled")
1998  * @before <input disabled="disabled"/>
1999  * @result <input/>
2000  *
2001  * @name removeAttr
2002  * @type jQuery
2003  * @param String name The name of the attribute to remove.
2004  * @cat DOM/Attributes
2005  */
2006
2007 /**
2008  * Adds the specified class(es) to each of the set of matched elements.
2009  *
2010  * @example $("p").addClass("selected")
2011  * @before <p>Hello</p>
2012  * @result [ <p class="selected">Hello</p> ]
2013  *
2014  * @example $("p").addClass("selected highlight")
2015  * @before <p>Hello</p>
2016  * @result [ <p class="selected highlight">Hello</p> ]
2017  *
2018  * @name addClass
2019  * @type jQuery
2020  * @param String class One or more CSS classes to add to the elements
2021  * @cat DOM/Attributes
2022  * @see removeClass(String)
2023  */
2024
2025 /**
2026  * Removes all or the specified class(es) from the set of matched elements.
2027  *
2028  * @example $("p").removeClass()
2029  * @before <p class="selected">Hello</p>
2030  * @result [ <p>Hello</p> ]
2031  *
2032  * @example $("p").removeClass("selected")
2033  * @before <p class="selected first">Hello</p>
2034  * @result [ <p class="first">Hello</p> ]
2035  *
2036  * @example $("p").removeClass("selected highlight")
2037  * @before <p class="highlight selected first">Hello</p>
2038  * @result [ <p class="first">Hello</p> ]
2039  *
2040  * @name removeClass
2041  * @type jQuery
2042  * @param String class (optional) One or more CSS classes to remove from the elements
2043  * @cat DOM/Attributes
2044  * @see addClass(String)
2045  */
2046
2047 /**
2048  * Adds the specified class if it is not present, removes it if it is
2049  * present.
2050  *
2051  * @example $("p").toggleClass("selected")
2052  * @before <p>Hello</p><p class="selected">Hello Again</p>
2053  * @result [ <p class="selected">Hello</p>, <p>Hello Again</p> ]
2054  *
2055  * @name toggleClass
2056  * @type jQuery
2057  * @param String class A CSS class with which to toggle the elements
2058  * @cat DOM/Attributes
2059  */
2060
2061 /**
2062  * Removes all matched elements from the DOM. This does NOT remove them from the
2063  * jQuery object, allowing you to use the matched elements further.
2064  *
2065  * Can be filtered with an optional expressions.
2066  *
2067  * @example $("p").remove();
2068  * @before <p>Hello</p> how are <p>you?</p>
2069  * @result how are
2070  *
2071  * @example $("p").remove(".hello");
2072  * @before <p class="hello">Hello</p> how are <p>you?</p>
2073  * @result how are <p>you?</p>
2074  *
2075  * @name remove
2076  * @type jQuery
2077  * @param String expr (optional) A jQuery expression to filter elements by.
2078  * @cat DOM/Manipulation
2079  */
2080
2081 /**
2082  * Removes all child nodes from the set of matched elements.
2083  *
2084  * @example $("p").empty()
2085  * @before <p>Hello, <span>Person</span> <a href="#">and person</a></p>
2086  * @result [ <p></p> ]
2087  *
2088  * @name empty
2089  * @type jQuery
2090  * @cat DOM/Manipulation
2091  */
2092
2093 jQuery.each( {
2094         removeAttr: function( key ) {
2095                 jQuery.attr( this, key, "" );
2096                 this.removeAttribute( key );
2097         },
2098         addClass: function(c){
2099                 jQuery.className.add(this,c);
2100         },
2101         removeClass: function(c){
2102                 jQuery.className.remove(this,c);
2103         },
2104         toggleClass: function( c ){
2105                 jQuery.className[ jQuery.className.has(this,c) ? "remove" : "add" ](this, c);
2106         },
2107         remove: function(a){
2108                 if ( !a || jQuery.filter( a, [this] ).r.length )
2109                         this.parentNode.removeChild( this );
2110         },
2111         empty: function() {
2112                 while ( this.firstChild )
2113                         this.removeChild( this.firstChild );
2114         }
2115 }, function(i,n){
2116         jQuery.fn[ i ] = function() {
2117                 return this.each( n, arguments );
2118         };
2119 });
2120
2121 /**
2122  * Reduce the set of matched elements to a single element.
2123  * The position of the element in the set of matched elements
2124  * starts at 0 and goes to length - 1.
2125  *
2126  * @example $("p").eq(1)
2127  * @before <p>This is just a test.</p><p>So is this</p>
2128  * @result [ <p>So is this</p> ]
2129  *
2130  * @name eq
2131  * @type jQuery
2132  * @param Number pos The index of the element that you wish to limit to.
2133  * @cat Core
2134  */
2135
2136 /**
2137  * Reduce the set of matched elements to all elements before a given position.
2138  * The position of the element in the set of matched elements
2139  * starts at 0 and goes to length - 1.
2140  *
2141  * @example $("p").lt(1)
2142  * @before <p>This is just a test.</p><p>So is this</p>
2143  * @result [ <p>This is just a test.</p> ]
2144  *
2145  * @name lt
2146  * @type jQuery
2147  * @param Number pos Reduce the set to all elements below this position.
2148  * @cat Core
2149  */
2150
2151 /**
2152  * Reduce the set of matched elements to all elements after a given position.
2153  * The position of the element in the set of matched elements
2154  * starts at 0 and goes to length - 1.
2155  *
2156  * @example $("p").gt(0)
2157  * @before <p>This is just a test.</p><p>So is this</p>
2158  * @result [ <p>So is this</p> ]
2159  *
2160  * @name gt
2161  * @type jQuery
2162  * @param Number pos Reduce the set to all elements after this position.
2163  * @cat Core
2164  */
2165
2166 /**
2167  * Filter the set of elements to those that contain the specified text.
2168  *
2169  * @example $("p").contains("test")
2170  * @before <p>This is just a test.</p><p>So is this</p>
2171  * @result [ <p>This is just a test.</p> ]
2172  *
2173  * @name contains
2174  * @type jQuery
2175  * @param String str The string that will be contained within the text of an element.
2176  * @cat DOM/Traversing
2177  */
2178 jQuery.each( [ "eq", "lt", "gt", "contains" ], function(i,n){
2179         jQuery.fn[ n ] = function(num,fn) {
2180                 return this.filter( ":" + n + "(" + num + ")", fn );
2181         };
2182 });
2183
2184 /**
2185  * Get the current computed, pixel, width of the first matched element.
2186  *
2187  * @example $("p").width();
2188  * @before <p>This is just a test.</p>
2189  * @result 300
2190  *
2191  * @name width
2192  * @type String
2193  * @cat CSS
2194  */
2195
2196 /**
2197  * Set the CSS width of every matched element. If no explicit unit
2198  * was specified (like 'em' or '%') then "px" is added to the width.
2199  *
2200  * @example $("p").width(20);
2201  * @before <p>This is just a test.</p>
2202  * @result <p style="width:20px;">This is just a test.</p>
2203  *
2204  * @example $("p").width("20em");
2205  * @before <p>This is just a test.</p>
2206  * @result <p style="width:20em;">This is just a test.</p>
2207  *
2208  * @name width
2209  * @type jQuery
2210  * @param String|Number val Set the CSS property to the specified value.
2211  * @cat CSS
2212  */
2213  
2214 /**
2215  * Get the current computed, pixel, height of the first matched element.
2216  *
2217  * @example $("p").height();
2218  * @before <p>This is just a test.</p>
2219  * @result 300
2220  *
2221  * @name height
2222  * @type String
2223  * @cat CSS
2224  */
2225
2226 /**
2227  * Set the CSS width of every matched element. If no explicit unit
2228  * was specified (like 'em' or '%') then "px" is added to the width.
2229  *
2230  * @example $("p").height(20);
2231  * @before <p>This is just a test.</p>
2232  * @result <p style="height:20px;">This is just a test.</p>
2233  *
2234  * @example $("p").height("20em");
2235  * @before <p>This is just a test.</p>
2236  * @result <p style="height:20em;">This is just a test.</p>
2237  *
2238  * @name height
2239  * @type jQuery
2240  * @param String|Number val Set the CSS property to the specified value.
2241  * @cat CSS
2242  */
2243
2244 jQuery.each( [ "height", "width" ], function(i,n){
2245         jQuery.fn[ n ] = function(h) {
2246                 return h == undefined ?
2247                         ( this.length ? jQuery.css( this[0], n ) : null ) :
2248                         this.css( n, h.constructor == String ? h : h + "px" );
2249         };
2250 });