Updated the build script to generate the docs too.
[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 != undefined ?
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.filter, function(i,n){
764                         jQuery.fn[ n ] = function(num,fn) {
765                                 return this.filter( ":" + n + "(" + num + ")", fn );
766                         };
767                 });
768                 
769                 jQuery.each( jQuery.macros.attr, function(i,n){
770                         n = n || i;
771                         jQuery.fn[ i ] = function(h) {
772                                 return h == undefined ?
773                                         this.length ? this[0][n] : null :
774                                         this.attr( n, h );
775                         };
776                 });
777         
778                 jQuery.each( jQuery.macros.css, function(i,n){
779                         jQuery.fn[ i ] = function(h) {
780                                 return h == undefined ?
781                                         ( this.length ? jQuery.css( this[0], n ) : null ) :
782                                         this.css( n, h );
783                         };
784                 });
785         
786         },
787         
788         /**
789          * A generic iterator function, which can be used to seemlessly
790          * iterate over both objects and arrays.
791          *
792          * @name $.each
793          * @param Object obj The object, or array, to iterate over.
794          * @param Object fn The function that will be executed on every object.
795          * @type Object
796          */
797         each: function( obj, fn, args ) {
798                 if ( obj.length == undefined )
799                         for ( var i in obj )
800                                 fn.apply( obj[i], args || [i, obj[i]] );
801                 else
802                         for ( var i = 0; i < obj.length; i++ )
803                                 fn.apply( obj[i], args || [i, obj[i]] );
804                 return obj;
805         },
806         
807         className: {
808                 add: function(o,c){
809                         if (jQuery.className.has(o,c)) return;
810                         o.className += ( o.className ? " " : "" ) + c;
811                 },
812                 remove: function(o,c){
813                         o.className = !c ? "" :
814                                 o.className.replace(
815                                         new RegExp("(^|\\s*\\b[^-])"+c+"($|\\b(?=[^-]))", "g"), "");
816                 },
817                 has: function(e,a) {
818                         if ( e.className )
819                                 e = e.className;
820                         return new RegExp("(^|\\s)" + a + "(\\s|$)").test(e);
821                 }
822         },
823         
824         /**
825          * Swap in/out style options.
826          * @private
827          */
828         swap: function(e,o,f) {
829                 for ( var i in o ) {
830                         e.style["old"+i] = e.style[i];
831                         e.style[i] = o[i];
832                 }
833                 f.apply( e, [] );
834                 for ( var i in o )
835                         e.style[i] = e.style["old"+i];
836         },
837         
838         css: function(e,p) {
839                 if ( p == "height" || p == "width" ) {
840                         var old = {}, oHeight, oWidth, d = ["Top","Bottom","Right","Left"];
841         
842                         for ( var i in d ) {
843                                 old["padding" + d[i]] = 0;
844                                 old["border" + d[i] + "Width"] = 0;
845                         }
846         
847                         jQuery.swap( e, old, function() {
848                                 if (jQuery.css(e,"display") != "none") {
849                                         oHeight = e.offsetHeight;
850                                         oWidth = e.offsetWidth;
851                                 } else
852                                         jQuery.swap( e, { visibility: "hidden", position: "absolute", display: "" },
853                                                 function(){
854                                                         oHeight = e.clientHeight;
855                                                         oWidth = e.clientWidth;
856                                                 });
857                         });
858         
859                         return p == "height" ? oHeight : oWidth;
860                 } else if ( p == "opacity" && jQuery.browser.msie )
861                         return parseFloat(  jQuery.curCSS(e,"filter").replace(/[^0-9.]/,"") ) || 1;
862
863                 return jQuery.curCSS( e, p );
864         },
865
866         curCSS: function(e,p,force) {
867                 var r;
868         
869                 if (!force && e.style[p])
870                         r = e.style[p];
871                 else if (e.currentStyle) {
872                         p = p.replace(/\-(\w)/g,function(m,c){return c.toUpperCase()}); 
873                         r = e.currentStyle[p];
874                 } else if (document.defaultView && document.defaultView.getComputedStyle) {
875                         p = p.replace(/([A-Z])/g,"-$1").toLowerCase();
876                         var s = document.defaultView.getComputedStyle(e,"");
877                         r = s ? s.getPropertyValue(p) : null;
878                 }
879                 
880                 return r;
881         },
882         
883         clean: function(a) {
884                 var r = [];
885                 for ( var i = 0; i < a.length; i++ ) {
886                         if ( a[i].constructor == String ) {
887         
888                                 if ( !a[i].indexOf("<tr") ) {
889                                         var tr = true;
890                                         a[i] = "<table>" + a[i] + "</table>";
891                                 } else if ( !a[i].indexOf("<td") || !a[i].indexOf("<th") ) {
892                                         var td = true;
893                                         a[i] = "<table><tbody><tr>" + a[i] + "</tr></tbody></table>";
894                                 }
895         
896                                 var div = document.createElement("div");
897                                 div.innerHTML = a[i];
898         
899                                 if ( tr || td ) {
900                                         div = div.firstChild.firstChild;
901                                         if ( td ) div = div.firstChild;
902                                 }
903         
904                                 for ( var j = 0; j < div.childNodes.length; j++ )
905                                         r.push( div.childNodes[j] );
906                         } else if ( a[i].jquery || a[i].length && !a[i].nodeType )
907                                 for ( var k = 0; k < a[i].length; k++ )
908                                         r.push( a[i][k] );
909                         else if ( a[i] !== null )
910                                 r.push( a[i].nodeType ? a[i] : document.createTextNode(a[i].toString()) );
911                 }
912                 return r;
913         },
914         
915         expr: {
916                 "": "m[2]== '*'||a.nodeName.toUpperCase()==m[2].toUpperCase()",
917                 "#": "a.getAttribute('id')&&a.getAttribute('id')==m[2]",
918                 ":": {
919                         // Position Checks
920                         lt: "i<m[3]-0",
921                         gt: "i>m[3]-0",
922                         nth: "m[3]-0==i",
923                         eq: "m[3]-0==i",
924                         first: "i==0",
925                         last: "i==r.length-1",
926                         even: "i%2==0",
927                         odd: "i%2",
928                         
929                         // Child Checks
930                         "first-child": "jQuery.sibling(a,0).cur",
931                         "last-child": "jQuery.sibling(a,0).last",
932                         "only-child": "jQuery.sibling(a).length==1",
933                         
934                         // Parent Checks
935                         parent: "a.childNodes.length",
936                         empty: "!a.childNodes.length",
937                         
938                         // Text Check
939                         contains: "(a.innerText||a.innerHTML).indexOf(m[3])>=0",
940                         
941                         // Visibility
942                         visible: "a.type!='hidden'&&jQuery.css(a,'display')!='none'&&jQuery.css(a,'visibility')!='hidden'",
943                         hidden: "a.type=='hidden'||jQuery.css(a,'display')=='none'||jQuery.css(a,'visibility')=='hidden'",
944                         
945                         // Form elements
946                         enabled: "!a.disabled",
947                         disabled: "a.disabled",
948                         checked: "a.checked"
949                 },
950                 ".": "jQuery.className.has(a,m[2])",
951                 "@": {
952                         "=": "z==m[4]",
953                         "!=": "z!=m[4]",
954                         "^=": "!z.indexOf(m[4])",
955                         "$=": "z.substr(z.length - m[4].length,m[4].length)==m[4]",
956                         "*=": "z.indexOf(m[4])>=0",
957                         "": "z"
958                 },
959                 "[": "jQuery.find(m[2],a).length"
960         },
961         
962         token: [
963                 "\\.\\.|/\\.\\.", "a.parentNode",
964                 ">|/", "jQuery.sibling(a.firstChild)",
965                 "\\+", "jQuery.sibling(a).next",
966                 "~", function(a){
967                         var r = [];
968                         var s = jQuery.sibling(a);
969                         if ( s.n > 0 )
970                                 for ( var i = s.n; i < s.length; i++ )
971                                         r.push( s[i] );
972                         return r;
973                 }
974         ],
975         
976         find: function( t, context ) {
977                 // Make sure that the context is a DOM Element
978                 if ( context && context.nodeType == undefined )
979                         context = null;
980         
981                 // Set the correct context (if none is provided)
982                 context = context || jQuery.context || document;
983         
984                 if ( t.constructor != String ) return [t];
985         
986                 if ( !t.indexOf("//") ) {
987                         context = context.documentElement;
988                         t = t.substr(2,t.length);
989                 } else if ( !t.indexOf("/") ) {
990                         context = context.documentElement;
991                         t = t.substr(1,t.length);
992                         // FIX Assume the root element is right :(
993                         if ( t.indexOf("/") >= 1 )
994                                 t = t.substr(t.indexOf("/"),t.length);
995                 }
996         
997                 var ret = [context];
998                 var done = [];
999                 var last = null;
1000         
1001                 while ( t.length > 0 && last != t ) {
1002                         var r = [];
1003                         last = t;
1004         
1005                         t = jQuery.trim(t).replace( /^\/\//i, "" );
1006                         
1007                         var foundToken = false;
1008                         
1009                         for ( var i = 0; i < jQuery.token.length; i += 2 ) {
1010                                 var re = new RegExp("^(" + jQuery.token[i] + ")");
1011                                 var m = re.exec(t);
1012                                 
1013                                 if ( m ) {
1014                                         r = ret = jQuery.map( ret, jQuery.token[i+1] );
1015                                         t = jQuery.trim( t.replace( re, "" ) );
1016                                         foundToken = true;
1017                                 }
1018                         }
1019                         
1020                         if ( !foundToken ) {
1021                                 if ( !t.indexOf(",") || !t.indexOf("|") ) {
1022                                         if ( ret[0] == context ) ret.shift();
1023                                         done = jQuery.merge( done, ret );
1024                                         r = ret = [context];
1025                                         t = " " + t.substr(1,t.length);
1026                                 } else {
1027                                         var re2 = /^([#.]?)([a-z0-9\\*_-]*)/i;
1028                                         var m = re2.exec(t);
1029                 
1030                                         if ( m[1] == "#" ) {
1031                                                 // Ummm, should make this work in all XML docs
1032                                                 var oid = document.getElementById(m[2]);
1033                                                 r = ret = oid ? [oid] : [];
1034                                                 t = t.replace( re2, "" );
1035                                         } else {
1036                                                 if ( !m[2] || m[1] == "." ) m[2] = "*";
1037                 
1038                                                 for ( var i = 0; i < ret.length; i++ )
1039                                                         r = jQuery.merge( r,
1040                                                                 m[2] == "*" ?
1041                                                                         jQuery.getAll(ret[i]) :
1042                                                                         ret[i].getElementsByTagName(m[2])
1043                                                         );
1044                                         }
1045                                 }
1046                         }
1047         
1048                         if ( t ) {
1049                                 var val = jQuery.filter(t,r);
1050                                 ret = r = val.r;
1051                                 t = jQuery.trim(val.t);
1052                         }
1053                 }
1054         
1055                 if ( ret && ret[0] == context ) ret.shift();
1056                 done = jQuery.merge( done, ret );
1057         
1058                 return done;
1059         },
1060         
1061         getAll: function(o,r) {
1062                 r = r || [];
1063                 var s = o.childNodes;
1064                 for ( var i = 0; i < s.length; i++ )
1065                         if ( s[i].nodeType == 1 ) {
1066                                 r.push( s[i] );
1067                                 jQuery.getAll( s[i], r );
1068                         }
1069                 return r;
1070         },
1071         
1072         attr: function(o,a,v){
1073                 if ( a && a.constructor == String ) {
1074                         var fix = {
1075                                 "for": "htmlFor",
1076                                 "class": "className",
1077                                 "float": "cssFloat"
1078                         };
1079                         
1080                         a = (fix[a] && fix[a].replace && fix[a] || a)
1081                                 .replace(/-([a-z])/ig,function(z,b){
1082                                         return b.toUpperCase();
1083                                 });
1084                         
1085                         if ( v != undefined ) {
1086                                 o[a] = v;
1087                                 if ( o.setAttribute && a != "disabled" )
1088                                         o.setAttribute(a,v);
1089                         }
1090                         
1091                         return o[a] || o.getAttribute && o.getAttribute(a) || "";
1092                 } else
1093                         return "";
1094         },
1095
1096         // The regular expressions that power the parsing engine
1097         parse: [
1098                 // Match: [@value='test'], [@foo]
1099                 [ "\\[ *(@)S *([!*$^=]*) *Q\\]", 1 ],
1100
1101                 // Match: [div], [div p]
1102                 [ "(\\[)Q\\]", 0 ],
1103
1104                 // Match: :contains('foo')
1105                 [ "(:)S\\(Q\\)", 0 ],
1106
1107                 // Match: :even, :last-chlid
1108                 [ "([:.#]*)S", 0 ]
1109         ],
1110         
1111         filter: function(t,r,not) {
1112                 // Figure out if we're doing regular, or inverse, filtering
1113                 var g = not !== false ? jQuery.grep :
1114                         function(a,f) {return jQuery.grep(a,f,true);};
1115                 
1116                 while ( t && /^[a-z[({<*:.#]/i.test(t) ) {
1117
1118                         var p = jQuery.parse;
1119
1120                         for ( var i = 0; i < p.length; i++ ) {
1121                                 var re = new RegExp( "^" + p[i][0]
1122
1123                                         // Look for a string-like sequence
1124                                         .replace( 'S', "([a-z*_-][a-z0-9_-]*)" )
1125
1126                                         // Look for something (optionally) enclosed with quotes
1127                                         .replace( 'Q', " *'?\"?([^'\"]*)'?\"? *" ), "i" );
1128
1129                                 var m = re.exec( t );
1130
1131                                 if ( m ) {
1132                                         // Re-organize the match
1133                                         if ( p[i][1] )
1134                                                 m = ["", m[1], m[3], m[2], m[4]];
1135
1136                                         // Remove what we just matched
1137                                         t = t.replace( re, "" );
1138
1139                                         break;
1140                                 }
1141                         }
1142         
1143                         // :not() is a special case that can be optomized by
1144                         // keeping it out of the expression list
1145                         if ( m[1] == ":" && m[2] == "not" )
1146                                 r = jQuery.filter(m[3],r,false).r;
1147                         
1148                         // Otherwise, find the expression to execute
1149                         else {
1150                                 var f = jQuery.expr[m[1]];
1151                                 if ( f.constructor != String )
1152                                         f = jQuery.expr[m[1]][m[2]];
1153                                         
1154                                 // Build a custom macro to enclose it
1155                                 eval("f = function(a,i){" + 
1156                                         ( m[1] == "@" ? "z=jQuery.attr(a,m[3]);" : "" ) + 
1157                                         "return " + f + "}");
1158                                 
1159                                 // Execute it against the current filter
1160                                 r = g( r, f );
1161                         }
1162                 }
1163         
1164                 // Return an array of filtered elements (r)
1165                 // and the modified expression string (t)
1166                 return { r: r, t: t };
1167         },
1168         
1169         /**
1170          * Remove the whitespace from the beginning and end of a string.
1171          *
1172          * @private
1173          * @name $.trim
1174          * @type String
1175          * @param String str The string to trim.
1176          */
1177         trim: function(t){
1178                 return t.replace(/^\s+|\s+$/g, "");
1179         },
1180         
1181         /**
1182          * All ancestors of a given element.
1183          *
1184          * @private
1185          * @name $.parents
1186          * @type Array<Element>
1187          * @param Element elem The element to find the ancestors of.
1188          */
1189         parents: function(a){
1190                 var b = [];
1191                 var c = a.parentNode;
1192                 while ( c && c != document ) {
1193                         b.push( c );
1194                         c = c.parentNode;
1195                 }
1196                 return b;
1197         },
1198         
1199         /**
1200          * All elements on a specified axis.
1201          *
1202          * @private
1203          * @name $.sibling
1204          * @type Array
1205          * @param Element elem The element to find all the siblings of (including itself).
1206          */
1207         sibling: function(a,n) {
1208                 var type = [];
1209                 var tmp = a.parentNode.childNodes;
1210                 for ( var i = 0; i < tmp.length; i++ ) {
1211                         if ( tmp[i].nodeType == 1 )
1212                                 type.push( tmp[i] );
1213                         if ( tmp[i] == a )
1214                                 type.n = type.length - 1;
1215                 }
1216                 type.last = type.n == type.length - 1;
1217                 type.cur =
1218                         n == "even" && type.n % 2 == 0 ||
1219                         n == "odd" && type.n % 2 ||
1220                         type[n] == a;
1221                 type.prev = type[type.n - 1];
1222                 type.next = type[type.n + 1];
1223                 return type;
1224         },
1225         
1226         /**
1227          * Merge two arrays together, removing all duplicates.
1228          *
1229          * @private
1230          * @name $.merge
1231          * @type Array
1232          * @param Array a The first array to merge.
1233          * @param Array b The second array to merge.
1234          */
1235         merge: function(a,b) {
1236                 var d = [];
1237                 
1238                 // Move b over to the new array (this helps to avoid
1239                 // StaticNodeList instances)
1240                 for ( var k = 0; k < b.length; k++ )
1241                         d[k] = b[k];
1242         
1243                 // Now check for duplicates between a and b and only
1244                 // add the unique items
1245                 for ( var i = 0; i < a.length; i++ ) {
1246                         var c = true;
1247                         
1248                         // The collision-checking process
1249                         for ( var j = 0; j < b.length; j++ )
1250                                 if ( a[i] == b[j] )
1251                                         c = false;
1252                                 
1253                         // If the item is unique, add it
1254                         if ( c )
1255                                 d.push( a[i] );
1256                 }
1257         
1258                 return d;
1259         },
1260         
1261         /**
1262          * Remove items that aren't matched in an array. The function passed
1263          * in to this method will be passed two arguments: 'a' (which is the
1264          * array item) and 'i' (which is the index of the item in the array).
1265          *
1266          * @private
1267          * @name $.grep
1268          * @type Array
1269          * @param Array array The Array to find items in.
1270          * @param Function fn The function to process each item against.
1271          * @param Boolean inv Invert the selection - select the opposite of the function.
1272          */
1273         grep: function(a,f,s) {
1274                 // If a string is passed in for the function, make a function
1275                 // for it (a handy shortcut)
1276                 if ( f.constructor == String )
1277                         f = new Function("a","i","return " + f);
1278                         
1279                 var r = [];
1280                 
1281                 // Go through the array, only saving the items
1282                 // that pass the validator function
1283                 for ( var i = 0; i < a.length; i++ )
1284                         if ( !s && f(a[i],i) || s && !f(a[i],i) )
1285                                 r.push( a[i] );
1286                 
1287                 return r;
1288         },
1289         
1290         /**
1291          * Translate all items in array to another array of items. The translation function
1292          * that is provided to this method is passed one argument: 'a' (the item to be 
1293          * translated). If an array is returned, that array is mapped out and merged into
1294          * the full array. Additionally, returning 'null' or 'undefined' will delete the item
1295          * from the array. Both of these changes imply that the size of the array may not
1296          * be the same size upon completion, as it was when it started.
1297          *
1298          * @private
1299          * @name $.map
1300          * @type Array
1301          * @param Array array The Array to translate.
1302          * @param Function fn The function to process each item against.
1303          */
1304         map: function(a,f) {
1305                 // If a string is passed in for the function, make a function
1306                 // for it (a handy shortcut)
1307                 if ( f.constructor == String )
1308                         f = new Function("a","return " + f);
1309                 
1310                 var r = [];
1311                 
1312                 // Go through the array, translating each of the items to their
1313                 // new value (or values).
1314                 for ( var i = 0; i < a.length; i++ ) {
1315                         var t = f(a[i],i);
1316                         if ( t !== null && t != undefined ) {
1317                                 if ( t.constructor != Array ) t = [t];
1318                                 r = jQuery.merge( t, r );
1319                         }
1320                 }
1321                 return r;
1322         },
1323         
1324         /*
1325          * A number of helper functions used for managing events.
1326          * Many of the ideas behind this code orignated from Dean Edwards' addEvent library.
1327          */
1328         event: {
1329         
1330                 // Bind an event to an element
1331                 // Original by Dean Edwards
1332                 add: function(element, type, handler) {
1333                         // For whatever reason, IE has trouble passing the window object
1334                         // around, causing it to be cloned in the process
1335                         if ( jQuery.browser.msie && element.setInterval != undefined )
1336                                 element = window;
1337                 
1338                         // Make sure that the function being executed has a unique ID
1339                         if ( !handler.guid )
1340                                 handler.guid = this.guid++;
1341                                 
1342                         // Init the element's event structure
1343                         if (!element.events)
1344                                 element.events = {};
1345                         
1346                         // Get the current list of functions bound to this event
1347                         var handlers = element.events[type];
1348                         
1349                         // If it hasn't been initialized yet
1350                         if (!handlers) {
1351                                 // Init the event handler queue
1352                                 handlers = element.events[type] = {};
1353                                 
1354                                 // Remember an existing handler, if it's already there
1355                                 if (element["on" + type])
1356                                         handlers[0] = element["on" + type];
1357                         }
1358
1359                         // Add the function to the element's handler list
1360                         handlers[handler.guid] = handler;
1361                         
1362                         // And bind the global event handler to the element
1363                         element["on" + type] = this.handle;
1364         
1365                         // Remember the function in a global list (for triggering)
1366                         if (!this.global[type])
1367                                 this.global[type] = [];
1368                         this.global[type].push( element );
1369                 },
1370                 
1371                 guid: 1,
1372                 global: {},
1373                 
1374                 // Detach an event or set of events from an element
1375                 remove: function(element, type, handler) {
1376                         if (element.events)
1377                                 if (type && element.events[type])
1378                                         if ( handler )
1379                                                 delete element.events[type][handler.guid];
1380                                         else
1381                                                 for ( var i in element.events[type] )
1382                                                         delete element.events[type][i];
1383                                 else
1384                                         for ( var j in element.events )
1385                                                 this.remove( element, j );
1386                 },
1387                 
1388                 trigger: function(type,data,element) {
1389                         // Touch up the incoming data
1390                         data = data || [];
1391         
1392                         // Handle a global trigger
1393                         if ( !element ) {
1394                                 var g = this.global[type];
1395                                 if ( g )
1396                                         for ( var i = 0; i < g.length; i++ )
1397                                                 this.trigger( type, data, g[i] );
1398         
1399                         // Handle triggering a single element
1400                         } else if ( element["on" + type] ) {
1401                                 // Pass along a fake event
1402                                 data.unshift( this.fix({ type: type, target: element }) );
1403         
1404                                 // Trigger the event
1405                                 element["on" + type].apply( element, data );
1406                         }
1407                 },
1408                 
1409                 handle: function(event) {
1410                         if ( typeof jQuery == "undefined" ) return;
1411
1412                         event = event || jQuery.event.fix( window.event );
1413         
1414                         // If no correct event was found, fail
1415                         if ( !event ) return;
1416                 
1417                         var returnValue = true;
1418
1419                         var c = this.events[event.type];
1420                 
1421                         for ( var j in c ) {
1422                                 if ( c[j].apply( this, [event] ) === false ) {
1423                                         event.preventDefault();
1424                                         event.stopPropagation();
1425                                         returnValue = false;
1426                                 }
1427                         }
1428                         
1429                         return returnValue;
1430                 },
1431                 
1432                 fix: function(event) {
1433                         if ( event ) {
1434                                 event.preventDefault = function() {
1435                                         this.returnValue = false;
1436                                 };
1437                         
1438                                 event.stopPropagation = function() {
1439                                         this.cancelBubble = true;
1440                                 };
1441                         }
1442                         
1443                         return event;
1444                 }
1445         
1446         }
1447 });
1448
1449 new function() {
1450         var b = navigator.userAgent.toLowerCase();
1451
1452         // Figure out what browser is being used
1453         jQuery.browser = {
1454                 safari: /webkit/.test(b),
1455                 opera: /opera/.test(b),
1456                 msie: /msie/.test(b) && !/opera/.test(b),
1457                 mozilla: /mozilla/.test(b) && !/compatible/.test(b)
1458         };
1459
1460         // Check to see if the W3C box model is being used
1461         jQuery.boxModel = !jQuery.browser.msie || document.compatMode == "CSS1Compat";
1462 };
1463
1464 jQuery.macros = {
1465         to: {
1466                 /**
1467                  * Append all of the matched elements to another, specified, set of elements.
1468                  * This operation is, essentially, the reverse of doing a regular
1469                  * $(A).append(B), in that instead of appending B to A, you're appending
1470                  * A to B.
1471                  * 
1472                  * @example $("p").appendTo("#foo");
1473                  * @before <p>I would like to say: </p><div id="foo"></div>
1474                  * @result <div id="foo"><p>I would like to say: </p></div>
1475                  *
1476                  * @name appendTo
1477                  * @type jQuery
1478                  * @param String expr A jQuery expression of elements to match.
1479                  */
1480                 appendTo: "append",
1481                 
1482                 /**
1483                  * Prepend all of the matched elements to another, specified, set of elements.
1484                  * This operation is, essentially, the reverse of doing a regular
1485                  * $(A).prepend(B), in that instead of prepending B to A, you're prepending
1486                  * A to B.
1487                  * 
1488                  * @example $("p").prependTo("#foo");
1489                  * @before <p>I would like to say: </p><div id="foo"><b>Hello</b></div>
1490                  * @result <div id="foo"><p>I would like to say: </p><b>Hello</b></div>
1491                  *
1492                  * @name prependTo
1493                  * @type jQuery
1494                  * @param String expr A jQuery expression of elements to match.
1495                  */
1496                 prependTo: "prepend",
1497                 
1498                 /**
1499                  * Insert all of the matched elements before another, specified, set of elements.
1500                  * This operation is, essentially, the reverse of doing a regular
1501                  * $(A).before(B), in that instead of inserting B before A, you're inserting
1502                  * A before B.
1503                  * 
1504                  * @example $("p").insertBefore("#foo");
1505                  * @before <div id="foo">Hello</div><p>I would like to say: </p>
1506                  * @result <p>I would like to say: </p><div id="foo">Hello</div>
1507                  *
1508                  * @name insertBefore
1509                  * @type jQuery
1510                  * @param String expr A jQuery expression of elements to match.
1511                  */
1512                 insertBefore: "before",
1513                 
1514                 /**
1515                  * Insert all of the matched elements after another, specified, set of elements.
1516                  * This operation is, essentially, the reverse of doing a regular
1517                  * $(A).after(B), in that instead of inserting B after A, you're inserting
1518                  * A after B.
1519                  * 
1520                  * @example $("p").insertAfter("#foo");
1521                  * @before <p>I would like to say: </p><div id="foo">Hello</div>
1522                  * @result <div id="foo">Hello</div><p>I would like to say: </p>
1523                  *
1524                  * @name insertAfter
1525                  * @type jQuery
1526                  * @param String expr A jQuery expression of elements to match.
1527                  */
1528                 insertAfter: "after"
1529         },
1530         
1531         /**
1532          * Get the current CSS width of the first matched element.
1533          * 
1534          * @example $("p").width();
1535          * @before <p>This is just a test.</p>
1536          * @result "300px"
1537          *
1538          * @name width
1539          * @type String
1540          */
1541          
1542         /**
1543          * Set the CSS width of every matched element. Be sure to include
1544          * the "px" (or other unit of measurement) after the number that you 
1545          * specify, otherwise you might get strange results.
1546          * 
1547          * @example $("p").width("20px");
1548          * @before <p>This is just a test.</p>
1549          * @result <p style="width:20px;">This is just a test.</p>
1550          *
1551          * @name width
1552          * @type jQuery
1553          * @param String val Set the CSS property to the specified value.
1554          */
1555         
1556         /**
1557          * Get the current CSS height of the first matched element.
1558          * 
1559          * @example $("p").height();
1560          * @before <p>This is just a test.</p>
1561          * @result "14px"
1562          *
1563          * @name height
1564          * @type String
1565          */
1566          
1567         /**
1568          * Set the CSS height of every matched element. Be sure to include
1569          * the "px" (or other unit of measurement) after the number that you 
1570          * specify, otherwise you might get strange results.
1571          * 
1572          * @example $("p").height("20px");
1573          * @before <p>This is just a test.</p>
1574          * @result <p style="height:20px;">This is just a test.</p>
1575          *
1576          * @name height
1577          * @type jQuery
1578          * @param String val Set the CSS property to the specified value.
1579          */
1580          
1581         /**
1582          * Get the current CSS top of the first matched element.
1583          * 
1584          * @example $("p").top();
1585          * @before <p>This is just a test.</p>
1586          * @result "0px"
1587          *
1588          * @name top
1589          * @type String
1590          */
1591          
1592         /**
1593          * Set the CSS top of every matched element. Be sure to include
1594          * the "px" (or other unit of measurement) after the number that you 
1595          * specify, otherwise you might get strange results.
1596          * 
1597          * @example $("p").top("20px");
1598          * @before <p>This is just a test.</p>
1599          * @result <p style="top:20px;">This is just a test.</p>
1600          *
1601          * @name top
1602          * @type jQuery
1603          * @param String val Set the CSS property to the specified value.
1604          */
1605          
1606         /**
1607          * Get the current CSS left of the first matched element.
1608          * 
1609          * @example $("p").left();
1610          * @before <p>This is just a test.</p>
1611          * @result "0px"
1612          *
1613          * @name left
1614          * @type String
1615          */
1616          
1617         /**
1618          * Set the CSS left of every matched element. Be sure to include
1619          * the "px" (or other unit of measurement) after the number that you 
1620          * specify, otherwise you might get strange results.
1621          * 
1622          * @example $("p").left("20px");
1623          * @before <p>This is just a test.</p>
1624          * @result <p style="left:20px;">This is just a test.</p>
1625          *
1626          * @name left
1627          * @type jQuery
1628          * @param String val Set the CSS property to the specified value.
1629          */
1630          
1631         /**
1632          * Get the current CSS position of the first matched element.
1633          * 
1634          * @example $("p").position();
1635          * @before <p>This is just a test.</p>
1636          * @result "static"
1637          *
1638          * @name position
1639          * @type String
1640          */
1641          
1642         /**
1643          * Set the CSS position of every matched element.
1644          * 
1645          * @example $("p").position("relative");
1646          * @before <p>This is just a test.</p>
1647          * @result <p style="position:relative;">This is just a test.</p>
1648          *
1649          * @name position
1650          * @type jQuery
1651          * @param String val Set the CSS property to the specified value.
1652          */
1653          
1654         /**
1655          * Get the current CSS float of the first matched element.
1656          * 
1657          * @example $("p").float();
1658          * @before <p>This is just a test.</p>
1659          * @result "none"
1660          *
1661          * @name float
1662          * @type String
1663          */
1664          
1665         /**
1666          * Set the CSS float of every matched element.
1667          * 
1668          * @example $("p").float("left");
1669          * @before <p>This is just a test.</p>
1670          * @result <p style="float:left;">This is just a test.</p>
1671          *
1672          * @name float
1673          * @type jQuery
1674          * @param String val Set the CSS property to the specified value.
1675          */
1676          
1677         /**
1678          * Get the current CSS overflow of the first matched element.
1679          * 
1680          * @example $("p").overflow();
1681          * @before <p>This is just a test.</p>
1682          * @result "none"
1683          *
1684          * @name overflow
1685          * @type String
1686          */
1687          
1688         /**
1689          * Set the CSS overflow of every matched element.
1690          * 
1691          * @example $("p").overflow("auto");
1692          * @before <p>This is just a test.</p>
1693          * @result <p style="overflow:auto;">This is just a test.</p>
1694          *
1695          * @name overflow
1696          * @type jQuery
1697          * @param String val Set the CSS property to the specified value.
1698          */
1699          
1700         /**
1701          * Get the current CSS color of the first matched element.
1702          * 
1703          * @example $("p").color();
1704          * @before <p>This is just a test.</p>
1705          * @result "black"
1706          *
1707          * @name color
1708          * @type String
1709          */
1710          
1711         /**
1712          * Set the CSS color of every matched element.
1713          * 
1714          * @example $("p").color("blue");
1715          * @before <p>This is just a test.</p>
1716          * @result <p style="color:blue;">This is just a test.</p>
1717          *
1718          * @name color
1719          * @type jQuery
1720          * @param String val Set the CSS property to the specified value.
1721          */
1722          
1723         /**
1724          * Get the current CSS background of the first matched element.
1725          * 
1726          * @example $("p").background();
1727          * @before <p>This is just a test.</p>
1728          * @result ""
1729          *
1730          * @name background
1731          * @type String
1732          */
1733          
1734         /**
1735          * Set the CSS background of every matched element.
1736          * 
1737          * @example $("p").background("blue");
1738          * @before <p>This is just a test.</p>
1739          * @result <p style="background:blue;">This is just a test.</p>
1740          *
1741          * @name background
1742          * @type jQuery
1743          * @param String val Set the CSS property to the specified value.
1744          */
1745         
1746         css: "width,height,top,left,position,float,overflow,color,background".split(","),
1747
1748         filter: [ "eq", "lt", "gt", "contains" ],
1749
1750         attr: {
1751                 /**
1752                  * Get the current value of the first matched element.
1753                  * 
1754                  * @example $("input").val();
1755                  * @before <input type="text" value="some text"/>
1756                  * @result "some text"
1757                  *
1758                  * @name val
1759                  * @type String
1760                  */
1761                  
1762                 /**
1763                  * Set the value of every matched element.
1764                  * 
1765                  * @example $("input").value("test");
1766                  * @before <input type="text" value="some text"/>
1767                  * @result <input type="text" value="test"/>
1768                  *
1769                  * @name val
1770                  * @type jQuery
1771                  * @param String val Set the property to the specified value.
1772                  */
1773                 val: "value",
1774                 
1775                 /**
1776                  * Get the html contents of the first matched element.
1777                  * 
1778                  * @example $("div").html();
1779                  * @before <div><input/></div>
1780                  * @result <input/>
1781                  *
1782                  * @name html
1783                  * @type String
1784                  */
1785                  
1786                 /**
1787                  * Set the html contents of every matched element.
1788                  * 
1789                  * @example $("div").html("<b>new stuff</b>");
1790                  * @before <div><input/></div>
1791                  * @result <div><b>new stuff</b</div>
1792                  *
1793                  * @name html
1794                  * @type jQuery
1795                  * @param String val Set the html contents to the specified value.
1796                  */
1797                 html: "innerHTML",
1798                 
1799                 /**
1800                  * Get the current id of the first matched element.
1801                  * 
1802                  * @example $("input").id();
1803                  * @before <input type="text" id="test" value="some text"/>
1804                  * @result "test"
1805                  *
1806                  * @name id
1807                  * @type String
1808                  */
1809                  
1810                 /**
1811                  * Set the id of every matched element.
1812                  * 
1813                  * @example $("input").id("newid");
1814                  * @before <input type="text" id="test" value="some text"/>
1815                  * @result <input type="text" id="newid" value="some text"/>
1816                  *
1817                  * @name id
1818                  * @type jQuery
1819                  * @param String val Set the property to the specified value.
1820                  */
1821                 id: null,
1822                 
1823                 /**
1824                  * Get the current title of the first matched element.
1825                  * 
1826                  * @example $("img").title();
1827                  * @before <img src="test.jpg" title="my image"/>
1828                  * @result "my image"
1829                  *
1830                  * @name title
1831                  * @type String
1832                  */
1833                  
1834                 /**
1835                  * Set the title of every matched element.
1836                  * 
1837                  * @example $("img").title("new title");
1838                  * @before <img src="test.jpg" title="my image"/>
1839                  * @result <img src="test.jpg" title="new image"/>
1840                  *
1841                  * @name title
1842                  * @type jQuery
1843                  * @param String val Set the property to the specified value.
1844                  */
1845                 title: null,
1846                 
1847                 /**
1848                  * Get the current name of the first matched element.
1849                  * 
1850                  * @example $("input").name();
1851                  * @before <input type="text" name="username"/>
1852                  * @result "username"
1853                  *
1854                  * @name name
1855                  * @type String
1856                  */
1857                  
1858                 /**
1859                  * Set the name of every matched element.
1860                  * 
1861                  * @example $("input").name("user");
1862                  * @before <input type="text" name="username"/>
1863                  * @result <input type="text" name="user"/>
1864                  *
1865                  * @name name
1866                  * @type jQuery
1867                  * @param String val Set the property to the specified value.
1868                  */
1869                 name: null,
1870                 
1871                 /**
1872                  * Get the current href of the first matched element.
1873                  * 
1874                  * @example $("a").href();
1875                  * @before <a href="test.html">my link</a>
1876                  * @result "test.html"
1877                  *
1878                  * @name href
1879                  * @type String
1880                  */
1881                  
1882                 /**
1883                  * Set the href of every matched element.
1884                  * 
1885                  * @example $("a").href("test2.html");
1886                  * @before <a href="test.html">my link</a>
1887                  * @result <a href="test2.html">my link</a>
1888                  *
1889                  * @name href
1890                  * @type jQuery
1891                  * @param String val Set the property to the specified value.
1892                  */
1893                 href: null,
1894                 
1895                 /**
1896                  * Get the current src of the first matched element.
1897                  * 
1898                  * @example $("img").src();
1899                  * @before <img src="test.jpg" title="my image"/>
1900                  * @result "test.jpg"
1901                  *
1902                  * @name src
1903                  * @type String
1904                  */
1905                  
1906                 /**
1907                  * Set the src of every matched element.
1908                  * 
1909                  * @example $("img").src("test2.jpg");
1910                  * @before <img src="test.jpg" title="my image"/>
1911                  * @result <img src="test2.jpg" title="my image"/>
1912                  *
1913                  * @name src
1914                  * @type jQuery
1915                  * @param String val Set the property to the specified value.
1916                  */
1917                 src: null,
1918                 
1919                 /**
1920                  * Get the current rel of the first matched element.
1921                  * 
1922                  * @example $("a").rel();
1923                  * @before <a href="test.html" rel="nofollow">my link</a>
1924                  * @result "nofollow"
1925                  *
1926                  * @name rel
1927                  * @type String
1928                  */
1929                  
1930                 /**
1931                  * Set the rel of every matched element.
1932                  * 
1933                  * @example $("a").rel("nofollow");
1934                  * @before <a href="test.html">my link</a>
1935                  * @result <a href="test.html" rel="nofollow">my link</a>
1936                  *
1937                  * @name rel
1938                  * @type jQuery
1939                  * @param String val Set the property to the specified value.
1940                  */
1941                 rel: null
1942         },
1943         
1944         axis: {
1945                 /**
1946                  * Get a set of elements containing the unique parents of the matched
1947                  * set of elements.
1948                  *
1949                  * @example $("p").parent()
1950                  * @before <div><p>Hello</p><p>Hello</p></div>
1951                  * @result [ <div><p>Hello</p><p>Hello</p></div> ]
1952                  *
1953                  * @name parent
1954                  * @type jQuery
1955                  */
1956
1957                 /**
1958                  * Get a set of elements containing the unique parents of the matched
1959                  * set of elements, and filtered by an expression.
1960                  *
1961                  * @example $("p").parent(".selected")
1962                  * @before <div><p>Hello</p></div><div class="selected"><p>Hello Again</p></div>
1963                  * @result [ <div class="selected"><p>Hello Again</p></div> ]
1964                  *
1965                  * @name parent
1966                  * @type jQuery
1967                  * @param String expr An expression to filter the parents with
1968                  */
1969                 parent: "a.parentNode",
1970
1971                 /**
1972                  * Get a set of elements containing the unique ancestors of the matched
1973                  * set of elements.
1974                  *
1975                  * @example $("span").ancestors()
1976                  * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html>
1977                  * @result [ <body>...</body>, <div>...</div>, <p><span>Hello</span></p> ] 
1978                  *
1979                  * @name ancestors
1980                  * @type jQuery
1981                  */
1982
1983                 /**
1984                  * Get a set of elements containing the unique ancestors of the matched
1985                  * set of elements, and filtered by an expression.
1986                  *
1987                  * @example $("span").ancestors("p")
1988                  * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html>
1989                  * @result [ <p><span>Hello</span></p> ] 
1990                  *
1991                  * @name ancestors
1992                  * @type jQuery
1993                  * @param String expr An expression to filter the ancestors with
1994                  */
1995                 ancestors: jQuery.parents,
1996                 
1997                 /**
1998                  * Get a set of elements containing the unique ancestors of the matched
1999                  * set of elements.
2000                  *
2001                  * @example $("span").ancestors()
2002                  * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html>
2003                  * @result [ <body>...</body>, <div>...</div>, <p><span>Hello</span></p> ] 
2004                  *
2005                  * @name parents
2006                  * @type jQuery
2007                  */
2008
2009                 /**
2010                  * Get a set of elements containing the unique ancestors of the matched
2011                  * set of elements, and filtered by an expression.
2012                  *
2013                  * @example $("span").ancestors("p")
2014                  * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html>
2015                  * @result [ <p><span>Hello</span></p> ] 
2016                  *
2017                  * @name parents
2018                  * @type jQuery
2019                  * @param String expr An expression to filter the ancestors with
2020                  */
2021                 parents: jQuery.parents,
2022
2023                 /**
2024                  * Get a set of elements containing the unique next siblings of each of the 
2025                  * matched set of elements.
2026                  * 
2027                  * It only returns the very next sibling, not all next siblings.
2028                  *
2029                  * @example $("p").next()
2030                  * @before <p>Hello</p><p>Hello Again</p><div><span>And Again</span></div>
2031                  * @result [ <p>Hello Again</p>, <div><span>And Again</span></div> ]
2032                  *
2033                  * @name next
2034                  * @type jQuery
2035                  */
2036
2037                 /**
2038                  * Get a set of elements containing the unique next siblings of each of the 
2039                  * matched set of elements, and filtered by an expression.
2040                  * 
2041                  * It only returns the very next sibling, not all next siblings.
2042                  *
2043                  * @example $("p").next(".selected")
2044                  * @before <p>Hello</p><p class="selected">Hello Again</p><div><span>And Again</span></div>
2045                  * @result [ <p class="selected">Hello Again</p> ]
2046                  *
2047                  * @name next
2048                  * @type jQuery
2049                  * @param String expr An expression to filter the next Elements with
2050                  */
2051                 next: "jQuery.sibling(a).next",
2052
2053                 /**
2054                  * Get a set of elements containing the unique previous siblings of each of the 
2055                  * matched set of elements.
2056                  * 
2057                  * It only returns the immediately previous sibling, not all previous siblings.
2058                  *
2059                  * @example $("p").previous()
2060                  * @before <p>Hello</p><div><span>Hello Again</span></div><p>And Again</p>
2061                  * @result [ <div><span>Hello Again</span></div> ]
2062                  *
2063                  * @name prev
2064                  * @type jQuery
2065                  */
2066
2067                 /**
2068                  * Get a set of elements containing the unique previous siblings of each of the 
2069                  * matched set of elements, and filtered by an expression.
2070                  * 
2071                  * It only returns the immediately previous sibling, not all previous siblings.
2072                  *
2073                  * @example $("p").previous(".selected")
2074                  * @before <div><span>Hello</span></div><p class="selected">Hello Again</p><p>And Again</p>
2075                  * @result [ <div><span>Hello</span></div> ]
2076                  *
2077                  * @name prev
2078                  * @type jQuery
2079                  * @param String expr An expression to filter the previous Elements with
2080                  */
2081                 prev: "jQuery.sibling(a).prev",
2082
2083                 /**
2084                  * Get a set of elements containing all of the unique siblings of each of the 
2085                  * matched set of elements.
2086                  * 
2087                  * @example $("div").siblings()
2088                  * @before <p>Hello</p><div><span>Hello Again</span></div><p>And Again</p>
2089                  * @result [ <p>Hello</p>, <p>And Again</p> ]
2090                  *
2091                  * @name siblings
2092                  * @type jQuery
2093                  */
2094
2095                 /**
2096                  * Get a set of elements containing all of the unique siblings of each of the 
2097                  * matched set of elements, and filtered by an expression.
2098                  *
2099                  * @example $("div").siblings(".selected")
2100                  * @before <div><span>Hello</span></div><p class="selected">Hello Again</p><p>And Again</p>
2101                  * @result [ <p class="selected">Hello Again</p> ]
2102                  *
2103                  * @name siblings
2104                  * @type jQuery
2105                  * @param String expr An expression to filter the sibling Elements with
2106                  */
2107                 siblings: jQuery.sibling,
2108                 
2109                 
2110                 /**
2111                  * Get a set of elements containing all of the unique children of each of the 
2112                  * matched set of elements.
2113                  * 
2114                  * @example $("div").children()
2115                  * @before <p>Hello</p><div><span>Hello Again</span></div><p>And Again</p>
2116                  * @result [ <span>Hello Again</span> ]
2117                  *
2118                  * @name children
2119                  * @type jQuery
2120                  */
2121
2122                 /**
2123                  * Get a set of elements containing all of the unique siblings of each of the 
2124                  * matched set of elements, and filtered by an expression.
2125                  *
2126                  * @example $("div").children(".selected")
2127                  * @before <div><span>Hello</span><p class="selected">Hello Again</p><p>And Again</p></div>
2128                  * @result [ <p class="selected">Hello Again</p> ]
2129                  *
2130                  * @name children
2131                  * @type jQuery
2132                  * @param String expr An expression to filter the child Elements with
2133                  */
2134                 children: "a.childNodes"
2135         },
2136
2137         each: {
2138                 /**
2139                  * Displays each of the set of matched elements if they are hidden.
2140                  * 
2141                  * @example $("p").show()
2142                  * @before <p style="display: none">Hello</p>
2143                  * @result [ <p style="display: block">Hello</p> ]
2144                  *
2145                  * @name show
2146                  * @type jQuery
2147                  */
2148                 _show: function(){
2149                         this.style.display = this.oldblock ? this.oldblock : "";
2150                         if ( jQuery.css(this,"display") == "none" )
2151                                 this.style.display = "block";
2152                 },
2153
2154                 /**
2155                  * Hides each of the set of matched elements if they are shown.
2156                  *
2157                  * @example $("p").hide()
2158                  * @before <p>Hello</p>
2159                  * @result [ <p style="display: none">Hello</p> ]
2160                  *
2161                  * @name hide
2162                  * @type jQuery
2163                  */
2164                 _hide: function(){
2165                         this.oldblock = this.oldblock || jQuery.css(this,"display");
2166                         if ( this.oldblock == "none" )
2167                                 this.oldblock = "block";
2168                         this.style.display = "none";
2169                 },
2170                 
2171                 /**
2172                  * Toggles each of the set of matched elements. If they are shown,
2173                  * toggle makes them hidden. If they are hidden, toggle
2174                  * makes them shown.
2175                  *
2176                  * @example $("p").toggle()
2177                  * @before <p>Hello</p><p style="display: none">Hello Again</p>
2178                  * @result [ <p style="display: none">Hello</p>, <p style="display: block">Hello Again</p> ]
2179                  *
2180                  * @name toggle
2181                  * @type jQuery
2182                  */
2183                 _toggle: function(){
2184                         var d = jQuery.css(this,"display");
2185                         $(this)[ !d || d == "none" ? "show" : "hide" ]();
2186                 },
2187                 
2188                 /**
2189                  * Adds the specified class to each of the set of matched elements.
2190                  *
2191                  * @example ("p").addClass("selected")
2192                  * @before <p>Hello</p>
2193                  * @result [ <p class="selected">Hello</p> ]
2194                  * 
2195                  * @name addClass
2196                  * @type jQuery
2197                  * @param String class A CSS class to add to the elements
2198                  */
2199                 addClass: function(c){
2200                         jQuery.className.add(this,c);
2201                 },
2202                 
2203                 /**
2204                  * The opposite of addClass. Removes the specified class from the
2205                  * set of matched elements.
2206                  *
2207                  * @example ("p").removeClass("selected")
2208                  * @before <p class="selected">Hello</p>
2209                  * @result [ <p>Hello</p> ]
2210                  *
2211                  * @name removeClass
2212                  * @type jQuery
2213                  * @param String class A CSS class to remove from the elements
2214                  */
2215                 removeClass: function(c){
2216                         jQuery.className.remove(this,c);
2217                 },
2218         
2219                 /**
2220                  * Adds the specified class if it is present. Remove it if it is
2221                  * not present.
2222                  *
2223                  * @example ("p").toggleClass("selected")
2224                  * @before <p>Hello</p><p class="selected">Hello Again</p>
2225                  * @result [ <p class="selected">Hello</p>, <p>Hello Again</p> ]
2226                  *
2227                  * @name toggleClass
2228                  * @type jQuery
2229                  * @param String class A CSS class with which to toggle the elements
2230                  */
2231                 toggleClass: function( c ){
2232                         jQuery.className[ jQuery.className.has(this,c) ? "remove" : "add" ](this,c);
2233                 },
2234                 
2235                 /**
2236                  * TODO: Document
2237                  */
2238                 remove: function(a){
2239                         if ( !a || jQuery.filter( [this], a ).r )
2240                                 this.parentNode.removeChild( this );
2241                 },
2242         
2243                 /**
2244                  * Removes all child nodes from the set of matched elements.
2245                  *
2246                  * @example ("p").empty()
2247                  * @before <p>Hello, <span>Person</span> <a href="#">and person</a></p>
2248                  * @result [ <p></p> ]
2249                  *
2250                  * @name empty
2251                  * @type jQuery
2252                  */
2253                 empty: function(){
2254                         while ( this.firstChild )
2255                                 this.removeChild( this.firstChild );
2256                 },
2257                 
2258                 /**
2259                  * Binds a particular event (like click) to a each of a set of match elements.
2260                  *
2261                  * @example $("p").bind( "click", function() { alert("Hello"); } )
2262                  * @before <p>Hello</p>
2263                  * @result [ <p>Hello</p> ]
2264                  *
2265                  * Cancel a default action and prevent it from bubbling by returning false
2266                  * from your function.
2267                  *
2268                  * @example $("form").bind( "submit", function() { return false; } )
2269                  *
2270                  * Cancel a default action by using the preventDefault method.
2271                  *
2272                  * @example $("form").bind( "submit", function() { e.preventDefault(); } )
2273                  *
2274                  * Stop an event from bubbling by using the stopPropogation method.
2275                  *
2276                  * @example $("form").bind( "submit", function() { e.stopPropogation(); } )
2277                  *
2278                  * @name bind
2279                  * @type jQuery
2280                  * @param String type An event type
2281                  * @param Function fn A function to bind to the event on each of the set of matched elements
2282                  */
2283                 bind: function( type, fn ) {
2284                         if ( fn.constructor == String )
2285                                 fn = new Function("e", ( !fn.indexOf(".") ? "$(this)" : "return " ) + fn);
2286                         jQuery.event.add( this, type, fn );
2287                 },
2288                 
2289                 /**
2290                  * The opposite of bind, removes a bound event from each of the matched
2291                  * elements. You must pass the identical function that was used in the original 
2292                  * bind method.
2293                  *
2294                  * @example $("p").unbind( "click", function() { alert("Hello"); } )
2295                  * @before <p onclick="alert('Hello');">Hello</p>
2296                  * @result [ <p>Hello</p> ]
2297                  *
2298                  * @name unbind
2299                  * @type jQuery
2300                  * @param String type An event type
2301                  * @param Function fn A function to unbind from the event on each of the set of matched elements
2302                  */
2303                  
2304                 /**
2305                  * Removes all bound events of a particular type from each of the matched
2306                  * elements.
2307                  *
2308                  * @example $("p").unbind( "click" )
2309                  * @before <p onclick="alert('Hello');">Hello</p>
2310                  * @result [ <p>Hello</p> ]
2311                  *
2312                  * @name unbind
2313                  * @type jQuery
2314                  * @param String type An event type
2315                  */
2316                  
2317                 /**
2318                  * Removes all bound events from each of the matched elements.
2319                  *
2320                  * @example $("p").unbind()
2321                  * @before <p onclick="alert('Hello');">Hello</p>
2322                  * @result [ <p>Hello</p> ]
2323                  *
2324                  * @name unbind
2325                  * @type jQuery
2326                  */
2327                 unbind: function( type, fn ) {
2328                         jQuery.event.remove( this, type, fn );
2329                 },
2330                 
2331                 /**
2332                  * Trigger a type of event on every matched element.
2333                  *
2334                  * @example $("p").trigger("click")
2335                  * @before <p click="alert('hello')">Hello</p>
2336                  * @result alert('hello')
2337                  *
2338                  * @name trigger
2339                  * @type jQuery
2340                  * @param String type An event type to trigger.
2341                  */
2342                 trigger: function( type, data ) {
2343                         jQuery.event.trigger( type, data, this );
2344                 }
2345         }
2346 };