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