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