Fix #1907 where the never-ending loop prevention used a coersion comparison which...
[jquery.git] / src / core.js
1 /*\r
2  * jQuery @VERSION - New Wave Javascript\r
3  *\r
4  * Copyright (c) 2007 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 // Map over jQuery in case of overwrite\r
13 if ( window.jQuery )\r
14         var _jQuery = window.jQuery;\r
15 \r
16 var jQuery = window.jQuery = function( selector, context ) {\r
17         // If the context is a namespace object, return a new object\r
18         return this instanceof jQuery ?\r
19                 this.init( selector, context ) :\r
20                 new jQuery( selector, context );\r
21 };\r
22 \r
23 // Map over the $ in case of overwrite\r
24 if ( window.$ )\r
25         var _$ = window.$;\r
26         \r
27 // Map the jQuery namespace to the '$' one\r
28 window.$ = jQuery;\r
29 \r
30 // A simple way to check for HTML strings or ID strings\r
31 // (both of which we optimize for)\r
32 var quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/;\r
33 \r
34 jQuery.fn = jQuery.prototype = {\r
35         init: function( selector, context ) {\r
36                 // Make sure that a selection was provided\r
37                 selector = selector || document;\r
38 \r
39                 // Handle HTML strings\r
40                 if ( typeof selector  == "string" ) {\r
41                         // Are we dealing with HTML string or an ID?\r
42                         var match = quickExpr.exec( selector );\r
43 \r
44                         // Verify a match, and that no context was specified for #id\r
45                         if ( match && (match[1] || !context) ) {\r
46 \r
47                                 // HANDLE: $(html) -> $(array)\r
48                                 if ( match[1] )\r
49                                         selector = jQuery.clean( [ match[1] ], context );\r
50 \r
51                                 // HANDLE: $("#id")\r
52                                 else {\r
53                                         var elem = document.getElementById( match[3] );\r
54 \r
55                                         // Make sure an element was located\r
56                                         if ( elem )\r
57                                                 // Handle the case where IE and Opera return items\r
58                                                 // by name instead of ID\r
59                                                 if ( elem.id != match[3] )\r
60                                                         return jQuery().find( selector );\r
61 \r
62                                                 // Otherwise, we inject the element directly into the jQuery object\r
63                                                 else {\r
64                                                         this[0] = elem;\r
65                                                         this.length = 1;\r
66                                                         return this;\r
67                                                 }\r
68 \r
69                                         else\r
70                                                 selector = [];\r
71                                 }\r
72 \r
73                         // HANDLE: $(expr, [context])\r
74                         // (which is just equivalent to: $(content).find(expr)\r
75                         } else\r
76                                 return new jQuery( context ).find( selector );\r
77 \r
78                 // HANDLE: $(function)\r
79                 // Shortcut for document ready\r
80                 } else if ( jQuery.isFunction( selector ) )\r
81                         return new jQuery( document )[ jQuery.fn.ready ? "ready" : "load" ]( selector );\r
82 \r
83                 return this.setArray(\r
84                         // HANDLE: $(array)\r
85                         selector.constructor == Array && selector ||\r
86 \r
87                         // HANDLE: $(arraylike)\r
88                         // Watch for when an array-like object, contains DOM nodes, is passed in as the selector\r
89                         (selector.jquery || selector.length && selector != window && !selector.nodeType && selector[0] != undefined && selector[0].nodeType) && jQuery.makeArray( selector ) ||\r
90 \r
91                         // HANDLE: $(*)\r
92                         [ selector ] );\r
93         },\r
94         \r
95         // The current version of jQuery being used\r
96         jquery: "@VERSION",\r
97 \r
98         // The number of elements contained in the matched element set\r
99         size: function() {\r
100                 return this.length;\r
101         },\r
102         \r
103         // The number of elements contained in the matched element set\r
104         length: 0,\r
105 \r
106         // Get the Nth element in the matched element set OR\r
107         // Get the whole matched element set as a clean array\r
108         get: function( num ) {\r
109                 return num == undefined ?\r
110 \r
111                         // Return a 'clean' array\r
112                         jQuery.makeArray( this ) :\r
113 \r
114                         // Return just the object\r
115                         this[ num ];\r
116         },\r
117         \r
118         // Take an array of elements and push it onto the stack\r
119         // (returning the new matched element set)\r
120         pushStack: function( elems ) {\r
121                 // Build a new jQuery matched element set\r
122                 var ret = jQuery( elems );\r
123 \r
124                 // Add the old object onto the stack (as a reference)\r
125                 ret.prevObject = this;\r
126 \r
127                 // Return the newly-formed element set\r
128                 return ret;\r
129         },\r
130         \r
131         // Force the current matched set of elements to become\r
132         // the specified array of elements (destroying the stack in the process)\r
133         // You should use pushStack() in order to do this, but maintain the stack\r
134         setArray: function( elems ) {\r
135                 // Resetting the length to 0, then using the native Array push\r
136                 // is a super-fast way to populate an object with array-like properties\r
137                 this.length = 0;\r
138                 Array.prototype.push.apply( this, elems );\r
139                 \r
140                 return this;\r
141         },\r
142 \r
143         // Execute a callback for every element in the matched set.\r
144         // (You can seed the arguments with an array of args, but this is\r
145         // only used internally.)\r
146         each: function( callback, args ) {\r
147                 return jQuery.each( this, callback, args );\r
148         },\r
149 \r
150         // Determine the position of an element within \r
151         // the matched set of elements\r
152         index: function( elem ) {\r
153                 var ret = -1;\r
154 \r
155                 // Locate the position of the desired element\r
156                 this.each(function(i){\r
157                         if ( this == elem )\r
158                                 ret = i;\r
159                 });\r
160 \r
161                 return ret;\r
162         },\r
163 \r
164         attr: function( name, value, type ) {\r
165                 var options = name;\r
166                 \r
167                 // Look for the case where we're accessing a style value\r
168                 if ( name.constructor == String )\r
169                         if ( value == undefined )\r
170                                 return this.length && jQuery[ type || "attr" ]( this[0], name ) || undefined;\r
171 \r
172                         else {\r
173                                 options = {};\r
174                                 options[ name ] = value;\r
175                         }\r
176                 \r
177                 // Check to see if we're setting style values\r
178                 return this.each(function(i){\r
179                         // Set all the styles\r
180                         for ( name in options )\r
181                                 jQuery.attr(\r
182                                         type ?\r
183                                                 this.style :\r
184                                                 this,\r
185                                         name, jQuery.prop( this, options[ name ], type, i, name )\r
186                                 );\r
187                 });\r
188         },\r
189 \r
190         css: function( key, value ) {\r
191                 return this.attr( key, value, "curCSS" );\r
192         },\r
193 \r
194         text: function( text ) {\r
195                 if ( typeof text != "object" && text != null )\r
196                         return this.empty().append( document.createTextNode( text ) );\r
197 \r
198                 var ret = "";\r
199 \r
200                 jQuery.each( text || this, function(){\r
201                         jQuery.each( this.childNodes, function(){\r
202                                 if ( this.nodeType != 8 )\r
203                                         ret += this.nodeType != 1 ?\r
204                                                 this.nodeValue :\r
205                                                 jQuery.fn.text( [ this ] );\r
206                         });\r
207                 });\r
208 \r
209                 return ret;\r
210         },\r
211 \r
212         wrapAll: function( html ) {\r
213                 if ( this[0] )\r
214                         // The elements to wrap the target around\r
215                         jQuery( html, this[0].ownerDocument )\r
216                                 .clone()\r
217                                 .insertBefore( this[0] )\r
218                                 .map(function(){\r
219                                         var elem = this;\r
220 \r
221                                         while ( elem.firstChild )\r
222                                                 elem = elem.firstChild;\r
223 \r
224                                         return elem;\r
225                                 })\r
226                                 .append(this);\r
227 \r
228                 return this;\r
229         },\r
230 \r
231         wrapInner: function( html ) {\r
232                 return this.each(function(){\r
233                         jQuery( this ).contents().wrapAll( html );\r
234                 });\r
235         },\r
236 \r
237         wrap: function( html ) {\r
238                 return this.each(function(){\r
239                         jQuery( this ).wrapAll( html );\r
240                 });\r
241         },\r
242 \r
243         append: function() {\r
244                 return this.domManip(arguments, true, false, function(elem){\r
245                         this.appendChild( elem );\r
246                 });\r
247         },\r
248 \r
249         prepend: function() {\r
250                 return this.domManip(arguments, true, true, function(elem){\r
251                         this.insertBefore( elem, this.firstChild );\r
252                 });\r
253         },\r
254         \r
255         before: function() {\r
256                 return this.domManip(arguments, false, false, function(elem){\r
257                         this.parentNode.insertBefore( elem, this );\r
258                 });\r
259         },\r
260 \r
261         after: function() {\r
262                 return this.domManip(arguments, false, true, function(elem){\r
263                         this.parentNode.insertBefore( elem, this.nextSibling );\r
264                 });\r
265         },\r
266 \r
267         end: function() {\r
268                 return this.prevObject || jQuery( [] );\r
269         },\r
270 \r
271         find: function( selector ) {\r
272                 var elems = jQuery.map(this, function(elem){\r
273                         return jQuery.find( selector, elem );\r
274                 });\r
275 \r
276                 return this.pushStack( /[^+>] [^+>]/.test( selector ) || selector.indexOf("..") > -1 ?\r
277                         jQuery.unique( elems ) :\r
278                         elems );\r
279         },\r
280 \r
281         clone: function( events ) {\r
282                 // Do the clone\r
283                 var ret = this.map(function(){\r
284                         return this.outerHTML ?\r
285                                 jQuery( this.outerHTML )[0] :\r
286                                 this.cloneNode( true );\r
287                 });\r
288 \r
289                 // Need to set the expando to null on the cloned set if it exists\r
290                 // removeData doesn't work here, IE removes it from the original as well\r
291                 // this is primarily for IE but the data expando shouldn't be copied over in any browser\r
292                 var clone = ret.find("*").andSelf().each(function(){\r
293                         if ( this[ expando ] != undefined )\r
294                                 this[ expando ] = null;\r
295                 });\r
296                 \r
297                 // Copy the events from the original to the clone\r
298                 if ( events === true )\r
299                         this.find("*").andSelf().each(function(i){\r
300                                 var events = jQuery.data( this, "events" );\r
301 \r
302                                 for ( var type in events )\r
303                                         for ( var handler in events[ type ] )\r
304                                                 jQuery.event.add( clone[ i ], type, events[ type ][ handler ], events[ type ][ handler ].data );\r
305                         });\r
306 \r
307                 // Return the cloned set\r
308                 return ret;\r
309         },\r
310 \r
311         filter: function( selector ) {\r
312                 return this.pushStack(\r
313                         jQuery.isFunction( selector ) &&\r
314                         jQuery.grep(this, function(elem, i){\r
315                                 return selector.call( elem, i );\r
316                         }) ||\r
317 \r
318                         jQuery.multiFilter( selector, this ) );\r
319         },\r
320 \r
321         not: function( selector ) {\r
322                 return this.pushStack(\r
323                         selector.constructor == String &&\r
324                         jQuery.multiFilter( selector, this, true ) ||\r
325 \r
326                         jQuery.grep(this, function(elem) {\r
327                                 return selector.constructor == Array || selector.jquery ?\r
328                                         jQuery.inArray( elem, selector ) < 0 :\r
329                                         elem != selector;\r
330                         }) );\r
331         },\r
332 \r
333         add: function( selector ) {\r
334                 return this.pushStack( jQuery.merge( \r
335                         this.get(),\r
336                         selector.constructor == String ? \r
337                                 jQuery( selector ).get() :\r
338                                 selector.length != undefined && (!selector.nodeName || jQuery.nodeName(selector, "form")) ?\r
339                                         selector : [selector] ) );\r
340         },\r
341 \r
342         is: function( selector ) {\r
343                 return selector ?\r
344                         jQuery.multiFilter( selector, this ).length > 0 :\r
345                         false;\r
346         },\r
347 \r
348         hasClass: function( selector ) {\r
349                 return this.is( "." + selector );\r
350         },\r
351         \r
352         val: function( value ) {\r
353                 if ( value == undefined ) {\r
354 \r
355                         if ( this.length ) {\r
356                                 var elem = this[0];\r
357                         \r
358                                 // We need to handle select boxes special\r
359                                 if ( jQuery.nodeName( elem, "select" ) ) {\r
360                                         var index = elem.selectedIndex,\r
361                                                 values = [],\r
362                                                 options = elem.options,\r
363                                                 one = elem.type == "select-one";\r
364                                         \r
365                                         // Nothing was selected\r
366                                         if ( index < 0 )\r
367                                                 return null;\r
368 \r
369                                         // Loop through all the selected options\r
370                                         for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {\r
371                                                 var option = options[ i ];\r
372 \r
373                                                 if ( option.selected ) {\r
374                                                         // Get the specifc value for the option\r
375                                                         value = jQuery.browser.msie && !option.attributes.value.specified ? option.text : option.value;\r
376                                                         \r
377                                                         // We don't need an array for one selects\r
378                                                         if ( one )\r
379                                                                 return value;\r
380                                                         \r
381                                                         // Multi-Selects return an array\r
382                                                         values.push( value );\r
383                                                 }\r
384                                         }\r
385                                         \r
386                                         return values;\r
387                                         \r
388                                 // Everything else, we just grab the value\r
389                                 } else\r
390                                         return this[0].value.replace(/\r/g, "");\r
391 \r
392                         }\r
393 \r
394                 } else\r
395                         return this.each(function(){\r
396                                 if ( value.constructor == Array && /radio|checkbox/.test( this.type ) )\r
397                                         this.checked = (jQuery.inArray(this.value, value) >= 0 ||\r
398                                                 jQuery.inArray(this.name, value) >= 0);\r
399 \r
400                                 else if ( jQuery.nodeName( this, "select" ) ) {\r
401                                         var values = value.constructor == Array ?\r
402                                                 value :\r
403                                                 [ value ];\r
404 \r
405                                         jQuery( "option", this ).each(function(){\r
406                                                 this.selected = (jQuery.inArray( this.value, values ) >= 0 ||\r
407                                                         jQuery.inArray( this.text, values ) >= 0);\r
408                                         });\r
409 \r
410                                         if ( !values.length )\r
411                                                 this.selectedIndex = -1;\r
412 \r
413                                 } else\r
414                                         this.value = value;\r
415                         });\r
416         },\r
417         \r
418         html: function( value ) {\r
419                 return value == undefined ?\r
420                         (this.length ?\r
421                                 this[0].innerHTML :\r
422                                 null) :\r
423                         this.empty().append( value );\r
424         },\r
425 \r
426         replaceWith: function( value ) {\r
427                 return this.after( value ).remove();\r
428         },\r
429 \r
430         eq: function( i ) {\r
431                 return this.slice( i, i + 1 );\r
432         },\r
433 \r
434         slice: function() {\r
435                 return this.pushStack( Array.prototype.slice.apply( this, arguments ) );\r
436         },\r
437 \r
438         map: function( callback ) {\r
439                 return this.pushStack( jQuery.map(this, function(elem, i){\r
440                         return callback.call( elem, i, elem );\r
441                 }));\r
442         },\r
443 \r
444         andSelf: function() {\r
445                 return this.add( this.prevObject );\r
446         },\r
447         \r
448         domManip: function( args, table, reverse, callback ) {\r
449                 var clone = this.length > 1, elems; \r
450 \r
451                 return this.each(function(){\r
452                         if ( !elems ) {\r
453                                 elems = jQuery.clean( args, this.ownerDocument );\r
454 \r
455                                 if ( reverse )\r
456                                         elems.reverse();\r
457                         }\r
458 \r
459                         var obj = this;\r
460 \r
461                         if ( table && jQuery.nodeName( this, "table" ) && jQuery.nodeName( elems[0], "tr" ) )\r
462                                 obj = this.getElementsByTagName("tbody")[0] || this.appendChild( document.createElement("tbody") );\r
463 \r
464                         var scripts = jQuery( [] );\r
465 \r
466                         jQuery.each(elems, function(){\r
467                                 var elem = clone ?\r
468                                         this.cloneNode( true ) :\r
469                                         this;\r
470 \r
471                                 if ( jQuery.nodeName( elem, "script" ) ) {\r
472 \r
473                                         // If scripts are waiting to be executed, wait on this script as well\r
474                                         if ( scripts.length )\r
475                                                 scripts = scripts.add( elem );\r
476 \r
477                                         // If nothing is waiting to be executed, run immediately\r
478                                         else\r
479                                                 evalScript( 0, elem );\r
480 \r
481                                 } else {\r
482                                         // Remove any inner scripts for later evaluation\r
483                                         if ( elem.nodeType == 1 )\r
484                                                 scripts = scripts.add( jQuery( "script", elem ).remove() );\r
485 \r
486                                         // Inject the elements into the document\r
487                                         callback.call( obj, elem );\r
488                                 }\r
489                         });\r
490 \r
491                         scripts.each( evalScript );\r
492                 });\r
493         }\r
494 };\r
495 \r
496 function evalScript( i, elem ) {\r
497         if ( elem.src )\r
498                 jQuery.ajax({\r
499                         url: elem.src,\r
500                         async: false,\r
501                         dataType: "script"\r
502                 });\r
503 \r
504         else\r
505                 jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" );\r
506 \r
507         if ( elem.parentNode )\r
508                 elem.parentNode.removeChild( elem );\r
509 }\r
510 \r
511 jQuery.extend = jQuery.fn.extend = function() {\r
512         // copy reference to target object\r
513         var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options;\r
514 \r
515         // Handle a deep copy situation\r
516         if ( target.constructor == Boolean ) {\r
517                 deep = target;\r
518                 target = arguments[1] || {};\r
519                 // skip the boolean and the target\r
520                 i = 2;\r
521         }\r
522 \r
523         // Handle case when target is a string or something (possible in deep copy)\r
524         if ( typeof target != "object" )\r
525                 target = {};\r
526 \r
527         // extend jQuery itself if only one argument is passed\r
528         if ( length == 1 ) {\r
529                 target = this;\r
530                 i = 0;\r
531         }\r
532 \r
533         for ( ; i < length; i++ )\r
534                 // Only deal with non-null/undefined values\r
535                 if ( (options = arguments[ i ]) != null )\r
536                         // Extend the base object\r
537                         for ( var name in options ) {\r
538                                 // Prevent never-ending loop\r
539                                 if ( target === options[ name ] )\r
540                                         continue;\r
541 \r
542                                 // Recurse if we're merging object values\r
543                                 if ( deep && typeof options[ name ] == "object" && target[ name ] && !options[ name ].nodeType )\r
544                                         target[ name ] = jQuery.extend( target[ name ], options[ name ] );\r
545 \r
546                                 // Don't bring in undefined values\r
547                                 else if ( options[ name ] != undefined )\r
548                                         target[ name ] = options[ name ];\r
549 \r
550                         }\r
551 \r
552         // Return the modified object\r
553         return target;\r
554 };\r
555 \r
556 var expando = "jQuery" + (new Date()).getTime(), uuid = 0, windowData = {};\r
557 \r
558 // exclude the following css properties to add px\r
559 var exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i;\r
560 \r
561 jQuery.extend({\r
562         noConflict: function( deep ) {\r
563                 window.$ = _$;\r
564 \r
565                 if ( deep )\r
566                         window.jQuery = _jQuery;\r
567 \r
568                 return jQuery;\r
569         },\r
570 \r
571         // This may seem like some crazy code, but trust me when I say that this\r
572         // is the only cross-browser way to do this. --John\r
573         isFunction: function( fn ) {\r
574                 return !!fn && typeof fn != "string" && !fn.nodeName && \r
575                         fn.constructor != Array && /function/i.test( fn + "" );\r
576         },\r
577         \r
578         // check if an element is in a (or is an) XML document\r
579         isXMLDoc: function( elem ) {\r
580                 return elem.documentElement && !elem.body ||\r
581                         elem.tagName && elem.ownerDocument && !elem.ownerDocument.body;\r
582         },\r
583 \r
584         // Evalulates a script in a global context\r
585         // Evaluates Async. in Safari 2 :-(\r
586         globalEval: function( data ) {\r
587                 data = jQuery.trim( data );\r
588 \r
589                 if ( data ) {\r
590                         // Inspired by code by Andrea Giammarchi\r
591                         // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html\r
592                         var head = document.getElementsByTagName("head")[0] || document.documentElement,\r
593                                 script = document.createElement("script");\r
594 \r
595                         script.type = "text/javascript";\r
596                         if ( jQuery.browser.msie )\r
597                                 script.text = data;\r
598                         else\r
599                                 script.appendChild( document.createTextNode( data ) );\r
600 \r
601                         head.appendChild( script );\r
602                         head.removeChild( script );\r
603                 }\r
604         },\r
605 \r
606         nodeName: function( elem, name ) {\r
607                 return elem.nodeName && elem.nodeName.toUpperCase() == name.toUpperCase();\r
608         },\r
609         \r
610         cache: {},\r
611         \r
612         data: function( elem, name, data ) {\r
613                 elem = elem == window ?\r
614                         windowData :\r
615                         elem;\r
616 \r
617                 var id = elem[ expando ];\r
618 \r
619                 // Compute a unique ID for the element\r
620                 if ( !id ) \r
621                         id = elem[ expando ] = ++uuid;\r
622 \r
623                 // Only generate the data cache if we're\r
624                 // trying to access or manipulate it\r
625                 if ( name && !jQuery.cache[ id ] )\r
626                         jQuery.cache[ id ] = {};\r
627                 \r
628                 // Prevent overriding the named cache with undefined values\r
629                 if ( data != undefined )\r
630                         jQuery.cache[ id ][ name ] = data;\r
631                 \r
632                 // Return the named cache data, or the ID for the element       \r
633                 return name ?\r
634                         jQuery.cache[ id ][ name ] :\r
635                         id;\r
636         },\r
637         \r
638         removeData: function( elem, name ) {\r
639                 elem = elem == window ?\r
640                         windowData :\r
641                         elem;\r
642 \r
643                 var id = elem[ expando ];\r
644 \r
645                 // If we want to remove a specific section of the element's data\r
646                 if ( name ) {\r
647                         if ( jQuery.cache[ id ] ) {\r
648                                 // Remove the section of cache data\r
649                                 delete jQuery.cache[ id ][ name ];\r
650 \r
651                                 // If we've removed all the data, remove the element's cache\r
652                                 name = "";\r
653 \r
654                                 for ( name in jQuery.cache[ id ] )\r
655                                         break;\r
656 \r
657                                 if ( !name )\r
658                                         jQuery.removeData( elem );\r
659                         }\r
660 \r
661                 // Otherwise, we want to remove all of the element's data\r
662                 } else {\r
663                         // Clean up the element expando\r
664                         try {\r
665                                 delete elem[ expando ];\r
666                         } catch(e){\r
667                                 // IE has trouble directly removing the expando\r
668                                 // but it's ok with using removeAttribute\r
669                                 if ( elem.removeAttribute )\r
670                                         elem.removeAttribute( expando );\r
671                         }\r
672 \r
673                         // Completely remove the data cache\r
674                         delete jQuery.cache[ id ];\r
675                 }\r
676         },\r
677 \r
678         // args is for internal usage only\r
679         each: function( object, callback, args ) {\r
680                 if ( args ) {\r
681                         if ( object.length == undefined )\r
682                                 for ( var name in object )\r
683                                         callback.apply( object[ name ], args );\r
684                         else\r
685                                 for ( var i = 0, length = object.length; i < length; i++ )\r
686                                         if ( callback.apply( object[ i ], args ) === false )\r
687                                                 break;\r
688 \r
689                 // A special, fast, case for the most common use of each\r
690                 } else {\r
691                         if ( object.length == undefined )\r
692                                 for ( var name in object )\r
693                                         callback.call( object[ name ], name, object[ name ] );\r
694                         else\r
695                                 for ( var i = 0, length = object.length, value = object[0]; \r
696                                         i < length && callback.call( value, i, value ) !== false; value = object[++i] ){}\r
697                 }\r
698 \r
699                 return object;\r
700         },\r
701         \r
702         prop: function( elem, value, type, i, name ) {\r
703                         // Handle executable functions\r
704                         if ( jQuery.isFunction( value ) )\r
705                                 value = value.call( elem, i );\r
706                                 \r
707                         // Handle passing in a number to a CSS property\r
708                         return value && value.constructor == Number && type == "curCSS" && !exclude.test( name ) ?\r
709                                 value + "px" :\r
710                                 value;\r
711         },\r
712 \r
713         className: {\r
714                 // internal only, use addClass("class")\r
715                 add: function( elem, classNames ) {\r
716                         jQuery.each((classNames || "").split(/\s+/), function(i, className){\r
717                                 if ( !jQuery.className.has( elem.className, className ) )\r
718                                         elem.className += (elem.className ? " " : "") + className;\r
719                         });\r
720                 },\r
721 \r
722                 // internal only, use removeClass("class")\r
723                 remove: function( elem, classNames ) {\r
724                         elem.className = classNames != undefined ?\r
725                                 jQuery.grep(elem.className.split(/\s+/), function(className){\r
726                                         return !jQuery.className.has( classNames, className );  \r
727                                 }).join(" ") :\r
728                                 "";\r
729                 },\r
730 \r
731                 // internal only, use is(".class")\r
732                 has: function( elem, className ) {\r
733                         return jQuery.inArray( className, (elem.className || elem).toString().split(/\s+/) ) > -1;\r
734                 }\r
735         },\r
736 \r
737         // A method for quickly swapping in/out CSS properties to get correct calculations\r
738         swap: function( elem, options, callback ) {\r
739                 // Remember the old values, and insert the new ones\r
740                 for ( var name in options ) {\r
741                         elem.style[ "old" + name ] = elem.style[ name ];\r
742                         elem.style[ name ] = options[ name ];\r
743                 }\r
744 \r
745                 callback.call( elem );\r
746 \r
747                 // Revert the old values\r
748                 for ( var name in options )\r
749                         elem.style[ name ] = elem.style[ "old" + name ];\r
750         },\r
751 \r
752         css: function( elem, name ) {\r
753                 if ( name == "height" || name == "width" ) {\r
754                         var old = {}, height, width;\r
755 \r
756                         // Revert the padding and border widths to get the\r
757                         // correct height/width values\r
758                         jQuery.each([ "Top", "Bottom", "Right", "Left" ], function(){\r
759                                 old[ "padding" + this ] = 0;\r
760                                 old[ "border" + this + "Width" ] = 0;\r
761                         });\r
762 \r
763                         // Swap out the padding/border values temporarily\r
764                         jQuery.swap( elem, old, function() {\r
765 \r
766                                 // If the element is visible, then the calculation is easy\r
767                                 if ( jQuery( elem ).is(":visible") ) {\r
768                                         height = elem.offsetHeight;\r
769                                         width = elem.offsetWidth;\r
770 \r
771                                 // Otherwise, we need to flip out more values\r
772                                 } else {\r
773                                         elem = jQuery( elem.cloneNode(true) )\r
774                                                 .find(":radio").removeAttr("checked").removeAttr("defaultChecked").end()\r
775                                                 .css({\r
776                                                         visibility: "hidden",\r
777                                                         position: "absolute",\r
778                                                         display: "block",\r
779                                                         right: "0",\r
780                                                         left: "0"\r
781                                                 }).appendTo( elem.parentNode )[0];\r
782 \r
783                                         var position = jQuery.css( elem.parentNode, "position" ) || "static";\r
784                                         if ( position == "static" )\r
785                                                 elem.parentNode.style.position = "relative";\r
786 \r
787                                         height = elem.clientHeight;\r
788                                         width = elem.clientWidth;\r
789 \r
790                                         if ( position == "static" )\r
791                                                 elem.parentNode.style.position = "static";\r
792 \r
793                                         elem.parentNode.removeChild( elem );\r
794                                 }\r
795                         });\r
796 \r
797                         return name == "height" ?\r
798                                 height :\r
799                                 width;\r
800                 }\r
801 \r
802                 return jQuery.curCSS( elem, name );\r
803         },\r
804 \r
805         curCSS: function( elem, name, force ) {\r
806                 var ret;\r
807 \r
808                 // A helper method for determining if an element's values are broken\r
809                 function color( elem ) {\r
810                         if ( !jQuery.browser.safari )\r
811                                 return false;\r
812 \r
813                         var ret = document.defaultView.getComputedStyle( elem, null );\r
814                         return !ret || ret.getPropertyValue("color") == "";\r
815                 }\r
816 \r
817                 // We need to handle opacity special in IE\r
818                 if ( name == "opacity" && jQuery.browser.msie ) {\r
819                         ret = jQuery.attr( elem.style, "opacity" );\r
820 \r
821                         return ret == "" ?\r
822                                 "1" :\r
823                                 ret;\r
824                 }\r
825                 \r
826                 // Make sure we're using the right name for getting the float value\r
827                 if ( name.match( /float/i ) )\r
828                         name = styleFloat;\r
829 \r
830                 if ( !force && elem.style[ name ] )\r
831                         ret = elem.style[ name ];\r
832 \r
833                 else if ( document.defaultView && document.defaultView.getComputedStyle ) {\r
834 \r
835                         // Only "float" is needed here\r
836                         if ( name.match( /float/i ) )\r
837                                 name = "float";\r
838 \r
839                         name = name.replace( /([A-Z])/g, "-$1" ).toLowerCase();\r
840 \r
841                         var getComputedStyle = document.defaultView.getComputedStyle( elem, null );\r
842 \r
843                         if ( getComputedStyle && !color( elem ) )\r
844                                 ret = getComputedStyle.getPropertyValue( name );\r
845 \r
846                         // If the element isn't reporting its values properly in Safari\r
847                         // then some display: none elements are involved\r
848                         else {\r
849                                 var swap = [], stack = [];\r
850 \r
851                                 // Locate all of the parent display: none elements\r
852                                 for ( var a = elem; a && color(a); a = a.parentNode )\r
853                                         stack.unshift(a);\r
854 \r
855                                 // Go through and make them visible, but in reverse\r
856                                 // (It would be better if we knew the exact display type that they had)\r
857                                 for ( var i = 0; i < stack.length; i++ )\r
858                                         if ( color( stack[ i ] ) ) {\r
859                                                 swap[ i ] = stack[ i ].style.display;\r
860                                                 stack[ i ].style.display = "block";\r
861                                         }\r
862 \r
863                                 // Since we flip the display style, we have to handle that\r
864                                 // one special, otherwise get the value\r
865                                 ret = name == "display" && swap[ stack.length - 1 ] != null ?\r
866                                         "none" :\r
867                                         ( getComputedStyle && getComputedStyle.getPropertyValue( name ) ) || "";\r
868 \r
869                                 // Finally, revert the display styles back\r
870                                 for ( var i = 0; i < swap.length; i++ )\r
871                                         if ( swap[ i ] != null )\r
872                                                 stack[ i ].style.display = swap[ i ];\r
873                         }\r
874 \r
875                         // We should always get a number back from opacity\r
876                         if ( name == "opacity" && ret == "" )\r
877                                 ret = "1";\r
878 \r
879                 } else if ( elem.currentStyle ) {\r
880                         var camelCase = name.replace(/\-(\w)/g, function(all, letter){\r
881                                 return letter.toUpperCase();\r
882                         });\r
883 \r
884                         ret = elem.currentStyle[ name ] || elem.currentStyle[ camelCase ];\r
885 \r
886                         // From the awesome hack by Dean Edwards\r
887                         // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291\r
888 \r
889                         // If we're not dealing with a regular pixel number\r
890                         // but a number that has a weird ending, we need to convert it to pixels\r
891                         if ( !/^\d+(px)?$/i.test( ret ) && /^\d/.test( ret ) ) {\r
892                                 // Remember the original values\r
893                                 var style = elem.style.left, runtimeStyle = elem.runtimeStyle.left;\r
894 \r
895                                 // Put in the new values to get a computed value out\r
896                                 elem.runtimeStyle.left = elem.currentStyle.left;\r
897                                 elem.style.left = ret || 0;\r
898                                 ret = elem.style.pixelLeft + "px";\r
899 \r
900                                 // Revert the changed values\r
901                                 elem.style.left = style;\r
902                                 elem.runtimeStyle.left = runtimeStyle;\r
903                         }\r
904                 }\r
905 \r
906                 return ret;\r
907         },\r
908         \r
909         clean: function( elems, context ) {\r
910                 var ret = [];\r
911                 context = context || document;\r
912 \r
913                 jQuery.each(elems, function(i, elem){\r
914                         if ( !elem )\r
915                                 return;\r
916 \r
917                         if ( elem.constructor == Number )\r
918                                 elem = elem.toString();\r
919                         \r
920                         // Convert html string into DOM nodes\r
921                         if ( typeof elem == "string" ) {\r
922                                 // Fix "XHTML"-style tags in all browsers\r
923                                 elem = elem.replace(/(<(\w+)[^>]*?)\/>/g, function(all, front, tag){\r
924                                         return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area)$/i) ?\r
925                                                 all :\r
926                                                 front + "></" + tag + ">";\r
927                                 });\r
928 \r
929                                 // Trim whitespace, otherwise indexOf won't work as expected\r
930                                 var tags = jQuery.trim( elem ).toLowerCase(), div = context.createElement("div");\r
931 \r
932                                 var wrap =\r
933                                         // option or optgroup\r
934                                         !tags.indexOf("<opt") &&\r
935                                         [ 1, "<select>", "</select>" ] ||\r
936                                         \r
937                                         !tags.indexOf("<leg") &&\r
938                                         [ 1, "<fieldset>", "</fieldset>" ] ||\r
939                                         \r
940                                         tags.match(/^<(thead|tbody|tfoot|colg|cap)/) &&\r
941                                         [ 1, "<table>", "</table>" ] ||\r
942                                         \r
943                                         !tags.indexOf("<tr") &&\r
944                                         [ 2, "<table><tbody>", "</tbody></table>" ] ||\r
945                                         \r
946                                         // <thead> matched above\r
947                                         (!tags.indexOf("<td") || !tags.indexOf("<th")) &&\r
948                                         [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ] ||\r
949                                         \r
950                                         !tags.indexOf("<col") &&\r
951                                         [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ] ||\r
952 \r
953                                         // IE can't serialize <link> and <script> tags normally\r
954                                         jQuery.browser.msie &&\r
955                                         [ 1, "div<div>", "</div>" ] ||\r
956                                         \r
957                                         [ 0, "", "" ];\r
958 \r
959                                 // Go to html and back, then peel off extra wrappers\r
960                                 div.innerHTML = wrap[1] + elem + wrap[2];\r
961                                 \r
962                                 // Move to the right depth\r
963                                 while ( wrap[0]-- )\r
964                                         div = div.lastChild;\r
965                                 \r
966                                 // Remove IE's autoinserted <tbody> from table fragments\r
967                                 if ( jQuery.browser.msie ) {\r
968                                         \r
969                                         // String was a <table>, *may* have spurious <tbody>\r
970                                         var tbody = !tags.indexOf("<table") && tags.indexOf("<tbody") < 0 ?\r
971                                                 div.firstChild && div.firstChild.childNodes :\r
972                                                 \r
973                                                 // String was a bare <thead> or <tfoot>\r
974                                                 wrap[1] == "<table>" && tags.indexOf("<tbody") < 0 ?\r
975                                                         div.childNodes :\r
976                                                         [];\r
977                                 \r
978                                         for ( var i = tbody.length - 1; i >= 0 ; --i )\r
979                                                 if ( jQuery.nodeName( tbody[ i ], "tbody" ) && !tbody[ i ].childNodes.length )\r
980                                                         tbody[ i ].parentNode.removeChild( tbody[ i ] );\r
981                                         \r
982                                         // IE completely kills leading whitespace when innerHTML is used        \r
983                                         if ( /^\s/.test( elem ) )       \r
984                                                 div.insertBefore( context.createTextNode( elem.match(/^\s*/)[0] ), div.firstChild );\r
985                                 \r
986                                 }\r
987                                 \r
988                                 elem = jQuery.makeArray( div.childNodes );\r
989                         }\r
990 \r
991                         if ( elem.length === 0 && (!jQuery.nodeName( elem, "form" ) && !jQuery.nodeName( elem, "select" )) )\r
992                                 return;\r
993 \r
994                         if ( elem[0] == undefined || jQuery.nodeName( elem, "form" ) || elem.options )\r
995                                 ret.push( elem );\r
996 \r
997                         else\r
998                                 ret = jQuery.merge( ret, elem );\r
999 \r
1000                 });\r
1001 \r
1002                 return ret;\r
1003         },\r
1004         \r
1005         attr: function( elem, name, value ) {\r
1006                 var fix = jQuery.isXMLDoc( elem ) ?\r
1007                         {} :\r
1008                         jQuery.props;\r
1009 \r
1010                 // Safari mis-reports the default selected property of a hidden option\r
1011                 // Accessing the parent's selectedIndex property fixes it\r
1012                 if ( name == "selected" && jQuery.browser.safari )\r
1013                         elem.parentNode.selectedIndex;\r
1014                 \r
1015                 // Certain attributes only work when accessed via the old DOM 0 way\r
1016                 if ( fix[ name ] ) {\r
1017                         if ( value != undefined )\r
1018                                 elem[ fix[ name ] ] = value;\r
1019 \r
1020                         return elem[ fix[ name ] ];\r
1021 \r
1022                 } else if ( jQuery.browser.msie && name == "style" )\r
1023                         return jQuery.attr( elem.style, "cssText", value );\r
1024 \r
1025                 else if ( value == undefined && jQuery.browser.msie && jQuery.nodeName( elem, "form" ) && (name == "action" || name == "method") )\r
1026                         return elem.getAttributeNode( name ).nodeValue;\r
1027 \r
1028                 // IE elem.getAttribute passes even for style\r
1029                 else if ( elem.tagName ) {\r
1030 \r
1031                         if ( value != undefined ) {\r
1032                                 // We can't allow the type property to be changed (since it causes problems in IE)\r
1033                                 if ( name == "type" && jQuery.nodeName( elem, "input" ) && elem.parentNode )\r
1034                                         throw "type property can't be changed";\r
1035 \r
1036                                 elem.setAttribute( name, value );\r
1037                         }\r
1038 \r
1039                         if ( jQuery.browser.msie && /href|src/.test( name ) && !jQuery.isXMLDoc( elem ) ) \r
1040                                 return elem.getAttribute( name, 2 );\r
1041 \r
1042                         return elem.getAttribute( name );\r
1043 \r
1044                 // elem is actually elem.style ... set the style\r
1045                 } else {\r
1046                         // IE actually uses filters for opacity\r
1047                         if ( name == "opacity" && jQuery.browser.msie ) {\r
1048                                 if ( value != undefined ) {\r
1049                                         // IE has trouble with opacity if it does not have layout\r
1050                                         // Force it by setting the zoom level\r
1051                                         elem.zoom = 1; \r
1052         \r
1053                                         // Set the alpha filter to set the opacity\r
1054                                         elem.filter = (elem.filter || "").replace( /alpha\([^)]*\)/, "" ) +\r
1055                                                 (parseFloat( value ).toString() == "NaN" ? "" : "alpha(opacity=" + value * 100 + ")");\r
1056                                 }\r
1057         \r
1058                                 return elem.filter ? \r
1059                                         (parseFloat( elem.filter.match(/opacity=([^)]*)/)[1] ) / 100).toString() :\r
1060                                         "";\r
1061                         }\r
1062 \r
1063                         name = name.replace(/-([a-z])/ig, function(all, letter){\r
1064                                 return letter.toUpperCase();\r
1065                         });\r
1066 \r
1067                         if ( value != undefined )\r
1068                                 elem[ name ] = value;\r
1069 \r
1070                         return elem[ name ];\r
1071                 }\r
1072         },\r
1073         \r
1074         trim: function( text ) {\r
1075                 return (text || "").replace( /^\s+|\s+$/g, "" );\r
1076         },\r
1077 \r
1078         makeArray: function( array ) {\r
1079                 var ret = [];\r
1080 \r
1081                 // Need to use typeof to fight Safari childNodes crashes\r
1082                 if ( typeof array != "array" )\r
1083                         for ( var i = 0, length = array.length; i < length; i++ )\r
1084                                 ret.push( array[ i ] );\r
1085                 else\r
1086                         ret = array.slice( 0 );\r
1087 \r
1088                 return ret;\r
1089         },\r
1090 \r
1091         inArray: function( elem, array ) {\r
1092                 for ( var i = 0, length = array.length; i < length; i++ )\r
1093                         if ( array[ i ] == elem )\r
1094                                 return i;\r
1095 \r
1096                 return -1;\r
1097         },\r
1098 \r
1099         merge: function( first, second ) {\r
1100                 // We have to loop this way because IE & Opera overwrite the length\r
1101                 // expando of getElementsByTagName\r
1102 \r
1103                 // Also, we need to make sure that the correct elements are being returned\r
1104                 // (IE returns comment nodes in a '*' query)\r
1105                 if ( jQuery.browser.msie ) {\r
1106                         for ( var i = 0; second[ i ]; i++ )\r
1107                                 if ( second[ i ].nodeType != 8 )\r
1108                                         first.push( second[ i ] );\r
1109 \r
1110                 } else\r
1111                         for ( var i = 0; second[ i ]; i++ )\r
1112                                 first.push( second[ i ] );\r
1113 \r
1114                 return first;\r
1115         },\r
1116 \r
1117         unique: function( array ) {\r
1118                 var ret = [], done = {};\r
1119 \r
1120                 try {\r
1121 \r
1122                         for ( var i = 0, length = array.length; i < length; i++ ) {\r
1123                                 var id = jQuery.data( array[ i ] );\r
1124 \r
1125                                 if ( !done[ id ] ) {\r
1126                                         done[ id ] = true;\r
1127                                         ret.push( array[ i ] );\r
1128                                 }\r
1129                         }\r
1130 \r
1131                 } catch( e ) {\r
1132                         ret = array;\r
1133                 }\r
1134 \r
1135                 return ret;\r
1136         },\r
1137 \r
1138         grep: function( elems, callback, inv ) {\r
1139                 // If a string is passed in for the function, make a function\r
1140                 // for it (a handy shortcut)\r
1141                 if ( typeof callback == "string" )\r
1142                         callback = eval("false||function(a,i){return " + callback + "}");\r
1143 \r
1144                 var ret = [];\r
1145 \r
1146                 // Go through the array, only saving the items\r
1147                 // that pass the validator function\r
1148                 for ( var i = 0, length = elems.length; i < length; i++ )\r
1149                         if ( !inv && callback( elems[ i ], i ) || inv && !callback( elems[ i ], i ) )\r
1150                                 ret.push( elems[ i ] );\r
1151 \r
1152                 return ret;\r
1153         },\r
1154 \r
1155         map: function( elems, callback ) {\r
1156                 var ret = [];\r
1157 \r
1158                 // Go through the array, translating each of the items to their\r
1159                 // new value (or values).\r
1160                 for ( var i = 0, length = elems.length; i < length; i++ ) {\r
1161                         var value = callback( elems[ i ], i );\r
1162 \r
1163                         if ( value !== null && value != undefined ) {\r
1164                                 if ( value.constructor != Array )\r
1165                                         value = [ value ];\r
1166 \r
1167                                 ret = ret.concat( value );\r
1168                         }\r
1169                 }\r
1170 \r
1171                 return ret;\r
1172         }\r
1173 });\r
1174 \r
1175 var userAgent = navigator.userAgent.toLowerCase();\r
1176 \r
1177 // Figure out what browser is being used\r
1178 jQuery.browser = {\r
1179         version: (userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [])[1],\r
1180         safari: /webkit/.test( userAgent ),\r
1181         opera: /opera/.test( userAgent ),\r
1182         msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ),\r
1183         mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent )\r
1184 };\r
1185 \r
1186 var styleFloat = jQuery.browser.msie ?\r
1187         "styleFloat" :\r
1188         "cssFloat";\r
1189         \r
1190 jQuery.extend({\r
1191         // Check to see if the W3C box model is being used\r
1192         boxModel: !jQuery.browser.msie || document.compatMode == "CSS1Compat",\r
1193         \r
1194         props: {\r
1195                 "for": "htmlFor",\r
1196                 "class": "className",\r
1197                 "float": styleFloat,\r
1198                 cssFloat: styleFloat,\r
1199                 styleFloat: styleFloat,\r
1200                 innerHTML: "innerHTML",\r
1201                 className: "className",\r
1202                 value: "value",\r
1203                 disabled: "disabled",\r
1204                 checked: "checked",\r
1205                 readonly: "readOnly",\r
1206                 selected: "selected",\r
1207                 maxlength: "maxLength",\r
1208                 selectedIndex: "selectedIndex",\r
1209                 defaultValue: "defaultValue"\r
1210         }\r
1211 });\r
1212 \r
1213 jQuery.each({\r
1214         parent: "elem.parentNode",\r
1215         parents: "jQuery.dir(elem,'parentNode')",\r
1216         next: "jQuery.nth(elem,2,'nextSibling')",\r
1217         prev: "jQuery.nth(elem,2,'previousSibling')",\r
1218         nextAll: "jQuery.dir(elem,'nextSibling')",\r
1219         prevAll: "jQuery.dir(elem,'previousSibling')",\r
1220         siblings: "jQuery.sibling(elem.parentNode.firstChild,elem)",\r
1221         children: "jQuery.sibling(elem.firstChild)",\r
1222         contents: "jQuery.nodeName(elem,'iframe')?elem.contentDocument||elem.contentWindow.document:jQuery.makeArray(elem.childNodes)"\r
1223 }, function(name, fn){\r
1224         fn = eval("false||function(elem){return " + fn + "}");\r
1225 \r
1226         jQuery.fn[ name ] = function( selector ) {\r
1227                 var ret = jQuery.map( this, fn );\r
1228 \r
1229                 if ( selector && typeof selector == "string" )\r
1230                         ret = jQuery.multiFilter( selector, ret );\r
1231 \r
1232                 return this.pushStack( jQuery.unique( ret ) );\r
1233         };\r
1234 });\r
1235 \r
1236 jQuery.each({\r
1237         appendTo: "append",\r
1238         prependTo: "prepend",\r
1239         insertBefore: "before",\r
1240         insertAfter: "after",\r
1241         replaceAll: "replaceWith"\r
1242 }, function(name, original){\r
1243         jQuery.fn[ name ] = function() {\r
1244                 var args = arguments;\r
1245 \r
1246                 return this.each(function(){\r
1247                         for ( var i = 0, length = args.length; i < length; i++ )\r
1248                                 jQuery( args[ i ] )[ original ]( this );\r
1249                 });\r
1250         };\r
1251 });\r
1252 \r
1253 jQuery.each({\r
1254         removeAttr: function( name ) {\r
1255                 jQuery.attr( this, name, "" );\r
1256                 this.removeAttribute( name );\r
1257         },\r
1258 \r
1259         addClass: function( classNames ) {\r
1260                 jQuery.className.add( this, classNames );\r
1261         },\r
1262 \r
1263         removeClass: function( classNames ) {\r
1264                 jQuery.className.remove( this, classNames );\r
1265         },\r
1266 \r
1267         toggleClass: function( classNames ) {\r
1268                 jQuery.className[ jQuery.className.has( this, classNames ) ? "remove" : "add" ]( this, classNames );\r
1269         },\r
1270 \r
1271         remove: function( selector ) {\r
1272                 if ( !selector || jQuery.filter( selector, [ this ] ).r.length ) {\r
1273                         // Prevent memory leaks\r
1274                         jQuery( "*", this ).add(this).each(function(){\r
1275                                 jQuery.event.remove(this);\r
1276                                 jQuery.removeData(this);\r
1277                         });\r
1278                         if (this.parentNode)\r
1279                                 this.parentNode.removeChild( this );\r
1280                 }\r
1281         },\r
1282 \r
1283         empty: function() {\r
1284                 // Remove element nodes and prevent memory leaks\r
1285                 jQuery( ">*", this ).remove();\r
1286                 \r
1287                 // Remove any remaining nodes\r
1288                 while ( this.firstChild )\r
1289                         this.removeChild( this.firstChild );\r
1290         }\r
1291 }, function(name, fn){\r
1292         jQuery.fn[ name ] = function(){\r
1293                 return this.each( fn, arguments );\r
1294         };\r
1295 });\r
1296 \r
1297 jQuery.each([ "Height", "Width" ], function(i, name){\r
1298         var type = name.toLowerCase();\r
1299         \r
1300         jQuery.fn[ type ] = function( size ) {\r
1301                 // Get window width or height\r
1302                 return this[0] == window ?\r
1303                         // Opera reports document.body.client[Width/Height] properly in both quirks and standards\r
1304                         jQuery.browser.opera && document.body[ "client" + name ] || \r
1305                         \r
1306                         // Safari reports inner[Width/Height] just fine (Mozilla and Opera include scroll bar widths)\r
1307                         jQuery.browser.safari && window[ "inner" + name ] ||\r
1308                         \r
1309                         // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode\r
1310                         document.compatMode == "CSS1Compat" && document.documentElement[ "client" + name ] || document.body[ "client" + name ] :\r
1311                 \r
1312                         // Get document width or height\r
1313                         this[0] == document ?\r
1314                                 // Either scroll[Width/Height] or offset[Width/Height], whichever is greater (Mozilla reports scrollWidth the same as offsetWidth)\r
1315                                 Math.max( document.body[ "scroll" + name ], document.body[ "offset" + name ] ) :\r
1316         \r
1317                                 // Get or set width or height on the element\r
1318                                 size == undefined ?\r
1319                                         // Get width or height on the element\r
1320                                         (this.length ? jQuery.css( this[0], type ) : null) :\r
1321 \r
1322                                         // Set the width or height on the element (default to pixels if value is unitless)\r
1323                                         this.css( type, size.constructor == String ? size : size + "px" );\r
1324         };\r
1325 });\r