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