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