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