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