~jstys-z/helioviewer.org/client5

« back to all changes in this revision

Viewing changes to lib/jquery-ui/jquery-ui.1.8.18.js

  • Committer: Keith Hughitt
  • Date: 2012-06-12 20:18:46 UTC
  • Revision ID: keith.hughitt@gmail.com-20120612201846-k3nm2g2sznpfumhc
Added latest movies page

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*!
2
 
 * jQuery UI 1.8.18
3
 
 *
4
 
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
5
 
 * Dual licensed under the MIT or GPL Version 2 licenses.
6
 
 * http://jquery.org/license
7
 
 *
8
 
 * http://docs.jquery.com/UI
9
 
 */
10
 
(function( $, undefined ) {
11
 
 
12
 
// prevent duplicate loading
13
 
// this is only a problem because we proxy existing functions
14
 
// and we don't want to double proxy them
15
 
$.ui = $.ui || {};
16
 
if ( $.ui.version ) {
17
 
        return;
18
 
}
19
 
 
20
 
$.extend( $.ui, {
21
 
        version: "1.8.18",
22
 
 
23
 
        keyCode: {
24
 
                ALT: 18,
25
 
                BACKSPACE: 8,
26
 
                CAPS_LOCK: 20,
27
 
                COMMA: 188,
28
 
                COMMAND: 91,
29
 
                COMMAND_LEFT: 91, // COMMAND
30
 
                COMMAND_RIGHT: 93,
31
 
                CONTROL: 17,
32
 
                DELETE: 46,
33
 
                DOWN: 40,
34
 
                END: 35,
35
 
                ENTER: 13,
36
 
                ESCAPE: 27,
37
 
                HOME: 36,
38
 
                INSERT: 45,
39
 
                LEFT: 37,
40
 
                MENU: 93, // COMMAND_RIGHT
41
 
                NUMPAD_ADD: 107,
42
 
                NUMPAD_DECIMAL: 110,
43
 
                NUMPAD_DIVIDE: 111,
44
 
                NUMPAD_ENTER: 108,
45
 
                NUMPAD_MULTIPLY: 106,
46
 
                NUMPAD_SUBTRACT: 109,
47
 
                PAGE_DOWN: 34,
48
 
                PAGE_UP: 33,
49
 
                PERIOD: 190,
50
 
                RIGHT: 39,
51
 
                SHIFT: 16,
52
 
                SPACE: 32,
53
 
                TAB: 9,
54
 
                UP: 38,
55
 
                WINDOWS: 91 // COMMAND
56
 
        }
57
 
});
58
 
 
59
 
// plugins
60
 
$.fn.extend({
61
 
        propAttr: $.fn.prop || $.fn.attr,
62
 
 
63
 
        _focus: $.fn.focus,
64
 
        focus: function( delay, fn ) {
65
 
                return typeof delay === "number" ?
66
 
                        this.each(function() {
67
 
                                var elem = this;
68
 
                                setTimeout(function() {
69
 
                                        $( elem ).focus();
70
 
                                        if ( fn ) {
71
 
                                                fn.call( elem );
72
 
                                        }
73
 
                                }, delay );
74
 
                        }) :
75
 
                        this._focus.apply( this, arguments );
76
 
        },
77
 
 
78
 
        scrollParent: function() {
79
 
                var scrollParent;
80
 
                if (($.browser.msie && (/(static|relative)/).test(this.css('position'))) || (/absolute/).test(this.css('position'))) {
81
 
                        scrollParent = this.parents().filter(function() {
82
 
                                return (/(relative|absolute|fixed)/).test($.curCSS(this,'position',1)) && (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));
83
 
                        }).eq(0);
84
 
                } else {
85
 
                        scrollParent = this.parents().filter(function() {
86
 
                                return (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));
87
 
                        }).eq(0);
88
 
                }
89
 
 
90
 
                return (/fixed/).test(this.css('position')) || !scrollParent.length ? $(document) : scrollParent;
91
 
        },
92
 
 
93
 
        zIndex: function( zIndex ) {
94
 
                if ( zIndex !== undefined ) {
95
 
                        return this.css( "zIndex", zIndex );
96
 
                }
97
 
 
98
 
                if ( this.length ) {
99
 
                        var elem = $( this[ 0 ] ), position, value;
100
 
                        while ( elem.length && elem[ 0 ] !== document ) {
101
 
                                // Ignore z-index if position is set to a value where z-index is ignored by the browser
102
 
                                // This makes behavior of this function consistent across browsers
103
 
                                // WebKit always returns auto if the element is positioned
104
 
                                position = elem.css( "position" );
105
 
                                if ( position === "absolute" || position === "relative" || position === "fixed" ) {
106
 
                                        // IE returns 0 when zIndex is not specified
107
 
                                        // other browsers return a string
108
 
                                        // we ignore the case of nested elements with an explicit value of 0
109
 
                                        // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
110
 
                                        value = parseInt( elem.css( "zIndex" ), 10 );
111
 
                                        if ( !isNaN( value ) && value !== 0 ) {
112
 
                                                return value;
113
 
                                        }
114
 
                                }
115
 
                                elem = elem.parent();
116
 
                        }
117
 
                }
118
 
 
119
 
                return 0;
120
 
        },
121
 
 
122
 
        disableSelection: function() {
123
 
                return this.bind( ( $.support.selectstart ? "selectstart" : "mousedown" ) +
124
 
                        ".ui-disableSelection", function( event ) {
125
 
                                event.preventDefault();
126
 
                        });
127
 
        },
128
 
 
129
 
        enableSelection: function() {
130
 
                return this.unbind( ".ui-disableSelection" );
131
 
        }
132
 
});
133
 
 
134
 
$.each( [ "Width", "Height" ], function( i, name ) {
135
 
        var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
136
 
                type = name.toLowerCase(),
137
 
                orig = {
138
 
                        innerWidth: $.fn.innerWidth,
139
 
                        innerHeight: $.fn.innerHeight,
140
 
                        outerWidth: $.fn.outerWidth,
141
 
                        outerHeight: $.fn.outerHeight
142
 
                };
143
 
 
144
 
        function reduce( elem, size, border, margin ) {
145
 
                $.each( side, function() {
146
 
                        size -= parseFloat( $.curCSS( elem, "padding" + this, true) ) || 0;
147
 
                        if ( border ) {
148
 
                                size -= parseFloat( $.curCSS( elem, "border" + this + "Width", true) ) || 0;
149
 
                        }
150
 
                        if ( margin ) {
151
 
                                size -= parseFloat( $.curCSS( elem, "margin" + this, true) ) || 0;
152
 
                        }
153
 
                });
154
 
                return size;
155
 
        }
156
 
 
157
 
        $.fn[ "inner" + name ] = function( size ) {
158
 
                if ( size === undefined ) {
159
 
                        return orig[ "inner" + name ].call( this );
160
 
                }
161
 
 
162
 
                return this.each(function() {
163
 
                        $( this ).css( type, reduce( this, size ) + "px" );
164
 
                });
165
 
        };
166
 
 
167
 
        $.fn[ "outer" + name] = function( size, margin ) {
168
 
                if ( typeof size !== "number" ) {
169
 
                        return orig[ "outer" + name ].call( this, size );
170
 
                }
171
 
 
172
 
                return this.each(function() {
173
 
                        $( this).css( type, reduce( this, size, true, margin ) + "px" );
174
 
                });
175
 
        };
176
 
});
177
 
 
178
 
// selectors
179
 
function focusable( element, isTabIndexNotNaN ) {
180
 
        var nodeName = element.nodeName.toLowerCase();
181
 
        if ( "area" === nodeName ) {
182
 
                var map = element.parentNode,
183
 
                        mapName = map.name,
184
 
                        img;
185
 
                if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
186
 
                        return false;
187
 
                }
188
 
                img = $( "img[usemap=#" + mapName + "]" )[0];
189
 
                return !!img && visible( img );
190
 
        }
191
 
        return ( /input|select|textarea|button|object/.test( nodeName )
192
 
                ? !element.disabled
193
 
                : "a" == nodeName
194
 
                        ? element.href || isTabIndexNotNaN
195
 
                        : isTabIndexNotNaN)
196
 
                // the element and all of its ancestors must be visible
197
 
                && visible( element );
198
 
}
199
 
 
200
 
function visible( element ) {
201
 
        return !$( element ).parents().andSelf().filter(function() {
202
 
                return $.curCSS( this, "visibility" ) === "hidden" ||
203
 
                        $.expr.filters.hidden( this );
204
 
        }).length;
205
 
}
206
 
 
207
 
$.extend( $.expr[ ":" ], {
208
 
        data: function( elem, i, match ) {
209
 
                return !!$.data( elem, match[ 3 ] );
210
 
        },
211
 
 
212
 
        focusable: function( element ) {
213
 
                return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) );
214
 
        },
215
 
 
216
 
        tabbable: function( element ) {
217
 
                var tabIndex = $.attr( element, "tabindex" ),
218
 
                        isTabIndexNaN = isNaN( tabIndex );
219
 
                return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
220
 
        }
221
 
});
222
 
 
223
 
// support
224
 
$(function() {
225
 
        var body = document.body,
226
 
                div = body.appendChild( div = document.createElement( "div" ) );
227
 
 
228
 
        // access offsetHeight before setting the style to prevent a layout bug
229
 
        // in IE 9 which causes the elemnt to continue to take up space even
230
 
        // after it is removed from the DOM (#8026)
231
 
        div.offsetHeight;
232
 
 
233
 
        $.extend( div.style, {
234
 
                minHeight: "100px",
235
 
                height: "auto",
236
 
                padding: 0,
237
 
                borderWidth: 0
238
 
        });
239
 
 
240
 
        $.support.minHeight = div.offsetHeight === 100;
241
 
        $.support.selectstart = "onselectstart" in div;
242
 
 
243
 
        // set display to none to avoid a layout bug in IE
244
 
        // http://dev.jquery.com/ticket/4014
245
 
        body.removeChild( div ).style.display = "none";
246
 
});
247
 
 
248
 
 
249
 
 
250
 
 
251
 
 
252
 
// deprecated
253
 
$.extend( $.ui, {
254
 
        // $.ui.plugin is deprecated.  Use the proxy pattern instead.
255
 
        plugin: {
256
 
                add: function( module, option, set ) {
257
 
                        var proto = $.ui[ module ].prototype;
258
 
                        for ( var i in set ) {
259
 
                                proto.plugins[ i ] = proto.plugins[ i ] || [];
260
 
                                proto.plugins[ i ].push( [ option, set[ i ] ] );
261
 
                        }
262
 
                },
263
 
                call: function( instance, name, args ) {
264
 
                        var set = instance.plugins[ name ];
265
 
                        if ( !set || !instance.element[ 0 ].parentNode ) {
266
 
                                return;
267
 
                        }
268
 
        
269
 
                        for ( var i = 0; i < set.length; i++ ) {
270
 
                                if ( instance.options[ set[ i ][ 0 ] ] ) {
271
 
                                        set[ i ][ 1 ].apply( instance.element, args );
272
 
                                }
273
 
                        }
274
 
                }
275
 
        },
276
 
        
277
 
        // will be deprecated when we switch to jQuery 1.4 - use jQuery.contains()
278
 
        contains: function( a, b ) {
279
 
                return document.compareDocumentPosition ?
280
 
                        a.compareDocumentPosition( b ) & 16 :
281
 
                        a !== b && a.contains( b );
282
 
        },
283
 
        
284
 
        // only used by resizable
285
 
        hasScroll: function( el, a ) {
286
 
        
287
 
                //If overflow is hidden, the element might have extra content, but the user wants to hide it
288
 
                if ( $( el ).css( "overflow" ) === "hidden") {
289
 
                        return false;
290
 
                }
291
 
        
292
 
                var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
293
 
                        has = false;
294
 
        
295
 
                if ( el[ scroll ] > 0 ) {
296
 
                        return true;
297
 
                }
298
 
        
299
 
                // TODO: determine which cases actually cause this to happen
300
 
                // if the element doesn't have the scroll set, see if it's possible to
301
 
                // set the scroll
302
 
                el[ scroll ] = 1;
303
 
                has = ( el[ scroll ] > 0 );
304
 
                el[ scroll ] = 0;
305
 
                return has;
306
 
        },
307
 
        
308
 
        // these are odd functions, fix the API or move into individual plugins
309
 
        isOverAxis: function( x, reference, size ) {
310
 
                //Determines when x coordinate is over "b" element axis
311
 
                return ( x > reference ) && ( x < ( reference + size ) );
312
 
        },
313
 
        isOver: function( y, x, top, left, height, width ) {
314
 
                //Determines when x, y coordinates is over "b" element
315
 
                return $.ui.isOverAxis( y, top, height ) && $.ui.isOverAxis( x, left, width );
316
 
        }
317
 
});
318
 
 
319
 
})( jQuery );
320
 
/*!
321
 
 * jQuery UI Widget 1.8.18
322
 
 *
323
 
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
324
 
 * Dual licensed under the MIT or GPL Version 2 licenses.
325
 
 * http://jquery.org/license
326
 
 *
327
 
 * http://docs.jquery.com/UI/Widget
328
 
 */
329
 
(function( $, undefined ) {
330
 
 
331
 
// jQuery 1.4+
332
 
if ( $.cleanData ) {
333
 
        var _cleanData = $.cleanData;
334
 
        $.cleanData = function( elems ) {
335
 
                for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
336
 
                        try {
337
 
                                $( elem ).triggerHandler( "remove" );
338
 
                        // http://bugs.jquery.com/ticket/8235
339
 
                        } catch( e ) {}
340
 
                }
341
 
                _cleanData( elems );
342
 
        };
343
 
} else {
344
 
        var _remove = $.fn.remove;
345
 
        $.fn.remove = function( selector, keepData ) {
346
 
                return this.each(function() {
347
 
                        if ( !keepData ) {
348
 
                                if ( !selector || $.filter( selector, [ this ] ).length ) {
349
 
                                        $( "*", this ).add( [ this ] ).each(function() {
350
 
                                                try {
351
 
                                                        $( this ).triggerHandler( "remove" );
352
 
                                                // http://bugs.jquery.com/ticket/8235
353
 
                                                } catch( e ) {}
354
 
                                        });
355
 
                                }
356
 
                        }
357
 
                        return _remove.call( $(this), selector, keepData );
358
 
                });
359
 
        };
360
 
}
361
 
 
362
 
$.widget = function( name, base, prototype ) {
363
 
        var namespace = name.split( "." )[ 0 ],
364
 
                fullName;
365
 
        name = name.split( "." )[ 1 ];
366
 
        fullName = namespace + "-" + name;
367
 
 
368
 
        if ( !prototype ) {
369
 
                prototype = base;
370
 
                base = $.Widget;
371
 
        }
372
 
 
373
 
        // create selector for plugin
374
 
        $.expr[ ":" ][ fullName ] = function( elem ) {
375
 
                return !!$.data( elem, name );
376
 
        };
377
 
 
378
 
        $[ namespace ] = $[ namespace ] || {};
379
 
        $[ namespace ][ name ] = function( options, element ) {
380
 
                // allow instantiation without initializing for simple inheritance
381
 
                if ( arguments.length ) {
382
 
                        this._createWidget( options, element );
383
 
                }
384
 
        };
385
 
 
386
 
        var basePrototype = new base();
387
 
        // we need to make the options hash a property directly on the new instance
388
 
        // otherwise we'll modify the options hash on the prototype that we're
389
 
        // inheriting from
390
 
//      $.each( basePrototype, function( key, val ) {
391
 
//              if ( $.isPlainObject(val) ) {
392
 
//                      basePrototype[ key ] = $.extend( {}, val );
393
 
//              }
394
 
//      });
395
 
        basePrototype.options = $.extend( true, {}, basePrototype.options );
396
 
        $[ namespace ][ name ].prototype = $.extend( true, basePrototype, {
397
 
                namespace: namespace,
398
 
                widgetName: name,
399
 
                widgetEventPrefix: $[ namespace ][ name ].prototype.widgetEventPrefix || name,
400
 
                widgetBaseClass: fullName
401
 
        }, prototype );
402
 
 
403
 
        $.widget.bridge( name, $[ namespace ][ name ] );
404
 
};
405
 
 
406
 
$.widget.bridge = function( name, object ) {
407
 
        $.fn[ name ] = function( options ) {
408
 
                var isMethodCall = typeof options === "string",
409
 
                        args = Array.prototype.slice.call( arguments, 1 ),
410
 
                        returnValue = this;
411
 
 
412
 
                // allow multiple hashes to be passed on init
413
 
                options = !isMethodCall && args.length ?
414
 
                        $.extend.apply( null, [ true, options ].concat(args) ) :
415
 
                        options;
416
 
 
417
 
                // prevent calls to internal methods
418
 
                if ( isMethodCall && options.charAt( 0 ) === "_" ) {
419
 
                        return returnValue;
420
 
                }
421
 
 
422
 
                if ( isMethodCall ) {
423
 
                        this.each(function() {
424
 
                                var instance = $.data( this, name ),
425
 
                                        methodValue = instance && $.isFunction( instance[options] ) ?
426
 
                                                instance[ options ].apply( instance, args ) :
427
 
                                                instance;
428
 
                                // TODO: add this back in 1.9 and use $.error() (see #5972)
429
 
//                              if ( !instance ) {
430
 
//                                      throw "cannot call methods on " + name + " prior to initialization; " +
431
 
//                                              "attempted to call method '" + options + "'";
432
 
//                              }
433
 
//                              if ( !$.isFunction( instance[options] ) ) {
434
 
//                                      throw "no such method '" + options + "' for " + name + " widget instance";
435
 
//                              }
436
 
//                              var methodValue = instance[ options ].apply( instance, args );
437
 
                                if ( methodValue !== instance && methodValue !== undefined ) {
438
 
                                        returnValue = methodValue;
439
 
                                        return false;
440
 
                                }
441
 
                        });
442
 
                } else {
443
 
                        this.each(function() {
444
 
                                var instance = $.data( this, name );
445
 
                                if ( instance ) {
446
 
                                        instance.option( options || {} )._init();
447
 
                                } else {
448
 
                                        $.data( this, name, new object( options, this ) );
449
 
                                }
450
 
                        });
451
 
                }
452
 
 
453
 
                return returnValue;
454
 
        };
455
 
};
456
 
 
457
 
$.Widget = function( options, element ) {
458
 
        // allow instantiation without initializing for simple inheritance
459
 
        if ( arguments.length ) {
460
 
                this._createWidget( options, element );
461
 
        }
462
 
};
463
 
 
464
 
$.Widget.prototype = {
465
 
        widgetName: "widget",
466
 
        widgetEventPrefix: "",
467
 
        options: {
468
 
                disabled: false
469
 
        },
470
 
        _createWidget: function( options, element ) {
471
 
                // $.widget.bridge stores the plugin instance, but we do it anyway
472
 
                // so that it's stored even before the _create function runs
473
 
                $.data( element, this.widgetName, this );
474
 
                this.element = $( element );
475
 
                this.options = $.extend( true, {},
476
 
                        this.options,
477
 
                        this._getCreateOptions(),
478
 
                        options );
479
 
 
480
 
                var self = this;
481
 
                this.element.bind( "remove." + this.widgetName, function() {
482
 
                        self.destroy();
483
 
                });
484
 
 
485
 
                this._create();
486
 
                this._trigger( "create" );
487
 
                this._init();
488
 
        },
489
 
        _getCreateOptions: function() {
490
 
                return $.metadata && $.metadata.get( this.element[0] )[ this.widgetName ];
491
 
        },
492
 
        _create: function() {},
493
 
        _init: function() {},
494
 
 
495
 
        destroy: function() {
496
 
                this.element
497
 
                        .unbind( "." + this.widgetName )
498
 
                        .removeData( this.widgetName );
499
 
                this.widget()
500
 
                        .unbind( "." + this.widgetName )
501
 
                        .removeAttr( "aria-disabled" )
502
 
                        .removeClass(
503
 
                                this.widgetBaseClass + "-disabled " +
504
 
                                "ui-state-disabled" );
505
 
        },
506
 
 
507
 
        widget: function() {
508
 
                return this.element;
509
 
        },
510
 
 
511
 
        option: function( key, value ) {
512
 
                var options = key;
513
 
 
514
 
                if ( arguments.length === 0 ) {
515
 
                        // don't return a reference to the internal hash
516
 
                        return $.extend( {}, this.options );
517
 
                }
518
 
 
519
 
                if  (typeof key === "string" ) {
520
 
                        if ( value === undefined ) {
521
 
                                return this.options[ key ];
522
 
                        }
523
 
                        options = {};
524
 
                        options[ key ] = value;
525
 
                }
526
 
 
527
 
                this._setOptions( options );
528
 
 
529
 
                return this;
530
 
        },
531
 
        _setOptions: function( options ) {
532
 
                var self = this;
533
 
                $.each( options, function( key, value ) {
534
 
                        self._setOption( key, value );
535
 
                });
536
 
 
537
 
                return this;
538
 
        },
539
 
        _setOption: function( key, value ) {
540
 
                this.options[ key ] = value;
541
 
 
542
 
                if ( key === "disabled" ) {
543
 
                        this.widget()
544
 
                                [ value ? "addClass" : "removeClass"](
545
 
                                        this.widgetBaseClass + "-disabled" + " " +
546
 
                                        "ui-state-disabled" )
547
 
                                .attr( "aria-disabled", value );
548
 
                }
549
 
 
550
 
                return this;
551
 
        },
552
 
 
553
 
        enable: function() {
554
 
                return this._setOption( "disabled", false );
555
 
        },
556
 
        disable: function() {
557
 
                return this._setOption( "disabled", true );
558
 
        },
559
 
 
560
 
        _trigger: function( type, event, data ) {
561
 
                var prop, orig,
562
 
                        callback = this.options[ type ];
563
 
 
564
 
                data = data || {};
565
 
                event = $.Event( event );
566
 
                event.type = ( type === this.widgetEventPrefix ?
567
 
                        type :
568
 
                        this.widgetEventPrefix + type ).toLowerCase();
569
 
                // the original event may come from any element
570
 
                // so we need to reset the target on the new event
571
 
                event.target = this.element[ 0 ];
572
 
 
573
 
                // copy original event properties over to the new event
574
 
                orig = event.originalEvent;
575
 
                if ( orig ) {
576
 
                        for ( prop in orig ) {
577
 
                                if ( !( prop in event ) ) {
578
 
                                        event[ prop ] = orig[ prop ];
579
 
                                }
580
 
                        }
581
 
                }
582
 
 
583
 
                this.element.trigger( event, data );
584
 
 
585
 
                return !( $.isFunction(callback) &&
586
 
                        callback.call( this.element[0], event, data ) === false ||
587
 
                        event.isDefaultPrevented() );
588
 
        }
589
 
};
590
 
 
591
 
})( jQuery );
592
 
/*!
593
 
 * jQuery UI Mouse 1.8.18
594
 
 *
595
 
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
596
 
 * Dual licensed under the MIT or GPL Version 2 licenses.
597
 
 * http://jquery.org/license
598
 
 *
599
 
 * http://docs.jquery.com/UI/Mouse
600
 
 *
601
 
 * Depends:
602
 
 *      jquery.ui.widget.js
603
 
 */
604
 
(function( $, undefined ) {
605
 
 
606
 
var mouseHandled = false;
607
 
$( document ).mouseup( function( e ) {
608
 
        mouseHandled = false;
609
 
});
610
 
 
611
 
$.widget("ui.mouse", {
612
 
        options: {
613
 
                cancel: ':input,option',
614
 
                distance: 1,
615
 
                delay: 0
616
 
        },
617
 
        _mouseInit: function() {
618
 
                var self = this;
619
 
 
620
 
                this.element
621
 
                        .bind('mousedown.'+this.widgetName, function(event) {
622
 
                                return self._mouseDown(event);
623
 
                        })
624
 
                        .bind('click.'+this.widgetName, function(event) {
625
 
                                if (true === $.data(event.target, self.widgetName + '.preventClickEvent')) {
626
 
                                    $.removeData(event.target, self.widgetName + '.preventClickEvent');
627
 
                                        event.stopImmediatePropagation();
628
 
                                        return false;
629
 
                                }
630
 
                        });
631
 
 
632
 
                this.started = false;
633
 
        },
634
 
 
635
 
        // TODO: make sure destroying one instance of mouse doesn't mess with
636
 
        // other instances of mouse
637
 
        _mouseDestroy: function() {
638
 
                this.element.unbind('.'+this.widgetName);
639
 
        },
640
 
 
641
 
        _mouseDown: function(event) {
642
 
                // don't let more than one widget handle mouseStart
643
 
                if( mouseHandled ) { return };
644
 
 
645
 
                // we may have missed mouseup (out of window)
646
 
                (this._mouseStarted && this._mouseUp(event));
647
 
 
648
 
                this._mouseDownEvent = event;
649
 
 
650
 
                var self = this,
651
 
                        btnIsLeft = (event.which == 1),
652
 
                        // event.target.nodeName works around a bug in IE 8 with
653
 
                        // disabled inputs (#7620)
654
 
                        elIsCancel = (typeof this.options.cancel == "string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length : false);
655
 
                if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
656
 
                        return true;
657
 
                }
658
 
 
659
 
                this.mouseDelayMet = !this.options.delay;
660
 
                if (!this.mouseDelayMet) {
661
 
                        this._mouseDelayTimer = setTimeout(function() {
662
 
                                self.mouseDelayMet = true;
663
 
                        }, this.options.delay);
664
 
                }
665
 
 
666
 
                if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
667
 
                        this._mouseStarted = (this._mouseStart(event) !== false);
668
 
                        if (!this._mouseStarted) {
669
 
                                event.preventDefault();
670
 
                                return true;
671
 
                        }
672
 
                }
673
 
 
674
 
                // Click event may never have fired (Gecko & Opera)
675
 
                if (true === $.data(event.target, this.widgetName + '.preventClickEvent')) {
676
 
                        $.removeData(event.target, this.widgetName + '.preventClickEvent');
677
 
                }
678
 
 
679
 
                // these delegates are required to keep context
680
 
                this._mouseMoveDelegate = function(event) {
681
 
                        return self._mouseMove(event);
682
 
                };
683
 
                this._mouseUpDelegate = function(event) {
684
 
                        return self._mouseUp(event);
685
 
                };
686
 
                $(document)
687
 
                        .bind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
688
 
                        .bind('mouseup.'+this.widgetName, this._mouseUpDelegate);
689
 
 
690
 
                event.preventDefault();
691
 
                
692
 
                mouseHandled = true;
693
 
                return true;
694
 
        },
695
 
 
696
 
        _mouseMove: function(event) {
697
 
                // IE mouseup check - mouseup happened when mouse was out of window
698
 
                if ($.browser.msie && !(document.documentMode >= 9) && !event.button) {
699
 
                        return this._mouseUp(event);
700
 
                }
701
 
 
702
 
                if (this._mouseStarted) {
703
 
                        this._mouseDrag(event);
704
 
                        return event.preventDefault();
705
 
                }
706
 
 
707
 
                if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
708
 
                        this._mouseStarted =
709
 
                                (this._mouseStart(this._mouseDownEvent, event) !== false);
710
 
                        (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
711
 
                }
712
 
 
713
 
                return !this._mouseStarted;
714
 
        },
715
 
 
716
 
        _mouseUp: function(event) {
717
 
                $(document)
718
 
                        .unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
719
 
                        .unbind('mouseup.'+this.widgetName, this._mouseUpDelegate);
720
 
 
721
 
                if (this._mouseStarted) {
722
 
                        this._mouseStarted = false;
723
 
 
724
 
                        if (event.target == this._mouseDownEvent.target) {
725
 
                            $.data(event.target, this.widgetName + '.preventClickEvent', true);
726
 
                        }
727
 
 
728
 
                        this._mouseStop(event);
729
 
                }
730
 
 
731
 
                return false;
732
 
        },
733
 
 
734
 
        _mouseDistanceMet: function(event) {
735
 
                return (Math.max(
736
 
                                Math.abs(this._mouseDownEvent.pageX - event.pageX),
737
 
                                Math.abs(this._mouseDownEvent.pageY - event.pageY)
738
 
                        ) >= this.options.distance
739
 
                );
740
 
        },
741
 
 
742
 
        _mouseDelayMet: function(event) {
743
 
                return this.mouseDelayMet;
744
 
        },
745
 
 
746
 
        // These are placeholder methods, to be overriden by extending plugin
747
 
        _mouseStart: function(event) {},
748
 
        _mouseDrag: function(event) {},
749
 
        _mouseStop: function(event) {},
750
 
        _mouseCapture: function(event) { return true; }
751
 
});
752
 
 
753
 
})(jQuery);
754
 
/*
755
 
 * jQuery UI Draggable 1.8.18
756
 
 *
757
 
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
758
 
 * Dual licensed under the MIT or GPL Version 2 licenses.
759
 
 * http://jquery.org/license
760
 
 *
761
 
 * http://docs.jquery.com/UI/Draggables
762
 
 *
763
 
 * Depends:
764
 
 *      jquery.ui.core.js
765
 
 *      jquery.ui.mouse.js
766
 
 *      jquery.ui.widget.js
767
 
 */
768
 
(function( $, undefined ) {
769
 
 
770
 
$.widget("ui.draggable", $.ui.mouse, {
771
 
        widgetEventPrefix: "drag",
772
 
        options: {
773
 
                addClasses: true,
774
 
                appendTo: "parent",
775
 
                axis: false,
776
 
                connectToSortable: false,
777
 
                containment: false,
778
 
                cursor: "auto",
779
 
                cursorAt: false,
780
 
                grid: false,
781
 
                handle: false,
782
 
                helper: "original",
783
 
                iframeFix: false,
784
 
                opacity: false,
785
 
                refreshPositions: false,
786
 
                revert: false,
787
 
                revertDuration: 500,
788
 
                scope: "default",
789
 
                scroll: true,
790
 
                scrollSensitivity: 20,
791
 
                scrollSpeed: 20,
792
 
                snap: false,
793
 
                snapMode: "both",
794
 
                snapTolerance: 20,
795
 
                stack: false,
796
 
                zIndex: false
797
 
        },
798
 
        _create: function() {
799
 
 
800
 
                if (this.options.helper == 'original' && !(/^(?:r|a|f)/).test(this.element.css("position")))
801
 
                        this.element[0].style.position = 'relative';
802
 
 
803
 
                (this.options.addClasses && this.element.addClass("ui-draggable"));
804
 
                (this.options.disabled && this.element.addClass("ui-draggable-disabled"));
805
 
 
806
 
                this._mouseInit();
807
 
 
808
 
        },
809
 
 
810
 
        destroy: function() {
811
 
                if(!this.element.data('draggable')) return;
812
 
                this.element
813
 
                        .removeData("draggable")
814
 
                        .unbind(".draggable")
815
 
                        .removeClass("ui-draggable"
816
 
                                + " ui-draggable-dragging"
817
 
                                + " ui-draggable-disabled");
818
 
                this._mouseDestroy();
819
 
 
820
 
                return this;
821
 
        },
822
 
 
823
 
        _mouseCapture: function(event) {
824
 
 
825
 
                var o = this.options;
826
 
 
827
 
                // among others, prevent a drag on a resizable-handle
828
 
                if (this.helper || o.disabled || $(event.target).is('.ui-resizable-handle'))
829
 
                        return false;
830
 
 
831
 
                //Quit if we're not on a valid handle
832
 
                this.handle = this._getHandle(event);
833
 
                if (!this.handle)
834
 
                        return false;
835
 
                
836
 
                if ( o.iframeFix ) {
837
 
                        $(o.iframeFix === true ? "iframe" : o.iframeFix).each(function() {
838
 
                                $('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>')
839
 
                                .css({
840
 
                                        width: this.offsetWidth+"px", height: this.offsetHeight+"px",
841
 
                                        position: "absolute", opacity: "0.001", zIndex: 1000
842
 
                                })
843
 
                                .css($(this).offset())
844
 
                                .appendTo("body");
845
 
                        });
846
 
                }
847
 
 
848
 
                return true;
849
 
 
850
 
        },
851
 
 
852
 
        _mouseStart: function(event) {
853
 
 
854
 
                var o = this.options;
855
 
 
856
 
                //Create and append the visible helper
857
 
                this.helper = this._createHelper(event);
858
 
 
859
 
                //Cache the helper size
860
 
                this._cacheHelperProportions();
861
 
 
862
 
                //If ddmanager is used for droppables, set the global draggable
863
 
                if($.ui.ddmanager)
864
 
                        $.ui.ddmanager.current = this;
865
 
 
866
 
                /*
867
 
                 * - Position generation -
868
 
                 * This block generates everything position related - it's the core of draggables.
869
 
                 */
870
 
 
871
 
                //Cache the margins of the original element
872
 
                this._cacheMargins();
873
 
 
874
 
                //Store the helper's css position
875
 
                this.cssPosition = this.helper.css("position");
876
 
                this.scrollParent = this.helper.scrollParent();
877
 
 
878
 
                //The element's absolute position on the page minus margins
879
 
                this.offset = this.positionAbs = this.element.offset();
880
 
                this.offset = {
881
 
                        top: this.offset.top - this.margins.top,
882
 
                        left: this.offset.left - this.margins.left
883
 
                };
884
 
 
885
 
                $.extend(this.offset, {
886
 
                        click: { //Where the click happened, relative to the element
887
 
                                left: event.pageX - this.offset.left,
888
 
                                top: event.pageY - this.offset.top
889
 
                        },
890
 
                        parent: this._getParentOffset(),
891
 
                        relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
892
 
                });
893
 
 
894
 
                //Generate the original position
895
 
                this.originalPosition = this.position = this._generatePosition(event);
896
 
                this.originalPageX = event.pageX;
897
 
                this.originalPageY = event.pageY;
898
 
 
899
 
                //Adjust the mouse offset relative to the helper if 'cursorAt' is supplied
900
 
                (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
901
 
 
902
 
                //Set a containment if given in the options
903
 
                if(o.containment)
904
 
                        this._setContainment();
905
 
 
906
 
                //Trigger event + callbacks
907
 
                if(this._trigger("start", event) === false) {
908
 
                        this._clear();
909
 
                        return false;
910
 
                }
911
 
 
912
 
                //Recache the helper size
913
 
                this._cacheHelperProportions();
914
 
 
915
 
                //Prepare the droppable offsets
916
 
                if ($.ui.ddmanager && !o.dropBehaviour)
917
 
                        $.ui.ddmanager.prepareOffsets(this, event);
918
 
 
919
 
                this.helper.addClass("ui-draggable-dragging");
920
 
                this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
921
 
                
922
 
                //If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003)
923
 
                if ( $.ui.ddmanager ) $.ui.ddmanager.dragStart(this, event);
924
 
                
925
 
                return true;
926
 
        },
927
 
 
928
 
        _mouseDrag: function(event, noPropagation) {
929
 
 
930
 
                //Compute the helpers position
931
 
                this.position = this._generatePosition(event);
932
 
                this.positionAbs = this._convertPositionTo("absolute");
933
 
 
934
 
                //Call plugins and callbacks and use the resulting position if something is returned
935
 
                if (!noPropagation) {
936
 
                        var ui = this._uiHash();
937
 
                        if(this._trigger('drag', event, ui) === false) {
938
 
                                this._mouseUp({});
939
 
                                return false;
940
 
                        }
941
 
                        this.position = ui.position;
942
 
                }
943
 
 
944
 
                if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px';
945
 
                if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px';
946
 
                if($.ui.ddmanager) $.ui.ddmanager.drag(this, event);
947
 
 
948
 
                return false;
949
 
        },
950
 
 
951
 
        _mouseStop: function(event) {
952
 
 
953
 
                //If we are using droppables, inform the manager about the drop
954
 
                var dropped = false;
955
 
                if ($.ui.ddmanager && !this.options.dropBehaviour)
956
 
                        dropped = $.ui.ddmanager.drop(this, event);
957
 
 
958
 
                //if a drop comes from outside (a sortable)
959
 
                if(this.dropped) {
960
 
                        dropped = this.dropped;
961
 
                        this.dropped = false;
962
 
                }
963
 
                
964
 
                //if the original element is removed, don't bother to continue if helper is set to "original"
965
 
                if((!this.element[0] || !this.element[0].parentNode) && this.options.helper == "original")
966
 
                        return false;
967
 
 
968
 
                if((this.options.revert == "invalid" && !dropped) || (this.options.revert == "valid" && dropped) || this.options.revert === true || ($.isFunction(this.options.revert) && this.options.revert.call(this.element, dropped))) {
969
 
                        var self = this;
970
 
                        $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() {
971
 
                                if(self._trigger("stop", event) !== false) {
972
 
                                        self._clear();
973
 
                                }
974
 
                        });
975
 
                } else {
976
 
                        if(this._trigger("stop", event) !== false) {
977
 
                                this._clear();
978
 
                        }
979
 
                }
980
 
 
981
 
                return false;
982
 
        },
983
 
        
984
 
        _mouseUp: function(event) {
985
 
                if (this.options.iframeFix === true) {
986
 
                        $("div.ui-draggable-iframeFix").each(function() { 
987
 
                                this.parentNode.removeChild(this); 
988
 
                        }); //Remove frame helpers
989
 
                }
990
 
                
991
 
                //If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003)
992
 
                if( $.ui.ddmanager ) $.ui.ddmanager.dragStop(this, event);
993
 
                
994
 
                return $.ui.mouse.prototype._mouseUp.call(this, event);
995
 
        },
996
 
        
997
 
        cancel: function() {
998
 
                
999
 
                if(this.helper.is(".ui-draggable-dragging")) {
1000
 
                        this._mouseUp({});
1001
 
                } else {
1002
 
                        this._clear();
1003
 
                }
1004
 
                
1005
 
                return this;
1006
 
                
1007
 
        },
1008
 
 
1009
 
        _getHandle: function(event) {
1010
 
 
1011
 
                var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false;
1012
 
                $(this.options.handle, this.element)
1013
 
                        .find("*")
1014
 
                        .andSelf()
1015
 
                        .each(function() {
1016
 
                                if(this == event.target) handle = true;
1017
 
                        });
1018
 
 
1019
 
                return handle;
1020
 
 
1021
 
        },
1022
 
 
1023
 
        _createHelper: function(event) {
1024
 
 
1025
 
                var o = this.options;
1026
 
                var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event])) : (o.helper == 'clone' ? this.element.clone().removeAttr('id') : this.element);
1027
 
 
1028
 
                if(!helper.parents('body').length)
1029
 
                        helper.appendTo((o.appendTo == 'parent' ? this.element[0].parentNode : o.appendTo));
1030
 
 
1031
 
                if(helper[0] != this.element[0] && !(/(fixed|absolute)/).test(helper.css("position")))
1032
 
                        helper.css("position", "absolute");
1033
 
 
1034
 
                return helper;
1035
 
 
1036
 
        },
1037
 
 
1038
 
        _adjustOffsetFromHelper: function(obj) {
1039
 
                if (typeof obj == 'string') {
1040
 
                        obj = obj.split(' ');
1041
 
                }
1042
 
                if ($.isArray(obj)) {
1043
 
                        obj = {left: +obj[0], top: +obj[1] || 0};
1044
 
                }
1045
 
                if ('left' in obj) {
1046
 
                        this.offset.click.left = obj.left + this.margins.left;
1047
 
                }
1048
 
                if ('right' in obj) {
1049
 
                        this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
1050
 
                }
1051
 
                if ('top' in obj) {
1052
 
                        this.offset.click.top = obj.top + this.margins.top;
1053
 
                }
1054
 
                if ('bottom' in obj) {
1055
 
                        this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
1056
 
                }
1057
 
        },
1058
 
 
1059
 
        _getParentOffset: function() {
1060
 
 
1061
 
                //Get the offsetParent and cache its position
1062
 
                this.offsetParent = this.helper.offsetParent();
1063
 
                var po = this.offsetParent.offset();
1064
 
 
1065
 
                // This is a special case where we need to modify a offset calculated on start, since the following happened:
1066
 
                // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
1067
 
                // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
1068
 
                //    the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
1069
 
                if(this.cssPosition == 'absolute' && this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) {
1070
 
                        po.left += this.scrollParent.scrollLeft();
1071
 
                        po.top += this.scrollParent.scrollTop();
1072
 
                }
1073
 
 
1074
 
                if((this.offsetParent[0] == document.body) //This needs to be actually done for all browsers, since pageX/pageY includes this information
1075
 
                || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.browser.msie)) //Ugly IE fix
1076
 
                        po = { top: 0, left: 0 };
1077
 
 
1078
 
                return {
1079
 
                        top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
1080
 
                        left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
1081
 
                };
1082
 
 
1083
 
        },
1084
 
 
1085
 
        _getRelativeOffset: function() {
1086
 
 
1087
 
                if(this.cssPosition == "relative") {
1088
 
                        var p = this.element.position();
1089
 
                        return {
1090
 
                                top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
1091
 
                                left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
1092
 
                        };
1093
 
                } else {
1094
 
                        return { top: 0, left: 0 };
1095
 
                }
1096
 
 
1097
 
        },
1098
 
 
1099
 
        _cacheMargins: function() {
1100
 
                this.margins = {
1101
 
                        left: (parseInt(this.element.css("marginLeft"),10) || 0),
1102
 
                        top: (parseInt(this.element.css("marginTop"),10) || 0),
1103
 
                        right: (parseInt(this.element.css("marginRight"),10) || 0),
1104
 
                        bottom: (parseInt(this.element.css("marginBottom"),10) || 0)
1105
 
                };
1106
 
        },
1107
 
 
1108
 
        _cacheHelperProportions: function() {
1109
 
                this.helperProportions = {
1110
 
                        width: this.helper.outerWidth(),
1111
 
                        height: this.helper.outerHeight()
1112
 
                };
1113
 
        },
1114
 
 
1115
 
        _setContainment: function() {
1116
 
 
1117
 
                var o = this.options;
1118
 
                if(o.containment == 'parent') o.containment = this.helper[0].parentNode;
1119
 
                if(o.containment == 'document' || o.containment == 'window') this.containment = [
1120
 
                        o.containment == 'document' ? 0 : $(window).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
1121
 
                        o.containment == 'document' ? 0 : $(window).scrollTop() - this.offset.relative.top - this.offset.parent.top,
1122
 
                        (o.containment == 'document' ? 0 : $(window).scrollLeft()) + $(o.containment == 'document' ? document : window).width() - this.helperProportions.width - this.margins.left,
1123
 
                        (o.containment == 'document' ? 0 : $(window).scrollTop()) + ($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
1124
 
                ];
1125
 
 
1126
 
                if(!(/^(document|window|parent)$/).test(o.containment) && o.containment.constructor != Array) {
1127
 
                        var c = $(o.containment);
1128
 
                        var ce = c[0]; if(!ce) return;
1129
 
                        var co = c.offset();
1130
 
                        var over = ($(ce).css("overflow") != 'hidden');
1131
 
 
1132
 
                        this.containment = [
1133
 
                                (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0),
1134
 
                                (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0),
1135
 
                                (over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left - this.margins.right,
1136
 
                                (over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top  - this.margins.bottom
1137
 
                        ];
1138
 
                        this.relative_container = c;
1139
 
 
1140
 
                } else if(o.containment.constructor == Array) {
1141
 
                        this.containment = o.containment;
1142
 
                }
1143
 
 
1144
 
        },
1145
 
 
1146
 
        _convertPositionTo: function(d, pos) {
1147
 
 
1148
 
                if(!pos) pos = this.position;
1149
 
                var mod = d == "absolute" ? 1 : -1;
1150
 
                var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
1151
 
 
1152
 
                return {
1153
 
                        top: (
1154
 
                                pos.top                                                                                                                                 // The absolute mouse position
1155
 
                                + this.offset.relative.top * mod                                                                                // Only for relative positioned nodes: Relative offset from element to offset parent
1156
 
                                + this.offset.parent.top * mod                                                                                  // The offsetParent's offset without borders (offset + border)
1157
 
                                - ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
1158
 
                        ),
1159
 
                        left: (
1160
 
                                pos.left                                                                                                                                // The absolute mouse position
1161
 
                                + this.offset.relative.left * mod                                                                               // Only for relative positioned nodes: Relative offset from element to offset parent
1162
 
                                + this.offset.parent.left * mod                                                                                 // The offsetParent's offset without borders (offset + border)
1163
 
                                - ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
1164
 
                        )
1165
 
                };
1166
 
 
1167
 
        },
1168
 
 
1169
 
        _generatePosition: function(event) {
1170
 
 
1171
 
                var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
1172
 
                var pageX = event.pageX;
1173
 
                var pageY = event.pageY;
1174
 
 
1175
 
                /*
1176
 
                 * - Position constraining -
1177
 
                 * Constrain the position to a mix of grid, containment.
1178
 
                 */
1179
 
 
1180
 
                if(this.originalPosition) { //If we are not dragging yet, we won't check for options
1181
 
                         var containment;
1182
 
                         if(this.containment) {
1183
 
                                 if (this.relative_container){
1184
 
                                     var co = this.relative_container.offset();
1185
 
                                     containment = [ this.containment[0] + co.left,
1186
 
                                                     this.containment[1] + co.top,
1187
 
                                                     this.containment[2] + co.left,
1188
 
                                                     this.containment[3] + co.top ];
1189
 
                                 }
1190
 
                                 else {
1191
 
                                     containment = this.containment;
1192
 
                                 }
1193
 
 
1194
 
                                if(event.pageX - this.offset.click.left < containment[0]) pageX = containment[0] + this.offset.click.left;
1195
 
                                if(event.pageY - this.offset.click.top < containment[1]) pageY = containment[1] + this.offset.click.top;
1196
 
                                if(event.pageX - this.offset.click.left > containment[2]) pageX = containment[2] + this.offset.click.left;
1197
 
                                if(event.pageY - this.offset.click.top > containment[3]) pageY = containment[3] + this.offset.click.top;
1198
 
                        }
1199
 
 
1200
 
                        if(o.grid) {
1201
 
                                //Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950)
1202
 
                                var top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY;
1203
 
                                pageY = containment ? (!(top - this.offset.click.top < containment[1] || top - this.offset.click.top > containment[3]) ? top : (!(top - this.offset.click.top < containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
1204
 
 
1205
 
                                var left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX;
1206
 
                                pageX = containment ? (!(left - this.offset.click.left < containment[0] || left - this.offset.click.left > containment[2]) ? left : (!(left - this.offset.click.left < containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
1207
 
                        }
1208
 
 
1209
 
                }
1210
 
 
1211
 
                return {
1212
 
                        top: (
1213
 
                                pageY                                                                                                                           // The absolute mouse position
1214
 
                                - this.offset.click.top                                                                                                 // Click offset (relative to the element)
1215
 
                                - this.offset.relative.top                                                                                              // Only for relative positioned nodes: Relative offset from element to offset parent
1216
 
                                - this.offset.parent.top                                                                                                // The offsetParent's offset without borders (offset + border)
1217
 
                                + ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
1218
 
                        ),
1219
 
                        left: (
1220
 
                                pageX                                                                                                                           // The absolute mouse position
1221
 
                                - this.offset.click.left                                                                                                // Click offset (relative to the element)
1222
 
                                - this.offset.relative.left                                                                                             // Only for relative positioned nodes: Relative offset from element to offset parent
1223
 
                                - this.offset.parent.left                                                                                               // The offsetParent's offset without borders (offset + border)
1224
 
                                + ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
1225
 
                        )
1226
 
                };
1227
 
 
1228
 
        },
1229
 
 
1230
 
        _clear: function() {
1231
 
                this.helper.removeClass("ui-draggable-dragging");
1232
 
                if(this.helper[0] != this.element[0] && !this.cancelHelperRemoval) this.helper.remove();
1233
 
                //if($.ui.ddmanager) $.ui.ddmanager.current = null;
1234
 
                this.helper = null;
1235
 
                this.cancelHelperRemoval = false;
1236
 
        },
1237
 
 
1238
 
        // From now on bulk stuff - mainly helpers
1239
 
 
1240
 
        _trigger: function(type, event, ui) {
1241
 
                ui = ui || this._uiHash();
1242
 
                $.ui.plugin.call(this, type, [event, ui]);
1243
 
                if(type == "drag") this.positionAbs = this._convertPositionTo("absolute"); //The absolute position has to be recalculated after plugins
1244
 
                return $.Widget.prototype._trigger.call(this, type, event, ui);
1245
 
        },
1246
 
 
1247
 
        plugins: {},
1248
 
 
1249
 
        _uiHash: function(event) {
1250
 
                return {
1251
 
                        helper: this.helper,
1252
 
                        position: this.position,
1253
 
                        originalPosition: this.originalPosition,
1254
 
                        offset: this.positionAbs
1255
 
                };
1256
 
        }
1257
 
 
1258
 
});
1259
 
 
1260
 
$.extend($.ui.draggable, {
1261
 
        version: "1.8.18"
1262
 
});
1263
 
 
1264
 
$.ui.plugin.add("draggable", "connectToSortable", {
1265
 
        start: function(event, ui) {
1266
 
 
1267
 
                var inst = $(this).data("draggable"), o = inst.options,
1268
 
                        uiSortable = $.extend({}, ui, { item: inst.element });
1269
 
                inst.sortables = [];
1270
 
                $(o.connectToSortable).each(function() {
1271
 
                        var sortable = $.data(this, 'sortable');
1272
 
                        if (sortable && !sortable.options.disabled) {
1273
 
                                inst.sortables.push({
1274
 
                                        instance: sortable,
1275
 
                                        shouldRevert: sortable.options.revert
1276
 
                                });
1277
 
                                sortable.refreshPositions();    // Call the sortable's refreshPositions at drag start to refresh the containerCache since the sortable container cache is used in drag and needs to be up to date (this will ensure it's initialised as well as being kept in step with any changes that might have happened on the page).
1278
 
                                sortable._trigger("activate", event, uiSortable);
1279
 
                        }
1280
 
                });
1281
 
 
1282
 
        },
1283
 
        stop: function(event, ui) {
1284
 
 
1285
 
                //If we are still over the sortable, we fake the stop event of the sortable, but also remove helper
1286
 
                var inst = $(this).data("draggable"),
1287
 
                        uiSortable = $.extend({}, ui, { item: inst.element });
1288
 
 
1289
 
                $.each(inst.sortables, function() {
1290
 
                        if(this.instance.isOver) {
1291
 
 
1292
 
                                this.instance.isOver = 0;
1293
 
 
1294
 
                                inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance
1295
 
                                this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work)
1296
 
 
1297
 
                                //The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: 'valid/invalid'
1298
 
                                if(this.shouldRevert) this.instance.options.revert = true;
1299
 
 
1300
 
                                //Trigger the stop of the sortable
1301
 
                                this.instance._mouseStop(event);
1302
 
 
1303
 
                                this.instance.options.helper = this.instance.options._helper;
1304
 
 
1305
 
                                //If the helper has been the original item, restore properties in the sortable
1306
 
                                if(inst.options.helper == 'original')
1307
 
                                        this.instance.currentItem.css({ top: 'auto', left: 'auto' });
1308
 
 
1309
 
                        } else {
1310
 
                                this.instance.cancelHelperRemoval = false; //Remove the helper in the sortable instance
1311
 
                                this.instance._trigger("deactivate", event, uiSortable);
1312
 
                        }
1313
 
 
1314
 
                });
1315
 
 
1316
 
        },
1317
 
        drag: function(event, ui) {
1318
 
 
1319
 
                var inst = $(this).data("draggable"), self = this;
1320
 
 
1321
 
                var checkPos = function(o) {
1322
 
                        var dyClick = this.offset.click.top, dxClick = this.offset.click.left;
1323
 
                        var helperTop = this.positionAbs.top, helperLeft = this.positionAbs.left;
1324
 
                        var itemHeight = o.height, itemWidth = o.width;
1325
 
                        var itemTop = o.top, itemLeft = o.left;
1326
 
 
1327
 
                        return $.ui.isOver(helperTop + dyClick, helperLeft + dxClick, itemTop, itemLeft, itemHeight, itemWidth);
1328
 
                };
1329
 
 
1330
 
                $.each(inst.sortables, function(i) {
1331
 
                        
1332
 
                        //Copy over some variables to allow calling the sortable's native _intersectsWith
1333
 
                        this.instance.positionAbs = inst.positionAbs;
1334
 
                        this.instance.helperProportions = inst.helperProportions;
1335
 
                        this.instance.offset.click = inst.offset.click;
1336
 
                        
1337
 
                        if(this.instance._intersectsWith(this.instance.containerCache)) {
1338
 
 
1339
 
                                //If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once
1340
 
                                if(!this.instance.isOver) {
1341
 
 
1342
 
                                        this.instance.isOver = 1;
1343
 
                                        //Now we fake the start of dragging for the sortable instance,
1344
 
                                        //by cloning the list group item, appending it to the sortable and using it as inst.currentItem
1345
 
                                        //We can then fire the start event of the sortable with our passed browser event, and our own helper (so it doesn't create a new one)
1346
 
                                        this.instance.currentItem = $(self).clone().removeAttr('id').appendTo(this.instance.element).data("sortable-item", true);
1347
 
                                        this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it
1348
 
                                        this.instance.options.helper = function() { return ui.helper[0]; };
1349
 
 
1350
 
                                        event.target = this.instance.currentItem[0];
1351
 
                                        this.instance._mouseCapture(event, true);
1352
 
                                        this.instance._mouseStart(event, true, true);
1353
 
 
1354
 
                                        //Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes
1355
 
                                        this.instance.offset.click.top = inst.offset.click.top;
1356
 
                                        this.instance.offset.click.left = inst.offset.click.left;
1357
 
                                        this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left;
1358
 
                                        this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top;
1359
 
 
1360
 
                                        inst._trigger("toSortable", event);
1361
 
                                        inst.dropped = this.instance.element; //draggable revert needs that
1362
 
                                        //hack so receive/update callbacks work (mostly)
1363
 
                                        inst.currentItem = inst.element;
1364
 
                                        this.instance.fromOutside = inst;
1365
 
 
1366
 
                                }
1367
 
 
1368
 
                                //Provided we did all the previous steps, we can fire the drag event of the sortable on every draggable drag, when it intersects with the sortable
1369
 
                                if(this.instance.currentItem) this.instance._mouseDrag(event);
1370
 
 
1371
 
                        } else {
1372
 
 
1373
 
                                //If it doesn't intersect with the sortable, and it intersected before,
1374
 
                                //we fake the drag stop of the sortable, but make sure it doesn't remove the helper by using cancelHelperRemoval
1375
 
                                if(this.instance.isOver) {
1376
 
 
1377
 
                                        this.instance.isOver = 0;
1378
 
                                        this.instance.cancelHelperRemoval = true;
1379
 
                                        
1380
 
                                        //Prevent reverting on this forced stop
1381
 
                                        this.instance.options.revert = false;
1382
 
                                        
1383
 
                                        // The out event needs to be triggered independently
1384
 
                                        this.instance._trigger('out', event, this.instance._uiHash(this.instance));
1385
 
                                        
1386
 
                                        this.instance._mouseStop(event, true);
1387
 
                                        this.instance.options.helper = this.instance.options._helper;
1388
 
 
1389
 
                                        //Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size
1390
 
                                        this.instance.currentItem.remove();
1391
 
                                        if(this.instance.placeholder) this.instance.placeholder.remove();
1392
 
 
1393
 
                                        inst._trigger("fromSortable", event);
1394
 
                                        inst.dropped = false; //draggable revert needs that
1395
 
                                }
1396
 
 
1397
 
                        };
1398
 
 
1399
 
                });
1400
 
 
1401
 
        }
1402
 
});
1403
 
 
1404
 
$.ui.plugin.add("draggable", "cursor", {
1405
 
        start: function(event, ui) {
1406
 
                var t = $('body'), o = $(this).data('draggable').options;
1407
 
                if (t.css("cursor")) o._cursor = t.css("cursor");
1408
 
                t.css("cursor", o.cursor);
1409
 
        },
1410
 
        stop: function(event, ui) {
1411
 
                var o = $(this).data('draggable').options;
1412
 
                if (o._cursor) $('body').css("cursor", o._cursor);
1413
 
        }
1414
 
});
1415
 
 
1416
 
$.ui.plugin.add("draggable", "opacity", {
1417
 
        start: function(event, ui) {
1418
 
                var t = $(ui.helper), o = $(this).data('draggable').options;
1419
 
                if(t.css("opacity")) o._opacity = t.css("opacity");
1420
 
                t.css('opacity', o.opacity);
1421
 
        },
1422
 
        stop: function(event, ui) {
1423
 
                var o = $(this).data('draggable').options;
1424
 
                if(o._opacity) $(ui.helper).css('opacity', o._opacity);
1425
 
        }
1426
 
});
1427
 
 
1428
 
$.ui.plugin.add("draggable", "scroll", {
1429
 
        start: function(event, ui) {
1430
 
                var i = $(this).data("draggable");
1431
 
                if(i.scrollParent[0] != document && i.scrollParent[0].tagName != 'HTML') i.overflowOffset = i.scrollParent.offset();
1432
 
        },
1433
 
        drag: function(event, ui) {
1434
 
 
1435
 
                var i = $(this).data("draggable"), o = i.options, scrolled = false;
1436
 
 
1437
 
                if(i.scrollParent[0] != document && i.scrollParent[0].tagName != 'HTML') {
1438
 
 
1439
 
                        if(!o.axis || o.axis != 'x') {
1440
 
                                if((i.overflowOffset.top + i.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity)
1441
 
                                        i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop + o.scrollSpeed;
1442
 
                                else if(event.pageY - i.overflowOffset.top < o.scrollSensitivity)
1443
 
                                        i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop - o.scrollSpeed;
1444
 
                        }
1445
 
 
1446
 
                        if(!o.axis || o.axis != 'y') {
1447
 
                                if((i.overflowOffset.left + i.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity)
1448
 
                                        i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft + o.scrollSpeed;
1449
 
                                else if(event.pageX - i.overflowOffset.left < o.scrollSensitivity)
1450
 
                                        i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft - o.scrollSpeed;
1451
 
                        }
1452
 
 
1453
 
                } else {
1454
 
 
1455
 
                        if(!o.axis || o.axis != 'x') {
1456
 
                                if(event.pageY - $(document).scrollTop() < o.scrollSensitivity)
1457
 
                                        scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
1458
 
                                else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity)
1459
 
                                        scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
1460
 
                        }
1461
 
 
1462
 
                        if(!o.axis || o.axis != 'y') {
1463
 
                                if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity)
1464
 
                                        scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
1465
 
                                else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity)
1466
 
                                        scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
1467
 
                        }
1468
 
 
1469
 
                }
1470
 
 
1471
 
                if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour)
1472
 
                        $.ui.ddmanager.prepareOffsets(i, event);
1473
 
 
1474
 
        }
1475
 
});
1476
 
 
1477
 
$.ui.plugin.add("draggable", "snap", {
1478
 
        start: function(event, ui) {
1479
 
 
1480
 
                var i = $(this).data("draggable"), o = i.options;
1481
 
                i.snapElements = [];
1482
 
 
1483
 
                $(o.snap.constructor != String ? ( o.snap.items || ':data(draggable)' ) : o.snap).each(function() {
1484
 
                        var $t = $(this); var $o = $t.offset();
1485
 
                        if(this != i.element[0]) i.snapElements.push({
1486
 
                                item: this,
1487
 
                                width: $t.outerWidth(), height: $t.outerHeight(),
1488
 
                                top: $o.top, left: $o.left
1489
 
                        });
1490
 
                });
1491
 
 
1492
 
        },
1493
 
        drag: function(event, ui) {
1494
 
 
1495
 
                var inst = $(this).data("draggable"), o = inst.options;
1496
 
                var d = o.snapTolerance;
1497
 
 
1498
 
                var x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
1499
 
                        y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
1500
 
 
1501
 
                for (var i = inst.snapElements.length - 1; i >= 0; i--){
1502
 
 
1503
 
                        var l = inst.snapElements[i].left, r = l + inst.snapElements[i].width,
1504
 
                                t = inst.snapElements[i].top, b = t + inst.snapElements[i].height;
1505
 
 
1506
 
                        //Yes, I know, this is insane ;)
1507
 
                        if(!((l-d < x1 && x1 < r+d && t-d < y1 && y1 < b+d) || (l-d < x1 && x1 < r+d && t-d < y2 && y2 < b+d) || (l-d < x2 && x2 < r+d && t-d < y1 && y1 < b+d) || (l-d < x2 && x2 < r+d && t-d < y2 && y2 < b+d))) {
1508
 
                                if(inst.snapElements[i].snapping) (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
1509
 
                                inst.snapElements[i].snapping = false;
1510
 
                                continue;
1511
 
                        }
1512
 
 
1513
 
                        if(o.snapMode != 'inner') {
1514
 
                                var ts = Math.abs(t - y2) <= d;
1515
 
                                var bs = Math.abs(b - y1) <= d;
1516
 
                                var ls = Math.abs(l - x2) <= d;
1517
 
                                var rs = Math.abs(r - x1) <= d;
1518
 
                                if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
1519
 
                                if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top - inst.margins.top;
1520
 
                                if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left - inst.margins.left;
1521
 
                                if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left - inst.margins.left;
1522
 
                        }
1523
 
 
1524
 
                        var first = (ts || bs || ls || rs);
1525
 
 
1526
 
                        if(o.snapMode != 'outer') {
1527
 
                                var ts = Math.abs(t - y1) <= d;
1528
 
                                var bs = Math.abs(b - y2) <= d;
1529
 
                                var ls = Math.abs(l - x1) <= d;
1530
 
                                var rs = Math.abs(r - x2) <= d;
1531
 
                                if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top - inst.margins.top;
1532
 
                                if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
1533
 
                                if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left - inst.margins.left;
1534
 
                                if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left - inst.margins.left;
1535
 
                        }
1536
 
 
1537
 
                        if(!inst.snapElements[i].snapping && (ts || bs || ls || rs || first))
1538
 
                                (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
1539
 
                        inst.snapElements[i].snapping = (ts || bs || ls || rs || first);
1540
 
 
1541
 
                };
1542
 
 
1543
 
        }
1544
 
});
1545
 
 
1546
 
$.ui.plugin.add("draggable", "stack", {
1547
 
        start: function(event, ui) {
1548
 
 
1549
 
                var o = $(this).data("draggable").options;
1550
 
 
1551
 
                var group = $.makeArray($(o.stack)).sort(function(a,b) {
1552
 
                        return (parseInt($(a).css("zIndex"),10) || 0) - (parseInt($(b).css("zIndex"),10) || 0);
1553
 
                });
1554
 
                if (!group.length) { return; }
1555
 
                
1556
 
                var min = parseInt(group[0].style.zIndex) || 0;
1557
 
                $(group).each(function(i) {
1558
 
                        this.style.zIndex = min + i;
1559
 
                });
1560
 
 
1561
 
                this[0].style.zIndex = min + group.length;
1562
 
 
1563
 
        }
1564
 
});
1565
 
 
1566
 
$.ui.plugin.add("draggable", "zIndex", {
1567
 
        start: function(event, ui) {
1568
 
                var t = $(ui.helper), o = $(this).data("draggable").options;
1569
 
                if(t.css("zIndex")) o._zIndex = t.css("zIndex");
1570
 
                t.css('zIndex', o.zIndex);
1571
 
        },
1572
 
        stop: function(event, ui) {
1573
 
                var o = $(this).data("draggable").options;
1574
 
                if(o._zIndex) $(ui.helper).css('zIndex', o._zIndex);
1575
 
        }
1576
 
});
1577
 
 
1578
 
})(jQuery);
1579
 
/*
1580
 
 * jQuery UI Droppable 1.8.18
1581
 
 *
1582
 
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
1583
 
 * Dual licensed under the MIT or GPL Version 2 licenses.
1584
 
 * http://jquery.org/license
1585
 
 *
1586
 
 * http://docs.jquery.com/UI/Droppables
1587
 
 *
1588
 
 * Depends:
1589
 
 *      jquery.ui.core.js
1590
 
 *      jquery.ui.widget.js
1591
 
 *      jquery.ui.mouse.js
1592
 
 *      jquery.ui.draggable.js
1593
 
 */
1594
 
(function( $, undefined ) {
1595
 
 
1596
 
$.widget("ui.droppable", {
1597
 
        widgetEventPrefix: "drop",
1598
 
        options: {
1599
 
                accept: '*',
1600
 
                activeClass: false,
1601
 
                addClasses: true,
1602
 
                greedy: false,
1603
 
                hoverClass: false,
1604
 
                scope: 'default',
1605
 
                tolerance: 'intersect'
1606
 
        },
1607
 
        _create: function() {
1608
 
 
1609
 
                var o = this.options, accept = o.accept;
1610
 
                this.isover = 0; this.isout = 1;
1611
 
 
1612
 
                this.accept = $.isFunction(accept) ? accept : function(d) {
1613
 
                        return d.is(accept);
1614
 
                };
1615
 
 
1616
 
                //Store the droppable's proportions
1617
 
                this.proportions = { width: this.element[0].offsetWidth, height: this.element[0].offsetHeight };
1618
 
 
1619
 
                // Add the reference and positions to the manager
1620
 
                $.ui.ddmanager.droppables[o.scope] = $.ui.ddmanager.droppables[o.scope] || [];
1621
 
                $.ui.ddmanager.droppables[o.scope].push(this);
1622
 
 
1623
 
                (o.addClasses && this.element.addClass("ui-droppable"));
1624
 
 
1625
 
        },
1626
 
 
1627
 
        destroy: function() {
1628
 
                var drop = $.ui.ddmanager.droppables[this.options.scope];
1629
 
                for ( var i = 0; i < drop.length; i++ )
1630
 
                        if ( drop[i] == this )
1631
 
                                drop.splice(i, 1);
1632
 
 
1633
 
                this.element
1634
 
                        .removeClass("ui-droppable ui-droppable-disabled")
1635
 
                        .removeData("droppable")
1636
 
                        .unbind(".droppable");
1637
 
 
1638
 
                return this;
1639
 
        },
1640
 
 
1641
 
        _setOption: function(key, value) {
1642
 
 
1643
 
                if(key == 'accept') {
1644
 
                        this.accept = $.isFunction(value) ? value : function(d) {
1645
 
                                return d.is(value);
1646
 
                        };
1647
 
                }
1648
 
                $.Widget.prototype._setOption.apply(this, arguments);
1649
 
        },
1650
 
 
1651
 
        _activate: function(event) {
1652
 
                var draggable = $.ui.ddmanager.current;
1653
 
                if(this.options.activeClass) this.element.addClass(this.options.activeClass);
1654
 
                (draggable && this._trigger('activate', event, this.ui(draggable)));
1655
 
        },
1656
 
 
1657
 
        _deactivate: function(event) {
1658
 
                var draggable = $.ui.ddmanager.current;
1659
 
                if(this.options.activeClass) this.element.removeClass(this.options.activeClass);
1660
 
                (draggable && this._trigger('deactivate', event, this.ui(draggable)));
1661
 
        },
1662
 
 
1663
 
        _over: function(event) {
1664
 
 
1665
 
                var draggable = $.ui.ddmanager.current;
1666
 
                if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return; // Bail if draggable and droppable are same element
1667
 
 
1668
 
                if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
1669
 
                        if(this.options.hoverClass) this.element.addClass(this.options.hoverClass);
1670
 
                        this._trigger('over', event, this.ui(draggable));
1671
 
                }
1672
 
 
1673
 
        },
1674
 
 
1675
 
        _out: function(event) {
1676
 
 
1677
 
                var draggable = $.ui.ddmanager.current;
1678
 
                if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return; // Bail if draggable and droppable are same element
1679
 
 
1680
 
                if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
1681
 
                        if(this.options.hoverClass) this.element.removeClass(this.options.hoverClass);
1682
 
                        this._trigger('out', event, this.ui(draggable));
1683
 
                }
1684
 
 
1685
 
        },
1686
 
 
1687
 
        _drop: function(event,custom) {
1688
 
 
1689
 
                var draggable = custom || $.ui.ddmanager.current;
1690
 
                if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return false; // Bail if draggable and droppable are same element
1691
 
 
1692
 
                var childrenIntersection = false;
1693
 
                this.element.find(":data(droppable)").not(".ui-draggable-dragging").each(function() {
1694
 
                        var inst = $.data(this, 'droppable');
1695
 
                        if(
1696
 
                                inst.options.greedy
1697
 
                                && !inst.options.disabled
1698
 
                                && inst.options.scope == draggable.options.scope
1699
 
                                && inst.accept.call(inst.element[0], (draggable.currentItem || draggable.element))
1700
 
                                && $.ui.intersect(draggable, $.extend(inst, { offset: inst.element.offset() }), inst.options.tolerance)
1701
 
                        ) { childrenIntersection = true; return false; }
1702
 
                });
1703
 
                if(childrenIntersection) return false;
1704
 
 
1705
 
                if(this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
1706
 
                        if(this.options.activeClass) this.element.removeClass(this.options.activeClass);
1707
 
                        if(this.options.hoverClass) this.element.removeClass(this.options.hoverClass);
1708
 
                        this._trigger('drop', event, this.ui(draggable));
1709
 
                        return this.element;
1710
 
                }
1711
 
 
1712
 
                return false;
1713
 
 
1714
 
        },
1715
 
 
1716
 
        ui: function(c) {
1717
 
                return {
1718
 
                        draggable: (c.currentItem || c.element),
1719
 
                        helper: c.helper,
1720
 
                        position: c.position,
1721
 
                        offset: c.positionAbs
1722
 
                };
1723
 
        }
1724
 
 
1725
 
});
1726
 
 
1727
 
$.extend($.ui.droppable, {
1728
 
        version: "1.8.18"
1729
 
});
1730
 
 
1731
 
$.ui.intersect = function(draggable, droppable, toleranceMode) {
1732
 
 
1733
 
        if (!droppable.offset) return false;
1734
 
 
1735
 
        var x1 = (draggable.positionAbs || draggable.position.absolute).left, x2 = x1 + draggable.helperProportions.width,
1736
 
                y1 = (draggable.positionAbs || draggable.position.absolute).top, y2 = y1 + draggable.helperProportions.height;
1737
 
        var l = droppable.offset.left, r = l + droppable.proportions.width,
1738
 
                t = droppable.offset.top, b = t + droppable.proportions.height;
1739
 
 
1740
 
        switch (toleranceMode) {
1741
 
                case 'fit':
1742
 
                        return (l <= x1 && x2 <= r
1743
 
                                && t <= y1 && y2 <= b);
1744
 
                        break;
1745
 
                case 'intersect':
1746
 
                        return (l < x1 + (draggable.helperProportions.width / 2) // Right Half
1747
 
                                && x2 - (draggable.helperProportions.width / 2) < r // Left Half
1748
 
                                && t < y1 + (draggable.helperProportions.height / 2) // Bottom Half
1749
 
                                && y2 - (draggable.helperProportions.height / 2) < b ); // Top Half
1750
 
                        break;
1751
 
                case 'pointer':
1752
 
                        var draggableLeft = ((draggable.positionAbs || draggable.position.absolute).left + (draggable.clickOffset || draggable.offset.click).left),
1753
 
                                draggableTop = ((draggable.positionAbs || draggable.position.absolute).top + (draggable.clickOffset || draggable.offset.click).top),
1754
 
                                isOver = $.ui.isOver(draggableTop, draggableLeft, t, l, droppable.proportions.height, droppable.proportions.width);
1755
 
                        return isOver;
1756
 
                        break;
1757
 
                case 'touch':
1758
 
                        return (
1759
 
                                        (y1 >= t && y1 <= b) || // Top edge touching
1760
 
                                        (y2 >= t && y2 <= b) || // Bottom edge touching
1761
 
                                        (y1 < t && y2 > b)              // Surrounded vertically
1762
 
                                ) && (
1763
 
                                        (x1 >= l && x1 <= r) || // Left edge touching
1764
 
                                        (x2 >= l && x2 <= r) || // Right edge touching
1765
 
                                        (x1 < l && x2 > r)              // Surrounded horizontally
1766
 
                                );
1767
 
                        break;
1768
 
                default:
1769
 
                        return false;
1770
 
                        break;
1771
 
                }
1772
 
 
1773
 
};
1774
 
 
1775
 
/*
1776
 
        This manager tracks offsets of draggables and droppables
1777
 
*/
1778
 
$.ui.ddmanager = {
1779
 
        current: null,
1780
 
        droppables: { 'default': [] },
1781
 
        prepareOffsets: function(t, event) {
1782
 
 
1783
 
                var m = $.ui.ddmanager.droppables[t.options.scope] || [];
1784
 
                var type = event ? event.type : null; // workaround for #2317
1785
 
                var list = (t.currentItem || t.element).find(":data(droppable)").andSelf();
1786
 
 
1787
 
                droppablesLoop: for (var i = 0; i < m.length; i++) {
1788
 
 
1789
 
                        if(m[i].options.disabled || (t && !m[i].accept.call(m[i].element[0],(t.currentItem || t.element)))) continue;   //No disabled and non-accepted
1790
 
                        for (var j=0; j < list.length; j++) { if(list[j] == m[i].element[0]) { m[i].proportions.height = 0; continue droppablesLoop; } }; //Filter out elements in the current dragged item
1791
 
                        m[i].visible = m[i].element.css("display") != "none"; if(!m[i].visible) continue;                                                                       //If the element is not visible, continue
1792
 
 
1793
 
                        if(type == "mousedown") m[i]._activate.call(m[i], event); //Activate the droppable if used directly from draggables
1794
 
 
1795
 
                        m[i].offset = m[i].element.offset();
1796
 
                        m[i].proportions = { width: m[i].element[0].offsetWidth, height: m[i].element[0].offsetHeight };
1797
 
 
1798
 
                }
1799
 
 
1800
 
        },
1801
 
        drop: function(draggable, event) {
1802
 
 
1803
 
                var dropped = false;
1804
 
                $.each($.ui.ddmanager.droppables[draggable.options.scope] || [], function() {
1805
 
 
1806
 
                        if(!this.options) return;
1807
 
                        if (!this.options.disabled && this.visible && $.ui.intersect(draggable, this, this.options.tolerance))
1808
 
                                dropped = this._drop.call(this, event) || dropped;
1809
 
 
1810
 
                        if (!this.options.disabled && this.visible && this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
1811
 
                                this.isout = 1; this.isover = 0;
1812
 
                                this._deactivate.call(this, event);
1813
 
                        }
1814
 
 
1815
 
                });
1816
 
                return dropped;
1817
 
 
1818
 
        },
1819
 
        dragStart: function( draggable, event ) {
1820
 
                //Listen for scrolling so that if the dragging causes scrolling the position of the droppables can be recalculated (see #5003)
1821
 
                draggable.element.parents( ":not(body,html)" ).bind( "scroll.droppable", function() {
1822
 
                        if( !draggable.options.refreshPositions ) $.ui.ddmanager.prepareOffsets( draggable, event );
1823
 
                });
1824
 
        },
1825
 
        drag: function(draggable, event) {
1826
 
 
1827
 
                //If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse.
1828
 
                if(draggable.options.refreshPositions) $.ui.ddmanager.prepareOffsets(draggable, event);
1829
 
 
1830
 
                //Run through all droppables and check their positions based on specific tolerance options
1831
 
                $.each($.ui.ddmanager.droppables[draggable.options.scope] || [], function() {
1832
 
 
1833
 
                        if(this.options.disabled || this.greedyChild || !this.visible) return;
1834
 
                        var intersects = $.ui.intersect(draggable, this, this.options.tolerance);
1835
 
 
1836
 
                        var c = !intersects && this.isover == 1 ? 'isout' : (intersects && this.isover == 0 ? 'isover' : null);
1837
 
                        if(!c) return;
1838
 
 
1839
 
                        var parentInstance;
1840
 
                        if (this.options.greedy) {
1841
 
                                var parent = this.element.parents(':data(droppable):eq(0)');
1842
 
                                if (parent.length) {
1843
 
                                        parentInstance = $.data(parent[0], 'droppable');
1844
 
                                        parentInstance.greedyChild = (c == 'isover' ? 1 : 0);
1845
 
                                }
1846
 
                        }
1847
 
 
1848
 
                        // we just moved into a greedy child
1849
 
                        if (parentInstance && c == 'isover') {
1850
 
                                parentInstance['isover'] = 0;
1851
 
                                parentInstance['isout'] = 1;
1852
 
                                parentInstance._out.call(parentInstance, event);
1853
 
                        }
1854
 
 
1855
 
                        this[c] = 1; this[c == 'isout' ? 'isover' : 'isout'] = 0;
1856
 
                        this[c == "isover" ? "_over" : "_out"].call(this, event);
1857
 
 
1858
 
                        // we just moved out of a greedy child
1859
 
                        if (parentInstance && c == 'isout') {
1860
 
                                parentInstance['isout'] = 0;
1861
 
                                parentInstance['isover'] = 1;
1862
 
                                parentInstance._over.call(parentInstance, event);
1863
 
                        }
1864
 
                });
1865
 
 
1866
 
        },
1867
 
        dragStop: function( draggable, event ) {
1868
 
                draggable.element.parents( ":not(body,html)" ).unbind( "scroll.droppable" );
1869
 
                //Call prepareOffsets one final time since IE does not fire return scroll events when overflow was caused by drag (see #5003)
1870
 
                if( !draggable.options.refreshPositions ) $.ui.ddmanager.prepareOffsets( draggable, event );
1871
 
        }
1872
 
};
1873
 
 
1874
 
})(jQuery);
1875
 
/*
1876
 
 * jQuery UI Resizable 1.8.18
1877
 
 *
1878
 
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
1879
 
 * Dual licensed under the MIT or GPL Version 2 licenses.
1880
 
 * http://jquery.org/license
1881
 
 *
1882
 
 * http://docs.jquery.com/UI/Resizables
1883
 
 *
1884
 
 * Depends:
1885
 
 *      jquery.ui.core.js
1886
 
 *      jquery.ui.mouse.js
1887
 
 *      jquery.ui.widget.js
1888
 
 */
1889
 
(function( $, undefined ) {
1890
 
 
1891
 
$.widget("ui.resizable", $.ui.mouse, {
1892
 
        widgetEventPrefix: "resize",
1893
 
        options: {
1894
 
                alsoResize: false,
1895
 
                animate: false,
1896
 
                animateDuration: "slow",
1897
 
                animateEasing: "swing",
1898
 
                aspectRatio: false,
1899
 
                autoHide: false,
1900
 
                containment: false,
1901
 
                ghost: false,
1902
 
                grid: false,
1903
 
                handles: "e,s,se",
1904
 
                helper: false,
1905
 
                maxHeight: null,
1906
 
                maxWidth: null,
1907
 
                minHeight: 10,
1908
 
                minWidth: 10,
1909
 
                zIndex: 1000
1910
 
        },
1911
 
        _create: function() {
1912
 
 
1913
 
                var self = this, o = this.options;
1914
 
                this.element.addClass("ui-resizable");
1915
 
 
1916
 
                $.extend(this, {
1917
 
                        _aspectRatio: !!(o.aspectRatio),
1918
 
                        aspectRatio: o.aspectRatio,
1919
 
                        originalElement: this.element,
1920
 
                        _proportionallyResizeElements: [],
1921
 
                        _helper: o.helper || o.ghost || o.animate ? o.helper || 'ui-resizable-helper' : null
1922
 
                });
1923
 
 
1924
 
                //Wrap the element if it cannot hold child nodes
1925
 
                if(this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)) {
1926
 
 
1927
 
                        //Create a wrapper element and set the wrapper to the new current internal element
1928
 
                        this.element.wrap(
1929
 
                                $('<div class="ui-wrapper" style="overflow: hidden;"></div>').css({
1930
 
                                        position: this.element.css('position'),
1931
 
                                        width: this.element.outerWidth(),
1932
 
                                        height: this.element.outerHeight(),
1933
 
                                        top: this.element.css('top'),
1934
 
                                        left: this.element.css('left')
1935
 
                                })
1936
 
                        );
1937
 
 
1938
 
                        //Overwrite the original this.element
1939
 
                        this.element = this.element.parent().data(
1940
 
                                "resizable", this.element.data('resizable')
1941
 
                        );
1942
 
 
1943
 
                        this.elementIsWrapper = true;
1944
 
 
1945
 
                        //Move margins to the wrapper
1946
 
                        this.element.css({ marginLeft: this.originalElement.css("marginLeft"), marginTop: this.originalElement.css("marginTop"), marginRight: this.originalElement.css("marginRight"), marginBottom: this.originalElement.css("marginBottom") });
1947
 
                        this.originalElement.css({ marginLeft: 0, marginTop: 0, marginRight: 0, marginBottom: 0});
1948
 
 
1949
 
                        //Prevent Safari textarea resize
1950
 
                        this.originalResizeStyle = this.originalElement.css('resize');
1951
 
                        this.originalElement.css('resize', 'none');
1952
 
 
1953
 
                        //Push the actual element to our proportionallyResize internal array
1954
 
                        this._proportionallyResizeElements.push(this.originalElement.css({ position: 'static', zoom: 1, display: 'block' }));
1955
 
 
1956
 
                        // avoid IE jump (hard set the margin)
1957
 
                        this.originalElement.css({ margin: this.originalElement.css('margin') });
1958
 
 
1959
 
                        // fix handlers offset
1960
 
                        this._proportionallyResize();
1961
 
 
1962
 
                }
1963
 
 
1964
 
                this.handles = o.handles || (!$('.ui-resizable-handle', this.element).length ? "e,s,se" : { n: '.ui-resizable-n', e: '.ui-resizable-e', s: '.ui-resizable-s', w: '.ui-resizable-w', se: '.ui-resizable-se', sw: '.ui-resizable-sw', ne: '.ui-resizable-ne', nw: '.ui-resizable-nw' });
1965
 
                if(this.handles.constructor == String) {
1966
 
 
1967
 
                        if(this.handles == 'all') this.handles = 'n,e,s,w,se,sw,ne,nw';
1968
 
                        var n = this.handles.split(","); this.handles = {};
1969
 
 
1970
 
                        for(var i = 0; i < n.length; i++) {
1971
 
 
1972
 
                                var handle = $.trim(n[i]), hname = 'ui-resizable-'+handle;
1973
 
                                var axis = $('<div class="ui-resizable-handle ' + hname + '"></div>');
1974
 
 
1975
 
                                // increase zIndex of sw, se, ne, nw axis
1976
 
                                //TODO : this modifies original option
1977
 
                                if(/sw|se|ne|nw/.test(handle)) axis.css({ zIndex: ++o.zIndex });
1978
 
 
1979
 
                                //TODO : What's going on here?
1980
 
                                if ('se' == handle) {
1981
 
                                        axis.addClass('ui-icon ui-icon-gripsmall-diagonal-se');
1982
 
                                };
1983
 
 
1984
 
                                //Insert into internal handles object and append to element
1985
 
                                this.handles[handle] = '.ui-resizable-'+handle;
1986
 
                                this.element.append(axis);
1987
 
                        }
1988
 
 
1989
 
                }
1990
 
 
1991
 
                this._renderAxis = function(target) {
1992
 
 
1993
 
                        target = target || this.element;
1994
 
 
1995
 
                        for(var i in this.handles) {
1996
 
 
1997
 
                                if(this.handles[i].constructor == String)
1998
 
                                        this.handles[i] = $(this.handles[i], this.element).show();
1999
 
 
2000
 
                                //Apply pad to wrapper element, needed to fix axis position (textarea, inputs, scrolls)
2001
 
                                if (this.elementIsWrapper && this.originalElement[0].nodeName.match(/textarea|input|select|button/i)) {
2002
 
 
2003
 
                                        var axis = $(this.handles[i], this.element), padWrapper = 0;
2004
 
 
2005
 
                                        //Checking the correct pad and border
2006
 
                                        padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth();
2007
 
 
2008
 
                                        //The padding type i have to apply...
2009
 
                                        var padPos = [ 'padding',
2010
 
                                                /ne|nw|n/.test(i) ? 'Top' :
2011
 
                                                /se|sw|s/.test(i) ? 'Bottom' :
2012
 
                                                /^e$/.test(i) ? 'Right' : 'Left' ].join("");
2013
 
 
2014
 
                                        target.css(padPos, padWrapper);
2015
 
 
2016
 
                                        this._proportionallyResize();
2017
 
 
2018
 
                                }
2019
 
 
2020
 
                                //TODO: What's that good for? There's not anything to be executed left
2021
 
                                if(!$(this.handles[i]).length)
2022
 
                                        continue;
2023
 
 
2024
 
                        }
2025
 
                };
2026
 
 
2027
 
                //TODO: make renderAxis a prototype function
2028
 
                this._renderAxis(this.element);
2029
 
 
2030
 
                this._handles = $('.ui-resizable-handle', this.element)
2031
 
                        .disableSelection();
2032
 
 
2033
 
                //Matching axis name
2034
 
                this._handles.mouseover(function() {
2035
 
                        if (!self.resizing) {
2036
 
                                if (this.className)
2037
 
                                        var axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);
2038
 
                                //Axis, default = se
2039
 
                                self.axis = axis && axis[1] ? axis[1] : 'se';
2040
 
                        }
2041
 
                });
2042
 
 
2043
 
                //If we want to auto hide the elements
2044
 
                if (o.autoHide) {
2045
 
                        this._handles.hide();
2046
 
                        $(this.element)
2047
 
                                .addClass("ui-resizable-autohide")
2048
 
                                .hover(function() {
2049
 
                                        if (o.disabled) return;
2050
 
                                        $(this).removeClass("ui-resizable-autohide");
2051
 
                                        self._handles.show();
2052
 
                                },
2053
 
                                function(){
2054
 
                                        if (o.disabled) return;
2055
 
                                        if (!self.resizing) {
2056
 
                                                $(this).addClass("ui-resizable-autohide");
2057
 
                                                self._handles.hide();
2058
 
                                        }
2059
 
                                });
2060
 
                }
2061
 
 
2062
 
                //Initialize the mouse interaction
2063
 
                this._mouseInit();
2064
 
 
2065
 
        },
2066
 
 
2067
 
        destroy: function() {
2068
 
 
2069
 
                this._mouseDestroy();
2070
 
 
2071
 
                var _destroy = function(exp) {
2072
 
                        $(exp).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing")
2073
 
                                .removeData("resizable").unbind(".resizable").find('.ui-resizable-handle').remove();
2074
 
                };
2075
 
 
2076
 
                //TODO: Unwrap at same DOM position
2077
 
                if (this.elementIsWrapper) {
2078
 
                        _destroy(this.element);
2079
 
                        var wrapper = this.element;
2080
 
                        wrapper.after(
2081
 
                                this.originalElement.css({
2082
 
                                        position: wrapper.css('position'),
2083
 
                                        width: wrapper.outerWidth(),
2084
 
                                        height: wrapper.outerHeight(),
2085
 
                                        top: wrapper.css('top'),
2086
 
                                        left: wrapper.css('left')
2087
 
                                })
2088
 
                        ).remove();
2089
 
                }
2090
 
 
2091
 
                this.originalElement.css('resize', this.originalResizeStyle);
2092
 
                _destroy(this.originalElement);
2093
 
 
2094
 
                return this;
2095
 
        },
2096
 
 
2097
 
        _mouseCapture: function(event) {
2098
 
                var handle = false;
2099
 
                for (var i in this.handles) {
2100
 
                        if ($(this.handles[i])[0] == event.target) {
2101
 
                                handle = true;
2102
 
                        }
2103
 
                }
2104
 
 
2105
 
                return !this.options.disabled && handle;
2106
 
        },
2107
 
 
2108
 
        _mouseStart: function(event) {
2109
 
 
2110
 
                var o = this.options, iniPos = this.element.position(), el = this.element;
2111
 
 
2112
 
                this.resizing = true;
2113
 
                this.documentScroll = { top: $(document).scrollTop(), left: $(document).scrollLeft() };
2114
 
 
2115
 
                // bugfix for http://dev.jquery.com/ticket/1749
2116
 
                if (el.is('.ui-draggable') || (/absolute/).test(el.css('position'))) {
2117
 
                        el.css({ position: 'absolute', top: iniPos.top, left: iniPos.left });
2118
 
                }
2119
 
 
2120
 
                this._renderProxy();
2121
 
 
2122
 
                var curleft = num(this.helper.css('left')), curtop = num(this.helper.css('top'));
2123
 
 
2124
 
                if (o.containment) {
2125
 
                        curleft += $(o.containment).scrollLeft() || 0;
2126
 
                        curtop += $(o.containment).scrollTop() || 0;
2127
 
                }
2128
 
 
2129
 
                //Store needed variables
2130
 
                this.offset = this.helper.offset();
2131
 
                this.position = { left: curleft, top: curtop };
2132
 
                this.size = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
2133
 
                this.originalSize = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
2134
 
                this.originalPosition = { left: curleft, top: curtop };
2135
 
                this.sizeDiff = { width: el.outerWidth() - el.width(), height: el.outerHeight() - el.height() };
2136
 
                this.originalMousePosition = { left: event.pageX, top: event.pageY };
2137
 
 
2138
 
                //Aspect Ratio
2139
 
                this.aspectRatio = (typeof o.aspectRatio == 'number') ? o.aspectRatio : ((this.originalSize.width / this.originalSize.height) || 1);
2140
 
 
2141
 
            var cursor = $('.ui-resizable-' + this.axis).css('cursor');
2142
 
            $('body').css('cursor', cursor == 'auto' ? this.axis + '-resize' : cursor);
2143
 
 
2144
 
                el.addClass("ui-resizable-resizing");
2145
 
                this._propagate("start", event);
2146
 
                return true;
2147
 
        },
2148
 
 
2149
 
        _mouseDrag: function(event) {
2150
 
 
2151
 
                //Increase performance, avoid regex
2152
 
                var el = this.helper, o = this.options, props = {},
2153
 
                        self = this, smp = this.originalMousePosition, a = this.axis;
2154
 
 
2155
 
                var dx = (event.pageX-smp.left)||0, dy = (event.pageY-smp.top)||0;
2156
 
                var trigger = this._change[a];
2157
 
                if (!trigger) return false;
2158
 
 
2159
 
                // Calculate the attrs that will be change
2160
 
                var data = trigger.apply(this, [event, dx, dy]), ie6 = $.browser.msie && $.browser.version < 7, csdif = this.sizeDiff;
2161
 
 
2162
 
                // Put this in the mouseDrag handler since the user can start pressing shift while resizing
2163
 
                this._updateVirtualBoundaries(event.shiftKey);
2164
 
                if (this._aspectRatio || event.shiftKey)
2165
 
                        data = this._updateRatio(data, event);
2166
 
 
2167
 
                data = this._respectSize(data, event);
2168
 
 
2169
 
                // plugins callbacks need to be called first
2170
 
                this._propagate("resize", event);
2171
 
 
2172
 
                el.css({
2173
 
                        top: this.position.top + "px", left: this.position.left + "px",
2174
 
                        width: this.size.width + "px", height: this.size.height + "px"
2175
 
                });
2176
 
 
2177
 
                if (!this._helper && this._proportionallyResizeElements.length)
2178
 
                        this._proportionallyResize();
2179
 
 
2180
 
                this._updateCache(data);
2181
 
 
2182
 
                // calling the user callback at the end
2183
 
                this._trigger('resize', event, this.ui());
2184
 
 
2185
 
                return false;
2186
 
        },
2187
 
 
2188
 
        _mouseStop: function(event) {
2189
 
 
2190
 
                this.resizing = false;
2191
 
                var o = this.options, self = this;
2192
 
 
2193
 
                if(this._helper) {
2194
 
                        var pr = this._proportionallyResizeElements, ista = pr.length && (/textarea/i).test(pr[0].nodeName),
2195
 
                                soffseth = ista && $.ui.hasScroll(pr[0], 'left') /* TODO - jump height */ ? 0 : self.sizeDiff.height,
2196
 
                                soffsetw = ista ? 0 : self.sizeDiff.width;
2197
 
 
2198
 
                        var s = { width: (self.helper.width()  - soffsetw), height: (self.helper.height() - soffseth) },
2199
 
                                left = (parseInt(self.element.css('left'), 10) + (self.position.left - self.originalPosition.left)) || null,
2200
 
                                top = (parseInt(self.element.css('top'), 10) + (self.position.top - self.originalPosition.top)) || null;
2201
 
 
2202
 
                        if (!o.animate)
2203
 
                                this.element.css($.extend(s, { top: top, left: left }));
2204
 
 
2205
 
                        self.helper.height(self.size.height);
2206
 
                        self.helper.width(self.size.width);
2207
 
 
2208
 
                        if (this._helper && !o.animate) this._proportionallyResize();
2209
 
                }
2210
 
 
2211
 
                $('body').css('cursor', 'auto');
2212
 
 
2213
 
                this.element.removeClass("ui-resizable-resizing");
2214
 
 
2215
 
                this._propagate("stop", event);
2216
 
 
2217
 
                if (this._helper) this.helper.remove();
2218
 
                return false;
2219
 
 
2220
 
        },
2221
 
 
2222
 
    _updateVirtualBoundaries: function(forceAspectRatio) {
2223
 
        var o = this.options, pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b;
2224
 
 
2225
 
        b = {
2226
 
            minWidth: isNumber(o.minWidth) ? o.minWidth : 0,
2227
 
            maxWidth: isNumber(o.maxWidth) ? o.maxWidth : Infinity,
2228
 
            minHeight: isNumber(o.minHeight) ? o.minHeight : 0,
2229
 
            maxHeight: isNumber(o.maxHeight) ? o.maxHeight : Infinity
2230
 
        };
2231
 
 
2232
 
        if(this._aspectRatio || forceAspectRatio) {
2233
 
            // We want to create an enclosing box whose aspect ration is the requested one
2234
 
            // First, compute the "projected" size for each dimension based on the aspect ratio and other dimension
2235
 
            pMinWidth = b.minHeight * this.aspectRatio;
2236
 
            pMinHeight = b.minWidth / this.aspectRatio;
2237
 
            pMaxWidth = b.maxHeight * this.aspectRatio;
2238
 
            pMaxHeight = b.maxWidth / this.aspectRatio;
2239
 
 
2240
 
            if(pMinWidth > b.minWidth) b.minWidth = pMinWidth;
2241
 
            if(pMinHeight > b.minHeight) b.minHeight = pMinHeight;
2242
 
            if(pMaxWidth < b.maxWidth) b.maxWidth = pMaxWidth;
2243
 
            if(pMaxHeight < b.maxHeight) b.maxHeight = pMaxHeight;
2244
 
        }
2245
 
        this._vBoundaries = b;
2246
 
    },
2247
 
 
2248
 
        _updateCache: function(data) {
2249
 
                var o = this.options;
2250
 
                this.offset = this.helper.offset();
2251
 
                if (isNumber(data.left)) this.position.left = data.left;
2252
 
                if (isNumber(data.top)) this.position.top = data.top;
2253
 
                if (isNumber(data.height)) this.size.height = data.height;
2254
 
                if (isNumber(data.width)) this.size.width = data.width;
2255
 
        },
2256
 
 
2257
 
        _updateRatio: function(data, event) {
2258
 
 
2259
 
                var o = this.options, cpos = this.position, csize = this.size, a = this.axis;
2260
 
 
2261
 
                if (isNumber(data.height)) data.width = (data.height * this.aspectRatio);
2262
 
                else if (isNumber(data.width)) data.height = (data.width / this.aspectRatio);
2263
 
 
2264
 
                if (a == 'sw') {
2265
 
                        data.left = cpos.left + (csize.width - data.width);
2266
 
                        data.top = null;
2267
 
                }
2268
 
                if (a == 'nw') {
2269
 
                        data.top = cpos.top + (csize.height - data.height);
2270
 
                        data.left = cpos.left + (csize.width - data.width);
2271
 
                }
2272
 
 
2273
 
                return data;
2274
 
        },
2275
 
 
2276
 
        _respectSize: function(data, event) {
2277
 
 
2278
 
                var el = this.helper, o = this._vBoundaries, pRatio = this._aspectRatio || event.shiftKey, a = this.axis,
2279
 
                                ismaxw = isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width), ismaxh = isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height),
2280
 
                                        isminw = isNumber(data.width) && o.minWidth && (o.minWidth > data.width), isminh = isNumber(data.height) && o.minHeight && (o.minHeight > data.height);
2281
 
 
2282
 
                if (isminw) data.width = o.minWidth;
2283
 
                if (isminh) data.height = o.minHeight;
2284
 
                if (ismaxw) data.width = o.maxWidth;
2285
 
                if (ismaxh) data.height = o.maxHeight;
2286
 
 
2287
 
                var dw = this.originalPosition.left + this.originalSize.width, dh = this.position.top + this.size.height;
2288
 
                var cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a);
2289
 
 
2290
 
                if (isminw && cw) data.left = dw - o.minWidth;
2291
 
                if (ismaxw && cw) data.left = dw - o.maxWidth;
2292
 
                if (isminh && ch)       data.top = dh - o.minHeight;
2293
 
                if (ismaxh && ch)       data.top = dh - o.maxHeight;
2294
 
 
2295
 
                // fixing jump error on top/left - bug #2330
2296
 
                var isNotwh = !data.width && !data.height;
2297
 
                if (isNotwh && !data.left && data.top) data.top = null;
2298
 
                else if (isNotwh && !data.top && data.left) data.left = null;
2299
 
 
2300
 
                return data;
2301
 
        },
2302
 
 
2303
 
        _proportionallyResize: function() {
2304
 
 
2305
 
                var o = this.options;
2306
 
                if (!this._proportionallyResizeElements.length) return;
2307
 
                var element = this.helper || this.element;
2308
 
 
2309
 
                for (var i=0; i < this._proportionallyResizeElements.length; i++) {
2310
 
 
2311
 
                        var prel = this._proportionallyResizeElements[i];
2312
 
 
2313
 
                        if (!this.borderDif) {
2314
 
                                var b = [prel.css('borderTopWidth'), prel.css('borderRightWidth'), prel.css('borderBottomWidth'), prel.css('borderLeftWidth')],
2315
 
                                        p = [prel.css('paddingTop'), prel.css('paddingRight'), prel.css('paddingBottom'), prel.css('paddingLeft')];
2316
 
 
2317
 
                                this.borderDif = $.map(b, function(v, i) {
2318
 
                                        var border = parseInt(v,10)||0, padding = parseInt(p[i],10)||0;
2319
 
                                        return border + padding;
2320
 
                                });
2321
 
                        }
2322
 
 
2323
 
                        if ($.browser.msie && !(!($(element).is(':hidden') || $(element).parents(':hidden').length)))
2324
 
                                continue;
2325
 
 
2326
 
                        prel.css({
2327
 
                                height: (element.height() - this.borderDif[0] - this.borderDif[2]) || 0,
2328
 
                                width: (element.width() - this.borderDif[1] - this.borderDif[3]) || 0
2329
 
                        });
2330
 
 
2331
 
                };
2332
 
 
2333
 
        },
2334
 
 
2335
 
        _renderProxy: function() {
2336
 
 
2337
 
                var el = this.element, o = this.options;
2338
 
                this.elementOffset = el.offset();
2339
 
 
2340
 
                if(this._helper) {
2341
 
 
2342
 
                        this.helper = this.helper || $('<div style="overflow:hidden;"></div>');
2343
 
 
2344
 
                        // fix ie6 offset TODO: This seems broken
2345
 
                        var ie6 = $.browser.msie && $.browser.version < 7, ie6offset = (ie6 ? 1 : 0),
2346
 
                        pxyoffset = ( ie6 ? 2 : -1 );
2347
 
 
2348
 
                        this.helper.addClass(this._helper).css({
2349
 
                                width: this.element.outerWidth() + pxyoffset,
2350
 
                                height: this.element.outerHeight() + pxyoffset,
2351
 
                                position: 'absolute',
2352
 
                                left: this.elementOffset.left - ie6offset +'px',
2353
 
                                top: this.elementOffset.top - ie6offset +'px',
2354
 
                                zIndex: ++o.zIndex //TODO: Don't modify option
2355
 
                        });
2356
 
 
2357
 
                        this.helper
2358
 
                                .appendTo("body")
2359
 
                                .disableSelection();
2360
 
 
2361
 
                } else {
2362
 
                        this.helper = this.element;
2363
 
                }
2364
 
 
2365
 
        },
2366
 
 
2367
 
        _change: {
2368
 
                e: function(event, dx, dy) {
2369
 
                        return { width: this.originalSize.width + dx };
2370
 
                },
2371
 
                w: function(event, dx, dy) {
2372
 
                        var o = this.options, cs = this.originalSize, sp = this.originalPosition;
2373
 
                        return { left: sp.left + dx, width: cs.width - dx };
2374
 
                },
2375
 
                n: function(event, dx, dy) {
2376
 
                        var o = this.options, cs = this.originalSize, sp = this.originalPosition;
2377
 
                        return { top: sp.top + dy, height: cs.height - dy };
2378
 
                },
2379
 
                s: function(event, dx, dy) {
2380
 
                        return { height: this.originalSize.height + dy };
2381
 
                },
2382
 
                se: function(event, dx, dy) {
2383
 
                        return $.extend(this._change.s.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
2384
 
                },
2385
 
                sw: function(event, dx, dy) {
2386
 
                        return $.extend(this._change.s.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
2387
 
                },
2388
 
                ne: function(event, dx, dy) {
2389
 
                        return $.extend(this._change.n.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
2390
 
                },
2391
 
                nw: function(event, dx, dy) {
2392
 
                        return $.extend(this._change.n.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
2393
 
                }
2394
 
        },
2395
 
 
2396
 
        _propagate: function(n, event) {
2397
 
                $.ui.plugin.call(this, n, [event, this.ui()]);
2398
 
                (n != "resize" && this._trigger(n, event, this.ui()));
2399
 
        },
2400
 
 
2401
 
        plugins: {},
2402
 
 
2403
 
        ui: function() {
2404
 
                return {
2405
 
                        originalElement: this.originalElement,
2406
 
                        element: this.element,
2407
 
                        helper: this.helper,
2408
 
                        position: this.position,
2409
 
                        size: this.size,
2410
 
                        originalSize: this.originalSize,
2411
 
                        originalPosition: this.originalPosition
2412
 
                };
2413
 
        }
2414
 
 
2415
 
});
2416
 
 
2417
 
$.extend($.ui.resizable, {
2418
 
        version: "1.8.18"
2419
 
});
2420
 
 
2421
 
/*
2422
 
 * Resizable Extensions
2423
 
 */
2424
 
 
2425
 
$.ui.plugin.add("resizable", "alsoResize", {
2426
 
 
2427
 
        start: function (event, ui) {
2428
 
                var self = $(this).data("resizable"), o = self.options;
2429
 
 
2430
 
                var _store = function (exp) {
2431
 
                        $(exp).each(function() {
2432
 
                                var el = $(this);
2433
 
                                el.data("resizable-alsoresize", {
2434
 
                                        width: parseInt(el.width(), 10), height: parseInt(el.height(), 10),
2435
 
                                        left: parseInt(el.css('left'), 10), top: parseInt(el.css('top'), 10)
2436
 
                                });
2437
 
                        });
2438
 
                };
2439
 
 
2440
 
                if (typeof(o.alsoResize) == 'object' && !o.alsoResize.parentNode) {
2441
 
                        if (o.alsoResize.length) { o.alsoResize = o.alsoResize[0]; _store(o.alsoResize); }
2442
 
                        else { $.each(o.alsoResize, function (exp) { _store(exp); }); }
2443
 
                }else{
2444
 
                        _store(o.alsoResize);
2445
 
                }
2446
 
        },
2447
 
 
2448
 
        resize: function (event, ui) {
2449
 
                var self = $(this).data("resizable"), o = self.options, os = self.originalSize, op = self.originalPosition;
2450
 
 
2451
 
                var delta = {
2452
 
                        height: (self.size.height - os.height) || 0, width: (self.size.width - os.width) || 0,
2453
 
                        top: (self.position.top - op.top) || 0, left: (self.position.left - op.left) || 0
2454
 
                },
2455
 
 
2456
 
                _alsoResize = function (exp, c) {
2457
 
                        $(exp).each(function() {
2458
 
                                var el = $(this), start = $(this).data("resizable-alsoresize"), style = {}, 
2459
 
                                        css = c && c.length ? c : el.parents(ui.originalElement[0]).length ? ['width', 'height'] : ['width', 'height', 'top', 'left'];
2460
 
 
2461
 
                                $.each(css, function (i, prop) {
2462
 
                                        var sum = (start[prop]||0) + (delta[prop]||0);
2463
 
                                        if (sum && sum >= 0)
2464
 
                                                style[prop] = sum || null;
2465
 
                                });
2466
 
 
2467
 
                                el.css(style);
2468
 
                        });
2469
 
                };
2470
 
 
2471
 
                if (typeof(o.alsoResize) == 'object' && !o.alsoResize.nodeType) {
2472
 
                        $.each(o.alsoResize, function (exp, c) { _alsoResize(exp, c); });
2473
 
                }else{
2474
 
                        _alsoResize(o.alsoResize);
2475
 
                }
2476
 
        },
2477
 
 
2478
 
        stop: function (event, ui) {
2479
 
                $(this).removeData("resizable-alsoresize");
2480
 
        }
2481
 
});
2482
 
 
2483
 
$.ui.plugin.add("resizable", "animate", {
2484
 
 
2485
 
        stop: function(event, ui) {
2486
 
                var self = $(this).data("resizable"), o = self.options;
2487
 
 
2488
 
                var pr = self._proportionallyResizeElements, ista = pr.length && (/textarea/i).test(pr[0].nodeName),
2489
 
                                        soffseth = ista && $.ui.hasScroll(pr[0], 'left') /* TODO - jump height */ ? 0 : self.sizeDiff.height,
2490
 
                                                soffsetw = ista ? 0 : self.sizeDiff.width;
2491
 
 
2492
 
                var style = { width: (self.size.width - soffsetw), height: (self.size.height - soffseth) },
2493
 
                                        left = (parseInt(self.element.css('left'), 10) + (self.position.left - self.originalPosition.left)) || null,
2494
 
                                                top = (parseInt(self.element.css('top'), 10) + (self.position.top - self.originalPosition.top)) || null;
2495
 
 
2496
 
                self.element.animate(
2497
 
                        $.extend(style, top && left ? { top: top, left: left } : {}), {
2498
 
                                duration: o.animateDuration,
2499
 
                                easing: o.animateEasing,
2500
 
                                step: function() {
2501
 
 
2502
 
                                        var data = {
2503
 
                                                width: parseInt(self.element.css('width'), 10),
2504
 
                                                height: parseInt(self.element.css('height'), 10),
2505
 
                                                top: parseInt(self.element.css('top'), 10),
2506
 
                                                left: parseInt(self.element.css('left'), 10)
2507
 
                                        };
2508
 
 
2509
 
                                        if (pr && pr.length) $(pr[0]).css({ width: data.width, height: data.height });
2510
 
 
2511
 
                                        // propagating resize, and updating values for each animation step
2512
 
                                        self._updateCache(data);
2513
 
                                        self._propagate("resize", event);
2514
 
 
2515
 
                                }
2516
 
                        }
2517
 
                );
2518
 
        }
2519
 
 
2520
 
});
2521
 
 
2522
 
$.ui.plugin.add("resizable", "containment", {
2523
 
 
2524
 
        start: function(event, ui) {
2525
 
                var self = $(this).data("resizable"), o = self.options, el = self.element;
2526
 
                var oc = o.containment, ce = (oc instanceof $) ? oc.get(0) : (/parent/.test(oc)) ? el.parent().get(0) : oc;
2527
 
                if (!ce) return;
2528
 
 
2529
 
                self.containerElement = $(ce);
2530
 
 
2531
 
                if (/document/.test(oc) || oc == document) {
2532
 
                        self.containerOffset = { left: 0, top: 0 };
2533
 
                        self.containerPosition = { left: 0, top: 0 };
2534
 
 
2535
 
                        self.parentData = {
2536
 
                                element: $(document), left: 0, top: 0,
2537
 
                                width: $(document).width(), height: $(document).height() || document.body.parentNode.scrollHeight
2538
 
                        };
2539
 
                }
2540
 
 
2541
 
                // i'm a node, so compute top, left, right, bottom
2542
 
                else {
2543
 
                        var element = $(ce), p = [];
2544
 
                        $([ "Top", "Right", "Left", "Bottom" ]).each(function(i, name) { p[i] = num(element.css("padding" + name)); });
2545
 
 
2546
 
                        self.containerOffset = element.offset();
2547
 
                        self.containerPosition = element.position();
2548
 
                        self.containerSize = { height: (element.innerHeight() - p[3]), width: (element.innerWidth() - p[1]) };
2549
 
 
2550
 
                        var co = self.containerOffset, ch = self.containerSize.height,  cw = self.containerSize.width,
2551
 
                                                width = ($.ui.hasScroll(ce, "left") ? ce.scrollWidth : cw ), height = ($.ui.hasScroll(ce) ? ce.scrollHeight : ch);
2552
 
 
2553
 
                        self.parentData = {
2554
 
                                element: ce, left: co.left, top: co.top, width: width, height: height
2555
 
                        };
2556
 
                }
2557
 
        },
2558
 
 
2559
 
        resize: function(event, ui) {
2560
 
                var self = $(this).data("resizable"), o = self.options,
2561
 
                                ps = self.containerSize, co = self.containerOffset, cs = self.size, cp = self.position,
2562
 
                                pRatio = self._aspectRatio || event.shiftKey, cop = { top:0, left:0 }, ce = self.containerElement;
2563
 
 
2564
 
                if (ce[0] != document && (/static/).test(ce.css('position'))) cop = co;
2565
 
 
2566
 
                if (cp.left < (self._helper ? co.left : 0)) {
2567
 
                        self.size.width = self.size.width + (self._helper ? (self.position.left - co.left) : (self.position.left - cop.left));
2568
 
                        if (pRatio) self.size.height = self.size.width / o.aspectRatio;
2569
 
                        self.position.left = o.helper ? co.left : 0;
2570
 
                }
2571
 
 
2572
 
                if (cp.top < (self._helper ? co.top : 0)) {
2573
 
                        self.size.height = self.size.height + (self._helper ? (self.position.top - co.top) : self.position.top);
2574
 
                        if (pRatio) self.size.width = self.size.height * o.aspectRatio;
2575
 
                        self.position.top = self._helper ? co.top : 0;
2576
 
                }
2577
 
 
2578
 
                self.offset.left = self.parentData.left+self.position.left;
2579
 
                self.offset.top = self.parentData.top+self.position.top;
2580
 
 
2581
 
                var woset = Math.abs( (self._helper ? self.offset.left - cop.left : (self.offset.left - cop.left)) + self.sizeDiff.width ),
2582
 
                                        hoset = Math.abs( (self._helper ? self.offset.top - cop.top : (self.offset.top - co.top)) + self.sizeDiff.height );
2583
 
 
2584
 
                var isParent = self.containerElement.get(0) == self.element.parent().get(0),
2585
 
                    isOffsetRelative = /relative|absolute/.test(self.containerElement.css('position'));
2586
 
 
2587
 
                if(isParent && isOffsetRelative) woset -= self.parentData.left;
2588
 
 
2589
 
                if (woset + self.size.width >= self.parentData.width) {
2590
 
                        self.size.width = self.parentData.width - woset;
2591
 
                        if (pRatio) self.size.height = self.size.width / self.aspectRatio;
2592
 
                }
2593
 
 
2594
 
                if (hoset + self.size.height >= self.parentData.height) {
2595
 
                        self.size.height = self.parentData.height - hoset;
2596
 
                        if (pRatio) self.size.width = self.size.height * self.aspectRatio;
2597
 
                }
2598
 
        },
2599
 
 
2600
 
        stop: function(event, ui){
2601
 
                var self = $(this).data("resizable"), o = self.options, cp = self.position,
2602
 
                                co = self.containerOffset, cop = self.containerPosition, ce = self.containerElement;
2603
 
 
2604
 
                var helper = $(self.helper), ho = helper.offset(), w = helper.outerWidth() - self.sizeDiff.width, h = helper.outerHeight() - self.sizeDiff.height;
2605
 
 
2606
 
                if (self._helper && !o.animate && (/relative/).test(ce.css('position')))
2607
 
                        $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
2608
 
 
2609
 
                if (self._helper && !o.animate && (/static/).test(ce.css('position')))
2610
 
                        $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
2611
 
 
2612
 
        }
2613
 
});
2614
 
 
2615
 
$.ui.plugin.add("resizable", "ghost", {
2616
 
 
2617
 
        start: function(event, ui) {
2618
 
 
2619
 
                var self = $(this).data("resizable"), o = self.options, cs = self.size;
2620
 
 
2621
 
                self.ghost = self.originalElement.clone();
2622
 
                self.ghost
2623
 
                        .css({ opacity: .25, display: 'block', position: 'relative', height: cs.height, width: cs.width, margin: 0, left: 0, top: 0 })
2624
 
                        .addClass('ui-resizable-ghost')
2625
 
                        .addClass(typeof o.ghost == 'string' ? o.ghost : '');
2626
 
 
2627
 
                self.ghost.appendTo(self.helper);
2628
 
 
2629
 
        },
2630
 
 
2631
 
        resize: function(event, ui){
2632
 
                var self = $(this).data("resizable"), o = self.options;
2633
 
                if (self.ghost) self.ghost.css({ position: 'relative', height: self.size.height, width: self.size.width });
2634
 
        },
2635
 
 
2636
 
        stop: function(event, ui){
2637
 
                var self = $(this).data("resizable"), o = self.options;
2638
 
                if (self.ghost && self.helper) self.helper.get(0).removeChild(self.ghost.get(0));
2639
 
        }
2640
 
 
2641
 
});
2642
 
 
2643
 
$.ui.plugin.add("resizable", "grid", {
2644
 
 
2645
 
        resize: function(event, ui) {
2646
 
                var self = $(this).data("resizable"), o = self.options, cs = self.size, os = self.originalSize, op = self.originalPosition, a = self.axis, ratio = o._aspectRatio || event.shiftKey;
2647
 
                o.grid = typeof o.grid == "number" ? [o.grid, o.grid] : o.grid;
2648
 
                var ox = Math.round((cs.width - os.width) / (o.grid[0]||1)) * (o.grid[0]||1), oy = Math.round((cs.height - os.height) / (o.grid[1]||1)) * (o.grid[1]||1);
2649
 
 
2650
 
                if (/^(se|s|e)$/.test(a)) {
2651
 
                        self.size.width = os.width + ox;
2652
 
                        self.size.height = os.height + oy;
2653
 
                }
2654
 
                else if (/^(ne)$/.test(a)) {
2655
 
                        self.size.width = os.width + ox;
2656
 
                        self.size.height = os.height + oy;
2657
 
                        self.position.top = op.top - oy;
2658
 
                }
2659
 
                else if (/^(sw)$/.test(a)) {
2660
 
                        self.size.width = os.width + ox;
2661
 
                        self.size.height = os.height + oy;
2662
 
                        self.position.left = op.left - ox;
2663
 
                }
2664
 
                else {
2665
 
                        self.size.width = os.width + ox;
2666
 
                        self.size.height = os.height + oy;
2667
 
                        self.position.top = op.top - oy;
2668
 
                        self.position.left = op.left - ox;
2669
 
                }
2670
 
        }
2671
 
 
2672
 
});
2673
 
 
2674
 
var num = function(v) {
2675
 
        return parseInt(v, 10) || 0;
2676
 
};
2677
 
 
2678
 
var isNumber = function(value) {
2679
 
        return !isNaN(parseInt(value, 10));
2680
 
};
2681
 
 
2682
 
})(jQuery);
2683
 
/*
2684
 
 * jQuery UI Selectable 1.8.18
2685
 
 *
2686
 
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
2687
 
 * Dual licensed under the MIT or GPL Version 2 licenses.
2688
 
 * http://jquery.org/license
2689
 
 *
2690
 
 * http://docs.jquery.com/UI/Selectables
2691
 
 *
2692
 
 * Depends:
2693
 
 *      jquery.ui.core.js
2694
 
 *      jquery.ui.mouse.js
2695
 
 *      jquery.ui.widget.js
2696
 
 */
2697
 
(function( $, undefined ) {
2698
 
 
2699
 
$.widget("ui.selectable", $.ui.mouse, {
2700
 
        options: {
2701
 
                appendTo: 'body',
2702
 
                autoRefresh: true,
2703
 
                distance: 0,
2704
 
                filter: '*',
2705
 
                tolerance: 'touch'
2706
 
        },
2707
 
        _create: function() {
2708
 
                var self = this;
2709
 
 
2710
 
                this.element.addClass("ui-selectable");
2711
 
 
2712
 
                this.dragged = false;
2713
 
 
2714
 
                // cache selectee children based on filter
2715
 
                var selectees;
2716
 
                this.refresh = function() {
2717
 
                        selectees = $(self.options.filter, self.element[0]);
2718
 
                        selectees.addClass("ui-selectee");
2719
 
                        selectees.each(function() {
2720
 
                                var $this = $(this);
2721
 
                                var pos = $this.offset();
2722
 
                                $.data(this, "selectable-item", {
2723
 
                                        element: this,
2724
 
                                        $element: $this,
2725
 
                                        left: pos.left,
2726
 
                                        top: pos.top,
2727
 
                                        right: pos.left + $this.outerWidth(),
2728
 
                                        bottom: pos.top + $this.outerHeight(),
2729
 
                                        startselected: false,
2730
 
                                        selected: $this.hasClass('ui-selected'),
2731
 
                                        selecting: $this.hasClass('ui-selecting'),
2732
 
                                        unselecting: $this.hasClass('ui-unselecting')
2733
 
                                });
2734
 
                        });
2735
 
                };
2736
 
                this.refresh();
2737
 
 
2738
 
                this.selectees = selectees.addClass("ui-selectee");
2739
 
 
2740
 
                this._mouseInit();
2741
 
 
2742
 
                this.helper = $("<div class='ui-selectable-helper'></div>");
2743
 
        },
2744
 
 
2745
 
        destroy: function() {
2746
 
                this.selectees
2747
 
                        .removeClass("ui-selectee")
2748
 
                        .removeData("selectable-item");
2749
 
                this.element
2750
 
                        .removeClass("ui-selectable ui-selectable-disabled")
2751
 
                        .removeData("selectable")
2752
 
                        .unbind(".selectable");
2753
 
                this._mouseDestroy();
2754
 
 
2755
 
                return this;
2756
 
        },
2757
 
 
2758
 
        _mouseStart: function(event) {
2759
 
                var self = this;
2760
 
 
2761
 
                this.opos = [event.pageX, event.pageY];
2762
 
 
2763
 
                if (this.options.disabled)
2764
 
                        return;
2765
 
 
2766
 
                var options = this.options;
2767
 
 
2768
 
                this.selectees = $(options.filter, this.element[0]);
2769
 
 
2770
 
                this._trigger("start", event);
2771
 
 
2772
 
                $(options.appendTo).append(this.helper);
2773
 
                // position helper (lasso)
2774
 
                this.helper.css({
2775
 
                        "left": event.clientX,
2776
 
                        "top": event.clientY,
2777
 
                        "width": 0,
2778
 
                        "height": 0
2779
 
                });
2780
 
 
2781
 
                if (options.autoRefresh) {
2782
 
                        this.refresh();
2783
 
                }
2784
 
 
2785
 
                this.selectees.filter('.ui-selected').each(function() {
2786
 
                        var selectee = $.data(this, "selectable-item");
2787
 
                        selectee.startselected = true;
2788
 
                        if (!event.metaKey && !event.ctrlKey) {
2789
 
                                selectee.$element.removeClass('ui-selected');
2790
 
                                selectee.selected = false;
2791
 
                                selectee.$element.addClass('ui-unselecting');
2792
 
                                selectee.unselecting = true;
2793
 
                                // selectable UNSELECTING callback
2794
 
                                self._trigger("unselecting", event, {
2795
 
                                        unselecting: selectee.element
2796
 
                                });
2797
 
                        }
2798
 
                });
2799
 
 
2800
 
                $(event.target).parents().andSelf().each(function() {
2801
 
                        var selectee = $.data(this, "selectable-item");
2802
 
                        if (selectee) {
2803
 
                                var doSelect = (!event.metaKey && !event.ctrlKey) || !selectee.$element.hasClass('ui-selected');
2804
 
                                selectee.$element
2805
 
                                        .removeClass(doSelect ? "ui-unselecting" : "ui-selected")
2806
 
                                        .addClass(doSelect ? "ui-selecting" : "ui-unselecting");
2807
 
                                selectee.unselecting = !doSelect;
2808
 
                                selectee.selecting = doSelect;
2809
 
                                selectee.selected = doSelect;
2810
 
                                // selectable (UN)SELECTING callback
2811
 
                                if (doSelect) {
2812
 
                                        self._trigger("selecting", event, {
2813
 
                                                selecting: selectee.element
2814
 
                                        });
2815
 
                                } else {
2816
 
                                        self._trigger("unselecting", event, {
2817
 
                                                unselecting: selectee.element
2818
 
                                        });
2819
 
                                }
2820
 
                                return false;
2821
 
                        }
2822
 
                });
2823
 
 
2824
 
        },
2825
 
 
2826
 
        _mouseDrag: function(event) {
2827
 
                var self = this;
2828
 
                this.dragged = true;
2829
 
 
2830
 
                if (this.options.disabled)
2831
 
                        return;
2832
 
 
2833
 
                var options = this.options;
2834
 
 
2835
 
                var x1 = this.opos[0], y1 = this.opos[1], x2 = event.pageX, y2 = event.pageY;
2836
 
                if (x1 > x2) { var tmp = x2; x2 = x1; x1 = tmp; }
2837
 
                if (y1 > y2) { var tmp = y2; y2 = y1; y1 = tmp; }
2838
 
                this.helper.css({left: x1, top: y1, width: x2-x1, height: y2-y1});
2839
 
 
2840
 
                this.selectees.each(function() {
2841
 
                        var selectee = $.data(this, "selectable-item");
2842
 
                        //prevent helper from being selected if appendTo: selectable
2843
 
                        if (!selectee || selectee.element == self.element[0])
2844
 
                                return;
2845
 
                        var hit = false;
2846
 
                        if (options.tolerance == 'touch') {
2847
 
                                hit = ( !(selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1) );
2848
 
                        } else if (options.tolerance == 'fit') {
2849
 
                                hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2);
2850
 
                        }
2851
 
 
2852
 
                        if (hit) {
2853
 
                                // SELECT
2854
 
                                if (selectee.selected) {
2855
 
                                        selectee.$element.removeClass('ui-selected');
2856
 
                                        selectee.selected = false;
2857
 
                                }
2858
 
                                if (selectee.unselecting) {
2859
 
                                        selectee.$element.removeClass('ui-unselecting');
2860
 
                                        selectee.unselecting = false;
2861
 
                                }
2862
 
                                if (!selectee.selecting) {
2863
 
                                        selectee.$element.addClass('ui-selecting');
2864
 
                                        selectee.selecting = true;
2865
 
                                        // selectable SELECTING callback
2866
 
                                        self._trigger("selecting", event, {
2867
 
                                                selecting: selectee.element
2868
 
                                        });
2869
 
                                }
2870
 
                        } else {
2871
 
                                // UNSELECT
2872
 
                                if (selectee.selecting) {
2873
 
                                        if ((event.metaKey || event.ctrlKey) && selectee.startselected) {
2874
 
                                                selectee.$element.removeClass('ui-selecting');
2875
 
                                                selectee.selecting = false;
2876
 
                                                selectee.$element.addClass('ui-selected');
2877
 
                                                selectee.selected = true;
2878
 
                                        } else {
2879
 
                                                selectee.$element.removeClass('ui-selecting');
2880
 
                                                selectee.selecting = false;
2881
 
                                                if (selectee.startselected) {
2882
 
                                                        selectee.$element.addClass('ui-unselecting');
2883
 
                                                        selectee.unselecting = true;
2884
 
                                                }
2885
 
                                                // selectable UNSELECTING callback
2886
 
                                                self._trigger("unselecting", event, {
2887
 
                                                        unselecting: selectee.element
2888
 
                                                });
2889
 
                                        }
2890
 
                                }
2891
 
                                if (selectee.selected) {
2892
 
                                        if (!event.metaKey && !event.ctrlKey && !selectee.startselected) {
2893
 
                                                selectee.$element.removeClass('ui-selected');
2894
 
                                                selectee.selected = false;
2895
 
 
2896
 
                                                selectee.$element.addClass('ui-unselecting');
2897
 
                                                selectee.unselecting = true;
2898
 
                                                // selectable UNSELECTING callback
2899
 
                                                self._trigger("unselecting", event, {
2900
 
                                                        unselecting: selectee.element
2901
 
                                                });
2902
 
                                        }
2903
 
                                }
2904
 
                        }
2905
 
                });
2906
 
 
2907
 
                return false;
2908
 
        },
2909
 
 
2910
 
        _mouseStop: function(event) {
2911
 
                var self = this;
2912
 
 
2913
 
                this.dragged = false;
2914
 
 
2915
 
                var options = this.options;
2916
 
 
2917
 
                $('.ui-unselecting', this.element[0]).each(function() {
2918
 
                        var selectee = $.data(this, "selectable-item");
2919
 
                        selectee.$element.removeClass('ui-unselecting');
2920
 
                        selectee.unselecting = false;
2921
 
                        selectee.startselected = false;
2922
 
                        self._trigger("unselected", event, {
2923
 
                                unselected: selectee.element
2924
 
                        });
2925
 
                });
2926
 
                $('.ui-selecting', this.element[0]).each(function() {
2927
 
                        var selectee = $.data(this, "selectable-item");
2928
 
                        selectee.$element.removeClass('ui-selecting').addClass('ui-selected');
2929
 
                        selectee.selecting = false;
2930
 
                        selectee.selected = true;
2931
 
                        selectee.startselected = true;
2932
 
                        self._trigger("selected", event, {
2933
 
                                selected: selectee.element
2934
 
                        });
2935
 
                });
2936
 
                this._trigger("stop", event);
2937
 
 
2938
 
                this.helper.remove();
2939
 
 
2940
 
                return false;
2941
 
        }
2942
 
 
2943
 
});
2944
 
 
2945
 
$.extend($.ui.selectable, {
2946
 
        version: "1.8.18"
2947
 
});
2948
 
 
2949
 
})(jQuery);
2950
 
/*
2951
 
 * jQuery UI Sortable 1.8.18
2952
 
 *
2953
 
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
2954
 
 * Dual licensed under the MIT or GPL Version 2 licenses.
2955
 
 * http://jquery.org/license
2956
 
 *
2957
 
 * http://docs.jquery.com/UI/Sortables
2958
 
 *
2959
 
 * Depends:
2960
 
 *      jquery.ui.core.js
2961
 
 *      jquery.ui.mouse.js
2962
 
 *      jquery.ui.widget.js
2963
 
 */
2964
 
(function( $, undefined ) {
2965
 
 
2966
 
$.widget("ui.sortable", $.ui.mouse, {
2967
 
        widgetEventPrefix: "sort",
2968
 
        ready: false,
2969
 
        options: {
2970
 
                appendTo: "parent",
2971
 
                axis: false,
2972
 
                connectWith: false,
2973
 
                containment: false,
2974
 
                cursor: 'auto',
2975
 
                cursorAt: false,
2976
 
                dropOnEmpty: true,
2977
 
                forcePlaceholderSize: false,
2978
 
                forceHelperSize: false,
2979
 
                grid: false,
2980
 
                handle: false,
2981
 
                helper: "original",
2982
 
                items: '> *',
2983
 
                opacity: false,
2984
 
                placeholder: false,
2985
 
                revert: false,
2986
 
                scroll: true,
2987
 
                scrollSensitivity: 20,
2988
 
                scrollSpeed: 20,
2989
 
                scope: "default",
2990
 
                tolerance: "intersect",
2991
 
                zIndex: 1000
2992
 
        },
2993
 
        _create: function() {
2994
 
 
2995
 
                var o = this.options;
2996
 
                this.containerCache = {};
2997
 
                this.element.addClass("ui-sortable");
2998
 
 
2999
 
                //Get the items
3000
 
                this.refresh();
3001
 
 
3002
 
                //Let's determine if the items are being displayed horizontally
3003
 
                this.floating = this.items.length ? o.axis === 'x' || (/left|right/).test(this.items[0].item.css('float')) || (/inline|table-cell/).test(this.items[0].item.css('display')) : false;
3004
 
 
3005
 
                //Let's determine the parent's offset
3006
 
                this.offset = this.element.offset();
3007
 
 
3008
 
                //Initialize mouse events for interaction
3009
 
                this._mouseInit();
3010
 
                
3011
 
                //We're ready to go
3012
 
                this.ready = true
3013
 
 
3014
 
        },
3015
 
 
3016
 
        destroy: function() {
3017
 
                $.Widget.prototype.destroy.call( this );
3018
 
                this.element
3019
 
                        .removeClass("ui-sortable ui-sortable-disabled");
3020
 
                this._mouseDestroy();
3021
 
 
3022
 
                for ( var i = this.items.length - 1; i >= 0; i-- )
3023
 
                        this.items[i].item.removeData(this.widgetName + "-item");
3024
 
 
3025
 
                return this;
3026
 
        },
3027
 
 
3028
 
        _setOption: function(key, value){
3029
 
                if ( key === "disabled" ) {
3030
 
                        this.options[ key ] = value;
3031
 
        
3032
 
                        this.widget()
3033
 
                                [ value ? "addClass" : "removeClass"]( "ui-sortable-disabled" );
3034
 
                } else {
3035
 
                        // Don't call widget base _setOption for disable as it adds ui-state-disabled class
3036
 
                        $.Widget.prototype._setOption.apply(this, arguments);
3037
 
                }
3038
 
        },
3039
 
 
3040
 
        _mouseCapture: function(event, overrideHandle) {
3041
 
                var that = this;
3042
 
 
3043
 
                if (this.reverting) {
3044
 
                        return false;
3045
 
                }
3046
 
 
3047
 
                if(this.options.disabled || this.options.type == 'static') return false;
3048
 
 
3049
 
                //We have to refresh the items data once first
3050
 
                this._refreshItems(event);
3051
 
 
3052
 
                //Find out if the clicked node (or one of its parents) is a actual item in this.items
3053
 
                var currentItem = null, self = this, nodes = $(event.target).parents().each(function() {
3054
 
                        if($.data(this, that.widgetName + '-item') == self) {
3055
 
                                currentItem = $(this);
3056
 
                                return false;
3057
 
                        }
3058
 
                });
3059
 
                if($.data(event.target, that.widgetName + '-item') == self) currentItem = $(event.target);
3060
 
 
3061
 
                if(!currentItem) return false;
3062
 
                if(this.options.handle && !overrideHandle) {
3063
 
                        var validHandle = false;
3064
 
 
3065
 
                        $(this.options.handle, currentItem).find("*").andSelf().each(function() { if(this == event.target) validHandle = true; });
3066
 
                        if(!validHandle) return false;
3067
 
                }
3068
 
 
3069
 
                this.currentItem = currentItem;
3070
 
                this._removeCurrentsFromItems();
3071
 
                return true;
3072
 
 
3073
 
        },
3074
 
 
3075
 
        _mouseStart: function(event, overrideHandle, noActivation) {
3076
 
 
3077
 
                var o = this.options, self = this;
3078
 
                this.currentContainer = this;
3079
 
 
3080
 
                //We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture
3081
 
                this.refreshPositions();
3082
 
 
3083
 
                //Create and append the visible helper
3084
 
                this.helper = this._createHelper(event);
3085
 
 
3086
 
                //Cache the helper size
3087
 
                this._cacheHelperProportions();
3088
 
 
3089
 
                /*
3090
 
                 * - Position generation -
3091
 
                 * This block generates everything position related - it's the core of draggables.
3092
 
                 */
3093
 
 
3094
 
                //Cache the margins of the original element
3095
 
                this._cacheMargins();
3096
 
 
3097
 
                //Get the next scrolling parent
3098
 
                this.scrollParent = this.helper.scrollParent();
3099
 
 
3100
 
                //The element's absolute position on the page minus margins
3101
 
                this.offset = this.currentItem.offset();
3102
 
                this.offset = {
3103
 
                        top: this.offset.top - this.margins.top,
3104
 
                        left: this.offset.left - this.margins.left
3105
 
                };
3106
 
 
3107
 
                // Only after we got the offset, we can change the helper's position to absolute
3108
 
                // TODO: Still need to figure out a way to make relative sorting possible
3109
 
                this.helper.css("position", "absolute");
3110
 
                this.cssPosition = this.helper.css("position");
3111
 
 
3112
 
                $.extend(this.offset, {
3113
 
                        click: { //Where the click happened, relative to the element
3114
 
                                left: event.pageX - this.offset.left,
3115
 
                                top: event.pageY - this.offset.top
3116
 
                        },
3117
 
                        parent: this._getParentOffset(),
3118
 
                        relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
3119
 
                });
3120
 
 
3121
 
                //Generate the original position
3122
 
                this.originalPosition = this._generatePosition(event);
3123
 
                this.originalPageX = event.pageX;
3124
 
                this.originalPageY = event.pageY;
3125
 
 
3126
 
                //Adjust the mouse offset relative to the helper if 'cursorAt' is supplied
3127
 
                (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
3128
 
 
3129
 
                //Cache the former DOM position
3130
 
                this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] };
3131
 
 
3132
 
                //If the helper is not the original, hide the original so it's not playing any role during the drag, won't cause anything bad this way
3133
 
                if(this.helper[0] != this.currentItem[0]) {
3134
 
                        this.currentItem.hide();
3135
 
                }
3136
 
 
3137
 
                //Create the placeholder
3138
 
                this._createPlaceholder();
3139
 
 
3140
 
                //Set a containment if given in the options
3141
 
                if(o.containment)
3142
 
                        this._setContainment();
3143
 
 
3144
 
                if(o.cursor) { // cursor option
3145
 
                        if ($('body').css("cursor")) this._storedCursor = $('body').css("cursor");
3146
 
                        $('body').css("cursor", o.cursor);
3147
 
                }
3148
 
 
3149
 
                if(o.opacity) { // opacity option
3150
 
                        if (this.helper.css("opacity")) this._storedOpacity = this.helper.css("opacity");
3151
 
                        this.helper.css("opacity", o.opacity);
3152
 
                }
3153
 
 
3154
 
                if(o.zIndex) { // zIndex option
3155
 
                        if (this.helper.css("zIndex")) this._storedZIndex = this.helper.css("zIndex");
3156
 
                        this.helper.css("zIndex", o.zIndex);
3157
 
                }
3158
 
 
3159
 
                //Prepare scrolling
3160
 
                if(this.scrollParent[0] != document && this.scrollParent[0].tagName != 'HTML')
3161
 
                        this.overflowOffset = this.scrollParent.offset();
3162
 
 
3163
 
                //Call callbacks
3164
 
                this._trigger("start", event, this._uiHash());
3165
 
 
3166
 
                //Recache the helper size
3167
 
                if(!this._preserveHelperProportions)
3168
 
                        this._cacheHelperProportions();
3169
 
 
3170
 
 
3171
 
                //Post 'activate' events to possible containers
3172
 
                if(!noActivation) {
3173
 
                         for (var i = this.containers.length - 1; i >= 0; i--) { this.containers[i]._trigger("activate", event, self._uiHash(this)); }
3174
 
                }
3175
 
 
3176
 
                //Prepare possible droppables
3177
 
                if($.ui.ddmanager)
3178
 
                        $.ui.ddmanager.current = this;
3179
 
 
3180
 
                if ($.ui.ddmanager && !o.dropBehaviour)
3181
 
                        $.ui.ddmanager.prepareOffsets(this, event);
3182
 
 
3183
 
                this.dragging = true;
3184
 
 
3185
 
                this.helper.addClass("ui-sortable-helper");
3186
 
                this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position
3187
 
                return true;
3188
 
 
3189
 
        },
3190
 
 
3191
 
        _mouseDrag: function(event) {
3192
 
 
3193
 
                //Compute the helpers position
3194
 
                this.position = this._generatePosition(event);
3195
 
                this.positionAbs = this._convertPositionTo("absolute");
3196
 
 
3197
 
                if (!this.lastPositionAbs) {
3198
 
                        this.lastPositionAbs = this.positionAbs;
3199
 
                }
3200
 
 
3201
 
                //Do scrolling
3202
 
                if(this.options.scroll) {
3203
 
                        var o = this.options, scrolled = false;
3204
 
                        if(this.scrollParent[0] != document && this.scrollParent[0].tagName != 'HTML') {
3205
 
 
3206
 
                                if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity)
3207
 
                                        this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
3208
 
                                else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity)
3209
 
                                        this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
3210
 
 
3211
 
                                if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity)
3212
 
                                        this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
3213
 
                                else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity)
3214
 
                                        this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
3215
 
 
3216
 
                        } else {
3217
 
 
3218
 
                                if(event.pageY - $(document).scrollTop() < o.scrollSensitivity)
3219
 
                                        scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
3220
 
                                else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity)
3221
 
                                        scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
3222
 
 
3223
 
                                if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity)
3224
 
                                        scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
3225
 
                                else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity)
3226
 
                                        scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
3227
 
 
3228
 
                        }
3229
 
 
3230
 
                        if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour)
3231
 
                                $.ui.ddmanager.prepareOffsets(this, event);
3232
 
                }
3233
 
 
3234
 
                //Regenerate the absolute position used for position checks
3235
 
                this.positionAbs = this._convertPositionTo("absolute");
3236
 
 
3237
 
                //Set the helper position
3238
 
                if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px';
3239
 
                if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px';
3240
 
 
3241
 
                //Rearrange
3242
 
                for (var i = this.items.length - 1; i >= 0; i--) {
3243
 
 
3244
 
                        //Cache variables and intersection, continue if no intersection
3245
 
                        var item = this.items[i], itemElement = item.item[0], intersection = this._intersectsWithPointer(item);
3246
 
                        if (!intersection) continue;
3247
 
 
3248
 
                        if(itemElement != this.currentItem[0] //cannot intersect with itself
3249
 
                                &&      this.placeholder[intersection == 1 ? "next" : "prev"]()[0] != itemElement //no useless actions that have been done before
3250
 
                                &&      !$.ui.contains(this.placeholder[0], itemElement) //no action if the item moved is the parent of the item checked
3251
 
                                && (this.options.type == 'semi-dynamic' ? !$.ui.contains(this.element[0], itemElement) : true)
3252
 
                                //&& itemElement.parentNode == this.placeholder[0].parentNode // only rearrange items within the same container
3253
 
                        ) {
3254
 
 
3255
 
                                this.direction = intersection == 1 ? "down" : "up";
3256
 
 
3257
 
                                if (this.options.tolerance == "pointer" || this._intersectsWithSides(item)) {
3258
 
                                        this._rearrange(event, item);
3259
 
                                } else {
3260
 
                                        break;
3261
 
                                }
3262
 
 
3263
 
                                this._trigger("change", event, this._uiHash());
3264
 
                                break;
3265
 
                        }
3266
 
                }
3267
 
 
3268
 
                //Post events to containers
3269
 
                this._contactContainers(event);
3270
 
 
3271
 
                //Interconnect with droppables
3272
 
                if($.ui.ddmanager) $.ui.ddmanager.drag(this, event);
3273
 
 
3274
 
                //Call callbacks
3275
 
                this._trigger('sort', event, this._uiHash());
3276
 
 
3277
 
                this.lastPositionAbs = this.positionAbs;
3278
 
                return false;
3279
 
 
3280
 
        },
3281
 
 
3282
 
        _mouseStop: function(event, noPropagation) {
3283
 
 
3284
 
                if(!event) return;
3285
 
 
3286
 
                //If we are using droppables, inform the manager about the drop
3287
 
                if ($.ui.ddmanager && !this.options.dropBehaviour)
3288
 
                        $.ui.ddmanager.drop(this, event);
3289
 
 
3290
 
                if(this.options.revert) {
3291
 
                        var self = this;
3292
 
                        var cur = self.placeholder.offset();
3293
 
 
3294
 
                        self.reverting = true;
3295
 
 
3296
 
                        $(this.helper).animate({
3297
 
                                left: cur.left - this.offset.parent.left - self.margins.left + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollLeft),
3298
 
                                top: cur.top - this.offset.parent.top - self.margins.top + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollTop)
3299
 
                        }, parseInt(this.options.revert, 10) || 500, function() {
3300
 
                                self._clear(event);
3301
 
                        });
3302
 
                } else {
3303
 
                        this._clear(event, noPropagation);
3304
 
                }
3305
 
 
3306
 
                return false;
3307
 
 
3308
 
        },
3309
 
 
3310
 
        cancel: function() {
3311
 
 
3312
 
                var self = this;
3313
 
 
3314
 
                if(this.dragging) {
3315
 
 
3316
 
                        this._mouseUp({ target: null });
3317
 
 
3318
 
                        if(this.options.helper == "original")
3319
 
                                this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
3320
 
                        else
3321
 
                                this.currentItem.show();
3322
 
 
3323
 
                        //Post deactivating events to containers
3324
 
                        for (var i = this.containers.length - 1; i >= 0; i--){
3325
 
                                this.containers[i]._trigger("deactivate", null, self._uiHash(this));
3326
 
                                if(this.containers[i].containerCache.over) {
3327
 
                                        this.containers[i]._trigger("out", null, self._uiHash(this));
3328
 
                                        this.containers[i].containerCache.over = 0;
3329
 
                                }
3330
 
                        }
3331
 
 
3332
 
                }
3333
 
 
3334
 
                if (this.placeholder) {
3335
 
                        //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
3336
 
                        if(this.placeholder[0].parentNode) this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
3337
 
                        if(this.options.helper != "original" && this.helper && this.helper[0].parentNode) this.helper.remove();
3338
 
 
3339
 
                        $.extend(this, {
3340
 
                                helper: null,
3341
 
                                dragging: false,
3342
 
                                reverting: false,
3343
 
                                _noFinalSort: null
3344
 
                        });
3345
 
 
3346
 
                        if(this.domPosition.prev) {
3347
 
                                $(this.domPosition.prev).after(this.currentItem);
3348
 
                        } else {
3349
 
                                $(this.domPosition.parent).prepend(this.currentItem);
3350
 
                        }
3351
 
                }
3352
 
 
3353
 
                return this;
3354
 
 
3355
 
        },
3356
 
 
3357
 
        serialize: function(o) {
3358
 
 
3359
 
                var items = this._getItemsAsjQuery(o && o.connected);
3360
 
                var str = []; o = o || {};
3361
 
 
3362
 
                $(items).each(function() {
3363
 
                        var res = ($(o.item || this).attr(o.attribute || 'id') || '').match(o.expression || (/(.+)[-=_](.+)/));
3364
 
                        if(res) str.push((o.key || res[1]+'[]')+'='+(o.key && o.expression ? res[1] : res[2]));
3365
 
                });
3366
 
 
3367
 
                if(!str.length && o.key) {
3368
 
                        str.push(o.key + '=');
3369
 
                }
3370
 
 
3371
 
                return str.join('&');
3372
 
 
3373
 
        },
3374
 
 
3375
 
        toArray: function(o) {
3376
 
 
3377
 
                var items = this._getItemsAsjQuery(o && o.connected);
3378
 
                var ret = []; o = o || {};
3379
 
 
3380
 
                items.each(function() { ret.push($(o.item || this).attr(o.attribute || 'id') || ''); });
3381
 
                return ret;
3382
 
 
3383
 
        },
3384
 
 
3385
 
        /* Be careful with the following core functions */
3386
 
        _intersectsWith: function(item) {
3387
 
 
3388
 
                var x1 = this.positionAbs.left,
3389
 
                        x2 = x1 + this.helperProportions.width,
3390
 
                        y1 = this.positionAbs.top,
3391
 
                        y2 = y1 + this.helperProportions.height;
3392
 
 
3393
 
                var l = item.left,
3394
 
                        r = l + item.width,
3395
 
                        t = item.top,
3396
 
                        b = t + item.height;
3397
 
 
3398
 
                var dyClick = this.offset.click.top,
3399
 
                        dxClick = this.offset.click.left;
3400
 
 
3401
 
                var isOverElement = (y1 + dyClick) > t && (y1 + dyClick) < b && (x1 + dxClick) > l && (x1 + dxClick) < r;
3402
 
 
3403
 
                if(        this.options.tolerance == "pointer"
3404
 
                        || this.options.forcePointerForContainers
3405
 
                        || (this.options.tolerance != "pointer" && this.helperProportions[this.floating ? 'width' : 'height'] > item[this.floating ? 'width' : 'height'])
3406
 
                ) {
3407
 
                        return isOverElement;
3408
 
                } else {
3409
 
 
3410
 
                        return (l < x1 + (this.helperProportions.width / 2) // Right Half
3411
 
                                && x2 - (this.helperProportions.width / 2) < r // Left Half
3412
 
                                && t < y1 + (this.helperProportions.height / 2) // Bottom Half
3413
 
                                && y2 - (this.helperProportions.height / 2) < b ); // Top Half
3414
 
 
3415
 
                }
3416
 
        },
3417
 
 
3418
 
        _intersectsWithPointer: function(item) {
3419
 
 
3420
 
                var isOverElementHeight = $.ui.isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
3421
 
                        isOverElementWidth = $.ui.isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
3422
 
                        isOverElement = isOverElementHeight && isOverElementWidth,
3423
 
                        verticalDirection = this._getDragVerticalDirection(),
3424
 
                        horizontalDirection = this._getDragHorizontalDirection();
3425
 
 
3426
 
                if (!isOverElement)
3427
 
                        return false;
3428
 
 
3429
 
                return this.floating ?
3430
 
                        ( ((horizontalDirection && horizontalDirection == "right") || verticalDirection == "down") ? 2 : 1 )
3431
 
                        : ( verticalDirection && (verticalDirection == "down" ? 2 : 1) );
3432
 
 
3433
 
        },
3434
 
 
3435
 
        _intersectsWithSides: function(item) {
3436
 
 
3437
 
                var isOverBottomHalf = $.ui.isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height),
3438
 
                        isOverRightHalf = $.ui.isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width),
3439
 
                        verticalDirection = this._getDragVerticalDirection(),
3440
 
                        horizontalDirection = this._getDragHorizontalDirection();
3441
 
 
3442
 
                if (this.floating && horizontalDirection) {
3443
 
                        return ((horizontalDirection == "right" && isOverRightHalf) || (horizontalDirection == "left" && !isOverRightHalf));
3444
 
                } else {
3445
 
                        return verticalDirection && ((verticalDirection == "down" && isOverBottomHalf) || (verticalDirection == "up" && !isOverBottomHalf));
3446
 
                }
3447
 
 
3448
 
        },
3449
 
 
3450
 
        _getDragVerticalDirection: function() {
3451
 
                var delta = this.positionAbs.top - this.lastPositionAbs.top;
3452
 
                return delta != 0 && (delta > 0 ? "down" : "up");
3453
 
        },
3454
 
 
3455
 
        _getDragHorizontalDirection: function() {
3456
 
                var delta = this.positionAbs.left - this.lastPositionAbs.left;
3457
 
                return delta != 0 && (delta > 0 ? "right" : "left");
3458
 
        },
3459
 
 
3460
 
        refresh: function(event) {
3461
 
                this._refreshItems(event);
3462
 
                this.refreshPositions();
3463
 
                return this;
3464
 
        },
3465
 
 
3466
 
        _connectWith: function() {
3467
 
                var options = this.options;
3468
 
                return options.connectWith.constructor == String
3469
 
                        ? [options.connectWith]
3470
 
                        : options.connectWith;
3471
 
        },
3472
 
        
3473
 
        _getItemsAsjQuery: function(connected) {
3474
 
 
3475
 
                var self = this;
3476
 
                var items = [];
3477
 
                var queries = [];
3478
 
                var connectWith = this._connectWith();
3479
 
 
3480
 
                if(connectWith && connected) {
3481
 
                        for (var i = connectWith.length - 1; i >= 0; i--){
3482
 
                                var cur = $(connectWith[i]);
3483
 
                                for (var j = cur.length - 1; j >= 0; j--){
3484
 
                                        var inst = $.data(cur[j], this.widgetName);
3485
 
                                        if(inst && inst != this && !inst.options.disabled) {
3486
 
                                                queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element) : $(inst.options.items, inst.element).not(".ui-sortable-helper").not('.ui-sortable-placeholder'), inst]);
3487
 
                                        }
3488
 
                                };
3489
 
                        };
3490
 
                }
3491
 
 
3492
 
                queries.push([$.isFunction(this.options.items) ? this.options.items.call(this.element, null, { options: this.options, item: this.currentItem }) : $(this.options.items, this.element).not(".ui-sortable-helper").not('.ui-sortable-placeholder'), this]);
3493
 
 
3494
 
                for (var i = queries.length - 1; i >= 0; i--){
3495
 
                        queries[i][0].each(function() {
3496
 
                                items.push(this);
3497
 
                        });
3498
 
                };
3499
 
 
3500
 
                return $(items);
3501
 
 
3502
 
        },
3503
 
 
3504
 
        _removeCurrentsFromItems: function() {
3505
 
 
3506
 
                var list = this.currentItem.find(":data(" + this.widgetName + "-item)");
3507
 
 
3508
 
                for (var i=0; i < this.items.length; i++) {
3509
 
 
3510
 
                        for (var j=0; j < list.length; j++) {
3511
 
                                if(list[j] == this.items[i].item[0])
3512
 
                                        this.items.splice(i,1);
3513
 
                        };
3514
 
 
3515
 
                };
3516
 
 
3517
 
        },
3518
 
 
3519
 
        _refreshItems: function(event) {
3520
 
 
3521
 
                this.items = [];
3522
 
                this.containers = [this];
3523
 
                var items = this.items;
3524
 
                var self = this;
3525
 
                var queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]];
3526
 
                var connectWith = this._connectWith();
3527
 
 
3528
 
                if(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down
3529
 
                        for (var i = connectWith.length - 1; i >= 0; i--){
3530
 
                                var cur = $(connectWith[i]);
3531
 
                                for (var j = cur.length - 1; j >= 0; j--){
3532
 
                                        var inst = $.data(cur[j], this.widgetName);
3533
 
                                        if(inst && inst != this && !inst.options.disabled) {
3534
 
                                                queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]);
3535
 
                                                this.containers.push(inst);
3536
 
                                        }
3537
 
                                };
3538
 
                        };
3539
 
                }
3540
 
 
3541
 
                for (var i = queries.length - 1; i >= 0; i--) {
3542
 
                        var targetData = queries[i][1];
3543
 
                        var _queries = queries[i][0];
3544
 
 
3545
 
                        for (var j=0, queriesLength = _queries.length; j < queriesLength; j++) {
3546
 
                                var item = $(_queries[j]);
3547
 
 
3548
 
                                item.data(this.widgetName + '-item', targetData); // Data for target checking (mouse manager)
3549
 
 
3550
 
                                items.push({
3551
 
                                        item: item,
3552
 
                                        instance: targetData,
3553
 
                                        width: 0, height: 0,
3554
 
                                        left: 0, top: 0
3555
 
                                });
3556
 
                        };
3557
 
                };
3558
 
 
3559
 
        },
3560
 
 
3561
 
        refreshPositions: function(fast) {
3562
 
 
3563
 
                //This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change
3564
 
                if(this.offsetParent && this.helper) {
3565
 
                        this.offset.parent = this._getParentOffset();
3566
 
                }
3567
 
 
3568
 
                for (var i = this.items.length - 1; i >= 0; i--){
3569
 
                        var item = this.items[i];
3570
 
 
3571
 
                        //We ignore calculating positions of all connected containers when we're not over them
3572
 
                        if(item.instance != this.currentContainer && this.currentContainer && item.item[0] != this.currentItem[0])
3573
 
                                continue;
3574
 
 
3575
 
                        var t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item;
3576
 
 
3577
 
                        if (!fast) {
3578
 
                                item.width = t.outerWidth();
3579
 
                                item.height = t.outerHeight();
3580
 
                        }
3581
 
 
3582
 
                        var p = t.offset();
3583
 
                        item.left = p.left;
3584
 
                        item.top = p.top;
3585
 
                };
3586
 
 
3587
 
                if(this.options.custom && this.options.custom.refreshContainers) {
3588
 
                        this.options.custom.refreshContainers.call(this);
3589
 
                } else {
3590
 
                        for (var i = this.containers.length - 1; i >= 0; i--){
3591
 
                                var p = this.containers[i].element.offset();
3592
 
                                this.containers[i].containerCache.left = p.left;
3593
 
                                this.containers[i].containerCache.top = p.top;
3594
 
                                this.containers[i].containerCache.width = this.containers[i].element.outerWidth();
3595
 
                                this.containers[i].containerCache.height = this.containers[i].element.outerHeight();
3596
 
                        };
3597
 
                }
3598
 
 
3599
 
                return this;
3600
 
        },
3601
 
 
3602
 
        _createPlaceholder: function(that) {
3603
 
 
3604
 
                var self = that || this, o = self.options;
3605
 
 
3606
 
                if(!o.placeholder || o.placeholder.constructor == String) {
3607
 
                        var className = o.placeholder;
3608
 
                        o.placeholder = {
3609
 
                                element: function() {
3610
 
 
3611
 
                                        var el = $(document.createElement(self.currentItem[0].nodeName))
3612
 
                                                .addClass(className || self.currentItem[0].className+" ui-sortable-placeholder")
3613
 
                                                .removeClass("ui-sortable-helper")[0];
3614
 
 
3615
 
                                        if(!className)
3616
 
                                                el.style.visibility = "hidden";
3617
 
 
3618
 
                                        return el;
3619
 
                                },
3620
 
                                update: function(container, p) {
3621
 
 
3622
 
                                        // 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that
3623
 
                                        // 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified
3624
 
                                        if(className && !o.forcePlaceholderSize) return;
3625
 
 
3626
 
                                        //If the element doesn't have a actual height by itself (without styles coming from a stylesheet), it receives the inline height from the dragged item
3627
 
                                        if(!p.height()) { p.height(self.currentItem.innerHeight() - parseInt(self.currentItem.css('paddingTop')||0, 10) - parseInt(self.currentItem.css('paddingBottom')||0, 10)); };
3628
 
                                        if(!p.width()) { p.width(self.currentItem.innerWidth() - parseInt(self.currentItem.css('paddingLeft')||0, 10) - parseInt(self.currentItem.css('paddingRight')||0, 10)); };
3629
 
                                }
3630
 
                        };
3631
 
                }
3632
 
 
3633
 
                //Create the placeholder
3634
 
                self.placeholder = $(o.placeholder.element.call(self.element, self.currentItem));
3635
 
 
3636
 
                //Append it after the actual current item
3637
 
                self.currentItem.after(self.placeholder);
3638
 
 
3639
 
                //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
3640
 
                o.placeholder.update(self, self.placeholder);
3641
 
 
3642
 
        },
3643
 
 
3644
 
        _contactContainers: function(event) {
3645
 
                
3646
 
                // get innermost container that intersects with item 
3647
 
                var innermostContainer = null, innermostIndex = null;           
3648
 
                
3649
 
                
3650
 
                for (var i = this.containers.length - 1; i >= 0; i--){
3651
 
 
3652
 
                        // never consider a container that's located within the item itself 
3653
 
                        if($.ui.contains(this.currentItem[0], this.containers[i].element[0]))
3654
 
                                continue;
3655
 
 
3656
 
                        if(this._intersectsWith(this.containers[i].containerCache)) {
3657
 
 
3658
 
                                // if we've already found a container and it's more "inner" than this, then continue 
3659
 
                                if(innermostContainer && $.ui.contains(this.containers[i].element[0], innermostContainer.element[0]))
3660
 
                                        continue;
3661
 
 
3662
 
                                innermostContainer = this.containers[i]; 
3663
 
                                innermostIndex = i;
3664
 
                                        
3665
 
                        } else {
3666
 
                                // container doesn't intersect. trigger "out" event if necessary 
3667
 
                                if(this.containers[i].containerCache.over) {
3668
 
                                        this.containers[i]._trigger("out", event, this._uiHash(this));
3669
 
                                        this.containers[i].containerCache.over = 0;
3670
 
                                }
3671
 
                        }
3672
 
 
3673
 
                }
3674
 
                
3675
 
                // if no intersecting containers found, return 
3676
 
                if(!innermostContainer) return; 
3677
 
 
3678
 
                // move the item into the container if it's not there already
3679
 
                if(this.containers.length === 1) {
3680
 
                        this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
3681
 
                        this.containers[innermostIndex].containerCache.over = 1;
3682
 
                } else if(this.currentContainer != this.containers[innermostIndex]) { 
3683
 
 
3684
 
                        //When entering a new container, we will find the item with the least distance and append our item near it 
3685
 
                        var dist = 10000; var itemWithLeastDistance = null; var base = this.positionAbs[this.containers[innermostIndex].floating ? 'left' : 'top']; 
3686
 
                        for (var j = this.items.length - 1; j >= 0; j--) { 
3687
 
                                if(!$.ui.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) continue; 
3688
 
                                var cur = this.items[j][this.containers[innermostIndex].floating ? 'left' : 'top']; 
3689
 
                                if(Math.abs(cur - base) < dist) { 
3690
 
                                        dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j]; 
3691
 
                                } 
3692
 
                        } 
3693
 
 
3694
 
                        if(!itemWithLeastDistance && !this.options.dropOnEmpty) //Check if dropOnEmpty is enabled 
3695
 
                                return; 
3696
 
 
3697
 
                        this.currentContainer = this.containers[innermostIndex]; 
3698
 
                        itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true); 
3699
 
                        this._trigger("change", event, this._uiHash()); 
3700
 
                        this.containers[innermostIndex]._trigger("change", event, this._uiHash(this)); 
3701
 
 
3702
 
                        //Update the placeholder 
3703
 
                        this.options.placeholder.update(this.currentContainer, this.placeholder); 
3704
 
                
3705
 
                        this.containers[innermostIndex]._trigger("over", event, this._uiHash(this)); 
3706
 
                        this.containers[innermostIndex].containerCache.over = 1;
3707
 
                } 
3708
 
        
3709
 
                
3710
 
        },
3711
 
 
3712
 
        _createHelper: function(event) {
3713
 
 
3714
 
                var o = this.options;
3715
 
                var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper == 'clone' ? this.currentItem.clone() : this.currentItem);
3716
 
 
3717
 
                if(!helper.parents('body').length) //Add the helper to the DOM if that didn't happen already
3718
 
                        $(o.appendTo != 'parent' ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]);
3719
 
 
3720
 
                if(helper[0] == this.currentItem[0])
3721
 
                        this._storedCSS = { width: this.currentItem[0].style.width, height: this.currentItem[0].style.height, position: this.currentItem.css("position"), top: this.currentItem.css("top"), left: this.currentItem.css("left") };
3722
 
 
3723
 
                if(helper[0].style.width == '' || o.forceHelperSize) helper.width(this.currentItem.width());
3724
 
                if(helper[0].style.height == '' || o.forceHelperSize) helper.height(this.currentItem.height());
3725
 
 
3726
 
                return helper;
3727
 
 
3728
 
        },
3729
 
 
3730
 
        _adjustOffsetFromHelper: function(obj) {
3731
 
                if (typeof obj == 'string') {
3732
 
                        obj = obj.split(' ');
3733
 
                }
3734
 
                if ($.isArray(obj)) {
3735
 
                        obj = {left: +obj[0], top: +obj[1] || 0};
3736
 
                }
3737
 
                if ('left' in obj) {
3738
 
                        this.offset.click.left = obj.left + this.margins.left;
3739
 
                }
3740
 
                if ('right' in obj) {
3741
 
                        this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
3742
 
                }
3743
 
                if ('top' in obj) {
3744
 
                        this.offset.click.top = obj.top + this.margins.top;
3745
 
                }
3746
 
                if ('bottom' in obj) {
3747
 
                        this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
3748
 
                }
3749
 
        },
3750
 
 
3751
 
        _getParentOffset: function() {
3752
 
 
3753
 
 
3754
 
                //Get the offsetParent and cache its position
3755
 
                this.offsetParent = this.helper.offsetParent();
3756
 
                var po = this.offsetParent.offset();
3757
 
 
3758
 
                // This is a special case where we need to modify a offset calculated on start, since the following happened:
3759
 
                // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
3760
 
                // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
3761
 
                //    the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
3762
 
                if(this.cssPosition == 'absolute' && this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) {
3763
 
                        po.left += this.scrollParent.scrollLeft();
3764
 
                        po.top += this.scrollParent.scrollTop();
3765
 
                }
3766
 
 
3767
 
                if((this.offsetParent[0] == document.body) //This needs to be actually done for all browsers, since pageX/pageY includes this information
3768
 
                || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.browser.msie)) //Ugly IE fix
3769
 
                        po = { top: 0, left: 0 };
3770
 
 
3771
 
                return {
3772
 
                        top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
3773
 
                        left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
3774
 
                };
3775
 
 
3776
 
        },
3777
 
 
3778
 
        _getRelativeOffset: function() {
3779
 
 
3780
 
                if(this.cssPosition == "relative") {
3781
 
                        var p = this.currentItem.position();
3782
 
                        return {
3783
 
                                top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
3784
 
                                left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
3785
 
                        };
3786
 
                } else {
3787
 
                        return { top: 0, left: 0 };
3788
 
                }
3789
 
 
3790
 
        },
3791
 
 
3792
 
        _cacheMargins: function() {
3793
 
                this.margins = {
3794
 
                        left: (parseInt(this.currentItem.css("marginLeft"),10) || 0),
3795
 
                        top: (parseInt(this.currentItem.css("marginTop"),10) || 0)
3796
 
                };
3797
 
        },
3798
 
 
3799
 
        _cacheHelperProportions: function() {
3800
 
                this.helperProportions = {
3801
 
                        width: this.helper.outerWidth(),
3802
 
                        height: this.helper.outerHeight()
3803
 
                };
3804
 
        },
3805
 
 
3806
 
        _setContainment: function() {
3807
 
 
3808
 
                var o = this.options;
3809
 
                if(o.containment == 'parent') o.containment = this.helper[0].parentNode;
3810
 
                if(o.containment == 'document' || o.containment == 'window') this.containment = [
3811
 
                        0 - this.offset.relative.left - this.offset.parent.left,
3812
 
                        0 - this.offset.relative.top - this.offset.parent.top,
3813
 
                        $(o.containment == 'document' ? document : window).width() - this.helperProportions.width - this.margins.left,
3814
 
                        ($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
3815
 
                ];
3816
 
 
3817
 
                if(!(/^(document|window|parent)$/).test(o.containment)) {
3818
 
                        var ce = $(o.containment)[0];
3819
 
                        var co = $(o.containment).offset();
3820
 
                        var over = ($(ce).css("overflow") != 'hidden');
3821
 
 
3822
 
                        this.containment = [
3823
 
                                co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
3824
 
                                co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
3825
 
                                co.left+(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left,
3826
 
                                co.top+(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top
3827
 
                        ];
3828
 
                }
3829
 
 
3830
 
        },
3831
 
 
3832
 
        _convertPositionTo: function(d, pos) {
3833
 
 
3834
 
                if(!pos) pos = this.position;
3835
 
                var mod = d == "absolute" ? 1 : -1;
3836
 
                var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
3837
 
 
3838
 
                return {
3839
 
                        top: (
3840
 
                                pos.top                                                                                                                                 // The absolute mouse position
3841
 
                                + this.offset.relative.top * mod                                                                                // Only for relative positioned nodes: Relative offset from element to offset parent
3842
 
                                + this.offset.parent.top * mod                                                                                  // The offsetParent's offset without borders (offset + border)
3843
 
                                - ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
3844
 
                        ),
3845
 
                        left: (
3846
 
                                pos.left                                                                                                                                // The absolute mouse position
3847
 
                                + this.offset.relative.left * mod                                                                               // Only for relative positioned nodes: Relative offset from element to offset parent
3848
 
                                + this.offset.parent.left * mod                                                                                 // The offsetParent's offset without borders (offset + border)
3849
 
                                - ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
3850
 
                        )
3851
 
                };
3852
 
 
3853
 
        },
3854
 
 
3855
 
        _generatePosition: function(event) {
3856
 
 
3857
 
                var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
3858
 
 
3859
 
                // This is another very weird special case that only happens for relative elements:
3860
 
                // 1. If the css position is relative
3861
 
                // 2. and the scroll parent is the document or similar to the offset parent
3862
 
                // we have to refresh the relative offset during the scroll so there are no jumps
3863
 
                if(this.cssPosition == 'relative' && !(this.scrollParent[0] != document && this.scrollParent[0] != this.offsetParent[0])) {
3864
 
                        this.offset.relative = this._getRelativeOffset();
3865
 
                }
3866
 
 
3867
 
                var pageX = event.pageX;
3868
 
                var pageY = event.pageY;
3869
 
 
3870
 
                /*
3871
 
                 * - Position constraining -
3872
 
                 * Constrain the position to a mix of grid, containment.
3873
 
                 */
3874
 
 
3875
 
                if(this.originalPosition) { //If we are not dragging yet, we won't check for options
3876
 
 
3877
 
                        if(this.containment) {
3878
 
                                if(event.pageX - this.offset.click.left < this.containment[0]) pageX = this.containment[0] + this.offset.click.left;
3879
 
                                if(event.pageY - this.offset.click.top < this.containment[1]) pageY = this.containment[1] + this.offset.click.top;
3880
 
                                if(event.pageX - this.offset.click.left > this.containment[2]) pageX = this.containment[2] + this.offset.click.left;
3881
 
                                if(event.pageY - this.offset.click.top > this.containment[3]) pageY = this.containment[3] + this.offset.click.top;
3882
 
                        }
3883
 
 
3884
 
                        if(o.grid) {
3885
 
                                var top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
3886
 
                                pageY = this.containment ? (!(top - this.offset.click.top < this.containment[1] || top - this.offset.click.top > this.containment[3]) ? top : (!(top - this.offset.click.top < this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
3887
 
 
3888
 
                                var left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
3889
 
                                pageX = this.containment ? (!(left - this.offset.click.left < this.containment[0] || left - this.offset.click.left > this.containment[2]) ? left : (!(left - this.offset.click.left < this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
3890
 
                        }
3891
 
 
3892
 
                }
3893
 
 
3894
 
                return {
3895
 
                        top: (
3896
 
                                pageY                                                                                                                           // The absolute mouse position
3897
 
                                - this.offset.click.top                                                                                                 // Click offset (relative to the element)
3898
 
                                - this.offset.relative.top                                                                                              // Only for relative positioned nodes: Relative offset from element to offset parent
3899
 
                                - this.offset.parent.top                                                                                                // The offsetParent's offset without borders (offset + border)
3900
 
                                + ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
3901
 
                        ),
3902
 
                        left: (
3903
 
                                pageX                                                                                                                           // The absolute mouse position
3904
 
                                - this.offset.click.left                                                                                                // Click offset (relative to the element)
3905
 
                                - this.offset.relative.left                                                                                             // Only for relative positioned nodes: Relative offset from element to offset parent
3906
 
                                - this.offset.parent.left                                                                                               // The offsetParent's offset without borders (offset + border)
3907
 
                                + ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
3908
 
                        )
3909
 
                };
3910
 
 
3911
 
        },
3912
 
 
3913
 
        _rearrange: function(event, i, a, hardRefresh) {
3914
 
 
3915
 
                a ? a[0].appendChild(this.placeholder[0]) : i.item[0].parentNode.insertBefore(this.placeholder[0], (this.direction == 'down' ? i.item[0] : i.item[0].nextSibling));
3916
 
 
3917
 
                //Various things done here to improve the performance:
3918
 
                // 1. we create a setTimeout, that calls refreshPositions
3919
 
                // 2. on the instance, we have a counter variable, that get's higher after every append
3920
 
                // 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same
3921
 
                // 4. this lets only the last addition to the timeout stack through
3922
 
                this.counter = this.counter ? ++this.counter : 1;
3923
 
                var self = this, counter = this.counter;
3924
 
 
3925
 
                window.setTimeout(function() {
3926
 
                        if(counter == self.counter) self.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
3927
 
                },0);
3928
 
 
3929
 
        },
3930
 
 
3931
 
        _clear: function(event, noPropagation) {
3932
 
 
3933
 
                this.reverting = false;
3934
 
                // We delay all events that have to be triggered to after the point where the placeholder has been removed and
3935
 
                // everything else normalized again
3936
 
                var delayedTriggers = [], self = this;
3937
 
 
3938
 
                // We first have to update the dom position of the actual currentItem
3939
 
                // Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088)
3940
 
                if(!this._noFinalSort && this.currentItem.parent().length) this.placeholder.before(this.currentItem);
3941
 
                this._noFinalSort = null;
3942
 
 
3943
 
                if(this.helper[0] == this.currentItem[0]) {
3944
 
                        for(var i in this._storedCSS) {
3945
 
                                if(this._storedCSS[i] == 'auto' || this._storedCSS[i] == 'static') this._storedCSS[i] = '';
3946
 
                        }
3947
 
                        this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
3948
 
                } else {
3949
 
                        this.currentItem.show();
3950
 
                }
3951
 
 
3952
 
                if(this.fromOutside && !noPropagation) delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); });
3953
 
                if((this.fromOutside || this.domPosition.prev != this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent != this.currentItem.parent()[0]) && !noPropagation) delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed
3954
 
                if(!$.ui.contains(this.element[0], this.currentItem[0])) { //Node was moved out of the current element
3955
 
                        if(!noPropagation) delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
3956
 
                        for (var i = this.containers.length - 1; i >= 0; i--){
3957
 
                                if($.ui.contains(this.containers[i].element[0], this.currentItem[0]) && !noPropagation) {
3958
 
                                        delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); };  }).call(this, this.containers[i]));
3959
 
                                        delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this));  }; }).call(this, this.containers[i]));
3960
 
                                }
3961
 
                        };
3962
 
                };
3963
 
 
3964
 
                //Post events to containers
3965
 
                for (var i = this.containers.length - 1; i >= 0; i--){
3966
 
                        if(!noPropagation) delayedTriggers.push((function(c) { return function(event) { c._trigger("deactivate", event, this._uiHash(this)); };  }).call(this, this.containers[i]));
3967
 
                        if(this.containers[i].containerCache.over) {
3968
 
                                delayedTriggers.push((function(c) { return function(event) { c._trigger("out", event, this._uiHash(this)); };  }).call(this, this.containers[i]));
3969
 
                                this.containers[i].containerCache.over = 0;
3970
 
                        }
3971
 
                }
3972
 
 
3973
 
                //Do what was originally in plugins
3974
 
                if(this._storedCursor) $('body').css("cursor", this._storedCursor); //Reset cursor
3975
 
                if(this._storedOpacity) this.helper.css("opacity", this._storedOpacity); //Reset opacity
3976
 
                if(this._storedZIndex) this.helper.css("zIndex", this._storedZIndex == 'auto' ? '' : this._storedZIndex); //Reset z-index
3977
 
 
3978
 
                this.dragging = false;
3979
 
                if(this.cancelHelperRemoval) {
3980
 
                        if(!noPropagation) {
3981
 
                                this._trigger("beforeStop", event, this._uiHash());
3982
 
                                for (var i=0; i < delayedTriggers.length; i++) { delayedTriggers[i].call(this, event); }; //Trigger all delayed events
3983
 
                                this._trigger("stop", event, this._uiHash());
3984
 
                        }
3985
 
                        return false;
3986
 
                }
3987
 
 
3988
 
                if(!noPropagation) this._trigger("beforeStop", event, this._uiHash());
3989
 
 
3990
 
                //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
3991
 
                this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
3992
 
 
3993
 
                if(this.helper[0] != this.currentItem[0]) this.helper.remove(); this.helper = null;
3994
 
 
3995
 
                if(!noPropagation) {
3996
 
                        for (var i=0; i < delayedTriggers.length; i++) { delayedTriggers[i].call(this, event); }; //Trigger all delayed events
3997
 
                        this._trigger("stop", event, this._uiHash());
3998
 
                }
3999
 
 
4000
 
                this.fromOutside = false;
4001
 
                return true;
4002
 
 
4003
 
        },
4004
 
 
4005
 
        _trigger: function() {
4006
 
                if ($.Widget.prototype._trigger.apply(this, arguments) === false) {
4007
 
                        this.cancel();
4008
 
                }
4009
 
        },
4010
 
 
4011
 
        _uiHash: function(inst) {
4012
 
                var self = inst || this;
4013
 
                return {
4014
 
                        helper: self.helper,
4015
 
                        placeholder: self.placeholder || $([]),
4016
 
                        position: self.position,
4017
 
                        originalPosition: self.originalPosition,
4018
 
                        offset: self.positionAbs,
4019
 
                        item: self.currentItem,
4020
 
                        sender: inst ? inst.element : null
4021
 
                };
4022
 
        }
4023
 
 
4024
 
});
4025
 
 
4026
 
$.extend($.ui.sortable, {
4027
 
        version: "1.8.18"
4028
 
});
4029
 
 
4030
 
})(jQuery);
4031
 
/*
4032
 
 * jQuery UI Effects 1.8.18
4033
 
 *
4034
 
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
4035
 
 * Dual licensed under the MIT or GPL Version 2 licenses.
4036
 
 * http://jquery.org/license
4037
 
 *
4038
 
 * http://docs.jquery.com/UI/Effects/
4039
 
 */
4040
 
;jQuery.effects || (function($, undefined) {
4041
 
 
4042
 
$.effects = {};
4043
 
 
4044
 
 
4045
 
 
4046
 
/******************************************************************************/
4047
 
/****************************** COLOR ANIMATIONS ******************************/
4048
 
/******************************************************************************/
4049
 
 
4050
 
// override the animation for color styles
4051
 
$.each(['backgroundColor', 'borderBottomColor', 'borderLeftColor',
4052
 
        'borderRightColor', 'borderTopColor', 'borderColor', 'color', 'outlineColor'],
4053
 
function(i, attr) {
4054
 
        $.fx.step[attr] = function(fx) {
4055
 
                if (!fx.colorInit) {
4056
 
                        fx.start = getColor(fx.elem, attr);
4057
 
                        fx.end = getRGB(fx.end);
4058
 
                        fx.colorInit = true;
4059
 
                }
4060
 
 
4061
 
                fx.elem.style[attr] = 'rgb(' +
4062
 
                        Math.max(Math.min(parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0], 10), 255), 0) + ',' +
4063
 
                        Math.max(Math.min(parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1], 10), 255), 0) + ',' +
4064
 
                        Math.max(Math.min(parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2], 10), 255), 0) + ')';
4065
 
        };
4066
 
});
4067
 
 
4068
 
// Color Conversion functions from highlightFade
4069
 
// By Blair Mitchelmore
4070
 
// http://jquery.offput.ca/highlightFade/
4071
 
 
4072
 
// Parse strings looking for color tuples [255,255,255]
4073
 
function getRGB(color) {
4074
 
                var result;
4075
 
 
4076
 
                // Check if we're already dealing with an array of colors
4077
 
                if ( color && color.constructor == Array && color.length == 3 )
4078
 
                                return color;
4079
 
 
4080
 
                // Look for rgb(num,num,num)
4081
 
                if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color))
4082
 
                                return [parseInt(result[1],10), parseInt(result[2],10), parseInt(result[3],10)];
4083
 
 
4084
 
                // Look for rgb(num%,num%,num%)
4085
 
                if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color))
4086
 
                                return [parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55];
4087
 
 
4088
 
                // Look for #a0b1c2
4089
 
                if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color))
4090
 
                                return [parseInt(result[1],16), parseInt(result[2],16), parseInt(result[3],16)];
4091
 
 
4092
 
                // Look for #fff
4093
 
                if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color))
4094
 
                                return [parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16)];
4095
 
 
4096
 
                // Look for rgba(0, 0, 0, 0) == transparent in Safari 3
4097
 
                if (result = /rgba\(0, 0, 0, 0\)/.exec(color))
4098
 
                                return colors['transparent'];
4099
 
 
4100
 
                // Otherwise, we're most likely dealing with a named color
4101
 
                return colors[$.trim(color).toLowerCase()];
4102
 
}
4103
 
 
4104
 
function getColor(elem, attr) {
4105
 
                var color;
4106
 
 
4107
 
                do {
4108
 
                                color = $.curCSS(elem, attr);
4109
 
 
4110
 
                                // Keep going until we find an element that has color, or we hit the body
4111
 
                                if ( color != '' && color != 'transparent' || $.nodeName(elem, "body") )
4112
 
                                                break;
4113
 
 
4114
 
                                attr = "backgroundColor";
4115
 
                } while ( elem = elem.parentNode );
4116
 
 
4117
 
                return getRGB(color);
4118
 
};
4119
 
 
4120
 
// Some named colors to work with
4121
 
// From Interface by Stefan Petre
4122
 
// http://interface.eyecon.ro/
4123
 
 
4124
 
var colors = {
4125
 
        aqua:[0,255,255],
4126
 
        azure:[240,255,255],
4127
 
        beige:[245,245,220],
4128
 
        black:[0,0,0],
4129
 
        blue:[0,0,255],
4130
 
        brown:[165,42,42],
4131
 
        cyan:[0,255,255],
4132
 
        darkblue:[0,0,139],
4133
 
        darkcyan:[0,139,139],
4134
 
        darkgrey:[169,169,169],
4135
 
        darkgreen:[0,100,0],
4136
 
        darkkhaki:[189,183,107],
4137
 
        darkmagenta:[139,0,139],
4138
 
        darkolivegreen:[85,107,47],
4139
 
        darkorange:[255,140,0],
4140
 
        darkorchid:[153,50,204],
4141
 
        darkred:[139,0,0],
4142
 
        darksalmon:[233,150,122],
4143
 
        darkviolet:[148,0,211],
4144
 
        fuchsia:[255,0,255],
4145
 
        gold:[255,215,0],
4146
 
        green:[0,128,0],
4147
 
        indigo:[75,0,130],
4148
 
        khaki:[240,230,140],
4149
 
        lightblue:[173,216,230],
4150
 
        lightcyan:[224,255,255],
4151
 
        lightgreen:[144,238,144],
4152
 
        lightgrey:[211,211,211],
4153
 
        lightpink:[255,182,193],
4154
 
        lightyellow:[255,255,224],
4155
 
        lime:[0,255,0],
4156
 
        magenta:[255,0,255],
4157
 
        maroon:[128,0,0],
4158
 
        navy:[0,0,128],
4159
 
        olive:[128,128,0],
4160
 
        orange:[255,165,0],
4161
 
        pink:[255,192,203],
4162
 
        purple:[128,0,128],
4163
 
        violet:[128,0,128],
4164
 
        red:[255,0,0],
4165
 
        silver:[192,192,192],
4166
 
        white:[255,255,255],
4167
 
        yellow:[255,255,0],
4168
 
        transparent: [255,255,255]
4169
 
};
4170
 
 
4171
 
 
4172
 
 
4173
 
/******************************************************************************/
4174
 
/****************************** CLASS ANIMATIONS ******************************/
4175
 
/******************************************************************************/
4176
 
 
4177
 
var classAnimationActions = ['add', 'remove', 'toggle'],
4178
 
        shorthandStyles = {
4179
 
                border: 1,
4180
 
                borderBottom: 1,
4181
 
                borderColor: 1,
4182
 
                borderLeft: 1,
4183
 
                borderRight: 1,
4184
 
                borderTop: 1,
4185
 
                borderWidth: 1,
4186
 
                margin: 1,
4187
 
                padding: 1
4188
 
        };
4189
 
 
4190
 
function getElementStyles() {
4191
 
        var style = document.defaultView
4192
 
                        ? document.defaultView.getComputedStyle(this, null)
4193
 
                        : this.currentStyle,
4194
 
                newStyle = {},
4195
 
                key,
4196
 
                camelCase;
4197
 
 
4198
 
        // webkit enumerates style porperties
4199
 
        if (style && style.length && style[0] && style[style[0]]) {
4200
 
                var len = style.length;
4201
 
                while (len--) {
4202
 
                        key = style[len];
4203
 
                        if (typeof style[key] == 'string') {
4204
 
                                camelCase = key.replace(/\-(\w)/g, function(all, letter){
4205
 
                                        return letter.toUpperCase();
4206
 
                                });
4207
 
                                newStyle[camelCase] = style[key];
4208
 
                        }
4209
 
                }
4210
 
        } else {
4211
 
                for (key in style) {
4212
 
                        if (typeof style[key] === 'string') {
4213
 
                                newStyle[key] = style[key];
4214
 
                        }
4215
 
                }
4216
 
        }
4217
 
        
4218
 
        return newStyle;
4219
 
}
4220
 
 
4221
 
function filterStyles(styles) {
4222
 
        var name, value;
4223
 
        for (name in styles) {
4224
 
                value = styles[name];
4225
 
                if (
4226
 
                        // ignore null and undefined values
4227
 
                        value == null ||
4228
 
                        // ignore functions (when does this occur?)
4229
 
                        $.isFunction(value) ||
4230
 
                        // shorthand styles that need to be expanded
4231
 
                        name in shorthandStyles ||
4232
 
                        // ignore scrollbars (break in IE)
4233
 
                        (/scrollbar/).test(name) ||
4234
 
 
4235
 
                        // only colors or values that can be converted to numbers
4236
 
                        (!(/color/i).test(name) && isNaN(parseFloat(value)))
4237
 
                ) {
4238
 
                        delete styles[name];
4239
 
                }
4240
 
        }
4241
 
        
4242
 
        return styles;
4243
 
}
4244
 
 
4245
 
function styleDifference(oldStyle, newStyle) {
4246
 
        var diff = { _: 0 }, // http://dev.jquery.com/ticket/5459
4247
 
                name;
4248
 
 
4249
 
        for (name in newStyle) {
4250
 
                if (oldStyle[name] != newStyle[name]) {
4251
 
                        diff[name] = newStyle[name];
4252
 
                }
4253
 
        }
4254
 
 
4255
 
        return diff;
4256
 
}
4257
 
 
4258
 
$.effects.animateClass = function(value, duration, easing, callback) {
4259
 
        if ($.isFunction(easing)) {
4260
 
                callback = easing;
4261
 
                easing = null;
4262
 
        }
4263
 
 
4264
 
        return this.queue(function() {
4265
 
                var that = $(this),
4266
 
                        originalStyleAttr = that.attr('style') || ' ',
4267
 
                        originalStyle = filterStyles(getElementStyles.call(this)),
4268
 
                        newStyle,
4269
 
                        className = that.attr('class');
4270
 
 
4271
 
                $.each(classAnimationActions, function(i, action) {
4272
 
                        if (value[action]) {
4273
 
                                that[action + 'Class'](value[action]);
4274
 
                        }
4275
 
                });
4276
 
                newStyle = filterStyles(getElementStyles.call(this));
4277
 
                that.attr('class', className);
4278
 
 
4279
 
                that.animate(styleDifference(originalStyle, newStyle), {
4280
 
                        queue: false,
4281
 
                        duration: duration,
4282
 
                        easing: easing,
4283
 
                        complete: function() {
4284
 
                                $.each(classAnimationActions, function(i, action) {
4285
 
                                        if (value[action]) { that[action + 'Class'](value[action]); }
4286
 
                                });
4287
 
                                // work around bug in IE by clearing the cssText before setting it
4288
 
                                if (typeof that.attr('style') == 'object') {
4289
 
                                        that.attr('style').cssText = '';
4290
 
                                        that.attr('style').cssText = originalStyleAttr;
4291
 
                                } else {
4292
 
                                        that.attr('style', originalStyleAttr);
4293
 
                                }
4294
 
                                if (callback) { callback.apply(this, arguments); }
4295
 
                                $.dequeue( this );
4296
 
                        }
4297
 
                });
4298
 
        });
4299
 
};
4300
 
 
4301
 
$.fn.extend({
4302
 
        _addClass: $.fn.addClass,
4303
 
        addClass: function(classNames, speed, easing, callback) {
4304
 
                return speed ? $.effects.animateClass.apply(this, [{ add: classNames },speed,easing,callback]) : this._addClass(classNames);
4305
 
        },
4306
 
 
4307
 
        _removeClass: $.fn.removeClass,
4308
 
        removeClass: function(classNames,speed,easing,callback) {
4309
 
                return speed ? $.effects.animateClass.apply(this, [{ remove: classNames },speed,easing,callback]) : this._removeClass(classNames);
4310
 
        },
4311
 
 
4312
 
        _toggleClass: $.fn.toggleClass,
4313
 
        toggleClass: function(classNames, force, speed, easing, callback) {
4314
 
                if ( typeof force == "boolean" || force === undefined ) {
4315
 
                        if ( !speed ) {
4316
 
                                // without speed parameter;
4317
 
                                return this._toggleClass(classNames, force);
4318
 
                        } else {
4319
 
                                return $.effects.animateClass.apply(this, [(force?{add:classNames}:{remove:classNames}),speed,easing,callback]);
4320
 
                        }
4321
 
                } else {
4322
 
                        // without switch parameter;
4323
 
                        return $.effects.animateClass.apply(this, [{ toggle: classNames },force,speed,easing]);
4324
 
                }
4325
 
        },
4326
 
 
4327
 
        switchClass: function(remove,add,speed,easing,callback) {
4328
 
                return $.effects.animateClass.apply(this, [{ add: add, remove: remove },speed,easing,callback]);
4329
 
        }
4330
 
});
4331
 
 
4332
 
 
4333
 
 
4334
 
/******************************************************************************/
4335
 
/*********************************** EFFECTS **********************************/
4336
 
/******************************************************************************/
4337
 
 
4338
 
$.extend($.effects, {
4339
 
        version: "1.8.18",
4340
 
 
4341
 
        // Saves a set of properties in a data storage
4342
 
        save: function(element, set) {
4343
 
                for(var i=0; i < set.length; i++) {
4344
 
                        if(set[i] !== null) element.data("ec.storage."+set[i], element[0].style[set[i]]);
4345
 
                }
4346
 
        },
4347
 
 
4348
 
        // Restores a set of previously saved properties from a data storage
4349
 
        restore: function(element, set) {
4350
 
                for(var i=0; i < set.length; i++) {
4351
 
                        if(set[i] !== null) element.css(set[i], element.data("ec.storage."+set[i]));
4352
 
                }
4353
 
        },
4354
 
 
4355
 
        setMode: function(el, mode) {
4356
 
                if (mode == 'toggle') mode = el.is(':hidden') ? 'show' : 'hide'; // Set for toggle
4357
 
                return mode;
4358
 
        },
4359
 
 
4360
 
        getBaseline: function(origin, original) { // Translates a [top,left] array into a baseline value
4361
 
                // this should be a little more flexible in the future to handle a string & hash
4362
 
                var y, x;
4363
 
                switch (origin[0]) {
4364
 
                        case 'top': y = 0; break;
4365
 
                        case 'middle': y = 0.5; break;
4366
 
                        case 'bottom': y = 1; break;
4367
 
                        default: y = origin[0] / original.height;
4368
 
                };
4369
 
                switch (origin[1]) {
4370
 
                        case 'left': x = 0; break;
4371
 
                        case 'center': x = 0.5; break;
4372
 
                        case 'right': x = 1; break;
4373
 
                        default: x = origin[1] / original.width;
4374
 
                };
4375
 
                return {x: x, y: y};
4376
 
        },
4377
 
 
4378
 
        // Wraps the element around a wrapper that copies position properties
4379
 
        createWrapper: function(element) {
4380
 
 
4381
 
                // if the element is already wrapped, return it
4382
 
                if (element.parent().is('.ui-effects-wrapper')) {
4383
 
                        return element.parent();
4384
 
                }
4385
 
 
4386
 
                // wrap the element
4387
 
                var props = {
4388
 
                                width: element.outerWidth(true),
4389
 
                                height: element.outerHeight(true),
4390
 
                                'float': element.css('float')
4391
 
                        },
4392
 
                        wrapper = $('<div></div>')
4393
 
                                .addClass('ui-effects-wrapper')
4394
 
                                .css({
4395
 
                                        fontSize: '100%',
4396
 
                                        background: 'transparent',
4397
 
                                        border: 'none',
4398
 
                                        margin: 0,
4399
 
                                        padding: 0
4400
 
                                }),
4401
 
                        active = document.activeElement;
4402
 
 
4403
 
                element.wrap(wrapper);
4404
 
 
4405
 
                // Fixes #7595 - Elements lose focus when wrapped.
4406
 
                if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
4407
 
                        $( active ).focus();
4408
 
                }
4409
 
                
4410
 
                wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually loose the reference to the wrapped element
4411
 
 
4412
 
                // transfer positioning properties to the wrapper
4413
 
                if (element.css('position') == 'static') {
4414
 
                        wrapper.css({ position: 'relative' });
4415
 
                        element.css({ position: 'relative' });
4416
 
                } else {
4417
 
                        $.extend(props, {
4418
 
                                position: element.css('position'),
4419
 
                                zIndex: element.css('z-index')
4420
 
                        });
4421
 
                        $.each(['top', 'left', 'bottom', 'right'], function(i, pos) {
4422
 
                                props[pos] = element.css(pos);
4423
 
                                if (isNaN(parseInt(props[pos], 10))) {
4424
 
                                        props[pos] = 'auto';
4425
 
                                }
4426
 
                        });
4427
 
                        element.css({position: 'relative', top: 0, left: 0, right: 'auto', bottom: 'auto' });
4428
 
                }
4429
 
 
4430
 
                return wrapper.css(props).show();
4431
 
        },
4432
 
 
4433
 
        removeWrapper: function(element) {
4434
 
                var parent,
4435
 
                        active = document.activeElement;
4436
 
                
4437
 
                if (element.parent().is('.ui-effects-wrapper')) {
4438
 
                        parent = element.parent().replaceWith(element);
4439
 
                        // Fixes #7595 - Elements lose focus when wrapped.
4440
 
                        if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
4441
 
                                $( active ).focus();
4442
 
                        }
4443
 
                        return parent;
4444
 
                }
4445
 
                        
4446
 
                return element;
4447
 
        },
4448
 
 
4449
 
        setTransition: function(element, list, factor, value) {
4450
 
                value = value || {};
4451
 
                $.each(list, function(i, x){
4452
 
                        unit = element.cssUnit(x);
4453
 
                        if (unit[0] > 0) value[x] = unit[0] * factor + unit[1];
4454
 
                });
4455
 
                return value;
4456
 
        }
4457
 
});
4458
 
 
4459
 
 
4460
 
function _normalizeArguments(effect, options, speed, callback) {
4461
 
        // shift params for method overloading
4462
 
        if (typeof effect == 'object') {
4463
 
                callback = options;
4464
 
                speed = null;
4465
 
                options = effect;
4466
 
                effect = options.effect;
4467
 
        }
4468
 
        if ($.isFunction(options)) {
4469
 
                callback = options;
4470
 
                speed = null;
4471
 
                options = {};
4472
 
        }
4473
 
        if (typeof options == 'number' || $.fx.speeds[options]) {
4474
 
                callback = speed;
4475
 
                speed = options;
4476
 
                options = {};
4477
 
        }
4478
 
        if ($.isFunction(speed)) {
4479
 
                callback = speed;
4480
 
                speed = null;
4481
 
        }
4482
 
 
4483
 
        options = options || {};
4484
 
 
4485
 
        speed = speed || options.duration;
4486
 
        speed = $.fx.off ? 0 : typeof speed == 'number'
4487
 
                ? speed : speed in $.fx.speeds ? $.fx.speeds[speed] : $.fx.speeds._default;
4488
 
 
4489
 
        callback = callback || options.complete;
4490
 
 
4491
 
        return [effect, options, speed, callback];
4492
 
}
4493
 
 
4494
 
function standardSpeed( speed ) {
4495
 
        // valid standard speeds
4496
 
        if ( !speed || typeof speed === "number" || $.fx.speeds[ speed ] ) {
4497
 
                return true;
4498
 
        }
4499
 
        
4500
 
        // invalid strings - treat as "normal" speed
4501
 
        if ( typeof speed === "string" && !$.effects[ speed ] ) {
4502
 
                return true;
4503
 
        }
4504
 
        
4505
 
        return false;
4506
 
}
4507
 
 
4508
 
$.fn.extend({
4509
 
        effect: function(effect, options, speed, callback) {
4510
 
                var args = _normalizeArguments.apply(this, arguments),
4511
 
                        // TODO: make effects take actual parameters instead of a hash
4512
 
                        args2 = {
4513
 
                                options: args[1],
4514
 
                                duration: args[2],
4515
 
                                callback: args[3]
4516
 
                        },
4517
 
                        mode = args2.options.mode,
4518
 
                        effectMethod = $.effects[effect];
4519
 
                
4520
 
                if ( $.fx.off || !effectMethod ) {
4521
 
                        // delegate to the original method (e.g., .show()) if possible
4522
 
                        if ( mode ) {
4523
 
                                return this[ mode ]( args2.duration, args2.callback );
4524
 
                        } else {
4525
 
                                return this.each(function() {
4526
 
                                        if ( args2.callback ) {
4527
 
                                                args2.callback.call( this );
4528
 
                                        }
4529
 
                                });
4530
 
                        }
4531
 
                }
4532
 
                
4533
 
                return effectMethod.call(this, args2);
4534
 
        },
4535
 
 
4536
 
        _show: $.fn.show,
4537
 
        show: function(speed) {
4538
 
                if ( standardSpeed( speed ) ) {
4539
 
                        return this._show.apply(this, arguments);
4540
 
                } else {
4541
 
                        var args = _normalizeArguments.apply(this, arguments);
4542
 
                        args[1].mode = 'show';
4543
 
                        return this.effect.apply(this, args);
4544
 
                }
4545
 
        },
4546
 
 
4547
 
        _hide: $.fn.hide,
4548
 
        hide: function(speed) {
4549
 
                if ( standardSpeed( speed ) ) {
4550
 
                        return this._hide.apply(this, arguments);
4551
 
                } else {
4552
 
                        var args = _normalizeArguments.apply(this, arguments);
4553
 
                        args[1].mode = 'hide';
4554
 
                        return this.effect.apply(this, args);
4555
 
                }
4556
 
        },
4557
 
 
4558
 
        // jQuery core overloads toggle and creates _toggle
4559
 
        __toggle: $.fn.toggle,
4560
 
        toggle: function(speed) {
4561
 
                if ( standardSpeed( speed ) || typeof speed === "boolean" || $.isFunction( speed ) ) {
4562
 
                        return this.__toggle.apply(this, arguments);
4563
 
                } else {
4564
 
                        var args = _normalizeArguments.apply(this, arguments);
4565
 
                        args[1].mode = 'toggle';
4566
 
                        return this.effect.apply(this, args);
4567
 
                }
4568
 
        },
4569
 
 
4570
 
        // helper functions
4571
 
        cssUnit: function(key) {
4572
 
                var style = this.css(key), val = [];
4573
 
                $.each( ['em','px','%','pt'], function(i, unit){
4574
 
                        if(style.indexOf(unit) > 0)
4575
 
                                val = [parseFloat(style), unit];
4576
 
                });
4577
 
                return val;
4578
 
        }
4579
 
});
4580
 
 
4581
 
 
4582
 
 
4583
 
/******************************************************************************/
4584
 
/*********************************** EASING ***********************************/
4585
 
/******************************************************************************/
4586
 
 
4587
 
/*
4588
 
 * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
4589
 
 *
4590
 
 * Uses the built in easing capabilities added In jQuery 1.1
4591
 
 * to offer multiple easing options
4592
 
 *
4593
 
 * TERMS OF USE - jQuery Easing
4594
 
 *
4595
 
 * Open source under the BSD License.
4596
 
 *
4597
 
 * Copyright 2008 George McGinley Smith
4598
 
 * All rights reserved.
4599
 
 *
4600
 
 * Redistribution and use in source and binary forms, with or without modification,
4601
 
 * are permitted provided that the following conditions are met:
4602
 
 *
4603
 
 * Redistributions of source code must retain the above copyright notice, this list of
4604
 
 * conditions and the following disclaimer.
4605
 
 * Redistributions in binary form must reproduce the above copyright notice, this list
4606
 
 * of conditions and the following disclaimer in the documentation and/or other materials
4607
 
 * provided with the distribution.
4608
 
 *
4609
 
 * Neither the name of the author nor the names of contributors may be used to endorse
4610
 
 * or promote products derived from this software without specific prior written permission.
4611
 
 *
4612
 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
4613
 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
4614
 
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
4615
 
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
4616
 
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
4617
 
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
4618
 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
4619
 
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
4620
 
 * OF THE POSSIBILITY OF SUCH DAMAGE.
4621
 
 *
4622
 
*/
4623
 
 
4624
 
// t: current time, b: begInnIng value, c: change In value, d: duration
4625
 
$.easing.jswing = $.easing.swing;
4626
 
 
4627
 
$.extend($.easing,
4628
 
{
4629
 
        def: 'easeOutQuad',
4630
 
        swing: function (x, t, b, c, d) {
4631
 
                //alert($.easing.default);
4632
 
                return $.easing[$.easing.def](x, t, b, c, d);
4633
 
        },
4634
 
        easeInQuad: function (x, t, b, c, d) {
4635
 
                return c*(t/=d)*t + b;
4636
 
        },
4637
 
        easeOutQuad: function (x, t, b, c, d) {
4638
 
                return -c *(t/=d)*(t-2) + b;
4639
 
        },
4640
 
        easeInOutQuad: function (x, t, b, c, d) {
4641
 
                if ((t/=d/2) < 1) return c/2*t*t + b;
4642
 
                return -c/2 * ((--t)*(t-2) - 1) + b;
4643
 
        },
4644
 
        easeInCubic: function (x, t, b, c, d) {
4645
 
                return c*(t/=d)*t*t + b;
4646
 
        },
4647
 
        easeOutCubic: function (x, t, b, c, d) {
4648
 
                return c*((t=t/d-1)*t*t + 1) + b;
4649
 
        },
4650
 
        easeInOutCubic: function (x, t, b, c, d) {
4651
 
                if ((t/=d/2) < 1) return c/2*t*t*t + b;
4652
 
                return c/2*((t-=2)*t*t + 2) + b;
4653
 
        },
4654
 
        easeInQuart: function (x, t, b, c, d) {
4655
 
                return c*(t/=d)*t*t*t + b;
4656
 
        },
4657
 
        easeOutQuart: function (x, t, b, c, d) {
4658
 
                return -c * ((t=t/d-1)*t*t*t - 1) + b;
4659
 
        },
4660
 
        easeInOutQuart: function (x, t, b, c, d) {
4661
 
                if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
4662
 
                return -c/2 * ((t-=2)*t*t*t - 2) + b;
4663
 
        },
4664
 
        easeInQuint: function (x, t, b, c, d) {
4665
 
                return c*(t/=d)*t*t*t*t + b;
4666
 
        },
4667
 
        easeOutQuint: function (x, t, b, c, d) {
4668
 
                return c*((t=t/d-1)*t*t*t*t + 1) + b;
4669
 
        },
4670
 
        easeInOutQuint: function (x, t, b, c, d) {
4671
 
                if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
4672
 
                return c/2*((t-=2)*t*t*t*t + 2) + b;
4673
 
        },
4674
 
        easeInSine: function (x, t, b, c, d) {
4675
 
                return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
4676
 
        },
4677
 
        easeOutSine: function (x, t, b, c, d) {
4678
 
                return c * Math.sin(t/d * (Math.PI/2)) + b;
4679
 
        },
4680
 
        easeInOutSine: function (x, t, b, c, d) {
4681
 
                return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
4682
 
        },
4683
 
        easeInExpo: function (x, t, b, c, d) {
4684
 
                return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
4685
 
        },
4686
 
        easeOutExpo: function (x, t, b, c, d) {
4687
 
                return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
4688
 
        },
4689
 
        easeInOutExpo: function (x, t, b, c, d) {
4690
 
                if (t==0) return b;
4691
 
                if (t==d) return b+c;
4692
 
                if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
4693
 
                return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
4694
 
        },
4695
 
        easeInCirc: function (x, t, b, c, d) {
4696
 
                return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
4697
 
        },
4698
 
        easeOutCirc: function (x, t, b, c, d) {
4699
 
                return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
4700
 
        },
4701
 
        easeInOutCirc: function (x, t, b, c, d) {
4702
 
                if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
4703
 
                return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
4704
 
        },
4705
 
        easeInElastic: function (x, t, b, c, d) {
4706
 
                var s=1.70158;var p=0;var a=c;
4707
 
                if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
4708
 
                if (a < Math.abs(c)) { a=c; var s=p/4; }
4709
 
                else var s = p/(2*Math.PI) * Math.asin (c/a);
4710
 
                return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
4711
 
        },
4712
 
        easeOutElastic: function (x, t, b, c, d) {
4713
 
                var s=1.70158;var p=0;var a=c;
4714
 
                if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
4715
 
                if (a < Math.abs(c)) { a=c; var s=p/4; }
4716
 
                else var s = p/(2*Math.PI) * Math.asin (c/a);
4717
 
                return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
4718
 
        },
4719
 
        easeInOutElastic: function (x, t, b, c, d) {
4720
 
                var s=1.70158;var p=0;var a=c;
4721
 
                if (t==0) return b;  if ((t/=d/2)==2) return b+c;  if (!p) p=d*(.3*1.5);
4722
 
                if (a < Math.abs(c)) { a=c; var s=p/4; }
4723
 
                else var s = p/(2*Math.PI) * Math.asin (c/a);
4724
 
                if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
4725
 
                return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
4726
 
        },
4727
 
        easeInBack: function (x, t, b, c, d, s) {
4728
 
                if (s == undefined) s = 1.70158;
4729
 
                return c*(t/=d)*t*((s+1)*t - s) + b;
4730
 
        },
4731
 
        easeOutBack: function (x, t, b, c, d, s) {
4732
 
                if (s == undefined) s = 1.70158;
4733
 
                return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
4734
 
        },
4735
 
        easeInOutBack: function (x, t, b, c, d, s) {
4736
 
                if (s == undefined) s = 1.70158;
4737
 
                if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
4738
 
                return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
4739
 
        },
4740
 
        easeInBounce: function (x, t, b, c, d) {
4741
 
                return c - $.easing.easeOutBounce (x, d-t, 0, c, d) + b;
4742
 
        },
4743
 
        easeOutBounce: function (x, t, b, c, d) {
4744
 
                if ((t/=d) < (1/2.75)) {
4745
 
                        return c*(7.5625*t*t) + b;
4746
 
                } else if (t < (2/2.75)) {
4747
 
                        return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
4748
 
                } else if (t < (2.5/2.75)) {
4749
 
                        return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
4750
 
                } else {
4751
 
                        return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
4752
 
                }
4753
 
        },
4754
 
        easeInOutBounce: function (x, t, b, c, d) {
4755
 
                if (t < d/2) return $.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
4756
 
                return $.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
4757
 
        }
4758
 
});
4759
 
 
4760
 
/*
4761
 
 *
4762
 
 * TERMS OF USE - EASING EQUATIONS
4763
 
 *
4764
 
 * Open source under the BSD License.
4765
 
 *
4766
 
 * Copyright 2001 Robert Penner
4767
 
 * All rights reserved.
4768
 
 *
4769
 
 * Redistribution and use in source and binary forms, with or without modification,
4770
 
 * are permitted provided that the following conditions are met:
4771
 
 *
4772
 
 * Redistributions of source code must retain the above copyright notice, this list of
4773
 
 * conditions and the following disclaimer.
4774
 
 * Redistributions in binary form must reproduce the above copyright notice, this list
4775
 
 * of conditions and the following disclaimer in the documentation and/or other materials
4776
 
 * provided with the distribution.
4777
 
 *
4778
 
 * Neither the name of the author nor the names of contributors may be used to endorse
4779
 
 * or promote products derived from this software without specific prior written permission.
4780
 
 *
4781
 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
4782
 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
4783
 
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
4784
 
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
4785
 
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
4786
 
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
4787
 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
4788
 
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
4789
 
 * OF THE POSSIBILITY OF SUCH DAMAGE.
4790
 
 *
4791
 
 */
4792
 
 
4793
 
})(jQuery);
4794
 
/*
4795
 
 * jQuery UI Effects Blind 1.8.18
4796
 
 *
4797
 
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
4798
 
 * Dual licensed under the MIT or GPL Version 2 licenses.
4799
 
 * http://jquery.org/license
4800
 
 *
4801
 
 * http://docs.jquery.com/UI/Effects/Blind
4802
 
 *
4803
 
 * Depends:
4804
 
 *      jquery.effects.core.js
4805
 
 */
4806
 
(function( $, undefined ) {
4807
 
 
4808
 
$.effects.blind = function(o) {
4809
 
 
4810
 
        return this.queue(function() {
4811
 
 
4812
 
                // Create element
4813
 
                var el = $(this), props = ['position','top','bottom','left','right'];
4814
 
 
4815
 
                // Set options
4816
 
                var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode
4817
 
                var direction = o.options.direction || 'vertical'; // Default direction
4818
 
 
4819
 
                // Adjust
4820
 
                $.effects.save(el, props); el.show(); // Save & Show
4821
 
                var wrapper = $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper
4822
 
                var ref = (direction == 'vertical') ? 'height' : 'width';
4823
 
                var distance = (direction == 'vertical') ? wrapper.height() : wrapper.width();
4824
 
                if(mode == 'show') wrapper.css(ref, 0); // Shift
4825
 
 
4826
 
                // Animation
4827
 
                var animation = {};
4828
 
                animation[ref] = mode == 'show' ? distance : 0;
4829
 
 
4830
 
                // Animate
4831
 
                wrapper.animate(animation, o.duration, o.options.easing, function() {
4832
 
                        if(mode == 'hide') el.hide(); // Hide
4833
 
                        $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
4834
 
                        if(o.callback) o.callback.apply(el[0], arguments); // Callback
4835
 
                        el.dequeue();
4836
 
                });
4837
 
 
4838
 
        });
4839
 
 
4840
 
};
4841
 
 
4842
 
})(jQuery);
4843
 
/*
4844
 
 * jQuery UI Effects Bounce 1.8.18
4845
 
 *
4846
 
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
4847
 
 * Dual licensed under the MIT or GPL Version 2 licenses.
4848
 
 * http://jquery.org/license
4849
 
 *
4850
 
 * http://docs.jquery.com/UI/Effects/Bounce
4851
 
 *
4852
 
 * Depends:
4853
 
 *      jquery.effects.core.js
4854
 
 */
4855
 
(function( $, undefined ) {
4856
 
 
4857
 
$.effects.bounce = function(o) {
4858
 
 
4859
 
        return this.queue(function() {
4860
 
 
4861
 
                // Create element
4862
 
                var el = $(this), props = ['position','top','bottom','left','right'];
4863
 
 
4864
 
                // Set options
4865
 
                var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode
4866
 
                var direction = o.options.direction || 'up'; // Default direction
4867
 
                var distance = o.options.distance || 20; // Default distance
4868
 
                var times = o.options.times || 5; // Default # of times
4869
 
                var speed = o.duration || 250; // Default speed per bounce
4870
 
                if (/show|hide/.test(mode)) props.push('opacity'); // Avoid touching opacity to prevent clearType and PNG issues in IE
4871
 
 
4872
 
                // Adjust
4873
 
                $.effects.save(el, props); el.show(); // Save & Show
4874
 
                $.effects.createWrapper(el); // Create Wrapper
4875
 
                var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left';
4876
 
                var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg';
4877
 
                var distance = o.options.distance || (ref == 'top' ? el.outerHeight({margin:true}) / 3 : el.outerWidth({margin:true}) / 3);
4878
 
                if (mode == 'show') el.css('opacity', 0).css(ref, motion == 'pos' ? -distance : distance); // Shift
4879
 
                if (mode == 'hide') distance = distance / (times * 2);
4880
 
                if (mode != 'hide') times--;
4881
 
 
4882
 
                // Animate
4883
 
                if (mode == 'show') { // Show Bounce
4884
 
                        var animation = {opacity: 1};
4885
 
                        animation[ref] = (motion == 'pos' ? '+=' : '-=') + distance;
4886
 
                        el.animate(animation, speed / 2, o.options.easing);
4887
 
                        distance = distance / 2;
4888
 
                        times--;
4889
 
                };
4890
 
                for (var i = 0; i < times; i++) { // Bounces
4891
 
                        var animation1 = {}, animation2 = {};
4892
 
                        animation1[ref] = (motion == 'pos' ? '-=' : '+=') + distance;
4893
 
                        animation2[ref] = (motion == 'pos' ? '+=' : '-=') + distance;
4894
 
                        el.animate(animation1, speed / 2, o.options.easing).animate(animation2, speed / 2, o.options.easing);
4895
 
                        distance = (mode == 'hide') ? distance * 2 : distance / 2;
4896
 
                };
4897
 
                if (mode == 'hide') { // Last Bounce
4898
 
                        var animation = {opacity: 0};
4899
 
                        animation[ref] = (motion == 'pos' ? '-=' : '+=')  + distance;
4900
 
                        el.animate(animation, speed / 2, o.options.easing, function(){
4901
 
                                el.hide(); // Hide
4902
 
                                $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
4903
 
                                if(o.callback) o.callback.apply(this, arguments); // Callback
4904
 
                        });
4905
 
                } else {
4906
 
                        var animation1 = {}, animation2 = {};
4907
 
                        animation1[ref] = (motion == 'pos' ? '-=' : '+=') + distance;
4908
 
                        animation2[ref] = (motion == 'pos' ? '+=' : '-=') + distance;
4909
 
                        el.animate(animation1, speed / 2, o.options.easing).animate(animation2, speed / 2, o.options.easing, function(){
4910
 
                                $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
4911
 
                                if(o.callback) o.callback.apply(this, arguments); // Callback
4912
 
                        });
4913
 
                };
4914
 
                el.queue('fx', function() { el.dequeue(); });
4915
 
                el.dequeue();
4916
 
        });
4917
 
 
4918
 
};
4919
 
 
4920
 
})(jQuery);
4921
 
/*
4922
 
 * jQuery UI Effects Clip 1.8.18
4923
 
 *
4924
 
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
4925
 
 * Dual licensed under the MIT or GPL Version 2 licenses.
4926
 
 * http://jquery.org/license
4927
 
 *
4928
 
 * http://docs.jquery.com/UI/Effects/Clip
4929
 
 *
4930
 
 * Depends:
4931
 
 *      jquery.effects.core.js
4932
 
 */
4933
 
(function( $, undefined ) {
4934
 
 
4935
 
$.effects.clip = function(o) {
4936
 
 
4937
 
        return this.queue(function() {
4938
 
 
4939
 
                // Create element
4940
 
                var el = $(this), props = ['position','top','bottom','left','right','height','width'];
4941
 
 
4942
 
                // Set options
4943
 
                var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode
4944
 
                var direction = o.options.direction || 'vertical'; // Default direction
4945
 
 
4946
 
                // Adjust
4947
 
                $.effects.save(el, props); el.show(); // Save & Show
4948
 
                var wrapper = $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper
4949
 
                var animate = el[0].tagName == 'IMG' ? wrapper : el;
4950
 
                var ref = {
4951
 
                        size: (direction == 'vertical') ? 'height' : 'width',
4952
 
                        position: (direction == 'vertical') ? 'top' : 'left'
4953
 
                };
4954
 
                var distance = (direction == 'vertical') ? animate.height() : animate.width();
4955
 
                if(mode == 'show') { animate.css(ref.size, 0); animate.css(ref.position, distance / 2); } // Shift
4956
 
 
4957
 
                // Animation
4958
 
                var animation = {};
4959
 
                animation[ref.size] = mode == 'show' ? distance : 0;
4960
 
                animation[ref.position] = mode == 'show' ? 0 : distance / 2;
4961
 
 
4962
 
                // Animate
4963
 
                animate.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() {
4964
 
                        if(mode == 'hide') el.hide(); // Hide
4965
 
                        $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
4966
 
                        if(o.callback) o.callback.apply(el[0], arguments); // Callback
4967
 
                        el.dequeue();
4968
 
                }});
4969
 
 
4970
 
        });
4971
 
 
4972
 
};
4973
 
 
4974
 
})(jQuery);
4975
 
/*
4976
 
 * jQuery UI Effects Drop 1.8.18
4977
 
 *
4978
 
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
4979
 
 * Dual licensed under the MIT or GPL Version 2 licenses.
4980
 
 * http://jquery.org/license
4981
 
 *
4982
 
 * http://docs.jquery.com/UI/Effects/Drop
4983
 
 *
4984
 
 * Depends:
4985
 
 *      jquery.effects.core.js
4986
 
 */
4987
 
(function( $, undefined ) {
4988
 
 
4989
 
$.effects.drop = function(o) {
4990
 
 
4991
 
        return this.queue(function() {
4992
 
 
4993
 
                // Create element
4994
 
                var el = $(this), props = ['position','top','bottom','left','right','opacity'];
4995
 
 
4996
 
                // Set options
4997
 
                var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode
4998
 
                var direction = o.options.direction || 'left'; // Default Direction
4999
 
 
5000
 
                // Adjust
5001
 
                $.effects.save(el, props); el.show(); // Save & Show
5002
 
                $.effects.createWrapper(el); // Create Wrapper
5003
 
                var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left';
5004
 
                var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg';
5005
 
                var distance = o.options.distance || (ref == 'top' ? el.outerHeight({margin:true}) / 2 : el.outerWidth({margin:true}) / 2);
5006
 
                if (mode == 'show') el.css('opacity', 0).css(ref, motion == 'pos' ? -distance : distance); // Shift
5007
 
 
5008
 
                // Animation
5009
 
                var animation = {opacity: mode == 'show' ? 1 : 0};
5010
 
                animation[ref] = (mode == 'show' ? (motion == 'pos' ? '+=' : '-=') : (motion == 'pos' ? '-=' : '+=')) + distance;
5011
 
 
5012
 
                // Animate
5013
 
                el.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() {
5014
 
                        if(mode == 'hide') el.hide(); // Hide
5015
 
                        $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
5016
 
                        if(o.callback) o.callback.apply(this, arguments); // Callback
5017
 
                        el.dequeue();
5018
 
                }});
5019
 
 
5020
 
        });
5021
 
 
5022
 
};
5023
 
 
5024
 
})(jQuery);
5025
 
/*
5026
 
 * jQuery UI Effects Explode 1.8.18
5027
 
 *
5028
 
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
5029
 
 * Dual licensed under the MIT or GPL Version 2 licenses.
5030
 
 * http://jquery.org/license
5031
 
 *
5032
 
 * http://docs.jquery.com/UI/Effects/Explode
5033
 
 *
5034
 
 * Depends:
5035
 
 *      jquery.effects.core.js
5036
 
 */
5037
 
(function( $, undefined ) {
5038
 
 
5039
 
$.effects.explode = function(o) {
5040
 
 
5041
 
        return this.queue(function() {
5042
 
 
5043
 
        var rows = o.options.pieces ? Math.round(Math.sqrt(o.options.pieces)) : 3;
5044
 
        var cells = o.options.pieces ? Math.round(Math.sqrt(o.options.pieces)) : 3;
5045
 
 
5046
 
        o.options.mode = o.options.mode == 'toggle' ? ($(this).is(':visible') ? 'hide' : 'show') : o.options.mode;
5047
 
        var el = $(this).show().css('visibility', 'hidden');
5048
 
        var offset = el.offset();
5049
 
 
5050
 
        //Substract the margins - not fixing the problem yet.
5051
 
        offset.top -= parseInt(el.css("marginTop"),10) || 0;
5052
 
        offset.left -= parseInt(el.css("marginLeft"),10) || 0;
5053
 
 
5054
 
        var width = el.outerWidth(true);
5055
 
        var height = el.outerHeight(true);
5056
 
 
5057
 
        for(var i=0;i<rows;i++) { // =
5058
 
                for(var j=0;j<cells;j++) { // ||
5059
 
                        el
5060
 
                                .clone()
5061
 
                                .appendTo('body')
5062
 
                                .wrap('<div></div>')
5063
 
                                .css({
5064
 
                                        position: 'absolute',
5065
 
                                        visibility: 'visible',
5066
 
                                        left: -j*(width/cells),
5067
 
                                        top: -i*(height/rows)
5068
 
                                })
5069
 
                                .parent()
5070
 
                                .addClass('ui-effects-explode')
5071
 
                                .css({
5072
 
                                        position: 'absolute',
5073
 
                                        overflow: 'hidden',
5074
 
                                        width: width/cells,
5075
 
                                        height: height/rows,
5076
 
                                        left: offset.left + j*(width/cells) + (o.options.mode == 'show' ? (j-Math.floor(cells/2))*(width/cells) : 0),
5077
 
                                        top: offset.top + i*(height/rows) + (o.options.mode == 'show' ? (i-Math.floor(rows/2))*(height/rows) : 0),
5078
 
                                        opacity: o.options.mode == 'show' ? 0 : 1
5079
 
                                }).animate({
5080
 
                                        left: offset.left + j*(width/cells) + (o.options.mode == 'show' ? 0 : (j-Math.floor(cells/2))*(width/cells)),
5081
 
                                        top: offset.top + i*(height/rows) + (o.options.mode == 'show' ? 0 : (i-Math.floor(rows/2))*(height/rows)),
5082
 
                                        opacity: o.options.mode == 'show' ? 1 : 0
5083
 
                                }, o.duration || 500);
5084
 
                }
5085
 
        }
5086
 
 
5087
 
        // Set a timeout, to call the callback approx. when the other animations have finished
5088
 
        setTimeout(function() {
5089
 
 
5090
 
                o.options.mode == 'show' ? el.css({ visibility: 'visible' }) : el.css({ visibility: 'visible' }).hide();
5091
 
                                if(o.callback) o.callback.apply(el[0]); // Callback
5092
 
                                el.dequeue();
5093
 
 
5094
 
                                $('div.ui-effects-explode').remove();
5095
 
 
5096
 
        }, o.duration || 500);
5097
 
 
5098
 
 
5099
 
        });
5100
 
 
5101
 
};
5102
 
 
5103
 
})(jQuery);
5104
 
/*
5105
 
 * jQuery UI Effects Fade 1.8.18
5106
 
 *
5107
 
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
5108
 
 * Dual licensed under the MIT or GPL Version 2 licenses.
5109
 
 * http://jquery.org/license
5110
 
 *
5111
 
 * http://docs.jquery.com/UI/Effects/Fade
5112
 
 *
5113
 
 * Depends:
5114
 
 *      jquery.effects.core.js
5115
 
 */
5116
 
(function( $, undefined ) {
5117
 
 
5118
 
$.effects.fade = function(o) {
5119
 
        return this.queue(function() {
5120
 
                var elem = $(this),
5121
 
                        mode = $.effects.setMode(elem, o.options.mode || 'hide');
5122
 
 
5123
 
                elem.animate({ opacity: mode }, {
5124
 
                        queue: false,
5125
 
                        duration: o.duration,
5126
 
                        easing: o.options.easing,
5127
 
                        complete: function() {
5128
 
                                (o.callback && o.callback.apply(this, arguments));
5129
 
                                elem.dequeue();
5130
 
                        }
5131
 
                });
5132
 
        });
5133
 
};
5134
 
 
5135
 
})(jQuery);
5136
 
/*
5137
 
 * jQuery UI Effects Fold 1.8.18
5138
 
 *
5139
 
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
5140
 
 * Dual licensed under the MIT or GPL Version 2 licenses.
5141
 
 * http://jquery.org/license
5142
 
 *
5143
 
 * http://docs.jquery.com/UI/Effects/Fold
5144
 
 *
5145
 
 * Depends:
5146
 
 *      jquery.effects.core.js
5147
 
 */
5148
 
(function( $, undefined ) {
5149
 
 
5150
 
$.effects.fold = function(o) {
5151
 
 
5152
 
        return this.queue(function() {
5153
 
 
5154
 
                // Create element
5155
 
                var el = $(this), props = ['position','top','bottom','left','right'];
5156
 
 
5157
 
                // Set options
5158
 
                var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode
5159
 
                var size = o.options.size || 15; // Default fold size
5160
 
                var horizFirst = !(!o.options.horizFirst); // Ensure a boolean value
5161
 
                var duration = o.duration ? o.duration / 2 : $.fx.speeds._default / 2;
5162
 
 
5163
 
                // Adjust
5164
 
                $.effects.save(el, props); el.show(); // Save & Show
5165
 
                var wrapper = $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper
5166
 
                var widthFirst = ((mode == 'show') != horizFirst);
5167
 
                var ref = widthFirst ? ['width', 'height'] : ['height', 'width'];
5168
 
                var distance = widthFirst ? [wrapper.width(), wrapper.height()] : [wrapper.height(), wrapper.width()];
5169
 
                var percent = /([0-9]+)%/.exec(size);
5170
 
                if(percent) size = parseInt(percent[1],10) / 100 * distance[mode == 'hide' ? 0 : 1];
5171
 
                if(mode == 'show') wrapper.css(horizFirst ? {height: 0, width: size} : {height: size, width: 0}); // Shift
5172
 
 
5173
 
                // Animation
5174
 
                var animation1 = {}, animation2 = {};
5175
 
                animation1[ref[0]] = mode == 'show' ? distance[0] : size;
5176
 
                animation2[ref[1]] = mode == 'show' ? distance[1] : 0;
5177
 
 
5178
 
                // Animate
5179
 
                wrapper.animate(animation1, duration, o.options.easing)
5180
 
                .animate(animation2, duration, o.options.easing, function() {
5181
 
                        if(mode == 'hide') el.hide(); // Hide
5182
 
                        $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
5183
 
                        if(o.callback) o.callback.apply(el[0], arguments); // Callback
5184
 
                        el.dequeue();
5185
 
                });
5186
 
 
5187
 
        });
5188
 
 
5189
 
};
5190
 
 
5191
 
})(jQuery);
5192
 
/*
5193
 
 * jQuery UI Effects Highlight 1.8.18
5194
 
 *
5195
 
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
5196
 
 * Dual licensed under the MIT or GPL Version 2 licenses.
5197
 
 * http://jquery.org/license
5198
 
 *
5199
 
 * http://docs.jquery.com/UI/Effects/Highlight
5200
 
 *
5201
 
 * Depends:
5202
 
 *      jquery.effects.core.js
5203
 
 */
5204
 
(function( $, undefined ) {
5205
 
 
5206
 
$.effects.highlight = function(o) {
5207
 
        return this.queue(function() {
5208
 
                var elem = $(this),
5209
 
                        props = ['backgroundImage', 'backgroundColor', 'opacity'],
5210
 
                        mode = $.effects.setMode(elem, o.options.mode || 'show'),
5211
 
                        animation = {
5212
 
                                backgroundColor: elem.css('backgroundColor')
5213
 
                        };
5214
 
 
5215
 
                if (mode == 'hide') {
5216
 
                        animation.opacity = 0;
5217
 
                }
5218
 
 
5219
 
                $.effects.save(elem, props);
5220
 
                elem
5221
 
                        .show()
5222
 
                        .css({
5223
 
                                backgroundImage: 'none',
5224
 
                                backgroundColor: o.options.color || '#ffff99'
5225
 
                        })
5226
 
                        .animate(animation, {
5227
 
                                queue: false,
5228
 
                                duration: o.duration,
5229
 
                                easing: o.options.easing,
5230
 
                                complete: function() {
5231
 
                                        (mode == 'hide' && elem.hide());
5232
 
                                        $.effects.restore(elem, props);
5233
 
                                        (mode == 'show' && !$.support.opacity && this.style.removeAttribute('filter'));
5234
 
                                        (o.callback && o.callback.apply(this, arguments));
5235
 
                                        elem.dequeue();
5236
 
                                }
5237
 
                        });
5238
 
        });
5239
 
};
5240
 
 
5241
 
})(jQuery);
5242
 
/*
5243
 
 * jQuery UI Effects Pulsate 1.8.18
5244
 
 *
5245
 
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
5246
 
 * Dual licensed under the MIT or GPL Version 2 licenses.
5247
 
 * http://jquery.org/license
5248
 
 *
5249
 
 * http://docs.jquery.com/UI/Effects/Pulsate
5250
 
 *
5251
 
 * Depends:
5252
 
 *      jquery.effects.core.js
5253
 
 */
5254
 
(function( $, undefined ) {
5255
 
 
5256
 
$.effects.pulsate = function(o) {
5257
 
        return this.queue(function() {
5258
 
                var elem = $(this),
5259
 
                        mode = $.effects.setMode(elem, o.options.mode || 'show');
5260
 
                        times = ((o.options.times || 5) * 2) - 1;
5261
 
                        duration = o.duration ? o.duration / 2 : $.fx.speeds._default / 2,
5262
 
                        isVisible = elem.is(':visible'),
5263
 
                        animateTo = 0;
5264
 
 
5265
 
                if (!isVisible) {
5266
 
                        elem.css('opacity', 0).show();
5267
 
                        animateTo = 1;
5268
 
                }
5269
 
 
5270
 
                if ((mode == 'hide' && isVisible) || (mode == 'show' && !isVisible)) {
5271
 
                        times--;
5272
 
                }
5273
 
 
5274
 
                for (var i = 0; i < times; i++) {
5275
 
                        elem.animate({ opacity: animateTo }, duration, o.options.easing);
5276
 
                        animateTo = (animateTo + 1) % 2;
5277
 
                }
5278
 
 
5279
 
                elem.animate({ opacity: animateTo }, duration, o.options.easing, function() {
5280
 
                        if (animateTo == 0) {
5281
 
                                elem.hide();
5282
 
                        }
5283
 
                        (o.callback && o.callback.apply(this, arguments));
5284
 
                });
5285
 
 
5286
 
                elem
5287
 
                        .queue('fx', function() { elem.dequeue(); })
5288
 
                        .dequeue();
5289
 
        });
5290
 
};
5291
 
 
5292
 
})(jQuery);
5293
 
/*
5294
 
 * jQuery UI Effects Scale 1.8.18
5295
 
 *
5296
 
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
5297
 
 * Dual licensed under the MIT or GPL Version 2 licenses.
5298
 
 * http://jquery.org/license
5299
 
 *
5300
 
 * http://docs.jquery.com/UI/Effects/Scale
5301
 
 *
5302
 
 * Depends:
5303
 
 *      jquery.effects.core.js
5304
 
 */
5305
 
(function( $, undefined ) {
5306
 
 
5307
 
$.effects.puff = function(o) {
5308
 
        return this.queue(function() {
5309
 
                var elem = $(this),
5310
 
                        mode = $.effects.setMode(elem, o.options.mode || 'hide'),
5311
 
                        percent = parseInt(o.options.percent, 10) || 150,
5312
 
                        factor = percent / 100,
5313
 
                        original = { height: elem.height(), width: elem.width() };
5314
 
 
5315
 
                $.extend(o.options, {
5316
 
                        fade: true,
5317
 
                        mode: mode,
5318
 
                        percent: mode == 'hide' ? percent : 100,
5319
 
                        from: mode == 'hide'
5320
 
                                ? original
5321
 
                                : {
5322
 
                                        height: original.height * factor,
5323
 
                                        width: original.width * factor
5324
 
                                }
5325
 
                });
5326
 
 
5327
 
                elem.effect('scale', o.options, o.duration, o.callback);
5328
 
                elem.dequeue();
5329
 
        });
5330
 
};
5331
 
 
5332
 
$.effects.scale = function(o) {
5333
 
 
5334
 
        return this.queue(function() {
5335
 
 
5336
 
                // Create element
5337
 
                var el = $(this);
5338
 
 
5339
 
                // Set options
5340
 
                var options = $.extend(true, {}, o.options);
5341
 
                var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode
5342
 
                var percent = parseInt(o.options.percent,10) || (parseInt(o.options.percent,10) == 0 ? 0 : (mode == 'hide' ? 0 : 100)); // Set default scaling percent
5343
 
                var direction = o.options.direction || 'both'; // Set default axis
5344
 
                var origin = o.options.origin; // The origin of the scaling
5345
 
                if (mode != 'effect') { // Set default origin and restore for show/hide
5346
 
                        options.origin = origin || ['middle','center'];
5347
 
                        options.restore = true;
5348
 
                }
5349
 
                var original = {height: el.height(), width: el.width()}; // Save original
5350
 
                el.from = o.options.from || (mode == 'show' ? {height: 0, width: 0} : original); // Default from state
5351
 
 
5352
 
                // Adjust
5353
 
                var factor = { // Set scaling factor
5354
 
                        y: direction != 'horizontal' ? (percent / 100) : 1,
5355
 
                        x: direction != 'vertical' ? (percent / 100) : 1
5356
 
                };
5357
 
                el.to = {height: original.height * factor.y, width: original.width * factor.x}; // Set to state
5358
 
 
5359
 
                if (o.options.fade) { // Fade option to support puff
5360
 
                        if (mode == 'show') {el.from.opacity = 0; el.to.opacity = 1;};
5361
 
                        if (mode == 'hide') {el.from.opacity = 1; el.to.opacity = 0;};
5362
 
                };
5363
 
 
5364
 
                // Animation
5365
 
                options.from = el.from; options.to = el.to; options.mode = mode;
5366
 
 
5367
 
                // Animate
5368
 
                el.effect('size', options, o.duration, o.callback);
5369
 
                el.dequeue();
5370
 
        });
5371
 
 
5372
 
};
5373
 
 
5374
 
$.effects.size = function(o) {
5375
 
 
5376
 
        return this.queue(function() {
5377
 
 
5378
 
                // Create element
5379
 
                var el = $(this), props = ['position','top','bottom','left','right','width','height','overflow','opacity'];
5380
 
                var props1 = ['position','top','bottom','left','right','overflow','opacity']; // Always restore
5381
 
                var props2 = ['width','height','overflow']; // Copy for children
5382
 
                var cProps = ['fontSize'];
5383
 
                var vProps = ['borderTopWidth', 'borderBottomWidth', 'paddingTop', 'paddingBottom'];
5384
 
                var hProps = ['borderLeftWidth', 'borderRightWidth', 'paddingLeft', 'paddingRight'];
5385
 
 
5386
 
                // Set options
5387
 
                var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode
5388
 
                var restore = o.options.restore || false; // Default restore
5389
 
                var scale = o.options.scale || 'both'; // Default scale mode
5390
 
                var origin = o.options.origin; // The origin of the sizing
5391
 
                var original = {height: el.height(), width: el.width()}; // Save original
5392
 
                el.from = o.options.from || original; // Default from state
5393
 
                el.to = o.options.to || original; // Default to state
5394
 
                // Adjust
5395
 
                if (origin) { // Calculate baseline shifts
5396
 
                        var baseline = $.effects.getBaseline(origin, original);
5397
 
                        el.from.top = (original.height - el.from.height) * baseline.y;
5398
 
                        el.from.left = (original.width - el.from.width) * baseline.x;
5399
 
                        el.to.top = (original.height - el.to.height) * baseline.y;
5400
 
                        el.to.left = (original.width - el.to.width) * baseline.x;
5401
 
                };
5402
 
                var factor = { // Set scaling factor
5403
 
                        from: {y: el.from.height / original.height, x: el.from.width / original.width},
5404
 
                        to: {y: el.to.height / original.height, x: el.to.width / original.width}
5405
 
                };
5406
 
                if (scale == 'box' || scale == 'both') { // Scale the css box
5407
 
                        if (factor.from.y != factor.to.y) { // Vertical props scaling
5408
 
                                props = props.concat(vProps);
5409
 
                                el.from = $.effects.setTransition(el, vProps, factor.from.y, el.from);
5410
 
                                el.to = $.effects.setTransition(el, vProps, factor.to.y, el.to);
5411
 
                        };
5412
 
                        if (factor.from.x != factor.to.x) { // Horizontal props scaling
5413
 
                                props = props.concat(hProps);
5414
 
                                el.from = $.effects.setTransition(el, hProps, factor.from.x, el.from);
5415
 
                                el.to = $.effects.setTransition(el, hProps, factor.to.x, el.to);
5416
 
                        };
5417
 
                };
5418
 
                if (scale == 'content' || scale == 'both') { // Scale the content
5419
 
                        if (factor.from.y != factor.to.y) { // Vertical props scaling
5420
 
                                props = props.concat(cProps);
5421
 
                                el.from = $.effects.setTransition(el, cProps, factor.from.y, el.from);
5422
 
                                el.to = $.effects.setTransition(el, cProps, factor.to.y, el.to);
5423
 
                        };
5424
 
                };
5425
 
                $.effects.save(el, restore ? props : props1); el.show(); // Save & Show
5426
 
                $.effects.createWrapper(el); // Create Wrapper
5427
 
                el.css('overflow','hidden').css(el.from); // Shift
5428
 
 
5429
 
                // Animate
5430
 
                if (scale == 'content' || scale == 'both') { // Scale the children
5431
 
                        vProps = vProps.concat(['marginTop','marginBottom']).concat(cProps); // Add margins/font-size
5432
 
                        hProps = hProps.concat(['marginLeft','marginRight']); // Add margins
5433
 
                        props2 = props.concat(vProps).concat(hProps); // Concat
5434
 
                        el.find("*[width]").each(function(){
5435
 
                                child = $(this);
5436
 
                                if (restore) $.effects.save(child, props2);
5437
 
                                var c_original = {height: child.height(), width: child.width()}; // Save original
5438
 
                                child.from = {height: c_original.height * factor.from.y, width: c_original.width * factor.from.x};
5439
 
                                child.to = {height: c_original.height * factor.to.y, width: c_original.width * factor.to.x};
5440
 
                                if (factor.from.y != factor.to.y) { // Vertical props scaling
5441
 
                                        child.from = $.effects.setTransition(child, vProps, factor.from.y, child.from);
5442
 
                                        child.to = $.effects.setTransition(child, vProps, factor.to.y, child.to);
5443
 
                                };
5444
 
                                if (factor.from.x != factor.to.x) { // Horizontal props scaling
5445
 
                                        child.from = $.effects.setTransition(child, hProps, factor.from.x, child.from);
5446
 
                                        child.to = $.effects.setTransition(child, hProps, factor.to.x, child.to);
5447
 
                                };
5448
 
                                child.css(child.from); // Shift children
5449
 
                                child.animate(child.to, o.duration, o.options.easing, function(){
5450
 
                                        if (restore) $.effects.restore(child, props2); // Restore children
5451
 
                                }); // Animate children
5452
 
                        });
5453
 
                };
5454
 
 
5455
 
                // Animate
5456
 
                el.animate(el.to, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() {
5457
 
                        if (el.to.opacity === 0) {
5458
 
                                el.css('opacity', el.from.opacity);
5459
 
                        }
5460
 
                        if(mode == 'hide') el.hide(); // Hide
5461
 
                        $.effects.restore(el, restore ? props : props1); $.effects.removeWrapper(el); // Restore
5462
 
                        if(o.callback) o.callback.apply(this, arguments); // Callback
5463
 
                        el.dequeue();
5464
 
                }});
5465
 
 
5466
 
        });
5467
 
 
5468
 
};
5469
 
 
5470
 
})(jQuery);
5471
 
/*
5472
 
 * jQuery UI Effects Shake 1.8.18
5473
 
 *
5474
 
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
5475
 
 * Dual licensed under the MIT or GPL Version 2 licenses.
5476
 
 * http://jquery.org/license
5477
 
 *
5478
 
 * http://docs.jquery.com/UI/Effects/Shake
5479
 
 *
5480
 
 * Depends:
5481
 
 *      jquery.effects.core.js
5482
 
 */
5483
 
(function( $, undefined ) {
5484
 
 
5485
 
$.effects.shake = function(o) {
5486
 
 
5487
 
        return this.queue(function() {
5488
 
 
5489
 
                // Create element
5490
 
                var el = $(this), props = ['position','top','bottom','left','right'];
5491
 
 
5492
 
                // Set options
5493
 
                var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode
5494
 
                var direction = o.options.direction || 'left'; // Default direction
5495
 
                var distance = o.options.distance || 20; // Default distance
5496
 
                var times = o.options.times || 3; // Default # of times
5497
 
                var speed = o.duration || o.options.duration || 140; // Default speed per shake
5498
 
 
5499
 
                // Adjust
5500
 
                $.effects.save(el, props); el.show(); // Save & Show
5501
 
                $.effects.createWrapper(el); // Create Wrapper
5502
 
                var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left';
5503
 
                var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg';
5504
 
 
5505
 
                // Animation
5506
 
                var animation = {}, animation1 = {}, animation2 = {};
5507
 
                animation[ref] = (motion == 'pos' ? '-=' : '+=')  + distance;
5508
 
                animation1[ref] = (motion == 'pos' ? '+=' : '-=')  + distance * 2;
5509
 
                animation2[ref] = (motion == 'pos' ? '-=' : '+=')  + distance * 2;
5510
 
 
5511
 
                // Animate
5512
 
                el.animate(animation, speed, o.options.easing);
5513
 
                for (var i = 1; i < times; i++) { // Shakes
5514
 
                        el.animate(animation1, speed, o.options.easing).animate(animation2, speed, o.options.easing);
5515
 
                };
5516
 
                el.animate(animation1, speed, o.options.easing).
5517
 
                animate(animation, speed / 2, o.options.easing, function(){ // Last shake
5518
 
                        $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
5519
 
                        if(o.callback) o.callback.apply(this, arguments); // Callback
5520
 
                });
5521
 
                el.queue('fx', function() { el.dequeue(); });
5522
 
                el.dequeue();
5523
 
        });
5524
 
 
5525
 
};
5526
 
 
5527
 
})(jQuery);
5528
 
/*
5529
 
 * jQuery UI Effects Slide 1.8.18
5530
 
 *
5531
 
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
5532
 
 * Dual licensed under the MIT or GPL Version 2 licenses.
5533
 
 * http://jquery.org/license
5534
 
 *
5535
 
 * http://docs.jquery.com/UI/Effects/Slide
5536
 
 *
5537
 
 * Depends:
5538
 
 *      jquery.effects.core.js
5539
 
 */
5540
 
(function( $, undefined ) {
5541
 
 
5542
 
$.effects.slide = function(o) {
5543
 
 
5544
 
        return this.queue(function() {
5545
 
 
5546
 
                // Create element
5547
 
                var el = $(this), props = ['position','top','bottom','left','right'];
5548
 
 
5549
 
                // Set options
5550
 
                var mode = $.effects.setMode(el, o.options.mode || 'show'); // Set Mode
5551
 
                var direction = o.options.direction || 'left'; // Default Direction
5552
 
 
5553
 
                // Adjust
5554
 
                $.effects.save(el, props); el.show(); // Save & Show
5555
 
                $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper
5556
 
                var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left';
5557
 
                var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg';
5558
 
                var distance = o.options.distance || (ref == 'top' ? el.outerHeight({margin:true}) : el.outerWidth({margin:true}));
5559
 
                if (mode == 'show') el.css(ref, motion == 'pos' ? (isNaN(distance) ? "-" + distance : -distance) : distance); // Shift
5560
 
 
5561
 
                // Animation
5562
 
                var animation = {};
5563
 
                animation[ref] = (mode == 'show' ? (motion == 'pos' ? '+=' : '-=') : (motion == 'pos' ? '-=' : '+=')) + distance;
5564
 
 
5565
 
                // Animate
5566
 
                el.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() {
5567
 
                        if(mode == 'hide') el.hide(); // Hide
5568
 
                        $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
5569
 
                        if(o.callback) o.callback.apply(this, arguments); // Callback
5570
 
                        el.dequeue();
5571
 
                }});
5572
 
 
5573
 
        });
5574
 
 
5575
 
};
5576
 
 
5577
 
})(jQuery);
5578
 
/*
5579
 
 * jQuery UI Effects Transfer 1.8.18
5580
 
 *
5581
 
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
5582
 
 * Dual licensed under the MIT or GPL Version 2 licenses.
5583
 
 * http://jquery.org/license
5584
 
 *
5585
 
 * http://docs.jquery.com/UI/Effects/Transfer
5586
 
 *
5587
 
 * Depends:
5588
 
 *      jquery.effects.core.js
5589
 
 */
5590
 
(function( $, undefined ) {
5591
 
 
5592
 
$.effects.transfer = function(o) {
5593
 
        return this.queue(function() {
5594
 
                var elem = $(this),
5595
 
                        target = $(o.options.to),
5596
 
                        endPosition = target.offset(),
5597
 
                        animation = {
5598
 
                                top: endPosition.top,
5599
 
                                left: endPosition.left,
5600
 
                                height: target.innerHeight(),
5601
 
                                width: target.innerWidth()
5602
 
                        },
5603
 
                        startPosition = elem.offset(),
5604
 
                        transfer = $('<div class="ui-effects-transfer"></div>')
5605
 
                                .appendTo(document.body)
5606
 
                                .addClass(o.options.className)
5607
 
                                .css({
5608
 
                                        top: startPosition.top,
5609
 
                                        left: startPosition.left,
5610
 
                                        height: elem.innerHeight(),
5611
 
                                        width: elem.innerWidth(),
5612
 
                                        position: 'absolute'
5613
 
                                })
5614
 
                                .animate(animation, o.duration, o.options.easing, function() {
5615
 
                                        transfer.remove();
5616
 
                                        (o.callback && o.callback.apply(elem[0], arguments));
5617
 
                                        elem.dequeue();
5618
 
                                });
5619
 
        });
5620
 
};
5621
 
 
5622
 
})(jQuery);
5623
 
/*
5624
 
 * jQuery UI Accordion 1.8.18
5625
 
 *
5626
 
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
5627
 
 * Dual licensed under the MIT or GPL Version 2 licenses.
5628
 
 * http://jquery.org/license
5629
 
 *
5630
 
 * http://docs.jquery.com/UI/Accordion
5631
 
 *
5632
 
 * Depends:
5633
 
 *      jquery.ui.core.js
5634
 
 *      jquery.ui.widget.js
5635
 
 */
5636
 
(function( $, undefined ) {
5637
 
 
5638
 
$.widget( "ui.accordion", {
5639
 
        options: {
5640
 
                active: 0,
5641
 
                animated: "slide",
5642
 
                autoHeight: true,
5643
 
                clearStyle: false,
5644
 
                collapsible: false,
5645
 
                event: "click",
5646
 
                fillSpace: false,
5647
 
                header: "> li > :first-child,> :not(li):even",
5648
 
                icons: {
5649
 
                        header: "ui-icon-triangle-1-e",
5650
 
                        headerSelected: "ui-icon-triangle-1-s"
5651
 
                },
5652
 
                navigation: false,
5653
 
                navigationFilter: function() {
5654
 
                        return this.href.toLowerCase() === location.href.toLowerCase();
5655
 
                }
5656
 
        },
5657
 
 
5658
 
        _create: function() {
5659
 
                var self = this,
5660
 
                        options = self.options;
5661
 
 
5662
 
                self.running = 0;
5663
 
 
5664
 
                self.element
5665
 
                        .addClass( "ui-accordion ui-widget ui-helper-reset" )
5666
 
                        // in lack of child-selectors in CSS
5667
 
                        // we need to mark top-LIs in a UL-accordion for some IE-fix
5668
 
                        .children( "li" )
5669
 
                                .addClass( "ui-accordion-li-fix" );
5670
 
 
5671
 
                self.headers = self.element.find( options.header )
5672
 
                        .addClass( "ui-accordion-header ui-helper-reset ui-state-default ui-corner-all" )
5673
 
                        .bind( "mouseenter.accordion", function() {
5674
 
                                if ( options.disabled ) {
5675
 
                                        return;
5676
 
                                }
5677
 
                                $( this ).addClass( "ui-state-hover" );
5678
 
                        })
5679
 
                        .bind( "mouseleave.accordion", function() {
5680
 
                                if ( options.disabled ) {
5681
 
                                        return;
5682
 
                                }
5683
 
                                $( this ).removeClass( "ui-state-hover" );
5684
 
                        })
5685
 
                        .bind( "focus.accordion", function() {
5686
 
                                if ( options.disabled ) {
5687
 
                                        return;
5688
 
                                }
5689
 
                                $( this ).addClass( "ui-state-focus" );
5690
 
                        })
5691
 
                        .bind( "blur.accordion", function() {
5692
 
                                if ( options.disabled ) {
5693
 
                                        return;
5694
 
                                }
5695
 
                                $( this ).removeClass( "ui-state-focus" );
5696
 
                        });
5697
 
 
5698
 
                self.headers.next()
5699
 
                        .addClass( "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" );
5700
 
 
5701
 
                if ( options.navigation ) {
5702
 
                        var current = self.element.find( "a" ).filter( options.navigationFilter ).eq( 0 );
5703
 
                        if ( current.length ) {
5704
 
                                var header = current.closest( ".ui-accordion-header" );
5705
 
                                if ( header.length ) {
5706
 
                                        // anchor within header
5707
 
                                        self.active = header;
5708
 
                                } else {
5709
 
                                        // anchor within content
5710
 
                                        self.active = current.closest( ".ui-accordion-content" ).prev();
5711
 
                                }
5712
 
                        }
5713
 
                }
5714
 
 
5715
 
                self.active = self._findActive( self.active || options.active )
5716
 
                        .addClass( "ui-state-default ui-state-active" )
5717
 
                        .toggleClass( "ui-corner-all" )
5718
 
                        .toggleClass( "ui-corner-top" );
5719
 
                self.active.next().addClass( "ui-accordion-content-active" );
5720
 
 
5721
 
                self._createIcons();
5722
 
                self.resize();
5723
 
                
5724
 
                // ARIA
5725
 
                self.element.attr( "role", "tablist" );
5726
 
 
5727
 
                self.headers
5728
 
                        .attr( "role", "tab" )
5729
 
                        .bind( "keydown.accordion", function( event ) {
5730
 
                                return self._keydown( event );
5731
 
                        })
5732
 
                        .next()
5733
 
                                .attr( "role", "tabpanel" );
5734
 
 
5735
 
                self.headers
5736
 
                        .not( self.active || "" )
5737
 
                        .attr({
5738
 
                                "aria-expanded": "false",
5739
 
                                "aria-selected": "false",
5740
 
                                tabIndex: -1
5741
 
                        })
5742
 
                        .next()
5743
 
                                .hide();
5744
 
 
5745
 
                // make sure at least one header is in the tab order
5746
 
                if ( !self.active.length ) {
5747
 
                        self.headers.eq( 0 ).attr( "tabIndex", 0 );
5748
 
                } else {
5749
 
                        self.active
5750
 
                                .attr({
5751
 
                                        "aria-expanded": "true",
5752
 
                                        "aria-selected": "true",
5753
 
                                        tabIndex: 0
5754
 
                                });
5755
 
                }
5756
 
 
5757
 
                // only need links in tab order for Safari
5758
 
                if ( !$.browser.safari ) {
5759
 
                        self.headers.find( "a" ).attr( "tabIndex", -1 );
5760
 
                }
5761
 
 
5762
 
                if ( options.event ) {
5763
 
                        self.headers.bind( options.event.split(" ").join(".accordion ") + ".accordion", function(event) {
5764
 
                                self._clickHandler.call( self, event, this );
5765
 
                                event.preventDefault();
5766
 
                        });
5767
 
                }
5768
 
        },
5769
 
 
5770
 
        _createIcons: function() {
5771
 
                var options = this.options;
5772
 
                if ( options.icons ) {
5773
 
                        $( "<span></span>" )
5774
 
                                .addClass( "ui-icon " + options.icons.header )
5775
 
                                .prependTo( this.headers );
5776
 
                        this.active.children( ".ui-icon" )
5777
 
                                .toggleClass(options.icons.header)
5778
 
                                .toggleClass(options.icons.headerSelected);
5779
 
                        this.element.addClass( "ui-accordion-icons" );
5780
 
                }
5781
 
        },
5782
 
 
5783
 
        _destroyIcons: function() {
5784
 
                this.headers.children( ".ui-icon" ).remove();
5785
 
                this.element.removeClass( "ui-accordion-icons" );
5786
 
        },
5787
 
 
5788
 
        destroy: function() {
5789
 
                var options = this.options;
5790
 
 
5791
 
                this.element
5792
 
                        .removeClass( "ui-accordion ui-widget ui-helper-reset" )
5793
 
                        .removeAttr( "role" );
5794
 
 
5795
 
                this.headers
5796
 
                        .unbind( ".accordion" )
5797
 
                        .removeClass( "ui-accordion-header ui-accordion-disabled ui-helper-reset ui-state-default ui-corner-all ui-state-active ui-state-disabled ui-corner-top" )
5798
 
                        .removeAttr( "role" )
5799
 
                        .removeAttr( "aria-expanded" )
5800
 
                        .removeAttr( "aria-selected" )
5801
 
                        .removeAttr( "tabIndex" );
5802
 
 
5803
 
                this.headers.find( "a" ).removeAttr( "tabIndex" );
5804
 
                this._destroyIcons();
5805
 
                var contents = this.headers.next()
5806
 
                        .css( "display", "" )
5807
 
                        .removeAttr( "role" )
5808
 
                        .removeClass( "ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-accordion-disabled ui-state-disabled" );
5809
 
                if ( options.autoHeight || options.fillHeight ) {
5810
 
                        contents.css( "height", "" );
5811
 
                }
5812
 
 
5813
 
                return $.Widget.prototype.destroy.call( this );
5814
 
        },
5815
 
 
5816
 
        _setOption: function( key, value ) {
5817
 
                $.Widget.prototype._setOption.apply( this, arguments );
5818
 
                        
5819
 
                if ( key == "active" ) {
5820
 
                        this.activate( value );
5821
 
                }
5822
 
                if ( key == "icons" ) {
5823
 
                        this._destroyIcons();
5824
 
                        if ( value ) {
5825
 
                                this._createIcons();
5826
 
                        }
5827
 
                }
5828
 
                // #5332 - opacity doesn't cascade to positioned elements in IE
5829
 
                // so we need to add the disabled class to the headers and panels
5830
 
                if ( key == "disabled" ) {
5831
 
                        this.headers.add(this.headers.next())
5832
 
                                [ value ? "addClass" : "removeClass" ](
5833
 
                                        "ui-accordion-disabled ui-state-disabled" );
5834
 
                }
5835
 
        },
5836
 
 
5837
 
        _keydown: function( event ) {
5838
 
                if ( this.options.disabled || event.altKey || event.ctrlKey ) {
5839
 
                        return;
5840
 
                }
5841
 
 
5842
 
                var keyCode = $.ui.keyCode,
5843
 
                        length = this.headers.length,
5844
 
                        currentIndex = this.headers.index( event.target ),
5845
 
                        toFocus = false;
5846
 
 
5847
 
                switch ( event.keyCode ) {
5848
 
                        case keyCode.RIGHT:
5849
 
                        case keyCode.DOWN:
5850
 
                                toFocus = this.headers[ ( currentIndex + 1 ) % length ];
5851
 
                                break;
5852
 
                        case keyCode.LEFT:
5853
 
                        case keyCode.UP:
5854
 
                                toFocus = this.headers[ ( currentIndex - 1 + length ) % length ];
5855
 
                                break;
5856
 
                        case keyCode.SPACE:
5857
 
                        case keyCode.ENTER:
5858
 
                                this._clickHandler( { target: event.target }, event.target );
5859
 
                                event.preventDefault();
5860
 
                }
5861
 
 
5862
 
                if ( toFocus ) {
5863
 
                        $( event.target ).attr( "tabIndex", -1 );
5864
 
                        $( toFocus ).attr( "tabIndex", 0 );
5865
 
                        toFocus.focus();
5866
 
                        return false;
5867
 
                }
5868
 
 
5869
 
                return true;
5870
 
        },
5871
 
 
5872
 
        resize: function() {
5873
 
                var options = this.options,
5874
 
                        maxHeight;
5875
 
 
5876
 
                if ( options.fillSpace ) {
5877
 
                        if ( $.browser.msie ) {
5878
 
                                var defOverflow = this.element.parent().css( "overflow" );
5879
 
                                this.element.parent().css( "overflow", "hidden");
5880
 
                        }
5881
 
                        maxHeight = this.element.parent().height();
5882
 
                        if ($.browser.msie) {
5883
 
                                this.element.parent().css( "overflow", defOverflow );
5884
 
                        }
5885
 
 
5886
 
                        this.headers.each(function() {
5887
 
                                maxHeight -= $( this ).outerHeight( true );
5888
 
                        });
5889
 
 
5890
 
                        this.headers.next()
5891
 
                                .each(function() {
5892
 
                                        $( this ).height( Math.max( 0, maxHeight -
5893
 
                                                $( this ).innerHeight() + $( this ).height() ) );
5894
 
                                })
5895
 
                                .css( "overflow", "auto" );
5896
 
                } else if ( options.autoHeight ) {
5897
 
                        maxHeight = 0;
5898
 
                        this.headers.next()
5899
 
                                .each(function() {
5900
 
                                        maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() );
5901
 
                                })
5902
 
                                .height( maxHeight );
5903
 
                }
5904
 
 
5905
 
                return this;
5906
 
        },
5907
 
 
5908
 
        activate: function( index ) {
5909
 
                // TODO this gets called on init, changing the option without an explicit call for that
5910
 
                this.options.active = index;
5911
 
                // call clickHandler with custom event
5912
 
                var active = this._findActive( index )[ 0 ];
5913
 
                this._clickHandler( { target: active }, active );
5914
 
 
5915
 
                return this;
5916
 
        },
5917
 
 
5918
 
        _findActive: function( selector ) {
5919
 
                return selector
5920
 
                        ? typeof selector === "number"
5921
 
                                ? this.headers.filter( ":eq(" + selector + ")" )
5922
 
                                : this.headers.not( this.headers.not( selector ) )
5923
 
                        : selector === false
5924
 
                                ? $( [] )
5925
 
                                : this.headers.filter( ":eq(0)" );
5926
 
        },
5927
 
 
5928
 
        // TODO isn't event.target enough? why the separate target argument?
5929
 
        _clickHandler: function( event, target ) {
5930
 
                var options = this.options;
5931
 
                if ( options.disabled ) {
5932
 
                        return;
5933
 
                }
5934
 
 
5935
 
                // called only when using activate(false) to close all parts programmatically
5936
 
                if ( !event.target ) {
5937
 
                        if ( !options.collapsible ) {
5938
 
                                return;
5939
 
                        }
5940
 
                        this.active
5941
 
                                .removeClass( "ui-state-active ui-corner-top" )
5942
 
                                .addClass( "ui-state-default ui-corner-all" )
5943
 
                                .children( ".ui-icon" )
5944
 
                                        .removeClass( options.icons.headerSelected )
5945
 
                                        .addClass( options.icons.header );
5946
 
                        this.active.next().addClass( "ui-accordion-content-active" );
5947
 
                        var toHide = this.active.next(),
5948
 
                                data = {
5949
 
                                        options: options,
5950
 
                                        newHeader: $( [] ),
5951
 
                                        oldHeader: options.active,
5952
 
                                        newContent: $( [] ),
5953
 
                                        oldContent: toHide
5954
 
                                },
5955
 
                                toShow = ( this.active = $( [] ) );
5956
 
                        this._toggle( toShow, toHide, data );
5957
 
                        return;
5958
 
                }
5959
 
 
5960
 
                // get the click target
5961
 
                var clicked = $( event.currentTarget || target ),
5962
 
                        clickedIsActive = clicked[0] === this.active[0];
5963
 
 
5964
 
                // TODO the option is changed, is that correct?
5965
 
                // TODO if it is correct, shouldn't that happen after determining that the click is valid?
5966
 
                options.active = options.collapsible && clickedIsActive ?
5967
 
                        false :
5968
 
                        this.headers.index( clicked );
5969
 
 
5970
 
                // if animations are still active, or the active header is the target, ignore click
5971
 
                if ( this.running || ( !options.collapsible && clickedIsActive ) ) {
5972
 
                        return;
5973
 
                }
5974
 
 
5975
 
                // find elements to show and hide
5976
 
                var active = this.active,
5977
 
                        toShow = clicked.next(),
5978
 
                        toHide = this.active.next(),
5979
 
                        data = {
5980
 
                                options: options,
5981
 
                                newHeader: clickedIsActive && options.collapsible ? $([]) : clicked,
5982
 
                                oldHeader: this.active,
5983
 
                                newContent: clickedIsActive && options.collapsible ? $([]) : toShow,
5984
 
                                oldContent: toHide
5985
 
                        },
5986
 
                        down = this.headers.index( this.active[0] ) > this.headers.index( clicked[0] );
5987
 
 
5988
 
                // when the call to ._toggle() comes after the class changes
5989
 
                // it causes a very odd bug in IE 8 (see #6720)
5990
 
                this.active = clickedIsActive ? $([]) : clicked;
5991
 
                this._toggle( toShow, toHide, data, clickedIsActive, down );
5992
 
 
5993
 
                // switch classes
5994
 
                active
5995
 
                        .removeClass( "ui-state-active ui-corner-top" )
5996
 
                        .addClass( "ui-state-default ui-corner-all" )
5997
 
                        .children( ".ui-icon" )
5998
 
                                .removeClass( options.icons.headerSelected )
5999
 
                                .addClass( options.icons.header );
6000
 
                if ( !clickedIsActive ) {
6001
 
                        clicked
6002
 
                                .removeClass( "ui-state-default ui-corner-all" )
6003
 
                                .addClass( "ui-state-active ui-corner-top" )
6004
 
                                .children( ".ui-icon" )
6005
 
                                        .removeClass( options.icons.header )
6006
 
                                        .addClass( options.icons.headerSelected );
6007
 
                        clicked
6008
 
                                .next()
6009
 
                                .addClass( "ui-accordion-content-active" );
6010
 
                }
6011
 
 
6012
 
                return;
6013
 
        },
6014
 
 
6015
 
        _toggle: function( toShow, toHide, data, clickedIsActive, down ) {
6016
 
                var self = this,
6017
 
                        options = self.options;
6018
 
 
6019
 
                self.toShow = toShow;
6020
 
                self.toHide = toHide;
6021
 
                self.data = data;
6022
 
 
6023
 
                var complete = function() {
6024
 
                        if ( !self ) {
6025
 
                                return;
6026
 
                        }
6027
 
                        return self._completed.apply( self, arguments );
6028
 
                };
6029
 
 
6030
 
                // trigger changestart event
6031
 
                self._trigger( "changestart", null, self.data );
6032
 
 
6033
 
                // count elements to animate
6034
 
                self.running = toHide.size() === 0 ? toShow.size() : toHide.size();
6035
 
 
6036
 
                if ( options.animated ) {
6037
 
                        var animOptions = {};
6038
 
 
6039
 
                        if ( options.collapsible && clickedIsActive ) {
6040
 
                                animOptions = {
6041
 
                                        toShow: $( [] ),
6042
 
                                        toHide: toHide,
6043
 
                                        complete: complete,
6044
 
                                        down: down,
6045
 
                                        autoHeight: options.autoHeight || options.fillSpace
6046
 
                                };
6047
 
                        } else {
6048
 
                                animOptions = {
6049
 
                                        toShow: toShow,
6050
 
                                        toHide: toHide,
6051
 
                                        complete: complete,
6052
 
                                        down: down,
6053
 
                                        autoHeight: options.autoHeight || options.fillSpace
6054
 
                                };
6055
 
                        }
6056
 
 
6057
 
                        if ( !options.proxied ) {
6058
 
                                options.proxied = options.animated;
6059
 
                        }
6060
 
 
6061
 
                        if ( !options.proxiedDuration ) {
6062
 
                                options.proxiedDuration = options.duration;
6063
 
                        }
6064
 
 
6065
 
                        options.animated = $.isFunction( options.proxied ) ?
6066
 
                                options.proxied( animOptions ) :
6067
 
                                options.proxied;
6068
 
 
6069
 
                        options.duration = $.isFunction( options.proxiedDuration ) ?
6070
 
                                options.proxiedDuration( animOptions ) :
6071
 
                                options.proxiedDuration;
6072
 
 
6073
 
                        var animations = $.ui.accordion.animations,
6074
 
                                duration = options.duration,
6075
 
                                easing = options.animated;
6076
 
 
6077
 
                        if ( easing && !animations[ easing ] && !$.easing[ easing ] ) {
6078
 
                                easing = "slide";
6079
 
                        }
6080
 
                        if ( !animations[ easing ] ) {
6081
 
                                animations[ easing ] = function( options ) {
6082
 
                                        this.slide( options, {
6083
 
                                                easing: easing,
6084
 
                                                duration: duration || 700
6085
 
                                        });
6086
 
                                };
6087
 
                        }
6088
 
 
6089
 
                        animations[ easing ]( animOptions );
6090
 
                } else {
6091
 
                        if ( options.collapsible && clickedIsActive ) {
6092
 
                                toShow.toggle();
6093
 
                        } else {
6094
 
                                toHide.hide();
6095
 
                                toShow.show();
6096
 
                        }
6097
 
 
6098
 
                        complete( true );
6099
 
                }
6100
 
 
6101
 
                // TODO assert that the blur and focus triggers are really necessary, remove otherwise
6102
 
                toHide.prev()
6103
 
                        .attr({
6104
 
                                "aria-expanded": "false",
6105
 
                                "aria-selected": "false",
6106
 
                                tabIndex: -1
6107
 
                        })
6108
 
                        .blur();
6109
 
                toShow.prev()
6110
 
                        .attr({
6111
 
                                "aria-expanded": "true",
6112
 
                                "aria-selected": "true",
6113
 
                                tabIndex: 0
6114
 
                        })
6115
 
                        .focus();
6116
 
        },
6117
 
 
6118
 
        _completed: function( cancel ) {
6119
 
                this.running = cancel ? 0 : --this.running;
6120
 
                if ( this.running ) {
6121
 
                        return;
6122
 
                }
6123
 
 
6124
 
                if ( this.options.clearStyle ) {
6125
 
                        this.toShow.add( this.toHide ).css({
6126
 
                                height: "",
6127
 
                                overflow: ""
6128
 
                        });
6129
 
                }
6130
 
 
6131
 
                // other classes are removed before the animation; this one needs to stay until completed
6132
 
                this.toHide.removeClass( "ui-accordion-content-active" );
6133
 
                // Work around for rendering bug in IE (#5421)
6134
 
                if ( this.toHide.length ) {
6135
 
                        this.toHide.parent()[0].className = this.toHide.parent()[0].className;
6136
 
                }
6137
 
 
6138
 
                this._trigger( "change", null, this.data );
6139
 
        }
6140
 
});
6141
 
 
6142
 
$.extend( $.ui.accordion, {
6143
 
        version: "1.8.18",
6144
 
        animations: {
6145
 
                slide: function( options, additions ) {
6146
 
                        options = $.extend({
6147
 
                                easing: "swing",
6148
 
                                duration: 300
6149
 
                        }, options, additions );
6150
 
                        if ( !options.toHide.size() ) {
6151
 
                                options.toShow.animate({
6152
 
                                        height: "show",
6153
 
                                        paddingTop: "show",
6154
 
                                        paddingBottom: "show"
6155
 
                                }, options );
6156
 
                                return;
6157
 
                        }
6158
 
                        if ( !options.toShow.size() ) {
6159
 
                                options.toHide.animate({
6160
 
                                        height: "hide",
6161
 
                                        paddingTop: "hide",
6162
 
                                        paddingBottom: "hide"
6163
 
                                }, options );
6164
 
                                return;
6165
 
                        }
6166
 
                        var overflow = options.toShow.css( "overflow" ),
6167
 
                                percentDone = 0,
6168
 
                                showProps = {},
6169
 
                                hideProps = {},
6170
 
                                fxAttrs = [ "height", "paddingTop", "paddingBottom" ],
6171
 
                                originalWidth;
6172
 
                        // fix width before calculating height of hidden element
6173
 
                        var s = options.toShow;
6174
 
                        originalWidth = s[0].style.width;
6175
 
                        s.width( s.parent().width()
6176
 
                                - parseFloat( s.css( "paddingLeft" ) )
6177
 
                                - parseFloat( s.css( "paddingRight" ) )
6178
 
                                - ( parseFloat( s.css( "borderLeftWidth" ) ) || 0 )
6179
 
                                - ( parseFloat( s.css( "borderRightWidth" ) ) || 0 ) );
6180
 
 
6181
 
                        $.each( fxAttrs, function( i, prop ) {
6182
 
                                hideProps[ prop ] = "hide";
6183
 
 
6184
 
                                var parts = ( "" + $.css( options.toShow[0], prop ) ).match( /^([\d+-.]+)(.*)$/ );
6185
 
                                showProps[ prop ] = {
6186
 
                                        value: parts[ 1 ],
6187
 
                                        unit: parts[ 2 ] || "px"
6188
 
                                };
6189
 
                        });
6190
 
                        options.toShow.css({ height: 0, overflow: "hidden" }).show();
6191
 
                        options.toHide
6192
 
                                .filter( ":hidden" )
6193
 
                                        .each( options.complete )
6194
 
                                .end()
6195
 
                                .filter( ":visible" )
6196
 
                                .animate( hideProps, {
6197
 
                                step: function( now, settings ) {
6198
 
                                        // only calculate the percent when animating height
6199
 
                                        // IE gets very inconsistent results when animating elements
6200
 
                                        // with small values, which is common for padding
6201
 
                                        if ( settings.prop == "height" ) {
6202
 
                                                percentDone = ( settings.end - settings.start === 0 ) ? 0 :
6203
 
                                                        ( settings.now - settings.start ) / ( settings.end - settings.start );
6204
 
                                        }
6205
 
 
6206
 
                                        options.toShow[ 0 ].style[ settings.prop ] =
6207
 
                                                ( percentDone * showProps[ settings.prop ].value )
6208
 
                                                + showProps[ settings.prop ].unit;
6209
 
                                },
6210
 
                                duration: options.duration,
6211
 
                                easing: options.easing,
6212
 
                                complete: function() {
6213
 
                                        if ( !options.autoHeight ) {
6214
 
                                                options.toShow.css( "height", "" );
6215
 
                                        }
6216
 
                                        options.toShow.css({
6217
 
                                                width: originalWidth,
6218
 
                                                overflow: overflow
6219
 
                                        });
6220
 
                                        options.complete();
6221
 
                                }
6222
 
                        });
6223
 
                },
6224
 
                bounceslide: function( options ) {
6225
 
                        this.slide( options, {
6226
 
                                easing: options.down ? "easeOutBounce" : "swing",
6227
 
                                duration: options.down ? 1000 : 200
6228
 
                        });
6229
 
                }
6230
 
        }
6231
 
});
6232
 
 
6233
 
})( jQuery );
6234
 
/*
6235
 
 * jQuery UI Autocomplete 1.8.18
6236
 
 *
6237
 
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
6238
 
 * Dual licensed under the MIT or GPL Version 2 licenses.
6239
 
 * http://jquery.org/license
6240
 
 *
6241
 
 * http://docs.jquery.com/UI/Autocomplete
6242
 
 *
6243
 
 * Depends:
6244
 
 *      jquery.ui.core.js
6245
 
 *      jquery.ui.widget.js
6246
 
 *      jquery.ui.position.js
6247
 
 */
6248
 
(function( $, undefined ) {
6249
 
 
6250
 
// used to prevent race conditions with remote data sources
6251
 
var requestIndex = 0;
6252
 
 
6253
 
$.widget( "ui.autocomplete", {
6254
 
        options: {
6255
 
                appendTo: "body",
6256
 
                autoFocus: false,
6257
 
                delay: 300,
6258
 
                minLength: 1,
6259
 
                position: {
6260
 
                        my: "left top",
6261
 
                        at: "left bottom",
6262
 
                        collision: "none"
6263
 
                },
6264
 
                source: null
6265
 
        },
6266
 
 
6267
 
        pending: 0,
6268
 
 
6269
 
        _create: function() {
6270
 
                var self = this,
6271
 
                        doc = this.element[ 0 ].ownerDocument,
6272
 
                        suppressKeyPress;
6273
 
 
6274
 
                this.element
6275
 
                        .addClass( "ui-autocomplete-input" )
6276
 
                        .attr( "autocomplete", "off" )
6277
 
                        // TODO verify these actually work as intended
6278
 
                        .attr({
6279
 
                                role: "textbox",
6280
 
                                "aria-autocomplete": "list",
6281
 
                                "aria-haspopup": "true"
6282
 
                        })
6283
 
                        .bind( "keydown.autocomplete", function( event ) {
6284
 
                                if ( self.options.disabled || self.element.propAttr( "readOnly" ) ) {
6285
 
                                        return;
6286
 
                                }
6287
 
 
6288
 
                                suppressKeyPress = false;
6289
 
                                var keyCode = $.ui.keyCode;
6290
 
                                switch( event.keyCode ) {
6291
 
                                case keyCode.PAGE_UP:
6292
 
                                        self._move( "previousPage", event );
6293
 
                                        break;
6294
 
                                case keyCode.PAGE_DOWN:
6295
 
                                        self._move( "nextPage", event );
6296
 
                                        break;
6297
 
                                case keyCode.UP:
6298
 
                                        self._move( "previous", event );
6299
 
                                        // prevent moving cursor to beginning of text field in some browsers
6300
 
                                        event.preventDefault();
6301
 
                                        break;
6302
 
                                case keyCode.DOWN:
6303
 
                                        self._move( "next", event );
6304
 
                                        // prevent moving cursor to end of text field in some browsers
6305
 
                                        event.preventDefault();
6306
 
                                        break;
6307
 
                                case keyCode.ENTER:
6308
 
                                case keyCode.NUMPAD_ENTER:
6309
 
                                        // when menu is open and has focus
6310
 
                                        if ( self.menu.active ) {
6311
 
                                                // #6055 - Opera still allows the keypress to occur
6312
 
                                                // which causes forms to submit
6313
 
                                                suppressKeyPress = true;
6314
 
                                                event.preventDefault();
6315
 
                                        }
6316
 
                                        //passthrough - ENTER and TAB both select the current element
6317
 
                                case keyCode.TAB:
6318
 
                                        if ( !self.menu.active ) {
6319
 
                                                return;
6320
 
                                        }
6321
 
                                        self.menu.select( event );
6322
 
                                        break;
6323
 
                                case keyCode.ESCAPE:
6324
 
                                        self.element.val( self.term );
6325
 
                                        self.close( event );
6326
 
                                        break;
6327
 
                                default:
6328
 
                                        // keypress is triggered before the input value is changed
6329
 
                                        clearTimeout( self.searching );
6330
 
                                        self.searching = setTimeout(function() {
6331
 
                                                // only search if the value has changed
6332
 
                                                if ( self.term != self.element.val() ) {
6333
 
                                                        self.selectedItem = null;
6334
 
                                                        self.search( null, event );
6335
 
                                                }
6336
 
                                        }, self.options.delay );
6337
 
                                        break;
6338
 
                                }
6339
 
                        })
6340
 
                        .bind( "keypress.autocomplete", function( event ) {
6341
 
                                if ( suppressKeyPress ) {
6342
 
                                        suppressKeyPress = false;
6343
 
                                        event.preventDefault();
6344
 
                                }
6345
 
                        })
6346
 
                        .bind( "focus.autocomplete", function() {
6347
 
                                if ( self.options.disabled ) {
6348
 
                                        return;
6349
 
                                }
6350
 
 
6351
 
                                self.selectedItem = null;
6352
 
                                self.previous = self.element.val();
6353
 
                        })
6354
 
                        .bind( "blur.autocomplete", function( event ) {
6355
 
                                if ( self.options.disabled ) {
6356
 
                                        return;
6357
 
                                }
6358
 
 
6359
 
                                clearTimeout( self.searching );
6360
 
                                // clicks on the menu (or a button to trigger a search) will cause a blur event
6361
 
                                self.closing = setTimeout(function() {
6362
 
                                        self.close( event );
6363
 
                                        self._change( event );
6364
 
                                }, 150 );
6365
 
                        });
6366
 
                this._initSource();
6367
 
                this.response = function() {
6368
 
                        return self._response.apply( self, arguments );
6369
 
                };
6370
 
                this.menu = $( "<ul></ul>" )
6371
 
                        .addClass( "ui-autocomplete" )
6372
 
                        .appendTo( $( this.options.appendTo || "body", doc )[0] )
6373
 
                        // prevent the close-on-blur in case of a "slow" click on the menu (long mousedown)
6374
 
                        .mousedown(function( event ) {
6375
 
                                // clicking on the scrollbar causes focus to shift to the body
6376
 
                                // but we can't detect a mouseup or a click immediately afterward
6377
 
                                // so we have to track the next mousedown and close the menu if
6378
 
                                // the user clicks somewhere outside of the autocomplete
6379
 
                                var menuElement = self.menu.element[ 0 ];
6380
 
                                if ( !$( event.target ).closest( ".ui-menu-item" ).length ) {
6381
 
                                        setTimeout(function() {
6382
 
                                                $( document ).one( 'mousedown', function( event ) {
6383
 
                                                        if ( event.target !== self.element[ 0 ] &&
6384
 
                                                                event.target !== menuElement &&
6385
 
                                                                !$.ui.contains( menuElement, event.target ) ) {
6386
 
                                                                self.close();
6387
 
                                                        }
6388
 
                                                });
6389
 
                                        }, 1 );
6390
 
                                }
6391
 
 
6392
 
                                // use another timeout to make sure the blur-event-handler on the input was already triggered
6393
 
                                setTimeout(function() {
6394
 
                                        clearTimeout( self.closing );
6395
 
                                }, 13);
6396
 
                        })
6397
 
                        .menu({
6398
 
                                focus: function( event, ui ) {
6399
 
                                        var item = ui.item.data( "item.autocomplete" );
6400
 
                                        if ( false !== self._trigger( "focus", event, { item: item } ) ) {
6401
 
                                                // use value to match what will end up in the input, if it was a key event
6402
 
                                                if ( /^key/.test(event.originalEvent.type) ) {
6403
 
                                                        self.element.val( item.value );
6404
 
                                                }
6405
 
                                        }
6406
 
                                },
6407
 
                                selected: function( event, ui ) {
6408
 
                                        var item = ui.item.data( "item.autocomplete" ),
6409
 
                                                previous = self.previous;
6410
 
 
6411
 
                                        // only trigger when focus was lost (click on menu)
6412
 
                                        if ( self.element[0] !== doc.activeElement ) {
6413
 
                                                self.element.focus();
6414
 
                                                self.previous = previous;
6415
 
                                                // #6109 - IE triggers two focus events and the second
6416
 
                                                // is asynchronous, so we need to reset the previous
6417
 
                                                // term synchronously and asynchronously :-(
6418
 
                                                setTimeout(function() {
6419
 
                                                        self.previous = previous;
6420
 
                                                        self.selectedItem = item;
6421
 
                                                }, 1);
6422
 
                                        }
6423
 
 
6424
 
                                        if ( false !== self._trigger( "select", event, { item: item } ) ) {
6425
 
                                                self.element.val( item.value );
6426
 
                                        }
6427
 
                                        // reset the term after the select event
6428
 
                                        // this allows custom select handling to work properly
6429
 
                                        self.term = self.element.val();
6430
 
 
6431
 
                                        self.close( event );
6432
 
                                        self.selectedItem = item;
6433
 
                                },
6434
 
                                blur: function( event, ui ) {
6435
 
                                        // don't set the value of the text field if it's already correct
6436
 
                                        // this prevents moving the cursor unnecessarily
6437
 
                                        if ( self.menu.element.is(":visible") &&
6438
 
                                                ( self.element.val() !== self.term ) ) {
6439
 
                                                self.element.val( self.term );
6440
 
                                        }
6441
 
                                }
6442
 
                        })
6443
 
                        .zIndex( this.element.zIndex() + 1 )
6444
 
                        // workaround for jQuery bug #5781 http://dev.jquery.com/ticket/5781
6445
 
                        .css({ top: 0, left: 0 })
6446
 
                        .hide()
6447
 
                        .data( "menu" );
6448
 
                if ( $.fn.bgiframe ) {
6449
 
                         this.menu.element.bgiframe();
6450
 
                }
6451
 
                // turning off autocomplete prevents the browser from remembering the
6452
 
                // value when navigating through history, so we re-enable autocomplete
6453
 
                // if the page is unloaded before the widget is destroyed. #7790
6454
 
                self.beforeunloadHandler = function() {
6455
 
                        self.element.removeAttr( "autocomplete" );
6456
 
                };
6457
 
                $( window ).bind( "beforeunload", self.beforeunloadHandler );
6458
 
        },
6459
 
 
6460
 
        destroy: function() {
6461
 
                this.element
6462
 
                        .removeClass( "ui-autocomplete-input" )
6463
 
                        .removeAttr( "autocomplete" )
6464
 
                        .removeAttr( "role" )
6465
 
                        .removeAttr( "aria-autocomplete" )
6466
 
                        .removeAttr( "aria-haspopup" );
6467
 
                this.menu.element.remove();
6468
 
                $( window ).unbind( "beforeunload", this.beforeunloadHandler );
6469
 
                $.Widget.prototype.destroy.call( this );
6470
 
        },
6471
 
 
6472
 
        _setOption: function( key, value ) {
6473
 
                $.Widget.prototype._setOption.apply( this, arguments );
6474
 
                if ( key === "source" ) {
6475
 
                        this._initSource();
6476
 
                }
6477
 
                if ( key === "appendTo" ) {
6478
 
                        this.menu.element.appendTo( $( value || "body", this.element[0].ownerDocument )[0] )
6479
 
                }
6480
 
                if ( key === "disabled" && value && this.xhr ) {
6481
 
                        this.xhr.abort();
6482
 
                }
6483
 
        },
6484
 
 
6485
 
        _initSource: function() {
6486
 
                var self = this,
6487
 
                        array,
6488
 
                        url;
6489
 
                if ( $.isArray(this.options.source) ) {
6490
 
                        array = this.options.source;
6491
 
                        this.source = function( request, response ) {
6492
 
                                response( $.ui.autocomplete.filter(array, request.term) );
6493
 
                        };
6494
 
                } else if ( typeof this.options.source === "string" ) {
6495
 
                        url = this.options.source;
6496
 
                        this.source = function( request, response ) {
6497
 
                                if ( self.xhr ) {
6498
 
                                        self.xhr.abort();
6499
 
                                }
6500
 
                                self.xhr = $.ajax({
6501
 
                                        url: url,
6502
 
                                        data: request,
6503
 
                                        dataType: "json",
6504
 
                                        context: {
6505
 
                                                autocompleteRequest: ++requestIndex
6506
 
                                        },
6507
 
                                        success: function( data, status ) {
6508
 
                                                if ( this.autocompleteRequest === requestIndex ) {
6509
 
                                                        response( data );
6510
 
                                                }
6511
 
                                        },
6512
 
                                        error: function() {
6513
 
                                                if ( this.autocompleteRequest === requestIndex ) {
6514
 
                                                        response( [] );
6515
 
                                                }
6516
 
                                        }
6517
 
                                });
6518
 
                        };
6519
 
                } else {
6520
 
                        this.source = this.options.source;
6521
 
                }
6522
 
        },
6523
 
 
6524
 
        search: function( value, event ) {
6525
 
                value = value != null ? value : this.element.val();
6526
 
 
6527
 
                // always save the actual value, not the one passed as an argument
6528
 
                this.term = this.element.val();
6529
 
 
6530
 
                if ( value.length < this.options.minLength ) {
6531
 
                        return this.close( event );
6532
 
                }
6533
 
 
6534
 
                clearTimeout( this.closing );
6535
 
                if ( this._trigger( "search", event ) === false ) {
6536
 
                        return;
6537
 
                }
6538
 
 
6539
 
                return this._search( value );
6540
 
        },
6541
 
 
6542
 
        _search: function( value ) {
6543
 
                this.pending++;
6544
 
                this.element.addClass( "ui-autocomplete-loading" );
6545
 
 
6546
 
                this.source( { term: value }, this.response );
6547
 
        },
6548
 
 
6549
 
        _response: function( content ) {
6550
 
                if ( !this.options.disabled && content && content.length ) {
6551
 
                        content = this._normalize( content );
6552
 
                        this._suggest( content );
6553
 
                        this._trigger( "open" );
6554
 
                } else {
6555
 
                        this.close();
6556
 
                }
6557
 
                this.pending--;
6558
 
                if ( !this.pending ) {
6559
 
                        this.element.removeClass( "ui-autocomplete-loading" );
6560
 
                }
6561
 
        },
6562
 
 
6563
 
        close: function( event ) {
6564
 
                clearTimeout( this.closing );
6565
 
                if ( this.menu.element.is(":visible") ) {
6566
 
                        this.menu.element.hide();
6567
 
                        this.menu.deactivate();
6568
 
                        this._trigger( "close", event );
6569
 
                }
6570
 
        },
6571
 
        
6572
 
        _change: function( event ) {
6573
 
                if ( this.previous !== this.element.val() ) {
6574
 
                        this._trigger( "change", event, { item: this.selectedItem } );
6575
 
                }
6576
 
        },
6577
 
 
6578
 
        _normalize: function( items ) {
6579
 
                // assume all items have the right format when the first item is complete
6580
 
                if ( items.length && items[0].label && items[0].value ) {
6581
 
                        return items;
6582
 
                }
6583
 
                return $.map( items, function(item) {
6584
 
                        if ( typeof item === "string" ) {
6585
 
                                return {
6586
 
                                        label: item,
6587
 
                                        value: item
6588
 
                                };
6589
 
                        }
6590
 
                        return $.extend({
6591
 
                                label: item.label || item.value,
6592
 
                                value: item.value || item.label
6593
 
                        }, item );
6594
 
                });
6595
 
        },
6596
 
 
6597
 
        _suggest: function( items ) {
6598
 
                var ul = this.menu.element
6599
 
                        .empty()
6600
 
                        .zIndex( this.element.zIndex() + 1 );
6601
 
                this._renderMenu( ul, items );
6602
 
                // TODO refresh should check if the active item is still in the dom, removing the need for a manual deactivate
6603
 
                this.menu.deactivate();
6604
 
                this.menu.refresh();
6605
 
 
6606
 
                // size and position menu
6607
 
                ul.show();
6608
 
                this._resizeMenu();
6609
 
                ul.position( $.extend({
6610
 
                        of: this.element
6611
 
                }, this.options.position ));
6612
 
 
6613
 
                if ( this.options.autoFocus ) {
6614
 
                        this.menu.next( new $.Event("mouseover") );
6615
 
                }
6616
 
        },
6617
 
 
6618
 
        _resizeMenu: function() {
6619
 
                var ul = this.menu.element;
6620
 
                ul.outerWidth( Math.max(
6621
 
                        // Firefox wraps long text (possibly a rounding bug)
6622
 
                        // so we add 1px to avoid the wrapping (#7513)
6623
 
                        ul.width( "" ).outerWidth() + 1,
6624
 
                        this.element.outerWidth()
6625
 
                ) );
6626
 
        },
6627
 
 
6628
 
        _renderMenu: function( ul, items ) {
6629
 
                var self = this;
6630
 
                $.each( items, function( index, item ) {
6631
 
                        self._renderItem( ul, item );
6632
 
                });
6633
 
        },
6634
 
 
6635
 
        _renderItem: function( ul, item) {
6636
 
                return $( "<li></li>" )
6637
 
                        .data( "item.autocomplete", item )
6638
 
                        .append( $( "<a></a>" ).text( item.label ) )
6639
 
                        .appendTo( ul );
6640
 
        },
6641
 
 
6642
 
        _move: function( direction, event ) {
6643
 
                if ( !this.menu.element.is(":visible") ) {
6644
 
                        this.search( null, event );
6645
 
                        return;
6646
 
                }
6647
 
                if ( this.menu.first() && /^previous/.test(direction) ||
6648
 
                                this.menu.last() && /^next/.test(direction) ) {
6649
 
                        this.element.val( this.term );
6650
 
                        this.menu.deactivate();
6651
 
                        return;
6652
 
                }
6653
 
                this.menu[ direction ]( event );
6654
 
        },
6655
 
 
6656
 
        widget: function() {
6657
 
                return this.menu.element;
6658
 
        }
6659
 
});
6660
 
 
6661
 
$.extend( $.ui.autocomplete, {
6662
 
        escapeRegex: function( value ) {
6663
 
                return value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
6664
 
        },
6665
 
        filter: function(array, term) {
6666
 
                var matcher = new RegExp( $.ui.autocomplete.escapeRegex(term), "i" );
6667
 
                return $.grep( array, function(value) {
6668
 
                        return matcher.test( value.label || value.value || value );
6669
 
                });
6670
 
        }
6671
 
});
6672
 
 
6673
 
}( jQuery ));
6674
 
 
6675
 
/*
6676
 
 * jQuery UI Menu (not officially released)
6677
 
 * 
6678
 
 * This widget isn't yet finished and the API is subject to change. We plan to finish
6679
 
 * it for the next release. You're welcome to give it a try anyway and give us feedback,
6680
 
 * as long as you're okay with migrating your code later on. We can help with that, too.
6681
 
 *
6682
 
 * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
6683
 
 * Dual licensed under the MIT or GPL Version 2 licenses.
6684
 
 * http://jquery.org/license
6685
 
 *
6686
 
 * http://docs.jquery.com/UI/Menu
6687
 
 *
6688
 
 * Depends:
6689
 
 *      jquery.ui.core.js
6690
 
 *  jquery.ui.widget.js
6691
 
 */
6692
 
(function($) {
6693
 
 
6694
 
$.widget("ui.menu", {
6695
 
        _create: function() {
6696
 
                var self = this;
6697
 
                this.element
6698
 
                        .addClass("ui-menu ui-widget ui-widget-content ui-corner-all")
6699
 
                        .attr({
6700
 
                                role: "listbox",
6701
 
                                "aria-activedescendant": "ui-active-menuitem"
6702
 
                        })
6703
 
                        .click(function( event ) {
6704
 
                                if ( !$( event.target ).closest( ".ui-menu-item a" ).length ) {
6705
 
                                        return;
6706
 
                                }
6707
 
                                // temporary
6708
 
                                event.preventDefault();
6709
 
                                self.select( event );
6710
 
                        });
6711
 
                this.refresh();
6712
 
        },
6713
 
        
6714
 
        refresh: function() {
6715
 
                var self = this;
6716
 
 
6717
 
                // don't refresh list items that are already adapted
6718
 
                var items = this.element.children("li:not(.ui-menu-item):has(a)")
6719
 
                        .addClass("ui-menu-item")
6720
 
                        .attr("role", "menuitem");
6721
 
                
6722
 
                items.children("a")
6723
 
                        .addClass("ui-corner-all")
6724
 
                        .attr("tabindex", -1)
6725
 
                        // mouseenter doesn't work with event delegation
6726
 
                        .mouseenter(function( event ) {
6727
 
                                self.activate( event, $(this).parent() );
6728
 
                        })
6729
 
                        .mouseleave(function() {
6730
 
                                self.deactivate();
6731
 
                        });
6732
 
        },
6733
 
 
6734
 
        activate: function( event, item ) {
6735
 
                this.deactivate();
6736
 
                if (this.hasScroll()) {
6737
 
                        var offset = item.offset().top - this.element.offset().top,
6738
 
                                scroll = this.element.scrollTop(),
6739
 
                                elementHeight = this.element.height();
6740
 
                        if (offset < 0) {
6741
 
                                this.element.scrollTop( scroll + offset);
6742
 
                        } else if (offset >= elementHeight) {
6743
 
                                this.element.scrollTop( scroll + offset - elementHeight + item.height());
6744
 
                        }
6745
 
                }
6746
 
                this.active = item.eq(0)
6747
 
                        .children("a")
6748
 
                                .addClass("ui-state-hover")
6749
 
                                .attr("id", "ui-active-menuitem")
6750
 
                        .end();
6751
 
                this._trigger("focus", event, { item: item });
6752
 
        },
6753
 
 
6754
 
        deactivate: function() {
6755
 
                if (!this.active) { return; }
6756
 
 
6757
 
                this.active.children("a")
6758
 
                        .removeClass("ui-state-hover")
6759
 
                        .removeAttr("id");
6760
 
                this._trigger("blur");
6761
 
                this.active = null;
6762
 
        },
6763
 
 
6764
 
        next: function(event) {
6765
 
                this.move("next", ".ui-menu-item:first", event);
6766
 
        },
6767
 
 
6768
 
        previous: function(event) {
6769
 
                this.move("prev", ".ui-menu-item:last", event);
6770
 
        },
6771
 
 
6772
 
        first: function() {
6773
 
                return this.active && !this.active.prevAll(".ui-menu-item").length;
6774
 
        },
6775
 
 
6776
 
        last: function() {
6777
 
                return this.active && !this.active.nextAll(".ui-menu-item").length;
6778
 
        },
6779
 
 
6780
 
        move: function(direction, edge, event) {
6781
 
                if (!this.active) {
6782
 
                        this.activate(event, this.element.children(edge));
6783
 
                        return;
6784
 
                }
6785
 
                var next = this.active[direction + "All"](".ui-menu-item").eq(0);
6786
 
                if (next.length) {
6787
 
                        this.activate(event, next);
6788
 
                } else {
6789
 
                        this.activate(event, this.element.children(edge));
6790
 
                }
6791
 
        },
6792
 
 
6793
 
        // TODO merge with previousPage
6794
 
        nextPage: function(event) {
6795
 
                if (this.hasScroll()) {
6796
 
                        // TODO merge with no-scroll-else
6797
 
                        if (!this.active || this.last()) {
6798
 
                                this.activate(event, this.element.children(".ui-menu-item:first"));
6799
 
                                return;
6800
 
                        }
6801
 
                        var base = this.active.offset().top,
6802
 
                                height = this.element.height(),
6803
 
                                result = this.element.children(".ui-menu-item").filter(function() {
6804
 
                                        var close = $(this).offset().top - base - height + $(this).height();
6805
 
                                        // TODO improve approximation
6806
 
                                        return close < 10 && close > -10;
6807
 
                                });
6808
 
 
6809
 
                        // TODO try to catch this earlier when scrollTop indicates the last page anyway
6810
 
                        if (!result.length) {
6811
 
                                result = this.element.children(".ui-menu-item:last");
6812
 
                        }
6813
 
                        this.activate(event, result);
6814
 
                } else {
6815
 
                        this.activate(event, this.element.children(".ui-menu-item")
6816
 
                                .filter(!this.active || this.last() ? ":first" : ":last"));
6817
 
                }
6818
 
        },
6819
 
 
6820
 
        // TODO merge with nextPage
6821
 
        previousPage: function(event) {
6822
 
                if (this.hasScroll()) {
6823
 
                        // TODO merge with no-scroll-else
6824
 
                        if (!this.active || this.first()) {
6825
 
                                this.activate(event, this.element.children(".ui-menu-item:last"));
6826
 
                                return;
6827
 
                        }
6828
 
 
6829
 
                        var base = this.active.offset().top,
6830
 
                                height = this.element.height();
6831
 
                                result = this.element.children(".ui-menu-item").filter(function() {
6832
 
                                        var close = $(this).offset().top - base + height - $(this).height();
6833
 
                                        // TODO improve approximation
6834
 
                                        return close < 10 && close > -10;
6835
 
                                });
6836
 
 
6837
 
                        // TODO try to catch this earlier when scrollTop indicates the last page anyway
6838
 
                        if (!result.length) {
6839
 
                                result = this.element.children(".ui-menu-item:first");
6840
 
                        }
6841
 
                        this.activate(event, result);
6842
 
                } else {
6843
 
                        this.activate(event, this.element.children(".ui-menu-item")
6844
 
                                .filter(!this.active || this.first() ? ":last" : ":first"));
6845
 
                }
6846
 
        },
6847
 
 
6848
 
        hasScroll: function() {
6849
 
                return this.element.height() < this.element[ $.fn.prop ? "prop" : "attr" ]("scrollHeight");
6850
 
        },
6851
 
 
6852
 
        select: function( event ) {
6853
 
                this._trigger("selected", event, { item: this.active });
6854
 
        }
6855
 
});
6856
 
 
6857
 
}(jQuery));
6858
 
/*
6859
 
 * jQuery UI Button 1.8.18
6860
 
 *
6861
 
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
6862
 
 * Dual licensed under the MIT or GPL Version 2 licenses.
6863
 
 * http://jquery.org/license
6864
 
 *
6865
 
 * http://docs.jquery.com/UI/Button
6866
 
 *
6867
 
 * Depends:
6868
 
 *      jquery.ui.core.js
6869
 
 *      jquery.ui.widget.js
6870
 
 */
6871
 
(function( $, undefined ) {
6872
 
 
6873
 
var lastActive, startXPos, startYPos, clickDragged,
6874
 
        baseClasses = "ui-button ui-widget ui-state-default ui-corner-all",
6875
 
        stateClasses = "ui-state-hover ui-state-active ",
6876
 
        typeClasses = "ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary ui-button-text-only",
6877
 
        formResetHandler = function() {
6878
 
                var buttons = $( this ).find( ":ui-button" );
6879
 
                setTimeout(function() {
6880
 
                        buttons.button( "refresh" );
6881
 
                }, 1 );
6882
 
        },
6883
 
        radioGroup = function( radio ) {
6884
 
                var name = radio.name,
6885
 
                        form = radio.form,
6886
 
                        radios = $( [] );
6887
 
                if ( name ) {
6888
 
                        if ( form ) {
6889
 
                                radios = $( form ).find( "[name='" + name + "']" );
6890
 
                        } else {
6891
 
                                radios = $( "[name='" + name + "']", radio.ownerDocument )
6892
 
                                        .filter(function() {
6893
 
                                                return !this.form;
6894
 
                                        });
6895
 
                        }
6896
 
                }
6897
 
                return radios;
6898
 
        };
6899
 
 
6900
 
$.widget( "ui.button", {
6901
 
        options: {
6902
 
                disabled: null,
6903
 
                text: true,
6904
 
                label: null,
6905
 
                icons: {
6906
 
                        primary: null,
6907
 
                        secondary: null
6908
 
                }
6909
 
        },
6910
 
        _create: function() {
6911
 
                this.element.closest( "form" )
6912
 
                        .unbind( "reset.button" )
6913
 
                        .bind( "reset.button", formResetHandler );
6914
 
 
6915
 
                if ( typeof this.options.disabled !== "boolean" ) {
6916
 
                        this.options.disabled = !!this.element.propAttr( "disabled" );
6917
 
                } else {
6918
 
                        this.element.propAttr( "disabled", this.options.disabled );
6919
 
                }
6920
 
 
6921
 
                this._determineButtonType();
6922
 
                this.hasTitle = !!this.buttonElement.attr( "title" );
6923
 
 
6924
 
                var self = this,
6925
 
                        options = this.options,
6926
 
                        toggleButton = this.type === "checkbox" || this.type === "radio",
6927
 
                        hoverClass = "ui-state-hover" + ( !toggleButton ? " ui-state-active" : "" ),
6928
 
                        focusClass = "ui-state-focus";
6929
 
 
6930
 
                if ( options.label === null ) {
6931
 
                        options.label = this.buttonElement.html();
6932
 
                }
6933
 
 
6934
 
                this.buttonElement
6935
 
                        .addClass( baseClasses )
6936
 
                        .attr( "role", "button" )
6937
 
                        .bind( "mouseenter.button", function() {
6938
 
                                if ( options.disabled ) {
6939
 
                                        return;
6940
 
                                }
6941
 
                                $( this ).addClass( "ui-state-hover" );
6942
 
                                if ( this === lastActive ) {
6943
 
                                        $( this ).addClass( "ui-state-active" );
6944
 
                                }
6945
 
                        })
6946
 
                        .bind( "mouseleave.button", function() {
6947
 
                                if ( options.disabled ) {
6948
 
                                        return;
6949
 
                                }
6950
 
                                $( this ).removeClass( hoverClass );
6951
 
                        })
6952
 
                        .bind( "click.button", function( event ) {
6953
 
                                if ( options.disabled ) {
6954
 
                                        event.preventDefault();
6955
 
                                        event.stopImmediatePropagation();
6956
 
                                }
6957
 
                        });
6958
 
 
6959
 
                this.element
6960
 
                        .bind( "focus.button", function() {
6961
 
                                // no need to check disabled, focus won't be triggered anyway
6962
 
                                self.buttonElement.addClass( focusClass );
6963
 
                        })
6964
 
                        .bind( "blur.button", function() {
6965
 
                                self.buttonElement.removeClass( focusClass );
6966
 
                        });
6967
 
 
6968
 
                if ( toggleButton ) {
6969
 
                        this.element.bind( "change.button", function() {
6970
 
                                if ( clickDragged ) {
6971
 
                                        return;
6972
 
                                }
6973
 
                                self.refresh();
6974
 
                        });
6975
 
                        // if mouse moves between mousedown and mouseup (drag) set clickDragged flag
6976
 
                        // prevents issue where button state changes but checkbox/radio checked state
6977
 
                        // does not in Firefox (see ticket #6970)
6978
 
                        this.buttonElement
6979
 
                                .bind( "mousedown.button", function( event ) {
6980
 
                                        if ( options.disabled ) {
6981
 
                                                return;
6982
 
                                        }
6983
 
                                        clickDragged = false;
6984
 
                                        startXPos = event.pageX;
6985
 
                                        startYPos = event.pageY;
6986
 
                                })
6987
 
                                .bind( "mouseup.button", function( event ) {
6988
 
                                        if ( options.disabled ) {
6989
 
                                                return;
6990
 
                                        }
6991
 
                                        if ( startXPos !== event.pageX || startYPos !== event.pageY ) {
6992
 
                                                clickDragged = true;
6993
 
                                        }
6994
 
                        });
6995
 
                }
6996
 
 
6997
 
                if ( this.type === "checkbox" ) {
6998
 
                        this.buttonElement.bind( "click.button", function() {
6999
 
                                if ( options.disabled || clickDragged ) {
7000
 
                                        return false;
7001
 
                                }
7002
 
                                $( this ).toggleClass( "ui-state-active" );
7003
 
                                self.buttonElement.attr( "aria-pressed", self.element[0].checked );
7004
 
                        });
7005
 
                } else if ( this.type === "radio" ) {
7006
 
                        this.buttonElement.bind( "click.button", function() {
7007
 
                                if ( options.disabled || clickDragged ) {
7008
 
                                        return false;
7009
 
                                }
7010
 
                                $( this ).addClass( "ui-state-active" );
7011
 
                                self.buttonElement.attr( "aria-pressed", "true" );
7012
 
 
7013
 
                                var radio = self.element[ 0 ];
7014
 
                                radioGroup( radio )
7015
 
                                        .not( radio )
7016
 
                                        .map(function() {
7017
 
                                                return $( this ).button( "widget" )[ 0 ];
7018
 
                                        })
7019
 
                                        .removeClass( "ui-state-active" )
7020
 
                                        .attr( "aria-pressed", "false" );
7021
 
                        });
7022
 
                } else {
7023
 
                        this.buttonElement
7024
 
                                .bind( "mousedown.button", function() {
7025
 
                                        if ( options.disabled ) {
7026
 
                                                return false;
7027
 
                                        }
7028
 
                                        $( this ).addClass( "ui-state-active" );
7029
 
                                        lastActive = this;
7030
 
                                        $( document ).one( "mouseup", function() {
7031
 
                                                lastActive = null;
7032
 
                                        });
7033
 
                                })
7034
 
                                .bind( "mouseup.button", function() {
7035
 
                                        if ( options.disabled ) {
7036
 
                                                return false;
7037
 
                                        }
7038
 
                                        $( this ).removeClass( "ui-state-active" );
7039
 
                                })
7040
 
                                .bind( "keydown.button", function(event) {
7041
 
                                        if ( options.disabled ) {
7042
 
                                                return false;
7043
 
                                        }
7044
 
                                        if ( event.keyCode == $.ui.keyCode.SPACE || event.keyCode == $.ui.keyCode.ENTER ) {
7045
 
                                                $( this ).addClass( "ui-state-active" );
7046
 
                                        }
7047
 
                                })
7048
 
                                .bind( "keyup.button", function() {
7049
 
                                        $( this ).removeClass( "ui-state-active" );
7050
 
                                });
7051
 
 
7052
 
                        if ( this.buttonElement.is("a") ) {
7053
 
                                this.buttonElement.keyup(function(event) {
7054
 
                                        if ( event.keyCode === $.ui.keyCode.SPACE ) {
7055
 
                                                // TODO pass through original event correctly (just as 2nd argument doesn't work)
7056
 
                                                $( this ).click();
7057
 
                                        }
7058
 
                                });
7059
 
                        }
7060
 
                }
7061
 
 
7062
 
                // TODO: pull out $.Widget's handling for the disabled option into
7063
 
                // $.Widget.prototype._setOptionDisabled so it's easy to proxy and can
7064
 
                // be overridden by individual plugins
7065
 
                this._setOption( "disabled", options.disabled );
7066
 
                this._resetButton();
7067
 
        },
7068
 
 
7069
 
        _determineButtonType: function() {
7070
 
 
7071
 
                if ( this.element.is(":checkbox") ) {
7072
 
                        this.type = "checkbox";
7073
 
                } else if ( this.element.is(":radio") ) {
7074
 
                        this.type = "radio";
7075
 
                } else if ( this.element.is("input") ) {
7076
 
                        this.type = "input";
7077
 
                } else {
7078
 
                        this.type = "button";
7079
 
                }
7080
 
 
7081
 
                if ( this.type === "checkbox" || this.type === "radio" ) {
7082
 
                        // we don't search against the document in case the element
7083
 
                        // is disconnected from the DOM
7084
 
                        var ancestor = this.element.parents().filter(":last"),
7085
 
                                labelSelector = "label[for='" + this.element.attr("id") + "']";
7086
 
                        this.buttonElement = ancestor.find( labelSelector );
7087
 
                        if ( !this.buttonElement.length ) {
7088
 
                                ancestor = ancestor.length ? ancestor.siblings() : this.element.siblings();
7089
 
                                this.buttonElement = ancestor.filter( labelSelector );
7090
 
                                if ( !this.buttonElement.length ) {
7091
 
                                        this.buttonElement = ancestor.find( labelSelector );
7092
 
                                }
7093
 
                        }
7094
 
                        this.element.addClass( "ui-helper-hidden-accessible" );
7095
 
 
7096
 
                        var checked = this.element.is( ":checked" );
7097
 
                        if ( checked ) {
7098
 
                                this.buttonElement.addClass( "ui-state-active" );
7099
 
                        }
7100
 
                        this.buttonElement.attr( "aria-pressed", checked );
7101
 
                } else {
7102
 
                        this.buttonElement = this.element;
7103
 
                }
7104
 
        },
7105
 
 
7106
 
        widget: function() {
7107
 
                return this.buttonElement;
7108
 
        },
7109
 
 
7110
 
        destroy: function() {
7111
 
                this.element
7112
 
                        .removeClass( "ui-helper-hidden-accessible" );
7113
 
                this.buttonElement
7114
 
                        .removeClass( baseClasses + " " + stateClasses + " " + typeClasses )
7115
 
                        .removeAttr( "role" )
7116
 
                        .removeAttr( "aria-pressed" )
7117
 
                        .html( this.buttonElement.find(".ui-button-text").html() );
7118
 
 
7119
 
                if ( !this.hasTitle ) {
7120
 
                        this.buttonElement.removeAttr( "title" );
7121
 
                }
7122
 
 
7123
 
                $.Widget.prototype.destroy.call( this );
7124
 
        },
7125
 
 
7126
 
        _setOption: function( key, value ) {
7127
 
                $.Widget.prototype._setOption.apply( this, arguments );
7128
 
                if ( key === "disabled" ) {
7129
 
                        if ( value ) {
7130
 
                                this.element.propAttr( "disabled", true );
7131
 
                        } else {
7132
 
                                this.element.propAttr( "disabled", false );
7133
 
                        }
7134
 
                        return;
7135
 
                }
7136
 
                this._resetButton();
7137
 
        },
7138
 
 
7139
 
        refresh: function() {
7140
 
                var isDisabled = this.element.is( ":disabled" );
7141
 
                if ( isDisabled !== this.options.disabled ) {
7142
 
                        this._setOption( "disabled", isDisabled );
7143
 
                }
7144
 
                if ( this.type === "radio" ) {
7145
 
                        radioGroup( this.element[0] ).each(function() {
7146
 
                                if ( $( this ).is( ":checked" ) ) {
7147
 
                                        $( this ).button( "widget" )
7148
 
                                                .addClass( "ui-state-active" )
7149
 
                                                .attr( "aria-pressed", "true" );
7150
 
                                } else {
7151
 
                                        $( this ).button( "widget" )
7152
 
                                                .removeClass( "ui-state-active" )
7153
 
                                                .attr( "aria-pressed", "false" );
7154
 
                                }
7155
 
                        });
7156
 
                } else if ( this.type === "checkbox" ) {
7157
 
                        if ( this.element.is( ":checked" ) ) {
7158
 
                                this.buttonElement
7159
 
                                        .addClass( "ui-state-active" )
7160
 
                                        .attr( "aria-pressed", "true" );
7161
 
                        } else {
7162
 
                                this.buttonElement
7163
 
                                        .removeClass( "ui-state-active" )
7164
 
                                        .attr( "aria-pressed", "false" );
7165
 
                        }
7166
 
                }
7167
 
        },
7168
 
 
7169
 
        _resetButton: function() {
7170
 
                if ( this.type === "input" ) {
7171
 
                        if ( this.options.label ) {
7172
 
                                this.element.val( this.options.label );
7173
 
                        }
7174
 
                        return;
7175
 
                }
7176
 
                var buttonElement = this.buttonElement.removeClass( typeClasses ),
7177
 
                        buttonText = $( "<span></span>", this.element[0].ownerDocument )
7178
 
                                .addClass( "ui-button-text" )
7179
 
                                .html( this.options.label )
7180
 
                                .appendTo( buttonElement.empty() )
7181
 
                                .text(),
7182
 
                        icons = this.options.icons,
7183
 
                        multipleIcons = icons.primary && icons.secondary,
7184
 
                        buttonClasses = [];  
7185
 
 
7186
 
                if ( icons.primary || icons.secondary ) {
7187
 
                        if ( this.options.text ) {
7188
 
                                buttonClasses.push( "ui-button-text-icon" + ( multipleIcons ? "s" : ( icons.primary ? "-primary" : "-secondary" ) ) );
7189
 
                        }
7190
 
 
7191
 
                        if ( icons.primary ) {
7192
 
                                buttonElement.prepend( "<span class='ui-button-icon-primary ui-icon " + icons.primary + "'></span>" );
7193
 
                        }
7194
 
 
7195
 
                        if ( icons.secondary ) {
7196
 
                                buttonElement.append( "<span class='ui-button-icon-secondary ui-icon " + icons.secondary + "'></span>" );
7197
 
                        }
7198
 
 
7199
 
                        if ( !this.options.text ) {
7200
 
                                buttonClasses.push( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" );
7201
 
 
7202
 
                                if ( !this.hasTitle ) {
7203
 
                                        buttonElement.attr( "title", buttonText );
7204
 
                                }
7205
 
                        }
7206
 
                } else {
7207
 
                        buttonClasses.push( "ui-button-text-only" );
7208
 
                }
7209
 
                buttonElement.addClass( buttonClasses.join( " " ) );
7210
 
        }
7211
 
});
7212
 
 
7213
 
$.widget( "ui.buttonset", {
7214
 
        options: {
7215
 
                items: ":button, :submit, :reset, :checkbox, :radio, a, :data(button)"
7216
 
        },
7217
 
 
7218
 
        _create: function() {
7219
 
                this.element.addClass( "ui-buttonset" );
7220
 
        },
7221
 
        
7222
 
        _init: function() {
7223
 
                this.refresh();
7224
 
        },
7225
 
 
7226
 
        _setOption: function( key, value ) {
7227
 
                if ( key === "disabled" ) {
7228
 
                        this.buttons.button( "option", key, value );
7229
 
                }
7230
 
 
7231
 
                $.Widget.prototype._setOption.apply( this, arguments );
7232
 
        },
7233
 
        
7234
 
        refresh: function() {
7235
 
                var rtl = this.element.css( "direction" ) === "rtl";
7236
 
                
7237
 
                this.buttons = this.element.find( this.options.items )
7238
 
                        .filter( ":ui-button" )
7239
 
                                .button( "refresh" )
7240
 
                        .end()
7241
 
                        .not( ":ui-button" )
7242
 
                                .button()
7243
 
                        .end()
7244
 
                        .map(function() {
7245
 
                                return $( this ).button( "widget" )[ 0 ];
7246
 
                        })
7247
 
                                .removeClass( "ui-corner-all ui-corner-left ui-corner-right" )
7248
 
                                .filter( ":first" )
7249
 
                                        .addClass( rtl ? "ui-corner-right" : "ui-corner-left" )
7250
 
                                .end()
7251
 
                                .filter( ":last" )
7252
 
                                        .addClass( rtl ? "ui-corner-left" : "ui-corner-right" )
7253
 
                                .end()
7254
 
                        .end();
7255
 
        },
7256
 
 
7257
 
        destroy: function() {
7258
 
                this.element.removeClass( "ui-buttonset" );
7259
 
                this.buttons
7260
 
                        .map(function() {
7261
 
                                return $( this ).button( "widget" )[ 0 ];
7262
 
                        })
7263
 
                                .removeClass( "ui-corner-left ui-corner-right" )
7264
 
                        .end()
7265
 
                        .button( "destroy" );
7266
 
 
7267
 
                $.Widget.prototype.destroy.call( this );
7268
 
        }
7269
 
});
7270
 
 
7271
 
}( jQuery ) );
7272
 
/*
7273
 
 * jQuery UI Datepicker 1.8.18
7274
 
 *
7275
 
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
7276
 
 * Dual licensed under the MIT or GPL Version 2 licenses.
7277
 
 * http://jquery.org/license
7278
 
 *
7279
 
 * http://docs.jquery.com/UI/Datepicker
7280
 
 *
7281
 
 * Depends:
7282
 
 *      jquery.ui.core.js
7283
 
 */
7284
 
(function( $, undefined ) {
7285
 
 
7286
 
$.extend($.ui, { datepicker: { version: "1.8.18" } });
7287
 
 
7288
 
var PROP_NAME = 'datepicker';
7289
 
var dpuuid = new Date().getTime();
7290
 
var instActive;
7291
 
 
7292
 
/* Date picker manager.
7293
 
   Use the singleton instance of this class, $.datepicker, to interact with the date picker.
7294
 
   Settings for (groups of) date pickers are maintained in an instance object,
7295
 
   allowing multiple different settings on the same page. */
7296
 
 
7297
 
function Datepicker() {
7298
 
        this.debug = false; // Change this to true to start debugging
7299
 
        this._curInst = null; // The current instance in use
7300
 
        this._keyEvent = false; // If the last event was a key event
7301
 
        this._disabledInputs = []; // List of date picker inputs that have been disabled
7302
 
        this._datepickerShowing = false; // True if the popup picker is showing , false if not
7303
 
        this._inDialog = false; // True if showing within a "dialog", false if not
7304
 
        this._mainDivId = 'ui-datepicker-div'; // The ID of the main datepicker division
7305
 
        this._inlineClass = 'ui-datepicker-inline'; // The name of the inline marker class
7306
 
        this._appendClass = 'ui-datepicker-append'; // The name of the append marker class
7307
 
        this._triggerClass = 'ui-datepicker-trigger'; // The name of the trigger marker class
7308
 
        this._dialogClass = 'ui-datepicker-dialog'; // The name of the dialog marker class
7309
 
        this._disableClass = 'ui-datepicker-disabled'; // The name of the disabled covering marker class
7310
 
        this._unselectableClass = 'ui-datepicker-unselectable'; // The name of the unselectable cell marker class
7311
 
        this._currentClass = 'ui-datepicker-current-day'; // The name of the current day marker class
7312
 
        this._dayOverClass = 'ui-datepicker-days-cell-over'; // The name of the day hover marker class
7313
 
        this.regional = []; // Available regional settings, indexed by language code
7314
 
        this.regional[''] = { // Default regional settings
7315
 
                closeText: 'Done', // Display text for close link
7316
 
                prevText: 'Prev', // Display text for previous month link
7317
 
                nextText: 'Next', // Display text for next month link
7318
 
                currentText: 'Today', // Display text for current month link
7319
 
                monthNames: ['January','February','March','April','May','June',
7320
 
                        'July','August','September','October','November','December'], // Names of months for drop-down and formatting
7321
 
                monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], // For formatting
7322
 
                dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], // For formatting
7323
 
                dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], // For formatting
7324
 
                dayNamesMin: ['Su','Mo','Tu','We','Th','Fr','Sa'], // Column headings for days starting at Sunday
7325
 
                weekHeader: 'Wk', // Column header for week of the year
7326
 
                dateFormat: 'mm/dd/yy', // See format options on parseDate
7327
 
                firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
7328
 
                isRTL: false, // True if right-to-left language, false if left-to-right
7329
 
                showMonthAfterYear: false, // True if the year select precedes month, false for month then year
7330
 
                yearSuffix: '' // Additional text to append to the year in the month headers
7331
 
        };
7332
 
        this._defaults = { // Global defaults for all the date picker instances
7333
 
                showOn: 'focus', // 'focus' for popup on focus,
7334
 
                        // 'button' for trigger button, or 'both' for either
7335
 
                showAnim: 'fadeIn', // Name of jQuery animation for popup
7336
 
                showOptions: {}, // Options for enhanced animations
7337
 
                defaultDate: null, // Used when field is blank: actual date,
7338
 
                        // +/-number for offset from today, null for today
7339
 
                appendText: '', // Display text following the input box, e.g. showing the format
7340
 
                buttonText: '...', // Text for trigger button
7341
 
                buttonImage: '', // URL for trigger button image
7342
 
                buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
7343
 
                hideIfNoPrevNext: false, // True to hide next/previous month links
7344
 
                        // if not applicable, false to just disable them
7345
 
                navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
7346
 
                gotoCurrent: false, // True if today link goes back to current selection instead
7347
 
                changeMonth: false, // True if month can be selected directly, false if only prev/next
7348
 
                changeYear: false, // True if year can be selected directly, false if only prev/next
7349
 
                yearRange: 'c-10:c+10', // Range of years to display in drop-down,
7350
 
                        // either relative to today's year (-nn:+nn), relative to currently displayed year
7351
 
                        // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
7352
 
                showOtherMonths: false, // True to show dates in other months, false to leave blank
7353
 
                selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable
7354
 
                showWeek: false, // True to show week of the year, false to not show it
7355
 
                calculateWeek: this.iso8601Week, // How to calculate the week of the year,
7356
 
                        // takes a Date and returns the number of the week for it
7357
 
                shortYearCutoff: '+10', // Short year values < this are in the current century,
7358
 
                        // > this are in the previous century,
7359
 
                        // string value starting with '+' for current year + value
7360
 
                minDate: null, // The earliest selectable date, or null for no limit
7361
 
                maxDate: null, // The latest selectable date, or null for no limit
7362
 
                duration: 'fast', // Duration of display/closure
7363
 
                beforeShowDay: null, // Function that takes a date and returns an array with
7364
 
                        // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or '',
7365
 
                        // [2] = cell title (optional), e.g. $.datepicker.noWeekends
7366
 
                beforeShow: null, // Function that takes an input field and
7367
 
                        // returns a set of custom settings for the date picker
7368
 
                onSelect: null, // Define a callback function when a date is selected
7369
 
                onChangeMonthYear: null, // Define a callback function when the month or year is changed
7370
 
                onClose: null, // Define a callback function when the datepicker is closed
7371
 
                numberOfMonths: 1, // Number of months to show at a time
7372
 
                showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
7373
 
                stepMonths: 1, // Number of months to step back/forward
7374
 
                stepBigMonths: 12, // Number of months to step back/forward for the big links
7375
 
                altField: '', // Selector for an alternate field to store selected dates into
7376
 
                altFormat: '', // The date format to use for the alternate field
7377
 
                constrainInput: true, // The input is constrained by the current date format
7378
 
                showButtonPanel: false, // True to show button panel, false to not show it
7379
 
                autoSize: false, // True to size the input for the date format, false to leave as is
7380
 
                disabled: false // The initial disabled state
7381
 
        };
7382
 
        $.extend(this._defaults, this.regional['']);
7383
 
        this.dpDiv = bindHover($('<div id="' + this._mainDivId + '" class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>'));
7384
 
}
7385
 
 
7386
 
$.extend(Datepicker.prototype, {
7387
 
        /* Class name added to elements to indicate already configured with a date picker. */
7388
 
        markerClassName: 'hasDatepicker',
7389
 
        
7390
 
        //Keep track of the maximum number of rows displayed (see #7043)
7391
 
        maxRows: 4,
7392
 
 
7393
 
        /* Debug logging (if enabled). */
7394
 
        log: function () {
7395
 
                if (this.debug)
7396
 
                        console.log.apply('', arguments);
7397
 
        },
7398
 
        
7399
 
        // TODO rename to "widget" when switching to widget factory
7400
 
        _widgetDatepicker: function() {
7401
 
                return this.dpDiv;
7402
 
        },
7403
 
 
7404
 
        /* Override the default settings for all instances of the date picker.
7405
 
           @param  settings  object - the new settings to use as defaults (anonymous object)
7406
 
           @return the manager object */
7407
 
        setDefaults: function(settings) {
7408
 
                extendRemove(this._defaults, settings || {});
7409
 
                return this;
7410
 
        },
7411
 
 
7412
 
        /* Attach the date picker to a jQuery selection.
7413
 
           @param  target    element - the target input field or division or span
7414
 
           @param  settings  object - the new settings to use for this date picker instance (anonymous) */
7415
 
        _attachDatepicker: function(target, settings) {
7416
 
                // check for settings on the control itself - in namespace 'date:'
7417
 
                var inlineSettings = null;
7418
 
                for (var attrName in this._defaults) {
7419
 
                        var attrValue = target.getAttribute('date:' + attrName);
7420
 
                        if (attrValue) {
7421
 
                                inlineSettings = inlineSettings || {};
7422
 
                                try {
7423
 
                                        inlineSettings[attrName] = eval(attrValue);
7424
 
                                } catch (err) {
7425
 
                                        inlineSettings[attrName] = attrValue;
7426
 
                                }
7427
 
                        }
7428
 
                }
7429
 
                var nodeName = target.nodeName.toLowerCase();
7430
 
                var inline = (nodeName == 'div' || nodeName == 'span');
7431
 
                if (!target.id) {
7432
 
                        this.uuid += 1;
7433
 
                        target.id = 'dp' + this.uuid;
7434
 
                }
7435
 
                var inst = this._newInst($(target), inline);
7436
 
                inst.settings = $.extend({}, settings || {}, inlineSettings || {});
7437
 
                if (nodeName == 'input') {
7438
 
                        this._connectDatepicker(target, inst);
7439
 
                } else if (inline) {
7440
 
                        this._inlineDatepicker(target, inst);
7441
 
                }
7442
 
        },
7443
 
 
7444
 
        /* Create a new instance object. */
7445
 
        _newInst: function(target, inline) {
7446
 
                var id = target[0].id.replace(/([^A-Za-z0-9_-])/g, '\\\\$1'); // escape jQuery meta chars
7447
 
                return {id: id, input: target, // associated target
7448
 
                        selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
7449
 
                        drawMonth: 0, drawYear: 0, // month being drawn
7450
 
                        inline: inline, // is datepicker inline or not
7451
 
                        dpDiv: (!inline ? this.dpDiv : // presentation div
7452
 
                        bindHover($('<div class="' + this._inlineClass + ' ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>')))};
7453
 
        },
7454
 
 
7455
 
        /* Attach the date picker to an input field. */
7456
 
        _connectDatepicker: function(target, inst) {
7457
 
                var input = $(target);
7458
 
                inst.append = $([]);
7459
 
                inst.trigger = $([]);
7460
 
                if (input.hasClass(this.markerClassName))
7461
 
                        return;
7462
 
                this._attachments(input, inst);
7463
 
                input.addClass(this.markerClassName).keydown(this._doKeyDown).
7464
 
                        keypress(this._doKeyPress).keyup(this._doKeyUp).
7465
 
                        bind("setData.datepicker", function(event, key, value) {
7466
 
                                inst.settings[key] = value;
7467
 
                        }).bind("getData.datepicker", function(event, key) {
7468
 
                                return this._get(inst, key);
7469
 
                        });
7470
 
                this._autoSize(inst);
7471
 
                $.data(target, PROP_NAME, inst);
7472
 
                //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665)
7473
 
                if( inst.settings.disabled ) {
7474
 
                        this._disableDatepicker( target );
7475
 
                }
7476
 
        },
7477
 
 
7478
 
        /* Make attachments based on settings. */
7479
 
        _attachments: function(input, inst) {
7480
 
                var appendText = this._get(inst, 'appendText');
7481
 
                var isRTL = this._get(inst, 'isRTL');
7482
 
                if (inst.append)
7483
 
                        inst.append.remove();
7484
 
                if (appendText) {
7485
 
                        inst.append = $('<span class="' + this._appendClass + '">' + appendText + '</span>');
7486
 
                        input[isRTL ? 'before' : 'after'](inst.append);
7487
 
                }
7488
 
                input.unbind('focus', this._showDatepicker);
7489
 
                if (inst.trigger)
7490
 
                        inst.trigger.remove();
7491
 
                var showOn = this._get(inst, 'showOn');
7492
 
                if (showOn == 'focus' || showOn == 'both') // pop-up date picker when in the marked field
7493
 
                        input.focus(this._showDatepicker);
7494
 
                if (showOn == 'button' || showOn == 'both') { // pop-up date picker when button clicked
7495
 
                        var buttonText = this._get(inst, 'buttonText');
7496
 
                        var buttonImage = this._get(inst, 'buttonImage');
7497
 
                        inst.trigger = $(this._get(inst, 'buttonImageOnly') ?
7498
 
                                $('<img/>').addClass(this._triggerClass).
7499
 
                                        attr({ src: buttonImage, alt: buttonText, title: buttonText }) :
7500
 
                                $('<button type="button"></button>').addClass(this._triggerClass).
7501
 
                                        html(buttonImage == '' ? buttonText : $('<img/>').attr(
7502
 
                                        { src:buttonImage, alt:buttonText, title:buttonText })));
7503
 
                        input[isRTL ? 'before' : 'after'](inst.trigger);
7504
 
                        inst.trigger.click(function() {
7505
 
                                if ($.datepicker._datepickerShowing && $.datepicker._lastInput == input[0])
7506
 
                                        $.datepicker._hideDatepicker();
7507
 
                                else if ($.datepicker._datepickerShowing && $.datepicker._lastInput != input[0]) {
7508
 
                                        $.datepicker._hideDatepicker(); 
7509
 
                                        $.datepicker._showDatepicker(input[0]);
7510
 
                                } else
7511
 
                                        $.datepicker._showDatepicker(input[0]);
7512
 
                                return false;
7513
 
                        });
7514
 
                }
7515
 
        },
7516
 
 
7517
 
        /* Apply the maximum length for the date format. */
7518
 
        _autoSize: function(inst) {
7519
 
                if (this._get(inst, 'autoSize') && !inst.inline) {
7520
 
                        var date = new Date(2009, 12 - 1, 20); // Ensure double digits
7521
 
                        var dateFormat = this._get(inst, 'dateFormat');
7522
 
                        if (dateFormat.match(/[DM]/)) {
7523
 
                                var findMax = function(names) {
7524
 
                                        var max = 0;
7525
 
                                        var maxI = 0;
7526
 
                                        for (var i = 0; i < names.length; i++) {
7527
 
                                                if (names[i].length > max) {
7528
 
                                                        max = names[i].length;
7529
 
                                                        maxI = i;
7530
 
                                                }
7531
 
                                        }
7532
 
                                        return maxI;
7533
 
                                };
7534
 
                                date.setMonth(findMax(this._get(inst, (dateFormat.match(/MM/) ?
7535
 
                                        'monthNames' : 'monthNamesShort'))));
7536
 
                                date.setDate(findMax(this._get(inst, (dateFormat.match(/DD/) ?
7537
 
                                        'dayNames' : 'dayNamesShort'))) + 20 - date.getDay());
7538
 
                        }
7539
 
                        inst.input.attr('size', this._formatDate(inst, date).length);
7540
 
                }
7541
 
        },
7542
 
 
7543
 
        /* Attach an inline date picker to a div. */
7544
 
        _inlineDatepicker: function(target, inst) {
7545
 
                var divSpan = $(target);
7546
 
                if (divSpan.hasClass(this.markerClassName))
7547
 
                        return;
7548
 
                divSpan.addClass(this.markerClassName).append(inst.dpDiv).
7549
 
                        bind("setData.datepicker", function(event, key, value){
7550
 
                                inst.settings[key] = value;
7551
 
                        }).bind("getData.datepicker", function(event, key){
7552
 
                                return this._get(inst, key);
7553
 
                        });
7554
 
                $.data(target, PROP_NAME, inst);
7555
 
                this._setDate(inst, this._getDefaultDate(inst), true);
7556
 
                this._updateDatepicker(inst);
7557
 
                this._updateAlternate(inst);
7558
 
                //If disabled option is true, disable the datepicker before showing it (see ticket #5665)
7559
 
                if( inst.settings.disabled ) {
7560
 
                        this._disableDatepicker( target );
7561
 
                }
7562
 
                // Set display:block in place of inst.dpDiv.show() which won't work on disconnected elements
7563
 
                // http://bugs.jqueryui.com/ticket/7552 - A Datepicker created on a detached div has zero height
7564
 
                inst.dpDiv.css( "display", "block" );
7565
 
        },
7566
 
 
7567
 
        /* Pop-up the date picker in a "dialog" box.
7568
 
           @param  input     element - ignored
7569
 
           @param  date      string or Date - the initial date to display
7570
 
           @param  onSelect  function - the function to call when a date is selected
7571
 
           @param  settings  object - update the dialog date picker instance's settings (anonymous object)
7572
 
           @param  pos       int[2] - coordinates for the dialog's position within the screen or
7573
 
                             event - with x/y coordinates or
7574
 
                             leave empty for default (screen centre)
7575
 
           @return the manager object */
7576
 
        _dialogDatepicker: function(input, date, onSelect, settings, pos) {
7577
 
                var inst = this._dialogInst; // internal instance
7578
 
                if (!inst) {
7579
 
                        this.uuid += 1;
7580
 
                        var id = 'dp' + this.uuid;
7581
 
                        this._dialogInput = $('<input type="text" id="' + id +
7582
 
                                '" style="position: absolute; top: -100px; width: 0px; z-index: -10;"/>');
7583
 
                        this._dialogInput.keydown(this._doKeyDown);
7584
 
                        $('body').append(this._dialogInput);
7585
 
                        inst = this._dialogInst = this._newInst(this._dialogInput, false);
7586
 
                        inst.settings = {};
7587
 
                        $.data(this._dialogInput[0], PROP_NAME, inst);
7588
 
                }
7589
 
                extendRemove(inst.settings, settings || {});
7590
 
                date = (date && date.constructor == Date ? this._formatDate(inst, date) : date);
7591
 
                this._dialogInput.val(date);
7592
 
 
7593
 
                this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null);
7594
 
                if (!this._pos) {
7595
 
                        var browserWidth = document.documentElement.clientWidth;
7596
 
                        var browserHeight = document.documentElement.clientHeight;
7597
 
                        var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
7598
 
                        var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
7599
 
                        this._pos = // should use actual width/height below
7600
 
                                [(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY];
7601
 
                }
7602
 
 
7603
 
                // move input on screen for focus, but hidden behind dialog
7604
 
                this._dialogInput.css('left', (this._pos[0] + 20) + 'px').css('top', this._pos[1] + 'px');
7605
 
                inst.settings.onSelect = onSelect;
7606
 
                this._inDialog = true;
7607
 
                this.dpDiv.addClass(this._dialogClass);
7608
 
                this._showDatepicker(this._dialogInput[0]);
7609
 
                if ($.blockUI)
7610
 
                        $.blockUI(this.dpDiv);
7611
 
                $.data(this._dialogInput[0], PROP_NAME, inst);
7612
 
                return this;
7613
 
        },
7614
 
 
7615
 
        /* Detach a datepicker from its control.
7616
 
           @param  target    element - the target input field or division or span */
7617
 
        _destroyDatepicker: function(target) {
7618
 
                var $target = $(target);
7619
 
                var inst = $.data(target, PROP_NAME);
7620
 
                if (!$target.hasClass(this.markerClassName)) {
7621
 
                        return;
7622
 
                }
7623
 
                var nodeName = target.nodeName.toLowerCase();
7624
 
                $.removeData(target, PROP_NAME);
7625
 
                if (nodeName == 'input') {
7626
 
                        inst.append.remove();
7627
 
                        inst.trigger.remove();
7628
 
                        $target.removeClass(this.markerClassName).
7629
 
                                unbind('focus', this._showDatepicker).
7630
 
                                unbind('keydown', this._doKeyDown).
7631
 
                                unbind('keypress', this._doKeyPress).
7632
 
                                unbind('keyup', this._doKeyUp);
7633
 
                } else if (nodeName == 'div' || nodeName == 'span')
7634
 
                        $target.removeClass(this.markerClassName).empty();
7635
 
        },
7636
 
 
7637
 
        /* Enable the date picker to a jQuery selection.
7638
 
           @param  target    element - the target input field or division or span */
7639
 
        _enableDatepicker: function(target) {
7640
 
                var $target = $(target);
7641
 
                var inst = $.data(target, PROP_NAME);
7642
 
                if (!$target.hasClass(this.markerClassName)) {
7643
 
                        return;
7644
 
                }
7645
 
                var nodeName = target.nodeName.toLowerCase();
7646
 
                if (nodeName == 'input') {
7647
 
                        target.disabled = false;
7648
 
                        inst.trigger.filter('button').
7649
 
                                each(function() { this.disabled = false; }).end().
7650
 
                                filter('img').css({opacity: '1.0', cursor: ''});
7651
 
                }
7652
 
                else if (nodeName == 'div' || nodeName == 'span') {
7653
 
                        var inline = $target.children('.' + this._inlineClass);
7654
 
                        inline.children().removeClass('ui-state-disabled');
7655
 
                        inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
7656
 
                                removeAttr("disabled");
7657
 
                }
7658
 
                this._disabledInputs = $.map(this._disabledInputs,
7659
 
                        function(value) { return (value == target ? null : value); }); // delete entry
7660
 
        },
7661
 
 
7662
 
        /* Disable the date picker to a jQuery selection.
7663
 
           @param  target    element - the target input field or division or span */
7664
 
        _disableDatepicker: function(target) {
7665
 
                var $target = $(target);
7666
 
                var inst = $.data(target, PROP_NAME);
7667
 
                if (!$target.hasClass(this.markerClassName)) {
7668
 
                        return;
7669
 
                }
7670
 
                var nodeName = target.nodeName.toLowerCase();
7671
 
                if (nodeName == 'input') {
7672
 
                        target.disabled = true;
7673
 
                        inst.trigger.filter('button').
7674
 
                                each(function() { this.disabled = true; }).end().
7675
 
                                filter('img').css({opacity: '0.5', cursor: 'default'});
7676
 
                }
7677
 
                else if (nodeName == 'div' || nodeName == 'span') {
7678
 
                        var inline = $target.children('.' + this._inlineClass);
7679
 
                        inline.children().addClass('ui-state-disabled');
7680
 
                        inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
7681
 
                                attr("disabled", "disabled");
7682
 
                }
7683
 
                this._disabledInputs = $.map(this._disabledInputs,
7684
 
                        function(value) { return (value == target ? null : value); }); // delete entry
7685
 
                this._disabledInputs[this._disabledInputs.length] = target;
7686
 
        },
7687
 
 
7688
 
        /* Is the first field in a jQuery collection disabled as a datepicker?
7689
 
           @param  target    element - the target input field or division or span
7690
 
           @return boolean - true if disabled, false if enabled */
7691
 
        _isDisabledDatepicker: function(target) {
7692
 
                if (!target) {
7693
 
                        return false;
7694
 
                }
7695
 
                for (var i = 0; i < this._disabledInputs.length; i++) {
7696
 
                        if (this._disabledInputs[i] == target)
7697
 
                                return true;
7698
 
                }
7699
 
                return false;
7700
 
        },
7701
 
 
7702
 
        /* Retrieve the instance data for the target control.
7703
 
           @param  target  element - the target input field or division or span
7704
 
           @return  object - the associated instance data
7705
 
           @throws  error if a jQuery problem getting data */
7706
 
        _getInst: function(target) {
7707
 
                try {
7708
 
                        return $.data(target, PROP_NAME);
7709
 
                }
7710
 
                catch (err) {
7711
 
                        throw 'Missing instance data for this datepicker';
7712
 
                }
7713
 
        },
7714
 
 
7715
 
        /* Update or retrieve the settings for a date picker attached to an input field or division.
7716
 
           @param  target  element - the target input field or division or span
7717
 
           @param  name    object - the new settings to update or
7718
 
                           string - the name of the setting to change or retrieve,
7719
 
                           when retrieving also 'all' for all instance settings or
7720
 
                           'defaults' for all global defaults
7721
 
           @param  value   any - the new value for the setting
7722
 
                           (omit if above is an object or to retrieve a value) */
7723
 
        _optionDatepicker: function(target, name, value) {
7724
 
                var inst = this._getInst(target);
7725
 
                if (arguments.length == 2 && typeof name == 'string') {
7726
 
                        return (name == 'defaults' ? $.extend({}, $.datepicker._defaults) :
7727
 
                                (inst ? (name == 'all' ? $.extend({}, inst.settings) :
7728
 
                                this._get(inst, name)) : null));
7729
 
                }
7730
 
                var settings = name || {};
7731
 
                if (typeof name == 'string') {
7732
 
                        settings = {};
7733
 
                        settings[name] = value;
7734
 
                }
7735
 
                if (inst) {
7736
 
                        if (this._curInst == inst) {
7737
 
                                this._hideDatepicker();
7738
 
                        }
7739
 
                        var date = this._getDateDatepicker(target, true);
7740
 
                        var minDate = this._getMinMaxDate(inst, 'min');
7741
 
                        var maxDate = this._getMinMaxDate(inst, 'max');
7742
 
                        extendRemove(inst.settings, settings);
7743
 
                        // reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided
7744
 
                        if (minDate !== null && settings['dateFormat'] !== undefined && settings['minDate'] === undefined)
7745
 
                                inst.settings.minDate = this._formatDate(inst, minDate);
7746
 
                        if (maxDate !== null && settings['dateFormat'] !== undefined && settings['maxDate'] === undefined)
7747
 
                                inst.settings.maxDate = this._formatDate(inst, maxDate);
7748
 
                        this._attachments($(target), inst);
7749
 
                        this._autoSize(inst);
7750
 
                        this._setDate(inst, date);
7751
 
                        this._updateAlternate(inst);
7752
 
                        this._updateDatepicker(inst);
7753
 
                }
7754
 
        },
7755
 
 
7756
 
        // change method deprecated
7757
 
        _changeDatepicker: function(target, name, value) {
7758
 
                this._optionDatepicker(target, name, value);
7759
 
        },
7760
 
 
7761
 
        /* Redraw the date picker attached to an input field or division.
7762
 
           @param  target  element - the target input field or division or span */
7763
 
        _refreshDatepicker: function(target) {
7764
 
                var inst = this._getInst(target);
7765
 
                if (inst) {
7766
 
                        this._updateDatepicker(inst);
7767
 
                }
7768
 
        },
7769
 
 
7770
 
        /* Set the dates for a jQuery selection.
7771
 
           @param  target   element - the target input field or division or span
7772
 
           @param  date     Date - the new date */
7773
 
        _setDateDatepicker: function(target, date) {
7774
 
                var inst = this._getInst(target);
7775
 
                if (inst) {
7776
 
                        this._setDate(inst, date);
7777
 
                        this._updateDatepicker(inst);
7778
 
                        this._updateAlternate(inst);
7779
 
                }
7780
 
        },
7781
 
 
7782
 
        /* Get the date(s) for the first entry in a jQuery selection.
7783
 
           @param  target     element - the target input field or division or span
7784
 
           @param  noDefault  boolean - true if no default date is to be used
7785
 
           @return Date - the current date */
7786
 
        _getDateDatepicker: function(target, noDefault) {
7787
 
                var inst = this._getInst(target);
7788
 
                if (inst && !inst.inline)
7789
 
                        this._setDateFromField(inst, noDefault);
7790
 
                return (inst ? this._getDate(inst) : null);
7791
 
        },
7792
 
 
7793
 
        /* Handle keystrokes. */
7794
 
        _doKeyDown: function(event) {
7795
 
                var inst = $.datepicker._getInst(event.target);
7796
 
                var handled = true;
7797
 
                var isRTL = inst.dpDiv.is('.ui-datepicker-rtl');
7798
 
                inst._keyEvent = true;
7799
 
                if ($.datepicker._datepickerShowing)
7800
 
                        switch (event.keyCode) {
7801
 
                                case 9: $.datepicker._hideDatepicker();
7802
 
                                                handled = false;
7803
 
                                                break; // hide on tab out
7804
 
                                case 13: var sel = $('td.' + $.datepicker._dayOverClass + ':not(.' + 
7805
 
                                                                        $.datepicker._currentClass + ')', inst.dpDiv);
7806
 
                                                if (sel[0])
7807
 
                                                        $.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]);
7808
 
                                                        var onSelect = $.datepicker._get(inst, 'onSelect');
7809
 
                                                        if (onSelect) {
7810
 
                                                                var dateStr = $.datepicker._formatDate(inst);
7811
 
 
7812
 
                                                                // trigger custom callback
7813
 
                                                                onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]);
7814
 
                                                        }
7815
 
                                                else
7816
 
                                                        $.datepicker._hideDatepicker();
7817
 
                                                return false; // don't submit the form
7818
 
                                                break; // select the value on enter
7819
 
                                case 27: $.datepicker._hideDatepicker();
7820
 
                                                break; // hide on escape
7821
 
                                case 33: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
7822
 
                                                        -$.datepicker._get(inst, 'stepBigMonths') :
7823
 
                                                        -$.datepicker._get(inst, 'stepMonths')), 'M');
7824
 
                                                break; // previous month/year on page up/+ ctrl
7825
 
                                case 34: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
7826
 
                                                        +$.datepicker._get(inst, 'stepBigMonths') :
7827
 
                                                        +$.datepicker._get(inst, 'stepMonths')), 'M');
7828
 
                                                break; // next month/year on page down/+ ctrl
7829
 
                                case 35: if (event.ctrlKey || event.metaKey) $.datepicker._clearDate(event.target);
7830
 
                                                handled = event.ctrlKey || event.metaKey;
7831
 
                                                break; // clear on ctrl or command +end
7832
 
                                case 36: if (event.ctrlKey || event.metaKey) $.datepicker._gotoToday(event.target);
7833
 
                                                handled = event.ctrlKey || event.metaKey;
7834
 
                                                break; // current on ctrl or command +home
7835
 
                                case 37: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), 'D');
7836
 
                                                handled = event.ctrlKey || event.metaKey;
7837
 
                                                // -1 day on ctrl or command +left
7838
 
                                                if (event.originalEvent.altKey) $.datepicker._adjustDate(event.target, (event.ctrlKey ?
7839
 
                                                                        -$.datepicker._get(inst, 'stepBigMonths') :
7840
 
                                                                        -$.datepicker._get(inst, 'stepMonths')), 'M');
7841
 
                                                // next month/year on alt +left on Mac
7842
 
                                                break;
7843
 
                                case 38: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, -7, 'D');
7844
 
                                                handled = event.ctrlKey || event.metaKey;
7845
 
                                                break; // -1 week on ctrl or command +up
7846
 
                                case 39: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), 'D');
7847
 
                                                handled = event.ctrlKey || event.metaKey;
7848
 
                                                // +1 day on ctrl or command +right
7849
 
                                                if (event.originalEvent.altKey) $.datepicker._adjustDate(event.target, (event.ctrlKey ?
7850
 
                                                                        +$.datepicker._get(inst, 'stepBigMonths') :
7851
 
                                                                        +$.datepicker._get(inst, 'stepMonths')), 'M');
7852
 
                                                // next month/year on alt +right
7853
 
                                                break;
7854
 
                                case 40: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, +7, 'D');
7855
 
                                                handled = event.ctrlKey || event.metaKey;
7856
 
                                                break; // +1 week on ctrl or command +down
7857
 
                                default: handled = false;
7858
 
                        }
7859
 
                else if (event.keyCode == 36 && event.ctrlKey) // display the date picker on ctrl+home
7860
 
                        $.datepicker._showDatepicker(this);
7861
 
                else {
7862
 
                        handled = false;
7863
 
                }
7864
 
                if (handled) {
7865
 
                        event.preventDefault();
7866
 
                        event.stopPropagation();
7867
 
                }
7868
 
        },
7869
 
 
7870
 
        /* Filter entered characters - based on date format. */
7871
 
        _doKeyPress: function(event) {
7872
 
                var inst = $.datepicker._getInst(event.target);
7873
 
                if ($.datepicker._get(inst, 'constrainInput')) {
7874
 
                        var chars = $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat'));
7875
 
                        var chr = String.fromCharCode(event.charCode == undefined ? event.keyCode : event.charCode);
7876
 
                        return event.ctrlKey || event.metaKey || (chr < ' ' || !chars || chars.indexOf(chr) > -1);
7877
 
                }
7878
 
        },
7879
 
 
7880
 
        /* Synchronise manual entry and field/alternate field. */
7881
 
        _doKeyUp: function(event) {
7882
 
                var inst = $.datepicker._getInst(event.target);
7883
 
                if (inst.input.val() != inst.lastVal) {
7884
 
                        try {
7885
 
                                var date = $.datepicker.parseDate($.datepicker._get(inst, 'dateFormat'),
7886
 
                                        (inst.input ? inst.input.val() : null),
7887
 
                                        $.datepicker._getFormatConfig(inst));
7888
 
                                if (date) { // only if valid
7889
 
                                        $.datepicker._setDateFromField(inst);
7890
 
                                        $.datepicker._updateAlternate(inst);
7891
 
                                        $.datepicker._updateDatepicker(inst);
7892
 
                                }
7893
 
                        }
7894
 
                        catch (event) {
7895
 
                                $.datepicker.log(event);
7896
 
                        }
7897
 
                }
7898
 
                return true;
7899
 
        },
7900
 
 
7901
 
        /* Pop-up the date picker for a given input field.
7902
 
       If false returned from beforeShow event handler do not show. 
7903
 
           @param  input  element - the input field attached to the date picker or
7904
 
                          event - if triggered by focus */
7905
 
        _showDatepicker: function(input) {
7906
 
                input = input.target || input;
7907
 
                if (input.nodeName.toLowerCase() != 'input') // find from button/image trigger
7908
 
                        input = $('input', input.parentNode)[0];
7909
 
                if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput == input) // already here
7910
 
                        return;
7911
 
                var inst = $.datepicker._getInst(input);
7912
 
                if ($.datepicker._curInst && $.datepicker._curInst != inst) {
7913
 
                        $.datepicker._curInst.dpDiv.stop(true, true);
7914
 
                        if ( inst && $.datepicker._datepickerShowing ) {
7915
 
                                $.datepicker._hideDatepicker( $.datepicker._curInst.input[0] );
7916
 
                        }
7917
 
                }
7918
 
                var beforeShow = $.datepicker._get(inst, 'beforeShow');
7919
 
                var beforeShowSettings = beforeShow ? beforeShow.apply(input, [input, inst]) : {};
7920
 
                if(beforeShowSettings === false){
7921
 
            //false
7922
 
                        return;
7923
 
                }
7924
 
                extendRemove(inst.settings, beforeShowSettings);
7925
 
                inst.lastVal = null;
7926
 
                $.datepicker._lastInput = input;
7927
 
                $.datepicker._setDateFromField(inst);
7928
 
                if ($.datepicker._inDialog) // hide cursor
7929
 
                        input.value = '';
7930
 
                if (!$.datepicker._pos) { // position below input
7931
 
                        $.datepicker._pos = $.datepicker._findPos(input);
7932
 
                        $.datepicker._pos[1] += input.offsetHeight; // add the height
7933
 
                }
7934
 
                var isFixed = false;
7935
 
                $(input).parents().each(function() {
7936
 
                        isFixed |= $(this).css('position') == 'fixed';
7937
 
                        return !isFixed;
7938
 
                });
7939
 
                if (isFixed && $.browser.opera) { // correction for Opera when fixed and scrolled
7940
 
                        $.datepicker._pos[0] -= document.documentElement.scrollLeft;
7941
 
                        $.datepicker._pos[1] -= document.documentElement.scrollTop;
7942
 
                }
7943
 
                var offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]};
7944
 
                $.datepicker._pos = null;
7945
 
                //to avoid flashes on Firefox
7946
 
                inst.dpDiv.empty();
7947
 
                // determine sizing offscreen
7948
 
                inst.dpDiv.css({position: 'absolute', display: 'block', top: '-1000px'});
7949
 
                $.datepicker._updateDatepicker(inst);
7950
 
                // fix width for dynamic number of date pickers
7951
 
                // and adjust position before showing
7952
 
                offset = $.datepicker._checkOffset(inst, offset, isFixed);
7953
 
                inst.dpDiv.css({position: ($.datepicker._inDialog && $.blockUI ?
7954
 
                        'static' : (isFixed ? 'fixed' : 'absolute')), display: 'none',
7955
 
                        left: offset.left + 'px', top: offset.top + 'px'});
7956
 
                if (!inst.inline) {
7957
 
                        var showAnim = $.datepicker._get(inst, 'showAnim');
7958
 
                        var duration = $.datepicker._get(inst, 'duration');
7959
 
                        var postProcess = function() {
7960
 
                                var cover = inst.dpDiv.find('iframe.ui-datepicker-cover'); // IE6- only
7961
 
                                if( !! cover.length ){
7962
 
                                        var borders = $.datepicker._getBorders(inst.dpDiv);
7963
 
                                        cover.css({left: -borders[0], top: -borders[1],
7964
 
                                                width: inst.dpDiv.outerWidth(), height: inst.dpDiv.outerHeight()});
7965
 
                                }
7966
 
                        };
7967
 
                        inst.dpDiv.zIndex($(input).zIndex()+1);
7968
 
                        $.datepicker._datepickerShowing = true;
7969
 
                        if ($.effects && $.effects[showAnim])
7970
 
                                inst.dpDiv.show(showAnim, $.datepicker._get(inst, 'showOptions'), duration, postProcess);
7971
 
                        else
7972
 
                                inst.dpDiv[showAnim || 'show']((showAnim ? duration : null), postProcess);
7973
 
                        if (!showAnim || !duration)
7974
 
                                postProcess();
7975
 
                        if (inst.input.is(':visible') && !inst.input.is(':disabled'))
7976
 
                                inst.input.focus();
7977
 
                        $.datepicker._curInst = inst;
7978
 
                }
7979
 
        },
7980
 
 
7981
 
        /* Generate the date picker content. */
7982
 
        _updateDatepicker: function(inst) {
7983
 
                var self = this;
7984
 
                self.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
7985
 
                var borders = $.datepicker._getBorders(inst.dpDiv);
7986
 
                instActive = inst; // for delegate hover events
7987
 
                inst.dpDiv.empty().append(this._generateHTML(inst));
7988
 
                var cover = inst.dpDiv.find('iframe.ui-datepicker-cover'); // IE6- only
7989
 
                if( !!cover.length ){ //avoid call to outerXXXX() when not in IE6
7990
 
                        cover.css({left: -borders[0], top: -borders[1], width: inst.dpDiv.outerWidth(), height: inst.dpDiv.outerHeight()})
7991
 
                }
7992
 
                inst.dpDiv.find('.' + this._dayOverClass + ' a').mouseover();
7993
 
                var numMonths = this._getNumberOfMonths(inst);
7994
 
                var cols = numMonths[1];
7995
 
                var width = 17;
7996
 
                inst.dpDiv.removeClass('ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4').width('');
7997
 
                if (cols > 1)
7998
 
                        inst.dpDiv.addClass('ui-datepicker-multi-' + cols).css('width', (width * cols) + 'em');
7999
 
                inst.dpDiv[(numMonths[0] != 1 || numMonths[1] != 1 ? 'add' : 'remove') +
8000
 
                        'Class']('ui-datepicker-multi');
8001
 
                inst.dpDiv[(this._get(inst, 'isRTL') ? 'add' : 'remove') +
8002
 
                        'Class']('ui-datepicker-rtl');
8003
 
                if (inst == $.datepicker._curInst && $.datepicker._datepickerShowing && inst.input &&
8004
 
                                // #6694 - don't focus the input if it's already focused
8005
 
                                // this breaks the change event in IE
8006
 
                                inst.input.is(':visible') && !inst.input.is(':disabled') && inst.input[0] != document.activeElement)
8007
 
                        inst.input.focus();
8008
 
                // deffered render of the years select (to avoid flashes on Firefox) 
8009
 
                if( inst.yearshtml ){
8010
 
                        var origyearshtml = inst.yearshtml;
8011
 
                        setTimeout(function(){
8012
 
                                //assure that inst.yearshtml didn't change.
8013
 
                                if( origyearshtml === inst.yearshtml && inst.yearshtml ){
8014
 
                                        inst.dpDiv.find('select.ui-datepicker-year:first').replaceWith(inst.yearshtml);
8015
 
                                }
8016
 
                                origyearshtml = inst.yearshtml = null;
8017
 
                        }, 0);
8018
 
                }
8019
 
        },
8020
 
 
8021
 
        /* Retrieve the size of left and top borders for an element.
8022
 
           @param  elem  (jQuery object) the element of interest
8023
 
           @return  (number[2]) the left and top borders */
8024
 
        _getBorders: function(elem) {
8025
 
                var convert = function(value) {
8026
 
                        return {thin: 1, medium: 2, thick: 3}[value] || value;
8027
 
                };
8028
 
                return [parseFloat(convert(elem.css('border-left-width'))),
8029
 
                        parseFloat(convert(elem.css('border-top-width')))];
8030
 
        },
8031
 
 
8032
 
        /* Check positioning to remain on screen. */
8033
 
        _checkOffset: function(inst, offset, isFixed) {
8034
 
                var dpWidth = inst.dpDiv.outerWidth();
8035
 
                var dpHeight = inst.dpDiv.outerHeight();
8036
 
                var inputWidth = inst.input ? inst.input.outerWidth() : 0;
8037
 
                var inputHeight = inst.input ? inst.input.outerHeight() : 0;
8038
 
                var viewWidth = document.documentElement.clientWidth + $(document).scrollLeft();
8039
 
                var viewHeight = document.documentElement.clientHeight + $(document).scrollTop();
8040
 
 
8041
 
                offset.left -= (this._get(inst, 'isRTL') ? (dpWidth - inputWidth) : 0);
8042
 
                offset.left -= (isFixed && offset.left == inst.input.offset().left) ? $(document).scrollLeft() : 0;
8043
 
                offset.top -= (isFixed && offset.top == (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0;
8044
 
 
8045
 
                // now check if datepicker is showing outside window viewport - move to a better place if so.
8046
 
                offset.left -= Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ?
8047
 
                        Math.abs(offset.left + dpWidth - viewWidth) : 0);
8048
 
                offset.top -= Math.min(offset.top, (offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ?
8049
 
                        Math.abs(dpHeight + inputHeight) : 0);
8050
 
 
8051
 
                return offset;
8052
 
        },
8053
 
 
8054
 
        /* Find an object's position on the screen. */
8055
 
        _findPos: function(obj) {
8056
 
                var inst = this._getInst(obj);
8057
 
                var isRTL = this._get(inst, 'isRTL');
8058
 
        while (obj && (obj.type == 'hidden' || obj.nodeType != 1 || $.expr.filters.hidden(obj))) {
8059
 
            obj = obj[isRTL ? 'previousSibling' : 'nextSibling'];
8060
 
        }
8061
 
        var position = $(obj).offset();
8062
 
            return [position.left, position.top];
8063
 
        },
8064
 
 
8065
 
        /* Hide the date picker from view.
8066
 
           @param  input  element - the input field attached to the date picker */
8067
 
        _hideDatepicker: function(input) {
8068
 
                var inst = this._curInst;
8069
 
                if (!inst || (input && inst != $.data(input, PROP_NAME)))
8070
 
                        return;
8071
 
                if (this._datepickerShowing) {
8072
 
                        var showAnim = this._get(inst, 'showAnim');
8073
 
                        var duration = this._get(inst, 'duration');
8074
 
                        var self = this;
8075
 
                        var postProcess = function() {
8076
 
                                $.datepicker._tidyDialog(inst);
8077
 
                                self._curInst = null;
8078
 
                        };
8079
 
                        if ($.effects && $.effects[showAnim])
8080
 
                                inst.dpDiv.hide(showAnim, $.datepicker._get(inst, 'showOptions'), duration, postProcess);
8081
 
                        else
8082
 
                                inst.dpDiv[(showAnim == 'slideDown' ? 'slideUp' :
8083
 
                                        (showAnim == 'fadeIn' ? 'fadeOut' : 'hide'))]((showAnim ? duration : null), postProcess);
8084
 
                        if (!showAnim)
8085
 
                                postProcess();
8086
 
                        this._datepickerShowing = false;
8087
 
                        var onClose = this._get(inst, 'onClose');
8088
 
                        if (onClose)
8089
 
                                onClose.apply((inst.input ? inst.input[0] : null),
8090
 
                                        [(inst.input ? inst.input.val() : ''), inst]);
8091
 
                        this._lastInput = null;
8092
 
                        if (this._inDialog) {
8093
 
                                this._dialogInput.css({ position: 'absolute', left: '0', top: '-100px' });
8094
 
                                if ($.blockUI) {
8095
 
                                        $.unblockUI();
8096
 
                                        $('body').append(this.dpDiv);
8097
 
                                }
8098
 
                        }
8099
 
                        this._inDialog = false;
8100
 
                }
8101
 
        },
8102
 
 
8103
 
        /* Tidy up after a dialog display. */
8104
 
        _tidyDialog: function(inst) {
8105
 
                inst.dpDiv.removeClass(this._dialogClass).unbind('.ui-datepicker-calendar');
8106
 
        },
8107
 
 
8108
 
        /* Close date picker if clicked elsewhere. */
8109
 
        _checkExternalClick: function(event) {
8110
 
                if (!$.datepicker._curInst)
8111
 
                        return;
8112
 
 
8113
 
                var $target = $(event.target),
8114
 
                        inst = $.datepicker._getInst($target[0]);
8115
 
 
8116
 
                if ( ( ( $target[0].id != $.datepicker._mainDivId &&
8117
 
                                $target.parents('#' + $.datepicker._mainDivId).length == 0 &&
8118
 
                                !$target.hasClass($.datepicker.markerClassName) &&
8119
 
                                !$target.closest("." + $.datepicker._triggerClass).length &&
8120
 
                                $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI) ) ) ||
8121
 
                        ( $target.hasClass($.datepicker.markerClassName) && $.datepicker._curInst != inst ) )
8122
 
                        $.datepicker._hideDatepicker();
8123
 
        },
8124
 
 
8125
 
        /* Adjust one of the date sub-fields. */
8126
 
        _adjustDate: function(id, offset, period) {
8127
 
                var target = $(id);
8128
 
                var inst = this._getInst(target[0]);
8129
 
                if (this._isDisabledDatepicker(target[0])) {
8130
 
                        return;
8131
 
                }
8132
 
                this._adjustInstDate(inst, offset +
8133
 
                        (period == 'M' ? this._get(inst, 'showCurrentAtPos') : 0), // undo positioning
8134
 
                        period);
8135
 
                this._updateDatepicker(inst);
8136
 
        },
8137
 
 
8138
 
        /* Action for current link. */
8139
 
        _gotoToday: function(id) {
8140
 
                var target = $(id);
8141
 
                var inst = this._getInst(target[0]);
8142
 
                if (this._get(inst, 'gotoCurrent') && inst.currentDay) {
8143
 
                        inst.selectedDay = inst.currentDay;
8144
 
                        inst.drawMonth = inst.selectedMonth = inst.currentMonth;
8145
 
                        inst.drawYear = inst.selectedYear = inst.currentYear;
8146
 
                }
8147
 
                else {
8148
 
                        var date = new Date();
8149
 
                        inst.selectedDay = date.getDate();
8150
 
                        inst.drawMonth = inst.selectedMonth = date.getMonth();
8151
 
                        inst.drawYear = inst.selectedYear = date.getFullYear();
8152
 
                }
8153
 
                this._notifyChange(inst);
8154
 
                this._adjustDate(target);
8155
 
        },
8156
 
 
8157
 
        /* Action for selecting a new month/year. */
8158
 
        _selectMonthYear: function(id, select, period) {
8159
 
                var target = $(id);
8160
 
                var inst = this._getInst(target[0]);
8161
 
                inst['selected' + (period == 'M' ? 'Month' : 'Year')] =
8162
 
                inst['draw' + (period == 'M' ? 'Month' : 'Year')] =
8163
 
                        parseInt(select.options[select.selectedIndex].value,10);
8164
 
                this._notifyChange(inst);
8165
 
                this._adjustDate(target);
8166
 
        },
8167
 
 
8168
 
        /* Action for selecting a day. */
8169
 
        _selectDay: function(id, month, year, td) {
8170
 
                var target = $(id);
8171
 
                if ($(td).hasClass(this._unselectableClass) || this._isDisabledDatepicker(target[0])) {
8172
 
                        return;
8173
 
                }
8174
 
                var inst = this._getInst(target[0]);
8175
 
                inst.selectedDay = inst.currentDay = $('a', td).html();
8176
 
                inst.selectedMonth = inst.currentMonth = month;
8177
 
                inst.selectedYear = inst.currentYear = year;
8178
 
                this._selectDate(id, this._formatDate(inst,
8179
 
                        inst.currentDay, inst.currentMonth, inst.currentYear));
8180
 
        },
8181
 
 
8182
 
        /* Erase the input field and hide the date picker. */
8183
 
        _clearDate: function(id) {
8184
 
                var target = $(id);
8185
 
                var inst = this._getInst(target[0]);
8186
 
                this._selectDate(target, '');
8187
 
        },
8188
 
 
8189
 
        /* Update the input field with the selected date. */
8190
 
        _selectDate: function(id, dateStr) {
8191
 
                var target = $(id);
8192
 
                var inst = this._getInst(target[0]);
8193
 
                dateStr = (dateStr != null ? dateStr : this._formatDate(inst));
8194
 
                if (inst.input)
8195
 
                        inst.input.val(dateStr);
8196
 
                this._updateAlternate(inst);
8197
 
                var onSelect = this._get(inst, 'onSelect');
8198
 
                if (onSelect)
8199
 
                        onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]);  // trigger custom callback
8200
 
                else if (inst.input)
8201
 
                        inst.input.trigger('change'); // fire the change event
8202
 
                if (inst.inline)
8203
 
                        this._updateDatepicker(inst);
8204
 
                else {
8205
 
                        this._hideDatepicker();
8206
 
                        this._lastInput = inst.input[0];
8207
 
                        if (typeof(inst.input[0]) != 'object')
8208
 
                                inst.input.focus(); // restore focus
8209
 
                        this._lastInput = null;
8210
 
                }
8211
 
        },
8212
 
 
8213
 
        /* Update any alternate field to synchronise with the main field. */
8214
 
        _updateAlternate: function(inst) {
8215
 
                var altField = this._get(inst, 'altField');
8216
 
                if (altField) { // update alternate field too
8217
 
                        var altFormat = this._get(inst, 'altFormat') || this._get(inst, 'dateFormat');
8218
 
                        var date = this._getDate(inst);
8219
 
                        var dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst));
8220
 
                        $(altField).each(function() { $(this).val(dateStr); });
8221
 
                }
8222
 
        },
8223
 
 
8224
 
        /* Set as beforeShowDay function to prevent selection of weekends.
8225
 
           @param  date  Date - the date to customise
8226
 
           @return [boolean, string] - is this date selectable?, what is its CSS class? */
8227
 
        noWeekends: function(date) {
8228
 
                var day = date.getDay();
8229
 
                return [(day > 0 && day < 6), ''];
8230
 
        },
8231
 
 
8232
 
        /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
8233
 
           @param  date  Date - the date to get the week for
8234
 
           @return  number - the number of the week within the year that contains this date */
8235
 
        iso8601Week: function(date) {
8236
 
                var checkDate = new Date(date.getTime());
8237
 
                // Find Thursday of this week starting on Monday
8238
 
                checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
8239
 
                var time = checkDate.getTime();
8240
 
                checkDate.setMonth(0); // Compare with Jan 1
8241
 
                checkDate.setDate(1);
8242
 
                return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
8243
 
        },
8244
 
 
8245
 
        /* Parse a string value into a date object.
8246
 
           See formatDate below for the possible formats.
8247
 
 
8248
 
           @param  format    string - the expected format of the date
8249
 
           @param  value     string - the date in the above format
8250
 
           @param  settings  Object - attributes include:
8251
 
                             shortYearCutoff  number - the cutoff year for determining the century (optional)
8252
 
                             dayNamesShort    string[7] - abbreviated names of the days from Sunday (optional)
8253
 
                             dayNames         string[7] - names of the days from Sunday (optional)
8254
 
                             monthNamesShort  string[12] - abbreviated names of the months (optional)
8255
 
                             monthNames       string[12] - names of the months (optional)
8256
 
           @return  Date - the extracted date value or null if value is blank */
8257
 
        parseDate: function (format, value, settings) {
8258
 
                if (format == null || value == null)
8259
 
                        throw 'Invalid arguments';
8260
 
                value = (typeof value == 'object' ? value.toString() : value + '');
8261
 
                if (value == '')
8262
 
                        return null;
8263
 
                var shortYearCutoff = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff;
8264
 
                shortYearCutoff = (typeof shortYearCutoff != 'string' ? shortYearCutoff :
8265
 
                                new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
8266
 
                var dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort;
8267
 
                var dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames;
8268
 
                var monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort;
8269
 
                var monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames;
8270
 
                var year = -1;
8271
 
                var month = -1;
8272
 
                var day = -1;
8273
 
                var doy = -1;
8274
 
                var literal = false;
8275
 
                // Check whether a format character is doubled
8276
 
                var lookAhead = function(match) {
8277
 
                        var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
8278
 
                        if (matches)
8279
 
                                iFormat++;
8280
 
                        return matches;
8281
 
                };
8282
 
                // Extract a number from the string value
8283
 
                var getNumber = function(match) {
8284
 
                        var isDoubled = lookAhead(match);
8285
 
                        var size = (match == '@' ? 14 : (match == '!' ? 20 :
8286
 
                                (match == 'y' && isDoubled ? 4 : (match == 'o' ? 3 : 2))));
8287
 
                        var digits = new RegExp('^\\d{1,' + size + '}');
8288
 
                        var num = value.substring(iValue).match(digits);
8289
 
                        if (!num)
8290
 
                                throw 'Missing number at position ' + iValue;
8291
 
                        iValue += num[0].length;
8292
 
                        return parseInt(num[0], 10);
8293
 
                };
8294
 
                // Extract a name from the string value and convert to an index
8295
 
                var getName = function(match, shortNames, longNames) {
8296
 
                        var names = $.map(lookAhead(match) ? longNames : shortNames, function (v, k) {
8297
 
                                return [ [k, v] ];
8298
 
                        }).sort(function (a, b) {
8299
 
                                return -(a[1].length - b[1].length);
8300
 
                        });
8301
 
                        var index = -1;
8302
 
                        $.each(names, function (i, pair) {
8303
 
                                var name = pair[1];
8304
 
                                if (value.substr(iValue, name.length).toLowerCase() == name.toLowerCase()) {
8305
 
                                        index = pair[0];
8306
 
                                        iValue += name.length;
8307
 
                                        return false;
8308
 
                                }
8309
 
                        });
8310
 
                        if (index != -1)
8311
 
                                return index + 1;
8312
 
                        else
8313
 
                                throw 'Unknown name at position ' + iValue;
8314
 
                };
8315
 
                // Confirm that a literal character matches the string value
8316
 
                var checkLiteral = function() {
8317
 
                        if (value.charAt(iValue) != format.charAt(iFormat))
8318
 
                                throw 'Unexpected literal at position ' + iValue;
8319
 
                        iValue++;
8320
 
                };
8321
 
                var iValue = 0;
8322
 
                for (var iFormat = 0; iFormat < format.length; iFormat++) {
8323
 
                        if (literal)
8324
 
                                if (format.charAt(iFormat) == "'" && !lookAhead("'"))
8325
 
                                        literal = false;
8326
 
                                else
8327
 
                                        checkLiteral();
8328
 
                        else
8329
 
                                switch (format.charAt(iFormat)) {
8330
 
                                        case 'd':
8331
 
                                                day = getNumber('d');
8332
 
                                                break;
8333
 
                                        case 'D':
8334
 
                                                getName('D', dayNamesShort, dayNames);
8335
 
                                                break;
8336
 
                                        case 'o':
8337
 
                                                doy = getNumber('o');
8338
 
                                                break;
8339
 
                                        case 'm':
8340
 
                                                month = getNumber('m');
8341
 
                                                break;
8342
 
                                        case 'M':
8343
 
                                                month = getName('M', monthNamesShort, monthNames);
8344
 
                                                break;
8345
 
                                        case 'y':
8346
 
                                                year = getNumber('y');
8347
 
                                                break;
8348
 
                                        case '@':
8349
 
                                                var date = new Date(getNumber('@'));
8350
 
                                                year = date.getFullYear();
8351
 
                                                month = date.getMonth() + 1;
8352
 
                                                day = date.getDate();
8353
 
                                                break;
8354
 
                                        case '!':
8355
 
                                                var date = new Date((getNumber('!') - this._ticksTo1970) / 10000);
8356
 
                                                year = date.getFullYear();
8357
 
                                                month = date.getMonth() + 1;
8358
 
                                                day = date.getDate();
8359
 
                                                break;
8360
 
                                        case "'":
8361
 
                                                if (lookAhead("'"))
8362
 
                                                        checkLiteral();
8363
 
                                                else
8364
 
                                                        literal = true;
8365
 
                                                break;
8366
 
                                        default:
8367
 
                                                checkLiteral();
8368
 
                                }
8369
 
                }
8370
 
                if (iValue < value.length){
8371
 
                        throw "Extra/unparsed characters found in date: " + value.substring(iValue);
8372
 
                }
8373
 
                if (year == -1)
8374
 
                        year = new Date().getFullYear();
8375
 
                else if (year < 100)
8376
 
                        year += new Date().getFullYear() - new Date().getFullYear() % 100 +
8377
 
                                (year <= shortYearCutoff ? 0 : -100);
8378
 
                if (doy > -1) {
8379
 
                        month = 1;
8380
 
                        day = doy;
8381
 
                        do {
8382
 
                                var dim = this._getDaysInMonth(year, month - 1);
8383
 
                                if (day <= dim)
8384
 
                                        break;
8385
 
                                month++;
8386
 
                                day -= dim;
8387
 
                        } while (true);
8388
 
                }
8389
 
                var date = this._daylightSavingAdjust(new Date(year, month - 1, day));
8390
 
                if (date.getFullYear() != year || date.getMonth() + 1 != month || date.getDate() != day)
8391
 
                        throw 'Invalid date'; // E.g. 31/02/00
8392
 
                return date;
8393
 
        },
8394
 
 
8395
 
        /* Standard date formats. */
8396
 
        ATOM: 'yy-mm-dd', // RFC 3339 (ISO 8601)
8397
 
        COOKIE: 'D, dd M yy',
8398
 
        ISO_8601: 'yy-mm-dd',
8399
 
        RFC_822: 'D, d M y',
8400
 
        RFC_850: 'DD, dd-M-y',
8401
 
        RFC_1036: 'D, d M y',
8402
 
        RFC_1123: 'D, d M yy',
8403
 
        RFC_2822: 'D, d M yy',
8404
 
        RSS: 'D, d M y', // RFC 822
8405
 
        TICKS: '!',
8406
 
        TIMESTAMP: '@',
8407
 
        W3C: 'yy-mm-dd', // ISO 8601
8408
 
 
8409
 
        _ticksTo1970: (((1970 - 1) * 365 + Math.floor(1970 / 4) - Math.floor(1970 / 100) +
8410
 
                Math.floor(1970 / 400)) * 24 * 60 * 60 * 10000000),
8411
 
 
8412
 
        /* Format a date object into a string value.
8413
 
           The format can be combinations of the following:
8414
 
           d  - day of month (no leading zero)
8415
 
           dd - day of month (two digit)
8416
 
           o  - day of year (no leading zeros)
8417
 
           oo - day of year (three digit)
8418
 
           D  - day name short
8419
 
           DD - day name long
8420
 
           m  - month of year (no leading zero)
8421
 
           mm - month of year (two digit)
8422
 
           M  - month name short
8423
 
           MM - month name long
8424
 
           y  - year (two digit)
8425
 
           yy - year (four digit)
8426
 
           @ - Unix timestamp (ms since 01/01/1970)
8427
 
           ! - Windows ticks (100ns since 01/01/0001)
8428
 
           '...' - literal text
8429
 
           '' - single quote
8430
 
 
8431
 
           @param  format    string - the desired format of the date
8432
 
           @param  date      Date - the date value to format
8433
 
           @param  settings  Object - attributes include:
8434
 
                             dayNamesShort    string[7] - abbreviated names of the days from Sunday (optional)
8435
 
                             dayNames         string[7] - names of the days from Sunday (optional)
8436
 
                             monthNamesShort  string[12] - abbreviated names of the months (optional)
8437
 
                             monthNames       string[12] - names of the months (optional)
8438
 
           @return  string - the date in the above format */
8439
 
        formatDate: function (format, date, settings) {
8440
 
                if (!date)
8441
 
                        return '';
8442
 
                var dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort;
8443
 
                var dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames;
8444
 
                var monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort;
8445
 
                var monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames;
8446
 
                // Check whether a format character is doubled
8447
 
                var lookAhead = function(match) {
8448
 
                        var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
8449
 
                        if (matches)
8450
 
                                iFormat++;
8451
 
                        return matches;
8452
 
                };
8453
 
                // Format a number, with leading zero if necessary
8454
 
                var formatNumber = function(match, value, len) {
8455
 
                        var num = '' + value;
8456
 
                        if (lookAhead(match))
8457
 
                                while (num.length < len)
8458
 
                                        num = '0' + num;
8459
 
                        return num;
8460
 
                };
8461
 
                // Format a name, short or long as requested
8462
 
                var formatName = function(match, value, shortNames, longNames) {
8463
 
                        return (lookAhead(match) ? longNames[value] : shortNames[value]);
8464
 
                };
8465
 
                var output = '';
8466
 
                var literal = false;
8467
 
                if (date)
8468
 
                        for (var iFormat = 0; iFormat < format.length; iFormat++) {
8469
 
                                if (literal)
8470
 
                                        if (format.charAt(iFormat) == "'" && !lookAhead("'"))
8471
 
                                                literal = false;
8472
 
                                        else
8473
 
                                                output += format.charAt(iFormat);
8474
 
                                else
8475
 
                                        switch (format.charAt(iFormat)) {
8476
 
                                                case 'd':
8477
 
                                                        output += formatNumber('d', date.getDate(), 2);
8478
 
                                                        break;
8479
 
                                                case 'D':
8480
 
                                                        output += formatName('D', date.getDay(), dayNamesShort, dayNames);
8481
 
                                                        break;
8482
 
                                                case 'o':
8483
 
                                                        output += formatNumber('o',
8484
 
                                                                Math.round((new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000), 3);
8485
 
                                                        break;
8486
 
                                                case 'm':
8487
 
                                                        output += formatNumber('m', date.getMonth() + 1, 2);
8488
 
                                                        break;
8489
 
                                                case 'M':
8490
 
                                                        output += formatName('M', date.getMonth(), monthNamesShort, monthNames);
8491
 
                                                        break;
8492
 
                                                case 'y':
8493
 
                                                        output += (lookAhead('y') ? date.getFullYear() :
8494
 
                                                                (date.getYear() % 100 < 10 ? '0' : '') + date.getYear() % 100);
8495
 
                                                        break;
8496
 
                                                case '@':
8497
 
                                                        output += date.getTime();
8498
 
                                                        break;
8499
 
                                                case '!':
8500
 
                                                        output += date.getTime() * 10000 + this._ticksTo1970;
8501
 
                                                        break;
8502
 
                                                case "'":
8503
 
                                                        if (lookAhead("'"))
8504
 
                                                                output += "'";
8505
 
                                                        else
8506
 
                                                                literal = true;
8507
 
                                                        break;
8508
 
                                                default:
8509
 
                                                        output += format.charAt(iFormat);
8510
 
                                        }
8511
 
                        }
8512
 
                return output;
8513
 
        },
8514
 
 
8515
 
        /* Extract all possible characters from the date format. */
8516
 
        _possibleChars: function (format) {
8517
 
                var chars = '';
8518
 
                var literal = false;
8519
 
                // Check whether a format character is doubled
8520
 
                var lookAhead = function(match) {
8521
 
                        var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
8522
 
                        if (matches)
8523
 
                                iFormat++;
8524
 
                        return matches;
8525
 
                };
8526
 
                for (var iFormat = 0; iFormat < format.length; iFormat++)
8527
 
                        if (literal)
8528
 
                                if (format.charAt(iFormat) == "'" && !lookAhead("'"))
8529
 
                                        literal = false;
8530
 
                                else
8531
 
                                        chars += format.charAt(iFormat);
8532
 
                        else
8533
 
                                switch (format.charAt(iFormat)) {
8534
 
                                        case 'd': case 'm': case 'y': case '@':
8535
 
                                                chars += '0123456789';
8536
 
                                                break;
8537
 
                                        case 'D': case 'M':
8538
 
                                                return null; // Accept anything
8539
 
                                        case "'":
8540
 
                                                if (lookAhead("'"))
8541
 
                                                        chars += "'";
8542
 
                                                else
8543
 
                                                        literal = true;
8544
 
                                                break;
8545
 
                                        default:
8546
 
                                                chars += format.charAt(iFormat);
8547
 
                                }
8548
 
                return chars;
8549
 
        },
8550
 
 
8551
 
        /* Get a setting value, defaulting if necessary. */
8552
 
        _get: function(inst, name) {
8553
 
                return inst.settings[name] !== undefined ?
8554
 
                        inst.settings[name] : this._defaults[name];
8555
 
        },
8556
 
 
8557
 
        /* Parse existing date and initialise date picker. */
8558
 
        _setDateFromField: function(inst, noDefault) {
8559
 
                if (inst.input.val() == inst.lastVal) {
8560
 
                        return;
8561
 
                }
8562
 
                var dateFormat = this._get(inst, 'dateFormat');
8563
 
                var dates = inst.lastVal = inst.input ? inst.input.val() : null;
8564
 
                var date, defaultDate;
8565
 
                date = defaultDate = this._getDefaultDate(inst);
8566
 
                var settings = this._getFormatConfig(inst);
8567
 
                try {
8568
 
                        date = this.parseDate(dateFormat, dates, settings) || defaultDate;
8569
 
                } catch (event) {
8570
 
                        this.log(event);
8571
 
                        dates = (noDefault ? '' : dates);
8572
 
                }
8573
 
                inst.selectedDay = date.getDate();
8574
 
                inst.drawMonth = inst.selectedMonth = date.getMonth();
8575
 
                inst.drawYear = inst.selectedYear = date.getFullYear();
8576
 
                inst.currentDay = (dates ? date.getDate() : 0);
8577
 
                inst.currentMonth = (dates ? date.getMonth() : 0);
8578
 
                inst.currentYear = (dates ? date.getFullYear() : 0);
8579
 
                this._adjustInstDate(inst);
8580
 
        },
8581
 
 
8582
 
        /* Retrieve the default date shown on opening. */
8583
 
        _getDefaultDate: function(inst) {
8584
 
                return this._restrictMinMax(inst,
8585
 
                        this._determineDate(inst, this._get(inst, 'defaultDate'), new Date()));
8586
 
        },
8587
 
 
8588
 
        /* A date may be specified as an exact value or a relative one. */
8589
 
        _determineDate: function(inst, date, defaultDate) {
8590
 
                var offsetNumeric = function(offset) {
8591
 
                        var date = new Date();
8592
 
                        date.setDate(date.getDate() + offset);
8593
 
                        return date;
8594
 
                };
8595
 
                var offsetString = function(offset) {
8596
 
                        try {
8597
 
                                return $.datepicker.parseDate($.datepicker._get(inst, 'dateFormat'),
8598
 
                                        offset, $.datepicker._getFormatConfig(inst));
8599
 
                        }
8600
 
                        catch (e) {
8601
 
                                // Ignore
8602
 
                        }
8603
 
                        var date = (offset.toLowerCase().match(/^c/) ?
8604
 
                                $.datepicker._getDate(inst) : null) || new Date();
8605
 
                        var year = date.getFullYear();
8606
 
                        var month = date.getMonth();
8607
 
                        var day = date.getDate();
8608
 
                        var pattern = /([+-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g;
8609
 
                        var matches = pattern.exec(offset);
8610
 
                        while (matches) {
8611
 
                                switch (matches[2] || 'd') {
8612
 
                                        case 'd' : case 'D' :
8613
 
                                                day += parseInt(matches[1],10); break;
8614
 
                                        case 'w' : case 'W' :
8615
 
                                                day += parseInt(matches[1],10) * 7; break;
8616
 
                                        case 'm' : case 'M' :
8617
 
                                                month += parseInt(matches[1],10);
8618
 
                                                day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
8619
 
                                                break;
8620
 
                                        case 'y': case 'Y' :
8621
 
                                                year += parseInt(matches[1],10);
8622
 
                                                day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
8623
 
                                                break;
8624
 
                                }
8625
 
                                matches = pattern.exec(offset);
8626
 
                        }
8627
 
                        return new Date(year, month, day);
8628
 
                };
8629
 
                var newDate = (date == null || date === '' ? defaultDate : (typeof date == 'string' ? offsetString(date) :
8630
 
                        (typeof date == 'number' ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : new Date(date.getTime()))));
8631
 
                newDate = (newDate && newDate.toString() == 'Invalid Date' ? defaultDate : newDate);
8632
 
                if (newDate) {
8633
 
                        newDate.setHours(0);
8634
 
                        newDate.setMinutes(0);
8635
 
                        newDate.setSeconds(0);
8636
 
                        newDate.setMilliseconds(0);
8637
 
                }
8638
 
                return this._daylightSavingAdjust(newDate);
8639
 
        },
8640
 
 
8641
 
        /* Handle switch to/from daylight saving.
8642
 
           Hours may be non-zero on daylight saving cut-over:
8643
 
           > 12 when midnight changeover, but then cannot generate
8644
 
           midnight datetime, so jump to 1AM, otherwise reset.
8645
 
           @param  date  (Date) the date to check
8646
 
           @return  (Date) the corrected date */
8647
 
        _daylightSavingAdjust: function(date) {
8648
 
                if (!date) return null;
8649
 
                date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0);
8650
 
                return date;
8651
 
        },
8652
 
 
8653
 
        /* Set the date(s) directly. */
8654
 
        _setDate: function(inst, date, noChange) {
8655
 
                var clear = !date;
8656
 
                var origMonth = inst.selectedMonth;
8657
 
                var origYear = inst.selectedYear;
8658
 
                var newDate = this._restrictMinMax(inst, this._determineDate(inst, date, new Date()));
8659
 
                inst.selectedDay = inst.currentDay = newDate.getDate();
8660
 
                inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth();
8661
 
                inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear();
8662
 
                if ((origMonth != inst.selectedMonth || origYear != inst.selectedYear) && !noChange)
8663
 
                        this._notifyChange(inst);
8664
 
                this._adjustInstDate(inst);
8665
 
                if (inst.input) {
8666
 
                        inst.input.val(clear ? '' : this._formatDate(inst));
8667
 
                }
8668
 
        },
8669
 
 
8670
 
        /* Retrieve the date(s) directly. */
8671
 
        _getDate: function(inst) {
8672
 
                var startDate = (!inst.currentYear || (inst.input && inst.input.val() == '') ? null :
8673
 
                        this._daylightSavingAdjust(new Date(
8674
 
                        inst.currentYear, inst.currentMonth, inst.currentDay)));
8675
 
                        return startDate;
8676
 
        },
8677
 
 
8678
 
        /* Generate the HTML for the current state of the date picker. */
8679
 
        _generateHTML: function(inst) {
8680
 
                var today = new Date();
8681
 
                today = this._daylightSavingAdjust(
8682
 
                        new Date(today.getFullYear(), today.getMonth(), today.getDate())); // clear time
8683
 
                var isRTL = this._get(inst, 'isRTL');
8684
 
                var showButtonPanel = this._get(inst, 'showButtonPanel');
8685
 
                var hideIfNoPrevNext = this._get(inst, 'hideIfNoPrevNext');
8686
 
                var navigationAsDateFormat = this._get(inst, 'navigationAsDateFormat');
8687
 
                var numMonths = this._getNumberOfMonths(inst);
8688
 
                var showCurrentAtPos = this._get(inst, 'showCurrentAtPos');
8689
 
                var stepMonths = this._get(inst, 'stepMonths');
8690
 
                var isMultiMonth = (numMonths[0] != 1 || numMonths[1] != 1);
8691
 
                var currentDate = this._daylightSavingAdjust((!inst.currentDay ? new Date(9999, 9, 9) :
8692
 
                        new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
8693
 
                var minDate = this._getMinMaxDate(inst, 'min');
8694
 
                var maxDate = this._getMinMaxDate(inst, 'max');
8695
 
                var drawMonth = inst.drawMonth - showCurrentAtPos;
8696
 
                var drawYear = inst.drawYear;
8697
 
                if (drawMonth < 0) {
8698
 
                        drawMonth += 12;
8699
 
                        drawYear--;
8700
 
                }
8701
 
                if (maxDate) {
8702
 
                        var maxDraw = this._daylightSavingAdjust(new Date(maxDate.getFullYear(),
8703
 
                                maxDate.getMonth() - (numMonths[0] * numMonths[1]) + 1, maxDate.getDate()));
8704
 
                        maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw);
8705
 
                        while (this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1)) > maxDraw) {
8706
 
                                drawMonth--;
8707
 
                                if (drawMonth < 0) {
8708
 
                                        drawMonth = 11;
8709
 
                                        drawYear--;
8710
 
                                }
8711
 
                        }
8712
 
                }
8713
 
                inst.drawMonth = drawMonth;
8714
 
                inst.drawYear = drawYear;
8715
 
                var prevText = this._get(inst, 'prevText');
8716
 
                prevText = (!navigationAsDateFormat ? prevText : this.formatDate(prevText,
8717
 
                        this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)),
8718
 
                        this._getFormatConfig(inst)));
8719
 
                var prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ?
8720
 
                        '<a class="ui-datepicker-prev ui-corner-all" onclick="DP_jQuery_' + dpuuid +
8721
 
                        '.datepicker._adjustDate(\'#' + inst.id + '\', -' + stepMonths + ', \'M\');"' +
8722
 
                        ' title="' + prevText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'e' : 'w') + '">' + prevText + '</span></a>' :
8723
 
                        (hideIfNoPrevNext ? '' : '<a class="ui-datepicker-prev ui-corner-all ui-state-disabled" title="'+ prevText +'"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'e' : 'w') + '">' + prevText + '</span></a>'));
8724
 
                var nextText = this._get(inst, 'nextText');
8725
 
                nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText,
8726
 
                        this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)),
8727
 
                        this._getFormatConfig(inst)));
8728
 
                var next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ?
8729
 
                        '<a class="ui-datepicker-next ui-corner-all" onclick="DP_jQuery_' + dpuuid +
8730
 
                        '.datepicker._adjustDate(\'#' + inst.id + '\', +' + stepMonths + ', \'M\');"' +
8731
 
                        ' title="' + nextText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'w' : 'e') + '">' + nextText + '</span></a>' :
8732
 
                        (hideIfNoPrevNext ? '' : '<a class="ui-datepicker-next ui-corner-all ui-state-disabled" title="'+ nextText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'w' : 'e') + '">' + nextText + '</span></a>'));
8733
 
                var currentText = this._get(inst, 'currentText');
8734
 
                var gotoDate = (this._get(inst, 'gotoCurrent') && inst.currentDay ? currentDate : today);
8735
 
                currentText = (!navigationAsDateFormat ? currentText :
8736
 
                        this.formatDate(currentText, gotoDate, this._getFormatConfig(inst)));
8737
 
                var controls = (!inst.inline ? '<button type="button" class="ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all" onclick="DP_jQuery_' + dpuuid +
8738
 
                        '.datepicker._hideDatepicker();">' + this._get(inst, 'closeText') + '</button>' : '');
8739
 
                var buttonPanel = (showButtonPanel) ? '<div class="ui-datepicker-buttonpane ui-widget-content">' + (isRTL ? controls : '') +
8740
 
                        (this._isInRange(inst, gotoDate) ? '<button type="button" class="ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all" onclick="DP_jQuery_' + dpuuid +
8741
 
                        '.datepicker._gotoToday(\'#' + inst.id + '\');"' +
8742
 
                        '>' + currentText + '</button>' : '') + (isRTL ? '' : controls) + '</div>' : '';
8743
 
                var firstDay = parseInt(this._get(inst, 'firstDay'),10);
8744
 
                firstDay = (isNaN(firstDay) ? 0 : firstDay);
8745
 
                var showWeek = this._get(inst, 'showWeek');
8746
 
                var dayNames = this._get(inst, 'dayNames');
8747
 
                var dayNamesShort = this._get(inst, 'dayNamesShort');
8748
 
                var dayNamesMin = this._get(inst, 'dayNamesMin');
8749
 
                var monthNames = this._get(inst, 'monthNames');
8750
 
                var monthNamesShort = this._get(inst, 'monthNamesShort');
8751
 
                var beforeShowDay = this._get(inst, 'beforeShowDay');
8752
 
                var showOtherMonths = this._get(inst, 'showOtherMonths');
8753
 
                var selectOtherMonths = this._get(inst, 'selectOtherMonths');
8754
 
                var calculateWeek = this._get(inst, 'calculateWeek') || this.iso8601Week;
8755
 
                var defaultDate = this._getDefaultDate(inst);
8756
 
                var html = '';
8757
 
                for (var row = 0; row < numMonths[0]; row++) {
8758
 
                        var group = '';
8759
 
                        this.maxRows = 4;
8760
 
                        for (var col = 0; col < numMonths[1]; col++) {
8761
 
                                var selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay));
8762
 
                                var cornerClass = ' ui-corner-all';
8763
 
                                var calender = '';
8764
 
                                if (isMultiMonth) {
8765
 
                                        calender += '<div class="ui-datepicker-group';
8766
 
                                        if (numMonths[1] > 1)
8767
 
                                                switch (col) {
8768
 
                                                        case 0: calender += ' ui-datepicker-group-first';
8769
 
                                                                cornerClass = ' ui-corner-' + (isRTL ? 'right' : 'left'); break;
8770
 
                                                        case numMonths[1]-1: calender += ' ui-datepicker-group-last';
8771
 
                                                                cornerClass = ' ui-corner-' + (isRTL ? 'left' : 'right'); break;
8772
 
                                                        default: calender += ' ui-datepicker-group-middle'; cornerClass = ''; break;
8773
 
                                                }
8774
 
                                        calender += '">';
8775
 
                                }
8776
 
                                calender += '<div class="ui-datepicker-header ui-widget-header ui-helper-clearfix' + cornerClass + '">' +
8777
 
                                        (/all|left/.test(cornerClass) && row == 0 ? (isRTL ? next : prev) : '') +
8778
 
                                        (/all|right/.test(cornerClass) && row == 0 ? (isRTL ? prev : next) : '') +
8779
 
                                        this._generateMonthYearHeader(inst, drawMonth, drawYear, minDate, maxDate,
8780
 
                                        row > 0 || col > 0, monthNames, monthNamesShort) + // draw month headers
8781
 
                                        '</div><table class="ui-datepicker-calendar"><thead>' +
8782
 
                                        '<tr>';
8783
 
                                var thead = (showWeek ? '<th class="ui-datepicker-week-col">' + this._get(inst, 'weekHeader') + '</th>' : '');
8784
 
                                for (var dow = 0; dow < 7; dow++) { // days of the week
8785
 
                                        var day = (dow + firstDay) % 7;
8786
 
                                        thead += '<th' + ((dow + firstDay + 6) % 7 >= 5 ? ' class="ui-datepicker-week-end"' : '') + '>' +
8787
 
                                                '<span title="' + dayNames[day] + '">' + dayNamesMin[day] + '</span></th>';
8788
 
                                }
8789
 
                                calender += thead + '</tr></thead><tbody>';
8790
 
                                var daysInMonth = this._getDaysInMonth(drawYear, drawMonth);
8791
 
                                if (drawYear == inst.selectedYear && drawMonth == inst.selectedMonth)
8792
 
                                        inst.selectedDay = Math.min(inst.selectedDay, daysInMonth);
8793
 
                                var leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7;
8794
 
                                var curRows = Math.ceil((leadDays + daysInMonth) / 7); // calculate the number of rows to generate
8795
 
                                var numRows = (isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows); //If multiple months, use the higher number of rows (see #7043)
8796
 
                                this.maxRows = numRows;
8797
 
                                var printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays));
8798
 
                                for (var dRow = 0; dRow < numRows; dRow++) { // create date picker rows
8799
 
                                        calender += '<tr>';
8800
 
                                        var tbody = (!showWeek ? '' : '<td class="ui-datepicker-week-col">' +
8801
 
                                                this._get(inst, 'calculateWeek')(printDate) + '</td>');
8802
 
                                        for (var dow = 0; dow < 7; dow++) { // create date picker days
8803
 
                                                var daySettings = (beforeShowDay ?
8804
 
                                                        beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, '']);
8805
 
                                                var otherMonth = (printDate.getMonth() != drawMonth);
8806
 
                                                var unselectable = (otherMonth && !selectOtherMonths) || !daySettings[0] ||
8807
 
                                                        (minDate && printDate < minDate) || (maxDate && printDate > maxDate);
8808
 
                                                tbody += '<td class="' +
8809
 
                                                        ((dow + firstDay + 6) % 7 >= 5 ? ' ui-datepicker-week-end' : '') + // highlight weekends
8810
 
                                                        (otherMonth ? ' ui-datepicker-other-month' : '') + // highlight days from other months
8811
 
                                                        ((printDate.getTime() == selectedDate.getTime() && drawMonth == inst.selectedMonth && inst._keyEvent) || // user pressed key
8812
 
                                                        (defaultDate.getTime() == printDate.getTime() && defaultDate.getTime() == selectedDate.getTime()) ?
8813
 
                                                        // or defaultDate is current printedDate and defaultDate is selectedDate
8814
 
                                                        ' ' + this._dayOverClass : '') + // highlight selected day
8815
 
                                                        (unselectable ? ' ' + this._unselectableClass + ' ui-state-disabled': '') +  // highlight unselectable days
8816
 
                                                        (otherMonth && !showOtherMonths ? '' : ' ' + daySettings[1] + // highlight custom dates
8817
 
                                                        (printDate.getTime() == currentDate.getTime() ? ' ' + this._currentClass : '') + // highlight selected day
8818
 
                                                        (printDate.getTime() == today.getTime() ? ' ui-datepicker-today' : '')) + '"' + // highlight today (if different)
8819
 
                                                        ((!otherMonth || showOtherMonths) && daySettings[2] ? ' title="' + daySettings[2] + '"' : '') + // cell title
8820
 
                                                        (unselectable ? '' : ' onclick="DP_jQuery_' + dpuuid + '.datepicker._selectDay(\'#' +
8821
 
                                                        inst.id + '\',' + printDate.getMonth() + ',' + printDate.getFullYear() + ', this);return false;"') + '>' + // actions
8822
 
                                                        (otherMonth && !showOtherMonths ? '&#xa0;' : // display for other months
8823
 
                                                        (unselectable ? '<span class="ui-state-default">' + printDate.getDate() + '</span>' : '<a class="ui-state-default' +
8824
 
                                                        (printDate.getTime() == today.getTime() ? ' ui-state-highlight' : '') +
8825
 
                                                        (printDate.getTime() == currentDate.getTime() ? ' ui-state-active' : '') + // highlight selected day
8826
 
                                                        (otherMonth ? ' ui-priority-secondary' : '') + // distinguish dates from other months
8827
 
                                                        '" href="#">' + printDate.getDate() + '</a>')) + '</td>'; // display selectable date
8828
 
                                                printDate.setDate(printDate.getDate() + 1);
8829
 
                                                printDate = this._daylightSavingAdjust(printDate);
8830
 
                                        }
8831
 
                                        calender += tbody + '</tr>';
8832
 
                                }
8833
 
                                drawMonth++;
8834
 
                                if (drawMonth > 11) {
8835
 
                                        drawMonth = 0;
8836
 
                                        drawYear++;
8837
 
                                }
8838
 
                                calender += '</tbody></table>' + (isMultiMonth ? '</div>' + 
8839
 
                                                        ((numMonths[0] > 0 && col == numMonths[1]-1) ? '<div class="ui-datepicker-row-break"></div>' : '') : '');
8840
 
                                group += calender;
8841
 
                        }
8842
 
                        html += group;
8843
 
                }
8844
 
                html += buttonPanel + ($.browser.msie && parseInt($.browser.version,10) < 7 && !inst.inline ?
8845
 
                        '<iframe src="javascript:false;" class="ui-datepicker-cover" frameborder="0"></iframe>' : '');
8846
 
                inst._keyEvent = false;
8847
 
                return html;
8848
 
        },
8849
 
 
8850
 
        /* Generate the month and year header. */
8851
 
        _generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate,
8852
 
                        secondary, monthNames, monthNamesShort) {
8853
 
                var changeMonth = this._get(inst, 'changeMonth');
8854
 
                var changeYear = this._get(inst, 'changeYear');
8855
 
                var showMonthAfterYear = this._get(inst, 'showMonthAfterYear');
8856
 
                var html = '<div class="ui-datepicker-title">';
8857
 
                var monthHtml = '';
8858
 
                // month selection
8859
 
                if (secondary || !changeMonth)
8860
 
                        monthHtml += '<span class="ui-datepicker-month">' + monthNames[drawMonth] + '</span>';
8861
 
                else {
8862
 
                        var inMinYear = (minDate && minDate.getFullYear() == drawYear);
8863
 
                        var inMaxYear = (maxDate && maxDate.getFullYear() == drawYear);
8864
 
                        monthHtml += '<select class="ui-datepicker-month" ' +
8865
 
                                'onchange="DP_jQuery_' + dpuuid + '.datepicker._selectMonthYear(\'#' + inst.id + '\', this, \'M\');" ' +
8866
 
                                '>';
8867
 
                        for (var month = 0; month < 12; month++) {
8868
 
                                if ((!inMinYear || month >= minDate.getMonth()) &&
8869
 
                                                (!inMaxYear || month <= maxDate.getMonth()))
8870
 
                                        monthHtml += '<option value="' + month + '"' +
8871
 
                                                (month == drawMonth ? ' selected="selected"' : '') +
8872
 
                                                '>' + monthNamesShort[month] + '</option>';
8873
 
                        }
8874
 
                        monthHtml += '</select>';
8875
 
                }
8876
 
                if (!showMonthAfterYear)
8877
 
                        html += monthHtml + (secondary || !(changeMonth && changeYear) ? '&#xa0;' : '');
8878
 
                // year selection
8879
 
                if ( !inst.yearshtml ) {
8880
 
                        inst.yearshtml = '';
8881
 
                        if (secondary || !changeYear)
8882
 
                                html += '<span class="ui-datepicker-year">' + drawYear + '</span>';
8883
 
                        else {
8884
 
                                // determine range of years to display
8885
 
                                var years = this._get(inst, 'yearRange').split(':');
8886
 
                                var thisYear = new Date().getFullYear();
8887
 
                                var determineYear = function(value) {
8888
 
                                        var year = (value.match(/c[+-].*/) ? drawYear + parseInt(value.substring(1), 10) :
8889
 
                                                (value.match(/[+-].*/) ? thisYear + parseInt(value, 10) :
8890
 
                                                parseInt(value, 10)));
8891
 
                                        return (isNaN(year) ? thisYear : year);
8892
 
                                };
8893
 
                                var year = determineYear(years[0]);
8894
 
                                var endYear = Math.max(year, determineYear(years[1] || ''));
8895
 
                                year = (minDate ? Math.max(year, minDate.getFullYear()) : year);
8896
 
                                endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear);
8897
 
                                inst.yearshtml += '<select class="ui-datepicker-year" ' +
8898
 
                                        'onchange="DP_jQuery_' + dpuuid + '.datepicker._selectMonthYear(\'#' + inst.id + '\', this, \'Y\');" ' +
8899
 
                                        '>';
8900
 
                                for (; year <= endYear; year++) {
8901
 
                                        inst.yearshtml += '<option value="' + year + '"' +
8902
 
                                                (year == drawYear ? ' selected="selected"' : '') +
8903
 
                                                '>' + year + '</option>';
8904
 
                                }
8905
 
                                inst.yearshtml += '</select>';
8906
 
                                
8907
 
                                html += inst.yearshtml;
8908
 
                                inst.yearshtml = null;
8909
 
                        }
8910
 
                }
8911
 
                html += this._get(inst, 'yearSuffix');
8912
 
                if (showMonthAfterYear)
8913
 
                        html += (secondary || !(changeMonth && changeYear) ? '&#xa0;' : '') + monthHtml;
8914
 
                html += '</div>'; // Close datepicker_header
8915
 
                return html;
8916
 
        },
8917
 
 
8918
 
        /* Adjust one of the date sub-fields. */
8919
 
        _adjustInstDate: function(inst, offset, period) {
8920
 
                var year = inst.drawYear + (period == 'Y' ? offset : 0);
8921
 
                var month = inst.drawMonth + (period == 'M' ? offset : 0);
8922
 
                var day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) +
8923
 
                        (period == 'D' ? offset : 0);
8924
 
                var date = this._restrictMinMax(inst,
8925
 
                        this._daylightSavingAdjust(new Date(year, month, day)));
8926
 
                inst.selectedDay = date.getDate();
8927
 
                inst.drawMonth = inst.selectedMonth = date.getMonth();
8928
 
                inst.drawYear = inst.selectedYear = date.getFullYear();
8929
 
                if (period == 'M' || period == 'Y')
8930
 
                        this._notifyChange(inst);
8931
 
        },
8932
 
 
8933
 
        /* Ensure a date is within any min/max bounds. */
8934
 
        _restrictMinMax: function(inst, date) {
8935
 
                var minDate = this._getMinMaxDate(inst, 'min');
8936
 
                var maxDate = this._getMinMaxDate(inst, 'max');
8937
 
                var newDate = (minDate && date < minDate ? minDate : date);
8938
 
                newDate = (maxDate && newDate > maxDate ? maxDate : newDate);
8939
 
                return newDate;
8940
 
        },
8941
 
 
8942
 
        /* Notify change of month/year. */
8943
 
        _notifyChange: function(inst) {
8944
 
                var onChange = this._get(inst, 'onChangeMonthYear');
8945
 
                if (onChange)
8946
 
                        onChange.apply((inst.input ? inst.input[0] : null),
8947
 
                                [inst.selectedYear, inst.selectedMonth + 1, inst]);
8948
 
        },
8949
 
 
8950
 
        /* Determine the number of months to show. */
8951
 
        _getNumberOfMonths: function(inst) {
8952
 
                var numMonths = this._get(inst, 'numberOfMonths');
8953
 
                return (numMonths == null ? [1, 1] : (typeof numMonths == 'number' ? [1, numMonths] : numMonths));
8954
 
        },
8955
 
 
8956
 
        /* Determine the current maximum date - ensure no time components are set. */
8957
 
        _getMinMaxDate: function(inst, minMax) {
8958
 
                return this._determineDate(inst, this._get(inst, minMax + 'Date'), null);
8959
 
        },
8960
 
 
8961
 
        /* Find the number of days in a given month. */
8962
 
        _getDaysInMonth: function(year, month) {
8963
 
                return 32 - this._daylightSavingAdjust(new Date(year, month, 32)).getDate();
8964
 
        },
8965
 
 
8966
 
        /* Find the day of the week of the first of a month. */
8967
 
        _getFirstDayOfMonth: function(year, month) {
8968
 
                return new Date(year, month, 1).getDay();
8969
 
        },
8970
 
 
8971
 
        /* Determines if we should allow a "next/prev" month display change. */
8972
 
        _canAdjustMonth: function(inst, offset, curYear, curMonth) {
8973
 
                var numMonths = this._getNumberOfMonths(inst);
8974
 
                var date = this._daylightSavingAdjust(new Date(curYear,
8975
 
                        curMonth + (offset < 0 ? offset : numMonths[0] * numMonths[1]), 1));
8976
 
                if (offset < 0)
8977
 
                        date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth()));
8978
 
                return this._isInRange(inst, date);
8979
 
        },
8980
 
 
8981
 
        /* Is the given date in the accepted range? */
8982
 
        _isInRange: function(inst, date) {
8983
 
                var minDate = this._getMinMaxDate(inst, 'min');
8984
 
                var maxDate = this._getMinMaxDate(inst, 'max');
8985
 
                return ((!minDate || date.getTime() >= minDate.getTime()) &&
8986
 
                        (!maxDate || date.getTime() <= maxDate.getTime()));
8987
 
        },
8988
 
 
8989
 
        /* Provide the configuration settings for formatting/parsing. */
8990
 
        _getFormatConfig: function(inst) {
8991
 
                var shortYearCutoff = this._get(inst, 'shortYearCutoff');
8992
 
                shortYearCutoff = (typeof shortYearCutoff != 'string' ? shortYearCutoff :
8993
 
                        new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
8994
 
                return {shortYearCutoff: shortYearCutoff,
8995
 
                        dayNamesShort: this._get(inst, 'dayNamesShort'), dayNames: this._get(inst, 'dayNames'),
8996
 
                        monthNamesShort: this._get(inst, 'monthNamesShort'), monthNames: this._get(inst, 'monthNames')};
8997
 
        },
8998
 
 
8999
 
        /* Format the given date for display. */
9000
 
        _formatDate: function(inst, day, month, year) {
9001
 
                if (!day) {
9002
 
                        inst.currentDay = inst.selectedDay;
9003
 
                        inst.currentMonth = inst.selectedMonth;
9004
 
                        inst.currentYear = inst.selectedYear;
9005
 
                }
9006
 
                var date = (day ? (typeof day == 'object' ? day :
9007
 
                        this._daylightSavingAdjust(new Date(year, month, day))) :
9008
 
                        this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
9009
 
                return this.formatDate(this._get(inst, 'dateFormat'), date, this._getFormatConfig(inst));
9010
 
        }
9011
 
});
9012
 
 
9013
 
/*
9014
 
 * Bind hover events for datepicker elements.
9015
 
 * Done via delegate so the binding only occurs once in the lifetime of the parent div.
9016
 
 * Global instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker.
9017
 
 */ 
9018
 
function bindHover(dpDiv) {
9019
 
        var selector = 'button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a';
9020
 
        return dpDiv.bind('mouseout', function(event) {
9021
 
                        var elem = $( event.target ).closest( selector );
9022
 
                        if ( !elem.length ) {
9023
 
                                return;
9024
 
                        }
9025
 
                        elem.removeClass( "ui-state-hover ui-datepicker-prev-hover ui-datepicker-next-hover" );
9026
 
                })
9027
 
                .bind('mouseover', function(event) {
9028
 
                        var elem = $( event.target ).closest( selector );
9029
 
                        if ($.datepicker._isDisabledDatepicker( instActive.inline ? dpDiv.parent()[0] : instActive.input[0]) ||
9030
 
                                        !elem.length ) {
9031
 
                                return;
9032
 
                        }
9033
 
                        elem.parents('.ui-datepicker-calendar').find('a').removeClass('ui-state-hover');
9034
 
                        elem.addClass('ui-state-hover');
9035
 
                        if (elem.hasClass('ui-datepicker-prev')) elem.addClass('ui-datepicker-prev-hover');
9036
 
                        if (elem.hasClass('ui-datepicker-next')) elem.addClass('ui-datepicker-next-hover');
9037
 
                });
9038
 
}
9039
 
 
9040
 
/* jQuery extend now ignores nulls! */
9041
 
function extendRemove(target, props) {
9042
 
        $.extend(target, props);
9043
 
        for (var name in props)
9044
 
                if (props[name] == null || props[name] == undefined)
9045
 
                        target[name] = props[name];
9046
 
        return target;
9047
 
};
9048
 
 
9049
 
/* Determine whether an object is an array. */
9050
 
function isArray(a) {
9051
 
        return (a && (($.browser.safari && typeof a == 'object' && a.length) ||
9052
 
                (a.constructor && a.constructor.toString().match(/\Array\(\)/))));
9053
 
};
9054
 
 
9055
 
/* Invoke the datepicker functionality.
9056
 
   @param  options  string - a command, optionally followed by additional parameters or
9057
 
                    Object - settings for attaching new datepicker functionality
9058
 
   @return  jQuery object */
9059
 
$.fn.datepicker = function(options){
9060
 
        
9061
 
        /* Verify an empty collection wasn't passed - Fixes #6976 */
9062
 
        if ( !this.length ) {
9063
 
                return this;
9064
 
        }
9065
 
        
9066
 
        /* Initialise the date picker. */
9067
 
        if (!$.datepicker.initialized) {
9068
 
                $(document).mousedown($.datepicker._checkExternalClick).
9069
 
                        find('body').append($.datepicker.dpDiv);
9070
 
                $.datepicker.initialized = true;
9071
 
        }
9072
 
 
9073
 
        var otherArgs = Array.prototype.slice.call(arguments, 1);
9074
 
        if (typeof options == 'string' && (options == 'isDisabled' || options == 'getDate' || options == 'widget'))
9075
 
                return $.datepicker['_' + options + 'Datepicker'].
9076
 
                        apply($.datepicker, [this[0]].concat(otherArgs));
9077
 
        if (options == 'option' && arguments.length == 2 && typeof arguments[1] == 'string')
9078
 
                return $.datepicker['_' + options + 'Datepicker'].
9079
 
                        apply($.datepicker, [this[0]].concat(otherArgs));
9080
 
        return this.each(function() {
9081
 
                typeof options == 'string' ?
9082
 
                        $.datepicker['_' + options + 'Datepicker'].
9083
 
                                apply($.datepicker, [this].concat(otherArgs)) :
9084
 
                        $.datepicker._attachDatepicker(this, options);
9085
 
        });
9086
 
};
9087
 
 
9088
 
$.datepicker = new Datepicker(); // singleton instance
9089
 
$.datepicker.initialized = false;
9090
 
$.datepicker.uuid = new Date().getTime();
9091
 
$.datepicker.version = "1.8.18";
9092
 
 
9093
 
// Workaround for #4055
9094
 
// Add another global to avoid noConflict issues with inline event handlers
9095
 
window['DP_jQuery_' + dpuuid] = $;
9096
 
 
9097
 
})(jQuery);
9098
 
/*
9099
 
 * jQuery UI Dialog 1.8.18
9100
 
 *
9101
 
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
9102
 
 * Dual licensed under the MIT or GPL Version 2 licenses.
9103
 
 * http://jquery.org/license
9104
 
 *
9105
 
 * http://docs.jquery.com/UI/Dialog
9106
 
 *
9107
 
 * Depends:
9108
 
 *      jquery.ui.core.js
9109
 
 *      jquery.ui.widget.js
9110
 
 *  jquery.ui.button.js
9111
 
 *      jquery.ui.draggable.js
9112
 
 *      jquery.ui.mouse.js
9113
 
 *      jquery.ui.position.js
9114
 
 *      jquery.ui.resizable.js
9115
 
 */
9116
 
(function( $, undefined ) {
9117
 
 
9118
 
var uiDialogClasses =
9119
 
                'ui-dialog ' +
9120
 
                'ui-widget ' +
9121
 
                'ui-widget-content ' +
9122
 
                'ui-corner-all ',
9123
 
        sizeRelatedOptions = {
9124
 
                buttons: true,
9125
 
                height: true,
9126
 
                maxHeight: true,
9127
 
                maxWidth: true,
9128
 
                minHeight: true,
9129
 
                minWidth: true,
9130
 
                width: true
9131
 
        },
9132
 
        resizableRelatedOptions = {
9133
 
                maxHeight: true,
9134
 
                maxWidth: true,
9135
 
                minHeight: true,
9136
 
                minWidth: true
9137
 
        },
9138
 
        // support for jQuery 1.3.2 - handle common attrFn methods for dialog
9139
 
        attrFn = $.attrFn || {
9140
 
                val: true,
9141
 
                css: true,
9142
 
                html: true,
9143
 
                text: true,
9144
 
                data: true,
9145
 
                width: true,
9146
 
                height: true,
9147
 
                offset: true,
9148
 
                click: true
9149
 
        };
9150
 
 
9151
 
$.widget("ui.dialog", {
9152
 
        options: {
9153
 
                autoOpen: true,
9154
 
                buttons: {},
9155
 
                closeOnEscape: true,
9156
 
                closeText: 'close',
9157
 
                dialogClass: '',
9158
 
                draggable: true,
9159
 
                hide: null,
9160
 
                height: 'auto',
9161
 
                maxHeight: false,
9162
 
                maxWidth: false,
9163
 
                minHeight: 150,
9164
 
                minWidth: 150,
9165
 
                modal: false,
9166
 
                position: {
9167
 
                        my: 'center',
9168
 
                        at: 'center',
9169
 
                        collision: 'fit',
9170
 
                        // ensure that the titlebar is never outside the document
9171
 
                        using: function(pos) {
9172
 
                                var topOffset = $(this).css(pos).offset().top;
9173
 
                                if (topOffset < 0) {
9174
 
                                        $(this).css('top', pos.top - topOffset);
9175
 
                                }
9176
 
                        }
9177
 
                },
9178
 
                resizable: true,
9179
 
                show: null,
9180
 
                stack: true,
9181
 
                title: '',
9182
 
                width: 300,
9183
 
                zIndex: 1000
9184
 
        },
9185
 
 
9186
 
        _create: function() {
9187
 
                this.originalTitle = this.element.attr('title');
9188
 
                // #5742 - .attr() might return a DOMElement
9189
 
                if ( typeof this.originalTitle !== "string" ) {
9190
 
                        this.originalTitle = "";
9191
 
                }
9192
 
 
9193
 
                this.options.title = this.options.title || this.originalTitle;
9194
 
                var self = this,
9195
 
                        options = self.options,
9196
 
 
9197
 
                        title = options.title || '&#160;',
9198
 
                        titleId = $.ui.dialog.getTitleId(self.element),
9199
 
 
9200
 
                        uiDialog = (self.uiDialog = $('<div></div>'))
9201
 
                                .appendTo(document.body)
9202
 
                                .hide()
9203
 
                                .addClass(uiDialogClasses + options.dialogClass)
9204
 
                                .css({
9205
 
                                        zIndex: options.zIndex
9206
 
                                })
9207
 
                                // setting tabIndex makes the div focusable
9208
 
                                // setting outline to 0 prevents a border on focus in Mozilla
9209
 
                                .attr('tabIndex', -1).css('outline', 0).keydown(function(event) {
9210
 
                                        if (options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
9211
 
                                                event.keyCode === $.ui.keyCode.ESCAPE) {
9212
 
                                                
9213
 
                                                self.close(event);
9214
 
                                                event.preventDefault();
9215
 
                                        }
9216
 
                                })
9217
 
                                .attr({
9218
 
                                        role: 'dialog',
9219
 
                                        'aria-labelledby': titleId
9220
 
                                })
9221
 
                                .mousedown(function(event) {
9222
 
                                        self.moveToTop(false, event);
9223
 
                                }),
9224
 
 
9225
 
                        uiDialogContent = self.element
9226
 
                                .show()
9227
 
                                .removeAttr('title')
9228
 
                                .addClass(
9229
 
                                        'ui-dialog-content ' +
9230
 
                                        'ui-widget-content')
9231
 
                                .appendTo(uiDialog),
9232
 
 
9233
 
                        uiDialogTitlebar = (self.uiDialogTitlebar = $('<div></div>'))
9234
 
                                .addClass(
9235
 
                                        'ui-dialog-titlebar ' +
9236
 
                                        'ui-widget-header ' +
9237
 
                                        'ui-corner-all ' +
9238
 
                                        'ui-helper-clearfix'
9239
 
                                )
9240
 
                                .prependTo(uiDialog),
9241
 
 
9242
 
                        uiDialogTitlebarClose = $('<a href="#"></a>')
9243
 
                                .addClass(
9244
 
                                        'ui-dialog-titlebar-close ' +
9245
 
                                        'ui-corner-all'
9246
 
                                )
9247
 
                                .attr('role', 'button')
9248
 
                                .hover(
9249
 
                                        function() {
9250
 
                                                uiDialogTitlebarClose.addClass('ui-state-hover');
9251
 
                                        },
9252
 
                                        function() {
9253
 
                                                uiDialogTitlebarClose.removeClass('ui-state-hover');
9254
 
                                        }
9255
 
                                )
9256
 
                                .focus(function() {
9257
 
                                        uiDialogTitlebarClose.addClass('ui-state-focus');
9258
 
                                })
9259
 
                                .blur(function() {
9260
 
                                        uiDialogTitlebarClose.removeClass('ui-state-focus');
9261
 
                                })
9262
 
                                .click(function(event) {
9263
 
                                        self.close(event);
9264
 
                                        return false;
9265
 
                                })
9266
 
                                .appendTo(uiDialogTitlebar),
9267
 
 
9268
 
                        uiDialogTitlebarCloseText = (self.uiDialogTitlebarCloseText = $('<span></span>'))
9269
 
                                .addClass(
9270
 
                                        'ui-icon ' +
9271
 
                                        'ui-icon-closethick'
9272
 
                                )
9273
 
                                .text(options.closeText)
9274
 
                                .appendTo(uiDialogTitlebarClose),
9275
 
 
9276
 
                        uiDialogTitle = $('<span></span>')
9277
 
                                .addClass('ui-dialog-title')
9278
 
                                .attr('id', titleId)
9279
 
                                .html(title)
9280
 
                                .prependTo(uiDialogTitlebar);
9281
 
 
9282
 
                //handling of deprecated beforeclose (vs beforeClose) option
9283
 
                //Ticket #4669 http://dev.jqueryui.com/ticket/4669
9284
 
                //TODO: remove in 1.9pre
9285
 
                if ($.isFunction(options.beforeclose) && !$.isFunction(options.beforeClose)) {
9286
 
                        options.beforeClose = options.beforeclose;
9287
 
                }
9288
 
 
9289
 
                uiDialogTitlebar.find("*").add(uiDialogTitlebar).disableSelection();
9290
 
 
9291
 
                if (options.draggable && $.fn.draggable) {
9292
 
                        self._makeDraggable();
9293
 
                }
9294
 
                if (options.resizable && $.fn.resizable) {
9295
 
                        self._makeResizable();
9296
 
                }
9297
 
 
9298
 
                self._createButtons(options.buttons);
9299
 
                self._isOpen = false;
9300
 
 
9301
 
                if ($.fn.bgiframe) {
9302
 
                        uiDialog.bgiframe();
9303
 
                }
9304
 
        },
9305
 
 
9306
 
        _init: function() {
9307
 
                if ( this.options.autoOpen ) {
9308
 
                        this.open();
9309
 
                }
9310
 
        },
9311
 
 
9312
 
        destroy: function() {
9313
 
                var self = this;
9314
 
                
9315
 
                if (self.overlay) {
9316
 
                        self.overlay.destroy();
9317
 
                }
9318
 
                self.uiDialog.hide();
9319
 
                self.element
9320
 
                        .unbind('.dialog')
9321
 
                        .removeData('dialog')
9322
 
                        .removeClass('ui-dialog-content ui-widget-content')
9323
 
                        .hide().appendTo('body');
9324
 
                self.uiDialog.remove();
9325
 
 
9326
 
                if (self.originalTitle) {
9327
 
                        self.element.attr('title', self.originalTitle);
9328
 
                }
9329
 
 
9330
 
                return self;
9331
 
        },
9332
 
 
9333
 
        widget: function() {
9334
 
                return this.uiDialog;
9335
 
        },
9336
 
 
9337
 
        close: function(event) {
9338
 
                var self = this,
9339
 
                        maxZ, thisZ;
9340
 
                
9341
 
                if (false === self._trigger('beforeClose', event)) {
9342
 
                        return;
9343
 
                }
9344
 
 
9345
 
                if (self.overlay) {
9346
 
                        self.overlay.destroy();
9347
 
                }
9348
 
                self.uiDialog.unbind('keypress.ui-dialog');
9349
 
 
9350
 
                self._isOpen = false;
9351
 
 
9352
 
                if (self.options.hide) {
9353
 
                        self.uiDialog.hide(self.options.hide, function() {
9354
 
                                self._trigger('close', event);
9355
 
                        });
9356
 
                } else {
9357
 
                        self.uiDialog.hide();
9358
 
                        self._trigger('close', event);
9359
 
                }
9360
 
 
9361
 
                $.ui.dialog.overlay.resize();
9362
 
 
9363
 
                // adjust the maxZ to allow other modal dialogs to continue to work (see #4309)
9364
 
                if (self.options.modal) {
9365
 
                        maxZ = 0;
9366
 
                        $('.ui-dialog').each(function() {
9367
 
                                if (this !== self.uiDialog[0]) {
9368
 
                                        thisZ = $(this).css('z-index');
9369
 
                                        if(!isNaN(thisZ)) {
9370
 
                                                maxZ = Math.max(maxZ, thisZ);
9371
 
                                        }
9372
 
                                }
9373
 
                        });
9374
 
                        $.ui.dialog.maxZ = maxZ;
9375
 
                }
9376
 
 
9377
 
                return self;
9378
 
        },
9379
 
 
9380
 
        isOpen: function() {
9381
 
                return this._isOpen;
9382
 
        },
9383
 
 
9384
 
        // the force parameter allows us to move modal dialogs to their correct
9385
 
        // position on open
9386
 
        moveToTop: function(force, event) {
9387
 
                var self = this,
9388
 
                        options = self.options,
9389
 
                        saveScroll;
9390
 
 
9391
 
                if ((options.modal && !force) ||
9392
 
                        (!options.stack && !options.modal)) {
9393
 
                        return self._trigger('focus', event);
9394
 
                }
9395
 
 
9396
 
                if (options.zIndex > $.ui.dialog.maxZ) {
9397
 
                        $.ui.dialog.maxZ = options.zIndex;
9398
 
                }
9399
 
                if (self.overlay) {
9400
 
                        $.ui.dialog.maxZ += 1;
9401
 
                        self.overlay.$el.css('z-index', $.ui.dialog.overlay.maxZ = $.ui.dialog.maxZ);
9402
 
                }
9403
 
 
9404
 
                //Save and then restore scroll since Opera 9.5+ resets when parent z-Index is changed.
9405
 
                //  http://ui.jquery.com/bugs/ticket/3193
9406
 
                saveScroll = { scrollTop: self.element.scrollTop(), scrollLeft: self.element.scrollLeft() };
9407
 
                $.ui.dialog.maxZ += 1;
9408
 
                self.uiDialog.css('z-index', $.ui.dialog.maxZ);
9409
 
                self.element.attr(saveScroll);
9410
 
                self._trigger('focus', event);
9411
 
 
9412
 
                return self;
9413
 
        },
9414
 
 
9415
 
        open: function() {
9416
 
                if (this._isOpen) { return; }
9417
 
 
9418
 
                var self = this,
9419
 
                        options = self.options,
9420
 
                        uiDialog = self.uiDialog;
9421
 
 
9422
 
                self.overlay = options.modal ? new $.ui.dialog.overlay(self) : null;
9423
 
                self._size();
9424
 
                self._position(options.position);
9425
 
                uiDialog.show(options.show);
9426
 
                self.moveToTop(true);
9427
 
 
9428
 
                // prevent tabbing out of modal dialogs
9429
 
                if ( options.modal ) {
9430
 
                        uiDialog.bind( "keydown.ui-dialog", function( event ) {
9431
 
                                if ( event.keyCode !== $.ui.keyCode.TAB ) {
9432
 
                                        return;
9433
 
                                }
9434
 
 
9435
 
                                var tabbables = $(':tabbable', this),
9436
 
                                        first = tabbables.filter(':first'),
9437
 
                                        last  = tabbables.filter(':last');
9438
 
 
9439
 
                                if (event.target === last[0] && !event.shiftKey) {
9440
 
                                        first.focus(1);
9441
 
                                        return false;
9442
 
                                } else if (event.target === first[0] && event.shiftKey) {
9443
 
                                        last.focus(1);
9444
 
                                        return false;
9445
 
                                }
9446
 
                        });
9447
 
                }
9448
 
 
9449
 
                // set focus to the first tabbable element in the content area or the first button
9450
 
                // if there are no tabbable elements, set focus on the dialog itself
9451
 
                $(self.element.find(':tabbable').get().concat(
9452
 
                        uiDialog.find('.ui-dialog-buttonpane :tabbable').get().concat(
9453
 
                                uiDialog.get()))).eq(0).focus();
9454
 
 
9455
 
                self._isOpen = true;
9456
 
                self._trigger('open');
9457
 
 
9458
 
                return self;
9459
 
        },
9460
 
 
9461
 
        _createButtons: function(buttons) {
9462
 
                var self = this,
9463
 
                        hasButtons = false,
9464
 
                        uiDialogButtonPane = $('<div></div>')
9465
 
                                .addClass(
9466
 
                                        'ui-dialog-buttonpane ' +
9467
 
                                        'ui-widget-content ' +
9468
 
                                        'ui-helper-clearfix'
9469
 
                                ),
9470
 
                        uiButtonSet = $( "<div></div>" )
9471
 
                                .addClass( "ui-dialog-buttonset" )
9472
 
                                .appendTo( uiDialogButtonPane );
9473
 
 
9474
 
                // if we already have a button pane, remove it
9475
 
                self.uiDialog.find('.ui-dialog-buttonpane').remove();
9476
 
 
9477
 
                if (typeof buttons === 'object' && buttons !== null) {
9478
 
                        $.each(buttons, function() {
9479
 
                                return !(hasButtons = true);
9480
 
                        });
9481
 
                }
9482
 
                if (hasButtons) {
9483
 
                        $.each(buttons, function(name, props) {
9484
 
                                props = $.isFunction( props ) ?
9485
 
                                        { click: props, text: name } :
9486
 
                                        props;
9487
 
                                var button = $('<button type="button"></button>')
9488
 
                                        .click(function() {
9489
 
                                                props.click.apply(self.element[0], arguments);
9490
 
                                        })
9491
 
                                        .appendTo(uiButtonSet);
9492
 
                                // can't use .attr( props, true ) with jQuery 1.3.2.
9493
 
                                $.each( props, function( key, value ) {
9494
 
                                        if ( key === "click" ) {
9495
 
                                                return;
9496
 
                                        }
9497
 
                                        if ( key in attrFn ) {
9498
 
                                                button[ key ]( value );
9499
 
                                        } else {
9500
 
                                                button.attr( key, value );
9501
 
                                        }
9502
 
                                });
9503
 
                                if ($.fn.button) {
9504
 
                                        button.button();
9505
 
                                }
9506
 
                        });
9507
 
                        uiDialogButtonPane.appendTo(self.uiDialog);
9508
 
                }
9509
 
        },
9510
 
 
9511
 
        _makeDraggable: function() {
9512
 
                var self = this,
9513
 
                        options = self.options,
9514
 
                        doc = $(document),
9515
 
                        heightBeforeDrag;
9516
 
 
9517
 
                function filteredUi(ui) {
9518
 
                        return {
9519
 
                                position: ui.position,
9520
 
                                offset: ui.offset
9521
 
                        };
9522
 
                }
9523
 
 
9524
 
                self.uiDialog.draggable({
9525
 
                        cancel: '.ui-dialog-content, .ui-dialog-titlebar-close',
9526
 
                        handle: '.ui-dialog-titlebar',
9527
 
                        containment: 'document',
9528
 
                        start: function(event, ui) {
9529
 
                                heightBeforeDrag = options.height === "auto" ? "auto" : $(this).height();
9530
 
                                $(this).height($(this).height()).addClass("ui-dialog-dragging");
9531
 
                                self._trigger('dragStart', event, filteredUi(ui));
9532
 
                        },
9533
 
                        drag: function(event, ui) {
9534
 
                                self._trigger('drag', event, filteredUi(ui));
9535
 
                        },
9536
 
                        stop: function(event, ui) {
9537
 
                                options.position = [ui.position.left - doc.scrollLeft(),
9538
 
                                        ui.position.top - doc.scrollTop()];
9539
 
                                $(this).removeClass("ui-dialog-dragging").height(heightBeforeDrag);
9540
 
                                self._trigger('dragStop', event, filteredUi(ui));
9541
 
                                $.ui.dialog.overlay.resize();
9542
 
                        }
9543
 
                });
9544
 
        },
9545
 
 
9546
 
        _makeResizable: function(handles) {
9547
 
                handles = (handles === undefined ? this.options.resizable : handles);
9548
 
                var self = this,
9549
 
                        options = self.options,
9550
 
                        // .ui-resizable has position: relative defined in the stylesheet
9551
 
                        // but dialogs have to use absolute or fixed positioning
9552
 
                        position = self.uiDialog.css('position'),
9553
 
                        resizeHandles = (typeof handles === 'string' ?
9554
 
                                handles :
9555
 
                                'n,e,s,w,se,sw,ne,nw'
9556
 
                        );
9557
 
 
9558
 
                function filteredUi(ui) {
9559
 
                        return {
9560
 
                                originalPosition: ui.originalPosition,
9561
 
                                originalSize: ui.originalSize,
9562
 
                                position: ui.position,
9563
 
                                size: ui.size
9564
 
                        };
9565
 
                }
9566
 
 
9567
 
                self.uiDialog.resizable({
9568
 
                        cancel: '.ui-dialog-content',
9569
 
                        containment: 'document',
9570
 
                        alsoResize: self.element,
9571
 
                        maxWidth: options.maxWidth,
9572
 
                        maxHeight: options.maxHeight,
9573
 
                        minWidth: options.minWidth,
9574
 
                        minHeight: self._minHeight(),
9575
 
                        handles: resizeHandles,
9576
 
                        start: function(event, ui) {
9577
 
                                $(this).addClass("ui-dialog-resizing");
9578
 
                                self._trigger('resizeStart', event, filteredUi(ui));
9579
 
                        },
9580
 
                        resize: function(event, ui) {
9581
 
                                self._trigger('resize', event, filteredUi(ui));
9582
 
                        },
9583
 
                        stop: function(event, ui) {
9584
 
                                $(this).removeClass("ui-dialog-resizing");
9585
 
                                options.height = $(this).height();
9586
 
                                options.width = $(this).width();
9587
 
                                self._trigger('resizeStop', event, filteredUi(ui));
9588
 
                                $.ui.dialog.overlay.resize();
9589
 
                        }
9590
 
                })
9591
 
                .css('position', position)
9592
 
                .find('.ui-resizable-se').addClass('ui-icon ui-icon-grip-diagonal-se');
9593
 
        },
9594
 
 
9595
 
        _minHeight: function() {
9596
 
                var options = this.options;
9597
 
 
9598
 
                if (options.height === 'auto') {
9599
 
                        return options.minHeight;
9600
 
                } else {
9601
 
                        return Math.min(options.minHeight, options.height);
9602
 
                }
9603
 
        },
9604
 
 
9605
 
        _position: function(position) {
9606
 
                var myAt = [],
9607
 
                        offset = [0, 0],
9608
 
                        isVisible;
9609
 
 
9610
 
                if (position) {
9611
 
                        // deep extending converts arrays to objects in jQuery <= 1.3.2 :-(
9612
 
        //              if (typeof position == 'string' || $.isArray(position)) {
9613
 
        //                      myAt = $.isArray(position) ? position : position.split(' ');
9614
 
 
9615
 
                        if (typeof position === 'string' || (typeof position === 'object' && '0' in position)) {
9616
 
                                myAt = position.split ? position.split(' ') : [position[0], position[1]];
9617
 
                                if (myAt.length === 1) {
9618
 
                                        myAt[1] = myAt[0];
9619
 
                                }
9620
 
 
9621
 
                                $.each(['left', 'top'], function(i, offsetPosition) {
9622
 
                                        if (+myAt[i] === myAt[i]) {
9623
 
                                                offset[i] = myAt[i];
9624
 
                                                myAt[i] = offsetPosition;
9625
 
                                        }
9626
 
                                });
9627
 
 
9628
 
                                position = {
9629
 
                                        my: myAt.join(" "),
9630
 
                                        at: myAt.join(" "),
9631
 
                                        offset: offset.join(" ")
9632
 
                                };
9633
 
                        } 
9634
 
 
9635
 
                        position = $.extend({}, $.ui.dialog.prototype.options.position, position);
9636
 
                } else {
9637
 
                        position = $.ui.dialog.prototype.options.position;
9638
 
                }
9639
 
 
9640
 
                // need to show the dialog to get the actual offset in the position plugin
9641
 
                isVisible = this.uiDialog.is(':visible');
9642
 
                if (!isVisible) {
9643
 
                        this.uiDialog.show();
9644
 
                }
9645
 
                this.uiDialog
9646
 
                        // workaround for jQuery bug #5781 http://dev.jquery.com/ticket/5781
9647
 
                        .css({ top: 0, left: 0 })
9648
 
                        .position($.extend({ of: window }, position));
9649
 
                if (!isVisible) {
9650
 
                        this.uiDialog.hide();
9651
 
                }
9652
 
        },
9653
 
 
9654
 
        _setOptions: function( options ) {
9655
 
                var self = this,
9656
 
                        resizableOptions = {},
9657
 
                        resize = false;
9658
 
 
9659
 
                $.each( options, function( key, value ) {
9660
 
                        self._setOption( key, value );
9661
 
                        
9662
 
                        if ( key in sizeRelatedOptions ) {
9663
 
                                resize = true;
9664
 
                        }
9665
 
                        if ( key in resizableRelatedOptions ) {
9666
 
                                resizableOptions[ key ] = value;
9667
 
                        }
9668
 
                });
9669
 
 
9670
 
                if ( resize ) {
9671
 
                        this._size();
9672
 
                }
9673
 
                if ( this.uiDialog.is( ":data(resizable)" ) ) {
9674
 
                        this.uiDialog.resizable( "option", resizableOptions );
9675
 
                }
9676
 
        },
9677
 
 
9678
 
        _setOption: function(key, value){
9679
 
                var self = this,
9680
 
                        uiDialog = self.uiDialog;
9681
 
 
9682
 
                switch (key) {
9683
 
                        //handling of deprecated beforeclose (vs beforeClose) option
9684
 
                        //Ticket #4669 http://dev.jqueryui.com/ticket/4669
9685
 
                        //TODO: remove in 1.9pre
9686
 
                        case "beforeclose":
9687
 
                                key = "beforeClose";
9688
 
                                break;
9689
 
                        case "buttons":
9690
 
                                self._createButtons(value);
9691
 
                                break;
9692
 
                        case "closeText":
9693
 
                                // ensure that we always pass a string
9694
 
                                self.uiDialogTitlebarCloseText.text("" + value);
9695
 
                                break;
9696
 
                        case "dialogClass":
9697
 
                                uiDialog
9698
 
                                        .removeClass(self.options.dialogClass)
9699
 
                                        .addClass(uiDialogClasses + value);
9700
 
                                break;
9701
 
                        case "disabled":
9702
 
                                if (value) {
9703
 
                                        uiDialog.addClass('ui-dialog-disabled');
9704
 
                                } else {
9705
 
                                        uiDialog.removeClass('ui-dialog-disabled');
9706
 
                                }
9707
 
                                break;
9708
 
                        case "draggable":
9709
 
                                var isDraggable = uiDialog.is( ":data(draggable)" );
9710
 
                                if ( isDraggable && !value ) {
9711
 
                                        uiDialog.draggable( "destroy" );
9712
 
                                }
9713
 
                                
9714
 
                                if ( !isDraggable && value ) {
9715
 
                                        self._makeDraggable();
9716
 
                                }
9717
 
                                break;
9718
 
                        case "position":
9719
 
                                self._position(value);
9720
 
                                break;
9721
 
                        case "resizable":
9722
 
                                // currently resizable, becoming non-resizable
9723
 
                                var isResizable = uiDialog.is( ":data(resizable)" );
9724
 
                                if (isResizable && !value) {
9725
 
                                        uiDialog.resizable('destroy');
9726
 
                                }
9727
 
 
9728
 
                                // currently resizable, changing handles
9729
 
                                if (isResizable && typeof value === 'string') {
9730
 
                                        uiDialog.resizable('option', 'handles', value);
9731
 
                                }
9732
 
 
9733
 
                                // currently non-resizable, becoming resizable
9734
 
                                if (!isResizable && value !== false) {
9735
 
                                        self._makeResizable(value);
9736
 
                                }
9737
 
                                break;
9738
 
                        case "title":
9739
 
                                // convert whatever was passed in o a string, for html() to not throw up
9740
 
                                $(".ui-dialog-title", self.uiDialogTitlebar).html("" + (value || '&#160;'));
9741
 
                                break;
9742
 
                }
9743
 
 
9744
 
                $.Widget.prototype._setOption.apply(self, arguments);
9745
 
        },
9746
 
 
9747
 
        _size: function() {
9748
 
                /* If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
9749
 
                 * divs will both have width and height set, so we need to reset them
9750
 
                 */
9751
 
                var options = this.options,
9752
 
                        nonContentHeight,
9753
 
                        minContentHeight,
9754
 
                        isVisible = this.uiDialog.is( ":visible" );
9755
 
 
9756
 
                // reset content sizing
9757
 
                this.element.show().css({
9758
 
                        width: 'auto',
9759
 
                        minHeight: 0,
9760
 
                        height: 0
9761
 
                });
9762
 
 
9763
 
                if (options.minWidth > options.width) {
9764
 
                        options.width = options.minWidth;
9765
 
                }
9766
 
 
9767
 
                // reset wrapper sizing
9768
 
                // determine the height of all the non-content elements
9769
 
                nonContentHeight = this.uiDialog.css({
9770
 
                                height: 'auto',
9771
 
                                width: options.width
9772
 
                        })
9773
 
                        .height();
9774
 
                minContentHeight = Math.max( 0, options.minHeight - nonContentHeight );
9775
 
                
9776
 
                if ( options.height === "auto" ) {
9777
 
                        // only needed for IE6 support
9778
 
                        if ( $.support.minHeight ) {
9779
 
                                this.element.css({
9780
 
                                        minHeight: minContentHeight,
9781
 
                                        height: "auto"
9782
 
                                });
9783
 
                        } else {
9784
 
                                this.uiDialog.show();
9785
 
                                var autoHeight = this.element.css( "height", "auto" ).height();
9786
 
                                if ( !isVisible ) {
9787
 
                                        this.uiDialog.hide();
9788
 
                                }
9789
 
                                this.element.height( Math.max( autoHeight, minContentHeight ) );
9790
 
                        }
9791
 
                } else {
9792
 
                        this.element.height( Math.max( options.height - nonContentHeight, 0 ) );
9793
 
                }
9794
 
 
9795
 
                if (this.uiDialog.is(':data(resizable)')) {
9796
 
                        this.uiDialog.resizable('option', 'minHeight', this._minHeight());
9797
 
                }
9798
 
        }
9799
 
});
9800
 
 
9801
 
$.extend($.ui.dialog, {
9802
 
        version: "1.8.18",
9803
 
 
9804
 
        uuid: 0,
9805
 
        maxZ: 0,
9806
 
 
9807
 
        getTitleId: function($el) {
9808
 
                var id = $el.attr('id');
9809
 
                if (!id) {
9810
 
                        this.uuid += 1;
9811
 
                        id = this.uuid;
9812
 
                }
9813
 
                return 'ui-dialog-title-' + id;
9814
 
        },
9815
 
 
9816
 
        overlay: function(dialog) {
9817
 
                this.$el = $.ui.dialog.overlay.create(dialog);
9818
 
        }
9819
 
});
9820
 
 
9821
 
$.extend($.ui.dialog.overlay, {
9822
 
        instances: [],
9823
 
        // reuse old instances due to IE memory leak with alpha transparency (see #5185)
9824
 
        oldInstances: [],
9825
 
        maxZ: 0,
9826
 
        events: $.map('focus,mousedown,mouseup,keydown,keypress,click'.split(','),
9827
 
                function(event) { return event + '.dialog-overlay'; }).join(' '),
9828
 
        create: function(dialog) {
9829
 
                if (this.instances.length === 0) {
9830
 
                        // prevent use of anchors and inputs
9831
 
                        // we use a setTimeout in case the overlay is created from an
9832
 
                        // event that we're going to be cancelling (see #2804)
9833
 
                        setTimeout(function() {
9834
 
                                // handle $(el).dialog().dialog('close') (see #4065)
9835
 
                                if ($.ui.dialog.overlay.instances.length) {
9836
 
                                        $(document).bind($.ui.dialog.overlay.events, function(event) {
9837
 
                                                // stop events if the z-index of the target is < the z-index of the overlay
9838
 
                                                // we cannot return true when we don't want to cancel the event (#3523)
9839
 
                                                if ($(event.target).zIndex() < $.ui.dialog.overlay.maxZ) {
9840
 
                                                        return false;
9841
 
                                                }
9842
 
                                        });
9843
 
                                }
9844
 
                        }, 1);
9845
 
 
9846
 
                        // allow closing by pressing the escape key
9847
 
                        $(document).bind('keydown.dialog-overlay', function(event) {
9848
 
                                if (dialog.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
9849
 
                                        event.keyCode === $.ui.keyCode.ESCAPE) {
9850
 
                                        
9851
 
                                        dialog.close(event);
9852
 
                                        event.preventDefault();
9853
 
                                }
9854
 
                        });
9855
 
 
9856
 
                        // handle window resize
9857
 
                        $(window).bind('resize.dialog-overlay', $.ui.dialog.overlay.resize);
9858
 
                }
9859
 
 
9860
 
                var $el = (this.oldInstances.pop() || $('<div></div>').addClass('ui-widget-overlay'))
9861
 
                        .appendTo(document.body)
9862
 
                        .css({
9863
 
                                width: this.width(),
9864
 
                                height: this.height()
9865
 
                        });
9866
 
 
9867
 
                if ($.fn.bgiframe) {
9868
 
                        $el.bgiframe();
9869
 
                }
9870
 
 
9871
 
                this.instances.push($el);
9872
 
                return $el;
9873
 
        },
9874
 
 
9875
 
        destroy: function($el) {
9876
 
                var indexOf = $.inArray($el, this.instances);
9877
 
                if (indexOf != -1){
9878
 
                        this.oldInstances.push(this.instances.splice(indexOf, 1)[0]);
9879
 
                }
9880
 
 
9881
 
                if (this.instances.length === 0) {
9882
 
                        $([document, window]).unbind('.dialog-overlay');
9883
 
                }
9884
 
 
9885
 
                $el.remove();
9886
 
                
9887
 
                // adjust the maxZ to allow other modal dialogs to continue to work (see #4309)
9888
 
                var maxZ = 0;
9889
 
                $.each(this.instances, function() {
9890
 
                        maxZ = Math.max(maxZ, this.css('z-index'));
9891
 
                });
9892
 
                this.maxZ = maxZ;
9893
 
        },
9894
 
 
9895
 
        height: function() {
9896
 
                var scrollHeight,
9897
 
                        offsetHeight;
9898
 
                // handle IE 6
9899
 
                if ($.browser.msie && $.browser.version < 7) {
9900
 
                        scrollHeight = Math.max(
9901
 
                                document.documentElement.scrollHeight,
9902
 
                                document.body.scrollHeight
9903
 
                        );
9904
 
                        offsetHeight = Math.max(
9905
 
                                document.documentElement.offsetHeight,
9906
 
                                document.body.offsetHeight
9907
 
                        );
9908
 
 
9909
 
                        if (scrollHeight < offsetHeight) {
9910
 
                                return $(window).height() + 'px';
9911
 
                        } else {
9912
 
                                return scrollHeight + 'px';
9913
 
                        }
9914
 
                // handle "good" browsers
9915
 
                } else {
9916
 
                        return $(document).height() + 'px';
9917
 
                }
9918
 
        },
9919
 
 
9920
 
        width: function() {
9921
 
                var scrollWidth,
9922
 
                        offsetWidth;
9923
 
                // handle IE
9924
 
                if ( $.browser.msie ) {
9925
 
                        scrollWidth = Math.max(
9926
 
                                document.documentElement.scrollWidth,
9927
 
                                document.body.scrollWidth
9928
 
                        );
9929
 
                        offsetWidth = Math.max(
9930
 
                                document.documentElement.offsetWidth,
9931
 
                                document.body.offsetWidth
9932
 
                        );
9933
 
 
9934
 
                        if (scrollWidth < offsetWidth) {
9935
 
                                return $(window).width() + 'px';
9936
 
                        } else {
9937
 
                                return scrollWidth + 'px';
9938
 
                        }
9939
 
                // handle "good" browsers
9940
 
                } else {
9941
 
                        return $(document).width() + 'px';
9942
 
                }
9943
 
        },
9944
 
 
9945
 
        resize: function() {
9946
 
                /* If the dialog is draggable and the user drags it past the
9947
 
                 * right edge of the window, the document becomes wider so we
9948
 
                 * need to stretch the overlay. If the user then drags the
9949
 
                 * dialog back to the left, the document will become narrower,
9950
 
                 * so we need to shrink the overlay to the appropriate size.
9951
 
                 * This is handled by shrinking the overlay before setting it
9952
 
                 * to the full document size.
9953
 
                 */
9954
 
                var $overlays = $([]);
9955
 
                $.each($.ui.dialog.overlay.instances, function() {
9956
 
                        $overlays = $overlays.add(this);
9957
 
                });
9958
 
 
9959
 
                $overlays.css({
9960
 
                        width: 0,
9961
 
                        height: 0
9962
 
                }).css({
9963
 
                        width: $.ui.dialog.overlay.width(),
9964
 
                        height: $.ui.dialog.overlay.height()
9965
 
                });
9966
 
        }
9967
 
});
9968
 
 
9969
 
$.extend($.ui.dialog.overlay.prototype, {
9970
 
        destroy: function() {
9971
 
                $.ui.dialog.overlay.destroy(this.$el);
9972
 
        }
9973
 
});
9974
 
 
9975
 
}(jQuery));
9976
 
/*
9977
 
 * jQuery UI Position 1.8.18
9978
 
 *
9979
 
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
9980
 
 * Dual licensed under the MIT or GPL Version 2 licenses.
9981
 
 * http://jquery.org/license
9982
 
 *
9983
 
 * http://docs.jquery.com/UI/Position
9984
 
 */
9985
 
(function( $, undefined ) {
9986
 
 
9987
 
$.ui = $.ui || {};
9988
 
 
9989
 
var horizontalPositions = /left|center|right/,
9990
 
        verticalPositions = /top|center|bottom/,
9991
 
        center = "center",
9992
 
        support = {},
9993
 
        _position = $.fn.position,
9994
 
        _offset = $.fn.offset;
9995
 
 
9996
 
$.fn.position = function( options ) {
9997
 
        if ( !options || !options.of ) {
9998
 
                return _position.apply( this, arguments );
9999
 
        }
10000
 
 
10001
 
        // make a copy, we don't want to modify arguments
10002
 
        options = $.extend( {}, options );
10003
 
 
10004
 
        var target = $( options.of ),
10005
 
                targetElem = target[0],
10006
 
                collision = ( options.collision || "flip" ).split( " " ),
10007
 
                offset = options.offset ? options.offset.split( " " ) : [ 0, 0 ],
10008
 
                targetWidth,
10009
 
                targetHeight,
10010
 
                basePosition;
10011
 
 
10012
 
        if ( targetElem.nodeType === 9 ) {
10013
 
                targetWidth = target.width();
10014
 
                targetHeight = target.height();
10015
 
                basePosition = { top: 0, left: 0 };
10016
 
        // TODO: use $.isWindow() in 1.9
10017
 
        } else if ( targetElem.setTimeout ) {
10018
 
                targetWidth = target.width();
10019
 
                targetHeight = target.height();
10020
 
                basePosition = { top: target.scrollTop(), left: target.scrollLeft() };
10021
 
        } else if ( targetElem.preventDefault ) {
10022
 
                // force left top to allow flipping
10023
 
                options.at = "left top";
10024
 
                targetWidth = targetHeight = 0;
10025
 
                basePosition = { top: options.of.pageY, left: options.of.pageX };
10026
 
        } else {
10027
 
                targetWidth = target.outerWidth();
10028
 
                targetHeight = target.outerHeight();
10029
 
                basePosition = target.offset();
10030
 
        }
10031
 
 
10032
 
        // force my and at to have valid horizontal and veritcal positions
10033
 
        // if a value is missing or invalid, it will be converted to center 
10034
 
        $.each( [ "my", "at" ], function() {
10035
 
                var pos = ( options[this] || "" ).split( " " );
10036
 
                if ( pos.length === 1) {
10037
 
                        pos = horizontalPositions.test( pos[0] ) ?
10038
 
                                pos.concat( [center] ) :
10039
 
                                verticalPositions.test( pos[0] ) ?
10040
 
                                        [ center ].concat( pos ) :
10041
 
                                        [ center, center ];
10042
 
                }
10043
 
                pos[ 0 ] = horizontalPositions.test( pos[0] ) ? pos[ 0 ] : center;
10044
 
                pos[ 1 ] = verticalPositions.test( pos[1] ) ? pos[ 1 ] : center;
10045
 
                options[ this ] = pos;
10046
 
        });
10047
 
 
10048
 
        // normalize collision option
10049
 
        if ( collision.length === 1 ) {
10050
 
                collision[ 1 ] = collision[ 0 ];
10051
 
        }
10052
 
 
10053
 
        // normalize offset option
10054
 
        offset[ 0 ] = parseInt( offset[0], 10 ) || 0;
10055
 
        if ( offset.length === 1 ) {
10056
 
                offset[ 1 ] = offset[ 0 ];
10057
 
        }
10058
 
        offset[ 1 ] = parseInt( offset[1], 10 ) || 0;
10059
 
 
10060
 
        if ( options.at[0] === "right" ) {
10061
 
                basePosition.left += targetWidth;
10062
 
        } else if ( options.at[0] === center ) {
10063
 
                basePosition.left += targetWidth / 2;
10064
 
        }
10065
 
 
10066
 
        if ( options.at[1] === "bottom" ) {
10067
 
                basePosition.top += targetHeight;
10068
 
        } else if ( options.at[1] === center ) {
10069
 
                basePosition.top += targetHeight / 2;
10070
 
        }
10071
 
 
10072
 
        basePosition.left += offset[ 0 ];
10073
 
        basePosition.top += offset[ 1 ];
10074
 
 
10075
 
        return this.each(function() {
10076
 
                var elem = $( this ),
10077
 
                        elemWidth = elem.outerWidth(),
10078
 
                        elemHeight = elem.outerHeight(),
10079
 
                        marginLeft = parseInt( $.curCSS( this, "marginLeft", true ) ) || 0,
10080
 
                        marginTop = parseInt( $.curCSS( this, "marginTop", true ) ) || 0,
10081
 
                        collisionWidth = elemWidth + marginLeft +
10082
 
                                ( parseInt( $.curCSS( this, "marginRight", true ) ) || 0 ),
10083
 
                        collisionHeight = elemHeight + marginTop +
10084
 
                                ( parseInt( $.curCSS( this, "marginBottom", true ) ) || 0 ),
10085
 
                        position = $.extend( {}, basePosition ),
10086
 
                        collisionPosition;
10087
 
 
10088
 
                if ( options.my[0] === "right" ) {
10089
 
                        position.left -= elemWidth;
10090
 
                } else if ( options.my[0] === center ) {
10091
 
                        position.left -= elemWidth / 2;
10092
 
                }
10093
 
 
10094
 
                if ( options.my[1] === "bottom" ) {
10095
 
                        position.top -= elemHeight;
10096
 
                } else if ( options.my[1] === center ) {
10097
 
                        position.top -= elemHeight / 2;
10098
 
                }
10099
 
 
10100
 
                // prevent fractions if jQuery version doesn't support them (see #5280)
10101
 
                if ( !support.fractions ) {
10102
 
                        position.left = Math.round( position.left );
10103
 
                        position.top = Math.round( position.top );
10104
 
                }
10105
 
 
10106
 
                collisionPosition = {
10107
 
                        left: position.left - marginLeft,
10108
 
                        top: position.top - marginTop
10109
 
                };
10110
 
 
10111
 
                $.each( [ "left", "top" ], function( i, dir ) {
10112
 
                        if ( $.ui.position[ collision[i] ] ) {
10113
 
                                $.ui.position[ collision[i] ][ dir ]( position, {
10114
 
                                        targetWidth: targetWidth,
10115
 
                                        targetHeight: targetHeight,
10116
 
                                        elemWidth: elemWidth,
10117
 
                                        elemHeight: elemHeight,
10118
 
                                        collisionPosition: collisionPosition,
10119
 
                                        collisionWidth: collisionWidth,
10120
 
                                        collisionHeight: collisionHeight,
10121
 
                                        offset: offset,
10122
 
                                        my: options.my,
10123
 
                                        at: options.at
10124
 
                                });
10125
 
                        }
10126
 
                });
10127
 
 
10128
 
                if ( $.fn.bgiframe ) {
10129
 
                        elem.bgiframe();
10130
 
                }
10131
 
                elem.offset( $.extend( position, { using: options.using } ) );
10132
 
        });
10133
 
};
10134
 
 
10135
 
$.ui.position = {
10136
 
        fit: {
10137
 
                left: function( position, data ) {
10138
 
                        var win = $( window ),
10139
 
                                over = data.collisionPosition.left + data.collisionWidth - win.width() - win.scrollLeft();
10140
 
                        position.left = over > 0 ? position.left - over : Math.max( position.left - data.collisionPosition.left, position.left );
10141
 
                },
10142
 
                top: function( position, data ) {
10143
 
                        var win = $( window ),
10144
 
                                over = data.collisionPosition.top + data.collisionHeight - win.height() - win.scrollTop();
10145
 
                        position.top = over > 0 ? position.top - over : Math.max( position.top - data.collisionPosition.top, position.top );
10146
 
                }
10147
 
        },
10148
 
 
10149
 
        flip: {
10150
 
                left: function( position, data ) {
10151
 
                        if ( data.at[0] === center ) {
10152
 
                                return;
10153
 
                        }
10154
 
                        var win = $( window ),
10155
 
                                over = data.collisionPosition.left + data.collisionWidth - win.width() - win.scrollLeft(),
10156
 
                                myOffset = data.my[ 0 ] === "left" ?
10157
 
                                        -data.elemWidth :
10158
 
                                        data.my[ 0 ] === "right" ?
10159
 
                                                data.elemWidth :
10160
 
                                                0,
10161
 
                                atOffset = data.at[ 0 ] === "left" ?
10162
 
                                        data.targetWidth :
10163
 
                                        -data.targetWidth,
10164
 
                                offset = -2 * data.offset[ 0 ];
10165
 
                        position.left += data.collisionPosition.left < 0 ?
10166
 
                                myOffset + atOffset + offset :
10167
 
                                over > 0 ?
10168
 
                                        myOffset + atOffset + offset :
10169
 
                                        0;
10170
 
                },
10171
 
                top: function( position, data ) {
10172
 
                        if ( data.at[1] === center ) {
10173
 
                                return;
10174
 
                        }
10175
 
                        var win = $( window ),
10176
 
                                over = data.collisionPosition.top + data.collisionHeight - win.height() - win.scrollTop(),
10177
 
                                myOffset = data.my[ 1 ] === "top" ?
10178
 
                                        -data.elemHeight :
10179
 
                                        data.my[ 1 ] === "bottom" ?
10180
 
                                                data.elemHeight :
10181
 
                                                0,
10182
 
                                atOffset = data.at[ 1 ] === "top" ?
10183
 
                                        data.targetHeight :
10184
 
                                        -data.targetHeight,
10185
 
                                offset = -2 * data.offset[ 1 ];
10186
 
                        position.top += data.collisionPosition.top < 0 ?
10187
 
                                myOffset + atOffset + offset :
10188
 
                                over > 0 ?
10189
 
                                        myOffset + atOffset + offset :
10190
 
                                        0;
10191
 
                }
10192
 
        }
10193
 
};
10194
 
 
10195
 
// offset setter from jQuery 1.4
10196
 
if ( !$.offset.setOffset ) {
10197
 
        $.offset.setOffset = function( elem, options ) {
10198
 
                // set position first, in-case top/left are set even on static elem
10199
 
                if ( /static/.test( $.curCSS( elem, "position" ) ) ) {
10200
 
                        elem.style.position = "relative";
10201
 
                }
10202
 
                var curElem   = $( elem ),
10203
 
                        curOffset = curElem.offset(),
10204
 
                        curTop    = parseInt( $.curCSS( elem, "top",  true ), 10 ) || 0,
10205
 
                        curLeft   = parseInt( $.curCSS( elem, "left", true ), 10)  || 0,
10206
 
                        props     = {
10207
 
                                top:  (options.top  - curOffset.top)  + curTop,
10208
 
                                left: (options.left - curOffset.left) + curLeft
10209
 
                        };
10210
 
                
10211
 
                if ( 'using' in options ) {
10212
 
                        options.using.call( elem, props );
10213
 
                } else {
10214
 
                        curElem.css( props );
10215
 
                }
10216
 
        };
10217
 
 
10218
 
        $.fn.offset = function( options ) {
10219
 
                var elem = this[ 0 ];
10220
 
                if ( !elem || !elem.ownerDocument ) { return null; }
10221
 
                if ( options ) { 
10222
 
                        return this.each(function() {
10223
 
                                $.offset.setOffset( this, options );
10224
 
                        });
10225
 
                }
10226
 
                return _offset.call( this );
10227
 
        };
10228
 
}
10229
 
 
10230
 
// fraction support test (older versions of jQuery don't support fractions)
10231
 
(function () {
10232
 
        var body = document.getElementsByTagName( "body" )[ 0 ], 
10233
 
                div = document.createElement( "div" ),
10234
 
                testElement, testElementParent, testElementStyle, offset, offsetTotal;
10235
 
 
10236
 
        //Create a "fake body" for testing based on method used in jQuery.support
10237
 
        testElement = document.createElement( body ? "div" : "body" );
10238
 
        testElementStyle = {
10239
 
                visibility: "hidden",
10240
 
                width: 0,
10241
 
                height: 0,
10242
 
                border: 0,
10243
 
                margin: 0,
10244
 
                background: "none"
10245
 
        };
10246
 
        if ( body ) {
10247
 
                $.extend( testElementStyle, {
10248
 
                        position: "absolute",
10249
 
                        left: "-1000px",
10250
 
                        top: "-1000px"
10251
 
                });
10252
 
        }
10253
 
        for ( var i in testElementStyle ) {
10254
 
                testElement.style[ i ] = testElementStyle[ i ];
10255
 
        }
10256
 
        testElement.appendChild( div );
10257
 
        testElementParent = body || document.documentElement;
10258
 
        testElementParent.insertBefore( testElement, testElementParent.firstChild );
10259
 
 
10260
 
        div.style.cssText = "position: absolute; left: 10.7432222px; top: 10.432325px; height: 30px; width: 201px;";
10261
 
 
10262
 
        offset = $( div ).offset( function( _, offset ) {
10263
 
                return offset;
10264
 
        }).offset();
10265
 
 
10266
 
        testElement.innerHTML = "";
10267
 
        testElementParent.removeChild( testElement );
10268
 
 
10269
 
        offsetTotal = offset.top + offset.left + ( body ? 2000 : 0 );
10270
 
        support.fractions = offsetTotal > 21 && offsetTotal < 22;
10271
 
})();
10272
 
 
10273
 
}( jQuery ));
10274
 
/*
10275
 
 * jQuery UI Progressbar 1.8.18
10276
 
 *
10277
 
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
10278
 
 * Dual licensed under the MIT or GPL Version 2 licenses.
10279
 
 * http://jquery.org/license
10280
 
 *
10281
 
 * http://docs.jquery.com/UI/Progressbar
10282
 
 *
10283
 
 * Depends:
10284
 
 *   jquery.ui.core.js
10285
 
 *   jquery.ui.widget.js
10286
 
 */
10287
 
(function( $, undefined ) {
10288
 
 
10289
 
$.widget( "ui.progressbar", {
10290
 
        options: {
10291
 
                value: 0,
10292
 
                max: 100
10293
 
        },
10294
 
 
10295
 
        min: 0,
10296
 
 
10297
 
        _create: function() {
10298
 
                this.element
10299
 
                        .addClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
10300
 
                        .attr({
10301
 
                                role: "progressbar",
10302
 
                                "aria-valuemin": this.min,
10303
 
                                "aria-valuemax": this.options.max,
10304
 
                                "aria-valuenow": this._value()
10305
 
                        });
10306
 
 
10307
 
                this.valueDiv = $( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>" )
10308
 
                        .appendTo( this.element );
10309
 
 
10310
 
                this.oldValue = this._value();
10311
 
                this._refreshValue();
10312
 
        },
10313
 
 
10314
 
        destroy: function() {
10315
 
                this.element
10316
 
                        .removeClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
10317
 
                        .removeAttr( "role" )
10318
 
                        .removeAttr( "aria-valuemin" )
10319
 
                        .removeAttr( "aria-valuemax" )
10320
 
                        .removeAttr( "aria-valuenow" );
10321
 
 
10322
 
                this.valueDiv.remove();
10323
 
 
10324
 
                $.Widget.prototype.destroy.apply( this, arguments );
10325
 
        },
10326
 
 
10327
 
        value: function( newValue ) {
10328
 
                if ( newValue === undefined ) {
10329
 
                        return this._value();
10330
 
                }
10331
 
 
10332
 
                this._setOption( "value", newValue );
10333
 
                return this;
10334
 
        },
10335
 
 
10336
 
        _setOption: function( key, value ) {
10337
 
                if ( key === "value" ) {
10338
 
                        this.options.value = value;
10339
 
                        this._refreshValue();
10340
 
                        if ( this._value() === this.options.max ) {
10341
 
                                this._trigger( "complete" );
10342
 
                        }
10343
 
                }
10344
 
 
10345
 
                $.Widget.prototype._setOption.apply( this, arguments );
10346
 
        },
10347
 
 
10348
 
        _value: function() {
10349
 
                var val = this.options.value;
10350
 
                // normalize invalid value
10351
 
                if ( typeof val !== "number" ) {
10352
 
                        val = 0;
10353
 
                }
10354
 
                return Math.min( this.options.max, Math.max( this.min, val ) );
10355
 
        },
10356
 
 
10357
 
        _percentage: function() {
10358
 
                return 100 * this._value() / this.options.max;
10359
 
        },
10360
 
 
10361
 
        _refreshValue: function() {
10362
 
                var value = this.value();
10363
 
                var percentage = this._percentage();
10364
 
 
10365
 
                if ( this.oldValue !== value ) {
10366
 
                        this.oldValue = value;
10367
 
                        this._trigger( "change" );
10368
 
                }
10369
 
 
10370
 
                this.valueDiv
10371
 
                        .toggle( value > this.min )
10372
 
                        .toggleClass( "ui-corner-right", value === this.options.max )
10373
 
                        .width( percentage.toFixed(0) + "%" );
10374
 
                this.element.attr( "aria-valuenow", value );
10375
 
        }
10376
 
});
10377
 
 
10378
 
$.extend( $.ui.progressbar, {
10379
 
        version: "1.8.18"
10380
 
});
10381
 
 
10382
 
})( jQuery );
10383
 
/*
10384
 
 * jQuery UI Slider 1.8.18
10385
 
 *
10386
 
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
10387
 
 * Dual licensed under the MIT or GPL Version 2 licenses.
10388
 
 * http://jquery.org/license
10389
 
 *
10390
 
 * http://docs.jquery.com/UI/Slider
10391
 
 *
10392
 
 * Depends:
10393
 
 *      jquery.ui.core.js
10394
 
 *      jquery.ui.mouse.js
10395
 
 *      jquery.ui.widget.js
10396
 
 */
10397
 
(function( $, undefined ) {
10398
 
 
10399
 
// number of pages in a slider
10400
 
// (how many times can you page up/down to go through the whole range)
10401
 
var numPages = 5;
10402
 
 
10403
 
$.widget( "ui.slider", $.ui.mouse, {
10404
 
 
10405
 
        widgetEventPrefix: "slide",
10406
 
 
10407
 
        options: {
10408
 
                animate: false,
10409
 
                distance: 0,
10410
 
                max: 100,
10411
 
                min: 0,
10412
 
                orientation: "horizontal",
10413
 
                range: false,
10414
 
                step: 1,
10415
 
                value: 0,
10416
 
                values: null
10417
 
        },
10418
 
 
10419
 
        _create: function() {
10420
 
                var self = this,
10421
 
                        o = this.options,
10422
 
                        existingHandles = this.element.find( ".ui-slider-handle" ).addClass( "ui-state-default ui-corner-all" ),
10423
 
                        handle = "<a class='ui-slider-handle ui-state-default ui-corner-all' href='#'></a>",
10424
 
                        handleCount = ( o.values && o.values.length ) || 1,
10425
 
                        handles = [];
10426
 
 
10427
 
                this._keySliding = false;
10428
 
                this._mouseSliding = false;
10429
 
                this._animateOff = true;
10430
 
                this._handleIndex = null;
10431
 
                this._detectOrientation();
10432
 
                this._mouseInit();
10433
 
 
10434
 
                this.element
10435
 
                        .addClass( "ui-slider" +
10436
 
                                " ui-slider-" + this.orientation +
10437
 
                                " ui-widget" +
10438
 
                                " ui-widget-content" +
10439
 
                                " ui-corner-all" +
10440
 
                                ( o.disabled ? " ui-slider-disabled ui-disabled" : "" ) );
10441
 
 
10442
 
                this.range = $([]);
10443
 
 
10444
 
                if ( o.range ) {
10445
 
                        if ( o.range === true ) {
10446
 
                                if ( !o.values ) {
10447
 
                                        o.values = [ this._valueMin(), this._valueMin() ];
10448
 
                                }
10449
 
                                if ( o.values.length && o.values.length !== 2 ) {
10450
 
                                        o.values = [ o.values[0], o.values[0] ];
10451
 
                                }
10452
 
                        }
10453
 
 
10454
 
                        this.range = $( "<div></div>" )
10455
 
                                .appendTo( this.element )
10456
 
                                .addClass( "ui-slider-range" +
10457
 
                                // note: this isn't the most fittingly semantic framework class for this element,
10458
 
                                // but worked best visually with a variety of themes
10459
 
                                " ui-widget-header" + 
10460
 
                                ( ( o.range === "min" || o.range === "max" ) ? " ui-slider-range-" + o.range : "" ) );
10461
 
                }
10462
 
 
10463
 
                for ( var i = existingHandles.length; i < handleCount; i += 1 ) {
10464
 
                        handles.push( handle );
10465
 
                }
10466
 
 
10467
 
                this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( self.element ) );
10468
 
 
10469
 
                this.handle = this.handles.eq( 0 );
10470
 
 
10471
 
                this.handles.add( this.range ).filter( "a" )
10472
 
                        .click(function( event ) {
10473
 
                                event.preventDefault();
10474
 
                        })
10475
 
                        .hover(function() {
10476
 
                                if ( !o.disabled ) {
10477
 
                                        $( this ).addClass( "ui-state-hover" );
10478
 
                                }
10479
 
                        }, function() {
10480
 
                                $( this ).removeClass( "ui-state-hover" );
10481
 
                        })
10482
 
                        .focus(function() {
10483
 
                                if ( !o.disabled ) {
10484
 
                                        $( ".ui-slider .ui-state-focus" ).removeClass( "ui-state-focus" );
10485
 
                                        $( this ).addClass( "ui-state-focus" );
10486
 
                                } else {
10487
 
                                        $( this ).blur();
10488
 
                                }
10489
 
                        })
10490
 
                        .blur(function() {
10491
 
                                $( this ).removeClass( "ui-state-focus" );
10492
 
                        });
10493
 
 
10494
 
                this.handles.each(function( i ) {
10495
 
                        $( this ).data( "index.ui-slider-handle", i );
10496
 
                });
10497
 
 
10498
 
                this.handles
10499
 
                        .keydown(function( event ) {
10500
 
                                var index = $( this ).data( "index.ui-slider-handle" ),
10501
 
                                        allowed,
10502
 
                                        curVal,
10503
 
                                        newVal,
10504
 
                                        step;
10505
 
        
10506
 
                                if ( self.options.disabled ) {
10507
 
                                        return;
10508
 
                                }
10509
 
        
10510
 
                                switch ( event.keyCode ) {
10511
 
                                        case $.ui.keyCode.HOME:
10512
 
                                        case $.ui.keyCode.END:
10513
 
                                        case $.ui.keyCode.PAGE_UP:
10514
 
                                        case $.ui.keyCode.PAGE_DOWN:
10515
 
                                        case $.ui.keyCode.UP:
10516
 
                                        case $.ui.keyCode.RIGHT:
10517
 
                                        case $.ui.keyCode.DOWN:
10518
 
                                        case $.ui.keyCode.LEFT:
10519
 
                                                event.preventDefault();
10520
 
                                                if ( !self._keySliding ) {
10521
 
                                                        self._keySliding = true;
10522
 
                                                        $( this ).addClass( "ui-state-active" );
10523
 
                                                        allowed = self._start( event, index );
10524
 
                                                        if ( allowed === false ) {
10525
 
                                                                return;
10526
 
                                                        }
10527
 
                                                }
10528
 
                                                break;
10529
 
                                }
10530
 
        
10531
 
                                step = self.options.step;
10532
 
                                if ( self.options.values && self.options.values.length ) {
10533
 
                                        curVal = newVal = self.values( index );
10534
 
                                } else {
10535
 
                                        curVal = newVal = self.value();
10536
 
                                }
10537
 
        
10538
 
                                switch ( event.keyCode ) {
10539
 
                                        case $.ui.keyCode.HOME:
10540
 
                                                newVal = self._valueMin();
10541
 
                                                break;
10542
 
                                        case $.ui.keyCode.END:
10543
 
                                                newVal = self._valueMax();
10544
 
                                                break;
10545
 
                                        case $.ui.keyCode.PAGE_UP:
10546
 
                                                newVal = self._trimAlignValue( curVal + ( (self._valueMax() - self._valueMin()) / numPages ) );
10547
 
                                                break;
10548
 
                                        case $.ui.keyCode.PAGE_DOWN:
10549
 
                                                newVal = self._trimAlignValue( curVal - ( (self._valueMax() - self._valueMin()) / numPages ) );
10550
 
                                                break;
10551
 
                                        case $.ui.keyCode.UP:
10552
 
                                        case $.ui.keyCode.RIGHT:
10553
 
                                                if ( curVal === self._valueMax() ) {
10554
 
                                                        return;
10555
 
                                                }
10556
 
                                                newVal = self._trimAlignValue( curVal + step );
10557
 
                                                break;
10558
 
                                        case $.ui.keyCode.DOWN:
10559
 
                                        case $.ui.keyCode.LEFT:
10560
 
                                                if ( curVal === self._valueMin() ) {
10561
 
                                                        return;
10562
 
                                                }
10563
 
                                                newVal = self._trimAlignValue( curVal - step );
10564
 
                                                break;
10565
 
                                }
10566
 
        
10567
 
                                self._slide( event, index, newVal );
10568
 
                        })
10569
 
                        .keyup(function( event ) {
10570
 
                                var index = $( this ).data( "index.ui-slider-handle" );
10571
 
        
10572
 
                                if ( self._keySliding ) {
10573
 
                                        self._keySliding = false;
10574
 
                                        self._stop( event, index );
10575
 
                                        self._change( event, index );
10576
 
                                        $( this ).removeClass( "ui-state-active" );
10577
 
                                }
10578
 
        
10579
 
                        });
10580
 
 
10581
 
                this._refreshValue();
10582
 
 
10583
 
                this._animateOff = false;
10584
 
        },
10585
 
 
10586
 
        destroy: function() {
10587
 
                this.handles.remove();
10588
 
                this.range.remove();
10589
 
 
10590
 
                this.element
10591
 
                        .removeClass( "ui-slider" +
10592
 
                                " ui-slider-horizontal" +
10593
 
                                " ui-slider-vertical" +
10594
 
                                " ui-slider-disabled" +
10595
 
                                " ui-widget" +
10596
 
                                " ui-widget-content" +
10597
 
                                " ui-corner-all" )
10598
 
                        .removeData( "slider" )
10599
 
                        .unbind( ".slider" );
10600
 
 
10601
 
                this._mouseDestroy();
10602
 
 
10603
 
                return this;
10604
 
        },
10605
 
 
10606
 
        _mouseCapture: function( event ) {
10607
 
                var o = this.options,
10608
 
                        position,
10609
 
                        normValue,
10610
 
                        distance,
10611
 
                        closestHandle,
10612
 
                        self,
10613
 
                        index,
10614
 
                        allowed,
10615
 
                        offset,
10616
 
                        mouseOverHandle;
10617
 
 
10618
 
                if ( o.disabled ) {
10619
 
                        return false;
10620
 
                }
10621
 
 
10622
 
                this.elementSize = {
10623
 
                        width: this.element.outerWidth(),
10624
 
                        height: this.element.outerHeight()
10625
 
                };
10626
 
                this.elementOffset = this.element.offset();
10627
 
 
10628
 
                position = { x: event.pageX, y: event.pageY };
10629
 
                normValue = this._normValueFromMouse( position );
10630
 
                distance = this._valueMax() - this._valueMin() + 1;
10631
 
                self = this;
10632
 
                this.handles.each(function( i ) {
10633
 
                        var thisDistance = Math.abs( normValue - self.values(i) );
10634
 
                        if ( distance > thisDistance ) {
10635
 
                                distance = thisDistance;
10636
 
                                closestHandle = $( this );
10637
 
                                index = i;
10638
 
                        }
10639
 
                });
10640
 
 
10641
 
                // workaround for bug #3736 (if both handles of a range are at 0,
10642
 
                // the first is always used as the one with least distance,
10643
 
                // and moving it is obviously prevented by preventing negative ranges)
10644
 
                if( o.range === true && this.values(1) === o.min ) {
10645
 
                        index += 1;
10646
 
                        closestHandle = $( this.handles[index] );
10647
 
                }
10648
 
 
10649
 
                allowed = this._start( event, index );
10650
 
                if ( allowed === false ) {
10651
 
                        return false;
10652
 
                }
10653
 
                this._mouseSliding = true;
10654
 
 
10655
 
                self._handleIndex = index;
10656
 
 
10657
 
                closestHandle
10658
 
                        .addClass( "ui-state-active" )
10659
 
                        .focus();
10660
 
                
10661
 
                offset = closestHandle.offset();
10662
 
                mouseOverHandle = !$( event.target ).parents().andSelf().is( ".ui-slider-handle" );
10663
 
                this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
10664
 
                        left: event.pageX - offset.left - ( closestHandle.width() / 2 ),
10665
 
                        top: event.pageY - offset.top -
10666
 
                                ( closestHandle.height() / 2 ) -
10667
 
                                ( parseInt( closestHandle.css("borderTopWidth"), 10 ) || 0 ) -
10668
 
                                ( parseInt( closestHandle.css("borderBottomWidth"), 10 ) || 0) +
10669
 
                                ( parseInt( closestHandle.css("marginTop"), 10 ) || 0)
10670
 
                };
10671
 
 
10672
 
                if ( !this.handles.hasClass( "ui-state-hover" ) ) {
10673
 
                        this._slide( event, index, normValue );
10674
 
                }
10675
 
                this._animateOff = true;
10676
 
                return true;
10677
 
        },
10678
 
 
10679
 
        _mouseStart: function( event ) {
10680
 
                return true;
10681
 
        },
10682
 
 
10683
 
        _mouseDrag: function( event ) {
10684
 
                var position = { x: event.pageX, y: event.pageY },
10685
 
                        normValue = this._normValueFromMouse( position );
10686
 
                
10687
 
                this._slide( event, this._handleIndex, normValue );
10688
 
 
10689
 
                return false;
10690
 
        },
10691
 
 
10692
 
        _mouseStop: function( event ) {
10693
 
                this.handles.removeClass( "ui-state-active" );
10694
 
                this._mouseSliding = false;
10695
 
 
10696
 
                this._stop( event, this._handleIndex );
10697
 
                this._change( event, this._handleIndex );
10698
 
 
10699
 
                this._handleIndex = null;
10700
 
                this._clickOffset = null;
10701
 
                this._animateOff = false;
10702
 
 
10703
 
                return false;
10704
 
        },
10705
 
        
10706
 
        _detectOrientation: function() {
10707
 
                this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal";
10708
 
        },
10709
 
 
10710
 
        _normValueFromMouse: function( position ) {
10711
 
                var pixelTotal,
10712
 
                        pixelMouse,
10713
 
                        percentMouse,
10714
 
                        valueTotal,
10715
 
                        valueMouse;
10716
 
 
10717
 
                if ( this.orientation === "horizontal" ) {
10718
 
                        pixelTotal = this.elementSize.width;
10719
 
                        pixelMouse = position.x - this.elementOffset.left - ( this._clickOffset ? this._clickOffset.left : 0 );
10720
 
                } else {
10721
 
                        pixelTotal = this.elementSize.height;
10722
 
                        pixelMouse = position.y - this.elementOffset.top - ( this._clickOffset ? this._clickOffset.top : 0 );
10723
 
                }
10724
 
 
10725
 
                percentMouse = ( pixelMouse / pixelTotal );
10726
 
                if ( percentMouse > 1 ) {
10727
 
                        percentMouse = 1;
10728
 
                }
10729
 
                if ( percentMouse < 0 ) {
10730
 
                        percentMouse = 0;
10731
 
                }
10732
 
                if ( this.orientation === "vertical" ) {
10733
 
                        percentMouse = 1 - percentMouse;
10734
 
                }
10735
 
 
10736
 
                valueTotal = this._valueMax() - this._valueMin();
10737
 
                valueMouse = this._valueMin() + percentMouse * valueTotal;
10738
 
 
10739
 
                return this._trimAlignValue( valueMouse );
10740
 
        },
10741
 
 
10742
 
        _start: function( event, index ) {
10743
 
                var uiHash = {
10744
 
                        handle: this.handles[ index ],
10745
 
                        value: this.value()
10746
 
                };
10747
 
                if ( this.options.values && this.options.values.length ) {
10748
 
                        uiHash.value = this.values( index );
10749
 
                        uiHash.values = this.values();
10750
 
                }
10751
 
                return this._trigger( "start", event, uiHash );
10752
 
        },
10753
 
 
10754
 
        _slide: function( event, index, newVal ) {
10755
 
                var otherVal,
10756
 
                        newValues,
10757
 
                        allowed;
10758
 
 
10759
 
                if ( this.options.values && this.options.values.length ) {
10760
 
                        otherVal = this.values( index ? 0 : 1 );
10761
 
 
10762
 
                        if ( ( this.options.values.length === 2 && this.options.range === true ) && 
10763
 
                                        ( ( index === 0 && newVal > otherVal) || ( index === 1 && newVal < otherVal ) )
10764
 
                                ) {
10765
 
                                newVal = otherVal;
10766
 
                        }
10767
 
 
10768
 
                        if ( newVal !== this.values( index ) ) {
10769
 
                                newValues = this.values();
10770
 
                                newValues[ index ] = newVal;
10771
 
                                // A slide can be canceled by returning false from the slide callback
10772
 
                                allowed = this._trigger( "slide", event, {
10773
 
                                        handle: this.handles[ index ],
10774
 
                                        value: newVal,
10775
 
                                        values: newValues
10776
 
                                } );
10777
 
                                otherVal = this.values( index ? 0 : 1 );
10778
 
                                if ( allowed !== false ) {
10779
 
                                        this.values( index, newVal, true );
10780
 
                                }
10781
 
                        }
10782
 
                } else {
10783
 
                        if ( newVal !== this.value() ) {
10784
 
                                // A slide can be canceled by returning false from the slide callback
10785
 
                                allowed = this._trigger( "slide", event, {
10786
 
                                        handle: this.handles[ index ],
10787
 
                                        value: newVal
10788
 
                                } );
10789
 
                                if ( allowed !== false ) {
10790
 
                                        this.value( newVal );
10791
 
                                }
10792
 
                        }
10793
 
                }
10794
 
        },
10795
 
 
10796
 
        _stop: function( event, index ) {
10797
 
                var uiHash = {
10798
 
                        handle: this.handles[ index ],
10799
 
                        value: this.value()
10800
 
                };
10801
 
                if ( this.options.values && this.options.values.length ) {
10802
 
                        uiHash.value = this.values( index );
10803
 
                        uiHash.values = this.values();
10804
 
                }
10805
 
 
10806
 
                this._trigger( "stop", event, uiHash );
10807
 
        },
10808
 
 
10809
 
        _change: function( event, index ) {
10810
 
                if ( !this._keySliding && !this._mouseSliding ) {
10811
 
                        var uiHash = {
10812
 
                                handle: this.handles[ index ],
10813
 
                                value: this.value()
10814
 
                        };
10815
 
                        if ( this.options.values && this.options.values.length ) {
10816
 
                                uiHash.value = this.values( index );
10817
 
                                uiHash.values = this.values();
10818
 
                        }
10819
 
 
10820
 
                        this._trigger( "change", event, uiHash );
10821
 
                }
10822
 
        },
10823
 
 
10824
 
        value: function( newValue ) {
10825
 
                if ( arguments.length ) {
10826
 
                        this.options.value = this._trimAlignValue( newValue );
10827
 
                        this._refreshValue();
10828
 
                        this._change( null, 0 );
10829
 
                        return;
10830
 
                }
10831
 
 
10832
 
                return this._value();
10833
 
        },
10834
 
 
10835
 
        values: function( index, newValue ) {
10836
 
                var vals,
10837
 
                        newValues,
10838
 
                        i;
10839
 
 
10840
 
                if ( arguments.length > 1 ) {
10841
 
                        this.options.values[ index ] = this._trimAlignValue( newValue );
10842
 
                        this._refreshValue();
10843
 
                        this._change( null, index );
10844
 
                        return;
10845
 
                }
10846
 
 
10847
 
                if ( arguments.length ) {
10848
 
                        if ( $.isArray( arguments[ 0 ] ) ) {
10849
 
                                vals = this.options.values;
10850
 
                                newValues = arguments[ 0 ];
10851
 
                                for ( i = 0; i < vals.length; i += 1 ) {
10852
 
                                        vals[ i ] = this._trimAlignValue( newValues[ i ] );
10853
 
                                        this._change( null, i );
10854
 
                                }
10855
 
                                this._refreshValue();
10856
 
                        } else {
10857
 
                                if ( this.options.values && this.options.values.length ) {
10858
 
                                        return this._values( index );
10859
 
                                } else {
10860
 
                                        return this.value();
10861
 
                                }
10862
 
                        }
10863
 
                } else {
10864
 
                        return this._values();
10865
 
                }
10866
 
        },
10867
 
 
10868
 
        _setOption: function( key, value ) {
10869
 
                var i,
10870
 
                        valsLength = 0;
10871
 
 
10872
 
                if ( $.isArray( this.options.values ) ) {
10873
 
                        valsLength = this.options.values.length;
10874
 
                }
10875
 
 
10876
 
                $.Widget.prototype._setOption.apply( this, arguments );
10877
 
 
10878
 
                switch ( key ) {
10879
 
                        case "disabled":
10880
 
                                if ( value ) {
10881
 
                                        this.handles.filter( ".ui-state-focus" ).blur();
10882
 
                                        this.handles.removeClass( "ui-state-hover" );
10883
 
                                        this.handles.propAttr( "disabled", true );
10884
 
                                        this.element.addClass( "ui-disabled" );
10885
 
                                } else {
10886
 
                                        this.handles.propAttr( "disabled", false );
10887
 
                                        this.element.removeClass( "ui-disabled" );
10888
 
                                }
10889
 
                                break;
10890
 
                        case "orientation":
10891
 
                                this._detectOrientation();
10892
 
                                this.element
10893
 
                                        .removeClass( "ui-slider-horizontal ui-slider-vertical" )
10894
 
                                        .addClass( "ui-slider-" + this.orientation );
10895
 
                                this._refreshValue();
10896
 
                                break;
10897
 
                        case "value":
10898
 
                                this._animateOff = true;
10899
 
                                this._refreshValue();
10900
 
                                this._change( null, 0 );
10901
 
                                this._animateOff = false;
10902
 
                                break;
10903
 
                        case "values":
10904
 
                                this._animateOff = true;
10905
 
                                this._refreshValue();
10906
 
                                for ( i = 0; i < valsLength; i += 1 ) {
10907
 
                                        this._change( null, i );
10908
 
                                }
10909
 
                                this._animateOff = false;
10910
 
                                break;
10911
 
                }
10912
 
        },
10913
 
 
10914
 
        //internal value getter
10915
 
        // _value() returns value trimmed by min and max, aligned by step
10916
 
        _value: function() {
10917
 
                var val = this.options.value;
10918
 
                val = this._trimAlignValue( val );
10919
 
 
10920
 
                return val;
10921
 
        },
10922
 
 
10923
 
        //internal values getter
10924
 
        // _values() returns array of values trimmed by min and max, aligned by step
10925
 
        // _values( index ) returns single value trimmed by min and max, aligned by step
10926
 
        _values: function( index ) {
10927
 
                var val,
10928
 
                        vals,
10929
 
                        i;
10930
 
 
10931
 
                if ( arguments.length ) {
10932
 
                        val = this.options.values[ index ];
10933
 
                        val = this._trimAlignValue( val );
10934
 
 
10935
 
                        return val;
10936
 
                } else {
10937
 
                        // .slice() creates a copy of the array
10938
 
                        // this copy gets trimmed by min and max and then returned
10939
 
                        vals = this.options.values.slice();
10940
 
                        for ( i = 0; i < vals.length; i+= 1) {
10941
 
                                vals[ i ] = this._trimAlignValue( vals[ i ] );
10942
 
                        }
10943
 
 
10944
 
                        return vals;
10945
 
                }
10946
 
        },
10947
 
        
10948
 
        // returns the step-aligned value that val is closest to, between (inclusive) min and max
10949
 
        _trimAlignValue: function( val ) {
10950
 
                if ( val <= this._valueMin() ) {
10951
 
                        return this._valueMin();
10952
 
                }
10953
 
                if ( val >= this._valueMax() ) {
10954
 
                        return this._valueMax();
10955
 
                }
10956
 
                var step = ( this.options.step > 0 ) ? this.options.step : 1,
10957
 
                        valModStep = (val - this._valueMin()) % step,
10958
 
                        alignValue = val - valModStep;
10959
 
 
10960
 
                if ( Math.abs(valModStep) * 2 >= step ) {
10961
 
                        alignValue += ( valModStep > 0 ) ? step : ( -step );
10962
 
                }
10963
 
 
10964
 
                // Since JavaScript has problems with large floats, round
10965
 
                // the final value to 5 digits after the decimal point (see #4124)
10966
 
                return parseFloat( alignValue.toFixed(5) );
10967
 
        },
10968
 
 
10969
 
        _valueMin: function() {
10970
 
                return this.options.min;
10971
 
        },
10972
 
 
10973
 
        _valueMax: function() {
10974
 
                return this.options.max;
10975
 
        },
10976
 
        
10977
 
        _refreshValue: function() {
10978
 
                var oRange = this.options.range,
10979
 
                        o = this.options,
10980
 
                        self = this,
10981
 
                        animate = ( !this._animateOff ) ? o.animate : false,
10982
 
                        valPercent,
10983
 
                        _set = {},
10984
 
                        lastValPercent,
10985
 
                        value,
10986
 
                        valueMin,
10987
 
                        valueMax;
10988
 
 
10989
 
                if ( this.options.values && this.options.values.length ) {
10990
 
                        this.handles.each(function( i, j ) {
10991
 
                                valPercent = ( self.values(i) - self._valueMin() ) / ( self._valueMax() - self._valueMin() ) * 100;
10992
 
                                _set[ self.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
10993
 
                                $( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
10994
 
                                if ( self.options.range === true ) {
10995
 
                                        if ( self.orientation === "horizontal" ) {
10996
 
                                                if ( i === 0 ) {
10997
 
                                                        self.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { left: valPercent + "%" }, o.animate );
10998
 
                                                }
10999
 
                                                if ( i === 1 ) {
11000
 
                                                        self.range[ animate ? "animate" : "css" ]( { width: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
11001
 
                                                }
11002
 
                                        } else {
11003
 
                                                if ( i === 0 ) {
11004
 
                                                        self.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { bottom: ( valPercent ) + "%" }, o.animate );
11005
 
                                                }
11006
 
                                                if ( i === 1 ) {
11007
 
                                                        self.range[ animate ? "animate" : "css" ]( { height: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
11008
 
                                                }
11009
 
                                        }
11010
 
                                }
11011
 
                                lastValPercent = valPercent;
11012
 
                        });
11013
 
                } else {
11014
 
                        value = this.value();
11015
 
                        valueMin = this._valueMin();
11016
 
                        valueMax = this._valueMax();
11017
 
                        valPercent = ( valueMax !== valueMin ) ?
11018
 
                                        ( value - valueMin ) / ( valueMax - valueMin ) * 100 :
11019
 
                                        0;
11020
 
                        _set[ self.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
11021
 
                        this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
11022
 
 
11023
 
                        if ( oRange === "min" && this.orientation === "horizontal" ) {
11024
 
                                this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { width: valPercent + "%" }, o.animate );
11025
 
                        }
11026
 
                        if ( oRange === "max" && this.orientation === "horizontal" ) {
11027
 
                                this.range[ animate ? "animate" : "css" ]( { width: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
11028
 
                        }
11029
 
                        if ( oRange === "min" && this.orientation === "vertical" ) {
11030
 
                                this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { height: valPercent + "%" }, o.animate );
11031
 
                        }
11032
 
                        if ( oRange === "max" && this.orientation === "vertical" ) {
11033
 
                                this.range[ animate ? "animate" : "css" ]( { height: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
11034
 
                        }
11035
 
                }
11036
 
        }
11037
 
 
11038
 
});
11039
 
 
11040
 
$.extend( $.ui.slider, {
11041
 
        version: "1.8.18"
11042
 
});
11043
 
 
11044
 
}(jQuery));
11045
 
/*
11046
 
 * jQuery UI Tabs 1.8.18
11047
 
 *
11048
 
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
11049
 
 * Dual licensed under the MIT or GPL Version 2 licenses.
11050
 
 * http://jquery.org/license
11051
 
 *
11052
 
 * http://docs.jquery.com/UI/Tabs
11053
 
 *
11054
 
 * Depends:
11055
 
 *      jquery.ui.core.js
11056
 
 *      jquery.ui.widget.js
11057
 
 */
11058
 
(function( $, undefined ) {
11059
 
 
11060
 
var tabId = 0,
11061
 
        listId = 0;
11062
 
 
11063
 
function getNextTabId() {
11064
 
        return ++tabId;
11065
 
}
11066
 
 
11067
 
function getNextListId() {
11068
 
        return ++listId;
11069
 
}
11070
 
 
11071
 
$.widget( "ui.tabs", {
11072
 
        options: {
11073
 
                add: null,
11074
 
                ajaxOptions: null,
11075
 
                cache: false,
11076
 
                cookie: null, // e.g. { expires: 7, path: '/', domain: 'jquery.com', secure: true }
11077
 
                collapsible: false,
11078
 
                disable: null,
11079
 
                disabled: [],
11080
 
                enable: null,
11081
 
                event: "click",
11082
 
                fx: null, // e.g. { height: 'toggle', opacity: 'toggle', duration: 200 }
11083
 
                idPrefix: "ui-tabs-",
11084
 
                load: null,
11085
 
                panelTemplate: "<div></div>",
11086
 
                remove: null,
11087
 
                select: null,
11088
 
                show: null,
11089
 
                spinner: "<em>Loading&#8230;</em>",
11090
 
                tabTemplate: "<li><a href='#{href}'><span>#{label}</span></a></li>"
11091
 
        },
11092
 
 
11093
 
        _create: function() {
11094
 
                this._tabify( true );
11095
 
        },
11096
 
 
11097
 
        _setOption: function( key, value ) {
11098
 
                if ( key == "selected" ) {
11099
 
                        if (this.options.collapsible && value == this.options.selected ) {
11100
 
                                return;
11101
 
                        }
11102
 
                        this.select( value );
11103
 
                } else {
11104
 
                        this.options[ key ] = value;
11105
 
                        this._tabify();
11106
 
                }
11107
 
        },
11108
 
 
11109
 
        _tabId: function( a ) {
11110
 
                return a.title && a.title.replace( /\s/g, "_" ).replace( /[^\w\u00c0-\uFFFF-]/g, "" ) ||
11111
 
                        this.options.idPrefix + getNextTabId();
11112
 
        },
11113
 
 
11114
 
        _sanitizeSelector: function( hash ) {
11115
 
                // we need this because an id may contain a ":"
11116
 
                return hash.replace( /:/g, "\\:" );
11117
 
        },
11118
 
 
11119
 
        _cookie: function() {
11120
 
                var cookie = this.cookie ||
11121
 
                        ( this.cookie = this.options.cookie.name || "ui-tabs-" + getNextListId() );
11122
 
                return $.cookie.apply( null, [ cookie ].concat( $.makeArray( arguments ) ) );
11123
 
        },
11124
 
 
11125
 
        _ui: function( tab, panel ) {
11126
 
                return {
11127
 
                        tab: tab,
11128
 
                        panel: panel,
11129
 
                        index: this.anchors.index( tab )
11130
 
                };
11131
 
        },
11132
 
 
11133
 
        _cleanup: function() {
11134
 
                // restore all former loading tabs labels
11135
 
                this.lis.filter( ".ui-state-processing" )
11136
 
                        .removeClass( "ui-state-processing" )
11137
 
                        .find( "span:data(label.tabs)" )
11138
 
                                .each(function() {
11139
 
                                        var el = $( this );
11140
 
                                        el.html( el.data( "label.tabs" ) ).removeData( "label.tabs" );
11141
 
                                });
11142
 
        },
11143
 
 
11144
 
        _tabify: function( init ) {
11145
 
                var self = this,
11146
 
                        o = this.options,
11147
 
                        fragmentId = /^#.+/; // Safari 2 reports '#' for an empty hash
11148
 
 
11149
 
                this.list = this.element.find( "ol,ul" ).eq( 0 );
11150
 
                this.lis = $( " > li:has(a[href])", this.list );
11151
 
                this.anchors = this.lis.map(function() {
11152
 
                        return $( "a", this )[ 0 ];
11153
 
                });
11154
 
                this.panels = $( [] );
11155
 
 
11156
 
                this.anchors.each(function( i, a ) {
11157
 
                        var href = $( a ).attr( "href" );
11158
 
                        // For dynamically created HTML that contains a hash as href IE < 8 expands
11159
 
                        // such href to the full page url with hash and then misinterprets tab as ajax.
11160
 
                        // Same consideration applies for an added tab with a fragment identifier
11161
 
                        // since a[href=#fragment-identifier] does unexpectedly not match.
11162
 
                        // Thus normalize href attribute...
11163
 
                        var hrefBase = href.split( "#" )[ 0 ],
11164
 
                                baseEl;
11165
 
                        if ( hrefBase && ( hrefBase === location.toString().split( "#" )[ 0 ] ||
11166
 
                                        ( baseEl = $( "base" )[ 0 ]) && hrefBase === baseEl.href ) ) {
11167
 
                                href = a.hash;
11168
 
                                a.href = href;
11169
 
                        }
11170
 
 
11171
 
                        // inline tab
11172
 
                        if ( fragmentId.test( href ) ) {
11173
 
                                self.panels = self.panels.add( self.element.find( self._sanitizeSelector( href ) ) );
11174
 
                        // remote tab
11175
 
                        // prevent loading the page itself if href is just "#"
11176
 
                        } else if ( href && href !== "#" ) {
11177
 
                                // required for restore on destroy
11178
 
                                $.data( a, "href.tabs", href );
11179
 
 
11180
 
                                // TODO until #3808 is fixed strip fragment identifier from url
11181
 
                                // (IE fails to load from such url)
11182
 
                                $.data( a, "load.tabs", href.replace( /#.*$/, "" ) );
11183
 
 
11184
 
                                var id = self._tabId( a );
11185
 
                                a.href = "#" + id;
11186
 
                                var $panel = self.element.find( "#" + id );
11187
 
                                if ( !$panel.length ) {
11188
 
                                        $panel = $( o.panelTemplate )
11189
 
                                                .attr( "id", id )
11190
 
                                                .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
11191
 
                                                .insertAfter( self.panels[ i - 1 ] || self.list );
11192
 
                                        $panel.data( "destroy.tabs", true );
11193
 
                                }
11194
 
                                self.panels = self.panels.add( $panel );
11195
 
                        // invalid tab href
11196
 
                        } else {
11197
 
                                o.disabled.push( i );
11198
 
                        }
11199
 
                });
11200
 
 
11201
 
                // initialization from scratch
11202
 
                if ( init ) {
11203
 
                        // attach necessary classes for styling
11204
 
                        this.element.addClass( "ui-tabs ui-widget ui-widget-content ui-corner-all" );
11205
 
                        this.list.addClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" );
11206
 
                        this.lis.addClass( "ui-state-default ui-corner-top" );
11207
 
                        this.panels.addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" );
11208
 
 
11209
 
                        // Selected tab
11210
 
                        // use "selected" option or try to retrieve:
11211
 
                        // 1. from fragment identifier in url
11212
 
                        // 2. from cookie
11213
 
                        // 3. from selected class attribute on <li>
11214
 
                        if ( o.selected === undefined ) {
11215
 
                                if ( location.hash ) {
11216
 
                                        this.anchors.each(function( i, a ) {
11217
 
                                                if ( a.hash == location.hash ) {
11218
 
                                                        o.selected = i;
11219
 
                                                        return false;
11220
 
                                                }
11221
 
                                        });
11222
 
                                }
11223
 
                                if ( typeof o.selected !== "number" && o.cookie ) {
11224
 
                                        o.selected = parseInt( self._cookie(), 10 );
11225
 
                                }
11226
 
                                if ( typeof o.selected !== "number" && this.lis.filter( ".ui-tabs-selected" ).length ) {
11227
 
                                        o.selected = this.lis.index( this.lis.filter( ".ui-tabs-selected" ) );
11228
 
                                }
11229
 
                                o.selected = o.selected || ( this.lis.length ? 0 : -1 );
11230
 
                        } else if ( o.selected === null ) { // usage of null is deprecated, TODO remove in next release
11231
 
                                o.selected = -1;
11232
 
                        }
11233
 
 
11234
 
                        // sanity check - default to first tab...
11235
 
                        o.selected = ( ( o.selected >= 0 && this.anchors[ o.selected ] ) || o.selected < 0 )
11236
 
                                ? o.selected
11237
 
                                : 0;
11238
 
 
11239
 
                        // Take disabling tabs via class attribute from HTML
11240
 
                        // into account and update option properly.
11241
 
                        // A selected tab cannot become disabled.
11242
 
                        o.disabled = $.unique( o.disabled.concat(
11243
 
                                $.map( this.lis.filter( ".ui-state-disabled" ), function( n, i ) {
11244
 
                                        return self.lis.index( n );
11245
 
                                })
11246
 
                        ) ).sort();
11247
 
 
11248
 
                        if ( $.inArray( o.selected, o.disabled ) != -1 ) {
11249
 
                                o.disabled.splice( $.inArray( o.selected, o.disabled ), 1 );
11250
 
                        }
11251
 
 
11252
 
                        // highlight selected tab
11253
 
                        this.panels.addClass( "ui-tabs-hide" );
11254
 
                        this.lis.removeClass( "ui-tabs-selected ui-state-active" );
11255
 
                        // check for length avoids error when initializing empty list
11256
 
                        if ( o.selected >= 0 && this.anchors.length ) {
11257
 
                                self.element.find( self._sanitizeSelector( self.anchors[ o.selected ].hash ) ).removeClass( "ui-tabs-hide" );
11258
 
                                this.lis.eq( o.selected ).addClass( "ui-tabs-selected ui-state-active" );
11259
 
 
11260
 
                                // seems to be expected behavior that the show callback is fired
11261
 
                                self.element.queue( "tabs", function() {
11262
 
                                        self._trigger( "show", null,
11263
 
                                                self._ui( self.anchors[ o.selected ], self.element.find( self._sanitizeSelector( self.anchors[ o.selected ].hash ) )[ 0 ] ) );
11264
 
                                });
11265
 
 
11266
 
                                this.load( o.selected );
11267
 
                        }
11268
 
 
11269
 
                        // clean up to avoid memory leaks in certain versions of IE 6
11270
 
                        // TODO: namespace this event
11271
 
                        $( window ).bind( "unload", function() {
11272
 
                                self.lis.add( self.anchors ).unbind( ".tabs" );
11273
 
                                self.lis = self.anchors = self.panels = null;
11274
 
                        });
11275
 
                // update selected after add/remove
11276
 
                } else {
11277
 
                        o.selected = this.lis.index( this.lis.filter( ".ui-tabs-selected" ) );
11278
 
                }
11279
 
 
11280
 
                // update collapsible
11281
 
                // TODO: use .toggleClass()
11282
 
                this.element[ o.collapsible ? "addClass" : "removeClass" ]( "ui-tabs-collapsible" );
11283
 
 
11284
 
                // set or update cookie after init and add/remove respectively
11285
 
                if ( o.cookie ) {
11286
 
                        this._cookie( o.selected, o.cookie );
11287
 
                }
11288
 
 
11289
 
                // disable tabs
11290
 
                for ( var i = 0, li; ( li = this.lis[ i ] ); i++ ) {
11291
 
                        $( li )[ $.inArray( i, o.disabled ) != -1 &&
11292
 
                                // TODO: use .toggleClass()
11293
 
                                !$( li ).hasClass( "ui-tabs-selected" ) ? "addClass" : "removeClass" ]( "ui-state-disabled" );
11294
 
                }
11295
 
 
11296
 
                // reset cache if switching from cached to not cached
11297
 
                if ( o.cache === false ) {
11298
 
                        this.anchors.removeData( "cache.tabs" );
11299
 
                }
11300
 
 
11301
 
                // remove all handlers before, tabify may run on existing tabs after add or option change
11302
 
                this.lis.add( this.anchors ).unbind( ".tabs" );
11303
 
 
11304
 
                if ( o.event !== "mouseover" ) {
11305
 
                        var addState = function( state, el ) {
11306
 
                                if ( el.is( ":not(.ui-state-disabled)" ) ) {
11307
 
                                        el.addClass( "ui-state-" + state );
11308
 
                                }
11309
 
                        };
11310
 
                        var removeState = function( state, el ) {
11311
 
                                el.removeClass( "ui-state-" + state );
11312
 
                        };
11313
 
                        this.lis.bind( "mouseover.tabs" , function() {
11314
 
                                addState( "hover", $( this ) );
11315
 
                        });
11316
 
                        this.lis.bind( "mouseout.tabs", function() {
11317
 
                                removeState( "hover", $( this ) );
11318
 
                        });
11319
 
                        this.anchors.bind( "focus.tabs", function() {
11320
 
                                addState( "focus", $( this ).closest( "li" ) );
11321
 
                        });
11322
 
                        this.anchors.bind( "blur.tabs", function() {
11323
 
                                removeState( "focus", $( this ).closest( "li" ) );
11324
 
                        });
11325
 
                }
11326
 
 
11327
 
                // set up animations
11328
 
                var hideFx, showFx;
11329
 
                if ( o.fx ) {
11330
 
                        if ( $.isArray( o.fx ) ) {
11331
 
                                hideFx = o.fx[ 0 ];
11332
 
                                showFx = o.fx[ 1 ];
11333
 
                        } else {
11334
 
                                hideFx = showFx = o.fx;
11335
 
                        }
11336
 
                }
11337
 
 
11338
 
                // Reset certain styles left over from animation
11339
 
                // and prevent IE's ClearType bug...
11340
 
                function resetStyle( $el, fx ) {
11341
 
                        $el.css( "display", "" );
11342
 
                        if ( !$.support.opacity && fx.opacity ) {
11343
 
                                $el[ 0 ].style.removeAttribute( "filter" );
11344
 
                        }
11345
 
                }
11346
 
 
11347
 
                // Show a tab...
11348
 
                var showTab = showFx
11349
 
                        ? function( clicked, $show ) {
11350
 
                                $( clicked ).closest( "li" ).addClass( "ui-tabs-selected ui-state-active" );
11351
 
                                $show.hide().removeClass( "ui-tabs-hide" ) // avoid flicker that way
11352
 
                                        .animate( showFx, showFx.duration || "normal", function() {
11353
 
                                                resetStyle( $show, showFx );
11354
 
                                                self._trigger( "show", null, self._ui( clicked, $show[ 0 ] ) );
11355
 
                                        });
11356
 
                        }
11357
 
                        : function( clicked, $show ) {
11358
 
                                $( clicked ).closest( "li" ).addClass( "ui-tabs-selected ui-state-active" );
11359
 
                                $show.removeClass( "ui-tabs-hide" );
11360
 
                                self._trigger( "show", null, self._ui( clicked, $show[ 0 ] ) );
11361
 
                        };
11362
 
 
11363
 
                // Hide a tab, $show is optional...
11364
 
                var hideTab = hideFx
11365
 
                        ? function( clicked, $hide ) {
11366
 
                                $hide.animate( hideFx, hideFx.duration || "normal", function() {
11367
 
                                        self.lis.removeClass( "ui-tabs-selected ui-state-active" );
11368
 
                                        $hide.addClass( "ui-tabs-hide" );
11369
 
                                        resetStyle( $hide, hideFx );
11370
 
                                        self.element.dequeue( "tabs" );
11371
 
                                });
11372
 
                        }
11373
 
                        : function( clicked, $hide, $show ) {
11374
 
                                self.lis.removeClass( "ui-tabs-selected ui-state-active" );
11375
 
                                $hide.addClass( "ui-tabs-hide" );
11376
 
                                self.element.dequeue( "tabs" );
11377
 
                        };
11378
 
 
11379
 
                // attach tab event handler, unbind to avoid duplicates from former tabifying...
11380
 
                this.anchors.bind( o.event + ".tabs", function() {
11381
 
                        var el = this,
11382
 
                                $li = $(el).closest( "li" ),
11383
 
                                $hide = self.panels.filter( ":not(.ui-tabs-hide)" ),
11384
 
                                $show = self.element.find( self._sanitizeSelector( el.hash ) );
11385
 
 
11386
 
                        // If tab is already selected and not collapsible or tab disabled or
11387
 
                        // or is already loading or click callback returns false stop here.
11388
 
                        // Check if click handler returns false last so that it is not executed
11389
 
                        // for a disabled or loading tab!
11390
 
                        if ( ( $li.hasClass( "ui-tabs-selected" ) && !o.collapsible) ||
11391
 
                                $li.hasClass( "ui-state-disabled" ) ||
11392
 
                                $li.hasClass( "ui-state-processing" ) ||
11393
 
                                self.panels.filter( ":animated" ).length ||
11394
 
                                self._trigger( "select", null, self._ui( this, $show[ 0 ] ) ) === false ) {
11395
 
                                this.blur();
11396
 
                                return false;
11397
 
                        }
11398
 
 
11399
 
                        o.selected = self.anchors.index( this );
11400
 
 
11401
 
                        self.abort();
11402
 
 
11403
 
                        // if tab may be closed
11404
 
                        if ( o.collapsible ) {
11405
 
                                if ( $li.hasClass( "ui-tabs-selected" ) ) {
11406
 
                                        o.selected = -1;
11407
 
 
11408
 
                                        if ( o.cookie ) {
11409
 
                                                self._cookie( o.selected, o.cookie );
11410
 
                                        }
11411
 
 
11412
 
                                        self.element.queue( "tabs", function() {
11413
 
                                                hideTab( el, $hide );
11414
 
                                        }).dequeue( "tabs" );
11415
 
 
11416
 
                                        this.blur();
11417
 
                                        return false;
11418
 
                                } else if ( !$hide.length ) {
11419
 
                                        if ( o.cookie ) {
11420
 
                                                self._cookie( o.selected, o.cookie );
11421
 
                                        }
11422
 
 
11423
 
                                        self.element.queue( "tabs", function() {
11424
 
                                                showTab( el, $show );
11425
 
                                        });
11426
 
 
11427
 
                                        // TODO make passing in node possible, see also http://dev.jqueryui.com/ticket/3171
11428
 
                                        self.load( self.anchors.index( this ) );
11429
 
 
11430
 
                                        this.blur();
11431
 
                                        return false;
11432
 
                                }
11433
 
                        }
11434
 
 
11435
 
                        if ( o.cookie ) {
11436
 
                                self._cookie( o.selected, o.cookie );
11437
 
                        }
11438
 
 
11439
 
                        // show new tab
11440
 
                        if ( $show.length ) {
11441
 
                                if ( $hide.length ) {
11442
 
                                        self.element.queue( "tabs", function() {
11443
 
                                                hideTab( el, $hide );
11444
 
                                        });
11445
 
                                }
11446
 
                                self.element.queue( "tabs", function() {
11447
 
                                        showTab( el, $show );
11448
 
                                });
11449
 
 
11450
 
                                self.load( self.anchors.index( this ) );
11451
 
                        } else {
11452
 
                                throw "jQuery UI Tabs: Mismatching fragment identifier.";
11453
 
                        }
11454
 
 
11455
 
                        // Prevent IE from keeping other link focussed when using the back button
11456
 
                        // and remove dotted border from clicked link. This is controlled via CSS
11457
 
                        // in modern browsers; blur() removes focus from address bar in Firefox
11458
 
                        // which can become a usability and annoying problem with tabs('rotate').
11459
 
                        if ( $.browser.msie ) {
11460
 
                                this.blur();
11461
 
                        }
11462
 
                });
11463
 
 
11464
 
                // disable click in any case
11465
 
                this.anchors.bind( "click.tabs", function(){
11466
 
                        return false;
11467
 
                });
11468
 
        },
11469
 
 
11470
 
    _getIndex: function( index ) {
11471
 
                // meta-function to give users option to provide a href string instead of a numerical index.
11472
 
                // also sanitizes numerical indexes to valid values.
11473
 
                if ( typeof index == "string" ) {
11474
 
                        index = this.anchors.index( this.anchors.filter( "[href$=" + index + "]" ) );
11475
 
                }
11476
 
 
11477
 
                return index;
11478
 
        },
11479
 
 
11480
 
        destroy: function() {
11481
 
                var o = this.options;
11482
 
 
11483
 
                this.abort();
11484
 
 
11485
 
                this.element
11486
 
                        .unbind( ".tabs" )
11487
 
                        .removeClass( "ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible" )
11488
 
                        .removeData( "tabs" );
11489
 
 
11490
 
                this.list.removeClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" );
11491
 
 
11492
 
                this.anchors.each(function() {
11493
 
                        var href = $.data( this, "href.tabs" );
11494
 
                        if ( href ) {
11495
 
                                this.href = href;
11496
 
                        }
11497
 
                        var $this = $( this ).unbind( ".tabs" );
11498
 
                        $.each( [ "href", "load", "cache" ], function( i, prefix ) {
11499
 
                                $this.removeData( prefix + ".tabs" );
11500
 
                        });
11501
 
                });
11502
 
 
11503
 
                this.lis.unbind( ".tabs" ).add( this.panels ).each(function() {
11504
 
                        if ( $.data( this, "destroy.tabs" ) ) {
11505
 
                                $( this ).remove();
11506
 
                        } else {
11507
 
                                $( this ).removeClass([
11508
 
                                        "ui-state-default",
11509
 
                                        "ui-corner-top",
11510
 
                                        "ui-tabs-selected",
11511
 
                                        "ui-state-active",
11512
 
                                        "ui-state-hover",
11513
 
                                        "ui-state-focus",
11514
 
                                        "ui-state-disabled",
11515
 
                                        "ui-tabs-panel",
11516
 
                                        "ui-widget-content",
11517
 
                                        "ui-corner-bottom",
11518
 
                                        "ui-tabs-hide"
11519
 
                                ].join( " " ) );
11520
 
                        }
11521
 
                });
11522
 
 
11523
 
                if ( o.cookie ) {
11524
 
                        this._cookie( null, o.cookie );
11525
 
                }
11526
 
 
11527
 
                return this;
11528
 
        },
11529
 
 
11530
 
        add: function( url, label, index ) {
11531
 
                if ( index === undefined ) {
11532
 
                        index = this.anchors.length;
11533
 
                }
11534
 
 
11535
 
                var self = this,
11536
 
                        o = this.options,
11537
 
                        $li = $( o.tabTemplate.replace( /#\{href\}/g, url ).replace( /#\{label\}/g, label ) ),
11538
 
                        id = !url.indexOf( "#" ) ? url.replace( "#", "" ) : this._tabId( $( "a", $li )[ 0 ] );
11539
 
 
11540
 
                $li.addClass( "ui-state-default ui-corner-top" ).data( "destroy.tabs", true );
11541
 
 
11542
 
                // try to find an existing element before creating a new one
11543
 
                var $panel = self.element.find( "#" + id );
11544
 
                if ( !$panel.length ) {
11545
 
                        $panel = $( o.panelTemplate )
11546
 
                                .attr( "id", id )
11547
 
                                .data( "destroy.tabs", true );
11548
 
                }
11549
 
                $panel.addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" );
11550
 
 
11551
 
                if ( index >= this.lis.length ) {
11552
 
                        $li.appendTo( this.list );
11553
 
                        $panel.appendTo( this.list[ 0 ].parentNode );
11554
 
                } else {
11555
 
                        $li.insertBefore( this.lis[ index ] );
11556
 
                        $panel.insertBefore( this.panels[ index ] );
11557
 
                }
11558
 
 
11559
 
                o.disabled = $.map( o.disabled, function( n, i ) {
11560
 
                        return n >= index ? ++n : n;
11561
 
                });
11562
 
 
11563
 
                this._tabify();
11564
 
 
11565
 
                if ( this.anchors.length == 1 ) {
11566
 
                        o.selected = 0;
11567
 
                        $li.addClass( "ui-tabs-selected ui-state-active" );
11568
 
                        $panel.removeClass( "ui-tabs-hide" );
11569
 
                        this.element.queue( "tabs", function() {
11570
 
                                self._trigger( "show", null, self._ui( self.anchors[ 0 ], self.panels[ 0 ] ) );
11571
 
                        });
11572
 
 
11573
 
                        this.load( 0 );
11574
 
                }
11575
 
 
11576
 
                this._trigger( "add", null, this._ui( this.anchors[ index ], this.panels[ index ] ) );
11577
 
                return this;
11578
 
        },
11579
 
 
11580
 
        remove: function( index ) {
11581
 
                index = this._getIndex( index );
11582
 
                var o = this.options,
11583
 
                        $li = this.lis.eq( index ).remove(),
11584
 
                        $panel = this.panels.eq( index ).remove();
11585
 
 
11586
 
                // If selected tab was removed focus tab to the right or
11587
 
                // in case the last tab was removed the tab to the left.
11588
 
                if ( $li.hasClass( "ui-tabs-selected" ) && this.anchors.length > 1) {
11589
 
                        this.select( index + ( index + 1 < this.anchors.length ? 1 : -1 ) );
11590
 
                }
11591
 
 
11592
 
                o.disabled = $.map(
11593
 
                        $.grep( o.disabled, function(n, i) {
11594
 
                                return n != index;
11595
 
                        }),
11596
 
                        function( n, i ) {
11597
 
                                return n >= index ? --n : n;
11598
 
                        });
11599
 
 
11600
 
                this._tabify();
11601
 
 
11602
 
                this._trigger( "remove", null, this._ui( $li.find( "a" )[ 0 ], $panel[ 0 ] ) );
11603
 
                return this;
11604
 
        },
11605
 
 
11606
 
        enable: function( index ) {
11607
 
                index = this._getIndex( index );
11608
 
                var o = this.options;
11609
 
                if ( $.inArray( index, o.disabled ) == -1 ) {
11610
 
                        return;
11611
 
                }
11612
 
 
11613
 
                this.lis.eq( index ).removeClass( "ui-state-disabled" );
11614
 
                o.disabled = $.grep( o.disabled, function( n, i ) {
11615
 
                        return n != index;
11616
 
                });
11617
 
 
11618
 
                this._trigger( "enable", null, this._ui( this.anchors[ index ], this.panels[ index ] ) );
11619
 
                return this;
11620
 
        },
11621
 
 
11622
 
        disable: function( index ) {
11623
 
                index = this._getIndex( index );
11624
 
                var self = this, o = this.options;
11625
 
                // cannot disable already selected tab
11626
 
                if ( index != o.selected ) {
11627
 
                        this.lis.eq( index ).addClass( "ui-state-disabled" );
11628
 
 
11629
 
                        o.disabled.push( index );
11630
 
                        o.disabled.sort();
11631
 
 
11632
 
                        this._trigger( "disable", null, this._ui( this.anchors[ index ], this.panels[ index ] ) );
11633
 
                }
11634
 
 
11635
 
                return this;
11636
 
        },
11637
 
 
11638
 
        select: function( index ) {
11639
 
                index = this._getIndex( index );
11640
 
                if ( index == -1 ) {
11641
 
                        if ( this.options.collapsible && this.options.selected != -1 ) {
11642
 
                                index = this.options.selected;
11643
 
                        } else {
11644
 
                                return this;
11645
 
                        }
11646
 
                }
11647
 
                this.anchors.eq( index ).trigger( this.options.event + ".tabs" );
11648
 
                return this;
11649
 
        },
11650
 
 
11651
 
        load: function( index ) {
11652
 
                index = this._getIndex( index );
11653
 
                var self = this,
11654
 
                        o = this.options,
11655
 
                        a = this.anchors.eq( index )[ 0 ],
11656
 
                        url = $.data( a, "load.tabs" );
11657
 
 
11658
 
                this.abort();
11659
 
 
11660
 
                // not remote or from cache
11661
 
                if ( !url || this.element.queue( "tabs" ).length !== 0 && $.data( a, "cache.tabs" ) ) {
11662
 
                        this.element.dequeue( "tabs" );
11663
 
                        return;
11664
 
                }
11665
 
 
11666
 
                // load remote from here on
11667
 
                this.lis.eq( index ).addClass( "ui-state-processing" );
11668
 
 
11669
 
                if ( o.spinner ) {
11670
 
                        var span = $( "span", a );
11671
 
                        span.data( "label.tabs", span.html() ).html( o.spinner );
11672
 
                }
11673
 
 
11674
 
                this.xhr = $.ajax( $.extend( {}, o.ajaxOptions, {
11675
 
                        url: url,
11676
 
                        success: function( r, s ) {
11677
 
                                self.element.find( self._sanitizeSelector( a.hash ) ).html( r );
11678
 
 
11679
 
                                // take care of tab labels
11680
 
                                self._cleanup();
11681
 
 
11682
 
                                if ( o.cache ) {
11683
 
                                        $.data( a, "cache.tabs", true );
11684
 
                                }
11685
 
 
11686
 
                                self._trigger( "load", null, self._ui( self.anchors[ index ], self.panels[ index ] ) );
11687
 
                                try {
11688
 
                                        o.ajaxOptions.success( r, s );
11689
 
                                }
11690
 
                                catch ( e ) {}
11691
 
                        },
11692
 
                        error: function( xhr, s, e ) {
11693
 
                                // take care of tab labels
11694
 
                                self._cleanup();
11695
 
 
11696
 
                                self._trigger( "load", null, self._ui( self.anchors[ index ], self.panels[ index ] ) );
11697
 
                                try {
11698
 
                                        // Passing index avoid a race condition when this method is
11699
 
                                        // called after the user has selected another tab.
11700
 
                                        // Pass the anchor that initiated this request allows
11701
 
                                        // loadError to manipulate the tab content panel via $(a.hash)
11702
 
                                        o.ajaxOptions.error( xhr, s, index, a );
11703
 
                                }
11704
 
                                catch ( e ) {}
11705
 
                        }
11706
 
                } ) );
11707
 
 
11708
 
                // last, so that load event is fired before show...
11709
 
                self.element.dequeue( "tabs" );
11710
 
 
11711
 
                return this;
11712
 
        },
11713
 
 
11714
 
        abort: function() {
11715
 
                // stop possibly running animations
11716
 
                this.element.queue( [] );
11717
 
                this.panels.stop( false, true );
11718
 
 
11719
 
                // "tabs" queue must not contain more than two elements,
11720
 
                // which are the callbacks for the latest clicked tab...
11721
 
                this.element.queue( "tabs", this.element.queue( "tabs" ).splice( -2, 2 ) );
11722
 
 
11723
 
                // terminate pending requests from other tabs
11724
 
                if ( this.xhr ) {
11725
 
                        this.xhr.abort();
11726
 
                        delete this.xhr;
11727
 
                }
11728
 
 
11729
 
                // take care of tab labels
11730
 
                this._cleanup();
11731
 
                return this;
11732
 
        },
11733
 
 
11734
 
        url: function( index, url ) {
11735
 
                this.anchors.eq( index ).removeData( "cache.tabs" ).data( "load.tabs", url );
11736
 
                return this;
11737
 
        },
11738
 
 
11739
 
        length: function() {
11740
 
                return this.anchors.length;
11741
 
        }
11742
 
});
11743
 
 
11744
 
$.extend( $.ui.tabs, {
11745
 
        version: "1.8.18"
11746
 
});
11747
 
 
11748
 
/*
11749
 
 * Tabs Extensions
11750
 
 */
11751
 
 
11752
 
/*
11753
 
 * Rotate
11754
 
 */
11755
 
$.extend( $.ui.tabs.prototype, {
11756
 
        rotation: null,
11757
 
        rotate: function( ms, continuing ) {
11758
 
                var self = this,
11759
 
                        o = this.options;
11760
 
 
11761
 
                var rotate = self._rotate || ( self._rotate = function( e ) {
11762
 
                        clearTimeout( self.rotation );
11763
 
                        self.rotation = setTimeout(function() {
11764
 
                                var t = o.selected;
11765
 
                                self.select( ++t < self.anchors.length ? t : 0 );
11766
 
                        }, ms );
11767
 
                        
11768
 
                        if ( e ) {
11769
 
                                e.stopPropagation();
11770
 
                        }
11771
 
                });
11772
 
 
11773
 
                var stop = self._unrotate || ( self._unrotate = !continuing
11774
 
                        ? function(e) {
11775
 
                                if (e.clientX) { // in case of a true click
11776
 
                                        self.rotate(null);
11777
 
                                }
11778
 
                        }
11779
 
                        : function( e ) {
11780
 
                                t = o.selected;
11781
 
                                rotate();
11782
 
                        });
11783
 
 
11784
 
                // start rotation
11785
 
                if ( ms ) {
11786
 
                        this.element.bind( "tabsshow", rotate );
11787
 
                        this.anchors.bind( o.event + ".tabs", stop );
11788
 
                        rotate();
11789
 
                // stop rotation
11790
 
                } else {
11791
 
                        clearTimeout( self.rotation );
11792
 
                        this.element.unbind( "tabsshow", rotate );
11793
 
                        this.anchors.unbind( o.event + ".tabs", stop );
11794
 
                        delete this._rotate;
11795
 
                        delete this._unrotate;
11796
 
                }
11797
 
 
11798
 
                return this;
11799
 
        }
11800
 
});
11801
 
 
11802
 
})( jQuery );