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