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