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