Added fix for radio inputs becoming unchecked during an animation.
[jquery.git] / src / jquery / jquery.js
1 /*
2  * jQuery @VERSION - New Wave Javascript
3  *
4  * Copyright (c) 2006 John Resig (jquery.com)
5  * Dual licensed under the MIT (MIT-LICENSE.txt)
6  * and GPL (GPL-LICENSE.txt) licenses.
7  *
8  * $Date$
9  * $Rev$
10  */
11
12 // Global undefined variable
13 window.undefined = window.undefined;
14
15 /**
16  * Create a new jQuery Object
17  *
18  * @test ok( Array.prototype.push, "Array.push()" );
19  * ok( Function.prototype.apply, "Function.apply()" );
20  * ok( document.getElementById, "getElementById" );
21  * ok( document.getElementsByTagName, "getElementsByTagName" );
22  * ok( RegExp, "RegExp" );
23  * ok( jQuery, "jQuery" );
24  * ok( $, "$()" );
25  *
26  * @constructor
27  * @private
28  * @name jQuery
29  * @cat Core
30  */
31 var jQuery = function(a,c) {
32
33         // Shortcut for document ready (because $(document).each() is silly)
34         if ( a && typeof a == "function" && jQuery.fn.ready )
35                 return jQuery(document).ready(a);
36
37         // Make sure that a selection was provided
38         a = a || jQuery.context || document;
39
40         // Watch for when a jQuery object is passed as the selector
41         if ( a.jquery )
42                 return jQuery( jQuery.merge( a, [] ) );
43
44         // Watch for when a jQuery object is passed at the context
45         if ( c && c.jquery )
46                 return jQuery( c ).find(a);
47
48         // If the context is global, return a new object
49         if ( window == this )
50                 return new jQuery(a,c);
51
52         // Handle HTML strings
53         if ( a.constructor == String ) {
54                 var m = /^[^<]*(<.+>)[^>]*$/.exec(a);
55                 if ( m ) a = jQuery.clean( [ m[1] ] );
56         }
57
58         // Watch for when an array is passed in
59         this.get( a.constructor == Array || a.length && !a.nodeType && a[0] != undefined && a[0].nodeType ?
60                 // Assume that it is an array of DOM Elements
61                 jQuery.merge( a, [] ) :
62
63                 // Find the matching elements and save them for later
64                 jQuery.find( a, c ) );
65
66         // See if an extra function was provided
67         var fn = arguments[ arguments.length - 1 ];
68
69         // If so, execute it in context
70         if ( fn && typeof fn == "function" )
71                 this.each(fn);
72
73         return this;
74 };
75
76 // Map over the $ in case of overwrite
77 if ( typeof $ != "undefined" )
78         jQuery._$ = $;
79
80 /**
81  * This function accepts a string containing a CSS selector,
82  * basic XPath, or raw HTML, which is then used to match a set of elements.
83  * The HTML string is different from the traditional selectors in that
84  * it creates the DOM elements representing that HTML string, on the fly,
85  * to be (assumedly) inserted into the document later.
86  *
87  * The core functionality of jQuery centers around this function.
88  * Everything in jQuery is based upon this, or uses this in some way.
89  * The most basic use of this function is to pass in an expression
90  * (usually consisting of CSS or XPath), which then finds all matching
91  * elements and remembers them for later use.
92  *
93  * By default, $() looks for DOM elements within the context of the
94  * current HTML document.
95  *
96  * @example $("div > p")
97  * @desc This finds all p elements that are children of a div element.
98  * @before <p>one</p> <div><p>two</p></div> <p>three</p>
99  * @result [ <p>two</p> ]
100  *
101  * @example $("<div><p>Hello</p></div>").appendTo("#body")
102  * @desc Creates a div element (and all of its contents) dynamically, 
103  * and appends it to the element with the ID of body. Internally, an
104  * element is created and it's innerHTML property set to the given markup.
105  * It is therefore both quite flexible and limited. 
106  *
107  * @name $
108  * @param String expr An expression to search with, or a string of HTML to create on the fly.
109  * @cat Core
110  * @type jQuery
111  */
112
113 /**
114  * This function accepts a string containing a CSS selector, or
115  * basic XPath, which is then used to match a set of elements with the
116  * context of the specified DOM element, or document
117  *
118  * @example $("div", xml.responseXML)
119  * @desc This finds all div elements within the specified XML document.
120  *
121  * @name $
122  * @param String expr An expression to search with.
123  * @param Element context A DOM Element, or Document, representing the base context.
124  * @cat Core
125  * @type jQuery
126  */
127
128 /**
129  * Wrap jQuery functionality around a specific DOM Element.
130  * This function also accepts XML Documents and Window objects
131  * as valid arguments (even though they are not DOM Elements).
132  *
133  * @example $(document).find("div > p")
134  * @before <p>one</p> <div><p>two</p></div> <p>three</p>
135  * @result [ <p>two</p> ]
136  *
137  * @example $(document.body).background( "black" );
138  * @desc Sets the background color of the page to black.
139  *
140  * @name $
141  * @param Element elem A DOM element to be encapsulated by a jQuery object.
142  * @cat Core
143  * @type jQuery
144  */
145
146 /**
147  * Wrap jQuery functionality around a set of DOM Elements.
148  *
149  * @example $( myForm.elements ).hide()
150  * @desc Hides all the input elements within a form
151  *
152  * @name $
153  * @param Array<Element> elems An array of DOM elements to be encapsulated by a jQuery object.
154  * @cat Core
155  * @type jQuery
156  */
157
158 /**
159  * A shorthand for $(document).ready(), allowing you to bind a function
160  * to be executed when the DOM document has finished loading. This function
161  * behaves just like $(document).ready(), in that it should be used to wrap
162  * all of the other $() operations on your page. While this function is,
163  * technically, chainable - there really isn't much use for chaining against it.
164  * You can have as many $(document).ready events on your page as you like.
165  *
166  * @example $(function(){
167  *   // Document is ready
168  * });
169  * @desc Executes the function when the DOM is ready to be used.
170  *
171  * @name $
172  * @param Function fn The function to execute when the DOM is ready.
173  * @cat Core
174  * @type jQuery
175  */
176
177 /**
178  * A means of creating a cloned copy of a jQuery object. This function
179  * copies the set of matched elements from one jQuery object and creates
180  * another, new, jQuery object containing the same elements.
181  *
182  * @example var div = $("div");
183  * $( div ).find("p");
184  * @desc Locates all p elements with all div elements, without disrupting the original jQuery object contained in 'div' (as would normally be the case if a simple div.find("p") was done).
185  *
186  * @name $
187  * @param jQuery obj The jQuery object to be cloned.
188  * @cat Core
189  * @type jQuery
190  */
191
192 // Map the jQuery namespace to the '$' one
193 var $ = jQuery;
194
195 jQuery.fn = jQuery.prototype = {
196         /**
197          * The current version of jQuery.
198          *
199          * @private
200          * @property
201          * @name jquery
202          * @type String
203          * @cat Core
204          */
205         jquery: "@VERSION",
206
207         /**
208          * The number of elements currently matched.
209          *
210          * @example $("img").length;
211          * @before <img src="test1.jpg"/> <img src="test2.jpg"/>
212          * @result 2
213          *
214          * @test ok( $("div").length == 2, "Get Number of Elements Found" );
215          *
216          * @property
217          * @name length
218          * @type Number
219          * @cat Core
220          */
221
222         /**
223          * The number of elements currently matched.
224          *
225          * @example $("img").size();
226          * @before <img src="test1.jpg"/> <img src="test2.jpg"/>
227          * @result 2
228          *
229          * @test ok( $("div").size() == 2, "Get Number of Elements Found" );
230          *
231          * @name size
232          * @type Number
233          * @cat Core
234          */
235         size: function() {
236                 return this.length;
237         },
238
239         /**
240          * Access all matched elements. This serves as a backwards-compatible
241          * way of accessing all matched elements (other than the jQuery object
242          * itself, which is, in fact, an array of elements).
243          *
244          * @example $("img").get();
245          * @before <img src="test1.jpg"/> <img src="test2.jpg"/>
246          * @result [ <img src="test1.jpg"/> <img src="test2.jpg"/> ]
247          *
248          * @test isSet( $("div").get(), q("main","foo"), "Get All Elements" );
249          *
250          * @name get
251          * @type Array<Element>
252          * @cat Core
253          */
254
255         /**
256          * Access a single matched element. num is used to access the
257          * Nth element matched.
258          *
259          * @example $("img").get(1);
260          * @before <img src="test1.jpg"/> <img src="test2.jpg"/>
261          * @result [ <img src="test1.jpg"/> ]
262          *
263          * @test ok( $("div").get(0) == document.getElementById("main"), "Get A Single Element" );
264          *
265          * @name get
266          * @type Element
267          * @param Number num Access the element in the Nth position.
268          * @cat Core
269          */
270
271         /**
272          * Set the jQuery object to an array of elements.
273          *
274          * @example $("img").get([ document.body ]);
275          * @result $("img").get() == [ document.body ]
276          *
277          * @private
278          * @name get
279          * @type jQuery
280          * @param Elements elems An array of elements
281          * @cat Core
282          */
283         get: function( num ) {
284                 // Watch for when an array (of elements) is passed in
285                 if ( num && num.constructor == Array ) {
286
287                         // Use a tricky hack to make the jQuery object
288                         // look and feel like an array
289                         this.length = 0;
290                         [].push.apply( this, num );
291
292                         return this;
293                 } else
294                         return num == undefined ?
295
296                                 // Return a 'clean' array
297                                 jQuery.merge( this, [] ) :
298
299                                 // Return just the object
300                                 this[num];
301         },
302
303         /**
304          * Execute a function within the context of every matched element.
305          * This means that every time the passed-in function is executed
306          * (which is once for every element matched) the 'this' keyword
307          * points to the specific element.
308          *
309          * Additionally, the function, when executed, is passed a single
310          * argument representing the position of the element in the matched
311          * set.
312          *
313          * @example $("img").each(function(){
314          *   this.src = "test.jpg";
315          * });
316          * @before <img/> <img/>
317          * @result <img src="test.jpg"/> <img src="test.jpg"/>
318          *
319          * @example $("img").each(function(i){
320          *   alert( "Image #" + i + " is " + this );
321          * });
322          * @before <img/> <img/>
323          * @result <img src="test.jpg"/> <img src="test.jpg"/>
324          *
325          * @test var div = $("div");
326          * div.each(function(){this.foo = 'zoo';});
327          * var pass = true;
328          * for ( var i = 0; i < div.size(); i++ ) {
329          *   if ( div.get(i).foo != "zoo" ) pass = false;
330          * }
331          * ok( pass, "Execute a function, Relative" );
332          *
333          * @name each
334          * @type jQuery
335          * @param Function fn A function to execute
336          * @cat Core
337          */
338         each: function( fn, args ) {
339                 return jQuery.each( this, fn, args );
340         },
341
342         /**
343          * Searches every matched element for the object and returns
344          * the index of the element, if found, starting with zero. 
345          * Returns -1 if the object wasn't found.
346          *
347          * @example $("*").index(document.getElementById('foobar')) 
348          * @before <div id="foobar"></div><b></b><span id="foo"></span>
349          * @result 0
350          *
351          * @example $("*").index(document.getElementById('foo')) 
352          * @before <div id="foobar"></div><b></b><span id="foo"></span>
353          * @result 2
354          *
355          * @example $("*").index(document.getElementById('bar')) 
356          * @before <div id="foobar"></div><b></b><span id="foo"></span>
357          * @result -1
358          *
359          * @test ok( $([window, document]).index(window) == 0, "Check for index of elements" );
360          * ok( $([window, document]).index(document) == 1, "Check for index of elements" );
361          * var inputElements = $('#radio1,#radio2,#check1,#check2');
362          * ok( inputElements.index(document.getElementById('radio1')) == 0, "Check for index of elements" );
363          * ok( inputElements.index(document.getElementById('radio2')) == 1, "Check for index of elements" );
364          * ok( inputElements.index(document.getElementById('check1')) == 2, "Check for index of elements" );
365          * ok( inputElements.index(document.getElementById('check2')) == 3, "Check for index of elements" );
366          * ok( inputElements.index(window) == -1, "Check for not found index" );
367          * ok( inputElements.index(document) == -1, "Check for not found index" );
368          * 
369          * @name index
370          * @type Number
371          * @param Object obj Object to search for
372          * @cat Core
373          */
374         index: function( obj ) {
375                 var pos = -1;
376                 this.each(function(i){
377                         if ( this == obj ) pos = i;
378                 });
379                 return pos;
380         },
381
382         /**
383          * Access a property on the first matched element.
384          * This method makes it easy to retrieve a property value
385          * from the first matched element.
386          *
387          * @example $("img").attr("src");
388          * @before <img src="test.jpg"/>
389          * @result test.jpg
390          *
391          * @test ok( $('#text1').attr('value') == "Test", 'Check for value attribute' );
392          * ok( $('#text1').attr('type') == "text", 'Check for type attribute' );
393          * ok( $('#radio1').attr('type') == "radio", 'Check for type attribute' );
394          * ok( $('#check1').attr('type') == "checkbox", 'Check for type attribute' );
395          * ok( $('#simon1').attr('rel') == "bookmark", 'Check for rel attribute' );
396          * ok( $('#google').attr('title') == "Google!", 'Check for title attribute' );
397          * ok( $('#mark').attr('hreflang') == "en", 'Check for hreflang attribute' );
398          * ok( $('#en').attr('lang') == "en", 'Check for lang attribute' );
399          * ok( $('#simon').attr('class') == "blog link", 'Check for class attribute' );
400          * ok( $('#name').attr('name') == "name", 'Check for name attribute' );
401          * ok( $('#text1').attr('name') == "action", 'Check for name attribute' );
402          * ok( $('#form').attr('action').indexOf("formaction") >= 0, 'Check for action attribute' );
403          *
404          * @name attr
405          * @type Object
406          * @param String name The name of the property to access.
407          * @cat DOM
408          */
409
410         /**
411          * Set a hash of key/value object properties to all matched elements.
412          * This serves as the best way to set a large number of properties
413          * on all matched elements.
414          *
415          * @example $("img").attr({ src: "test.jpg", alt: "Test Image" });
416          * @before <img/>
417          * @result <img src="test.jpg" alt="Test Image"/>
418          *
419          * @test var pass = true;
420          * $("div").attr({foo: 'baz', zoo: 'ping'}).each(function(){
421          *   if ( this.getAttribute('foo') != "baz" && this.getAttribute('zoo') != "ping" ) pass = false;
422          * });
423          * ok( pass, "Set Multiple Attributes" );
424          *
425          * @name attr
426          * @type jQuery
427          * @param Hash prop A set of key/value pairs to set as object properties.
428          * @cat DOM
429          */
430
431         /**
432          * Set a single property to a value, on all matched elements.
433          *
434          * @example $("img").attr("src","test.jpg");
435          * @before <img/>
436          * @result <img src="test.jpg"/>
437          *
438          * @test var div = $("div");
439          * div.attr("foo", "bar");
440          * var pass = true;
441          * for ( var i = 0; i < div.size(); i++ ) {
442          *   if ( div.get(i).getAttribute('foo') != "bar" ) pass = false;
443          * }
444          * ok( pass, "Set Attribute" );
445          *
446          * $("#name").attr('name', 'something');
447          * ok( $("#name").name() == 'something', 'Set name attribute' );
448          * $("#check2").attr('checked', true);
449          * ok( document.getElementById('check2').checked == true, 'Set checked attribute' );
450          * $("#check2").attr('checked', false);
451          * ok( document.getElementById('check2').checked == false, 'Set checked attribute' );
452          *
453          * @test stop();
454          * $.get('data/dashboard.xml', function(xml) { 
455          *   var titles = [];
456          *   $('tab', xml).each(function() {
457          *     titles.push($(this).attr('title'));
458          *   });
459          *   ok( titles[0] == 'Location', 'attr() in XML context: Check first title' );
460          *   ok( titles[1] == 'Users', 'attr() in XML context: Check second title' );
461          *   start();
462          * });
463          *
464          * @name attr
465          * @type jQuery
466          * @param String key The name of the property to set.
467          * @param Object value The value to set the property to.
468          * @cat DOM
469          */
470         attr: function( key, value, type ) {
471                 // Check to see if we're setting style values
472                 return key.constructor != String || value != undefined ?
473                         this.each(function(){
474                                 // See if we're setting a hash of styles
475                                 if ( value == undefined )
476                                         // Set all the styles
477                                         for ( var prop in key )
478                                                 jQuery.attr(
479                                                         type ? this.style : this,
480                                                         prop, key[prop]
481                                                 );
482
483                                 // See if we're setting a single key/value style
484                                 else
485                                         jQuery.attr(
486                                                 type ? this.style : this,
487                                                 key, value
488                                         );
489                         }) :
490
491                         // Look for the case where we're accessing a style value
492                         jQuery[ type || "attr" ]( this[0], key );
493         },
494
495         /**
496          * Access a style property on the first matched element.
497          * This method makes it easy to retrieve a style property value
498          * from the first matched element.
499          *
500          * @example $("p").css("color");
501          * @before <p style="color:red;">Test Paragraph.</p>
502          * @result red
503          * @desc Retrieves the color style of the first paragraph
504          *
505          * @example $("p").css("fontWeight");
506          * @before <p style="font-weight: bold;">Test Paragraph.</p>
507          * @result bold
508          * @desc Retrieves the font-weight style of the first paragraph.
509          * Note that for all style properties with a dash (like 'font-weight'), you have to
510          * write it in camelCase. In other words: Every time you have a '-' in a 
511          * property, remove it and replace the next character with an uppercase 
512          * representation of itself. Eg. fontWeight, fontSize, fontFamily, borderWidth,
513          * borderStyle, borderBottomWidth etc.
514          *
515          * @test ok( $('#main').css("display") == 'none', 'Check for css property "display"');
516          *
517          * @name css
518          * @type Object
519          * @param String name The name of the property to access.
520          * @cat CSS
521          */
522
523         /**
524          * Set a hash of key/value style properties to all matched elements.
525          * This serves as the best way to set a large number of style properties
526          * on all matched elements.
527          *
528          * @example $("p").css({ color: "red", background: "blue" });
529          * @before <p>Test Paragraph.</p>
530          * @result <p style="color:red; background:blue;">Test Paragraph.</p>
531          *
532          * @test ok( $('#foo').is(':visible'), 'Modifying CSS display: Assert element is visible');
533          * $('#foo').css({display: 'none'});
534          * ok( !$('#foo').is(':visible'), 'Modified CSS display: Assert element is hidden');
535          * $('#foo').css({display: 'block'});
536          * ok( $('#foo').is(':visible'), 'Modified CSS display: Assert element is visible');
537          * $('#floatTest').css({styleFloat: 'right'});
538          * ok( $('#floatTest').css('styleFloat') == 'right', 'Modified CSS float using "styleFloat": Assert float is right');
539          * $('#floatTest').css({cssFloat: 'left'});
540          * ok( $('#floatTest').css('cssFloat') == 'left', 'Modified CSS float using "cssFloat": Assert float is left');
541          * $('#floatTest').css({'float': 'right'});
542          * ok( $('#floatTest').css('float') == 'right', 'Modified CSS float using "float": Assert float is right');
543          * $('#floatTest').css({'font-size': '30px'});
544          * ok( $('#floatTest').css('font-size') == '30px', 'Modified CSS font-size: Assert font-size is 30px');
545          * 
546          * @name css
547          * @type jQuery
548          * @param Hash prop A set of key/value pairs to set as style properties.
549          * @cat CSS
550          */
551
552         /**
553          * Set a single style property to a value, on all matched elements.
554          *
555          * @example $("p").css("color","red");
556          * @before <p>Test Paragraph.</p>
557          * @result <p style="color:red;">Test Paragraph.</p>
558          * @desc Changes the color of all paragraphs to red
559          *
560          *
561          * @test ok( $('#foo').is(':visible'), 'Modifying CSS display: Assert element is visible');
562          * $('#foo').css('display', 'none');
563          * ok( !$('#foo').is(':visible'), 'Modified CSS display: Assert element is hidden');
564          * $('#foo').css('display', 'block');
565          * ok( $('#foo').is(':visible'), 'Modified CSS display: Assert element is visible');
566          * $('#floatTest').css('styleFloat', 'left');
567          * ok( $('#floatTest').css('styleFloat') == 'left', 'Modified CSS float using "styleFloat": Assert float is left');
568          * $('#floatTest').css('cssFloat', 'right');
569          * ok( $('#floatTest').css('cssFloat') == 'right', 'Modified CSS float using "cssFloat": Assert float is right');
570          * $('#floatTest').css('float', 'left');
571          * ok( $('#floatTest').css('float') == 'left', 'Modified CSS float using "float": Assert float is left');
572          * $('#floatTest').css('font-size', '20px');
573          * ok( $('#floatTest').css('font-size') == '20px', 'Modified CSS font-size: Assert font-size is 20px');
574          *
575          * @name css
576          * @type jQuery
577          * @param String key The name of the property to set.
578          * @param Object value The value to set the property to.
579          * @cat CSS
580          */
581         css: function( key, value ) {
582                 return this.attr( key, value, "curCSS" );
583         },
584
585         /**
586          * Retrieve the text contents of all matched elements. The result is
587          * a string that contains the combined text contents of all matched
588          * elements. This method works on both HTML and XML documents.
589          *
590          * @example $("p").text();
591          * @before <p>Test Paragraph.</p>
592          * @result Test Paragraph.
593          *
594          * @test var expected = "This link has class=\"blog\": Simon Willison's Weblog";
595          * ok( $('#sap').text() == expected, 'Check for merged text of more then one element.' );
596          *
597          * @name text
598          * @type String
599          * @cat DOM
600          */
601         text: function(e) {
602                 e = e || this;
603                 var t = "";
604                 for ( var j = 0; j < e.length; j++ ) {
605                         var r = e[j].childNodes;
606                         for ( var i = 0; i < r.length; i++ )
607                                 if ( r[i].nodeType != 8 )
608                                         t += r[i].nodeType != 1 ?
609                                                 r[i].nodeValue : jQuery.fn.text([ r[i] ]);
610                 }
611                 return t;
612         },
613
614         /**
615          * Wrap all matched elements with a structure of other elements.
616          * This wrapping process is most useful for injecting additional
617          * stucture into a document, without ruining the original semantic
618          * qualities of a document.
619          *
620          * This works by going through the first element
621          * provided (which is generated, on the fly, from the provided HTML)
622          * and finds the deepest ancestor element within its
623          * structure - it is that element that will en-wrap everything else.
624          *
625          * This does not work with elements that contain text. Any necessary text
626          * must be added after the wrapping is done.
627          *
628          * @example $("p").wrap("<div class='wrap'></div>");
629          * @before <p>Test Paragraph.</p>
630          * @result <div class='wrap'><p>Test Paragraph.</p></div>
631          * 
632          * @test var defaultText = 'Try them out:'
633          * var result = $('#first').wrap('<div class="red"><span></span></div>').text();
634          * ok( defaultText == result, 'Check for wrapping of on-the-fly html' );
635          * ok( $('#first').parent().parent().is('.red'), 'Check if wrapper has class "red"' );
636          *
637          * @name wrap
638          * @type jQuery
639          * @param String html A string of HTML, that will be created on the fly and wrapped around the target.
640          * @cat DOM/Manipulation
641          */
642
643         /**
644          * Wrap all matched elements with a structure of other elements.
645          * This wrapping process is most useful for injecting additional
646          * stucture into a document, without ruining the original semantic
647          * qualities of a document.
648          *
649          * This works by going through the first element
650          * provided and finding the deepest ancestor element within its
651          * structure - it is that element that will en-wrap everything else.
652          *
653          * This does not work with elements that contain text. Any necessary text
654          * must be added after the wrapping is done.
655          *
656          * @example $("p").wrap( document.getElementById('content') );
657          * @before <p>Test Paragraph.</p><div id="content"></div>
658          * @result <div id="content"><p>Test Paragraph.</p></div>
659          *
660          * @test var defaultText = 'Try them out:'
661          * var result = $('#first').wrap(document.getElementById('empty')).parent();
662          * ok( result.is('ol'), 'Check for element wrapping' );
663          * ok( result.text() == defaultText, 'Check for element wrapping' );
664          *
665          * @name wrap
666          * @type jQuery
667          * @param Element elem A DOM element that will be wrapped.
668          * @cat DOM/Manipulation
669          */
670         wrap: function() {
671                 // The elements to wrap the target around
672                 var a = jQuery.clean(arguments);
673
674                 // Wrap each of the matched elements individually
675                 return this.each(function(){
676                         // Clone the structure that we're using to wrap
677                         var b = a[0].cloneNode(true);
678
679                         // Insert it before the element to be wrapped
680                         this.parentNode.insertBefore( b, this );
681
682                         // Find the deepest point in the wrap structure
683                         while ( b.firstChild )
684                                 b = b.firstChild;
685
686                         // Move the matched element to within the wrap structure
687                         b.appendChild( this );
688                 });
689         },
690
691         /**
692          * Append any number of elements to the inside of every matched elements,
693          * generated from the provided HTML.
694          * This operation is similar to doing an appendChild to all the
695          * specified elements, adding them into the document.
696          *
697          * @example $("p").append("<b>Hello</b>");
698          * @before <p>I would like to say: </p>
699          * @result <p>I would like to say: <b>Hello</b></p>
700          *
701          * @test var defaultText = 'Try them out:'
702          * var result = $('#first').append('<b>buga</b>');
703          * ok( result.text() == defaultText + 'buga', 'Check if text appending works' );
704          * ok( $('#select3').append('<option value="appendTest">Append Test</option>').find('option:last-child').attr('value') == 'appendTest', 'Appending html options to select element');
705          *
706          * @name append
707          * @type jQuery
708          * @param String html A string of HTML, that will be created on the fly and appended to the target.
709          * @cat DOM/Manipulation
710          */
711
712         /**
713          * Append an element to the inside of all matched elements.
714          * This operation is similar to doing an appendChild to all the
715          * specified elements, adding them into the document.
716          *
717          * @example $("p").append( $("#foo")[0] );
718          * @before <p>I would like to say: </p><b id="foo">Hello</b>
719          * @result <p>I would like to say: <b id="foo">Hello</b></p>
720          *
721          * @test var expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:";
722          * $('#sap').append(document.getElementById('first'));
723          * ok( expected == $('#sap').text(), "Check for appending of element" );
724          *
725          * @name append
726          * @type jQuery
727          * @param Element elem A DOM element that will be appended.
728          * @cat DOM/Manipulation
729          */
730
731         /**
732          * Append any number of elements to the inside of all matched elements.
733          * This operation is similar to doing an appendChild to all the
734          * specified elements, adding them into the document.
735          *
736          * @example $("p").append( $("b") );
737          * @before <p>I would like to say: </p><b>Hello</b>
738          * @result <p>I would like to say: <b>Hello</b></p>
739          *
740          * @test var expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo";
741          * $('#sap').append([document.getElementById('first'), document.getElementById('yahoo')]);
742          * ok( expected == $('#sap').text(), "Check for appending of array of elements" );
743          *
744          * @name append
745          * @type jQuery
746          * @param Array<Element> elems An array of elements, all of which will be appended.
747          * @cat DOM/Manipulation
748          */
749         append: function() {
750                 return this.domManip(arguments, true, 1, function(a){
751                         this.appendChild( a );
752                 });
753         },
754
755         /**
756          * Prepend any number of elements to the inside of every matched elements,
757          * generated from the provided HTML.
758          * This operation is the best way to insert dynamically created elements
759          * inside, at the beginning, of all the matched element.
760          *
761          * @example $("p").prepend("<b>Hello</b>");
762          * @before <p>I would like to say: </p>
763          * @result <p><b>Hello</b>I would like to say: </p>
764          *
765          * @test var defaultText = 'Try them out:'
766          * var result = $('#first').prepend('<b>buga</b>');
767          * ok( result.text() == 'buga' + defaultText, 'Check if text prepending works' );
768          * ok( $('#select3').prepend('<option value="prependTest">Prepend Test</option>').find('option:first-child').attr('value') == 'prependTest', 'Prepending html options to select element');
769          *
770          * @name prepend
771          * @type jQuery
772          * @param String html A string of HTML, that will be created on the fly and appended to the target.
773          * @cat DOM/Manipulation
774          */
775
776         /**
777          * Prepend an element to the inside of all matched elements.
778          * This operation is the best way to insert an element inside, at the
779          * beginning, of all the matched element.
780          *
781          * @example $("p").prepend( $("#foo")[0] );
782          * @before <p>I would like to say: </p><b id="foo">Hello</b>
783          * @result <p><b id="foo">Hello</b>I would like to say: </p>
784          *       
785          * @test var expected = "Try them out:This link has class=\"blog\": Simon Willison's Weblog";
786          * $('#sap').prepend(document.getElementById('first'));
787          * ok( expected == $('#sap').text(), "Check for prepending of element" );
788          *
789          * @name prepend
790          * @type jQuery
791          * @param Element elem A DOM element that will be appended.
792          * @cat DOM/Manipulation
793          */
794
795         /**
796          * Prepend any number of elements to the inside of all matched elements.
797          * This operation is the best way to insert a set of elements inside, at the
798          * beginning, of all the matched element.
799          *
800          * @example $("p").prepend( $("b") );
801          * @before <p>I would like to say: </p><b>Hello</b>
802          * @result <p><b>Hello</b>I would like to say: </p>
803          *
804          * @test var expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog";
805          * $('#sap').prepend([document.getElementById('first'), document.getElementById('yahoo')]);
806          * ok( expected == $('#sap').text(), "Check for prepending of array of elements" );
807          *
808          * @name prepend
809          * @type jQuery
810          * @param Array<Element> elems An array of elements, all of which will be appended.
811          * @cat DOM/Manipulation
812          */
813         prepend: function() {
814                 return this.domManip(arguments, true, -1, function(a){
815                         this.insertBefore( a, this.firstChild );
816                 });
817         },
818
819         /**
820          * Insert any number of dynamically generated elements before each of the
821          * matched elements.
822          *
823          * @example $("p").before("<b>Hello</b>");
824          * @before <p>I would like to say: </p>
825          * @result <b>Hello</b><p>I would like to say: </p>
826          *
827          * @test var expected = 'This is a normal link: bugaYahoo';
828          * $('#yahoo').before('<b>buga</b>');
829          * ok( expected == $('#en').text(), 'Insert String before' );
830          *
831          * @name before
832          * @type jQuery
833          * @param String html A string of HTML, that will be created on the fly and appended to the target.
834          * @cat DOM/Manipulation
835          */
836
837         /**
838          * Insert an element before each of the matched elements.
839          *
840          * @example $("p").before( $("#foo")[0] );
841          * @before <p>I would like to say: </p><b id="foo">Hello</b>
842          * @result <b id="foo">Hello</b><p>I would like to say: </p>
843          *
844          * @test var expected = "This is a normal link: Try them out:Yahoo";
845          * $('#yahoo').before(document.getElementById('first'));
846          * ok( expected == $('#en').text(), "Insert element before" );
847          *
848          * @name before
849          * @type jQuery
850          * @param Element elem A DOM element that will be appended.
851          * @cat DOM/Manipulation
852          */
853
854         /**
855          * Insert any number of elements before each of the matched elements.
856          *
857          * @example $("p").before( $("b") );
858          * @before <p>I would like to say: </p><b>Hello</b>
859          * @result <b>Hello</b><p>I would like to say: </p>
860          *
861          * @test var expected = "This is a normal link: Try them out:diveintomarkYahoo";
862          * $('#yahoo').before([document.getElementById('first'), document.getElementById('mark')]);
863          * ok( expected == $('#en').text(), "Insert array of elements before" );
864          *
865          * @name before
866          * @type jQuery
867          * @param Array<Element> elems An array of elements, all of which will be appended.
868          * @cat DOM/Manipulation
869          */
870         before: function() {
871                 return this.domManip(arguments, false, 1, function(a){
872                         this.parentNode.insertBefore( a, this );
873                 });
874         },
875
876         /**
877          * Insert any number of dynamically generated elements after each of the
878          * matched elements.
879          *
880          * @example $("p").after("<b>Hello</b>");
881          * @before <p>I would like to say: </p>
882          * @result <p>I would like to say: </p><b>Hello</b>
883          *
884          * @test var expected = 'This is a normal link: Yahoobuga';
885          * $('#yahoo').after('<b>buga</b>');
886          * ok( expected == $('#en').text(), 'Insert String after' );
887          *
888          * @name after
889          * @type jQuery
890          * @param String html A string of HTML, that will be created on the fly and appended to the target.
891          * @cat DOM/Manipulation
892          */
893
894         /**
895          * Insert an element after each of the matched elements.
896          *
897          * @example $("p").after( $("#foo")[0] );
898          * @before <b id="foo">Hello</b><p>I would like to say: </p>
899          * @result <p>I would like to say: </p><b id="foo">Hello</b>
900          *
901          * @test var expected = "This is a normal link: YahooTry them out:";
902          * $('#yahoo').after(document.getElementById('first'));
903          * ok( expected == $('#en').text(), "Insert element after" );
904          *
905          * @name after
906          * @type jQuery
907          * @param Element elem A DOM element that will be appended.
908          * @cat DOM/Manipulation
909          */
910
911         /**
912          * Insert any number of elements after each of the matched elements.
913          *
914          * @example $("p").after( $("b") );
915          * @before <b>Hello</b><p>I would like to say: </p>
916          * @result <p>I would like to say: </p><b>Hello</b>
917          *
918          * @test var expected = "This is a normal link: YahooTry them out:diveintomark";
919          * $('#yahoo').after([document.getElementById('first'), document.getElementById('mark')]);
920          * ok( expected == $('#en').text(), "Insert array of elements after" );
921          *
922          * @name after
923          * @type jQuery
924          * @param Array<Element> elems An array of elements, all of which will be appended.
925          * @cat DOM/Manipulation
926          */
927         after: function() {
928                 return this.domManip(arguments, false, -1, function(a){
929                         this.parentNode.insertBefore( a, this.nextSibling );
930                 });
931         },
932
933         /**
934          * End the most recent 'destructive' operation, reverting the list of matched elements
935          * back to its previous state. After an end operation, the list of matched elements will
936          * revert to the last state of matched elements.
937          *
938          * @example $("p").find("span").end();
939          * @before <p><span>Hello</span>, how are you?</p>
940          * @result $("p").find("span").end() == [ <p>...</p> ]
941          *
942          * @test ok( 'Yahoo' == $('#yahoo').parent().end().text(), 'Check for end' );
943          *
944          * @name end
945          * @type jQuery
946          * @cat DOM/Traversing
947          */
948         end: function() {
949                 return this.get( this.stack.pop() );
950         },
951
952         /**
953          * Searches for all elements that match the specified expression.
954          * This method is the optimal way of finding additional descendant
955          * elements with which to process.
956          *
957          * All searching is done using a jQuery expression. The expression can be
958          * written using CSS 1-3 Selector syntax, or basic XPath.
959          *
960          * @example $("p").find("span");
961          * @before <p><span>Hello</span>, how are you?</p>
962          * @result $("p").find("span") == [ <span>Hello</span> ]
963          *
964          * @test ok( 'Yahoo' == $('#foo').find('.blogTest').text(), 'Check for find' );
965          *
966          * @name find
967          * @type jQuery
968          * @param String expr An expression to search with.
969          * @cat DOM/Traversing
970          */
971         find: function(t) {
972                 return this.pushStack( jQuery.map( this, function(a){
973                         return jQuery.find(t,a);
974                 }), arguments );
975         },
976
977         /**
978          * Create cloned copies of all matched DOM Elements. This does
979          * not create a cloned copy of this particular jQuery object,
980          * instead it creates duplicate copies of all DOM Elements.
981          * This is useful for moving copies of the elements to another
982          * location in the DOM.
983          *
984          * @example $("b").clone().prependTo("p");
985          * @before <b>Hello</b><p>, how are you?</p>
986          * @result <b>Hello</b><p><b>Hello</b>, how are you?</p>
987          *
988          * @test ok( 'This is a normal link: Yahoo' == $('#en').text(), 'Assert text for #en' );
989          * var clone = $('#yahoo').clone();
990          * ok( 'Try them out:Yahoo' == $('#first').append(clone).text(), 'Check for clone' );
991          * ok( 'This is a normal link: Yahoo' == $('#en').text(), 'Reassert text for #en' );
992          *
993          * @name clone
994          * @type jQuery
995          * @cat DOM/Manipulation
996          */
997         clone: function(deep) {
998                 return this.pushStack( jQuery.map( this, function(a){
999                         return a.cloneNode( deep != undefined ? deep : true );
1000                 }), arguments );
1001         },
1002
1003         /**
1004          * Removes all elements from the set of matched elements that do not
1005          * match the specified expression. This method is used to narrow down
1006          * the results of a search.
1007          *
1008          * All searching is done using a jQuery expression. The expression
1009          * can be written using CSS 1-3 Selector syntax, or basic XPath.
1010          *
1011          * @example $("p").filter(".selected")
1012          * @before <p class="selected">Hello</p><p>How are you?</p>
1013          * @result $("p").filter(".selected") == [ <p class="selected">Hello</p> ]
1014          *
1015          * @test isSet( $("input").filter(":checked").get(), q("radio2", "check1"), "Filter elements" );
1016          * @test $("input").filter(":checked",function(i){ 
1017          *   ok( this == q("radio2", "check1")[i], "Filter elements, context" );
1018          * });
1019          * @test $("#main > p#ap > a").filter("#foobar",function(){},function(i){
1020          *   ok( this == q("google","groups", "mark")[i], "Filter elements, else context" );
1021          * });
1022          *
1023          * @name filter
1024          * @type jQuery
1025          * @param String expr An expression to search with.
1026          * @cat DOM/Traversing
1027          */
1028
1029         /**
1030          * Removes all elements from the set of matched elements that do not
1031          * match at least one of the expressions passed to the function. This
1032          * method is used when you want to filter the set of matched elements
1033          * through more than one expression.
1034          *
1035          * Elements will be retained in the jQuery object if they match at
1036          * least one of the expressions passed.
1037          *
1038          * @example $("p").filter([".selected", ":first"])
1039          * @before <p>Hello</p><p>Hello Again</p><p class="selected">And Again</p>
1040          * @result $("p").filter([".selected", ":first"]) == [ <p>Hello</p>, <p class="selected">And Again</p> ]
1041          *
1042          * @name filter
1043          * @type jQuery
1044          * @param Array<String> exprs A set of expressions to evaluate against
1045          * @cat DOM/Traversing
1046          */
1047         filter: function(t) {
1048                 return this.pushStack(
1049                         t.constructor == Array &&
1050                         jQuery.map(this,function(a){
1051                                 for ( var i = 0; i < t.length; i++ )
1052                                         if ( jQuery.filter(t[i],[a]).r.length )
1053                                                 return a;
1054                                 return false;
1055                         }) ||
1056
1057                         t.constructor == Boolean &&
1058                         ( t ? this.get() : [] ) ||
1059
1060                         typeof t == "function" &&
1061                         jQuery.grep( this, t ) ||
1062
1063                         jQuery.filter(t,this).r, arguments );
1064         },
1065
1066         /**
1067          * Removes the specified Element from the set of matched elements. This
1068          * method is used to remove a single Element from a jQuery object.
1069          *
1070          * @example $("p").not( document.getElementById("selected") )
1071          * @before <p>Hello</p><p id="selected">Hello Again</p>
1072          * @result [ <p>Hello</p> ]
1073          *
1074          * @name not
1075          * @type jQuery
1076          * @param Element el An element to remove from the set
1077          * @cat DOM/Traversing
1078          */
1079
1080         /**
1081          * Removes elements matching the specified expression from the set
1082          * of matched elements. This method is used to remove one or more
1083          * elements from a jQuery object.
1084          *
1085          * @example $("p").not("#selected")
1086          * @before <p>Hello</p><p id="selected">Hello Again</p>
1087          * @result [ <p>Hello</p> ]
1088          *
1089          * @test ok($("#main > p#ap > a").not("#google").length == 2, ".not")
1090          *
1091          * @name not
1092          * @type jQuery
1093          * @param String expr An expression with which to remove matching elements
1094          * @cat DOM/Traversing
1095          */
1096         not: function(t) {
1097                 return this.pushStack( t.constructor == String ?
1098                         jQuery.filter(t,this,false).r :
1099                         jQuery.grep(this,function(a){ return a != t; }), arguments );
1100         },
1101
1102         /**
1103          * Adds the elements matched by the expression to the jQuery object. This
1104          * can be used to concatenate the result sets of two expressions.
1105          *
1106          * @example $("p").add("span")
1107          * @before <p>Hello</p><p><span>Hello Again</span></p>
1108          * @result [ <p>Hello</p>, <span>Hello Again</span> ]
1109          *
1110          * @name add
1111          * @type jQuery
1112          * @param String expr An expression whose matched elements are added
1113          * @cat DOM/Traversing
1114          */
1115
1116         /**
1117          * Adds each of the Elements in the array to the set of matched elements.
1118          * This is used to add a set of Elements to a jQuery object.
1119          *
1120          * @example $("p").add([document.getElementById("a"), document.getElementById("b")])
1121          * @before <p>Hello</p><p><span id="a">Hello Again</span><span id="b">And Again</span></p>
1122          * @result [ <p>Hello</p>, <span id="a">Hello Again</span>, <span id="b">And Again</span> ]
1123          *
1124          * @name add
1125          * @type jQuery
1126          * @param Array<Element> els An array of Elements to add
1127          * @cat DOM/Traversing
1128          */
1129
1130         /**
1131          * Adds a single Element to the set of matched elements. This is used to
1132          * add a single Element to a jQuery object.
1133          *
1134          * @example $("p").add( document.getElementById("a") )
1135          * @before <p>Hello</p><p><span id="a">Hello Again</span></p>
1136          * @result [ <p>Hello</p>, <span id="a">Hello Again</span> ]
1137          *
1138          * @name add
1139          * @type jQuery
1140          * @param Element el An Element to add
1141          * @cat DOM/Traversing
1142          */
1143         add: function(t) {
1144                 return this.pushStack( jQuery.merge( this, t.constructor == String ?
1145                         jQuery.find(t) : t.constructor == Array ? t : [t] ), arguments );
1146         },
1147
1148         /**
1149          * Checks the current selection against an expression and returns true,
1150          * if the selection fits the given expression. Does return false, if the
1151          * selection does not fit or the expression is not valid.
1152          *
1153          * @example $("input[@type='checkbox']").parent().is("form")
1154          * @before <form><input type="checkbox" /></form>
1155          * @result true
1156          * @desc Returns true, because the parent of the input is a form element
1157          * 
1158          * @example $("input[@type='checkbox']").parent().is("form")
1159          * @before <form><p><input type="checkbox" /></p></form>
1160          * @result false
1161          * @desc Returns false, because the parent of the input is a p element
1162          *
1163          * @example $("form").is(null)
1164          * @before <form></form>
1165          * @result false
1166          * @desc An invalid expression always returns false.
1167          *
1168          * @test ok( $('#form').is('form'), 'Check for element: A form must be a form' );
1169          * ok( !$('#form').is('div'), 'Check for element: A form is not a div' );
1170          * ok( $('#mark').is('.blog'), 'Check for class: Expected class "blog"' );
1171          * ok( !$('#mark').is('.link'), 'Check for class: Did not expect class "link"' );
1172          * ok( $('#simon').is('.blog.link'), 'Check for multiple classes: Expected classes "blog" and "link"' );
1173          * ok( !$('#simon').is('.blogTest'), 'Check for multiple classes: Expected classes "blog" and "link", but not "blogTest"' );
1174          * ok( $('#en').is('[@lang="en"]'), 'Check for attribute: Expected attribute lang to be "en"' );
1175          * ok( !$('#en').is('[@lang="de"]'), 'Check for attribute: Expected attribute lang to be "en", not "de"' );
1176          * ok( $('#text1').is('[@type="text"]'), 'Check for attribute: Expected attribute type to be "text"' );
1177          * ok( !$('#text1').is('[@type="radio"]'), 'Check for attribute: Expected attribute type to be "text", not "radio"' );
1178          * ok( $('#text2').is(':disabled'), 'Check for pseudoclass: Expected to be disabled' );
1179          * ok( !$('#text1').is(':disabled'), 'Check for pseudoclass: Expected not disabled' );
1180          * ok( $('#radio2').is(':checked'), 'Check for pseudoclass: Expected to be checked' );
1181          * ok( !$('#radio1').is(':checked'), 'Check for pseudoclass: Expected not checked' );
1182          * ok( $('#foo').is('[p]'), 'Check for child: Expected a child "p" element' );
1183          * ok( !$('#foo').is('[ul]'), 'Check for child: Did not expect "ul" element' );
1184          * ok( $('#foo').is('[p][a][code]'), 'Check for childs: Expected "p", "a" and "code" child elements' );
1185          * ok( !$('#foo').is('[p][a][code][ol]'), 'Check for childs: Expected "p", "a" and "code" child elements, but no "ol"' );
1186          * ok( !$('#foo').is(0), 'Expected false for an invalid expression - 0' );
1187          * ok( !$('#foo').is(null), 'Expected false for an invalid expression - null' );
1188          * ok( !$('#foo').is(''), 'Expected false for an invalid expression - ""' );
1189          * ok( !$('#foo').is(undefined), 'Expected false for an invalid expression - undefined' );
1190          *
1191          * @name is
1192          * @type Boolean
1193          * @param String expr The expression with which to filter
1194          * @cat DOM/Traversing
1195          */
1196         is: function(expr) {
1197                 return expr ? jQuery.filter(expr,this).r.length > 0 : false;
1198         },
1199         
1200         /**
1201          *
1202          *
1203          * @private
1204          * @name domManip
1205          * @param Array args
1206          * @param Boolean table
1207          * @param Number int
1208          * @param Function fn The function doing the DOM manipulation.
1209          * @type jQuery
1210          * @cat Core
1211          */
1212         domManip: function(args, table, dir, fn){
1213                 var clone = this.size() > 1;
1214                 var a = jQuery.clean(args);
1215
1216                 return this.each(function(){
1217                         var obj = this;
1218
1219                         if ( table && this.nodeName.toUpperCase() == "TABLE" && a[0].nodeName.toUpperCase() != "THEAD" ) {
1220                                 var tbody = this.getElementsByTagName("tbody");
1221
1222                                 if ( !tbody.length ) {
1223                                         obj = document.createElement("tbody");
1224                                         this.appendChild( obj );
1225                                 } else
1226                                         obj = tbody[0];
1227                         }
1228
1229                         for ( var i = ( dir < 0 ? a.length - 1 : 0 );
1230                                 i != ( dir < 0 ? dir : a.length ); i += dir ) {
1231                                         fn.apply( obj, [ clone ? a[i].cloneNode(true) : a[i] ] );
1232                         }
1233                 });
1234         },
1235
1236         /**
1237          *
1238          *
1239          * @private
1240          * @name pushStack
1241          * @param Array a
1242          * @param Array args
1243          * @type jQuery
1244          * @cat Core
1245          */
1246         pushStack: function(a,args) {
1247                 var fn = args && args[args.length-1];
1248                 var fn2 = args && args[args.length-2];
1249                 
1250                 if ( fn && fn.constructor != Function ) fn = null;
1251                 if ( fn2 && fn2.constructor != Function ) fn2 = null;
1252
1253                 if ( !fn ) {
1254                         if ( !this.stack ) this.stack = [];
1255                         this.stack.push( this.get() );
1256                         this.get( a );
1257                 } else {
1258                         var old = this.get();
1259                         this.get( a );
1260
1261                         if ( fn2 && a.length || !fn2 )
1262                                 this.each( fn2 || fn ).get( old );
1263                         else
1264                                 this.get( old ).each( fn );
1265                 }
1266
1267                 return this;
1268         }
1269 };
1270
1271 /**
1272  * Extends the jQuery object itself. Can be used to add both static
1273  * functions and plugin methods.
1274  * 
1275  * @example $.fn.extend({
1276  *   check: function() {
1277  *     this.each(function() { this.checked = true; });
1278  *   ),
1279  *   uncheck: function() {
1280  *     this.each(function() { this.checked = false; });
1281  *   }
1282  * });
1283  * $("input[@type=checkbox]").check();
1284  * $("input[@type=radio]").uncheck();
1285  * @desc Adds two plugin methods.
1286  *
1287  * @private
1288  * @name extend
1289  * @param Object obj
1290  * @type Object
1291  * @cat Core
1292  */
1293
1294 /**
1295  * Extend one object with another, returning the original,
1296  * modified, object. This is a great utility for simple inheritance.
1297  * 
1298  * @example var settings = { validate: false, limit: 5, name: "foo" };
1299  * var options = { validate: true, name: "bar" };
1300  * jQuery.extend(settings, options);
1301  * @result settings == { validate: true, limit: 5, name: "bar" }
1302  *
1303  * @test var settings = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" };
1304  * var options =     { xnumber2: 1, xstring2: "x", xxx: "newstring" };
1305  * var optionsCopy = { xnumber2: 1, xstring2: "x", xxx: "newstring" };
1306  * var merged = { xnumber1: 5, xnumber2: 1, xstring1: "peter", xstring2: "x", xxx: "newstring" };
1307  * jQuery.extend(settings, options);
1308  * isSet( settings, merged, "Check if extended: settings must be extended" );
1309  * isSet ( options, optionsCopy, "Check if not modified: options must not be modified" );
1310  *
1311  * @name $.extend
1312  * @param Object obj The object to extend
1313  * @param Object prop The object that will be merged into the first.
1314  * @type Object
1315  * @cat Javascript
1316  */
1317 jQuery.extend = jQuery.fn.extend = function(obj,prop) {
1318         // Watch for the case where null or undefined gets passed in by accident
1319         if ( arguments.length > 1 && (prop === null || prop == undefined) )
1320                 return obj;
1321
1322         // If no property object was provided, then we're extending jQuery
1323         if ( !prop ) { prop = obj; obj = this; }
1324
1325         // Extend the base object
1326         for ( var i in prop ) obj[i] = prop[i];
1327
1328         // Return the modified object
1329         return obj;
1330 };
1331
1332 jQuery.extend({
1333         /**
1334          * @private
1335          * @name init
1336          * @type undefined
1337          * @cat Core
1338          */
1339         init: function(){
1340                 jQuery.initDone = true;
1341
1342                 jQuery.each( jQuery.macros.axis, function(i,n){
1343                         jQuery.fn[ i ] = function(a) {
1344                                 var ret = jQuery.map(this,n);
1345                                 if ( a && a.constructor == String )
1346                                         ret = jQuery.filter(a,ret).r;
1347                                 return this.pushStack( ret, arguments );
1348                         };
1349                 });
1350
1351                 jQuery.each( jQuery.macros.to, function(i,n){
1352                         jQuery.fn[ i ] = function(){
1353                                 var a = arguments;
1354                                 return this.each(function(){
1355                                         for ( var j = 0; j < a.length; j++ )
1356                                                 jQuery(a[j])[n]( this );
1357                                 });
1358                         };
1359                 });
1360
1361                 jQuery.each( jQuery.macros.each, function(i,n){
1362                         jQuery.fn[ i ] = function() {
1363                                 return this.each( n, arguments );
1364                         };
1365                 });
1366
1367                 jQuery.each( jQuery.macros.filter, function(i,n){
1368                         jQuery.fn[ n ] = function(num,fn) {
1369                                 return this.filter( ":" + n + "(" + num + ")", fn );
1370                         };
1371                 });
1372
1373                 jQuery.each( jQuery.macros.attr, function(i,n){
1374                         n = n || i;
1375                         jQuery.fn[ i ] = function(h) {
1376                                 return h == undefined ?
1377                                         this.length ? this[0][n] : null :
1378                                         this.attr( n, h );
1379                         };
1380                 });
1381
1382                 jQuery.each( jQuery.macros.css, function(i,n){
1383                         jQuery.fn[ n ] = function(h) {
1384                                 return h == undefined ?
1385                                         ( this.length ? jQuery.css( this[0], n ) : null ) :
1386                                         this.css( n, h );
1387                         };
1388                 });
1389
1390         },
1391
1392         /**
1393          * A generic iterator function, which can be used to seemlessly
1394          * iterate over both objects and arrays. This function is not the same
1395          * as $().each() - which is used to iterate, exclusively, over a jQuery
1396          * object. This function can be used to iterate over anything.
1397          *
1398          * @example $.each( [0,1,2], function(i){
1399          *   alert( "Item #" + i + ": " + this );
1400          * });
1401          * @desc This is an example of iterating over the items in an array, accessing both the current item and its index.
1402          *
1403          * @example $.each( { name: "John", lang: "JS" }, function(i){
1404          *   alert( "Name: " + i + ", Value: " + this );
1405          * });
1406          * @desc This is an example of iterating over the properties in an Object, accessing both the current item and its key.
1407          *
1408          * @name $.each
1409          * @param Object obj The object, or array, to iterate over.
1410          * @param Function fn The function that will be executed on every object.
1411          * @type Object
1412          * @cat Javascript
1413          */
1414         each: function( obj, fn, args ) {
1415                 if ( obj.length == undefined )
1416                         for ( var i in obj )
1417                                 fn.apply( obj[i], args || [i, obj[i]] );
1418                 else
1419                         for ( var i = 0; i < obj.length; i++ )
1420                                 if ( fn.apply( obj[i], args || [i, obj[i]] ) === false ) break;
1421                 return obj;
1422         },
1423
1424         className: {
1425                 add: function(o,c){
1426                         if (jQuery.className.has(o,c)) return;
1427                         o.className += ( o.className ? " " : "" ) + c;
1428                 },
1429                 remove: function(o,c){
1430                         if( !c ) {
1431                                 o.className = "";
1432                         } else {
1433                                 var classes = o.className.split(" ");
1434                                 for(var i=0; i<classes.length; i++) {
1435                                         if(classes[i] == c) {
1436                                                 classes.splice(i, 1);
1437                                                 break;
1438                                         }
1439                                 }
1440                                 o.className = classes.join(' ');
1441                         }
1442                 },
1443                 has: function(e,a) {
1444                         if ( e.className != undefined )
1445                                 e = e.className;
1446                         return new RegExp("(^|\\s)" + a + "(\\s|$)").test(e);
1447                 }
1448         },
1449
1450         /**
1451          * Swap in/out style options.
1452          * @private
1453          */
1454         swap: function(e,o,f) {
1455                 for ( var i in o ) {
1456                         e.style["old"+i] = e.style[i];
1457                         e.style[i] = o[i];
1458                 }
1459                 f.apply( e, [] );
1460                 for ( var i in o )
1461                         e.style[i] = e.style["old"+i];
1462         },
1463
1464         css: function(e,p) {
1465                 if ( p == "height" || p == "width" ) {
1466                         var old = {}, oHeight, oWidth, d = ["Top","Bottom","Right","Left"];
1467
1468                         for ( var i in d ) {
1469                                 old["padding" + d[i]] = 0;
1470                                 old["border" + d[i] + "Width"] = 0;
1471                         }
1472
1473                         jQuery.swap( e, old, function() {
1474                                 if (jQuery.css(e,"display") != "none") {
1475                                         oHeight = e.offsetHeight;
1476                                         oWidth = e.offsetWidth;
1477                                 } else {
1478                                         e = jQuery(e.cloneNode(true))
1479                                                 .find(":radio").removeAttr("checked").end()
1480                                                 .css({
1481                                                         visibility: "hidden", position: "absolute", display: "block", right: "0", left: "0"
1482                                                 }).appendTo(e.parentNode)[0];
1483
1484                                         var parPos = jQuery.css(e.parentNode,"position");
1485                                         if ( parPos == "" || parPos == "static" )
1486                                                 e.parentNode.style.position = "relative";
1487
1488                                         oHeight = e.clientHeight;
1489                                         oWidth = e.clientWidth;
1490
1491                                         if ( parPos == "" || parPos == "static" )
1492                                                 e.parentNode.style.position = "static";
1493
1494                                         e.parentNode.removeChild(e);
1495                                 }
1496                         });
1497
1498                         return p == "height" ? oHeight : oWidth;
1499                 }
1500
1501                 return jQuery.curCSS( e, p );
1502         },
1503
1504         curCSS: function(elem, prop, force) {
1505                 var ret;
1506                 
1507                 if (prop == 'opacity' && jQuery.browser.msie)
1508                         return jQuery.attr(elem.style, 'opacity');
1509                         
1510                 if (prop == "float" || prop == "cssFloat")
1511                     prop = jQuery.browser.msie ? "styleFloat" : "cssFloat";
1512
1513                 if (!force && elem.style[prop]) {
1514
1515                         ret = elem.style[prop];
1516
1517                 } else if (elem.currentStyle) {
1518
1519                         var newProp = prop.replace(/\-(\w)/g,function(m,c){return c.toUpperCase();});
1520                         ret = elem.currentStyle[prop] || elem.currentStyle[newProp];
1521
1522                 } else if (document.defaultView && document.defaultView.getComputedStyle) {
1523
1524                         if (prop == "cssFloat" || prop == "styleFloat")
1525                                 prop = "float";
1526
1527                         prop = prop.replace(/([A-Z])/g,"-$1").toLowerCase();
1528                         var cur = document.defaultView.getComputedStyle(elem, null);
1529
1530                         if ( cur )
1531                                 ret = cur.getPropertyValue(prop);
1532                         else if ( prop == 'display' )
1533                                 ret = 'none';
1534                         else
1535                                 jQuery.swap(elem, { display: 'block' }, function() {
1536                                         ret = document.defaultView.getComputedStyle(this,null).getPropertyValue(prop);
1537                                 });
1538
1539                 }
1540
1541                 return ret;
1542         },
1543
1544         clean: function(a) {
1545                 var r = [];
1546                 for ( var i = 0; i < a.length; i++ ) {
1547                         if ( a[i].constructor == String ) {
1548                                 // trim whitespace, otherwise indexOf won't work as expected
1549                                 a[i] = jQuery.trim(a[i]);
1550                                 
1551                                 var table = "";
1552
1553                                 if ( !a[i].indexOf("<opt") ) {
1554                                    table = "thead";
1555                                    a[i] = "<select>" + a[i] + "</select>";
1556                                 } else if ( !a[i].indexOf("<thead") || !a[i].indexOf("<tbody") ) {
1557                                         table = "thead";
1558                                         a[i] = "<table>" + a[i] + "</table>";
1559                                 } else if ( !a[i].indexOf("<tr") ) {
1560                                         table = "tr";
1561                                         a[i] = "<table>" + a[i] + "</table>";
1562                                 } else if ( !a[i].indexOf("<td") || !a[i].indexOf("<th") ) {
1563                                         table = "td";
1564                                         a[i] = "<table><tbody><tr>" + a[i] + "</tr></tbody></table>";
1565                                 }
1566
1567                                 var div = document.createElement("div");
1568                                 div.innerHTML = a[i];
1569
1570                                 if ( table ) {
1571                                         div = div.firstChild;
1572                                         if ( table != "thead" ) div = div.firstChild;
1573                                         if ( table == "td" ) div = div.firstChild;
1574                                 }
1575
1576                                 for ( var j = 0; j < div.childNodes.length; j++ )
1577                                         r.push( div.childNodes[j] );
1578                                 } else if ( a[i].jquery || a[i].length && !a[i].nodeType )
1579                                         for ( var k = 0; k < a[i].length; k++ )
1580                                                 r.push( a[i][k] );
1581                                 else if ( a[i] !== null )
1582                                         r.push( a[i].nodeType ? a[i] : document.createTextNode(a[i].toString()) );
1583                 }
1584                 return r;
1585         },
1586
1587         expr: {
1588                 "": "m[2]== '*'||a.nodeName.toUpperCase()==m[2].toUpperCase()",
1589                 "#": "a.getAttribute('id')&&a.getAttribute('id')==m[2]",
1590                 ":": {
1591                         // Position Checks
1592                         lt: "i<m[3]-0",
1593                         gt: "i>m[3]-0",
1594                         nth: "m[3]-0==i",
1595                         eq: "m[3]-0==i",
1596                         first: "i==0",
1597                         last: "i==r.length-1",
1598                         even: "i%2==0",
1599                         odd: "i%2",
1600
1601                         // Child Checks
1602                         "nth-child": "jQuery.sibling(a,m[3]).cur",
1603                         "first-child": "jQuery.sibling(a,0).cur",
1604                         "last-child": "jQuery.sibling(a,0).last",
1605                         "only-child": "jQuery.sibling(a).length==1",
1606
1607                         // Parent Checks
1608                         parent: "a.childNodes.length",
1609                         empty: "!a.childNodes.length",
1610
1611                         // Text Check
1612                         contains: "jQuery.fn.text.apply([a]).indexOf(m[3])>=0",
1613
1614                         // Visibility
1615                         visible: "a.type!='hidden'&&jQuery.css(a,'display')!='none'&&jQuery.css(a,'visibility')!='hidden'",
1616                         hidden: "a.type=='hidden'||jQuery.css(a,'display')=='none'||jQuery.css(a,'visibility')=='hidden'",
1617
1618                         // Form attributes
1619                         enabled: "!a.disabled",
1620                         disabled: "a.disabled",
1621                         checked: "a.checked",
1622                         selected: "a.selected || jQuery.attr(a, 'selected')",
1623
1624                         // Form elements
1625                         text: "a.type=='text'",
1626                         radio: "a.type=='radio'",
1627                         checkbox: "a.type=='checkbox'",
1628                         file: "a.type=='file'",
1629                         password: "a.type=='password'",
1630                         submit: "a.type=='submit'",
1631                         image: "a.type=='image'",
1632                         reset: "a.type=='reset'",
1633                         button: "a.type=='button'",
1634                         input: "a.nodeName.toLowerCase().match(/input|select|textarea|button/)"
1635                 },
1636                 ".": "jQuery.className.has(a,m[2])",
1637                 "@": {
1638                         "=": "z==m[4]",
1639                         "!=": "z!=m[4]",
1640                         "^=": "z && !z.indexOf(m[4])",
1641                         "$=": "z && z.substr(z.length - m[4].length,m[4].length)==m[4]",
1642                         "*=": "z && z.indexOf(m[4])>=0",
1643                         "": "z"
1644                 },
1645                 "[": "jQuery.find(m[2],a).length"
1646         },
1647
1648         token: [
1649                 "\\.\\.|/\\.\\.", "a.parentNode",
1650                 ">|/", "jQuery.sibling(a.firstChild)",
1651                 "\\+", "jQuery.sibling(a).next",
1652                 "~", function(a){
1653                         var r = [];
1654                         var s = jQuery.sibling(a);
1655                         if ( s.n > 0 )
1656                                 for ( var i = s.n; i < s.length; i++ )
1657                                         r.push( s[i] );
1658                         return r;
1659                 }
1660         ],
1661
1662         /**
1663          *
1664          * @test t( "Element Selector", "div", ["main","foo"] );
1665          * t( "Element Selector", "body", ["body"] );
1666          * t( "Element Selector", "html", ["html"] );
1667          * ok( $("*").size() >= 30, "Element Selector" );
1668          * t( "Parent Element", "div div", ["foo"] );
1669          *
1670          * t( "ID Selector", "#body", ["body"] );
1671          * t( "ID Selector w/ Element", "body#body", ["body"] );
1672          * t( "ID Selector w/ Element", "ul#first", [] );
1673          *
1674          * t( "Class Selector", ".blog", ["mark","simon"] );
1675          * t( "Class Selector", ".blog.link", ["simon"] );
1676          * t( "Class Selector w/ Element", "a.blog", ["mark","simon"] );
1677          * t( "Parent Class Selector", "p .blog", ["mark","simon"] );
1678          *
1679          * t( "Comma Support", "a.blog, div", ["mark","simon","main","foo"] );
1680          * t( "Comma Support", "a.blog , div", ["mark","simon","main","foo"] );
1681          * t( "Comma Support", "a.blog ,div", ["mark","simon","main","foo"] );
1682          * t( "Comma Support", "a.blog,div", ["mark","simon","main","foo"] );
1683          *
1684          * t( "Child", "p > a", ["simon1","google","groups","mark","yahoo","simon"] );
1685          * t( "Child", "p> a", ["simon1","google","groups","mark","yahoo","simon"] );
1686          * t( "Child", "p >a", ["simon1","google","groups","mark","yahoo","simon"] );
1687          * t( "Child", "p>a", ["simon1","google","groups","mark","yahoo","simon"] );
1688          * t( "Child w/ Class", "p > a.blog", ["mark","simon"] );
1689          * t( "All Children", "code > *", ["anchor1","anchor2"] );
1690          * t( "All Grandchildren", "p > * > *", ["anchor1","anchor2"] );
1691          * t( "Adjacent", "a + a", ["groups"] );
1692          * t( "Adjacent", "a +a", ["groups"] );
1693          * t( "Adjacent", "a+ a", ["groups"] );
1694          * t( "Adjacent", "a+a", ["groups"] );
1695          * t( "Adjacent", "p + p", ["ap","en","sap"] );
1696          * t( "Comma, Child, and Adjacent", "a + a, code > a", ["groups","anchor1","anchor2"] );
1697          * t( "First Child", "p:first-child", ["firstp","sndp"] );
1698          * t( "Attribute Exists", "a[@title]", ["google"] );
1699          * t( "Attribute Exists", "*[@title]", ["google"] );
1700          * t( "Attribute Exists", "[@title]", ["google"] );
1701          * 
1702          * t( "Non-existing part of attribute", "[@name*=bla]", [] ); 
1703          * t( "Non-existing start of attribute", "[@name^=bla]", [] ); 
1704          * t( "Non-existing end of attribute", "[@name$=bla]", [] ); 
1705          *
1706          * t( "Attribute Equals", "a[@rel='bookmark']", ["simon1"] );
1707          * t( "Attribute Equals", 'a[@rel="bookmark"]', ["simon1"] );
1708          * t( "Attribute Equals", "a[@rel=bookmark]", ["simon1"] );
1709          * t( "Multiple Attribute Equals", "input[@type='hidden'],input[@type='radio']", ["hidden1","radio1","radio2"] );
1710          * t( "Multiple Attribute Equals", "input[@type=\"hidden\"],input[@type='radio']", ["hidden1","radio1","radio2"] );
1711          * t( "Multiple Attribute Equals", "input[@type=hidden],input[@type=radio]", ["hidden1","radio1","radio2"] );
1712          *
1713          * t( "Attribute Begins With", "a[@href ^= 'http://www']", ["google","yahoo"] );
1714          * t( "Attribute Ends With", "a[@href $= 'org/']", ["mark"] );
1715          * t( "Attribute Contains", "a[@href *= 'google']", ["google","groups"] );
1716          * t( "First Child", "p:first-child", ["firstp","sndp"] );
1717          * t( "Last Child", "p:last-child", ["sap"] );
1718          * t( "Only Child", "a:only-child", ["simon1","anchor1","yahoo","anchor2"] );
1719          * t( "Empty", "ul:empty", ["firstUL"] );
1720          * t( "Enabled UI Element", "input:enabled", ["text1","radio1","radio2","check1","check2","hidden1","hidden2","name"] );
1721          * t( "Disabled UI Element", "input:disabled", ["text2"] );
1722          * t( "Checked UI Element", "input:checked", ["radio2","check1"] );
1723          * t( "Selected Option Element", "option:selected", ["option1a","option2d","option3b","option3c"] );
1724          * t( "Text Contains", "a:contains('Google')", ["google","groups"] );
1725          * t( "Text Contains", "a:contains('Google Groups')", ["groups"] );
1726          * t( "Element Preceded By", "p ~ div", ["foo"] );
1727          * t( "Not", "a.blog:not(.link)", ["mark"] );
1728          *
1729          * ok( jQuery.find("//*").length >= 30, "All Elements (//*)" );
1730          * t( "All Div Elements", "//div", ["main","foo"] );
1731          * t( "Absolute Path", "/html/body", ["body"] );
1732          * t( "Absolute Path w/ *", "/* /body", ["body"] );
1733          * t( "Long Absolute Path", "/html/body/dl/div/div/p", ["sndp","en","sap"] );
1734          * t( "Absolute and Relative Paths", "/html//div", ["main","foo"] );
1735          * t( "All Children, Explicit", "//code/*", ["anchor1","anchor2"] );
1736          * t( "All Children, Implicit", "//code/", ["anchor1","anchor2"] );
1737          * t( "Attribute Exists", "//a[@title]", ["google"] );
1738          * t( "Attribute Equals", "//a[@rel='bookmark']", ["simon1"] );
1739          * t( "Parent Axis", "//p/..", ["main","foo"] );
1740          * t( "Sibling Axis", "//p/../", ["firstp","ap","foo","first","firstUL","empty","form","sndp","en","sap"] );
1741          * t( "Sibling Axis", "//p/../*", ["firstp","ap","foo","first","firstUL","empty","form","sndp","en","sap"] );
1742          * t( "Has Children", "//p[a]", ["firstp","ap","en","sap"] );
1743          *
1744          * t( "nth Element", "p:nth(1)", ["ap"] );
1745          * t( "First Element", "p:first", ["firstp"] );
1746          * t( "Last Element", "p:last", ["first"] );
1747          * t( "Even Elements", "p:even", ["firstp","sndp","sap"] );
1748          * t( "Odd Elements", "p:odd", ["ap","en","first"] );
1749          * t( "Position Equals", "p:eq(1)", ["ap"] );
1750          * t( "Position Greater Than", "p:gt(0)", ["ap","sndp","en","sap","first"] );
1751          * t( "Position Less Than", "p:lt(3)", ["firstp","ap","sndp"] );
1752          * t( "Is A Parent", "p:parent", ["firstp","ap","sndp","en","sap","first"] );
1753          * t( "Is Visible", "input:visible", ["text1","text2","radio1","radio2","check1","check2","name"] );
1754          * t( "Is Hidden", "input:hidden", ["hidden1","hidden2"] );
1755          *
1756          * t( "Grouped Form Elements", "input[@name='foo[bar]']", ["hidden2"] );
1757          *
1758          * t( "All Children of ID", "#foo/*", ["sndp", "en", "sap"]  );
1759          * t( "All Children of ID with no children", "#firstUL/*", []  );
1760          *
1761          * t( "Form element :input", ":input", ["text1", "text2", "radio1", "radio2", "check1", "check2", "hidden1", "hidden2", "name", "button", "area1", "select1", "select2", "select3"] );
1762          * t( "Form element :radio", ":radio", ["radio1", "radio2"] );
1763          * t( "Form element :checkbox", ":checkbox", ["check1", "check2"] );
1764          * t( "Form element :text", ":text", ["text1", "text2", "hidden2", "name"] );
1765          * t( "Form element :radio:checked", ":radio:checked", ["radio2"] );
1766          * t( "Form element :checkbox:checked", ":checkbox:checked", ["check1"] );
1767          * t( "Form element :checkbox:checked, :radio:checked", ":checkbox:checked, :radio:checked", ["check1", "radio2"] );
1768          *
1769          * t( ":not() Existing attribute", "select:not([@multiple])", ["select1", "select2"]);
1770          * t( ":not() Equals attribute", "select:not([@name=select1])", ["select2", "select3"]);
1771          * t( ":not() Equals quoted attribute", "select:not([@name='select1'])", ["select2", "select3"]);
1772          *
1773          * @name $.find
1774          * @type Array<Element>
1775          * @private
1776          * @cat Core
1777          */
1778         find: function( t, context ) {
1779                 // Make sure that the context is a DOM Element
1780                 if ( context && context.nodeType == undefined )
1781                         context = null;
1782
1783                 // Set the correct context (if none is provided)
1784                 context = context || jQuery.context || document;
1785
1786                 if ( t.constructor != String ) return [t];
1787
1788                 if ( !t.indexOf("//") ) {
1789                         context = context.documentElement;
1790                         t = t.substr(2,t.length);
1791                 } else if ( !t.indexOf("/") ) {
1792                         context = context.documentElement;
1793                         t = t.substr(1,t.length);
1794                         // FIX Assume the root element is right :(
1795                         if ( t.indexOf("/") >= 1 )
1796                                 t = t.substr(t.indexOf("/"),t.length);
1797                 }
1798
1799                 var ret = [context];
1800                 var done = [];
1801                 var last = null;
1802
1803                 while ( t.length > 0 && last != t ) {
1804                         var r = [];
1805                         last = t;
1806
1807                         t = jQuery.trim(t).replace( /^\/\//i, "" );
1808
1809                         var foundToken = false;
1810
1811                         for ( var i = 0; i < jQuery.token.length; i += 2 ) {
1812                                 if ( foundToken ) continue;
1813
1814                                 var re = new RegExp("^(" + jQuery.token[i] + ")");
1815                                 var m = re.exec(t);
1816
1817                                 if ( m ) {
1818                                         r = ret = jQuery.map( ret, jQuery.token[i+1] );
1819                                         t = jQuery.trim( t.replace( re, "" ) );
1820                                         foundToken = true;
1821                                 }
1822                         }
1823
1824                         if ( !foundToken ) {
1825                                 if ( !t.indexOf(",") || !t.indexOf("|") ) {
1826                                         if ( ret[0] == context ) ret.shift();
1827                                         done = jQuery.merge( done, ret );
1828                                         r = ret = [context];
1829                                         t = " " + t.substr(1,t.length);
1830                                 } else {
1831                                         var re2 = /^([#.]?)([a-z0-9\\*_-]*)/i;
1832                                         var m = re2.exec(t);
1833
1834                                         if ( m[1] == "#" ) {
1835                                                 // Ummm, should make this work in all XML docs
1836                                                 var oid = document.getElementById(m[2]);
1837                                                 r = ret = oid ? [oid] : [];
1838                                                 t = t.replace( re2, "" );
1839                                         } else {
1840                                                 if ( !m[2] || m[1] == "." ) m[2] = "*";
1841
1842                                                 for ( var i = 0; i < ret.length; i++ )
1843                                                         r = jQuery.merge( r,
1844                                                                 m[2] == "*" ?
1845                                                                         jQuery.getAll(ret[i]) :
1846                                                                         ret[i].getElementsByTagName(m[2])
1847                                                         );
1848                                         }
1849                                 }
1850
1851                         }
1852
1853                         if ( t ) {
1854                                 var val = jQuery.filter(t,r);
1855                                 ret = r = val.r;
1856                                 t = jQuery.trim(val.t);
1857                         }
1858                 }
1859
1860                 if ( ret && ret[0] == context ) ret.shift();
1861                 done = jQuery.merge( done, ret );
1862
1863                 return done;
1864         },
1865
1866         getAll: function(o,r) {
1867                 r = r || [];
1868                 var s = o.childNodes;
1869                 for ( var i = 0; i < s.length; i++ )
1870                         if ( s[i].nodeType == 1 ) {
1871                                 r.push( s[i] );
1872                                 jQuery.getAll( s[i], r );
1873                         }
1874                 return r;
1875         },
1876
1877         attr: function(elem, name, value){
1878                 var fix = {
1879                         "for": "htmlFor",
1880                         "class": "className",
1881                         "float": jQuery.browser.msie ? "styleFloat" : "cssFloat",
1882                         cssFloat: jQuery.browser.msie ? "styleFloat" : "cssFloat",
1883                         innerHTML: "innerHTML",
1884                         className: "className",
1885                         value: "value",
1886                         disabled: "disabled",
1887                         checked: "checked"
1888                 };
1889                 
1890                 // IE actually uses filters for opacity ... elem is actually elem.style
1891                 if (name == "opacity" && jQuery.browser.msie && value != undefined) {
1892                         // IE has trouble with opacity if it does not have layout
1893                         // Would prefer to check element.hasLayout first but don't have access to the element here
1894                         elem['zoom'] = 1; 
1895                         if (value == 1) // Remove filter to avoid more IE weirdness
1896                                 return elem["filter"] = elem["filter"].replace(/alpha\([^\)]*\)/gi,"");
1897                         else
1898                                 return elem["filter"] = elem["filter"].replace(/alpha\([^\)]*\)/gi,"") + "alpha(opacity=" + value * 100 + ")";
1899                 } else if (name == "opacity" && jQuery.browser.msie) {
1900                         return elem["filter"] ? parseFloat( elem["filter"].match(/alpha\(opacity=(.*)\)/)[1] )/100 : 1;
1901                 }
1902                 
1903                 // Mozilla doesn't play well with opacity 1
1904                 if (name == "opacity" && jQuery.browser.mozilla && value == 1) value = 0.9999;
1905
1906                 if ( fix[name] ) {
1907                         if ( value != undefined ) elem[fix[name]] = value;
1908                         return elem[fix[name]];
1909                 } else if( value == undefined && jQuery.browser.msie && elem.nodeName && elem.nodeName.toUpperCase() == 'FORM' && (name == 'action' || name == 'method') ) {
1910                         return elem.getAttributeNode(name).nodeValue;
1911                 } else if ( elem.getAttribute != undefined && elem.tagName ) { // IE elem.getAttribute passes even for style
1912                         if ( value != undefined ) elem.setAttribute( name, value );
1913                         return elem.getAttribute( name );
1914                 } else {
1915                         name = name.replace(/-([a-z])/ig,function(z,b){return b.toUpperCase();});
1916                         if ( value != undefined ) elem[name] = value;
1917                         return elem[name];
1918                 }
1919         },
1920
1921         // The regular expressions that power the parsing engine
1922         parse: [
1923                 // Match: [@value='test'], [@foo]
1924                 "\\[ *(@)S *([!*$^=]*) *('?\"?)(.*?)\\4 *\\]",
1925
1926                 // Match: [div], [div p]
1927                 "(\\[)\s*(.*?)\s*\\]",
1928
1929                 // Match: :contains('foo')
1930                 "(:)S\\(\"?'?([^\\)]*?)\"?'?\\)",
1931
1932                 // Match: :even, :last-chlid
1933                 "([:.#]*)S"
1934         ],
1935
1936         filter: function(t,r,not) {
1937                 // Figure out if we're doing regular, or inverse, filtering
1938                 var g = not !== false ? jQuery.grep :
1939                         function(a,f) {return jQuery.grep(a,f,true);};
1940
1941                 while ( t && /^[a-z[({<*:.#]/i.test(t) ) {
1942
1943                         var p = jQuery.parse;
1944
1945                         for ( var i = 0; i < p.length; i++ ) {
1946                 
1947                                 // Look for, and replace, string-like sequences
1948                                 // and finally build a regexp out of it
1949                                 var re = new RegExp(
1950                                         "^" + p[i].replace("S", "([a-z*_-][a-z0-9_-]*)"), "i" );
1951
1952                                 var m = re.exec( t );
1953
1954                                 if ( m ) {
1955                                         // Re-organize the first match
1956                                         if ( !i )
1957                                                 m = ["",m[1], m[3], m[2], m[5]];
1958
1959                                         // Remove what we just matched
1960                                         t = t.replace( re, "" );
1961
1962                                         break;
1963                                 }
1964                         }
1965
1966                         // :not() is a special case that can be optimized by
1967                         // keeping it out of the expression list
1968                         if ( m[1] == ":" && m[2] == "not" )
1969                                 r = jQuery.filter(m[3],r,false).r;
1970
1971                         // Otherwise, find the expression to execute
1972                         else {
1973                                 var f = jQuery.expr[m[1]];
1974                                 if ( f.constructor != String )
1975                                         f = jQuery.expr[m[1]][m[2]];
1976
1977                                 // Build a custom macro to enclose it
1978                                 eval("f = function(a,i){" +
1979                                         ( m[1] == "@" ? "z=jQuery.attr(a,m[3]);" : "" ) +
1980                                         "return " + f + "}");
1981
1982                                 // Execute it against the current filter
1983                                 r = g( r, f );
1984                         }
1985                 }
1986
1987                 // Return an array of filtered elements (r)
1988                 // and the modified expression string (t)
1989                 return { r: r, t: t };
1990         },
1991
1992         /**
1993          * Remove the whitespace from the beginning and end of a string.
1994          *
1995          * @example $.trim("  hello, how are you?  ");
1996          * @result "hello, how are you?"
1997          *
1998          * @name $.trim
1999          * @type String
2000          * @param String str The string to trim.
2001          * @cat Javascript
2002          */
2003         trim: function(t){
2004                 return t.replace(/^\s+|\s+$/g, "");
2005         },
2006
2007         /**
2008          * All ancestors of a given element.
2009          *
2010          * @private
2011          * @name $.parents
2012          * @type Array<Element>
2013          * @param Element elem The element to find the ancestors of.
2014          * @cat DOM/Traversing
2015          */
2016         parents: function( elem ){
2017                 var matched = [];
2018                 var cur = elem.parentNode;
2019                 while ( cur && cur != document ) {
2020                         matched.push( cur );
2021                         cur = cur.parentNode;
2022                 }
2023                 return matched;
2024         },
2025
2026         /**
2027          * All elements on a specified axis.
2028          *
2029          * @private
2030          * @name $.sibling
2031          * @type Array
2032          * @param Element elem The element to find all the siblings of (including itself).
2033          * @cat DOM/Traversing
2034          */
2035         sibling: function(elem, pos, not) {
2036                 var elems = [];
2037                 
2038                 if(elem) {
2039                         var siblings = elem.parentNode.childNodes;
2040                         for ( var i = 0; i < siblings.length; i++ ) {
2041                                 if ( not === true && siblings[i] == elem ) continue;
2042         
2043                                 if ( siblings[i].nodeType == 1 )
2044                                         elems.push( siblings[i] );
2045                                 if ( siblings[i] == elem )
2046                                         elems.n = elems.length - 1;
2047                         }
2048                 }
2049
2050                 return jQuery.extend( elems, {
2051                         last: elems.n == elems.length - 1,
2052                         cur: pos == "even" && elems.n % 2 == 0 || pos == "odd" && elems.n % 2 || elems[pos] == elem,
2053                         prev: elems[elems.n - 1],
2054                         next: elems[elems.n + 1]
2055                 });
2056         },
2057
2058         /**
2059          * Merge two arrays together, removing all duplicates. The final order
2060          * or the new array is: All the results from the first array, followed
2061          * by the unique results from the second array.
2062          *
2063          * @example $.merge( [0,1,2], [2,3,4] )
2064          * @result [0,1,2,3,4]
2065          *
2066          * @example $.merge( [3,2,1], [4,3,2] )
2067          * @result [3,2,1,4]
2068          *
2069          * @name $.merge
2070          * @type Array
2071          * @param Array first The first array to merge.
2072          * @param Array second The second array to merge.
2073          * @cat Javascript
2074          */
2075         merge: function(first, second) {
2076                 var result = [];
2077
2078                 // Move b over to the new array (this helps to avoid
2079                 // StaticNodeList instances)
2080                 for ( var k = 0; k < first.length; k++ )
2081                         result[k] = first[k];
2082
2083                 // Now check for duplicates between a and b and only
2084                 // add the unique items
2085                 for ( var i = 0; i < second.length; i++ ) {
2086                         var noCollision = true;
2087
2088                         // The collision-checking process
2089                         for ( var j = 0; j < first.length; j++ )
2090                                 if ( second[i] == first[j] )
2091                                         noCollision = false;
2092
2093                         // If the item is unique, add it
2094                         if ( noCollision )
2095                                 result.push( second[i] );
2096                 }
2097
2098                 return result;
2099         },
2100
2101         /**
2102          * Filter items out of an array, by using a filter function.
2103          * The specified function will be passed two arguments: The
2104          * current array item and the index of the item in the array. The
2105          * function should return 'true' if you wish to keep the item in
2106          * the array, false if it should be removed.
2107          *
2108          * @example $.grep( [0,1,2], function(i){
2109          *   return i > 0;
2110          * });
2111          * @result [1, 2]
2112          *
2113          * @name $.grep
2114          * @type Array
2115          * @param Array array The Array to find items in.
2116          * @param Function fn The function to process each item against.
2117          * @param Boolean inv Invert the selection - select the opposite of the function.
2118          * @cat Javascript
2119          */
2120         grep: function(elems, fn, inv) {
2121                 // If a string is passed in for the function, make a function
2122                 // for it (a handy shortcut)
2123                 if ( fn.constructor == String )
2124                         fn = new Function("a","i","return " + fn);
2125
2126                 var result = [];
2127
2128                 // Go through the array, only saving the items
2129                 // that pass the validator function
2130                 for ( var i = 0; i < elems.length; i++ )
2131                         if ( !inv && fn(elems[i],i) || inv && !fn(elems[i],i) )
2132                                 result.push( elems[i] );
2133
2134                 return result;
2135         },
2136
2137         /**
2138          * Translate all items in an array to another array of items. 
2139          * The translation function that is provided to this method is 
2140          * called for each item in the array and is passed one argument: 
2141          * The item to be translated. The function can then return:
2142          * The translated value, 'null' (to remove the item), or 
2143          * an array of values - which will be flattened into the full array.
2144          *
2145          * @example $.map( [0,1,2], function(i){
2146          *   return i + 4;
2147          * });
2148          * @result [4, 5, 6]
2149          *
2150          * @example $.map( [0,1,2], function(i){
2151          *   return i > 0 ? i + 1 : null;
2152          * });
2153          * @result [2, 3]
2154          * 
2155          * @example $.map( [0,1,2], function(i){
2156          *   return [ i, i + 1 ];
2157          * });
2158          * @result [0, 1, 1, 2, 2, 3]
2159          *
2160          * @name $.map
2161          * @type Array
2162          * @param Array array The Array to translate.
2163          * @param Function fn The function to process each item against.
2164          * @cat Javascript
2165          */
2166         map: function(elems, fn) {
2167                 // If a string is passed in for the function, make a function
2168                 // for it (a handy shortcut)
2169                 if ( fn.constructor == String )
2170                         fn = new Function("a","return " + fn);
2171
2172                 var result = [];
2173
2174                 // Go through the array, translating each of the items to their
2175                 // new value (or values).
2176                 for ( var i = 0; i < elems.length; i++ ) {
2177                         var val = fn(elems[i],i);
2178
2179                         if ( val !== null && val != undefined ) {
2180                                 if ( val.constructor != Array ) val = [val];
2181                                 result = jQuery.merge( result, val );
2182                         }
2183                 }
2184
2185                 return result;
2186         },
2187
2188         /*
2189          * A number of helper functions used for managing events.
2190          * Many of the ideas behind this code orignated from Dean Edwards' addEvent library.
2191          */
2192         event: {
2193
2194                 // Bind an event to an element
2195                 // Original by Dean Edwards
2196                 add: function(element, type, handler) {
2197                         // For whatever reason, IE has trouble passing the window object
2198                         // around, causing it to be cloned in the process
2199                         if ( jQuery.browser.msie && element.setInterval != undefined )
2200                                 element = window;
2201
2202                         // Make sure that the function being executed has a unique ID
2203                         if ( !handler.guid )
2204                                 handler.guid = this.guid++;
2205
2206                         // Init the element's event structure
2207                         if (!element.events)
2208                                 element.events = {};
2209
2210                         // Get the current list of functions bound to this event
2211                         var handlers = element.events[type];
2212
2213                         // If it hasn't been initialized yet
2214                         if (!handlers) {
2215                                 // Init the event handler queue
2216                                 handlers = element.events[type] = {};
2217
2218                                 // Remember an existing handler, if it's already there
2219                                 if (element["on" + type])
2220                                         handlers[0] = element["on" + type];
2221                         }
2222
2223                         // Add the function to the element's handler list
2224                         handlers[handler.guid] = handler;
2225
2226                         // And bind the global event handler to the element
2227                         element["on" + type] = this.handle;
2228
2229                         // Remember the function in a global list (for triggering)
2230                         if (!this.global[type])
2231                                 this.global[type] = [];
2232                         this.global[type].push( element );
2233                 },
2234
2235                 guid: 1,
2236                 global: {},
2237
2238                 // Detach an event or set of events from an element
2239                 remove: function(element, type, handler) {
2240                         if (element.events)
2241                                 if (type && element.events[type])
2242                                         if ( handler )
2243                                                 delete element.events[type][handler.guid];
2244                                         else
2245                                                 for ( var i in element.events[type] )
2246                                                         delete element.events[type][i];
2247                                 else
2248                                         for ( var j in element.events )
2249                                                 this.remove( element, j );
2250                 },
2251
2252                 trigger: function(type,data,element) {
2253                         // Touch up the incoming data
2254                         data = data || [];
2255
2256                         // Handle a global trigger
2257                         if ( !element ) {
2258                                 var g = this.global[type];
2259                                 if ( g )
2260                                         for ( var i = 0; i < g.length; i++ )
2261                                                 this.trigger( type, data, g[i] );
2262
2263                         // Handle triggering a single element
2264                         } else if ( element["on" + type] ) {
2265                                 // Pass along a fake event
2266                                 data.unshift( this.fix({ type: type, target: element }) );
2267
2268                                 // Trigger the event
2269                                 element["on" + type].apply( element, data );
2270                         }
2271                 },
2272
2273                 handle: function(event) {
2274                         if ( typeof jQuery == "undefined" ) return false;
2275
2276                         event = event || jQuery.event.fix( window.event );
2277
2278                         // If no correct event was found, fail
2279                         if ( !event ) return false;
2280
2281                         var returnValue = true;
2282
2283                         var c = this.events[event.type];
2284
2285                         var args = [].slice.call( arguments, 1 );
2286                         args.unshift( event );
2287
2288                         for ( var j in c ) {
2289                                 if ( c[j].apply( this, args ) === false ) {
2290                                         event.preventDefault();
2291                                         event.stopPropagation();
2292                                         returnValue = false;
2293                                 }
2294                         }
2295
2296                         return returnValue;
2297                 },
2298
2299                 fix: function(event) {
2300                         if ( event ) {
2301                                 event.preventDefault = function() {
2302                                         this.returnValue = false;
2303                                 };
2304
2305                                 event.stopPropagation = function() {
2306                                         this.cancelBubble = true;
2307                                 };
2308                         }
2309
2310                         return event;
2311                 }
2312
2313         }
2314 });
2315
2316 /**
2317  * Contains flags for the useragent, read from navigator.userAgent.
2318  * Available flags are: safari, opera, msie, mozilla
2319  * This property is available before the DOM is ready, therefore you can
2320  * use it to add ready events only for certain browsers.
2321  *
2322  * See <a href="http://davecardwell.co.uk/geekery/javascript/jquery/jqbrowser/">
2323  * jQBrowser plugin</a> for advanced browser detection:
2324  *
2325  * @example $.browser.msie
2326  * @desc returns true if the current useragent is some version of microsoft's internet explorer
2327  *
2328  * @example if($.browser.safari) { $( function() { alert("this is safari!"); } ); }
2329  * @desc Alerts "this is safari!" only for safari browsers
2330  *
2331  * @name $.browser
2332  * @type Boolean
2333  * @cat Javascript
2334  */
2335 new function() {
2336         var b = navigator.userAgent.toLowerCase();
2337
2338         // Figure out what browser is being used
2339         jQuery.browser = {
2340                 safari: /webkit/.test(b),
2341                 opera: /opera/.test(b),
2342                 msie: /msie/.test(b) && !/opera/.test(b),
2343                 mozilla: /mozilla/.test(b) && !/(compatible|webkit)/.test(b)
2344         };
2345
2346         // Check to see if the W3C box model is being used
2347         jQuery.boxModel = !jQuery.browser.msie || document.compatMode == "CSS1Compat";
2348 };
2349
2350 jQuery.macros = {
2351         to: {
2352                 /**
2353                  * Append all of the matched elements to another, specified, set of elements.
2354                  * This operation is, essentially, the reverse of doing a regular
2355                  * $(A).append(B), in that instead of appending B to A, you're appending
2356                  * A to B.
2357                  *
2358                  * @example $("p").appendTo("#foo");
2359                  * @before <p>I would like to say: </p><div id="foo"></div>
2360                  * @result <div id="foo"><p>I would like to say: </p></div>
2361                  *
2362                  * @name appendTo
2363                  * @type jQuery
2364                  * @param String expr A jQuery expression of elements to match.
2365                  * @cat DOM/Manipulation
2366                  */
2367                 appendTo: "append",
2368
2369                 /**
2370                  * Prepend all of the matched elements to another, specified, set of elements.
2371                  * This operation is, essentially, the reverse of doing a regular
2372                  * $(A).prepend(B), in that instead of prepending B to A, you're prepending
2373                  * A to B.
2374                  *
2375                  * @example $("p").prependTo("#foo");
2376                  * @before <p>I would like to say: </p><div id="foo"><b>Hello</b></div>
2377                  * @result <div id="foo"><p>I would like to say: </p><b>Hello</b></div>
2378                  *
2379                  * @name prependTo
2380                  * @type jQuery
2381                  * @param String expr A jQuery expression of elements to match.
2382                  * @cat DOM/Manipulation
2383                  */
2384                 prependTo: "prepend",
2385
2386                 /**
2387                  * Insert all of the matched elements before another, specified, set of elements.
2388                  * This operation is, essentially, the reverse of doing a regular
2389                  * $(A).before(B), in that instead of inserting B before A, you're inserting
2390                  * A before B.
2391                  *
2392                  * @example $("p").insertBefore("#foo");
2393                  * @before <div id="foo">Hello</div><p>I would like to say: </p>
2394                  * @result <p>I would like to say: </p><div id="foo">Hello</div>
2395                  *
2396                  * @name insertBefore
2397                  * @type jQuery
2398                  * @param String expr A jQuery expression of elements to match.
2399                  * @cat DOM/Manipulation
2400                  */
2401                 insertBefore: "before",
2402
2403                 /**
2404                  * Insert all of the matched elements after another, specified, set of elements.
2405                  * This operation is, essentially, the reverse of doing a regular
2406                  * $(A).after(B), in that instead of inserting B after A, you're inserting
2407                  * A after B.
2408                  *
2409                  * @example $("p").insertAfter("#foo");
2410                  * @before <p>I would like to say: </p><div id="foo">Hello</div>
2411                  * @result <div id="foo">Hello</div><p>I would like to say: </p>
2412                  *
2413                  * @name insertAfter
2414                  * @type jQuery
2415                  * @param String expr A jQuery expression of elements to match.
2416                  * @cat DOM/Manipulation
2417                  */
2418                 insertAfter: "after"
2419         },
2420
2421         /**
2422          * Get the current CSS width of the first matched element.
2423          *
2424          * @example $("p").width();
2425          * @before <p>This is just a test.</p>
2426          * @result "300px"
2427          *
2428          * @name width
2429          * @type String
2430          * @cat CSS
2431          */
2432
2433         /**
2434          * Set the CSS width of every matched element. Be sure to include
2435          * the "px" (or other unit of measurement) after the number that you
2436          * specify, otherwise you might get strange results.
2437          *
2438          * @example $("p").width("20px");
2439          * @before <p>This is just a test.</p>
2440          * @result <p style="width:20px;">This is just a test.</p>
2441          *
2442          * @name width
2443          * @type jQuery
2444          * @param String val Set the CSS property to the specified value.
2445          * @cat CSS
2446          */
2447
2448         /**
2449          * Get the current CSS height of the first matched element.
2450          *
2451          * @example $("p").height();
2452          * @before <p>This is just a test.</p>
2453          * @result "14px"
2454          *
2455          * @name height
2456          * @type String
2457          * @cat CSS
2458          */
2459
2460         /**
2461          * Set the CSS height of every matched element. Be sure to include
2462          * the "px" (or other unit of measurement) after the number that you
2463          * specify, otherwise you might get strange results.
2464          *
2465          * @example $("p").height("20px");
2466          * @before <p>This is just a test.</p>
2467          * @result <p style="height:20px;">This is just a test.</p>
2468          *
2469          * @name height
2470          * @type jQuery
2471          * @param String val Set the CSS property to the specified value.
2472          * @cat CSS
2473          */
2474
2475         /**
2476          * Get the current CSS top of the first matched element.
2477          *
2478          * @example $("p").top();
2479          * @before <p>This is just a test.</p>
2480          * @result "0px"
2481          *
2482          * @name top
2483          * @type String
2484          * @cat CSS
2485          */
2486
2487         /**
2488          * Set the CSS top of every matched element. Be sure to include
2489          * the "px" (or other unit of measurement) after the number that you
2490          * specify, otherwise you might get strange results.
2491          *
2492          * @example $("p").top("20px");
2493          * @before <p>This is just a test.</p>
2494          * @result <p style="top:20px;">This is just a test.</p>
2495          *
2496          * @name top
2497          * @type jQuery
2498          * @param String val Set the CSS property to the specified value.
2499          * @cat CSS
2500          */
2501
2502         /**
2503          * Get the current CSS left of the first matched element.
2504          *
2505          * @example $("p").left();
2506          * @before <p>This is just a test.</p>
2507          * @result "0px"
2508          *
2509          * @name left
2510          * @type String
2511          * @cat CSS
2512          */
2513
2514         /**
2515          * Set the CSS left of every matched element. Be sure to include
2516          * the "px" (or other unit of measurement) after the number that you
2517          * specify, otherwise you might get strange results.
2518          *
2519          * @example $("p").left("20px");
2520          * @before <p>This is just a test.</p>
2521          * @result <p style="left:20px;">This is just a test.</p>
2522          *
2523          * @name left
2524          * @type jQuery
2525          * @param String val Set the CSS property to the specified value.
2526          * @cat CSS
2527          */
2528
2529         /**
2530          * Get the current CSS position of the first matched element.
2531          *
2532          * @example $("p").position();
2533          * @before <p>This is just a test.</p>
2534          * @result "static"
2535          *
2536          * @name position
2537          * @type String
2538          * @cat CSS
2539          */
2540
2541         /**
2542          * Set the CSS position of every matched element.
2543          *
2544          * @example $("p").position("relative");
2545          * @before <p>This is just a test.</p>
2546          * @result <p style="position:relative;">This is just a test.</p>
2547          *
2548          * @name position
2549          * @type jQuery
2550          * @param String val Set the CSS property to the specified value.
2551          * @cat CSS
2552          */
2553
2554         /**
2555          * Get the current CSS float of the first matched element.
2556          *
2557          * @example $("p").float();
2558          * @before <p>This is just a test.</p>
2559          * @result "none"
2560          *
2561          * @name float
2562          * @type String
2563          * @cat CSS
2564          */
2565
2566         /**
2567          * Set the CSS float of every matched element.
2568          *
2569          * @example $("p").float("left");
2570          * @before <p>This is just a test.</p>
2571          * @result <p style="float:left;">This is just a test.</p>
2572          *
2573          * @name float
2574          * @type jQuery
2575          * @param String val Set the CSS property to the specified value.
2576          * @cat CSS
2577          */
2578
2579         /**
2580          * Get the current CSS overflow of the first matched element.
2581          *
2582          * @example $("p").overflow();
2583          * @before <p>This is just a test.</p>
2584          * @result "none"
2585          *
2586          * @name overflow
2587          * @type String
2588          * @cat CSS
2589          */
2590
2591         /**
2592          * Set the CSS overflow of every matched element.
2593          *
2594          * @example $("p").overflow("auto");
2595          * @before <p>This is just a test.</p>
2596          * @result <p style="overflow:auto;">This is just a test.</p>
2597          *
2598          * @name overflow
2599          * @type jQuery
2600          * @param String val Set the CSS property to the specified value.
2601          * @cat CSS
2602          */
2603
2604         /**
2605          * Get the current CSS color of the first matched element.
2606          *
2607          * @example $("p").color();
2608          * @before <p>This is just a test.</p>
2609          * @result "black"
2610          *
2611          * @name color
2612          * @type String
2613          * @cat CSS
2614          */
2615
2616         /**
2617          * Set the CSS color of every matched element.
2618          *
2619          * @example $("p").color("blue");
2620          * @before <p>This is just a test.</p>
2621          * @result <p style="color:blue;">This is just a test.</p>
2622          *
2623          * @name color
2624          * @type jQuery
2625          * @param String val Set the CSS property to the specified value.
2626          * @cat CSS
2627          */
2628
2629         /**
2630          * Get the current CSS background of the first matched element.
2631          *
2632          * @example $("p").background();
2633          * @before <p style="background:blue;">This is just a test.</p>
2634          * @result "blue"
2635          *
2636          * @name background
2637          * @type String
2638          * @cat CSS
2639          */
2640
2641         /**
2642          * Set the CSS background of every matched element.
2643          *
2644          * @example $("p").background("blue");
2645          * @before <p>This is just a test.</p>
2646          * @result <p style="background:blue;">This is just a test.</p>
2647          *
2648          * @name background
2649          * @type jQuery
2650          * @param String val Set the CSS property to the specified value.
2651          * @cat CSS
2652          */
2653
2654         css: "width,height,top,left,position,float,overflow,color,background".split(","),
2655
2656         /**
2657          * Reduce the set of matched elements to a single element.
2658          * The position of the element in the set of matched elements
2659          * starts at 0 and goes to length - 1.
2660          *
2661          * @example $("p").eq(1)
2662          * @before <p>This is just a test.</p><p>So is this</p>
2663          * @result [ <p>So is this</p> ]
2664          *
2665          * @name eq
2666          * @type jQuery
2667          * @param Number pos The index of the element that you wish to limit to.
2668          * @cat Core
2669          */
2670
2671         /**
2672          * Reduce the set of matched elements to all elements before a given position.
2673          * The position of the element in the set of matched elements
2674          * starts at 0 and goes to length - 1.
2675          *
2676          * @example $("p").lt(1)
2677          * @before <p>This is just a test.</p><p>So is this</p>
2678          * @result [ <p>This is just a test.</p> ]
2679          *
2680          * @name lt
2681          * @type jQuery
2682          * @param Number pos Reduce the set to all elements below this position.
2683          * @cat Core
2684          */
2685
2686         /**
2687          * Reduce the set of matched elements to all elements after a given position.
2688          * The position of the element in the set of matched elements
2689          * starts at 0 and goes to length - 1.
2690          *
2691          * @example $("p").gt(0)
2692          * @before <p>This is just a test.</p><p>So is this</p>
2693          * @result [ <p>So is this</p> ]
2694          *
2695          * @name gt
2696          * @type jQuery
2697          * @param Number pos Reduce the set to all elements after this position.
2698          * @cat Core
2699          */
2700
2701         /**
2702          * Filter the set of elements to those that contain the specified text.
2703          *
2704          * @example $("p").contains("test")
2705          * @before <p>This is just a test.</p><p>So is this</p>
2706          * @result [ <p>This is just a test.</p> ]
2707          *
2708          * @name contains
2709          * @type jQuery
2710          * @param String str The string that will be contained within the text of an element.
2711          * @cat DOM/Traversing
2712          */
2713
2714         filter: [ "eq", "lt", "gt", "contains" ],
2715
2716         attr: {
2717                 /**
2718                  * Get the current value of the first matched element.
2719                  *
2720                  * @example $("input").val();
2721                  * @before <input type="text" value="some text"/>
2722                  * @result "some text"
2723                  *
2724                  * @test ok( $("#text1").val() == "Test", "Check for value of input element" );
2725                  * ok( !$("#text1").val() == "", "Check for value of input element" );
2726                  *
2727                  * @name val
2728                  * @type String
2729                  * @cat DOM/Attributes
2730                  */
2731
2732                 /**
2733                  * Set the value of every matched element.
2734                  *
2735                  * @example $("input").val("test");
2736                  * @before <input type="text" value="some text"/>
2737                  * @result <input type="text" value="test"/>
2738                  *
2739                  * @test document.getElementById('text1').value = "bla";
2740                  * ok( $("#text1").val() == "bla", "Check for modified value of input element" );
2741                  * $("#text1").val('test');
2742                  * ok ( document.getElementById('text1').value == "test", "Check for modified (via val(String)) value of input element" );
2743                  *
2744                  * @name val
2745                  * @type jQuery
2746                  * @param String val Set the property to the specified value.
2747                  * @cat DOM/Attributes
2748                  */
2749                 val: "value",
2750
2751                 /**
2752                  * Get the html contents of the first matched element.
2753                  *
2754                  * @example $("div").html();
2755                  * @before <div><input/></div>
2756                  * @result <input/>
2757                  *
2758                  * @name html
2759                  * @type String
2760                  * @cat DOM/Attributes
2761                  */
2762
2763                 /**
2764                  * Set the html contents of every matched element.
2765                  *
2766                  * @example $("div").html("<b>new stuff</b>");
2767                  * @before <div><input/></div>
2768                  * @result <div><b>new stuff</b></div>
2769                  *
2770                  * @test var div = $("div");
2771                  * div.html("<b>test</b>");
2772                  * var pass = true;
2773                  * for ( var i = 0; i < div.size(); i++ ) {
2774                  *   if ( div.get(i).childNodes.length == 0 ) pass = false;
2775                  * }
2776                  * ok( pass, "Set HTML" );
2777                  *
2778                  * @name html
2779                  * @type jQuery
2780                  * @param String val Set the html contents to the specified value.
2781                  * @cat DOM/Attributes
2782                  */
2783                 html: "innerHTML",
2784
2785                 /**
2786                  * Get the current id of the first matched element.
2787                  *
2788                  * @example $("input").id();
2789                  * @before <input type="text" id="test" value="some text"/>
2790                  * @result "test"
2791                  *
2792                  * @test ok( $(document.getElementById('main')).id() == "main", "Check for id" );
2793                  * ok( $("#foo").id() == "foo", "Check for id" );
2794                  * ok( !$("head").id(), "Check for id" );
2795                  *
2796                  * @name id
2797                  * @type String
2798                  * @cat DOM/Attributes
2799                  */
2800
2801                 /**
2802                  * Set the id of every matched element.
2803                  *
2804                  * @example $("input").id("newid");
2805                  * @before <input type="text" id="test" value="some text"/>
2806                  * @result <input type="text" id="newid" value="some text"/>
2807                  *
2808                  * @name id
2809                  * @type jQuery
2810                  * @param String val Set the property to the specified value.
2811                  * @cat DOM/Attributes
2812                  */
2813                 id: null,
2814
2815                 /**
2816                  * Get the current title of the first matched element.
2817                  *
2818                  * @example $("img").title();
2819                  * @before <img src="test.jpg" title="my image"/>
2820                  * @result "my image"
2821                  *
2822                  * @test ok( $(document.getElementById('google')).title() == "Google!", "Check for title" );
2823                  * ok( !$("#yahoo").title(), "Check for title" );
2824                  *
2825                  * @name title
2826                  * @type String
2827                  * @cat DOM/Attributes
2828                  */
2829
2830                 /**
2831                  * Set the title of every matched element.
2832                  *
2833                  * @example $("img").title("new title");
2834                  * @before <img src="test.jpg" title="my image"/>
2835                  * @result <img src="test.jpg" title="new image"/>
2836                  *
2837                  * @name title
2838                  * @type jQuery
2839                  * @param String val Set the property to the specified value.
2840                  * @cat DOM/Attributes
2841                  */
2842                 title: null,
2843
2844                 /**
2845                  * Get the current name of the first matched element.
2846                  *
2847                  * @example $("input").name();
2848                  * @before <input type="text" name="username"/>
2849                  * @result "username"
2850                  *
2851                  * @test ok( $(document.getElementById('text1')).name() == "action", "Check for name" );
2852                  * ok( $("#hidden1").name() == "hidden", "Check for name" );
2853                  * ok( !$("#area1").name(), "Check for name" );
2854                  *
2855                  * @name name
2856                  * @type String
2857                  * @cat DOM/Attributes
2858                  */
2859
2860                 /**
2861                  * Set the name of every matched element.
2862                  *
2863                  * @example $("input").name("user");
2864                  * @before <input type="text" name="username"/>
2865                  * @result <input type="text" name="user"/>
2866                  *
2867                  * @name name
2868                  * @type jQuery
2869                  * @param String val Set the property to the specified value.
2870                  * @cat DOM/Attributes
2871                  */
2872                 name: null,
2873
2874                 /**
2875                  * Get the current href of the first matched element.
2876                  *
2877                  * @example $("a").href();
2878                  * @before <a href="test.html">my link</a>
2879                  * @result "test.html"
2880                  *
2881                  * @name href
2882                  * @type String
2883                  * @cat DOM/Attributes
2884                  */
2885
2886                 /**
2887                  * Set the href of every matched element.
2888                  *
2889                  * @example $("a").href("test2.html");
2890                  * @before <a href="test.html">my link</a>
2891                  * @result <a href="test2.html">my link</a>
2892                  *
2893                  * @name href
2894                  * @type jQuery
2895                  * @param String val Set the property to the specified value.
2896                  * @cat DOM/Attributes
2897                  */
2898                 href: null,
2899
2900                 /**
2901                  * Get the current src of the first matched element.
2902                  *
2903                  * @example $("img").src();
2904                  * @before <img src="test.jpg" title="my image"/>
2905                  * @result "test.jpg"
2906                  *
2907                  * @name src
2908                  * @type String
2909                  * @cat DOM/Attributes
2910                  */
2911
2912                 /**
2913                  * Set the src of every matched element.
2914                  *
2915                  * @example $("img").src("test2.jpg");
2916                  * @before <img src="test.jpg" title="my image"/>
2917                  * @result <img src="test2.jpg" title="my image"/>
2918                  *
2919                  * @name src
2920                  * @type jQuery
2921                  * @param String val Set the property to the specified value.
2922                  * @cat DOM/Attributes
2923                  */
2924                 src: null,
2925
2926                 /**
2927                  * Get the current rel of the first matched element.
2928                  *
2929                  * @example $("a").rel();
2930                  * @before <a href="test.html" rel="nofollow">my link</a>
2931                  * @result "nofollow"
2932                  *
2933                  * @name rel
2934                  * @type String
2935                  * @cat DOM/Attributes
2936                  */
2937
2938                 /**
2939                  * Set the rel of every matched element.
2940                  *
2941                  * @example $("a").rel("nofollow");
2942                  * @before <a href="test.html">my link</a>
2943                  * @result <a href="test.html" rel="nofollow">my link</a>
2944                  *
2945                  * @name rel
2946                  * @type jQuery
2947                  * @param String val Set the property to the specified value.
2948                  * @cat DOM/Attributes
2949                  */
2950                 rel: null
2951         },
2952
2953         axis: {
2954                 /**
2955                  * Get a set of elements containing the unique parents of the matched
2956                  * set of elements.
2957                  *
2958                  * @example $("p").parent()
2959                  * @before <div><p>Hello</p><p>Hello</p></div>
2960                  * @result [ <div><p>Hello</p><p>Hello</p></div> ]
2961                  *
2962                  * @name parent
2963                  * @type jQuery
2964                  * @cat DOM/Traversing
2965                  */
2966
2967                 /**
2968                  * Get a set of elements containing the unique parents of the matched
2969                  * set of elements, and filtered by an expression.
2970                  *
2971                  * @example $("p").parent(".selected")
2972                  * @before <div><p>Hello</p></div><div class="selected"><p>Hello Again</p></div>
2973                  * @result [ <div class="selected"><p>Hello Again</p></div> ]
2974                  *
2975                  * @name parent
2976                  * @type jQuery
2977                  * @param String expr An expression to filter the parents with
2978                  * @cat DOM/Traversing
2979                  */
2980                 parent: "a.parentNode",
2981
2982                 /**
2983                  * Get a set of elements containing the unique ancestors of the matched
2984                  * set of elements (except for the root element).
2985                  *
2986                  * @example $("span").ancestors()
2987                  * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html>
2988                  * @result [ <body>...</body>, <div>...</div>, <p><span>Hello</span></p> ]
2989                  *
2990                  * @name ancestors
2991                  * @type jQuery
2992                  * @cat DOM/Traversing
2993                  */
2994
2995                 /**
2996                  * Get a set of elements containing the unique ancestors of the matched
2997                  * set of elements, and filtered by an expression.
2998                  *
2999                  * @example $("span").ancestors("p")
3000                  * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html>
3001                  * @result [ <p><span>Hello</span></p> ]
3002                  *
3003                  * @name ancestors
3004                  * @type jQuery
3005                  * @param String expr An expression to filter the ancestors with
3006                  * @cat DOM/Traversing
3007                  */
3008                 ancestors: jQuery.parents,
3009
3010                 /**
3011                  * Get a set of elements containing the unique ancestors of the matched
3012                  * set of elements (except for the root element).
3013                  *
3014                  * @example $("span").ancestors()
3015                  * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html>
3016                  * @result [ <body>...</body>, <div>...</div>, <p><span>Hello</span></p> ]
3017                  *
3018                  * @name parents
3019                  * @type jQuery
3020                  * @cat DOM/Traversing
3021                  */
3022
3023                 /**
3024                  * Get a set of elements containing the unique ancestors of the matched
3025                  * set of elements, and filtered by an expression.
3026                  *
3027                  * @example $("span").ancestors("p")
3028                  * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html>
3029                  * @result [ <p><span>Hello</span></p> ]
3030                  *
3031                  * @name parents
3032                  * @type jQuery
3033                  * @param String expr An expression to filter the ancestors with
3034                  * @cat DOM/Traversing
3035                  */
3036                 parents: jQuery.parents,
3037
3038                 /**
3039                  * Get a set of elements containing the unique next siblings of each of the
3040                  * matched set of elements.
3041                  *
3042                  * It only returns the very next sibling, not all next siblings.
3043                  *
3044                  * @example $("p").next()
3045                  * @before <p>Hello</p><p>Hello Again</p><div><span>And Again</span></div>
3046                  * @result [ <p>Hello Again</p>, <div><span>And Again</span></div> ]
3047                  *
3048                  * @name next
3049                  * @type jQuery
3050                  * @cat DOM/Traversing
3051                  */
3052
3053                 /**
3054                  * Get a set of elements containing the unique next siblings of each of the
3055                  * matched set of elements, and filtered by an expression.
3056                  *
3057                  * It only returns the very next sibling, not all next siblings.
3058                  *
3059                  * @example $("p").next(".selected")
3060                  * @before <p>Hello</p><p class="selected">Hello Again</p><div><span>And Again</span></div>
3061                  * @result [ <p class="selected">Hello Again</p> ]
3062                  *
3063                  * @name next
3064                  * @type jQuery
3065                  * @param String expr An expression to filter the next Elements with
3066                  * @cat DOM/Traversing
3067                  */
3068                 next: "jQuery.sibling(a).next",
3069
3070                 /**
3071                  * Get a set of elements containing the unique previous siblings of each of the
3072                  * matched set of elements.
3073                  *
3074                  * It only returns the immediately previous sibling, not all previous siblings.
3075                  *
3076                  * @example $("p").prev()
3077                  * @before <p>Hello</p><div><span>Hello Again</span></div><p>And Again</p>
3078                  * @result [ <div><span>Hello Again</span></div> ]
3079                  *
3080                  * @name prev
3081                  * @type jQuery
3082                  * @cat DOM/Traversing
3083                  */
3084
3085                 /**
3086                  * Get a set of elements containing the unique previous siblings of each of the
3087                  * matched set of elements, and filtered by an expression.
3088                  *
3089                  * It only returns the immediately previous sibling, not all previous siblings.
3090                  *
3091                  * @example $("p").previous(".selected")
3092                  * @before <div><span>Hello</span></div><p class="selected">Hello Again</p><p>And Again</p>
3093                  * @result [ <div><span>Hello</span></div> ]
3094                  *
3095                  * @name prev
3096                  * @type jQuery
3097                  * @param String expr An expression to filter the previous Elements with
3098                  * @cat DOM/Traversing
3099                  */
3100                 prev: "jQuery.sibling(a).prev",
3101
3102                 /**
3103                  * Get a set of elements containing all of the unique siblings of each of the
3104                  * matched set of elements.
3105                  *
3106                  * @example $("div").siblings()
3107                  * @before <p>Hello</p><div><span>Hello Again</span></div><p>And Again</p>
3108                  * @result [ <p>Hello</p>, <p>And Again</p> ]
3109                  *
3110                  * @test isSet( $("#en").siblings().get(), q("sndp", "sap"), "Check for siblings" ); 
3111                  *
3112                  * @name siblings
3113                  * @type jQuery
3114                  * @cat DOM/Traversing
3115                  */
3116
3117                 /**
3118                  * Get a set of elements containing all of the unique siblings of each of the
3119                  * matched set of elements, and filtered by an expression.
3120                  *
3121                  * @example $("div").siblings(".selected")
3122                  * @before <div><span>Hello</span></div><p class="selected">Hello Again</p><p>And Again</p>
3123                  * @result [ <p class="selected">Hello Again</p> ]
3124                  *
3125                  * @test isSet( $("#sndp").siblings("[code]").get(), q("sap"), "Check for filtered siblings (has code child element)" ); 
3126                  * isSet( $("#sndp").siblings("[a]").get(), q("en", "sap"), "Check for filtered siblings (has anchor child element)" );
3127                  *
3128                  * @name siblings
3129                  * @type jQuery
3130                  * @param String expr An expression to filter the sibling Elements with
3131                  * @cat DOM/Traversing
3132                  */
3133                 siblings: "jQuery.sibling(a, null, true)",
3134
3135
3136                 /**
3137                  * Get a set of elements containing all of the unique children of each of the
3138                  * matched set of elements.
3139                  *
3140                  * @example $("div").children()
3141                  * @before <p>Hello</p><div><span>Hello Again</span></div><p>And Again</p>
3142                  * @result [ <span>Hello Again</span> ]
3143                  *
3144                  * @test isSet( $("#foo").children().get(), q("sndp", "en", "sap"), "Check for children" );
3145                  *
3146                  * @name children
3147                  * @type jQuery
3148                  * @cat DOM/Traversing
3149                  */
3150
3151                 /**
3152                  * Get a set of elements containing all of the unique children of each of the
3153                  * matched set of elements, and filtered by an expression.
3154                  *
3155                  * @example $("div").children(".selected")
3156                  * @before <div><span>Hello</span><p class="selected">Hello Again</p><p>And Again</p></div>
3157                  * @result [ <p class="selected">Hello Again</p> ]
3158                  *
3159                  * @test isSet( $("#foo").children("[code]").get(), q("sndp", "sap"), "Check for filtered children" ); 
3160                  *
3161                  * @name children
3162                  * @type jQuery
3163                  * @param String expr An expression to filter the child Elements with
3164                  * @cat DOM/Traversing
3165                  */
3166                 children: "jQuery.sibling(a.firstChild)"
3167         },
3168
3169         each: {
3170
3171                 /**
3172                  * Remove an attribute from each of the matched elements.
3173                  *
3174                  * @example $("input").removeAttr("disabled")
3175                  * @before <input disabled="disabled"/>
3176                  * @result <input/>
3177                  *
3178                  * @name removeAttr
3179                  * @type jQuery
3180                  * @param String name The name of the attribute to remove.
3181                  * @cat DOM
3182                  */
3183                 removeAttr: function( key ) {
3184                         this.removeAttribute( key );
3185                 },
3186
3187                 /**
3188                  * Displays each of the set of matched elements if they are hidden.
3189                  *
3190                  * @example $("p").show()
3191                  * @before <p style="display: none">Hello</p>
3192                  * @result [ <p style="display: block">Hello</p> ]
3193                  *
3194                  * @test var pass = true, div = $("div");
3195                  * div.show().each(function(){
3196                  *   if ( this.style.display == "none" ) pass = false;
3197                  * });
3198                  * ok( pass, "Show" );
3199                  *
3200                  * @name show
3201                  * @type jQuery
3202                  * @cat Effects
3203                  */
3204                 show: function(){
3205                         this.style.display = this.oldblock ? this.oldblock : "";
3206                         if ( jQuery.css(this,"display") == "none" )
3207                                 this.style.display = "block";
3208                 },
3209
3210                 /**
3211                  * Hides each of the set of matched elements if they are shown.
3212                  *
3213                  * @example $("p").hide()
3214                  * @before <p>Hello</p>
3215                  * @result [ <p style="display: none">Hello</p> ]
3216                  *
3217                  * var pass = true, div = $("div");
3218                  * div.hide().each(function(){
3219                  *   if ( this.style.display != "none" ) pass = false;
3220                  * });
3221                  * ok( pass, "Hide" );
3222                  *
3223                  * @name hide
3224                  * @type jQuery
3225                  * @cat Effects
3226                  */
3227                 hide: function(){
3228                         this.oldblock = this.oldblock || jQuery.css(this,"display");
3229                         if ( this.oldblock == "none" )
3230                                 this.oldblock = "block";
3231                         this.style.display = "none";
3232                 },
3233
3234                 /**
3235                  * Toggles each of the set of matched elements. If they are shown,
3236                  * toggle makes them hidden. If they are hidden, toggle
3237                  * makes them shown.
3238                  *
3239                  * @example $("p").toggle()
3240                  * @before <p>Hello</p><p style="display: none">Hello Again</p>
3241                  * @result [ <p style="display: none">Hello</p>, <p style="display: block">Hello Again</p> ]
3242                  *
3243                  * @name toggle
3244                  * @type jQuery
3245                  * @cat Effects
3246                  */
3247                 toggle: function(){
3248                         jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ].apply( jQuery(this), arguments );
3249                 },
3250
3251                 /**
3252                  * Adds the specified class to each of the set of matched elements.
3253                  *
3254                  * @example $("p").addClass("selected")
3255                  * @before <p>Hello</p>
3256                  * @result [ <p class="selected">Hello</p> ]
3257                  *
3258                  * @test var div = $("div");
3259                  * div.addClass("test");
3260                  * var pass = true;
3261                  * for ( var i = 0; i < div.size(); i++ ) {
3262                  *  if ( div.get(i).className.indexOf("test") == -1 ) pass = false;
3263                  * }
3264                  * ok( pass, "Add Class" );
3265                  *
3266                  * @name addClass
3267                  * @type jQuery
3268                  * @param String class A CSS class to add to the elements
3269                  * @cat DOM
3270                  */
3271                 addClass: function(c){
3272                         jQuery.className.add(this,c);
3273                 },
3274
3275                 /**
3276                  * Removes the specified class from the set of matched elements.
3277                  *
3278                  * @example $("p").removeClass("selected")
3279                  * @before <p class="selected">Hello</p>
3280                  * @result [ <p>Hello</p> ]
3281                  *
3282                  * @test var div = $("div").addClass("test");
3283                  * div.removeClass("test");
3284                  * var pass = true;
3285                  * for ( var i = 0; i < div.size(); i++ ) {
3286                  *  if ( div.get(i).className.indexOf("test") != -1 ) pass = false;
3287                  * }
3288                  * ok( pass, "Remove Class" );
3289                  * 
3290                  * reset();
3291                  *
3292                  * var div = $("div").addClass("test").addClass("foo").addClass("bar");
3293                  * div.removeClass("test").removeClass("bar").removeClass("foo");
3294                  * var pass = true;
3295                  * for ( var i = 0; i < div.size(); i++ ) {
3296                  *  if ( div.get(i).className.match(/test|bar|foo/) ) pass = false;
3297                  * }
3298                  * ok( pass, "Remove multiple classes" );
3299                  *
3300                  * @name removeClass
3301                  * @type jQuery
3302                  * @param String class A CSS class to remove from the elements
3303                  * @cat DOM
3304                  */
3305                 removeClass: function(c){
3306                         jQuery.className.remove(this,c);
3307                 },
3308
3309                 /**
3310                  * Adds the specified class if it is present, removes it if it is
3311                  * not present.
3312                  *
3313                  * @example $("p").toggleClass("selected")
3314                  * @before <p>Hello</p><p class="selected">Hello Again</p>
3315                  * @result [ <p class="selected">Hello</p>, <p>Hello Again</p> ]
3316                  *
3317                  * @name toggleClass
3318                  * @type jQuery
3319                  * @param String class A CSS class with which to toggle the elements
3320                  * @cat DOM
3321                  */
3322                 toggleClass: function( c ){
3323                         jQuery.className[ jQuery.className.has(this,c) ? "remove" : "add" ](this,c);
3324                 },
3325
3326                 /**
3327                  * Removes all matched elements from the DOM. This does NOT remove them from the
3328                  * jQuery object, allowing you to use the matched elements further.
3329                  *
3330                  * @example $("p").remove();
3331                  * @before <p>Hello</p> how are <p>you?</p>
3332                  * @result how are
3333                  *
3334                  * @name remove
3335                  * @type jQuery
3336                  * @cat DOM/Manipulation
3337                  */
3338
3339                 /**
3340                  * Removes only elements (out of the list of matched elements) that match
3341                  * the specified jQuery expression. This does NOT remove them from the
3342                  * jQuery object, allowing you to use the matched elements further.
3343                  *
3344                  * @example $("p").remove(".hello");
3345                  * @before <p class="hello">Hello</p> how are <p>you?</p>
3346                  * @result how are <p>you?</p>
3347                  *
3348                  * @name remove
3349                  * @type jQuery
3350                  * @param String expr A jQuery expression to filter elements by.
3351                  * @cat DOM/Manipulation
3352                  */
3353                 remove: function(a){
3354                         if ( !a || jQuery.filter( a, [this] ).r )
3355                                 this.parentNode.removeChild( this );
3356                 },
3357
3358                 /**
3359                  * Removes all child nodes from the set of matched elements.
3360                  *
3361                  * @example $("p").empty()
3362                  * @before <p>Hello, <span>Person</span> <a href="#">and person</a></p>
3363                  * @result [ <p></p> ]
3364                  *
3365                  * @name empty
3366                  * @type jQuery
3367                  * @cat DOM/Manipulation
3368                  */
3369                 empty: function(){
3370                         while ( this.firstChild )
3371                                 this.removeChild( this.firstChild );
3372                 },
3373
3374                 /**
3375                  * Binds a handler to a particular event (like click) for each matched element.
3376                  * The event handler is passed an event object that you can use to prevent
3377                  * default behaviour. To stop both default action and event bubbling, your handler
3378                  * has to return false.
3379                  *
3380                  * @example $("p").bind( "click", function() {
3381                  *   alert( $(this).text() );
3382                  * } )
3383                  * @before <p>Hello</p>
3384                  * @result alert("Hello")
3385                  *
3386                  * @example $("form").bind( "submit", function() { return false; } )
3387                  * @desc Cancel a default action and prevent it from bubbling by returning false
3388                  * from your function.
3389                  *
3390                  * @example $("form").bind( "submit", function(event) {
3391                  *   event.preventDefault();
3392                  * } );
3393                  * @desc Cancel only the default action by using the preventDefault method.
3394                  *
3395                  *
3396                  * @example $("form").bind( "submit", function(event) {
3397                  *   event.stopPropagation();
3398                  * } )
3399                  * @desc Stop only an event from bubbling by using the stopPropagation method.
3400                  *
3401                  * @name bind
3402                  * @type jQuery
3403                  * @param String type An event type
3404                  * @param Function fn A function to bind to the event on each of the set of matched elements
3405                  * @cat Events
3406                  */
3407                 bind: function( type, fn ) {
3408                         if ( fn.constructor == String )
3409                                 fn = new Function("e", ( !fn.indexOf(".") ? "jQuery(this)" : "return " ) + fn);
3410                         jQuery.event.add( this, type, fn );
3411                 },
3412
3413                 /**
3414                  * The opposite of bind, removes a bound event from each of the matched
3415                  * elements. You must pass the identical function that was used in the original
3416                  * bind method.
3417                  *
3418                  * @example $("p").unbind( "click", function() { alert("Hello"); } )
3419                  * @before <p onclick="alert('Hello');">Hello</p>
3420                  * @result [ <p>Hello</p> ]
3421                  *
3422                  * @name unbind
3423                  * @type jQuery
3424                  * @param String type An event type
3425                  * @param Function fn A function to unbind from the event on each of the set of matched elements
3426                  * @cat Events
3427                  */
3428
3429                 /**
3430                  * Removes all bound events of a particular type from each of the matched
3431                  * elements.
3432                  *
3433                  * @example $("p").unbind( "click" )
3434                  * @before <p onclick="alert('Hello');">Hello</p>
3435                  * @result [ <p>Hello</p> ]
3436                  *
3437                  * @name unbind
3438                  * @type jQuery
3439                  * @param String type An event type
3440                  * @cat Events
3441                  */
3442
3443                 /**
3444                  * Removes all bound events from each of the matched elements.
3445                  *
3446                  * @example $("p").unbind()
3447                  * @before <p onclick="alert('Hello');">Hello</p>
3448                  * @result [ <p>Hello</p> ]
3449                  *
3450                  * @name unbind
3451                  * @type jQuery
3452                  * @cat Events
3453                  */
3454                 unbind: function( type, fn ) {
3455                         jQuery.event.remove( this, type, fn );
3456                 },
3457
3458                 /**
3459                  * Trigger a type of event on every matched element.
3460                  *
3461                  * @example $("p").trigger("click")
3462                  * @before <p click="alert('hello')">Hello</p>
3463                  * @result alert('hello')
3464                  *
3465                  * @name trigger
3466                  * @type jQuery
3467                  * @param String type An event type to trigger.
3468                  * @cat Events
3469                  */
3470                 trigger: function( type, data ) {
3471                         jQuery.event.trigger( type, data, this );
3472                 }
3473         }
3474 };
3475
3476 jQuery.init();