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