Imported Upstream version 0.8.0.4
[psensor-pkg-ubuntu.git] / www / jquery.js
1 /*!
2  * jQuery JavaScript Library v1.6.4
3  * http://jquery.com/
4  *
5  * Copyright 2011, John Resig
6  * Dual licensed under the MIT or GPL Version 2 licenses.
7  * http://jquery.org/license
8  *
9  * Includes Sizzle.js
10  * http://sizzlejs.com/
11  * Copyright 2011, The Dojo Foundation
12  * Released under the MIT, BSD, and GPL Licenses.
13  *
14  * Date: Mon Sep 12 18:54:48 2011 -0400
15  */
16 (function( window, undefined ) {
17
18 // Use the correct document accordingly with window argument (sandbox)
19 var document = window.document,
20         navigator = window.navigator,
21         location = window.location;
22 var jQuery = (function() {
23
24 // Define a local copy of jQuery
25 var jQuery = function( selector, context ) {
26                 // The jQuery object is actually just the init constructor 'enhanced'
27                 return new jQuery.fn.init( selector, context, rootjQuery );
28         },
29
30         // Map over jQuery in case of overwrite
31         _jQuery = window.jQuery,
32
33         // Map over the $ in case of overwrite
34         _$ = window.$,
35
36         // A central reference to the root jQuery(document)
37         rootjQuery,
38
39         // A simple way to check for HTML strings or ID strings
40         // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
41         quickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,
42
43         // Check if a string has a non-whitespace character in it
44         rnotwhite = /\S/,
45
46         // Used for trimming whitespace
47         trimLeft = /^\s+/,
48         trimRight = /\s+$/,
49
50         // Check for digits
51         rdigit = /\d/,
52
53         // Match a standalone tag
54         rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
55
56         // JSON RegExp
57         rvalidchars = /^[\],:{}\s]*$/,
58         rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,
59         rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
60         rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
61
62         // Useragent RegExp
63         rwebkit = /(webkit)[ \/]([\w.]+)/,
64         ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/,
65         rmsie = /(msie) ([\w.]+)/,
66         rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/,
67
68         // Matches dashed string for camelizing
69         rdashAlpha = /-([a-z]|[0-9])/ig,
70         rmsPrefix = /^-ms-/,
71
72         // Used by jQuery.camelCase as callback to replace()
73         fcamelCase = function( all, letter ) {
74                 return ( letter + "" ).toUpperCase();
75         },
76
77         // Keep a UserAgent string for use with jQuery.browser
78         userAgent = navigator.userAgent,
79
80         // For matching the engine and version of the browser
81         browserMatch,
82
83         // The deferred used on DOM ready
84         readyList,
85
86         // The ready event handler
87         DOMContentLoaded,
88
89         // Save a reference to some core methods
90         toString = Object.prototype.toString,
91         hasOwn = Object.prototype.hasOwnProperty,
92         push = Array.prototype.push,
93         slice = Array.prototype.slice,
94         trim = String.prototype.trim,
95         indexOf = Array.prototype.indexOf,
96
97         // [[Class]] -> type pairs
98         class2type = {};
99
100 jQuery.fn = jQuery.prototype = {
101         constructor: jQuery,
102         init: function( selector, context, rootjQuery ) {
103                 var match, elem, ret, doc;
104
105                 // Handle $(""), $(null), or $(undefined)
106                 if ( !selector ) {
107                         return this;
108                 }
109
110                 // Handle $(DOMElement)
111                 if ( selector.nodeType ) {
112                         this.context = this[0] = selector;
113                         this.length = 1;
114                         return this;
115                 }
116
117                 // The body element only exists once, optimize finding it
118                 if ( selector === "body" && !context && document.body ) {
119                         this.context = document;
120                         this[0] = document.body;
121                         this.selector = selector;
122                         this.length = 1;
123                         return this;
124                 }
125
126                 // Handle HTML strings
127                 if ( typeof selector === "string" ) {
128                         // Are we dealing with HTML string or an ID?
129                         if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
130                                 // Assume that strings that start and end with <> are HTML and skip the regex check
131                                 match = [ null, selector, null ];
132
133                         } else {
134                                 match = quickExpr.exec( selector );
135                         }
136
137                         // Verify a match, and that no context was specified for #id
138                         if ( match && (match[1] || !context) ) {
139
140                                 // HANDLE: $(html) -> $(array)
141                                 if ( match[1] ) {
142                                         context = context instanceof jQuery ? context[0] : context;
143                                         doc = (context ? context.ownerDocument || context : document);
144
145                                         // If a single string is passed in and it's a single tag
146                                         // just do a createElement and skip the rest
147                                         ret = rsingleTag.exec( selector );
148
149                                         if ( ret ) {
150                                                 if ( jQuery.isPlainObject( context ) ) {
151                                                         selector = [ document.createElement( ret[1] ) ];
152                                                         jQuery.fn.attr.call( selector, context, true );
153
154                                                 } else {
155                                                         selector = [ doc.createElement( ret[1] ) ];
156                                                 }
157
158                                         } else {
159                                                 ret = jQuery.buildFragment( [ match[1] ], [ doc ] );
160                                                 selector = (ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment).childNodes;
161                                         }
162
163                                         return jQuery.merge( this, selector );
164
165                                 // HANDLE: $("#id")
166                                 } else {
167                                         elem = document.getElementById( match[2] );
168
169                                         // Check parentNode to catch when Blackberry 4.6 returns
170                                         // nodes that are no longer in the document #6963
171                                         if ( elem && elem.parentNode ) {
172                                                 // Handle the case where IE and Opera return items
173                                                 // by name instead of ID
174                                                 if ( elem.id !== match[2] ) {
175                                                         return rootjQuery.find( selector );
176                                                 }
177
178                                                 // Otherwise, we inject the element directly into the jQuery object
179                                                 this.length = 1;
180                                                 this[0] = elem;
181                                         }
182
183                                         this.context = document;
184                                         this.selector = selector;
185                                         return this;
186                                 }
187
188                         // HANDLE: $(expr, $(...))
189                         } else if ( !context || context.jquery ) {
190                                 return (context || rootjQuery).find( selector );
191
192                         // HANDLE: $(expr, context)
193                         // (which is just equivalent to: $(context).find(expr)
194                         } else {
195                                 return this.constructor( context ).find( selector );
196                         }
197
198                 // HANDLE: $(function)
199                 // Shortcut for document ready
200                 } else if ( jQuery.isFunction( selector ) ) {
201                         return rootjQuery.ready( selector );
202                 }
203
204                 if (selector.selector !== undefined) {
205                         this.selector = selector.selector;
206                         this.context = selector.context;
207                 }
208
209                 return jQuery.makeArray( selector, this );
210         },
211
212         // Start with an empty selector
213         selector: "",
214
215         // The current version of jQuery being used
216         jquery: "1.6.4",
217
218         // The default length of a jQuery object is 0
219         length: 0,
220
221         // The number of elements contained in the matched element set
222         size: function() {
223                 return this.length;
224         },
225
226         toArray: function() {
227                 return slice.call( this, 0 );
228         },
229
230         // Get the Nth element in the matched element set OR
231         // Get the whole matched element set as a clean array
232         get: function( num ) {
233                 return num == null ?
234
235                         // Return a 'clean' array
236                         this.toArray() :
237
238                         // Return just the object
239                         ( num < 0 ? this[ this.length + num ] : this[ num ] );
240         },
241
242         // Take an array of elements and push it onto the stack
243         // (returning the new matched element set)
244         pushStack: function( elems, name, selector ) {
245                 // Build a new jQuery matched element set
246                 var ret = this.constructor();
247
248                 if ( jQuery.isArray( elems ) ) {
249                         push.apply( ret, elems );
250
251                 } else {
252                         jQuery.merge( ret, elems );
253                 }
254
255                 // Add the old object onto the stack (as a reference)
256                 ret.prevObject = this;
257
258                 ret.context = this.context;
259
260                 if ( name === "find" ) {
261                         ret.selector = this.selector + (this.selector ? " " : "") + selector;
262                 } else if ( name ) {
263                         ret.selector = this.selector + "." + name + "(" + selector + ")";
264                 }
265
266                 // Return the newly-formed element set
267                 return ret;
268         },
269
270         // Execute a callback for every element in the matched set.
271         // (You can seed the arguments with an array of args, but this is
272         // only used internally.)
273         each: function( callback, args ) {
274                 return jQuery.each( this, callback, args );
275         },
276
277         ready: function( fn ) {
278                 // Attach the listeners
279                 jQuery.bindReady();
280
281                 // Add the callback
282                 readyList.done( fn );
283
284                 return this;
285         },
286
287         eq: function( i ) {
288                 return i === -1 ?
289                         this.slice( i ) :
290                         this.slice( i, +i + 1 );
291         },
292
293         first: function() {
294                 return this.eq( 0 );
295         },
296
297         last: function() {
298                 return this.eq( -1 );
299         },
300
301         slice: function() {
302                 return this.pushStack( slice.apply( this, arguments ),
303                         "slice", slice.call(arguments).join(",") );
304         },
305
306         map: function( callback ) {
307                 return this.pushStack( jQuery.map(this, function( elem, i ) {
308                         return callback.call( elem, i, elem );
309                 }));
310         },
311
312         end: function() {
313                 return this.prevObject || this.constructor(null);
314         },
315
316         // For internal use only.
317         // Behaves like an Array's method, not like a jQuery method.
318         push: push,
319         sort: [].sort,
320         splice: [].splice
321 };
322
323 // Give the init function the jQuery prototype for later instantiation
324 jQuery.fn.init.prototype = jQuery.fn;
325
326 jQuery.extend = jQuery.fn.extend = function() {
327         var options, name, src, copy, copyIsArray, clone,
328                 target = arguments[0] || {},
329                 i = 1,
330                 length = arguments.length,
331                 deep = false;
332
333         // Handle a deep copy situation
334         if ( typeof target === "boolean" ) {
335                 deep = target;
336                 target = arguments[1] || {};
337                 // skip the boolean and the target
338                 i = 2;
339         }
340
341         // Handle case when target is a string or something (possible in deep copy)
342         if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
343                 target = {};
344         }
345
346         // extend jQuery itself if only one argument is passed
347         if ( length === i ) {
348                 target = this;
349                 --i;
350         }
351
352         for ( ; i < length; i++ ) {
353                 // Only deal with non-null/undefined values
354                 if ( (options = arguments[ i ]) != null ) {
355                         // Extend the base object
356                         for ( name in options ) {
357                                 src = target[ name ];
358                                 copy = options[ name ];
359
360                                 // Prevent never-ending loop
361                                 if ( target === copy ) {
362                                         continue;
363                                 }
364
365                                 // Recurse if we're merging plain objects or arrays
366                                 if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
367                                         if ( copyIsArray ) {
368                                                 copyIsArray = false;
369                                                 clone = src && jQuery.isArray(src) ? src : [];
370
371                                         } else {
372                                                 clone = src && jQuery.isPlainObject(src) ? src : {};
373                                         }
374
375                                         // Never move original objects, clone them
376                                         target[ name ] = jQuery.extend( deep, clone, copy );
377
378                                 // Don't bring in undefined values
379                                 } else if ( copy !== undefined ) {
380                                         target[ name ] = copy;
381                                 }
382                         }
383                 }
384         }
385
386         // Return the modified object
387         return target;
388 };
389
390 jQuery.extend({
391         noConflict: function( deep ) {
392                 if ( window.$ === jQuery ) {
393                         window.$ = _$;
394                 }
395
396                 if ( deep && window.jQuery === jQuery ) {
397                         window.jQuery = _jQuery;
398                 }
399
400                 return jQuery;
401         },
402
403         // Is the DOM ready to be used? Set to true once it occurs.
404         isReady: false,
405
406         // A counter to track how many items to wait for before
407         // the ready event fires. See #6781
408         readyWait: 1,
409
410         // Hold (or release) the ready event
411         holdReady: function( hold ) {
412                 if ( hold ) {
413                         jQuery.readyWait++;
414                 } else {
415                         jQuery.ready( true );
416                 }
417         },
418
419         // Handle when the DOM is ready
420         ready: function( wait ) {
421                 // Either a released hold or an DOMready/load event and not yet ready
422                 if ( (wait === true && !--jQuery.readyWait) || (wait !== true && !jQuery.isReady) ) {
423                         // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
424                         if ( !document.body ) {
425                                 return setTimeout( jQuery.ready, 1 );
426                         }
427
428                         // Remember that the DOM is ready
429                         jQuery.isReady = true;
430
431                         // If a normal DOM Ready event fired, decrement, and wait if need be
432                         if ( wait !== true && --jQuery.readyWait > 0 ) {
433                                 return;
434                         }
435
436                         // If there are functions bound, to execute
437                         readyList.resolveWith( document, [ jQuery ] );
438
439                         // Trigger any bound ready events
440                         if ( jQuery.fn.trigger ) {
441                                 jQuery( document ).trigger( "ready" ).unbind( "ready" );
442                         }
443                 }
444         },
445
446         bindReady: function() {
447                 if ( readyList ) {
448                         return;
449                 }
450
451                 readyList = jQuery._Deferred();
452
453                 // Catch cases where $(document).ready() is called after the
454                 // browser event has already occurred.
455                 if ( document.readyState === "complete" ) {
456                         // Handle it asynchronously to allow scripts the opportunity to delay ready
457                         return setTimeout( jQuery.ready, 1 );
458                 }
459
460                 // Mozilla, Opera and webkit nightlies currently support this event
461                 if ( document.addEventListener ) {
462                         // Use the handy event callback
463                         document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
464
465                         // A fallback to window.onload, that will always work
466                         window.addEventListener( "load", jQuery.ready, false );
467
468                 // If IE event model is used
469                 } else if ( document.attachEvent ) {
470                         // ensure firing before onload,
471                         // maybe late but safe also for iframes
472                         document.attachEvent( "onreadystatechange", DOMContentLoaded );
473
474                         // A fallback to window.onload, that will always work
475                         window.attachEvent( "onload", jQuery.ready );
476
477                         // If IE and not a frame
478                         // continually check to see if the document is ready
479                         var toplevel = false;
480
481                         try {
482                                 toplevel = window.frameElement == null;
483                         } catch(e) {}
484
485                         if ( document.documentElement.doScroll && toplevel ) {
486                                 doScrollCheck();
487                         }
488                 }
489         },
490
491         // See test/unit/core.js for details concerning isFunction.
492         // Since version 1.3, DOM methods and functions like alert
493         // aren't supported. They return false on IE (#2968).
494         isFunction: function( obj ) {
495                 return jQuery.type(obj) === "function";
496         },
497
498         isArray: Array.isArray || function( obj ) {
499                 return jQuery.type(obj) === "array";
500         },
501
502         // A crude way of determining if an object is a window
503         isWindow: function( obj ) {
504                 return obj && typeof obj === "object" && "setInterval" in obj;
505         },
506
507         isNaN: function( obj ) {
508                 return obj == null || !rdigit.test( obj ) || isNaN( obj );
509         },
510
511         type: function( obj ) {
512                 return obj == null ?
513                         String( obj ) :
514                         class2type[ toString.call(obj) ] || "object";
515         },
516
517         isPlainObject: function( obj ) {
518                 // Must be an Object.
519                 // Because of IE, we also have to check the presence of the constructor property.
520                 // Make sure that DOM nodes and window objects don't pass through, as well
521                 if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
522                         return false;
523                 }
524
525                 try {
526                         // Not own constructor property must be Object
527                         if ( obj.constructor &&
528                                 !hasOwn.call(obj, "constructor") &&
529                                 !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
530                                 return false;
531                         }
532                 } catch ( e ) {
533                         // IE8,9 Will throw exceptions on certain host objects #9897
534                         return false;
535                 }
536
537                 // Own properties are enumerated firstly, so to speed up,
538                 // if last one is own, then all properties are own.
539
540                 var key;
541                 for ( key in obj ) {}
542
543                 return key === undefined || hasOwn.call( obj, key );
544         },
545
546         isEmptyObject: function( obj ) {
547                 for ( var name in obj ) {
548                         return false;
549                 }
550                 return true;
551         },
552
553         error: function( msg ) {
554                 throw msg;
555         },
556
557         parseJSON: function( data ) {
558                 if ( typeof data !== "string" || !data ) {
559                         return null;
560                 }
561
562                 // Make sure leading/trailing whitespace is removed (IE can't handle it)
563                 data = jQuery.trim( data );
564
565                 // Attempt to parse using the native JSON parser first
566                 if ( window.JSON && window.JSON.parse ) {
567                         return window.JSON.parse( data );
568                 }
569
570                 // Make sure the incoming data is actual JSON
571                 // Logic borrowed from http://json.org/json2.js
572                 if ( rvalidchars.test( data.replace( rvalidescape, "@" )
573                         .replace( rvalidtokens, "]" )
574                         .replace( rvalidbraces, "")) ) {
575
576                         return (new Function( "return " + data ))();
577
578                 }
579                 jQuery.error( "Invalid JSON: " + data );
580         },
581
582         // Cross-browser xml parsing
583         parseXML: function( data ) {
584                 var xml, tmp;
585                 try {
586                         if ( window.DOMParser ) { // Standard
587                                 tmp = new DOMParser();
588                                 xml = tmp.parseFromString( data , "text/xml" );
589                         } else { // IE
590                                 xml = new ActiveXObject( "Microsoft.XMLDOM" );
591                                 xml.async = "false";
592                                 xml.loadXML( data );
593                         }
594                 } catch( e ) {
595                         xml = undefined;
596                 }
597                 if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
598                         jQuery.error( "Invalid XML: " + data );
599                 }
600                 return xml;
601         },
602
603         noop: function() {},
604
605         // Evaluates a script in a global context
606         // Workarounds based on findings by Jim Driscoll
607         // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
608         globalEval: function( data ) {
609                 if ( data && rnotwhite.test( data ) ) {
610                         // We use execScript on Internet Explorer
611                         // We use an anonymous function so that context is window
612                         // rather than jQuery in Firefox
613                         ( window.execScript || function( data ) {
614                                 window[ "eval" ].call( window, data );
615                         } )( data );
616                 }
617         },
618
619         // Convert dashed to camelCase; used by the css and data modules
620         // Microsoft forgot to hump their vendor prefix (#9572)
621         camelCase: function( string ) {
622                 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
623         },
624
625         nodeName: function( elem, name ) {
626                 return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
627         },
628
629         // args is for internal usage only
630         each: function( object, callback, args ) {
631                 var name, i = 0,
632                         length = object.length,
633                         isObj = length === undefined || jQuery.isFunction( object );
634
635                 if ( args ) {
636                         if ( isObj ) {
637                                 for ( name in object ) {
638                                         if ( callback.apply( object[ name ], args ) === false ) {
639                                                 break;
640                                         }
641                                 }
642                         } else {
643                                 for ( ; i < length; ) {
644                                         if ( callback.apply( object[ i++ ], args ) === false ) {
645                                                 break;
646                                         }
647                                 }
648                         }
649
650                 // A special, fast, case for the most common use of each
651                 } else {
652                         if ( isObj ) {
653                                 for ( name in object ) {
654                                         if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
655                                                 break;
656                                         }
657                                 }
658                         } else {
659                                 for ( ; i < length; ) {
660                                         if ( callback.call( object[ i ], i, object[ i++ ] ) === false ) {
661                                                 break;
662                                         }
663                                 }
664                         }
665                 }
666
667                 return object;
668         },
669
670         // Use native String.trim function wherever possible
671         trim: trim ?
672                 function( text ) {
673                         return text == null ?
674                                 "" :
675                                 trim.call( text );
676                 } :
677
678                 // Otherwise use our own trimming functionality
679                 function( text ) {
680                         return text == null ?
681                                 "" :
682                                 text.toString().replace( trimLeft, "" ).replace( trimRight, "" );
683                 },
684
685         // results is for internal usage only
686         makeArray: function( array, results ) {
687                 var ret = results || [];
688
689                 if ( array != null ) {
690                         // The window, strings (and functions) also have 'length'
691                         // The extra typeof function check is to prevent crashes
692                         // in Safari 2 (See: #3039)
693                         // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
694                         var type = jQuery.type( array );
695
696                         if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) {
697                                 push.call( ret, array );
698                         } else {
699                                 jQuery.merge( ret, array );
700                         }
701                 }
702
703                 return ret;
704         },
705
706         inArray: function( elem, array ) {
707                 if ( !array ) {
708                         return -1;
709                 }
710
711                 if ( indexOf ) {
712                         return indexOf.call( array, elem );
713                 }
714
715                 for ( var i = 0, length = array.length; i < length; i++ ) {
716                         if ( array[ i ] === elem ) {
717                                 return i;
718                         }
719                 }
720
721                 return -1;
722         },
723
724         merge: function( first, second ) {
725                 var i = first.length,
726                         j = 0;
727
728                 if ( typeof second.length === "number" ) {
729                         for ( var l = second.length; j < l; j++ ) {
730                                 first[ i++ ] = second[ j ];
731                         }
732
733                 } else {
734                         while ( second[j] !== undefined ) {
735                                 first[ i++ ] = second[ j++ ];
736                         }
737                 }
738
739                 first.length = i;
740
741                 return first;
742         },
743
744         grep: function( elems, callback, inv ) {
745                 var ret = [], retVal;
746                 inv = !!inv;
747
748                 // Go through the array, only saving the items
749                 // that pass the validator function
750                 for ( var i = 0, length = elems.length; i < length; i++ ) {
751                         retVal = !!callback( elems[ i ], i );
752                         if ( inv !== retVal ) {
753                                 ret.push( elems[ i ] );
754                         }
755                 }
756
757                 return ret;
758         },
759
760         // arg is for internal usage only
761         map: function( elems, callback, arg ) {
762                 var value, key, ret = [],
763                         i = 0,
764                         length = elems.length,
765                         // jquery objects are treated as arrays
766                         isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ;
767
768                 // Go through the array, translating each of the items to their
769                 if ( isArray ) {
770                         for ( ; i < length; i++ ) {
771                                 value = callback( elems[ i ], i, arg );
772
773                                 if ( value != null ) {
774                                         ret[ ret.length ] = value;
775                                 }
776                         }
777
778                 // Go through every key on the object,
779                 } else {
780                         for ( key in elems ) {
781                                 value = callback( elems[ key ], key, arg );
782
783                                 if ( value != null ) {
784                                         ret[ ret.length ] = value;
785                                 }
786                         }
787                 }
788
789                 // Flatten any nested arrays
790                 return ret.concat.apply( [], ret );
791         },
792
793         // A global GUID counter for objects
794         guid: 1,
795
796         // Bind a function to a context, optionally partially applying any
797         // arguments.
798         proxy: function( fn, context ) {
799                 if ( typeof context === "string" ) {
800                         var tmp = fn[ context ];
801                         context = fn;
802                         fn = tmp;
803                 }
804
805                 // Quick check to determine if target is callable, in the spec
806                 // this throws a TypeError, but we will just return undefined.
807                 if ( !jQuery.isFunction( fn ) ) {
808                         return undefined;
809                 }
810
811                 // Simulated bind
812                 var args = slice.call( arguments, 2 ),
813                         proxy = function() {
814                                 return fn.apply( context, args.concat( slice.call( arguments ) ) );
815                         };
816
817                 // Set the guid of unique handler to the same of original handler, so it can be removed
818                 proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
819
820                 return proxy;
821         },
822
823         // Mutifunctional method to get and set values to a collection
824         // The value/s can optionally be executed if it's a function
825         access: function( elems, key, value, exec, fn, pass ) {
826                 var length = elems.length;
827
828                 // Setting many attributes
829                 if ( typeof key === "object" ) {
830                         for ( var k in key ) {
831                                 jQuery.access( elems, k, key[k], exec, fn, value );
832                         }
833                         return elems;
834                 }
835
836                 // Setting one attribute
837                 if ( value !== undefined ) {
838                         // Optionally, function values get executed if exec is true
839                         exec = !pass && exec && jQuery.isFunction(value);
840
841                         for ( var i = 0; i < length; i++ ) {
842                                 fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
843                         }
844
845                         return elems;
846                 }
847
848                 // Getting an attribute
849                 return length ? fn( elems[0], key ) : undefined;
850         },
851
852         now: function() {
853                 return (new Date()).getTime();
854         },
855
856         // Use of jQuery.browser is frowned upon.
857         // More details: http://docs.jquery.com/Utilities/jQuery.browser
858         uaMatch: function( ua ) {
859                 ua = ua.toLowerCase();
860
861                 var match = rwebkit.exec( ua ) ||
862                         ropera.exec( ua ) ||
863                         rmsie.exec( ua ) ||
864                         ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) ||
865                         [];
866
867                 return { browser: match[1] || "", version: match[2] || "0" };
868         },
869
870         sub: function() {
871                 function jQuerySub( selector, context ) {
872                         return new jQuerySub.fn.init( selector, context );
873                 }
874                 jQuery.extend( true, jQuerySub, this );
875                 jQuerySub.superclass = this;
876                 jQuerySub.fn = jQuerySub.prototype = this();
877                 jQuerySub.fn.constructor = jQuerySub;
878                 jQuerySub.sub = this.sub;
879                 jQuerySub.fn.init = function init( selector, context ) {
880                         if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) {
881                                 context = jQuerySub( context );
882                         }
883
884                         return jQuery.fn.init.call( this, selector, context, rootjQuerySub );
885                 };
886                 jQuerySub.fn.init.prototype = jQuerySub.fn;
887                 var rootjQuerySub = jQuerySub(document);
888                 return jQuerySub;
889         },
890
891         browser: {}
892 });
893
894 // Populate the class2type map
895 jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
896         class2type[ "[object " + name + "]" ] = name.toLowerCase();
897 });
898
899 browserMatch = jQuery.uaMatch( userAgent );
900 if ( browserMatch.browser ) {
901         jQuery.browser[ browserMatch.browser ] = true;
902         jQuery.browser.version = browserMatch.version;
903 }
904
905 // Deprecated, use jQuery.browser.webkit instead
906 if ( jQuery.browser.webkit ) {
907         jQuery.browser.safari = true;
908 }
909
910 // IE doesn't match non-breaking spaces with \s
911 if ( rnotwhite.test( "\xA0" ) ) {
912         trimLeft = /^[\s\xA0]+/;
913         trimRight = /[\s\xA0]+$/;
914 }
915
916 // All jQuery objects should point back to these
917 rootjQuery = jQuery(document);
918
919 // Cleanup functions for the document ready method
920 if ( document.addEventListener ) {
921         DOMContentLoaded = function() {
922                 document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
923                 jQuery.ready();
924         };
925
926 } else if ( document.attachEvent ) {
927         DOMContentLoaded = function() {
928                 // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
929                 if ( document.readyState === "complete" ) {
930                         document.detachEvent( "onreadystatechange", DOMContentLoaded );
931                         jQuery.ready();
932                 }
933         };
934 }
935
936 // The DOM ready check for Internet Explorer
937 function doScrollCheck() {
938         if ( jQuery.isReady ) {
939                 return;
940         }
941
942         try {
943                 // If IE is used, use the trick by Diego Perini
944                 // http://javascript.nwbox.com/IEContentLoaded/
945                 document.documentElement.doScroll("left");
946         } catch(e) {
947                 setTimeout( doScrollCheck, 1 );
948                 return;
949         }
950
951         // and execute any waiting functions
952         jQuery.ready();
953 }
954
955 return jQuery;
956
957 })();
958
959
960 var // Promise methods
961         promiseMethods = "done fail isResolved isRejected promise then always pipe".split( " " ),
962         // Static reference to slice
963         sliceDeferred = [].slice;
964
965 jQuery.extend({
966         // Create a simple deferred (one callbacks list)
967         _Deferred: function() {
968                 var // callbacks list
969                         callbacks = [],
970                         // stored [ context , args ]
971                         fired,
972                         // to avoid firing when already doing so
973                         firing,
974                         // flag to know if the deferred has been cancelled
975                         cancelled,
976                         // the deferred itself
977                         deferred  = {
978
979                                 // done( f1, f2, ...)
980                                 done: function() {
981                                         if ( !cancelled ) {
982                                                 var args = arguments,
983                                                         i,
984                                                         length,
985                                                         elem,
986                                                         type,
987                                                         _fired;
988                                                 if ( fired ) {
989                                                         _fired = fired;
990                                                         fired = 0;
991                                                 }
992                                                 for ( i = 0, length = args.length; i < length; i++ ) {
993                                                         elem = args[ i ];
994                                                         type = jQuery.type( elem );
995                                                         if ( type === "array" ) {
996                                                                 deferred.done.apply( deferred, elem );
997                                                         } else if ( type === "function" ) {
998                                                                 callbacks.push( elem );
999                                                         }
1000                                                 }
1001                                                 if ( _fired ) {
1002                                                         deferred.resolveWith( _fired[ 0 ], _fired[ 1 ] );
1003                                                 }
1004                                         }
1005                                         return this;
1006                                 },
1007
1008                                 // resolve with given context and args
1009                                 resolveWith: function( context, args ) {
1010                                         if ( !cancelled && !fired && !firing ) {
1011                                                 // make sure args are available (#8421)
1012                                                 args = args || [];
1013                                                 firing = 1;
1014                                                 try {
1015                                                         while( callbacks[ 0 ] ) {
1016                                                                 callbacks.shift().apply( context, args );
1017                                                         }
1018                                                 }
1019                                                 finally {
1020                                                         fired = [ context, args ];
1021                                                         firing = 0;
1022                                                 }
1023                                         }
1024                                         return this;
1025                                 },
1026
1027                                 // resolve with this as context and given arguments
1028                                 resolve: function() {
1029                                         deferred.resolveWith( this, arguments );
1030                                         return this;
1031                                 },
1032
1033                                 // Has this deferred been resolved?
1034                                 isResolved: function() {
1035                                         return !!( firing || fired );
1036                                 },
1037
1038                                 // Cancel
1039                                 cancel: function() {
1040                                         cancelled = 1;
1041                                         callbacks = [];
1042                                         return this;
1043                                 }
1044                         };
1045
1046                 return deferred;
1047         },
1048
1049         // Full fledged deferred (two callbacks list)
1050         Deferred: function( func ) {
1051                 var deferred = jQuery._Deferred(),
1052                         failDeferred = jQuery._Deferred(),
1053                         promise;
1054                 // Add errorDeferred methods, then and promise
1055                 jQuery.extend( deferred, {
1056                         then: function( doneCallbacks, failCallbacks ) {
1057                                 deferred.done( doneCallbacks ).fail( failCallbacks );
1058                                 return this;
1059                         },
1060                         always: function() {
1061                                 return deferred.done.apply( deferred, arguments ).fail.apply( this, arguments );
1062                         },
1063                         fail: failDeferred.done,
1064                         rejectWith: failDeferred.resolveWith,
1065                         reject: failDeferred.resolve,
1066                         isRejected: failDeferred.isResolved,
1067                         pipe: function( fnDone, fnFail ) {
1068                                 return jQuery.Deferred(function( newDefer ) {
1069                                         jQuery.each( {
1070                                                 done: [ fnDone, "resolve" ],
1071                                                 fail: [ fnFail, "reject" ]
1072                                         }, function( handler, data ) {
1073                                                 var fn = data[ 0 ],
1074                                                         action = data[ 1 ],
1075                                                         returned;
1076                                                 if ( jQuery.isFunction( fn ) ) {
1077                                                         deferred[ handler ](function() {
1078                                                                 returned = fn.apply( this, arguments );
1079                                                                 if ( returned && jQuery.isFunction( returned.promise ) ) {
1080                                                                         returned.promise().then( newDefer.resolve, newDefer.reject );
1081                                                                 } else {
1082                                                                         newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] );
1083                                                                 }
1084                                                         });
1085                                                 } else {
1086                                                         deferred[ handler ]( newDefer[ action ] );
1087                                                 }
1088                                         });
1089                                 }).promise();
1090                         },
1091                         // Get a promise for this deferred
1092                         // If obj is provided, the promise aspect is added to the object
1093                         promise: function( obj ) {
1094                                 if ( obj == null ) {
1095                                         if ( promise ) {
1096                                                 return promise;
1097                                         }
1098                                         promise = obj = {};
1099                                 }
1100                                 var i = promiseMethods.length;
1101                                 while( i-- ) {
1102                                         obj[ promiseMethods[i] ] = deferred[ promiseMethods[i] ];
1103                                 }
1104                                 return obj;
1105                         }
1106                 });
1107                 // Make sure only one callback list will be used
1108                 deferred.done( failDeferred.cancel ).fail( deferred.cancel );
1109                 // Unexpose cancel
1110                 delete deferred.cancel;
1111                 // Call given func if any
1112                 if ( func ) {
1113                         func.call( deferred, deferred );
1114                 }
1115                 return deferred;
1116         },
1117
1118         // Deferred helper
1119         when: function( firstParam ) {
1120                 var args = arguments,
1121                         i = 0,
1122                         length = args.length,
1123                         count = length,
1124                         deferred = length <= 1 && firstParam && jQuery.isFunction( firstParam.promise ) ?
1125                                 firstParam :
1126                                 jQuery.Deferred();
1127                 function resolveFunc( i ) {
1128                         return function( value ) {
1129                                 args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value;
1130                                 if ( !( --count ) ) {
1131                                         // Strange bug in FF4:
1132                                         // Values changed onto the arguments object sometimes end up as undefined values
1133                                         // outside the $.when method. Cloning the object into a fresh array solves the issue
1134                                         deferred.resolveWith( deferred, sliceDeferred.call( args, 0 ) );
1135                                 }
1136                         };
1137                 }
1138                 if ( length > 1 ) {
1139                         for( ; i < length; i++ ) {
1140                                 if ( args[ i ] && jQuery.isFunction( args[ i ].promise ) ) {
1141                                         args[ i ].promise().then( resolveFunc(i), deferred.reject );
1142                                 } else {
1143                                         --count;
1144                                 }
1145                         }
1146                         if ( !count ) {
1147                                 deferred.resolveWith( deferred, args );
1148                         }
1149                 } else if ( deferred !== firstParam ) {
1150                         deferred.resolveWith( deferred, length ? [ firstParam ] : [] );
1151                 }
1152                 return deferred.promise();
1153         }
1154 });
1155
1156
1157
1158 jQuery.support = (function() {
1159
1160         var div = document.createElement( "div" ),
1161                 documentElement = document.documentElement,
1162                 all,
1163                 a,
1164                 select,
1165                 opt,
1166                 input,
1167                 marginDiv,
1168                 support,
1169                 fragment,
1170                 body,
1171                 testElementParent,
1172                 testElement,
1173                 testElementStyle,
1174                 tds,
1175                 events,
1176                 eventName,
1177                 i,
1178                 isSupported;
1179
1180         // Preliminary tests
1181         div.setAttribute("className", "t");
1182         div.innerHTML = "   <link/><table></table><a href='/a' style='top:1px;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
1183
1184
1185         all = div.getElementsByTagName( "*" );
1186         a = div.getElementsByTagName( "a" )[ 0 ];
1187
1188         // Can't get basic test support
1189         if ( !all || !all.length || !a ) {
1190                 return {};
1191         }
1192
1193         // First batch of supports tests
1194         select = document.createElement( "select" );
1195         opt = select.appendChild( document.createElement("option") );
1196         input = div.getElementsByTagName( "input" )[ 0 ];
1197
1198         support = {
1199                 // IE strips leading whitespace when .innerHTML is used
1200                 leadingWhitespace: ( div.firstChild.nodeType === 3 ),
1201
1202                 // Make sure that tbody elements aren't automatically inserted
1203                 // IE will insert them into empty tables
1204                 tbody: !div.getElementsByTagName( "tbody" ).length,
1205
1206                 // Make sure that link elements get serialized correctly by innerHTML
1207                 // This requires a wrapper element in IE
1208                 htmlSerialize: !!div.getElementsByTagName( "link" ).length,
1209
1210                 // Get the style information from getAttribute
1211                 // (IE uses .cssText instead)
1212                 style: /top/.test( a.getAttribute("style") ),
1213
1214                 // Make sure that URLs aren't manipulated
1215                 // (IE normalizes it by default)
1216                 hrefNormalized: ( a.getAttribute( "href" ) === "/a" ),
1217
1218                 // Make sure that element opacity exists
1219                 // (IE uses filter instead)
1220                 // Use a regex to work around a WebKit issue. See #5145
1221                 opacity: /^0.55$/.test( a.style.opacity ),
1222
1223                 // Verify style float existence
1224                 // (IE uses styleFloat instead of cssFloat)
1225                 cssFloat: !!a.style.cssFloat,
1226
1227                 // Make sure that if no value is specified for a checkbox
1228                 // that it defaults to "on".
1229                 // (WebKit defaults to "" instead)
1230                 checkOn: ( input.value === "on" ),
1231
1232                 // Make sure that a selected-by-default option has a working selected property.
1233                 // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
1234                 optSelected: opt.selected,
1235
1236                 // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
1237                 getSetAttribute: div.className !== "t",
1238
1239                 // Will be defined later
1240                 submitBubbles: true,
1241                 changeBubbles: true,
1242                 focusinBubbles: false,
1243                 deleteExpando: true,
1244                 noCloneEvent: true,
1245                 inlineBlockNeedsLayout: false,
1246                 shrinkWrapBlocks: false,
1247                 reliableMarginRight: true
1248         };
1249
1250         // Make sure checked status is properly cloned
1251         input.checked = true;
1252         support.noCloneChecked = input.cloneNode( true ).checked;
1253
1254         // Make sure that the options inside disabled selects aren't marked as disabled
1255         // (WebKit marks them as disabled)
1256         select.disabled = true;
1257         support.optDisabled = !opt.disabled;
1258
1259         // Test to see if it's possible to delete an expando from an element
1260         // Fails in Internet Explorer
1261         try {
1262                 delete div.test;
1263         } catch( e ) {
1264                 support.deleteExpando = false;
1265         }
1266
1267         if ( !div.addEventListener && div.attachEvent && div.fireEvent ) {
1268                 div.attachEvent( "onclick", function() {
1269                         // Cloning a node shouldn't copy over any
1270                         // bound event handlers (IE does this)
1271                         support.noCloneEvent = false;
1272                 });
1273                 div.cloneNode( true ).fireEvent( "onclick" );
1274         }
1275
1276         // Check if a radio maintains it's value
1277         // after being appended to the DOM
1278         input = document.createElement("input");
1279         input.value = "t";
1280         input.setAttribute("type", "radio");
1281         support.radioValue = input.value === "t";
1282
1283         input.setAttribute("checked", "checked");
1284         div.appendChild( input );
1285         fragment = document.createDocumentFragment();
1286         fragment.appendChild( div.firstChild );
1287
1288         // WebKit doesn't clone checked state correctly in fragments
1289         support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked;
1290
1291         div.innerHTML = "";
1292
1293         // Figure out if the W3C box model works as expected
1294         div.style.width = div.style.paddingLeft = "1px";
1295
1296         body = document.getElementsByTagName( "body" )[ 0 ];
1297         // We use our own, invisible, body unless the body is already present
1298         // in which case we use a div (#9239)
1299         testElement = document.createElement( body ? "div" : "body" );
1300         testElementStyle = {
1301                 visibility: "hidden",
1302                 width: 0,
1303                 height: 0,
1304                 border: 0,
1305                 margin: 0,
1306                 background: "none"
1307         };
1308         if ( body ) {
1309                 jQuery.extend( testElementStyle, {
1310                         position: "absolute",
1311                         left: "-1000px",
1312                         top: "-1000px"
1313                 });
1314         }
1315         for ( i in testElementStyle ) {
1316                 testElement.style[ i ] = testElementStyle[ i ];
1317         }
1318         testElement.appendChild( div );
1319         testElementParent = body || documentElement;
1320         testElementParent.insertBefore( testElement, testElementParent.firstChild );
1321
1322         // Check if a disconnected checkbox will retain its checked
1323         // value of true after appended to the DOM (IE6/7)
1324         support.appendChecked = input.checked;
1325
1326         support.boxModel = div.offsetWidth === 2;
1327
1328         if ( "zoom" in div.style ) {
1329                 // Check if natively block-level elements act like inline-block
1330                 // elements when setting their display to 'inline' and giving
1331                 // them layout
1332                 // (IE < 8 does this)
1333                 div.style.display = "inline";
1334                 div.style.zoom = 1;
1335                 support.inlineBlockNeedsLayout = ( div.offsetWidth === 2 );
1336
1337                 // Check if elements with layout shrink-wrap their children
1338                 // (IE 6 does this)
1339                 div.style.display = "";
1340                 div.innerHTML = "<div style='width:4px;'></div>";
1341                 support.shrinkWrapBlocks = ( div.offsetWidth !== 2 );
1342         }
1343
1344         div.innerHTML = "<table><tr><td style='padding:0;border:0;display:none'></td><td>t</td></tr></table>";
1345         tds = div.getElementsByTagName( "td" );
1346
1347         // Check if table cells still have offsetWidth/Height when they are set
1348         // to display:none and there are still other visible table cells in a
1349         // table row; if so, offsetWidth/Height are not reliable for use when
1350         // determining if an element has been hidden directly using
1351         // display:none (it is still safe to use offsets if a parent element is
1352         // hidden; don safety goggles and see bug #4512 for more information).
1353         // (only IE 8 fails this test)
1354         isSupported = ( tds[ 0 ].offsetHeight === 0 );
1355
1356         tds[ 0 ].style.display = "";
1357         tds[ 1 ].style.display = "none";
1358
1359         // Check if empty table cells still have offsetWidth/Height
1360         // (IE < 8 fail this test)
1361         support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 );
1362         div.innerHTML = "";
1363
1364         // Check if div with explicit width and no margin-right incorrectly
1365         // gets computed margin-right based on width of container. For more
1366         // info see bug #3333
1367         // Fails in WebKit before Feb 2011 nightlies
1368         // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
1369         if ( document.defaultView && document.defaultView.getComputedStyle ) {
1370                 marginDiv = document.createElement( "div" );
1371                 marginDiv.style.width = "0";
1372                 marginDiv.style.marginRight = "0";
1373                 div.appendChild( marginDiv );
1374                 support.reliableMarginRight =
1375                         ( parseInt( ( document.defaultView.getComputedStyle( marginDiv, null ) || { marginRight: 0 } ).marginRight, 10 ) || 0 ) === 0;
1376         }
1377
1378         // Remove the body element we added
1379         testElement.innerHTML = "";
1380         testElementParent.removeChild( testElement );
1381
1382         // Technique from Juriy Zaytsev
1383         // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
1384         // We only care about the case where non-standard event systems
1385         // are used, namely in IE. Short-circuiting here helps us to
1386         // avoid an eval call (in setAttribute) which can cause CSP
1387         // to go haywire. See: https://developer.mozilla.org/en/Security/CSP
1388         if ( div.attachEvent ) {
1389                 for( i in {
1390                         submit: 1,
1391                         change: 1,
1392                         focusin: 1
1393                 } ) {
1394                         eventName = "on" + i;
1395                         isSupported = ( eventName in div );
1396                         if ( !isSupported ) {
1397                                 div.setAttribute( eventName, "return;" );
1398                                 isSupported = ( typeof div[ eventName ] === "function" );
1399                         }
1400                         support[ i + "Bubbles" ] = isSupported;
1401                 }
1402         }
1403
1404         // Null connected elements to avoid leaks in IE
1405         testElement = fragment = select = opt = body = marginDiv = div = input = null;
1406
1407         return support;
1408 })();
1409
1410 // Keep track of boxModel
1411 jQuery.boxModel = jQuery.support.boxModel;
1412
1413
1414
1415
1416 var rbrace = /^(?:\{.*\}|\[.*\])$/,
1417         rmultiDash = /([A-Z])/g;
1418
1419 jQuery.extend({
1420         cache: {},
1421
1422         // Please use with caution
1423         uuid: 0,
1424
1425         // Unique for each copy of jQuery on the page
1426         // Non-digits removed to match rinlinejQuery
1427         expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ),
1428
1429         // The following elements throw uncatchable exceptions if you
1430         // attempt to add expando properties to them.
1431         noData: {
1432                 "embed": true,
1433                 // Ban all objects except for Flash (which handle expandos)
1434                 "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
1435                 "applet": true
1436         },
1437
1438         hasData: function( elem ) {
1439                 elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
1440
1441                 return !!elem && !isEmptyDataObject( elem );
1442         },
1443
1444         data: function( elem, name, data, pvt /* Internal Use Only */ ) {
1445                 if ( !jQuery.acceptData( elem ) ) {
1446                         return;
1447                 }
1448
1449                 var thisCache, ret,
1450                         internalKey = jQuery.expando,
1451                         getByName = typeof name === "string",
1452
1453                         // We have to handle DOM nodes and JS objects differently because IE6-7
1454                         // can't GC object references properly across the DOM-JS boundary
1455                         isNode = elem.nodeType,
1456
1457                         // Only DOM nodes need the global jQuery cache; JS object data is
1458                         // attached directly to the object so GC can occur automatically
1459                         cache = isNode ? jQuery.cache : elem,
1460
1461                         // Only defining an ID for JS objects if its cache already exists allows
1462                         // the code to shortcut on the same path as a DOM node with no cache
1463                         id = isNode ? elem[ jQuery.expando ] : elem[ jQuery.expando ] && jQuery.expando;
1464
1465                 // Avoid doing any more work than we need to when trying to get data on an
1466                 // object that has no data at all
1467                 if ( (!id || (pvt && id && (cache[ id ] && !cache[ id ][ internalKey ]))) && getByName && data === undefined ) {
1468                         return;
1469                 }
1470
1471                 if ( !id ) {
1472                         // Only DOM nodes need a new unique ID for each element since their data
1473                         // ends up in the global cache
1474                         if ( isNode ) {
1475                                 elem[ jQuery.expando ] = id = ++jQuery.uuid;
1476                         } else {
1477                                 id = jQuery.expando;
1478                         }
1479                 }
1480
1481                 if ( !cache[ id ] ) {
1482                         cache[ id ] = {};
1483
1484                         // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery
1485                         // metadata on plain JS objects when the object is serialized using
1486                         // JSON.stringify
1487                         if ( !isNode ) {
1488                                 cache[ id ].toJSON = jQuery.noop;
1489                         }
1490                 }
1491
1492                 // An object can be passed to jQuery.data instead of a key/value pair; this gets
1493                 // shallow copied over onto the existing cache
1494                 if ( typeof name === "object" || typeof name === "function" ) {
1495                         if ( pvt ) {
1496                                 cache[ id ][ internalKey ] = jQuery.extend(cache[ id ][ internalKey ], name);
1497                         } else {
1498                                 cache[ id ] = jQuery.extend(cache[ id ], name);
1499                         }
1500                 }
1501
1502                 thisCache = cache[ id ];
1503
1504                 // Internal jQuery data is stored in a separate object inside the object's data
1505                 // cache in order to avoid key collisions between internal data and user-defined
1506                 // data
1507                 if ( pvt ) {
1508                         if ( !thisCache[ internalKey ] ) {
1509                                 thisCache[ internalKey ] = {};
1510                         }
1511
1512                         thisCache = thisCache[ internalKey ];
1513                 }
1514
1515                 if ( data !== undefined ) {
1516                         thisCache[ jQuery.camelCase( name ) ] = data;
1517                 }
1518
1519                 // TODO: This is a hack for 1.5 ONLY. It will be removed in 1.6. Users should
1520                 // not attempt to inspect the internal events object using jQuery.data, as this
1521                 // internal data object is undocumented and subject to change.
1522                 if ( name === "events" && !thisCache[name] ) {
1523                         return thisCache[ internalKey ] && thisCache[ internalKey ].events;
1524                 }
1525
1526                 // Check for both converted-to-camel and non-converted data property names
1527                 // If a data property was specified
1528                 if ( getByName ) {
1529
1530                         // First Try to find as-is property data
1531                         ret = thisCache[ name ];
1532
1533                         // Test for null|undefined property data
1534                         if ( ret == null ) {
1535
1536                                 // Try to find the camelCased property
1537                                 ret = thisCache[ jQuery.camelCase( name ) ];
1538                         }
1539                 } else {
1540                         ret = thisCache;
1541                 }
1542
1543                 return ret;
1544         },
1545
1546         removeData: function( elem, name, pvt /* Internal Use Only */ ) {
1547                 if ( !jQuery.acceptData( elem ) ) {
1548                         return;
1549                 }
1550
1551                 var thisCache,
1552
1553                         // Reference to internal data cache key
1554                         internalKey = jQuery.expando,
1555
1556                         isNode = elem.nodeType,
1557
1558                         // See jQuery.data for more information
1559                         cache = isNode ? jQuery.cache : elem,
1560
1561                         // See jQuery.data for more information
1562                         id = isNode ? elem[ jQuery.expando ] : jQuery.expando;
1563
1564                 // If there is already no cache entry for this object, there is no
1565                 // purpose in continuing
1566                 if ( !cache[ id ] ) {
1567                         return;
1568                 }
1569
1570                 if ( name ) {
1571
1572                         thisCache = pvt ? cache[ id ][ internalKey ] : cache[ id ];
1573
1574                         if ( thisCache ) {
1575
1576                                 // Support interoperable removal of hyphenated or camelcased keys
1577                                 if ( !thisCache[ name ] ) {
1578                                         name = jQuery.camelCase( name );
1579                                 }
1580
1581                                 delete thisCache[ name ];
1582
1583                                 // If there is no data left in the cache, we want to continue
1584                                 // and let the cache object itself get destroyed
1585                                 if ( !isEmptyDataObject(thisCache) ) {
1586                                         return;
1587                                 }
1588                         }
1589                 }
1590
1591                 // See jQuery.data for more information
1592                 if ( pvt ) {
1593                         delete cache[ id ][ internalKey ];
1594
1595                         // Don't destroy the parent cache unless the internal data object
1596                         // had been the only thing left in it
1597                         if ( !isEmptyDataObject(cache[ id ]) ) {
1598                                 return;
1599                         }
1600                 }
1601
1602                 var internalCache = cache[ id ][ internalKey ];
1603
1604                 // Browsers that fail expando deletion also refuse to delete expandos on
1605                 // the window, but it will allow it on all other JS objects; other browsers
1606                 // don't care
1607                 // Ensure that `cache` is not a window object #10080
1608                 if ( jQuery.support.deleteExpando || !cache.setInterval ) {
1609                         delete cache[ id ];
1610                 } else {
1611                         cache[ id ] = null;
1612                 }
1613
1614                 // We destroyed the entire user cache at once because it's faster than
1615                 // iterating through each key, but we need to continue to persist internal
1616                 // data if it existed
1617                 if ( internalCache ) {
1618                         cache[ id ] = {};
1619                         // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery
1620                         // metadata on plain JS objects when the object is serialized using
1621                         // JSON.stringify
1622                         if ( !isNode ) {
1623                                 cache[ id ].toJSON = jQuery.noop;
1624                         }
1625
1626                         cache[ id ][ internalKey ] = internalCache;
1627
1628                 // Otherwise, we need to eliminate the expando on the node to avoid
1629                 // false lookups in the cache for entries that no longer exist
1630                 } else if ( isNode ) {
1631                         // IE does not allow us to delete expando properties from nodes,
1632                         // nor does it have a removeAttribute function on Document nodes;
1633                         // we must handle all of these cases
1634                         if ( jQuery.support.deleteExpando ) {
1635                                 delete elem[ jQuery.expando ];
1636                         } else if ( elem.removeAttribute ) {
1637                                 elem.removeAttribute( jQuery.expando );
1638                         } else {
1639                                 elem[ jQuery.expando ] = null;
1640                         }
1641                 }
1642         },
1643
1644         // For internal use only.
1645         _data: function( elem, name, data ) {
1646                 return jQuery.data( elem, name, data, true );
1647         },
1648
1649         // A method for determining if a DOM node can handle the data expando
1650         acceptData: function( elem ) {
1651                 if ( elem.nodeName ) {
1652                         var match = jQuery.noData[ elem.nodeName.toLowerCase() ];
1653
1654                         if ( match ) {
1655                                 return !(match === true || elem.getAttribute("classid") !== match);
1656                         }
1657                 }
1658
1659                 return true;
1660         }
1661 });
1662
1663 jQuery.fn.extend({
1664         data: function( key, value ) {
1665                 var data = null;
1666
1667                 if ( typeof key === "undefined" ) {
1668                         if ( this.length ) {
1669                                 data = jQuery.data( this[0] );
1670
1671                                 if ( this[0].nodeType === 1 ) {
1672                             var attr = this[0].attributes, name;
1673                                         for ( var i = 0, l = attr.length; i < l; i++ ) {
1674                                                 name = attr[i].name;
1675
1676                                                 if ( name.indexOf( "data-" ) === 0 ) {
1677                                                         name = jQuery.camelCase( name.substring(5) );
1678
1679                                                         dataAttr( this[0], name, data[ name ] );
1680                                                 }
1681                                         }
1682                                 }
1683                         }
1684
1685                         return data;
1686
1687                 } else if ( typeof key === "object" ) {
1688                         return this.each(function() {
1689                                 jQuery.data( this, key );
1690                         });
1691                 }
1692
1693                 var parts = key.split(".");
1694                 parts[1] = parts[1] ? "." + parts[1] : "";
1695
1696                 if ( value === undefined ) {
1697                         data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
1698
1699                         // Try to fetch any internally stored data first
1700                         if ( data === undefined && this.length ) {
1701                                 data = jQuery.data( this[0], key );
1702                                 data = dataAttr( this[0], key, data );
1703                         }
1704
1705                         return data === undefined && parts[1] ?
1706                                 this.data( parts[0] ) :
1707                                 data;
1708
1709                 } else {
1710                         return this.each(function() {
1711                                 var $this = jQuery( this ),
1712                                         args = [ parts[0], value ];
1713
1714                                 $this.triggerHandler( "setData" + parts[1] + "!", args );
1715                                 jQuery.data( this, key, value );
1716                                 $this.triggerHandler( "changeData" + parts[1] + "!", args );
1717                         });
1718                 }
1719         },
1720
1721         removeData: function( key ) {
1722                 return this.each(function() {
1723                         jQuery.removeData( this, key );
1724                 });
1725         }
1726 });
1727
1728 function dataAttr( elem, key, data ) {
1729         // If nothing was found internally, try to fetch any
1730         // data from the HTML5 data-* attribute
1731         if ( data === undefined && elem.nodeType === 1 ) {
1732
1733                 var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
1734
1735                 data = elem.getAttribute( name );
1736
1737                 if ( typeof data === "string" ) {
1738                         try {
1739                                 data = data === "true" ? true :
1740                                 data === "false" ? false :
1741                                 data === "null" ? null :
1742                                 !jQuery.isNaN( data ) ? parseFloat( data ) :
1743                                         rbrace.test( data ) ? jQuery.parseJSON( data ) :
1744                                         data;
1745                         } catch( e ) {}
1746
1747                         // Make sure we set the data so it isn't changed later
1748                         jQuery.data( elem, key, data );
1749
1750                 } else {
1751                         data = undefined;
1752                 }
1753         }
1754
1755         return data;
1756 }
1757
1758 // TODO: This is a hack for 1.5 ONLY to allow objects with a single toJSON
1759 // property to be considered empty objects; this property always exists in
1760 // order to make sure JSON.stringify does not expose internal metadata
1761 function isEmptyDataObject( obj ) {
1762         for ( var name in obj ) {
1763                 if ( name !== "toJSON" ) {
1764                         return false;
1765                 }
1766         }
1767
1768         return true;
1769 }
1770
1771
1772
1773
1774 function handleQueueMarkDefer( elem, type, src ) {
1775         var deferDataKey = type + "defer",
1776                 queueDataKey = type + "queue",
1777                 markDataKey = type + "mark",
1778                 defer = jQuery.data( elem, deferDataKey, undefined, true );
1779         if ( defer &&
1780                 ( src === "queue" || !jQuery.data( elem, queueDataKey, undefined, true ) ) &&
1781                 ( src === "mark" || !jQuery.data( elem, markDataKey, undefined, true ) ) ) {
1782                 // Give room for hard-coded callbacks to fire first
1783                 // and eventually mark/queue something else on the element
1784                 setTimeout( function() {
1785                         if ( !jQuery.data( elem, queueDataKey, undefined, true ) &&
1786                                 !jQuery.data( elem, markDataKey, undefined, true ) ) {
1787                                 jQuery.removeData( elem, deferDataKey, true );
1788                                 defer.resolve();
1789                         }
1790                 }, 0 );
1791         }
1792 }
1793
1794 jQuery.extend({
1795
1796         _mark: function( elem, type ) {
1797                 if ( elem ) {
1798                         type = (type || "fx") + "mark";
1799                         jQuery.data( elem, type, (jQuery.data(elem,type,undefined,true) || 0) + 1, true );
1800                 }
1801         },
1802
1803         _unmark: function( force, elem, type ) {
1804                 if ( force !== true ) {
1805                         type = elem;
1806                         elem = force;
1807                         force = false;
1808                 }
1809                 if ( elem ) {
1810                         type = type || "fx";
1811                         var key = type + "mark",
1812                                 count = force ? 0 : ( (jQuery.data( elem, key, undefined, true) || 1 ) - 1 );
1813                         if ( count ) {
1814                                 jQuery.data( elem, key, count, true );
1815                         } else {
1816                                 jQuery.removeData( elem, key, true );
1817                                 handleQueueMarkDefer( elem, type, "mark" );
1818                         }
1819                 }
1820         },
1821
1822         queue: function( elem, type, data ) {
1823                 if ( elem ) {
1824                         type = (type || "fx") + "queue";
1825                         var q = jQuery.data( elem, type, undefined, true );
1826                         // Speed up dequeue by getting out quickly if this is just a lookup
1827                         if ( data ) {
1828                                 if ( !q || jQuery.isArray(data) ) {
1829                                         q = jQuery.data( elem, type, jQuery.makeArray(data), true );
1830                                 } else {
1831                                         q.push( data );
1832                                 }
1833                         }
1834                         return q || [];
1835                 }
1836         },
1837
1838         dequeue: function( elem, type ) {
1839                 type = type || "fx";
1840
1841                 var queue = jQuery.queue( elem, type ),
1842                         fn = queue.shift(),
1843                         defer;
1844
1845                 // If the fx queue is dequeued, always remove the progress sentinel
1846                 if ( fn === "inprogress" ) {
1847                         fn = queue.shift();
1848                 }
1849
1850                 if ( fn ) {
1851                         // Add a progress sentinel to prevent the fx queue from being
1852                         // automatically dequeued
1853                         if ( type === "fx" ) {
1854                                 queue.unshift("inprogress");
1855                         }
1856
1857                         fn.call(elem, function() {
1858                                 jQuery.dequeue(elem, type);
1859                         });
1860                 }
1861
1862                 if ( !queue.length ) {
1863                         jQuery.removeData( elem, type + "queue", true );
1864                         handleQueueMarkDefer( elem, type, "queue" );
1865                 }
1866         }
1867 });
1868
1869 jQuery.fn.extend({
1870         queue: function( type, data ) {
1871                 if ( typeof type !== "string" ) {
1872                         data = type;
1873                         type = "fx";
1874                 }
1875
1876                 if ( data === undefined ) {
1877                         return jQuery.queue( this[0], type );
1878                 }
1879                 return this.each(function() {
1880                         var queue = jQuery.queue( this, type, data );
1881
1882                         if ( type === "fx" && queue[0] !== "inprogress" ) {
1883                                 jQuery.dequeue( this, type );
1884                         }
1885                 });
1886         },
1887         dequeue: function( type ) {
1888                 return this.each(function() {
1889                         jQuery.dequeue( this, type );
1890                 });
1891         },
1892         // Based off of the plugin by Clint Helfers, with permission.
1893         // http://blindsignals.com/index.php/2009/07/jquery-delay/
1894         delay: function( time, type ) {
1895                 time = jQuery.fx ? jQuery.fx.speeds[time] || time : time;
1896                 type = type || "fx";
1897
1898                 return this.queue( type, function() {
1899                         var elem = this;
1900                         setTimeout(function() {
1901                                 jQuery.dequeue( elem, type );
1902                         }, time );
1903                 });
1904         },
1905         clearQueue: function( type ) {
1906                 return this.queue( type || "fx", [] );
1907         },
1908         // Get a promise resolved when queues of a certain type
1909         // are emptied (fx is the type by default)
1910         promise: function( type, object ) {
1911                 if ( typeof type !== "string" ) {
1912                         object = type;
1913                         type = undefined;
1914                 }
1915                 type = type || "fx";
1916                 var defer = jQuery.Deferred(),
1917                         elements = this,
1918                         i = elements.length,
1919                         count = 1,
1920                         deferDataKey = type + "defer",
1921                         queueDataKey = type + "queue",
1922                         markDataKey = type + "mark",
1923                         tmp;
1924                 function resolve() {
1925                         if ( !( --count ) ) {
1926                                 defer.resolveWith( elements, [ elements ] );
1927                         }
1928                 }
1929                 while( i-- ) {
1930                         if (( tmp = jQuery.data( elements[ i ], deferDataKey, undefined, true ) ||
1931                                         ( jQuery.data( elements[ i ], queueDataKey, undefined, true ) ||
1932                                                 jQuery.data( elements[ i ], markDataKey, undefined, true ) ) &&
1933                                         jQuery.data( elements[ i ], deferDataKey, jQuery._Deferred(), true ) )) {
1934                                 count++;
1935                                 tmp.done( resolve );
1936                         }
1937                 }
1938                 resolve();
1939                 return defer.promise();
1940         }
1941 });
1942
1943
1944
1945
1946 var rclass = /[\n\t\r]/g,
1947         rspace = /\s+/,
1948         rreturn = /\r/g,
1949         rtype = /^(?:button|input)$/i,
1950         rfocusable = /^(?:button|input|object|select|textarea)$/i,
1951         rclickable = /^a(?:rea)?$/i,
1952         rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
1953         nodeHook, boolHook;
1954
1955 jQuery.fn.extend({
1956         attr: function( name, value ) {
1957                 return jQuery.access( this, name, value, true, jQuery.attr );
1958         },
1959
1960         removeAttr: function( name ) {
1961                 return this.each(function() {
1962                         jQuery.removeAttr( this, name );
1963                 });
1964         },
1965         
1966         prop: function( name, value ) {
1967                 return jQuery.access( this, name, value, true, jQuery.prop );
1968         },
1969         
1970         removeProp: function( name ) {
1971                 name = jQuery.propFix[ name ] || name;
1972                 return this.each(function() {
1973                         // try/catch handles cases where IE balks (such as removing a property on window)
1974                         try {
1975                                 this[ name ] = undefined;
1976                                 delete this[ name ];
1977                         } catch( e ) {}
1978                 });
1979         },
1980
1981         addClass: function( value ) {
1982                 var classNames, i, l, elem,
1983                         setClass, c, cl;
1984
1985                 if ( jQuery.isFunction( value ) ) {
1986                         return this.each(function( j ) {
1987                                 jQuery( this ).addClass( value.call(this, j, this.className) );
1988                         });
1989                 }
1990
1991                 if ( value && typeof value === "string" ) {
1992                         classNames = value.split( rspace );
1993
1994                         for ( i = 0, l = this.length; i < l; i++ ) {
1995                                 elem = this[ i ];
1996
1997                                 if ( elem.nodeType === 1 ) {
1998                                         if ( !elem.className && classNames.length === 1 ) {
1999                                                 elem.className = value;
2000
2001                                         } else {
2002                                                 setClass = " " + elem.className + " ";
2003
2004                                                 for ( c = 0, cl = classNames.length; c < cl; c++ ) {
2005                                                         if ( !~setClass.indexOf( " " + classNames[ c ] + " " ) ) {
2006                                                                 setClass += classNames[ c ] + " ";
2007                                                         }
2008                                                 }
2009                                                 elem.className = jQuery.trim( setClass );
2010                                         }
2011                                 }
2012                         }
2013                 }
2014
2015                 return this;
2016         },
2017
2018         removeClass: function( value ) {
2019                 var classNames, i, l, elem, className, c, cl;
2020
2021                 if ( jQuery.isFunction( value ) ) {
2022                         return this.each(function( j ) {
2023                                 jQuery( this ).removeClass( value.call(this, j, this.className) );
2024                         });
2025                 }
2026
2027                 if ( (value && typeof value === "string") || value === undefined ) {
2028                         classNames = (value || "").split( rspace );
2029
2030                         for ( i = 0, l = this.length; i < l; i++ ) {
2031                                 elem = this[ i ];
2032
2033                                 if ( elem.nodeType === 1 && elem.className ) {
2034                                         if ( value ) {
2035                                                 className = (" " + elem.className + " ").replace( rclass, " " );
2036                                                 for ( c = 0, cl = classNames.length; c < cl; c++ ) {
2037                                                         className = className.replace(" " + classNames[ c ] + " ", " ");
2038                                                 }
2039                                                 elem.className = jQuery.trim( className );
2040
2041                                         } else {
2042                                                 elem.className = "";
2043                                         }
2044                                 }
2045                         }
2046                 }
2047
2048                 return this;
2049         },
2050
2051         toggleClass: function( value, stateVal ) {
2052                 var type = typeof value,
2053                         isBool = typeof stateVal === "boolean";
2054
2055                 if ( jQuery.isFunction( value ) ) {
2056                         return this.each(function( i ) {
2057                                 jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
2058                         });
2059                 }
2060
2061                 return this.each(function() {
2062                         if ( type === "string" ) {
2063                                 // toggle individual class names
2064                                 var className,
2065                                         i = 0,
2066                                         self = jQuery( this ),
2067                                         state = stateVal,
2068                                         classNames = value.split( rspace );
2069
2070                                 while ( (className = classNames[ i++ ]) ) {
2071                                         // check each className given, space seperated list
2072                                         state = isBool ? state : !self.hasClass( className );
2073                                         self[ state ? "addClass" : "removeClass" ]( className );
2074                                 }
2075
2076                         } else if ( type === "undefined" || type === "boolean" ) {
2077                                 if ( this.className ) {
2078                                         // store className if set
2079                                         jQuery._data( this, "__className__", this.className );
2080                                 }
2081
2082                                 // toggle whole className
2083                                 this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
2084                         }
2085                 });
2086         },
2087
2088         hasClass: function( selector ) {
2089                 var className = " " + selector + " ";
2090                 for ( var i = 0, l = this.length; i < l; i++ ) {
2091                         if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
2092                                 return true;
2093                         }
2094                 }
2095
2096                 return false;
2097         },
2098
2099         val: function( value ) {
2100                 var hooks, ret,
2101                         elem = this[0];
2102                 
2103                 if ( !arguments.length ) {
2104                         if ( elem ) {
2105                                 hooks = jQuery.valHooks[ elem.nodeName.toLowerCase() ] || jQuery.valHooks[ elem.type ];
2106
2107                                 if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
2108                                         return ret;
2109                                 }
2110
2111                                 ret = elem.value;
2112
2113                                 return typeof ret === "string" ? 
2114                                         // handle most common string cases
2115                                         ret.replace(rreturn, "") : 
2116                                         // handle cases where value is null/undef or number
2117                                         ret == null ? "" : ret;
2118                         }
2119
2120                         return undefined;
2121                 }
2122
2123                 var isFunction = jQuery.isFunction( value );
2124
2125                 return this.each(function( i ) {
2126                         var self = jQuery(this), val;
2127
2128                         if ( this.nodeType !== 1 ) {
2129                                 return;
2130                         }
2131
2132                         if ( isFunction ) {
2133                                 val = value.call( this, i, self.val() );
2134                         } else {
2135                                 val = value;
2136                         }
2137
2138                         // Treat null/undefined as ""; convert numbers to string
2139                         if ( val == null ) {
2140                                 val = "";
2141                         } else if ( typeof val === "number" ) {
2142                                 val += "";
2143                         } else if ( jQuery.isArray( val ) ) {
2144                                 val = jQuery.map(val, function ( value ) {
2145                                         return value == null ? "" : value + "";
2146                                 });
2147                         }
2148
2149                         hooks = jQuery.valHooks[ this.nodeName.toLowerCase() ] || jQuery.valHooks[ this.type ];
2150
2151                         // If set returns undefined, fall back to normal setting
2152                         if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
2153                                 this.value = val;
2154                         }
2155                 });
2156         }
2157 });
2158
2159 jQuery.extend({
2160         valHooks: {
2161                 option: {
2162                         get: function( elem ) {
2163                                 // attributes.value is undefined in Blackberry 4.7 but
2164                                 // uses .value. See #6932
2165                                 var val = elem.attributes.value;
2166                                 return !val || val.specified ? elem.value : elem.text;
2167                         }
2168                 },
2169                 select: {
2170                         get: function( elem ) {
2171                                 var value,
2172                                         index = elem.selectedIndex,
2173                                         values = [],
2174                                         options = elem.options,
2175                                         one = elem.type === "select-one";
2176
2177                                 // Nothing was selected
2178                                 if ( index < 0 ) {
2179                                         return null;
2180                                 }
2181
2182                                 // Loop through all the selected options
2183                                 for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
2184                                         var option = options[ i ];
2185
2186                                         // Don't return options that are disabled or in a disabled optgroup
2187                                         if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) &&
2188                                                         (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) {
2189
2190                                                 // Get the specific value for the option
2191                                                 value = jQuery( option ).val();
2192
2193                                                 // We don't need an array for one selects
2194                                                 if ( one ) {
2195                                                         return value;
2196                                                 }
2197
2198                                                 // Multi-Selects return an array
2199                                                 values.push( value );
2200                                         }
2201                                 }
2202
2203                                 // Fixes Bug #2551 -- select.val() broken in IE after form.reset()
2204                                 if ( one && !values.length && options.length ) {
2205                                         return jQuery( options[ index ] ).val();
2206                                 }
2207
2208                                 return values;
2209                         },
2210
2211                         set: function( elem, value ) {
2212                                 var values = jQuery.makeArray( value );
2213
2214                                 jQuery(elem).find("option").each(function() {
2215                                         this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
2216                                 });
2217
2218                                 if ( !values.length ) {
2219                                         elem.selectedIndex = -1;
2220                                 }
2221                                 return values;
2222                         }
2223                 }
2224         },
2225
2226         attrFn: {
2227                 val: true,
2228                 css: true,
2229                 html: true,
2230                 text: true,
2231                 data: true,
2232                 width: true,
2233                 height: true,
2234                 offset: true
2235         },
2236         
2237         attrFix: {
2238                 // Always normalize to ensure hook usage
2239                 tabindex: "tabIndex"
2240         },
2241         
2242         attr: function( elem, name, value, pass ) {
2243                 var nType = elem.nodeType;
2244                 
2245                 // don't get/set attributes on text, comment and attribute nodes
2246                 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
2247                         return undefined;
2248                 }
2249
2250                 if ( pass && name in jQuery.attrFn ) {
2251                         return jQuery( elem )[ name ]( value );
2252                 }
2253
2254                 // Fallback to prop when attributes are not supported
2255                 if ( !("getAttribute" in elem) ) {
2256                         return jQuery.prop( elem, name, value );
2257                 }
2258
2259                 var ret, hooks,
2260                         notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
2261
2262                 // Normalize the name if needed
2263                 if ( notxml ) {
2264                         name = jQuery.attrFix[ name ] || name;
2265
2266                         hooks = jQuery.attrHooks[ name ];
2267
2268                         if ( !hooks ) {
2269                                 // Use boolHook for boolean attributes
2270                                 if ( rboolean.test( name ) ) {
2271                                         hooks = boolHook;
2272
2273                                 // Use nodeHook if available( IE6/7 )
2274                                 } else if ( nodeHook ) {
2275                                         hooks = nodeHook;
2276                                 }
2277                         }
2278                 }
2279
2280                 if ( value !== undefined ) {
2281
2282                         if ( value === null ) {
2283                                 jQuery.removeAttr( elem, name );
2284                                 return undefined;
2285
2286                         } else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) {
2287                                 return ret;
2288
2289                         } else {
2290                                 elem.setAttribute( name, "" + value );
2291                                 return value;
2292                         }
2293
2294                 } else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) !== null ) {
2295                         return ret;
2296
2297                 } else {
2298
2299                         ret = elem.getAttribute( name );
2300
2301                         // Non-existent attributes return null, we normalize to undefined
2302                         return ret === null ?
2303                                 undefined :
2304                                 ret;
2305                 }
2306         },
2307
2308         removeAttr: function( elem, name ) {
2309                 var propName;
2310                 if ( elem.nodeType === 1 ) {
2311                         name = jQuery.attrFix[ name ] || name;
2312
2313                         jQuery.attr( elem, name, "" );
2314                         elem.removeAttribute( name );
2315
2316                         // Set corresponding property to false for boolean attributes
2317                         if ( rboolean.test( name ) && (propName = jQuery.propFix[ name ] || name) in elem ) {
2318                                 elem[ propName ] = false;
2319                         }
2320                 }
2321         },
2322
2323         attrHooks: {
2324                 type: {
2325                         set: function( elem, value ) {
2326                                 // We can't allow the type property to be changed (since it causes problems in IE)
2327                                 if ( rtype.test( elem.nodeName ) && elem.parentNode ) {
2328                                         jQuery.error( "type property can't be changed" );
2329                                 } else if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
2330                                         // Setting the type on a radio button after the value resets the value in IE6-9
2331                                         // Reset value to it's default in case type is set after value
2332                                         // This is for element creation
2333                                         var val = elem.value;
2334                                         elem.setAttribute( "type", value );
2335                                         if ( val ) {
2336                                                 elem.value = val;
2337                                         }
2338                                         return value;
2339                                 }
2340                         }
2341                 },
2342                 // Use the value property for back compat
2343                 // Use the nodeHook for button elements in IE6/7 (#1954)
2344                 value: {
2345                         get: function( elem, name ) {
2346                                 if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
2347                                         return nodeHook.get( elem, name );
2348                                 }
2349                                 return name in elem ?
2350                                         elem.value :
2351                                         null;
2352                         },
2353                         set: function( elem, value, name ) {
2354                                 if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
2355                                         return nodeHook.set( elem, value, name );
2356                                 }
2357                                 // Does not return so that setAttribute is also used
2358                                 elem.value = value;
2359                         }
2360                 }
2361         },
2362
2363         propFix: {
2364                 tabindex: "tabIndex",
2365                 readonly: "readOnly",
2366                 "for": "htmlFor",
2367                 "class": "className",
2368                 maxlength: "maxLength",
2369                 cellspacing: "cellSpacing",
2370                 cellpadding: "cellPadding",
2371                 rowspan: "rowSpan",
2372                 colspan: "colSpan",
2373                 usemap: "useMap",
2374                 frameborder: "frameBorder",
2375                 contenteditable: "contentEditable"
2376         },
2377         
2378         prop: function( elem, name, value ) {
2379                 var nType = elem.nodeType;
2380
2381                 // don't get/set properties on text, comment and attribute nodes
2382                 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
2383                         return undefined;
2384                 }
2385
2386                 var ret, hooks,
2387                         notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
2388
2389                 if ( notxml ) {
2390                         // Fix name and attach hooks
2391                         name = jQuery.propFix[ name ] || name;
2392                         hooks = jQuery.propHooks[ name ];
2393                 }
2394
2395                 if ( value !== undefined ) {
2396                         if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
2397                                 return ret;
2398
2399                         } else {
2400                                 return (elem[ name ] = value);
2401                         }
2402
2403                 } else {
2404                         if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
2405                                 return ret;
2406
2407                         } else {
2408                                 return elem[ name ];
2409                         }
2410                 }
2411         },
2412         
2413         propHooks: {
2414                 tabIndex: {
2415                         get: function( elem ) {
2416                                 // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
2417                                 // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
2418                                 var attributeNode = elem.getAttributeNode("tabindex");
2419
2420                                 return attributeNode && attributeNode.specified ?
2421                                         parseInt( attributeNode.value, 10 ) :
2422                                         rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
2423                                                 0 :
2424                                                 undefined;
2425                         }
2426                 }
2427         }
2428 });
2429
2430 // Add the tabindex propHook to attrHooks for back-compat
2431 jQuery.attrHooks.tabIndex = jQuery.propHooks.tabIndex;
2432
2433 // Hook for boolean attributes
2434 boolHook = {
2435         get: function( elem, name ) {
2436                 // Align boolean attributes with corresponding properties
2437                 // Fall back to attribute presence where some booleans are not supported
2438                 var attrNode;
2439                 return jQuery.prop( elem, name ) === true || ( attrNode = elem.getAttributeNode( name ) ) && attrNode.nodeValue !== false ?
2440                         name.toLowerCase() :
2441                         undefined;
2442         },
2443         set: function( elem, value, name ) {
2444                 var propName;
2445                 if ( value === false ) {
2446                         // Remove boolean attributes when set to false
2447                         jQuery.removeAttr( elem, name );
2448                 } else {
2449                         // value is true since we know at this point it's type boolean and not false
2450                         // Set boolean attributes to the same name and set the DOM property
2451                         propName = jQuery.propFix[ name ] || name;
2452                         if ( propName in elem ) {
2453                                 // Only set the IDL specifically if it already exists on the element
2454                                 elem[ propName ] = true;
2455                         }
2456
2457                         elem.setAttribute( name, name.toLowerCase() );
2458                 }
2459                 return name;
2460         }
2461 };
2462
2463 // IE6/7 do not support getting/setting some attributes with get/setAttribute
2464 if ( !jQuery.support.getSetAttribute ) {
2465         
2466         // Use this for any attribute in IE6/7
2467         // This fixes almost every IE6/7 issue
2468         nodeHook = jQuery.valHooks.button = {
2469                 get: function( elem, name ) {
2470                         var ret;
2471                         ret = elem.getAttributeNode( name );
2472                         // Return undefined if nodeValue is empty string
2473                         return ret && ret.nodeValue !== "" ?
2474                                 ret.nodeValue :
2475                                 undefined;
2476                 },
2477                 set: function( elem, value, name ) {
2478                         // Set the existing or create a new attribute node
2479                         var ret = elem.getAttributeNode( name );
2480                         if ( !ret ) {
2481                                 ret = document.createAttribute( name );
2482                                 elem.setAttributeNode( ret );
2483                         }
2484                         return (ret.nodeValue = value + "");
2485                 }
2486         };
2487
2488         // Set width and height to auto instead of 0 on empty string( Bug #8150 )
2489         // This is for removals
2490         jQuery.each([ "width", "height" ], function( i, name ) {
2491                 jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
2492                         set: function( elem, value ) {
2493                                 if ( value === "" ) {
2494                                         elem.setAttribute( name, "auto" );
2495                                         return value;
2496                                 }
2497                         }
2498                 });
2499         });
2500 }
2501
2502
2503 // Some attributes require a special call on IE
2504 if ( !jQuery.support.hrefNormalized ) {
2505         jQuery.each([ "href", "src", "width", "height" ], function( i, name ) {
2506                 jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
2507                         get: function( elem ) {
2508                                 var ret = elem.getAttribute( name, 2 );
2509                                 return ret === null ? undefined : ret;
2510                         }
2511                 });
2512         });
2513 }
2514
2515 if ( !jQuery.support.style ) {
2516         jQuery.attrHooks.style = {
2517                 get: function( elem ) {
2518                         // Return undefined in the case of empty string
2519                         // Normalize to lowercase since IE uppercases css property names
2520                         return elem.style.cssText.toLowerCase() || undefined;
2521                 },
2522                 set: function( elem, value ) {
2523                         return (elem.style.cssText = "" + value);
2524                 }
2525         };
2526 }
2527
2528 // Safari mis-reports the default selected property of an option
2529 // Accessing the parent's selectedIndex property fixes it
2530 if ( !jQuery.support.optSelected ) {
2531         jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, {
2532                 get: function( elem ) {
2533                         var parent = elem.parentNode;
2534
2535                         if ( parent ) {
2536                                 parent.selectedIndex;
2537
2538                                 // Make sure that it also works with optgroups, see #5701
2539                                 if ( parent.parentNode ) {
2540                                         parent.parentNode.selectedIndex;
2541                                 }
2542                         }
2543                         return null;
2544                 }
2545         });
2546 }
2547
2548 // Radios and checkboxes getter/setter
2549 if ( !jQuery.support.checkOn ) {
2550         jQuery.each([ "radio", "checkbox" ], function() {
2551                 jQuery.valHooks[ this ] = {
2552                         get: function( elem ) {
2553                                 // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
2554                                 return elem.getAttribute("value") === null ? "on" : elem.value;
2555                         }
2556                 };
2557         });
2558 }
2559 jQuery.each([ "radio", "checkbox" ], function() {
2560         jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], {
2561                 set: function( elem, value ) {
2562                         if ( jQuery.isArray( value ) ) {
2563                                 return (elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0);
2564                         }
2565                 }
2566         });
2567 });
2568
2569
2570
2571
2572 var rnamespaces = /\.(.*)$/,
2573         rformElems = /^(?:textarea|input|select)$/i,
2574         rperiod = /\./g,
2575         rspaces = / /g,
2576         rescape = /[^\w\s.|`]/g,
2577         fcleanup = function( nm ) {
2578                 return nm.replace(rescape, "\\$&");
2579         };
2580
2581 /*
2582  * A number of helper functions used for managing events.
2583  * Many of the ideas behind this code originated from
2584  * Dean Edwards' addEvent library.
2585  */
2586 jQuery.event = {
2587
2588         // Bind an event to an element
2589         // Original by Dean Edwards
2590         add: function( elem, types, handler, data ) {
2591                 if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
2592                         return;
2593                 }
2594
2595                 if ( handler === false ) {
2596                         handler = returnFalse;
2597                 } else if ( !handler ) {
2598                         // Fixes bug #7229. Fix recommended by jdalton
2599                         return;
2600                 }
2601
2602                 var handleObjIn, handleObj;
2603
2604                 if ( handler.handler ) {
2605                         handleObjIn = handler;
2606                         handler = handleObjIn.handler;
2607                 }
2608
2609                 // Make sure that the function being executed has a unique ID
2610                 if ( !handler.guid ) {
2611                         handler.guid = jQuery.guid++;
2612                 }
2613
2614                 // Init the element's event structure
2615                 var elemData = jQuery._data( elem );
2616
2617                 // If no elemData is found then we must be trying to bind to one of the
2618                 // banned noData elements
2619                 if ( !elemData ) {
2620                         return;
2621                 }
2622
2623                 var events = elemData.events,
2624                         eventHandle = elemData.handle;
2625
2626                 if ( !events ) {
2627                         elemData.events = events = {};
2628                 }
2629
2630                 if ( !eventHandle ) {
2631                         elemData.handle = eventHandle = function( e ) {
2632                                 // Discard the second event of a jQuery.event.trigger() and
2633                                 // when an event is called after a page has unloaded
2634                                 return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ?
2635                                         jQuery.event.handle.apply( eventHandle.elem, arguments ) :
2636                                         undefined;
2637                         };
2638                 }
2639
2640                 // Add elem as a property of the handle function
2641                 // This is to prevent a memory leak with non-native events in IE.
2642                 eventHandle.elem = elem;
2643
2644                 // Handle multiple events separated by a space
2645                 // jQuery(...).bind("mouseover mouseout", fn);
2646                 types = types.split(" ");
2647
2648                 var type, i = 0, namespaces;
2649
2650                 while ( (type = types[ i++ ]) ) {
2651                         handleObj = handleObjIn ?
2652                                 jQuery.extend({}, handleObjIn) :
2653                                 { handler: handler, data: data };
2654
2655                         // Namespaced event handlers
2656                         if ( type.indexOf(".") > -1 ) {
2657                                 namespaces = type.split(".");
2658                                 type = namespaces.shift();
2659                                 handleObj.namespace = namespaces.slice(0).sort().join(".");
2660
2661                         } else {
2662                                 namespaces = [];
2663                                 handleObj.namespace = "";
2664                         }
2665
2666                         handleObj.type = type;
2667                         if ( !handleObj.guid ) {
2668                                 handleObj.guid = handler.guid;
2669                         }
2670
2671                         // Get the current list of functions bound to this event
2672                         var handlers = events[ type ],
2673                                 special = jQuery.event.special[ type ] || {};
2674
2675                         // Init the event handler queue
2676                         if ( !handlers ) {
2677                                 handlers = events[ type ] = [];
2678
2679                                 // Check for a special event handler
2680                                 // Only use addEventListener/attachEvent if the special
2681                                 // events handler returns false
2682                                 if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
2683                                         // Bind the global event handler to the element
2684                                         if ( elem.addEventListener ) {
2685                                                 elem.addEventListener( type, eventHandle, false );
2686
2687                                         } else if ( elem.attachEvent ) {
2688                                                 elem.attachEvent( "on" + type, eventHandle );
2689                                         }
2690                                 }
2691                         }
2692
2693                         if ( special.add ) {
2694                                 special.add.call( elem, handleObj );
2695
2696                                 if ( !handleObj.handler.guid ) {
2697                                         handleObj.handler.guid = handler.guid;
2698                                 }
2699                         }
2700
2701                         // Add the function to the element's handler list
2702                         handlers.push( handleObj );
2703
2704                         // Keep track of which events have been used, for event optimization
2705                         jQuery.event.global[ type ] = true;
2706                 }
2707
2708                 // Nullify elem to prevent memory leaks in IE
2709                 elem = null;
2710         },
2711
2712         global: {},
2713
2714         // Detach an event or set of events from an element
2715         remove: function( elem, types, handler, pos ) {
2716                 // don't do events on text and comment nodes
2717                 if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
2718                         return;
2719                 }
2720
2721                 if ( handler === false ) {
2722                         handler = returnFalse;
2723                 }
2724
2725                 var ret, type, fn, j, i = 0, all, namespaces, namespace, special, eventType, handleObj, origType,
2726                         elemData = jQuery.hasData( elem ) && jQuery._data( elem ),
2727                         events = elemData && elemData.events;
2728
2729                 if ( !elemData || !events ) {
2730                         return;
2731                 }
2732
2733                 // types is actually an event object here
2734                 if ( types && types.type ) {
2735                         handler = types.handler;
2736                         types = types.type;
2737                 }
2738
2739                 // Unbind all events for the element
2740                 if ( !types || typeof types === "string" && types.charAt(0) === "." ) {
2741                         types = types || "";
2742
2743                         for ( type in events ) {
2744                                 jQuery.event.remove( elem, type + types );
2745                         }
2746
2747                         return;
2748                 }
2749
2750                 // Handle multiple events separated by a space
2751                 // jQuery(...).unbind("mouseover mouseout", fn);
2752                 types = types.split(" ");
2753
2754                 while ( (type = types[ i++ ]) ) {
2755                         origType = type;
2756                         handleObj = null;
2757                         all = type.indexOf(".") < 0;
2758                         namespaces = [];
2759
2760                         if ( !all ) {
2761                                 // Namespaced event handlers
2762                                 namespaces = type.split(".");
2763                                 type = namespaces.shift();
2764
2765                                 namespace = new RegExp("(^|\\.)" +
2766                                         jQuery.map( namespaces.slice(0).sort(), fcleanup ).join("\\.(?:.*\\.)?") + "(\\.|$)");
2767                         }
2768
2769                         eventType = events[ type ];
2770
2771                         if ( !eventType ) {
2772                                 continue;
2773                         }
2774
2775                         if ( !handler ) {
2776                                 for ( j = 0; j < eventType.length; j++ ) {
2777                                         handleObj = eventType[ j ];
2778
2779                                         if ( all || namespace.test( handleObj.namespace ) ) {
2780                                                 jQuery.event.remove( elem, origType, handleObj.handler, j );
2781                                                 eventType.splice( j--, 1 );
2782                                         }
2783                                 }
2784
2785                                 continue;
2786                         }
2787
2788                         special = jQuery.event.special[ type ] || {};
2789
2790                         for ( j = pos || 0; j < eventType.length; j++ ) {
2791                                 handleObj = eventType[ j ];
2792
2793                                 if ( handler.guid === handleObj.guid ) {
2794                                         // remove the given handler for the given type
2795                                         if ( all || namespace.test( handleObj.namespace ) ) {
2796                                                 if ( pos == null ) {
2797                                                         eventType.splice( j--, 1 );
2798                                                 }
2799
2800                                                 if ( special.remove ) {
2801                                                         special.remove.call( elem, handleObj );
2802                                                 }
2803                                         }
2804
2805                                         if ( pos != null ) {
2806                                                 break;
2807                                         }
2808                                 }
2809                         }
2810
2811                         // remove generic event handler if no more handlers exist
2812                         if ( eventType.length === 0 || pos != null && eventType.length === 1 ) {
2813                                 if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) {
2814                                         jQuery.removeEvent( elem, type, elemData.handle );
2815                                 }
2816
2817                                 ret = null;
2818                                 delete events[ type ];
2819                         }
2820                 }
2821
2822                 // Remove the expando if it's no longer used
2823                 if ( jQuery.isEmptyObject( events ) ) {
2824                         var handle = elemData.handle;
2825                         if ( handle ) {
2826                                 handle.elem = null;
2827                         }
2828
2829                         delete elemData.events;
2830                         delete elemData.handle;
2831
2832                         if ( jQuery.isEmptyObject( elemData ) ) {
2833                                 jQuery.removeData( elem, undefined, true );
2834                         }
2835                 }
2836         },
2837         
2838         // Events that are safe to short-circuit if no handlers are attached.
2839         // Native DOM events should not be added, they may have inline handlers.
2840         customEvent: {
2841                 "getData": true,
2842                 "setData": true,
2843                 "changeData": true
2844         },
2845
2846         trigger: function( event, data, elem, onlyHandlers ) {
2847                 // Event object or event type
2848                 var type = event.type || event,
2849                         namespaces = [],
2850                         exclusive;
2851
2852                 if ( type.indexOf("!") >= 0 ) {
2853                         // Exclusive events trigger only for the exact event (no namespaces)
2854                         type = type.slice(0, -1);
2855                         exclusive = true;
2856                 }
2857
2858                 if ( type.indexOf(".") >= 0 ) {
2859                         // Namespaced trigger; create a regexp to match event type in handle()
2860                         namespaces = type.split(".");
2861                         type = namespaces.shift();
2862                         namespaces.sort();
2863                 }
2864
2865                 if ( (!elem || jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ] ) {
2866                         // No jQuery handlers for this event type, and it can't have inline handlers
2867                         return;
2868                 }
2869
2870                 // Caller can pass in an Event, Object, or just an event type string
2871                 event = typeof event === "object" ?
2872                         // jQuery.Event object
2873                         event[ jQuery.expando ] ? event :
2874                         // Object literal
2875                         new jQuery.Event( type, event ) :
2876                         // Just the event type (string)
2877                         new jQuery.Event( type );
2878
2879                 event.type = type;
2880                 event.exclusive = exclusive;
2881                 event.namespace = namespaces.join(".");