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