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