Added back in Joern's changes - oops! Let me know if I missed any.
[jquery.git] / src / jquery / jquery.js
1 /*
2  * jQuery @VERSION - New Wave Javascript
3  *
4  * Copyright (c) 2006 John Resig (jquery.com)
5  * Dual licensed under the MIT (MIT-LICENSE.txt)
6  * and GPL (GPL-LICENSE.txt) licenses.
7  *
8  * $Date$
9  * $Rev$
10  */
11
12 // Global undefined variable
13 window.undefined = window.undefined;
14
15 /**
16  * Create a new jQuery Object
17  *
18  * @constructor
19  * @private
20  * @name jQuery
21  * @cat Core
22  */
23 var jQuery = function(a,c) {
24
25         // Shortcut for document ready
26         if ( a && typeof a == "function" && jQuery.fn.ready && !a.nodeType && a[0] == undefined ) // Safari reports typeof on DOM NodeLists as a function
27                 return jQuery(document).ready(a);
28
29         // Make sure that a selection was provided
30         a = a || document;
31
32         // Watch for when a jQuery object is passed as the selector
33         if ( a.jquery )
34                 return jQuery( jQuery.makeArray( a ) );
35
36         // Watch for when a jQuery object is passed at the context
37         if ( c && c.jquery )
38                 return jQuery( c ).find(a);
39
40         // If the context is global, return a new object
41         if ( window == this )
42                 return new jQuery(a,c);
43
44         // Handle HTML strings
45         if ( typeof a  == "string" ) {
46                 var m = /^[^<]*(<.+>)[^>]*$/.exec(a);
47                 if ( m ) a = jQuery.clean( [ m[1] ] );
48         }
49
50         // Watch for when an array is passed in
51         this.set( a.constructor == Array || a.length && a != window && !a.nodeType && a[0] != undefined && a[0].nodeType ?
52                 // Assume that it is an array of DOM Elements
53                 jQuery.makeArray( a ) :
54
55                 // Find the matching elements and save them for later
56                 jQuery.find( a, c ) );
57
58         // See if an extra function was provided
59         var fn = arguments[ arguments.length - 1 ];
60
61         // If so, execute it in context
62         if ( fn && typeof fn == "function" )
63                 this.each(fn);
64
65         return this;
66 };
67
68 // Map over the $ in case of overwrite
69 if ( typeof $ != "undefined" )
70         jQuery._$ = $;
71         
72 // Map the jQuery namespace to the '$' one
73 var $ = jQuery;
74
75 /**
76  * This function accepts a string containing a CSS or
77  * basic XPath selector which is then used to match a set of elements.
78  *
79  * The core functionality of jQuery centers around this function.
80  * Everything in jQuery is based upon this, or uses this in some way.
81  * The most basic use of this function is to pass in an expression
82  * (usually consisting of CSS or XPath), which then finds all matching
83  * elements.
84  *
85  * By default, $() looks for DOM elements within the context of the
86  * current HTML document.
87  *
88  * @example $("div > p")
89  * @desc This finds all p elements that are children of a div element.
90  * @before <p>one</p> <div><p>two</p></div> <p>three</p>
91  * @result [ <p>two</p> ]
92  *
93  * @example $("input:radio", document.forms[0])
94  * @desc Searches for all inputs of type radio within the first form in the document
95  *
96  * @example $("div", xml.responseXML)
97  * @desc This finds all div elements within the specified XML document.
98  *
99  * @name $
100  * @param String expr An expression to search with
101  * @param Element context (optional) A DOM Element, or Document, representing the base context.
102  * @cat Core
103  * @type jQuery
104  * @see $(Element)
105  * @see $(Element<Array>)
106  */
107  
108 /**
109  * This function accepts a string of raw HTML.
110  *
111  * The HTML string is different from the traditional selectors in that
112  * it creates the DOM elements representing that HTML string, on the fly,
113  * to be (assumedly) inserted into the document later.
114  *
115  * @example $("<div><p>Hello</p></div>").appendTo("#body")
116  * @desc Creates a div element (and all of its contents) dynamically, 
117  * and appends it to the element with the ID of body. Internally, an
118  * element is created and it's innerHTML property set to the given markup.
119  * It is therefore both quite flexible and limited. 
120  *
121  * @name $
122  * @param String html A string of HTML to create on the fly.
123  * @cat Core
124  * @type jQuery
125  */
126
127 /**
128  * Wrap jQuery functionality around a specific DOM Element.
129  * This function also accepts XML Documents and Window objects
130  * as valid arguments (even though they are not DOM Elements).
131  *
132  * @example $(document).find("div > p")
133  * @before <p>one</p> <div><p>two</p></div> <p>three</p>
134  * @result [ <p>two</p> ]
135  *
136  * @example $(document.body).background( "black" );
137  * @desc Sets the background color of the page to black.
138  *
139  * @name $
140  * @param Element elem A DOM element to be encapsulated by a jQuery object.
141  * @cat Core
142  * @type jQuery
143  */
144
145 /**
146  * Wrap jQuery functionality around a set of DOM Elements.
147  *
148  * @example $( myForm.elements ).hide()
149  * @desc Hides all the input elements within a form
150  *
151  * @name $
152  * @param Array<Element> elems An array of DOM elements to be encapsulated by a jQuery object.
153  * @cat Core
154  * @type jQuery
155  */
156
157 /**
158  * A shorthand for $(document).ready(), allowing you to bind a function
159  * to be executed when the DOM document has finished loading. This function
160  * behaves just like $(document).ready(), in that it should be used to wrap
161  * all of the other $() operations on your page. While this function is,
162  * technically, chainable - there really isn't much use for chaining against it.
163  * You can have as many $(document).ready events on your page as you like.
164  *
165  * See ready(Function) for details about the ready event. 
166  * 
167  * @example $(function(){
168  *   // Document is ready
169  * });
170  * @desc Executes the function when the DOM is ready to be used.
171  *
172  * @name $
173  * @param Function fn The function to execute when the DOM is ready.
174  * @cat Core
175  * @type jQuery
176  */
177
178 /**
179  * A means of creating a cloned copy of a jQuery object. This function
180  * copies the set of matched elements from one jQuery object and creates
181  * another, new, jQuery object containing the same elements.
182  *
183  * @example var div = $("div");
184  * $( div ).find("p");
185  * @desc Locates all p elements with all div elements, without disrupting the original jQuery object contained in 'div' (as would normally be the case if a simple div.find("p") was done).
186  *
187  * @name $
188  * @param jQuery obj The jQuery object to be cloned.
189  * @cat Core
190  * @type jQuery
191  */
192
193 jQuery.fn = jQuery.prototype = {
194         /**
195          * The current version of jQuery.
196          *
197          * @private
198          * @property
199          * @name jquery
200          * @type String
201          * @cat Core
202          */
203         jquery: "@VERSION",
204
205         /**
206          * The number of elements currently matched.
207          *
208          * @example $("img").length;
209          * @before <img src="test1.jpg"/> <img src="test2.jpg"/>
210          * @result 2
211          *
212          * @property
213          * @name length
214          * @type Number
215          * @cat Core
216          */
217
218         /**
219          * The number of elements currently matched.
220          *
221          * @example $("img").size();
222          * @before <img src="test1.jpg"/> <img src="test2.jpg"/>
223          * @result 2
224          *
225          * @name size
226          * @type Number
227          * @cat Core
228          */
229         size: function() {
230                 return this.length;
231         },
232
233         /**
234          * Access all matched elements. This serves as a backwards-compatible
235          * way of accessing all matched elements (other than the jQuery object
236          * itself, which is, in fact, an array of elements).
237          *
238          * @example $("img").get();
239          * @before <img src="test1.jpg"/> <img src="test2.jpg"/>
240          * @result [ <img src="test1.jpg"/> <img src="test2.jpg"/> ]
241          *
242          * @name get
243          * @type Array<Element>
244          * @cat Core
245          */
246
247         /**
248          * Access a single matched element. num is used to access the
249          * Nth element matched.
250          *
251          * @example $("img").get(1);
252          * @before <img src="test1.jpg"/> <img src="test2.jpg"/>
253          * @result [ <img src="test1.jpg"/> ]
254          *
255          * @name get
256          * @type Element
257          * @param Number num Access the element in the Nth position.
258          * @cat Core
259          */
260         get: function( num ) {
261                 return num == undefined ?
262
263                         // Return a 'clean' array
264                         jQuery.makeArray( this ) :
265
266                         // Return just the object
267                         this[num];
268         },
269         
270         /**
271          * Set the jQuery object to an array of elements.
272          *
273          * @example $("img").set([ document.body ]);
274          * @result $("img").set() == [ document.body ]
275          *
276          * @private
277          * @name set
278          * @type jQuery
279          * @param Elements elems An array of elements
280          * @cat Core
281          */
282         set: function( array ) {
283                 // Use a tricky hack to make the jQuery object
284                 // look and feel like an array
285                 this.length = 0;
286                 [].push.apply( this, array );
287                 return this;
288         },
289
290         /**
291          * Execute a function within the context of every matched element.
292          * This means that every time the passed-in function is executed
293          * (which is once for every element matched) the 'this' keyword
294          * points to the specific element.
295          *
296          * Additionally, the function, when executed, is passed a single
297          * argument representing the position of the element in the matched
298          * set.
299          *
300          * @example $("img").each(function(i){
301          *   this.src = "test" + i + ".jpg";
302          * });
303          * @before <img/> <img/>
304          * @result <img src="test0.jpg"/> <img src="test1.jpg"/>
305          * @desc Iterates over two images and sets their src property
306          *
307          * @name each
308          * @type jQuery
309          * @param Function fn A function to execute
310          * @cat Core
311          */
312         each: function( fn, args ) {
313                 return jQuery.each( this, fn, args );
314         },
315
316         /**
317          * Searches every matched element for the object and returns
318          * the index of the element, if found, starting with zero. 
319          * Returns -1 if the object wasn't found.
320          *
321          * @example $("*").index(document.getElementById('foobar')) 
322          * @before <div id="foobar"></div><b></b><span id="foo"></span>
323          * @result 0
324          *
325          * @example $("*").index(document.getElementById('foo')) 
326          * @before <div id="foobar"></div><b></b><span id="foo"></span>
327          * @result 2
328          *
329          * @example $("*").index(document.getElementById('bar')) 
330          * @before <div id="foobar"></div><b></b><span id="foo"></span>
331          * @result -1
332          *
333          * @name index
334          * @type Number
335          * @param Object obj Object to search for
336          * @cat Core
337          */
338         index: function( obj ) {
339                 var pos = -1;
340                 this.each(function(i){
341                         if ( this == obj ) pos = i;
342                 });
343                 return pos;
344         },
345
346         /**
347          * Access a property on the first matched element.
348          * This method makes it easy to retrieve a property value
349          * from the first matched element.
350          *
351          * @example $("img").attr("src");
352          * @before <img src="test.jpg"/>
353          * @result test.jpg
354          *
355          * @name attr
356          * @type Object
357          * @param String name The name of the property to access.
358          * @cat DOM
359          */
360
361         /**
362          * Set a hash of key/value object properties to all matched elements.
363          * This serves as the best way to set a large number of properties
364          * on all matched elements.
365          *
366          * @example $("img").attr({ src: "test.jpg", alt: "Test Image" });
367          * @before <img/>
368          * @result <img src="test.jpg" alt="Test Image"/>
369          *
370          * @name attr
371          * @type jQuery
372          * @param Hash prop A set of key/value pairs to set as object properties.
373          * @cat DOM
374          */
375
376         /**
377          * Set a single property to a value, on all matched elements.
378          *
379          * Note that you can't set the name property of input elements in IE.
380          * Use $(html) or $().append(html) or $().html(html) to create elements
381          * on the fly including the name property.
382          *
383          * @example $("img").attr("src","test.jpg");
384          * @before <img/>
385          * @result <img src="test.jpg"/>
386          *
387          * @name attr
388          * @type jQuery
389          * @param String key The name of the property to set.
390          * @param Object value The value to set the property to.
391          * @cat DOM
392          */
393         attr: function( key, value, type ) {
394                 // Check to see if we're setting style values
395                 return typeof key != "string" || value != undefined ?
396                         this.each(function(){
397                                 // See if we're setting a hash of styles
398                                 if ( value == undefined )
399                                         // Set all the styles
400                                         for ( var prop in key )
401                                                 jQuery.attr(
402                                                         type ? this.style : this,
403                                                         prop, key[prop]
404                                                 );
405
406                                 // See if we're setting a single key/value style
407                                 else
408                                         jQuery.attr(
409                                                 type ? this.style : this,
410                                                 key, value
411                                         );
412                         }) :
413
414                         // Look for the case where we're accessing a style value
415                         jQuery[ type || "attr" ]( this[0], key );
416         },
417
418         /**
419          * Access a style property on the first matched element.
420          * This method makes it easy to retrieve a style property value
421          * from the first matched element.
422          *
423          * @example $("p").css("color");
424          * @before <p style="color:red;">Test Paragraph.</p>
425          * @result red
426          * @desc Retrieves the color style of the first paragraph
427          *
428          * @example $("p").css("fontWeight");
429          * @before <p style="font-weight: bold;">Test Paragraph.</p>
430          * @result bold
431          * @desc Retrieves the font-weight style of the first paragraph.
432          * Note that for all style properties with a dash (like 'font-weight'), you have to
433          * write it in camelCase. In other words: Every time you have a '-' in a 
434          * property, remove it and replace the next character with an uppercase 
435          * representation of itself. Eg. fontWeight, fontSize, fontFamily, borderWidth,
436          * borderStyle, borderBottomWidth etc.
437          *
438          * @name css
439          * @type Object
440          * @param String name The name of the property to access.
441          * @cat CSS
442          */
443
444         /**
445          * Set a hash of key/value style properties to all matched elements.
446          * This serves as the best way to set a large number of style properties
447          * on all matched elements.
448          *
449          * @example $("p").css({ color: "red", background: "blue" });
450          * @before <p>Test Paragraph.</p>
451          * @result <p style="color:red; background:blue;">Test Paragraph.</p>
452          *
453          * @name css
454          * @type jQuery
455          * @param Hash prop A set of key/value pairs to set as style properties.
456          * @cat CSS
457          */
458
459         /**
460          * Set a single style property to a value, on all matched elements.
461          *
462          * @example $("p").css("color","red");
463          * @before <p>Test Paragraph.</p>
464          * @result <p style="color:red;">Test Paragraph.</p>
465          * @desc Changes the color of all paragraphs to red
466          *
467          * @name css
468          * @type jQuery
469          * @param String key The name of the property to set.
470          * @param Object value The value to set the property to.
471          * @cat CSS
472          */
473         css: function( key, value ) {
474                 return this.attr( key, value, "curCSS" );
475         },
476
477         /**
478          * Retrieve the text contents of all matched elements. The result is
479          * a string that contains the combined text contents of all matched
480          * elements. This method works on both HTML and XML documents.
481          *
482          * @example $("p").text();
483          * @before <p>Test Paragraph.</p>
484          * @result Test Paragraph.
485          *
486          * @name text
487          * @type String
488          * @cat DOM
489          */
490         text: function(e) {
491                 e = e || this;
492                 var t = "";
493                 for ( var j = 0; j < e.length; j++ ) {
494                         var r = e[j].childNodes;
495                         for ( var i = 0; i < r.length; i++ )
496                                 if ( r[i].nodeType != 8 )
497                                         t += r[i].nodeType != 1 ?
498                                                 r[i].nodeValue : jQuery.fn.text([ r[i] ]);
499                 }
500                 return t;
501         },
502
503         /**
504          * Wrap all matched elements with a structure of other elements.
505          * This wrapping process is most useful for injecting additional
506          * stucture into a document, without ruining the original semantic
507          * qualities of a document.
508          *
509          * This works by going through the first element
510          * provided (which is generated, on the fly, from the provided HTML)
511          * and finds the deepest ancestor element within its
512          * structure - it is that element that will en-wrap everything else.
513          *
514          * This does not work with elements that contain text. Any necessary text
515          * must be added after the wrapping is done.
516          *
517          * @example $("p").wrap("<div class='wrap'></div>");
518          * @before <p>Test Paragraph.</p>
519          * @result <div class='wrap'><p>Test Paragraph.</p></div>
520          * 
521          * @name wrap
522          * @type jQuery
523          * @param String html A string of HTML, that will be created on the fly and wrapped around the target.
524          * @cat DOM/Manipulation
525          */
526
527         /**
528          * Wrap all matched elements with a structure of other elements.
529          * This wrapping process is most useful for injecting additional
530          * stucture into a document, without ruining the original semantic
531          * qualities of a document.
532          *
533          * This works by going through the first element
534          * provided and finding the deepest ancestor element within its
535          * structure - it is that element that will en-wrap everything else.
536          *
537          * This does not work with elements that contain text. Any necessary text
538          * must be added after the wrapping is done.
539          *
540          * @example $("p").wrap( document.getElementById('content') );
541          * @before <p>Test Paragraph.</p><div id="content"></div>
542          * @result <div id="content"><p>Test Paragraph.</p></div>
543          *
544          * @name wrap
545          * @type jQuery
546          * @param Element elem A DOM element that will be wrapped.
547          * @cat DOM/Manipulation
548          */
549         wrap: function() {
550                 // The elements to wrap the target around
551                 var a = jQuery.clean(arguments);
552
553                 // Wrap each of the matched elements individually
554                 return this.each(function(){
555                         // Clone the structure that we're using to wrap
556                         var b = a[0].cloneNode(true);
557
558                         // Insert it before the element to be wrapped
559                         this.parentNode.insertBefore( b, this );
560
561                         // Find the deepest point in the wrap structure
562                         while ( b.firstChild )
563                                 b = b.firstChild;
564
565                         // Move the matched element to within the wrap structure
566                         b.appendChild( this );
567                 });
568         },
569
570         /**
571          * Append any number of elements to the inside of every matched elements,
572          * generated from the provided HTML.
573          * This operation is similar to doing an appendChild to all the
574          * specified elements, adding them into the document.
575          *
576          * @example $("p").append("<b>Hello</b>");
577          * @before <p>I would like to say: </p>
578          * @result <p>I would like to say: <b>Hello</b></p>
579          *
580          * @name append
581          * @type jQuery
582          * @param String html A string of HTML, that will be created on the fly and appended to the target.
583          * @cat DOM/Manipulation
584          */
585
586         /**
587          * Append an element to the inside of all matched elements.
588          * This operation is similar to doing an appendChild to all the
589          * specified elements, adding them into the document.
590          *
591          * @example $("p").append( $("#foo")[0] );
592          * @before <p>I would like to say: </p><b id="foo">Hello</b>
593          * @result <p>I would like to say: <b id="foo">Hello</b></p>
594          *
595          * @name append
596          * @type jQuery
597          * @param Element elem A DOM element that will be appended.
598          * @cat DOM/Manipulation
599          */
600
601         /**
602          * Append any number of elements to the inside of all matched elements.
603          * This operation is similar to doing an appendChild to all the
604          * specified elements, adding them into the document.
605          *
606          * @example $("p").append( $("b") );
607          * @before <p>I would like to say: </p><b>Hello</b>
608          * @result <p>I would like to say: <b>Hello</b></p>
609          *
610          * @name append
611          * @type jQuery
612          * @param Array<Element> elems An array of elements, all of which will be appended.
613          * @cat DOM/Manipulation
614          */
615         append: function() {
616                 return this.domManip(arguments, true, 1, function(a){
617                         this.appendChild( a );
618                 });
619         },
620
621         /**
622          * Prepend any number of elements to the inside of every matched elements,
623          * generated from the provided HTML.
624          * This operation is the best way to insert dynamically created elements
625          * inside, at the beginning, of all the matched element.
626          *
627          * @example $("p").prepend("<b>Hello</b>");
628          * @before <p>I would like to say: </p>
629          * @result <p><b>Hello</b>I would like to say: </p>
630          *
631          * @name prepend
632          * @type jQuery
633          * @param String html A string of HTML, that will be created on the fly and appended to the target.
634          * @cat DOM/Manipulation
635          */
636
637         /**
638          * Prepend an element to the inside of all matched elements.
639          * This operation is the best way to insert an element inside, at the
640          * beginning, of all the matched element.
641          *
642          * @example $("p").prepend( $("#foo")[0] );
643          * @before <p>I would like to say: </p><b id="foo">Hello</b>
644          * @result <p><b id="foo">Hello</b>I would like to say: </p>
645          *       
646          * @name prepend
647          * @type jQuery
648          * @param Element elem A DOM element that will be appended.
649          * @cat DOM/Manipulation
650          */
651
652         /**
653          * Prepend any number of elements to the inside of all matched elements.
654          * This operation is the best way to insert a set of elements inside, at the
655          * beginning, of all the matched element.
656          *
657          * @example $("p").prepend( $("b") );
658          * @before <p>I would like to say: </p><b>Hello</b>
659          * @result <p><b>Hello</b>I would like to say: </p>
660          *
661          * @name prepend
662          * @type jQuery
663          * @param Array<Element> elems An array of elements, all of which will be appended.
664          * @cat DOM/Manipulation
665          */
666         prepend: function() {
667                 return this.domManip(arguments, true, -1, function(a){
668                         this.insertBefore( a, this.firstChild );
669                 });
670         },
671
672         /**
673          * Insert any number of dynamically generated elements before each of the
674          * matched elements.
675          *
676          * @example $("p").before("<b>Hello</b>");
677          * @before <p>I would like to say: </p>
678          * @result <b>Hello</b><p>I would like to say: </p>
679          *
680          * @name before
681          * @type jQuery
682          * @param String html A string of HTML, that will be created on the fly and appended to the target.
683          * @cat DOM/Manipulation
684          */
685
686         /**
687          * Insert an element before each of the matched elements.
688          *
689          * @example $("p").before( $("#foo")[0] );
690          * @before <p>I would like to say: </p><b id="foo">Hello</b>
691          * @result <b id="foo">Hello</b><p>I would like to say: </p>
692          *
693          * @name before
694          * @type jQuery
695          * @param Element elem A DOM element that will be appended.
696          * @cat DOM/Manipulation
697          */
698
699         /**
700          * Insert any number of elements before each of the matched elements.
701          *
702          * @example $("p").before( $("b") );
703          * @before <p>I would like to say: </p><b>Hello</b>
704          * @result <b>Hello</b><p>I would like to say: </p>
705          *
706          * @name before
707          * @type jQuery
708          * @param Array<Element> elems An array of elements, all of which will be appended.
709          * @cat DOM/Manipulation
710          */
711         before: function() {
712                 return this.domManip(arguments, false, 1, function(a){
713                         this.parentNode.insertBefore( a, this );
714                 });
715         },
716
717         /**
718          * Insert any number of dynamically generated elements after each of the
719          * matched elements.
720          *
721          * @example $("p").after("<b>Hello</b>");
722          * @before <p>I would like to say: </p>
723          * @result <p>I would like to say: </p><b>Hello</b>
724          *
725          * @name after
726          * @type jQuery
727          * @param String html A string of HTML, that will be created on the fly and appended to the target.
728          * @cat DOM/Manipulation
729          */
730
731         /**
732          * Insert an element after each of the matched elements.
733          *
734          * @example $("p").after( $("#foo")[0] );
735          * @before <b id="foo">Hello</b><p>I would like to say: </p>
736          * @result <p>I would like to say: </p><b id="foo">Hello</b>
737          *
738          * @name after
739          * @type jQuery
740          * @param Element elem A DOM element that will be appended.
741          * @cat DOM/Manipulation
742          */
743
744         /**
745          * Insert any number of elements after each of the matched elements.
746          *
747          * @example $("p").after( $("b") );
748          * @before <b>Hello</b><p>I would like to say: </p>
749          * @result <p>I would like to say: </p><b>Hello</b>
750          *
751          * @name after
752          * @type jQuery
753          * @param Array<Element> elems An array of elements, all of which will be appended.
754          * @cat DOM/Manipulation
755          */
756         after: function() {
757                 return this.domManip(arguments, false, -1, function(a){
758                         this.parentNode.insertBefore( a, this.nextSibling );
759                 });
760         },
761
762         /**
763          * End the most recent 'destructive' operation, reverting the list of matched elements
764          * back to its previous state. After an end operation, the list of matched elements will
765          * revert to the last state of matched elements.
766          *
767          * @example $("p").find("span").end();
768          * @before <p><span>Hello</span>, how are you?</p>
769          * @result $("p").find("span").end() == [ <p>...</p> ]
770          *
771          * @name end
772          * @type jQuery
773          * @cat DOM/Traversing
774          */
775         end: function() {
776                 if( !(this.stack && this.stack.length) )
777                         return this;
778                 return this.set( this.stack.pop() );
779         },
780
781         /**
782          * Searches for all elements that match the specified expression.
783          * This method is the optimal way of finding additional descendant
784          * elements with which to process.
785          *
786          * All searching is done using a jQuery expression. The expression can be
787          * written using CSS 1-3 Selector syntax, or basic XPath.
788          *
789          * @example $("p").find("span");
790          * @before <p><span>Hello</span>, how are you?</p>
791          * @result $("p").find("span") == [ <span>Hello</span> ]
792          *
793          * @name find
794          * @type jQuery
795          * @param String expr An expression to search with.
796          * @cat DOM/Traversing
797          */
798         find: function(t) {
799                 return this.pushStack( jQuery.map( this, function(a){
800                         return jQuery.find(t,a);
801                 }), arguments );
802         },
803
804         /**
805          * Create cloned copies of all matched DOM Elements. This does
806          * not create a cloned copy of this particular jQuery object,
807          * instead it creates duplicate copies of all DOM Elements.
808          * This is useful for moving copies of the elements to another
809          * location in the DOM.
810          *
811          * @example $("b").clone().prependTo("p");
812          * @before <b>Hello</b><p>, how are you?</p>
813          * @result <b>Hello</b><p><b>Hello</b>, how are you?</p>
814          *
815          * @name clone
816          * @type jQuery
817          * @cat DOM/Manipulation
818          */
819         clone: function(deep) {
820                 return this.pushStack( jQuery.map( this, function(a){
821                         return a.cloneNode( deep != undefined ? deep : true );
822                 }), arguments );
823         },
824
825         /**
826          * Removes all elements from the set of matched elements that do not
827          * match the specified expression. This method is used to narrow down
828          * the results of a search.
829          *
830          * All searching is done using a jQuery expression. The expression
831          * can be written using CSS 1-3 Selector syntax, or basic XPath.
832          *
833          * @example $("p").filter(".selected")
834          * @before <p class="selected">Hello</p><p>How are you?</p>
835          * @result $("p").filter(".selected") == [ <p class="selected">Hello</p> ]
836          *
837          * @name filter
838          * @type jQuery
839          * @param String expr An expression to search with.
840          * @cat DOM/Traversing
841          */
842
843         /**
844          * Removes all elements from the set of matched elements that do not
845          * match at least one of the expressions passed to the function. This
846          * method is used when you want to filter the set of matched elements
847          * through more than one expression.
848          *
849          * Elements will be retained in the jQuery object if they match at
850          * least one of the expressions passed.
851          *
852          * @example $("p").filter([".selected", ":first"])
853          * @before <p>Hello</p><p>Hello Again</p><p class="selected">And Again</p>
854          * @result $("p").filter([".selected", ":first"]) == [ <p>Hello</p>, <p class="selected">And Again</p> ]
855          *
856          * @name filter
857          * @type jQuery
858          * @param Array<String> exprs A set of expressions to evaluate against
859          * @cat DOM/Traversing
860          */
861         filter: function(t) {
862                 return this.pushStack(
863                         t.constructor == Array &&
864                         jQuery.map(this,function(a){
865                                 for ( var i = 0; i < t.length; i++ )
866                                         if ( jQuery.filter(t[i],[a]).r.length )
867                                                 return a;
868                                 return null;
869                         }) ||
870
871                         t.constructor == Boolean &&
872                         ( t ? this.get() : [] ) ||
873
874                         typeof t == "function" &&
875                         jQuery.grep( this, t ) ||
876
877                         jQuery.filter(t,this).r, arguments );
878         },
879
880         /**
881          * Removes the specified Element from the set of matched elements. This
882          * method is used to remove a single Element from a jQuery object.
883          *
884          * @example $("p").not( document.getElementById("selected") )
885          * @before <p>Hello</p><p id="selected">Hello Again</p>
886          * @result [ <p>Hello</p> ]
887          *
888          * @name not
889          * @type jQuery
890          * @param Element el An element to remove from the set
891          * @cat DOM/Traversing
892          */
893
894         /**
895          * Removes elements matching the specified expression from the set
896          * of matched elements. This method is used to remove one or more
897          * elements from a jQuery object.
898          *
899          * @example $("p").not("#selected")
900          * @before <p>Hello</p><p id="selected">Hello Again</p>
901          * @result [ <p>Hello</p> ]
902          *
903          * @name not
904          * @type jQuery
905          * @param String expr An expression with which to remove matching elements
906          * @cat DOM/Traversing
907          */
908         not: function(t) {
909                 return this.pushStack( typeof t == "string" ?
910                         jQuery.filter(t,this,true).r :
911                         jQuery.grep(this,function(a){ return a != t; }), arguments );
912         },
913
914         /**
915          * Adds the elements matched by the expression to the jQuery object. This
916          * can be used to concatenate the result sets of two expressions.
917          *
918          * @example $("p").add("span")
919          * @before <p>Hello</p><p><span>Hello Again</span></p>
920          * @result [ <p>Hello</p>, <span>Hello Again</span> ]
921          *
922          * @name add
923          * @type jQuery
924          * @param String expr An expression whose matched elements are added
925          * @cat DOM/Traversing
926          */
927
928         /**
929          * Adds each of the Elements in the array to the set of matched elements.
930          * This is used to add a set of Elements to a jQuery object.
931          *
932          * @example $("p").add([document.getElementById("a"), document.getElementById("b")])
933          * @before <p>Hello</p><p><span id="a">Hello Again</span><span id="b">And Again</span></p>
934          * @result [ <p>Hello</p>, <span id="a">Hello Again</span>, <span id="b">And Again</span> ]
935          *
936          * @name add
937          * @type jQuery
938          * @param Array<Element> els An array of Elements to add
939          * @cat DOM/Traversing
940          */
941
942         /**
943          * Adds a single Element to the set of matched elements. This is used to
944          * add a single Element to a jQuery object.
945          *
946          * @example $("p").add( document.getElementById("a") )
947          * @before <p>Hello</p><p><span id="a">Hello Again</span></p>
948          * @result [ <p>Hello</p>, <span id="a">Hello Again</span> ]
949          *
950          * @name add
951          * @type jQuery
952          * @param Element el An Element to add
953          * @cat DOM/Traversing
954          */
955         add: function(t) {
956                 return this.pushStack( jQuery.merge(
957                         this.get(), typeof t == "string" ?
958                                 jQuery.find(t) :
959                                 t.constructor == Array ? t : [t] ), arguments );
960         },
961
962         /**
963          * Checks the current selection against an expression and returns true,
964          * if at least one element of the selection fits the given expression.
965          * Does return false, if no element fits or the expression is not valid.
966          *
967          * @example $("input[@type='checkbox']").parent().is("form")
968          * @before <form><input type="checkbox" /></form>
969          * @result true
970          * @desc Returns true, because the parent of the input is a form element
971          * 
972          * @example $("input[@type='checkbox']").parent().is("form")
973          * @before <form><p><input type="checkbox" /></p></form>
974          * @result false
975          * @desc Returns false, because the parent of the input is a p element
976          *
977          * @example $("form").is(null)
978          * @before <form></form>
979          * @result false
980          * @desc An invalid expression always returns false.
981          *
982          * @name is
983          * @type Boolean
984          * @param String expr The expression with which to filter
985          * @cat DOM/Traversing
986          */
987         is: function(expr) {
988                 return expr ? jQuery.filter(expr,this).r.length > 0 : false;
989         },
990         
991         /**
992          * @private
993          * @name domManip
994          * @param Array args
995          * @param Boolean table Insert TBODY in TABLEs if one is not found.
996          * @param Number dir If dir<0, process args in reverse order.
997          * @param Function fn The function doing the DOM manipulation.
998          * @type jQuery
999          * @cat Core
1000          */
1001         domManip: function(args, table, dir, fn){
1002                 var clone = this.length > 1; 
1003                 var a = jQuery.clean(args);
1004                 if ( dir < 0 )
1005                         a.reverse();
1006
1007                 return this.each(function(){
1008                         var obj = this;
1009
1010                         if ( table && this.nodeName.toUpperCase() == "TABLE" && a[0].nodeName.toUpperCase() == "TR" )
1011                                 obj = this.getElementsByTagName("tbody")[0] || this.appendChild(document.createElement("tbody"));
1012
1013                         for ( var i=0; i < a.length; i++ )
1014                                 fn.apply( obj, [ clone ? a[i].cloneNode(true) : a[i] ] );
1015
1016                 });
1017         },
1018
1019         /**
1020          *
1021          *
1022          * @private
1023          * @name pushStack
1024          * @param Array a
1025          * @param Array args
1026          * @type jQuery
1027          * @cat Core
1028          */
1029         pushStack: function(a,args) {
1030                 var fn = args && args.length > 1 && args[args.length-1];
1031                 var fn2 = args && args.length > 2 && args[args.length-2];
1032                 
1033                 if ( fn && fn.constructor != Function ) fn = null;
1034                 if ( fn2 && fn2.constructor != Function ) fn2 = null;
1035
1036                 if ( !fn ) {
1037                         if ( !this.stack ) this.stack = [];
1038                         this.stack.push( this.get() );
1039                         this.set( a );
1040                 } else {
1041                         var old = this.get();
1042                         this.set( a );
1043
1044                         if ( fn2 && a.length || !fn2 )
1045                                 this.each( fn2 || fn ).set( old );
1046                         else
1047                                 this.set( old ).each( fn );
1048                 }
1049
1050                 return this;
1051         }
1052 };
1053
1054 /**
1055  * Extends the jQuery object itself. Can be used to add functions into
1056  * the jQuery namespace and to add plugin methods (plugins).
1057  * 
1058  * @example jQuery.fn.extend({
1059  *   check: function() {
1060  *     return this.each(function() { this.checked = true; });
1061  *   ),
1062  *   uncheck: function() {
1063  *     return this.each(function() { this.checked = false; });
1064  *   }
1065  * });
1066  * $("input[@type=checkbox]").check();
1067  * $("input[@type=radio]").uncheck();
1068  * @desc Adds two plugin methods.
1069  *
1070  * @example jQuery.extend({
1071  *   min: function(a, b) { return a < b ? a : b; },
1072  *   max: function(a, b) { return a > b ? a : b; }
1073  * });
1074  * @desc Adds two functions into the jQuery namespace
1075  *
1076  * @name $.extend
1077  * @param Object prop The object that will be merged into the jQuery object
1078  * @type Object
1079  * @cat Core
1080  */
1081
1082 /**
1083  * Extend one object with one or more others, returning the original,
1084  * modified, object. This is a great utility for simple inheritance.
1085  * 
1086  * @example var settings = { validate: false, limit: 5, name: "foo" };
1087  * var options = { validate: true, name: "bar" };
1088  * jQuery.extend(settings, options);
1089  * @result settings == { validate: true, limit: 5, name: "bar" }
1090  * @desc Merge settings and options, modifying settings
1091  *
1092  * @example var defaults = { validate: false, limit: 5, name: "foo" };
1093  * var options = { validate: true, name: "bar" };
1094  * var settings = jQuery.extend({}, defaults, options);
1095  * @result settings == { validate: true, limit: 5, name: "bar" }
1096  * @desc Merge defaults and options, without modifying the defaults
1097  *
1098  * @name $.extend
1099  * @param Object target The object to extend
1100  * @param Object prop1 The object that will be merged into the first.
1101  * @param Object propN (optional) More objects to merge into the first
1102  * @type Object
1103  * @cat Javascript
1104  */
1105 jQuery.extend = jQuery.fn.extend = function() {
1106         // copy reference to target object
1107         var target = arguments[0],
1108                 a = 1;
1109
1110         // extend jQuery itself if only one argument is passed
1111         if ( arguments.length == 1 ) {
1112                 target = this;
1113                 a = 0;
1114         }
1115         var prop;
1116         while (prop = arguments[a++])
1117                 // Extend the base object
1118                 for ( var i in prop ) target[i] = prop[i];
1119
1120         // Return the modified object
1121         return target;
1122 };
1123
1124 jQuery.extend({
1125         /**
1126          * @private
1127          * @name init
1128          * @type undefined
1129          * @cat Core
1130          */
1131         init: function(){
1132                 jQuery.initDone = true;
1133
1134                 jQuery.each( jQuery.macros.axis, function(i,n){
1135                         jQuery.fn[ i ] = function(a) {
1136                                 var ret = jQuery.map(this,n);
1137                                 if ( a && typeof a == "string" )
1138                                         ret = jQuery.filter(a,ret).r;
1139                                 return this.pushStack( ret, arguments );
1140                         };
1141                 });
1142
1143                 jQuery.each( jQuery.macros.to, function(i,n){
1144                         jQuery.fn[ i ] = function(){
1145                                 var a = arguments;
1146                                 return this.each(function(){
1147                                         for ( var j = 0; j < a.length; j++ )
1148                                                 jQuery(a[j])[n]( this );
1149                                 });
1150                         };
1151                 });
1152
1153                 jQuery.each( jQuery.macros.each, function(i,n){
1154                         jQuery.fn[ i ] = function() {
1155                                 return this.each( n, arguments );
1156                         };
1157                 });
1158
1159                 jQuery.each( jQuery.macros.filter, function(i,n){
1160                         jQuery.fn[ n ] = function(num,fn) {
1161                                 return this.filter( ":" + n + "(" + num + ")", fn );
1162                         };
1163                 });
1164
1165                 jQuery.each( jQuery.macros.attr, function(i,n){
1166                         n = n || i;
1167                         jQuery.fn[ i ] = function(h) {
1168                                 return h == undefined ?
1169                                         this.length ? this[0][n] : null :
1170                                         this.attr( n, h );
1171                         };
1172                 });
1173
1174                 jQuery.each( jQuery.macros.css, function(i,n){
1175                         jQuery.fn[ n ] = function(h) {
1176                                 return h == undefined ?
1177                                         ( this.length ? jQuery.css( this[0], n ) : null ) :
1178                                         this.css( n, h );
1179                         };
1180                 });
1181
1182         },
1183
1184         /**
1185          * A generic iterator function, which can be used to seemlessly
1186          * iterate over both objects and arrays. This function is not the same
1187          * as $().each() - which is used to iterate, exclusively, over a jQuery
1188          * object. This function can be used to iterate over anything.
1189          *
1190          * @example $.each( [0,1,2], function(i){
1191          *   alert( "Item #" + i + ": " + this );
1192          * });
1193          * @desc This is an example of iterating over the items in an array, accessing both the current item and its index.
1194          *
1195          * @example $.each( { name: "John", lang: "JS" }, function(i){
1196          *   alert( "Name: " + i + ", Value: " + this );
1197          * });
1198          * @desc This is an example of iterating over the properties in an Object, accessing both the current item and its key.
1199          *
1200          * @name $.each
1201          * @param Object obj The object, or array, to iterate over.
1202          * @param Function fn The function that will be executed on every object.
1203          * @type Object
1204          * @cat Javascript
1205          */
1206         // args is for internal usage only
1207         each: function( obj, fn, args ) {
1208                 if ( obj.length == undefined )
1209                         for ( var i in obj )
1210                                 fn.apply( obj[i], args || [i, obj[i]] );
1211                 else
1212                         for ( var i = 0; i < obj.length; i++ )
1213                                 if ( fn.apply( obj[i], args || [i, obj[i]] ) === false ) break;
1214                 return obj;
1215         },
1216
1217         className: {
1218                 add: function(o,c){
1219                         if (jQuery.className.has(o,c)) return;
1220                         o.className += ( o.className ? " " : "" ) + c;
1221                 },
1222                 remove: function(o,c){
1223                         if( !c ) {
1224                                 o.className = "";
1225                         } else {
1226                                 var classes = o.className.split(" ");
1227                                 for(var i=0; i<classes.length; i++) {
1228                                         if(classes[i] == c) {
1229                                                 classes.splice(i, 1);
1230                                                 break;
1231                                         }
1232                                 }
1233                                 o.className = classes.join(' ');
1234                         }
1235                 },
1236                 has: function(e,a) {
1237                         if ( e.className != undefined )
1238                                 e = e.className;
1239                         return new RegExp("(^|\\s)" + a + "(\\s|$)").test(e);
1240                 }
1241         },
1242
1243         /**
1244          * Swap in/out style options.
1245          * @private
1246          */
1247         swap: function(e,o,f) {
1248                 for ( var i in o ) {
1249                         e.style["old"+i] = e.style[i];
1250                         e.style[i] = o[i];
1251                 }
1252                 f.apply( e, [] );
1253                 for ( var i in o )
1254                         e.style[i] = e.style["old"+i];
1255         },
1256
1257         css: function(e,p) {
1258                 if ( p == "height" || p == "width" ) {
1259                         var old = {}, oHeight, oWidth, d = ["Top","Bottom","Right","Left"];
1260
1261                         for ( var i=0; i<d.length; i++ ) {
1262                                 old["padding" + d[i]] = 0;
1263                                 old["border" + d[i] + "Width"] = 0;
1264                         }
1265
1266                         jQuery.swap( e, old, function() {
1267                                 if (jQuery.css(e,"display") != "none") {
1268                                         oHeight = e.offsetHeight;
1269                                         oWidth = e.offsetWidth;
1270                                 } else {
1271                                         e = jQuery(e.cloneNode(true))
1272                                                 .find(":radio").removeAttr("checked").end()
1273                                                 .css({
1274                                                         visibility: "hidden", position: "absolute", display: "block", right: "0", left: "0"
1275                                                 }).appendTo(e.parentNode)[0];
1276
1277                                         var parPos = jQuery.css(e.parentNode,"position");
1278                                         if ( parPos == "" || parPos == "static" )
1279                                                 e.parentNode.style.position = "relative";
1280
1281                                         oHeight = e.clientHeight;
1282                                         oWidth = e.clientWidth;
1283
1284                                         if ( parPos == "" || parPos == "static" )
1285                                                 e.parentNode.style.position = "static";
1286
1287                                         e.parentNode.removeChild(e);
1288                                 }
1289                         });
1290
1291                         return p == "height" ? oHeight : oWidth;
1292                 }
1293
1294                 return jQuery.curCSS( e, p );
1295         },
1296
1297         curCSS: function(elem, prop, force) {
1298                 var ret;
1299                 
1300                 if (prop == 'opacity' && jQuery.browser.msie)
1301                         return jQuery.attr(elem.style, 'opacity');
1302                         
1303                 if (prop == "float" || prop == "cssFloat")
1304                     prop = jQuery.browser.msie ? "styleFloat" : "cssFloat";
1305
1306                 if (!force && elem.style[prop]) {
1307
1308                         ret = elem.style[prop];
1309
1310                 } else if (document.defaultView && document.defaultView.getComputedStyle) {
1311
1312                         if (prop == "cssFloat" || prop == "styleFloat")
1313                                 prop = "float";
1314
1315                         prop = prop.replace(/([A-Z])/g,"-$1").toLowerCase();
1316                         var cur = document.defaultView.getComputedStyle(elem, null);
1317
1318                         if ( cur )
1319                                 ret = cur.getPropertyValue(prop);
1320                         else if ( prop == 'display' )
1321                                 ret = 'none';
1322                         else
1323                                 jQuery.swap(elem, { display: 'block' }, function() {
1324                                     var c = document.defaultView.getComputedStyle(this, '');
1325                                     ret = c && c.getPropertyValue(prop) || '';
1326                                 });
1327
1328                 } else if (elem.currentStyle) {
1329
1330                         var newProp = prop.replace(/\-(\w)/g,function(m,c){return c.toUpperCase();});
1331                         ret = elem.currentStyle[prop] || elem.currentStyle[newProp];
1332                         
1333                 }
1334
1335                 return ret;
1336         },
1337         
1338         clean: function(a) {
1339                 var r = [];
1340                 for ( var i = 0; i < a.length; i++ ) {
1341                         var arg = a[i];
1342                         if ( typeof arg == "string" ) { // Convert html string into DOM nodes
1343                                 // Trim whitespace, otherwise indexOf won't work as expected
1344                                 var s = jQuery.trim(arg), s3 = s.substring(0,3), s6 = s.substring(0,6),
1345                                         div = document.createElement("div"), wrap = [0,"",""];
1346
1347                                 if ( s.substring(0,4) == "<opt" ) // option or optgroup
1348                                         wrap = [1, "<select>", "</select>"];
1349                                 else if ( s6 == "<thead" || s6 == "<tbody" || s6 == "<tfoot" )
1350                                         wrap = [1, "<table>", "</table>"];
1351                                 else if ( s3 == "<tr" )
1352                                         wrap = [2, "<table><tbody>", "</tbody></table>"];
1353                                 else if ( s3 == "<td" || s3 == "<th" ) // <thead> matched above
1354                                         wrap = [3, "<table><tbody><tr>", "</tr></tbody></table>"];
1355
1356                                 // Go to html and back, then peel off extra wrappers
1357                                 div.innerHTML = wrap[1] + s + wrap[2];
1358                                 while ( wrap[0]-- ) div = div.firstChild;
1359                                 
1360                                 // Remove IE's autoinserted <tbody> from table fragments
1361                                 if ( jQuery.browser.msie ) {
1362                                         var tb = null;
1363                                         // String was a <table>, *may* have spurious <tbody>
1364                                         if ( s6 == "<table" && s.indexOf("<tbody") < 0 ) 
1365                                                 tb = div.firstChild && div.firstChild.childNodes;
1366                                         // String was a bare <thead> or <tfoot>
1367                                         else if ( wrap[1] == "<table>" && s.indexOf("<tbody") < 0 )
1368                                                 tb = div.childNodes;
1369                                         if ( tb ) {
1370                                                 for ( var n = tb.length-1; n >= 0 ; --n )
1371                                                         if ( tb[n].nodeName.toUpperCase() == "TBODY" && !tb[n].childNodes.length )
1372                                                                 tb[n].parentNode.removeChild(tb[n]);
1373                                         }
1374                                 }
1375                                 
1376                                 arg = div.childNodes;
1377                         } 
1378                         
1379                         
1380                         if ( arg.length != undefined && ( (jQuery.browser.safari && typeof arg == 'function') || !arg.nodeType ) ) // Safari reports typeof on a DOM NodeList to be a function
1381                                 for ( var n = 0; n < arg.length; n++ ) // Handles Array, jQuery, DOM NodeList collections
1382                                         r.push(arg[n]);
1383                         else
1384                                 r.push( arg.nodeType ? arg : document.createTextNode(arg.toString()) );
1385                 }
1386
1387                 return r;
1388         },
1389
1390         nth: function(cur,result,dir){
1391                 result = result || 1;
1392                 var num = 0;
1393                 for ( ; cur; cur = cur[dir] ) {
1394                         if ( cur.nodeType == 1 ) num++;
1395                         if ( num == result || result == "even" && num % 2 == 0 && num > 1 ||
1396                                 result == "odd" && num % 2 == 1 ) return cur;
1397                 }
1398         },
1399
1400         expr: {
1401                 "": "m[2]== '*'||a.nodeName.toUpperCase()==m[2].toUpperCase()",
1402                 "#": "a.getAttribute('id')==m[2]",
1403                 ":": {
1404                         // Position Checks
1405                         lt: "i<m[3]-0",
1406                         gt: "i>m[3]-0",
1407                         nth: "m[3]-0==i",
1408                         eq: "m[3]-0==i",
1409                         first: "i==0",
1410                         last: "i==r.length-1",
1411                         even: "i%2==0",
1412                         odd: "i%2",
1413
1414                         // Child Checks
1415                         "nth-child": "jQuery.nth(a.parentNode.firstChild,m[3],'nextSibling')==a",
1416                         "first-child": "jQuery.nth(a.parentNode.firstChild,1,'nextSibling')==a",
1417                         "last-child": "jQuery.nth(a.parentNode.lastChild,1,'previousSibling')==a",
1418                         "only-child": "jQuery.sibling(a.parentNode.firstChild).length==1",
1419
1420                         // Parent Checks
1421                         parent: "a.childNodes.length",
1422                         empty: "!a.childNodes.length",
1423
1424                         // Text Check
1425                         contains: "jQuery.fn.text.apply([a]).indexOf(m[3])>=0",
1426
1427                         // Visibility
1428                         visible: "a.type!='hidden'&&jQuery.css(a,'display')!='none'&&jQuery.css(a,'visibility')!='hidden'",
1429                         hidden: "a.type=='hidden'||jQuery.css(a,'display')=='none'||jQuery.css(a,'visibility')=='hidden'",
1430
1431                         // Form attributes
1432                         enabled: "!a.disabled",
1433                         disabled: "a.disabled",
1434                         checked: "a.checked",
1435                         selected: "a.selected || jQuery.attr(a, 'selected')",
1436
1437                         // Form elements
1438                         text: "a.type=='text'",
1439                         radio: "a.type=='radio'",
1440                         checkbox: "a.type=='checkbox'",
1441                         file: "a.type=='file'",
1442                         password: "a.type=='password'",
1443                         submit: "a.type=='submit'",
1444                         image: "a.type=='image'",
1445                         reset: "a.type=='reset'",
1446                         button: "a.type=='button'",
1447                         input: "/input|select|textarea|button/i.test(a.nodeName)"
1448                 },
1449                 ".": "jQuery.className.has(a,m[2])",
1450                 "@": {
1451                         "=": "z==m[4]",
1452                         "!=": "z!=m[4]",
1453                         "^=": "z && !z.indexOf(m[4])",
1454                         "$=": "z && z.substr(z.length - m[4].length,m[4].length)==m[4]",
1455                         "*=": "z && z.indexOf(m[4])>=0",
1456                         "": "z"
1457                 },
1458                 "[": "jQuery.find(m[2],a).length"
1459         },
1460
1461   /**
1462          * All elements on a specified axis.
1463          *
1464          * @private
1465          * @name $.sibling
1466          * @type Array
1467          * @param Element elem The element to find all the siblings of (including itself).
1468    * @cat DOM/Traversing
1469    */
1470         sibling: function( n, elem ) {
1471                 var r = [];
1472
1473                 for ( ; n; n = n.nextSibling ) {
1474                         if ( n.nodeType == 1 && (!elem || n != elem) )
1475                                 r.push( n );
1476                 }
1477
1478                 return r;
1479         },
1480
1481         token: [
1482                 "\\.\\.|/\\.\\.", "a.parentNode",
1483                 ">|/", "jQuery.sibling(a.firstChild)",
1484                 "\\+", "jQuery.nth(a,2,'nextSibling')",
1485                 "~", function(a){
1486                         var s = jQuery.sibling(a.parentNode.firstChild)
1487                         return s.slice(0, jQuery.inArray(a,s));
1488                 }
1489         ],
1490
1491         /**
1492          * @name $.find
1493          * @type Array<Element>
1494          * @private
1495          * @cat Core
1496          */
1497         find: function( t, context ) {
1498                 // Quickly handle non-string expressions
1499                 if ( typeof t != "string" )
1500                         return [ t ];
1501
1502                 // Make sure that the context is a DOM Element
1503                 if ( context && context.nodeType == undefined )
1504                         context = null;
1505
1506                 // Set the correct context (if none is provided)
1507                 context = context || document;
1508
1509                 // Handle the common XPath // expression
1510                 if ( !t.indexOf("//") ) {
1511                         context = context.documentElement;
1512                         t = t.substr(2,t.length);
1513
1514                 // And the / root expression
1515                 } else if ( !t.indexOf("/") ) {
1516                         context = context.documentElement;
1517                         t = t.substr(1,t.length);
1518                         if ( t.indexOf("/") >= 1 )
1519                                 t = t.substr(t.indexOf("/"),t.length);
1520                 }
1521
1522                 // Initialize the search
1523                 var ret = [context], done = [], last = null;
1524
1525                 // Continue while a selector expression exists, and while
1526                 // we're no longer looping upon ourselves
1527                 while ( t && last != t ) {
1528                         var r = [];
1529                         last = t;
1530
1531                         t = jQuery.trim(t).replace( /^\/\//i, "" );
1532
1533                         var foundToken = false;
1534
1535                         // An attempt at speeding up child selectors that
1536                         // point to a specific element tag
1537                         var re = /^[\/>]\s*([a-z0-9*-]+)/i;
1538                         var m = re.exec(t);
1539
1540                         if ( m ) {
1541                                 // Perform our own iteration and filter
1542                                 for ( var i = 0; i < ret.length; i++ )
1543                                         for ( var c = ret[i].firstChild; c; c = c.nextSibling )
1544                                                 if ( c.nodeType == 1 && ( c.nodeName == m[1].toUpperCase() || m[1] == "*" ) )
1545                                                         r.push( c );
1546
1547                                 ret = r;
1548                                 t = jQuery.trim( t.replace( re, "" ) );
1549                                 foundToken = true;
1550                         } else {
1551                                 // Look for pre-defined expression tokens
1552                                 for ( var i = 0; i < jQuery.token.length; i += 2 ) {
1553                                         // Attempt to match each, individual, token in
1554                                         // the specified order
1555                                         var re = new RegExp("^(" + jQuery.token[i] + ")");
1556                                         var m = re.exec(t);
1557
1558                                         // If the token match was found
1559                                         if ( m ) {
1560                                                 // Map it against the token's handler
1561                                                 r = ret = jQuery.map( ret, jQuery.token[i+1].constructor == Function ?
1562                                                         jQuery.token[i+1] :
1563                                                         function(a){ return eval(jQuery.token[i+1]); });
1564
1565                                                 // And remove the token
1566                                                 t = jQuery.trim( t.replace( re, "" ) );
1567                                                 foundToken = true;
1568                                                 break;
1569                                         }
1570                                 }
1571                         }
1572
1573                         // See if there's still an expression, and that we haven't already
1574                         // matched a token
1575                         if ( t && !foundToken ) {
1576                                 // Handle multiple expressions
1577                                 if ( !t.indexOf(",") || !t.indexOf("|") ) {
1578                                         // Clean teh result set
1579                                         if ( ret[0] == context ) ret.shift();
1580
1581                                         // Merge the result sets
1582                                         jQuery.merge( done, ret );
1583
1584                                         // Reset the context
1585                                         r = ret = [context];
1586
1587                                         // Touch up the selector string
1588                                         t = " " + t.substr(1,t.length);
1589
1590                                 } else {
1591                                         // Optomize for the case nodeName#idName
1592                                         var re2 = /^([a-z0-9_-]+)(#)([a-z0-9\\*_-]*)/i;
1593                                         var m = re2.exec(t);
1594                                         
1595                                         // Re-organize the results, so that they're consistent
1596                                         if ( m ) {
1597                                            m = [ 0, m[2], m[3], m[1] ];
1598
1599                                         } else {
1600                                                 // Otherwise, do a traditional filter check for
1601                                                 // ID, class, and element selectors
1602                                                 re2 = /^([#.]?)([a-z0-9\\*_-]*)/i;
1603                                                 m = re2.exec(t);
1604                                         }
1605
1606                                         // Try to do a global search by ID, where we can
1607                                         if ( m[1] == "#" && ret[ret.length-1].getElementById ) {
1608                                                 // Optimization for HTML document case
1609                                                 var oid = ret[ret.length-1].getElementById(m[2]);
1610
1611                                                 // Do a quick check for node name (where applicable) so
1612                                                 // that div#foo searches will be really fast
1613                                                 ret = r = oid && 
1614                                                   (!m[3] || oid.nodeName == m[3].toUpperCase()) ? [oid] : [];
1615
1616                                         // Use the DOM 0 shortcut for the body element
1617                                         } else if ( m[1] == "" && m[2] == "body" ) {
1618                                                 ret = r = [ document.body ];
1619
1620                                         } else {
1621                                                 // Pre-compile a regular expression to handle class searches
1622                                                 if ( m[1] == "." )
1623                                                         var rec = new RegExp("(^|\\s)" + m[2] + "(\\s|$)");
1624
1625                                                 // We need to find all descendant elements, it is more
1626                                                 // efficient to use getAll() when we are already further down
1627                                                 // the tree - we try to recognize that here
1628                                                 for ( var i = 0; i < ret.length; i++ )
1629                                                         jQuery.merge( r,
1630                                                                 m[1] != "" && ret.length != 1 ?
1631                                                                         jQuery.getAll( ret[i], [], m[1], m[2], rec ) :
1632                                                                         ret[i].getElementsByTagName( m[1] != "" || m[0] == "" ? "*" : m[2] )
1633                                                         );
1634
1635                                                 // It's faster to filter by class and be done with it
1636                                                 if ( m[1] == "." && ret.length == 1 )
1637                                                         r = jQuery.grep( r, function(e) {
1638                                                                 return rec.test(e.className);
1639                                                         });
1640
1641                                                 // Same with ID filtering
1642                                                 if ( m[1] == "#" && ret.length == 1 ) {
1643                                                         // Remember, then wipe out, the result set
1644                                                         var tmp = r;
1645                                                         r = [];
1646
1647                                                         // Then try to find the element with the ID
1648                                                         for ( var i = 0; i < tmp.length; i++ )
1649                                                                 if ( tmp[i].getAttribute("id") == m[2] ) {
1650                                                                         r = [ tmp[i] ];
1651                                                                         break;
1652                                                                 }
1653                                                 }
1654
1655                                                 ret = r;
1656                                         }
1657
1658                                         t = t.replace( re2, "" );
1659                                 }
1660
1661                         }
1662
1663                         // If a selector string still exists
1664                         if ( t ) {
1665                                 // Attempt to filter it
1666                                 var val = jQuery.filter(t,r);
1667                                 ret = r = val.r;
1668                                 t = jQuery.trim(val.t);
1669                         }
1670                 }
1671
1672                 // Remove the root context
1673                 if ( ret && ret[0] == context ) ret.shift();
1674
1675                 // And combine the results
1676                 jQuery.merge( done, ret );
1677
1678                 return done;
1679         },
1680
1681         getAll: function( o, r, token, name, re ) {
1682                 for ( var s = o.firstChild; s; s = s.nextSibling )
1683                         if ( s.nodeType == 1 ) {
1684                                 var add = true;
1685
1686                                 if ( token == "." )
1687                                         add = s.className && re.test(s.className);
1688                                 else if ( token == "#" )
1689                                         add = s.getAttribute('id') == name;
1690         
1691                                 if ( add )
1692                                         r.push( s );
1693
1694                                 if ( token == "#" && r.length ) break;
1695
1696                                 if ( s.firstChild )
1697                                         jQuery.getAll( s, r, token, name, re );
1698                         }
1699
1700                 return r;
1701         },
1702
1703         attr: function(elem, name, value){
1704                 var fix = {
1705                         "for": "htmlFor",
1706                         "class": "className",
1707                         "float": jQuery.browser.msie ? "styleFloat" : "cssFloat",
1708                         cssFloat: jQuery.browser.msie ? "styleFloat" : "cssFloat",
1709                         innerHTML: "innerHTML",
1710                         className: "className",
1711                         value: "value",
1712                         disabled: "disabled",
1713                         checked: "checked",
1714                         readonly: "readOnly"
1715                 };
1716                 
1717                 // IE actually uses filters for opacity ... elem is actually elem.style
1718                 if ( name == "opacity" && jQuery.browser.msie && value != undefined ) {
1719                         // IE has trouble with opacity if it does not have layout
1720                         // Force it by setting the zoom level
1721                         elem.zoom = 1; 
1722
1723                         // Set the alpha filter to set the opacity
1724                         return elem.filter = elem.filter.replace(/alpha\([^\)]*\)/gi,"") +
1725                                 ( value == 1 ? "" : "alpha(opacity=" + value * 100 + ")" );
1726
1727                 } else if ( name == "opacity" && jQuery.browser.msie ) {
1728                         return elem.filter ? 
1729                                 parseFloat( elem.filter.match(/alpha\(opacity=(.*)\)/)[1] ) / 100 : 1;
1730                 }
1731                 
1732                 // Mozilla doesn't play well with opacity 1
1733                 if ( name == "opacity" && jQuery.browser.mozilla && value == 1 )
1734                         value = 0.9999;
1735
1736                 // Certain attributes only work when accessed via the old DOM 0 way
1737                 if ( fix[name] ) {
1738                         if ( value != undefined ) elem[fix[name]] = value;
1739                         return elem[fix[name]];
1740
1741                 } else if ( value == undefined && jQuery.browser.msie && elem.nodeName && elem.nodeName.toUpperCase() == 'FORM' && (name == 'action' || name == 'method') ) {
1742                         return elem.getAttributeNode(name).nodeValue;
1743
1744                 // IE elem.getAttribute passes even for style
1745                 } else if ( elem.tagName ) {
1746                         if ( value != undefined ) elem.setAttribute( name, value );
1747                         return elem.getAttribute( name );
1748
1749                 } else {
1750                         name = name.replace(/-([a-z])/ig,function(z,b){return b.toUpperCase();});
1751                         if ( value != undefined ) elem[name] = value;
1752                         return elem[name];
1753                 }
1754         },
1755
1756         // The regular expressions that power the parsing engine
1757         parse: [
1758                 // Match: [@value='test'], [@foo]
1759                 "\\[ *(@)S *([!*$^=]*) *('?\"?)(.*?)\\4 *\\]",
1760
1761                 // Match: [div], [div p]
1762                 "(\\[)\s*(.*?)\s*\\]",
1763
1764                 // Match: :contains('foo')
1765                 "(:)S\\(\"?'?([^\\)]*?)\"?'?\\)",
1766
1767                 // Match: :even, :last-chlid
1768                 "([:.#]*)S"
1769         ],
1770
1771         filter: function(t,r,not) {
1772                 // Look for common filter expressions
1773                 while ( t && /^[a-z[({<*:.#]/i.test(t) ) {
1774
1775                         var p = jQuery.parse;
1776
1777                         for ( var i = 0; i < p.length; i++ ) {
1778                 
1779                                 // Look for, and replace, string-like sequences
1780                                 // and finally build a regexp out of it
1781                                 var re = new RegExp(
1782                                         "^" + p[i].replace("S", "([a-z*_-][a-z0-9_-]*)"), "i" );
1783
1784                                 var m = re.exec( t );
1785
1786                                 if ( m ) {
1787                                         // Re-organize the first match
1788                                         if ( !i )
1789                                                 m = ["",m[1], m[3], m[2], m[5]];
1790
1791                                         // Remove what we just matched
1792                                         t = t.replace( re, "" );
1793
1794                                         break;
1795                                 }
1796                         }
1797
1798                         // :not() is a special case that can be optimized by
1799                         // keeping it out of the expression list
1800                         if ( m[1] == ":" && m[2] == "not" )
1801                                 r = jQuery.filter(m[3], r, true).r;
1802
1803                         // Handle classes as a special case (this will help to
1804                         // improve the speed, as the regexp will only be compiled once)
1805                         else if ( m[1] == "." ) {
1806
1807                                 var re = new RegExp("(^|\\s)" + m[2] + "(\\s|$)");
1808                                 r = jQuery.grep( r, function(e){
1809                                         return re.test(e.className || '');
1810                                 }, not);
1811
1812                         // Otherwise, find the expression to execute
1813                         } else {
1814                                 var f = jQuery.expr[m[1]];
1815                                 if ( typeof f != "string" )
1816                                         f = jQuery.expr[m[1]][m[2]];
1817
1818                                 // Build a custom macro to enclose it
1819                                 eval("f = function(a,i){" +
1820                                         ( m[1] == "@" ? "z=jQuery.attr(a,m[3]);" : "" ) +
1821                                         "return " + f + "}");
1822
1823                                 // Execute it against the current filter
1824                                 r = jQuery.grep( r, f, not );
1825                         }
1826                 }
1827
1828                 // Return an array of filtered elements (r)
1829                 // and the modified expression string (t)
1830                 return { r: r, t: t };
1831         },
1832
1833         /**
1834          * Remove the whitespace from the beginning and end of a string.
1835          *
1836          * @example $.trim("  hello, how are you?  ");
1837          * @result "hello, how are you?"
1838          *
1839          * @name $.trim
1840          * @type String
1841          * @param String str The string to trim.
1842          * @cat Javascript
1843          */
1844         trim: function(t){
1845                 return t.replace(/^\s+|\s+$/g, "");
1846         },
1847
1848         /**
1849          * All ancestors of a given element.
1850          *
1851          * @private
1852          * @name $.parents
1853          * @type Array<Element>
1854          * @param Element elem The element to find the ancestors of.
1855          * @cat DOM/Traversing
1856          */
1857         parents: function( elem ){
1858                 var matched = [];
1859                 var cur = elem.parentNode;
1860                 while ( cur && cur != document ) {
1861                         matched.push( cur );
1862                         cur = cur.parentNode;
1863                 }
1864                 return matched;
1865         },
1866
1867         makeArray: function( a ) {
1868                 var r = [];
1869
1870                 if ( a.constructor != Array ) {
1871                         for ( var i = 0; i < a.length; i++ )
1872                                 r.push( a[i] );
1873                 } else
1874                         r = a.slice( 0 );
1875
1876                 return r;
1877         },
1878
1879         inArray: function( b, a ) {
1880                 for ( var i = 0; i < a.length; i++ )
1881                         if ( a[i] == b )
1882                                 return i;
1883                 return -1;
1884         },
1885
1886         /**
1887          * Merge two arrays together, removing all duplicates. The final order
1888          * or the new array is: All the results from the first array, followed
1889          * by the unique results from the second array.
1890          *
1891          * @example $.merge( [0,1,2], [2,3,4] )
1892          * @result [0,1,2,3,4]
1893          *
1894          * @example $.merge( [3,2,1], [4,3,2] )
1895          * @result [3,2,1,4]
1896          *
1897          * @name $.merge
1898          * @type Array
1899          * @param Array first The first array to merge.
1900          * @param Array second The second array to merge.
1901          * @cat Javascript
1902          */
1903         merge: function(first, second) {
1904                 var r = [].slice.call( first, 0 );
1905
1906                 // Now check for duplicates between the two arrays
1907                 // and only add the unique items
1908                 for ( var i = 0; i < second.length; i++ ) {
1909                         // Check for duplicates
1910                         if ( jQuery.inArray( second[i], r ) == -1 )
1911                                 // The item is unique, add it
1912                                 first.push( second[i] );
1913                 }
1914
1915                 return first;
1916         },
1917
1918         /**
1919          * Filter items out of an array, by using a filter function.
1920          * The specified function will be passed two arguments: The
1921          * current array item and the index of the item in the array. The
1922          * function should return 'true' if you wish to keep the item in
1923          * the array, false if it should be removed.
1924          *
1925          * @example $.grep( [0,1,2], function(i){
1926          *   return i > 0;
1927          * });
1928          * @result [1, 2]
1929          *
1930          * @name $.grep
1931          * @type Array
1932          * @param Array array The Array to find items in.
1933          * @param Function fn The function to process each item against.
1934          * @param Boolean inv Invert the selection - select the opposite of the function.
1935          * @cat Javascript
1936          */
1937         grep: function(elems, fn, inv) {
1938                 // If a string is passed in for the function, make a function
1939                 // for it (a handy shortcut)
1940                 if ( typeof fn == "string" )
1941                         fn = new Function("a","i","return " + fn);
1942
1943                 var result = [];
1944
1945                 // Go through the array, only saving the items
1946                 // that pass the validator function
1947                 for ( var i = 0; i < elems.length; i++ )
1948                         if ( !inv && fn(elems[i],i) || inv && !fn(elems[i],i) )
1949                                 result.push( elems[i] );
1950
1951                 return result;
1952         },
1953
1954         /**
1955          * Translate all items in an array to another array of items. 
1956          * The translation function that is provided to this method is 
1957          * called for each item in the array and is passed one argument: 
1958          * The item to be translated. The function can then return:
1959          * The translated value, 'null' (to remove the item), or 
1960          * an array of values - which will be flattened into the full array.
1961          *
1962          * @example $.map( [0,1,2], function(i){
1963          *   return i + 4;
1964          * });
1965          * @result [4, 5, 6]
1966          *
1967          * @example $.map( [0,1,2], function(i){
1968          *   return i > 0 ? i + 1 : null;
1969          * });
1970          * @result [2, 3]
1971          * 
1972          * @example $.map( [0,1,2], function(i){
1973          *   return [ i, i + 1 ];
1974          * });
1975          * @result [0, 1, 1, 2, 2, 3]
1976          *
1977          * @name $.map
1978          * @type Array
1979          * @param Array array The Array to translate.
1980          * @param Function fn The function to process each item against.
1981          * @cat Javascript
1982          */
1983         map: function(elems, fn) {
1984                 // If a string is passed in for the function, make a function
1985                 // for it (a handy shortcut)
1986                 if ( typeof fn == "string" )
1987                         fn = new Function("a","return " + fn);
1988
1989                 var result = [], r = [];
1990
1991                 // Go through the array, translating each of the items to their
1992                 // new value (or values).
1993                 for ( var i = 0; i < elems.length; i++ ) {
1994                         var val = fn(elems[i],i);
1995
1996                         if ( val !== null && val != undefined ) {
1997                                 if ( val.constructor != Array ) val = [val];
1998                                 result = result.concat( val );
1999                         }
2000                 }
2001
2002                 var r = [ result[0] ];
2003
2004                 check: for ( var i = 1; i < result.length; i++ ) {
2005                         for ( var j = 0; j < i; j++ )
2006                                 if ( result[i] == r[j] )
2007                                         continue check;
2008
2009                         r.push( result[i] );
2010                 }
2011
2012                 return r;
2013         },
2014
2015         /*
2016          * A number of helper functions used for managing events.
2017          * Many of the ideas behind this code orignated from Dean Edwards' addEvent library.
2018          */
2019         event: {
2020
2021                 // Bind an event to an element
2022                 // Original by Dean Edwards
2023                 add: function(element, type, handler) {
2024                         // For whatever reason, IE has trouble passing the window object
2025                         // around, causing it to be cloned in the process
2026                         if ( jQuery.browser.msie && element.setInterval != undefined )
2027                                 element = window;
2028
2029                         // Make sure that the function being executed has a unique ID
2030                         if ( !handler.guid )
2031                                 handler.guid = this.guid++;
2032
2033                         // Init the element's event structure
2034                         if (!element.events)
2035                                 element.events = {};
2036
2037                         // Get the current list of functions bound to this event
2038                         var handlers = element.events[type];
2039
2040                         // If it hasn't been initialized yet
2041                         if (!handlers) {
2042                                 // Init the event handler queue
2043                                 handlers = element.events[type] = {};
2044
2045                                 // Remember an existing handler, if it's already there
2046                                 if (element["on" + type])
2047                                         handlers[0] = element["on" + type];
2048                         }
2049
2050                         // Add the function to the element's handler list
2051                         handlers[handler.guid] = handler;
2052
2053                         // And bind the global event handler to the element
2054                         element["on" + type] = this.handle;
2055
2056                         // Remember the function in a global list (for triggering)
2057                         if (!this.global[type])
2058                                 this.global[type] = [];
2059                         this.global[type].push( element );
2060                 },
2061
2062                 guid: 1,
2063                 global: {},
2064
2065                 // Detach an event or set of events from an element
2066                 remove: function(element, type, handler) {
2067                         if (element.events)
2068                                 if (type && element.events[type])
2069                                         if ( handler )
2070                                                 delete element.events[type][handler.guid];
2071                                         else
2072                                                 for ( var i in element.events[type] )
2073                                                         delete element.events[type][i];
2074                                 else
2075                                         for ( var j in element.events )
2076                                                 this.remove( element, j );
2077                 },
2078
2079                 trigger: function(type,data,element) {
2080                         // Clone the incoming data, if any
2081                         data = jQuery.makeArray(data || []);
2082
2083                         // Handle a global trigger
2084                         if ( !element ) {
2085                                 var g = this.global[type];
2086                                 if ( g )
2087                                         for ( var i = 0; i < g.length; i++ )
2088                                                 this.trigger( type, data, g[i] );
2089
2090                         // Handle triggering a single element
2091                         } else if ( element["on" + type] ) {
2092                                 // Pass along a fake event
2093                                 data.unshift( this.fix({ type: type, target: element }) );
2094
2095                                 // Trigger the event
2096                                 element["on" + type].apply( element, data );
2097                         }
2098                 },
2099
2100                 handle: function(event) {
2101                         if ( typeof jQuery == "undefined" ) return false;
2102
2103                         event = jQuery.event.fix( event || window.event || {} ); // Empty object is for triggered events with no data
2104
2105                         var returnValue = true;
2106
2107                         var c = this.events[event.type];
2108
2109                         var args = [].slice.call( arguments, 1 );
2110                         args.unshift( event );
2111
2112                         for ( var j in c ) {
2113                                 if ( c[j].apply( this, args ) === false ) {
2114                                         event.preventDefault();
2115                                         event.stopPropagation();
2116                                         returnValue = false;
2117                                 }
2118                         }
2119
2120                         // Clean up added properties in IE to prevent memory leak
2121                         if (jQuery.browser.msie) event.target = event.preventDefault = event.stopPropagation = null;
2122
2123                         return returnValue;
2124                 },
2125
2126                 fix: function(event) {
2127                         // Fix target property, if necessary
2128                         if ( !event.target && event.srcElement )
2129                                 event.target = event.srcElement;
2130
2131                         // Calculate pageX/Y if missing and clientX/Y available
2132                         if ( typeof event.pageX == "undefined" && typeof event.clientX != "undefined" ) {
2133                                 var e = document.documentElement, b = document.body;
2134                                 event.pageX = event.clientX + (e.scrollLeft || b.scrollLeft);
2135                                 event.pageY = event.clientY + (e.scrollTop || b.scrollTop);
2136                         }
2137                                         
2138                         // Check safari and if target is a textnode
2139                         if ( jQuery.browser.safari && event.target.nodeType == 3 ) {
2140                                 // target is readonly, clone the event object
2141                                 event = jQuery.extend({}, event);
2142                                 // get parentnode from textnode
2143                                 event.target = event.target.parentNode;
2144                         }
2145                         
2146                         // fix preventDefault and stopPropagation
2147                         if (!event.preventDefault) {
2148                                 event.preventDefault = function() {
2149                                         this.returnValue = false;
2150                                 };
2151                         }
2152                                 
2153                         if (!event.stopPropagation) {
2154                                 event.stopPropagation = function() {
2155                                         this.cancelBubble = true;
2156                                 };
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();