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