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