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