Fixed .val(String) for select elements (#1760) [Thanks Sam]
[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 ( typeof jQuery != "undefined" )\r
14         var _jQuery = 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 ( typeof $ != "undefined" )\r
25         var _$ = $;\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                         jQuery.each(elems, function(){\r
465                                 var elem = clone ?\r
466                                         this.cloneNode( true ) :\r
467                                         this;\r
468 \r
469                                 if ( !evalScript( 0, elem ) )\r
470                                         callback.call( obj, elem );\r
471                         });\r
472                 });\r
473         }\r
474 };\r
475 \r
476 function evalScript( i, elem ) {\r
477         var script = jQuery.nodeName( elem, "script" );\r
478 \r
479         if ( script ) {\r
480                 if ( elem.src )\r
481                         jQuery.ajax({\r
482                                 url: elem.src,\r
483                                 async: false,\r
484                                 dataType: "script"\r
485                         });\r
486 \r
487                 else\r
488                         jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" );\r
489         \r
490                 if ( elem.parentNode )\r
491                         elem.parentNode.removeChild( elem );\r
492 \r
493         } else if ( elem.nodeType == 1 )\r
494                 jQuery( "script", elem ).each( evalScript );\r
495 \r
496         return script;\r
497 }\r
498 \r
499 jQuery.extend = jQuery.fn.extend = function() {\r
500         // copy reference to target object\r
501         var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options;\r
502 \r
503         // Handle a deep copy situation\r
504         if ( target.constructor == Boolean ) {\r
505                 deep = target;\r
506                 target = arguments[1] || {};\r
507         }\r
508 \r
509         // extend jQuery itself if only one argument is passed\r
510         if ( length == 1 ) {\r
511                 target = this;\r
512                 i = 0;\r
513         }\r
514 \r
515         for ( ; i < length; i++ )\r
516                 // Only deal with non-null/undefined values\r
517                 if ( (options = arguments[ i ]) != null )\r
518                         // Extend the base object\r
519                         for ( var name in options ) {\r
520                                 // Prevent never-ending loop\r
521                                 if ( target == options[ name ] )\r
522                                         continue;\r
523 \r
524                                 // Recurse if we're merging object values\r
525                                 if ( deep && typeof options[ name ] == "object" && target[ name ] )\r
526                                         jQuery.extend( target[ name ], options[ name ] );\r
527 \r
528                                 // Don't bring in undefined values\r
529                                 else if ( options[ name ] != undefined )\r
530                                         target[ name ] = options[ name ];\r
531 \r
532                         }\r
533 \r
534         // Return the modified object\r
535         return target;\r
536 };\r
537 \r
538 var expando = "jQuery" + (new Date()).getTime(), uuid = 0, windowData = {};\r
539 \r
540 // exclude the following css properties to add px\r
541 var exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i;\r
542 \r
543 jQuery.extend({\r
544         noConflict: function( deep ) {\r
545                 window.$ = _$;\r
546 \r
547                 if ( deep )\r
548                         window.jQuery = _jQuery;\r
549 \r
550                 return jQuery;\r
551         },\r
552 \r
553         // This may seem like some crazy code, but trust me when I say that this\r
554         // is the only cross-browser way to do this. --John\r
555         isFunction: function( fn ) {\r
556                 return !!fn && typeof fn != "string" && !fn.nodeName && \r
557                         fn.constructor != Array && /function/i.test( fn + "" );\r
558         },\r
559         \r
560         // check if an element is in a (or is an) XML document\r
561         isXMLDoc: function( elem ) {\r
562                 return elem.documentElement && !elem.body ||\r
563                         elem.tagName && elem.ownerDocument && !elem.ownerDocument.body;\r
564         },\r
565 \r
566         // Evalulates a script in a global context\r
567         // Evaluates Async. in Safari 2 :-(\r
568         globalEval: function( data ) {\r
569                 data = jQuery.trim( data );\r
570 \r
571                 if ( data ) {\r
572                         // Inspired by code by Andrea Giammarchi\r
573                         // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html\r
574                         var head = document.getElementsByTagName("head")[0] || document.documentElement,\r
575                                 script = document.createElement("script");\r
576 \r
577                         script.type = "text/javascript";\r
578                         if ( jQuery.browser.msie )\r
579                                 script.text = data;\r
580                         else\r
581                                 script.appendChild( document.createTextNode( data ) );\r
582 \r
583                         head.appendChild( script );\r
584                         head.removeChild( script );\r
585                 }\r
586         },\r
587 \r
588         nodeName: function( elem, name ) {\r
589                 return elem.nodeName && elem.nodeName.toUpperCase() == name.toUpperCase();\r
590         },\r
591         \r
592         cache: {},\r
593         \r
594         data: function( elem, name, data ) {\r
595                 elem = elem == window ?\r
596                         windowData :\r
597                         elem;\r
598 \r
599                 var id = elem[ expando ];\r
600 \r
601                 // Compute a unique ID for the element\r
602                 if ( !id ) \r
603                         id = elem[ expando ] = ++uuid;\r
604 \r
605                 // Only generate the data cache if we're\r
606                 // trying to access or manipulate it\r
607                 if ( name && !jQuery.cache[ id ] )\r
608                         jQuery.cache[ id ] = {};\r
609                 \r
610                 // Prevent overriding the named cache with undefined values\r
611                 if ( data != undefined )\r
612                         jQuery.cache[ id ][ name ] = data;\r
613                 \r
614                 // Return the named cache data, or the ID for the element       \r
615                 return name ?\r
616                         jQuery.cache[ id ][ name ] :\r
617                         id;\r
618         },\r
619         \r
620         removeData: function( elem, name ) {\r
621                 elem = elem == window ?\r
622                         windowData :\r
623                         elem;\r
624 \r
625                 var id = elem[ expando ];\r
626 \r
627                 // If we want to remove a specific section of the element's data\r
628                 if ( name ) {\r
629                         if ( jQuery.cache[ id ] ) {\r
630                                 // Remove the section of cache data\r
631                                 delete jQuery.cache[ id ][ name ];\r
632 \r
633                                 // If we've removed all the data, remove the element's cache\r
634                                 name = "";\r
635 \r
636                                 for ( name in jQuery.cache[ id ] )\r
637                                         break;\r
638 \r
639                                 if ( !name )\r
640                                         jQuery.removeData( elem );\r
641                         }\r
642 \r
643                 // Otherwise, we want to remove all of the element's data\r
644                 } else {\r
645                         // Clean up the element expando\r
646                         try {\r
647                                 delete elem[ expando ];\r
648                         } catch(e){\r
649                                 // IE has trouble directly removing the expando\r
650                                 // but it's ok with using removeAttribute\r
651                                 if ( elem.removeAttribute )\r
652                                         elem.removeAttribute( expando );\r
653                         }\r
654 \r
655                         // Completely remove the data cache\r
656                         delete jQuery.cache[ id ];\r
657                 }\r
658         },\r
659 \r
660         // args is for internal usage only\r
661         each: function( object, callback, args ) {\r
662                 if ( args ) {\r
663                         if ( object.length == undefined )\r
664                                 for ( var name in object )\r
665                                         callback.apply( object[ name ], args );\r
666                         else\r
667                                 for ( var i = 0, length = object.length; i < length; i++ )\r
668                                         if ( callback.apply( object[ i ], args ) === false )\r
669                                                 break;\r
670 \r
671                 // A special, fast, case for the most common use of each\r
672                 } else {\r
673                         if ( object.length == undefined )\r
674                                 for ( var name in object )\r
675                                         callback.call( object[ name ], name, object[ name ] );\r
676                         else\r
677                                 for ( var i = 0, length = object.length, value = object[0]; \r
678                                         i < length && callback.call( value, i, value ) !== false; value = object[++i] ){}\r
679                 }\r
680 \r
681                 return object;\r
682         },\r
683         \r
684         prop: function( elem, value, type, i, name ) {\r
685                         // Handle executable functions\r
686                         if ( jQuery.isFunction( value ) )\r
687                                 value = value.call( elem, i );\r
688                                 \r
689                         // Handle passing in a number to a CSS property\r
690                         return value && value.constructor == Number && type == "curCSS" && !exclude.test( name ) ?\r
691                                 value + "px" :\r
692                                 value;\r
693         },\r
694 \r
695         className: {\r
696                 // internal only, use addClass("class")\r
697                 add: function( elem, classNames ) {\r
698                         jQuery.each((classNames || "").split(/\s+/), function(i, className){\r
699                                 if ( !jQuery.className.has( elem.className, className ) )\r
700                                         elem.className += (elem.className ? " " : "") + className;\r
701                         });\r
702                 },\r
703 \r
704                 // internal only, use removeClass("class")\r
705                 remove: function( elem, classNames ) {\r
706                         elem.className = classNames != undefined ?\r
707                                 jQuery.grep(elem.className.split(/\s+/), function(className){\r
708                                         return !jQuery.className.has( classNames, className );  \r
709                                 }).join(" ") :\r
710                                 "";\r
711                 },\r
712 \r
713                 // internal only, use is(".class")\r
714                 has: function( elem, className ) {\r
715                         return jQuery.inArray( className, (elem.className || elem).toString().split(/\s+/) ) > -1;\r
716                 }\r
717         },\r
718 \r
719         // A method for quickly swapping in/out CSS properties to get correct calculations\r
720         swap: function( elem, options, callback ) {\r
721                 // Remember the old values, and insert the new ones\r
722                 for ( var name in options ) {\r
723                         elem.style[ "old" + name ] = elem.style[ name ];\r
724                         elem.style[ name ] = options[ name ];\r
725                 }\r
726 \r
727                 callback.call( elem );\r
728 \r
729                 // Revert the old values\r
730                 for ( var name in options )\r
731                         elem.style[ name ] = elem.style[ "old" + name ];\r
732         },\r
733 \r
734         css: function( elem, name ) {\r
735                 if ( name == "height" || name == "width" ) {\r
736                         var old = {}, height, width;\r
737 \r
738                         // Revert the padding and border widths to get the\r
739                         // correct height/width values\r
740                         jQuery.each([ "Top", "Bottom", "Right", "Left" ], function(){\r
741                                 old[ "padding" + this ] = 0;\r
742                                 old[ "border" + this + "Width" ] = 0;\r
743                         });\r
744 \r
745                         // Swap out the padding/border values temporarily\r
746                         jQuery.swap( elem, old, function() {\r
747 \r
748                                 // If the element is visible, then the calculation is easy\r
749                                 if ( jQuery( elem ).is(":visible") ) {\r
750                                         height = elem.offsetHeight;\r
751                                         width = elem.offsetWidth;\r
752 \r
753                                 // Otherwise, we need to flip out more values\r
754                                 } else {\r
755                                         elem = jQuery( elem.cloneNode(true) )\r
756                                                 .find(":radio").removeAttr("checked").end()\r
757                                                 .css({\r
758                                                         visibility: "hidden",\r
759                                                         position: "absolute",\r
760                                                         display: "block",\r
761                                                         right: "0",\r
762                                                         left: "0"\r
763                                                 }).appendTo( elem.parentNode )[0];\r
764 \r
765                                         var position = jQuery.css( elem.parentNode, "position" ) || "static";\r
766                                         if ( position == "static" )\r
767                                                 elem.parentNode.style.position = "relative";\r
768 \r
769                                         height = elem.clientHeight;\r
770                                         width = elem.clientWidth;\r
771 \r
772                                         if ( position == "static" )\r
773                                                 elem.parentNode.style.position = "static";\r
774 \r
775                                         elem.parentNode.removeChild( elem );\r
776                                 }\r
777                         });\r
778 \r
779                         return name == "height" ?\r
780                                 height :\r
781                                 width;\r
782                 }\r
783 \r
784                 return jQuery.curCSS( elem, name );\r
785         },\r
786 \r
787         curCSS: function( elem, name, force ) {\r
788                 var ret;\r
789 \r
790                 // A helper method for determining if an element's values are broken\r
791                 function color( elem ) {\r
792                         if ( !jQuery.browser.safari )\r
793                                 return false;\r
794 \r
795                         var ret = document.defaultView.getComputedStyle( elem, null );\r
796                         return !ret || ret.getPropertyValue("color") == "";\r
797                 }\r
798 \r
799                 // We need to handle opacity special in IE\r
800                 if ( name == "opacity" && jQuery.browser.msie ) {\r
801                         ret = jQuery.attr( elem.style, "opacity" );\r
802 \r
803                         return ret == "" ?\r
804                                 "1" :\r
805                                 ret;\r
806                 }\r
807                 \r
808                 // Make sure we're using the right name for getting the float value\r
809                 if ( name.match( /float/i ) )\r
810                         name = styleFloat;\r
811 \r
812                 if ( !force && elem.style[ name ] )\r
813                         ret = elem.style[ name ];\r
814 \r
815                 else if ( document.defaultView && document.defaultView.getComputedStyle ) {\r
816 \r
817                         // Only "float" is needed here\r
818                         if ( name.match( /float/i ) )\r
819                                 name = "float";\r
820 \r
821                         name = name.replace( /([A-Z])/g, "-$1" ).toLowerCase();\r
822 \r
823                         var getComputedStyle = document.defaultView.getComputedStyle( elem, null );\r
824 \r
825                         if ( getComputedStyle && !color( elem ) )\r
826                                 ret = getComputedStyle.getPropertyValue( name );\r
827 \r
828                         // If the element isn't reporting its values properly in Safari\r
829                         // then some display: none elements are involved\r
830                         else {\r
831                                 var swap = [], stack = [];\r
832 \r
833                                 // Locate all of the parent display: none elements\r
834                                 for ( var a = elem; a && color(a); a = a.parentNode )\r
835                                         stack.unshift(a);\r
836 \r
837                                 // Go through and make them visible, but in reverse\r
838                                 // (It would be better if we knew the exact display type that they had)\r
839                                 for ( var i = 0; i < stack.length; i++ )\r
840                                         if ( color( stack[ i ] ) ) {\r
841                                                 swap[ i ] = stack[ i ].style.display;\r
842                                                 stack[ i ].style.display = "block";\r
843                                         }\r
844 \r
845                                 // Since we flip the display style, we have to handle that\r
846                                 // one special, otherwise get the value\r
847                                 ret = name == "display" && swap[ stack.length - 1 ] != null ?\r
848                                         "none" :\r
849                                         ( getComputedStyle && getComputedStyle.getPropertyValue( name ) ) || "";\r
850 \r
851                                 // Finally, revert the display styles back\r
852                                 for ( var i = 0; i < swap.length; i++ )\r
853                                         if ( swap[ i ] != null )\r
854                                                 stack[ i ].style.display = swap[ i ];\r
855                         }\r
856 \r
857                         // We should always get a number back from opacity\r
858                         if ( name == "opacity" && ret == "" )\r
859                                 ret = "1";\r
860 \r
861                 } else if ( elem.currentStyle ) {\r
862                         var camelCase = name.replace(/\-(\w)/g, function(all, letter){\r
863                                 return letter.toUpperCase();\r
864                         });\r
865 \r
866                         ret = elem.currentStyle[ name ] || elem.currentStyle[ camelCase ];\r
867 \r
868                         // From the awesome hack by Dean Edwards\r
869                         // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291\r
870 \r
871                         // If we're not dealing with a regular pixel number\r
872                         // but a number that has a weird ending, we need to convert it to pixels\r
873                         if ( !/^\d+(px)?$/i.test( ret ) && /^\d/.test( ret ) ) {\r
874                                 // Remember the original values\r
875                                 var style = elem.style.left, runtimeStyle = elem.runtimeStyle.left;\r
876 \r
877                                 // Put in the new values to get a computed value out\r
878                                 elem.runtimeStyle.left = elem.currentStyle.left;\r
879                                 elem.style.left = ret || 0;\r
880                                 ret = elem.style.pixelLeft + "px";\r
881 \r
882                                 // Revert the changed values\r
883                                 elem.style.left = style;\r
884                                 elem.runtimeStyle.left = runtimeStyle;\r
885                         }\r
886                 }\r
887 \r
888                 return ret;\r
889         },\r
890         \r
891         clean: function( elems, context ) {\r
892                 var ret = [];\r
893                 context = context || document;\r
894 \r
895                 jQuery.each(elems, function(i, elem){\r
896                         if ( !elem )\r
897                                 return;\r
898 \r
899                         if ( elem.constructor == Number )\r
900                                 elem = elem.toString();\r
901                         \r
902                         // Convert html string into DOM nodes\r
903                         if ( typeof elem == "string" ) {\r
904                                 // Fix "XHTML"-style tags in all browsers\r
905                                 elem = elem.replace(/(<(\w+)[^>]*?)\/>/g, function(all, front, tag){\r
906                                         return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area)$/i) ?\r
907                                                 all :\r
908                                                 front + "></" + tag + ">";\r
909                                 });\r
910 \r
911                                 // Trim whitespace, otherwise indexOf won't work as expected\r
912                                 var tags = jQuery.trim( elem ).toLowerCase(), div = context.createElement("div");\r
913 \r
914                                 var wrap =\r
915                                         // option or optgroup\r
916                                         !tags.indexOf("<opt") &&\r
917                                         [ 1, "<select>", "</select>" ] ||\r
918                                         \r
919                                         !tags.indexOf("<leg") &&\r
920                                         [ 1, "<fieldset>", "</fieldset>" ] ||\r
921                                         \r
922                                         tags.match(/^<(thead|tbody|tfoot|colg|cap)/) &&\r
923                                         [ 1, "<table>", "</table>" ] ||\r
924                                         \r
925                                         !tags.indexOf("<tr") &&\r
926                                         [ 2, "<table><tbody>", "</tbody></table>" ] ||\r
927                                         \r
928                                         // <thead> matched above\r
929                                         (!tags.indexOf("<td") || !tags.indexOf("<th")) &&\r
930                                         [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ] ||\r
931                                         \r
932                                         !tags.indexOf("<col") &&\r
933                                         [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ] ||\r
934 \r
935                                         // IE can't serialize <link> and <script> tags normally\r
936                                         jQuery.browser.msie &&\r
937                                         [ 1, "div<div>", "</div>" ] ||\r
938                                         \r
939                                         [ 0, "", "" ];\r
940 \r
941                                 // Go to html and back, then peel off extra wrappers\r
942                                 div.innerHTML = wrap[1] + elem + wrap[2];\r
943                                 \r
944                                 // Move to the right depth\r
945                                 while ( wrap[0]-- )\r
946                                         div = div.lastChild;\r
947                                 \r
948                                 // Remove IE's autoinserted <tbody> from table fragments\r
949                                 if ( jQuery.browser.msie ) {\r
950                                         \r
951                                         // String was a <table>, *may* have spurious <tbody>\r
952                                         var tbody = !tags.indexOf("<table") && tags.indexOf("<tbody") < 0 ?\r
953                                                 div.firstChild && div.firstChild.childNodes :\r
954                                                 \r
955                                                 // String was a bare <thead> or <tfoot>\r
956                                                 wrap[1] == "<table>" && tags.indexOf("<tbody") < 0 ?\r
957                                                         div.childNodes :\r
958                                                         [];\r
959                                 \r
960                                         for ( var i = tbody.length - 1; i >= 0 ; --i )\r
961                                                 if ( jQuery.nodeName( tbody[ i ], "tbody" ) && !tbody[ i ].childNodes.length )\r
962                                                         tbody[ i ].parentNode.removeChild( tbody[ i ] );\r
963                                         \r
964                                         // IE completely kills leading whitespace when innerHTML is used        \r
965                                         if ( /^\s/.test( elem ) )       \r
966                                                 div.insertBefore( context.createTextNode( elem.match(/^\s*/)[0] ), div.firstChild );\r
967                                 \r
968                                 }\r
969                                 \r
970                                 elem = jQuery.makeArray( div.childNodes );\r
971                         }\r
972 \r
973                         if ( elem.length === 0 && (!jQuery.nodeName( elem, "form" ) && !jQuery.nodeName( elem, "select" )) )\r
974                                 return;\r
975 \r
976                         if ( elem[0] == undefined || jQuery.nodeName( elem, "form" ) || elem.options )\r
977                                 ret.push( elem );\r
978 \r
979                         else\r
980                                 ret = jQuery.merge( ret, elem );\r
981 \r
982                 });\r
983 \r
984                 return ret;\r
985         },\r
986         \r
987         attr: function( elem, name, value ) {\r
988                 var fix = jQuery.isXMLDoc( elem ) ?\r
989                         {} :\r
990                         jQuery.props;\r
991 \r
992                 // Safari mis-reports the default selected property of a hidden option\r
993                 // Accessing the parent's selectedIndex property fixes it\r
994                 if ( name == "selected" && jQuery.browser.safari )\r
995                         elem.parentNode.selectedIndex;\r
996                 \r
997                 // Certain attributes only work when accessed via the old DOM 0 way\r
998                 if ( fix[ name ] ) {\r
999                         if ( value != undefined )\r
1000                                 elem[ fix[ name ] ] = value;\r
1001 \r
1002                         return elem[ fix[ name ] ];\r
1003 \r
1004                 } else if ( jQuery.browser.msie && name == "style" )\r
1005                         return jQuery.attr( elem.style, "cssText", value );\r
1006 \r
1007                 else if ( value == undefined && jQuery.browser.msie && jQuery.nodeName( elem, "form" ) && (name == "action" || name == "method") )\r
1008                         return elem.getAttributeNode( name ).nodeValue;\r
1009 \r
1010                 // IE elem.getAttribute passes even for style\r
1011                 else if ( elem.tagName ) {\r
1012 \r
1013                         if ( value != undefined ) {\r
1014                                 // We can't allow the type property to be changed (since it causes problems in IE)\r
1015                                 if ( name == "type" && jQuery.nodeName( elem, "input" ) && elem.parentNode )\r
1016                                         throw "type property can't be changed";\r
1017 \r
1018                                 elem.setAttribute( name, value );\r
1019                         }\r
1020 \r
1021                         if ( jQuery.browser.msie && /href|src/.test( name ) && !jQuery.isXMLDoc( elem ) ) \r
1022                                 return elem.getAttribute( name, 2 );\r
1023 \r
1024                         return elem.getAttribute( name );\r
1025 \r
1026                 // elem is actually elem.style ... set the style\r
1027                 } else {\r
1028                         // IE actually uses filters for opacity\r
1029                         if ( name == "opacity" && jQuery.browser.msie ) {\r
1030                                 if ( value != undefined ) {\r
1031                                         // IE has trouble with opacity if it does not have layout\r
1032                                         // Force it by setting the zoom level\r
1033                                         elem.zoom = 1; \r
1034         \r
1035                                         // Set the alpha filter to set the opacity\r
1036                                         elem.filter = (elem.filter || "").replace( /alpha\([^)]*\)/, "" ) +\r
1037                                                 (parseFloat( value ).toString() == "NaN" ? "" : "alpha(opacity=" + value * 100 + ")");\r
1038                                 }\r
1039         \r
1040                                 return elem.filter ? \r
1041                                         (parseFloat( elem.filter.match(/opacity=([^)]*)/)[1] ) / 100).toString() :\r
1042                                         "";\r
1043                         }\r
1044 \r
1045                         name = name.replace(/-([a-z])/ig, function(all, letter){\r
1046                                 return letter.toUpperCase();\r
1047                         });\r
1048 \r
1049                         if ( value != undefined )\r
1050                                 elem[ name ] = value;\r
1051 \r
1052                         return elem[ name ];\r
1053                 }\r
1054         },\r
1055         \r
1056         trim: function( text ) {\r
1057                 return (text || "").replace( /^\s+|\s+$/g, "" );\r
1058         },\r
1059 \r
1060         makeArray: function( array ) {\r
1061                 var ret = [];\r
1062 \r
1063                 // Need to use typeof to fight Safari childNodes crashes\r
1064                 if ( typeof array != "array" )\r
1065                         for ( var i = 0, length = array.length; i < length; i++ )\r
1066                                 ret.push( array[ i ] );\r
1067                 else\r
1068                         ret = array.slice( 0 );\r
1069 \r
1070                 return ret;\r
1071         },\r
1072 \r
1073         inArray: function( elem, array ) {\r
1074                 for ( var i = 0, length = array.length; i < length; i++ )\r
1075                         if ( array[ i ] == elem )\r
1076                                 return i;\r
1077 \r
1078                 return -1;\r
1079         },\r
1080 \r
1081         merge: function( first, second ) {\r
1082                 // We have to loop this way because IE & Opera overwrite the length\r
1083                 // expando of getElementsByTagName\r
1084 \r
1085                 // Also, we need to make sure that the correct elements are being returned\r
1086                 // (IE returns comment nodes in a '*' query)\r
1087                 if ( jQuery.browser.msie ) {\r
1088                         for ( var i = 0; second[ i ]; i++ )\r
1089                                 if ( second[ i ].nodeType != 8 )\r
1090                                         first.push( second[ i ] );\r
1091 \r
1092                 } else\r
1093                         for ( var i = 0; second[ i ]; i++ )\r
1094                                 first.push( second[ i ] );\r
1095 \r
1096                 return first;\r
1097         },\r
1098 \r
1099         unique: function( array ) {\r
1100                 var ret = [], done = {};\r
1101 \r
1102                 try {\r
1103 \r
1104                         for ( var i = 0, length = array.length; i < length; i++ ) {\r
1105                                 var id = jQuery.data( array[ i ] );\r
1106 \r
1107                                 if ( !done[ id ] ) {\r
1108                                         done[ id ] = true;\r
1109                                         ret.push( array[ i ] );\r
1110                                 }\r
1111                         }\r
1112 \r
1113                 } catch( e ) {\r
1114                         ret = array;\r
1115                 }\r
1116 \r
1117                 return ret;\r
1118         },\r
1119 \r
1120         grep: function( elems, callback, inv ) {\r
1121                 // If a string is passed in for the function, make a function\r
1122                 // for it (a handy shortcut)\r
1123                 if ( typeof callback == "string" )\r
1124                         callback = eval("false||function(a,i){return " + callback + "}");\r
1125 \r
1126                 var ret = [];\r
1127 \r
1128                 // Go through the array, only saving the items\r
1129                 // that pass the validator function\r
1130                 for ( var i = 0, length = elems.length; i < length; i++ )\r
1131                         if ( !inv && callback( elems[ i ], i ) || inv && !callback( elems[ i ], i ) )\r
1132                                 ret.push( elems[ i ] );\r
1133 \r
1134                 return ret;\r
1135         },\r
1136 \r
1137         map: function( elems, callback ) {\r
1138                 var ret = [];\r
1139 \r
1140                 // Go through the array, translating each of the items to their\r
1141                 // new value (or values).\r
1142                 for ( var i = 0, length = elems.length; i < length; i++ ) {\r
1143                         var value = callback( elems[ i ], i );\r
1144 \r
1145                         if ( value !== null && value != undefined ) {\r
1146                                 if ( value.constructor != Array )\r
1147                                         value = [ value ];\r
1148 \r
1149                                 ret = ret.concat( value );\r
1150                         }\r
1151                 }\r
1152 \r
1153                 return ret;\r
1154         }\r
1155 });\r
1156 \r
1157 var userAgent = navigator.userAgent.toLowerCase();\r
1158 \r
1159 // Figure out what browser is being used\r
1160 jQuery.browser = {\r
1161         version: (userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [])[1],\r
1162         safari: /webkit/.test( userAgent ),\r
1163         opera: /opera/.test( userAgent ),\r
1164         msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ),\r
1165         mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent )\r
1166 };\r
1167 \r
1168 var styleFloat = jQuery.browser.msie ?\r
1169         "styleFloat" :\r
1170         "cssFloat";\r
1171         \r
1172 jQuery.extend({\r
1173         // Check to see if the W3C box model is being used\r
1174         boxModel: !jQuery.browser.msie || document.compatMode == "CSS1Compat",\r
1175         \r
1176         props: {\r
1177                 "for": "htmlFor",\r
1178                 "class": "className",\r
1179                 "float": styleFloat,\r
1180                 cssFloat: styleFloat,\r
1181                 styleFloat: styleFloat,\r
1182                 innerHTML: "innerHTML",\r
1183                 className: "className",\r
1184                 value: "value",\r
1185                 disabled: "disabled",\r
1186                 checked: "checked",\r
1187                 readonly: "readOnly",\r
1188                 selected: "selected",\r
1189                 maxlength: "maxLength",\r
1190                 selectedIndex: "selectedIndex"\r
1191         }\r
1192 });\r
1193 \r
1194 jQuery.each({\r
1195         parent: "elem.parentNode",\r
1196         parents: "jQuery.dir(elem,'parentNode')",\r
1197         next: "jQuery.nth(elem,2,'nextSibling')",\r
1198         prev: "jQuery.nth(elem,2,'previousSibling')",\r
1199         nextAll: "jQuery.dir(elem,'nextSibling')",\r
1200         prevAll: "jQuery.dir(elem,'previousSibling')",\r
1201         siblings: "jQuery.sibling(elem.parentNode.firstChild,elem)",\r
1202         children: "jQuery.sibling(elem.firstChild)",\r
1203         contents: "jQuery.nodeName(elem,'iframe')?elem.contentDocument||elem.contentWindow.document:jQuery.makeArray(elem.childNodes)"\r
1204 }, function(name, fn){\r
1205         fn = eval("false||function(elem){return " + fn + "}");\r
1206 \r
1207         jQuery.fn[ name ] = function( selector ) {\r
1208                 var ret = jQuery.map( this, fn );\r
1209 \r
1210                 if ( selector && typeof selector == "string" )\r
1211                         ret = jQuery.multiFilter( selector, ret );\r
1212 \r
1213                 return this.pushStack( jQuery.unique( ret ) );\r
1214         };\r
1215 });\r
1216 \r
1217 jQuery.each({\r
1218         appendTo: "append",\r
1219         prependTo: "prepend",\r
1220         insertBefore: "before",\r
1221         insertAfter: "after",\r
1222         replaceAll: "replaceWith"\r
1223 }, function(name, original){\r
1224         jQuery.fn[ name ] = function() {\r
1225                 var args = arguments;\r
1226 \r
1227                 return this.each(function(){\r
1228                         for ( var i = 0, length = args.length; i < length; i++ )\r
1229                                 jQuery( args[ i ] )[ original ]( this );\r
1230                 });\r
1231         };\r
1232 });\r
1233 \r
1234 jQuery.each({\r
1235         removeAttr: function( name ) {\r
1236                 jQuery.attr( this, name, "" );\r
1237                 this.removeAttribute( name );\r
1238         },\r
1239 \r
1240         addClass: function( classNames ) {\r
1241                 jQuery.className.add( this, classNames );\r
1242         },\r
1243 \r
1244         removeClass: function( classNames ) {\r
1245                 jQuery.className.remove( this, classNames );\r
1246         },\r
1247 \r
1248         toggleClass: function( classNames ) {\r
1249                 jQuery.className[ jQuery.className.has( this, classNames ) ? "remove" : "add" ]( this, classNames );\r
1250         },\r
1251 \r
1252         remove: function( selector ) {\r
1253                 if ( !selector || jQuery.filter( selector, [ this ] ).r.length ) {\r
1254                         // Prevent memory leaks\r
1255                         jQuery( "*", this ).add(this).each(function(){\r
1256                                 jQuery.event.remove(this);\r
1257                                 jQuery.removeData(this);\r
1258                         });\r
1259                         this.parentNode.removeChild( this );\r
1260                 }\r
1261         },\r
1262 \r
1263         empty: function() {\r
1264                 // Remove element nodes and prevent memory leaks\r
1265                 jQuery( ">*", this ).remove();\r
1266                 \r
1267                 // Remove any remaining nodes\r
1268                 while ( this.firstChild )\r
1269                         this.removeChild( this.firstChild );\r
1270         }\r
1271 }, function(name, fn){\r
1272         jQuery.fn[ name ] = function(){\r
1273                 return this.each( fn, arguments );\r
1274         };\r
1275 });\r
1276 \r
1277 jQuery.each([ "Height", "Width" ], function(i, name){\r
1278         var type = name.toLowerCase();\r
1279         \r
1280         jQuery.fn[ type ] = function( size ) {\r
1281                 // Get window width or height\r
1282                 return this[0] == window ?\r
1283                         // Opera reports document.body.client[Width/Height] properly in both quirks and standards\r
1284                         jQuery.browser.opera && document.body[ "client" + name ] || \r
1285                         \r
1286                         // Safari reports inner[Width/Height] just fine (Mozilla and Opera include scroll bar widths)\r
1287                         jQuery.browser.safari && self[ "inner" + name ] ||\r
1288                         \r
1289                         // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode\r
1290                         document.compatMode == "CSS1Compat" && document.documentElement[ "client" + name ] || document.body[ "client" + name ] :\r
1291                 \r
1292                         // Get document width or height\r
1293                         this[0] == document ?\r
1294                                 // Either scroll[Width/Height] or offset[Width/Height], whichever is greater (Mozilla reports scrollWidth the same as offsetWidth)\r
1295                                 Math.max( document.body[ "scroll" + name ], document.body[ "offset" + name ] ) :\r
1296         \r
1297                                 // Get or set width or height on the element\r
1298                                 size == undefined ?\r
1299                                         // Get width or height on the element\r
1300                                         (this.length ? jQuery.css( this[0], type ) : null) :\r
1301 \r
1302                                         // Set the width or height on the element (default to pixels if value is unitless)\r
1303                                         this.css( type, size.constructor == String ? size : size + "px" );\r
1304         };\r
1305 });\r