Added support .css("left",30). Fixed up the multiFilter code.
[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  * @constructor
19  * @private
20  * @name jQuery
21  * @param String|Function|Element|Array<Element>|jQuery a selector
22  * @param jQuery|Element|Array<Element> c context
23  * @cat Core
24  */
25 var jQuery = function(a,c) {
26         // If the context is global, return a new object
27         if ( window == this )
28                 return new jQuery(a,c);
29
30         // Make sure that a selection was provided
31         a = a || document;
32         
33         // HANDLE: $(function)
34         // Shortcut for document ready
35         // Safari reports typeof on DOM NodeLists as a function
36         if ( typeof a == "function" && !a.nodeType && a[0] == undefined )
37                 return new jQuery(document)[ jQuery.fn.ready ? "ready" : "load" ]( a );
38         
39         // Handle HTML strings
40         if ( typeof a  == "string" ) {
41                 // HANDLE: $(html) -> $(array)
42                 var m = /^[^<]*(<.+>)[^>]*$/.exec(a);
43                 if ( m )
44                         a = jQuery.clean( [ m[1] ] );
45                 
46                 // HANDLE: $(expr)
47                 else
48                         return new jQuery( c ).find( a );
49         }
50         
51         return this.setArray(
52                 // HANDLE: $(array)
53                 a.constructor == Array && a ||
54
55                 // HANDLE: $(arraylike)
56                 // Watch for when an array-like object is passed as the selector
57                 (a.jquery || a.length && a != window && !a.nodeType && a[0] != undefined && a[0].nodeType) && jQuery.makeArray( a ) ||
58
59                 // HANDLE: $(*)
60                 [ a ] );
61 };
62
63 // Map over the $ in case of overwrite
64 if ( typeof $ != "undefined" )
65         jQuery._$ = $;
66         
67 // Map the jQuery namespace to the '$' one
68 var $ = jQuery;
69
70 /**
71  * This function accepts a string containing a CSS or
72  * basic XPath selector which is then used to match a set of elements.
73  *
74  * The core functionality of jQuery centers around this function.
75  * Everything in jQuery is based upon this, or uses this in some way.
76  * The most basic use of this function is to pass in an expression
77  * (usually consisting of CSS or XPath), which then finds all matching
78  * elements.
79  *
80  * By default, $() looks for DOM elements within the context of the
81  * current HTML document.
82  *
83  * @example $("div > p")
84  * @desc Finds all p elements that are children of a div element.
85  * @before <p>one</p> <div><p>two</p></div> <p>three</p>
86  * @result [ <p>two</p> ]
87  *
88  * @example $("input:radio", document.forms[0])
89  * @desc Searches for all inputs of type radio within the first form in the document
90  *
91  * @example $("div", xml.responseXML)
92  * @desc This finds all div elements within the specified XML document.
93  *
94  * @name $
95  * @param String expr An expression to search with
96  * @param Element|jQuery context (optional) A DOM Element, Document or jQuery to use as context
97  * @cat Core
98  * @type jQuery
99  * @see $(Element)
100  * @see $(Element<Array>)
101  */
102  
103 /**
104  * Create DOM elements on-the-fly from the provided String of raw HTML.
105  *
106  * @example $("<div><p>Hello</p></div>").appendTo("#body")
107  * @desc Creates a div element (and all of its contents) dynamically, 
108  * and appends it to the element with the ID of body. Internally, an
109  * element is created and it's innerHTML property set to the given markup.
110  * It is therefore both quite flexible and limited. 
111  *
112  * @name $
113  * @param String html A string of HTML to create on the fly.
114  * @cat Core
115  * @type jQuery
116  * @see appendTo(String)
117  */
118
119 /**
120  * Wrap jQuery functionality around a single or multiple DOM Element(s).
121  *
122  * This function also accepts XML Documents and Window objects
123  * as valid arguments (even though they are not DOM Elements).
124  *
125  * @example $(document).find("div > p")
126  * @before <p>one</p> <div><p>two</p></div> <p>three</p>
127  * @result [ <p>two</p> ]
128  * @desc Same as $("div > p") because the document
129  *
130  * @example $(document.body).background( "black" );
131  * @desc Sets the background color of the page to black.
132  *
133  * @example $( myForm.elements ).hide()
134  * @desc Hides all the input elements within a form
135  *
136  * @name $
137  * @param Element|Array<Element> elems DOM element(s) to be encapsulated by a jQuery object.
138  * @cat Core
139  * @type jQuery
140  */
141
142 /**
143  * A shorthand for $(document).ready(), allowing you to bind a function
144  * to be executed when the DOM document has finished loading. This function
145  * behaves just like $(document).ready(), in that it should be used to wrap
146  * all of the other $() operations on your page. While this function is,
147  * technically, chainable - there really isn't much use for chaining against it.
148  * You can have as many $(document).ready events on your page as you like.
149  *
150  * See ready(Function) for details about the ready event. 
151  * 
152  * @example $(function(){
153  *   // Document is ready
154  * });
155  * @desc Executes the function when the DOM is ready to be used.
156  *
157  * @name $
158  * @param Function fn The function to execute when the DOM is ready.
159  * @cat Core
160  * @type jQuery
161  */
162
163 jQuery.fn = jQuery.prototype = {
164         /**
165          * The current version of jQuery.
166          *
167          * @private
168          * @property
169          * @name jquery
170          * @type String
171          * @cat Core
172          */
173         jquery: "@VERSION",
174
175         /**
176          * The number of elements currently matched.
177          *
178          * @example $("img").length;
179          * @before <img src="test1.jpg"/> <img src="test2.jpg"/>
180          * @result 2
181          *
182          * @property
183          * @name length
184          * @type Number
185          * @cat Core
186          */
187
188         /**
189          * The number of elements currently matched.
190          *
191          * @example $("img").size();
192          * @before <img src="test1.jpg"/> <img src="test2.jpg"/>
193          * @result 2
194          *
195          * @name size
196          * @type Number
197          * @cat Core
198          */
199         size: function() {
200                 return this.length;
201         },
202         
203         length: 0,
204
205         /**
206          * Access all matched elements. This serves as a backwards-compatible
207          * way of accessing all matched elements (other than the jQuery object
208          * itself, which is, in fact, an array of elements).
209          *
210          * @example $("img").get();
211          * @before <img src="test1.jpg"/> <img src="test2.jpg"/>
212          * @result [ <img src="test1.jpg"/> <img src="test2.jpg"/> ]
213          * @desc Selects all images in the document and returns the DOM Elements as an Array
214          *
215          * @name get
216          * @type Array<Element>
217          * @cat Core
218          */
219
220         /**
221          * Access a single matched element. num is used to access the
222          * Nth element matched.
223          *
224          * @example $("img").get(0);
225          * @before <img src="test1.jpg"/> <img src="test2.jpg"/>
226          * @result [ <img src="test1.jpg"/> ]
227          * @desc Selects all images in the document and returns the first one
228          *
229          * @name get
230          * @type Element
231          * @param Number num Access the element in the Nth position.
232          * @cat Core
233          */
234         get: function( num ) {
235                 return num == undefined ?
236
237                         // Return a 'clean' array
238                         jQuery.makeArray( this ) :
239
240                         // Return just the object
241                         this[num];
242         },
243         
244         /**
245          * Set the jQuery object to an array of elements, while maintaining
246          * the stack.
247          *
248          * @example $("img").pushStack([ document.body ]);
249          * @result $("img").pushStack() == [ document.body ]
250          *
251          * @private
252          * @name pushStack
253          * @type jQuery
254          * @param Elements elems An array of elements
255          * @cat Core
256          */
257         pushStack: function( a ) {
258                 var ret = jQuery(this);
259                 ret.prevObject = this;
260                 return ret.setArray( a );
261         },
262         
263         /**
264          * Set the jQuery object to an array of elements. This operation is
265          * completely destructive - be sure to use .pushStack() if you wish to maintain
266          * the jQuery stack.
267          *
268          * @example $("img").setArray([ document.body ]);
269          * @result $("img").setArray() == [ document.body ]
270          *
271          * @private
272          * @name setArray
273          * @type jQuery
274          * @param Elements elems An array of elements
275          * @cat Core
276          */
277         setArray: function( a ) {
278                 this.length = 0;
279                 [].push.apply( this, a );
280                 return this;
281         },
282
283         /**
284          * Execute a function within the context of every matched element.
285          * This means that every time the passed-in function is executed
286          * (which is once for every element matched) the 'this' keyword
287          * points to the specific element.
288          *
289          * Additionally, the function, when executed, is passed a single
290          * argument representing the position of the element in the matched
291          * set.
292          *
293          * @example $("img").each(function(i){
294          *   this.src = "test" + i + ".jpg";
295          * });
296          * @before <img/><img/>
297          * @result <img src="test0.jpg"/><img src="test1.jpg"/>
298          * @desc Iterates over two images and sets their src property
299          *
300          * @name each
301          * @type jQuery
302          * @param Function fn A function to execute
303          * @cat Core
304          */
305         each: function( fn, args ) {
306                 return jQuery.each( this, fn, args );
307         },
308
309         /**
310          * Searches every matched element for the object and returns
311          * the index of the element, if found, starting with zero. 
312          * Returns -1 if the object wasn't found.
313          *
314          * @example $("*").index( $('#foobar')[0] ) 
315          * @before <div id="foobar"></div><b></b><span id="foo"></span>
316          * @result 0
317          * @desc Returns the index for the element with ID foobar
318          *
319          * @example $("*").index( $('#foo')) 
320          * @before <div id="foobar"></div><b></b><span id="foo"></span>
321          * @result 2
322          * @desc Returns the index for the element with ID foo
323          *
324          * @example $("*").index( $('#bar')) 
325          * @before <div id="foobar"></div><b></b><span id="foo"></span>
326          * @result -1
327          * @desc Returns -1, as there is no element with ID bar
328          *
329          * @name index
330          * @type Number
331          * @param Element subject Object to search for
332          * @cat Core
333          */
334         index: function( obj ) {
335                 var pos = -1;
336                 this.each(function(i){
337                         if ( this == obj ) pos = i;
338                 });
339                 return pos;
340         },
341
342         /**
343          * Access a property on the first matched element.
344          * This method makes it easy to retrieve a property value
345          * from the first matched element.
346          *
347          * @example $("img").attr("src");
348          * @before <img src="test.jpg"/>
349          * @result test.jpg
350          * @desc Returns the src attribute from the first image in the document.
351          *
352          * @name attr
353          * @type Object
354          * @param String name The name of the property to access.
355          * @cat DOM/Attributes
356          */
357
358         /**
359          * Set a key/value object as properties to all matched elements.
360          *
361          * This serves as the best way to set a large number of properties
362          * on all matched elements.
363          *
364          * @example $("img").attr({ src: "test.jpg", alt: "Test Image" });
365          * @before <img/>
366          * @result <img src="test.jpg" alt="Test Image"/>
367          * @desc Sets src and alt attributes to all images.
368          *
369          * @name attr
370          * @type jQuery
371          * @param Map properties Key/value pairs to set as object properties.
372          * @cat DOM/Attributes
373          */
374
375         /**
376          * Set a single property to a value, on all matched elements.
377          *
378          * Can compute values provided as ${formula}, see second example.
379          *
380          * Note that you can't set the name property of input elements in IE.
381          * Use $(html) or .append(html) or .html(html) to create elements
382          * on the fly including the name property.
383          *
384          * @example $("img").attr("src","test.jpg");
385          * @before <img/>
386          * @result <img src="test.jpg"/>
387          * @desc Sets src attribute to all images.
388          *
389          * @example $("img").attr("title", "${this.src}");
390          * @before <img src="test.jpg" />
391          * @result <img src="test.jpg" title="test.jpg" />
392          * @desc Sets title attribute from src attribute, a shortcut for attr(String,Function)
393          *
394          * @name attr
395          * @type jQuery
396          * @param String key The name of the property to set.
397          * @param Object value The value to set the property to.
398          * @cat DOM/Attributes
399          */
400          
401         /**
402          * Set a single property to a computed value, on all matched elements.
403          *
404          * Instead of a value, a function is provided, that computes the value.
405          *
406          * @example $("img").attr("title", function() { return this.src });
407          * @before <img src="test.jpg" />
408          * @result <img src="test.jpg" title="test.jpg" />
409          * @desc Sets title attribute from src attribute.
410          *
411          * @name attr
412          * @type jQuery
413          * @param String key The name of the property to set.
414          * @param Function value A function returning the value to set.
415          * @cat DOM/Attributes
416          */
417         attr: function( key, value, type ) {
418                 var obj = key;
419                 
420                 // Look for the case where we're accessing a style value
421                 if ( key.constructor == String )
422                         if ( value == undefined )
423                                 return jQuery[ type || "attr" ]( this[0], key );
424                         else {
425                                 obj = {};
426                                 obj[ key ] = value;
427                         }
428                 
429                 // Check to see if we're setting style values
430                 return this.each(function(){
431                         // Set all the styles
432                         for ( var prop in obj )
433                                 jQuery.attr(
434                                         type ? this.style : this,
435                                         prop, jQuery.prop(this, obj[prop], type)
436                                 );
437                 });
438         },
439
440         /**
441          * Access a style property on the first matched element.
442          * This method makes it easy to retrieve a style property value
443          * from the first matched element.
444          *
445          * @example $("p").css("color");
446          * @before <p style="color:red;">Test Paragraph.</p>
447          * @result "red"
448          * @desc Retrieves the color style of the first paragraph
449          *
450          * @example $("p").css("font-weight");
451          * @before <p style="font-weight: bold;">Test Paragraph.</p>
452          * @result "bold"
453          * @desc Retrieves the font-weight style of the first paragraph.
454          *
455          * @name css
456          * @type String
457          * @param String name The name of the property to access.
458          * @cat CSS
459          */
460
461         /**
462          * Set a key/value object as style properties to all matched elements.
463          *
464          * This serves as the best way to set a large number of style properties
465          * on all matched elements.
466          *
467          * @example $("p").css({ color: "red", background: "blue" });
468          * @before <p>Test Paragraph.</p>
469          * @result <p style="color:red; background:blue;">Test Paragraph.</p>
470          * @desc Sets color and background styles to all p elements.
471          *
472          * @name css
473          * @type jQuery
474          * @param Map properties Key/value pairs to set as style properties.
475          * @cat CSS
476          */
477
478         /**
479          * Set a single style property to a value, on all matched elements.
480          * If a number is provided, it is automatically converted into a pixel value.
481          *
482          * @example $("p").css("color","red");
483          * @before <p>Test Paragraph.</p>
484          * @result <p style="color:red;">Test Paragraph.</p>
485          * @desc Changes the color of all paragraphs to red
486          *
487          * @example $("p").css("left",30);
488          * @before <p>Test Paragraph.</p>
489          * @result <p style="left:30px;">Test Paragraph.</p>
490          * @desc Changes the left of all paragraphs to "30px"
491          *
492          * @name css
493          * @type jQuery
494          * @param String key The name of the property to set.
495          * @param String|Number value The value to set the property to.
496          * @cat CSS
497          */
498         css: function( key, value ) {
499                 return this.attr( key, value, "curCSS" );
500         },
501
502         /**
503          * Get the text contents of all matched elements. The result is
504          * a string that contains the combined text contents of all matched
505          * elements. This method works on both HTML and XML documents.
506          *
507          * @example $("p").text();
508          * @before <p><b>Test</b> Paragraph.</p><p>Paraparagraph</p>
509          * @result Test Paragraph.Paraparagraph
510          * @desc Gets the concatenated text of all paragraphs
511          *
512          * @name text
513          * @type String
514          * @cat DOM/Attributes
515          */
516
517         /**
518          * Set the text contents of all matched elements.
519          *
520          * Similar to html(), but escapes HTML (replace "<" and ">" with their
521          * HTML entities).
522          *
523          * @example $("p").text("<b>Some</b> new text.");
524          * @before <p>Test Paragraph.</p>
525          * @result <p>&lt;b&gt;Some&lt;/b&gt; new text.</p>
526          * @desc Sets the text of all paragraphs.
527          *
528          * @example $("p").text("<b>Some</b> new text.", true);
529          * @before <p>Test Paragraph.</p>
530          * @result <p>Some new text.</p>
531          * @desc Sets the text of all paragraphs.
532          *
533          * @name text
534          * @type String
535          * @param String val The text value to set the contents of the element to.
536          * @cat DOM/Attributes
537          */
538         text: function(e) {
539                 var type = this.length && this[0].innerText == undefined ?
540                         "textContent" : "innerText";
541                         
542                 return e == undefined ?
543                         this.length && this[0][ type ] :
544                         this.each(function(){ this[ type ] = e; });
545         },
546
547         /**
548          * Wrap all matched elements with a structure of other elements.
549          * This wrapping process is most useful for injecting additional
550          * stucture into a document, without ruining the original semantic
551          * qualities of a document.
552          *
553          * This works by going through the first element
554          * provided (which is generated, on the fly, from the provided HTML)
555          * and finds the deepest ancestor element within its
556          * structure - it is that element that will en-wrap everything else.
557          *
558          * This does not work with elements that contain text. Any necessary text
559          * must be added after the wrapping is done.
560          *
561          * @example $("p").wrap("<div class='wrap'></div>");
562          * @before <p>Test Paragraph.</p>
563          * @result <div class='wrap'><p>Test Paragraph.</p></div>
564          * 
565          * @name wrap
566          * @type jQuery
567          * @param String html A string of HTML, that will be created on the fly and wrapped around the target.
568          * @cat DOM/Manipulation
569          */
570
571         /**
572          * Wrap all matched elements with a structure of other elements.
573          * This wrapping process is most useful for injecting additional
574          * stucture into a document, without ruining the original semantic
575          * qualities of a document.
576          *
577          * This works by going through the first element
578          * provided and finding the deepest ancestor element within its
579          * structure - it is that element that will en-wrap everything else.
580          *
581          * This does not work with elements that contain text. Any necessary text
582          * must be added after the wrapping is done.
583          *
584          * @example $("p").wrap( document.getElementById('content') );
585          * @before <p>Test Paragraph.</p><div id="content"></div>
586          * @result <div id="content"><p>Test Paragraph.</p></div>
587          *
588          * @name wrap
589          * @type jQuery
590          * @param Element elem A DOM element that will be wrapped around the target.
591          * @cat DOM/Manipulation
592          */
593         wrap: function() {
594                 // The elements to wrap the target around
595                 var a = jQuery.clean(arguments);
596
597                 // Wrap each of the matched elements individually
598                 return this.each(function(){
599                         // Clone the structure that we're using to wrap
600                         var b = a[0].cloneNode(true);
601
602                         // Insert it before the element to be wrapped
603                         this.parentNode.insertBefore( b, this );
604
605                         // Find the deepest point in the wrap structure
606                         while ( b.firstChild )
607                                 b = b.firstChild;
608
609                         // Move the matched element to within the wrap structure
610                         b.appendChild( this );
611                 });
612         },
613
614         /**
615          * Append content to the inside of every matched element.
616          *
617          * This operation is similar to doing an appendChild to all the
618          * specified elements, adding them into the document.
619          *
620          * @example $("p").append("<b>Hello</b>");
621          * @before <p>I would like to say: </p>
622          * @result <p>I would like to say: <b>Hello</b></p>
623          * @desc Appends some HTML to all paragraphs.
624          *
625          * @example $("p").append( $("#foo")[0] );
626          * @before <p>I would like to say: </p><b id="foo">Hello</b>
627          * @result <p>I would like to say: <b id="foo">Hello</b></p>
628          * @desc Appends an Element to all paragraphs.
629          *
630          * @example $("p").append( $("b") );
631          * @before <p>I would like to say: </p><b>Hello</b>
632          * @result <p>I would like to say: <b>Hello</b></p>
633          * @desc Appends a jQuery object (similar to an Array of DOM Elements) to all paragraphs.
634          *
635          * @name append
636          * @type jQuery
637          * @param <Content> content Content to append to the target
638          * @cat DOM/Manipulation
639          * @see prepend(<Content>)
640          * @see before(<Content>)
641          * @see after(<Content>)
642          */
643         append: function() {
644                 return this.domManip(arguments, true, 1, function(a){
645                         this.appendChild( a );
646                 });
647         },
648
649         /**
650          * Prepend content to the inside of every matched element.
651          *
652          * This operation is the best way to insert elements
653          * inside, at the beginning, of all matched elements.
654          *
655          * @example $("p").prepend("<b>Hello</b>");
656          * @before <p>I would like to say: </p>
657          * @result <p><b>Hello</b>I would like to say: </p>
658          * @desc Prepends some HTML to all paragraphs.
659          *
660          * @example $("p").prepend( $("#foo")[0] );
661          * @before <p>I would like to say: </p><b id="foo">Hello</b>
662          * @result <p><b id="foo">Hello</b>I would like to say: </p>
663          * @desc Prepends an Element to all paragraphs.
664          *      
665          * @example $("p").prepend( $("b") );
666          * @before <p>I would like to say: </p><b>Hello</b>
667          * @result <p><b>Hello</b>I would like to say: </p>
668          * @desc Prepends a jQuery object (similar to an Array of DOM Elements) to all paragraphs.
669          *
670          * @name prepend
671          * @type jQuery
672          * @param <Content> content Content to prepend to the target.
673          * @cat DOM/Manipulation
674          * @see append(<Content>)
675          * @see before(<Content>)
676          * @see after(<Content>)
677          */
678         prepend: function() {
679                 return this.domManip(arguments, true, -1, function(a){
680                         this.insertBefore( a, this.firstChild );
681                 });
682         },
683         
684         /**
685          * Insert content before each of the matched elements.
686          *
687          * @example $("p").before("<b>Hello</b>");
688          * @before <p>I would like to say: </p>
689          * @result <b>Hello</b><p>I would like to say: </p>
690          * @desc Inserts some HTML before all paragraphs.
691          *
692          * @example $("p").before( $("#foo")[0] );
693          * @before <p>I would like to say: </p><b id="foo">Hello</b>
694          * @result <b id="foo">Hello</b><p>I would like to say: </p>
695          * @desc Inserts an Element before all paragraphs.
696          *
697          * @example $("p").before( $("b") );
698          * @before <p>I would like to say: </p><b>Hello</b>
699          * @result <b>Hello</b><p>I would like to say: </p>
700          * @desc Inserts a jQuery object (similar to an Array of DOM Elements) before all paragraphs.
701          *
702          * @name before
703          * @type jQuery
704          * @param <Content> content Content to insert before each target.
705          * @cat DOM/Manipulation
706          * @see append(<Content>)
707          * @see prepend(<Content>)
708          * @see after(<Content>)
709          */
710         before: function() {
711                 return this.domManip(arguments, false, 1, function(a){
712                         this.parentNode.insertBefore( a, this );
713                 });
714         },
715
716         /**
717          * Insert content after each of the matched elements.
718          *
719          * @example $("p").after("<b>Hello</b>");
720          * @before <p>I would like to say: </p>
721          * @result <p>I would like to say: </p><b>Hello</b>
722          * @desc Inserts some HTML after all paragraphs.
723          *
724          * @example $("p").after( $("#foo")[0] );
725          * @before <b id="foo">Hello</b><p>I would like to say: </p>
726          * @result <p>I would like to say: </p><b id="foo">Hello</b>
727          * @desc Inserts an Element after all paragraphs.
728          *
729          * @example $("p").after( $("b") );
730          * @before <b>Hello</b><p>I would like to say: </p>
731          * @result <p>I would like to say: </p><b>Hello</b>
732          * @desc Inserts a jQuery object (similar to an Array of DOM Elements) after all paragraphs.
733          *
734          * @name after
735          * @type jQuery
736          * @param <Content> content Content to insert after each target.
737          * @cat DOM/Manipulation
738          * @see append(<Content>)
739          * @see prepend(<Content>)
740          * @see before(<Content>)
741          */
742         after: function() {
743                 return this.domManip(arguments, false, -1, function(a){
744                         this.parentNode.insertBefore( a, this.nextSibling );
745                 });
746         },
747
748         /**
749          * End the most recent 'destructive' operation, reverting the list of matched elements
750          * back to its previous state. After an end operation, the list of matched elements will
751          * revert to the last state of matched elements.
752          *
753          * If there was no destructive operation before, an empty set is returned.
754          *
755          * @example $("p").find("span").end();
756          * @before <p><span>Hello</span>, how are you?</p>
757          * @result [ <p>...</p> ]
758          * @desc Selects all paragraphs, finds span elements inside these, and reverts the
759          * selection back to the paragraphs.
760          *
761          * @name end
762          * @type jQuery
763          * @cat DOM/Traversing
764          */
765         end: function() {
766                 return this.prevObject || jQuery([]);
767         },
768
769         /**
770          * Searches for all elements that match the specified expression.
771          
772          * This method is a good way to find additional descendant
773          * elements with which to process.
774          *
775          * All searching is done using a jQuery expression. The expression can be
776          * written using CSS 1-3 Selector syntax, or basic XPath.
777          *
778          * @example $("p").find("span");
779          * @before <p><span>Hello</span>, how are you?</p>
780          * @result [ <span>Hello</span> ]
781          * @desc Starts with all paragraphs and searches for descendant span
782          * elements, same as $("p span")
783          *
784          * @name find
785          * @type jQuery
786          * @param String expr An expression to search with.
787          * @cat DOM/Traversing
788          */
789         find: function(t) {
790                 return this.pushStack( jQuery.map( this, function(a){
791                         return jQuery.find(t,a);
792                 }) );
793         },
794
795         /**
796          * Clone matched DOM Elements and select the clones. 
797          *
798          * This is useful for moving copies of the elements to another
799          * location in the DOM.
800          *
801          * @example $("b").clone().prependTo("p");
802          * @before <b>Hello</b><p>, how are you?</p>
803          * @result <b>Hello</b><p><b>Hello</b>, how are you?</p>
804          * @desc Clones all b elements (and selects the clones) and prepends them to all paragraphs.
805          *
806          * @name clone
807          * @type jQuery
808          * @cat DOM/Manipulation
809          */
810         clone: function(deep) {
811                 return this.pushStack( jQuery.map( this, function(a){
812                         return a.cloneNode( deep != undefined ? deep : true );
813                 }) );
814         },
815
816         /**
817          * Removes all elements from the set of matched elements that do not
818          * match the specified expression(s). This method is used to narrow down
819          * the results of a search.
820          *
821          * Provide a comma-separated list of expressions to apply multiple filters at once.
822          *
823          * @example $("p").filter(".selected")
824          * @before <p class="selected">Hello</p><p>How are you?</p>
825          * @result [ <p class="selected">Hello</p> ]
826          * @desc Selects all paragraphs and removes those without a class "selected".
827          *
828          * @example $("p").filter(".selected, :first")
829          * @before <p>Hello</p><p>Hello Again</p><p class="selected">And Again</p>
830          * @result [ <p>Hello</p>, <p class="selected">And Again</p> ]
831          * @desc Selects all paragraphs and removes those without class "selected" and being the first one.
832          *
833          * @name filter
834          * @type jQuery
835          * @param String expression Expression(s) to search with.
836          * @cat DOM/Traversing
837          */
838          
839         /**
840          * Removes all elements from the set of matched elements that do not
841          * pass the specified filter. This method is used to narrow down
842          * the results of a search.
843          *
844          * @example $("p").filter(function(index) {
845          *   return $("ol", this).length == 0;
846          * })
847          * @before <p><ol><li>Hello</li></ol></p><p>How are you?</p>
848          * @result [ <p>How are you?</p> ]
849          * @desc Remove all elements that have a child ol element
850          *
851          * @name filter
852          * @type jQuery
853          * @param Function filter A function to use for filtering
854          * @cat DOM/Traversing
855          */
856         filter: function(t) {
857                 return this.pushStack(
858                         t.constructor == Function &&
859                         jQuery.grep(this, function(el, index){
860                                 return t.apply(el, [index])
861                         }) ||
862
863                         jQuery.multiFilter(t,this) );
864         },
865
866         /**
867          * Removes the specified Element from the set of matched elements. This
868          * method is used to remove a single Element from a jQuery object.
869          *
870          * @example $("p").not( $("#selected")[0] )
871          * @before <p>Hello</p><p id="selected">Hello Again</p>
872          * @result [ <p>Hello</p> ]
873          * @desc Removes the element with the ID "selected" from the set of all paragraphs.
874          *
875          * @name not
876          * @type jQuery
877          * @param Element el An element to remove from the set
878          * @cat DOM/Traversing
879          */
880
881         /**
882          * Removes elements matching the specified expression from the set
883          * of matched elements. This method is used to remove one or more
884          * elements from a jQuery object.
885          *
886          * @example $("p").not("#selected")
887          * @before <p>Hello</p><p id="selected">Hello Again</p>
888          * @result [ <p>Hello</p> ]
889          * @desc Removes the element with the ID "selected" from the set of all paragraphs.
890          *
891          * @name not
892          * @type jQuery
893          * @param String expr An expression with which to remove matching elements
894          * @cat DOM/Traversing
895          */
896
897         /**
898          * Removes any elements inside the array of elements from the set
899          * of matched elements. This method is used to remove one or more
900          * elements from a jQuery object.
901          *
902          * @example $("p").not( $("div p.selected") )
903          * @before <div><p>Hello</p><p class="selected">Hello Again</p></div>
904          * @result [ <p>Hello</p> ]
905          * @desc Removes all elements that match "div p.selected" from the total set of all paragraphs.
906          *
907          * @name not
908          * @type jQuery
909          * @param Array|jQuery elems A set of elements to remove from the jQuery set of matched elements.
910          * @cat DOM/Traversing
911          */
912         not: function(t) {
913                 return this.pushStack(
914                         t.constructor == String &&
915                         jQuery.multiFilter(t,this,true) ||
916
917                         jQuery.grep(this,function(a){
918                                         if ( t.constructor == Array || t.jquery )
919                                                 return !jQuery.inArray( t, a );
920                                         else
921                                                 return a != t;
922                         }) );
923         },
924
925         /**
926          * Adds the elements matched by the expression to the jQuery object. This
927          * can be used to concatenate the result sets of two expressions.
928          *
929          * @example $("p").add("span")
930          * @before <p>Hello</p><p><span>Hello Again</span></p>
931          * @result [ <p>Hello</p>, <span>Hello Again</span> ]
932          *
933          * @name add
934          * @type jQuery
935          * @param String expr An expression whose matched elements are added
936          * @cat DOM/Traversing
937          */
938          
939         /**
940          * Adds the on the fly created elements to the jQuery object.
941          *
942          * @example $("p").add("<span>Again</span>")
943          * @before <p>Hello</p>
944          * @result [ <p>Hello</p>, <span>Again</span> ]
945          *
946          * @name add
947          * @type jQuery
948          * @param String html A string of HTML to create on the fly.
949          * @cat DOM/Traversing
950          */
951
952         /**
953          * Adds one or more Elements to the set of matched elements.
954          *
955          * This is used to add a set of Elements to a jQuery object.
956          *
957          * @example $("p").add( document.getElementById("a") )
958          * @before <p>Hello</p><p><span id="a">Hello Again</span></p>
959          * @result [ <p>Hello</p>, <span id="a">Hello Again</span> ]
960          *
961          * @example $("p").add([document.getElementById("a"), document.getElementById("b")])
962          * @before <p>Hello</p><p><span id="a">Hello Again</span><span id="b">And Again</span></p>
963          * @result [ <p>Hello</p>, <span id="a">Hello Again</span>, <span id="b">And Again</span> ]
964          *
965          * @name add
966          * @type jQuery
967          * @param Element|Array<Element> elements One or more Elements to add
968          * @cat DOM/Traversing
969          */
970         add: function(t) {
971                 return this.pushStack( jQuery.merge(
972                         this.get(),
973                         typeof t == "string" ? jQuery(t).get() : t )
974                 );
975         },
976
977         /**
978          * Checks the current selection against an expression and returns true,
979          * if at least one element of the selection fits the given expression.
980          *
981          * Does return false, if no element fits or the expression is not valid.
982          *
983          * filter(String) is used internally, therefore all rules that apply there
984          * apply here, too.
985          *
986          * @example $("input[@type='checkbox']").parent().is("form")
987          * @before <form><input type="checkbox" /></form>
988          * @result true
989          * @desc Returns true, because the parent of the input is a form element
990          * 
991          * @example $("input[@type='checkbox']").parent().is("form")
992          * @before <form><p><input type="checkbox" /></p></form>
993          * @result false
994          * @desc Returns false, because the parent of the input is a p element
995          *
996          * @name is
997          * @type Boolean
998          * @param String expr The expression with which to filter
999          * @cat DOM/Traversing
1000          */
1001         is: function(expr) {
1002                 return expr ? jQuery.filter(expr,this).r.length > 0 : false;
1003         },
1004         
1005         /**
1006          * Get the current value of the first matched element.
1007          *
1008          * @example $("input").val();
1009          * @before <input type="text" value="some text"/>
1010          * @result "some text"
1011          *
1012          * @name val
1013          * @type String
1014          * @cat DOM/Attributes
1015          */
1016         
1017         /**
1018          * Set the value of every matched element.
1019          *
1020          * @example $("input").val("test");
1021          * @before <input type="text" value="some text"/>
1022          * @result <input type="text" value="test"/>
1023          *
1024          * @name val
1025          * @type jQuery
1026          * @param String val Set the property to the specified value.
1027          * @cat DOM/Attributes
1028          */
1029         val: function( val ) {
1030                 return val == undefined ?
1031                         ( this.length ? this[0].value : null ) :
1032                         this.attr( "value", val );
1033         },
1034         
1035         /**
1036          * Get the html contents of the first matched element.
1037          * This property is not available on XML documents.
1038          *
1039          * @example $("div").html();
1040          * @before <div><input/></div>
1041          * @result <input/>
1042          *
1043          * @name html
1044          * @type String
1045          * @cat DOM/Attributes
1046          */
1047         
1048         /**
1049          * Set the html contents of every matched element.
1050          * This property is not available on XML documents.
1051          *
1052          * @example $("div").html("<b>new stuff</b>");
1053          * @before <div><input/></div>
1054          * @result <div><b>new stuff</b></div>
1055          *
1056          * @name html
1057          * @type jQuery
1058          * @param String val Set the html contents to the specified value.
1059          * @cat DOM/Attributes
1060          */
1061         html: function( val ) {
1062                 return val == undefined ?
1063                         ( this.length ? this[0].innerHTML : null ) :
1064                         this.empty().append( val );
1065         },
1066         
1067         /**
1068          * @private
1069          * @name domManip
1070          * @param Array args
1071          * @param Boolean table Insert TBODY in TABLEs if one is not found.
1072          * @param Number dir If dir<0, process args in reverse order.
1073          * @param Function fn The function doing the DOM manipulation.
1074          * @type jQuery
1075          * @cat Core
1076          */
1077         domManip: function(args, table, dir, fn){
1078                 var clone = this.length > 1; 
1079                 var a = jQuery.clean(args);
1080                 if ( dir < 0 )
1081                         a.reverse();
1082
1083                 return this.each(function(){
1084                         var obj = this;
1085
1086                         if ( table && this.nodeName.toUpperCase() == "TABLE" && a[0].nodeName.toUpperCase() == "TR" )
1087                                 obj = this.getElementsByTagName("tbody")[0] || this.appendChild(document.createElement("tbody"));
1088
1089                         for ( var i = 0, al = a.length; i < al; i++ )
1090                                 fn.apply( obj, [ clone ? a[i].cloneNode(true) : a[i] ] );
1091
1092                 });
1093         }
1094 };
1095
1096 /**
1097  * Extends the jQuery object itself. Can be used to add functions into
1098  * the jQuery namespace and to add plugin methods (plugins).
1099  * 
1100  * @example jQuery.fn.extend({
1101  *   check: function() {
1102  *     return this.each(function() { this.checked = true; });
1103  *   },
1104  *   uncheck: function() {
1105  *     return this.each(function() { this.checked = false; });
1106  *   }
1107  * });
1108  * $("input[@type=checkbox]").check();
1109  * $("input[@type=radio]").uncheck();
1110  * @desc Adds two plugin methods.
1111  *
1112  * @example jQuery.extend({
1113  *   min: function(a, b) { return a < b ? a : b; },
1114  *   max: function(a, b) { return a > b ? a : b; }
1115  * });
1116  * @desc Adds two functions into the jQuery namespace
1117  *
1118  * @name $.extend
1119  * @param Object prop The object that will be merged into the jQuery object
1120  * @type Object
1121  * @cat Core
1122  */
1123
1124 /**
1125  * Extend one object with one or more others, returning the original,
1126  * modified, object. This is a great utility for simple inheritance.
1127  * 
1128  * @example var settings = { validate: false, limit: 5, name: "foo" };
1129  * var options = { validate: true, name: "bar" };
1130  * jQuery.extend(settings, options);
1131  * @result settings == { validate: true, limit: 5, name: "bar" }
1132  * @desc Merge settings and options, modifying settings
1133  *
1134  * @example var defaults = { validate: false, limit: 5, name: "foo" };
1135  * var options = { validate: true, name: "bar" };
1136  * var settings = jQuery.extend({}, defaults, options);
1137  * @result settings == { validate: true, limit: 5, name: "bar" }
1138  * @desc Merge defaults and options, without modifying the defaults
1139  *
1140  * @name $.extend
1141  * @param Object target The object to extend
1142  * @param Object prop1 The object that will be merged into the first.
1143  * @param Object propN (optional) More objects to merge into the first
1144  * @type Object
1145  * @cat JavaScript
1146  */
1147 jQuery.extend = jQuery.fn.extend = function() {
1148         // copy reference to target object
1149         var target = arguments[0],
1150                 a = 1;
1151
1152         // extend jQuery itself if only one argument is passed
1153         if ( arguments.length == 1 ) {
1154                 target = this;
1155                 a = 0;
1156         }
1157         var prop;
1158         while (prop = arguments[a++])
1159                 // Extend the base object
1160                 for ( var i in prop ) target[i] = prop[i];
1161
1162         // Return the modified object
1163         return target;
1164 };
1165
1166 jQuery.extend({
1167         /**
1168          * Run this function to give control of the $ variable back
1169          * to whichever library first implemented it. This helps to make 
1170          * sure that jQuery doesn't conflict with the $ object
1171          * of other libraries.
1172          *
1173          * By using this function, you will only be able to access jQuery
1174          * using the 'jQuery' variable. For example, where you used to do
1175          * $("div p"), you now must do jQuery("div p").
1176          *
1177          * @example jQuery.noConflict();
1178          * // Do something with jQuery
1179          * jQuery("div p").hide();
1180          * // Do something with another library's $()
1181          * $("content").style.display = 'none';
1182          * @desc Maps the original object that was referenced by $ back to $
1183          *
1184          * @example jQuery.noConflict();
1185          * (function($) { 
1186          *   $(function() {
1187          *     // more code using $ as alias to jQuery
1188          *   });
1189          * })(jQuery);
1190          * // other code using $ as an alias to the other library
1191          * @desc Reverts the $ alias and then creates and executes a
1192          * function to provide the $ as a jQuery alias inside the functions
1193          * scope. Inside the function the original $ object is not available.
1194          * This works well for most plugins that don't rely on any other library.
1195          * 
1196          *
1197          * @name $.noConflict
1198          * @type undefined
1199          * @cat Core 
1200          */
1201         noConflict: function() {
1202                 if ( jQuery._$ )
1203                         $ = jQuery._$;
1204         },
1205
1206         /**
1207          * A generic iterator function, which can be used to seemlessly
1208          * iterate over both objects and arrays. This function is not the same
1209          * as $().each() - which is used to iterate, exclusively, over a jQuery
1210          * object. This function can be used to iterate over anything.
1211          *
1212          * The callback has two arguments:the key (objects) or index (arrays) as first
1213          * the first, and the value as the second.
1214          *
1215          * @example $.each( [0,1,2], function(i, n){
1216          *   alert( "Item #" + i + ": " + n );
1217          * });
1218          * @desc This is an example of iterating over the items in an array,
1219          * accessing both the current item and its index.
1220          *
1221          * @example $.each( { name: "John", lang: "JS" }, function(i, n){
1222          *   alert( "Name: " + i + ", Value: " + n );
1223          * });
1224          *
1225          * @desc This is an example of iterating over the properties in an
1226          * Object, accessing both the current item and its key.
1227          *
1228          * @name $.each
1229          * @param Object obj The object, or array, to iterate over.
1230          * @param Function fn The function that will be executed on every object.
1231          * @type Object
1232          * @cat JavaScript
1233          */
1234         // args is for internal usage only
1235         each: function( obj, fn, args ) {
1236                 if ( obj.length == undefined )
1237                         for ( var i in obj )
1238                                 fn.apply( obj[i], args || [i, obj[i]] );
1239                 else
1240                         for ( var i = 0, ol = obj.length; i < ol; i++ )
1241                                 if ( fn.apply( obj[i], args || [i, obj[i]] ) === false ) break;
1242                 return obj;
1243         },
1244         
1245         prop: function(elem, value, type){
1246                         // Handle executable functions
1247                         if ( value.constructor == Function )
1248                                 return value.call( elem )
1249
1250                         // Handle passing in a number to a CSS property
1251                         if ( value.constructor == Number && type == "css" )
1252                                 return value + "px";
1253
1254                         return value;
1255         },
1256
1257         className: {
1258                 // internal only, use addClass("class")
1259                 add: function( elem, c ){
1260                         jQuery.each( c.split(/\s+/), function(i, cur){
1261                                 if ( !jQuery.className.has( elem.className, cur ) )
1262                                         elem.className += ( elem.className ? " " : "" ) + cur;
1263                         });
1264                 },
1265
1266                 // internal only, use removeClass("class")
1267                 remove: function( elem, c ){
1268                         elem.className = c ?
1269                                 jQuery.grep( elem.className.split(/\s+/), function(cur){
1270                                         return !jQuery.className.has( c, cur ); 
1271                                 }).join(' ') : "";
1272                 },
1273
1274                 // internal only, use is(".class")
1275                 has: function( t, c ) {
1276                         t = t.className || t;
1277                         return t && new RegExp("(^|\\s)" + c + "(\\s|$)").test( t );
1278                 }
1279         },
1280
1281         /**
1282          * Swap in/out style options.
1283          * @private
1284          */
1285         swap: function(e,o,f) {
1286                 for ( var i in o ) {
1287                         e.style["old"+i] = e.style[i];
1288                         e.style[i] = o[i];
1289                 }
1290                 f.apply( e, [] );
1291                 for ( var i in o )
1292                         e.style[i] = e.style["old"+i];
1293         },
1294
1295         css: function(e,p) {
1296                 if ( p == "height" || p == "width" ) {
1297                         var old = {}, oHeight, oWidth, d = ["Top","Bottom","Right","Left"];
1298
1299                         for ( var i = 0, dl = d.length; i < dl; i++ ) {
1300                                 old["padding" + d[i]] = 0;
1301                                 old["border" + d[i] + "Width"] = 0;
1302                         }
1303
1304                         jQuery.swap( e, old, function() {
1305                                 if (jQuery.css(e,"display") != "none") {
1306                                         oHeight = e.offsetHeight;
1307                                         oWidth = e.offsetWidth;
1308                                 } else {
1309                                         e = jQuery(e.cloneNode(true))
1310                                                 .find(":radio").removeAttr("checked").end()
1311                                                 .css({
1312                                                         visibility: "hidden", position: "absolute", display: "block", right: "0", left: "0"
1313                                                 }).appendTo(e.parentNode)[0];
1314
1315                                         var parPos = jQuery.css(e.parentNode,"position");
1316                                         if ( parPos == "" || parPos == "static" )
1317                                                 e.parentNode.style.position = "relative";
1318
1319                                         oHeight = e.clientHeight;
1320                                         oWidth = e.clientWidth;
1321
1322                                         if ( parPos == "" || parPos == "static" )
1323                                                 e.parentNode.style.position = "static";
1324
1325                                         e.parentNode.removeChild(e);
1326                                 }
1327                         });
1328
1329                         return p == "height" ? oHeight : oWidth;
1330                 }
1331
1332                 return jQuery.curCSS( e, p );
1333         },
1334
1335         curCSS: function(elem, prop, force) {
1336                 var ret;
1337                 
1338                 if (prop == 'opacity' && jQuery.browser.msie)
1339                         return jQuery.attr(elem.style, 'opacity');
1340                         
1341                 if (prop == "float" || prop == "cssFloat")
1342                     prop = jQuery.browser.msie ? "styleFloat" : "cssFloat";
1343
1344                 if (!force && elem.style[prop])
1345                         ret = elem.style[prop];
1346
1347                 else if (document.defaultView && document.defaultView.getComputedStyle) {
1348
1349                         if (prop == "cssFloat" || prop == "styleFloat")
1350                                 prop = "float";
1351
1352                         prop = prop.replace(/([A-Z])/g,"-$1").toLowerCase();
1353                         var cur = document.defaultView.getComputedStyle(elem, null);
1354
1355                         if ( cur )
1356                                 ret = cur.getPropertyValue(prop);
1357                         else if ( prop == 'display' )
1358                                 ret = 'none';
1359                         else
1360                                 jQuery.swap(elem, { display: 'block' }, function() {
1361                                     var c = document.defaultView.getComputedStyle(this, '');
1362                                     ret = c && c.getPropertyValue(prop) || '';
1363                                 });
1364
1365                 } else if (elem.currentStyle) {
1366
1367                         var newProp = prop.replace(/\-(\w)/g,function(m,c){return c.toUpperCase();});
1368                         ret = elem.currentStyle[prop] || elem.currentStyle[newProp];
1369                         
1370                 }
1371
1372                 return ret;
1373         },
1374         
1375         clean: function(a) {
1376                 var r = [];
1377                 
1378                 for ( var i = 0, al = a.length; i < al; i++ ) {
1379                         var arg = a[i];
1380                         
1381                          // Convert html string into DOM nodes
1382                         if ( typeof arg == "string" ) {
1383                                 // Trim whitespace, otherwise indexOf won't work as expected
1384                                 var s = jQuery.trim(arg), div = document.createElement("div"), tb = [];
1385
1386                                 var wrap =
1387                                          // option or optgroup
1388                                         !s.indexOf("<opt") &&
1389                                         [1, "<select>", "</select>"] ||
1390                                         
1391                                         (!s.indexOf("<thead") || !s.indexOf("<tbody") || !s.indexOf("<tfoot")) &&
1392                                         [1, "<table>", "</table>"] ||
1393                                         
1394                                         !s.indexOf("<tr") &&
1395                                         [2, "<table><tbody>", "</tbody></table>"] ||
1396                                         
1397                                         // <thead> matched above
1398                                         (!s.indexOf("<td") || !s.indexOf("<th")) &&
1399                                         [3, "<table><tbody><tr>", "</tr></tbody></table>"] ||
1400                                         
1401                                         [0,"",""];
1402
1403                                 // Go to html and back, then peel off extra wrappers
1404                                 div.innerHTML = wrap[1] + s + wrap[2];
1405                                 
1406                                 // Move to the right depth
1407                                 while ( wrap[0]-- )
1408                                         div = div.firstChild;
1409                                 
1410                                 // Remove IE's autoinserted <tbody> from table fragments
1411                                 if ( jQuery.browser.msie ) {
1412                                         
1413                                         // String was a <table>, *may* have spurious <tbody>
1414                                         if ( !s.indexOf("<table") && s.indexOf("<tbody") < 0 ) 
1415                                                 tb = div.firstChild && div.firstChild.childNodes;
1416                                                 
1417                                         // String was a bare <thead> or <tfoot>
1418                                         else if ( wrap[1] == "<table>" && s.indexOf("<tbody") < 0 )
1419                                                 tb = div.childNodes;
1420
1421                                         for ( var n = tb.length-1; n >= 0 ; --n )
1422                                                 if ( tb[n].nodeName.toUpperCase() == "TBODY" && !tb[n].childNodes.length )
1423                                                         tb[n].parentNode.removeChild(tb[n]);
1424                                         
1425                                 }
1426                                 
1427                                 arg = div.childNodes;
1428                         }
1429                         
1430                         if ( arg.nodeType )
1431                                 r.push( arg );
1432                         else
1433                                 r = jQuery.merge( r, arg );
1434
1435                 }
1436
1437                 return r;
1438         },
1439         
1440         attr: function(elem, name, value){
1441                 var fix = {
1442                         "for": "htmlFor",
1443                         "class": "className",
1444                         "float": jQuery.browser.msie ? "styleFloat" : "cssFloat",
1445                         cssFloat: jQuery.browser.msie ? "styleFloat" : "cssFloat",
1446                         innerHTML: "innerHTML",
1447                         className: "className",
1448                         value: "value",
1449                         disabled: "disabled",
1450                         checked: "checked",
1451                         readonly: "readOnly",
1452                         selected: "selected"
1453                 };
1454                 
1455                 // IE actually uses filters for opacity ... elem is actually elem.style
1456                 if ( name == "opacity" && jQuery.browser.msie && value != undefined ) {
1457                         // IE has trouble with opacity if it does not have layout
1458                         // Force it by setting the zoom level
1459                         elem.zoom = 1; 
1460
1461                         // Set the alpha filter to set the opacity
1462                         return elem.filter = elem.filter.replace(/alpha\([^\)]*\)/gi,"") +
1463                                 ( value == 1 ? "" : "alpha(opacity=" + value * 100 + ")" );
1464
1465                 } else if ( name == "opacity" && jQuery.browser.msie )
1466                         return elem.filter ? 
1467                                 parseFloat( elem.filter.match(/alpha\(opacity=(.*)\)/)[1] ) / 100 : 1;
1468                 
1469                 // Mozilla doesn't play well with opacity 1
1470                 if ( name == "opacity" && jQuery.browser.mozilla && value == 1 )
1471                         value = 0.9999;
1472
1473                 // Certain attributes only work when accessed via the old DOM 0 way
1474                 if ( fix[name] ) {
1475                         if ( value != undefined ) elem[fix[name]] = value;
1476                         return elem[fix[name]];
1477
1478                 } else if ( value == undefined && jQuery.browser.msie && elem.nodeName && elem.nodeName.toUpperCase() == 'FORM' && (name == 'action' || name == 'method') )
1479                         return elem.getAttributeNode(name).nodeValue;
1480
1481                 // IE elem.getAttribute passes even for style
1482                 else if ( elem.tagName ) {
1483                         if ( value != undefined ) elem.setAttribute( name, value );
1484                         return elem.getAttribute( name );
1485
1486                 } else {
1487                         name = name.replace(/-([a-z])/ig,function(z,b){return b.toUpperCase();});
1488                         if ( value != undefined ) elem[name] = value;
1489                         return elem[name];
1490                 }
1491         },
1492         
1493         /**
1494          * Remove the whitespace from the beginning and end of a string.
1495          *
1496          * @example $.trim("  hello, how are you?  ");
1497          * @result "hello, how are you?"
1498          *
1499          * @name $.trim
1500          * @type String
1501          * @param String str The string to trim.
1502          * @cat JavaScript
1503          */
1504         trim: function(t){
1505                 return t.replace(/^\s+|\s+$/g, "");
1506         },
1507
1508         makeArray: function( a ) {
1509                 var r = [];
1510
1511                 if ( a.constructor != Array )
1512                         for ( var i = 0, al = a.length; i < al; i++ )
1513                                 r.push( a[i] );
1514                 else
1515                         r = a.slice( 0 );
1516
1517                 return r;
1518         },
1519
1520         inArray: function( b, a ) {
1521                 for ( var i = 0, al = a.length; i < al; i++ )
1522                         if ( a[i] == b )
1523                                 return i;
1524                 return -1;
1525         },
1526
1527         /**
1528          * Merge two arrays together, removing all duplicates.
1529          *
1530          * The new array is: All the results from the first array, followed
1531          * by the unique results from the second array.
1532          *
1533          * @example $.merge( [0,1,2], [2,3,4] )
1534          * @result [0,1,2,3,4]
1535          * @desc Merges two arrays, removing the duplicate 2
1536          *
1537          * @example $.merge( [3,2,1], [4,3,2] )
1538          * @result [3,2,1,4]
1539          * @desc Merges two arrays, removing the duplicates 3 and 2
1540          *
1541          * @name $.merge
1542          * @type Array
1543          * @param Array first The first array to merge.
1544          * @param Array second The second array to merge.
1545          * @cat JavaScript
1546          */
1547         merge: function(first, second) {
1548                 var r = [].slice.call( first, 0 );
1549
1550                 // Now check for duplicates between the two arrays
1551                 // and only add the unique items
1552                 for ( var i = 0, sl = second.length; i < sl; i++ )
1553                         // Check for duplicates
1554                         if ( jQuery.inArray( second[i], r ) == -1 )
1555                                 // The item is unique, add it
1556                                 first.push( second[i] );
1557
1558                 return first;
1559         },
1560
1561         /**
1562          * Filter items out of an array, by using a filter function.
1563          *
1564          * The specified function will be passed two arguments: The
1565          * current array item and the index of the item in the array. The
1566          * function must return 'true' to keep the item in the array, 
1567          * false to remove it.
1568          *
1569          * @example $.grep( [0,1,2], function(i){
1570          *   return i > 0;
1571          * });
1572          * @result [1, 2]
1573          *
1574          * @name $.grep
1575          * @type Array
1576          * @param Array array The Array to find items in.
1577          * @param Function fn The function to process each item against.
1578          * @param Boolean inv Invert the selection - select the opposite of the function.
1579          * @cat JavaScript
1580          */
1581         grep: function(elems, fn, inv) {
1582                 // If a string is passed in for the function, make a function
1583                 // for it (a handy shortcut)
1584                 if ( typeof fn == "string" )
1585                         fn = new Function("a","i","return " + fn);
1586
1587                 var result = [];
1588
1589                 // Go through the array, only saving the items
1590                 // that pass the validator function
1591                 for ( var i = 0, el = elems.length; i < el; i++ )
1592                         if ( !inv && fn(elems[i],i) || inv && !fn(elems[i],i) )
1593                                 result.push( elems[i] );
1594
1595                 return result;
1596         },
1597
1598         /**
1599          * Translate all items in an array to another array of items.
1600          *
1601          * The translation function that is provided to this method is 
1602          * called for each item in the array and is passed one argument: 
1603          * The item to be translated.
1604          *
1605          * The function can then return the translated value, 'null'
1606          * (to remove the item), or  an array of values - which will
1607          * be flattened into the full array.
1608          *
1609          * @example $.map( [0,1,2], function(i){
1610          *   return i + 4;
1611          * });
1612          * @result [4, 5, 6]
1613          * @desc Maps the original array to a new one and adds 4 to each value.
1614          *
1615          * @example $.map( [0,1,2], function(i){
1616          *   return i > 0 ? i + 1 : null;
1617          * });
1618          * @result [2, 3]
1619          * @desc Maps the original array to a new one and adds 1 to each
1620          * value if it is bigger then zero, otherwise it's removed-
1621          * 
1622          * @example $.map( [0,1,2], function(i){
1623          *   return [ i, i + 1 ];
1624          * });
1625          * @result [0, 1, 1, 2, 2, 3]
1626          * @desc Maps the original array to a new one, each element is added
1627          * with it's original value and the value plus one.
1628          *
1629          * @name $.map
1630          * @type Array
1631          * @param Array array The Array to translate.
1632          * @param Function fn The function to process each item against.
1633          * @cat JavaScript
1634          */
1635         map: function(elems, fn) {
1636                 // If a string is passed in for the function, make a function
1637                 // for it (a handy shortcut)
1638                 if ( typeof fn == "string" )
1639                         fn = new Function("a","return " + fn);
1640
1641                 var result = [], r = [];
1642
1643                 // Go through the array, translating each of the items to their
1644                 // new value (or values).
1645                 for ( var i = 0, el = elems.length; i < el; i++ ) {
1646                         var val = fn(elems[i],i);
1647
1648                         if ( val !== null && val != undefined ) {
1649                                 if ( val.constructor != Array ) val = [val];
1650                                 result = result.concat( val );
1651                         }
1652                 }
1653
1654                 var r = result.length ? [ result[0] ] : [];
1655
1656                 check: for ( var i = 1, rl = result.length; i < rl; i++ ) {
1657                         for ( var j = 0; j < i; j++ )
1658                                 if ( result[i] == r[j] )
1659                                         continue check;
1660
1661                         r.push( result[i] );
1662                 }
1663
1664                 return r;
1665         }
1666 });
1667
1668 /**
1669  * Contains flags for the useragent, read from navigator.userAgent.
1670  * Available flags are: safari, opera, msie, mozilla
1671  *
1672  * This property is available before the DOM is ready, therefore you can
1673  * use it to add ready events only for certain browsers.
1674  *
1675  * There are situations where object detections is not reliable enough, in that
1676  * cases it makes sense to use browser detection. Simply try to avoid both!
1677  *
1678  * A combination of browser and object detection yields quite reliable results.
1679  *
1680  * @example $.browser.msie
1681  * @desc Returns true if the current useragent is some version of microsoft's internet explorer
1682  *
1683  * @example if($.browser.safari) { $( function() { alert("this is safari!"); } ); }
1684  * @desc Alerts "this is safari!" only for safari browsers
1685  *
1686  * @property
1687  * @name $.browser
1688  * @type Boolean
1689  * @cat JavaScript
1690  */
1691  
1692 /*
1693  * Wheather the W3C compliant box model is being used.
1694  *
1695  * @property
1696  * @name $.boxModel
1697  * @type Boolean
1698  * @cat JavaScript
1699  */
1700 new function() {
1701         var b = navigator.userAgent.toLowerCase();
1702
1703         // Figure out what browser is being used
1704         jQuery.browser = {
1705                 safari: /webkit/.test(b),
1706                 opera: /opera/.test(b),
1707                 msie: /msie/.test(b) && !/opera/.test(b),
1708                 mozilla: /mozilla/.test(b) && !/(compatible|webkit)/.test(b)
1709         };
1710
1711         // Check to see if the W3C box model is being used
1712         jQuery.boxModel = !jQuery.browser.msie || document.compatMode == "CSS1Compat";
1713 };
1714
1715 /**
1716  * Get a set of elements containing the unique parents of the matched
1717  * set of elements.
1718  *
1719  * Can be filtered with an optional expressions.
1720  *
1721  * @example $("p").parent()
1722  * @before <div><p>Hello</p><p>Hello</p></div>
1723  * @result [ <div><p>Hello</p><p>Hello</p></div> ]
1724  * @desc Find the parent element of each paragraph.
1725  *
1726  * @example $("p").parent(".selected")
1727  * @before <div><p>Hello</p></div><div class="selected"><p>Hello Again</p></div>
1728  * @result [ <div class="selected"><p>Hello Again</p></div> ]
1729  * @desc Find the parent element of each paragraph with a class "selected".
1730  *
1731  * @name parent
1732  * @type jQuery
1733  * @param String expr (optional) An expression to filter the parents with
1734  * @cat DOM/Traversing
1735  */
1736
1737 /**
1738  * Get a set of elements containing the unique ancestors of the matched
1739  * set of elements (except for the root element).
1740  *
1741  * Can be filtered with an optional expressions.
1742  *
1743  * @example $("span").parents()
1744  * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html>
1745  * @result [ <body>...</body>, <div>...</div>, <p><span>Hello</span></p> ]
1746  * @desc Find all parent elements of each span.
1747  *
1748  * @example $("span").parents("p")
1749  * @before <html><body><div><p><span>Hello</span></p><span>Hello Again</span></div></body></html>
1750  * @result [ <p><span>Hello</span></p> ]
1751  * @desc Find all parent elements of each span that is a paragraph.
1752  *
1753  * @name parents
1754  * @type jQuery
1755  * @param String expr (optional) An expression to filter the ancestors with
1756  * @cat DOM/Traversing
1757  */
1758
1759 /**
1760  * Get a set of elements containing the unique next siblings of each of the
1761  * matched set of elements.
1762  *
1763  * It only returns the very next sibling, not all next siblings.
1764  *
1765  * Can be filtered with an optional expressions.
1766  *
1767  * @example $("p").next()
1768  * @before <p>Hello</p><p>Hello Again</p><div><span>And Again</span></div>
1769  * @result [ <p>Hello Again</p>, <div><span>And Again</span></div> ]
1770  * @desc Find the very next sibling of each paragraph.
1771  *
1772  * @example $("p").next(".selected")
1773  * @before <p>Hello</p><p class="selected">Hello Again</p><div><span>And Again</span></div>
1774  * @result [ <p class="selected">Hello Again</p> ]
1775  * @desc Find the very next sibling of each paragraph that has a class "selected".
1776  *
1777  * @name next
1778  * @type jQuery
1779  * @param String expr (optional) An expression to filter the next Elements with
1780  * @cat DOM/Traversing
1781  */
1782
1783 /**
1784  * Get a set of elements containing the unique previous siblings of each of the
1785  * matched set of elements.
1786  *
1787  * Can be filtered with an optional expressions.
1788  *
1789  * It only returns the immediately previous sibling, not all previous siblings.
1790  *
1791  * @example $("p").prev()
1792  * @before <p>Hello</p><div><span>Hello Again</span></div><p>And Again</p>
1793  * @result [ <div><span>Hello Again</span></div> ]
1794  * @desc Find the very previous sibling of each paragraph.
1795  *
1796  * @example $("p").prev(".selected")
1797  * @before <div><span>Hello</span></div><p class="selected">Hello Again</p><p>And Again</p>
1798  * @result [ <div><span>Hello</span></div> ]
1799  * @desc Find the very previous sibling of each paragraph that has a class "selected".
1800  *
1801  * @name prev
1802  * @type jQuery
1803  * @param String expr (optional) An expression to filter the previous Elements with
1804  * @cat DOM/Traversing
1805  */
1806
1807 /**
1808  * Get a set of elements containing all of the unique siblings of each of the
1809  * matched set of elements.
1810  *
1811  * Can be filtered with an optional expressions.
1812  *
1813  * @example $("div").siblings()
1814  * @before <p>Hello</p><div><span>Hello Again</span></div><p>And Again</p>
1815  * @result [ <p>Hello</p>, <p>And Again</p> ]
1816  * @desc Find all siblings of each div.
1817  *
1818  * @example $("div").siblings(".selected")
1819  * @before <div><span>Hello</span></div><p class="selected">Hello Again</p><p>And Again</p>
1820  * @result [ <p class="selected">Hello Again</p> ]
1821  * @desc Find all siblings with a class "selected" of each div.
1822  *
1823  * @name siblings
1824  * @type jQuery
1825  * @param String expr (optional) An expression to filter the sibling Elements with
1826  * @cat DOM/Traversing
1827  */
1828
1829 /**
1830  * Get a set of elements containing all of the unique children of each of the
1831  * matched set of elements.
1832  *
1833  * Can be filtered with an optional expressions.
1834  *
1835  * @example $("div").children()
1836  * @before <p>Hello</p><div><span>Hello Again</span></div><p>And Again</p>
1837  * @result [ <span>Hello Again</span> ]
1838  * @desc Find all children of each div.
1839  *
1840  * @example $("div").children(".selected")
1841  * @before <div><span>Hello</span><p class="selected">Hello Again</p><p>And Again</p></div>
1842  * @result [ <p class="selected">Hello Again</p> ]
1843  * @desc Find all children with a class "selected" of each div.
1844  *
1845  * @name children
1846  * @type jQuery
1847  * @param String expr (optional) An expression to filter the child Elements with
1848  * @cat DOM/Traversing
1849  */
1850 jQuery.each({
1851         parent: "a.parentNode",
1852         parents: "jQuery.parents(a)",
1853         next: "jQuery.nth(a,2,'nextSibling')",
1854         prev: "jQuery.nth(a,2,'previousSibling')",
1855         siblings: "jQuery.sibling(a.parentNode.firstChild,a)",
1856         children: "jQuery.sibling(a.firstChild)"
1857 }, function(i,n){
1858         jQuery.fn[ i ] = function(a) {
1859                 var ret = jQuery.map(this,n);
1860                 if ( a && typeof a == "string" )
1861                         ret = jQuery.multiFilter(a,ret);
1862                 return this.pushStack( ret );
1863         };
1864 });
1865
1866 /**
1867  * Append all of the matched elements to another, specified, set of elements.
1868  * This operation is, essentially, the reverse of doing a regular
1869  * $(A).append(B), in that instead of appending B to A, you're appending
1870  * A to B.
1871  *
1872  * @example $("p").appendTo("#foo");
1873  * @before <p>I would like to say: </p><div id="foo"></div>
1874  * @result <div id="foo"><p>I would like to say: </p></div>
1875  * @desc Appends all paragraphs to the element with the ID "foo"
1876  *
1877  * @name appendTo
1878  * @type jQuery
1879  * @param <Content> content Content to append to the selected element to.
1880  * @cat DOM/Manipulation
1881  * @see append(<Content>)
1882  */
1883
1884 /**
1885  * Prepend all of the matched elements to another, specified, set of elements.
1886  * This operation is, essentially, the reverse of doing a regular
1887  * $(A).prepend(B), in that instead of prepending B to A, you're prepending
1888  * A to B.
1889  *
1890  * @example $("p").prependTo("#foo");
1891  * @before <p>I would like to say: </p><div id="foo"><b>Hello</b></div>
1892  * @result <div id="foo"><p>I would like to say: </p><b>Hello</b></div>
1893  * @desc Prepends all paragraphs to the element with the ID "foo"
1894  *
1895  * @name prependTo
1896  * @type jQuery
1897  * @param <Content> content Content to prepend to the selected element to.
1898  * @cat DOM/Manipulation
1899  * @see prepend(<Content>)
1900  */
1901
1902 /**
1903  * Insert all of the matched elements before another, specified, set of elements.
1904  * This operation is, essentially, the reverse of doing a regular
1905  * $(A).before(B), in that instead of inserting B before A, you're inserting
1906  * A before B.
1907  *
1908  * @example $("p").insertBefore("#foo");
1909  * @before <div id="foo">Hello</div><p>I would like to say: </p>
1910  * @result <p>I would like to say: </p><div id="foo">Hello</div>
1911  * @desc Same as $("#foo").before("p")
1912  *
1913  * @name insertBefore
1914  * @type jQuery
1915  * @param <Content> content Content to insert the selected element before.
1916  * @cat DOM/Manipulation
1917  * @see before(<Content>)
1918  */
1919
1920 /**
1921  * Insert all of the matched elements after another, specified, set of elements.
1922  * This operation is, essentially, the reverse of doing a regular
1923  * $(A).after(B), in that instead of inserting B after A, you're inserting
1924  * A after B.
1925  *
1926  * @example $("p").insertAfter("#foo");
1927  * @before <p>I would like to say: </p><div id="foo">Hello</div>
1928  * @result <div id="foo">Hello</div><p>I would like to say: </p>
1929  * @desc Same as $("#foo").after("p")
1930  *
1931  * @name insertAfter
1932  * @type jQuery
1933  * @param <Content> content Content to insert the selected element after.
1934  * @cat DOM/Manipulation
1935  * @see after(<Content>)
1936  */
1937
1938 jQuery.each({
1939         appendTo: "append",
1940         prependTo: "prepend",
1941         insertBefore: "before",
1942         insertAfter: "after"
1943 }, function(i,n){
1944         jQuery.fn[ i ] = function(){
1945                 var a = arguments;
1946                 return this.each(function(){
1947                         for ( var j = 0, al = a.length; j < al; j++ )
1948                                 jQuery(a[j])[n]( this );
1949                 });
1950         };
1951 });
1952
1953 /**
1954  * Remove an attribute from each of the matched elements.
1955  *
1956  * @example $("input").removeAttr("disabled")
1957  * @before <input disabled="disabled"/>
1958  * @result <input/>
1959  *
1960  * @name removeAttr
1961  * @type jQuery
1962  * @param String name The name of the attribute to remove.
1963  * @cat DOM/Attributes
1964  */
1965
1966 /**
1967  * Adds the specified class(es) to each of the set of matched elements.
1968  *
1969  * @example $("p").addClass("selected")
1970  * @before <p>Hello</p>
1971  * @result [ <p class="selected">Hello</p> ]
1972  *
1973  * @example $("p").addClass("selected highlight")
1974  * @before <p>Hello</p>
1975  * @result [ <p class="selected highlight">Hello</p> ]
1976  *
1977  * @name addClass
1978  * @type jQuery
1979  * @param String class One or more CSS classes to add to the elements
1980  * @cat DOM/Attributes
1981  * @see removeClass(String)
1982  */
1983
1984 /**
1985  * Removes all or the specified class(es) from the set of matched elements.
1986  *
1987  * @example $("p").removeClass()
1988  * @before <p class="selected">Hello</p>
1989  * @result [ <p>Hello</p> ]
1990  *
1991  * @example $("p").removeClass("selected")
1992  * @before <p class="selected first">Hello</p>
1993  * @result [ <p class="first">Hello</p> ]
1994  *
1995  * @example $("p").removeClass("selected highlight")
1996  * @before <p class="highlight selected first">Hello</p>
1997  * @result [ <p class="first">Hello</p> ]
1998  *
1999  * @name removeClass
2000  * @type jQuery
2001  * @param String class (optional) One or more CSS classes to remove from the elements
2002  * @cat DOM/Attributes
2003  * @see addClass(String)
2004  */
2005
2006 /**
2007  * Adds the specified class if it is not present, removes it if it is
2008  * present.
2009  *
2010  * @example $("p").toggleClass("selected")
2011  * @before <p>Hello</p><p class="selected">Hello Again</p>
2012  * @result [ <p class="selected">Hello</p>, <p>Hello Again</p> ]
2013  *
2014  * @name toggleClass
2015  * @type jQuery
2016  * @param String class A CSS class with which to toggle the elements
2017  * @cat DOM/Attributes
2018  */
2019
2020 /**
2021  * Removes all matched elements from the DOM. This does NOT remove them from the
2022  * jQuery object, allowing you to use the matched elements further.
2023  *
2024  * Can be filtered with an optional expressions.
2025  *
2026  * @example $("p").remove();
2027  * @before <p>Hello</p> how are <p>you?</p>
2028  * @result how are
2029  *
2030  * @example $("p").remove(".hello");
2031  * @before <p class="hello">Hello</p> how are <p>you?</p>
2032  * @result how are <p>you?</p>
2033  *
2034  * @name remove
2035  * @type jQuery
2036  * @param String expr (optional) A jQuery expression to filter elements by.
2037  * @cat DOM/Manipulation
2038  */
2039
2040 /**
2041  * Removes all child nodes from the set of matched elements.
2042  *
2043  * @example $("p").empty()
2044  * @before <p>Hello, <span>Person</span> <a href="#">and person</a></p>
2045  * @result [ <p></p> ]
2046  *
2047  * @name empty
2048  * @type jQuery
2049  * @cat DOM/Manipulation
2050  */
2051
2052 jQuery.each( {
2053         removeAttr: function( key ) {
2054                 jQuery.attr( this, key, "" );
2055                 this.removeAttribute( key );
2056         },
2057         addClass: function(c){
2058                 jQuery.className.add(this,c);
2059         },
2060         removeClass: function(c){
2061                 jQuery.className.remove(this,c);
2062         },
2063         toggleClass: function( c ){
2064                 jQuery.className[ jQuery.className.has(this,c) ? "remove" : "add" ](this, c);
2065         },
2066         remove: function(a){
2067                 if ( !a || jQuery.filter( a, [this] ).r.length )
2068                         this.parentNode.removeChild( this );
2069         },
2070         empty: function() {
2071                 while ( this.firstChild )
2072                         this.removeChild( this.firstChild );
2073         }
2074 }, function(i,n){
2075         jQuery.fn[ i ] = function() {
2076                 return this.each( n, arguments );
2077         };
2078 });
2079
2080 /**
2081  * Reduce the set of matched elements to a single element.
2082  * The position of the element in the set of matched elements
2083  * starts at 0 and goes to length - 1.
2084  *
2085  * @example $("p").eq(1)
2086  * @before <p>This is just a test.</p><p>So is this</p>
2087  * @result [ <p>So is this</p> ]
2088  *
2089  * @name eq
2090  * @type jQuery
2091  * @param Number pos The index of the element that you wish to limit to.
2092  * @cat Core
2093  */
2094
2095 /**
2096  * Reduce the set of matched elements to all elements before a given position.
2097  * The position of the element in the set of matched elements
2098  * starts at 0 and goes to length - 1.
2099  *
2100  * @example $("p").lt(1)
2101  * @before <p>This is just a test.</p><p>So is this</p>
2102  * @result [ <p>This is just a test.</p> ]
2103  *
2104  * @name lt
2105  * @type jQuery
2106  * @param Number pos Reduce the set to all elements below this position.
2107  * @cat Core
2108  */
2109
2110 /**
2111  * Reduce the set of matched elements to all elements after a given position.
2112  * The position of the element in the set of matched elements
2113  * starts at 0 and goes to length - 1.
2114  *
2115  * @example $("p").gt(0)
2116  * @before <p>This is just a test.</p><p>So is this</p>
2117  * @result [ <p>So is this</p> ]
2118  *
2119  * @name gt
2120  * @type jQuery
2121  * @param Number pos Reduce the set to all elements after this position.
2122  * @cat Core
2123  */
2124
2125 /**
2126  * Filter the set of elements to those that contain the specified text.
2127  *
2128  * @example $("p").contains("test")
2129  * @before <p>This is just a test.</p><p>So is this</p>
2130  * @result [ <p>This is just a test.</p> ]
2131  *
2132  * @name contains
2133  * @type jQuery
2134  * @param String str The string that will be contained within the text of an element.
2135  * @cat DOM/Traversing
2136  */
2137 jQuery.each( [ "eq", "lt", "gt", "contains" ], function(i,n){
2138         jQuery.fn[ n ] = function(num,fn) {
2139                 return this.filter( ":" + n + "(" + num + ")", fn );
2140         };
2141 });
2142
2143 /**
2144  * Get the current computed, pixel, width of the first matched element.
2145  *
2146  * @example $("p").width();
2147  * @before <p>This is just a test.</p>
2148  * @result 300
2149  *
2150  * @name width
2151  * @type String
2152  * @cat CSS
2153  */
2154
2155 /**
2156  * Set the CSS width of every matched element. If no explicit unit
2157  * was specified (like 'em' or '%') then "px" is added to the width.
2158  *
2159  * @example $("p").width(20);
2160  * @before <p>This is just a test.</p>
2161  * @result <p style="width:20px;">This is just a test.</p>
2162  *
2163  * @example $("p").width("20em");
2164  * @before <p>This is just a test.</p>
2165  * @result <p style="width:20em;">This is just a test.</p>
2166  *
2167  * @name width
2168  * @type jQuery
2169  * @param Number|String val Set the CSS property to the specified value.
2170  * @cat CSS
2171  */
2172  
2173 /**
2174  * Get the current computed, pixel, height of the first matched element.
2175  *
2176  * @example $("p").height();
2177  * @before <p>This is just a test.</p>
2178  * @result 300
2179  *
2180  * @name height
2181  * @type String
2182  * @cat CSS
2183  */
2184
2185 /**
2186  * Set the CSS width of every matched element. If no explicit unit
2187  * was specified (like 'em' or '%') then "px" is added to the width.
2188  *
2189  * @example $("p").height(20);
2190  * @before <p>This is just a test.</p>
2191  * @result <p style="height:20px;">This is just a test.</p>
2192  *
2193  * @example $("p").height("20em");
2194  * @before <p>This is just a test.</p>
2195  * @result <p style="height:20em;">This is just a test.</p>
2196  *
2197  * @name height
2198  * @type jQuery
2199  * @param Number|String val Set the CSS property to the specified value.
2200  * @cat CSS
2201  */
2202
2203 jQuery.each( [ "height", "width" ], function(i,n){
2204         jQuery.fn[ n ] = function(h) {
2205                 return h == undefined ?
2206                         ( this.length ? jQuery.css( this[0], n ) : null ) :
2207                         this.css( n, h.constructor == String ? h : h + "px" );
2208         };
2209 });