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