Tizen 2.1 base
[platform/framework/web/web-ui-fw.git] / libs / js / jquery-mobile-1.0.1pre / js / 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
17 (function( window, undefined ) {
18
19 // Use the correct document accordingly with window argument (sandbox)
20 var document = window.document,
21         navigator = window.navigator,
22         location = window.location;
23 var jQuery = (function() {
24
25 // Define a local copy of jQuery
26 var jQuery = function( selector, context ) {
27                 // The jQuery object is actually just the init constructor 'enhanced'
28                 return new jQuery.fn.init( selector, context, rootjQuery );
29         },
30
31         // Map over jQuery in case of overwrite
32         _jQuery = window.jQuery,
33
34         // Map over the $ in case of overwrite
35         _$ = window.$,
36
37         // A central reference to the root jQuery(document)
38         rootjQuery,
39
40         // A simple way to check for HTML strings or ID strings
41         // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
42         quickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,
43
44         // Check if a string has a non-whitespace character in it
45         rnotwhite = /\S/,
46
47         // Used for trimming whitespace
48         trimLeft = /^\s+/,
49         trimRight = /\s+$/,
50
51         // Check for digits
52         rdigit = /\d/,
53
54         // Match a standalone tag
55         rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
56
57         // JSON RegExp
58         rvalidchars = /^[\],:{}\s]*$/,
59         rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,
60         rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
61         rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
62
63         // Useragent RegExp
64         rwebkit = /(webkit)[ \/]([\w.]+)/,
65         ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/,
66         rmsie = /(msie) ([\w.]+)/,
67         rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/,
68
69         // Matches dashed string for camelizing
70         rdashAlpha = /-([a-z]|[0-9])/ig,
71         rmsPrefix = /^-ms-/,
72
73         // Used by jQuery.camelCase as callback to replace()
74         fcamelCase = function( all, letter ) {
75                 return ( letter + "" ).toUpperCase();
76         },
77
78         // Keep a UserAgent string for use with jQuery.browser
79         userAgent = navigator.userAgent,
80
81         // For matching the engine and version of the browser
82         browserMatch,
83
84         // The deferred used on DOM ready
85         readyList,
86
87         // The ready event handler
88         DOMContentLoaded,
89
90         // Save a reference to some core methods
91         toString = Object.prototype.toString,
92         hasOwn = Object.prototype.hasOwnProperty,
93         push = Array.prototype.push,
94         slice = Array.prototype.slice,
95         trim = String.prototype.trim,
96         indexOf = Array.prototype.indexOf,
97
98         // [[Class]] -> type pairs
99         class2type = {};
100
101 jQuery.fn = jQuery.prototype = {
102         constructor: jQuery,
103         init: function( selector, context, rootjQuery ) {
104                 var match, elem, ret, doc;
105
106                 // Handle $(""), $(null), or $(undefined)
107                 if ( !selector ) {
108                         return this;
109                 }
110
111                 // Handle $(DOMElement)
112                 if ( selector.nodeType ) {
113                         this.context = this[0] = selector;
114                         this.length = 1;
115                         return this;
116                 }
117
118                 // The body element only exists once, optimize finding it
119                 if ( selector === "body" && !context && document.body ) {
120                         this.context = document;
121                         this[0] = document.body;
122                         this.selector = selector;
123                         this.length = 1;
124                         return this;
125                 }
126
127                 // Handle HTML strings
128                 if ( typeof selector === "string" ) {
129                         // Are we dealing with HTML string or an ID?
130                         if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
131                                 // Assume that strings that start and end with <> are HTML and skip the regex check
132                                 match = [ null, selector, null ];
133
134                         } else {
135                                 match = quickExpr.exec( selector );
136                         }
137
138                         // Verify a match, and that no context was specified for #id
139                         if ( match && (match[1] || !context) ) {
140
141                                 // HANDLE: $(html) -> $(array)
142                                 if ( match[1] ) {
143                                         context = context instanceof jQuery ? context[0] : context;
144                                         doc = (context ? context.ownerDocument || context : document);
145
146                                         // If a single string is passed in and it's a single tag
147                                         // just do a createElement and skip the rest
148                                         ret = rsingleTag.exec( selector );
149
150                                         if ( ret ) {
151                                                 if ( jQuery.isPlainObject( context ) ) {
152                                                         selector = [ document.createElement( ret[1] ) ];
153                                                         jQuery.fn.attr.call( selector, context, true );
154
155                                                 } else {
156                                                         selector = [ doc.createElement( ret[1] ) ];
157                                                 }
158
159                                         } else {
160                                                 ret = jQuery.buildFragment( [ match[1] ], [ doc ] );
161                                                 selector = (ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment).childNodes;
162                                         }
163
164                                         return jQuery.merge( this, selector );
165
166                                 // HANDLE: $("#id")
167                                 } else {
168                                         elem = document.getElementById( match[2] );
169
170                                         // Check parentNode to catch when Blackberry 4.6 returns
171                                         // nodes that are no longer in the document #6963
172                                         if ( elem && elem.parentNode ) {
173                                                 // Handle the case where IE and Opera return items
174                                                 // by name instead of ID
175                                                 if ( elem.id !== match[2] ) {
176                                                         return rootjQuery.find( selector );
177                                                 }
178
179                                                 // Otherwise, we inject the element directly into the jQuery object
180                                                 this.length = 1;
181                                                 this[0] = elem;
182                                         }
183
184                                         this.context = document;
185                                         this.selector = selector;
186                                         return this;
187                                 }
188
189                         // HANDLE: $(expr, $(...))
190                         } else if ( !context || context.jquery ) {
191                                 return (context || rootjQuery).find( selector );
192
193                         // HANDLE: $(expr, context)
194                         // (which is just equivalent to: $(context).find(expr)
195                         } else {
196                                 return this.constructor( context ).find( selector );
197                         }
198
199                 // HANDLE: $(function)
200                 // Shortcut for document ready
201                 } else if ( jQuery.isFunction( selector ) ) {
202                         return rootjQuery.ready( selector );
203                 }
204
205                 if (selector.selector !== undefined) {
206                         this.selector = selector.selector;
207                         this.context = selector.context;
208                 }
209
210                 return jQuery.makeArray( selector, this );
211         },
212
213         // Start with an empty selector
214         selector: "",
215
216         // The current version of jQuery being used
217         jquery: "1.6.4",
218
219         // The default length of a jQuery object is 0
220         length: 0,
221
222         // The number of elements contained in the matched element set
223         size: function() {
224                 return this.length;
225         },
226
227         toArray: function() {
228                 return slice.call( this, 0 );
229         },
230
231         // Get the Nth element in the matched element set OR
232         // Get the whole matched element set as a clean array
233         get: function( num ) {
234                 return num == null ?
235
236                         // Return a 'clean' array
237                         this.toArray() :
238
239                         // Return just the object
240                         ( num < 0 ? this[ this.length + num ] : this[ num ] );
241         },
242
243         // Take an array of elements and push it onto the stack
244         // (returning the new matched element set)
245         pushStack: function( elems, name, selector ) {
246                 // Build a new jQuery matched element set
247                 var ret = this.constructor();
248
249                 if ( jQuery.isArray( elems ) ) {
250                         push.apply( ret, elems );
251
252                 } else {
253                         jQuery.merge( ret, elems );
254                 }
255
256                 // Add the old object onto the stack (as a reference)
257                 ret.prevObject = this;
258
259                 ret.context = this.context;
260
261                 if ( name === "find" ) {
262                         ret.selector = this.selector + (this.selector ? " " : "") + selector;
263                 } else if ( name ) {
264                         ret.selector = this.selector + "." + name + "(" + selector + ")";
265                 }
266
267                 // Return the newly-formed element set
268                 return ret;
269         },
270
271         // Execute a callback for every element in the matched set.
272         // (You can seed the arguments with an array of args, but this is
273         // only used internally.)
274         each: function( callback, args ) {
275                 return jQuery.each( this, callback, args );
276         },
277
278         ready: function( fn ) {
279                 // Attach the listeners
280                 jQuery.bindReady();
281
282                 // Add the callback
283                 readyList.done( fn );
284
285                 return this;
286         },
287
288         eq: function( i ) {
289                 return i === -1 ?
290                         this.slice( i ) :
291                         this.slice( i, +i + 1 );
292         },
293
294         first: function() {
295                 return this.eq( 0 );
296         },
297
298         last: function() {
299                 return this.eq( -1 );
300         },
301
302         slice: function() {
303                 return this.pushStack( slice.apply( this, arguments ),
304                         "slice", slice.call(arguments).join(",") );
305         },
306
307         map: function( callback ) {
308                 return this.pushStack( jQuery.map(this, function( elem, i ) {
309                         return callback.call( elem, i, elem );
310                 }));
311         },
312
313         end: function() {
314                 return this.prevObject || this.constructor(null);
315         },
316
317         // For internal use only.
318         // Behaves like an Array's method, not like a jQuery method.
319         push: push,
320         sort: [].sort,
321         splice: [].splice
322 };
323
324 // Give the init function the jQuery prototype for later instantiation
325 jQuery.fn.init.prototype = jQuery.fn;
326
327 jQuery.extend = jQuery.fn.extend = function() {
328         var options, name, src, copy, copyIsArray, clone,
329                 target = arguments[0] || {},
330                 i = 1,
331                 length = arguments.length,
332                 deep = false;
333
334         // Handle a deep copy situation
335         if ( typeof target === "boolean" ) {
336                 deep = target;
337                 target = arguments[1] || {};
338                 // skip the boolean and the target
339                 i = 2;
340         }
341
342         // Handle case when target is a string or something (possible in deep copy)
343         if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
344                 target = {};
345         }
346
347         // extend jQuery itself if only one argument is passed
348         if ( length === i ) {
349                 target = this;
350                 --i;
351         }
352
353         for ( ; i < length; i++ ) {
354                 // Only deal with non-null/undefined values
355                 if ( (options = arguments[ i ]) != null ) {
356                         // Extend the base object
357                         for ( name in options ) {
358                                 src = target[ name ];
359                                 copy = options[ name ];
360
361                                 // Prevent never-ending loop
362                                 if ( target === copy ) {
363                                         continue;
364                                 }
365
366                                 // Recurse if we're merging plain objects or arrays
367                                 if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
368                                         if ( copyIsArray ) {
369                                                 copyIsArray = false;
370                                                 clone = src && jQuery.isArray(src) ? src : [];
371
372                                         } else {
373                                                 clone = src && jQuery.isPlainObject(src) ? src : {};
374                                         }
375
376                                         // Never move original objects, clone them
377                                         target[ name ] = jQuery.extend( deep, clone, copy );
378
379                                 // Don't bring in undefined values
380                                 } else if ( copy !== undefined ) {
381                                         target[ name ] = copy;
382                                 }
383                         }
384                 }
385         }
386
387         // Return the modified object
388         return target;
389 };
390
391 jQuery.extend({
392         noConflict: function( deep ) {
393                 if ( window.$ === jQuery ) {
394                         window.$ = _$;
395                 }
396
397                 if ( deep && window.jQuery === jQuery ) {
398                         window.jQuery = _jQuery;
399                 }
400
401                 return jQuery;
402         },
403
404         // Is the DOM ready to be used? Set to true once it occurs.
405         isReady: false,
406
407         // A counter to track how many items to wait for before
408         // the ready event fires. See #6781
409         readyWait: 1,
410
411         // Hold (or release) the ready event
412         holdReady: function( hold ) {
413                 if ( hold ) {
414                         jQuery.readyWait++;
415                 } else {
416                         jQuery.ready( true );
417                 }
418         },
419
420         // Handle when the DOM is ready
421         ready: function( wait ) {
422                 // Either a released hold or an DOMready/load event and not yet ready
423                 if ( (wait === true && !--jQuery.readyWait) || (wait !== true && !jQuery.isReady) ) {
424                         // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
425                         if ( !document.body ) {
426                                 return setTimeout( jQuery.ready, 1 );
427                         }
428
429                         // Remember that the DOM is ready
430                         jQuery.isReady = true;
431
432                         // If a normal DOM Ready event fired, decrement, and wait if need be
433                         if ( wait !== true && --jQuery.readyWait > 0 ) {
434                                 return;
435                         }
436
437                         // If there are functions bound, to execute
438                         readyList.resolveWith( document, [ jQuery ] );
439
440                         // Trigger any bound ready events
441                         if ( jQuery.fn.trigger ) {
442                                 jQuery( document ).trigger( "ready" ).unbind( "ready" );
443                         }
444                 }
445         },
446
447         bindReady: function() {
448                 if ( readyList ) {
449                         return;
450                 }
451
452                 readyList = jQuery._Deferred();
453
454                 // Catch cases where $(document).ready() is called after the
455                 // browser event has already occurred.
456                 if ( document.readyState === "complete" ) {
457                         // Handle it asynchronously to allow scripts the opportunity to delay ready
458                         return setTimeout( jQuery.ready, 1 );
459                 }
460
461                 // Mozilla, Opera and webkit nightlies currently support this event
462                 if ( document.addEventListener ) {
463                         // Use the handy event callback
464                         document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
465
466                         // A fallback to window.onload, that will always work
467                         window.addEventListener( "load", jQuery.ready, false );
468
469                 // If IE event model is used
470                 } else if ( document.attachEvent ) {
471                         // ensure firing before onload,
472                         // maybe late but safe also for iframes
473                         document.attachEvent( "onreadystatechange", DOMContentLoaded );
474
475                         // A fallback to window.onload, that will always work
476                         window.attachEvent( "onload", jQuery.ready );
477
478                         // If IE and not a frame
479                         // continually check to see if the document is ready
480                         var toplevel = false;
481
482                         try {
483                                 toplevel = window.frameElement == null;
484                         } catch(e) {}
485
486                         if ( document.documentElement.doScroll && toplevel ) {
487                                 doScrollCheck();
488                         }
489                 }
490         },
491
492         // See test/unit/core.js for details concerning isFunction.
493         // Since version 1.3, DOM methods and functions like alert
494         // aren't supported. They return false on IE (#2968).
495         isFunction: function( obj ) {
496                 return jQuery.type(obj) === "function";
497         },
498
499         isArray: Array.isArray || function( obj ) {
500                 return jQuery.type(obj) === "array";
501         },
502
503         // A crude way of determining if an object is a window
504         isWindow: function( obj ) {
505                 return obj && typeof obj === "object" && "setInterval" in obj;
506         },
507
508         isNaN: function( obj ) {
509                 return obj == null || !rdigit.test( obj ) || isNaN( obj );
510         },
511
512         type: function( obj ) {
513                 return obj == null ?
514                         String( obj ) :
515                         class2type[ toString.call(obj) ] || "object";
516         },
517
518         isPlainObject: function( obj ) {
519                 // Must be an Object.
520                 // Because of IE, we also have to check the presence of the constructor property.
521                 // Make sure that DOM nodes and window objects don't pass through, as well
522                 if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
523                         return false;
524                 }
525
526                 try {
527                         // Not own constructor property must be Object
528                         if ( obj.constructor &&
529                                 !hasOwn.call(obj, "constructor") &&
530                                 !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
531                                 return false;
532                         }
533                 } catch ( e ) {
534                         // IE8,9 Will throw exceptions on certain host objects #9897
535                         return false;
536                 }
537
538                 // Own properties are enumerated firstly, so to speed up,
539                 // if last one is own, then all properties are own.
540
541                 var key;
542                 for ( key in obj ) {}
543
544                 return key === undefined || hasOwn.call( obj, key );
545         },
546
547         isEmptyObject: function( obj ) {
548                 for ( var name in obj ) {
549                         return false;
550                 }
551                 return true;
552         },
553
554         error: function( msg ) {
555                 throw msg;
556         },
557
558         parseJSON: function( data ) {
559                 if ( typeof data !== "string" || !data ) {
560                         return null;
561                 }
562
563                 // Make sure leading/trailing whitespace is removed (IE can't handle it)
564                 data = jQuery.trim( data );
565
566                 // Attempt to parse using the native JSON parser first
567                 if ( window.JSON && window.JSON.parse ) {
568                         return window.JSON.parse( data );
569                 }
570
571                 // Make sure the incoming data is actual JSON
572                 // Logic borrowed from http://json.org/json2.js
573                 if ( rvalidchars.test( data.replace( rvalidescape, "@" )
574                         .replace( rvalidtokens, "]" )
575                         .replace( rvalidbraces, "")) ) {
576
577                         return (new Function( "return " + data ))();
578
579                 }
580                 jQuery.error( "Invalid JSON: " + data );
581         },
582
583         // Cross-browser xml parsing
584         parseXML: function( data ) {
585                 var xml, tmp;
586                 try {
587                         if ( window.DOMParser ) { // Standard
588                                 tmp = new DOMParser();
589                                 xml = tmp.parseFromString( data , "text/xml" );
590                         } else { // IE
591                                 xml = new ActiveXObject( "Microsoft.XMLDOM" );
592                                 xml.async = "false";
593                                 xml.loadXML( data );
594                         }
595                 } catch( e ) {
596                         xml = undefined;
597                 }
598                 if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
599                         jQuery.error( "Invalid XML: " + data );
600                 }
601                 return xml;
602         },
603
604         noop: function() {},
605
606         // Evaluates a script in a global context
607         // Workarounds based on findings by Jim Driscoll
608         // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
609         globalEval: function( data ) {
610                 if ( data && rnotwhite.test( data ) ) {
611                         // We use execScript on Internet Explorer
612                         // We use an anonymous function so that context is window
613                         // rather than jQuery in Firefox
614                         ( window.execScript || function( data ) {
615                                 window[ "eval" ].call( window, data );
616                         } )( data );
617                 }
618         },
619
620         // Convert dashed to camelCase; used by the css and data modules
621         // Microsoft forgot to hump their vendor prefix (#9572)
622         camelCase: function( string ) {
623                 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
624         },
625
626         nodeName: function( elem, name ) {
627                 return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
628         },
629
630         // args is for internal usage only
631         each: function( object, callback, args ) {
632                 var name, i = 0,
633                         length = object.length,
634                         isObj = length === undefined || jQuery.isFunction( object );
635
636                 if ( args ) {
637                         if ( isObj ) {
638                                 for ( name in object ) {
639                                         if ( callback.apply( object[ name ], args ) === false ) {
640                                                 break;
641                                         }
642                                 }
643                         } else {
644                                 for ( ; i < length; ) {
645                                         if ( callback.apply( object[ i++ ], args ) === false ) {
646                                                 break;
647                                         }
648                                 }
649                         }
650
651                 // A special, fast, case for the most common use of each
652                 } else {
653                         if ( isObj ) {
654                                 for ( name in object ) {
655                                         if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
656                                                 break;
657                                         }
658                                 }
659                         } else {
660                                 for ( ; i < length; ) {
661                                         if ( callback.call( object[ i ], i, object[ i++ ] ) === false ) {
662                                                 break;
663                                         }
664                                 }
665                         }
666                 }
667
668                 return object;
669         },
670
671         // Use native String.trim function wherever possible
672         trim: trim ?
673                 function( text ) {
674                         return text == null ?
675                                 "" :
676                                 trim.call( text );
677                 } :
678
679                 // Otherwise use our own trimming functionality
680                 function( text ) {
681                         return text == null ?
682                                 "" :
683                                 text.toString().replace( trimLeft, "" ).replace( trimRight, "" );
684                 },
685
686         // results is for internal usage only
687         makeArray: function( array, results ) {
688                 var ret = results || [];
689
690                 if ( array != null ) {
691                         // The window, strings (and functions) also have 'length'
692                         // The extra typeof function check is to prevent crashes
693                         // in Safari 2 (See: #3039)
694                         // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
695                         var type = jQuery.type( array );
696
697                         if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) {
698                                 push.call( ret, array );
699                         } else {
700                                 jQuery.merge( ret, array );
701                         }
702                 }
703
704                 return ret;
705         },
706
707         inArray: function( elem, array ) {
708                 if ( !array ) {
709                         return -1;
710                 }
711
712                 if ( indexOf ) {
713                         return indexOf.call( array, elem );
714                 }
715
716                 for ( var i = 0, length = array.length; i < length; i++ ) {
717                         if ( array[ i ] === elem ) {
718                                 return i;
719                         }
720                 }
721
722                 return -1;
723         },
724
725         merge: function( first, second ) {
726                 var i = first.length,
727                         j = 0;
728
729                 if ( typeof second.length === "number" ) {
730                         for ( var l = second.length; j < l; j++ ) {
731                                 first[ i++ ] = second[ j ];
732                         }
733
734                 } else {
735                         while ( second[j] !== undefined ) {
736                                 first[ i++ ] = second[ j++ ];
737                         }
738                 }
739
740                 first.length = i;
741
742                 return first;
743         },
744
745         grep: function( elems, callback, inv ) {
746                 var ret = [], retVal;
747                 inv = !!inv;
748
749                 // Go through the array, only saving the items
750                 // that pass the validator function
751                 for ( var i = 0, length = elems.length; i < length; i++ ) {
752                         retVal = !!callback( elems[ i ], i );
753                         if ( inv !== retVal ) {
754                                 ret.push( elems[ i ] );
755                         }
756                 }
757
758                 return ret;
759         },
760
761         // arg is for internal usage only
762         map: function( elems, callback, arg ) {
763                 var value, key, ret = [],
764                         i = 0,
765                         length = elems.length,
766                         // jquery objects are treated as arrays
767                         isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ;
768
769                 // Go through the array, translating each of the items to their
770                 if ( isArray ) {
771                         for ( ; i < length; i++ ) {
772                                 value = callback( elems[ i ], i, arg );
773
774                                 if ( value != null ) {
775                                         ret[ ret.length ] = value;
776                                 }
777                         }
778
779                 // Go through every key on the object,
780                 } else {
781                         for ( key in elems ) {
782                                 value = callback( elems[ key ], key, arg );
783
784                                 if ( value != null ) {
785                                         ret[ ret.length ] = value;
786                                 }
787                         }
788                 }
789
790                 // Flatten any nested arrays
791                 return ret.concat.apply( [], ret );
792         },
793
794         // A global GUID counter for objects
795         guid: 1,
796
797         // Bind a function to a context, optionally partially applying any
798         // arguments.
799         proxy: function( fn, context ) {
800                 if ( typeof context === "string" ) {
801                         var tmp = fn[ context ];
802                         context = fn;
803                         fn = tmp;
804                 }
805
806                 // Quick check to determine if target is callable, in the spec
807                 // this throws a TypeError, but we will just return undefined.
808                 if ( !jQuery.isFunction( fn ) ) {
809                         return undefined;
810                 }
811
812                 // Simulated bind
813                 var args = slice.call( arguments, 2 ),
814                         proxy = function() {
815                                 return fn.apply( context, args.concat( slice.call( arguments ) ) );
816                         };
817
818                 // Set the guid of unique handler to the same of original handler, so it can be removed
819                 proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
820
821                 return proxy;
822         },
823
824         // Mutifunctional method to get and set values to a collection
825         // The value/s can optionally be executed if it's a function
826         access: function( elems, key, value, exec, fn, pass ) {
827                 var length = elems.length;
828
829                 // Setting many attributes
830                 if ( typeof key === "object" ) {
831                         for ( var k in key ) {
832                                 jQuery.access( elems, k, key[k], exec, fn, value );
833                         }
834                         return elems;
835                 }
836
837                 // Setting one attribute
838                 if ( value !== undefined ) {
839                         // Optionally, function values get executed if exec is true
840                         exec = !pass && exec && jQuery.isFunction(value);
841
842                         for ( var i = 0; i < length; i++ ) {
843                                 fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
844                         }
845
846                         return elems;
847                 }
848
849                 // Getting an attribute
850                 return length ? fn( elems[0], key ) : undefined;
851         },
852
853         now: function() {
854                 return (new Date()).getTime();
855         },
856
857         // Use of jQuery.browser is frowned upon.
858         // More details: http://docs.jquery.com/Utilities/jQuery.browser
859         uaMatch: function( ua ) {
860                 ua = ua.toLowerCase();
861
862                 var match = rwebkit.exec( ua ) ||
863                         ropera.exec( ua ) ||
864                         rmsie.exec( ua ) ||
865                         ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) ||
866                         [];
867
868                 return { browser: match[1] || "", version: match[2] || "0" };
869         },
870
871         sub: function() {
872                 function jQuerySub( selector, context ) {
873                         return new jQuerySub.fn.init( selector, context );
874                 }
875                 jQuery.extend( true, jQuerySub, this );
876                 jQuerySub.superclass = this;
877                 jQuerySub.fn = jQuerySub.prototype = this();
878                 jQuerySub.fn.constructor = jQuerySub;
879                 jQuerySub.sub = this.sub;
880                 jQuerySub.fn.init = function init( selector, context ) {
881                         if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) {
882                                 context = jQuerySub( context );
883                         }
884
885                         return jQuery.fn.init.call( this, selector, context, rootjQuerySub );
886                 };
887                 jQuerySub.fn.init.prototype = jQuerySub.fn;
888                 var rootjQuerySub = jQuerySub(document);
889                 return jQuerySub;
890         },
891
892         browser: {}
893 });
894
895 // Populate the class2type map
896 jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
897         class2type[ "[object " + name + "]" ] = name.toLowerCase();
898 });
899
900 browserMatch = jQuery.uaMatch( userAgent );
901 if ( browserMatch.browser ) {
902         jQuery.browser[ browserMatch.browser ] = true;
903         jQuery.browser.version = browserMatch.version;
904 }
905
906 // Deprecated, use jQuery.browser.webkit instead
907 if ( jQuery.browser.webkit ) {
908         jQuery.browser.safari = true;
909 }
910
911 // IE doesn't match non-breaking spaces with \s
912 if ( rnotwhite.test( "\xA0" ) ) {
913         trimLeft = /^[\s\xA0]+/;
914         trimRight = /[\s\xA0]+$/;
915 }
916
917 // All jQuery objects should point back to these
918 rootjQuery = jQuery(document);
919
920 // Cleanup functions for the document ready method
921 if ( document.addEventListener ) {
922         DOMContentLoaded = function() {
923                 document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
924                 jQuery.ready();
925         };
926
927 } else if ( document.attachEvent ) {
928         DOMContentLoaded = function() {
929                 // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
930                 if ( document.readyState === "complete" ) {
931                         document.detachEvent( "onreadystatechange", DOMContentLoaded );
932                         jQuery.ready();
933                 }
934         };
935 }
936
937 // The DOM ready check for Internet Explorer
938 function doScrollCheck() {
939         if ( jQuery.isReady ) {
940                 return;
941         }
942
943         try {
944                 // If IE is used, use the trick by Diego Perini
945                 // http://javascript.nwbox.com/IEContentLoaded/
946                 document.documentElement.doScroll("left");
947         } catch(e) {
948                 setTimeout( doScrollCheck, 1 );
949                 return;
950         }
951
952         // and execute any waiting functions
953         jQuery.ready();
954 }
955
956 return jQuery;
957
958 })();
959
960
961 var // Promise methods
962         promiseMethods = "done fail isResolved isRejected promise then always pipe".split( " " ),
963         // Static reference to slice
964         sliceDeferred = [].slice;
965
966 jQuery.extend({
967         // Create a simple deferred (one callbacks list)
968         _Deferred: function() {
969                 var // callbacks list
970                         callbacks = [],
971                         // stored [ context , args ]
972                         fired,
973                         // to avoid firing when already doing so
974                         firing,
975                         // flag to know if the deferred has been cancelled
976                         cancelled,
977                         // the deferred itself
978                         deferred  = {
979
980                                 // done( f1, f2, ...)
981                                 done: function() {
982                                         if ( !cancelled ) {
983                                                 var args = arguments,
984                                                         i,
985                                                         length,
986                                                         elem,
987                                                         type,
988                                                         _fired;
989                                                 if ( fired ) {
990                                                         _fired = fired;
991                                                         fired = 0;
992                                                 }
993                                                 for ( i = 0, length = args.length; i < length; i++ ) {
994                                                         elem = args[ i ];
995                                                         type = jQuery.type( elem );
996                                                         if ( type === "array" ) {
997                                                                 deferred.done.apply( deferred, elem );
998                                                         } else if ( type === "function" ) {
999                                                                 callbacks.push( elem );
1000                                                         }
1001                                                 }
1002                                                 if ( _fired ) {
1003                                                         deferred.resolveWith( _fired[ 0 ], _fired[ 1 ] );
1004                                                 }
1005                                         }
1006                                         return this;
1007                                 },
1008
1009                                 // resolve with given context and args
1010                                 resolveWith: function( context, args ) {
1011                                         if ( !cancelled && !fired && !firing ) {
1012                                                 // make sure args are available (#8421)
1013                                                 args = args || [];
1014                                                 firing = 1;
1015                                                 try {
1016                                                         while( callbacks[ 0 ] ) {
1017                                                                 callbacks.shift().apply( context, args );
1018                                                         }
1019                                                 }
1020                                                 finally {
1021                                                         fired = [ context, args ];
1022                                                         firing = 0;
1023                                                 }
1024                                         }
1025                                         return this;
1026                                 },
1027
1028                                 // resolve with this as context and given arguments
1029                                 resolve: function() {
1030                                         deferred.resolveWith( this, arguments );
1031                                         return this;
1032                                 },
1033
1034                                 // Has this deferred been resolved?
1035                                 isResolved: function() {
1036                                         return !!( firing || fired );
1037                                 },
1038
1039                                 // Cancel
1040                                 cancel: function() {
1041                                         cancelled = 1;
1042                                         callbacks = [];
1043                                         return this;
1044                                 }
1045                         };
1046
1047                 return deferred;
1048         },
1049
1050         // Full fledged deferred (two callbacks list)
1051         Deferred: function( func ) {
1052                 var deferred = jQuery._Deferred(),
1053                         failDeferred = jQuery._Deferred(),
1054                         promise;
1055                 // Add errorDeferred methods, then and promise
1056                 jQuery.extend( deferred, {
1057                         then: function( doneCallbacks, failCallbacks ) {
1058                                 deferred.done( doneCallbacks ).fail( failCallbacks );
1059                                 return this;
1060                         },
1061                         always: function() {
1062                                 return deferred.done.apply( deferred, arguments ).fail.apply( this, arguments );
1063                         },
1064                         fail: failDeferred.done,
1065                         rejectWith: failDeferred.resolveWith,
1066                         reject: failDeferred.resolve,
1067                         isRejected: failDeferred.isResolved,
1068                         pipe: function( fnDone, fnFail ) {
1069                                 return jQuery.Deferred(function( newDefer ) {
1070                                         jQuery.each( {
1071                                                 done: [ fnDone, "resolve" ],
1072                                                 fail: [ fnFail, "reject" ]
1073                                         }, function( handler, data ) {
1074                                                 var fn = data[ 0 ],
1075                                                         action = data[ 1 ],
1076                                                         returned;
1077                                                 if ( jQuery.isFunction( fn ) ) {
1078                                                         deferred[ handler ](function() {
1079                                                                 returned = fn.apply( this, arguments );
1080                                                                 if ( returned && jQuery.isFunction( returned.promise ) ) {
1081                                                                         returned.promise().then( newDefer.resolve, newDefer.reject );
1082                                                                 } else {
1083                                                                         newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] );
1084                                                                 }
1085                                                         });
1086                                                 } else {
1087                                                         deferred[ handler ]( newDefer[ action ] );
1088                                                 }
1089                                         });
1090                                 }).promise();
1091                         },
1092                         // Get a promise for this deferred
1093                         // If obj is provided, the promise aspect is added to the object
1094                         promise: function( obj ) {
1095                                 if ( obj == null ) {
1096                                         if ( promise ) {
1097                                                 return promise;
1098                                         }
1099                                         promise = obj = {};
1100                                 }
1101                                 var i = promiseMethods.length;
1102                                 while( i-- ) {
1103                                         obj[ promiseMethods[i] ] = deferred[ promiseMethods[i] ];
1104                                 }
1105                                 return obj;
1106                         }
1107                 });
1108                 // Make sure only one callback list will be used
1109                 deferred.done( failDeferred.cancel ).fail( deferred.cancel );
1110                 // Unexpose cancel
1111                 delete deferred.cancel;
1112                 // Call given func if any
1113                 if ( func ) {
1114                         func.call( deferred, deferred );
1115                 }
1116                 return deferred;
1117         },
1118
1119         // Deferred helper
1120         when: function( firstParam ) {
1121                 var args = arguments,
1122                         i = 0,
1123                         length = args.length,
1124                         count = length,
1125                         deferred = length <= 1 && firstParam && jQuery.isFunction( firstParam.promise ) ?
1126                                 firstParam :
1127                                 jQuery.Deferred();
1128                 function resolveFunc( i ) {
1129                         return function( value ) {
1130                                 args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value;
1131                                 if ( !( --count ) ) {
1132                                         // Strange bug in FF4:
1133                                         // Values changed onto the arguments object sometimes end up as undefined values
1134                                         // outside the $.when method. Cloning the object into a fresh array solves the issue
1135                                         deferred.resolveWith( deferred, sliceDeferred.call( args, 0 ) );
1136                                 }
1137                         };
1138                 }
1139                 if ( length > 1 ) {
1140                         for( ; i < length; i++ ) {
1141                                 if ( args[ i ] && jQuery.isFunction( args[ i ].promise ) ) {
1142                                         args[ i ].promise().then( resolveFunc(i), deferred.reject );
1143                                 } else {
1144                                         --count;
1145                                 }
1146                         }
1147                         if ( !count ) {
1148                                 deferred.resolveWith( deferred, args );
1149                         }
1150                 } else if ( deferred !== firstParam ) {
1151                         deferred.resolveWith( deferred, length ? [ firstParam ] : [] );
1152                 }
1153                 return deferred.promise();
1154         }
1155 });
1156
1157
1158
1159 jQuery.support = (function() {
1160
1161         var div = document.createElement( "div" ),
1162                 documentElement = document.documentElement,
1163                 all,
1164                 a,
1165                 select,
1166                 opt,
1167                 input,
1168                 marginDiv,
1169                 support,
1170                 fragment,
1171                 body,
1172                 testElementParent,
1173                 testElement,
1174                 testElementStyle,
1175                 tds,
1176                 events,
1177                 eventName,
1178                 i,
1179                 isSupported;
1180
1181         // Preliminary tests
1182         div.setAttribute("className", "t");
1183         div.innerHTML = "   <link/><table></table><a href='/a' style='top:1px;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
1184
1185
1186         all = div.getElementsByTagName( "*" );
1187         a = div.getElementsByTagName( "a" )[ 0 ];
1188
1189         // Can't get basic test support
1190         if ( !all || !all.length || !a ) {
1191                 return {};
1192         }
1193
1194         // First batch of supports tests
1195         select = document.createElement( "select" );
1196         opt = select.appendChild( document.createElement("option") );
1197         input = div.getElementsByTagName( "input" )[ 0 ];
1198
1199         support = {
1200                 // IE strips leading whitespace when .innerHTML is used
1201                 leadingWhitespace: ( div.firstChild.nodeType === 3 ),
1202
1203                 // Make sure that tbody elements aren't automatically inserted
1204                 // IE will insert them into empty tables
1205                 tbody: !div.getElementsByTagName( "tbody" ).length,
1206
1207                 // Make sure that link elements get serialized correctly by innerHTML
1208                 // This requires a wrapper element in IE
1209                 htmlSerialize: !!div.getElementsByTagName( "link" ).length,
1210
1211                 // Get the style information from getAttribute
1212                 // (IE uses .cssText instead)
1213                 style: /top/.test( a.getAttribute("style") ),
1214
1215                 // Make sure that URLs aren't manipulated
1216                 // (IE normalizes it by default)
1217                 hrefNormalized: ( a.getAttribute( "href" ) === "/a" ),
1218
1219                 // Make sure that element opacity exists
1220                 // (IE uses filter instead)
1221                 // Use a regex to work around a WebKit issue. See #5145
1222                 opacity: /^0.55$/.test( a.style.opacity ),
1223
1224                 // Verify style float existence
1225                 // (IE uses styleFloat instead of cssFloat)
1226                 cssFloat: !!a.style.cssFloat,
1227
1228                 // Make sure that if no value is specified for a checkbox
1229                 // that it defaults to "on".
1230                 // (WebKit defaults to "" instead)
1231                 checkOn: ( input.value === "on" ),
1232
1233                 // Make sure that a selected-by-default option has a working selected property.
1234                 // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
1235                 optSelected: opt.selected,
1236
1237                 // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
1238                 getSetAttribute: div.className !== "t",
1239
1240                 // Will be defined later
1241                 submitBubbles: true,
1242                 changeBubbles: true,
1243                 focusinBubbles: false,
1244                 deleteExpando: true,
1245                 noCloneEvent: true,
1246                 inlineBlockNeedsLayout: false,
1247                 shrinkWrapBlocks: false,
1248                 reliableMarginRight: true
1249         };
1250
1251         // Make sure checked status is properly cloned
1252         input.checked = true;
1253         support.noCloneChecked = input.cloneNode( true ).checked;
1254
1255         // Make sure that the options inside disabled selects aren't marked as disabled
1256         // (WebKit marks them as disabled)
1257         select.disabled = true;
1258         support.optDisabled = !opt.disabled;
1259
1260         // Test to see if it's possible to delete an expando from an element
1261         // Fails in Internet Explorer
1262         try {
1263                 delete div.test;
1264         } catch( e ) {
1265                 support.deleteExpando = false;
1266         }
1267
1268         if ( !div.addEventListener && div.attachEvent && div.fireEvent ) {
1269                 div.attachEvent( "onclick", function() {
1270                         // Cloning a node shouldn't copy over any
1271                         // bound event handlers (IE does this)
1272                         support.noCloneEvent = false;
1273                 });
1274                 div.cloneNode( true ).fireEvent( "onclick" );
1275         }
1276
1277         // Check if a radio maintains it's value
1278         // after being appended to the DOM
1279         input = document.createElement("input");
1280         input.value = "t";
1281         input.setAttribute("type", "radio");
1282         support.radioValue = input.value === "t";
1283
1284         input.setAttribute("checked", "checked");
1285         div.appendChild( input );
1286         fragment = document.createDocumentFragment();
1287         fragment.appendChild( div.firstChild );
1288
1289         // WebKit doesn't clone checked state correctly in fragments
1290         support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked;
1291
1292         div.innerHTML = "";
1293
1294         // Figure out if the W3C box model works as expected
1295         div.style.width = div.style.paddingLeft = "1px";
1296
1297         body = document.getElementsByTagName( "body" )[ 0 ];
1298         // We use our own, invisible, body unless the body is already present
1299         // in which case we use a div (#9239)
1300         testElement = document.createElement( body ? "div" : "body" );
1301         testElementStyle = {
1302                 visibility: "hidden",
1303                 width: 0,
1304                 height: 0,
1305                 border: 0,
1306                 margin: 0,
1307                 background: "none"
1308         };
1309         if ( body ) {
1310                 jQuery.extend( testElementStyle, {
1311                         position: "absolute",
1312                         left: "-1000px",
1313                         top: "-1000px"
1314                 });
1315         }
1316         for ( i in testElementStyle ) {
1317                 testElement.style[ i ] = testElementStyle[ i ];
1318         }
1319         testElement.appendChild( div );
1320         testElementParent = body || documentElement;
1321         testElementParent.insertBefore( testElement, testElementParent.firstChild );
1322
1323         // Check if a disconnected checkbox will retain its checked
1324         // value of true after appended to the DOM (IE6/7)
1325         support.appendChecked = input.checked;
1326
1327         support.boxModel = div.offsetWidth === 2;
1328
1329         if ( "zoom" in div.style ) {
1330                 // Check if natively block-level elements act like inline-block
1331                 // elements when setting their display to 'inline' and giving
1332                 // them layout
1333                 // (IE < 8 does this)
1334                 div.style.display = "inline";
1335                 div.style.zoom = 1;
1336                 support.inlineBlockNeedsLayout = ( div.offsetWidth === 2 );
1337
1338                 // Check if elements with layout shrink-wrap their children
1339                 // (IE 6 does this)
1340                 div.style.display = "";
1341                 div.innerHTML = "<div style='width:4px;'></div>";
1342                 support.shrinkWrapBlocks = ( div.offsetWidth !== 2 );
1343         }
1344
1345         div.innerHTML = "<table><tr><td style='padding:0;border:0;display:none'></td><td>t</td></tr></table>";
1346         tds = div.getElementsByTagName( "td" );
1347
1348         // Check if table cells still have offsetWidth/Height when they are set
1349         // to display:none and there are still other visible table cells in a
1350         // table row; if so, offsetWidth/Height are not reliable for use when
1351         // determining if an element has been hidden directly using
1352         // display:none (it is still safe to use offsets if a parent element is
1353         // hidden; don safety goggles and see bug #4512 for more information).
1354         // (only IE 8 fails this test)
1355         isSupported = ( tds[ 0 ].offsetHeight === 0 );
1356
1357         tds[ 0 ].style.display = "";
1358         tds[ 1 ].style.display = "none";
1359
1360         // Check if empty table cells still have offsetWidth/Height
1361         // (IE < 8 fail this test)
1362         support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 );
1363         div.innerHTML = "";
1364
1365         // Check if div with explicit width and no margin-right incorrectly
1366         // gets computed margin-right based on width of container. For more
1367         // info see bug #3333
1368         // Fails in WebKit before Feb 2011 nightlies
1369         // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
1370         if ( document.defaultView && document.defaultView.getComputedStyle ) {
1371                 marginDiv = document.createElement( "div" );
1372                 marginDiv.style.width = "0";
1373                 marginDiv.style.marginRight = "0";
1374                 div.appendChild( marginDiv );
1375                 support.reliableMarginRight =
1376                         ( parseInt( ( document.defaultView.getComputedStyle( marginDiv, null ) || { marginRight: 0 } ).marginRight, 10 ) || 0 ) === 0;
1377         }
1378
1379         // Remove the body element we added
1380         testElement.innerHTML = "";
1381         testElementParent.removeChild( testElement );
1382
1383         // Technique from Juriy Zaytsev
1384         // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
1385         // We only care about the case where non-standard event systems
1386         // are used, namely in IE. Short-circuiting here helps us to
1387         // avoid an eval call (in setAttribute) which can cause CSP
1388         // to go haywire. See: https://developer.mozilla.org/en/Security/CSP
1389         if ( div.attachEvent ) {
1390                 for( i in {
1391                         submit: 1,
1392                         change: 1,
1393                         focusin: 1
1394                 } ) {
1395                         eventName = "on" + i;
1396                         isSupported = ( eventName in div );
1397                         if ( !isSupported ) {
1398                                 div.setAttribute( eventName, "return;" );
1399                                 isSupported = ( typeof div[ eventName ] === "function" );
1400                         }
1401                         support[ i + "Bubbles" ] = isSupported;
1402                 }
1403         }
1404
1405         // Null connected elements to avoid leaks in IE
1406         testElement = fragment = select = opt = body = marginDiv = div = input = null;
1407
1408         return support;
1409 })();
1410
1411 // Keep track of boxModel
1412 jQuery.boxModel = jQuery.support.boxModel;
1413
1414
1415
1416
1417 var rbrace = /^(?:\{.*\}|\[.*\])$/,
1418         rmultiDash = /([A-Z])/g;
1419
1420 jQuery.extend({
1421         cache: {},
1422
1423         // Please use with caution
1424         uuid: 0,
1425
1426         // Unique for each copy of jQuery on the page
1427         // Non-digits removed to match rinlinejQuery
1428         expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ),
1429
1430         // The following elements throw uncatchable exceptions if you
1431         // attempt to add expando properties to them.
1432         noData: {
1433                 "embed": true,
1434                 // Ban all objects except for Flash (which handle expandos)
1435                 "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
1436                 "applet": true
1437         },
1438
1439         hasData: function( elem ) {
1440                 elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
1441
1442                 return !!elem && !isEmptyDataObject( elem );
1443         },
1444
1445         data: function( elem, name, data, pvt /* Internal Use Only */ ) {
1446                 if ( !jQuery.acceptData( elem ) ) {
1447                         return;
1448                 }
1449
1450                 var thisCache, ret,
1451                         internalKey = jQuery.expando,
1452                         getByName = typeof name === "string",
1453
1454                         // We have to handle DOM nodes and JS objects differently because IE6-7
1455                         // can't GC object references properly across the DOM-JS boundary
1456                         isNode = elem.nodeType,
1457
1458                         // Only DOM nodes need the global jQuery cache; JS object data is
1459                         // attached directly to the object so GC can occur automatically
1460                         cache = isNode ? jQuery.cache : elem,
1461
1462                         // Only defining an ID for JS objects if its cache already exists allows
1463                         // the code to shortcut on the same path as a DOM node with no cache
1464                         id = isNode ? elem[ jQuery.expando ] : elem[ jQuery.expando ] && jQuery.expando;
1465
1466                 // Avoid doing any more work than we need to when trying to get data on an
1467                 // object that has no data at all
1468                 if ( (!id || (pvt && id && (cache[ id ] && !cache[ id ][ internalKey ]))) && getByName && data === undefined ) {
1469                         return;
1470                 }
1471
1472                 if ( !id ) {
1473                         // Only DOM nodes need a new unique ID for each element since their data
1474                         // ends up in the global cache
1475                         if ( isNode ) {
1476                                 elem[ jQuery.expando ] = id = ++jQuery.uuid;
1477                         } else {
1478                                 id = jQuery.expando;
1479                         }
1480                 }
1481
1482                 if ( !cache[ id ] ) {
1483                         cache[ id ] = {};
1484
1485                         // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery
1486                         // metadata on plain JS objects when the object is serialized using
1487                         // JSON.stringify
1488                         if ( !isNode ) {
1489                                 cache[ id ].toJSON = jQuery.noop;
1490                         }
1491                 }
1492
1493                 // An object can be passed to jQuery.data instead of a key/value pair; this gets
1494                 // shallow copied over onto the existing cache
1495                 if ( typeof name === "object" || typeof name === "function" ) {
1496                         if ( pvt ) {
1497                                 cache[ id ][ internalKey ] = jQuery.extend(cache[ id ][ internalKey ], name);
1498                         } else {
1499                                 cache[ id ] = jQuery.extend(cache[ id ], name);
1500                         }
1501                 }
1502
1503                 thisCache = cache[ id ];
1504
1505                 // Internal jQuery data is stored in a separate object inside the object's data
1506                 // cache in order to avoid key collisions between internal data and user-defined
1507                 // data
1508                 if ( pvt ) {
1509                         if ( !thisCache[ internalKey ] ) {
1510                                 thisCache[ internalKey ] = {};
1511                         }
1512
1513                         thisCache = thisCache[ internalKey ];
1514                 }
1515
1516                 if ( data !== undefined ) {
1517                         thisCache[ jQuery.camelCase( name ) ] = data;
1518                 }
1519
1520                 // TODO: This is a hack for 1.5 ONLY. It will be removed in 1.6. Users should
1521                 // not attempt to inspect the internal events object using jQuery.data, as this
1522                 // internal data object is undocumented and subject to change.
1523                 if ( name === "events" && !thisCache[name] ) {
1524                         return thisCache[ internalKey ] && thisCache[ internalKey ].events;
1525                 }
1526
1527                 // Check for both converted-to-camel and non-converted data property names
1528                 // If a data property was specified
1529                 if ( getByName ) {
1530
1531                         // First Try to find as-is property data
1532                         ret = thisCache[ name ];
1533
1534                         // Test for null|undefined property data
1535                         if ( ret == null ) {
1536
1537                                 // Try to find the camelCased property
1538                                 ret = thisCache[ jQuery.camelCase( name ) ];
1539                         }
1540                 } else {
1541                         ret = thisCache;
1542                 }
1543
1544                 return ret;
1545         },
1546
1547         removeData: function( elem, name, pvt /* Internal Use Only */ ) {
1548                 if ( !jQuery.acceptData( elem ) ) {
1549                         return;
1550                 }
1551
1552                 var thisCache,
1553
1554                         // Reference to internal data cache key
1555                         internalKey = jQuery.expando,
1556
1557                         isNode = elem.nodeType,
1558
1559                         // See jQuery.data for more information
1560                         cache = isNode ? jQuery.cache : elem,
1561
1562                         // See jQuery.data for more information
1563                         id = isNode ? elem[ jQuery.expando ] : jQuery.expando;
1564
1565                 // If there is already no cache entry for this object, there is no
1566                 // purpose in continuing
1567                 if ( !cache[ id ] ) {
1568                         return;
1569                 }
1570
1571                 if ( name ) {
1572
1573                         thisCache = pvt ? cache[ id ][ internalKey ] : cache[ id ];
1574
1575                         if ( thisCache ) {
1576
1577                                 // Support interoperable removal of hyphenated or camelcased keys
1578                                 if ( !thisCache[ name ] ) {
1579                                         name = jQuery.camelCase( name );
1580                                 }
1581
1582                                 delete thisCache[ name ];
1583
1584                                 // If there is no data left in the cache, we want to continue
1585                                 // and let the cache object itself get destroyed
1586                                 if ( !isEmptyDataObject(thisCache) ) {
1587                                         return;
1588                                 }
1589                         }
1590                 }
1591
1592                 // See jQuery.data for more information
1593                 if ( pvt ) {
1594                         delete cache[ id ][ internalKey ];
1595
1596                         // Don't destroy the parent cache unless the internal data object
1597                         // had been the only thing left in it
1598                         if ( !isEmptyDataObject(cache[ id ]) ) {
1599                                 return;
1600                         }
1601                 }
1602
1603                 var internalCache = cache[ id ][ internalKey ];
1604
1605                 // Browsers that fail expando deletion also refuse to delete expandos on
1606                 // the window, but it will allow it on all other JS objects; other browsers
1607                 // don't care
1608                 // Ensure that `cache` is not a window object #10080
1609                 if ( jQuery.support.deleteExpando || !cache.setInterval ) {
1610                         delete cache[ id ];
1611                 } else {
1612                         cache[ id ] = null;
1613                 }
1614
1615                 // We destroyed the entire user cache at once because it's faster than
1616                 // iterating through each key, but we need to continue to persist internal
1617                 // data if it existed
1618                 if ( internalCache ) {
1619                         cache[ id ] = {};
1620                         // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery
1621                         // metadata on plain JS objects when the object is serialized using
1622                         // JSON.stringify
1623                         if ( !isNode ) {
1624                                 cache[ id ].toJSON = jQuery.noop;
1625                         }
1626
1627                         cache[ id ][ internalKey ] = internalCache;
1628
1629                 // Otherwise, we need to eliminate the expando on the node to avoid
1630                 // false lookups in the cache for entries that no longer exist
1631                 } else if ( isNode ) {
1632                         // IE does not allow us to delete expando properties from nodes,
1633                         // nor does it have a removeAttribute function on Document nodes;
1634                         // we must handle all of these cases
1635                         if ( jQuery.support.deleteExpando ) {
1636                                 delete elem[ jQuery.expando ];
1637                         } else if ( elem.removeAttribute ) {
1638                                 elem.removeAttribute( jQuery.expando );
1639                         } else {
1640                                 elem[ jQuery.expando ] = null;
1641                         }
1642                 }
1643         },
1644
1645         // For internal use only.
1646         _data: function( elem, name, data ) {
1647                 return jQuery.data( elem, name, data, true );
1648         },
1649
1650         // A method for determining if a DOM node can handle the data expando
1651         acceptData: function( elem ) {
1652                 if ( elem.nodeName ) {
1653                         var match = jQuery.noData[ elem.nodeName.toLowerCase() ];
1654
1655                         if ( match ) {
1656                                 return !(match === true || elem.getAttribute("classid") !== match);
1657                         }
1658                 }
1659
1660                 return true;
1661         }
1662 });
1663
1664 jQuery.fn.extend({
1665         data: function( key, value ) {
1666                 var data = null;
1667
1668                 if ( typeof key === "undefined" ) {
1669                         if ( this.length ) {
1670                                 data = jQuery.data( this[0] );
1671
1672                                 if ( this[0].nodeType === 1 ) {
1673                             var attr = this[0].attributes, name;
1674                                         for ( var i = 0, l = attr.length; i < l; i++ ) {
1675                                                 name = attr[i].name;
1676
1677                                                 if ( name.indexOf( "data-" ) === 0 ) {
1678                                                         name = jQuery.camelCase( name.substring(5) );
1679
1680                                                         dataAttr( this[0], name, data[ name ] );
1681                                                 }
1682                                         }
1683                                 }
1684                         }
1685
1686                         return data;
1687
1688                 } else if ( typeof key === "object" ) {
1689                         return this.each(function() {
1690                                 jQuery.data( this, key );
1691                         });
1692                 }
1693
1694                 var parts = key.split(".");
1695                 parts[1] = parts[1] ? "." + parts[1] : "";
1696
1697                 if ( value === undefined ) {
1698                         data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
1699
1700                         // Try to fetch any internally stored data first
1701                         if ( data === undefined && this.length ) {
1702                                 data = jQuery.data( this[0], key );
1703                                 data = dataAttr( this[0], key, data );
1704                         }
1705
1706                         return data === undefined && parts[1] ?
1707                                 this.data( parts[0] ) :
1708                                 data;
1709
1710                 } else {
1711                         return this.each(function() {
1712                                 var $this = jQuery( this ),
1713                                         args = [ parts[0], value ];
1714
1715                                 $this.triggerHandler( "setData" + parts[1] + "!", args );
1716                                 jQuery.data( this, key, value );
1717                                 $this.triggerHandler( "changeData" + parts[1] + "!", args );
1718                         });
1719                 }
1720         },
1721
1722         removeData: function( key ) {
1723                 return this.each(function() {
1724                         jQuery.removeData( this, key );
1725                 });
1726         }
1727 });
1728
1729 function dataAttr( elem, key, data ) {
1730         // If nothing was found internally, try to fetch any
1731         // data from the HTML5 data-* attribute
1732         if ( data === undefined && elem.nodeType === 1 ) {
1733
1734                 var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
1735
1736                 data = elem.getAttribute( name );
1737
1738                 if ( typeof data === "string" ) {
1739                         try {
1740                                 data = data === "true" ? true :
1741                                 data === "false" ? false :
1742                                 data === "null" ? null :
1743                                 !jQuery.isNaN( data ) ? parseFloat( data ) :
1744                                         rbrace.test( data ) ? jQuery.parseJSON( data ) :
1745                                         data;
1746                         } catch( e ) {}
1747
1748                         // Make sure we set the data so it isn't changed later
1749                         jQuery.data( elem, key, data );
1750
1751                 } else {
1752                         data = undefined;
1753                 }
1754         }
1755
1756         return data;
1757 }
1758
1759 // TODO: This is a hack for 1.5 ONLY to allow objects with a single toJSON
1760 // property to be considered empty objects; this property always exists in
1761 // order to make sure JSON.stringify does not expose internal metadata
1762 function isEmptyDataObject( obj ) {
1763         for ( var name in obj ) {
1764                 if ( name !== "toJSON" ) {
1765                         return false;
1766                 }
1767         }
1768
1769         return true;
1770 }
1771
1772
1773
1774
1775 function handleQueueMarkDefer( elem, type, src ) {
1776         var deferDataKey = type + "defer",
1777                 queueDataKey = type + "queue",
1778                 markDataKey = type + "mark",
1779                 defer = jQuery.data( elem, deferDataKey, undefined, true );
1780         if ( defer &&
1781                 ( src === "queue" || !jQuery.data( elem, queueDataKey, undefined, true ) ) &&
1782                 ( src === "mark" || !jQuery.data( elem, markDataKey, undefined, true ) ) ) {
1783                 // Give room for hard-coded callbacks to fire first
1784                 // and eventually mark/queue something else on the element
1785                 setTimeout( function() {
1786                         if ( !jQuery.data( elem, queueDataKey, undefined, true ) &&
1787                                 !jQuery.data( elem, markDataKey, undefined, true ) ) {
1788                                 jQuery.removeData( elem, deferDataKey, true );
1789                                 defer.resolve();
1790                         }
1791                 }, 0 );
1792         }
1793 }
1794
1795 jQuery.extend({
1796
1797         _mark: function( elem, type ) {
1798                 if ( elem ) {
1799                         type = (type || "fx") + "mark";
1800                         jQuery.data( elem, type, (jQuery.data(elem,type,undefined,true) || 0) + 1, true );
1801                 }
1802         },
1803
1804         _unmark: function( force, elem, type ) {
1805                 if ( force !== true ) {
1806                         type = elem;
1807                         elem = force;
1808                         force = false;
1809                 }
1810                 if ( elem ) {
1811                         type = type || "fx";
1812                         var key = type + "mark",
1813                                 count = force ? 0 : ( (jQuery.data( elem, key, undefined, true) || 1 ) - 1 );
1814                         if ( count ) {
1815                                 jQuery.data( elem, key, count, true );
1816                         } else {
1817                                 jQuery.removeData( elem, key, true );
1818                                 handleQueueMarkDefer( elem, type, "mark" );
1819                         }
1820                 }
1821         },
1822
1823         queue: function( elem, type, data ) {
1824                 if ( elem ) {
1825                         type = (type || "fx") + "queue";
1826                         var q = jQuery.data( elem, type, undefined, true );
1827                         // Speed up dequeue by getting out quickly if this is just a lookup
1828                         if ( data ) {
1829                                 if ( !q || jQuery.isArray(data) ) {
1830                                         q = jQuery.data( elem, type, jQuery.makeArray(data), true );
1831                                 } else {
1832                                         q.push( data );
1833                                 }
1834                         }
1835                         return q || [];
1836                 }
1837         },
1838
1839         dequeue: function( elem, type ) {
1840                 type = type || "fx";
1841
1842                 var queue = jQuery.queue( elem, type ),
1843                         fn = queue.shift(),
1844                         defer;
1845
1846                 // If the fx queue is dequeued, always remove the progress sentinel
1847                 if ( fn === "inprogress" ) {
1848                         fn = queue.shift();
1849                 }
1850
1851                 if ( fn ) {
1852                         // Add a progress sentinel to prevent the fx queue from being
1853                         // automatically dequeued
1854                         if ( type === "fx" ) {
1855                                 queue.unshift("inprogress");
1856                         }
1857
1858                         fn.call(elem, function() {
1859                                 jQuery.dequeue(elem, type);
1860                         });
1861                 }
1862
1863                 if ( !queue.length ) {
1864                         jQuery.removeData( elem, type + "queue", true );
1865                         handleQueueMarkDefer( elem, type, "queue" );
1866                 }
1867         }
1868 });
1869
1870 jQuery.fn.extend({
1871         queue: function( type, data ) {
1872                 if ( typeof type !== "string" ) {
1873                         data = type;
1874                         type = "fx";
1875                 }
1876
1877                 if ( data === undefined ) {
1878                         return jQuery.queue( this[0], type );
1879                 }
1880                 return this.each(function() {
1881                         var queue = jQuery.queue( this, type, data );
1882
1883                         if ( type === "fx" && queue[0] !== "inprogress" ) {
1884                                 jQuery.dequeue( this, type );
1885                         }
1886                 });
1887         },
1888         dequeue: function( type ) {
1889                 return this.each(function() {
1890                         jQuery.dequeue( this, type );
1891                 });
1892         },
1893         // Based off of the plugin by Clint Helfers, with permission.
1894         // http://blindsignals.com/index.php/2009/07/jquery-delay/
1895         delay: function( time, type ) {
1896                 time = jQuery.fx ? jQuery.fx.speeds[time] || time : time;
1897                 type = type || "fx";
1898
1899                 return this.queue( type, function() {
1900                         var elem = this;
1901                         setTimeout(function() {
1902                                 jQuery.dequeue( elem, type );
1903                         }, time );
1904                 });
1905         },
1906         clearQueue: function( type ) {
1907                 return this.queue( type || "fx", [] );
1908         },
1909         // Get a promise resolved when queues of a certain type
1910         // are emptied (fx is the type by default)
1911         promise: function( type, object ) {
1912                 if ( typeof type !== "string" ) {
1913                         object = type;
1914                         type = undefined;
1915                 }
1916                 type = type || "fx";
1917                 var defer = jQuery.Deferred(),
1918                         elements = this,
1919                         i = elements.length,
1920                         count = 1,
1921                         deferDataKey = type + "defer",
1922                         queueDataKey = type + "queue",
1923                         markDataKey = type + "mark",
1924                         tmp;
1925                 function resolve() {
1926                         if ( !( --count ) ) {
1927                                 defer.resolveWith( elements, [ elements ] );
1928                         }
1929                 }
1930                 while( i-- ) {
1931                         if (( tmp = jQuery.data( elements[ i ], deferDataKey, undefined, true ) ||
1932                                         ( jQuery.data( elements[ i ], queueDataKey, undefined, true ) ||
1933                                                 jQuery.data( elements[ i ], markDataKey, undefined, true ) ) &&
1934                                         jQuery.data( elements[ i ], deferDataKey, jQuery._Deferred(), true ) )) {
1935                                 count++;
1936                                 tmp.done( resolve );
1937                         }
1938                 }
1939                 resolve();
1940                 return defer.promise();
1941         }
1942 });
1943
1944
1945
1946
1947 var rclass = /[\n\t\r]/g,
1948         rspace = /\s+/,
1949         rreturn = /\r/g,
1950         rtype = /^(?:button|input)$/i,
1951         rfocusable = /^(?:button|input|object|select|textarea)$/i,
1952         rclickable = /^a(?:rea)?$/i,
1953         rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
1954         nodeHook, boolHook;
1955
1956 jQuery.fn.extend({
1957         attr: function( name, value ) {
1958                 return jQuery.access( this, name, value, true, jQuery.attr );
1959         },
1960
1961         removeAttr: function( name ) {
1962                 return this.each(function() {
1963                         jQuery.removeAttr( this, name );
1964                 });
1965         },
1966         
1967         prop: function( name, value ) {
1968                 return jQuery.access( this, name, value, true, jQuery.prop );
1969         },
1970         
1971         removeProp: function( name ) {
1972                 name = jQuery.propFix[ name ] || name;
1973                 return this.each(function() {
1974                         // try/catch handles cases where IE balks (such as removing a property on window)
1975                         try {
1976                                 this[ name ] = undefined;
1977                                 delete this[ name ];
1978                         } catch( e ) {}
1979                 });
1980         },
1981
1982         addClass: function( value ) {
1983                 var classNames, i, l, elem,
1984                         setClass, c, cl;
1985
1986                 if ( jQuery.isFunction( value ) ) {
1987                         return this.each(function( j ) {
1988                                 jQuery( this ).addClass( value.call(this, j, this.className) );
1989                         });
1990                 }
1991
1992                 if ( value && typeof value === "string" ) {
1993                         classNames = value.split( rspace );
1994
1995                         for ( i = 0, l = this.length; i < l; i++ ) {
1996                                 elem = this[ i ];
1997
1998                                 if ( elem.nodeType === 1 ) {
1999                                         if ( !elem.className && classNames.length === 1 ) {
2000                                                 elem.className = value;
2001
2002                                         } else {
2003                                                 setClass = " " + elem.className + " ";
2004
2005                                                 for ( c = 0, cl = classNames.length; c < cl; c++ ) {
2006                                                         if ( !~setClass.indexOf( " " + classNames[ c ] + " " ) ) {
2007                                                                 setClass += classNames[ c ] + " ";
2008                                                         }
2009                                                 }
2010                                                 elem.className = jQuery.trim( setClass );
2011                                         }
2012                                 }
2013                         }
2014                 }
2015
2016                 return this;
2017         },
2018
2019         removeClass: function( value ) {
2020                 var classNames, i, l, elem, className, c, cl;
2021
2022                 if ( jQuery.isFunction( value ) ) {
2023                         return this.each(function( j ) {
2024                                 jQuery( this ).removeClass( value.call(this, j, this.className) );
2025                         });
2026                 }
2027
2028                 if ( (value && typeof value === "string") || value === undefined ) {
2029                         classNames = (value || "").split( rspace );
2030
2031                         for ( i = 0, l = this.length; i < l; i++ ) {
2032                                 elem = this[ i ];
2033
2034                                 if ( elem.nodeType === 1 && elem.className ) {
2035                                         if ( value ) {
2036                                                 className = (" " + elem.className + " ").replace( rclass, " " );
2037                                                 for ( c = 0, cl = classNames.length; c < cl; c++ ) {
2038                                                         className = className.replace(" " + classNames[ c ] + " ", " ");
2039                                                 }
2040                                                 elem.className = jQuery.trim( className );
2041
2042                                         } else {
2043                                                 elem.className = "";
2044                                         }
2045                                 }
2046                         }
2047                 }
2048
2049                 return this;
2050         },
2051
2052         toggleClass: function( value, stateVal ) {
2053                 var type = typeof value,
2054                         isBool = typeof stateVal === "boolean";
2055
2056                 if ( jQuery.isFunction( value ) ) {
2057                         return this.each(function( i ) {
2058                                 jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
2059                         });
2060                 }
2061
2062                 return this.each(function() {
2063                         if ( type === "string" ) {
2064                                 // toggle individual class names
2065                                 var className,
2066                                         i = 0,
2067                                         self = jQuery( this ),
2068                                         state = stateVal,
2069                                         classNames = value.split( rspace );
2070
2071                                 while ( (className = classNames[ i++ ]) ) {
2072                                         // check each className given, space seperated list
2073                                         state = isBool ? state : !self.hasClass( className );
2074                                         self[ state ? "addClass" : "removeClass" ]( className );
2075                                 }
2076
2077                         } else if ( type === "undefined" || type === "boolean" ) {
2078                                 if ( this.className ) {
2079                                         // store className if set
2080                                         jQuery._data( this, "__className__", this.className );
2081                                 }
2082
2083                                 // toggle whole className
2084                                 this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
2085                         }
2086                 });
2087         },
2088
2089         hasClass: function( selector ) {
2090                 var className = " " + selector + " ";
2091                 for ( var i = 0, l = this.length; i < l; i++ ) {
2092                         if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
2093                                 return true;
2094                         }
2095                 }
2096
2097                 return false;
2098         },
2099
2100         val: function( value ) {
2101                 var hooks, ret,
2102                         elem = this[0];
2103                 
2104                 if ( !arguments.length ) {
2105                         if ( elem ) {
2106                                 hooks = jQuery.valHooks[ elem.nodeName.toLowerCase() ] || jQuery.valHooks[ elem.type ];
2107
2108                                 if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
2109                                         return ret;
2110                                 }
2111
2112                                 ret = elem.value;
2113
2114                                 return typeof ret === "string" ? 
2115                                         // handle most common string cases
2116                                         ret.replace(rreturn, "") : 
2117                                         // handle cases where value is null/undef or number
2118                                         ret == null ? "" : ret;
2119                         }
2120
2121                         return undefined;
2122                 }
2123
2124                 var isFunction = jQuery.isFunction( value );
2125
2126                 return this.each(function( i ) {
2127                         var self = jQuery(this), val;
2128
2129                         if ( this.nodeType !== 1 ) {
2130                                 return;
2131                         }
2132
2133                         if ( isFunction ) {
2134                                 val = value.call( this, i, self.val() );
2135                         } else {
2136                                 val = value;
2137                         }
2138
2139                         // Treat null/undefined as ""; convert numbers to string
2140                         if ( val == null ) {
2141                                 val = "";
2142                         } else if ( typeof val === "number" ) {
2143                                 val += "";
2144                         } else if ( jQuery.isArray( val ) ) {
2145                                 val = jQuery.map(val, function ( value ) {
2146                                         return value == null ? "" : value + "";
2147                                 });
2148                         }
2149
2150                         hooks = jQuery.valHooks[ this.nodeName.toLowerCase() ] || jQuery.valHooks[ this.type ];
2151
2152                         // If set returns undefined, fall back to normal setting
2153                         if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
2154                                 this.value = val;
2155                         }
2156                 });
2157         }
2158 });
2159
2160 jQuery.extend({
2161         valHooks: {
2162                 option: {
2163                         get: function( elem ) {
2164                                 // attributes.value is undefined in Blackberry 4.7 but
2165                                 // uses .value. See #6932
2166                                 var val = elem.attributes.value;
2167                                 return !val || val.specified ? elem.value : elem.text;
2168                         }
2169                 },
2170                 select: {
2171                         get: function( elem ) {
2172                                 var value,
2173                                         index = elem.selectedIndex,
2174                                         values = [],
2175                                         options = elem.options,
2176                                         one = elem.type === "select-one";
2177
2178                                 // Nothing was selected
2179                                 if ( index < 0 ) {
2180                                         return null;
2181                                 }
2182
2183                                 // Loop through all the selected options
2184                                 for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
2185                                         var option = options[ i ];
2186
2187                                         // Don't return options that are disabled or in a disabled optgroup
2188                                         if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) &&
2189                                                         (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) {
2190
2191                                                 // Get the specific value for the option
2192                                                 value = jQuery( option ).val();
2193
2194                                                 // We don't need an array for one selects
2195                                                 if ( one ) {
2196                                                         return value;
2197                                                 }
2198
2199                                                 // Multi-Selects return an array
2200                                                 values.push( value );
2201                                         }
2202                                 }
2203
2204                                 // Fixes Bug #2551 -- select.val() broken in IE after form.reset()
2205                                 if ( one && !values.length && options.length ) {
2206                                         return jQuery( options[ index ] ).val();
2207                                 }
2208
2209                                 return values;
2210                         },
2211
2212                         set: function( elem, value ) {
2213                                 var values = jQuery.makeArray( value );
2214
2215                                 jQuery(elem).find("option").each(function() {
2216                                         this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
2217                                 });
2218
2219                                 if ( !values.length ) {
2220                                         elem.selectedIndex = -1;
2221                                 }
2222                                 return values;
2223                         }
2224                 }
2225         },
2226
2227         attrFn: {
2228                 val: true,
2229                 css: true,
2230                 html: true,
2231                 text: true,
2232                 data: true,
2233                 width: true,
2234                 height: true,
2235                 offset: true
2236         },
2237         
2238         attrFix: {
2239                 // Always normalize to ensure hook usage
2240                 tabindex: "tabIndex"
2241         },
2242         
2243         attr: function( elem, name, value, pass ) {
2244                 var nType = elem.nodeType;
2245                 
2246                 // don't get/set attributes on text, comment and attribute nodes
2247                 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
2248                         return undefined;
2249                 }
2250
2251                 if ( pass && name in jQuery.attrFn ) {
2252                         return jQuery( elem )[ name ]( value );
2253                 }
2254
2255                 // Fallback to prop when attributes are not supported
2256                 if ( !("getAttribute" in elem) ) {
2257                         return jQuery.prop( elem, name, value );
2258                 }
2259
2260                 var ret, hooks,
2261                         notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
2262
2263                 // Normalize the name if needed
2264                 if ( notxml ) {
2265                         name = jQuery.attrFix[ name ] || name;
2266
2267                         hooks = jQuery.attrHooks[ name ];
2268
2269                         if ( !hooks ) {
2270                                 // Use boolHook for boolean attributes
2271                                 if ( rboolean.test( name ) ) {
2272                                         hooks = boolHook;
2273
2274                                 // Use nodeHook if available( IE6/7 )
2275                                 } else if ( nodeHook ) {
2276                                         hooks = nodeHook;
2277                                 }
2278                         }
2279                 }
2280
2281                 if ( value !== undefined ) {
2282
2283                         if ( value === null ) {
2284                                 jQuery.removeAttr( elem, name );
2285                                 return undefined;
2286
2287                         } else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) {
2288                                 return ret;
2289
2290                         } else {
2291                                 elem.setAttribute( name, "" + value );
2292                                 return value;
2293                         }
2294
2295                 } else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) !== null ) {
2296                         return ret;
2297
2298                 } else {
2299
2300                         ret = elem.getAttribute( name );
2301
2302                         // Non-existent attributes return null, we normalize to undefined
2303                         return ret === null ?
2304                                 undefined :
2305                                 ret;
2306                 }
2307         },
2308
2309         removeAttr: function( elem, name ) {
2310                 var propName;
2311                 if ( elem.nodeType === 1 ) {
2312                         name = jQuery.attrFix[ name ] || name;
2313
2314                         jQuery.attr( elem, name, "" );
2315                         elem.removeAttribute( name );
2316
2317                         // Set corresponding property to false for boolean attributes
2318                         if ( rboolean.test( name ) && (propName = jQuery.propFix[ name ] || name) in elem ) {
2319                                 elem[ propName ] = false;
2320                         }
2321                 }
2322         },
2323
2324         attrHooks: {
2325                 type: {
2326                         set: function( elem, value ) {
2327                                 // We can't allow the type property to be changed (since it causes problems in IE)
2328                                 if ( rtype.test( elem.nodeName ) && elem.parentNode ) {
2329                                         jQuery.error( "type property can't be changed" );
2330                                 } else if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
2331                                         // Setting the type on a radio button after the value resets the value in IE6-9
2332                                         // Reset value to it's default in case type is set after value
2333                                         // This is for element creation
2334                                         var val = elem.value;
2335                                         elem.setAttribute( "type", value );
2336                                         if ( val ) {
2337                                                 elem.value = val;
2338                                         }
2339                                         return value;
2340                                 }
2341                         }
2342                 },
2343                 // Use the value property for back compat
2344                 // Use the nodeHook for button elements in IE6/7 (#1954)
2345                 value: {
2346                         get: function( elem, name ) {
2347                                 if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
2348                                         return nodeHook.get( elem, name );
2349                                 }
2350                                 return name in elem ?
2351                                         elem.value :
2352                                         null;
2353                         },
2354                         set: function( elem, value, name ) {
2355                                 if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
2356                                         return nodeHook.set( elem, value, name );
2357                                 }
2358                                 // Does not return so that setAttribute is also used
2359                                 elem.value = value;
2360                         }
2361                 }
2362         },
2363
2364         propFix: {
2365                 tabindex: "tabIndex",
2366                 readonly: "readOnly",
2367                 "for": "htmlFor",
2368                 "class": "className",
2369                 maxlength: "maxLength",
2370                 cellspacing: "cellSpacing",
2371                 cellpadding: "cellPadding",
2372                 rowspan: "rowSpan",
2373                 colspan: "colSpan",
2374                 usemap: "useMap",
2375                 frameborder: "frameBorder",
2376                 contenteditable: "contentEditable"
2377         },
2378         
2379         prop: function( elem, name, value ) {
2380                 var nType = elem.nodeType;
2381
2382                 // don't get/set properties on text, comment and attribute nodes
2383                 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
2384                         return undefined;
2385                 }
2386
2387                 var ret, hooks,
2388                         notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
2389
2390                 if ( notxml ) {
2391                         // Fix name and attach hooks
2392                         name = jQuery.propFix[ name ] || name;
2393                         hooks = jQuery.propHooks[ name ];
2394                 }
2395
2396                 if ( value !== undefined ) {
2397                         if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
2398                                 return ret;
2399
2400                         } else {
2401                                 return (elem[ name ] = value);
2402                         }
2403
2404                 } else {
2405                         if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
2406                                 return ret;
2407
2408                         } else {
2409                                 return elem[ name ];
2410                         }
2411                 }
2412         },
2413         
2414         propHooks: {
2415                 tabIndex: {
2416                         get: function( elem ) {
2417                                 // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
2418                                 // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
2419                                 var attributeNode = elem.getAttributeNode("tabindex");
2420
2421                                 return attributeNode && attributeNode.specified ?
2422                                         parseInt( attributeNode.value, 10 ) :
2423                                         rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
2424                                                 0 :
2425                                                 undefined;
2426                         }
2427                 }
2428         }
2429 });
2430
2431 // Add the tabindex propHook to attrHooks for back-compat
2432 jQuery.attrHooks.tabIndex = jQuery.propHooks.tabIndex;
2433
2434 // Hook for boolean attributes
2435 boolHook = {
2436         get: function( elem, name ) {
2437                 // Align boolean attributes with corresponding properties
2438                 // Fall back to attribute presence where some booleans are not supported
2439                 var attrNode;
2440                 return jQuery.prop( elem, name ) === true || ( attrNode = elem.getAttributeNode( name ) ) && attrNode.nodeValue !== false ?
2441                         name.toLowerCase() :
2442                         undefined;
2443         },
2444         set: function( elem, value, name ) {
2445                 var propName;
2446                 if ( value === false ) {
2447                         // Remove boolean attributes when set to false
2448                         jQuery.removeAttr( elem, name );
2449                 } else {
2450                         // value is true since we know at this point it's type boolean and not false
2451                         // Set boolean attributes to the same name and set the DOM property
2452                         propName = jQuery.propFix[ name ] || name;
2453                         if ( propName in elem ) {
2454                                 // Only set the IDL specifically if it already exists on the element
2455                                 elem[ propName ] = true;
2456                         }
2457
2458                         elem.setAttribute( name, name.toLowerCase() );
2459                 }
2460                 return name;
2461         }
2462 };
2463
2464 // IE6/7 do not support getting/setting some attributes with get/setAttribute
2465 if ( !jQuery.support.getSetAttribute ) {
2466         
2467         // Use this for any attribute in IE6/7
2468         // This fixes almost every IE6/7 issue
2469         nodeHook = jQuery.valHooks.button = {
2470                 get: function( elem, name ) {
2471                         var ret;
2472                         ret = elem.getAttributeNode( name );
2473                         // Return undefined if nodeValue is empty string
2474                         return ret && ret.nodeValue !== "" ?
2475                                 ret.nodeValue :
2476                                 undefined;
2477                 },
2478                 set: function( elem, value, name ) {
2479                         // Set the existing or create a new attribute node
2480                         var ret = elem.getAttributeNode( name );
2481                         if ( !ret ) {
2482                                 ret = document.createAttribute( name );
2483                                 elem.setAttributeNode( ret );
2484                         }
2485                         return (ret.nodeValue = value + "");
2486                 }
2487         };
2488
2489         // Set width and height to auto instead of 0 on empty string( Bug #8150 )
2490         // This is for removals
2491         jQuery.each([ "width", "height" ], function( i, name ) {
2492                 jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
2493                         set: function( elem, value ) {
2494                                 if ( value === "" ) {
2495                                         elem.setAttribute( name, "auto" );
2496                                         return value;
2497                                 }
2498                         }
2499                 });
2500         });
2501 }
2502
2503
2504 // Some attributes require a special call on IE
2505 if ( !jQuery.support.hrefNormalized ) {
2506         jQuery.each([ "href", "src", "width", "height" ], function( i, name ) {
2507                 jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
2508                         get: function( elem ) {
2509                                 var ret = elem.getAttribute( name, 2 );
2510                                 return ret === null ? undefined : ret;
2511                         }
2512                 });
2513         });
2514 }
2515
2516 if ( !jQuery.support.style ) {
2517         jQuery.attrHooks.style = {
2518                 get: function( elem ) {
2519                         // Return undefined in the case of empty string
2520                         // Normalize to lowercase since IE uppercases css property names
2521                         return elem.style.cssText.toLowerCase() || undefined;
2522                 },
2523                 set: function( elem, value ) {
2524                         return (elem.style.cssText = "" + value);
2525                 }
2526         };
2527 }
2528
2529 // Safari mis-reports the default selected property of an option
2530 // Accessing the parent's selectedIndex property fixes it
2531 if ( !jQuery.support.optSelected ) {
2532         jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, {
2533                 get: function( elem ) {
2534                         var parent = elem.parentNode;
2535
2536                         if ( parent ) {
2537                                 parent.selectedIndex;
2538
2539                                 // Make sure that it also works with optgroups, see #5701
2540                                 if ( parent.parentNode ) {
2541                                         parent.parentNode.selectedIndex;
2542                                 }
2543                         }
2544                         return null;
2545                 }
2546         });
2547 }
2548
2549 // Radios and checkboxes getter/setter
2550 if ( !jQuery.support.checkOn ) {
2551         jQuery.each([ "radio", "checkbox" ], function() {
2552                 jQuery.valHooks[ this ] = {
2553                         get: function( elem ) {
2554                                 // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
2555                                 return elem.getAttribute("value") === null ? "on" : elem.value;
2556                         }
2557                 };
2558         });
2559 }
2560 jQuery.each([ "radio", "checkbox" ], function() {
2561         jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], {
2562                 set: function( elem, value ) {
2563                         if ( jQuery.isArray( value ) ) {
2564                                 return (elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0);
2565                         }
2566                 }
2567         });
2568 });
2569
2570
2571
2572
2573 var rnamespaces = /\.(.*)$/,
2574         rformElems = /^(?:textarea|input|select)$/i,
2575         rperiod = /\./g,
2576         rspaces = / /g,
2577         rescape = /[^\w\s.|`]/g,
2578         fcleanup = function( nm ) {
2579                 return nm.replace(rescape, "\\$&");
2580         };
2581
2582 /*
2583  * A number of helper functions used for managing events.
2584  * Many of the ideas behind this code originated from
2585  * Dean Edwards' addEvent library.
2586  */
2587 jQuery.event = {
2588
2589         // Bind an event to an element
2590         // Original by Dean Edwards
2591         add: function( elem, types, handler, data ) {
2592                 if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
2593                         return;
2594                 }
2595
2596                 if ( handler === false ) {
2597                         handler = returnFalse;
2598                 } else if ( !handler ) {
2599                         // Fixes bug #7229. Fix recommended by jdalton
2600                         return;
2601                 }
2602
2603                 var handleObjIn, handleObj;
2604
2605                 if ( handler.handler ) {
2606                         handleObjIn = handler;
2607                         handler = handleObjIn.handler;
2608                 }
2609
2610                 // Make sure that the function being executed has a unique ID
2611                 if ( !handler.guid ) {
2612                         handler.guid = jQuery.guid++;
2613                 }
2614
2615                 // Init the element's event structure
2616                 var elemData = jQuery._data( elem );
2617
2618                 // If no elemData is found then we must be trying to bind to one of the
2619                 // banned noData elements
2620                 if ( !elemData ) {
2621                         return;
2622                 }
2623
2624                 var events = elemData.events,
2625                         eventHandle = elemData.handle;
2626
2627                 if ( !events ) {
2628                         elemData.events = events = {};
2629                 }
2630
2631                 if ( !eventHandle ) {
2632                         elemData.handle = eventHandle = function( e ) {
2633                                 // Discard the second event of a jQuery.event.trigger() and
2634                                 // when an event is called after a page has unloaded
2635                                 return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ?
2636                                         jQuery.event.handle.apply( eventHandle.elem, arguments ) :
2637                                         undefined;
2638                         };
2639                 }
2640
2641                 // Add elem as a property of the handle function
2642                 // This is to prevent a memory leak with non-native events in IE.
2643                 eventHandle.elem = elem;
2644
2645                 // Handle multiple events separated by a space
2646                 // jQuery(...).bind("mouseover mouseout", fn);
2647                 types = types.split(" ");
2648
2649                 var type, i = 0, namespaces;
2650
2651                 while ( (type = types[ i++ ]) ) {
2652                         handleObj = handleObjIn ?
2653                                 jQuery.extend({}, handleObjIn) :
2654                                 { handler: handler, data: data };
2655
2656                         // Namespaced event handlers
2657                         if ( type.indexOf(".") > -1 ) {
2658                                 namespaces = type.split(".");
2659                                 type = namespaces.shift();
2660                                 handleObj.namespace = namespaces.slice(0).sort().join(".");
2661
2662                         } else {
2663                                 namespaces = [];
2664                                 handleObj.namespace = "";
2665                         }
2666
2667                         handleObj.type = type;
2668                         if ( !handleObj.guid ) {
2669                                 handleObj.guid = handler.guid;
2670                         }
2671
2672                         // Get the current list of functions bound to this event
2673                         var handlers = events[ type ],
2674                                 special = jQuery.event.special[ type ] || {};
2675
2676                         // Init the event handler queue
2677                         if ( !handlers ) {
2678                                 handlers = events[ type ] = [];
2679
2680                                 // Check for a special event handler
2681                                 // Only use addEventListener/attachEvent if the special
2682                                 // events handler returns false
2683                                 if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
2684                                         // Bind the global event handler to the element
2685                                         if ( elem.addEventListener ) {
2686                                                 elem.addEventListener( type, eventHandle, false );
2687
2688                                         } else if ( elem.attachEvent ) {
2689                                                 elem.attachEvent( "on" + type, eventHandle );
2690                                         }
2691                                 }
2692                         }
2693
2694                         if ( special.add ) {
2695                                 special.add.call( elem, handleObj );
2696
2697                                 if ( !handleObj.handler.guid ) {
2698                                         handleObj.handler.guid = handler.guid;
2699                                 }
2700                         }
2701
2702                         // Add the function to the element's handler list
2703                         handlers.push( handleObj );
2704
2705                         // Keep track of which events have been used, for event optimization
2706                         jQuery.event.global[ type ] = true;
2707                 }
2708
2709                 // Nullify elem to prevent memory leaks in IE
2710                 elem = null;
2711         },
2712
2713         global: {},
2714
2715         // Detach an event or set of events from an element
2716         remove: function( elem, types, handler, pos ) {
2717                 // don't do events on text and comment nodes
2718                 if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
2719                         return;
2720                 }
2721
2722                 if ( handler === false ) {
2723                         handler = returnFalse;
2724                 }
2725
2726                 var ret, type, fn, j, i = 0, all, namespaces, namespace, special, eventType, handleObj, origType,
2727                         elemData = jQuery.hasData( elem ) && jQuery._data( elem ),
2728                         events = elemData && elemData.events;
2729
2730                 if ( !elemData || !events ) {
2731                         return;
2732                 }
2733
2734                 // types is actually an event object here
2735                 if ( types && types.type ) {
2736                         handler = types.handler;
2737                         types = types.type;
2738                 }
2739
2740                 // Unbind all events for the element
2741                 if ( !types || typeof types === "string" && types.charAt(0) === "." ) {
2742                         types = types || "";
2743
2744                         for ( type in events ) {
2745                                 jQuery.event.remove( elem, type + types );
2746                         }
2747
2748                         return;
2749                 }
2750
2751                 // Handle multiple events separated by a space
2752                 // jQuery(...).unbind("mouseover mouseout", fn);
2753                 types = types.split(" ");
2754
2755                 while ( (type = types[ i++ ]) ) {
2756                         origType = type;
2757                         handleObj = null;
2758                         all = type.indexOf(".") < 0;
2759                         namespaces = [];
2760
2761                         if ( !all ) {
2762                                 // Namespaced event handlers
2763                                 namespaces = type.split(".");
2764                                 type = namespaces.shift();
2765
2766                                 namespace = new RegExp("(^|\\.)" +
2767                                         jQuery.map( namespaces.slice(0).sort(), fcleanup ).join("\\.(?:.*\\.)?") + "(\\.|$)");
2768                         }
2769
2770                         eventType = events[ type ];
2771
2772                         if ( !eventType ) {
2773                                 continue;
2774                         }
2775
2776                         if ( !handler ) {
2777                                 for ( j = 0; j < eventType.length; j++ ) {
2778                                         handleObj = eventType[ j ];
2779
2780                                         if ( all || namespace.test( handleObj.namespace ) ) {
2781                                                 jQuery.event.remove( elem, origType, handleObj.handler, j );
2782                                                 eventType.splice( j--, 1 );
2783                                         }
2784                                 }
2785
2786                                 continue;
2787                         }
2788
2789                         special = jQuery.event.special[ type ] || {};
2790
2791                         for ( j = pos || 0; j < eventType.length; j++ ) {
2792                                 handleObj = eventType[ j ];
2793
2794                                 if ( handler.guid === handleObj.guid ) {
2795                                         // remove the given handler for the given type
2796                                         if ( all || namespace.test( handleObj.namespace ) ) {
2797                                                 if ( pos == null ) {
2798                                                         eventType.splice( j--, 1 );
2799                                                 }
2800
2801                                                 if ( special.remove ) {
2802                                                         special.remove.call( elem, handleObj );
2803                                                 }
2804                                         }
2805
2806                                         if ( pos != null ) {
2807                                                 break;
2808                                         }
2809                                 }
2810                         }
2811
2812                         // remove generic event handler if no more handlers exist
2813                         if ( eventType.length === 0 || pos != null && eventType.length === 1 ) {
2814                                 if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) {
2815                                         jQuery.removeEvent( elem, type, elemData.handle );
2816                                 }
2817
2818                                 ret = null;
2819                                 delete events[ type ];
2820                         }
2821                 }
2822
2823                 // Remove the expando if it's no longer used
2824                 if ( jQuery.isEmptyObject( events ) ) {
2825                         var handle = elemData.handle;
2826                         if ( handle ) {
2827                                 handle.elem = null;
2828                         }
2829
2830                         delete elemData.events;
2831                         delete elemData.handle;
2832
2833                         if ( jQuery.isEmptyObject( elemData ) ) {
2834                                 jQuery.removeData( elem, undefined, true );
2835                         }
2836                 }
2837         },
2838         
2839         // Events that are safe to short-circuit if no handlers are attached.
2840         // Native DOM events should not be added, they may have inline handlers.
2841         customEvent: {
2842                 "getData": true,
2843                 "setData": true,
2844                 "changeData": true
2845         },
2846
2847         trigger: function( event, data, elem, onlyHandlers ) {
2848                 // Event object or event type
2849                 var type = event.type || event,
2850                         namespaces = [],
2851                         exclusive;
2852
2853                 if ( type.indexOf("!") >= 0 ) {
2854                         // Exclusive events trigger only for the exact event (no namespaces)
2855                         type = type.slice(0, -1);
2856                         exclusive = true;
2857                 }
2858
2859                 if ( type.indexOf(".") >= 0 ) {
2860                         // Namespaced trigger; create a regexp to match event type in handle()
2861                         namespaces = type.split(".");
2862                         type = namespaces.shift();
2863                         namespaces.sort();
2864                 }
2865
2866                 if ( (!elem || jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ] ) {
2867                         // No jQuery handlers for this event type, and it can't have inline handlers
2868                         return;
2869                 }
2870
2871                 // Caller can pass in an Event, Object, or just an event type string
2872                 event = typeof event === "object" ?
2873                         // jQuery.Event object
2874                         event[ jQuery.expando ] ? event :
2875                         // Object literal
2876                         new jQuery.Event( type, event ) :
2877                         // Just the event type (string)
2878                         new jQuery.Event( type );
2879
2880                 event.type = type;
2881                 event.exclusive = exclusive;
2882                 event.namespace = namespaces.join(".");
2883                 event.namespace_re = new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)");
2884                 
2885                 // triggerHandler() and global events don't bubble or run the default action
2886                 if ( onlyHandlers || !elem ) {
2887                         event.preventDefault();
2888                         event.stopPropagation();
2889                 }
2890
2891                 // Handle a global trigger
2892                 if ( !elem ) {
2893                         // TODO: Stop taunting the data cache; remove global events and always attach to document
2894                         jQuery.each( jQuery.cache, function() {
2895                                 // internalKey variable is just used to make it easier to find
2896                                 // and potentially change this stuff later; currently it just
2897                                 // points to jQuery.expando
2898                                 var internalKey = jQuery.expando,
2899                                         internalCache = this[ internalKey ];
2900                                 if ( internalCache && internalCache.events && internalCache.events[ type ] ) {
2901                                         jQuery.event.trigger( event, data, internalCache.handle.elem );
2902                                 }
2903                         });
2904                         return;
2905                 }
2906
2907                 // Don't do events on text and comment nodes
2908                 if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
2909                         return;
2910                 }
2911
2912                 // Clean up the event in case it is being reused
2913                 event.result = undefined;
2914                 event.target = elem;
2915
2916                 // Clone any incoming data and prepend the event, creating the handler arg list
2917                 data = data != null ? jQuery.makeArray( data ) : [];
2918                 data.unshift( event );
2919
2920                 var cur = elem,
2921                         // IE doesn't like method names with a colon (#3533, #8272)
2922                         ontype = type.indexOf(":") < 0 ? "on" + type : "";
2923
2924                 // Fire event on the current element, then bubble up the DOM tree
2925                 do {
2926                         var handle = jQuery._data( cur, "handle" );
2927
2928                         event.currentTarget = cur;
2929                         if ( handle ) {
2930                                 handle.apply( cur, data );
2931                         }
2932
2933                         // Trigger an inline bound script
2934                         if ( ontype && jQuery.acceptData( cur ) && cur[ ontype ] && cur[ ontype ].apply( cur, data ) === false ) {
2935                                 event.result = false;
2936                                 event.preventDefault();
2937                         }
2938
2939                         // Bubble up to document, then to window
2940                         cur = cur.parentNode || cur.ownerDocument || cur === event.target.ownerDocument && window;
2941                 } while ( cur && !event.isPropagationStopped() );
2942
2943                 // If nobody prevented the default action, do it now
2944                 if ( !event.isDefaultPrevented() ) {
2945                         var old,
2946                                 special = jQuery.event.special[ type ] || {};
2947
2948                         if ( (!special._default || special._default.call( elem.ownerDocument, event ) === false) &&
2949                                 !(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) {
2950
2951                                 // Call a native DOM method on the target with the same name name as the event.
2952                                 // Can't use an .isFunction)() check here because IE6/7 fails that test.
2953                                 // IE<9 dies on focus to hidden element (#1486), may want to revisit a try/catch.
2954                                 try {
2955                                         if ( ontype && elem[ type ] ) {
2956                                                 // Don't re-trigger an onFOO event when we call its FOO() method
2957                                                 old = elem[ ontype ];
2958
2959                                                 if ( old ) {
2960                                                         elem[ ontype ] = null;
2961                                                 }
2962
2963                                                 jQuery.event.triggered = type;
2964                                                 elem[ type ]();
2965                                         }
2966                                 } catch ( ieError ) {}
2967
2968                                 if ( old ) {
2969                                         elem[ ontype ] = old;
2970                                 }
2971
2972                                 jQuery.event.triggered = undefined;
2973                         }
2974                 }
2975                 
2976                 return event.result;
2977         },
2978
2979         handle: function( event ) {
2980                 event = jQuery.event.fix( event || window.event );
2981                 // Snapshot the handlers list since a called handler may add/remove events.
2982                 var handlers = ((jQuery._data( this, "events" ) || {})[ event.type ] || []).slice(0),
2983                         run_all = !event.exclusive && !event.namespace,
2984                         args = Array.prototype.slice.call( arguments, 0 );
2985
2986                 // Use the fix-ed Event rather than the (read-only) native event
2987                 args[0] = event;
2988                 event.currentTarget = this;
2989
2990                 for ( var j = 0, l = handlers.length; j < l; j++ ) {
2991                         var handleObj = handlers[ j ];
2992
2993                         // Triggered event must 1) be non-exclusive and have no namespace, or
2994                         // 2) have namespace(s) a subset or equal to those in the bound event.
2995                         if ( run_all || event.namespace_re.test( handleObj.namespace ) ) {
2996                                 // Pass in a reference to the handler function itself
2997                                 // So that we can later remove it
2998                                 event.handler = handleObj.handler;
2999                                 event.data = handleObj.data;
3000                                 event.handleObj = handleObj;
3001
3002                                 var ret = handleObj.handler.apply( this, args );
3003
3004                                 if ( ret !== undefined ) {
3005                                         event.result = ret;
3006                                         if ( ret === false ) {
3007                                                 event.preventDefault();
3008                                                 event.stopPropagation();
3009                                         }
3010                                 }
3011
3012                                 if ( event.isImmediatePropagationStopped() ) {
3013                                         break;
3014                                 }
3015                         }
3016                 }
3017                 return event.result;
3018         },
3019
3020         props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),
3021
3022         fix: function( event ) {
3023                 if ( event[ jQuery.expando ] ) {
3024                         return event;
3025                 }
3026
3027                 // store a copy of the original event object
3028                 // and "clone" to set read-only properties
3029                 var originalEvent = event;
3030                 event = jQuery.Event( originalEvent );
3031
3032                 for ( var i = this.props.length, prop; i; ) {
3033                         prop = this.props[ --i ];
3034                         event[ prop ] = originalEvent[ prop ];
3035                 }
3036
3037                 // Fix target property, if necessary
3038                 if ( !event.target ) {
3039                         // Fixes #1925 where srcElement might not be defined either
3040                         event.target = event.srcElement || document;
3041                 }
3042
3043                 // check if target is a textnode (safari)
3044                 if ( event.target.nodeType === 3 ) {
3045                         event.target = event.target.parentNode;
3046                 }
3047
3048                 // Add relatedTarget, if necessary
3049                 if ( !event.relatedTarget && event.fromElement ) {
3050                         event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement;
3051                 }
3052
3053                 // Calculate pageX/Y if missing and clientX/Y available
3054                 if ( event.pageX == null && event.clientX != null ) {
3055                         var eventDocument = event.target.ownerDocument || document,
3056                                 doc = eventDocument.documentElement,
3057                                 body = eventDocument.body;
3058
3059                         event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0);
3060                         event.pageY = event.clientY + (doc && doc.scrollTop  || body && body.scrollTop  || 0) - (doc && doc.clientTop  || body && body.clientTop  || 0);
3061                 }
3062
3063                 // Add which for key events
3064                 if ( event.which == null && (event.charCode != null || event.keyCode != null) ) {
3065                         event.which = event.charCode != null ? event.charCode : event.keyCode;
3066                 }
3067
3068                 // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
3069                 if ( !event.metaKey && event.ctrlKey ) {
3070                         event.metaKey = event.ctrlKey;
3071                 }
3072
3073                 // Add which for click: 1 === left; 2 === middle; 3 === right
3074                 // Note: button is not normalized, so don't use it
3075                 if ( !event.which && event.button !== undefined ) {
3076                         event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));
3077                 }
3078
3079                 return event;
3080         },
3081
3082         // Deprecated, use jQuery.guid instead
3083         guid: 1E8,
3084
3085         // Deprecated, use jQuery.proxy instead
3086         proxy: jQuery.proxy,
3087
3088         special: {
3089                 ready: {
3090                         // Make sure the ready event is setup
3091                         setup: jQuery.bindReady,
3092                         teardown: jQuery.noop
3093                 },
3094
3095                 live: {
3096                         add: function( handleObj ) {
3097                                 jQuery.event.add( this,
3098                                         liveConvert( handleObj.origType, handleObj.selector ),
3099                                         jQuery.extend({}, handleObj, {handler: liveHandler, guid: handleObj.handler.guid}) );
3100                         },
3101
3102                         remove: function( handleObj ) {
3103                                 jQuery.event.remove( this, liveConvert( handleObj.origType, handleObj.selector ), handleObj );
3104                         }
3105                 },
3106
3107                 beforeunload: {
3108                         setup: function( data, namespaces, eventHandle ) {
3109                                 // We only want to do this special case on windows
3110                                 if ( jQuery.isWindow( this ) ) {
3111                                         this.onbeforeunload = eventHandle;
3112                                 }
3113                         },
3114
3115                         teardown: function( namespaces, eventHandle ) {
3116                                 if ( this.onbeforeunload === eventHandle ) {
3117                                         this.onbeforeunload = null;
3118                                 }
3119                         }
3120                 }
3121         }
3122 };
3123
3124 jQuery.removeEvent = document.removeEventListener ?
3125         function( elem, type, handle ) {
3126                 if ( elem.removeEventListener ) {
3127                         elem.removeEventListener( type, handle, false );
3128                 }
3129         } :
3130         function( elem, type, handle ) {
3131                 if ( elem.detachEvent ) {
3132                         elem.detachEvent( "on" + type, handle );
3133                 }
3134         };
3135
3136 jQuery.Event = function( src, props ) {
3137         // Allow instantiation without the 'new' keyword
3138         if ( !this.preventDefault ) {
3139                 return new jQuery.Event( src, props );
3140         }
3141
3142         // Event object
3143         if ( src && src.type ) {
3144                 this.originalEvent = src;
3145                 this.type = src.type;
3146
3147                 // Events bubbling up the document may have been marked as prevented
3148                 // by a handler lower down the tree; reflect the correct value.
3149                 this.isDefaultPrevented = (src.defaultPrevented || src.returnValue === false ||
3150                         src.getPreventDefault && src.getPreventDefault()) ? returnTrue : returnFalse;
3151
3152         // Event type
3153         } else {
3154                 this.type = src;
3155         }
3156
3157         // Put explicitly provided properties onto the event object
3158         if ( props ) {
3159                 jQuery.extend( this, props );
3160         }
3161
3162         // timeStamp is buggy for some events on Firefox(#3843)
3163         // So we won't rely on the native value
3164         this.timeStamp = jQuery.now();
3165
3166         // Mark it as fixed
3167         this[ jQuery.expando ] = true;
3168 };
3169
3170 function returnFalse() {
3171         return false;
3172 }
3173 function returnTrue() {
3174         return true;
3175 }
3176
3177 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
3178 // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
3179 jQuery.Event.prototype = {
3180         preventDefault: function() {
3181                 this.isDefaultPrevented = returnTrue;
3182
3183                 var e = this.originalEvent;
3184                 if ( !e ) {
3185                         return;
3186                 }
3187
3188                 // if preventDefault exists run it on the original event
3189                 if ( e.preventDefault ) {
3190                         e.preventDefault();
3191
3192                 // otherwise set the returnValue property of the original event to false (IE)
3193                 } else {
3194                         e.returnValue = false;
3195                 }
3196         },
3197         stopPropagation: function() {
3198                 this.isPropagationStopped = returnTrue;
3199
3200                 var e = this.originalEvent;
3201                 if ( !e ) {
3202                         return;
3203                 }
3204                 // if stopPropagation exists run it on the original event
3205                 if ( e.stopPropagation ) {
3206                         e.stopPropagation();
3207                 }
3208                 // otherwise set the cancelBubble property of the original event to true (IE)
3209                 e.cancelBubble = true;
3210         },
3211         stopImmediatePropagation: function() {
3212                 this.isImmediatePropagationStopped = returnTrue;
3213                 this.stopPropagation();
3214         },
3215         isDefaultPrevented: returnFalse,
3216         isPropagationStopped: returnFalse,
3217         isImmediatePropagationStopped: returnFalse
3218 };
3219
3220 // Checks if an event happened on an element within another element
3221 // Used in jQuery.event.special.mouseenter and mouseleave handlers
3222 var withinElement = function( event ) {
3223
3224         // Check if mouse(over|out) are still within the same parent element
3225         var related = event.relatedTarget,
3226                 inside = false,
3227                 eventType = event.type;
3228
3229         event.type = event.data;
3230
3231         if ( related !== this ) {
3232
3233                 if ( related ) {
3234                         inside = jQuery.contains( this, related );
3235                 }
3236
3237                 if ( !inside ) {
3238
3239                         jQuery.event.handle.apply( this, arguments );
3240
3241                         event.type = eventType;
3242                 }
3243         }
3244 },
3245
3246 // In case of event delegation, we only need to rename the event.type,
3247 // liveHandler will take care of the rest.
3248 delegate = function( event ) {
3249         event.type = event.data;
3250         jQuery.event.handle.apply( this, arguments );
3251 };
3252
3253 // Create mouseenter and mouseleave events
3254 jQuery.each({
3255         mouseenter: "mouseover",
3256         mouseleave: "mouseout"
3257 }, function( orig, fix ) {
3258         jQuery.event.special[ orig ] = {
3259                 setup: function( data ) {
3260                         jQuery.event.add( this, fix, data && data.selector ? delegate : withinElement, orig );
3261                 },
3262                 teardown: function( data ) {
3263                         jQuery.event.remove( this, fix, data && data.selector ? delegate : withinElement );
3264                 }
3265         };
3266 });
3267
3268 // submit delegation
3269 if ( !jQuery.support.submitBubbles ) {
3270
3271         jQuery.event.special.submit = {
3272                 setup: function( data, namespaces ) {
3273                         if ( !jQuery.nodeName( this, "form" ) ) {
3274                                 jQuery.event.add(this, "click.specialSubmit", function( e ) {
3275                                         // Avoid triggering error on non-existent type attribute in IE VML (#7071)
3276                                         var elem = e.target,
3277                                                 type = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.type : "";
3278
3279                                         if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) {
3280                                                 trigger( "submit", this, arguments );
3281                                         }
3282                                 });
3283
3284                                 jQuery.event.add(this, "keypress.specialSubmit", function( e ) {
3285                                         var elem = e.target,
3286                                                 type = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.type : "";
3287
3288                                         if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) {
3289                                                 trigger( "submit", this, arguments );
3290                                         }
3291                                 });
3292
3293                         } else {
3294                                 return false;
3295                         }
3296                 },
3297
3298                 teardown: function( namespaces ) {
3299                         jQuery.event.remove( this, ".specialSubmit" );
3300                 }
3301         };
3302
3303 }
3304
3305 // change delegation, happens here so we have bind.
3306 if ( !jQuery.support.changeBubbles ) {
3307
3308         var changeFilters,
3309
3310         getVal = function( elem ) {
3311                 var type = jQuery.nodeName( elem, "input" ) ? elem.type : "",
3312                         val = elem.value;
3313
3314                 if ( type === "radio" || type === "checkbox" ) {
3315                         val = elem.checked;
3316
3317                 } else if ( type === "select-multiple" ) {
3318                         val = elem.selectedIndex > -1 ?
3319                                 jQuery.map( elem.options, function( elem ) {
3320                                         return elem.selected;
3321                                 }).join("-") :
3322                                 "";
3323
3324                 } else if ( jQuery.nodeName( elem, "select" ) ) {
3325                         val = elem.selectedIndex;
3326                 }
3327
3328                 return val;
3329         },
3330
3331         testChange = function testChange( e ) {
3332                 var elem = e.target, data, val;
3333
3334                 if ( !rformElems.test( elem.nodeName ) || elem.readOnly ) {
3335                         return;
3336                 }
3337
3338                 data = jQuery._data( elem, "_change_data" );
3339                 val = getVal(elem);
3340
3341                 // the current data will be also retrieved by beforeactivate
3342                 if ( e.type !== "focusout" || elem.type !== "radio" ) {
3343                         jQuery._data( elem, "_change_data", val );
3344                 }
3345
3346                 if ( data === undefined || val === data ) {
3347                         return;
3348                 }
3349
3350                 if ( data != null || val ) {
3351                         e.type = "change";
3352                         e.liveFired = undefined;
3353                         jQuery.event.trigger( e, arguments[1], elem );
3354                 }
3355         };
3356
3357         jQuery.event.special.change = {
3358                 filters: {
3359                         focusout: testChange,
3360
3361                         beforedeactivate: testChange,
3362
3363                         click: function( e ) {
3364                                 var elem = e.target, type = jQuery.nodeName( elem, "input" ) ? elem.type : "";
3365
3366                                 if ( type === "radio" || type === "checkbox" || jQuery.nodeName( elem, "select" ) ) {
3367                                         testChange.call( this, e );
3368                                 }
3369                         },
3370
3371                         // Change has to be called before submit
3372                         // Keydown will be called before keypress, which is used in submit-event delegation
3373                         keydown: function( e ) {
3374                                 var elem = e.target, type = jQuery.nodeName( elem, "input" ) ? elem.type : "";
3375
3376                                 if ( (e.keyCode === 13 && !jQuery.nodeName( elem, "textarea" ) ) ||
3377                                         (e.keyCode === 32 && (type === "checkbox" || type === "radio")) ||
3378                                         type === "select-multiple" ) {
3379                                         testChange.call( this, e );
3380                                 }
3381                         },
3382
3383                         // Beforeactivate happens also before the previous element is blurred
3384                         // with this event you can't trigger a change event, but you can store
3385                         // information
3386                         beforeactivate: function( e ) {
3387                                 var elem = e.target;
3388                                 jQuery._data( elem, "_change_data", getVal(elem) );
3389                         }
3390                 },
3391
3392                 setup: function( data, namespaces ) {
3393                         if ( this.type === "file" ) {
3394                                 return false;
3395                         }
3396
3397                         for ( var type in changeFilters ) {
3398                                 jQuery.event.add( this, type + ".specialChange", changeFilters[type] );
3399                         }
3400
3401                         return rformElems.test( this.nodeName );
3402                 },
3403
3404                 teardown: function( namespaces ) {
3405                         jQuery.event.remove( this, ".specialChange" );
3406
3407                         return rformElems.test( this.nodeName );
3408                 }
3409         };
3410
3411         changeFilters = jQuery.event.special.change.filters;
3412
3413         // Handle when the input is .focus()'d
3414         changeFilters.focus = changeFilters.beforeactivate;
3415 }
3416
3417 function trigger( type, elem, args ) {
3418         // Piggyback on a donor event to simulate a different one.
3419         // Fake originalEvent to avoid donor's stopPropagation, but if the
3420         // simulated event prevents default then we do the same on the donor.
3421         // Don't pass args or remember liveFired; they apply to the donor event.
3422         var event = jQuery.extend( {}, args[ 0 ] );
3423         event.type = type;
3424         event.originalEvent = {};
3425         event.liveFired = undefined;
3426         jQuery.event.handle.call( elem, event );
3427         if ( event.isDefaultPrevented() ) {
3428                 args[ 0 ].preventDefault();
3429         }
3430 }
3431
3432 // Create "bubbling" focus and blur events
3433 if ( !jQuery.support.focusinBubbles ) {
3434         jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
3435
3436                 // Attach a single capturing handler while someone wants focusin/focusout
3437                 var attaches = 0;
3438
3439                 jQuery.event.special[ fix ] = {
3440                         setup: function() {
3441                                 if ( attaches++ === 0 ) {
3442                                         document.addEventListener( orig, handler, true );
3443                                 }
3444                         },
3445                         teardown: function() {
3446                                 if ( --attaches === 0 ) {
3447                                         document.removeEventListener( orig, handler, true );
3448                                 }
3449                         }
3450                 };
3451
3452                 function handler( donor ) {
3453                         // Donor event is always a native one; fix it and switch its type.
3454                         // Let focusin/out handler cancel the donor focus/blur event.
3455                         var e = jQuery.event.fix( donor );
3456                         e.type = fix;
3457                         e.originalEvent = {};
3458                         jQuery.event.trigger( e, null, e.target );
3459                         if ( e.isDefaultPrevented() ) {
3460                                 donor.preventDefault();
3461                         }
3462                 }
3463         });
3464 }
3465
3466 jQuery.each(["bind", "one"], function( i, name ) {
3467         jQuery.fn[ name ] = function( type, data, fn ) {
3468                 var handler;
3469
3470                 // Handle object literals
3471                 if ( typeof type === "object" ) {
3472                         for ( var key in type ) {
3473                                 this[ name ](key, data, type[key], fn);
3474                         }
3475                         return this;
3476                 }
3477
3478                 if ( arguments.length === 2 || data === false ) {
3479                         fn = data;
3480                         data = undefined;
3481                 }
3482
3483                 if ( name === "one" ) {
3484                         handler = function( event ) {
3485                                 jQuery( this ).unbind( event, handler );
3486                                 return fn.apply( this, arguments );
3487                         };
3488                         handler.guid = fn.guid || jQuery.guid++;
3489                 } else {
3490                         handler = fn;
3491                 }
3492
3493                 if ( type === "unload" && name !== "one" ) {
3494                         this.one( type, data, fn );
3495
3496                 } else {
3497                         for ( var i = 0, l = this.length; i < l; i++ ) {
3498                                 jQuery.event.add( this[i], type, handler, data );
3499                         }
3500                 }
3501
3502                 return this;
3503         };
3504 });
3505
3506 jQuery.fn.extend({
3507         unbind: function( type, fn ) {
3508                 // Handle object literals
3509                 if ( typeof type === "object" && !type.preventDefault ) {
3510                         for ( var key in type ) {
3511                                 this.unbind(key, type[key]);
3512                         }
3513
3514                 } else {
3515                         for ( var i = 0, l = this.length; i < l; i++ ) {
3516                                 jQuery.event.remove( this[i], type, fn );
3517                         }
3518                 }
3519
3520                 return this;
3521         },
3522
3523         delegate: function( selector, types, data, fn ) {
3524                 return this.live( types, data, fn, selector );
3525         },
3526
3527         undelegate: function( selector, types, fn ) {
3528                 if ( arguments.length === 0 ) {
3529                         return this.unbind( "live" );
3530
3531                 } else {
3532                         return this.die( types, null, fn, selector );
3533                 }
3534         },
3535
3536         trigger: function( type, data ) {
3537                 return this.each(function() {
3538                         jQuery.event.trigger( type, data, this );
3539                 });
3540         },
3541
3542         triggerHandler: function( type, data ) {
3543                 if ( this[0] ) {
3544                         return jQuery.event.trigger( type, data, this[0], true );
3545                 }
3546         },
3547
3548         toggle: function( fn ) {
3549                 // Save reference to arguments for access in closure
3550                 var args = arguments,
3551                         guid = fn.guid || jQuery.guid++,
3552                         i = 0,
3553                         toggler = function( event ) {
3554                                 // Figure out which function to execute
3555                                 var lastToggle = ( jQuery.data( this, "lastToggle" + fn.guid ) || 0 ) % i;
3556                                 jQuery.data( this, "lastToggle" + fn.guid, lastToggle + 1 );
3557
3558                                 // Make sure that clicks stop
3559                                 event.preventDefault();
3560
3561                                 // and execute the function
3562                                 return args[ lastToggle ].apply( this, arguments ) || false;
3563                         };
3564
3565                 // link all the functions, so any of them can unbind this click handler
3566                 toggler.guid = guid;
3567                 while ( i < args.length ) {
3568                         args[ i++ ].guid = guid;
3569                 }
3570
3571                 return this.click( toggler );
3572         },
3573
3574         hover: function( fnOver, fnOut ) {
3575                 return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
3576         }
3577 });
3578
3579 var liveMap = {
3580         focus: "focusin",
3581         blur: "focusout",
3582         mouseenter: "mouseover",
3583         mouseleave: "mouseout"
3584 };
3585
3586 jQuery.each(["live", "die"], function( i, name ) {
3587         jQuery.fn[ name ] = function( types, data, fn, origSelector /* Internal Use Only */ ) {
3588                 var type, i = 0, match, namespaces, preType,
3589                         selector = origSelector || this.selector,
3590                         context = origSelector ? this : jQuery( this.context );
3591
3592                 if ( typeof types === "object" && !types.preventDefault ) {
3593                         for ( var key in types ) {
3594                                 context[ name ]( key, data, types[key], selector );
3595                         }
3596
3597                         return this;
3598                 }
3599
3600                 if ( name === "die" && !types &&
3601                                         origSelector && origSelector.charAt(0) === "." ) {
3602
3603                         context.unbind( origSelector );
3604
3605                         return this;
3606                 }
3607
3608                 if ( data === false || jQuery.isFunction( data ) ) {
3609                         fn = data || returnFalse;
3610                         data = undefined;
3611                 }
3612
3613                 types = (types || "").split(" ");
3614
3615                 while ( (type = types[ i++ ]) != null ) {
3616                         match = rnamespaces.exec( type );
3617                         namespaces = "";
3618
3619                         if ( match )  {
3620                                 namespaces = match[0];
3621                                 type = type.replace( rnamespaces, "" );
3622                         }
3623
3624                         if ( type === "hover" ) {
3625                                 types.push( "mouseenter" + namespaces, "mouseleave" + namespaces );
3626                                 continue;
3627                         }
3628
3629                         preType = type;
3630
3631                         if ( liveMap[ type ] ) {
3632                                 types.push( liveMap[ type ] + namespaces );
3633                                 type = type + namespaces;
3634
3635                         } else {
3636                                 type = (liveMap[ type ] || type) + namespaces;
3637                         }
3638
3639                         if ( name === "live" ) {
3640                                 // bind live handler
3641                                 for ( var j = 0, l = context.length; j < l; j++ ) {
3642                                         jQuery.event.add( context[j], "live." + liveConvert( type, selector ),
3643                                                 { data: data, selector: selector, handler: fn, origType: type, origHandler: fn, preType: preType } );
3644                                 }
3645
3646                         } else {
3647                                 // unbind live handler
3648                                 context.unbind( "live." + liveConvert( type, selector ), fn );
3649                         }
3650                 }
3651
3652                 return this;
3653         };
3654 });
3655
3656 function liveHandler( event ) {
3657         var stop, maxLevel, related, match, handleObj, elem, j, i, l, data, close, namespace, ret,
3658                 elems = [],
3659                 selectors = [],
3660                 events = jQuery._data( this, "events" );
3661
3662         // Make sure we avoid non-left-click bubbling in Firefox (#3861) and disabled elements in IE (#6911)
3663         if ( event.liveFired === this || !events || !events.live || event.target.disabled || event.button && event.type === "click" ) {
3664                 return;
3665         }
3666
3667         if ( event.namespace ) {
3668                 namespace = new RegExp("(^|\\.)" + event.namespace.split(".").join("\\.(?:.*\\.)?") + "(\\.|$)");
3669         }
3670
3671         event.liveFired = this;
3672
3673         var live = events.live.slice(0);
3674
3675         for ( j = 0; j < live.length; j++ ) {
3676                 handleObj = live[j];
3677
3678                 if ( handleObj.origType.replace( rnamespaces, "" ) === event.type ) {
3679                         selectors.push( handleObj.selector );
3680
3681                 } else {
3682                         live.splice( j--, 1 );
3683                 }
3684         }
3685
3686         match = jQuery( event.target ).closest( selectors, event.currentTarget );
3687
3688         for ( i = 0, l = match.length; i < l; i++ ) {
3689                 close = match[i];
3690
3691                 for ( j = 0; j < live.length; j++ ) {
3692                         handleObj = live[j];
3693
3694                         if ( close.selector === handleObj.selector && (!namespace || namespace.test( handleObj.namespace )) && !close.elem.disabled ) {
3695                                 elem = close.elem;
3696                                 related = null;
3697
3698                                 // Those two events require additional checking
3699                                 if ( handleObj.preType === "mouseenter" || handleObj.preType === "mouseleave" ) {
3700                                         event.type = handleObj.preType;
3701                                         related = jQuery( event.relatedTarget ).closest( handleObj.selector )[0];
3702
3703                                         // Make sure not to accidentally match a child element with the same selector
3704                                         if ( related && jQuery.contains( elem, related ) ) {
3705                                                 related = elem;
3706                                         }
3707                                 }
3708
3709                                 if ( !related || related !== elem ) {
3710                                         elems.push({ elem: elem, handleObj: handleObj, level: close.level });
3711                                 }
3712                         }
3713                 }
3714         }
3715
3716         for ( i = 0, l = elems.length; i < l; i++ ) {
3717                 match = elems[i];
3718
3719                 if ( maxLevel && match.level > maxLevel ) {
3720                         break;
3721                 }
3722
3723                 event.currentTarget = match.elem;
3724                 event.data = match.handleObj.data;
3725                 event.handleObj = match.handleObj;
3726
3727                 ret = match.handleObj.origHandler.apply( match.elem, arguments );
3728
3729                 if ( ret === false || event.isPropagationStopped() ) {
3730                         maxLevel = match.level;
3731
3732                         if ( ret === false ) {
3733                                 stop = false;
3734                         }
3735                         if ( event.isImmediatePropagationStopped() ) {
3736                                 break;
3737                         }
3738                 }
3739         }
3740
3741         return stop;
3742 }
3743
3744 function liveConvert( type, selector ) {
3745         return (type && type !== "*" ? type + "." : "") + selector.replace(rperiod, "`").replace(rspaces, "&");
3746 }
3747
3748 jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
3749         "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
3750         "change select submit keydown keypress keyup error").split(" "), function( i, name ) {
3751
3752         // Handle event binding
3753         jQuery.fn[ name ] = function( data, fn ) {
3754                 if ( fn == null ) {
3755                         fn = data;
3756                         data = null;
3757                 }
3758
3759                 return arguments.length > 0 ?
3760                         this.bind( name, data, fn ) :
3761                         this.trigger( name );
3762         };
3763
3764         if ( jQuery.attrFn ) {
3765                 jQuery.attrFn[ name ] = true;
3766         }
3767 });
3768
3769
3770
3771 /*!
3772  * Sizzle CSS Selector Engine
3773  *  Copyright 2011, The Dojo Foundation
3774  *  Released under the MIT, BSD, and GPL Licenses.
3775  *  More information: http://sizzlejs.com/
3776  */
3777 (function(){
3778
3779 var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
3780         done = 0,
3781         toString = Object.prototype.toString,
3782         hasDuplicate = false,
3783         baseHasDuplicate = true,
3784         rBackslash = /\\/g,
3785         rNonWord = /\W/;
3786
3787 // Here we check if the JavaScript engine is using some sort of
3788 // optimization where it does not always call our comparision
3789 // function. If that is the case, discard the hasDuplicate value.
3790 //   Thus far that includes Google Chrome.
3791 [0, 0].sort(function() {
3792         baseHasDuplicate = false;
3793         return 0;
3794 });
3795
3796 var Sizzle = function( selector, context, results, seed ) {
3797         results = results || [];
3798         context = context || document;
3799
3800         var origContext = context;
3801
3802         if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
3803                 return [];
3804         }
3805         
3806         if ( !selector || typeof selector !== "string" ) {
3807                 return results;
3808         }
3809
3810         var m, set, checkSet, extra, ret, cur, pop, i,
3811                 prune = true,
3812                 contextXML = Sizzle.isXML( context ),
3813                 parts = [],
3814                 soFar = selector;
3815         
3816         // Reset the position of the chunker regexp (start from head)
3817         do {
3818                 chunker.exec( "" );
3819                 m = chunker.exec( soFar );
3820
3821                 if ( m ) {
3822                         soFar = m[3];
3823                 
3824                         parts.push( m[1] );
3825                 
3826                         if ( m[2] ) {
3827                                 extra = m[3];
3828                                 break;
3829                         }
3830                 }
3831         } while ( m );
3832
3833         if ( parts.length > 1 && origPOS.exec( selector ) ) {
3834
3835                 if ( parts.length === 2 && Expr.relative[ parts[0] ] ) {
3836                         set = posProcess( parts[0] + parts[1], context );
3837
3838                 } else {
3839                         set = Expr.relative[ parts[0] ] ?
3840                                 [ context ] :
3841                                 Sizzle( parts.shift(), context );
3842
3843                         while ( parts.length ) {
3844                                 selector = parts.shift();
3845
3846                                 if ( Expr.relative[ selector ] ) {
3847                                         selector += parts.shift();
3848                                 }
3849                                 
3850                                 set = posProcess( selector, set );
3851                         }
3852                 }
3853
3854         } else {
3855                 // Take a shortcut and set the context if the root selector is an ID
3856                 // (but not if it'll be faster if the inner selector is an ID)
3857                 if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML &&
3858                                 Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) {
3859
3860                         ret = Sizzle.find( parts.shift(), context, contextXML );
3861                         context = ret.expr ?
3862                                 Sizzle.filter( ret.expr, ret.set )[0] :
3863                                 ret.set[0];
3864                 }
3865
3866                 if ( context ) {
3867                         ret = seed ?
3868                                 { expr: parts.pop(), set: makeArray(seed) } :
3869                                 Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML );
3870
3871                         set = ret.expr ?
3872                                 Sizzle.filter( ret.expr, ret.set ) :
3873                                 ret.set;
3874
3875                         if ( parts.length > 0 ) {
3876                                 checkSet = makeArray( set );
3877
3878                         } else {
3879                                 prune = false;
3880                         }
3881
3882                         while ( parts.length ) {
3883                                 cur = parts.pop();
3884                                 pop = cur;
3885
3886                                 if ( !Expr.relative[ cur ] ) {
3887                                         cur = "";
3888                                 } else {
3889                                         pop = parts.pop();
3890                                 }
3891
3892                                 if ( pop == null ) {
3893                                         pop = context;
3894                                 }
3895
3896                                 Expr.relative[ cur ]( checkSet, pop, contextXML );
3897                         }
3898
3899                 } else {
3900                         checkSet = parts = [];
3901                 }
3902         }
3903
3904         if ( !checkSet ) {
3905                 checkSet = set;
3906         }
3907
3908         if ( !checkSet ) {
3909                 Sizzle.error( cur || selector );
3910         }
3911
3912         if ( toString.call(checkSet) === "[object Array]" ) {
3913                 if ( !prune ) {
3914                         results.push.apply( results, checkSet );
3915
3916                 } else if ( context && context.nodeType === 1 ) {
3917                         for ( i = 0; checkSet[i] != null; i++ ) {
3918                                 if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i])) ) {
3919                                         results.push( set[i] );
3920                                 }
3921                         }
3922
3923                 } else {
3924                         for ( i = 0; checkSet[i] != null; i++ ) {
3925                                 if ( checkSet[i] && checkSet[i].nodeType === 1 ) {
3926                                         results.push( set[i] );
3927                                 }
3928                         }
3929                 }
3930
3931         } else {
3932                 makeArray( checkSet, results );
3933         }
3934
3935         if ( extra ) {
3936                 Sizzle( extra, origContext, results, seed );
3937                 Sizzle.uniqueSort( results );
3938         }
3939
3940         return results;
3941 };
3942
3943 Sizzle.uniqueSort = function( results ) {
3944         if ( sortOrder ) {
3945                 hasDuplicate = baseHasDuplicate;
3946                 results.sort( sortOrder );
3947
3948                 if ( hasDuplicate ) {
3949                         for ( var i = 1; i < results.length; i++ ) {
3950                                 if ( results[i] === results[ i - 1 ] ) {
3951                                         results.splice( i--, 1 );
3952                                 }
3953                         }
3954                 }
3955         }
3956
3957         return results;
3958 };
3959
3960 Sizzle.matches = function( expr, set ) {
3961         return Sizzle( expr, null, null, set );
3962 };
3963
3964 Sizzle.matchesSelector = function( node, expr ) {
3965         return Sizzle( expr, null, null, [node] ).length > 0;
3966 };
3967
3968 Sizzle.find = function( expr, context, isXML ) {
3969         var set;
3970
3971         if ( !expr ) {
3972                 return [];
3973         }
3974
3975         for ( var i = 0, l = Expr.order.length; i < l; i++ ) {
3976                 var match,
3977                         type = Expr.order[i];
3978                 
3979                 if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
3980                         var left = match[1];
3981                         match.splice( 1, 1 );
3982
3983                         if ( left.substr( left.length - 1 ) !== "\\" ) {
3984                                 match[1] = (match[1] || "").replace( rBackslash, "" );
3985                                 set = Expr.find[ type ]( match, context, isXML );
3986
3987                                 if ( set != null ) {
3988                                         expr = expr.replace( Expr.match[ type ], "" );
3989                                         break;
3990                                 }
3991                         }
3992                 }
3993         }
3994
3995         if ( !set ) {
3996                 set = typeof context.getElementsByTagName !== "undefined" ?
3997                         context.getElementsByTagName( "*" ) :
3998                         [];
3999         }
4000
4001         return { set: set, expr: expr };
4002 };
4003
4004 Sizzle.filter = function( expr, set, inplace, not ) {
4005         var match, anyFound,
4006                 old = expr,
4007                 result = [],
4008                 curLoop = set,
4009                 isXMLFilter = set && set[0] && Sizzle.isXML( set[0] );
4010
4011         while ( expr && set.length ) {
4012                 for ( var type in Expr.filter ) {
4013                         if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) {
4014                                 var found, item,
4015                                         filter = Expr.filter[ type ],
4016                                         left = match[1];
4017
4018                                 anyFound = false;
4019
4020                                 match.splice(1,1);
4021
4022                                 if ( left.substr( left.length - 1 ) === "\\" ) {
4023                                         continue;
4024                                 }
4025
4026                                 if ( curLoop === result ) {
4027                                         result = [];
4028                                 }
4029
4030                                 if ( Expr.preFilter[ type ] ) {
4031                                         match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter );
4032
4033                                         if ( !match ) {
4034                                                 anyFound = found = true;
4035
4036                                         } else if ( match === true ) {
4037                                                 continue;
4038                                         }
4039                                 }
4040
4041                                 if ( match ) {
4042                                         for ( var i = 0; (item = curLoop[i]) != null; i++ ) {
4043                                                 if ( item ) {
4044                                                         found = filter( item, match, i, curLoop );
4045                                                         var pass = not ^ !!found;
4046
4047                                                         if ( inplace && found != null ) {
4048                                                                 if ( pass ) {
4049                                                                         anyFound = true;
4050
4051                                                                 } else {
4052                                                                         curLoop[i] = false;
4053                                                                 }
4054
4055                                                         } else if ( pass ) {
4056                                                                 result.push( item );
4057                                                                 anyFound = true;
4058                                                         }
4059                                                 }
4060                                         }
4061                                 }
4062
4063                                 if ( found !== undefined ) {
4064                                         if ( !inplace ) {
4065                                                 curLoop = result;
4066                                         }
4067
4068                                         expr = expr.replace( Expr.match[ type ], "" );
4069
4070                                         if ( !anyFound ) {
4071                                                 return [];
4072                                         }
4073
4074                                         break;
4075                                 }
4076                         }
4077                 }
4078
4079                 // Improper expression
4080                 if ( expr === old ) {
4081                         if ( anyFound == null ) {
4082                                 Sizzle.error( expr );
4083
4084                         } else {
4085                                 break;
4086                         }
4087                 }
4088
4089                 old = expr;
4090         }
4091
4092         return curLoop;
4093 };
4094
4095 Sizzle.error = function( msg ) {
4096         throw "Syntax error, unrecognized expression: " + msg;
4097 };
4098
4099 var Expr = Sizzle.selectors = {
4100         order: [ "ID", "NAME", "TAG" ],
4101
4102         match: {
4103                 ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
4104                 CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
4105                 NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,
4106                 ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/,
4107                 TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,
4108                 CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/,
4109                 POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,
4110                 PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/
4111         },
4112
4113         leftMatch: {},
4114
4115         attrMap: {
4116                 "class": "className",
4117                 "for": "htmlFor"
4118         },
4119
4120         attrHandle: {
4121                 href: function( elem ) {
4122                         return elem.getAttribute( "href" );
4123                 },
4124                 type: function( elem ) {
4125                         return elem.getAttribute( "type" );
4126                 }
4127         },
4128
4129         relative: {
4130                 "+": function(checkSet, part){
4131                         var isPartStr = typeof part === "string",
4132                                 isTag = isPartStr && !rNonWord.test( part ),
4133                                 isPartStrNotTag = isPartStr && !isTag;
4134
4135                         if ( isTag ) {
4136                                 part = part.toLowerCase();
4137                         }
4138
4139                         for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) {
4140                                 if ( (elem = checkSet[i]) ) {
4141                                         while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {}
4142
4143                                         checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ?
4144                                                 elem || false :
4145                                                 elem === part;
4146                                 }
4147                         }
4148
4149                         if ( isPartStrNotTag ) {
4150                                 Sizzle.filter( part, checkSet, true );
4151                         }
4152                 },
4153
4154                 ">": function( checkSet, part ) {
4155                         var elem,
4156                                 isPartStr = typeof part === "string",
4157                                 i = 0,
4158                                 l = checkSet.length;
4159
4160                         if ( isPartStr && !rNonWord.test( part ) ) {
4161                                 part = part.toLowerCase();
4162
4163                                 for ( ; i < l; i++ ) {
4164                                         elem = checkSet[i];
4165
4166                                         if ( elem ) {
4167                                                 var parent = elem.parentNode;
4168                                                 checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false;
4169                                         }
4170                                 }
4171
4172                         } else {
4173                                 for ( ; i < l; i++ ) {
4174                                         elem = checkSet[i];
4175
4176                                         if ( elem ) {
4177                                                 checkSet[i] = isPartStr ?
4178                                                         elem.parentNode :
4179                                                         elem.parentNode === part;
4180                                         }
4181                                 }
4182
4183                                 if ( isPartStr ) {
4184                                         Sizzle.filter( part, checkSet, true );
4185                                 }
4186                         }
4187                 },
4188
4189                 "": function(checkSet, part, isXML){
4190                         var nodeCheck,
4191                                 doneName = done++,
4192                                 checkFn = dirCheck;
4193
4194                         if ( typeof part === "string" && !rNonWord.test( part ) ) {
4195                                 part = part.toLowerCase();
4196                                 nodeCheck = part;
4197                                 checkFn = dirNodeCheck;
4198                         }
4199
4200                         checkFn( "parentNode", part, doneName, checkSet, nodeCheck, isXML );
4201                 },
4202
4203                 "~": function( checkSet, part, isXML ) {
4204                         var nodeCheck,
4205                                 doneName = done++,
4206                                 checkFn = dirCheck;
4207
4208                         if ( typeof part === "string" && !rNonWord.test( part ) ) {
4209                                 part = part.toLowerCase();
4210                                 nodeCheck = part;
4211                                 checkFn = dirNodeCheck;
4212                         }
4213
4214                         checkFn( "previousSibling", part, doneName, checkSet, nodeCheck, isXML );
4215                 }
4216         },
4217
4218         find: {
4219                 ID: function( match, context, isXML ) {
4220                         if ( typeof context.getElementById !== "undefined" && !isXML ) {
4221                                 var m = context.getElementById(match[1]);
4222                                 // Check parentNode to catch when Blackberry 4.6 returns
4223                                 // nodes that are no longer in the document #6963
4224                                 return m && m.parentNode ? [m] : [];
4225                         }
4226                 },
4227
4228                 NAME: function( match, context ) {
4229                         if ( typeof context.getElementsByName !== "undefined" ) {
4230                                 var ret = [],
4231                                         results = context.getElementsByName( match[1] );
4232
4233                                 for ( var i = 0, l = results.length; i < l; i++ ) {
4234                                         if ( results[i].getAttribute("name") === match[1] ) {
4235                                                 ret.push( results[i] );
4236                                         }
4237                                 }
4238
4239                                 return ret.length === 0 ? null : ret;
4240                         }
4241                 },
4242
4243                 TAG: function( match, context ) {
4244                         if ( typeof context.getElementsByTagName !== "undefined" ) {
4245                                 return context.getElementsByTagName( match[1] );
4246                         }
4247                 }
4248         },
4249         preFilter: {
4250                 CLASS: function( match, curLoop, inplace, result, not, isXML ) {
4251                         match = " " + match[1].replace( rBackslash, "" ) + " ";
4252
4253                         if ( isXML ) {
4254                                 return match;
4255                         }
4256
4257                         for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) {
4258                                 if ( elem ) {
4259                                         if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n\r]/g, " ").indexOf(match) >= 0) ) {
4260                                                 if ( !inplace ) {
4261                                                         result.push( elem );
4262                                                 }
4263
4264                                         } else if ( inplace ) {
4265                                                 curLoop[i] = false;
4266                                         }
4267                                 }
4268                         }
4269
4270                         return false;
4271                 },
4272
4273                 ID: function( match ) {
4274                         return match[1].replace( rBackslash, "" );
4275                 },
4276
4277                 TAG: function( match, curLoop ) {
4278                         return match[1].replace( rBackslash, "" ).toLowerCase();
4279                 },
4280
4281                 CHILD: function( match ) {
4282                         if ( match[1] === "nth" ) {
4283                                 if ( !match[2] ) {
4284                                         Sizzle.error( match[0] );
4285                                 }
4286
4287                                 match[2] = match[2].replace(/^\+|\s*/g, '');
4288
4289                                 // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
4290                                 var test = /(-?)(\d*)(?:n([+\-]?\d*))?/.exec(
4291                                         match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" ||
4292                                         !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);
4293
4294                                 // calculate the numbers (first)n+(last) including if they are negative
4295                                 match[2] = (test[1] + (test[2] || 1)) - 0;
4296                                 match[3] = test[3] - 0;
4297                         }
4298                         else if ( match[2] ) {
4299                                 Sizzle.error( match[0] );
4300                         }
4301
4302                         // TODO: Move to normal caching system
4303                         match[0] = done++;
4304
4305                         return match;
4306                 },
4307
4308                 ATTR: function( match, curLoop, inplace, result, not, isXML ) {
4309                         var name = match[1] = match[1].replace( rBackslash, "" );
4310                         
4311                         if ( !isXML && Expr.attrMap[name] ) {
4312                                 match[1] = Expr.attrMap[name];
4313                         }
4314
4315                         // Handle if an un-quoted value was used
4316                         match[4] = ( match[4] || match[5] || "" ).replace( rBackslash, "" );
4317
4318                         if ( match[2] === "~=" ) {
4319                                 match[4] = " " + match[4] + " ";
4320                         }
4321
4322                         return match;
4323                 },
4324
4325                 PSEUDO: function( match, curLoop, inplace, result, not ) {
4326                         if ( match[1] === "not" ) {
4327                                 // If we're dealing with a complex expression, or a simple one
4328                                 if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) {
4329                                         match[3] = Sizzle(match[3], null, null, curLoop);
4330
4331                                 } else {
4332                                         var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);
4333
4334                                         if ( !inplace ) {
4335                                                 result.push.apply( result, ret );
4336                                         }
4337
4338                                         return false;
4339                                 }
4340
4341                         } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
4342                                 return true;
4343                         }
4344                         
4345                         return match;
4346                 },
4347
4348                 POS: function( match ) {
4349                         match.unshift( true );
4350
4351                         return match;
4352                 }
4353         },
4354         
4355         filters: {
4356                 enabled: function( elem ) {
4357                         return elem.disabled === false && elem.type !== "hidden";
4358                 },
4359
4360                 disabled: function( elem ) {
4361                         return elem.disabled === true;
4362                 },
4363
4364                 checked: function( elem ) {
4365                         return elem.checked === true;
4366                 },
4367                 
4368                 selected: function( elem ) {
4369                         // Accessing this property makes selected-by-default
4370                         // options in Safari work properly
4371                         if ( elem.parentNode ) {
4372                                 elem.parentNode.selectedIndex;
4373                         }
4374                         
4375                         return elem.selected === true;
4376                 },
4377
4378                 parent: function( elem ) {
4379                         return !!elem.firstChild;
4380                 },
4381
4382                 empty: function( elem ) {
4383                         return !elem.firstChild;
4384                 },
4385
4386                 has: function( elem, i, match ) {
4387                         return !!Sizzle( match[3], elem ).length;
4388                 },
4389
4390                 header: function( elem ) {
4391                         return (/h\d/i).test( elem.nodeName );
4392                 },
4393
4394                 text: function( elem ) {
4395                         var attr = elem.getAttribute( "type" ), type = elem.type;
4396                         // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc) 
4397                         // use getAttribute instead to test this case
4398                         return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null );
4399                 },
4400
4401                 radio: function( elem ) {
4402                         return elem.nodeName.toLowerCase() === "input" && "radio" === elem.type;
4403                 },
4404
4405                 checkbox: function( elem ) {
4406                         return elem.nodeName.toLowerCase() === "input" && "checkbox" === elem.type;
4407                 },
4408
4409                 file: function( elem ) {
4410                         return elem.nodeName.toLowerCase() === "input" && "file" === elem.type;
4411                 },
4412
4413                 password: function( elem ) {
4414                         return elem.nodeName.toLowerCase() === "input" && "password" === elem.type;
4415                 },
4416
4417                 submit: function( elem ) {
4418                         var name = elem.nodeName.toLowerCase();
4419                         return (name === "input" || name === "button") && "submit" === elem.type;
4420                 },
4421
4422                 image: function( elem ) {
4423                         return elem.nodeName.toLowerCase() === "input" && "image" === elem.type;
4424                 },
4425
4426                 reset: function( elem ) {
4427                         var name = elem.nodeName.toLowerCase();
4428                         return (name === "input" || name === "button") && "reset" === elem.type;
4429                 },
4430
4431                 button: function( elem ) {
4432                         var name = elem.nodeName.toLowerCase();
4433                         return name === "input" && "button" === elem.type || name === "button";
4434                 },
4435
4436                 input: function( elem ) {
4437                         return (/input|select|textarea|button/i).test( elem.nodeName );
4438                 },
4439
4440                 focus: function( elem ) {
4441                         return elem === elem.ownerDocument.activeElement;
4442                 }
4443         },
4444         setFilters: {
4445                 first: function( elem, i ) {
4446                         return i === 0;
4447                 },
4448
4449                 last: function( elem, i, match, array ) {
4450                         return i === array.length - 1;
4451                 },
4452
4453                 even: function( elem, i ) {
4454                         return i % 2 === 0;
4455                 },
4456
4457                 odd: function( elem, i ) {
4458                         return i % 2 === 1;
4459                 },
4460
4461                 lt: function( elem, i, match ) {
4462                         return i < match[3] - 0;
4463                 },
4464
4465                 gt: function( elem, i, match ) {
4466                         return i > match[3] - 0;
4467                 },
4468
4469                 nth: function( elem, i, match ) {
4470                         return match[3] - 0 === i;
4471                 },
4472
4473                 eq: function( elem, i, match ) {
4474                         return match[3] - 0 === i;
4475                 }
4476         },
4477         filter: {
4478                 PSEUDO: function( elem, match, i, array ) {
4479                         var name = match[1],
4480                                 filter = Expr.filters[ name ];
4481
4482                         if ( filter ) {
4483                                 return filter( elem, i, match, array );
4484
4485                         } else if ( name === "contains" ) {
4486                                 return (elem.textContent || elem.innerText || Sizzle.getText([ elem ]) || "").indexOf(match[3]) >= 0;
4487
4488                         } else if ( name === "not" ) {
4489                                 var not = match[3];
4490
4491                                 for ( var j = 0, l = not.length; j < l; j++ ) {
4492                                         if ( not[j] === elem ) {
4493                                                 return false;
4494                                         }
4495                                 }
4496
4497                                 return true;
4498
4499                         } else {
4500                                 Sizzle.error( name );
4501                         }
4502                 },
4503
4504                 CHILD: function( elem, match ) {
4505                         var type = match[1],
4506                                 node = elem;
4507
4508                         switch ( type ) {
4509                                 case "only":
4510                                 case "first":
4511                                         while ( (node = node.previousSibling) )  {
4512                                                 if ( node.nodeType === 1 ) { 
4513                                                         return false; 
4514                                                 }
4515                                         }
4516
4517                                         if ( type === "first" ) { 
4518                                                 return true; 
4519                                         }
4520
4521                                         node = elem;
4522
4523                                 case "last":
4524                                         while ( (node = node.nextSibling) )      {
4525                                                 if ( node.nodeType === 1 ) { 
4526                                                         return false; 
4527                                                 }
4528                                         }
4529
4530                                         return true;
4531
4532                                 case "nth":
4533                                         var first = match[2],
4534                                                 last = match[3];
4535
4536                                         if ( first === 1 && last === 0 ) {
4537                                                 return true;
4538                                         }
4539                                         
4540                                         var doneName = match[0],
4541                                                 parent = elem.parentNode;
4542         
4543                                         if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) {
4544                                                 var count = 0;
4545                                                 
4546                                                 for ( node = parent.firstChild; node; node = node.nextSibling ) {
4547                                                         if ( node.nodeType === 1 ) {
4548                                                                 node.nodeIndex = ++count;
4549                                                         }
4550                                                 } 
4551
4552                                                 parent.sizcache = doneName;
4553                                         }
4554                                         
4555                                         var diff = elem.nodeIndex - last;
4556
4557                                         if ( first === 0 ) {
4558                                                 return diff === 0;
4559
4560                                         } else {
4561                                                 return ( diff % first === 0 && diff / first >= 0 );
4562                                         }
4563                         }
4564                 },
4565
4566                 ID: function( elem, match ) {
4567                         return elem.nodeType === 1 && elem.getAttribute("id") === match;
4568                 },
4569
4570                 TAG: function( elem, match ) {
4571                         return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match;
4572                 },
4573                 
4574                 CLASS: function( elem, match ) {
4575                         return (" " + (elem.className || elem.getAttribute("class")) + " ")
4576                                 .indexOf( match ) > -1;
4577                 },
4578
4579                 ATTR: function( elem, match ) {
4580                         var name = match[1],
4581                                 result = Expr.attrHandle[ name ] ?
4582                                         Expr.attrHandle[ name ]( elem ) :
4583                                         elem[ name ] != null ?
4584                                                 elem[ name ] :
4585                                                 elem.getAttribute( name ),
4586                                 value = result + "",
4587                                 type = match[2],
4588                                 check = match[4];
4589
4590                         return result == null ?
4591                                 type === "!=" :
4592                                 type === "=" ?
4593                                 value === check :
4594                                 type === "*=" ?
4595                                 value.indexOf(check) >= 0 :
4596                                 type === "~=" ?
4597                                 (" " + value + " ").indexOf(check) >= 0 :
4598                                 !check ?
4599                                 value && result !== false :
4600                                 type === "!=" ?
4601                                 value !== check :
4602                                 type === "^=" ?
4603                                 value.indexOf(check) === 0 :
4604                                 type === "$=" ?
4605                                 value.substr(value.length - check.length) === check :
4606                                 type === "|=" ?
4607                                 value === check || value.substr(0, check.length + 1) === check + "-" :
4608                                 false;
4609                 },
4610
4611                 POS: function( elem, match, i, array ) {
4612                         var name = match[2],
4613                                 filter = Expr.setFilters[ name ];
4614
4615                         if ( filter ) {
4616                                 return filter( elem, i, match, array );
4617                         }
4618                 }
4619         }
4620 };
4621
4622 var origPOS = Expr.match.POS,
4623         fescape = function(all, num){
4624                 return "\\" + (num - 0 + 1);
4625         };
4626
4627 for ( var type in Expr.match ) {
4628         Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) );
4629         Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) );
4630 }
4631
4632 var makeArray = function( array, results ) {
4633         array = Array.prototype.slice.call( array, 0 );
4634
4635         if ( results ) {
4636                 results.push.apply( results, array );
4637                 return results;
4638         }
4639         
4640         return array;
4641 };
4642
4643 // Perform a simple check to determine if the browser is capable of
4644 // converting a NodeList to an array using builtin methods.
4645 // Also verifies that the returned array holds DOM nodes
4646 // (which is not the case in the Blackberry browser)
4647 try {
4648         Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType;
4649
4650 // Provide a fallback method if it does not work
4651 } catch( e ) {
4652         makeArray = function( array, results ) {
4653                 var i = 0,
4654                         ret = results || [];
4655
4656                 if ( toString.call(array) === "[object Array]" ) {
4657                         Array.prototype.push.apply( ret, array );
4658
4659                 } else {
4660                         if ( typeof array.length === "number" ) {
4661                                 for ( var l = array.length; i < l; i++ ) {
4662                                         ret.push( array[i] );
4663                                 }
4664
4665                         } else {
4666                                 for ( ; array[i]; i++ ) {
4667                                         ret.push( array[i] );
4668                                 }
4669                         }
4670                 }
4671
4672                 return ret;
4673         };
4674 }
4675
4676 var sortOrder, siblingCheck;
4677
4678 if ( document.documentElement.compareDocumentPosition ) {
4679         sortOrder = function( a, b ) {
4680                 if ( a === b ) {
4681                         hasDuplicate = true;
4682                         return 0;
4683                 }
4684
4685                 if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) {
4686                         return a.compareDocumentPosition ? -1 : 1;
4687                 }
4688
4689                 return a.compareDocumentPosition(b) & 4 ? -1 : 1;
4690         };
4691
4692 } else {
4693         sortOrder = function( a, b ) {
4694                 // The nodes are identical, we can exit early
4695                 if ( a === b ) {
4696                         hasDuplicate = true;
4697                         return 0;
4698
4699                 // Fallback to using sourceIndex (in IE) if it's available on both nodes
4700                 } else if ( a.sourceIndex && b.sourceIndex ) {
4701                         return a.sourceIndex - b.sourceIndex;
4702                 }
4703
4704                 var al, bl,
4705                         ap = [],
4706                         bp = [],
4707                         aup = a.parentNode,
4708                         bup = b.parentNode,
4709                         cur = aup;
4710
4711                 // If the nodes are siblings (or identical) we can do a quick check
4712                 if ( aup === bup ) {
4713                         return siblingCheck( a, b );
4714
4715                 // If no parents were found then the nodes are disconnected
4716                 } else if ( !aup ) {
4717                         return -1;
4718
4719                 } else if ( !bup ) {
4720                         return 1;
4721                 }
4722
4723                 // Otherwise they're somewhere else in the tree so we need
4724                 // to build up a full list of the parentNodes for comparison
4725                 while ( cur ) {
4726                         ap.unshift( cur );
4727                         cur = cur.parentNode;
4728                 }
4729
4730                 cur = bup;
4731
4732                 while ( cur ) {
4733                         bp.unshift( cur );
4734                         cur = cur.parentNode;
4735                 }
4736
4737                 al = ap.length;
4738                 bl = bp.length;
4739
4740                 // Start walking down the tree looking for a discrepancy
4741                 for ( var i = 0; i < al && i < bl; i++ ) {
4742                         if ( ap[i] !== bp[i] ) {
4743                                 return siblingCheck( ap[i], bp[i] );
4744                         }
4745                 }
4746
4747                 // We ended someplace up the tree so do a sibling check
4748                 return i === al ?
4749                         siblingCheck( a, bp[i], -1 ) :
4750                         siblingCheck( ap[i], b, 1 );
4751         };
4752
4753         siblingCheck = function( a, b, ret ) {
4754                 if ( a === b ) {
4755                         return ret;
4756                 }
4757
4758                 var cur = a.nextSibling;
4759
4760                 while ( cur ) {
4761                         if ( cur === b ) {
4762                                 return -1;
4763                         }
4764
4765                         cur = cur.nextSibling;
4766                 }
4767
4768                 return 1;
4769         };
4770 }
4771
4772 // Utility function for retreiving the text value of an array of DOM nodes
4773 Sizzle.getText = function( elems ) {
4774         var ret = "", elem;
4775
4776         for ( var i = 0; elems[i]; i++ ) {
4777                 elem = elems[i];
4778
4779                 // Get the text from text nodes and CDATA nodes
4780                 if ( elem.nodeType === 3 || elem.nodeType === 4 ) {
4781                         ret += elem.nodeValue;
4782
4783                 // Traverse everything else, except comment nodes
4784                 } else if ( elem.nodeType !== 8 ) {
4785                         ret += Sizzle.getText( elem.childNodes );
4786                 }
4787         }
4788
4789         return ret;
4790 };
4791
4792 // Check to see if the browser returns elements by name when
4793 // querying by getElementById (and provide a workaround)
4794 (function(){
4795         // We're going to inject a fake input element with a specified name
4796         var form = document.createElement("div"),
4797                 id = "script" + (new Date()).getTime(),
4798                 root = document.documentElement;
4799
4800         form.innerHTML = "<a name='" + id + "'/>";
4801
4802         // Inject it into the root element, check its status, and remove it quickly
4803         root.insertBefore( form, root.firstChild );
4804
4805         // The workaround has to do additional checks after a getElementById
4806         // Which slows things down for other browsers (hence the branching)
4807         if ( document.getElementById( id ) ) {
4808                 Expr.find.ID = function( match, context, isXML ) {
4809                         if ( typeof context.getElementById !== "undefined" && !isXML ) {
4810                                 var m = context.getElementById(match[1]);
4811
4812                                 return m ?
4813                                         m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ?
4814                                                 [m] :
4815                                                 undefined :
4816                                         [];
4817                         }
4818                 };
4819
4820                 Expr.filter.ID = function( elem, match ) {
4821                         var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
4822
4823                         return elem.nodeType === 1 && node && node.nodeValue === match;
4824                 };
4825         }
4826
4827         root.removeChild( form );
4828
4829         // release memory in IE
4830         root = form = null;
4831 })();
4832
4833 (function(){
4834         // Check to see if the browser returns only elements
4835         // when doing getElementsByTagName("*")
4836
4837         // Create a fake element
4838         var div = document.createElement("div");
4839         div.appendChild( document.createComment("") );
4840
4841         // Make sure no comments are found
4842         if ( div.getElementsByTagName("*").length > 0 ) {
4843                 Expr.find.TAG = function( match, context ) {
4844                         var results = context.getElementsByTagName( match[1] );
4845
4846                         // Filter out possible comments
4847                         if ( match[1] === "*" ) {
4848                                 var tmp = [];
4849
4850                                 for ( var i = 0; results[i]; i++ ) {
4851                                         if ( results[i].nodeType === 1 ) {
4852                                                 tmp.push( results[i] );
4853                                         }
4854                                 }
4855
4856                                 results = tmp;
4857                         }
4858
4859                         return results;
4860                 };
4861         }
4862
4863         // Check to see if an attribute returns normalized href attributes
4864         div.innerHTML = "<a href='#'></a>";
4865
4866         if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" &&
4867                         div.firstChild.getAttribute("href") !== "#" ) {
4868
4869                 Expr.attrHandle.href = function( elem ) {
4870                         return elem.getAttribute( "href", 2 );
4871                 };
4872         }
4873
4874         // release memory in IE
4875         div = null;
4876 })();
4877
4878 if ( document.querySelectorAll ) {
4879         (function(){
4880                 var oldSizzle = Sizzle,
4881                         div = document.createElement("div"),
4882                         id = "__sizzle__";
4883
4884                 div.innerHTML = "<p class='TEST'></p>";
4885
4886                 // Safari can't handle uppercase or unicode characters when
4887                 // in quirks mode.
4888                 if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
4889                         return;
4890                 }
4891         
4892                 Sizzle = function( query, context, extra, seed ) {
4893                         context = context || document;
4894
4895                         // Only use querySelectorAll on non-XML documents
4896                         // (ID selectors don't work in non-HTML documents)
4897                         if ( !seed && !Sizzle.isXML(context) ) {
4898                                 // See if we find a selector to speed up
4899                                 var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query );
4900                                 
4901                                 if ( match && (context.nodeType === 1 || context.nodeType === 9) ) {
4902                                         // Speed-up: Sizzle("TAG")
4903                                         if ( match[1] ) {
4904                                                 return makeArray( context.getElementsByTagName( query ), extra );
4905                                         
4906                                         // Speed-up: Sizzle(".CLASS")
4907                                         } else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) {
4908                                                 return makeArray( context.getElementsByClassName( match[2] ), extra );
4909                                         }
4910                                 }
4911                                 
4912                                 if ( context.nodeType === 9 ) {
4913                                         // Speed-up: Sizzle("body")
4914                                         // The body element only exists once, optimize finding it
4915                                         if ( query === "body" && context.body ) {
4916                                                 return makeArray( [ context.body ], extra );
4917                                                 
4918                                         // Speed-up: Sizzle("#ID")
4919                                         } else if ( match && match[3] ) {
4920                                                 var elem = context.getElementById( match[3] );
4921
4922                                                 // Check parentNode to catch when Blackberry 4.6 returns
4923                                                 // nodes that are no longer in the document #6963
4924                                                 if ( elem && elem.parentNode ) {
4925                                                         // Handle the case where IE and Opera return items
4926                                                         // by name instead of ID
4927                                                         if ( elem.id === match[3] ) {
4928                                                                 return makeArray( [ elem ], extra );
4929                                                         }
4930                                                         
4931                                                 } else {
4932                                                         return makeArray( [], extra );
4933                                                 }
4934                                         }
4935                                         
4936                                         try {
4937                                                 return makeArray( context.querySelectorAll(query), extra );
4938                                         } catch(qsaError) {}
4939
4940                                 // qSA works strangely on Element-rooted queries
4941                                 // We can work around this by specifying an extra ID on the root
4942                                 // and working up from there (Thanks to Andrew Dupont for the technique)
4943                                 // IE 8 doesn't work on object elements
4944                                 } else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
4945                                         var oldContext = context,
4946                                                 old = context.getAttribute( "id" ),
4947                                                 nid = old || id,
4948                                                 hasParent = context.parentNode,
4949                                                 relativeHierarchySelector = /^\s*[+~]/.test( query );
4950
4951                                         if ( !old ) {
4952                                                 context.setAttribute( "id", nid );
4953                                         } else {
4954                                                 nid = nid.replace( /'/g, "\\$&" );
4955                                         }
4956                                         if ( relativeHierarchySelector && hasParent ) {
4957                                                 context = context.parentNode;
4958                                         }
4959
4960                                         try {
4961                                                 if ( !relativeHierarchySelector || hasParent ) {
4962                                                         return makeArray( context.querySelectorAll( "[id='" + nid + "'] " + query ), extra );
4963                                                 }
4964
4965                                         } catch(pseudoError) {
4966                                         } finally {
4967                                                 if ( !old ) {
4968                                                         oldContext.removeAttribute( "id" );
4969                                                 }
4970                                         }
4971                                 }
4972                         }
4973                 
4974                         return oldSizzle(query, context, extra, seed);
4975                 };
4976
4977                 for ( var prop in oldSizzle ) {
4978                         Sizzle[ prop ] = oldSizzle[ prop ];
4979                 }
4980
4981                 // release memory in IE
4982                 div = null;
4983         })();
4984 }
4985
4986 (function(){
4987         var html = document.documentElement,
4988                 matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector;
4989
4990         if ( matches ) {
4991                 // Check to see if it's possible to do matchesSelector
4992                 // on a disconnected node (IE 9 fails this)
4993                 var disconnectedMatch = !matches.call( document.createElement( "div" ), "div" ),
4994                         pseudoWorks = false;
4995
4996                 try {
4997                         // This should fail with an exception
4998                         // Gecko does not error, returns false instead
4999                         matches.call( document.documentElement, "[test!='']:sizzle" );
5000         
5001                 } catch( pseudoError ) {
5002                         pseudoWorks = true;
5003                 }
5004
5005                 Sizzle.matchesSelector = function( node, expr ) {
5006                         // Make sure that attribute selectors are quoted
5007                         expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']");
5008
5009                         if ( !Sizzle.isXML( node ) ) {
5010                                 try { 
5011                                         if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) {
5012                                                 var ret = matches.call( node, expr );
5013
5014                                                 // IE 9's matchesSelector returns false on disconnected nodes
5015                                                 if ( ret || !disconnectedMatch ||
5016                                                                 // As well, disconnected nodes are said to be in a document
5017                                                                 // fragment in IE 9, so check for that
5018                                                                 node.document && node.document.nodeType !== 11 ) {
5019                                                         return ret;
5020                                                 }
5021                                         }
5022                                 } catch(e) {}
5023                         }
5024
5025                         return Sizzle(expr, null, null, [node]).length > 0;
5026                 };
5027         }
5028 })();
5029
5030 (function(){
5031         var div = document.createElement("div");
5032
5033         div.innerHTML = "<div class='test e'></div><div class='test'></div>";
5034
5035         // Opera can't find a second classname (in 9.6)
5036         // Also, make sure that getElementsByClassName actually exists
5037         if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) {
5038                 return;
5039         }
5040
5041         // Safari caches class attributes, doesn't catch changes (in 3.2)
5042         div.lastChild.className = "e";
5043
5044         if ( div.getElementsByClassName("e").length === 1 ) {
5045                 return;
5046         }
5047         
5048         Expr.order.splice(1, 0, "CLASS");
5049         Expr.find.CLASS = function( match, context, isXML ) {
5050                 if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
5051                         return context.getElementsByClassName(match[1]);
5052                 }
5053         };
5054
5055         // release memory in IE
5056         div = null;
5057 })();
5058
5059 function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
5060         for ( var i = 0, l = checkSet.length; i < l; i++ ) {
5061                 var elem = checkSet[i];
5062
5063                 if ( elem ) {
5064                         var match = false;
5065
5066                         elem = elem[dir];
5067
5068                         while ( elem ) {
5069                                 if ( elem.sizcache === doneName ) {
5070                                         match = checkSet[elem.sizset];
5071                                         break;
5072                                 }
5073
5074                                 if ( elem.nodeType === 1 && !isXML ){
5075                                         elem.sizcache = doneName;
5076                                         elem.sizset = i;
5077                                 }
5078
5079                                 if ( elem.nodeName.toLowerCase() === cur ) {
5080                                         match = elem;
5081                                         break;
5082                                 }
5083
5084                                 elem = elem[dir];
5085                         }
5086
5087                         checkSet[i] = match;
5088                 }
5089         }
5090 }
5091
5092 function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
5093         for ( var i = 0, l = checkSet.length; i < l; i++ ) {
5094                 var elem = checkSet[i];
5095
5096                 if ( elem ) {
5097                         var match = false;
5098                         
5099                         elem = elem[dir];
5100
5101                         while ( elem ) {
5102                                 if ( elem.sizcache === doneName ) {
5103                                         match = checkSet[elem.sizset];
5104                                         break;
5105                                 }
5106
5107                                 if ( elem.nodeType === 1 ) {
5108                                         if ( !isXML ) {
5109                                                 elem.sizcache = doneName;
5110                                                 elem.sizset = i;
5111                                         }
5112
5113                                         if ( typeof cur !== "string" ) {
5114                                                 if ( elem === cur ) {
5115                                                         match = true;
5116                                                         break;
5117                                                 }
5118
5119                                         } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) {
5120                                                 match = elem;
5121                                                 break;
5122                                         }
5123                                 }
5124
5125                                 elem = elem[dir];
5126                         }
5127
5128                         checkSet[i] = match;
5129                 }
5130         }
5131 }
5132
5133 if ( document.documentElement.contains ) {
5134         Sizzle.contains = function( a, b ) {
5135                 return a !== b && (a.contains ? a.contains(b) : true);
5136         };
5137
5138 } else if ( document.documentElement.compareDocumentPosition ) {
5139         Sizzle.contains = function( a, b ) {
5140                 return !!(a.compareDocumentPosition(b) & 16);
5141         };
5142
5143 } else {
5144         Sizzle.contains = function() {
5145                 return false;
5146         };
5147 }
5148
5149 Sizzle.isXML = function( elem ) {
5150         // documentElement is verified for cases where it doesn't yet exist
5151         // (such as loading iframes in IE - #4833) 
5152         var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;
5153
5154         return documentElement ? documentElement.nodeName !== "HTML" : false;
5155 };
5156
5157 var posProcess = function( selector, context ) {
5158         var match,
5159                 tmpSet = [],
5160                 later = "",
5161                 root = context.nodeType ? [context] : context;
5162
5163         // Position selectors must be done after the filter
5164         // And so must :not(positional) so we move all PSEUDOs to the end
5165         while ( (match = Expr.match.PSEUDO.exec( selector )) ) {
5166                 later += match[0];
5167                 selector = selector.replace( Expr.match.PSEUDO, "" );
5168         }
5169
5170         selector = Expr.relative[selector] ? selector + "*" : selector;
5171
5172         for ( var i = 0, l = root.length; i < l; i++ ) {
5173                 Sizzle( selector, root[i], tmpSet );
5174         }
5175
5176         return Sizzle.filter( later, tmpSet );
5177 };
5178
5179 // EXPOSE
5180 jQuery.find = Sizzle;
5181 jQuery.expr = Sizzle.selectors;
5182 jQuery.expr[":"] = jQuery.expr.filters;
5183 jQuery.unique = Sizzle.uniqueSort;
5184 jQuery.text = Sizzle.getText;
5185 jQuery.isXMLDoc = Sizzle.isXML;
5186 jQuery.contains = Sizzle.contains;
5187
5188
5189 })();
5190
5191
5192 var runtil = /Until$/,
5193         rparentsprev = /^(?:parents|prevUntil|prevAll)/,
5194         // Note: This RegExp should be improved, or likely pulled from Sizzle
5195         rmultiselector = /,/,
5196         isSimple = /^.[^:#\[\.,]*$/,
5197         slice = Array.prototype.slice,
5198         POS = jQuery.expr.match.POS,
5199         // methods guaranteed to produce a unique set when starting from a unique set
5200         guaranteedUnique = {
5201                 children: true,
5202                 contents: true,
5203                 next: true,
5204                 prev: true
5205         };
5206
5207 jQuery.fn.extend({
5208         find: function( selector ) {
5209                 var self = this,
5210                         i, l;
5211
5212                 if ( typeof selector !== "string" ) {
5213                         return jQuery( selector ).filter(function() {
5214                                 for ( i = 0, l = self.length; i < l; i++ ) {
5215                                         if ( jQuery.contains( self[ i ], this ) ) {
5216                                                 return true;
5217                                         }
5218                                 }
5219                         });
5220                 }
5221
5222                 var ret = this.pushStack( "", "find", selector ),
5223                         length, n, r;
5224
5225                 for ( i = 0, l = this.length; i < l; i++ ) {
5226                         length = ret.length;
5227                         jQuery.find( selector, this[i], ret );
5228
5229                         if ( i > 0 ) {
5230                                 // Make sure that the results are unique
5231                                 for ( n = length; n < ret.length; n++ ) {
5232                                         for ( r = 0; r < length; r++ ) {
5233                                                 if ( ret[r] === ret[n] ) {
5234                                                         ret.splice(n--, 1);
5235                                                         break;
5236                                                 }
5237                                         }
5238                                 }
5239                         }
5240                 }
5241
5242                 return ret;
5243         },
5244
5245         has: function( target ) {
5246                 var targets = jQuery( target );
5247                 return this.filter(function() {
5248                         for ( var i = 0, l = targets.length; i < l; i++ ) {
5249                                 if ( jQuery.contains( this, targets[i] ) ) {
5250                                         return true;
5251                                 }
5252                         }
5253                 });
5254         },
5255
5256         not: function( selector ) {
5257                 return this.pushStack( winnow(this, selector, false), "not", selector);
5258         },
5259
5260         filter: function( selector ) {
5261                 return this.pushStack( winnow(this, selector, true), "filter", selector );
5262         },
5263
5264         is: function( selector ) {
5265                 return !!selector && ( typeof selector === "string" ?
5266                         jQuery.filter( selector, this ).length > 0 :
5267                         this.filter( selector ).length > 0 );
5268         },
5269
5270         closest: function( selectors, context ) {
5271                 var ret = [], i, l, cur = this[0];
5272                 
5273                 // Array
5274                 if ( jQuery.isArray( selectors ) ) {
5275                         var match, selector,
5276                                 matches = {},
5277                                 level = 1;
5278
5279                         if ( cur && selectors.length ) {
5280                                 for ( i = 0, l = selectors.length; i < l; i++ ) {
5281                                         selector = selectors[i];
5282
5283                                         if ( !matches[ selector ] ) {
5284                                                 matches[ selector ] = POS.test( selector ) ?
5285                                                         jQuery( selector, context || this.context ) :
5286                                                         selector;
5287                                         }
5288                                 }
5289
5290                                 while ( cur && cur.ownerDocument && cur !== context ) {
5291                                         for ( selector in matches ) {
5292                                                 match = matches[ selector ];
5293
5294                                                 if ( match.jquery ? match.index( cur ) > -1 : jQuery( cur ).is( match ) ) {
5295                                                         ret.push({ selector: selector, elem: cur, level: level });
5296                                                 }
5297                                         }
5298
5299                                         cur = cur.parentNode;
5300                                         level++;
5301                                 }
5302                         }
5303
5304                         return ret;
5305                 }
5306
5307                 // String
5308                 var pos = POS.test( selectors ) || typeof selectors !== "string" ?
5309                                 jQuery( selectors, context || this.context ) :
5310                                 0;
5311
5312                 for ( i = 0, l = this.length; i < l; i++ ) {
5313                         cur = this[i];
5314
5315                         while ( cur ) {
5316                                 if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) {
5317                                         ret.push( cur );
5318                                         break;
5319
5320                                 } else {
5321                                         cur = cur.parentNode;
5322                                         if ( !cur || !cur.ownerDocument || cur === context || cur.nodeType === 11 ) {
5323                                                 break;
5324                                         }
5325                                 }
5326                         }
5327                 }
5328
5329                 ret = ret.length > 1 ? jQuery.unique( ret ) : ret;
5330
5331                 return this.pushStack( ret, "closest", selectors );
5332         },
5333
5334         // Determine the position of an element within
5335         // the matched set of elements
5336         index: function( elem ) {
5337
5338                 // No argument, return index in parent
5339                 if ( !elem ) {
5340                         return ( this[0] && this[0].parentNode ) ? this.prevAll().length : -1;
5341                 }
5342
5343                 // index in selector
5344                 if ( typeof elem === "string" ) {
5345                         return jQuery.inArray( this[0], jQuery( elem ) );
5346                 }
5347
5348                 // Locate the position of the desired element
5349                 return jQuery.inArray(
5350                         // If it receives a jQuery object, the first element is used
5351                         elem.jquery ? elem[0] : elem, this );
5352         },
5353
5354         add: function( selector, context ) {
5355                 var set = typeof selector === "string" ?
5356                                 jQuery( selector, context ) :
5357                                 jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ),
5358                         all = jQuery.merge( this.get(), set );
5359
5360                 return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?
5361                         all :
5362                         jQuery.unique( all ) );
5363         },
5364
5365         andSelf: function() {
5366                 return this.add( this.prevObject );
5367         }
5368 });
5369
5370 // A painfully simple check to see if an element is disconnected
5371 // from a document (should be improved, where feasible).
5372 function isDisconnected( node ) {
5373         return !node || !node.parentNode || node.parentNode.nodeType === 11;
5374 }
5375
5376 jQuery.each({
5377         parent: function( elem ) {
5378                 var parent = elem.parentNode;
5379                 return parent && parent.nodeType !== 11 ? parent : null;
5380         },
5381         parents: function( elem ) {
5382                 return jQuery.dir( elem, "parentNode" );
5383         },
5384         parentsUntil: function( elem, i, until ) {
5385                 return jQuery.dir( elem, "parentNode", until );
5386         },
5387         next: function( elem ) {
5388                 return jQuery.nth( elem, 2, "nextSibling" );
5389         },
5390         prev: function( elem ) {
5391                 return jQuery.nth( elem, 2, "previousSibling" );
5392         },
5393         nextAll: function( elem ) {
5394                 return jQuery.dir( elem, "nextSibling" );
5395         },
5396         prevAll: function( elem ) {
5397                 return jQuery.dir( elem, "previousSibling" );
5398         },
5399         nextUntil: function( elem, i, until ) {
5400                 return jQuery.dir( elem, "nextSibling", until );
5401         },
5402         prevUntil: function( elem, i, until ) {
5403                 return jQuery.dir( elem, "previousSibling", until );
5404         },
5405         siblings: function( elem ) {
5406                 return jQuery.sibling( elem.parentNode.firstChild, elem );
5407         },
5408         children: function( elem ) {
5409                 return jQuery.sibling( elem.firstChild );
5410         },
5411         contents: function( elem ) {
5412                 return jQuery.nodeName( elem, "iframe" ) ?
5413                         elem.contentDocument || elem.contentWindow.document :
5414                         jQuery.makeArray( elem.childNodes );
5415         }
5416 }, function( name, fn ) {
5417         jQuery.fn[ name ] = function( until, selector ) {
5418                 var ret = jQuery.map( this, fn, until ),
5419                         // The variable 'args' was introduced in
5420                         // https://github.com/jquery/jquery/commit/52a0238
5421                         // to work around a bug in Chrome 10 (Dev) and should be removed when the bug is fixed.
5422                         // http://code.google.com/p/v8/issues/detail?id=1050
5423                         args = slice.call(arguments);
5424
5425                 if ( !runtil.test( name ) ) {
5426                         selector = until;
5427                 }
5428
5429                 if ( selector && typeof selector === "string" ) {
5430                         ret = jQuery.filter( selector, ret );
5431                 }
5432
5433                 ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret;
5434
5435                 if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) {
5436                         ret = ret.reverse();
5437                 }
5438
5439                 return this.pushStack( ret, name, args.join(",") );
5440         };
5441 });
5442
5443 jQuery.extend({
5444         filter: function( expr, elems, not ) {
5445                 if ( not ) {
5446                         expr = ":not(" + expr + ")";
5447                 }
5448
5449                 return elems.length === 1 ?
5450                         jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] :
5451                         jQuery.find.matches(expr, elems);
5452         },
5453
5454         dir: function( elem, dir, until ) {
5455                 var matched = [],
5456                         cur = elem[ dir ];
5457
5458                 while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
5459                         if ( cur.nodeType === 1 ) {
5460                                 matched.push( cur );
5461                         }
5462                         cur = cur[dir];
5463                 }
5464                 return matched;
5465         },
5466
5467         nth: function( cur, result, dir, elem ) {
5468                 result = result || 1;
5469                 var num = 0;
5470
5471                 for ( ; cur; cur = cur[dir] ) {
5472                         if ( cur.nodeType === 1 && ++num === result ) {
5473                                 break;
5474                         }
5475                 }
5476
5477                 return cur;
5478         },
5479
5480         sibling: function( n, elem ) {
5481                 var r = [];
5482
5483                 for ( ; n; n = n.nextSibling ) {
5484                         if ( n.nodeType === 1 && n !== elem ) {
5485                                 r.push( n );
5486                         }
5487                 }
5488
5489                 return r;
5490         }
5491 });
5492
5493 // Implement the identical functionality for filter and not
5494 function winnow( elements, qualifier, keep ) {
5495
5496         // Can't pass null or undefined to indexOf in Firefox 4
5497         // Set to 0 to skip string check
5498         qualifier = qualifier || 0;
5499
5500         if ( jQuery.isFunction( qualifier ) ) {
5501                 return jQuery.grep(elements, function( elem, i ) {
5502                         var retVal = !!qualifier.call( elem, i, elem );
5503                         return retVal === keep;
5504                 });
5505
5506         } else if ( qualifier.nodeType ) {
5507                 return jQuery.grep(elements, function( elem, i ) {
5508                         return (elem === qualifier) === keep;
5509                 });
5510
5511         } else if ( typeof qualifier === "string" ) {
5512                 var filtered = jQuery.grep(elements, function( elem ) {
5513                         return elem.nodeType === 1;
5514                 });
5515
5516                 if ( isSimple.test( qualifier ) ) {
5517                         return jQuery.filter(qualifier, filtered, !keep);
5518                 } else {
5519                         qualifier = jQuery.filter( qualifier, filtered );
5520                 }
5521         }
5522
5523         return jQuery.grep(elements, function( elem, i ) {
5524                 return (jQuery.inArray( elem, qualifier ) >= 0) === keep;
5525         });
5526 }
5527
5528
5529
5530
5531 var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
5532         rleadingWhitespace = /^\s+/,
5533         rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,
5534         rtagName = /<([\w:]+)/,
5535         rtbody = /<tbody/i,
5536         rhtml = /<|&#?\w+;/,
5537         rnocache = /<(?:script|object|embed|option|style)/i,
5538         // checked="checked" or checked
5539         rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
5540         rscriptType = /\/(java|ecma)script/i,
5541         rcleanScript = /^\s*<!(?:\[CDATA\[|\-\-)/,
5542         wrapMap = {
5543                 option: [ 1, "<select multiple='multiple'>", "</select>" ],
5544                 legend: [ 1, "<fieldset>", "</fieldset>" ],
5545                 thead: [ 1, "<table>", "</table>" ],
5546                 tr: [ 2, "<table><tbody>", "</tbody></table>" ],
5547                 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
5548                 col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
5549                 area: [ 1, "<map>", "</map>" ],
5550                 _default: [ 0, "", "" ]
5551         };
5552
5553 wrapMap.optgroup = wrapMap.option;
5554 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
5555 wrapMap.th = wrapMap.td;
5556
5557 // IE can't serialize <link> and <script> tags normally
5558 if ( !jQuery.support.htmlSerialize ) {
5559         wrapMap._default = [ 1, "div<div>", "</div>" ];
5560 }
5561
5562 jQuery.fn.extend({
5563         text: function( text ) {
5564                 if ( jQuery.isFunction(text) ) {
5565                         return this.each(function(i) {
5566                                 var self = jQuery( this );
5567
5568                                 self.text( text.call(this, i, self.text()) );
5569                         });
5570                 }
5571
5572                 if ( typeof text !== "object" && text !== undefined ) {
5573                         return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
5574                 }
5575
5576                 return jQuery.text( this );
5577         },
5578
5579         wrapAll: function( html ) {
5580                 if ( jQuery.isFunction( html ) ) {
5581                         return this.each(function(i) {
5582                                 jQuery(this).wrapAll( html.call(this, i) );
5583                         });
5584                 }
5585
5586                 if ( this[0] ) {
5587                         // The elements to wrap the target around
5588                         var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
5589
5590                         if ( this[0].parentNode ) {
5591                                 wrap.insertBefore( this[0] );
5592                         }
5593
5594                         wrap.map(function() {
5595                                 var elem = this;
5596
5597                                 while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
5598                                         elem = elem.firstChild;
5599                                 }
5600
5601                                 return elem;
5602                         }).append( this );
5603                 }
5604
5605                 return this;
5606         },
5607
5608         wrapInner: function( html ) {
5609                 if ( jQuery.isFunction( html ) ) {
5610                         return this.each(function(i) {
5611                                 jQuery(this).wrapInner( html.call(this, i) );
5612                         });
5613                 }
5614
5615                 return this.each(function() {
5616                         var self = jQuery( this ),
5617                                 contents = self.contents();
5618
5619                         if ( contents.length ) {
5620                                 contents.wrapAll( html );
5621
5622                         } else {
5623                                 self.append( html );
5624                         }
5625                 });
5626         },
5627
5628         wrap: function( html ) {
5629                 return this.each(function() {
5630                         jQuery( this ).wrapAll( html );
5631                 });
5632         },
5633
5634         unwrap: function() {
5635                 return this.parent().each(function() {
5636                         if ( !jQuery.nodeName( this, "body" ) ) {
5637                                 jQuery( this ).replaceWith( this.childNodes );
5638                         }
5639                 }).end();
5640         },
5641
5642         append: function() {
5643                 return this.domManip(arguments, true, function( elem ) {
5644                         if ( this.nodeType === 1 ) {
5645                                 this.appendChild( elem );
5646                         }
5647                 });
5648         },
5649
5650         prepend: function() {
5651                 return this.domManip(arguments, true, function( elem ) {
5652                         if ( this.nodeType === 1 ) {
5653                                 this.insertBefore( elem, this.firstChild );
5654                         }
5655                 });
5656         },
5657
5658         before: function() {
5659                 if ( this[0] && this[0].parentNode ) {
5660                         return this.domManip(arguments, false, function( elem ) {
5661                                 this.parentNode.insertBefore( elem, this );
5662                         });
5663                 } else if ( arguments.length ) {
5664                         var set = jQuery(arguments[0]);
5665                         set.push.apply( set, this.toArray() );
5666                         return this.pushStack( set, "before", arguments );
5667                 }
5668         },
5669
5670         after: function() {
5671                 if ( this[0] && this[0].parentNode ) {
5672                         return this.domManip(arguments, false, function( elem ) {
5673                                 this.parentNode.insertBefore( elem, this.nextSibling );
5674                         });
5675                 } else if ( arguments.length ) {
5676                         var set = this.pushStack( this, "after", arguments );
5677                         set.push.apply( set, jQuery(arguments[0]).toArray() );
5678                         return set;
5679                 }
5680         },
5681
5682         // keepData is for internal use only--do not document
5683         remove: function( selector, keepData ) {
5684                 for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
5685                         if ( !selector || jQuery.filter( selector, [ elem ] ).length ) {
5686                                 if ( !keepData && elem.nodeType === 1 ) {
5687                                         jQuery.cleanData( elem.getElementsByTagName("*") );
5688                                         jQuery.cleanData( [ elem ] );
5689                                 }
5690
5691                                 if ( elem.parentNode ) {
5692                                         elem.parentNode.removeChild( elem );
5693                                 }
5694                         }
5695                 }
5696
5697                 return this;
5698         },
5699
5700         empty: function() {
5701                 for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
5702                         // Remove element nodes and prevent memory leaks
5703                         if ( elem.nodeType === 1 ) {
5704                                 jQuery.cleanData( elem.getElementsByTagName("*") );
5705                         }
5706
5707                         // Remove any remaining nodes
5708                         while ( elem.firstChild ) {
5709                                 elem.removeChild( elem.firstChild );
5710                         }
5711                 }
5712
5713                 return this;
5714         },
5715
5716         clone: function( dataAndEvents, deepDataAndEvents ) {
5717                 dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
5718                 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
5719
5720                 return this.map( function () {
5721                         return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
5722                 });
5723         },
5724
5725         html: function( value ) {
5726                 if ( value === undefined ) {
5727                         return this[0] && this[0].nodeType === 1 ?
5728                                 this[0].innerHTML.replace(rinlinejQuery, "") :
5729                                 null;
5730
5731                 // See if we can take a shortcut and just use innerHTML
5732                 } else if ( typeof value === "string" && !rnocache.test( value ) &&
5733                         (jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value )) &&
5734                         !wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) {
5735
5736                         value = value.replace(rxhtmlTag, "<$1></$2>");
5737
5738                         try {
5739                                 for ( var i = 0, l = this.length; i < l; i++ ) {
5740                                         // Remove element nodes and prevent memory leaks
5741                                         if ( this[i].nodeType === 1 ) {
5742                                                 jQuery.cleanData( this[i].getElementsByTagName("*") );
5743                                                 this[i].innerHTML = value;
5744                                         }
5745                                 }
5746
5747                         // If using innerHTML throws an exception, use the fallback method
5748                         } catch(e) {
5749                                 this.empty().append( value );
5750                         }
5751
5752                 } else if ( jQuery.isFunction( value ) ) {
5753                         this.each(function(i){
5754                                 var self = jQuery( this );
5755
5756                                 self.html( value.call(this, i, self.html()) );
5757                         });
5758
5759                 } else {
5760                         this.empty().append( value );
5761                 }
5762
5763                 return this;
5764         },
5765
5766         replaceWith: function( value ) {
5767                 if ( this[0] && this[0].parentNode ) {
5768                         // Make sure that the elements are removed from the DOM before they are inserted
5769                         // this can help fix replacing a parent with child elements
5770                         if ( jQuery.isFunction( value ) ) {
5771                                 return this.each(function(i) {
5772                                         var self = jQuery(this), old = self.html();
5773                                         self.replaceWith( value.call( this, i, old ) );
5774                                 });
5775                         }
5776
5777                         if ( typeof value !== "string" ) {
5778                                 value = jQuery( value ).detach();
5779                         }
5780
5781                         return this.each(function() {
5782                                 var next = this.nextSibling,
5783                                         parent = this.parentNode;
5784
5785                                 jQuery( this ).remove();
5786
5787                                 if ( next ) {
5788                                         jQuery(next).before( value );
5789                                 } else {
5790                                         jQuery(parent).append( value );
5791                                 }
5792                         });
5793                 } else {
5794                         return this.length ?
5795                                 this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ) :
5796                                 this;
5797                 }
5798         },
5799
5800         detach: function( selector ) {
5801                 return this.remove( selector, true );
5802         },
5803
5804         domManip: function( args, table, callback ) {
5805                 var results, first, fragment, parent,
5806                         value = args[0],
5807                         scripts = [];
5808
5809                 // We can't cloneNode fragments that contain checked, in WebKit
5810                 if ( !jQuery.support.checkClone && arguments.length === 3 && typeof value === "string" && rchecked.test( value ) ) {
5811                         return this.each(function() {
5812                                 jQuery(this).domManip( args, table, callback, true );
5813                         });
5814                 }
5815
5816                 if ( jQuery.isFunction(value) ) {
5817                         return this.each(function(i) {
5818                                 var self = jQuery(this);
5819                                 args[0] = value.call(this, i, table ? self.html() : undefined);
5820                                 self.domManip( args, table, callback );
5821                         });
5822                 }
5823
5824                 if ( this[0] ) {
5825                         parent = value && value.parentNode;
5826
5827                         // If we're in a fragment, just use that instead of building a new one
5828                         if ( jQuery.support.parentNode && parent && parent.nodeType === 11 && parent.childNodes.length === this.length ) {
5829                                 results = { fragment: parent };
5830
5831                         } else {
5832                                 results = jQuery.buildFragment( args, this, scripts );
5833                         }
5834
5835                         fragment = results.fragment;
5836
5837                         if ( fragment.childNodes.length === 1 ) {
5838                                 first = fragment = fragment.firstChild;
5839                         } else {
5840                                 first = fragment.firstChild;
5841                         }
5842
5843                         if ( first ) {
5844                                 table = table && jQuery.nodeName( first, "tr" );
5845
5846                                 for ( var i = 0, l = this.length, lastIndex = l - 1; i < l; i++ ) {
5847                                         callback.call(
5848                                                 table ?
5849                                                         root(this[i], first) :
5850                                                         this[i],
5851                                                 // Make sure that we do not leak memory by inadvertently discarding
5852                                                 // the original fragment (which might have attached data) instead of
5853                                                 // using it; in addition, use the original fragment object for the last
5854                                                 // item instead of first because it can end up being emptied incorrectly
5855                                                 // in certain situations (Bug #8070).
5856                                                 // Fragments from the fragment cache must always be cloned and never used
5857                                                 // in place.
5858                                                 results.cacheable || (l > 1 && i < lastIndex) ?
5859                                                         jQuery.clone( fragment, true, true ) :
5860                                                         fragment
5861                                         );
5862                                 }
5863                         }
5864
5865                         if ( scripts.length ) {
5866                                 jQuery.each( scripts, evalScript );
5867                         }
5868                 }
5869
5870                 return this;
5871         }
5872 });
5873
5874 function root( elem, cur ) {
5875         return jQuery.nodeName(elem, "table") ?
5876                 (elem.getElementsByTagName("tbody")[0] ||
5877                 elem.appendChild(elem.ownerDocument.createElement("tbody"))) :
5878                 elem;
5879 }
5880
5881 function cloneCopyEvent( src, dest ) {
5882
5883         if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
5884                 return;
5885         }
5886
5887         var internalKey = jQuery.expando,
5888                 oldData = jQuery.data( src ),
5889                 curData = jQuery.data( dest, oldData );
5890
5891         // Switch to use the internal data object, if it exists, for the next
5892         // stage of data copying
5893         if ( (oldData = oldData[ internalKey ]) ) {
5894                 var events = oldData.events;
5895                                 curData = curData[ internalKey ] = jQuery.extend({}, oldData);
5896
5897                 if ( events ) {
5898                         delete curData.handle;
5899                         curData.events = {};
5900
5901                         for ( var type in events ) {
5902                                 for ( var i = 0, l = events[ type ].length; i < l; i++ ) {
5903                                         jQuery.event.add( dest, type + ( events[ type ][ i ].namespace ? "." : "" ) + events[ type ][ i ].namespace, events[ type ][ i ], events[ type ][ i ].data );
5904                                 }
5905                         }
5906                 }
5907         }
5908 }
5909
5910 function cloneFixAttributes( src, dest ) {
5911         var nodeName;
5912
5913         // We do not need to do anything for non-Elements
5914         if ( dest.nodeType !== 1 ) {
5915                 return;
5916         }
5917
5918         // clearAttributes removes the attributes, which we don't want,
5919         // but also removes the attachEvent events, which we *do* want
5920         if ( dest.clearAttributes ) {
5921                 dest.clearAttributes();
5922         }
5923
5924         // mergeAttributes, in contrast, only merges back on the
5925         // original attributes, not the events
5926         if ( dest.mergeAttributes ) {
5927                 dest.mergeAttributes( src );
5928         }
5929
5930         nodeName = dest.nodeName.toLowerCase();
5931
5932         // IE6-8 fail to clone children inside object elements that use
5933         // the proprietary classid attribute value (rather than the type
5934         // attribute) to identify the type of content to display
5935         if ( nodeName === "object" ) {
5936                 dest.outerHTML = src.outerHTML;
5937
5938         } else if ( nodeName === "input" && (src.type === "checkbox" || src.type === "radio") ) {
5939                 // IE6-8 fails to persist the checked state of a cloned checkbox
5940                 // or radio button. Worse, IE6-7 fail to give the cloned element
5941                 // a checked appearance if the defaultChecked value isn't also set
5942                 if ( src.checked ) {
5943                         dest.defaultChecked = dest.checked = src.checked;
5944                 }
5945
5946                 // IE6-7 get confused and end up setting the value of a cloned
5947                 // checkbox/radio button to an empty string instead of "on"
5948                 if ( dest.value !== src.value ) {
5949                         dest.value = src.value;
5950                 }
5951
5952         // IE6-8 fails to return the selected option to the default selected
5953         // state when cloning options
5954         } else if ( nodeName === "option" ) {
5955                 dest.selected = src.defaultSelected;
5956
5957         // IE6-8 fails to set the defaultValue to the correct value when
5958         // cloning other types of input fields
5959         } else if ( nodeName === "input" || nodeName === "textarea" ) {
5960                 dest.defaultValue = src.defaultValue;
5961         }
5962
5963         // Event data gets referenced instead of copied if the expando
5964         // gets copied too
5965         dest.removeAttribute( jQuery.expando );
5966 }
5967
5968 jQuery.buildFragment = function( args, nodes, scripts ) {
5969         var fragment, cacheable, cacheresults, doc;
5970
5971   // nodes may contain either an explicit document object,
5972   // a jQuery collection or context object.
5973   // If nodes[0] contains a valid object to assign to doc
5974   if ( nodes && nodes[0] ) {
5975     doc = nodes[0].ownerDocument || nodes[0];
5976   }
5977
5978   // Ensure that an attr object doesn't incorrectly stand in as a document object
5979         // Chrome and Firefox seem to allow this to occur and will throw exception
5980         // Fixes #8950
5981         if ( !doc.createDocumentFragment ) {
5982                 doc = document;
5983         }
5984
5985         // Only cache "small" (1/2 KB) HTML strings that are associated with the main document
5986         // Cloning options loses the selected state, so don't cache them
5987         // IE 6 doesn't like it when you put <object> or <embed> elements in a fragment
5988         // Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache
5989         if ( args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && doc === document &&
5990                 args[0].charAt(0) === "<" && !rnocache.test( args[0] ) && (jQuery.support.checkClone || !rchecked.test( args[0] )) ) {
5991
5992                 cacheable = true;
5993
5994                 cacheresults = jQuery.fragments[ args[0] ];
5995                 if ( cacheresults && cacheresults !== 1 ) {
5996                         fragment = cacheresults;
5997                 }
5998         }
5999
6000         if ( !fragment ) {
6001                 fragment = doc.createDocumentFragment();
6002                 jQuery.clean( args, doc, fragment, scripts );
6003         }
6004
6005         if ( cacheable ) {
6006                 jQuery.fragments[ args[0] ] = cacheresults ? fragment : 1;
6007         }
6008
6009         return { fragment: fragment, cacheable: cacheable };
6010 };
6011
6012 jQuery.fragments = {};
6013
6014 jQuery.each({
6015         appendTo: "append",
6016         prependTo: "prepend",
6017         insertBefore: "before",
6018         insertAfter: "after",
6019         replaceAll: "replaceWith"
6020 }, function( name, original ) {
6021         jQuery.fn[ name ] = function( selector ) {
6022                 var ret = [],
6023                         insert = jQuery( selector ),
6024                         parent = this.length === 1 && this[0].parentNode;
6025
6026                 if ( parent && parent.nodeType === 11 && parent.childNodes.length === 1 && insert.length === 1 ) {
6027                         insert[ original ]( this[0] );
6028                         return this;
6029
6030                 } else {
6031                         for ( var i = 0, l = insert.length; i < l; i++ ) {
6032                                 var elems = (i > 0 ? this.clone(true) : this).get();
6033                                 jQuery( insert[i] )[ original ]( elems );
6034                                 ret = ret.concat( elems );
6035                         }
6036
6037                         return this.pushStack( ret, name, insert.selector );
6038                 }
6039         };
6040 });
6041
6042 function getAll( elem ) {
6043         if ( "getElementsByTagName" in elem ) {
6044                 return elem.getElementsByTagName( "*" );
6045
6046         } else if ( "querySelectorAll" in elem ) {
6047                 return elem.querySelectorAll( "*" );
6048
6049         } else {
6050                 return [];
6051         }
6052 }
6053
6054 // Used in clean, fixes the defaultChecked property
6055 function fixDefaultChecked( elem ) {
6056         if ( elem.type === "checkbox" || elem.type === "radio" ) {
6057                 elem.defaultChecked = elem.checked;
6058         }
6059 }
6060 // Finds all inputs and passes them to fixDefaultChecked
6061 function findInputs( elem ) {
6062         if ( jQuery.nodeName( elem, "input" ) ) {
6063                 fixDefaultChecked( elem );
6064         } else if ( "getElementsByTagName" in elem ) {
6065                 jQuery.grep( elem.getElementsByTagName("input"), fixDefaultChecked );
6066         }
6067 }
6068
6069 jQuery.extend({
6070         clone: function( elem, dataAndEvents, deepDataAndEvents ) {
6071                 var clone = elem.cloneNode(true),
6072                                 srcElements,
6073                                 destElements,
6074                                 i;
6075
6076                 if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) &&
6077                                 (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
6078                         // IE copies events bound via attachEvent when using cloneNode.
6079                         // Calling detachEvent on the clone will also remove the events
6080                         // from the original. In order to get around this, we use some
6081                         // proprietary methods to clear the events. Thanks to MooTools
6082                         // guys for this hotness.
6083
6084                         cloneFixAttributes( elem, clone );
6085
6086                         // Using Sizzle here is crazy slow, so we use getElementsByTagName
6087                         // instead
6088                         srcElements = getAll( elem );
6089                         destElements = getAll( clone );
6090
6091                         // Weird iteration because IE will replace the length property
6092                         // with an element if you are cloning the body and one of the
6093                         // elements on the page has a name or id of "length"
6094                         for ( i = 0; srcElements[i]; ++i ) {
6095                                 // Ensure that the destination node is not null; Fixes #9587
6096                                 if ( destElements[i] ) {
6097                                         cloneFixAttributes( srcElements[i], destElements[i] );
6098                                 }
6099                         }
6100                 }
6101
6102                 // Copy the events from the original to the clone
6103                 if ( dataAndEvents ) {
6104                         cloneCopyEvent( elem, clone );
6105
6106                         if ( deepDataAndEvents ) {
6107                                 srcElements = getAll( elem );
6108                                 destElements = getAll( clone );
6109
6110                                 for ( i = 0; srcElements[i]; ++i ) {
6111                                         cloneCopyEvent( srcElements[i], destElements[i] );
6112                                 }
6113                         }
6114                 }
6115
6116                 srcElements = destElements = null;
6117
6118                 // Return the cloned set
6119                 return clone;
6120         },
6121
6122         clean: function( elems, context, fragment, scripts ) {
6123                 var checkScriptType;
6124
6125                 context = context || document;
6126
6127                 // !context.createElement fails in IE with an error but returns typeof 'object'
6128                 if ( typeof context.createElement === "undefined" ) {
6129                         context = context.ownerDocument || context[0] && context[0].ownerDocument || document;
6130                 }
6131
6132                 var ret = [], j;
6133
6134                 for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
6135                         if ( typeof elem === "number" ) {
6136                                 elem += "";
6137                         }
6138
6139                         if ( !elem ) {
6140                                 continue;
6141                         }
6142
6143                         // Convert html string into DOM nodes
6144                         if ( typeof elem === "string" ) {
6145                                 if ( !rhtml.test( elem ) ) {
6146                                         elem = context.createTextNode( elem );
6147                                 } else {
6148                                         // Fix "XHTML"-style tags in all browsers
6149                                         elem = elem.replace(rxhtmlTag, "<$1></$2>");
6150
6151                                         // Trim whitespace, otherwise indexOf won't work as expected
6152                                         var tag = (rtagName.exec( elem ) || ["", ""])[1].toLowerCase(),
6153                                                 wrap = wrapMap[ tag ] || wrapMap._default,
6154                                                 depth = wrap[0],
6155                                                 div = context.createElement("div");
6156
6157                                         // Go to html and back, then peel off extra wrappers
6158                                         div.innerHTML = wrap[1] + elem + wrap[2];
6159
6160                                         // Move to the right depth
6161                                         while ( depth-- ) {
6162                                                 div = div.lastChild;
6163                                         }
6164
6165                                         // Remove IE's autoinserted <tbody> from table fragments
6166                                         if ( !jQuery.support.tbody ) {
6167
6168                                                 // String was a <table>, *may* have spurious <tbody>
6169                                                 var hasBody = rtbody.test(elem),
6170                                                         tbody = tag === "table" && !hasBody ?
6171                                                                 div.firstChild && div.firstChild.childNodes :
6172
6173                                                                 // String was a bare <thead> or <tfoot>
6174                                                                 wrap[1] === "<table>" && !hasBody ?
6175                                                                         div.childNodes :
6176                                                                         [];
6177
6178                                                 for ( j = tbody.length - 1; j >= 0 ; --j ) {
6179                                                         if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) {
6180                                                                 tbody[ j ].parentNode.removeChild( tbody[ j ] );
6181                                                         }
6182                                                 }
6183                                         }
6184
6185                                         // IE completely kills leading whitespace when innerHTML is used
6186                                         if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
6187                                                 div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );
6188                                         }
6189
6190                                         elem = div.childNodes;
6191                                 }
6192                         }
6193
6194                         // Resets defaultChecked for any radios and checkboxes
6195                         // about to be appended to the DOM in IE 6/7 (#8060)
6196                         var len;
6197                         if ( !jQuery.support.appendChecked ) {
6198                                 if ( elem[0] && typeof (len = elem.length) === "number" ) {
6199                                         for ( j = 0; j < len; j++ ) {
6200                                                 findInputs( elem[j] );
6201                                         }
6202                                 } else {
6203                                         findInputs( elem );
6204                                 }
6205                         }
6206
6207                         if ( elem.nodeType ) {
6208                                 ret.push( elem );
6209                         } else {
6210                                 ret = jQuery.merge( ret, elem );
6211                         }
6212                 }
6213
6214                 if ( fragment ) {
6215                         checkScriptType = function( elem ) {
6216                                 return !elem.type || rscriptType.test( elem.type );
6217                         };
6218                         for ( i = 0; ret[i]; i++ ) {
6219                                 if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) {
6220                                         scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] );
6221
6222                                 } else {
6223                                         if ( ret[i].nodeType === 1 ) {
6224                                                 var jsTags = jQuery.grep( ret[i].getElementsByTagName( "script" ), checkScriptType );
6225
6226                                                 ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) );
6227                                         }
6228                                         fragment.appendChild( ret[i] );
6229                                 }
6230                         }
6231                 }
6232
6233                 return ret;
6234         },
6235
6236         cleanData: function( elems ) {
6237                 var data, id, cache = jQuery.cache, internalKey = jQuery.expando, special = jQuery.event.special,
6238                         deleteExpando = jQuery.support.deleteExpando;
6239
6240                 for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
6241                         if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) {
6242                                 continue;
6243                         }
6244
6245                         id = elem[ jQuery.expando ];
6246
6247                         if ( id ) {
6248                                 data = cache[ id ] && cache[ id ][ internalKey ];
6249
6250                                 if ( data && data.events ) {
6251                                         for ( var type in data.events ) {
6252                                                 if ( special[ type ] ) {
6253                                                         jQuery.event.remove( elem, type );
6254
6255                                                 // This is a shortcut to avoid jQuery.event.remove's overhead
6256                                                 } else {
6257                                                         jQuery.removeEvent( elem, type, data.handle );
6258                                                 }
6259                                         }
6260
6261                                         // Null the DOM reference to avoid IE6/7/8 leak (#7054)
6262                                         if ( data.handle ) {
6263                                                 data.handle.elem = null;
6264                                         }
6265                                 }
6266
6267                                 if ( deleteExpando ) {
6268                                         delete elem[ jQuery.expando ];
6269
6270                                 } else if ( elem.removeAttribute ) {
6271                                         elem.removeAttribute( jQuery.expando );
6272                                 }
6273
6274                                 delete cache[ id ];
6275                         }
6276                 }
6277         }
6278 });
6279
6280 function evalScript( i, elem ) {
6281         if ( elem.src ) {
6282                 jQuery.ajax({
6283                         url: elem.src,
6284                         async: false,
6285                         dataType: "script"
6286                 });
6287         } else {
6288                 jQuery.globalEval( ( elem.text || elem.textContent || elem.innerHTML || "" ).replace( rcleanScript, "/*$0*/" ) );
6289         }
6290
6291         if ( elem.parentNode ) {
6292                 elem.parentNode.removeChild( elem );
6293         }
6294 }
6295
6296
6297
6298
6299 var ralpha = /alpha\([^)]*\)/i,
6300         ropacity = /opacity=([^)]*)/,
6301         // fixed for IE9, see #8346
6302         rupper = /([A-Z]|^ms)/g,
6303         rnumpx = /^-?\d+(?:px)?$/i,
6304         rnum = /^-?\d/,
6305         rrelNum = /^([\-+])=([\-+.\de]+)/,
6306
6307         cssShow = { position: "absolute", visibility: "hidden", display: "block" },
6308         cssWidth = [ "Left", "Right" ],
6309         cssHeight = [ "Top", "Bottom" ],
6310         curCSS,
6311
6312         getComputedStyle,
6313         currentStyle;
6314
6315 jQuery.fn.css = function( name, value ) {
6316         // Setting 'undefined' is a no-op
6317         if ( arguments.length === 2 && value === undefined ) {
6318                 return this;
6319         }
6320
6321         return jQuery.access( this, name, value, true, function( elem, name, value ) {
6322                 return value !== undefined ?
6323                         jQuery.style( elem, name, value ) :
6324                         jQuery.css( elem, name );
6325         });
6326 };
6327
6328 jQuery.extend({
6329         // Add in style property hooks for overriding the default
6330         // behavior of getting and setting a style property
6331         cssHooks: {
6332                 opacity: {
6333                         get: function( elem, computed ) {
6334                                 if ( computed ) {
6335                                         // We should always get a number back from opacity
6336                                         var ret = curCSS( elem, "opacity", "opacity" );
6337                                         return ret === "" ? "1" : ret;
6338
6339                                 } else {
6340                                         return elem.style.opacity;
6341                                 }
6342                         }
6343                 }
6344         },
6345
6346         // Exclude the following css properties to add px
6347         cssNumber: {
6348                 "fillOpacity": true,
6349                 "fontWeight": true,
6350                 "lineHeight": true,
6351                 "opacity": true,
6352                 "orphans": true,
6353                 "widows": true,
6354                 "zIndex": true,
6355                 "zoom": true
6356         },
6357
6358         // Add in properties whose names you wish to fix before
6359         // setting or getting the value
6360         cssProps: {
6361                 // normalize float css property
6362                 "float": jQuery.support.cssFloat ? "cssFloat" : "styleFloat"
6363         },
6364
6365         // Get and set the style property on a DOM Node
6366         style: function( elem, name, value, extra ) {
6367                 // Don't set styles on text and comment nodes
6368                 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
6369                         return;
6370                 }
6371
6372                 // Make sure that we're working with the right name
6373                 var ret, type, origName = jQuery.camelCase( name ),
6374                         style = elem.style, hooks = jQuery.cssHooks[ origName ];
6375
6376                 name = jQuery.cssProps[ origName ] || origName;
6377
6378                 // Check if we're setting a value
6379                 if ( value !== undefined ) {
6380                         type = typeof value;
6381
6382                         // convert relative number strings (+= or -=) to relative numbers. #7345
6383                         if ( type === "string" && (ret = rrelNum.exec( value )) ) {
6384                                 value = ( +( ret[1] + 1) * +ret[2] ) + parseFloat( jQuery.css( elem, name ) );
6385                                 // Fixes bug #9237
6386                                 type = "number";
6387                         }
6388
6389                         // Make sure that NaN and null values aren't set. See: #7116
6390                         if ( value == null || type === "number" && isNaN( value ) ) {
6391                                 return;
6392                         }
6393
6394                         // If a number was passed in, add 'px' to the (except for certain CSS properties)
6395                         if ( type === "number" && !jQuery.cssNumber[ origName ] ) {
6396                                 value += "px";
6397                         }
6398
6399                         // If a hook was provided, use that value, otherwise just set the specified value
6400                         if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value )) !== undefined ) {
6401                                 // Wrapped to prevent IE from throwing errors when 'invalid' values are provided
6402                                 // Fixes bug #5509
6403                                 try {
6404                                         style[ name ] = value;
6405                                 } catch(e) {}
6406                         }
6407
6408                 } else {
6409                         // If a hook was provided get the non-computed value from there
6410                         if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
6411                                 return ret;
6412                         }
6413
6414                         // Otherwise just get the value from the style object
6415                         return style[ name ];
6416                 }
6417         },
6418
6419         css: function( elem, name, extra ) {
6420                 var ret, hooks;
6421
6422                 // Make sure that we're working with the right name
6423                 name = jQuery.camelCase( name );
6424                 hooks = jQuery.cssHooks[ name ];
6425                 name = jQuery.cssProps[ name ] || name;
6426
6427                 // cssFloat needs a special treatment
6428                 if ( name === "cssFloat" ) {
6429                         name = "float";
6430                 }
6431
6432                 // If a hook was provided get the computed value from there
6433                 if ( hooks && "get" in hooks && (ret = hooks.get( elem, true, extra )) !== undefined ) {
6434                         return ret;
6435
6436                 // Otherwise, if a way to get the computed value exists, use that
6437                 } else if ( curCSS ) {
6438                         return curCSS( elem, name );
6439                 }
6440         },
6441
6442         // A method for quickly swapping in/out CSS properties to get correct calculations
6443         swap: function( elem, options, callback ) {
6444                 var old = {};
6445
6446                 // Remember the old values, and insert the new ones
6447                 for ( var name in options ) {
6448                         old[ name ] = elem.style[ name ];
6449                         elem.style[ name ] = options[ name ];
6450                 }
6451
6452                 callback.call( elem );
6453
6454                 // Revert the old values
6455                 for ( name in options ) {
6456                         elem.style[ name ] = old[ name ];
6457                 }
6458         }
6459 });
6460
6461 // DEPRECATED, Use jQuery.css() instead
6462 jQuery.curCSS = jQuery.css;
6463
6464 jQuery.each(["height", "width"], function( i, name ) {
6465         jQuery.cssHooks[ name ] = {
6466                 get: function( elem, computed, extra ) {
6467                         var val;
6468
6469                         if ( computed ) {
6470                                 if ( elem.offsetWidth !== 0 ) {
6471                                         return getWH( elem, name, extra );
6472                                 } else {
6473                                         jQuery.swap( elem, cssShow, function() {
6474                                                 val = getWH( elem, name, extra );
6475                                         });
6476                                 }
6477
6478                                 return val;
6479                         }
6480                 },
6481
6482                 set: function( elem, value ) {
6483                         if ( rnumpx.test( value ) ) {
6484                                 // ignore negative width and height values #1599
6485                                 value = parseFloat( value );
6486
6487                                 if ( value >= 0 ) {
6488                                         return value + "px";
6489                                 }
6490
6491                         } else {
6492                                 return value;
6493                         }
6494                 }
6495         };
6496 });
6497
6498 if ( !jQuery.support.opacity ) {
6499         jQuery.cssHooks.opacity = {
6500                 get: function( elem, computed ) {
6501                         // IE uses filters for opacity
6502                         return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ?
6503                                 ( parseFloat( RegExp.$1 ) / 100 ) + "" :
6504                                 computed ? "1" : "";
6505                 },
6506
6507                 set: function( elem, value ) {
6508                         var style = elem.style,
6509                                 currentStyle = elem.currentStyle,
6510                                 opacity = jQuery.isNaN( value ) ? "" : "alpha(opacity=" + value * 100 + ")",
6511                                 filter = currentStyle && currentStyle.filter || style.filter || "";
6512
6513                         // IE has trouble with opacity if it does not have layout
6514                         // Force it by setting the zoom level
6515                         style.zoom = 1;
6516
6517                         // if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652
6518                         if ( value >= 1 && jQuery.trim( filter.replace( ralpha, "" ) ) === "" ) {
6519
6520                                 // Setting style.filter to null, "" & " " still leave "filter:" in the cssText
6521                                 // if "filter:" is present at all, clearType is disabled, we want to avoid this
6522                                 // style.removeAttribute is IE Only, but so apparently is this code path...
6523                                 style.removeAttribute( "filter" );
6524
6525                                 // if there there is no filter style applied in a css rule, we are done
6526                                 if ( currentStyle && !currentStyle.filter ) {
6527                                         return;
6528                                 }
6529                         }
6530
6531                         // otherwise, set new filter values
6532                         style.filter = ralpha.test( filter ) ?
6533                                 filter.replace( ralpha, opacity ) :
6534                                 filter + " " + opacity;
6535                 }
6536         };
6537 }
6538
6539 jQuery(function() {
6540         // This hook cannot be added until DOM ready because the support test
6541         // for it is not run until after DOM ready
6542         if ( !jQuery.support.reliableMarginRight ) {
6543                 jQuery.cssHooks.marginRight = {
6544                         get: function( elem, computed ) {
6545                                 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
6546                                 // Work around by temporarily setting element display to inline-block
6547                                 var ret;
6548                                 jQuery.swap( elem, { "display": "inline-block" }, function() {
6549                                         if ( computed ) {
6550                                                 ret = curCSS( elem, "margin-right", "marginRight" );
6551                                         } else {
6552                                                 ret = elem.style.marginRight;
6553                                         }
6554                                 });
6555                                 return ret;
6556                         }
6557                 };
6558         }
6559 });
6560
6561 if ( document.defaultView && document.defaultView.getComputedStyle ) {
6562         getComputedStyle = function( elem, name ) {
6563                 var ret, defaultView, computedStyle;
6564
6565                 name = name.replace( rupper, "-$1" ).toLowerCase();
6566
6567                 if ( !(defaultView = elem.ownerDocument.defaultView) ) {
6568                         return undefined;
6569                 }
6570
6571                 if ( (computedStyle = defaultView.getComputedStyle( elem, null )) ) {
6572                         ret = computedStyle.getPropertyValue( name );
6573                         if ( ret === "" && !jQuery.contains( elem.ownerDocument.documentElement, elem ) ) {
6574                                 ret = jQuery.style( elem, name );
6575                         }
6576                 }
6577
6578                 return ret;
6579         };
6580 }
6581
6582 if ( document.documentElement.currentStyle ) {
6583         currentStyle = function( elem, name ) {
6584                 var left,
6585                         ret = elem.currentStyle && elem.currentStyle[ name ],
6586                         rsLeft = elem.runtimeStyle && elem.runtimeStyle[ name ],
6587                         style = elem.style;
6588
6589                 // From the awesome hack by Dean Edwards
6590                 // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
6591
6592                 // If we're not dealing with a regular pixel number
6593                 // but a number that has a weird ending, we need to convert it to pixels
6594                 if ( !rnumpx.test( ret ) && rnum.test( ret ) ) {
6595                         // Remember the original values
6596                         left = style.left;
6597
6598                         // Put in the new values to get a computed value out
6599                         if ( rsLeft ) {
6600                                 elem.runtimeStyle.left = elem.currentStyle.left;
6601                         }
6602                         style.left = name === "fontSize" ? "1em" : (ret || 0);
6603                         ret = style.pixelLeft + "px";
6604
6605                         // Revert the changed values
6606                         style.left = left;
6607                         if ( rsLeft ) {
6608                                 elem.runtimeStyle.left = rsLeft;
6609                         }
6610                 }
6611
6612                 return ret === "" ? "auto" : ret;
6613         };
6614 }
6615
6616 curCSS = getComputedStyle || currentStyle;
6617
6618 function getWH( elem, name, extra ) {
6619
6620         // Start with offset property
6621         var val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
6622                 which = name === "width" ? cssWidth : cssHeight;
6623
6624         if ( val > 0 ) {
6625                 if ( extra !== "border" ) {
6626                         jQuery.each( which, function() {
6627                                 if ( !extra ) {
6628                                         val -= parseFloat( jQuery.css( elem, "padding" + this ) ) || 0;
6629                                 }
6630                                 if ( extra === "margin" ) {
6631                                         val += parseFloat( jQuery.css( elem, extra + this ) ) || 0;
6632                                 } else {
6633                                         val -= parseFloat( jQuery.css( elem, "border" + this + "Width" ) ) || 0;
6634                                 }
6635                         });
6636                 }
6637
6638                 return val + "px";
6639         }
6640
6641         // Fall back to computed then uncomputed css if necessary
6642         val = curCSS( elem, name, name );
6643         if ( val < 0 || val == null ) {
6644                 val = elem.style[ name ] || 0;
6645         }
6646         // Normalize "", auto, and prepare for extra
6647         val = parseFloat( val ) || 0;
6648
6649         // Add padding, border, margin
6650         if ( extra ) {
6651                 jQuery.each( which, function() {
6652                         val += parseFloat( jQuery.css( elem, "padding" + this ) ) || 0;
6653                         if ( extra !== "padding" ) {
6654                                 val += parseFloat( jQuery.css( elem, "border" + this + "Width" ) ) || 0;
6655                         }
6656                         if ( extra === "margin" ) {
6657                                 val += parseFloat( jQuery.css( elem, extra + this ) ) || 0;
6658                         }
6659                 });
6660         }
6661
6662         return val + "px";
6663 }
6664
6665 if ( jQuery.expr && jQuery.expr.filters ) {
6666         jQuery.expr.filters.hidden = function( elem ) {
6667                 var width = elem.offsetWidth,
6668                         height = elem.offsetHeight;
6669
6670                 return (width === 0 && height === 0) || (!jQuery.support.reliableHiddenOffsets && (elem.style.display || jQuery.css( elem, "display" )) === "none");
6671         };
6672
6673         jQuery.expr.filters.visible = function( elem ) {
6674                 return !jQuery.expr.filters.hidden( elem );
6675         };
6676 }
6677
6678
6679
6680
6681 var r20 = /%20/g,
6682         rbracket = /\[\]$/,
6683         rCRLF = /\r?\n/g,
6684         rhash = /#.*$/,
6685         rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
6686         rinput = /^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
6687         // #7653, #8125, #8152: local protocol detection
6688         rlocalProtocol = /^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,
6689         rnoContent = /^(?:GET|HEAD)$/,
6690         rprotocol = /^\/\//,
6691         rquery = /\?/,
6692         rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
6693         rselectTextarea = /^(?:select|textarea)/i,
6694         rspacesAjax = /\s+/,
6695         rts = /([?&])_=[^&]*/,
6696         rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,
6697
6698         // Keep a copy of the old load method
6699         _load = jQuery.fn.load,
6700
6701         /* Prefilters
6702          * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
6703          * 2) These are called:
6704          *    - BEFORE asking for a transport
6705          *    - AFTER param serialization (s.data is a string if s.processData is true)
6706          * 3) key is the dataType
6707          * 4) the catchall symbol "*" can be used
6708          * 5) execution will start with transport dataType and THEN continue down to "*" if needed
6709          */
6710         prefilters = {},
6711
6712         /* Transports bindings
6713          * 1) key is the dataType
6714          * 2) the catchall symbol "*" can be used
6715          * 3) selection will start with transport dataType and THEN go to "*" if needed
6716          */
6717         transports = {},
6718
6719         // Document location
6720         ajaxLocation,
6721
6722         // Document location segments
6723         ajaxLocParts,
6724         
6725         // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
6726         allTypes = ["*/"] + ["*"];
6727
6728 // #8138, IE may throw an exception when accessing
6729 // a field from window.location if document.domain has been set
6730 try {
6731         ajaxLocation = location.href;
6732 } catch( e ) {
6733         // Use the href attribute of an A element
6734         // since IE will modify it given document.location
6735         ajaxLocation = document.createElement( "a" );
6736         ajaxLocation.href = "";
6737         ajaxLocation = ajaxLocation.href;
6738 }
6739
6740 // Segment location into parts
6741 ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
6742
6743 // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
6744 function addToPrefiltersOrTransports( structure ) {
6745
6746         // dataTypeExpression is optional and defaults to "*"
6747         return function( dataTypeExpression, func ) {
6748
6749                 if ( typeof dataTypeExpression !== "string" ) {
6750                         func = dataTypeExpression;
6751                         dataTypeExpression = "*";
6752                 }
6753
6754                 if ( jQuery.isFunction( func ) ) {
6755                         var dataTypes = dataTypeExpression.toLowerCase().split( rspacesAjax ),
6756                                 i = 0,
6757                                 length = dataTypes.length,
6758                                 dataType,
6759                                 list,
6760                                 placeBefore;
6761
6762                         // For each dataType in the dataTypeExpression
6763                         for(; i < length; i++ ) {
6764                                 dataType = dataTypes[ i ];
6765                                 // We control if we're asked to add before
6766                                 // any existing element
6767                                 placeBefore = /^\+/.test( dataType );
6768                                 if ( placeBefore ) {
6769                                         dataType = dataType.substr( 1 ) || "*";
6770                                 }
6771                                 list = structure[ dataType ] = structure[ dataType ] || [];
6772                                 // then we add to the structure accordingly
6773                                 list[ placeBefore ? "unshift" : "push" ]( func );
6774                         }
6775                 }
6776         };
6777 }
6778
6779 // Base inspection function for prefilters and transports
6780 function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR,
6781                 dataType /* internal */, inspected /* internal */ ) {
6782
6783         dataType = dataType || options.dataTypes[ 0 ];
6784         inspected = inspected || {};
6785
6786         inspected[ dataType ] = true;
6787
6788         var list = structure[ dataType ],
6789                 i = 0,
6790                 length = list ? list.length : 0,
6791                 executeOnly = ( structure === prefilters ),
6792                 selection;
6793
6794         for(; i < length && ( executeOnly || !selection ); i++ ) {
6795                 selection = list[ i ]( options, originalOptions, jqXHR );
6796                 // If we got redirected to another dataType
6797                 // we try there if executing only and not done already
6798                 if ( typeof selection === "string" ) {
6799                         if ( !executeOnly || inspected[ selection ] ) {
6800                                 selection = undefined;
6801                         } else {
6802                                 options.dataTypes.unshift( selection );
6803                                 selection = inspectPrefiltersOrTransports(
6804                                                 structure, options, originalOptions, jqXHR, selection, inspected );
6805                         }
6806                 }
6807         }
6808         // If we're only executing or nothing was selected
6809         // we try the catchall dataType if not done already
6810         if ( ( executeOnly || !selection ) && !inspected[ "*" ] ) {
6811                 selection = inspectPrefiltersOrTransports(
6812                                 structure, options, originalOptions, jqXHR, "*", inspected );
6813         }
6814         // unnecessary when only executing (prefilters)
6815         // but it'll be ignored by the caller in that case
6816         return selection;
6817 }
6818
6819 // A special extend for ajax options
6820 // that takes "flat" options (not to be deep extended)
6821 // Fixes #9887
6822 function ajaxExtend( target, src ) {
6823         var key, deep,
6824                 flatOptions = jQuery.ajaxSettings.flatOptions || {};
6825         for( key in src ) {
6826                 if ( src[ key ] !== undefined ) {
6827                         ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
6828                 }
6829         }
6830         if ( deep ) {
6831                 jQuery.extend( true, target, deep );
6832         }
6833 }
6834
6835 jQuery.fn.extend({
6836         load: function( url, params, callback ) {
6837                 if ( typeof url !== "string" && _load ) {
6838                         return _load.apply( this, arguments );
6839
6840                 // Don't do a request if no elements are being requested
6841                 } else if ( !this.length ) {
6842                         return this;
6843                 }
6844
6845                 var off = url.indexOf( " " );
6846                 if ( off >= 0 ) {
6847                         var selector = url.slice( off, url.length );
6848                         url = url.slice( 0, off );
6849                 }
6850
6851                 // Default to a GET request
6852                 var type = "GET";
6853
6854                 // If the second parameter was provided
6855                 if ( params ) {
6856                         // If it's a function
6857                         if ( jQuery.isFunction( params ) ) {
6858                                 // We assume that it's the callback
6859                                 callback = params;
6860                                 params = undefined;
6861
6862                         // Otherwise, build a param string
6863                         } else if ( typeof params === "object" ) {
6864                                 params = jQuery.param( params, jQuery.ajaxSettings.traditional );
6865                                 type = "POST";
6866                         }
6867                 }
6868
6869                 var self = this;
6870
6871                 // Request the remote document
6872                 jQuery.ajax({
6873                         url: url,
6874                         type: type,
6875                         dataType: "html",
6876                         data: params,
6877                         // Complete callback (responseText is used internally)
6878                         complete: function( jqXHR, status, responseText ) {
6879                                 // Store the response as specified by the jqXHR object
6880                                 responseText = jqXHR.responseText;
6881                                 // If successful, inject the HTML into all the matched elements
6882                                 if ( jqXHR.isResolved() ) {
6883                                         // #4825: Get the actual response in case
6884                                         // a dataFilter is present in ajaxSettings
6885                                         jqXHR.done(function( r ) {
6886                                                 responseText = r;
6887                                         });
6888                                         // See if a selector was specified
6889                                         self.html( selector ?
6890                                                 // Create a dummy div to hold the results
6891                                                 jQuery("<div>")
6892                                                         // inject the contents of the document in, removing the scripts
6893                                                         // to avoid any 'Permission Denied' errors in IE
6894                                                         .append(responseText.replace(rscript, ""))
6895
6896                                                         // Locate the specified elements
6897                                                         .find(selector) :
6898
6899                                                 // If not, just inject the full result
6900                                                 responseText );
6901                                 }
6902
6903                                 if ( callback ) {
6904                                         self.each( callback, [ responseText, status, jqXHR ] );
6905                                 }
6906                         }
6907                 });
6908
6909                 return this;
6910         },
6911
6912         serialize: function() {
6913                 return jQuery.param( this.serializeArray() );
6914         },
6915
6916         serializeArray: function() {
6917                 return this.map(function(){
6918                         return this.elements ? jQuery.makeArray( this.elements ) : this;
6919                 })
6920                 .filter(function(){
6921                         return this.name && !this.disabled &&
6922                                 ( this.checked || rselectTextarea.test( this.nodeName ) ||
6923                                         rinput.test( this.type ) );
6924                 })
6925                 .map(function( i, elem ){
6926                         var val = jQuery( this ).val();
6927
6928                         return val == null ?
6929                                 null :
6930                                 jQuery.isArray( val ) ?
6931                                         jQuery.map( val, function( val, i ){
6932                                                 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
6933                                         }) :
6934                                         { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
6935                 }).get();
6936         }
6937 });
6938
6939 // Attach a bunch of functions for handling common AJAX events
6940 jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split( " " ), function( i, o ){
6941         jQuery.fn[ o ] = function( f ){
6942                 return this.bind( o, f );
6943         };
6944 });
6945
6946 jQuery.each( [ "get", "post" ], function( i, method ) {
6947         jQuery[ method ] = function( url, data, callback, type ) {
6948                 // shift arguments if data argument was omitted
6949                 if ( jQuery.isFunction( data ) ) {
6950                         type = type || callback;
6951                         callback = data;
6952                         data = undefined;
6953                 }
6954
6955                 return jQuery.ajax({
6956                         type: method,
6957                         url: url,
6958                         data: data,
6959                         success: callback,
6960                         dataType: type
6961                 });
6962         };
6963 });
6964
6965 jQuery.extend({
6966
6967         getScript: function( url, callback ) {
6968                 return jQuery.get( url, undefined, callback, "script" );
6969         },
6970
6971         getJSON: function( url, data, callback ) {
6972                 return jQuery.get( url, data, callback, "json" );
6973         },
6974
6975         // Creates a full fledged settings object into target
6976         // with both ajaxSettings and settings fields.
6977         // If target is omitted, writes into ajaxSettings.
6978         ajaxSetup: function( target, settings ) {
6979                 if ( settings ) {
6980                         // Building a settings object
6981                         ajaxExtend( target, jQuery.ajaxSettings );
6982                 } else {
6983                         // Extending ajaxSettings
6984                         settings = target;
6985                         target = jQuery.ajaxSettings;
6986                 }
6987                 ajaxExtend( target, settings );
6988                 return target;
6989         },
6990
6991         ajaxSettings: {
6992                 url: ajaxLocation,
6993                 isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
6994                 global: true,
6995                 type: "GET",
6996                 contentType: "application/x-www-form-urlencoded",
6997                 processData: true,
6998                 async: true,
6999                 /*
7000                 timeout: 0,
7001                 data: null,
7002                 dataType: null,
7003                 username: null,
7004                 password: null,
7005                 cache: null,
7006                 traditional: false,
7007                 headers: {},
7008                 */
7009
7010                 accepts: {
7011                         xml: "application/xml, text/xml",
7012                         html: "text/html",
7013                         text: "text/plain",
7014                         json: "application/json, text/javascript",
7015                         "*": allTypes
7016                 },
7017
7018                 contents: {
7019                         xml: /xml/,
7020                         html: /html/,
7021                         json: /json/
7022                 },
7023
7024                 responseFields: {
7025                         xml: "responseXML",
7026                         text: "responseText"
7027                 },
7028
7029                 // List of data converters
7030                 // 1) key format is "source_type destination_type" (a single space in-between)
7031                 // 2) the catchall symbol "*" can be used for source_type
7032                 converters: {
7033
7034                         // Convert anything to text
7035                         "* text": window.String,
7036
7037                         // Text to html (true = no transformation)
7038                         "text html": true,
7039
7040                         // Evaluate text as a json expression
7041                         "text json": jQuery.parseJSON,
7042
7043                         // Parse text as xml
7044                         "text xml": jQuery.parseXML
7045                 },
7046
7047                 // For options that shouldn't be deep extended:
7048                 // you can add your own custom options here if
7049                 // and when you create one that shouldn't be
7050                 // deep extended (see ajaxExtend)
7051                 flatOptions: {
7052                         context: true,
7053                         url: true
7054                 }
7055         },
7056
7057         ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
7058         ajaxTransport: addToPrefiltersOrTransports( transports ),
7059
7060         // Main method
7061         ajax: function( url, options ) {
7062
7063                 // If url is an object, simulate pre-1.5 signature
7064                 if ( typeof url === "object" ) {
7065                         options = url;
7066                         url = undefined;
7067                 }
7068
7069                 // Force options to be an object
7070                 options = options || {};
7071
7072                 var // Create the final options object
7073                         s = jQuery.ajaxSetup( {}, options ),
7074                         // Callbacks context
7075                         callbackContext = s.context || s,
7076                         // Context for global events
7077                         // It's the callbackContext if one was provided in the options
7078                         // and if it's a DOM node or a jQuery collection
7079                         globalEventContext = callbackContext !== s &&
7080                                 ( callbackContext.nodeType || callbackContext instanceof jQuery ) ?
7081                                                 jQuery( callbackContext ) : jQuery.event,
7082                         // Deferreds
7083                         deferred = jQuery.Deferred(),
7084                         completeDeferred = jQuery._Deferred(),
7085                         // Status-dependent callbacks
7086                         statusCode = s.statusCode || {},
7087                         // ifModified key
7088                         ifModifiedKey,
7089                         // Headers (they are sent all at once)
7090                         requestHeaders = {},
7091                         requestHeadersNames = {},
7092                         // Response headers
7093                         responseHeadersString,
7094                         responseHeaders,
7095                         // transport
7096                         transport,
7097                         // timeout handle
7098                         timeoutTimer,
7099                         // Cross-domain detection vars
7100                         parts,
7101                         // The jqXHR state
7102                         state = 0,
7103                         // To know if global events are to be dispatched
7104                         fireGlobals,
7105                         // Loop variable
7106                         i,
7107                         // Fake xhr
7108                         jqXHR = {
7109
7110                                 readyState: 0,
7111
7112                                 // Caches the header
7113                                 setRequestHeader: function( name, value ) {
7114                                         if ( !state ) {
7115                                                 var lname = name.toLowerCase();
7116                                                 name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
7117                                                 requestHeaders[ name ] = value;
7118                                         }
7119                                         return this;
7120                                 },
7121
7122                                 // Raw string
7123                                 getAllResponseHeaders: function() {
7124                                         return state === 2 ? responseHeadersString : null;
7125                                 },
7126
7127                                 // Builds headers hashtable if needed
7128                                 getResponseHeader: function( key ) {
7129                                         var match;
7130                                         if ( state === 2 ) {
7131                                                 if ( !responseHeaders ) {
7132                                                         responseHeaders = {};
7133                                                         while( ( match = rheaders.exec( responseHeadersString ) ) ) {
7134                                                                 responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
7135                                                         }
7136                                                 }
7137                                                 match = responseHeaders[ key.toLowerCase() ];
7138                                         }
7139                                         return match === undefined ? null : match;
7140                                 },
7141
7142                                 // Overrides response content-type header
7143                                 overrideMimeType: function( type ) {
7144                                         if ( !state ) {
7145                                                 s.mimeType = type;
7146                                         }
7147                                         return this;
7148                                 },
7149
7150                                 // Cancel the request
7151                                 abort: function( statusText ) {
7152                                         statusText = statusText || "abort";
7153                                         if ( transport ) {
7154                                                 transport.abort( statusText );
7155                                         }
7156                                         done( 0, statusText );
7157                                         return this;
7158                                 }
7159                         };
7160
7161                 // Callback for when everything is done
7162                 // It is defined here because jslint complains if it is declared
7163                 // at the end of the function (which would be more logical and readable)
7164                 function done( status, nativeStatusText, responses, headers ) {
7165
7166                         // Called once
7167                         if ( state === 2 ) {
7168                                 return;
7169                         }
7170
7171                         // State is "done" now
7172                         state = 2;
7173
7174                         // Clear timeout if it exists
7175                         if ( timeoutTimer ) {
7176                                 clearTimeout( timeoutTimer );
7177                         }
7178
7179                         // Dereference transport for early garbage collection
7180                         // (no matter how long the jqXHR object will be used)
7181                         transport = undefined;
7182
7183                         // Cache response headers
7184                         responseHeadersString = headers || "";
7185
7186                         // Set readyState
7187                         jqXHR.readyState = status > 0 ? 4 : 0;
7188
7189                         var isSuccess,
7190                                 success,
7191                                 error,
7192                                 statusText = nativeStatusText,
7193                                 response = responses ? ajaxHandleResponses( s, jqXHR, responses ) : undefined,
7194                                 lastModified,
7195                                 etag;
7196
7197                         // If successful, handle type chaining
7198                         if ( status >= 200 && status < 300 || status === 304 ) {
7199
7200                                 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
7201                                 if ( s.ifModified ) {
7202
7203                                         if ( ( lastModified = jqXHR.getResponseHeader( "Last-Modified" ) ) ) {
7204                                                 jQuery.lastModified[ ifModifiedKey ] = lastModified;
7205                                         }
7206                                         if ( ( etag = jqXHR.getResponseHeader( "Etag" ) ) ) {
7207                                                 jQuery.etag[ ifModifiedKey ] = etag;
7208                                         }
7209                                 }
7210
7211                                 // If not modified
7212                                 if ( status === 304 ) {
7213
7214                                         statusText = "notmodified";
7215                                         isSuccess = true;
7216
7217                                 // If we have data
7218                                 } else {
7219
7220                                         try {
7221                                                 success = ajaxConvert( s, response );
7222                                                 statusText = "success";
7223                                                 isSuccess = true;
7224                                         } catch(e) {
7225                                                 // We have a parsererror
7226                                                 statusText = "parsererror";
7227                                                 error = e;
7228                                         }
7229                                 }
7230                         } else {
7231                                 // We extract error from statusText
7232                                 // then normalize statusText and status for non-aborts
7233                                 error = statusText;
7234                                 if( !statusText || status ) {
7235                                         statusText = "error";
7236                                         if ( status < 0 ) {
7237                                                 status = 0;
7238                                         }
7239                                 }
7240                         }
7241
7242                         // Set data for the fake xhr object
7243                         jqXHR.status = status;
7244                         jqXHR.statusText = "" + ( nativeStatusText || statusText );
7245
7246                         // Success/Error
7247                         if ( isSuccess ) {
7248                                 deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
7249                         } else {
7250                                 deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
7251                         }
7252
7253                         // Status-dependent callbacks
7254                         jqXHR.statusCode( statusCode );
7255                         statusCode = undefined;
7256
7257                         if ( fireGlobals ) {
7258                                 globalEventContext.trigger( "ajax" + ( isSuccess ? "Success" : "Error" ),
7259                                                 [ jqXHR, s, isSuccess ? success : error ] );
7260                         }
7261
7262                         // Complete
7263                         completeDeferred.resolveWith( callbackContext, [ jqXHR, statusText ] );
7264
7265                         if ( fireGlobals ) {
7266                                 globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
7267                                 // Handle the global AJAX counter
7268                                 if ( !( --jQuery.active ) ) {
7269                                         jQuery.event.trigger( "ajaxStop" );
7270                                 }
7271                         }
7272                 }
7273
7274                 // Attach deferreds
7275                 deferred.promise( jqXHR );
7276                 jqXHR.success = jqXHR.done;
7277                 jqXHR.error = jqXHR.fail;
7278                 jqXHR.complete = completeDeferred.done;
7279
7280                 // Status-dependent callbacks
7281                 jqXHR.statusCode = function( map ) {
7282                         if ( map ) {
7283                                 var tmp;
7284                                 if ( state < 2 ) {
7285                                         for( tmp in map ) {
7286                                                 statusCode[ tmp ] = [ statusCode[tmp], map[tmp] ];
7287                                         }
7288                                 } else {
7289                                         tmp = map[ jqXHR.status ];
7290                                         jqXHR.then( tmp, tmp );
7291                                 }
7292                         }
7293                         return this;
7294                 };
7295
7296                 // Remove hash character (#7531: and string promotion)
7297                 // Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
7298                 // We also use the url parameter if available
7299                 s.url = ( ( url || s.url ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
7300
7301                 // Extract dataTypes list
7302                 s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( rspacesAjax );
7303
7304                 // Determine if a cross-domain request is in order
7305                 if ( s.crossDomain == null ) {
7306                         parts = rurl.exec( s.url.toLowerCase() );
7307                         s.crossDomain = !!( parts &&
7308                                 ( parts[ 1 ] != ajaxLocParts[ 1 ] || parts[ 2 ] != ajaxLocParts[ 2 ] ||
7309                                         ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? 80 : 443 ) ) !=
7310                                                 ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) ) )
7311                         );
7312                 }
7313
7314                 // Convert data if not already a string
7315                 if ( s.data && s.processData && typeof s.data !== "string" ) {
7316                         s.data = jQuery.param( s.data, s.traditional );
7317                 }
7318
7319                 // Apply prefilters
7320                 inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
7321
7322                 // If request was aborted inside a prefiler, stop there
7323                 if ( state === 2 ) {
7324                         return false;
7325                 }
7326
7327                 // We can fire global events as of now if asked to
7328                 fireGlobals = s.global;
7329
7330                 // Uppercase the type
7331                 s.type = s.type.toUpperCase();
7332
7333                 // Determine if request has content
7334                 s.hasContent = !rnoContent.test( s.type );
7335
7336                 // Watch for a new set of requests
7337                 if ( fireGlobals && jQuery.active++ === 0 ) {
7338                         jQuery.event.trigger( "ajaxStart" );
7339                 }
7340
7341                 // More options handling for requests with no content
7342                 if ( !s.hasContent ) {
7343
7344                         // If data is available, append data to url
7345                         if ( s.data ) {
7346                                 s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.data;
7347                                 // #9682: remove data so that it's not used in an eventual retry
7348                                 delete s.data;
7349                         }
7350
7351                         // Get ifModifiedKey before adding the anti-cache parameter
7352                         ifModifiedKey = s.url;
7353
7354                         // Add anti-cache in url if needed
7355                         if ( s.cache === false ) {
7356
7357                                 var ts = jQuery.now(),
7358                                         // try replacing _= if it is there
7359                                         ret = s.url.replace( rts, "$1_=" + ts );
7360
7361                                 // if nothing was replaced, add timestamp to the end
7362                                 s.url = ret + ( (ret === s.url ) ? ( rquery.test( s.url ) ? "&" : "?" ) + "_=" + ts : "" );
7363                         }
7364                 }
7365
7366                 // Set the correct header, if data is being sent
7367                 if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
7368                         jqXHR.setRequestHeader( "Content-Type", s.contentType );
7369                 }
7370
7371                 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
7372                 if ( s.ifModified ) {
7373                         ifModifiedKey = ifModifiedKey || s.url;
7374                         if ( jQuery.lastModified[ ifModifiedKey ] ) {
7375                                 jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ ifModifiedKey ] );
7376                         }
7377                         if ( jQuery.etag[ ifModifiedKey ] ) {
7378                                 jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ ifModifiedKey ] );
7379                         }
7380                 }
7381
7382                 // Set the Accepts header for the server, depending on the dataType
7383                 jqXHR.setRequestHeader(
7384                         "Accept",
7385                         s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
7386                                 s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
7387                                 s.accepts[ "*" ]
7388                 );
7389
7390                 // Check for headers option
7391                 for ( i in s.headers ) {
7392                         jqXHR.setRequestHeader( i, s.headers[ i ] );
7393                 }
7394
7395                 // Allow custom headers/mimetypes and early abort
7396                 if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
7397                                 // Abort if not done already
7398                                 jqXHR.abort();
7399                                 return false;
7400
7401                 }
7402
7403                 // Install callbacks on deferreds
7404                 for ( i in { success: 1, error: 1, complete: 1 } ) {
7405                         jqXHR[ i ]( s[ i ] );
7406                 }
7407
7408                 // Get transport
7409                 transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
7410
7411                 // If no transport, we auto-abort
7412                 if ( !transport ) {
7413                         done( -1, "No Transport" );
7414                 } else {
7415                         jqXHR.readyState = 1;
7416                         // Send global event
7417                         if ( fireGlobals ) {
7418                                 globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
7419                         }
7420                         // Timeout
7421                         if ( s.async && s.timeout > 0 ) {
7422                                 timeoutTimer = setTimeout( function(){
7423                                         jqXHR.abort( "timeout" );
7424                                 }, s.timeout );
7425                         }
7426
7427                         try {
7428                                 state = 1;
7429                                 transport.send( requestHeaders, done );
7430                         } catch (e) {
7431                                 // Propagate exception as error if not done
7432                                 if ( state < 2 ) {
7433                                         done( -1, e );
7434                                 // Simply rethrow otherwise
7435                                 } else {
7436                                         jQuery.error( e );
7437                                 }
7438                         }
7439                 }
7440
7441                 return jqXHR;
7442         },
7443
7444         // Serialize an array of form elements or a set of
7445         // key/values into a query string
7446         param: function( a, traditional ) {
7447                 var s = [],
7448                         add = function( key, value ) {
7449                                 // If value is a function, invoke it and return its value
7450                                 value = jQuery.isFunction( value ) ? value() : value;
7451                                 s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
7452                         };
7453
7454                 // Set traditional to true for jQuery <= 1.3.2 behavior.
7455                 if ( traditional === undefined ) {
7456                         traditional = jQuery.ajaxSettings.traditional;
7457                 }
7458
7459                 // If an array was passed in, assume that it is an array of form elements.
7460                 if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
7461                         // Serialize the form elements
7462                         jQuery.each( a, function() {
7463                                 add( this.name, this.value );
7464                         });
7465
7466                 } else {
7467                         // If traditional, encode the "old" way (the way 1.3.2 or older
7468                         // did it), otherwise encode params recursively.
7469                         for ( var prefix in a ) {
7470                                 buildParams( prefix, a[ prefix ], traditional, add );
7471                         }
7472                 }
7473
7474                 // Return the resulting serialization
7475                 return s.join( "&" ).replace( r20, "+" );
7476         }
7477 });
7478
7479 function buildParams( prefix, obj, traditional, add ) {
7480         if ( jQuery.isArray( obj ) ) {
7481                 // Serialize array item.
7482                 jQuery.each( obj, function( i, v ) {
7483                         if ( traditional || rbracket.test( prefix ) ) {
7484                                 // Treat each array item as a scalar.
7485                                 add( prefix, v );
7486
7487                         } else {
7488                                 // If array item is non-scalar (array or object), encode its
7489                                 // numeric index to resolve deserialization ambiguity issues.
7490                                 // Note that rack (as of 1.0.0) can't currently deserialize
7491                                 // nested arrays properly, and attempting to do so may cause
7492                                 // a server error. Possible fixes are to modify rack's
7493                                 // deserialization algorithm or to provide an option or flag
7494                                 // to force array serialization to be shallow.
7495                                 buildParams( prefix + "[" + ( typeof v === "object" || jQuery.isArray(v) ? i : "" ) + "]", v, traditional, add );
7496                         }
7497                 });
7498
7499         } else if ( !traditional && obj != null && typeof obj === "object" ) {
7500                 // Serialize object item.
7501                 for ( var name in obj ) {
7502                         buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
7503                 }
7504
7505         } else {
7506                 // Serialize scalar item.
7507                 add( prefix, obj );
7508         }
7509 }
7510
7511 // This is still on the jQuery object... for now
7512 // Want to move this to jQuery.ajax some day
7513 jQuery.extend({
7514
7515         // Counter for holding the number of active queries
7516         active: 0,
7517
7518         // Last-Modified header cache for next request
7519         lastModified: {},
7520         etag: {}
7521
7522 });
7523
7524 /* Handles responses to an ajax request:
7525  * - sets all responseXXX fields accordingly
7526  * - finds the right dataType (mediates between content-type and expected dataType)
7527  * - returns the corresponding response
7528  */
7529 function ajaxHandleResponses( s, jqXHR, responses ) {
7530
7531         var contents = s.contents,
7532                 dataTypes = s.dataTypes,
7533                 responseFields = s.responseFields,
7534                 ct,
7535                 type,
7536                 finalDataType,
7537                 firstDataType;
7538
7539         // Fill responseXXX fields
7540         for( type in responseFields ) {
7541                 if ( type in responses ) {
7542                         jqXHR[ responseFields[type] ] = responses[ type ];
7543                 }
7544         }
7545
7546         // Remove auto dataType and get content-type in the process
7547         while( dataTypes[ 0 ] === "*" ) {
7548                 dataTypes.shift();
7549                 if ( ct === undefined ) {
7550                         ct = s.mimeType || jqXHR.getResponseHeader( "content-type" );
7551                 }
7552         }
7553
7554         // Check if we're dealing with a known content-type
7555         if ( ct ) {
7556                 for ( type in contents ) {
7557                         if ( contents[ type ] && contents[ type ].test( ct ) ) {
7558                                 dataTypes.unshift( type );
7559                                 break;
7560                         }
7561                 }
7562         }
7563
7564         // Check to see if we have a response for the expected dataType
7565         if ( dataTypes[ 0 ] in responses ) {
7566                 finalDataType = dataTypes[ 0 ];
7567         } else {
7568                 // Try convertible dataTypes
7569                 for ( type in responses ) {
7570                         if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
7571                                 finalDataType = type;
7572                                 break;
7573                         }
7574                         if ( !firstDataType ) {
7575                                 firstDataType = type;
7576                         }
7577                 }
7578                 // Or just use first one
7579                 finalDataType = finalDataType || firstDataType;
7580         }
7581
7582         // If we found a dataType
7583         // We add the dataType to the list if needed
7584         // and return the corresponding response
7585         if ( finalDataType ) {
7586                 if ( finalDataType !== dataTypes[ 0 ] ) {
7587                         dataTypes.unshift( finalDataType );
7588                 }
7589                 return responses[ finalDataType ];
7590         }
7591 }
7592
7593 // Chain conversions given the request and the original response
7594 function ajaxConvert( s, response ) {
7595
7596         // Apply the dataFilter if provided
7597         if ( s.dataFilter ) {
7598                 response = s.dataFilter( response, s.dataType );
7599         }
7600
7601         var dataTypes = s.dataTypes,
7602                 converters = {},
7603                 i,
7604                 key,
7605                 length = dataTypes.length,
7606                 tmp,
7607                 // Current and previous dataTypes
7608                 current = dataTypes[ 0 ],
7609                 prev,
7610                 // Conversion expression
7611                 conversion,
7612                 // Conversion function
7613                 conv,
7614                 // Conversion functions (transitive conversion)
7615                 conv1,
7616                 conv2;
7617
7618         // For each dataType in the chain
7619         for( i = 1; i < length; i++ ) {
7620
7621                 // Create converters map
7622                 // with lowercased keys
7623                 if ( i === 1 ) {
7624                         for( key in s.converters ) {
7625                                 if( typeof key === "string" ) {
7626                                         converters[ key.toLowerCase() ] = s.converters[ key ];
7627                                 }
7628                         }
7629                 }
7630
7631                 // Get the dataTypes
7632                 prev = current;
7633                 current = dataTypes[ i ];
7634
7635                 // If current is auto dataType, update it to prev
7636                 if( current === "*" ) {
7637                         current = prev;
7638                 // If no auto and dataTypes are actually different
7639                 } else if ( prev !== "*" && prev !== current ) {
7640
7641                         // Get the converter
7642                         conversion = prev + " " + current;
7643                         conv = converters[ conversion ] || converters[ "* " + current ];
7644
7645                         // If there is no direct converter, search transitively
7646                         if ( !conv ) {
7647                                 conv2 = undefined;
7648                                 for( conv1 in converters ) {
7649                                         tmp = conv1.split( " " );
7650                                         if ( tmp[ 0 ] === prev || tmp[ 0 ] === "*" ) {
7651                                                 conv2 = converters[ tmp[1] + " " + current ];
7652                                                 if ( conv2 ) {
7653                                                         conv1 = converters[ conv1 ];
7654                                                         if ( conv1 === true ) {
7655                                                                 conv = conv2;
7656                                                         } else if ( conv2 === true ) {
7657                                                                 conv = conv1;
7658                                                         }
7659                                                         break;
7660                                                 }
7661                                         }
7662                                 }
7663                         }
7664                         // If we found no converter, dispatch an error
7665                         if ( !( conv || conv2 ) ) {
7666                                 jQuery.error( "No conversion from " + conversion.replace(" "," to ") );
7667                         }
7668                         // If found converter is not an equivalence
7669                         if ( conv !== true ) {
7670                                 // Convert with 1 or 2 converters accordingly
7671                                 response = conv ? conv( response ) : conv2( conv1(response) );
7672                         }
7673                 }
7674         }
7675         return response;
7676 }
7677
7678
7679
7680
7681 var jsc = jQuery.now(),
7682         jsre = /(\=)\?(&|$)|\?\?/i;
7683
7684 // Default jsonp settings
7685 jQuery.ajaxSetup({
7686         jsonp: "callback",
7687         jsonpCallback: function() {
7688                 return jQuery.expando + "_" + ( jsc++ );
7689         }
7690 });
7691
7692 // Detect, normalize options and install callbacks for jsonp requests
7693 jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
7694
7695         var inspectData = s.contentType === "application/x-www-form-urlencoded" &&
7696                 ( typeof s.data === "string" );
7697
7698         if ( s.dataTypes[ 0 ] === "jsonp" ||
7699                 s.jsonp !== false && ( jsre.test( s.url ) ||
7700                                 inspectData && jsre.test( s.data ) ) ) {
7701
7702                 var responseContainer,
7703                         jsonpCallback = s.jsonpCallback =
7704                                 jQuery.isFunction( s.jsonpCallback ) ? s.jsonpCallback() : s.jsonpCallback,
7705                         previous = window[ jsonpCallback ],
7706                         url = s.url,
7707                         data = s.data,
7708                         replace = "$1" + jsonpCallback + "$2";
7709
7710                 if ( s.jsonp !== false ) {
7711                         url = url.replace( jsre, replace );
7712                         if ( s.url === url ) {
7713                                 if ( inspectData ) {
7714                                         data = data.replace( jsre, replace );
7715                                 }
7716                                 if ( s.data === data ) {
7717                                         // Add callback manually
7718                                         url += (/\?/.test( url ) ? "&" : "?") + s.jsonp + "=" + jsonpCallback;
7719                                 }
7720                         }
7721                 }
7722
7723                 s.url = url;
7724                 s.data = data;
7725
7726                 // Install callback
7727                 window[ jsonpCallback ] = function( response ) {
7728                         responseContainer = [ response ];
7729                 };
7730
7731                 // Clean-up function
7732                 jqXHR.always(function() {
7733                         // Set callback back to previous value
7734                         window[ jsonpCallback ] = previous;
7735                         // Call if it was a function and we have a response
7736                         if ( responseContainer && jQuery.isFunction( previous ) ) {
7737                                 window[ jsonpCallback ]( responseContainer[ 0 ] );
7738                         }
7739                 });
7740
7741                 // Use data converter to retrieve json after script execution
7742                 s.converters["script json"] = function() {
7743                         if ( !responseContainer ) {
7744                                 jQuery.error( jsonpCallback + " was not called" );
7745                         }
7746                         return responseContainer[ 0 ];
7747                 };
7748
7749                 // force json dataType
7750                 s.dataTypes[ 0 ] = "json";
7751
7752                 // Delegate to script
7753                 return "script";
7754         }
7755 });
7756
7757
7758
7759
7760 // Install script dataType
7761 jQuery.ajaxSetup({
7762         accepts: {
7763                 script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
7764         },
7765         contents: {
7766                 script: /javascript|ecmascript/
7767         },
7768         converters: {
7769                 "text script": function( text ) {
7770                         jQuery.globalEval( text );
7771                         return text;
7772                 }
7773         }
7774 });
7775
7776 // Handle cache's special case and global
7777 jQuery.ajaxPrefilter( "script", function( s ) {
7778         if ( s.cache === undefined ) {
7779                 s.cache = false;
7780         }
7781         if ( s.crossDomain ) {
7782                 s.type = "GET";
7783                 s.global = false;
7784         }
7785 });
7786
7787 // Bind script tag hack transport
7788 jQuery.ajaxTransport( "script", function(s) {
7789
7790         // This transport only deals with cross domain requests
7791         if ( s.crossDomain ) {
7792
7793                 var script,
7794                         head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement;
7795
7796                 return {
7797
7798                         send: function( _, callback ) {
7799
7800                                 script = document.createElement( "script" );
7801
7802                                 script.async = "async";
7803
7804                                 if ( s.scriptCharset ) {
7805                                         script.charset = s.scriptCharset;
7806                                 }
7807
7808                                 script.src = s.url;
7809
7810                                 // Attach handlers for all browsers
7811                                 script.onload = script.onreadystatechange = function( _, isAbort ) {
7812
7813                                         if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) {
7814
7815                                                 // Handle memory leak in IE
7816                                                 script.onload = script.onreadystatechange = null;
7817
7818                                                 // Remove the script
7819                                                 if ( head && script.parentNode ) {
7820                                                         head.removeChild( script );
7821                                                 }
7822
7823                                                 // Dereference the script
7824                                                 script = undefined;
7825
7826                                                 // Callback if not abort
7827                                                 if ( !isAbort ) {
7828                                                         callback( 200, "success" );
7829                                                 }
7830                                         }
7831                                 };
7832                                 // Use insertBefore instead of appendChild  to circumvent an IE6 bug.
7833                                 // This arises when a base node is used (#2709 and #4378).
7834                                 head.insertBefore( script, head.firstChild );
7835                         },
7836
7837                         abort: function() {
7838                                 if ( script ) {
7839                                         script.onload( 0, 1 );
7840                                 }
7841                         }
7842                 };
7843         }
7844 });
7845
7846
7847
7848
7849 var // #5280: Internet Explorer will keep connections alive if we don't abort on unload
7850         xhrOnUnloadAbort = window.ActiveXObject ? function() {
7851                 // Abort all pending requests
7852                 for ( var key in xhrCallbacks ) {
7853                         xhrCallbacks[ key ]( 0, 1 );
7854                 }
7855         } : false,
7856         xhrId = 0,
7857         xhrCallbacks;
7858
7859 // Functions to create xhrs
7860 function createStandardXHR() {
7861         try {
7862                 return new window.XMLHttpRequest();
7863         } catch( e ) {}
7864 }
7865
7866 function createActiveXHR() {
7867         try {
7868                 return new window.ActiveXObject( "Microsoft.XMLHTTP" );
7869         } catch( e ) {}
7870 }
7871
7872 // Create the request object
7873 // (This is still attached to ajaxSettings for backward compatibility)
7874 jQuery.ajaxSettings.xhr = window.ActiveXObject ?
7875         /* Microsoft failed to properly
7876          * implement the XMLHttpRequest in IE7 (can't request local files),
7877          * so we use the ActiveXObject when it is available
7878          * Additionally XMLHttpRequest can be disabled in IE7/IE8 so
7879          * we need a fallback.
7880          */
7881         function() {
7882                 return !this.isLocal && createStandardXHR() || createActiveXHR();
7883         } :
7884         // For all other browsers, use the standard XMLHttpRequest object
7885         createStandardXHR;
7886
7887 // Determine support properties
7888 (function( xhr ) {
7889         jQuery.extend( jQuery.support, {
7890                 ajax: !!xhr,
7891                 cors: !!xhr && ( "withCredentials" in xhr )
7892         });
7893 })( jQuery.ajaxSettings.xhr() );
7894
7895 // Create transport if the browser can provide an xhr
7896 if ( jQuery.support.ajax ) {
7897
7898         jQuery.ajaxTransport(function( s ) {
7899                 // Cross domain only allowed if supported through XMLHttpRequest
7900                 if ( !s.crossDomain || jQuery.support.cors ) {
7901
7902                         var callback;
7903
7904                         return {
7905                                 send: function( headers, complete ) {
7906
7907                                         // Get a new xhr
7908                                         var xhr = s.xhr(),
7909                                                 handle,
7910                                                 i;
7911
7912                                         // Open the socket
7913                                         // Passing null username, generates a login popup on Opera (#2865)
7914                                         if ( s.username ) {
7915                                                 xhr.open( s.type, s.url, s.async, s.username, s.password );
7916                                         } else {
7917                                                 xhr.open( s.type, s.url, s.async );
7918                                         }
7919
7920                                         // Apply custom fields if provided
7921                                         if ( s.xhrFields ) {
7922                                                 for ( i in s.xhrFields ) {
7923                                                         xhr[ i ] = s.xhrFields[ i ];
7924                                                 }
7925                                         }
7926
7927                                         // Override mime type if needed
7928                                         if ( s.mimeType && xhr.overrideMimeType ) {
7929                                                 xhr.overrideMimeType( s.mimeType );
7930                                         }
7931
7932                                         // X-Requested-With header
7933                                         // For cross-domain requests, seeing as conditions for a preflight are
7934                                         // akin to a jigsaw puzzle, we simply never set it to be sure.
7935                                         // (it can always be set on a per-request basis or even using ajaxSetup)
7936                                         // For same-domain requests, won't change header if already provided.
7937                                         if ( !s.crossDomain && !headers["X-Requested-With"] ) {
7938                                                 headers[ "X-Requested-With" ] = "XMLHttpRequest";
7939                                         }
7940
7941                                         // Need an extra try/catch for cross domain requests in Firefox 3
7942                                         try {
7943                                                 for ( i in headers ) {
7944                                                         xhr.setRequestHeader( i, headers[ i ] );
7945                                                 }
7946                                         } catch( _ ) {}
7947
7948                                         // Do send the request
7949                                         // This may raise an exception which is actually
7950                                         // handled in jQuery.ajax (so no try/catch here)
7951                                         xhr.send( ( s.hasContent && s.data ) || null );
7952
7953                                         // Listener
7954                                         callback = function( _, isAbort ) {
7955
7956                                                 var status,
7957                                                         statusText,
7958                                                         responseHeaders,
7959                                                         responses,
7960                                                         xml;
7961
7962                                                 // Firefox throws exceptions when accessing properties
7963                                                 // of an xhr when a network error occured
7964                                                 // http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE)
7965                                                 try {
7966
7967                                                         // Was never called and is aborted or complete
7968                                                         if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
7969
7970                                                                 // Only called once
7971                                                                 callback = undefined;
7972
7973                                                                 // Do not keep as active anymore
7974                                                                 if ( handle ) {
7975                                                                         xhr.onreadystatechange = jQuery.noop;
7976                                                                         if ( xhrOnUnloadAbort ) {
7977                                                                                 delete xhrCallbacks[ handle ];
7978                                                                         }
7979                                                                 }
7980
7981                                                                 // If it's an abort
7982                                                                 if ( isAbort ) {
7983                                                                         // Abort it manually if needed
7984                                                                         if ( xhr.readyState !== 4 ) {
7985                                                                                 xhr.abort();
7986                                                                         }
7987                                                                 } else {
7988                                                                         status = xhr.status;
7989                                                                         responseHeaders = xhr.getAllResponseHeaders();
7990                                                                         responses = {};
7991                                                                         xml = xhr.responseXML;
7992
7993                                                                         // Construct response list
7994                                                                         if ( xml && xml.documentElement /* #4958 */ ) {
7995                                                                                 responses.xml = xml;
7996                                                                         }
7997                                                                         responses.text = xhr.responseText;
7998
7999                                                                         // Firefox throws an exception when accessing
8000                                                                         // statusText for faulty cross-domain requests
8001                                                                         try {
8002                                                                                 statusText = xhr.statusText;
8003                                                                         } catch( e ) {
8004                                                                                 // We normalize with Webkit giving an empty statusText
8005                                                                                 statusText = "";
8006                                                                         }
8007
8008                                                                         // Filter status for non standard behaviors
8009
8010                                                                         // If the request is local and we have data: assume a success
8011                                                                         // (success with no data won't get notified, that's the best we
8012                                                                         // can do given current implementations)
8013                                                                         if ( !status && s.isLocal && !s.crossDomain ) {
8014                                                                                 status = responses.text ? 200 : 404;
8015                                                                         // IE - #1450: sometimes returns 1223 when it should be 204
8016                                                                         } else if ( status === 1223 ) {
8017                                                                                 status = 204;
8018                                                                         }
8019                                                                 }
8020                                                         }
8021                                                 } catch( firefoxAccessException ) {
8022                                                         if ( !isAbort ) {
8023                                                                 complete( -1, firefoxAccessException );
8024                                                         }
8025                                                 }
8026
8027                                                 // Call complete if needed
8028                                                 if ( responses ) {
8029                                                         complete( status, statusText, responses, responseHeaders );
8030                                                 }
8031                                         };
8032
8033                                         // if we're in sync mode or it's in cache
8034                                         // and has been retrieved directly (IE6 & IE7)
8035                                         // we need to manually fire the callback
8036                                         if ( !s.async || xhr.readyState === 4 ) {
8037                                                 callback();
8038                                         } else {
8039                                                 handle = ++xhrId;
8040                                                 if ( xhrOnUnloadAbort ) {
8041                                                         // Create the active xhrs callbacks list if needed
8042                                                         // and attach the unload handler
8043                                                         if ( !xhrCallbacks ) {
8044                                                                 xhrCallbacks = {};
8045                                                                 jQuery( window ).unload( xhrOnUnloadAbort );
8046                                                         }
8047                                                         // Add to list of active xhrs callbacks
8048                                                         xhrCallbacks[ handle ] = callback;
8049                                                 }
8050                                                 xhr.onreadystatechange = callback;
8051                                         }
8052                                 },
8053
8054                                 abort: function() {
8055                                         if ( callback ) {
8056                                                 callback(0,1);
8057                                         }
8058                                 }
8059                         };
8060                 }
8061         });
8062 }
8063
8064
8065
8066
8067 var elemdisplay = {},
8068         iframe, iframeDoc,
8069         rfxtypes = /^(?:toggle|show|hide)$/,
8070         rfxnum = /^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,
8071         timerId,
8072         fxAttrs = [
8073                 // height animations
8074                 [ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom" ],
8075                 // width animations
8076                 [ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ],
8077                 // opacity animations
8078                 [ "opacity" ]
8079         ],
8080         fxNow;
8081
8082 jQuery.fn.extend({
8083         show: function( speed, easing, callback ) {
8084                 var elem, display;
8085
8086                 if ( speed || speed === 0 ) {
8087                         return this.animate( genFx("show", 3), speed, easing, callback);
8088
8089                 } else {
8090                         for ( var i = 0, j = this.length; i < j; i++ ) {
8091                                 elem = this[i];
8092
8093                                 if ( elem.style ) {
8094                                         display = elem.style.display;
8095
8096                                         // Reset the inline display of this element to learn if it is
8097                                         // being hidden by cascaded rules or not
8098                                         if ( !jQuery._data(elem, "olddisplay") && display === "none" ) {
8099                                                 display = elem.style.display = "";
8100                                         }
8101
8102                                         // Set elements which have been overridden with display: none
8103                                         // in a stylesheet to whatever the default browser style is
8104                                         // for such an element
8105                                         if ( display === "" && jQuery.css( elem, "display" ) === "none" ) {
8106                                                 jQuery._data(elem, "olddisplay", defaultDisplay(elem.nodeName));
8107                                         }
8108                                 }
8109                         }
8110
8111                         // Set the display of most of the elements in a second loop
8112                         // to avoid the constant reflow
8113                         for ( i = 0; i < j; i++ ) {
8114                                 elem = this[i];
8115
8116                                 if ( elem.style ) {
8117                                         display = elem.style.display;
8118
8119                                         if ( display === "" || display === "none" ) {
8120                                                 elem.style.display = jQuery._data(elem, "olddisplay") || "";
8121                                         }
8122                                 }
8123                         }
8124
8125                         return this;
8126                 }
8127         },
8128
8129         hide: function( speed, easing, callback ) {
8130                 if ( speed || speed === 0 ) {
8131                         return this.animate( genFx("hide", 3), speed, easing, callback);
8132
8133                 } else {
8134                         for ( var i = 0, j = this.length; i < j; i++ ) {
8135                                 if ( this[i].style ) {
8136                                         var display = jQuery.css( this[i], "display" );
8137
8138                                         if ( display !== "none" && !jQuery._data( this[i], "olddisplay" ) ) {
8139                                                 jQuery._data( this[i], "olddisplay", display );
8140                                         }
8141                                 }
8142                         }
8143
8144                         // Set the display of the elements in a second loop
8145                         // to avoid the constant reflow
8146                         for ( i = 0; i < j; i++ ) {
8147                                 if ( this[i].style ) {
8148                                         this[i].style.display = "none";
8149                                 }
8150                         }
8151
8152                         return this;
8153                 }
8154         },
8155
8156         // Save the old toggle function
8157         _toggle: jQuery.fn.toggle,
8158
8159         toggle: function( fn, fn2, callback ) {
8160                 var bool = typeof fn === "boolean";
8161
8162                 if ( jQuery.isFunction(fn) && jQuery.isFunction(fn2) ) {
8163                         this._toggle.apply( this, arguments );
8164
8165                 } else if ( fn == null || bool ) {
8166                         this.each(function() {
8167                                 var state = bool ? fn : jQuery(this).is(":hidden");
8168                                 jQuery(this)[ state ? "show" : "hide" ]();
8169                         });
8170
8171                 } else {
8172                         this.animate(genFx("toggle", 3), fn, fn2, callback);
8173                 }
8174
8175                 return this;
8176         },
8177
8178         fadeTo: function( speed, to, easing, callback ) {
8179                 return this.filter(":hidden").css("opacity", 0).show().end()
8180                                         .animate({opacity: to}, speed, easing, callback);
8181         },
8182
8183         animate: function( prop, speed, easing, callback ) {
8184                 var optall = jQuery.speed(speed, easing, callback);
8185
8186                 if ( jQuery.isEmptyObject( prop ) ) {
8187                         return this.each( optall.complete, [ false ] );
8188                 }
8189
8190                 // Do not change referenced properties as per-property easing will be lost
8191                 prop = jQuery.extend( {}, prop );
8192
8193                 return this[ optall.queue === false ? "each" : "queue" ](function() {
8194                         // XXX 'this' does not always have a nodeName when running the
8195                         // test suite
8196
8197                         if ( optall.queue === false ) {
8198                                 jQuery._mark( this );
8199                         }
8200
8201                         var opt = jQuery.extend( {}, optall ),
8202                                 isElement = this.nodeType === 1,
8203                                 hidden = isElement && jQuery(this).is(":hidden"),
8204                                 name, val, p,
8205                                 display, e,
8206                                 parts, start, end, unit;
8207
8208                         // will store per property easing and be used to determine when an animation is complete
8209                         opt.animatedProperties = {};
8210
8211                         for ( p in prop ) {
8212
8213                                 // property name normalization
8214                                 name = jQuery.camelCase( p );
8215                                 if ( p !== name ) {
8216                                         prop[ name ] = prop[ p ];
8217                                         delete prop[ p ];
8218                                 }
8219
8220                                 val = prop[ name ];
8221
8222                                 // easing resolution: per property > opt.specialEasing > opt.easing > 'swing' (default)
8223                                 if ( jQuery.isArray( val ) ) {
8224                                         opt.animatedProperties[ name ] = val[ 1 ];
8225                                         val = prop[ name ] = val[ 0 ];
8226                                 } else {
8227                                         opt.animatedProperties[ name ] = opt.specialEasing && opt.specialEasing[ name ] || opt.easing || 'swing';
8228                                 }
8229
8230                                 if ( val === "hide" && hidden || val === "show" && !hidden ) {
8231                                         return opt.complete.call( this );
8232                                 }
8233
8234                                 if ( isElement && ( name === "height" || name === "width" ) ) {
8235                                         // Make sure that nothing sneaks out
8236                                         // Record all 3 overflow attributes because IE does not
8237                                         // change the overflow attribute when overflowX and
8238                                         // overflowY are set to the same value
8239                                         opt.overflow = [ this.style.overflow, this.style.overflowX, this.style.overflowY ];
8240
8241                                         // Set display property to inline-block for height/width
8242                                         // animations on inline elements that are having width/height
8243                                         // animated
8244                                         if ( jQuery.css( this, "display" ) === "inline" &&
8245                                                         jQuery.css( this, "float" ) === "none" ) {
8246                                                 if ( !jQuery.support.inlineBlockNeedsLayout ) {
8247                                                         this.style.display = "inline-block";
8248
8249                                                 } else {
8250                                                         display = defaultDisplay( this.nodeName );
8251
8252                                                         // inline-level elements accept inline-block;
8253                                                         // block-level elements need to be inline with layout
8254                                                         if ( display === "inline" ) {
8255                                                                 this.style.display = "inline-block";
8256
8257                                                         } else {
8258                                                                 this.style.display = "inline";
8259                                                                 this.style.zoom = 1;
8260                                                         }
8261                                                 }
8262                                         }
8263                                 }
8264                         }
8265
8266                         if ( opt.overflow != null ) {
8267                                 this.style.overflow = "hidden";
8268                         }
8269
8270                         for ( p in prop ) {
8271                                 e = new jQuery.fx( this, opt, p );
8272                                 val = prop[ p ];
8273
8274                                 if ( rfxtypes.test(val) ) {
8275                                         e[ val === "toggle" ? hidden ? "show" : "hide" : val ]();
8276
8277                                 } else {
8278                                         parts = rfxnum.exec( val );
8279                                         start = e.cur();
8280
8281                                         if ( parts ) {
8282                                                 end = parseFloat( parts[2] );
8283                                                 unit = parts[3] || ( jQuery.cssNumber[ p ] ? "" : "px" );
8284
8285                                                 // We need to compute starting value
8286                                                 if ( unit !== "px" ) {
8287                                                         jQuery.style( this, p, (end || 1) + unit);
8288                                                         start = ((end || 1) / e.cur()) * start;
8289                                                         jQuery.style( this, p, start + unit);
8290                                                 }
8291
8292                                                 // If a +=/-= token was provided, we're doing a relative animation
8293                                                 if ( parts[1] ) {
8294                                                         end = ( (parts[ 1 ] === "-=" ? -1 : 1) * end ) + start;
8295                                                 }
8296
8297                                                 e.custom( start, end, unit );
8298
8299                                         } else {
8300                                                 e.custom( start, val, "" );
8301                                         }
8302                                 }
8303                         }
8304
8305                         // For JS strict compliance
8306                         return true;
8307                 });
8308         },
8309
8310         stop: function( clearQueue, gotoEnd ) {
8311                 if ( clearQueue ) {
8312                         this.queue([]);
8313                 }
8314
8315                 this.each(function() {
8316                         var timers = jQuery.timers,
8317                                 i = timers.length;
8318                         // clear marker counters if we know they won't be
8319                         if ( !gotoEnd ) {
8320                                 jQuery._unmark( true, this );
8321                         }
8322                         while ( i-- ) {
8323                                 if ( timers[i].elem === this ) {
8324                                         if (gotoEnd) {
8325                                                 // force the next step to be the last
8326                                                 timers[i](true);
8327                                         }
8328
8329                                         timers.splice(i, 1);
8330                                 }
8331                         }
8332                 });
8333
8334                 // start the next in the queue if the last step wasn't forced
8335                 if ( !gotoEnd ) {
8336                         this.dequeue();
8337                 }
8338
8339                 return this;
8340         }
8341
8342 });
8343
8344 // Animations created synchronously will run synchronously
8345 function createFxNow() {
8346         setTimeout( clearFxNow, 0 );
8347         return ( fxNow = jQuery.now() );
8348 }
8349
8350 function clearFxNow() {
8351         fxNow = undefined;
8352 }
8353
8354 // Generate parameters to create a standard animation
8355 function genFx( type, num ) {
8356         var obj = {};
8357
8358         jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice(0,num)), function() {
8359                 obj[ this ] = type;
8360         });
8361
8362         return obj;
8363 }
8364
8365 // Generate shortcuts for custom animations
8366 jQuery.each({
8367         slideDown: genFx("show", 1),
8368         slideUp: genFx("hide", 1),
8369         slideToggle: genFx("toggle", 1),
8370         fadeIn: { opacity: "show" },
8371         fadeOut: { opacity: "hide" },
8372         fadeToggle: { opacity: "toggle" }
8373 }, function( name, props ) {
8374         jQuery.fn[ name ] = function( speed, easing, callback ) {
8375                 return this.animate( props, speed, easing, callback );
8376         };
8377 });
8378
8379 jQuery.extend({
8380         speed: function( speed, easing, fn ) {
8381                 var opt = speed && typeof speed === "object" ? jQuery.extend({}, speed) : {
8382                         complete: fn || !fn && easing ||
8383                                 jQuery.isFunction( speed ) && speed,
8384                         duration: speed,
8385                         easing: fn && easing || easing && !jQuery.isFunction(easing) && easing
8386                 };
8387
8388                 opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
8389                         opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[opt.duration] : jQuery.fx.speeds._default;
8390
8391                 // Queueing
8392                 opt.old = opt.complete;
8393                 opt.complete = function( noUnmark ) {
8394                         if ( jQuery.isFunction( opt.old ) ) {
8395                                 opt.old.call( this );
8396                         }
8397
8398                         if ( opt.queue !== false ) {
8399                                 jQuery.dequeue( this );
8400                         } else if ( noUnmark !== false ) {
8401                                 jQuery._unmark( this );
8402                         }
8403                 };
8404
8405                 return opt;
8406         },
8407
8408         easing: {
8409                 linear: function( p, n, firstNum, diff ) {
8410                         return firstNum + diff * p;
8411                 },
8412                 swing: function( p, n, firstNum, diff ) {
8413                         return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum;
8414                 }
8415         },
8416
8417         timers: [],
8418
8419         fx: function( elem, options, prop ) {
8420                 this.options = options;
8421                 this.elem = elem;
8422                 this.prop = prop;
8423
8424                 options.orig = options.orig || {};
8425         }
8426
8427 });
8428
8429 jQuery.fx.prototype = {
8430         // Simple function for setting a style value
8431         update: function() {
8432                 if ( this.options.step ) {
8433                         this.options.step.call( this.elem, this.now, this );
8434                 }
8435
8436                 (jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this );
8437         },
8438
8439         // Get the current size
8440         cur: function() {
8441                 if ( this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null) ) {
8442                         return this.elem[ this.prop ];
8443                 }
8444
8445                 var parsed,
8446                         r = jQuery.css( this.elem, this.prop );
8447                 // Empty strings, null, undefined and "auto" are converted to 0,
8448                 // complex values such as "rotate(1rad)" are returned as is,
8449                 // simple values such as "10px" are parsed to Float.
8450                 return isNaN( parsed = parseFloat( r ) ) ? !r || r === "auto" ? 0 : r : parsed;
8451         },
8452
8453         // Start an animation from one number to another
8454         custom: function( from, to, unit ) {
8455                 var self = this,
8456                         fx = jQuery.fx;
8457
8458                 this.startTime = fxNow || createFxNow();
8459                 this.start = from;
8460                 this.end = to;
8461                 this.unit = unit || this.unit || ( jQuery.cssNumber[ this.prop ] ? "" : "px" );
8462                 this.now = this.start;
8463                 this.pos = this.state = 0;
8464
8465                 function t( gotoEnd ) {
8466                         return self.step(gotoEnd);
8467                 }
8468
8469                 t.elem = this.elem;
8470
8471                 if ( t() && jQuery.timers.push(t) && !timerId ) {
8472                         timerId = setInterval( fx.tick, fx.interval );
8473                 }
8474         },
8475
8476         // Simple 'show' function
8477         show: function() {
8478                 // Remember where we started, so that we can go back to it later
8479                 this.options.orig[this.prop] = jQuery.style( this.elem, this.prop );
8480                 this.options.show = true;
8481
8482                 // Begin the animation
8483                 // Make sure that we start at a small width/height to avoid any
8484                 // flash of content
8485                 this.custom(this.prop === "width" || this.prop === "height" ? 1 : 0, this.cur());
8486
8487                 // Start by showing the element
8488                 jQuery( this.elem ).show();
8489         },
8490
8491         // Simple 'hide' function
8492         hide: function() {
8493                 // Remember where we started, so that we can go back to it later
8494                 this.options.orig[this.prop] = jQuery.style( this.elem, this.prop );
8495                 this.options.hide = true;
8496
8497                 // Begin the animation
8498                 this.custom(this.cur(), 0);
8499         },
8500
8501         // Each step of an animation
8502         step: function( gotoEnd ) {
8503                 var t = fxNow || createFxNow(),
8504                         done = true,
8505                         elem = this.elem,
8506                         options = this.options,
8507                         i, n;
8508
8509                 if ( gotoEnd || t >= options.duration + this.startTime ) {
8510                         this.now = this.end;
8511                         this.pos = this.state = 1;
8512                         this.update();
8513
8514                         options.animatedProperties[ this.prop ] = true;
8515
8516                         for ( i in options.animatedProperties ) {
8517                                 if ( options.animatedProperties[i] !== true ) {
8518                                         done = false;
8519                                 }
8520                         }
8521
8522                         if ( done ) {
8523                                 // Reset the overflow
8524                                 if ( options.overflow != null && !jQuery.support.shrinkWrapBlocks ) {
8525
8526                                         jQuery.each( [ "", "X", "Y" ], function (index, value) {
8527                                                 elem.style[ "overflow" + value ] = options.overflow[index];
8528                                         });
8529                                 }
8530
8531                                 // Hide the element if the "hide" operation was done
8532                                 if ( options.hide ) {
8533                                         jQuery(elem).hide();
8534                                 }
8535
8536                                 // Reset the properties, if the item has been hidden or shown
8537                                 if ( options.hide || options.show ) {
8538                                         for ( var p in options.animatedProperties ) {
8539                                                 jQuery.style( elem, p, options.orig[p] );
8540                                         }
8541                                 }
8542
8543                                 // Execute the complete function
8544                                 options.complete.call( elem );
8545                         }
8546
8547                         return false;
8548
8549                 } else {
8550                         // classical easing cannot be used with an Infinity duration
8551                         if ( options.duration == Infinity ) {
8552                                 this.now = t;
8553                         } else {
8554                                 n = t - this.startTime;
8555                                 this.state = n / options.duration;
8556
8557                                 // Perform the easing function, defaults to swing
8558                                 this.pos = jQuery.easing[ options.animatedProperties[ this.prop ] ]( this.state, n, 0, 1, options.duration );
8559                                 this.now = this.start + ((this.end - this.start) * this.pos);
8560                         }
8561                         // Perform the next step of the animation
8562                         this.update();
8563                 }
8564
8565                 return true;
8566         }
8567 };
8568
8569 jQuery.extend( jQuery.fx, {
8570         tick: function() {
8571                 for ( var timers = jQuery.timers, i = 0 ; i < timers.length ; ++i ) {
8572                         if ( !timers[i]() ) {
8573                                 timers.splice(i--, 1);
8574                         }
8575                 }
8576
8577                 if ( !timers.length ) {
8578                         jQuery.fx.stop();
8579                 }
8580         },
8581
8582         interval: 13,
8583
8584         stop: function() {
8585                 clearInterval( timerId );
8586                 timerId = null;
8587         },
8588
8589         speeds: {
8590                 slow: 600,
8591                 fast: 200,
8592                 // Default speed
8593                 _default: 400
8594         },
8595
8596         step: {
8597                 opacity: function( fx ) {
8598                         jQuery.style( fx.elem, "opacity", fx.now );
8599                 },
8600
8601                 _default: function( fx ) {
8602                         if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) {
8603                                 fx.elem.style[ fx.prop ] = (fx.prop === "width" || fx.prop === "height" ? Math.max(0, fx.now) : fx.now) + fx.unit;
8604                         } else {
8605                                 fx.elem[ fx.prop ] = fx.now;
8606                         }
8607                 }
8608         }
8609 });
8610
8611 if ( jQuery.expr && jQuery.expr.filters ) {
8612         jQuery.expr.filters.animated = function( elem ) {
8613                 return jQuery.grep(jQuery.timers, function( fn ) {
8614                         return elem === fn.elem;
8615                 }).length;
8616         };
8617 }
8618
8619 // Try to restore the default display value of an element
8620 function defaultDisplay( nodeName ) {
8621
8622         if ( !elemdisplay[ nodeName ] ) {
8623
8624                 var body = document.body,
8625                         elem = jQuery( "<" + nodeName + ">" ).appendTo( body ),
8626                         display = elem.css( "display" );
8627
8628                 elem.remove();
8629
8630                 // If the simple way fails,
8631                 // get element's real default display by attaching it to a temp iframe
8632                 if ( display === "none" || display === "" ) {
8633                         // No iframe to use yet, so create it
8634                         if ( !iframe ) {
8635                                 iframe = document.createElement( "iframe" );
8636                                 iframe.frameBorder = iframe.width = iframe.height = 0;
8637                         }
8638
8639                         body.appendChild( iframe );
8640
8641                         // Create a cacheable copy of the iframe document on first call.
8642                         // IE and Opera will allow us to reuse the iframeDoc without re-writing the fake HTML
8643                         // document to it; WebKit & Firefox won't allow reusing the iframe document.
8644                         if ( !iframeDoc || !iframe.createElement ) {
8645                                 iframeDoc = ( iframe.contentWindow || iframe.contentDocument ).document;
8646                                 iframeDoc.write( ( document.compatMode === "CSS1Compat" ? "<!doctype html>" : "" ) + "<html><body>" );
8647                                 iframeDoc.close();
8648                         }
8649
8650                         elem = iframeDoc.createElement( nodeName );
8651
8652                         iframeDoc.body.appendChild( elem );
8653
8654                         display = jQuery.css( elem, "display" );
8655
8656                         body.removeChild( iframe );
8657                 }
8658
8659                 // Store the correct default display
8660                 elemdisplay[ nodeName ] = display;
8661         }
8662
8663         return elemdisplay[ nodeName ];
8664 }
8665
8666
8667
8668
8669 var rtable = /^t(?:able|d|h)$/i,
8670         rroot = /^(?:body|html)$/i;
8671
8672 if ( "getBoundingClientRect" in document.documentElement ) {
8673         jQuery.fn.offset = function( options ) {
8674                 var elem = this[0], box;
8675
8676                 if ( options ) {
8677                         return this.each(function( i ) {
8678                                 jQuery.offset.setOffset( this, options, i );
8679                         });
8680                 }
8681
8682                 if ( !elem || !elem.ownerDocument ) {
8683                         return null;
8684                 }
8685
8686                 if ( elem === elem.ownerDocument.body ) {
8687                         return jQuery.offset.bodyOffset( elem );
8688                 }
8689
8690                 try {
8691                         box = elem.getBoundingClientRect();
8692                 } catch(e) {}
8693
8694                 var doc = elem.ownerDocument,
8695                         docElem = doc.documentElement;
8696
8697                 // Make sure we're not dealing with a disconnected DOM node
8698                 if ( !box || !jQuery.contains( docElem, elem ) ) {
8699                         return box ? { top: box.top, left: box.left } : { top: 0, left: 0 };
8700                 }
8701
8702                 var body = doc.body,
8703                         win = getWindow(doc),
8704                         clientTop  = docElem.clientTop  || body.clientTop  || 0,
8705                         clientLeft = docElem.clientLeft || body.clientLeft || 0,
8706                         scrollTop  = win.pageYOffset || jQuery.support.boxModel && docElem.scrollTop  || body.scrollTop,
8707                         scrollLeft = win.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft,
8708                         top  = box.top  + scrollTop  - clientTop,
8709                         left = box.left + scrollLeft - clientLeft;
8710
8711                 return { top: top, left: left };
8712         };
8713
8714 } else {
8715         jQuery.fn.offset = function( options ) {
8716                 var elem = this[0];
8717
8718                 if ( options ) {
8719                         return this.each(function( i ) {
8720                                 jQuery.offset.setOffset( this, options, i );
8721                         });
8722                 }
8723
8724                 if ( !elem || !elem.ownerDocument ) {
8725                         return null;
8726                 }
8727
8728                 if ( elem === elem.ownerDocument.body ) {
8729                         return jQuery.offset.bodyOffset( elem );
8730                 }
8731
8732                 jQuery.offset.initialize();
8733
8734                 var computedStyle,
8735                         offsetParent = elem.offsetParent,
8736                         prevOffsetParent = elem,
8737                         doc = elem.ownerDocument,
8738                         docElem = doc.documentElement,
8739                         body = doc.body,
8740                         defaultView = doc.defaultView,
8741                         prevComputedStyle = defaultView ? defaultView.getComputedStyle( elem, null ) : elem.currentStyle,
8742                         top = elem.offsetTop,
8743                         left = elem.offsetLeft;
8744
8745                 while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) {
8746                         if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) {
8747                                 break;
8748                         }
8749
8750                         computedStyle = defaultView ? defaultView.getComputedStyle(elem, null) : elem.currentStyle;
8751                         top  -= elem.scrollTop;
8752                         left -= elem.scrollLeft;
8753
8754                         if ( elem === offsetParent ) {
8755                                 top  += elem.offsetTop;
8756                                 left += elem.offsetLeft;
8757
8758                                 if ( jQuery.offset.doesNotAddBorder && !(jQuery.offset.doesAddBorderForTableAndCells && rtable.test(elem.nodeName)) ) {
8759                                         top  += parseFloat( computedStyle.borderTopWidth  ) || 0;
8760                                         left += parseFloat( computedStyle.borderLeftWidth ) || 0;
8761                                 }
8762
8763                                 prevOffsetParent = offsetParent;
8764                                 offsetParent = elem.offsetParent;
8765                         }
8766
8767                         if ( jQuery.offset.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) {
8768                                 top  += parseFloat( computedStyle.borderTopWidth  ) || 0;
8769                                 left += parseFloat( computedStyle.borderLeftWidth ) || 0;
8770                         }
8771
8772                         prevComputedStyle = computedStyle;
8773                 }
8774
8775                 if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" ) {
8776                         top  += body.offsetTop;
8777                         left += body.offsetLeft;
8778                 }
8779
8780                 if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) {
8781                         top  += Math.max( docElem.scrollTop, body.scrollTop );
8782                         left += Math.max( docElem.scrollLeft, body.scrollLeft );
8783                 }
8784
8785                 return { top: top, left: left };
8786         };
8787 }
8788
8789 jQuery.offset = {
8790         initialize: function() {
8791                 var body = document.body, container = document.createElement("div"), innerDiv, checkDiv, table, td, bodyMarginTop = parseFloat( jQuery.css(body, "marginTop") ) || 0,
8792                         html = "<div style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;'><div></div></div><table style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>";
8793
8794                 jQuery.extend( container.style, { position: "absolute", top: 0, left: 0, margin: 0, border: 0, width: "1px", height: "1px", visibility: "hidden" } );
8795
8796                 container.innerHTML = html;
8797                 body.insertBefore( container, body.firstChild );
8798                 innerDiv = container.firstChild;
8799                 checkDiv = innerDiv.firstChild;
8800                 td = innerDiv.nextSibling.firstChild.firstChild;
8801
8802                 this.doesNotAddBorder = (checkDiv.offsetTop !== 5);
8803                 this.doesAddBorderForTableAndCells = (td.offsetTop === 5);
8804
8805                 checkDiv.style.position = "fixed";
8806                 checkDiv.style.top = "20px";
8807
8808                 // safari subtracts parent border width here which is 5px
8809                 this.supportsFixedPosition = (checkDiv.offsetTop === 20 || checkDiv.offsetTop === 15);
8810                 checkDiv.style.position = checkDiv.style.top = "";
8811
8812                 innerDiv.style.overflow = "hidden";
8813                 innerDiv.style.position = "relative";
8814
8815                 this.subtractsBorderForOverflowNotVisible = (checkDiv.offsetTop === -5);
8816
8817                 this.doesNotIncludeMarginInBodyOffset = (body.offsetTop !== bodyMarginTop);
8818
8819                 body.removeChild( container );
8820                 jQuery.offset.initialize = jQuery.noop;
8821         },
8822
8823         bodyOffset: function( body ) {
8824                 var top = body.offsetTop,
8825                         left = body.offsetLeft;
8826
8827                 jQuery.offset.initialize();
8828
8829                 if ( jQuery.offset.doesNotIncludeMarginInBodyOffset ) {
8830                         top  += parseFloat( jQuery.css(body, "marginTop") ) || 0;
8831                         left += parseFloat( jQuery.css(body, "marginLeft") ) || 0;
8832                 }
8833
8834                 return { top: top, left: left };
8835         },
8836
8837         setOffset: function( elem, options, i ) {
8838                 var position = jQuery.css( elem, "position" );
8839
8840                 // set position first, in-case top/left are set even on static elem
8841                 if ( position === "static" ) {
8842                         elem.style.position = "relative";
8843                 }
8844
8845                 var curElem = jQuery( elem ),
8846                         curOffset = curElem.offset(),
8847                         curCSSTop = jQuery.css( elem, "top" ),
8848                         curCSSLeft = jQuery.css( elem, "left" ),
8849                         calculatePosition = (position === "absolute" || position === "fixed") && jQuery.inArray("auto", [curCSSTop, curCSSLeft]) > -1,
8850                         props = {}, curPosition = {}, curTop, curLeft;
8851
8852                 // need to be able to calculate position if either top or left is auto and position is either absolute or fixed
8853                 if ( calculatePosition ) {
8854                         curPosition = curElem.position();
8855                         curTop = curPosition.top;
8856                         curLeft = curPosition.left;
8857                 } else {
8858                         curTop = parseFloat( curCSSTop ) || 0;
8859                         curLeft = parseFloat( curCSSLeft ) || 0;
8860                 }
8861
8862                 if ( jQuery.isFunction( options ) ) {
8863                         options = options.call( elem, i, curOffset );
8864                 }
8865
8866                 if (options.top != null) {
8867                         props.top = (options.top - curOffset.top) + curTop;
8868                 }
8869                 if (options.left != null) {
8870                         props.left = (options.left - curOffset.left) + curLeft;
8871                 }
8872
8873                 if ( "using" in options ) {
8874                         options.using.call( elem, props );
8875                 } else {
8876                         curElem.css( props );
8877                 }
8878         }
8879 };
8880
8881
8882 jQuery.fn.extend({
8883         position: function() {
8884                 if ( !this[0] ) {
8885                         return null;
8886                 }
8887
8888                 var elem = this[0],
8889
8890                 // Get *real* offsetParent
8891                 offsetParent = this.offsetParent(),
8892
8893                 // Get correct offsets
8894                 offset       = this.offset(),
8895                 parentOffset = rroot.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset();
8896
8897                 // Subtract element margins
8898                 // note: when an element has margin: auto the offsetLeft and marginLeft
8899                 // are the same in Safari causing offset.left to incorrectly be 0
8900                 offset.top  -= parseFloat( jQuery.css(elem, "marginTop") ) || 0;
8901                 offset.left -= parseFloat( jQuery.css(elem, "marginLeft") ) || 0;
8902
8903                 // Add offsetParent borders
8904                 parentOffset.top  += parseFloat( jQuery.css(offsetParent[0], "borderTopWidth") ) || 0;
8905                 parentOffset.left += parseFloat( jQuery.css(offsetParent[0], "borderLeftWidth") ) || 0;
8906
8907                 // Subtract the two offsets
8908                 return {
8909                         top:  offset.top  - parentOffset.top,
8910                         left: offset.left - parentOffset.left
8911                 };
8912         },
8913
8914         offsetParent: function() {
8915                 return this.map(function() {
8916                         var offsetParent = this.offsetParent || document.body;
8917                         while ( offsetParent && (!rroot.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) {
8918                                 offsetParent = offsetParent.offsetParent;
8919                         }
8920                         return offsetParent;
8921                 });
8922         }
8923 });
8924
8925
8926 // Create scrollLeft and scrollTop methods
8927 jQuery.each( ["Left", "Top"], function( i, name ) {
8928         var method = "scroll" + name;
8929
8930         jQuery.fn[ method ] = function( val ) {
8931                 var elem, win;
8932
8933                 if ( val === undefined ) {
8934                         elem = this[ 0 ];
8935
8936                         if ( !elem ) {
8937                                 return null;
8938                         }
8939
8940                         win = getWindow( elem );
8941
8942                         // Return the scroll offset
8943                         return win ? ("pageXOffset" in win) ? win[ i ? "pageYOffset" : "pageXOffset" ] :
8944                                 jQuery.support.boxModel && win.document.documentElement[ method ] ||
8945                                         win.document.body[ method ] :
8946                                 elem[ method ];
8947                 }
8948
8949                 // Set the scroll offset
8950                 return this.each(function() {
8951                         win = getWindow( this );
8952
8953                         if ( win ) {
8954                                 win.scrollTo(
8955                                         !i ? val : jQuery( win ).scrollLeft(),
8956                                          i ? val : jQuery( win ).scrollTop()
8957                                 );
8958
8959                         } else {
8960                                 this[ method ] = val;
8961                         }
8962                 });
8963         };
8964 });
8965
8966 function getWindow( elem ) {
8967         return jQuery.isWindow( elem ) ?
8968                 elem :
8969                 elem.nodeType === 9 ?
8970                         elem.defaultView || elem.parentWindow :
8971                         false;
8972 }
8973
8974
8975
8976
8977 // Create width, height, innerHeight, innerWidth, outerHeight and outerWidth methods
8978 jQuery.each([ "Height", "Width" ], function( i, name ) {
8979
8980         var type = name.toLowerCase();
8981
8982         // innerHeight and innerWidth
8983         jQuery.fn[ "inner" + name ] = function() {
8984                 var elem = this[0];
8985                 return elem && elem.style ?
8986                         parseFloat( jQuery.css( elem, type, "padding" ) ) :
8987                         null;
8988         };
8989
8990         // outerHeight and outerWidth
8991         jQuery.fn[ "outer" + name ] = function( margin ) {
8992                 var elem = this[0];
8993                 return elem && elem.style ?
8994                         parseFloat( jQuery.css( elem, type, margin ? "margin" : "border" ) ) :
8995                         null;
8996         };
8997
8998         jQuery.fn[ type ] = function( size ) {
8999                 // Get window width or height
9000                 var elem = this[0];
9001                 if ( !elem ) {
9002                         return size == null ? null : this;
9003                 }
9004
9005                 if ( jQuery.isFunction( size ) ) {
9006                         return this.each(function( i ) {
9007                                 var self = jQuery( this );
9008                                 self[ type ]( size.call( this, i, self[ type ]() ) );
9009                         });
9010                 }
9011
9012                 if ( jQuery.isWindow( elem ) ) {
9013                         // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
9014                         // 3rd condition allows Nokia support, as it supports the docElem prop but not CSS1Compat
9015                         var docElemProp = elem.document.documentElement[ "client" + name ],
9016                                 body = elem.document.body;
9017                         return elem.document.compatMode === "CSS1Compat" && docElemProp ||
9018                                 body && body[ "client" + name ] || docElemProp;
9019
9020                 // Get document width or height
9021                 } else if ( elem.nodeType === 9 ) {
9022                         // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
9023                         return Math.max(
9024                                 elem.documentElement["client" + name],
9025                                 elem.body["scroll" + name], elem.documentElement["scroll" + name],
9026                                 elem.body["offset" + name], elem.documentElement["offset" + name]
9027                         );
9028
9029                 // Get or set width or height on the element
9030                 } else if ( size === undefined ) {
9031                         var orig = jQuery.css( elem, type ),
9032                                 ret = parseFloat( orig );
9033
9034                         return jQuery.isNaN( ret ) ? orig : ret;
9035
9036                 // Set the width or height on the element (default to pixels if value is unitless)
9037                 } else {
9038                         return this.css( type, typeof size === "string" ? size : size + "px" );
9039                 }
9040         };
9041
9042 });
9043
9044
9045 // Expose jQuery to the global object
9046 window.jQuery = window.$ = jQuery;
9047 })(window);