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