(no commit message)
[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 (prop == "float" || prop == "cssFloat")
1466                     prop = jQuery.browser.msie ? "styleFloat" : "cssFloat";
1467
1468                 if (!force && elem.style[prop]) {
1469
1470                         ret = elem.style[prop];
1471
1472                 } else if (elem.currentStyle) {
1473
1474                         var newProp = prop.replace(/\-(\w)/g,function(m,c){return c.toUpperCase();});
1475                         ret = elem.currentStyle[prop] || elem.currentStyle[newProp];
1476
1477                 } else if (document.defaultView && document.defaultView.getComputedStyle) {
1478
1479                         prop = prop.replace(/([A-Z])/g,"-$1").toLowerCase();
1480                         var cur = document.defaultView.getComputedStyle(elem, null);
1481
1482                         if ( cur )
1483                                 ret = cur.getPropertyValue(prop);
1484                         else if ( prop == 'display' )
1485                                 ret = 'none';
1486                         else
1487                                 jQuery.swap(elem, { display: 'block' }, function() {
1488                                         ret = document.defaultView.getComputedStyle(this,null).getPropertyValue(prop);
1489                                 });
1490
1491                 }
1492
1493                 return ret;
1494         },
1495
1496         clean: function(a) {
1497                 var r = [];
1498                 for ( var i = 0; i < a.length; i++ ) {
1499                         if ( a[i].constructor == String ) {
1500                                 // trim whitespace, otherwise indexOf won't work as expected
1501                                 a[i] = jQuery.trim(a[i]);
1502                                 
1503                                 var table = "";
1504
1505                                 if ( !a[i].indexOf("<thead") || !a[i].indexOf("<tbody") ) {
1506                                         table = "thead";
1507                                         a[i] = "<table>" + a[i] + "</table>";
1508                                 } else if ( !a[i].indexOf("<tr") ) {
1509                                         table = "tr";
1510                                         a[i] = "<table>" + a[i] + "</table>";
1511                                 } else if ( !a[i].indexOf("<td") || !a[i].indexOf("<th") ) {
1512                                         table = "td";
1513                                         a[i] = "<table><tbody><tr>" + a[i] + "</tr></tbody></table>";
1514                                 }
1515
1516                                 var div = document.createElement("div");
1517                                 div.innerHTML = a[i];
1518
1519                                 if ( table ) {
1520                                         div = div.firstChild;
1521                                         if ( table != "thead" ) div = div.firstChild;
1522                                         if ( table == "td" ) div = div.firstChild;
1523                                 }
1524
1525                                 for ( var j = 0; j < div.childNodes.length; j++ )
1526                                         r.push( div.childNodes[j] );
1527                                 } else if ( a[i].jquery || a[i].length && !a[i].nodeType )
1528                                         for ( var k = 0; k < a[i].length; k++ )
1529                                                 r.push( a[i][k] );
1530                                 else if ( a[i] !== null )
1531                                         r.push( a[i].nodeType ? a[i] : document.createTextNode(a[i].toString()) );
1532                 }
1533                 return r;
1534         },
1535
1536         expr: {
1537                 "": "m[2]== '*'||a.nodeName.toUpperCase()==m[2].toUpperCase()",
1538                 "#": "a.getAttribute('id')&&a.getAttribute('id')==m[2]",
1539                 ":": {
1540                         // Position Checks
1541                         lt: "i<m[3]-0",
1542                         gt: "i>m[3]-0",
1543                         nth: "m[3]-0==i",
1544                         eq: "m[3]-0==i",
1545                         first: "i==0",
1546                         last: "i==r.length-1",
1547                         even: "i%2==0",
1548                         odd: "i%2",
1549
1550                         // Child Checks
1551                         "nth-child": "jQuery.sibling(a,m[3]).cur",
1552                         "first-child": "jQuery.sibling(a,0).cur",
1553                         "last-child": "jQuery.sibling(a,0).last",
1554                         "only-child": "jQuery.sibling(a).length==1",
1555
1556                         // Parent Checks
1557                         parent: "a.childNodes.length",
1558                         empty: "!a.childNodes.length",
1559
1560                         // Text Check
1561                         contains: "(a.innerText||a.innerHTML).indexOf(m[3])>=0",
1562
1563                         // Visibility
1564                         visible: "a.type!='hidden'&&jQuery.css(a,'display')!='none'&&jQuery.css(a,'visibility')!='hidden'",
1565                         hidden: "a.type=='hidden'||jQuery.css(a,'display')=='none'||jQuery.css(a,'visibility')=='hidden'",
1566
1567                         // Form attributes
1568                         enabled: "!a.disabled",
1569                         disabled: "a.disabled",
1570                         checked: "a.checked",
1571                         selected: "a.selected || jQuery.attr(a, 'selected')",
1572
1573                         // Form elements
1574                         text: "a.type=='text'",
1575                         radio: "a.type=='radio'",
1576                         checkbox: "a.type=='checkbox'",
1577                         file: "a.type=='file'",
1578                         password: "a.type=='password'",
1579                         submit: "a.type=='submit'",
1580                         image: "a.type=='image'",
1581                         reset: "a.type=='reset'",
1582                         button: "a.type=='button'",
1583                         input: "a.nodeName.toLowerCase().match(/input|select|textarea|button/)"
1584                 },
1585                 ".": "jQuery.className.has(a,m[2])",
1586                 "@": {
1587                         "=": "z==m[4]",
1588                         "!=": "z!=m[4]",
1589                         "^=": "z && !z.indexOf(m[4])",
1590                         "$=": "z && z.substr(z.length - m[4].length,m[4].length)==m[4]",
1591                         "*=": "z && z.indexOf(m[4])>=0",
1592                         "": "z"
1593                 },
1594                 "[": "jQuery.find(m[2],a).length"
1595         },
1596
1597         token: [
1598                 "\\.\\.|/\\.\\.", "a.parentNode",
1599                 ">|/", "jQuery.sibling(a.firstChild)",
1600                 "\\+", "jQuery.sibling(a).next",
1601                 "~", function(a){
1602                         var r = [];
1603                         var s = jQuery.sibling(a);
1604                         if ( s.n > 0 )
1605                                 for ( var i = s.n; i < s.length; i++ )
1606                                         r.push( s[i] );
1607                         return r;
1608                 }
1609         ],
1610
1611         /**
1612          *
1613          * @test t( "Element Selector", "div", ["main","foo"] );
1614          * t( "Element Selector", "body", ["body"] );
1615          * t( "Element Selector", "html", ["html"] );
1616          * ok( $("*").size() >= 30, "Element Selector" );
1617          * t( "Parent Element", "div div", ["foo"] );
1618          *
1619          * t( "ID Selector", "#body", ["body"] );
1620          * t( "ID Selector w/ Element", "body#body", ["body"] );
1621          * t( "ID Selector w/ Element", "ul#first", [] );
1622          *
1623          * t( "Class Selector", ".blog", ["mark","simon"] );
1624          * t( "Class Selector", ".blog.link", ["simon"] );
1625          * t( "Class Selector w/ Element", "a.blog", ["mark","simon"] );
1626          * t( "Parent Class Selector", "p .blog", ["mark","simon"] );
1627          *
1628          * t( "Comma Support", "a.blog, div", ["mark","simon","main","foo"] );
1629          * t( "Comma Support", "a.blog , div", ["mark","simon","main","foo"] );
1630          * t( "Comma Support", "a.blog ,div", ["mark","simon","main","foo"] );
1631          * t( "Comma Support", "a.blog,div", ["mark","simon","main","foo"] );
1632          *
1633          * t( "Child", "p > a", ["simon1","google","groups","mark","yahoo","simon"] );
1634          * t( "Child", "p> a", ["simon1","google","groups","mark","yahoo","simon"] );
1635          * t( "Child", "p >a", ["simon1","google","groups","mark","yahoo","simon"] );
1636          * t( "Child", "p>a", ["simon1","google","groups","mark","yahoo","simon"] );
1637          * t( "Child w/ Class", "p > a.blog", ["mark","simon"] );
1638          * t( "All Children", "code > *", ["anchor1","anchor2"] );
1639          * t( "All Grandchildren", "p > * > *", ["anchor1","anchor2"] );
1640          * t( "Adjacent", "a + a", ["groups"] );
1641          * t( "Adjacent", "a +a", ["groups"] );
1642          * t( "Adjacent", "a+ a", ["groups"] );
1643          * t( "Adjacent", "a+a", ["groups"] );
1644          * t( "Adjacent", "p + p", ["ap","en","sap"] );
1645          * t( "Comma, Child, and Adjacent", "a + a, code > a", ["groups","anchor1","anchor2"] );
1646          * t( "First Child", "p:first-child", ["firstp","sndp"] );
1647          * t( "Attribute Exists", "a[@title]", ["google"] );
1648          * t( "Attribute Exists", "*[@title]", ["google"] );
1649          * t( "Attribute Exists", "[@title]", ["google"] );
1650          * 
1651          * t( "Non-existing part of attribute [@name*=bla]", "[@name*=bla]", [] ); 
1652          * t( "Non-existing start of attribute [@name^=bla]", "[@name^=bla]", [] ); 
1653          * t( "Non-existing end of attribute [@name$=bla]", "[@name$=bla]", [] ); 
1654          *
1655          * t( "Attribute Equals", "a[@rel='bookmark']", ["simon1"] );
1656          * t( "Attribute Equals", 'a[@rel="bookmark"]', ["simon1"] );
1657          * t( "Attribute Equals", "a[@rel=bookmark]", ["simon1"] );
1658          * t( "Multiple Attribute Equals", "input[@type='hidden'],input[@type='radio']", ["hidden1","radio1","radio2"] );
1659          * t( "Multiple Attribute Equals", "input[@type=\"hidden\"],input[@type='radio']", ["hidden1","radio1","radio2"] );
1660          * t( "Multiple Attribute Equals", "input[@type=hidden],input[@type=radio]", ["hidden1","radio1","radio2"] );
1661          *
1662          * t( "Attribute Begins With", "a[@href ^= 'http://www']", ["google","yahoo"] );
1663          * t( "Attribute Ends With", "a[@href $= 'org/']", ["mark"] );
1664          * t( "Attribute Contains", "a[@href *= 'google']", ["google","groups"] );
1665          * t( "First Child", "p:first-child", ["firstp","sndp"] );
1666          * t( "Last Child", "p:last-child", ["sap"] );
1667          * t( "Only Child", "a:only-child", ["simon1","anchor1","yahoo","anchor2"] );
1668          * t( "Empty", "ul:empty", ["firstUL"] );
1669          * t( "Enabled UI Element", "input:enabled", ["text1","radio1","radio2","check1","check2","hidden1","hidden2","name"] );
1670          * t( "Disabled UI Element", "input:disabled", ["text2"] );
1671          * t( "Checked UI Element", "input:checked", ["radio2","check1"] );
1672          * t( "Selected Option Element", "option:selected", ["option1a","option2d","option3b","option3c"] );
1673          * t( "Text Contains", "a:contains('Google')", ["google","groups"] );
1674          * t( "Text Contains", "a:contains('Google Groups')", ["groups"] );
1675          * t( "Element Preceded By", "p ~ div", ["foo"] );
1676          * t( "Not", "a.blog:not(.link)", ["mark"] );
1677          *
1678          * ok( jQuery.find("//*").length >= 30, "All Elements (//*)" );
1679          * t( "All Div Elements", "//div", ["main","foo"] );
1680          * t( "Absolute Path", "/html/body", ["body"] );
1681          * t( "Absolute Path w/ *", "/* /body", ["body"] );
1682          * t( "Long Absolute Path", "/html/body/dl/div/div/p", ["sndp","en","sap"] );
1683          * t( "Absolute and Relative Paths", "/html//div", ["main","foo"] );
1684          * t( "All Children, Explicit", "//code/*", ["anchor1","anchor2"] );
1685          * t( "All Children, Implicit", "//code/", ["anchor1","anchor2"] );
1686          * t( "Attribute Exists", "//a[@title]", ["google"] );
1687          * t( "Attribute Equals", "//a[@rel='bookmark']", ["simon1"] );
1688          * t( "Parent Axis", "//p/..", ["main","foo"] );
1689          * t( "Sibling Axis", "//p/../", ["firstp","ap","foo","first","firstUL","empty","form","sndp","en","sap"] );
1690          * t( "Sibling Axis", "//p/../*", ["firstp","ap","foo","first","firstUL","empty","form","sndp","en","sap"] );
1691          * t( "Has Children", "//p[a]", ["firstp","ap","en","sap"] );
1692          *
1693          * t( "nth Element", "p:nth(1)", ["ap"] );
1694          * t( "First Element", "p:first", ["firstp"] );
1695          * t( "Last Element", "p:last", ["first"] );
1696          * t( "Even Elements", "p:even", ["firstp","sndp","sap"] );
1697          * t( "Odd Elements", "p:odd", ["ap","en","first"] );
1698          * t( "Position Equals", "p:eq(1)", ["ap"] );
1699          * t( "Position Greater Than", "p:gt(0)", ["ap","sndp","en","sap","first"] );
1700          * t( "Position Less Than", "p:lt(3)", ["firstp","ap","sndp"] );
1701          * t( "Is A Parent", "p:parent", ["firstp","ap","sndp","en","sap","first"] );
1702          * t( "Is Visible", "input:visible", ["text1","text2","radio1","radio2","check1","check2","name"] );
1703          * t( "Is Hidden", "input:hidden", ["hidden1","hidden2"] );
1704          *
1705          * t( "Grouped Form Elements", "input[@name='foo[bar]']", ["hidden2"] );
1706          *
1707          * t( "All Children of ID", "#foo/*", ["sndp", "en", "sap"]  );
1708          * t( "All Children of ID with no children", "#firstUL/*", []  );
1709          *
1710          * t( "Form element :input", ":input", ["text1", "text2", "radio1", "radio2", "check1", "check2", "hidden1", "hidden2", "name", "button", "area1", "select1", "select2", "select3"] );
1711          * t( "Form element :radio", ":radio", ["radio1", "radio2"] );
1712          * t( "Form element :checkbox", ":checkbox", ["check1", "check2"] );
1713          * t( "Form element :text", ":text", ["text1", "text2", "hidden2", "name"] );
1714          * t( "Form element :radio:checked", ":radio:checked", ["radio2"] );
1715          * t( "Form element :checkbox:checked", ":checkbox:checked", ["check1"] );
1716          * t( "Form element :checkbox:checked, :radio:checked", ":checkbox:checked, :radio:checked", ["check1", "radio2"] );
1717          *
1718          * t( ":not() Existing attribute", "select:not([@multiple])", ["select1", "select2"]);
1719          * t( ":not() Equals attribute", "select:not([@name=select1])", ["select2", "select3"]);
1720          * t( ":not() Equals quoted attribute", "select:not([@name='select1'])", ["select2", "select3"]);
1721          *
1722          * @name $.find
1723          * @type Array<Element>
1724          * @private
1725          * @cat Core
1726          */
1727         find: function( t, context ) {
1728                 // Make sure that the context is a DOM Element
1729                 if ( context && context.nodeType == undefined )
1730                         context = null;
1731
1732                 // Set the correct context (if none is provided)
1733                 context = context || jQuery.context || document;
1734
1735                 if ( t.constructor != String ) return [t];
1736
1737                 if ( !t.indexOf("//") ) {
1738                         context = context.documentElement;
1739                         t = t.substr(2,t.length);
1740                 } else if ( !t.indexOf("/") ) {
1741                         context = context.documentElement;
1742                         t = t.substr(1,t.length);
1743                         // FIX Assume the root element is right :(
1744                         if ( t.indexOf("/") >= 1 )
1745                                 t = t.substr(t.indexOf("/"),t.length);
1746                 }
1747
1748                 var ret = [context];
1749                 var done = [];
1750                 var last = null;
1751
1752                 while ( t.length > 0 && last != t ) {
1753                         var r = [];
1754                         last = t;
1755
1756                         t = jQuery.trim(t).replace( /^\/\//i, "" );
1757
1758                         var foundToken = false;
1759
1760                         for ( var i = 0; i < jQuery.token.length; i += 2 ) {
1761                                 if ( foundToken ) continue;
1762
1763                                 var re = new RegExp("^(" + jQuery.token[i] + ")");
1764                                 var m = re.exec(t);
1765
1766                                 if ( m ) {
1767                                         r = ret = jQuery.map( ret, jQuery.token[i+1] );
1768                                         t = jQuery.trim( t.replace( re, "" ) );
1769                                         foundToken = true;
1770                                 }
1771                         }
1772
1773                         if ( !foundToken ) {
1774                                 if ( !t.indexOf(",") || !t.indexOf("|") ) {
1775                                         if ( ret[0] == context ) ret.shift();
1776                                         done = jQuery.merge( done, ret );
1777                                         r = ret = [context];
1778                                         t = " " + t.substr(1,t.length);
1779                                 } else {
1780                                         var re2 = /^([#.]?)([a-z0-9\\*_-]*)/i;
1781                                         var m = re2.exec(t);
1782
1783                                         if ( m[1] == "#" ) {
1784                                                 // Ummm, should make this work in all XML docs
1785                                                 var oid = document.getElementById(m[2]);
1786                                                 r = ret = oid ? [oid] : [];
1787                                                 t = t.replace( re2, "" );
1788                                         } else {
1789                                                 if ( !m[2] || m[1] == "." ) m[2] = "*";
1790
1791                                                 for ( var i = 0; i < ret.length; i++ )
1792                                                         r = jQuery.merge( r,
1793                                                                 m[2] == "*" ?
1794                                                                         jQuery.getAll(ret[i]) :
1795                                                                         ret[i].getElementsByTagName(m[2])
1796                                                         );
1797                                         }
1798                                 }
1799
1800                         }
1801
1802                         if ( t ) {
1803                                 var val = jQuery.filter(t,r);
1804                                 ret = r = val.r;
1805                                 t = jQuery.trim(val.t);
1806                         }
1807                 }
1808
1809                 if ( ret && ret[0] == context ) ret.shift();
1810                 done = jQuery.merge( done, ret );
1811
1812                 return done;
1813         },
1814
1815         getAll: function(o,r) {
1816                 r = r || [];
1817                 var s = o.childNodes;
1818                 for ( var i = 0; i < s.length; i++ )
1819                         if ( s[i].nodeType == 1 ) {
1820                                 r.push( s[i] );
1821                                 jQuery.getAll( s[i], r );
1822                         }
1823                 return r;
1824         },
1825
1826         attr: function(elem, name, value){
1827                 var fix = {
1828                         "for": "htmlFor",
1829                         "class": "className",
1830                         "float": jQuery.browser.msie ? "styleFloat" : "cssFloat",
1831                         cssFloat: jQuery.browser.msie ? "styleFloat" : "cssFloat",
1832                         innerHTML: "innerHTML",
1833                         className: "className",
1834                         value: "value",
1835                         disabled: "disabled",
1836                         checked: "checked"
1837                 };
1838                 
1839                 // IE actually uses filters for opacity ... elem is actually elem.style
1840                 if (name == "opacity" && jQuery.browser.msie && value != undefined) {
1841                         // IE has trouble with opacity if it does not have layout
1842                         // Would prefer to check element.hasLayout first but don't have access to the element here
1843                         elem['zoom'] = 1; 
1844                         if (value == 1) // Remove filter to avoid more IE weirdness
1845                                 return elem["filter"] = elem["filter"].replace(/alpha\([^\)]*\)/gi,"");
1846                         else
1847                                 return elem["filter"] = elem["filter"].replace(/alpha\([^\)]*\)/gi,"") + "alpha(opacity=" + value * 100 + ")";
1848                 } else if (name == "opacity" && jQuery.browser.msie) {
1849                         return elem["filter"] ? parseFloat( elem["filter"].match(/alpha\(opacity=(.*)\)/)[1] )/100 : 1;
1850                 }
1851                 
1852                 // Mozilla doesn't play well with opacity 1
1853                 if (name == "opacity" && jQuery.browser.mozilla && value == 1) value = 0.9999;
1854
1855                 if ( fix[name] ) {
1856                         if ( value != undefined ) elem[fix[name]] = value;
1857                         return elem[fix[name]];
1858                 } else if( value == undefined && jQuery.browser.msie && elem.nodeName && elem.nodeName.toUpperCase() == 'FORM' && (name == 'action' || name == 'method') ) {
1859                         return elem.getAttributeNode(name).nodeValue;
1860                 } else if ( elem.getAttribute != undefined && elem.tagName ) { // IE elem.getAttribute passes even for style
1861                         if ( value != undefined ) elem.setAttribute( name, value );
1862                         return elem.getAttribute( name, 2 );
1863                 } else {
1864                         name = name.replace(/-([a-z])/ig,function(z,b){return b.toUpperCase();});
1865                         if ( value != undefined ) elem[name] = value;
1866                         return elem[name];
1867                 }
1868         },
1869
1870         // The regular expressions that power the parsing engine
1871         parse: [
1872                 // Match: [@value='test'], [@foo]
1873                 "\\[ *(@)S *([!*$^=]*) *('?\"?)(.*?)\\4 *\\]",
1874
1875                 // Match: [div], [div p]
1876                 "(\\[)\s*(.*?)\s*\\]",
1877
1878                 // Match: :contains('foo')
1879                 "(:)S\\(\"?'?([^\\)]*?)\"?'?\\)",
1880
1881                 // Match: :even, :last-chlid
1882                 "([:.#]*)S"
1883         ],
1884
1885         filter: function(t,r,not) {
1886                 // Figure out if we're doing regular, or inverse, filtering
1887                 var g = not !== false ? jQuery.grep :
1888                         function(a,f) {return jQuery.grep(a,f,true);};
1889
1890                 while ( t && /^[a-z[({<*:.#]/i.test(t) ) {
1891
1892                         var p = jQuery.parse;
1893
1894                         for ( var i = 0; i < p.length; i++ ) {
1895                 
1896                                 // Look for, and replace, string-like sequences
1897                                 // and finally build a regexp out of it
1898                                 var re = new RegExp(
1899                                         "^" + p[i].replace("S", "([a-z*_-][a-z0-9_-]*)"), "i" );
1900
1901                                 var m = re.exec( t );
1902
1903                                 if ( m ) {
1904                                         // Re-organize the first match
1905                                         if ( !i )
1906                                                 m = ["",m[1], m[3], m[2], m[5]];
1907
1908                                         // Remove what we just matched
1909                                         t = t.replace( re, "" );
1910
1911                                         break;
1912                                 }
1913                         }
1914
1915                         // :not() is a special case that can be optimized by
1916                         // keeping it out of the expression list
1917                         if ( m[1] == ":" && m[2] == "not" )
1918                                 r = jQuery.filter(m[3],r,false).r;
1919
1920                         // Otherwise, find the expression to execute
1921                         else {
1922                                 var f = jQuery.expr[m[1]];
1923                                 if ( f.constructor != String )
1924                                         f = jQuery.expr[m[1]][m[2]];
1925
1926                                 // Build a custom macro to enclose it
1927                                 eval("f = function(a,i){" +
1928                                         ( m[1] == "@" ? "z=jQuery.attr(a,m[3]);" : "" ) +
1929                                         "return " + f + "}");
1930
1931                                 // Execute it against the current filter
1932                                 r = g( r, f );
1933                         }
1934                 }
1935
1936                 // Return an array of filtered elements (r)
1937                 // and the modified expression string (t)
1938                 return { r: r, t: t };
1939         },
1940
1941         /**
1942          * Remove the whitespace from the beginning and end of a string.
1943          *
1944          * @example $.trim("  hello, how are you?  ");
1945          * @result "hello, how are you?"
1946          *
1947          * @name $.trim
1948          * @type String
1949          * @param String str The string to trim.
1950          * @cat Javascript
1951          */
1952         trim: function(t){
1953                 return t.replace(/^\s+|\s+$/g, "");
1954         },
1955
1956         /**
1957          * All ancestors of a given element.
1958          *
1959          * @private
1960          * @name $.parents
1961          * @type Array<Element>
1962          * @param Element elem The element to find the ancestors of.
1963          * @cat DOM/Traversing
1964          */
1965         parents: function( elem ){
1966                 var matched = [];
1967                 var cur = elem.parentNode;
1968                 while ( cur && cur != document ) {
1969                         matched.push( cur );
1970                         cur = cur.parentNode;
1971                 }
1972                 return matched;
1973         },
1974
1975         /**
1976          * All elements on a specified axis.
1977          *
1978          * @private
1979          * @name $.sibling
1980          * @type Array
1981          * @param Element elem The element to find all the siblings of (including itself).
1982          * @cat DOM/Traversing
1983          */
1984         sibling: function(elem, pos, not) {
1985                 var elems = [];
1986                 
1987                 if(elem) {
1988                         var siblings = elem.parentNode.childNodes;
1989                         for ( var i = 0; i < siblings.length; i++ ) {
1990                                 if ( not === true && siblings[i] == elem ) continue;
1991         
1992                                 if ( siblings[i].nodeType == 1 )
1993                                         elems.push( siblings[i] );
1994                                 if ( siblings[i] == elem )
1995                                         elems.n = elems.length - 1;
1996                         }
1997                 }
1998
1999                 return jQuery.extend( elems, {
2000                         last: elems.n == elems.length - 1,
2001                         cur: pos == "even" && elems.n % 2 == 0 || pos == "odd" && elems.n % 2 || elems[pos] == elem,
2002                         prev: elems[elems.n - 1],
2003                         next: elems[elems.n + 1]
2004                 });
2005         },
2006
2007         /**
2008          * Merge two arrays together, removing all duplicates. The final order
2009          * or the new array is: All the results from the first array, followed
2010          * by the unique results from the second array.
2011          *
2012          * @example $.merge( [0,1,2], [2,3,4] )
2013          * @result [0,1,2,3,4]
2014          *
2015          * @example $.merge( [3,2,1], [4,3,2] )
2016          * @result [3,2,1,4]
2017          *
2018          * @name $.merge
2019          * @type Array
2020          * @param Array first The first array to merge.
2021          * @param Array second The second array to merge.
2022          * @cat Javascript
2023          */
2024         merge: function(first, second) {
2025                 var result = [];
2026
2027                 // Move b over to the new array (this helps to avoid
2028                 // StaticNodeList instances)
2029                 for ( var k = 0; k < first.length; k++ )
2030                         result[k] = first[k];
2031
2032                 // Now check for duplicates between a and b and only
2033                 // add the unique items
2034                 for ( var i = 0; i < second.length; i++ ) {
2035                         var noCollision = true;
2036
2037                         // The collision-checking process
2038                         for ( var j = 0; j < first.length; j++ )
2039                                 if ( second[i] == first[j] )
2040                                         noCollision = false;
2041
2042                         // If the item is unique, add it
2043                         if ( noCollision )
2044                                 result.push( second[i] );
2045                 }
2046
2047                 return result;
2048         },
2049
2050         /**
2051          * Filter items out of an array, by using a filter function.
2052          * The specified function will be passed two arguments: The
2053          * current array item and the index of the item in the array. The
2054          * function should return 'true' if you wish to keep the item in
2055          * the array, false if it should be removed.
2056          *
2057          * @example $.grep( [0,1,2], function(i){
2058          *   return i > 0;
2059          * });
2060          * @result [1, 2]
2061          *
2062          * @name $.grep
2063          * @type Array
2064          * @param Array array The Array to find items in.
2065          * @param Function fn The function to process each item against.
2066          * @param Boolean inv Invert the selection - select the opposite of the function.
2067          * @cat Javascript
2068          */
2069         grep: function(elems, fn, inv) {
2070                 // If a string is passed in for the function, make a function
2071                 // for it (a handy shortcut)
2072                 if ( fn.constructor == String )
2073                         fn = new Function("a","i","return " + fn);
2074
2075                 var result = [];
2076
2077                 // Go through the array, only saving the items
2078                 // that pass the validator function
2079                 for ( var i = 0; i < elems.length; i++ )
2080                         if ( !inv && fn(elems[i],i) || inv && !fn(elems[i],i) )
2081                                 result.push( elems[i] );
2082
2083                 return result;
2084         },
2085
2086         /**
2087          * Translate all items in an array to another array of items. 
2088          * The translation function that is provided to this method is 
2089          * called for each item in the array and is passed one argument: 
2090          * The item to be translated. The function can then return:
2091          * The translated value, 'null' (to remove the item), or 
2092          * an array of values - which will be flattened into the full array.
2093          *
2094          * @example $.map( [0,1,2], function(i){
2095          *   return i + 4;
2096          * });
2097          * @result [4, 5, 6]
2098          *
2099          * @example $.map( [0,1,2], function(i){
2100          *   return i > 0 ? i + 1 : null;
2101          * });
2102          * @result [2, 3]
2103          * 
2104          * @example $.map( [0,1,2], function(i){
2105          *   return [ i, i + 1 ];
2106          * });
2107          * @result [0, 1, 1, 2, 2, 3]
2108          *
2109          * @name $.map
2110          * @type Array
2111          * @param Array array The Array to translate.
2112          * @param Function fn The function to process each item against.
2113          * @cat Javascript
2114          */
2115         map: function(elems, fn) {
2116                 // If a string is passed in for the function, make a function
2117                 // for it (a handy shortcut)
2118                 if ( fn.constructor == String )
2119                         fn = new Function("a","return " + fn);
2120
2121                 var result = [];
2122
2123                 // Go through the array, translating each of the items to their
2124                 // new value (or values).
2125                 for ( var i = 0; i < elems.length; i++ ) {
2126                         var val = fn(elems[i],i);
2127
2128                         if ( val !== null && val != undefined ) {
2129                                 if ( val.constructor != Array ) val = [val];
2130                                 result = jQuery.merge( result, val );
2131                         }
2132                 }
2133
2134                 return result;
2135         },
2136
2137         /*
2138          * A number of helper functions used for managing events.
2139          * Many of the ideas behind this code orignated from Dean Edwards' addEvent library.
2140          */
2141         event: {
2142
2143                 // Bind an event to an element
2144                 // Original by Dean Edwards
2145                 add: function(element, type, handler) {
2146                         // For whatever reason, IE has trouble passing the window object
2147                         // around, causing it to be cloned in the process
2148                         if ( jQuery.browser.msie && element.setInterval != undefined )
2149                                 element = window;
2150
2151                         // Make sure that the function being executed has a unique ID
2152                         if ( !handler.guid )
2153                                 handler.guid = this.guid++;
2154
2155                         // Init the element's event structure
2156                         if (!element.events)
2157                                 element.events = {};
2158
2159                         // Get the current list of functions bound to this event
2160                         var handlers = element.events[type];
2161
2162                         // If it hasn't been initialized yet
2163                         if (!handlers) {
2164                                 // Init the event handler queue
2165                                 handlers = element.events[type] = {};
2166
2167                                 // Remember an existing handler, if it's already there
2168                                 if (element["on" + type])
2169                                         handlers[0] = element["on" + type];
2170                         }
2171
2172                         // Add the function to the element's handler list
2173                         handlers[handler.guid] = handler;
2174
2175                         // And bind the global event handler to the element
2176                         element["on" + type] = this.handle;
2177
2178                         // Remember the function in a global list (for triggering)
2179                         if (!this.global[type])
2180                                 this.global[type] = [];
2181                         this.global[type].push( element );
2182                 },
2183
2184                 guid: 1,
2185                 global: {},
2186
2187                 // Detach an event or set of events from an element
2188                 remove: function(element, type, handler) {
2189                         if (element.events)
2190                                 if (type && element.events[type])
2191                                         if ( handler )
2192                                                 delete element.events[type][handler.guid];
2193                                         else
2194                                                 for ( var i in element.events[type] )
2195                                                         delete element.events[type][i];
2196                                 else
2197                                         for ( var j in element.events )
2198                                                 this.remove( element, j );
2199                 },
2200
2201                 trigger: function(type,data,element) {
2202                         // Touch up the incoming data
2203                         data = data || [];
2204
2205                         // Handle a global trigger
2206                         if ( !element ) {
2207                                 var g = this.global[type];
2208                                 if ( g )
2209                                         for ( var i = 0; i < g.length; i++ )
2210                                                 this.trigger( type, data, g[i] );
2211
2212                         // Handle triggering a single element
2213                         } else if ( element["on" + type] ) {
2214                                 // Pass along a fake event
2215                                 data.unshift( this.fix({ type: type, target: element }) );
2216
2217                                 // Trigger the event
2218                                 element["on" + type].apply( element, data );
2219                         }
2220                 },
2221
2222                 handle: function(event) {
2223                         if ( typeof jQuery == "undefined" ) return;
2224
2225                         event = event || jQuery.event.fix( window.event );
2226
2227                         // If no correct event was found, fail
2228                         if ( !event ) return;
2229
2230                         var returnValue = true;
2231
2232                         var c = this.events[event.type];
2233
2234                         var args = [].slice.call( arguments, 1 );
2235                         args.unshift( event );
2236
2237                         for ( var j in c ) {
2238                                 if ( c[j].apply( this, args ) === false ) {
2239                                         event.preventDefault();
2240                                         event.stopPropagation();
2241                                         returnValue = false;
2242                                 }
2243                         }
2244
2245                         return returnValue;
2246                 },
2247
2248                 fix: function(event) {
2249                         if ( event ) {
2250                                 event.preventDefault = function() {
2251                                         this.returnValue = false;
2252                                 };
2253
2254                                 event.stopPropagation = function() {
2255                                         this.cancelBubble = true;
2256                                 };
2257                         }
2258
2259                         return event;
2260                 }
2261
2262         }
2263 });
2264
2265 /**
2266  * Contains flags for the useragent, read from navigator.userAgent.
2267  * Available flags are: safari, opera, msie, mozilla
2268  * This property is available before the DOM is ready, therefore you can
2269  * use it to add ready events only for certain browsers.
2270  *
2271  * See <a href="http://davecardwell.co.uk/geekery/javascript/jquery/jqbrowser/">
2272  * jQBrowser plugin</a> for advanced browser detection:
2273  *
2274  * @example $.browser.msie
2275  * @desc returns true if the current useragent is some version of microsoft's internet explorer
2276  *
2277  * @example if($.browser.safari) { $( function() { alert("this is safari!"); } ); }
2278  * @desc Alerts "this is safari!" only for safari browsers
2279  *
2280  * @name $.browser
2281  * @type Boolean
2282  * @cat Javascript
2283  */
2284 new function() {
2285         var b = navigator.userAgent.toLowerCase();
2286
2287         // Figure out what browser is being used
2288         jQuery.browser = {
2289                 safari: /webkit/.test(b),
2290                 opera: /opera/.test(b),
2291                 msie: /msie/.test(b) && !/opera/.test(b),
2292                 mozilla: /mozilla/.test(b) && !/(compatible|webkit)/.test(b)
2293         };
2294
2295         // Check to see if the W3C box model is being used
2296         jQuery.boxModel = !jQuery.browser.msie || document.compatMode == "CSS1Compat";
2297 };
2298
2299 jQuery.macros = {
2300         to: {
2301                 /**
2302                  * Append all of the matched elements to another, specified, set of elements.
2303                  * This operation is, essentially, the reverse of doing a regular
2304                  * $(A).append(B), in that instead of appending B to A, you're appending
2305                  * A to B.
2306                  *
2307                  * @example $("p").appendTo("#foo");
2308                  * @before <p>I would like to say: </p><div id="foo"></div>
2309                  * @result <div id="foo"><p>I would like to say: </p></div>
2310                  *
2311                  * @name appendTo
2312                  * @type jQuery
2313                  * @param String expr A jQuery expression of elements to match.
2314                  * @cat DOM/Manipulation
2315                  */
2316                 appendTo: "append",
2317
2318                 /**
2319                  * Prepend all of the matched elements to another, specified, set of elements.
2320                  * This operation is, essentially, the reverse of doing a regular
2321                  * $(A).prepend(B), in that instead of prepending B to A, you're prepending
2322                  * A to B.
2323                  *
2324                  * @example $("p").prependTo("#foo");
2325                  * @before <p>I would like to say: </p><div id="foo"><b>Hello</b></div>
2326                  * @result <div id="foo"><p>I would like to say: </p><b>Hello</b></div>
2327                  *
2328                  * @name prependTo
2329                  * @type jQuery
2330                  * @param String expr A jQuery expression of elements to match.
2331                  * @cat DOM/Manipulation
2332                  */
2333                 prependTo: "prepend",
2334
2335                 /**
2336                  * Insert all of the matched elements before another, specified, set of elements.
2337                  * This operation is, essentially, the reverse of doing a regular
2338                  * $(A).before(B), in that instead of inserting B before A, you're inserting
2339                  * A before B.
2340                  *
2341                  * @example $("p").insertBefore("#foo");
2342                  * @before <div id="foo">Hello</div><p>I would like to say: </p>
2343                  * @result <p>I would like to say: </p><div id="foo">Hello</div>
2344                  *
2345                  * @name insertBefore
2346                  * @type jQuery
2347                  * @param String expr A jQuery expression of elements to match.
2348                  * @cat DOM/Manipulation
2349                  */
2350                 insertBefore: "before",
2351
2352                 /**
2353                  * Insert all of the matched elements after another, specified, set of elements.
2354                  * This operation is, essentially, the reverse of doing a regular
2355                  * $(A).after(B), in that instead of inserting B after A, you're inserting
2356                  * A after B.
2357                  *
2358                  * @example $("p").insertAfter("#foo");
2359                  * @before <p>I would like to say: </p><div id="foo">Hello</div>
2360                  * @result <div id="foo">Hello</div><p>I would like to say: </p>
2361                  *
2362                  * @name insertAfter
2363                  * @type jQuery
2364                  * @param String expr A jQuery expression of elements to match.
2365                  * @cat DOM/Manipulation
2366                  */
2367                 insertAfter: "after"
2368         },
2369
2370         /**
2371          * Get the current CSS width of the first matched element.
2372          *
2373          * @example $("p").width();
2374          * @before <p>This is just a test.</p>
2375          * @result "300px"
2376          *
2377          * @name width
2378          * @type String
2379          * @cat CSS
2380          */
2381
2382         /**
2383          * Set the CSS width of every matched element. Be sure to include
2384          * the "px" (or other unit of measurement) after the number that you
2385          * specify, otherwise you might get strange results.
2386          *
2387          * @example $("p").width("20px");
2388          * @before <p>This is just a test.</p>
2389          * @result <p style="width:20px;">This is just a test.</p>
2390          *
2391          * @name width
2392          * @type jQuery
2393          * @param String val Set the CSS property to the specified value.
2394          * @cat CSS
2395          */
2396
2397         /**
2398          * Get the current CSS height of the first matched element.
2399          *
2400          * @example $("p").height();
2401          * @before <p>This is just a test.</p>
2402          * @result "14px"
2403          *
2404          * @name height
2405          * @type String
2406          * @cat CSS
2407          */
2408
2409         /**
2410          * Set the CSS height of every matched element. Be sure to include
2411          * the "px" (or other unit of measurement) after the number that you
2412          * specify, otherwise you might get strange results.
2413          *
2414          * @example $("p").height("20px");
2415          * @before <p>This is just a test.</p>
2416          * @result <p style="height:20px;">This is just a test.</p>
2417          *
2418          * @name height
2419          * @type jQuery
2420          * @param String val Set the CSS property to the specified value.
2421          * @cat CSS
2422          */
2423
2424         /**
2425          * Get the current CSS top of the first matched element.
2426          *
2427          * @example $("p").top();
2428          * @before <p>This is just a test.</p>
2429          * @result "0px"
2430          *
2431          * @name top
2432          * @type String
2433          * @cat CSS
2434          */
2435
2436         /**
2437          * Set the CSS top of every matched element. Be sure to include
2438          * the "px" (or other unit of measurement) after the number that you
2439          * specify, otherwise you might get strange results.
2440          *
2441          * @example $("p").top("20px");
2442          * @before <p>This is just a test.</p>
2443          * @result <p style="top:20px;">This is just a test.</p>
2444          *
2445          * @name top
2446          * @type jQuery
2447          * @param String val Set the CSS property to the specified value.
2448          * @cat CSS
2449          */
2450
2451         /**
2452          * Get the current CSS left of the first matched element.
2453          *
2454          * @example $("p").left();
2455          * @before <p>This is just a test.</p>
2456          * @result "0px"
2457          *
2458          * @name left
2459          * @type String
2460          * @cat CSS
2461          */
2462
2463         /**
2464          * Set the CSS left of every matched element. Be sure to include
2465          * the "px" (or other unit of measurement) after the number that you
2466          * specify, otherwise you might get strange results.
2467          *
2468          * @example $("p").left("20px");
2469          * @before <p>This is just a test.</p>
2470          * @result <p style="left:20px;">This is just a test.</p>
2471          *
2472          * @name left
2473          * @type jQuery
2474          * @param String val Set the CSS property to the specified value.
2475          * @cat CSS
2476          */
2477
2478         /**
2479          * Get the current CSS position of the first matched element.
2480          *
2481          * @example $("p").position();
2482          * @before <p>This is just a test.</p>
2483          * @result "static"
2484          *
2485          * @name position
2486          * @type String
2487          * @cat CSS
2488          */
2489
2490         /**
2491          * Set the CSS position of every matched element.
2492          *
2493          * @example $("p").position("relative");
2494          * @before <p>This is just a test.</p>
2495          * @result <p style="position:relative;">This is just a test.</p>
2496          *
2497          * @name position
2498          * @type jQuery
2499          * @param String val Set the CSS property to the specified value.
2500          * @cat CSS
2501          */
2502
2503         /**
2504          * Get the current CSS float of the first matched element.
2505          *
2506          * @example $("p").float();
2507          * @before <p>This is just a test.</p>
2508          * @result "none"
2509          *
2510          * @name float
2511          * @type String
2512          * @cat CSS
2513          */
2514
2515         /**
2516          * Set the CSS float of every matched element.
2517          *
2518          * @example $("p").float("left");
2519          * @before <p>This is just a test.</p>
2520          * @result <p style="float:left;">This is just a test.</p>
2521          *
2522          * @name float
2523          * @type jQuery
2524          * @param String val Set the CSS property to the specified value.
2525          * @cat CSS
2526          */
2527
2528         /**
2529          * Get the current CSS overflow of the first matched element.
2530          *
2531          * @example $("p").overflow();
2532          * @before <p>This is just a test.</p>
2533          * @result "none"
2534          *
2535          * @name overflow
2536          * @type String
2537          * @cat CSS
2538          */
2539
2540         /**
2541          * Set the CSS overflow of every matched element.
2542          *
2543          * @example $("p").overflow("auto");
2544          * @before <p>This is just a test.</p>
2545          * @result <p style="overflow:auto;">This is just a test.</p>
2546          *
2547          * @name overflow
2548          * @type jQuery
2549          * @param String val Set the CSS property to the specified value.
2550          * @cat CSS
2551          */
2552
2553         /**
2554          * Get the current CSS color of the first matched element.
2555          *
2556          * @example $("p").color();
2557          * @before <p>This is just a test.</p>
2558          * @result "black"
2559          *
2560          * @name color
2561          * @type String
2562          * @cat CSS
2563          */
2564
2565         /**
2566          * Set the CSS color of every matched element.
2567          *
2568          * @example $("p").color("blue");
2569          * @before <p>This is just a test.</p>
2570          * @result <p style="color:blue;">This is just a test.</p>
2571          *
2572          * @name color
2573          * @type jQuery
2574          * @param String val Set the CSS property to the specified value.
2575          * @cat CSS
2576          */
2577
2578         /**
2579          * Get the current CSS background of the first matched element.
2580          *
2581          * @example $("p").background();
2582          * @before <p style="background:blue;">This is just a test.</p>
2583          * @result "blue"
2584          *
2585          * @name background
2586          * @type String
2587          * @cat CSS
2588          */
2589
2590         /**
2591          * Set the CSS background of every matched element.
2592          *
2593          * @example $("p").background("blue");
2594          * @before <p>This is just a test.</p>
2595          * @result <p style="background:blue;">This is just a test.</p>
2596          *
2597          * @name background
2598          * @type jQuery
2599          * @param String val Set the CSS property to the specified value.
2600          * @cat CSS
2601          */
2602
2603         css: "width,height,top,left,position,float,overflow,color,background".split(","),
2604
2605         /**
2606          * Reduce the set of matched elements to a single element.
2607          * The position of the element in the set of matched elements
2608          * starts at 0 and goes to length - 1.
2609          *
2610          * @example $("p").eq(1)
2611          * @before <p>This is just a test.</p><p>So is this</p>
2612          * @result [ <p>So is this</p> ]
2613          *
2614          * @name eq
2615          * @type jQuery
2616          * @param Number pos The index of the element that you wish to limit to.
2617          * @cat Core
2618          */
2619
2620         /**
2621          * Reduce the set of matched elements to all elements before a given position.
2622          * The position of the element in the set of matched elements
2623          * starts at 0 and goes to length - 1.
2624          *
2625          * @example $("p").lt(1)
2626          * @before <p>This is just a test.</p><p>So is this</p>
2627          * @result [ <p>This is just a test.</p> ]
2628          *
2629          * @name lt
2630          * @type jQuery
2631          * @param Number pos Reduce the set to all elements below this position.
2632          * @cat Core
2633          */
2634
2635         /**
2636          * Reduce the set of matched elements to all elements after a given position.
2637          * The position of the element in the set of matched elements
2638          * starts at 0 and goes to length - 1.
2639          *
2640          * @example $("p").gt(0)
2641          * @before <p>This is just a test.</p><p>So is this</p>
2642          * @result [ <p>So is this</p> ]
2643          *
2644          * @name gt
2645          * @type jQuery
2646          * @param Number pos Reduce the set to all elements after this position.
2647          * @cat Core
2648          */
2649
2650         /**
2651          * Filter the set of elements to those that contain the specified text.
2652          *
2653          * @example $("p").contains("test")
2654          * @before <p>This is just a test.</p><p>So is this</p>
2655          * @result [ <p>This is just a test.</p> ]
2656          *
2657          * @name contains
2658          * @type jQuery
2659          * @param String str The string that will be contained within the text of an element.
2660          * @cat DOM/Traversing
2661          */
2662
2663         filter: [ "eq", "lt", "gt", "contains" ],
2664
2665         attr: {
2666                 /**
2667                  * Get the current value of the first matched element.
2668                  *
2669                  * @example $("input").val();
2670                  * @before <input type="text" value="some text"/>
2671                  * @result "some text"
2672                  *
2673                  * @test ok( $("#text1").val() == "Test", "Check for value of input element" );
2674                  * ok( !$("#text1").val() == "", "Check for value of input element" );
2675                  *
2676                  * @name val
2677                  * @type String
2678                  * @cat DOM/Attributes
2679                  */
2680
2681                 /**
2682                  * Set the value of every matched element.
2683                  *
2684                  * @example $("input").value("test");
2685                  * @before <input type="text" value="some text"/>
2686                  * @result <input type="text" value="test"/>
2687                  *
2688                  * @test document.getElementById('text1').value = "bla";
2689                  * ok( $("#text1").val() == "bla", "Check for modified value of input element" );
2690                  * $("#text1").val('test');
2691                  * ok ( document.getElementById('text1').value == "test", "Check for modified (via val(String)) value of input element" );
2692                  *
2693                  * @name val
2694                  * @type jQuery
2695                  * @param String val Set the property to the specified value.
2696                  * @cat DOM/Attributes
2697                  */
2698                 val: "value",
2699
2700                 /**
2701                  * Get the html contents of the first matched element.
2702                  *
2703                  * @example $("div").html();
2704                  * @before <div><input/></div>
2705                  * @result <input/>
2706                  *
2707                  * @name html
2708                  * @type String
2709                  * @cat DOM/Attributes
2710                  */
2711
2712                 /**
2713                  * Set the html contents of every matched element.
2714                  *
2715                  * @example $("div").html("<b>new stuff</b>");
2716                  * @before <div><input/></div>
2717                  * @result <div><b>new stuff</b></div>
2718                  *
2719                  * @test var div = $("div");
2720                  * div.html("<b>test</b>");
2721                  * var pass = true;
2722                  * for ( var i = 0; i < div.size(); i++ ) {
2723                  *   if ( div.get(i).childNodes.length == 0 ) pass = false;
2724                  * }
2725                  * ok( pass, "Set HTML" );
2726                  *
2727                  * @name html
2728                  * @type jQuery
2729                  * @param String val Set the html contents to the specified value.
2730                  * @cat DOM/Attributes
2731                  */
2732                 html: "innerHTML",
2733
2734                 /**
2735                  * Get the current id of the first matched element.
2736                  *
2737                  * @example $("input").id();
2738                  * @before <input type="text" id="test" value="some text"/>
2739                  * @result "test"
2740                  *
2741                  * @test ok( $(document.getElementById('main')).id() == "main", "Check for id" );
2742                  * ok( $("#foo").id() == "foo", "Check for id" );
2743                  * ok( !$("head").id(), "Check for id" );
2744                  *
2745                  * @name id
2746                  * @type String
2747                  * @cat DOM/Attributes
2748                  */
2749
2750                 /**
2751                  * Set the id of every matched element.
2752                  *
2753                  * @example $("input").id("newid");
2754                  * @before <input type="text" id="test" value="some text"/>
2755                  * @result <input type="text" id="newid" value="some text"/>
2756                  *
2757                  * @name id
2758                  * @type jQuery
2759                  * @param String val Set the property to the specified value.
2760                  * @cat DOM/Attributes
2761                  */
2762                 id: null,
2763
2764                 /**
2765                  * Get the current title of the first matched element.
2766                  *
2767                  * @example $("img").title();
2768                  * @before <img src="test.jpg" title="my image"/>
2769                  * @result "my image"
2770                  *
2771                  * @test ok( $(document.getElementById('google')).title() == "Google!", "Check for title" );
2772                  * ok( !$("#yahoo").title(), "Check for title" );
2773                  *
2774                  * @name title
2775                  * @type String
2776                  * @cat DOM/Attributes
2777                  */
2778
2779                 /**
2780                  * Set the title of every matched element.
2781                  *
2782                  * @example $("img").title("new title");
2783                  * @before <img src="test.jpg" title="my image"/>
2784                  * @result <img src="test.jpg" title="new image"/>
2785                  *
2786                  * @name title
2787                  * @type jQuery
2788                  * @param String val Set the property to the specified value.
2789                  * @cat DOM/Attributes
2790                  */
2791                 title: null,
2792
2793                 /**
2794                  * Get the current name of the first matched element.
2795                  *
2796                  * @example $("input").name();
2797                  * @before <input type="text" name="username"/>
2798                  * @result "username"
2799                  *
2800                  * @test ok( $(document.getElementById('text1')).name() == "action", "Check for name" );
2801                  * ok( $("#hidden1").name() == "hidden", "Check for name" );
2802                  * ok( !$("#area1").name(), "Check for name" );
2803                  *
2804                  * @name name
2805                  * @type String
2806                  * @cat DOM/Attributes
2807                  */
2808
2809                 /**
2810                  * Set the name of every matched element.
2811                  *
2812                  * @example $("input").name("user");
2813                  * @before <input type="text" name="username"/>
2814                  * @result <input type="text" name="user"/>
2815                  *
2816                  * @name name
2817                  * @type jQuery
2818                  * @param String val Set the property to the specified value.
2819                  * @cat DOM/Attributes
2820                  */
2821                 name: null,
2822
2823                 /**
2824                  * Get the current href of the first matched element.
2825                  *
2826                  * @example $("a").href();
2827                  * @before <a href="test.html">my link</a>
2828                  * @result "test.html"
2829                  *
2830                  * @name href
2831                  * @type String
2832                  * @cat DOM/Attributes
2833                  */
2834
2835                 /**
2836                  * Set the href of every matched element.
2837                  *
2838                  * @example $("a").href("test2.html");
2839                  * @before <a href="test.html">my link</a>
2840                  * @result <a href="test2.html">my link</a>
2841                  *
2842                  * @name href
2843                  * @type jQuery
2844                  * @param String val Set the property to the specified value.
2845                  * @cat DOM/Attributes
2846                  */
2847                 href: null,
2848
2849                 /**
2850                  * Get the current src of the first matched element.
2851                  *
2852                  * @example $("img").src();
2853                  * @before <img src="test.jpg" title="my image"/>
2854                  * @result "test.jpg"
2855                  *
2856                  * @name src
2857                  * @type String
2858                  * @cat DOM/Attributes
2859                  */
2860
2861                 /**
2862                  * Set the src of every matched element.
2863                  *
2864                  * @example $("img").src("test2.jpg");
2865                  * @before <img src="test.jpg" title="my image"/>
2866                  * @result <img src="test2.jpg" title="my image"/>
2867                  *
2868                  * @name src
2869                  * @type jQuery
2870                  * @param String val Set the property to the specified value.
2871                  * @cat DOM/Attributes
2872                  */
2873                 src: null,
2874
2875                 /**
2876                  * Get the current rel of the first matched element.
2877                  *
2878                  * @example $("a").rel();
2879                  * @before <a href="test.html" rel="nofollow">my link</a>
2880                  * @result "nofollow"
2881                  *
2882                  * @name rel
2883                  * @type String
2884                  * @cat DOM/Attributes
2885                  */
2886
2887                 /**
2888                  * Set the rel of every matched element.
2889                  *
2890                  * @example $("a").rel("nofollow");
2891                  * @before <a href="test.html">my link</a>
2892                  * @result <a href="test.html" rel="nofollow">my link</a>
2893                  *
2894                  * @name rel
2895                  * @type jQuery
2896                  * @param String val Set the property to the specified value.
2897                  * @cat DOM/Attributes
2898                  */
2899                 rel: null
2900         },
2901
2902         axis: {
2903                 /**
2904                  * Get a set of elements containing the unique parents of the matched
2905                  * set of elements.
2906                  *
2907                  * @example $("p").parent()
2908                  * @before <div><p>Hello</p><p>Hello</p></div>
2909                  * @result [ <div><p>Hello</p><p>Hello</p></div> ]
2910                  *
2911                  * @name parent
2912                  * @type jQuery
2913                  * @cat DOM/Traversing
2914                  */
2915
2916                 /**
2917                  * Get a set of elements containing the unique parents of the matched
2918                  * set of elements, and filtered by an expression.
2919                  *
2920                  * @example $("p").parent(".selected")
2921                  * @before <div><p>Hello</p></div><div class="selected"><p>Hello Again</p></div>
2922                  * @result [ <div class="selected"><p>Hello Again</p></div> ]
2923                  *
2924                  * @name parent
2925                  * @type jQuery
2926                  * @param String expr An expression to filter the parents with
2927                  * @cat DOM/Traversing
2928                  */
2929                 parent: "a.parentNode",
2930
2931                 /**
2932                  * Get a set of elements containing the unique ancestors of the matched
2933                  * set of elements (except for the root element).
2934                  *
2935                  * @example $("span").ancestors()
2936                  * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html>
2937                  * @result [ <body>...</body>, <div>...</div>, <p><span>Hello</span></p> ]
2938                  *
2939                  * @name ancestors
2940                  * @type jQuery
2941                  * @cat DOM/Traversing
2942                  */
2943
2944                 /**
2945                  * Get a set of elements containing the unique ancestors of the matched
2946                  * set of elements, and filtered by an expression.
2947                  *
2948                  * @example $("span").ancestors("p")
2949                  * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html>
2950                  * @result [ <p><span>Hello</span></p> ]
2951                  *
2952                  * @name ancestors
2953                  * @type jQuery
2954                  * @param String expr An expression to filter the ancestors with
2955                  * @cat DOM/Traversing
2956                  */
2957                 ancestors: jQuery.parents,
2958
2959                 /**
2960                  * Get a set of elements containing the unique ancestors of the matched
2961                  * set of elements (except for the root element).
2962                  *
2963                  * @example $("span").ancestors()
2964                  * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html>
2965                  * @result [ <body>...</body>, <div>...</div>, <p><span>Hello</span></p> ]
2966                  *
2967                  * @name parents
2968                  * @type jQuery
2969                  * @cat DOM/Traversing
2970                  */
2971
2972                 /**
2973                  * Get a set of elements containing the unique ancestors of the matched
2974                  * set of elements, and filtered by an expression.
2975                  *
2976                  * @example $("span").ancestors("p")
2977                  * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html>
2978                  * @result [ <p><span>Hello</span></p> ]
2979                  *
2980                  * @name parents
2981                  * @type jQuery
2982                  * @param String expr An expression to filter the ancestors with
2983                  * @cat DOM/Traversing
2984                  */
2985                 parents: jQuery.parents,
2986
2987                 /**
2988                  * Get a set of elements containing the unique next siblings of each of the
2989                  * matched set of elements.
2990                  *
2991                  * It only returns the very next sibling, not all next siblings.
2992                  *
2993                  * @example $("p").next()
2994                  * @before <p>Hello</p><p>Hello Again</p><div><span>And Again</span></div>
2995                  * @result [ <p>Hello Again</p>, <div><span>And Again</span></div> ]
2996                  *
2997                  * @name next
2998                  * @type jQuery
2999                  * @cat DOM/Traversing
3000                  */
3001
3002                 /**
3003                  * Get a set of elements containing the unique next siblings of each of the
3004                  * matched set of elements, and filtered by an expression.
3005                  *
3006                  * It only returns the very next sibling, not all next siblings.
3007                  *
3008                  * @example $("p").next(".selected")
3009                  * @before <p>Hello</p><p class="selected">Hello Again</p><div><span>And Again</span></div>
3010                  * @result [ <p class="selected">Hello Again</p> ]
3011                  *
3012                  * @name next
3013                  * @type jQuery
3014                  * @param String expr An expression to filter the next Elements with
3015                  * @cat DOM/Traversing
3016                  */
3017                 next: "jQuery.sibling(a).next",
3018
3019                 /**
3020                  * Get a set of elements containing the unique previous siblings of each of the
3021                  * matched set of elements.
3022                  *
3023                  * It only returns the immediately previous sibling, not all previous siblings.
3024                  *
3025                  * @example $("p").prev()
3026                  * @before <p>Hello</p><div><span>Hello Again</span></div><p>And Again</p>
3027                  * @result [ <div><span>Hello Again</span></div> ]
3028                  *
3029                  * @name prev
3030                  * @type jQuery
3031                  * @cat DOM/Traversing
3032                  */
3033
3034                 /**
3035                  * Get a set of elements containing the unique previous siblings of each of the
3036                  * matched set of elements, and filtered by an expression.
3037                  *
3038                  * It only returns the immediately previous sibling, not all previous siblings.
3039                  *
3040                  * @example $("p").previous(".selected")
3041                  * @before <div><span>Hello</span></div><p class="selected">Hello Again</p><p>And Again</p>
3042                  * @result [ <div><span>Hello</span></div> ]
3043                  *
3044                  * @name prev
3045                  * @type jQuery
3046                  * @param String expr An expression to filter the previous Elements with
3047                  * @cat DOM/Traversing
3048                  */
3049                 prev: "jQuery.sibling(a).prev",
3050
3051                 /**
3052                  * Get a set of elements containing all of the unique siblings of each of the
3053                  * matched set of elements.
3054                  *
3055                  * @example $("div").siblings()
3056                  * @before <p>Hello</p><div><span>Hello Again</span></div><p>And Again</p>
3057                  * @result [ <p>Hello</p>, <p>And Again</p> ]
3058                  *
3059                  * @test isSet( $("#en").siblings().get(), q("sndp", "sap"), "Check for siblings" ); 
3060                  *
3061                  * @name siblings
3062                  * @type jQuery
3063                  * @cat DOM/Traversing
3064                  */
3065
3066                 /**
3067                  * Get a set of elements containing all of the unique siblings of each of the
3068                  * matched set of elements, and filtered by an expression.
3069                  *
3070                  * @example $("div").siblings(".selected")
3071                  * @before <div><span>Hello</span></div><p class="selected">Hello Again</p><p>And Again</p>
3072                  * @result [ <p class="selected">Hello Again</p> ]
3073                  *
3074                  * @test isSet( $("#sndp").siblings("[code]").get(), q("sap"), "Check for filtered siblings (has code child element)" ); 
3075                  * isSet( $("#sndp").siblings("[a]").get(), q("en", "sap"), "Check for filtered siblings (has anchor child element)" );
3076                  *
3077                  * @name siblings
3078                  * @type jQuery
3079                  * @param String expr An expression to filter the sibling Elements with
3080                  * @cat DOM/Traversing
3081                  */
3082                 siblings: "jQuery.sibling(a, null, true)",
3083
3084
3085                 /**
3086                  * Get a set of elements containing all of the unique children of each of the
3087                  * matched set of elements.
3088                  *
3089                  * @example $("div").children()
3090                  * @before <p>Hello</p><div><span>Hello Again</span></div><p>And Again</p>
3091                  * @result [ <span>Hello Again</span> ]
3092                  *
3093                  * @test isSet( $("#foo").children().get(), q("sndp", "en", "sap"), "Check for children" );
3094                  *
3095                  * @name children
3096                  * @type jQuery
3097                  * @cat DOM/Traversing
3098                  */
3099
3100                 /**
3101                  * Get a set of elements containing all of the unique children of each of the
3102                  * matched set of elements, and filtered by an expression.
3103                  *
3104                  * @example $("div").children(".selected")
3105                  * @before <div><span>Hello</span><p class="selected">Hello Again</p><p>And Again</p></div>
3106                  * @result [ <p class="selected">Hello Again</p> ]
3107                  *
3108                  * @test isSet( $("#foo").children("[code]").get(), q("sndp", "sap"), "Check for filtered children" ); 
3109                  *
3110                  * @name children
3111                  * @type jQuery
3112                  * @param String expr An expression to filter the child Elements with
3113                  * @cat DOM/Traversing
3114                  */
3115                 children: "jQuery.sibling(a.firstChild)"
3116         },
3117
3118         each: {
3119
3120                 /**
3121                  * Remove an attribute from each of the matched elements.
3122                  *
3123                  * @example $("input").removeAttr("disabled")
3124                  * @before <input disabled="disabled"/>
3125                  * @result <input/>
3126                  *
3127                  * @name removeAttr
3128                  * @type jQuery
3129                  * @param String name The name of the attribute to remove.
3130                  * @cat DOM
3131                  */
3132                 removeAttr: function( key ) {
3133                         this.removeAttribute( key );
3134                 },
3135
3136                 /**
3137                  * Displays each of the set of matched elements if they are hidden.
3138                  *
3139                  * @example $("p").show()
3140                  * @before <p style="display: none">Hello</p>
3141                  * @result [ <p style="display: block">Hello</p> ]
3142                  *
3143                  * @test var pass = true, div = $("div");
3144                  * div.show().each(function(){
3145                  *   if ( this.style.display == "none" ) pass = false;
3146                  * });
3147                  * ok( pass, "Show" );
3148                  *
3149                  * @name show
3150                  * @type jQuery
3151                  * @cat Effects
3152                  */
3153                 show: function(){
3154                         this.style.display = this.oldblock ? this.oldblock : "";
3155                         if ( jQuery.css(this,"display") == "none" )
3156                                 this.style.display = "block";
3157                 },
3158
3159                 /**
3160                  * Hides each of the set of matched elements if they are shown.
3161                  *
3162                  * @example $("p").hide()
3163                  * @before <p>Hello</p>
3164                  * @result [ <p style="display: none">Hello</p> ]
3165                  *
3166                  * var pass = true, div = $("div");
3167                  * div.hide().each(function(){
3168                  *   if ( this.style.display != "none" ) pass = false;
3169                  * });
3170                  * ok( pass, "Hide" );
3171                  *
3172                  * @name hide
3173                  * @type jQuery
3174                  * @cat Effects
3175                  */
3176                 hide: function(){
3177                         this.oldblock = this.oldblock || jQuery.css(this,"display");
3178                         if ( this.oldblock == "none" )
3179                                 this.oldblock = "block";
3180                         this.style.display = "none";
3181                 },
3182
3183                 /**
3184                  * Toggles each of the set of matched elements. If they are shown,
3185                  * toggle makes them hidden. If they are hidden, toggle
3186                  * makes them shown.
3187                  *
3188                  * @example $("p").toggle()
3189                  * @before <p>Hello</p><p style="display: none">Hello Again</p>
3190                  * @result [ <p style="display: none">Hello</p>, <p style="display: block">Hello Again</p> ]
3191                  *
3192                  * @name toggle
3193                  * @type jQuery
3194                  * @cat Effects
3195                  */
3196                 toggle: function(){
3197                         jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ].apply( jQuery(this), arguments );
3198                 },
3199
3200                 /**
3201                  * Adds the specified class to each of the set of matched elements.
3202                  *
3203                  * @example $("p").addClass("selected")
3204                  * @before <p>Hello</p>
3205                  * @result [ <p class="selected">Hello</p> ]
3206                  *
3207                  * @test var div = $("div");
3208                  * div.addClass("test");
3209                  * var pass = true;
3210                  * for ( var i = 0; i < div.size(); i++ ) {
3211                  *  if ( div.get(i).className.indexOf("test") == -1 ) pass = false;
3212                  * }
3213                  * ok( pass, "Add Class" );
3214                  *
3215                  * @name addClass
3216                  * @type jQuery
3217                  * @param String class A CSS class to add to the elements
3218                  * @cat DOM
3219                  */
3220                 addClass: function(c){
3221                         jQuery.className.add(this,c);
3222                 },
3223
3224                 /**
3225                  * Removes the specified class from the set of matched elements.
3226                  *
3227                  * @example $("p").removeClass("selected")
3228                  * @before <p class="selected">Hello</p>
3229                  * @result [ <p>Hello</p> ]
3230                  *
3231                  * @test var div = $("div").addClass("test");
3232                  * div.removeClass("test");
3233                  * var pass = true;
3234                  * for ( var i = 0; i < div.size(); i++ ) {
3235                  *  if ( div.get(i).className.indexOf("test") != -1 ) pass = false;
3236                  * }
3237                  * ok( pass, "Remove Class" );
3238                  * 
3239                  * reset();
3240                  *
3241                  * var div = $("div").addClass("test").addClass("foo").addClass("bar");
3242                  * div.removeClass("test").removeClass("bar").removeClass("foo");
3243                  * var pass = true;
3244                  * for ( var i = 0; i < div.size(); i++ ) {
3245                  *  if ( div.get(i).className.match(/test|bar|foo/) ) pass = false;
3246                  * }
3247                  * ok( pass, "Remove multiple classes" );
3248                  *
3249                  * @name removeClass
3250                  * @type jQuery
3251                  * @param String class A CSS class to remove from the elements
3252                  * @cat DOM
3253                  */
3254                 removeClass: function(c){
3255                         jQuery.className.remove(this,c);
3256                 },
3257
3258                 /**
3259                  * Adds the specified class if it is present, removes it if it is
3260                  * not present.
3261                  *
3262                  * @example $("p").toggleClass("selected")
3263                  * @before <p>Hello</p><p class="selected">Hello Again</p>
3264                  * @result [ <p class="selected">Hello</p>, <p>Hello Again</p> ]
3265                  *
3266                  * @name toggleClass
3267                  * @type jQuery
3268                  * @param String class A CSS class with which to toggle the elements
3269                  * @cat DOM
3270                  */
3271                 toggleClass: function( c ){
3272                         jQuery.className[ jQuery.className.has(this,c) ? "remove" : "add" ](this,c);
3273                 },
3274
3275                 /**
3276                  * Removes all matched elements from the DOM. This does NOT remove them from the
3277                  * jQuery object, allowing you to use the matched elements further.
3278                  *
3279                  * @example $("p").remove();
3280                  * @before <p>Hello</p> how are <p>you?</p>
3281                  * @result how are
3282                  *
3283                  * @name remove
3284                  * @type jQuery
3285                  * @cat DOM/Manipulation
3286                  */
3287
3288                 /**
3289                  * Removes only elements (out of the list of matched elements) that match
3290                  * the specified jQuery expression. This does NOT remove them from the
3291                  * jQuery object, allowing you to use the matched elements further.
3292                  *
3293                  * @example $("p").remove(".hello");
3294                  * @before <p class="hello">Hello</p> how are <p>you?</p>
3295                  * @result how are <p>you?</p>
3296                  *
3297                  * @name remove
3298                  * @type jQuery
3299                  * @param String expr A jQuery expression to filter elements by.
3300                  * @cat DOM/Manipulation
3301                  */
3302                 remove: function(a){
3303                         if ( !a || jQuery.filter( a, [this] ).r )
3304                                 this.parentNode.removeChild( this );
3305                 },
3306
3307                 /**
3308                  * Removes all child nodes from the set of matched elements.
3309                  *
3310                  * @example $("p").empty()
3311                  * @before <p>Hello, <span>Person</span> <a href="#">and person</a></p>
3312                  * @result [ <p></p> ]
3313                  *
3314                  * @name empty
3315                  * @type jQuery
3316                  * @cat DOM/Manipulation
3317                  */
3318                 empty: function(){
3319                         while ( this.firstChild )
3320                                 this.removeChild( this.firstChild );
3321                 },
3322
3323                 /**
3324                  * Binds a handler to a particular event (like click) for each matched element.
3325                  * The event handler is passed an event object that you can use to prevent
3326                  * default behaviour. To stop both default action and event bubbling, your handler
3327                  * has to return false.
3328                  *
3329                  * @example $("p").bind( "click", function() {
3330                  *   alert( $(this).text() );
3331                  * } )
3332                  * @before <p>Hello</p>
3333                  * @result alert("Hello")
3334                  *
3335                  * @example $("form").bind( "submit", function() { return false; } )
3336                  * @desc Cancel a default action and prevent it from bubbling by returning false
3337                  * from your function.
3338                  *
3339                  * @example $("form").bind( "submit", function(event) {
3340                  *   event.preventDefault();
3341                  * } );
3342                  * @desc Cancel only the default action by using the preventDefault method.
3343                  *
3344                  *
3345                  * @example $("form").bind( "submit", function(event) {
3346                  *   event.stopPropagation();
3347                  * } )
3348                  * @desc Stop only an event from bubbling by using the stopPropagation method.
3349                  *
3350                  * @name bind
3351                  * @type jQuery
3352                  * @param String type An event type
3353                  * @param Function fn A function to bind to the event on each of the set of matched elements
3354                  * @cat Events
3355                  */
3356                 bind: function( type, fn ) {
3357                         if ( fn.constructor == String )
3358                                 fn = new Function("e", ( !fn.indexOf(".") ? "jQuery(this)" : "return " ) + fn);
3359                         jQuery.event.add( this, type, fn );
3360                 },
3361
3362                 /**
3363                  * The opposite of bind, removes a bound event from each of the matched
3364                  * elements. You must pass the identical function that was used in the original
3365                  * bind method.
3366                  *
3367                  * @example $("p").unbind( "click", function() { alert("Hello"); } )
3368                  * @before <p onclick="alert('Hello');">Hello</p>
3369                  * @result [ <p>Hello</p> ]
3370                  *
3371                  * @name unbind
3372                  * @type jQuery
3373                  * @param String type An event type
3374                  * @param Function fn A function to unbind from the event on each of the set of matched elements
3375                  * @cat Events
3376                  */
3377
3378                 /**
3379                  * Removes all bound events of a particular type from each of the matched
3380                  * elements.
3381                  *
3382                  * @example $("p").unbind( "click" )
3383                  * @before <p onclick="alert('Hello');">Hello</p>
3384                  * @result [ <p>Hello</p> ]
3385                  *
3386                  * @name unbind
3387                  * @type jQuery
3388                  * @param String type An event type
3389                  * @cat Events
3390                  */
3391
3392                 /**
3393                  * Removes all bound events from each of the matched elements.
3394                  *
3395                  * @example $("p").unbind()
3396                  * @before <p onclick="alert('Hello');">Hello</p>
3397                  * @result [ <p>Hello</p> ]
3398                  *
3399                  * @name unbind
3400                  * @type jQuery
3401                  * @cat Events
3402                  */
3403                 unbind: function( type, fn ) {
3404                         jQuery.event.remove( this, type, fn );
3405                 },
3406
3407                 /**
3408                  * Trigger a type of event on every matched element.
3409                  *
3410                  * @example $("p").trigger("click")
3411                  * @before <p click="alert('hello')">Hello</p>
3412                  * @result alert('hello')
3413                  *
3414                  * @name trigger
3415                  * @type jQuery
3416                  * @param String type An event type to trigger.
3417                  * @cat Events
3418                  */
3419                 trigger: function( type, data ) {
3420                         jQuery.event.trigger( type, data, this );
3421                 }
3422         }
3423 };
3424
3425 jQuery.init();