~jstys-z/helioviewer.org/timeline

« back to all changes in this revision

Viewing changes to lib/jquery/jquery.ui-1.6rc2/ui/jquery.ui.all.js

  • Committer: V. Keith Hughitt
  • Date: 2009-03-26 19:20:57 UTC
  • Revision ID: hughitt1@kore-20090326192057-u0x8rf8sf5lmmnwh
nightly build 03-26-2009: Using alpha-channel JPEG 2000 dataset

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * jQuery UI @VERSION
3
 
 *
4
 
 * Copyright (c) 2008 Paul Bakaus (ui.jquery.com)
5
 
 * Dual licensed under the MIT (MIT-LICENSE.txt)
6
 
 * and GPL (GPL-LICENSE.txt) licenses.
7
 
 *
8
 
 * http://docs.jquery.com/UI
9
 
 */
10
 
;(function($) {
11
 
 
12
 
/** jQuery core modifications and additions **/
13
 
 
14
 
var _remove = $.fn.remove;
15
 
$.fn.remove = function() {
16
 
        $("*", this).add(this).triggerHandler("remove");
17
 
        return _remove.apply(this, arguments );
18
 
};
19
 
 
20
 
function isVisible(element) {
21
 
        function checkStyles(element) {
22
 
                var style = element.style;
23
 
                return (style.display != 'none' && style.visibility != 'hidden');
24
 
        }
25
 
        
26
 
        var visible = checkStyles(element);
27
 
        
28
 
        (visible && $.each($.dir(element, 'parentNode'), function() {
29
 
                return (visible = checkStyles(this));
30
 
        }));
31
 
        
32
 
        return visible;
33
 
}
34
 
 
35
 
$.extend($.expr[':'], {
36
 
        data: function(a, i, m) {
37
 
                return $.data(a, m[3]);
38
 
        },
39
 
        
40
 
        // TODO: add support for object, area
41
 
        tabbable: function(a, i, m) {
42
 
                var nodeName = a.nodeName.toLowerCase();
43
 
                
44
 
                return (
45
 
                        // in tab order
46
 
                        a.tabIndex >= 0 &&
47
 
                        
48
 
                        ( // filter node types that participate in the tab order
49
 
                                
50
 
                                // anchor tag
51
 
                                ('a' == nodeName && a.href) ||
52
 
                                
53
 
                                // enabled form element
54
 
                                (/input|select|textarea|button/.test(nodeName) &&
55
 
                                        'hidden' != a.type && !a.disabled)
56
 
                        ) &&
57
 
                        
58
 
                        // visible on page
59
 
                        isVisible(a)
60
 
                );
61
 
        }
62
 
});
63
 
 
64
 
$.keyCode = {
65
 
        BACKSPACE: 8,
66
 
        CAPS_LOCK: 20,
67
 
        COMMA: 188,
68
 
        CONTROL: 17,
69
 
        DELETE: 46,
70
 
        DOWN: 40,
71
 
        END: 35,
72
 
        ENTER: 13,
73
 
        ESCAPE: 27,
74
 
        HOME: 36,
75
 
        INSERT: 45,
76
 
        LEFT: 37,
77
 
        NUMPAD_ADD: 107,
78
 
        NUMPAD_DECIMAL: 110,
79
 
        NUMPAD_DIVIDE: 111,
80
 
        NUMPAD_ENTER: 108,
81
 
        NUMPAD_MULTIPLY: 106,
82
 
        NUMPAD_SUBTRACT: 109,
83
 
        PAGE_DOWN: 34,
84
 
        PAGE_UP: 33,
85
 
        PERIOD: 190,
86
 
        RIGHT: 39,
87
 
        SHIFT: 16,
88
 
        SPACE: 32,
89
 
        TAB: 9,
90
 
        UP: 38
91
 
};
92
 
 
93
 
// $.widget is a factory to create jQuery plugins
94
 
// taking some boilerplate code out of the plugin code
95
 
// created by Scott González and Jörn Zaefferer
96
 
function getter(namespace, plugin, method, args) {
97
 
        function getMethods(type) {
98
 
                var methods = $[namespace][plugin][type] || [];
99
 
                return (typeof methods == 'string' ? methods.split(/,?\s+/) : methods);
100
 
        }
101
 
        
102
 
        var methods = getMethods('getter');
103
 
        if (args.length == 1 && typeof args[0] == 'string') {
104
 
                methods = methods.concat(getMethods('getterSetter'));
105
 
        }
106
 
        return ($.inArray(method, methods) != -1);
107
 
}
108
 
 
109
 
$.widget = function(name, prototype) {
110
 
        var namespace = name.split(".")[0];
111
 
        name = name.split(".")[1];
112
 
        
113
 
        // create plugin method
114
 
        $.fn[name] = function(options) {
115
 
                var isMethodCall = (typeof options == 'string'),
116
 
                        args = Array.prototype.slice.call(arguments, 1);
117
 
                
118
 
                // prevent calls to internal methods
119
 
                if (isMethodCall && options.substring(0, 1) == '_') {
120
 
                        return this;
121
 
                }
122
 
                
123
 
                // handle getter methods
124
 
                if (isMethodCall && getter(namespace, name, options, args)) {
125
 
                        var instance = $.data(this[0], name);
126
 
                        return (instance ? instance[options].apply(instance, args)
127
 
                                : undefined);
128
 
                }
129
 
                
130
 
                // handle initialization and non-getter methods
131
 
                return this.each(function() {
132
 
                        var instance = $.data(this, name);
133
 
                        
134
 
                        // constructor
135
 
                        (!instance && !isMethodCall &&
136
 
                                $.data(this, name, new $[namespace][name](this, options)));
137
 
                        
138
 
                        // method call
139
 
                        (instance && isMethodCall && $.isFunction(instance[options]) &&
140
 
                                instance[options].apply(instance, args));
141
 
                });
142
 
        };
143
 
        
144
 
        // create widget constructor
145
 
        $[namespace][name] = function(element, options) {
146
 
                var self = this;
147
 
                
148
 
                this.widgetName = name;
149
 
                this.widgetEventPrefix = $[namespace][name].eventPrefix || name;
150
 
                this.widgetBaseClass = namespace + '-' + name;
151
 
                
152
 
                this.options = $.extend({},
153
 
                        $.widget.defaults,
154
 
                        $[namespace][name].defaults,
155
 
                        $.metadata && $.metadata.get(element)[name],
156
 
                        options);
157
 
                
158
 
                this.element = $(element)
159
 
                        .bind('setData.' + name, function(e, key, value) {
160
 
                                return self._setData(key, value);
161
 
                        })
162
 
                        .bind('getData.' + name, function(e, key) {
163
 
                                return self._getData(key);
164
 
                        })
165
 
                        .bind('remove', function() {
166
 
                                return self.destroy();
167
 
                        });
168
 
                
169
 
                this._init();
170
 
        };
171
 
        
172
 
        // add widget prototype
173
 
        $[namespace][name].prototype = $.extend({}, $.widget.prototype, prototype);
174
 
        
175
 
        // TODO: merge getter and getterSetter properties from widget prototype
176
 
        // and plugin prototype
177
 
        $[namespace][name].getterSetter = 'option';
178
 
};
179
 
 
180
 
$.widget.prototype = {
181
 
        _init: function() {},
182
 
        destroy: function() {
183
 
                this.element.removeData(this.widgetName);
184
 
        },
185
 
        
186
 
        option: function(key, value) {
187
 
                var options = key,
188
 
                        self = this;
189
 
                
190
 
                if (typeof key == "string") {
191
 
                        if (value === undefined) {
192
 
                                return this._getData(key);
193
 
                        }
194
 
                        options = {};
195
 
                        options[key] = value;
196
 
                }
197
 
                
198
 
                $.each(options, function(key, value) {
199
 
                        self._setData(key, value);
200
 
                });
201
 
        },
202
 
        _getData: function(key) {
203
 
                return this.options[key];
204
 
        },
205
 
        _setData: function(key, value) {
206
 
                this.options[key] = value;
207
 
                
208
 
                if (key == 'disabled') {
209
 
                        this.element[value ? 'addClass' : 'removeClass'](
210
 
                                this.widgetBaseClass + '-disabled');
211
 
                }
212
 
        },
213
 
        
214
 
        enable: function() {
215
 
                this._setData('disabled', false);
216
 
        },
217
 
        disable: function() {
218
 
                this._setData('disabled', true);
219
 
        },
220
 
        
221
 
        _trigger: function(type, e, data) {
222
 
                var eventName = (type == this.widgetEventPrefix
223
 
                        ? type : this.widgetEventPrefix + type);
224
 
                e = e  || $.event.fix({ type: eventName, target: this.element[0] });
225
 
                return this.element.triggerHandler(eventName, [e, data], this.options[type]);
226
 
        }
227
 
};
228
 
 
229
 
$.widget.defaults = {
230
 
        disabled: false
231
 
};
232
 
 
233
 
 
234
 
/** jQuery UI core **/
235
 
 
236
 
$.ui = {
237
 
        plugin: {
238
 
                add: function(module, option, set) {
239
 
                        var proto = $.ui[module].prototype;
240
 
                        for(var i in set) {
241
 
                                proto.plugins[i] = proto.plugins[i] || [];
242
 
                                proto.plugins[i].push([option, set[i]]);
243
 
                        }
244
 
                },
245
 
                call: function(instance, name, args) {
246
 
                        var set = instance.plugins[name];
247
 
                        if(!set) { return; }
248
 
                        
249
 
                        for (var i = 0; i < set.length; i++) {
250
 
                                if (instance.options[set[i][0]]) {
251
 
                                        set[i][1].apply(instance.element, args);
252
 
                                }
253
 
                        }
254
 
                }       
255
 
        },
256
 
        cssCache: {},
257
 
        css: function(name) {
258
 
                if ($.ui.cssCache[name]) { return $.ui.cssCache[name]; }
259
 
                var tmp = $('<div class="ui-gen">').addClass(name).css({position:'absolute', top:'-5000px', left:'-5000px', display:'block'}).appendTo('body');
260
 
                
261
 
                //if (!$.browser.safari)
262
 
                        //tmp.appendTo('body'); 
263
 
                
264
 
                //Opera and Safari set width and height to 0px instead of auto
265
 
                //Safari returns rgba(0,0,0,0) when bgcolor is not set
266
 
                $.ui.cssCache[name] = !!(
267
 
                        (!(/auto|default/).test(tmp.css('cursor')) || (/^[1-9]/).test(tmp.css('height')) || (/^[1-9]/).test(tmp.css('width')) || 
268
 
                        !(/none/).test(tmp.css('backgroundImage')) || !(/transparent|rgba\(0, 0, 0, 0\)/).test(tmp.css('backgroundColor')))
269
 
                );
270
 
                try { $('body').get(0).removeChild(tmp.get(0)); } catch(e){}
271
 
                return $.ui.cssCache[name];
272
 
        },
273
 
        disableSelection: function(el) {
274
 
                return $(el)
275
 
                        .attr('unselectable', 'on')
276
 
                        .css('MozUserSelect', 'none')
277
 
                        .bind('selectstart.ui', function() { return false; });
278
 
        },
279
 
        enableSelection: function(el) {
280
 
                return $(el)
281
 
                        .attr('unselectable', 'off')
282
 
                        .css('MozUserSelect', '')
283
 
                        .unbind('selectstart.ui');
284
 
        },
285
 
        hasScroll: function(e, a) {
286
 
                
287
 
                //If overflow is hidden, the element might have extra content, but the user wants to hide it
288
 
                if ($(e).css('overflow') == 'hidden') { return false; }
289
 
                
290
 
                var scroll = (a && a == 'left') ? 'scrollLeft' : 'scrollTop',
291
 
                        has = false;
292
 
                
293
 
                if (e[scroll] > 0) { return true; }
294
 
                
295
 
                // TODO: determine which cases actually cause this to happen
296
 
                // if the element doesn't have the scroll set, see if it's possible to
297
 
                // set the scroll
298
 
                e[scroll] = 1;
299
 
                has = (e[scroll] > 0);
300
 
                e[scroll] = 0;
301
 
                return has;
302
 
        }
303
 
};
304
 
 
305
 
 
306
 
/** Mouse Interaction Plugin **/
307
 
 
308
 
$.ui.mouse = {
309
 
        _mouseInit: function() {
310
 
                var self = this;
311
 
        
312
 
                this.element.bind('mousedown.'+this.widgetName, function(e) {
313
 
                        return self._mouseDown(e);
314
 
                });
315
 
                
316
 
                // Prevent text selection in IE
317
 
                if ($.browser.msie) {
318
 
                        this._mouseUnselectable = this.element.attr('unselectable');
319
 
                        this.element.attr('unselectable', 'on');
320
 
                }
321
 
                
322
 
                this.started = false;
323
 
        },
324
 
        
325
 
        // TODO: make sure destroying one instance of mouse doesn't mess with
326
 
        // other instances of mouse
327
 
        _mouseDestroy: function() {
328
 
                this.element.unbind('.'+this.widgetName);
329
 
                
330
 
                // Restore text selection in IE
331
 
                ($.browser.msie
332
 
                        && this.element.attr('unselectable', this._mouseUnselectable));
333
 
        },
334
 
        
335
 
        _mouseDown: function(e) {
336
 
                // we may have missed mouseup (out of window)
337
 
                (this._mouseStarted && this._mouseUp(e));
338
 
                
339
 
                this._mouseDownEvent = e;
340
 
                
341
 
                var self = this,
342
 
                        btnIsLeft = (e.which == 1),
343
 
                        elIsCancel = (typeof this.options.cancel == "string" ? $(e.target).parents().add(e.target).filter(this.options.cancel).length : false);
344
 
                if (!btnIsLeft || elIsCancel || !this._mouseCapture(e)) {
345
 
                        return true;
346
 
                }
347
 
                
348
 
                this.mouseDelayMet = !this.options.delay;
349
 
                if (!this.mouseDelayMet) {
350
 
                        this._mouseDelayTimer = setTimeout(function() {
351
 
                                self.mouseDelayMet = true;
352
 
                        }, this.options.delay);
353
 
                }
354
 
                
355
 
                if (this._mouseDistanceMet(e) && this._mouseDelayMet(e)) {
356
 
                        this._mouseStarted = (this._mouseStart(e) !== false);
357
 
                        if (!this._mouseStarted) {
358
 
                                e.preventDefault();
359
 
                                return true;
360
 
                        }
361
 
                }
362
 
                
363
 
                // these delegates are required to keep context
364
 
                this._mouseMoveDelegate = function(e) {
365
 
                        return self._mouseMove(e);
366
 
                };
367
 
                this._mouseUpDelegate = function(e) {
368
 
                        return self._mouseUp(e);
369
 
                };
370
 
                $(document)
371
 
                        .bind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
372
 
                        .bind('mouseup.'+this.widgetName, this._mouseUpDelegate);
373
 
                
374
 
                return false;
375
 
        },
376
 
        
377
 
        _mouseMove: function(e) {
378
 
                // IE mouseup check - mouseup happened when mouse was out of window
379
 
                if ($.browser.msie && !e.button) {
380
 
                        return this._mouseUp(e);
381
 
                }
382
 
                
383
 
                if (this._mouseStarted) {
384
 
                        this._mouseDrag(e);
385
 
                        return false;
386
 
                }
387
 
                
388
 
                if (this._mouseDistanceMet(e) && this._mouseDelayMet(e)) {
389
 
                        this._mouseStarted =
390
 
                                (this._mouseStart(this._mouseDownEvent, e) !== false);
391
 
                        (this._mouseStarted ? this._mouseDrag(e) : this._mouseUp(e));
392
 
                }
393
 
                
394
 
                return !this._mouseStarted;
395
 
        },
396
 
        
397
 
        _mouseUp: function(e) {
398
 
                $(document)
399
 
                        .unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
400
 
                        .unbind('mouseup.'+this.widgetName, this._mouseUpDelegate);
401
 
                
402
 
                if (this._mouseStarted) {
403
 
                        this._mouseStarted = false;
404
 
                        this._mouseStop(e);
405
 
                }
406
 
                
407
 
                return false;
408
 
        },
409
 
        
410
 
        _mouseDistanceMet: function(e) {
411
 
                return (Math.max(
412
 
                                Math.abs(this._mouseDownEvent.pageX - e.pageX),
413
 
                                Math.abs(this._mouseDownEvent.pageY - e.pageY)
414
 
                        ) >= this.options.distance
415
 
                );
416
 
        },
417
 
        
418
 
        _mouseDelayMet: function(e) {
419
 
                return this.mouseDelayMet;
420
 
        },
421
 
        
422
 
        // These are placeholder methods, to be overriden by extending plugin
423
 
        _mouseStart: function(e) {},
424
 
        _mouseDrag: function(e) {},
425
 
        _mouseStop: function(e) {},
426
 
        _mouseCapture: function(e) { return true; }
427
 
};
428
 
 
429
 
$.ui.mouse.defaults = {
430
 
        cancel: null,
431
 
        distance: 1,
432
 
        delay: 0
433
 
};
434
 
 
435
 
})(jQuery);
436
 
/*
437
 
 * jQuery UI Draggable @VERSION
438
 
 *
439
 
 * Copyright (c) 2008 Paul Bakaus
440
 
 * Dual licensed under the MIT (MIT-LICENSE.txt)
441
 
 * and GPL (GPL-LICENSE.txt) licenses.
442
 
 * 
443
 
 * http://docs.jquery.com/UI/Draggables
444
 
 *
445
 
 * Depends:
446
 
 *      ui.core.js
447
 
 */
448
 
(function($) {
449
 
 
450
 
$.widget("ui.draggable", $.extend({}, $.ui.mouse, {
451
 
        
452
 
        getHandle: function(e) {
453
 
 
454
 
                var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false;
455
 
                $(this.options.handle, this.element)
456
 
                        .find("*")
457
 
                        .andSelf()
458
 
                        .each(function() {
459
 
                                if(this == e.target) handle = true;
460
 
                        });
461
 
                
462
 
                return handle;
463
 
 
464
 
        },
465
 
        
466
 
        createHelper: function() {
467
 
 
468
 
                var o = this.options;
469
 
                var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [e])) : (o.helper == 'clone' ? this.element.clone() : this.element);
470
 
                
471
 
                if(!helper.parents('body').length)
472
 
                        helper.appendTo((o.appendTo == 'parent' ? this.element[0].parentNode : o.appendTo));
473
 
                        
474
 
                if(helper[0] != this.element[0] && !(/(fixed|absolute)/).test(helper.css("position")))
475
 
                        helper.css("position", "absolute");
476
 
                        
477
 
                return helper;
478
 
                
479
 
        },
480
 
        
481
 
        
482
 
        _init: function() {
483
 
                
484
 
                if (this.options.helper == 'original' && !(/^(?:r|a|f)/).test(this.element.css("position")))
485
 
                        this.element[0].style.position = 'relative';
486
 
                
487
 
                (this.options.cssNamespace && this.element.addClass(this.options.cssNamespace+"-draggable"));
488
 
                (this.options.disabled && this.element.addClass('ui-draggable-disabled'));
489
 
                
490
 
                this._mouseInit();
491
 
                
492
 
        },
493
 
 
494
 
        _mouseCapture: function(e) {
495
 
 
496
 
                var o = this.options;
497
 
                
498
 
                if (this.helper || o.disabled || $(e.target).is('.ui-resizable-handle'))
499
 
                        return false;
500
 
                        
501
 
                //Quit if we're not on a valid handle
502
 
                this.handle = this.getHandle(e);
503
 
                if (!this.handle)
504
 
                        return false;
505
 
                
506
 
                return true;
507
 
 
508
 
        },
509
 
 
510
 
        _mouseStart: function(e) {
511
 
                
512
 
                var o = this.options;
513
 
                
514
 
                //Create and append the visible helper
515
 
                this.helper = this.createHelper();
516
 
                
517
 
                //If ddmanager is used for droppables, set the global draggable
518
 
                if($.ui.ddmanager)
519
 
                        $.ui.ddmanager.current = this;
520
 
                
521
 
                /*
522
 
                 * - Position generation -
523
 
                 * This block generates everything position related - it's the core of draggables.
524
 
                 */
525
 
                
526
 
                this.margins = {                                                                                                                                                                //Cache the margins
527
 
                        left: (parseInt(this.element.css("marginLeft"),10) || 0),
528
 
                        top: (parseInt(this.element.css("marginTop"),10) || 0)
529
 
                };              
530
 
                
531
 
                this.cssPosition = this.helper.css("position");                                                                                                 //Store the helper's css position
532
 
                this.offset = this.element.offset();                                                                                                                    //The element's absolute position on the page
533
 
                this.offset = {                                                                                                                                                                 //Substract the margins from the element's absolute offset
534
 
                        top: this.offset.top - this.margins.top,
535
 
                        left: this.offset.left - this.margins.left
536
 
                };
537
 
                
538
 
                this.offset.click = {                                                                                                                                                   //Where the click happened, relative to the element
539
 
                        left: e.pageX - this.offset.left,
540
 
                        top: e.pageY - this.offset.top
541
 
                };
542
 
 
543
 
                //Calling this method cached the next parents that have scrollTop / scrollLeft attached
544
 
                this.cacheScrollParents();
545
 
                
546
 
                
547
 
                this.offsetParent = this.helper.offsetParent(); var po = this.offsetParent.offset();                    //Get the offsetParent and cache its position
548
 
                if(this.offsetParent[0] == document.body && $.browser.mozilla) po = { top: 0, left: 0 };                //Ugly FF3 fix
549
 
                this.offset.parent = {                                                                                                                                                  //Store its position plus border
550
 
                        top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
551
 
                        left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
552
 
                };
553
 
                
554
 
                //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
555
 
                if(this.cssPosition == "relative") {
556
 
                        var p = this.element.position();
557
 
                        this.offset.relative = {
558
 
                                top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollTopParent.scrollTop(),
559
 
                                left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollLeftParent.scrollLeft()
560
 
                        };
561
 
                } else {
562
 
                        this.offset.relative = { top: 0, left: 0 };
563
 
                }
564
 
                
565
 
                //Generate the original position
566
 
                this.originalPosition = this._generatePosition(e);
567
 
                
568
 
                //Cache the helper size
569
 
                this.cacheHelperProportions();
570
 
                
571
 
                //Adjust the mouse offset relative to the helper if 'cursorAt' is supplied
572
 
                if(o.cursorAt)
573
 
                        this.adjustOffsetFromHelper(o.cursorAt);
574
 
 
575
 
                //Cache later used stuff
576
 
                $.extend(this, {
577
 
                        PAGEY_INCLUDES_SCROLL: (this.cssPosition == "absolute" && (!this.scrollTopParent[0].tagName || (/(html|body)/i).test(this.scrollTopParent[0].tagName))),
578
 
                        PAGEX_INCLUDES_SCROLL: (this.cssPosition == "absolute" && (!this.scrollLeftParent[0].tagName || (/(html|body)/i).test(this.scrollLeftParent[0].tagName))),
579
 
                        OFFSET_PARENT_NOT_SCROLL_PARENT_Y: this.scrollTopParent[0] != this.offsetParent[0] && !(this.scrollTopParent[0] == document && (/(body|html)/i).test(this.offsetParent[0].tagName)),
580
 
                        OFFSET_PARENT_NOT_SCROLL_PARENT_X: this.scrollLeftParent[0] != this.offsetParent[0] && !(this.scrollLeftParent[0] == document && (/(body|html)/i).test(this.offsetParent[0].tagName))
581
 
                });
582
 
                
583
 
                if(o.containment)
584
 
                        this.setContainment();
585
 
 
586
 
                
587
 
                //Call plugins and callbacks
588
 
                this._propagate("start", e);
589
 
                
590
 
                //Recache the helper size
591
 
                this.cacheHelperProportions();
592
 
                
593
 
                //Prepare the droppable offsets
594
 
                if ($.ui.ddmanager && !o.dropBehaviour)
595
 
                        $.ui.ddmanager.prepareOffsets(this, e);
596
 
                
597
 
                this.helper.addClass("ui-draggable-dragging");
598
 
                this._mouseDrag(e); //Execute the drag once - this causes the helper not to be visible before getting its correct position
599
 
                return true;
600
 
        },
601
 
        
602
 
        cacheScrollParents: function() {
603
 
 
604
 
                this.scrollTopParent = function(el) {
605
 
                        do { if(/auto|scroll/.test(el.css('overflow')) || (/auto|scroll/).test(el.css('overflow-y'))) return el; el = el.parent(); } while (el[0].parentNode);
606
 
                        return $(document);
607
 
                }(this.helper);
608
 
                this.scrollLeftParent = function(el) {
609
 
                        do { if(/auto|scroll/.test(el.css('overflow')) || (/auto|scroll/).test(el.css('overflow-x'))) return el; el = el.parent(); } while (el[0].parentNode);
610
 
                        return $(document);
611
 
                }(this.helper);
612
 
 
613
 
        },
614
 
        
615
 
        adjustOffsetFromHelper: function(obj) {
616
 
                if(obj.left != undefined) this.offset.click.left = obj.left + this.margins.left;
617
 
                if(obj.right != undefined) this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
618
 
                if(obj.top != undefined) this.offset.click.top = obj.top + this.margins.top;
619
 
                if(obj.bottom != undefined) this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
620
 
        },
621
 
        
622
 
        cacheHelperProportions: function() {
623
 
                this.helperProportions = {
624
 
                        width: this.helper.outerWidth(),
625
 
                        height: this.helper.outerHeight()
626
 
                };
627
 
        },
628
 
        
629
 
        setContainment: function() {
630
 
 
631
 
                var o = this.options;
632
 
                if(o.containment == 'parent') o.containment = this.helper[0].parentNode;
633
 
                if(o.containment == 'document' || o.containment == 'window') this.containment = [
634
 
                        0 - this.offset.relative.left - this.offset.parent.left,
635
 
                        0 - this.offset.relative.top - this.offset.parent.top,
636
 
                        $(o.containment == 'document' ? document : window).width() - this.offset.relative.left - this.offset.parent.left - this.helperProportions.width - this.margins.left - (parseInt(this.element.css("marginRight"),10) || 0),
637
 
                        ($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.offset.relative.top - this.offset.parent.top - this.helperProportions.height - this.margins.top - (parseInt(this.element.css("marginBottom"),10) || 0)
638
 
                ];
639
 
                
640
 
                if(!(/^(document|window|parent)$/).test(o.containment)) {
641
 
                        var ce = $(o.containment)[0];
642
 
                        var co = $(o.containment).offset();
643
 
                        var over = ($(ce).css("overflow") != 'hidden');
644
 
                        
645
 
                        this.containment = [
646
 
                                co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) - this.offset.relative.left - this.offset.parent.left,
647
 
                                co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) - this.offset.relative.top - this.offset.parent.top,
648
 
                                co.left+(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - this.offset.relative.left - this.offset.parent.left - this.helperProportions.width - this.margins.left - (parseInt(this.element.css("marginRight"),10) || 0),
649
 
                                co.top+(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - this.offset.relative.top - this.offset.parent.top - this.helperProportions.height - this.margins.top - (parseInt(this.element.css("marginBottom"),10) || 0)
650
 
                        ];
651
 
                }
652
 
 
653
 
        },
654
 
        
655
 
        
656
 
        _convertPositionTo: function(d, pos) {
657
 
 
658
 
                if(!pos) pos = this.position;
659
 
                var mod = d == "absolute" ? 1 : -1;
660
 
 
661
 
                return {
662
 
                        top: (
663
 
                                pos.top                                                                                                                                 // the calculated relative position
664
 
                                + this.offset.relative.top      * mod                                                                           // Only for relative positioned nodes: Relative offset from element to offset parent
665
 
                                + this.offset.parent.top * mod                                                                                  // The offsetParent's offset without borders (offset + border)
666
 
                                - (this.cssPosition == "fixed" || this.PAGEY_INCLUDES_SCROLL || this.OFFSET_PARENT_NOT_SCROLL_PARENT_Y ? 0 : this.scrollTopParent.scrollTop()) * mod    // The offsetParent's scroll position, not if the element is fixed
667
 
                                + (this.cssPosition == "fixed" ? $(document).scrollTop() : 0) * mod
668
 
                                + this.margins.top * mod                                                                                                //Add the margin (you don't want the margin counting in intersection methods)
669
 
                        ),
670
 
                        left: (
671
 
                                pos.left                                                                                                                                // the calculated relative position
672
 
                                + this.offset.relative.left     * mod                                                                           // Only for relative positioned nodes: Relative offset from element to offset parent
673
 
                                + this.offset.parent.left * mod                                                                                 // The offsetParent's offset without borders (offset + border)
674
 
                                - (this.cssPosition == "fixed" || this.PAGEX_INCLUDES_SCROLL || this.OFFSET_PARENT_NOT_SCROLL_PARENT_X ? 0 : this.scrollLeftParent.scrollLeft()) * mod  // The offsetParent's scroll position, not if the element is fixed
675
 
                                + (this.cssPosition == "fixed" ? $(document).scrollLeft() : 0) * mod
676
 
                                + this.margins.left * mod                                                                                               //Add the margin (you don't want the margin counting in intersection methods)
677
 
                        )
678
 
                };
679
 
        },
680
 
        _generatePosition: function(e) {
681
 
 
682
 
                var o = this.options;
683
 
                var position = {
684
 
                        top: (
685
 
                                e.pageY                                                                                                                                 // The absolute mouse position
686
 
                                - this.offset.click.top                                                                                                 // Click offset (relative to the element)
687
 
                                - this.offset.relative.top                                                                                              // Only for relative positioned nodes: Relative offset from element to offset parent
688
 
                                - this.offset.parent.top                                                                                                // The offsetParent's offset without borders (offset + border)
689
 
                                + (this.cssPosition == "fixed" || this.PAGEY_INCLUDES_SCROLL || this.OFFSET_PARENT_NOT_SCROLL_PARENT_Y ? 0 : this.scrollTopParent.scrollTop())  // The offsetParent's scroll position, not if the element is fixed
690
 
                                - (this.cssPosition == "fixed" ? $(document).scrollTop() : 0)
691
 
                        ),
692
 
                        left: (
693
 
                                e.pageX                                                                                                                                 // The absolute mouse position
694
 
                                - this.offset.click.left                                                                                                // Click offset (relative to the element)
695
 
                                - this.offset.relative.left                                                                                             // Only for relative positioned nodes: Relative offset from element to offset parent
696
 
                                - this.offset.parent.left                                                                                               // The offsetParent's offset without borders (offset + border)
697
 
                                + (this.cssPosition == "fixed" || this.PAGEX_INCLUDES_SCROLL || this.OFFSET_PARENT_NOT_SCROLL_PARENT_X ? 0 : this.scrollLeftParent.scrollLeft())        // The offsetParent's scroll position, not if the element is fixed
698
 
                                - (this.cssPosition == "fixed" ? $(document).scrollLeft() : 0)
699
 
                        )
700
 
                };
701
 
        
702
 
                if(!this.originalPosition) return position;                                                                             //If we are not dragging yet, we won't check for options
703
 
                
704
 
                /*
705
 
                 * - Position constraining -
706
 
                 * Constrain the position to a mix of grid, containment.
707
 
                 */
708
 
                if(this.containment) {
709
 
                        if(position.left < this.containment[0]) position.left = this.containment[0];
710
 
                        if(position.top < this.containment[1]) position.top = this.containment[1];
711
 
                        if(position.left > this.containment[2]) position.left = this.containment[2];
712
 
                        if(position.top > this.containment[3]) position.top = this.containment[3];
713
 
                }
714
 
                
715
 
                if(o.grid) {
716
 
                        var top = this.originalPosition.top + Math.round((position.top - this.originalPosition.top) / o.grid[1]) * o.grid[1];
717
 
                        position.top = this.containment ? (!(top < this.containment[1] || top > this.containment[3]) ? top : (!(top < this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
718
 
                        
719
 
                        var left = this.originalPosition.left + Math.round((position.left - this.originalPosition.left) / o.grid[0]) * o.grid[0];
720
 
                        position.left = this.containment ? (!(left < this.containment[0] || left > this.containment[2]) ? left : (!(left < this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
721
 
                }
722
 
                
723
 
                return position;
724
 
        },
725
 
        _mouseDrag: function(e) {
726
 
        
727
 
                //Compute the helpers position
728
 
                this.position = this._generatePosition(e);
729
 
                this.positionAbs = this._convertPositionTo("absolute");
730
 
                
731
 
                //Call plugins and callbacks and use the resulting position if something is returned            
732
 
                this.position = this._propagate("drag", e) || this.position;
733
 
        
734
 
                if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px';
735
 
                if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px';
736
 
                if($.ui.ddmanager) $.ui.ddmanager.drag(this, e);
737
 
                
738
 
                return false;
739
 
        },
740
 
        _mouseStop: function(e) {
741
 
                
742
 
                //If we are using droppables, inform the manager about the drop
743
 
                var dropped = false;
744
 
                if ($.ui.ddmanager && !this.options.dropBehaviour)
745
 
                        var dropped = $.ui.ddmanager.drop(this, e);             
746
 
                
747
 
                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))) {
748
 
                        var self = this;
749
 
                        $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10) || 500, function() {
750
 
                                self._propagate("stop", e);
751
 
                                self._clear();
752
 
                        });
753
 
                } else {
754
 
                        this._propagate("stop", e);
755
 
                        this._clear();
756
 
                }
757
 
                
758
 
                return false;
759
 
        },
760
 
        _clear: function() {
761
 
                this.helper.removeClass("ui-draggable-dragging");
762
 
                if(this.options.helper != 'original' && !this.cancelHelperRemoval) this.helper.remove();
763
 
                //if($.ui.ddmanager) $.ui.ddmanager.current = null;
764
 
                this.helper = null;
765
 
                this.cancelHelperRemoval = false;
766
 
        },
767
 
        
768
 
        // From now on bulk stuff - mainly helpers
769
 
        plugins: {},
770
 
        uiHash: function(e) {
771
 
                return {
772
 
                        helper: this.helper,
773
 
                        position: this.position,
774
 
                        absolutePosition: this.positionAbs,
775
 
                        options: this.options                   
776
 
                };
777
 
        },
778
 
        _propagate: function(n,e) {
779
 
                $.ui.plugin.call(this, n, [e, this.uiHash()]);
780
 
                if(n == "drag") this.positionAbs = this._convertPositionTo("absolute"); //The absolute position has to be recalculated after plugins
781
 
                return this.element.triggerHandler(n == "drag" ? n : "drag"+n, [e, this.uiHash()], this.options[n]);
782
 
        },
783
 
        destroy: function() {
784
 
                if(!this.element.data('draggable')) return;
785
 
                this.element.removeData("draggable").unbind(".draggable").removeClass('ui-draggable ui-draggable-dragging ui-draggable-disabled');
786
 
                this._mouseDestroy();
787
 
        }
788
 
}));
789
 
 
790
 
$.extend($.ui.draggable, {
791
 
        defaults: {
792
 
                appendTo: "parent",
793
 
                axis: false,
794
 
                cancel: ":input",
795
 
                delay: 0,
796
 
                distance: 1,
797
 
                helper: "original",
798
 
                scope: "default",
799
 
                cssNamespace: "ui"
800
 
        }
801
 
});
802
 
 
803
 
$.ui.plugin.add("draggable", "cursor", {
804
 
        start: function(e, ui) {
805
 
                var t = $('body');
806
 
                if (t.css("cursor")) ui.options._cursor = t.css("cursor");
807
 
                t.css("cursor", ui.options.cursor);
808
 
        },
809
 
        stop: function(e, ui) {
810
 
                if (ui.options._cursor) $('body').css("cursor", ui.options._cursor);
811
 
        }
812
 
});
813
 
 
814
 
$.ui.plugin.add("draggable", "zIndex", {
815
 
        start: function(e, ui) {
816
 
                var t = $(ui.helper);
817
 
                if(t.css("zIndex")) ui.options._zIndex = t.css("zIndex");
818
 
                t.css('zIndex', ui.options.zIndex);
819
 
        },
820
 
        stop: function(e, ui) {
821
 
                if(ui.options._zIndex) $(ui.helper).css('zIndex', ui.options._zIndex);
822
 
        }
823
 
});
824
 
 
825
 
$.ui.plugin.add("draggable", "opacity", {
826
 
        start: function(e, ui) {
827
 
                var t = $(ui.helper);
828
 
                if(t.css("opacity")) ui.options._opacity = t.css("opacity");
829
 
                t.css('opacity', ui.options.opacity);
830
 
        },
831
 
        stop: function(e, ui) {
832
 
                if(ui.options._opacity) $(ui.helper).css('opacity', ui.options._opacity);
833
 
        }
834
 
});
835
 
 
836
 
$.ui.plugin.add("draggable", "iframeFix", {
837
 
        start: function(e, ui) {
838
 
                $(ui.options.iframeFix === true ? "iframe" : ui.options.iframeFix).each(function() {                                    
839
 
                        $('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>')
840
 
                        .css({
841
 
                                width: this.offsetWidth+"px", height: this.offsetHeight+"px",
842
 
                                position: "absolute", opacity: "0.001", zIndex: 1000
843
 
                        })
844
 
                        .css($(this).offset())
845
 
                        .appendTo("body");
846
 
                });
847
 
        },
848
 
        stop: function(e, ui) {
849
 
                $("div.ui-draggable-iframeFix").each(function() { this.parentNode.removeChild(this); }); //Remove frame helpers 
850
 
        }
851
 
});
852
 
 
853
 
 
854
 
 
855
 
$.ui.plugin.add("draggable", "scroll", {
856
 
        start: function(e, ui) {
857
 
                var o = ui.options;
858
 
                var i = $(this).data("draggable");
859
 
                o.scrollSensitivity     = o.scrollSensitivity || 20;
860
 
                o.scrollSpeed           = o.scrollSpeed || 20;
861
 
                
862
 
                i.overflowY = function(el) {
863
 
                        do { if(/auto|scroll/.test(el.css('overflow')) || (/auto|scroll/).test(el.css('overflow-y'))) return el; el = el.parent(); } while (el[0].parentNode);
864
 
                        return $(document);
865
 
                }(this);
866
 
                i.overflowX = function(el) {
867
 
                        do { if(/auto|scroll/.test(el.css('overflow')) || (/auto|scroll/).test(el.css('overflow-x'))) return el; el = el.parent(); } while (el[0].parentNode);
868
 
                        return $(document);
869
 
                }(this);
870
 
                
871
 
                if(i.overflowY[0] != document && i.overflowY[0].tagName != 'HTML') i.overflowYOffset = i.overflowY.offset();
872
 
                if(i.overflowX[0] != document && i.overflowX[0].tagName != 'HTML') i.overflowXOffset = i.overflowX.offset();
873
 
                
874
 
        },
875
 
        drag: function(e, ui) {
876
 
                
877
 
                var o = ui.options, scrolled = false;
878
 
                var i = $(this).data("draggable");
879
 
                
880
 
                if(i.overflowY[0] != document && i.overflowY[0].tagName != 'HTML') {
881
 
                        if((i.overflowYOffset.top + i.overflowY[0].offsetHeight) - e.pageY < o.scrollSensitivity)
882
 
                                i.overflowY[0].scrollTop = scrolled = i.overflowY[0].scrollTop + o.scrollSpeed;
883
 
                        if(e.pageY - i.overflowYOffset.top < o.scrollSensitivity)
884
 
                                i.overflowY[0].scrollTop = scrolled = i.overflowY[0].scrollTop - o.scrollSpeed;
885
 
                                                        
886
 
                } else {
887
 
                        if(e.pageY - $(document).scrollTop() < o.scrollSensitivity)
888
 
                                scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
889
 
                        if($(window).height() - (e.pageY - $(document).scrollTop()) < o.scrollSensitivity)
890
 
                                scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
891
 
                }
892
 
                
893
 
                if(i.overflowX[0] != document && i.overflowX[0].tagName != 'HTML') {
894
 
                        if((i.overflowXOffset.left + i.overflowX[0].offsetWidth) - e.pageX < o.scrollSensitivity)
895
 
                                i.overflowX[0].scrollLeft = scrolled = i.overflowX[0].scrollLeft + o.scrollSpeed;
896
 
                        if(e.pageX - i.overflowXOffset.left < o.scrollSensitivity)
897
 
                                i.overflowX[0].scrollLeft = scrolled = i.overflowX[0].scrollLeft - o.scrollSpeed;
898
 
                } else {
899
 
                        if(e.pageX - $(document).scrollLeft() < o.scrollSensitivity)
900
 
                                scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
901
 
                        if($(window).width() - (e.pageX - $(document).scrollLeft()) < o.scrollSensitivity)
902
 
                                scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
903
 
                }
904
 
                
905
 
                if(scrolled !== false)
906
 
                        $.ui.ddmanager.prepareOffsets(i, e);
907
 
                
908
 
        }
909
 
});
910
 
 
911
 
 
912
 
$.ui.plugin.add("draggable", "snap", {
913
 
        start: function(e, ui) {
914
 
                
915
 
                var inst = $(this).data("draggable");
916
 
                inst.snapElements = [];
917
 
 
918
 
                $(ui.options.snap.constructor != String ? ( ui.options.snap.items || ':data(draggable)' ) : ui.options.snap).each(function() {
919
 
                        var $t = $(this); var $o = $t.offset();
920
 
                        if(this != inst.element[0]) inst.snapElements.push({
921
 
                                item: this,
922
 
                                width: $t.outerWidth(), height: $t.outerHeight(),
923
 
                                top: $o.top, left: $o.left
924
 
                        });
925
 
                });
926
 
                
927
 
        },
928
 
        drag: function(e, ui) {
929
 
        
930
 
                var inst = $(this).data("draggable");
931
 
                var d = ui.options.snapTolerance || 20;
932
 
 
933
 
                var x1 = ui.absolutePosition.left, x2 = x1 + inst.helperProportions.width,
934
 
                        y1 = ui.absolutePosition.top, y2 = y1 + inst.helperProportions.height;
935
 
                
936
 
                for (var i = inst.snapElements.length - 1; i >= 0; i--){
937
 
                        
938
 
                        var l = inst.snapElements[i].left, r = l + inst.snapElements[i].width, 
939
 
                                t = inst.snapElements[i].top, b = t + inst.snapElements[i].height;
940
 
                
941
 
                        //Yes, I know, this is insane ;)
942
 
                        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))) {
943
 
                                if(inst.snapElements[i].snapping) (inst.options.snap.release && inst.options.snap.release.call(inst.element, null, $.extend(inst.uiHash(), { snapItem: inst.snapElements[i].item })));
944
 
                                inst.snapElements[i].snapping = false;
945
 
                                continue;
946
 
                        }
947
 
                
948
 
                        if(ui.options.snapMode != 'inner') {
949
 
                                var ts = Math.abs(t - y2) <= d;
950
 
                                var bs = Math.abs(b - y1) <= d;
951
 
                                var ls = Math.abs(l - x2) <= d;
952
 
                                var rs = Math.abs(r - x1) <= d;
953
 
                                if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top;
954
 
                                if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top;
955
 
                                if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left;
956
 
                                if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left;
957
 
                        }
958
 
                        
959
 
                        var first = (ts || bs || ls || rs);
960
 
                        
961
 
                        if(ui.options.snapMode != 'outer') {
962
 
                                var ts = Math.abs(t - y1) <= d;
963
 
                                var bs = Math.abs(b - y2) <= d;
964
 
                                var ls = Math.abs(l - x1) <= d;
965
 
                                var rs = Math.abs(r - x2) <= d;
966
 
                                if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top;
967
 
                                if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top;
968
 
                                if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left;
969
 
                                if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left;
970
 
                        }
971
 
                        
972
 
                        if(!inst.snapElements[i].snapping && (ts || bs || ls || rs || first))
973
 
                                (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, null, $.extend(inst.uiHash(), { snapItem: inst.snapElements[i].item })));
974
 
                        inst.snapElements[i].snapping = (ts || bs || ls || rs || first);
975
 
                        
976
 
                };
977
 
 
978
 
        }
979
 
});
980
 
 
981
 
$.ui.plugin.add("draggable", "connectToSortable", {
982
 
        start: function(e,ui) {
983
 
        
984
 
                var inst = $(this).data("draggable");
985
 
                inst.sortables = [];
986
 
                $(ui.options.connectToSortable).each(function() {
987
 
                        if($.data(this, 'sortable')) {
988
 
                                var sortable = $.data(this, 'sortable');
989
 
                                inst.sortables.push({
990
 
                                        instance: sortable,
991
 
                                        shouldRevert: sortable.options.revert
992
 
                                });
993
 
                                sortable._refreshItems();       //Do a one-time refresh at start to refresh the containerCache  
994
 
                                sortable._propagate("activate", e, inst);
995
 
                        }
996
 
                });
997
 
 
998
 
        },
999
 
        stop: function(e,ui) {
1000
 
                
1001
 
                //If we are still over the sortable, we fake the stop event of the sortable, but also remove helper
1002
 
                var inst = $(this).data("draggable");
1003
 
                
1004
 
                $.each(inst.sortables, function() {
1005
 
                        if(this.instance.isOver) {
1006
 
                                this.instance.isOver = 0;
1007
 
                                inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance
1008
 
                                this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work)
1009
 
                                if(this.shouldRevert) this.instance.options.revert = true; //revert here
1010
 
                                this.instance._mouseStop(e);
1011
 
                                
1012
 
                                //Also propagate receive event, since the sortable is actually receiving a element
1013
 
                                this.instance.element.triggerHandler("sortreceive", [e, $.extend(this.instance.ui(), { sender: inst.element })], this.instance.options["receive"]);
1014
 
 
1015
 
                                this.instance.options.helper = this.instance.options._helper;
1016
 
                        } else {
1017
 
                                this.instance._propagate("deactivate", e, inst);
1018
 
                        }
1019
 
 
1020
 
                });
1021
 
                
1022
 
        },
1023
 
        drag: function(e,ui) {
1024
 
 
1025
 
                var inst = $(this).data("draggable"), self = this;
1026
 
                
1027
 
                var checkPos = function(o) {
1028
 
                                
1029
 
                        var l = o.left, r = l + o.width,
1030
 
                                t = o.top, b = t + o.height;
1031
 
 
1032
 
                        return (l < (this.positionAbs.left + this.offset.click.left) && (this.positionAbs.left + this.offset.click.left) < r
1033
 
                                        && t < (this.positionAbs.top + this.offset.click.top) && (this.positionAbs.top + this.offset.click.top) < b);                           
1034
 
                };
1035
 
                
1036
 
                $.each(inst.sortables, function(i) {
1037
 
 
1038
 
                        if(checkPos.call(inst, this.instance.containerCache)) {
1039
 
 
1040
 
                                //If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once
1041
 
                                if(!this.instance.isOver) {
1042
 
                                        this.instance.isOver = 1;
1043
 
 
1044
 
                                        //Now we fake the start of dragging for the sortable instance,
1045
 
                                        //by cloning the list group item, appending it to the sortable and using it as inst.currentItem
1046
 
                                        //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)
1047
 
                                        this.instance.currentItem = $(self).clone().appendTo(this.instance.element).data("sortable-item", true);
1048
 
                                        this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it
1049
 
                                        this.instance.options.helper = function() { return ui.helper[0]; };
1050
 
                                
1051
 
                                        e.target = this.instance.currentItem[0];
1052
 
                                        this.instance._mouseCapture(e, true);
1053
 
                                        this.instance._mouseStart(e, true, true);
1054
 
 
1055
 
                                        //Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes
1056
 
                                        this.instance.offset.click.top = inst.offset.click.top;
1057
 
                                        this.instance.offset.click.left = inst.offset.click.left;
1058
 
                                        this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left;
1059
 
                                        this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top;
1060
 
                                        
1061
 
                                        inst._propagate("toSortable", e);
1062
 
                                
1063
 
                                }
1064
 
                                
1065
 
                                //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
1066
 
                                if(this.instance.currentItem) this.instance._mouseDrag(e);
1067
 
                                
1068
 
                        } else {
1069
 
                                
1070
 
                                //If it doesn't intersect with the sortable, and it intersected before,
1071
 
                                //we fake the drag stop of the sortable, but make sure it doesn't remove the helper by using cancelHelperRemoval
1072
 
                                if(this.instance.isOver) {
1073
 
                                        this.instance.isOver = 0;
1074
 
                                        this.instance.cancelHelperRemoval = true;
1075
 
                                        this.instance.options.revert = false; //No revert here
1076
 
                                        this.instance._mouseStop(e, true);
1077
 
                                        this.instance.options.helper = this.instance.options._helper;
1078
 
                                        
1079
 
                                        //Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size
1080
 
                                        this.instance.currentItem.remove();
1081
 
                                        if(this.instance.placeholder) this.instance.placeholder.remove();
1082
 
                                        
1083
 
                                        inst._propagate("fromSortable", e);
1084
 
                                }
1085
 
                                
1086
 
                        };
1087
 
 
1088
 
                });
1089
 
 
1090
 
        }
1091
 
});
1092
 
 
1093
 
$.ui.plugin.add("draggable", "stack", {
1094
 
        start: function(e,ui) {
1095
 
                var group = $.makeArray($(ui.options.stack.group)).sort(function(a,b) {
1096
 
                        return (parseInt($(a).css("zIndex"),10) || ui.options.stack.min) - (parseInt($(b).css("zIndex"),10) || ui.options.stack.min);
1097
 
                });
1098
 
                
1099
 
                $(group).each(function(i) {
1100
 
                        this.style.zIndex = ui.options.stack.min + i;
1101
 
                });
1102
 
                
1103
 
                this[0].style.zIndex = ui.options.stack.min + group.length;
1104
 
        }
1105
 
});
1106
 
 
1107
 
})(jQuery);
1108
 
/*
1109
 
 * jQuery UI Droppable @VERSION
1110
 
 *
1111
 
 * Copyright (c) 2008 Paul Bakaus
1112
 
 * Dual licensed under the MIT (MIT-LICENSE.txt)
1113
 
 * and GPL (GPL-LICENSE.txt) licenses.
1114
 
 * 
1115
 
 * http://docs.jquery.com/UI/Droppables
1116
 
 *
1117
 
 * Depends:
1118
 
 *      ui.core.js
1119
 
 *      ui.draggable.js
1120
 
 */
1121
 
(function($) {
1122
 
 
1123
 
$.widget("ui.droppable", {
1124
 
        
1125
 
        _setData: function(key, value) {
1126
 
 
1127
 
                if(key == 'accept') {
1128
 
                        this.options.accept = value && $.isFunction(value) ? value : function(d) {
1129
 
                                return d.is(accept);
1130
 
                        };
1131
 
                } else {
1132
 
                        $.widget.prototype._setData.apply(this, arguments);
1133
 
                }
1134
 
 
1135
 
        },
1136
 
        
1137
 
        _init: function() {
1138
 
                
1139
 
                var o = this.options, accept = o.accept;
1140
 
                this.isover = 0; this.isout = 1;
1141
 
 
1142
 
                this.options.accept = this.options.accept && $.isFunction(this.options.accept) ? this.options.accept : function(d) {
1143
 
                        return d.is(accept);
1144
 
                };
1145
 
 
1146
 
                //Store the droppable's proportions
1147
 
                this.proportions = { width: this.element[0].offsetWidth, height: this.element[0].offsetHeight };
1148
 
                
1149
 
                // Add the reference and positions to the manager
1150
 
                $.ui.ddmanager.droppables[this.options.scope] = $.ui.ddmanager.droppables[this.options.scope] || [];
1151
 
                $.ui.ddmanager.droppables[this.options.scope].push(this);
1152
 
                
1153
 
                (this.options.cssNamespace && this.element.addClass(this.options.cssNamespace+"-droppable"));
1154
 
                
1155
 
        },
1156
 
        plugins: {},
1157
 
        ui: function(c) {
1158
 
                return {
1159
 
                        draggable: (c.currentItem || c.element),
1160
 
                        helper: c.helper,
1161
 
                        position: c.position,
1162
 
                        absolutePosition: c.positionAbs,
1163
 
                        options: this.options,
1164
 
                        element: this.element
1165
 
                };
1166
 
        },
1167
 
        destroy: function() {
1168
 
                var drop = $.ui.ddmanager.droppables[this.options.scope];
1169
 
                for ( var i = 0; i < drop.length; i++ )
1170
 
                        if ( drop[i] == this )
1171
 
                                drop.splice(i, 1);
1172
 
                
1173
 
                this.element
1174
 
                        .removeClass("ui-droppable-disabled")
1175
 
                        .removeData("droppable")
1176
 
                        .unbind(".droppable");
1177
 
        },
1178
 
        _over: function(e) {
1179
 
                
1180
 
                var draggable = $.ui.ddmanager.current;
1181
 
                if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return; // Bail if draggable and droppable are same element
1182
 
                
1183
 
                if (this.options.accept.call(this.element,(draggable.currentItem || draggable.element))) {
1184
 
                        $.ui.plugin.call(this, 'over', [e, this.ui(draggable)]);
1185
 
                        this.element.triggerHandler("dropover", [e, this.ui(draggable)], this.options.over);
1186
 
                }
1187
 
                
1188
 
        },
1189
 
        _out: function(e) {
1190
 
                
1191
 
                var draggable = $.ui.ddmanager.current;
1192
 
                if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return; // Bail if draggable and droppable are same element
1193
 
                
1194
 
                if (this.options.accept.call(this.element,(draggable.currentItem || draggable.element))) {
1195
 
                        $.ui.plugin.call(this, 'out', [e, this.ui(draggable)]);
1196
 
                        this.element.triggerHandler("dropout", [e, this.ui(draggable)], this.options.out);
1197
 
                }
1198
 
                
1199
 
        },
1200
 
        _drop: function(e,custom) {
1201
 
                
1202
 
                var draggable = custom || $.ui.ddmanager.current;
1203
 
                if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return false; // Bail if draggable and droppable are same element
1204
 
                
1205
 
                var childrenIntersection = false;
1206
 
                this.element.find(":data(droppable)").not(".ui-draggable-dragging").each(function() {
1207
 
                        var inst = $.data(this, 'droppable');
1208
 
                        if(inst.options.greedy && $.ui.intersect(draggable, $.extend(inst, { offset: inst.element.offset() }), inst.options.tolerance)) {
1209
 
                                childrenIntersection = true; return false;
1210
 
                        }
1211
 
                });
1212
 
                if(childrenIntersection) return false;
1213
 
                
1214
 
                if(this.options.accept.call(this.element,(draggable.currentItem || draggable.element))) {
1215
 
                        $.ui.plugin.call(this, 'drop', [e, this.ui(draggable)]);
1216
 
                        this.element.triggerHandler("drop", [e, this.ui(draggable)], this.options.drop);
1217
 
                        return this.element;
1218
 
                }
1219
 
                
1220
 
                return false;
1221
 
                
1222
 
        },
1223
 
        _activate: function(e) {
1224
 
                
1225
 
                var draggable = $.ui.ddmanager.current;
1226
 
                $.ui.plugin.call(this, 'activate', [e, this.ui(draggable)]);
1227
 
                if(draggable) this.element.triggerHandler("dropactivate", [e, this.ui(draggable)], this.options.activate);
1228
 
                
1229
 
        },
1230
 
        _deactivate: function(e) {
1231
 
                
1232
 
                var draggable = $.ui.ddmanager.current;
1233
 
                $.ui.plugin.call(this, 'deactivate', [e, this.ui(draggable)]);
1234
 
                if(draggable) this.element.triggerHandler("dropdeactivate", [e, this.ui(draggable)], this.options.deactivate);
1235
 
                
1236
 
        }
1237
 
});
1238
 
 
1239
 
$.extend($.ui.droppable, {
1240
 
        defaults: {
1241
 
                disabled: false,
1242
 
                tolerance: 'intersect',
1243
 
                scope: 'default',
1244
 
                cssNamespace: 'ui'
1245
 
        }
1246
 
});
1247
 
 
1248
 
$.ui.intersect = function(draggable, droppable, toleranceMode) {
1249
 
        
1250
 
        if (!droppable.offset) return false;
1251
 
        
1252
 
        var x1 = (draggable.positionAbs || draggable.position.absolute).left, x2 = x1 + draggable.helperProportions.width,
1253
 
                y1 = (draggable.positionAbs || draggable.position.absolute).top, y2 = y1 + draggable.helperProportions.height;
1254
 
        var l = droppable.offset.left, r = l + droppable.proportions.width,
1255
 
                t = droppable.offset.top, b = t + droppable.proportions.height;
1256
 
        
1257
 
        switch (toleranceMode) {
1258
 
                case 'fit':
1259
 
                        return (l < x1 && x2 < r
1260
 
                                && t < y1 && y2 < b);
1261
 
                        break;
1262
 
                case 'intersect':
1263
 
                        return (l < x1 + (draggable.helperProportions.width / 2) // Right Half
1264
 
                                && x2 - (draggable.helperProportions.width / 2) < r // Left Half
1265
 
                                && t < y1 + (draggable.helperProportions.height / 2) // Bottom Half
1266
 
                                && y2 - (draggable.helperProportions.height / 2) < b ); // Top Half
1267
 
                        break;
1268
 
                case 'pointer':
1269
 
                        return (l < ((draggable.positionAbs || draggable.position.absolute).left + (draggable.clickOffset || draggable.offset.click).left) && ((draggable.positionAbs || draggable.position.absolute).left + (draggable.clickOffset || draggable.offset.click).left) < r
1270
 
                                && t < ((draggable.positionAbs || draggable.position.absolute).top + (draggable.clickOffset || draggable.offset.click).top) && ((draggable.positionAbs || draggable.position.absolute).top + (draggable.clickOffset || draggable.offset.click).top) < b);
1271
 
                        break;
1272
 
                case 'touch':
1273
 
                        return (
1274
 
                                        (y1 >= t && y1 <= b) || // Top edge touching
1275
 
                                        (y2 >= t && y2 <= b) || // Bottom edge touching
1276
 
                                        (y1 < t && y2 > b)              // Surrounded vertically
1277
 
                                ) && (
1278
 
                                        (x1 >= l && x1 <= r) || // Left edge touching
1279
 
                                        (x2 >= l && x2 <= r) || // Right edge touching
1280
 
                                        (x1 < l && x2 > r)              // Surrounded horizontally
1281
 
                                );
1282
 
                        break;
1283
 
                default:
1284
 
                        return false;
1285
 
                        break;
1286
 
                }
1287
 
        
1288
 
};
1289
 
 
1290
 
/*
1291
 
        This manager tracks offsets of draggables and droppables
1292
 
*/
1293
 
$.ui.ddmanager = {
1294
 
        current: null,
1295
 
        droppables: { 'default': [] },
1296
 
        prepareOffsets: function(t, e) {
1297
 
                
1298
 
                var m = $.ui.ddmanager.droppables[t.options.scope];
1299
 
                var type = e ? e.type : null; // workaround for #2317
1300
 
                var list = (t.currentItem || t.element).find(":data(droppable)").andSelf();     
1301
 
 
1302
 
                droppablesLoop: for (var i = 0; i < m.length; i++) {
1303
 
                        
1304
 
                        if(m[i].options.disabled || (t && !m[i].options.accept.call(m[i].element,(t.currentItem || t.element)))) continue;      //No disabled and non-accepted
1305
 
                        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
1306
 
                        m[i].visible = m[i].element.css("display") != "none"; if(!m[i].visible) continue;                                                                       //If the element is not visible, continue
1307
 
                        
1308
 
                        m[i].offset = m[i].element.offset();
1309
 
                        m[i].proportions = { width: m[i].element[0].offsetWidth, height: m[i].element[0].offsetHeight };
1310
 
                        
1311
 
                        if(type == "dragstart" || type == "sortactivate") m[i]._activate.call(m[i], e);                                                                                 //Activate the droppable if used directly from draggables
1312
 
                        
1313
 
                }
1314
 
                
1315
 
        },
1316
 
        drop: function(draggable, e) {
1317
 
                
1318
 
                var dropped = false;
1319
 
                $.each($.ui.ddmanager.droppables[draggable.options.scope], function() {
1320
 
                        
1321
 
                        if(!this.options) return;
1322
 
                        if (!this.options.disabled && this.visible && $.ui.intersect(draggable, this, this.options.tolerance))
1323
 
                                dropped = this._drop.call(this, e);
1324
 
                        
1325
 
                        if (!this.options.disabled && this.visible && this.options.accept.call(this.element,(draggable.currentItem || draggable.element))) {
1326
 
                                this.isout = 1; this.isover = 0;
1327
 
                                this._deactivate.call(this, e);
1328
 
                        }
1329
 
                        
1330
 
                });
1331
 
                return dropped;
1332
 
                
1333
 
        },
1334
 
        drag: function(draggable, e) {
1335
 
                
1336
 
                //If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse.
1337
 
                if(draggable.options.refreshPositions) $.ui.ddmanager.prepareOffsets(draggable, e);
1338
 
                
1339
 
                //Run through all droppables and check their positions based on specific tolerance options
1340
 
 
1341
 
                $.each($.ui.ddmanager.droppables[draggable.options.scope], function() {
1342
 
                        
1343
 
                        if(this.options.disabled || this.greedyChild || !this.visible) return;
1344
 
                        var intersects = $.ui.intersect(draggable, this, this.options.tolerance);
1345
 
                        
1346
 
                        var c = !intersects && this.isover == 1 ? 'isout' : (intersects && this.isover == 0 ? 'isover' : null);
1347
 
                        if(!c) return;
1348
 
                        
1349
 
                        var parentInstance;
1350
 
                        if (this.options.greedy) {
1351
 
                                var parent = this.element.parents(':data(droppable):eq(0)');
1352
 
                                if (parent.length) {
1353
 
                                        parentInstance = $.data(parent[0], 'droppable');
1354
 
                                        parentInstance.greedyChild = (c == 'isover' ? 1 : 0);
1355
 
                                }
1356
 
                        }
1357
 
                        
1358
 
                        // we just moved into a greedy child
1359
 
                        if (parentInstance && c == 'isover') {
1360
 
                                parentInstance['isover'] = 0;
1361
 
                                parentInstance['isout'] = 1;
1362
 
                                parentInstance._out.call(parentInstance, e);
1363
 
                        }
1364
 
                        
1365
 
                        this[c] = 1; this[c == 'isout' ? 'isover' : 'isout'] = 0;
1366
 
                        this[c == "isover" ? "_over" : "_out"].call(this, e);
1367
 
                        
1368
 
                        // we just moved out of a greedy child
1369
 
                        if (parentInstance && c == 'isout') {
1370
 
                                parentInstance['isout'] = 0;
1371
 
                                parentInstance['isover'] = 1;
1372
 
                                parentInstance._over.call(parentInstance, e);
1373
 
                        }
1374
 
                });
1375
 
                
1376
 
        }
1377
 
};
1378
 
 
1379
 
/*
1380
 
 * Droppable Extensions
1381
 
 */
1382
 
 
1383
 
$.ui.plugin.add("droppable", "activeClass", {
1384
 
        activate: function(e, ui) {
1385
 
                $(this).addClass(ui.options.activeClass);
1386
 
        },
1387
 
        deactivate: function(e, ui) {
1388
 
                $(this).removeClass(ui.options.activeClass);
1389
 
        },
1390
 
        drop: function(e, ui) {
1391
 
                $(this).removeClass(ui.options.activeClass);
1392
 
        }
1393
 
});
1394
 
 
1395
 
$.ui.plugin.add("droppable", "hoverClass", {
1396
 
        over: function(e, ui) {
1397
 
                $(this).addClass(ui.options.hoverClass);
1398
 
        },
1399
 
        out: function(e, ui) {
1400
 
                $(this).removeClass(ui.options.hoverClass);
1401
 
        },
1402
 
        drop: function(e, ui) {
1403
 
                $(this).removeClass(ui.options.hoverClass);
1404
 
        }
1405
 
});
1406
 
 
1407
 
})(jQuery);
1408
 
/*
1409
 
 * jQuery UI Resizable @VERSION
1410
 
 *
1411
 
 * Copyright (c) 2008 Paul Bakaus
1412
 
 * Dual licensed under the MIT (MIT-LICENSE.txt)
1413
 
 * and GPL (GPL-LICENSE.txt) licenses.
1414
 
 * 
1415
 
 * http://docs.jquery.com/UI/Resizables
1416
 
 *
1417
 
 * Depends:
1418
 
 *      ui.core.js
1419
 
 */
1420
 
(function($) {
1421
 
 
1422
 
$.widget("ui.resizable", $.extend({}, $.ui.mouse, {
1423
 
        _init: function() {
1424
 
 
1425
 
                var self = this, o = this.options;
1426
 
 
1427
 
                var elpos = this.element.css('position');
1428
 
                
1429
 
                this.originalElement = this.element;
1430
 
                
1431
 
                // simulate .ui-resizable { position: relative; }
1432
 
                this.element.addClass("ui-resizable").css({ position: /static/.test(elpos) ? 'relative' : elpos });
1433
 
                
1434
 
                $.extend(o, {
1435
 
                        _aspectRatio: !!(o.aspectRatio),
1436
 
                        helper: o.helper || o.ghost || o.animate ? o.helper || 'proxy' : null,
1437
 
                        knobHandles: o.knobHandles === true ? 'ui-resizable-knob-handle' : o.knobHandles
1438
 
                });
1439
 
                
1440
 
                //Default Theme
1441
 
                var aBorder = '1px solid #DEDEDE';
1442
 
                
1443
 
                o.defaultTheme = {
1444
 
                        'ui-resizable': { display: 'block' },
1445
 
                        'ui-resizable-handle': { position: 'absolute', background: '#F2F2F2', fontSize: '0.1px' },
1446
 
                        'ui-resizable-n': { cursor: 'n-resize', height: '4px', left: '0px', right: '0px', borderTop: aBorder },
1447
 
                        'ui-resizable-s': { cursor: 's-resize', height: '4px', left: '0px', right: '0px', borderBottom: aBorder },
1448
 
                        'ui-resizable-e': { cursor: 'e-resize', width: '4px', top: '0px', bottom: '0px', borderRight: aBorder },
1449
 
                        'ui-resizable-w': { cursor: 'w-resize', width: '4px', top: '0px', bottom: '0px', borderLeft: aBorder },
1450
 
                        'ui-resizable-se': { cursor: 'se-resize', width: '4px', height: '4px', borderRight: aBorder, borderBottom: aBorder },
1451
 
                        'ui-resizable-sw': { cursor: 'sw-resize', width: '4px', height: '4px', borderBottom: aBorder, borderLeft: aBorder },
1452
 
                        'ui-resizable-ne': { cursor: 'ne-resize', width: '4px', height: '4px', borderRight: aBorder, borderTop: aBorder },
1453
 
                        'ui-resizable-nw': { cursor: 'nw-resize', width: '4px', height: '4px', borderLeft: aBorder, borderTop: aBorder }
1454
 
                };
1455
 
                
1456
 
                o.knobTheme = {
1457
 
                        'ui-resizable-handle': { background: '#F2F2F2', border: '1px solid #808080', height: '8px', width: '8px' },
1458
 
                        'ui-resizable-n': { cursor: 'n-resize', top: '0px', left: '45%' },
1459
 
                        'ui-resizable-s': { cursor: 's-resize', bottom: '0px', left: '45%' },
1460
 
                        'ui-resizable-e': { cursor: 'e-resize', right: '0px', top: '45%' },
1461
 
                        'ui-resizable-w': { cursor: 'w-resize', left: '0px', top: '45%' },
1462
 
                        'ui-resizable-se': { cursor: 'se-resize', right: '0px', bottom: '0px' },
1463
 
                        'ui-resizable-sw': { cursor: 'sw-resize', left: '0px', bottom: '0px' },
1464
 
                        'ui-resizable-nw': { cursor: 'nw-resize', left: '0px', top: '0px' },
1465
 
                        'ui-resizable-ne': { cursor: 'ne-resize', right: '0px', top: '0px' }
1466
 
                };
1467
 
                
1468
 
                o._nodeName = this.element[0].nodeName;
1469
 
                
1470
 
                //Wrap the element if it cannot hold child nodes
1471
 
                if(o._nodeName.match(/canvas|textarea|input|select|button|img/i)) {
1472
 
                        var el = this.element;
1473
 
                        
1474
 
                        //Opera fixing relative position
1475
 
                        if (/relative/.test(el.css('position')) && $.browser.opera)
1476
 
                                el.css({ position: 'relative', top: 'auto', left: 'auto' });
1477
 
                        
1478
 
                        //Create a wrapper element and set the wrapper to the new current internal element
1479
 
                        el.wrap(
1480
 
                                $('<div class="ui-wrapper"      style="overflow: hidden;"></div>').css( {
1481
 
                                        position: el.css('position'),
1482
 
                                        width: el.outerWidth(),
1483
 
                                        height: el.outerHeight(),
1484
 
                                        top: el.css('top'),
1485
 
                                        left: el.css('left')
1486
 
                                })
1487
 
                        );
1488
 
                        
1489
 
                        var oel = this.element; this.element = this.element.parent();
1490
 
                        
1491
 
                        // store instance on wrapper
1492
 
                        this.element.data('resizable', this); 
1493
 
                        
1494
 
                        //Move margins to the wrapper
1495
 
                        this.element.css({ marginLeft: oel.css("marginLeft"), marginTop: oel.css("marginTop"),
1496
 
                                marginRight: oel.css("marginRight"), marginBottom: oel.css("marginBottom")
1497
 
                        });
1498
 
                        
1499
 
                        oel.css({ marginLeft: 0, marginTop: 0, marginRight: 0, marginBottom: 0});
1500
 
                        
1501
 
                        //Prevent Safari textarea resize
1502
 
                        if ($.browser.safari && o.preventDefault) oel.css('resize', 'none');
1503
 
                        
1504
 
                        o.proportionallyResize = oel.css({ position: 'static', zoom: 1, display: 'block' });
1505
 
                        
1506
 
                        // avoid IE jump
1507
 
                        this.element.css({ margin: oel.css('margin') });
1508
 
                        
1509
 
                        // fix handlers offset
1510
 
                        this._proportionallyResize();
1511
 
                }
1512
 
                
1513
 
                if(!o.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' };
1514
 
                if(o.handles.constructor == String) {
1515
 
                        
1516
 
                        o.zIndex = o.zIndex || 1000;
1517
 
                        
1518
 
                        if(o.handles == 'all') o.handles = 'n,e,s,w,se,sw,ne,nw';
1519
 
                        
1520
 
                        var n = o.handles.split(","); o.handles = {};
1521
 
                        
1522
 
                        // insertions are applied when don't have theme loaded
1523
 
                        var insertionsDefault = {
1524
 
                                handle: 'position: absolute; display: none; overflow:hidden;',
1525
 
                                n: 'top: 0pt; width:100%;',
1526
 
                                e: 'right: 0pt; height:100%;',
1527
 
                                s: 'bottom: 0pt; width:100%;',
1528
 
                                w: 'left: 0pt; height:100%;',
1529
 
                                se: 'bottom: 0pt; right: 0px;',
1530
 
                                sw: 'bottom: 0pt; left: 0px;',
1531
 
                                ne: 'top: 0pt; right: 0px;',
1532
 
                                nw: 'top: 0pt; left: 0px;'
1533
 
                        };
1534
 
                        
1535
 
                        for(var i = 0; i < n.length; i++) {
1536
 
                                var handle = $.trim(n[i]), dt = o.defaultTheme, hname = 'ui-resizable-'+handle, loadDefault = !$.ui.css(hname) && !o.knobHandles, userKnobClass = $.ui.css('ui-resizable-knob-handle'), 
1537
 
                                                        allDefTheme = $.extend(dt[hname], dt['ui-resizable-handle']), allKnobTheme = $.extend(o.knobTheme[hname], !userKnobClass ? o.knobTheme['ui-resizable-handle'] : {});
1538
 
                                
1539
 
                                // increase zIndex of sw, se, ne, nw axis
1540
 
                                var applyZIndex = /sw|se|ne|nw/.test(handle) ? { zIndex: ++o.zIndex } : {};
1541
 
                                
1542
 
                                var defCss = (loadDefault ? insertionsDefault[handle] : ''), 
1543
 
                                        axis = $(['<div class="ui-resizable-handle ', hname, '" style="', defCss, insertionsDefault.handle, '"></div>'].join('')).css( applyZIndex );
1544
 
                                o.handles[handle] = '.ui-resizable-'+handle;
1545
 
                                
1546
 
                                this.element.append(
1547
 
                                        //Theme detection, if not loaded, load o.defaultTheme
1548
 
                                        axis.css( loadDefault ? allDefTheme : {} )
1549
 
                                                // Load the knobHandle css, fix width, height, top, left...
1550
 
                                                .css( o.knobHandles ? allKnobTheme : {} ).addClass(o.knobHandles ? 'ui-resizable-knob-handle' : '').addClass(o.knobHandles)
1551
 
                                );
1552
 
                        }
1553
 
                        
1554
 
                        if (o.knobHandles) this.element.addClass('ui-resizable-knob').css( !$.ui.css('ui-resizable-knob') ? { /*border: '1px #fff dashed'*/ } : {} );
1555
 
                }
1556
 
                
1557
 
                this._renderAxis = function(target) {
1558
 
                        target = target || this.element;
1559
 
                        
1560
 
                        for(var i in o.handles) {
1561
 
                                if(o.handles[i].constructor == String) 
1562
 
                                        o.handles[i] = $(o.handles[i], this.element).show();
1563
 
                                
1564
 
                                if (o.transparent)
1565
 
                                        o.handles[i].css({opacity:0});
1566
 
                                
1567
 
                                //Apply pad to wrapper element, needed to fix axis position (textarea, inputs, scrolls)
1568
 
                                if (this.element.is('.ui-wrapper') && 
1569
 
                                        o._nodeName.match(/textarea|input|select|button/i)) {
1570
 
                                        
1571
 
                                        var axis = $(o.handles[i], this.element), padWrapper = 0;
1572
 
                                        
1573
 
                                        //Checking the correct pad and border
1574
 
                                        padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth();
1575
 
                                        
1576
 
                                        //The padding type i have to apply...
1577
 
                                        var padPos = [ 'padding', 
1578
 
                                                /ne|nw|n/.test(i) ? 'Top' :
1579
 
                                                /se|sw|s/.test(i) ? 'Bottom' : 
1580
 
                                                /^e$/.test(i) ? 'Right' : 'Left' ].join(""); 
1581
 
                                        
1582
 
                                        if (!o.transparent)
1583
 
                                                target.css(padPos, padWrapper);
1584
 
                                        
1585
 
                                        this._proportionallyResize();
1586
 
                                }
1587
 
                                if(!$(o.handles[i]).length) continue;
1588
 
                        }
1589
 
                };
1590
 
                
1591
 
                this._renderAxis(this.element);
1592
 
                o._handles = $('.ui-resizable-handle', self.element);
1593
 
                
1594
 
                if (o.disableSelection)
1595
 
                        o._handles.each(function(i, e) { $.ui.disableSelection(e); });
1596
 
                
1597
 
                //Matching axis name
1598
 
                o._handles.mouseover(function() {
1599
 
                        if (!o.resizing) {
1600
 
                                if (this.className) 
1601
 
                                        var axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);
1602
 
                                //Axis, default = se
1603
 
                                self.axis = o.axis = axis && axis[1] ? axis[1] : 'se';
1604
 
                        }
1605
 
                });
1606
 
                
1607
 
                //If we want to auto hide the elements
1608
 
                if (o.autoHide) {
1609
 
                        o._handles.hide();
1610
 
                        $(self.element).addClass("ui-resizable-autohide").hover(function() {
1611
 
                                $(this).removeClass("ui-resizable-autohide");
1612
 
                                o._handles.show();
1613
 
                        },
1614
 
                        function(){
1615
 
                                if (!o.resizing) {
1616
 
                                        $(this).addClass("ui-resizable-autohide");
1617
 
                                        o._handles.hide();
1618
 
                                }
1619
 
                        });
1620
 
                }
1621
 
                
1622
 
                this._mouseInit();
1623
 
        },
1624
 
        plugins: {},
1625
 
        ui: function() {
1626
 
                return {
1627
 
                        originalElement: this.originalElement,
1628
 
                        element: this.element,
1629
 
                        helper: this.helper,
1630
 
                        position: this.position,
1631
 
                        size: this.size,
1632
 
                        options: this.options,
1633
 
                        originalSize: this.originalSize,
1634
 
                        originalPosition: this.originalPosition
1635
 
                };
1636
 
        },
1637
 
        _propagate: function(n,e) {
1638
 
                $.ui.plugin.call(this, n, [e, this.ui()]);
1639
 
                if (n != "resize") this.element.triggerHandler(["resize", n].join(""), [e, this.ui()], this.options[n]);
1640
 
        },
1641
 
        destroy: function() {
1642
 
                var el = this.element, wrapped = el.children(".ui-resizable").get(0);
1643
 
                
1644
 
                this._mouseDestroy();
1645
 
                
1646
 
                var _destroy = function(exp) {
1647
 
                        $(exp).removeClass("ui-resizable ui-resizable-disabled")
1648
 
                                .removeData("resizable").unbind(".resizable").find('.ui-resizable-handle').remove();
1649
 
                };
1650
 
                
1651
 
                _destroy(el);
1652
 
                
1653
 
                if (el.is('.ui-wrapper') && wrapped) {
1654
 
                        el.parent().append(
1655
 
                                $(wrapped).css({
1656
 
                                        position: el.css('position'),
1657
 
                                        width: el.outerWidth(),
1658
 
                                        height: el.outerHeight(),
1659
 
                                        top: el.css('top'),
1660
 
                                        left: el.css('left')
1661
 
                                })
1662
 
                        ).end().remove();
1663
 
                        
1664
 
                        _destroy(wrapped);
1665
 
                }
1666
 
        },
1667
 
        
1668
 
        _mouseCapture: function(e) {
1669
 
                
1670
 
                if(this.options.disabled) return false;
1671
 
                
1672
 
                var handle = false;
1673
 
                for(var i in this.options.handles) {
1674
 
                        if($(this.options.handles[i])[0] == e.target) handle = true;
1675
 
                }
1676
 
                if (!handle) return false;
1677
 
                
1678
 
                return true;
1679
 
                
1680
 
        },
1681
 
        
1682
 
        _mouseStart: function(e) {
1683
 
                
1684
 
                var o = this.options, iniPos = this.element.position(), el = this.element, 
1685
 
                        num = function(v) { return parseInt(v, 10) || 0; }, ie6 = $.browser.msie && $.browser.version < 7;
1686
 
                o.resizing = true;
1687
 
                o.documentScroll = { top: $(document).scrollTop(), left: $(document).scrollLeft() };
1688
 
                
1689
 
                // bugfix #1749
1690
 
                if (el.is('.ui-draggable') || (/absolute/).test(el.css('position'))) {
1691
 
                        
1692
 
                        // sOffset decides if document scrollOffset will be added to the top/left of the resizable element
1693
 
                        var sOffset = $.browser.msie && !o.containment && (/absolute/).test(el.css('position')) && !(/relative/).test(el.parent().css('position'));
1694
 
                        var dscrollt = sOffset ? o.documentScroll.top : 0, dscrolll = sOffset ? o.documentScroll.left : 0;
1695
 
                        
1696
 
                        el.css({ position: 'absolute', top: (iniPos.top + dscrollt), left: (iniPos.left + dscrolll) });
1697
 
                }
1698
 
                
1699
 
                //Opera fixing relative position
1700
 
                if ($.browser.opera && /relative/.test(el.css('position')))
1701
 
                        el.css({ position: 'relative', top: 'auto', left: 'auto' });
1702
 
                
1703
 
                this._renderProxy();
1704
 
                
1705
 
                var curleft = num(this.helper.css('left')), curtop = num(this.helper.css('top'));
1706
 
                
1707
 
                if (o.containment) {
1708
 
                        curleft += $(o.containment).scrollLeft()||0;
1709
 
                        curtop += $(o.containment).scrollTop()||0;
1710
 
                }
1711
 
                
1712
 
                //Store needed variables
1713
 
                this.offset = this.helper.offset();
1714
 
                this.position = { left: curleft, top: curtop };
1715
 
                this.size = o.helper || ie6 ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
1716
 
                this.originalSize = o.helper || ie6 ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
1717
 
                this.originalPosition = { left: curleft, top: curtop };
1718
 
                this.sizeDiff = { width: el.outerWidth() - el.width(), height: el.outerHeight() - el.height() };
1719
 
                this.originalMousePosition = { left: e.pageX, top: e.pageY };
1720
 
                
1721
 
                //Aspect Ratio
1722
 
                o.aspectRatio = (typeof o.aspectRatio == 'number') ? o.aspectRatio : ((this.originalSize.width / this.originalSize.height)||1);
1723
 
                
1724
 
                if (o.preserveCursor)
1725
 
                        $('body').css('cursor', this.axis + '-resize');
1726
 
                        
1727
 
                this._propagate("start", e);
1728
 
                return true;
1729
 
        },
1730
 
        _mouseDrag: function(e) {
1731
 
                
1732
 
                //Increase performance, avoid regex
1733
 
                var el = this.helper, o = this.options, props = {},
1734
 
                        self = this, smp = this.originalMousePosition, a = this.axis;
1735
 
                
1736
 
                var dx = (e.pageX-smp.left)||0, dy = (e.pageY-smp.top)||0;
1737
 
                var trigger = this._change[a];
1738
 
                if (!trigger) return false;
1739
 
                
1740
 
                // Calculate the attrs that will be change
1741
 
                var data = trigger.apply(this, [e, dx, dy]), ie6 = $.browser.msie && $.browser.version < 7, csdif = this.sizeDiff;
1742
 
                
1743
 
                if (o._aspectRatio || e.shiftKey)
1744
 
                        data = this._updateRatio(data, e);
1745
 
                
1746
 
                data = this._respectSize(data, e);
1747
 
                
1748
 
                // plugins callbacks need to be called first
1749
 
                this._propagate("resize", e);
1750
 
                
1751
 
                el.css({
1752
 
                        top: this.position.top + "px", left: this.position.left + "px", 
1753
 
                        width: this.size.width + "px", height: this.size.height + "px"
1754
 
                });
1755
 
                
1756
 
                if (!o.helper && o.proportionallyResize)
1757
 
                        this._proportionallyResize();
1758
 
                
1759
 
                this._updateCache(data);
1760
 
                
1761
 
                // calling the user callback at the end
1762
 
                this.element.triggerHandler("resize", [e, this.ui()], this.options["resize"]);
1763
 
                
1764
 
                return false;
1765
 
        },
1766
 
        _mouseStop: function(e) {
1767
 
                
1768
 
                this.options.resizing = false;
1769
 
                var o = this.options, num = function(v) { return parseInt(v, 10) || 0; }, self = this;
1770
 
                
1771
 
                if(o.helper) {
1772
 
                        var pr = o.proportionallyResize, ista = pr && (/textarea/i).test(pr.get(0).nodeName), 
1773
 
                                                soffseth = ista && $.ui.hasScroll(pr.get(0), 'left') /* TODO - jump height */ ? 0 : self.sizeDiff.height,
1774
 
                                                        soffsetw = ista ? 0 : self.sizeDiff.width;
1775
 
                        
1776
 
                        var s = { width: (self.size.width - soffsetw), height: (self.size.height - soffseth) },
1777
 
                                left = (parseInt(self.element.css('left'), 10) + (self.position.left - self.originalPosition.left)) || null, 
1778
 
                                top = (parseInt(self.element.css('top'), 10) + (self.position.top - self.originalPosition.top)) || null;
1779
 
                        
1780
 
                        if (!o.animate)
1781
 
                                this.element.css($.extend(s, { top: top, left: left }));
1782
 
                        
1783
 
                        if (o.helper && !o.animate) this._proportionallyResize();
1784
 
                }
1785
 
                
1786
 
                if (o.preserveCursor)
1787
 
                        $('body').css('cursor', 'auto');
1788
 
                
1789
 
                this._propagate("stop", e);
1790
 
                
1791
 
                if (o.helper) this.helper.remove();
1792
 
                
1793
 
                return false;
1794
 
        },
1795
 
        _updateCache: function(data) {
1796
 
                var o = this.options;
1797
 
                this.offset = this.helper.offset();
1798
 
                if (data.left) this.position.left = data.left;
1799
 
                if (data.top) this.position.top = data.top;
1800
 
                if (data.height) this.size.height = data.height;
1801
 
                if (data.width) this.size.width = data.width;
1802
 
        },
1803
 
        _updateRatio: function(data, e) {
1804
 
                
1805
 
                var o = this.options, cpos = this.position, csize = this.size, a = this.axis;
1806
 
                
1807
 
                if (data.height) data.width = (csize.height * o.aspectRatio);
1808
 
                else if (data.width) data.height = (csize.width / o.aspectRatio);
1809
 
                
1810
 
                if (a == 'sw') {
1811
 
                        data.left = cpos.left + (csize.width - data.width);
1812
 
                        data.top = null;
1813
 
                }
1814
 
                if (a == 'nw') { 
1815
 
                        data.top = cpos.top + (csize.height - data.height);
1816
 
                        data.left = cpos.left + (csize.width - data.width);
1817
 
                }
1818
 
                
1819
 
                return data;
1820
 
        },
1821
 
        _respectSize: function(data, e) {
1822
 
                
1823
 
                var el = this.helper, o = this.options, pRatio = o._aspectRatio || e.shiftKey, a = this.axis, 
1824
 
                                ismaxw = data.width && o.maxWidth && o.maxWidth < data.width, ismaxh = data.height && o.maxHeight && o.maxHeight < data.height,
1825
 
                                        isminw = data.width && o.minWidth && o.minWidth > data.width, isminh = data.height && o.minHeight && o.minHeight > data.height;
1826
 
                
1827
 
                if (isminw) data.width = o.minWidth;
1828
 
                if (isminh) data.height = o.minHeight;
1829
 
                if (ismaxw) data.width = o.maxWidth;
1830
 
                if (ismaxh) data.height = o.maxHeight;
1831
 
                
1832
 
                var dw = this.originalPosition.left + this.originalSize.width, dh = this.position.top + this.size.height;
1833
 
                var cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a);
1834
 
                
1835
 
                if (isminw && cw) data.left = dw - o.minWidth;
1836
 
                if (ismaxw && cw) data.left = dw - o.maxWidth;
1837
 
                if (isminh && ch)       data.top = dh - o.minHeight;
1838
 
                if (ismaxh && ch)       data.top = dh - o.maxHeight;
1839
 
                
1840
 
                // fixing jump error on top/left - bug #2330
1841
 
                var isNotwh = !data.width && !data.height;
1842
 
                if (isNotwh && !data.left && data.top) data.top = null;
1843
 
                else if (isNotwh && !data.top && data.left) data.left = null;
1844
 
                
1845
 
                return data;
1846
 
        },
1847
 
        _proportionallyResize: function() {
1848
 
                var o = this.options;
1849
 
                if (!o.proportionallyResize) return;
1850
 
                var prel = o.proportionallyResize, el = this.helper || this.element;
1851
 
                
1852
 
                if (!o.borderDif) {
1853
 
                        var b = [prel.css('borderTopWidth'), prel.css('borderRightWidth'), prel.css('borderBottomWidth'), prel.css('borderLeftWidth')],
1854
 
                                p = [prel.css('paddingTop'), prel.css('paddingRight'), prel.css('paddingBottom'), prel.css('paddingLeft')];
1855
 
                        
1856
 
                        o.borderDif = $.map(b, function(v, i) {
1857
 
                                var border = parseInt(v,10)||0, padding = parseInt(p[i],10)||0;
1858
 
                                return border + padding; 
1859
 
                        });
1860
 
                }
1861
 
                prel.css({
1862
 
                        height: (el.height() - o.borderDif[0] - o.borderDif[2]) + "px",
1863
 
                        width: (el.width() - o.borderDif[1] - o.borderDif[3]) + "px"
1864
 
                });
1865
 
        },
1866
 
        _renderProxy: function() {
1867
 
                var el = this.element, o = this.options;
1868
 
                this.elementOffset = el.offset();
1869
 
                
1870
 
                if(o.helper) {
1871
 
                        this.helper = this.helper || $('<div style="overflow:hidden;"></div>');
1872
 
                        
1873
 
                        // fix ie6 offset
1874
 
                        var ie6 = $.browser.msie && $.browser.version < 7, ie6offset = (ie6 ? 1 : 0),
1875
 
                        pxyoffset = ( ie6 ? 2 : -1 );
1876
 
                        
1877
 
                        this.helper.addClass(o.helper).css({
1878
 
                                width: el.outerWidth() + pxyoffset,
1879
 
                                height: el.outerHeight() + pxyoffset,
1880
 
                                position: 'absolute',
1881
 
                                left: this.elementOffset.left - ie6offset +'px',
1882
 
                                top: this.elementOffset.top - ie6offset +'px',
1883
 
                                zIndex: ++o.zIndex
1884
 
                        });
1885
 
                        
1886
 
                        this.helper.appendTo("body");
1887
 
                        
1888
 
                        if (o.disableSelection)
1889
 
                                $.ui.disableSelection(this.helper.get(0));
1890
 
                        
1891
 
                } else {
1892
 
                        this.helper = el; 
1893
 
                }
1894
 
        },
1895
 
        _change: {
1896
 
                e: function(e, dx, dy) {
1897
 
                        return { width: this.originalSize.width + dx };
1898
 
                },
1899
 
                w: function(e, dx, dy) {
1900
 
                        var o = this.options, cs = this.originalSize, sp = this.originalPosition;
1901
 
                        return { left: sp.left + dx, width: cs.width - dx };
1902
 
                },
1903
 
                n: function(e, dx, dy) {
1904
 
                        var o = this.options, cs = this.originalSize, sp = this.originalPosition;
1905
 
                        return { top: sp.top + dy, height: cs.height - dy };
1906
 
                },
1907
 
                s: function(e, dx, dy) {
1908
 
                        return { height: this.originalSize.height + dy };
1909
 
                },
1910
 
                se: function(e, dx, dy) {
1911
 
                        return $.extend(this._change.s.apply(this, arguments), this._change.e.apply(this, [e, dx, dy]));
1912
 
                },
1913
 
                sw: function(e, dx, dy) {
1914
 
                        return $.extend(this._change.s.apply(this, arguments), this._change.w.apply(this, [e, dx, dy]));
1915
 
                },
1916
 
                ne: function(e, dx, dy) {
1917
 
                        return $.extend(this._change.n.apply(this, arguments), this._change.e.apply(this, [e, dx, dy]));
1918
 
                },
1919
 
                nw: function(e, dx, dy) {
1920
 
                        return $.extend(this._change.n.apply(this, arguments), this._change.w.apply(this, [e, dx, dy]));
1921
 
                }
1922
 
        }
1923
 
}));
1924
 
 
1925
 
$.extend($.ui.resizable, {
1926
 
        defaults: {
1927
 
                cancel: ":input",
1928
 
                distance: 1,
1929
 
                delay: 0,
1930
 
                preventDefault: true,
1931
 
                transparent: false,
1932
 
                minWidth: 10,
1933
 
                minHeight: 10,
1934
 
                aspectRatio: false,
1935
 
                disableSelection: true,
1936
 
                preserveCursor: true,
1937
 
                autoHide: false,
1938
 
                knobHandles: false
1939
 
        }
1940
 
});
1941
 
 
1942
 
/*
1943
 
 * Resizable Extensions
1944
 
 */
1945
 
 
1946
 
$.ui.plugin.add("resizable", "containment", {
1947
 
        
1948
 
        start: function(e, ui) {
1949
 
                var o = ui.options, self = $(this).data("resizable"), el = self.element;
1950
 
                var oc = o.containment, ce = (oc instanceof $) ? oc.get(0) : (/parent/.test(oc)) ? el.parent().get(0) : oc;
1951
 
                if (!ce) return;
1952
 
                
1953
 
                self.containerElement = $(ce);
1954
 
                
1955
 
                if (/document/.test(oc) || oc == document) {
1956
 
                        self.containerOffset = { left: 0, top: 0 };
1957
 
                        self.containerPosition = { left: 0, top: 0 };
1958
 
                        
1959
 
                        self.parentData = { 
1960
 
                                element: $(document), left: 0, top: 0, 
1961
 
                                width: $(document).width(), height: $(document).height() || document.body.parentNode.scrollHeight
1962
 
                        };
1963
 
                }
1964
 
                
1965
 
                                
1966
 
                // i'm a node, so compute top, left, right, bottom
1967
 
                else{
1968
 
                        self.containerOffset = $(ce).offset();
1969
 
                        self.containerPosition = $(ce).position();
1970
 
                        self.containerSize = { height: $(ce).innerHeight(), width: $(ce).innerWidth() };
1971
 
                
1972
 
                        var co = self.containerOffset, ch = self.containerSize.height,  cw = self.containerSize.width, 
1973
 
                                                width = ($.ui.hasScroll(ce, "left") ? ce.scrollWidth : cw ), height = ($.ui.hasScroll(ce) ? ce.scrollHeight : ch);
1974
 
                
1975
 
                        self.parentData = { 
1976
 
                                element: ce, left: co.left, top: co.top, width: width, height: height
1977
 
                        };
1978
 
                }
1979
 
        },
1980
 
        
1981
 
        resize: function(e, ui) {
1982
 
                var o = ui.options, self = $(this).data("resizable"), 
1983
 
                                ps = self.containerSize, co = self.containerOffset, cs = self.size, cp = self.position,
1984
 
                                pRatio = o._aspectRatio || e.shiftKey, cop = { top:0, left:0 }, ce = self.containerElement;
1985
 
                
1986
 
                if (ce[0] != document && /static/.test(ce.css('position')))
1987
 
                        cop = self.containerPosition;
1988
 
                
1989
 
                if (cp.left < (o.helper ? co.left : cop.left)) {
1990
 
                        self.size.width = self.size.width + (o.helper ? (self.position.left - co.left) : (self.position.left - cop.left));
1991
 
                        if (pRatio) self.size.height = self.size.width / o.aspectRatio;
1992
 
                        self.position.left = o.helper ? co.left : cop.left;
1993
 
                }
1994
 
                
1995
 
                if (cp.top < (o.helper ? co.top : 0)) {
1996
 
                        self.size.height = self.size.height + (o.helper ? (self.position.top - co.top) : self.position.top);
1997
 
                        if (pRatio) self.size.width = self.size.height * o.aspectRatio;
1998
 
                        self.position.top = o.helper ? co.top : 0;
1999
 
                }
2000
 
                
2001
 
                var woset = (o.helper ? self.offset.left - co.left : (self.position.left - cop.left)) + self.sizeDiff.width, 
2002
 
                                        hoset = (o.helper ? self.offset.top - co.top : self.position.top) + self.sizeDiff.height;
2003
 
                
2004
 
                if (woset + self.size.width >= self.parentData.width) {
2005
 
                        self.size.width = self.parentData.width - woset;
2006
 
                        if (pRatio) self.size.height = self.size.width / o.aspectRatio;
2007
 
                }
2008
 
                
2009
 
                if (hoset + self.size.height >= self.parentData.height) {
2010
 
                        self.size.height = self.parentData.height - hoset;
2011
 
                        if (pRatio) self.size.width = self.size.height * o.aspectRatio;
2012
 
                }
2013
 
        },
2014
 
        
2015
 
        stop: function(e, ui){
2016
 
                var o = ui.options, self = $(this).data("resizable"), cp = self.position,
2017
 
                                co = self.containerOffset, cop = self.containerPosition, ce = self.containerElement;
2018
 
                
2019
 
                var helper = $(self.helper), ho = helper.offset(), w = helper.innerWidth(), h = helper.innerHeight();
2020
 
                
2021
 
                
2022
 
                if (o.helper && !o.animate && /relative/.test(ce.css('position')))
2023
 
                        $(this).css({ left: (ho.left - co.left), top: (ho.top - co.top), width: w, height: h });
2024
 
                
2025
 
                if (o.helper && !o.animate && /static/.test(ce.css('position')))
2026
 
                        $(this).css({ left: cop.left + (ho.left - co.left), top: cop.top + (ho.top - co.top), width: w, height: h });
2027
 
                
2028
 
        }
2029
 
});
2030
 
 
2031
 
$.ui.plugin.add("resizable", "grid", {
2032
 
        
2033
 
        resize: function(e, ui) {
2034
 
                var o = ui.options, self = $(this).data("resizable"), cs = self.size, os = self.originalSize, op = self.originalPosition, a = self.axis, ratio = o._aspectRatio || e.shiftKey;
2035
 
                o.grid = typeof o.grid == "number" ? [o.grid, o.grid] : o.grid;
2036
 
                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);
2037
 
                
2038
 
                if (/^(se|s|e)$/.test(a)) {
2039
 
                        self.size.width = os.width + ox;
2040
 
                        self.size.height = os.height + oy;
2041
 
                }
2042
 
                else if (/^(ne)$/.test(a)) {
2043
 
                        self.size.width = os.width + ox;
2044
 
                        self.size.height = os.height + oy;
2045
 
                        self.position.top = op.top - oy;
2046
 
                }
2047
 
                else if (/^(sw)$/.test(a)) {
2048
 
                        self.size.width = os.width + ox;
2049
 
                        self.size.height = os.height + oy;
2050
 
                        self.position.left = op.left - ox;
2051
 
                }
2052
 
                else {
2053
 
                        self.size.width = os.width + ox;
2054
 
                        self.size.height = os.height + oy;
2055
 
                        self.position.top = op.top - oy;
2056
 
                        self.position.left = op.left - ox;
2057
 
                }
2058
 
        }
2059
 
        
2060
 
});
2061
 
 
2062
 
$.ui.plugin.add("resizable", "animate", {
2063
 
        
2064
 
        stop: function(e, ui) {
2065
 
                var o = ui.options, self = $(this).data("resizable");
2066
 
                
2067
 
                var pr = o.proportionallyResize, ista = pr && (/textarea/i).test(pr.get(0).nodeName), 
2068
 
                                                soffseth = ista && $.ui.hasScroll(pr.get(0), 'left') /* TODO - jump height */ ? 0 : self.sizeDiff.height,
2069
 
                                                        soffsetw = ista ? 0 : self.sizeDiff.width;
2070
 
                
2071
 
                var style = { width: (self.size.width - soffsetw), height: (self.size.height - soffseth) },
2072
 
                                        left = (parseInt(self.element.css('left'), 10) + (self.position.left - self.originalPosition.left)) || null, 
2073
 
                                                top = (parseInt(self.element.css('top'), 10) + (self.position.top - self.originalPosition.top)) || null; 
2074
 
                
2075
 
                self.element.animate(
2076
 
                        $.extend(style, top && left ? { top: top, left: left } : {}), { 
2077
 
                                duration: o.animateDuration || "slow", easing: o.animateEasing || "swing", 
2078
 
                                step: function() {
2079
 
                                        
2080
 
                                        var data = {
2081
 
                                                width: parseInt(self.element.css('width'), 10),
2082
 
                                                height: parseInt(self.element.css('height'), 10),
2083
 
                                                top: parseInt(self.element.css('top'), 10),
2084
 
                                                left: parseInt(self.element.css('left'), 10)
2085
 
                                        };
2086
 
                                        
2087
 
                                        if (pr) pr.css({ width: data.width, height: data.height });
2088
 
                                        
2089
 
                                        // propagating resize, and updating values for each animation step
2090
 
                                        self._updateCache(data);
2091
 
                                        self._propagate("animate", e);
2092
 
                                        
2093
 
                                }
2094
 
                        }
2095
 
                );
2096
 
        }
2097
 
        
2098
 
});
2099
 
 
2100
 
$.ui.plugin.add("resizable", "ghost", {
2101
 
        
2102
 
        start: function(e, ui) {
2103
 
                var o = ui.options, self = $(this).data("resizable"), pr = o.proportionallyResize, cs = self.size;
2104
 
                
2105
 
                if (!pr) self.ghost = self.element.clone();
2106
 
                else self.ghost = pr.clone();
2107
 
                
2108
 
                self.ghost.css(
2109
 
                        { opacity: .25, display: 'block', position: 'relative', height: cs.height, width: cs.width, margin: 0, left: 0, top: 0 }
2110
 
                )
2111
 
                .addClass('ui-resizable-ghost').addClass(typeof o.ghost == 'string' ? o.ghost : '');
2112
 
                
2113
 
                self.ghost.appendTo(self.helper);
2114
 
                
2115
 
        },
2116
 
        
2117
 
        resize: function(e, ui){
2118
 
                var o = ui.options, self = $(this).data("resizable"), pr = o.proportionallyResize;
2119
 
                
2120
 
                if (self.ghost) self.ghost.css({ position: 'relative', height: self.size.height, width: self.size.width });
2121
 
                
2122
 
        },
2123
 
        
2124
 
        stop: function(e, ui){
2125
 
                var o = ui.options, self = $(this).data("resizable"), pr = o.proportionallyResize;
2126
 
                if (self.ghost && self.helper) self.helper.get(0).removeChild(self.ghost.get(0));
2127
 
        }
2128
 
        
2129
 
});
2130
 
 
2131
 
$.ui.plugin.add("resizable", "alsoResize", {
2132
 
        
2133
 
        start: function(e, ui) {
2134
 
                var o = ui.options, self = $(this).data("resizable"), 
2135
 
                
2136
 
                _store = function(exp) {
2137
 
                        $(exp).each(function() {
2138
 
                                $(this).data("resizable-alsoresize", {
2139
 
                                        width: parseInt($(this).width(), 10), height: parseInt($(this).height(), 10),
2140
 
                                        left: parseInt($(this).css('left'), 10), top: parseInt($(this).css('top'), 10)
2141
 
                                });
2142
 
                        });
2143
 
                };
2144
 
                
2145
 
                if (typeof(o.alsoResize) == 'object') {
2146
 
                        if (o.alsoResize.length) { o.alsoResize = o.alsoResize[0];      _store(o.alsoResize); }
2147
 
                        else { $.each(o.alsoResize, function(exp, c) { _store(exp); }); }
2148
 
                }else{
2149
 
                        _store(o.alsoResize);
2150
 
                } 
2151
 
        },
2152
 
        
2153
 
        resize: function(e, ui){
2154
 
                var o = ui.options, self = $(this).data("resizable"), os = self.originalSize, op = self.originalPosition;
2155
 
                
2156
 
                var delta = { 
2157
 
                        height: (self.size.height - os.height) || 0, width: (self.size.width - os.width) || 0,
2158
 
                        top: (self.position.top - op.top) || 0, left: (self.position.left - op.left) || 0
2159
 
                },
2160
 
                
2161
 
                _alsoResize = function(exp, c) {
2162
 
                        $(exp).each(function() {
2163
 
                                var start = $(this).data("resizable-alsoresize"), style = {}, css = c && c.length ? c : ['width', 'height', 'top', 'left'];
2164
 
                                
2165
 
                                $.each(css || ['width', 'height', 'top', 'left'], function(i, prop) {
2166
 
                                        var sum = (start[prop]||0) + (delta[prop]||0);
2167
 
                                        if (sum && sum >= 0)
2168
 
                                                style[prop] = sum || null;
2169
 
                                });
2170
 
                                $(this).css(style);
2171
 
                        });
2172
 
                };
2173
 
                
2174
 
                if (typeof(o.alsoResize) == 'object') {
2175
 
                        $.each(o.alsoResize, function(exp, c) { _alsoResize(exp, c); });
2176
 
                }else{
2177
 
                        _alsoResize(o.alsoResize);
2178
 
                }
2179
 
        },
2180
 
        
2181
 
        stop: function(e, ui){
2182
 
                $(this).removeData("resizable-alsoresize-start");
2183
 
        }
2184
 
});
2185
 
 
2186
 
})(jQuery);
2187
 
/*
2188
 
 * jQuery UI Selectable @VERSION
2189
 
 *
2190
 
 * Copyright (c) 2008 Richard D. Worth (rdworth.org)
2191
 
 * Dual licensed under the MIT (MIT-LICENSE.txt)
2192
 
 * and GPL (GPL-LICENSE.txt) licenses.
2193
 
 * 
2194
 
 * http://docs.jquery.com/UI/Selectables
2195
 
 *
2196
 
 * Depends:
2197
 
 *      ui.core.js
2198
 
 */
2199
 
(function($) {
2200
 
 
2201
 
$.widget("ui.selectable", $.extend({}, $.ui.mouse, {
2202
 
        _init: function() {
2203
 
                var self = this;
2204
 
                
2205
 
                this.element.addClass("ui-selectable");
2206
 
                
2207
 
                this.dragged = false;
2208
 
 
2209
 
                // cache selectee children based on filter
2210
 
                var selectees;
2211
 
                this.refresh = function() {
2212
 
                        selectees = $(self.options.filter, self.element[0]);
2213
 
                        selectees.each(function() {
2214
 
                                var $this = $(this);
2215
 
                                var pos = $this.offset();
2216
 
                                $.data(this, "selectable-item", {
2217
 
                                        element: this,
2218
 
                                        $element: $this,
2219
 
                                        left: pos.left,
2220
 
                                        top: pos.top,
2221
 
                                        right: pos.left + $this.width(),
2222
 
                                        bottom: pos.top + $this.height(),
2223
 
                                        startselected: false,
2224
 
                                        selected: $this.hasClass('ui-selected'),
2225
 
                                        selecting: $this.hasClass('ui-selecting'),
2226
 
                                        unselecting: $this.hasClass('ui-unselecting')
2227
 
                                });
2228
 
                        });
2229
 
                };
2230
 
                this.refresh();
2231
 
 
2232
 
                this.selectees = selectees.addClass("ui-selectee");
2233
 
                
2234
 
                this._mouseInit();
2235
 
                
2236
 
                this.helper = $(document.createElement('div'))
2237
 
                        .css({border:'1px dotted black'})
2238
 
                        .addClass("ui-selectable-helper");
2239
 
        },
2240
 
        toggle: function() {
2241
 
                if(this.options.disabled){
2242
 
                        this.enable();
2243
 
                } else {
2244
 
                        this.disable();
2245
 
                }
2246
 
        },
2247
 
        destroy: function() {
2248
 
                this.element
2249
 
                        .removeClass("ui-selectable ui-selectable-disabled")
2250
 
                        .removeData("selectable")
2251
 
                        .unbind(".selectable");
2252
 
                this._mouseDestroy();
2253
 
        },
2254
 
        _mouseStart: function(e) {
2255
 
                var self = this;
2256
 
                
2257
 
                this.opos = [e.pageX, e.pageY];
2258
 
                
2259
 
                if (this.options.disabled)
2260
 
                        return;
2261
 
 
2262
 
                var options = this.options;
2263
 
 
2264
 
                this.selectees = $(options.filter, this.element[0]);
2265
 
 
2266
 
                // selectable START callback
2267
 
                this.element.triggerHandler("selectablestart", [e, {
2268
 
                        "selectable": this.element[0],
2269
 
                        "options": options
2270
 
                }], options.start);
2271
 
 
2272
 
                $('body').append(this.helper);
2273
 
                // position helper (lasso)
2274
 
                this.helper.css({
2275
 
                        "z-index": 100,
2276
 
                        "position": "absolute",
2277
 
                        "left": e.clientX,
2278
 
                        "top": e.clientY,
2279
 
                        "width": 0,
2280
 
                        "height": 0
2281
 
                });
2282
 
 
2283
 
                if (options.autoRefresh) {
2284
 
                        this.refresh();
2285
 
                }
2286
 
 
2287
 
                this.selectees.filter('.ui-selected').each(function() {
2288
 
                        var selectee = $.data(this, "selectable-item");
2289
 
                        selectee.startselected = true;
2290
 
                        if (!e.metaKey) {
2291
 
                                selectee.$element.removeClass('ui-selected');
2292
 
                                selectee.selected = false;
2293
 
                                selectee.$element.addClass('ui-unselecting');
2294
 
                                selectee.unselecting = true;
2295
 
                                // selectable UNSELECTING callback
2296
 
                                self.element.triggerHandler("selectableunselecting", [e, {
2297
 
                                        selectable: self.element[0],
2298
 
                                        unselecting: selectee.element,
2299
 
                                        options: options
2300
 
                                }], options.unselecting);
2301
 
                        }
2302
 
                });
2303
 
                
2304
 
                var isSelectee = false;
2305
 
                $(e.target).parents().andSelf().each(function() {
2306
 
                        if($.data(this, "selectable-item")) isSelectee = true;
2307
 
                });
2308
 
                return this.options.keyboard ? !isSelectee : true;
2309
 
        },
2310
 
        _mouseDrag: function(e) {
2311
 
                var self = this;
2312
 
                this.dragged = true;
2313
 
                
2314
 
                if (this.options.disabled)
2315
 
                        return;
2316
 
 
2317
 
                var options = this.options;
2318
 
 
2319
 
                var x1 = this.opos[0], y1 = this.opos[1], x2 = e.pageX, y2 = e.pageY;
2320
 
                if (x1 > x2) { var tmp = x2; x2 = x1; x1 = tmp; }
2321
 
                if (y1 > y2) { var tmp = y2; y2 = y1; y1 = tmp; }
2322
 
                this.helper.css({left: x1, top: y1, width: x2-x1, height: y2-y1});
2323
 
 
2324
 
                this.selectees.each(function() {
2325
 
                        var selectee = $.data(this, "selectable-item");
2326
 
                        //prevent helper from being selected if appendTo: selectable
2327
 
                        if (!selectee || selectee.element == self.element[0])
2328
 
                                return;
2329
 
                        var hit = false;
2330
 
                        if (options.tolerance == 'touch') {
2331
 
                                hit = ( !(selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1) );
2332
 
                        } else if (options.tolerance == 'fit') {
2333
 
                                hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2);
2334
 
                        }
2335
 
 
2336
 
                        if (hit) {
2337
 
                                // SELECT
2338
 
                                if (selectee.selected) {
2339
 
                                        selectee.$element.removeClass('ui-selected');
2340
 
                                        selectee.selected = false;
2341
 
                                }
2342
 
                                if (selectee.unselecting) {
2343
 
                                        selectee.$element.removeClass('ui-unselecting');
2344
 
                                        selectee.unselecting = false;
2345
 
                                }
2346
 
                                if (!selectee.selecting) {
2347
 
                                        selectee.$element.addClass('ui-selecting');
2348
 
                                        selectee.selecting = true;
2349
 
                                        // selectable SELECTING callback
2350
 
                                        self.element.triggerHandler("selectableselecting", [e, {
2351
 
                                                selectable: self.element[0],
2352
 
                                                selecting: selectee.element,
2353
 
                                                options: options
2354
 
                                        }], options.selecting);
2355
 
                                }
2356
 
                        } else {
2357
 
                                // UNSELECT
2358
 
                                if (selectee.selecting) {
2359
 
                                        if (e.metaKey && selectee.startselected) {
2360
 
                                                selectee.$element.removeClass('ui-selecting');
2361
 
                                                selectee.selecting = false;
2362
 
                                                selectee.$element.addClass('ui-selected');
2363
 
                                                selectee.selected = true;
2364
 
                                        } else {
2365
 
                                                selectee.$element.removeClass('ui-selecting');
2366
 
                                                selectee.selecting = false;
2367
 
                                                if (selectee.startselected) {
2368
 
                                                        selectee.$element.addClass('ui-unselecting');
2369
 
                                                        selectee.unselecting = true;
2370
 
                                                }
2371
 
                                                // selectable UNSELECTING callback
2372
 
                                                self.element.triggerHandler("selectableunselecting", [e, {
2373
 
                                                        selectable: self.element[0],
2374
 
                                                        unselecting: selectee.element,
2375
 
                                                        options: options
2376
 
                                                }], options.unselecting);
2377
 
                                        }
2378
 
                                }
2379
 
                                if (selectee.selected) {
2380
 
                                        if (!e.metaKey && !selectee.startselected) {
2381
 
                                                selectee.$element.removeClass('ui-selected');
2382
 
                                                selectee.selected = false;
2383
 
 
2384
 
                                                selectee.$element.addClass('ui-unselecting');
2385
 
                                                selectee.unselecting = true;
2386
 
                                                // selectable UNSELECTING callback
2387
 
                                                self.element.triggerHandler("selectableunselecting", [e, {
2388
 
                                                        selectable: self.element[0],
2389
 
                                                        unselecting: selectee.element,
2390
 
                                                        options: options
2391
 
                                                }], options.unselecting);
2392
 
                                        }
2393
 
                                }
2394
 
                        }
2395
 
                });
2396
 
                
2397
 
                return false;
2398
 
        },
2399
 
        _mouseStop: function(e) {
2400
 
                var self = this;
2401
 
                
2402
 
                this.dragged = false;
2403
 
                
2404
 
                var options = this.options;
2405
 
 
2406
 
                $('.ui-unselecting', this.element[0]).each(function() {
2407
 
                        var selectee = $.data(this, "selectable-item");
2408
 
                        selectee.$element.removeClass('ui-unselecting');
2409
 
                        selectee.unselecting = false;
2410
 
                        selectee.startselected = false;
2411
 
                        self.element.triggerHandler("selectableunselected", [e, {
2412
 
                                selectable: self.element[0],
2413
 
                                unselected: selectee.element,
2414
 
                                options: options
2415
 
                        }], options.unselected);
2416
 
                });
2417
 
                $('.ui-selecting', this.element[0]).each(function() {
2418
 
                        var selectee = $.data(this, "selectable-item");
2419
 
                        selectee.$element.removeClass('ui-selecting').addClass('ui-selected');
2420
 
                        selectee.selecting = false;
2421
 
                        selectee.selected = true;
2422
 
                        selectee.startselected = true;
2423
 
                        self.element.triggerHandler("selectableselected", [e, {
2424
 
                                selectable: self.element[0],
2425
 
                                selected: selectee.element,
2426
 
                                options: options
2427
 
                        }], options.selected);
2428
 
                });
2429
 
                this.element.triggerHandler("selectablestop", [e, {
2430
 
                        selectable: self.element[0],
2431
 
                        options: this.options
2432
 
                }], this.options.stop);
2433
 
                
2434
 
                this.helper.remove();
2435
 
                
2436
 
                return false;
2437
 
        }
2438
 
}));
2439
 
 
2440
 
$.extend($.ui.selectable, {
2441
 
        defaults: {
2442
 
                distance: 1,
2443
 
                delay: 0,
2444
 
                cancel: ":input",
2445
 
                appendTo: 'body',
2446
 
                autoRefresh: true,
2447
 
                filter: '*',
2448
 
                tolerance: 'touch'
2449
 
        }
2450
 
});
2451
 
 
2452
 
})(jQuery);
2453
 
/*
2454
 
 * jQuery UI Sortable @VERSION
2455
 
 *
2456
 
 * Copyright (c) 2008 Paul Bakaus
2457
 
 * Dual licensed under the MIT (MIT-LICENSE.txt)
2458
 
 * and GPL (GPL-LICENSE.txt) licenses.
2459
 
 * 
2460
 
 * http://docs.jquery.com/UI/Sortables
2461
 
 *
2462
 
 * Depends:
2463
 
 *      ui.core.js
2464
 
 */
2465
 
(function($) {
2466
 
 
2467
 
function contains(a, b) { 
2468
 
    var safari2 = $.browser.safari && $.browser.version < 522; 
2469
 
    if (a.contains && !safari2) { 
2470
 
        return a.contains(b); 
2471
 
    } 
2472
 
    if (a.compareDocumentPosition) 
2473
 
        return !!(a.compareDocumentPosition(b) & 16); 
2474
 
    while (b = b.parentNode) 
2475
 
          if (b == a) return true; 
2476
 
    return false; 
2477
 
};
2478
 
 
2479
 
$.widget("ui.sortable", $.extend({}, $.ui.mouse, {
2480
 
        _init: function() {
2481
 
 
2482
 
                var o = this.options;
2483
 
                this.containerCache = {};
2484
 
                this.element.addClass("ui-sortable");
2485
 
        
2486
 
                //Get the items
2487
 
                this.refresh();
2488
 
 
2489
 
                //Let's determine if the items are floating
2490
 
                this.floating = this.items.length ? (/left|right/).test(this.items[0].item.css('float')) : false;
2491
 
                
2492
 
                //Let's determine the parent's offset
2493
 
                this.offset = this.element.offset();
2494
 
 
2495
 
                //Initialize mouse events for interaction
2496
 
                this._mouseInit();
2497
 
                
2498
 
        },
2499
 
        plugins: {},
2500
 
        ui: function(inst) {
2501
 
                return {
2502
 
                        helper: (inst || this)["helper"],
2503
 
                        placeholder: (inst || this)["placeholder"] || $([]),
2504
 
                        position: (inst || this)["position"],
2505
 
                        absolutePosition: (inst || this)["positionAbs"],
2506
 
                        options: this.options,
2507
 
                        element: this.element,
2508
 
                        item: (inst || this)["currentItem"],
2509
 
                        sender: inst ? inst.element : null
2510
 
                };              
2511
 
        },
2512
 
        
2513
 
        _propagate: function(n,e,inst, noPropagation) {
2514
 
                $.ui.plugin.call(this, n, [e, this.ui(inst)]);
2515
 
                if(!noPropagation) this.element.triggerHandler(n == "sort" ? n : "sort"+n, [e, this.ui(inst)], this.options[n]);
2516
 
        },
2517
 
        
2518
 
        serialize: function(o) {
2519
 
 
2520
 
                var items = this._getItemsAsjQuery(o && o.connected);
2521
 
                var str = []; o = o || {};
2522
 
                
2523
 
                $(items).each(function() {
2524
 
                        var res = ($(this.item || this).attr(o.attribute || 'id') || '').match(o.expression || (/(.+)[-=_](.+)/));
2525
 
                        if(res) str.push((o.key || res[1]+'[]')+'='+(o.key && o.expression ? res[1] : res[2]));
2526
 
                });
2527
 
                
2528
 
                return str.join('&');
2529
 
                
2530
 
        },
2531
 
        
2532
 
        toArray: function(o) {
2533
 
                
2534
 
                var items = this._getItemsAsjQuery(o && o.connected);
2535
 
                var ret = [];
2536
 
 
2537
 
                items.each(function() { ret.push($(this).attr(o.attr || 'id')); });
2538
 
                return ret;
2539
 
                
2540
 
        },
2541
 
        
2542
 
        /* Be careful with the following core functions */
2543
 
        _intersectsWith: function(item) {
2544
 
                var x1 = this.positionAbs.left, x2 = x1 + this.helperProportions.width,
2545
 
                y1 = this.positionAbs.top, y2 = y1 + this.helperProportions.height;
2546
 
                var l = item.left, r = l + item.width, 
2547
 
                t = item.top, b = t + item.height;
2548
 
                
2549
 
                var dyClick = this.offset.click.top, dxClick = this.offset.click.left;
2550
 
                var isOverElement = (y1 + dyClick) > t && (y1 + dyClick) < b && (x1 + dxClick) > l && (x1 + dxClick) < r;
2551
 
                
2552
 
                if(this.options.tolerance == "pointer" || this.options.forcePointerForContainers || (this.options.tolerance == "guess" && this.helperProportions[this.floating ? 'width' : 'height'] > item[this.floating ? 'width' : 'height'])) {
2553
 
                        return isOverElement;
2554
 
                } else {
2555
 
                
2556
 
                        return (l < x1 + (this.helperProportions.width / 2) // Right Half
2557
 
                                && x2 - (this.helperProportions.width / 2) < r // Left Half
2558
 
                                && t < y1 + (this.helperProportions.height / 2) // Bottom Half
2559
 
                                && y2 - (this.helperProportions.height / 2) < b ); // Top Half
2560
 
                
2561
 
                }
2562
 
        },
2563
 
        
2564
 
        _intersectsWithEdge: function(item) {   
2565
 
                var x1 = this.positionAbs.left, x2 = x1 + this.helperProportions.width,
2566
 
                        y1 = this.positionAbs.top, y2 = y1 + this.helperProportions.height;
2567
 
                
2568
 
                var l = item.left, r = l + item.width, 
2569
 
                        t = item.top, b = t + item.height;
2570
 
                
2571
 
                var dyClick = this.offset.click.top, dxClick = this.offset.click.left;
2572
 
                var isOverElement = (y1 + dyClick) > t && (y1 + dyClick) < b && (x1 + dxClick) > l && (x1 + dxClick) < r;
2573
 
                
2574
 
                if(this.options.tolerance == "pointer" || (this.options.tolerance == "guess" && this.helperProportions[this.floating ? 'width' : 'height'] > item[this.floating ? 'width' : 'height'])) {
2575
 
                        if(!isOverElement) return false;
2576
 
 
2577
 
                        if(this.floating) {
2578
 
                                if ((x1 + dxClick) > l && (x1 + dxClick) < l + item.width/2) return 2;
2579
 
                                if ((x1 + dxClick) > l + item.width/2 && (x1 + dxClick) < r) return 1;
2580
 
                        } else {
2581
 
                                var height = item.height;
2582
 
                                var direction = y1 - this.updateOriginalPosition.top < 0 ? 2 : 1; // 2 = up
2583
 
                                
2584
 
                                if (direction == 1 && (y1 + dyClick) < t + height/2) { return 2; } // up
2585
 
                                else if (direction == 2 && (y1 + dyClick) > t + height/2) { return 1; } // down
2586
 
                        }
2587
 
 
2588
 
                } else {
2589
 
                        if (!(l < x1 + (this.helperProportions.width / 2) // Right Half
2590
 
                                && x2 - (this.helperProportions.width / 2) < r // Left Half
2591
 
                                && t < y1 + (this.helperProportions.height / 2) // Bottom Half
2592
 
                                && y2 - (this.helperProportions.height / 2) < b )) return false; // Top Half
2593
 
                        
2594
 
                        if(this.floating) {
2595
 
                                if(x2 > l && x1 < l) return 2; //Crosses left edge
2596
 
                                if(x1 < r && x2 > r) return 1; //Crosses right edge
2597
 
                        } else {
2598
 
                                if(y2 > t && y1 < t) return 1; //Crosses top edge
2599
 
                                if(y1 < b && y2 > b) return 2; //Crosses bottom edge
2600
 
                        }
2601
 
                }
2602
 
                
2603
 
                return false;
2604
 
                
2605
 
        },
2606
 
        
2607
 
        refresh: function() {
2608
 
                this._refreshItems();
2609
 
                this.refreshPositions();
2610
 
        },
2611
 
        
2612
 
        _getItemsAsjQuery: function(connected) {
2613
 
                
2614
 
                var self = this;
2615
 
                var items = [];
2616
 
                var queries = [];
2617
 
        
2618
 
                if(this.options.connectWith && connected) {
2619
 
                        for (var i = this.options.connectWith.length - 1; i >= 0; i--){
2620
 
                                var cur = $(this.options.connectWith[i]);
2621
 
                                for (var j = cur.length - 1; j >= 0; j--){
2622
 
                                        var inst = $.data(cur[j], 'sortable');
2623
 
                                        if(inst && inst != this && !inst.options.disabled) {
2624
 
                                                queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element) : $(inst.options.items, inst.element).not(".ui-sortable-helper"), inst]);
2625
 
                                        }
2626
 
                                };
2627
 
                        };
2628
 
                }
2629
 
                
2630
 
                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"), this]);
2631
 
 
2632
 
                for (var i = queries.length - 1; i >= 0; i--){
2633
 
                        queries[i][0].each(function() {
2634
 
                                items.push(this);
2635
 
                        });
2636
 
                };
2637
 
                
2638
 
                return $(items);
2639
 
                
2640
 
        },
2641
 
        
2642
 
        _removeCurrentsFromItems: function() {
2643
 
                        
2644
 
                var list = this.currentItem.find(":data(sortable-item)");       
2645
 
        
2646
 
                for (var i=0; i < this.items.length; i++) {
2647
 
                        
2648
 
                        for (var j=0; j < list.length; j++) {
2649
 
                                if(list[j] == this.items[i].item[0])
2650
 
                                        this.items.splice(i,1);
2651
 
                        };
2652
 
                
2653
 
                };
2654
 
                
2655
 
        },
2656
 
        
2657
 
        _refreshItems: function() {
2658
 
                
2659
 
                this.items = [];
2660
 
                this.containers = [this];
2661
 
                var items = this.items;
2662
 
                var self = this;
2663
 
                var queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element, null, { options: this.options, item: this.currentItem }) : $(this.options.items, this.element), this]];
2664
 
        
2665
 
                if(this.options.connectWith) {
2666
 
                        for (var i = this.options.connectWith.length - 1; i >= 0; i--){
2667
 
                                var cur = $(this.options.connectWith[i]);
2668
 
                                for (var j = cur.length - 1; j >= 0; j--){
2669
 
                                        var inst = $.data(cur[j], 'sortable');
2670
 
                                        if(inst && inst != this && !inst.options.disabled) {
2671
 
                                                queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element) : $(inst.options.items, inst.element), inst]);
2672
 
                                                this.containers.push(inst);
2673
 
                                        }
2674
 
                                };
2675
 
                        };
2676
 
                }
2677
 
 
2678
 
                for (var i = queries.length - 1; i >= 0; i--){
2679
 
                        queries[i][0].each(function() {
2680
 
                                $.data(this, 'sortable-item', queries[i][1]); // Data for target checking (mouse manager)
2681
 
                                items.push({
2682
 
                                        item: $(this),
2683
 
                                        instance: queries[i][1],
2684
 
                                        width: 0, height: 0,
2685
 
                                        left: 0, top: 0
2686
 
                                });
2687
 
                        });
2688
 
                };
2689
 
 
2690
 
        },
2691
 
        
2692
 
        refreshPositions: function(fast) {
2693
 
 
2694
 
                //This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change
2695
 
                if(this.offsetParent) {
2696
 
                        var po = this.offsetParent.offset();
2697
 
                        this.offset.parent = { top: po.top + this.offsetParentBorders.top, left: po.left + this.offsetParentBorders.left };
2698
 
                }
2699
 
 
2700
 
                for (var i = this.items.length - 1; i >= 0; i--){               
2701
 
                        
2702
 
                        //We ignore calculating positions of all connected containers when we're not over them
2703
 
                        if(this.items[i].instance != this.currentContainer && this.currentContainer && this.items[i].item[0] != this.currentItem[0])
2704
 
                                continue;
2705
 
                                
2706
 
                        var t = this.options.toleranceElement ? $(this.options.toleranceElement, this.items[i].item) : this.items[i].item;
2707
 
                        
2708
 
                        if(!fast) {
2709
 
                                this.items[i].width = t[0].offsetWidth;
2710
 
                                this.items[i].height = t[0].offsetHeight;
2711
 
                        }
2712
 
                        
2713
 
                        var p = t.offset();
2714
 
                        this.items[i].left = p.left;
2715
 
                        this.items[i].top = p.top;
2716
 
                        
2717
 
                };
2718
 
 
2719
 
                if(this.options.custom && this.options.custom.refreshContainers) {
2720
 
                        this.options.custom.refreshContainers.call(this);
2721
 
                } else {
2722
 
                        for (var i = this.containers.length - 1; i >= 0; i--){
2723
 
                                var p =this.containers[i].element.offset();
2724
 
                                this.containers[i].containerCache.left = p.left;
2725
 
                                this.containers[i].containerCache.top = p.top;
2726
 
                                this.containers[i].containerCache.width = this.containers[i].element.outerWidth();
2727
 
                                this.containers[i].containerCache.height = this.containers[i].element.outerHeight();
2728
 
                        };
2729
 
                }
2730
 
 
2731
 
        },
2732
 
        
2733
 
        destroy: function() {
2734
 
                this.element
2735
 
                        .removeClass("ui-sortable ui-sortable-disabled")
2736
 
                        .removeData("sortable")
2737
 
                        .unbind(".sortable");
2738
 
                this._mouseDestroy();
2739
 
                
2740
 
                for ( var i = this.items.length - 1; i >= 0; i-- )
2741
 
                        this.items[i].item.removeData("sortable-item");
2742
 
        },
2743
 
        
2744
 
        _createPlaceholder: function(that) {
2745
 
                
2746
 
                var self = that || this, o = self.options;
2747
 
 
2748
 
                if(!o.placeholder || o.placeholder.constructor == String) {
2749
 
                        var className = o.placeholder;
2750
 
                        o.placeholder = {
2751
 
                                element: function() {
2752
 
                                        var el = $(document.createElement(self.currentItem[0].nodeName)).addClass(className || "ui-sortable-placeholder")[0];
2753
 
 
2754
 
                                        if(!className) {
2755
 
                                                el.style.visibility = "hidden";
2756
 
                                                document.body.appendChild(el);
2757
 
                                                el.innerHTML = self.currentItem[0].innerHTML;
2758
 
                                                document.body.removeChild(el);
2759
 
                                        };
2760
 
 
2761
 
                                        return el;
2762
 
                                },
2763
 
                                update: function(container, p) {
2764
 
                                        if(className && !o.forcePlaceholderSize) return;
2765
 
                                        if(!p.height()) { p.height(self.currentItem.innerHeight() - parseInt(self.currentItem.css('paddingTop')||0, 10) - parseInt(self.currentItem.css('paddingBottom')||0, 10)); };
2766
 
                                        if(!p.width()) { p.width(self.currentItem.innerWidth() - parseInt(self.currentItem.css('paddingLeft')||0, 10) - parseInt(self.currentItem.css('paddingRight')||0, 10)); };
2767
 
                                }
2768
 
                        };
2769
 
                }
2770
 
                
2771
 
                self.placeholder = $(o.placeholder.element.call(self.element, self.currentItem))
2772
 
                self.currentItem.parent()[0].appendChild(self.placeholder[0]);
2773
 
                self.placeholder[0].parentNode.insertBefore(self.placeholder[0], self.currentItem[0]);
2774
 
                o.placeholder.update(self, self.placeholder);
2775
 
        },
2776
 
        
2777
 
        _contactContainers: function(e) {
2778
 
                for (var i = this.containers.length - 1; i >= 0; i--){
2779
 
 
2780
 
                        if(this._intersectsWith(this.containers[i].containerCache)) {
2781
 
                                if(!this.containers[i].containerCache.over) {
2782
 
                                        
2783
 
 
2784
 
                                        if(this.currentContainer != this.containers[i]) {
2785
 
                                                
2786
 
                                                //When entering a new container, we will find the item with the least distance and append our item near it
2787
 
                                                var dist = 10000; var itemWithLeastDistance = null; var base = this.positionAbs[this.containers[i].floating ? 'left' : 'top'];
2788
 
                                                for (var j = this.items.length - 1; j >= 0; j--) {
2789
 
                                                        if(!contains(this.containers[i].element[0], this.items[j].item[0])) continue;
2790
 
                                                        var cur = this.items[j][this.containers[i].floating ? 'left' : 'top'];
2791
 
                                                        if(Math.abs(cur - base) < dist) {
2792
 
                                                                dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j];
2793
 
                                                        }
2794
 
                                                }
2795
 
                                                
2796
 
                                                if(!itemWithLeastDistance && !this.options.dropOnEmpty) //Check if dropOnEmpty is enabled
2797
 
                                                        continue;
2798
 
                                                
2799
 
                                                this.currentContainer = this.containers[i];
2800
 
                                                itemWithLeastDistance ? this.options.sortIndicator.call(this, e, itemWithLeastDistance, null, true) : this.options.sortIndicator.call(this, e, null, this.containers[i].element, true);
2801
 
                                                this._propagate("change", e); //Call plugins and callbacks
2802
 
                                                this.containers[i]._propagate("change", e, this); //Call plugins and callbacks
2803
 
                                                
2804
 
                                                //Update the placeholder
2805
 
                                                this.options.placeholder.update(this.currentContainer, this.placeholder);
2806
 
 
2807
 
                                        }
2808
 
                                        
2809
 
                                        this.containers[i]._propagate("over", e, this);
2810
 
                                        this.containers[i].containerCache.over = 1;
2811
 
                                }
2812
 
                        } else {
2813
 
                                if(this.containers[i].containerCache.over) {
2814
 
                                        this.containers[i]._propagate("out", e, this);
2815
 
                                        this.containers[i].containerCache.over = 0;
2816
 
                                }
2817
 
                        }
2818
 
                        
2819
 
                };                      
2820
 
        },
2821
 
        
2822
 
        _mouseCapture: function(e, overrideHandle) {
2823
 
 
2824
 
                if(this.options.disabled || this.options.type == 'static') return false;
2825
 
 
2826
 
                //We have to refresh the items data once first
2827
 
                this._refreshItems();
2828
 
 
2829
 
                //Find out if the clicked node (or one of its parents) is a actual item in this.items
2830
 
                var currentItem = null, self = this, nodes = $(e.target).parents().each(function() {    
2831
 
                        if($.data(this, 'sortable-item') == self) {
2832
 
                                currentItem = $(this);
2833
 
                                return false;
2834
 
                        }
2835
 
                });
2836
 
                if($.data(e.target, 'sortable-item') == self) currentItem = $(e.target);
2837
 
 
2838
 
                if(!currentItem) return false;
2839
 
                if(this.options.handle && !overrideHandle) {
2840
 
                        var validHandle = false;
2841
 
                        
2842
 
                        $(this.options.handle, currentItem).find("*").andSelf().each(function() { if(this == e.target) validHandle = true; });
2843
 
                        if(!validHandle) return false;
2844
 
                }
2845
 
                        
2846
 
                this.currentItem = currentItem;
2847
 
                this._removeCurrentsFromItems();
2848
 
                return true;    
2849
 
                        
2850
 
        },
2851
 
        
2852
 
        createHelper: function(e) {
2853
 
                
2854
 
                var o = this.options;
2855
 
                var helper = typeof o.helper == 'function' ? $(o.helper.apply(this.element[0], [e, this.currentItem])) : (o.helper == "original" ? this.currentItem :  this.currentItem.clone());
2856
 
                
2857
 
                if (!helper.parents('body').length)
2858
 
                        $(o.appendTo != 'parent' ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]); //Add the helper to the DOM if that didn't happen already
2859
 
                        
2860
 
                return helper;
2861
 
 
2862
 
        },
2863
 
        
2864
 
        _mouseStart: function(e, overrideHandle, noActivation) {
2865
 
 
2866
 
                var o = this.options;
2867
 
                this.currentContainer = this;
2868
 
 
2869
 
                //We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture
2870
 
                this.refreshPositions();
2871
 
 
2872
 
                //Create and append the visible helper  
2873
 
                this.helper = this.createHelper(e);             
2874
 
 
2875
 
                /*
2876
 
                 * - Position generation -
2877
 
                 * This block generates everything position related - it's the core of draggables.
2878
 
                 */
2879
 
 
2880
 
                this.margins = {                                                                                                                                                                //Cache the margins
2881
 
                        left: (parseInt(this.currentItem.css("marginLeft"),10) || 0),
2882
 
                        top: (parseInt(this.currentItem.css("marginTop"),10) || 0)
2883
 
                };              
2884
 
        
2885
 
                this.offset = this.currentItem.offset();                                                                                                                //The element's absolute position on the page
2886
 
                this.offset = {                                                                                                                                                                 //Substract the margins from the element's absolute offset
2887
 
                        top: this.offset.top - this.margins.top,
2888
 
                        left: this.offset.left - this.margins.left
2889
 
                };
2890
 
                
2891
 
                this.offset.click = {                                                                                                                                                   //Where the click happened, relative to the element
2892
 
                        left: e.pageX - this.offset.left,
2893
 
                        top: e.pageY - this.offset.top
2894
 
                };
2895
 
                
2896
 
                this.offsetParent = this.helper.offsetParent();                                                                                                 //Get the offsetParent and cache its position
2897
 
                var po = this.offsetParent.offset();                    
2898
 
 
2899
 
                this.offsetParentBorders = {
2900
 
                        top: (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
2901
 
                        left: (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
2902
 
                };
2903
 
                
2904
 
                this.offset.parent = {                                                                                                                                                  //Store its position plus border
2905
 
                        top: po.top + this.offsetParentBorders.top,
2906
 
                        left: po.left + this.offsetParentBorders.left
2907
 
                };
2908
 
        
2909
 
                this.updateOriginalPosition = this.originalPosition = this._generatePosition(e);                                //Generate the original position
2910
 
                this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] };  //Cache the former DOM position
2911
 
                
2912
 
                //If o.placeholder is used, create a new element at the given position with the class
2913
 
                this.helperProportions = { width: this.helper.outerWidth(), height: this.helper.outerHeight() };//Cache the helper size
2914
 
 
2915
 
 
2916
 
                if(o.helper == "original") {
2917
 
                        this._storedCSS = { position: this.currentItem.css("position"), top: this.currentItem.css("top"), left: this.currentItem.css("left"), clear: this.currentItem.css("clear") };
2918
 
                } else {
2919
 
                        this.currentItem.hide(); //Hide the original, won't cause anything bad this way
2920
 
                }
2921
 
 
2922
 
                //Position it absolutely and add a helper class
2923
 
                this.helper
2924
 
                        .css({ position: 'absolute', clear: 'both' })
2925
 
                        .addClass('ui-sortable-helper');
2926
 
                
2927
 
                //Create the placeholder        
2928
 
                this._createPlaceholder();
2929
 
 
2930
 
                //Call plugins and callbacks
2931
 
                this._propagate("start", e);
2932
 
                
2933
 
                //Recache the helper size
2934
 
                if(!this._preserveHelperProportions)
2935
 
                        this.helperProportions = { width: this.helper.outerWidth(), height: this.helper.outerHeight() };
2936
 
                
2937
 
                if(o.cursorAt) {
2938
 
                        if(o.cursorAt.left != undefined) this.offset.click.left = o.cursorAt.left;
2939
 
                        if(o.cursorAt.right != undefined) this.offset.click.left = this.helperProportions.width - o.cursorAt.right;
2940
 
                        if(o.cursorAt.top != undefined) this.offset.click.top = o.cursorAt.top;
2941
 
                        if(o.cursorAt.bottom != undefined) this.offset.click.top = this.helperProportions.height - o.cursorAt.bottom;
2942
 
                }
2943
 
 
2944
 
                /*
2945
 
                 * - Position constraining -
2946
 
                 * Here we prepare position constraining like grid and containment.
2947
 
                 */     
2948
 
                
2949
 
                if(o.containment) {
2950
 
                        if(o.containment == 'parent') o.containment = this.helper[0].parentNode;
2951
 
                        if(o.containment == 'document' || o.containment == 'window') this.containment = [
2952
 
                                0 - this.offset.parent.left,
2953
 
                                0 - this.offset.parent.top,
2954
 
                                $(o.containment == 'document' ? document : window).width() - this.offset.parent.left - this.helperProportions.width - this.margins.left - (parseInt(this.element.css("marginRight"),10) || 0),
2955
 
                                ($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.offset.parent.top - this.helperProportions.height - this.margins.top - (parseInt(this.element.css("marginBottom"),10) || 0)
2956
 
                        ];
2957
 
 
2958
 
                        if(!(/^(document|window|parent)$/).test(o.containment)) {
2959
 
                                var ce = $(o.containment)[0];
2960
 
                                var co = $(o.containment).offset();
2961
 
                                var over = ($(ce).css("overflow") != 'hidden');
2962
 
                                
2963
 
                                this.containment = [
2964
 
                                        co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) - this.offset.parent.left,
2965
 
                                        co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) - this.offset.parent.top,
2966
 
                                        co.left+(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - this.offset.parent.left - this.helperProportions.width - this.margins.left - (parseInt(this.currentItem.css("marginRight"),10) || 0),
2967
 
                                        co.top+(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - this.offset.parent.top - this.helperProportions.height - this.margins.top - (parseInt(this.currentItem.css("marginBottom"),10) || 0)
2968
 
                                ];
2969
 
                        }
2970
 
                }
2971
 
                
2972
 
                //Post 'activate' events to possible containers
2973
 
                if(!noActivation) {
2974
 
                         for (var i = this.containers.length - 1; i >= 0; i--) { this.containers[i]._propagate("activate", e, this); }
2975
 
                }
2976
 
                
2977
 
                //Prepare possible droppables
2978
 
                if($.ui.ddmanager)
2979
 
                        $.ui.ddmanager.current = this;
2980
 
                
2981
 
                if ($.ui.ddmanager && !o.dropBehaviour)
2982
 
                        $.ui.ddmanager.prepareOffsets(this, e);
2983
 
 
2984
 
                this.dragging = true;
2985
 
 
2986
 
                this._mouseDrag(e); //Execute the drag once - this causes the helper not to be visible before getting its correct position
2987
 
                return true;
2988
 
 
2989
 
 
2990
 
        },
2991
 
        
2992
 
        _convertPositionTo: function(d, pos) {
2993
 
                if(!pos) pos = this.position;
2994
 
                var mod = d == "absolute" ? 1 : -1;
2995
 
                return {
2996
 
                        top: (
2997
 
                                pos.top                                                                                                                                 // the calculated relative position
2998
 
                                + this.offset.parent.top * mod                                                                                  // The offsetParent's offset without borders (offset + border)
2999
 
                                - (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollTop) * mod    // The offsetParent's scroll position
3000
 
                                + this.margins.top * mod                                                                                                //Add the margin (you don't want the margin counting in intersection methods)
3001
 
                        ),
3002
 
                        left: (
3003
 
                                pos.left                                                                                                                                // the calculated relative position
3004
 
                                + this.offset.parent.left * mod                                                                                 // The offsetParent's offset without borders (offset + border)
3005
 
                                - (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollLeft) * mod   // The offsetParent's scroll position
3006
 
                                + this.margins.left * mod                                                                                               //Add the margin (you don't want the margin counting in intersection methods)
3007
 
                        )
3008
 
                };
3009
 
        },
3010
 
        
3011
 
        _generatePosition: function(e) {
3012
 
                
3013
 
                var o = this.options;
3014
 
                var position = {
3015
 
                        top: (
3016
 
                                e.pageY                                                                                                                                 // The absolute mouse position
3017
 
                                - this.offset.click.top                                                                                                 // Click offset (relative to the element)
3018
 
                                - this.offset.parent.top                                                                                                // The offsetParent's offset without borders (offset + border)
3019
 
                                + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollTop)  // The offsetParent's scroll position, not if the element is fixed
3020
 
                        ),
3021
 
                        left: (
3022
 
                                e.pageX                                                                                                                                 // The absolute mouse position
3023
 
                                - this.offset.click.left                                                                                                // Click offset (relative to the element)
3024
 
                                - this.offset.parent.left                                                                                               // The offsetParent's offset without borders (offset + border)
3025
 
                                + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollLeft) // The offsetParent's scroll position, not if the element is fixed
3026
 
                        )
3027
 
                };
3028
 
                
3029
 
                if(!this.originalPosition) return position;                                                                             //If we are not dragging yet, we won't check for options
3030
 
                
3031
 
                /*
3032
 
                 * - Position constraining -
3033
 
                 * Constrain the position to a mix of grid, containment.
3034
 
                 */
3035
 
                if(this.containment) {
3036
 
                        if(position.left < this.containment[0]) position.left = this.containment[0];
3037
 
                        if(position.top < this.containment[1]) position.top = this.containment[1];
3038
 
                        if(position.left > this.containment[2]) position.left = this.containment[2];
3039
 
                        if(position.top > this.containment[3]) position.top = this.containment[3];
3040
 
                }
3041
 
                
3042
 
                if(o.grid) {
3043
 
                        var top = this.originalPosition.top + Math.round((position.top - this.originalPosition.top) / o.grid[1]) * o.grid[1];
3044
 
                        position.top = this.containment ? (!(top < this.containment[1] || top > this.containment[3]) ? top : (!(top < this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
3045
 
                        
3046
 
                        var left = this.originalPosition.left + Math.round((position.left - this.originalPosition.left) / o.grid[0]) * o.grid[0];
3047
 
                        position.left = this.containment ? (!(left < this.containment[0] || left > this.containment[2]) ? left : (!(left < this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
3048
 
                }
3049
 
                
3050
 
                return position;
3051
 
        },
3052
 
        
3053
 
        _mouseDrag: function(e) {
3054
 
 
3055
 
                //Compute the helpers position
3056
 
                this.position = this._generatePosition(e);
3057
 
                this.positionAbs = this._convertPositionTo("absolute");
3058
 
 
3059
 
                //Call the internal plugins
3060
 
                $.ui.plugin.call(this, "sort", [e, this.ui()]);
3061
 
                
3062
 
                //Regenerate the absolute position used for position checks
3063
 
                this.positionAbs = this._convertPositionTo("absolute");
3064
 
                
3065
 
                //Set the helper's position
3066
 
                this.helper[0].style.left = this.position.left+'px';
3067
 
                this.helper[0].style.top = this.position.top+'px';
3068
 
 
3069
 
                //Rearrange
3070
 
                for (var i = this.items.length - 1; i >= 0; i--) {
3071
 
                        var intersection = this._intersectsWithEdge(this.items[i]);
3072
 
                        if(!intersection) continue;
3073
 
                        
3074
 
                        if(this.items[i].item[0] != this.currentItem[0] //cannot intersect with itself
3075
 
                                &&      this.placeholder[intersection == 1 ? "next" : "prev"]()[0] != this.items[i].item[0] //no useless actions that have been done before
3076
 
                                &&      !contains(this.placeholder[0], this.items[i].item[0]) //no action if the item moved is the parent of the item checked
3077
 
                                && (this.options.type == 'semi-dynamic' ? !contains(this.element[0], this.items[i].item[0]) : true)
3078
 
                        ) {
3079
 
                                
3080
 
                                this.updateOriginalPosition = this._generatePosition(e);
3081
 
                                
3082
 
                                this.direction = intersection == 1 ? "down" : "up";
3083
 
                                this.options.sortIndicator.call(this, e, this.items[i]);
3084
 
                                this._propagate("change", e); //Call plugins and callbacks
3085
 
                                break;
3086
 
                        }
3087
 
                }
3088
 
                
3089
 
                //Post events to containers
3090
 
                this._contactContainers(e);
3091
 
                
3092
 
                //Interconnect with droppables
3093
 
                if($.ui.ddmanager) $.ui.ddmanager.drag(this, e);
3094
 
 
3095
 
                //Call callbacks
3096
 
                this.element.triggerHandler("sort", [e, this.ui()], this.options["sort"]);
3097
 
 
3098
 
                return false;
3099
 
                
3100
 
        },
3101
 
        
3102
 
        _rearrange: function(e, i, a, hardRefresh) {
3103
 
 
3104
 
                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));
3105
 
                
3106
 
                //Various things done here to improve the performance:
3107
 
                // 1. we create a setTimeout, that calls refreshPositions
3108
 
                // 2. on the instance, we have a counter variable, that get's higher after every append
3109
 
                // 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same
3110
 
                // 4. this lets only the last addition to the timeout stack through
3111
 
                this.counter = this.counter ? ++this.counter : 1;
3112
 
                var self = this, counter = this.counter;
3113
 
 
3114
 
                window.setTimeout(function() {
3115
 
                        if(counter == self.counter) self.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
3116
 
                },0);
3117
 
 
3118
 
        },
3119
 
        
3120
 
        _mouseStop: function(e, noPropagation) {
3121
 
 
3122
 
                //If we are using droppables, inform the manager about the drop
3123
 
                if ($.ui.ddmanager && !this.options.dropBehaviour)
3124
 
                        $.ui.ddmanager.drop(this, e);
3125
 
                        
3126
 
                if(this.options.revert) {
3127
 
                        var self = this;
3128
 
                        var cur = self.placeholder.offset();
3129
 
 
3130
 
                        $(this.helper).animate({
3131
 
                                left: cur.left - this.offset.parent.left - self.margins.left + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollLeft),
3132
 
                                top: cur.top - this.offset.parent.top - self.margins.top + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollTop)
3133
 
                        }, parseInt(this.options.revert, 10) || 500, function() {
3134
 
                                self._clear(e);
3135
 
                        });
3136
 
                } else {
3137
 
                        this._clear(e, noPropagation);
3138
 
                }
3139
 
 
3140
 
                return false;
3141
 
                
3142
 
        },
3143
 
        
3144
 
        _clear: function(e, noPropagation) {
3145
 
 
3146
 
                //We first have to update the dom position of the actual currentItem
3147
 
                if(!this._noFinalSort) this.placeholder.before(this.currentItem);
3148
 
                this._noFinalSort = null;
3149
 
 
3150
 
                if(this.options.helper == "original")
3151
 
                        this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
3152
 
                else
3153
 
                        this.currentItem.show();
3154
 
 
3155
 
                if(this.domPosition.prev != this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent != this.currentItem.parent()[0]) this._propagate("update", e, null, noPropagation); //Trigger update callback if the DOM position has changed
3156
 
                if(!contains(this.element[0], this.currentItem[0])) { //Node was moved out of the current element
3157
 
                        this._propagate("remove", e, null, noPropagation);
3158
 
                        for (var i = this.containers.length - 1; i >= 0; i--){
3159
 
                                if(contains(this.containers[i].element[0], this.currentItem[0])) {
3160
 
                                        this.containers[i]._propagate("update", e, this, noPropagation);
3161
 
                                        this.containers[i]._propagate("receive", e, this, noPropagation);
3162
 
                                }
3163
 
                        };
3164
 
                };
3165
 
                
3166
 
                //Post events to containers
3167
 
                for (var i = this.containers.length - 1; i >= 0; i--){
3168
 
                        this.containers[i]._propagate("deactivate", e, this, noPropagation);
3169
 
                        if(this.containers[i].containerCache.over) {
3170
 
                                this.containers[i]._propagate("out", e, this);
3171
 
                                this.containers[i].containerCache.over = 0;
3172
 
                        }
3173
 
                }
3174
 
                
3175
 
                this.dragging = false;
3176
 
                if(this.cancelHelperRemoval) {
3177
 
                        this._propagate("beforeStop", e, null, noPropagation);
3178
 
                        this._propagate("stop", e, null, noPropagation);
3179
 
                        return false;
3180
 
                }
3181
 
                
3182
 
                this._propagate("beforeStop", e, null, noPropagation);
3183
 
                
3184
 
                this.placeholder.remove();
3185
 
                if(this.options.helper != "original") this.helper.remove(); this.helper = null;
3186
 
                this._propagate("stop", e, null, noPropagation);
3187
 
                
3188
 
                return true;
3189
 
                
3190
 
        }
3191
 
}));
3192
 
 
3193
 
$.extend($.ui.sortable, {
3194
 
        getter: "serialize toArray",
3195
 
        defaults: {
3196
 
                helper: "original",
3197
 
                tolerance: "guess",
3198
 
                distance: 1,
3199
 
                delay: 0,
3200
 
                scroll: true,
3201
 
                scrollSensitivity: 20,
3202
 
                scrollSpeed: 20,
3203
 
                cancel: ":input",
3204
 
                items: '> *',
3205
 
                zIndex: 1000,
3206
 
                dropOnEmpty: true,
3207
 
                appendTo: "parent",
3208
 
                sortIndicator: $.ui.sortable.prototype._rearrange,
3209
 
                scope: "default",
3210
 
                forcePlaceholderSize: false
3211
 
        }
3212
 
});
3213
 
 
3214
 
/*
3215
 
 * Sortable Extensions
3216
 
 */
3217
 
 
3218
 
$.ui.plugin.add("sortable", "cursor", {
3219
 
        start: function(e, ui) {
3220
 
                var t = $('body');
3221
 
                if (t.css("cursor")) ui.options._cursor = t.css("cursor");
3222
 
                t.css("cursor", ui.options.cursor);
3223
 
        },
3224
 
        beforeStop: function(e, ui) {
3225
 
                if (ui.options._cursor) $('body').css("cursor", ui.options._cursor);
3226
 
        }
3227
 
});
3228
 
 
3229
 
$.ui.plugin.add("sortable", "zIndex", {
3230
 
        start: function(e, ui) {
3231
 
                var t = ui.helper;
3232
 
                if(t.css("zIndex")) ui.options._zIndex = t.css("zIndex");
3233
 
                t.css('zIndex', ui.options.zIndex);
3234
 
        },
3235
 
        beforeStop: function(e, ui) {
3236
 
                if(ui.options._zIndex) $(ui.helper).css('zIndex', ui.options._zIndex);
3237
 
        }
3238
 
});
3239
 
 
3240
 
$.ui.plugin.add("sortable", "opacity", {
3241
 
        start: function(e, ui) {
3242
 
                var t = ui.helper;
3243
 
                if(t.css("opacity")) ui.options._opacity = t.css("opacity");
3244
 
                t.css('opacity', ui.options.opacity);
3245
 
        },
3246
 
        beforeStop: function(e, ui) {
3247
 
                if(ui.options._opacity) $(ui.helper).css('opacity', ui.options._opacity);
3248
 
        }
3249
 
});
3250
 
 
3251
 
$.ui.plugin.add("sortable", "scroll", {
3252
 
        start: function(e, ui) {
3253
 
                var o = ui.options;
3254
 
                var i = $(this).data("sortable");
3255
 
        
3256
 
                i.overflowY = function(el) {
3257
 
                        do { if(/auto|scroll/.test(el.css('overflow')) || (/auto|scroll/).test(el.css('overflow-y'))) return el; el = el.parent(); } while (el[0].parentNode);
3258
 
                        return $(document);
3259
 
                }(i.currentItem);
3260
 
                i.overflowX = function(el) {
3261
 
                        do { if(/auto|scroll/.test(el.css('overflow')) || (/auto|scroll/).test(el.css('overflow-x'))) return el; el = el.parent(); } while (el[0].parentNode);
3262
 
                        return $(document);
3263
 
                }(i.currentItem);
3264
 
                
3265
 
                if(i.overflowY[0] != document && i.overflowY[0].tagName != 'HTML') i.overflowYOffset = i.overflowY.offset();
3266
 
                if(i.overflowX[0] != document && i.overflowX[0].tagName != 'HTML') i.overflowXOffset = i.overflowX.offset();
3267
 
                
3268
 
        },
3269
 
        sort: function(e, ui) {
3270
 
                
3271
 
                var o = ui.options;
3272
 
                var i = $(this).data("sortable");
3273
 
                
3274
 
                if(i.overflowY[0] != document && i.overflowY[0].tagName != 'HTML') {
3275
 
                        if((i.overflowYOffset.top + i.overflowY[0].offsetHeight) - e.pageY < o.scrollSensitivity)
3276
 
                                i.overflowY[0].scrollTop = i.overflowY[0].scrollTop + o.scrollSpeed;
3277
 
                        if(e.pageY - i.overflowYOffset.top < o.scrollSensitivity)
3278
 
                                i.overflowY[0].scrollTop = i.overflowY[0].scrollTop - o.scrollSpeed;
3279
 
                } else {
3280
 
                        if(e.pageY - $(document).scrollTop() < o.scrollSensitivity)
3281
 
                                $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
3282
 
                        if($(window).height() - (e.pageY - $(document).scrollTop()) < o.scrollSensitivity)
3283
 
                                $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
3284
 
                }
3285
 
                
3286
 
                if(i.overflowX[0] != document && i.overflowX[0].tagName != 'HTML') {
3287
 
                        if((i.overflowXOffset.left + i.overflowX[0].offsetWidth) - e.pageX < o.scrollSensitivity)
3288
 
                                i.overflowX[0].scrollLeft = i.overflowX[0].scrollLeft + o.scrollSpeed;
3289
 
                        if(e.pageX - i.overflowXOffset.left < o.scrollSensitivity)
3290
 
                                i.overflowX[0].scrollLeft = i.overflowX[0].scrollLeft - o.scrollSpeed;
3291
 
                } else {
3292
 
                        if(e.pageX - $(document).scrollLeft() < o.scrollSensitivity)
3293
 
                                $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
3294
 
                        if($(window).width() - (e.pageX - $(document).scrollLeft()) < o.scrollSensitivity)
3295
 
                                $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
3296
 
                }
3297
 
                
3298
 
        }
3299
 
});
3300
 
 
3301
 
$.ui.plugin.add("sortable", "axis", {
3302
 
        sort: function(e, ui) {
3303
 
                
3304
 
                var i = $(this).data("sortable");
3305
 
                
3306
 
                if(ui.options.axis == "y") i.position.left = i.originalPosition.left;
3307
 
                if(ui.options.axis == "x") i.position.top = i.originalPosition.top;
3308
 
                
3309
 
        }
3310
 
});
3311
 
 
3312
 
})(jQuery);
3313
 
/*
3314
 
 * jQuery UI Effects @VERSION
3315
 
 *
3316
 
 * Copyright (c) 2008 Aaron Eisenberger (aaronchi@gmail.com)
3317
 
 * Dual licensed under the MIT (MIT-LICENSE.txt)
3318
 
 * and GPL (GPL-LICENSE.txt) licenses.
3319
 
 * 
3320
 
 * http://docs.jquery.com/UI/Effects/
3321
 
 */
3322
 
;(function($) {
3323
 
 
3324
 
$.effects = $.effects || {}; //Add the 'effects' scope
3325
 
 
3326
 
$.extend($.effects, {
3327
 
        save: function(el, set) {
3328
 
                for(var i=0;i<set.length;i++) {
3329
 
                        if(set[i] !== null) $.data(el[0], "ec.storage."+set[i], el[0].style[set[i]]);
3330
 
                }
3331
 
        },
3332
 
        restore: function(el, set) {
3333
 
                for(var i=0;i<set.length;i++) {
3334
 
                        if(set[i] !== null) el.css(set[i], $.data(el[0], "ec.storage."+set[i]));
3335
 
                }
3336
 
        },
3337
 
        setMode: function(el, mode) {
3338
 
                if (mode == 'toggle') mode = el.is(':hidden') ? 'show' : 'hide'; // Set for toggle
3339
 
                return mode;
3340
 
        },
3341
 
        getBaseline: function(origin, original) { // Translates a [top,left] array into a baseline value
3342
 
                // this should be a little more flexible in the future to handle a string & hash
3343
 
                var y, x;
3344
 
                switch (origin[0]) {
3345
 
                        case 'top': y = 0; break;
3346
 
                        case 'middle': y = 0.5; break;
3347
 
                        case 'bottom': y = 1; break;
3348
 
                        default: y = origin[0] / original.height;
3349
 
                };
3350
 
                switch (origin[1]) {
3351
 
                        case 'left': x = 0; break;
3352
 
                        case 'center': x = 0.5; break;
3353
 
                        case 'right': x = 1; break;
3354
 
                        default: x = origin[1] / original.width;
3355
 
                };
3356
 
                return {x: x, y: y};
3357
 
        },
3358
 
        createWrapper: function(el) {
3359
 
                if (el.parent().attr('id') == 'fxWrapper')
3360
 
                        return el;
3361
 
                var props = {width: el.outerWidth({margin:true}), height: el.outerHeight({margin:true}), 'float': el.css('float')};
3362
 
                el.wrap('<div id="fxWrapper" style="font-size:100%;background:transparent;border:none;margin:0;padding:0"></div>');
3363
 
                var wrapper = el.parent();
3364
 
                if (el.css('position') == 'static'){
3365
 
                        wrapper.css({position: 'relative'});
3366
 
                        el.css({position: 'relative'});
3367
 
                } else {
3368
 
                        var top = el.css('top'); if(isNaN(parseInt(top))) top = 'auto';
3369
 
                        var left = el.css('left'); if(isNaN(parseInt(left))) left = 'auto';
3370
 
                        wrapper.css({ position: el.css('position'), top: top, left: left, zIndex: el.css('z-index') }).show();
3371
 
                        el.css({position: 'relative', top:0, left:0});
3372
 
                }
3373
 
                wrapper.css(props);
3374
 
                return wrapper;
3375
 
        },
3376
 
        removeWrapper: function(el) {
3377
 
                if (el.parent().attr('id') == 'fxWrapper')
3378
 
                        return el.parent().replaceWith(el);
3379
 
                return el;
3380
 
        },
3381
 
        setTransition: function(el, list, factor, val) {
3382
 
                val = val || {};
3383
 
                $.each(list,function(i, x){
3384
 
                        unit = el.cssUnit(x);
3385
 
                        if (unit[0] > 0) val[x] = unit[0] * factor + unit[1];
3386
 
                });
3387
 
                return val;
3388
 
        },
3389
 
        animateClass: function(value, duration, easing, callback) {
3390
 
 
3391
 
                var cb = (typeof easing == "function" ? easing : (callback ? callback : null));
3392
 
                var ea = (typeof easing == "object" ? easing : null);
3393
 
 
3394
 
                return this.each(function() {
3395
 
 
3396
 
                        var offset = {}; var that = $(this); var oldStyleAttr = that.attr("style") || '';
3397
 
                        if(typeof oldStyleAttr == 'object') oldStyleAttr = oldStyleAttr["cssText"]; /* Stupidly in IE, style is a object.. */
3398
 
                        if(value.toggle) { that.hasClass(value.toggle) ? value.remove = value.toggle : value.add = value.toggle; }
3399
 
 
3400
 
                        //Let's get a style offset
3401
 
                        var oldStyle = $.extend({}, (document.defaultView ? document.defaultView.getComputedStyle(this,null) : this.currentStyle));
3402
 
                        if(value.add) that.addClass(value.add); if(value.remove) that.removeClass(value.remove);
3403
 
                        var newStyle = $.extend({}, (document.defaultView ? document.defaultView.getComputedStyle(this,null) : this.currentStyle));
3404
 
                        if(value.add) that.removeClass(value.add); if(value.remove) that.addClass(value.remove);
3405
 
 
3406
 
                        // The main function to form the object for animation
3407
 
                        for(var n in newStyle) {
3408
 
                                if( typeof newStyle[n] != "function" && newStyle[n] /* No functions and null properties */
3409
 
                                && n.indexOf("Moz") == -1 && n.indexOf("length") == -1 /* No mozilla spezific render properties. */
3410
 
                                && newStyle[n] != oldStyle[n] /* Only values that have changed are used for the animation */
3411
 
                                && (n.match(/color/i) || (!n.match(/color/i) && !isNaN(parseInt(newStyle[n],10)))) /* Only things that can be parsed to integers or colors */
3412
 
                                && (oldStyle.position != "static" || (oldStyle.position == "static" && !n.match(/left|top|bottom|right/))) /* No need for positions when dealing with static positions */
3413
 
                                ) offset[n] = newStyle[n];
3414
 
                        }
3415
 
 
3416
 
                        that.animate(offset, duration, ea, function() { // Animate the newly constructed offset object
3417
 
                                // Change style attribute back to original. For stupid IE, we need to clear the damn object.
3418
 
                                if(typeof $(this).attr("style") == 'object') { $(this).attr("style")["cssText"] = ""; $(this).attr("style")["cssText"] = oldStyleAttr; } else $(this).attr("style", oldStyleAttr);
3419
 
                                if(value.add) $(this).addClass(value.add); if(value.remove) $(this).removeClass(value.remove);
3420
 
                                if(cb) cb.apply(this, arguments);
3421
 
                        });
3422
 
 
3423
 
                });
3424
 
        }
3425
 
});
3426
 
 
3427
 
//Extend the methods of jQuery
3428
 
$.fn.extend({
3429
 
        //Save old methods
3430
 
        _show: $.fn.show,
3431
 
        _hide: $.fn.hide,
3432
 
        __toggle: $.fn.toggle,
3433
 
        _addClass: $.fn.addClass,
3434
 
        _removeClass: $.fn.removeClass,
3435
 
        _toggleClass: $.fn.toggleClass,
3436
 
        // New ec methods
3437
 
        effect: function(fx,o,speed,callback) {
3438
 
                return $.effects[fx] ? $.effects[fx].call(this, {method: fx, options: o || {}, duration: speed, callback: callback }) : null;
3439
 
        },
3440
 
        show: function() {
3441
 
                if(!arguments[0] || (arguments[0].constructor == Number || /(slow|normal|fast)/.test(arguments[0])))
3442
 
                        return this._show.apply(this, arguments);
3443
 
                else {
3444
 
                        var o = arguments[1] || {}; o['mode'] = 'show';
3445
 
                        return this.effect.apply(this, [arguments[0], o, arguments[2] || o.duration, arguments[3] || o.callback]);
3446
 
                }
3447
 
        },
3448
 
        hide: function() {
3449
 
                if(!arguments[0] || (arguments[0].constructor == Number || /(slow|normal|fast)/.test(arguments[0])))
3450
 
                        return this._hide.apply(this, arguments);
3451
 
                else {
3452
 
                        var o = arguments[1] || {}; o['mode'] = 'hide';
3453
 
                        return this.effect.apply(this, [arguments[0], o, arguments[2] || o.duration, arguments[3] || o.callback]);
3454
 
                }
3455
 
        },
3456
 
        toggle: function(){
3457
 
                if(!arguments[0] || (arguments[0].constructor == Number || /(slow|normal|fast)/.test(arguments[0])) || (arguments[0].constructor == Function))
3458
 
                        return this.__toggle.apply(this, arguments);
3459
 
                else {
3460
 
                        var o = arguments[1] || {}; o['mode'] = 'toggle';
3461
 
                        return this.effect.apply(this, [arguments[0], o, arguments[2] || o.duration, arguments[3] || o.callback]);
3462
 
                }
3463
 
        },
3464
 
        addClass: function(classNames,speed,easing,callback) {
3465
 
                return speed ? $.effects.animateClass.apply(this, [{ add: classNames },speed,easing,callback]) : this._addClass(classNames);
3466
 
        },
3467
 
        removeClass: function(classNames,speed,easing,callback) {
3468
 
                return speed ? $.effects.animateClass.apply(this, [{ remove: classNames },speed,easing,callback]) : this._removeClass(classNames);
3469
 
        },
3470
 
        toggleClass: function(classNames,speed,easing,callback) {
3471
 
                return speed ? $.effects.animateClass.apply(this, [{ toggle: classNames },speed,easing,callback]) : this._toggleClass(classNames);
3472
 
        },
3473
 
        morph: function(remove,add,speed,easing,callback) {
3474
 
                return $.effects.animateClass.apply(this, [{ add: add, remove: remove },speed,easing,callback]);
3475
 
        },
3476
 
        switchClass: function() {
3477
 
                return this.morph.apply(this, arguments);
3478
 
        },
3479
 
        // helper functions
3480
 
        cssUnit: function(key) {
3481
 
                var style = this.css(key), val = [];
3482
 
                $.each( ['em','px','%','pt'], function(i, unit){
3483
 
                        if(style.indexOf(unit) > 0)
3484
 
                                val = [parseFloat(style), unit];
3485
 
                });
3486
 
                return val;
3487
 
        }
3488
 
});
3489
 
 
3490
 
/*
3491
 
 * jQuery Color Animations
3492
 
 * Copyright 2007 John Resig
3493
 
 * Released under the MIT and GPL licenses.
3494
 
 */
3495
 
 
3496
 
// We override the animation for all of these color styles
3497
 
jQuery.each(['backgroundColor', 'borderBottomColor', 'borderLeftColor', 'borderRightColor', 'borderTopColor', 'color', 'outlineColor'], function(i,attr){
3498
 
                jQuery.fx.step[attr] = function(fx){
3499
 
                                if ( fx.state == 0 ) {
3500
 
                                                fx.start = getColor( fx.elem, attr );
3501
 
                                                fx.end = getRGB( fx.end );
3502
 
                                }
3503
 
 
3504
 
                                fx.elem.style[attr] = "rgb(" + [
3505
 
                                                Math.max(Math.min( parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0]), 255), 0),
3506
 
                                                Math.max(Math.min( parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1]), 255), 0),
3507
 
                                                Math.max(Math.min( parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2]), 255), 0)
3508
 
                                ].join(",") + ")";
3509
 
                }
3510
 
});
3511
 
 
3512
 
// Color Conversion functions from highlightFade
3513
 
// By Blair Mitchelmore
3514
 
// http://jquery.offput.ca/highlightFade/
3515
 
 
3516
 
// Parse strings looking for color tuples [255,255,255]
3517
 
function getRGB(color) {
3518
 
                var result;
3519
 
 
3520
 
                // Check if we're already dealing with an array of colors
3521
 
                if ( color && color.constructor == Array && color.length == 3 )
3522
 
                                return color;
3523
 
 
3524
 
                // Look for rgb(num,num,num)
3525
 
                if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color))
3526
 
                                return [parseInt(result[1]), parseInt(result[2]), parseInt(result[3])];
3527
 
 
3528
 
                // Look for rgb(num%,num%,num%)
3529
 
                if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color))
3530
 
                                return [parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55];
3531
 
 
3532
 
                // Look for #a0b1c2
3533
 
                if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color))
3534
 
                                return [parseInt(result[1],16), parseInt(result[2],16), parseInt(result[3],16)];
3535
 
 
3536
 
                // Look for #fff
3537
 
                if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color))
3538
 
                                return [parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16)];
3539
 
 
3540
 
                // Look for rgba(0, 0, 0, 0) == transparent in Safari 3
3541
 
                if (result = /rgba\(0, 0, 0, 0\)/.exec(color))
3542
 
                                return colors['transparent']
3543
 
 
3544
 
                // Otherwise, we're most likely dealing with a named color
3545
 
                return colors[jQuery.trim(color).toLowerCase()];
3546
 
}
3547
 
 
3548
 
function getColor(elem, attr) {
3549
 
                var color;
3550
 
 
3551
 
                do {
3552
 
                                color = jQuery.curCSS(elem, attr);
3553
 
 
3554
 
                                // Keep going until we find an element that has color, or we hit the body
3555
 
                                if ( color != '' && color != 'transparent' || jQuery.nodeName(elem, "body") )
3556
 
                                                break;
3557
 
 
3558
 
                                attr = "backgroundColor";
3559
 
                } while ( elem = elem.parentNode );
3560
 
 
3561
 
                return getRGB(color);
3562
 
};
3563
 
 
3564
 
// Some named colors to work with
3565
 
// From Interface by Stefan Petre
3566
 
// http://interface.eyecon.ro/
3567
 
 
3568
 
var colors = {
3569
 
        aqua:[0,255,255],
3570
 
        azure:[240,255,255],
3571
 
        beige:[245,245,220],
3572
 
        black:[0,0,0],
3573
 
        blue:[0,0,255],
3574
 
        brown:[165,42,42],
3575
 
        cyan:[0,255,255],
3576
 
        darkblue:[0,0,139],
3577
 
        darkcyan:[0,139,139],
3578
 
        darkgrey:[169,169,169],
3579
 
        darkgreen:[0,100,0],
3580
 
        darkkhaki:[189,183,107],
3581
 
        darkmagenta:[139,0,139],
3582
 
        darkolivegreen:[85,107,47],
3583
 
        darkorange:[255,140,0],
3584
 
        darkorchid:[153,50,204],
3585
 
        darkred:[139,0,0],
3586
 
        darksalmon:[233,150,122],
3587
 
        darkviolet:[148,0,211],
3588
 
        fuchsia:[255,0,255],
3589
 
        gold:[255,215,0],
3590
 
        green:[0,128,0],
3591
 
        indigo:[75,0,130],
3592
 
        khaki:[240,230,140],
3593
 
        lightblue:[173,216,230],
3594
 
        lightcyan:[224,255,255],
3595
 
        lightgreen:[144,238,144],
3596
 
        lightgrey:[211,211,211],
3597
 
        lightpink:[255,182,193],
3598
 
        lightyellow:[255,255,224],
3599
 
        lime:[0,255,0],
3600
 
        magenta:[255,0,255],
3601
 
        maroon:[128,0,0],
3602
 
        navy:[0,0,128],
3603
 
        olive:[128,128,0],
3604
 
        orange:[255,165,0],
3605
 
        pink:[255,192,203],
3606
 
        purple:[128,0,128],
3607
 
        violet:[128,0,128],
3608
 
        red:[255,0,0],
3609
 
        silver:[192,192,192],
3610
 
        white:[255,255,255],
3611
 
        yellow:[255,255,0],
3612
 
        transparent: [255,255,255]
3613
 
};
3614
 
        
3615
 
/*
3616
 
 * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
3617
 
 *
3618
 
 * Uses the built in easing capabilities added In jQuery 1.1
3619
 
 * to offer multiple easing options
3620
 
 *
3621
 
 * TERMS OF USE - jQuery Easing
3622
 
 * 
3623
 
 * Open source under the BSD License. 
3624
 
 * 
3625
 
 * Copyright © 2008 George McGinley Smith
3626
 
 * All rights reserved.
3627
 
 * 
3628
 
 * Redistribution and use in source and binary forms, with or without modification, 
3629
 
 * are permitted provided that the following conditions are met:
3630
 
 * 
3631
 
 * Redistributions of source code must retain the above copyright notice, this list of 
3632
 
 * conditions and the following disclaimer.
3633
 
 * Redistributions in binary form must reproduce the above copyright notice, this list 
3634
 
 * of conditions and the following disclaimer in the documentation and/or other materials 
3635
 
 * provided with the distribution.
3636
 
 * 
3637
 
 * Neither the name of the author nor the names of contributors may be used to endorse 
3638
 
 * or promote products derived from this software without specific prior written permission.
3639
 
 * 
3640
 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
3641
 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
3642
 
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
3643
 
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
3644
 
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
3645
 
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
3646
 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
3647
 
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
3648
 
 * OF THE POSSIBILITY OF SUCH DAMAGE. 
3649
 
 *
3650
 
*/
3651
 
 
3652
 
// t: current time, b: begInnIng value, c: change In value, d: duration
3653
 
jQuery.easing['jswing'] = jQuery.easing['swing'];
3654
 
 
3655
 
jQuery.extend( jQuery.easing,
3656
 
{
3657
 
        def: 'easeOutQuad',
3658
 
        swing: function (x, t, b, c, d) {
3659
 
                //alert(jQuery.easing.default);
3660
 
                return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
3661
 
        },
3662
 
        easeInQuad: function (x, t, b, c, d) {
3663
 
                return c*(t/=d)*t + b;
3664
 
        },
3665
 
        easeOutQuad: function (x, t, b, c, d) {
3666
 
                return -c *(t/=d)*(t-2) + b;
3667
 
        },
3668
 
        easeInOutQuad: function (x, t, b, c, d) {
3669
 
                if ((t/=d/2) < 1) return c/2*t*t + b;
3670
 
                return -c/2 * ((--t)*(t-2) - 1) + b;
3671
 
        },
3672
 
        easeInCubic: function (x, t, b, c, d) {
3673
 
                return c*(t/=d)*t*t + b;
3674
 
        },
3675
 
        easeOutCubic: function (x, t, b, c, d) {
3676
 
                return c*((t=t/d-1)*t*t + 1) + b;
3677
 
        },
3678
 
        easeInOutCubic: function (x, t, b, c, d) {
3679
 
                if ((t/=d/2) < 1) return c/2*t*t*t + b;
3680
 
                return c/2*((t-=2)*t*t + 2) + b;
3681
 
        },
3682
 
        easeInQuart: function (x, t, b, c, d) {
3683
 
                return c*(t/=d)*t*t*t + b;
3684
 
        },
3685
 
        easeOutQuart: function (x, t, b, c, d) {
3686
 
                return -c * ((t=t/d-1)*t*t*t - 1) + b;
3687
 
        },
3688
 
        easeInOutQuart: function (x, t, b, c, d) {
3689
 
                if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
3690
 
                return -c/2 * ((t-=2)*t*t*t - 2) + b;
3691
 
        },
3692
 
        easeInQuint: function (x, t, b, c, d) {
3693
 
                return c*(t/=d)*t*t*t*t + b;
3694
 
        },
3695
 
        easeOutQuint: function (x, t, b, c, d) {
3696
 
                return c*((t=t/d-1)*t*t*t*t + 1) + b;
3697
 
        },
3698
 
        easeInOutQuint: function (x, t, b, c, d) {
3699
 
                if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
3700
 
                return c/2*((t-=2)*t*t*t*t + 2) + b;
3701
 
        },
3702
 
        easeInSine: function (x, t, b, c, d) {
3703
 
                return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
3704
 
        },
3705
 
        easeOutSine: function (x, t, b, c, d) {
3706
 
                return c * Math.sin(t/d * (Math.PI/2)) + b;
3707
 
        },
3708
 
        easeInOutSine: function (x, t, b, c, d) {
3709
 
                return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
3710
 
        },
3711
 
        easeInExpo: function (x, t, b, c, d) {
3712
 
                return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
3713
 
        },
3714
 
        easeOutExpo: function (x, t, b, c, d) {
3715
 
                return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
3716
 
        },
3717
 
        easeInOutExpo: function (x, t, b, c, d) {
3718
 
                if (t==0) return b;
3719
 
                if (t==d) return b+c;
3720
 
                if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
3721
 
                return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
3722
 
        },
3723
 
        easeInCirc: function (x, t, b, c, d) {
3724
 
                return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
3725
 
        },
3726
 
        easeOutCirc: function (x, t, b, c, d) {
3727
 
                return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
3728
 
        },
3729
 
        easeInOutCirc: function (x, t, b, c, d) {
3730
 
                if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
3731
 
                return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
3732
 
        },
3733
 
        easeInElastic: function (x, t, b, c, d) {
3734
 
                var s=1.70158;var p=0;var a=c;
3735
 
                if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
3736
 
                if (a < Math.abs(c)) { a=c; var s=p/4; }
3737
 
                else var s = p/(2*Math.PI) * Math.asin (c/a);
3738
 
                return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
3739
 
        },
3740
 
        easeOutElastic: function (x, t, b, c, d) {
3741
 
                var s=1.70158;var p=0;var a=c;
3742
 
                if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
3743
 
                if (a < Math.abs(c)) { a=c; var s=p/4; }
3744
 
                else var s = p/(2*Math.PI) * Math.asin (c/a);
3745
 
                return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
3746
 
        },
3747
 
        easeInOutElastic: function (x, t, b, c, d) {
3748
 
                var s=1.70158;var p=0;var a=c;
3749
 
                if (t==0) return b;  if ((t/=d/2)==2) return b+c;  if (!p) p=d*(.3*1.5);
3750
 
                if (a < Math.abs(c)) { a=c; var s=p/4; }
3751
 
                else var s = p/(2*Math.PI) * Math.asin (c/a);
3752
 
                if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
3753
 
                return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
3754
 
        },
3755
 
        easeInBack: function (x, t, b, c, d, s) {
3756
 
                if (s == undefined) s = 1.70158;
3757
 
                return c*(t/=d)*t*((s+1)*t - s) + b;
3758
 
        },
3759
 
        easeOutBack: function (x, t, b, c, d, s) {
3760
 
                if (s == undefined) s = 1.70158;
3761
 
                return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
3762
 
        },
3763
 
        easeInOutBack: function (x, t, b, c, d, s) {
3764
 
                if (s == undefined) s = 1.70158; 
3765
 
                if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
3766
 
                return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
3767
 
        },
3768
 
        easeInBounce: function (x, t, b, c, d) {
3769
 
                return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
3770
 
        },
3771
 
        easeOutBounce: function (x, t, b, c, d) {
3772
 
                if ((t/=d) < (1/2.75)) {
3773
 
                        return c*(7.5625*t*t) + b;
3774
 
                } else if (t < (2/2.75)) {
3775
 
                        return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
3776
 
                } else if (t < (2.5/2.75)) {
3777
 
                        return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
3778
 
                } else {
3779
 
                        return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
3780
 
                }
3781
 
        },
3782
 
        easeInOutBounce: function (x, t, b, c, d) {
3783
 
                if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
3784
 
                return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
3785
 
        }
3786
 
});
3787
 
 
3788
 
/*
3789
 
 *
3790
 
 * TERMS OF USE - EASING EQUATIONS
3791
 
 * 
3792
 
 * Open source under the BSD License. 
3793
 
 * 
3794
 
 * Copyright © 2001 Robert Penner
3795
 
 * All rights reserved.
3796
 
 * 
3797
 
 * Redistribution and use in source and binary forms, with or without modification, 
3798
 
 * are permitted provided that the following conditions are met:
3799
 
 * 
3800
 
 * Redistributions of source code must retain the above copyright notice, this list of 
3801
 
 * conditions and the following disclaimer.
3802
 
 * Redistributions in binary form must reproduce the above copyright notice, this list 
3803
 
 * of conditions and the following disclaimer in the documentation and/or other materials 
3804
 
 * provided with the distribution.
3805
 
 * 
3806
 
 * Neither the name of the author nor the names of contributors may be used to endorse 
3807
 
 * or promote products derived from this software without specific prior written permission.
3808
 
 * 
3809
 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
3810
 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
3811
 
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
3812
 
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
3813
 
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
3814
 
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
3815
 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
3816
 
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
3817
 
 * OF THE POSSIBILITY OF SUCH DAMAGE. 
3818
 
 *
3819
 
 */
3820
 
 
3821
 
})(jQuery);
3822
 
/*
3823
 
 * jQuery UI Effects Blind @VERSION
3824
 
 *
3825
 
 * Copyright (c) 2008 Aaron Eisenberger (aaronchi@gmail.com)
3826
 
 * Dual licensed under the MIT (MIT-LICENSE.txt)
3827
 
 * and GPL (GPL-LICENSE.txt) licenses.
3828
 
 * 
3829
 
 * http://docs.jquery.com/UI/Effects/Blind
3830
 
 *
3831
 
 * Depends:
3832
 
 *      effects.core.js
3833
 
 */
3834
 
(function($) {
3835
 
 
3836
 
$.effects.blind = function(o) {
3837
 
 
3838
 
        return this.queue(function() {
3839
 
 
3840
 
                // Create element
3841
 
                var el = $(this), props = ['position','top','left'];
3842
 
                
3843
 
                // Set options
3844
 
                var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode
3845
 
                var direction = o.options.direction || 'vertical'; // Default direction
3846
 
                
3847
 
                // Adjust
3848
 
                $.effects.save(el, props); el.show(); // Save & Show
3849
 
                var wrapper = $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper
3850
 
                var ref = (direction == 'vertical') ? 'height' : 'width';
3851
 
                var distance = (direction == 'vertical') ? wrapper.height() : wrapper.width();
3852
 
                if(mode == 'show') wrapper.css(ref, 0); // Shift
3853
 
                
3854
 
                // Animation
3855
 
                var animation = {};
3856
 
                animation[ref] = mode == 'show' ? distance : 0;
3857
 
         
3858
 
                // Animate
3859
 
                wrapper.animate(animation, o.duration, o.options.easing, function() {
3860
 
                        if(mode == 'hide') el.hide(); // Hide
3861
 
                        $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
3862
 
                        if(o.callback) o.callback.apply(el[0], arguments); // Callback
3863
 
                        el.dequeue();
3864
 
                });
3865
 
                
3866
 
        });
3867
 
        
3868
 
};
3869
 
 
3870
 
})(jQuery);
3871
 
/*
3872
 
 * jQuery UI Effects Bounce @VERSION
3873
 
 *
3874
 
 * Copyright (c) 2008 Aaron Eisenberger (aaronchi@gmail.com)
3875
 
 * Dual licensed under the MIT (MIT-LICENSE.txt)
3876
 
 * and GPL (GPL-LICENSE.txt) licenses.
3877
 
 * 
3878
 
 * http://docs.jquery.com/UI/Effects/Bounce
3879
 
 *
3880
 
 * Depends:
3881
 
 *      effects.core.js
3882
 
 */
3883
 
(function($) {
3884
 
 
3885
 
$.effects.bounce = function(o) {
3886
 
 
3887
 
        return this.queue(function() {
3888
 
 
3889
 
                // Create element
3890
 
                var el = $(this), props = ['position','top','left'];
3891
 
 
3892
 
                // Set options
3893
 
                var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode
3894
 
                var direction = o.options.direction || 'up'; // Default direction
3895
 
                var distance = o.options.distance || 20; // Default distance
3896
 
                var times = o.options.times || 5; // Default # of times
3897
 
                var speed = o.duration || 250; // Default speed per bounce
3898
 
                if (/show|hide/.test(mode)) props.push('opacity'); // Avoid touching opacity to prevent clearType and PNG issues in IE
3899
 
 
3900
 
                // Adjust
3901
 
                $.effects.save(el, props); el.show(); // Save & Show
3902
 
                $.effects.createWrapper(el); // Create Wrapper
3903
 
                var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left';
3904
 
                var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg';
3905
 
                var distance = o.options.distance || (ref == 'top' ? el.outerHeight({margin:true}) / 3 : el.outerWidth({margin:true}) / 3);
3906
 
                if (mode == 'show') el.css('opacity', 0).css(ref, motion == 'pos' ? -distance : distance); // Shift
3907
 
                if (mode == 'hide') distance = distance / (times * 2);
3908
 
                if (mode != 'hide') times--;
3909
 
                
3910
 
                // Animate
3911
 
                if (mode == 'show') { // Show Bounce
3912
 
                        var animation = {opacity: 1};
3913
 
                        animation[ref] = (motion == 'pos' ? '+=' : '-=') + distance;
3914
 
                        el.animate(animation, speed / 2, o.options.easing);
3915
 
                        distance = distance / 2;
3916
 
                        times--;
3917
 
                };
3918
 
                for (var i = 0; i < times; i++) { // Bounces
3919
 
                        var animation1 = {}, animation2 = {};
3920
 
                        animation1[ref] = (motion == 'pos' ? '-=' : '+=') + distance;
3921
 
                        animation2[ref] = (motion == 'pos' ? '+=' : '-=') + distance;
3922
 
                        el.animate(animation1, speed / 2, o.options.easing).animate(animation2, speed / 2, o.options.easing);
3923
 
                        distance = (mode == 'hide') ? distance * 2 : distance / 2;
3924
 
                };
3925
 
                if (mode == 'hide') { // Last Bounce
3926
 
                        var animation = {opacity: 0};
3927
 
                        animation[ref] = (motion == 'pos' ? '-=' : '+=')  + distance;
3928
 
                        el.animate(animation, speed / 2, o.options.easing, function(){
3929
 
                                el.hide(); // Hide
3930
 
                                $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
3931
 
                                if(o.callback) o.callback.apply(this, arguments); // Callback
3932
 
                        });
3933
 
                } else {
3934
 
                        var animation1 = {}, animation2 = {};
3935
 
                        animation1[ref] = (motion == 'pos' ? '-=' : '+=') + distance;
3936
 
                        animation2[ref] = (motion == 'pos' ? '+=' : '-=') + distance;
3937
 
                        el.animate(animation1, speed / 2, o.options.easing).animate(animation2, speed / 2, o.options.easing, function(){
3938
 
                                $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
3939
 
                                if(o.callback) o.callback.apply(this, arguments); // Callback
3940
 
                        });
3941
 
                };
3942
 
                el.queue('fx', function() { el.dequeue(); });
3943
 
                el.dequeue();
3944
 
        });
3945
 
        
3946
 
};
3947
 
 
3948
 
})(jQuery);
3949
 
/*
3950
 
 * jQuery UI Effects Clip @VERSION
3951
 
 *
3952
 
 * Copyright (c) 2008 Aaron Eisenberger (aaronchi@gmail.com)
3953
 
 * Dual licensed under the MIT (MIT-LICENSE.txt)
3954
 
 * and GPL (GPL-LICENSE.txt) licenses.
3955
 
 * 
3956
 
 * http://docs.jquery.com/UI/Effects/Clip
3957
 
 *
3958
 
 * Depends:
3959
 
 *      effects.core.js
3960
 
 */
3961
 
(function($) {
3962
 
 
3963
 
$.effects.clip = function(o) {
3964
 
 
3965
 
        return this.queue(function() {
3966
 
 
3967
 
                // Create element
3968
 
                var el = $(this), props = ['position','top','left','height','width'];
3969
 
                
3970
 
                // Set options
3971
 
                var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode
3972
 
                var direction = o.options.direction || 'vertical'; // Default direction
3973
 
                
3974
 
                // Adjust
3975
 
                $.effects.save(el, props); el.show(); // Save & Show
3976
 
                var wrapper = $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper
3977
 
                var animate = el[0].tagName == 'IMG' ? wrapper : el;
3978
 
                var ref = {
3979
 
                        size: (direction == 'vertical') ? 'height' : 'width',
3980
 
                        position: (direction == 'vertical') ? 'top' : 'left'
3981
 
                };
3982
 
                var distance = (direction == 'vertical') ? animate.height() : animate.width();
3983
 
                if(mode == 'show') { animate.css(ref.size, 0); animate.css(ref.position, distance / 2); } // Shift
3984
 
                
3985
 
                // Animation
3986
 
                var animation = {};
3987
 
                animation[ref.size] = mode == 'show' ? distance : 0;
3988
 
                animation[ref.position] = mode == 'show' ? 0 : distance / 2;
3989
 
                        
3990
 
                // Animate
3991
 
                animate.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() {
3992
 
                        if(mode == 'hide') el.hide(); // Hide
3993
 
                        $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
3994
 
                        if(o.callback) o.callback.apply(el[0], arguments); // Callback
3995
 
                        el.dequeue();
3996
 
                }}); 
3997
 
                
3998
 
        });
3999
 
        
4000
 
};
4001
 
 
4002
 
})(jQuery);
4003
 
/*
4004
 
 * jQuery UI Effects Drop @VERSION
4005
 
 *
4006
 
 * Copyright (c) 2008 Aaron Eisenberger (aaronchi@gmail.com)
4007
 
 * Dual licensed under the MIT (MIT-LICENSE.txt)
4008
 
 * and GPL (GPL-LICENSE.txt) licenses.
4009
 
 * 
4010
 
 * http://docs.jquery.com/UI/Effects/Drop
4011
 
 *
4012
 
 * Depends:
4013
 
 *      effects.core.js
4014
 
 */
4015
 
(function($) {
4016
 
 
4017
 
$.effects.drop = function(o) {
4018
 
 
4019
 
        return this.queue(function() {
4020
 
 
4021
 
                // Create element
4022
 
                var el = $(this), props = ['position','top','left','opacity'];
4023
 
                
4024
 
                // Set options
4025
 
                var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode
4026
 
                var direction = o.options.direction || 'left'; // Default Direction
4027
 
                
4028
 
                // Adjust
4029
 
                $.effects.save(el, props); el.show(); // Save & Show
4030
 
                $.effects.createWrapper(el); // Create Wrapper
4031
 
                var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left';
4032
 
                var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg';
4033
 
                var distance = o.options.distance || (ref == 'top' ? el.outerHeight({margin:true}) / 2 : el.outerWidth({margin:true}) / 2);
4034
 
                if (mode == 'show') el.css('opacity', 0).css(ref, motion == 'pos' ? -distance : distance); // Shift
4035
 
                
4036
 
                // Animation
4037
 
                var animation = {opacity: mode == 'show' ? 1 : 0};
4038
 
                animation[ref] = (mode == 'show' ? (motion == 'pos' ? '+=' : '-=') : (motion == 'pos' ? '-=' : '+=')) + distance;
4039
 
                
4040
 
                // Animate
4041
 
                el.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() {
4042
 
                        if(mode == 'hide') el.hide(); // Hide
4043
 
                        $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
4044
 
                        if(o.callback) o.callback.apply(this, arguments); // Callback
4045
 
                        el.dequeue();
4046
 
                }});
4047
 
                
4048
 
        });
4049
 
        
4050
 
};
4051
 
 
4052
 
})(jQuery);
4053
 
/*
4054
 
 * jQuery UI Effects Explode @VERSION
4055
 
 *
4056
 
 * Copyright (c) 2008 Paul Bakaus (ui.jquery.com)
4057
 
 * Dual licensed under the MIT (MIT-LICENSE.txt)
4058
 
 * and GPL (GPL-LICENSE.txt) licenses.
4059
 
 * 
4060
 
 * http://docs.jquery.com/UI/Effects/Explode
4061
 
 *
4062
 
 * Depends:
4063
 
 *      effects.core.js
4064
 
 */
4065
 
(function($) {
4066
 
 
4067
 
$.effects.explode = function(o) {
4068
 
 
4069
 
        return this.queue(function() {
4070
 
 
4071
 
        var rows = o.options.pieces ? Math.round(Math.sqrt(o.options.pieces)) : 3;
4072
 
        var cells = o.options.pieces ? Math.round(Math.sqrt(o.options.pieces)) : 3;
4073
 
        
4074
 
        o.options.mode = o.options.mode == 'toggle' ? ($(this).is(':visible') ? 'hide' : 'show') : o.options.mode;
4075
 
        var el = $(this).show().css('visibility', 'hidden');
4076
 
        var offset = el.offset();
4077
 
        
4078
 
        //Substract the margins - not fixing the problem yet.
4079
 
        offset.top -= parseInt(el.css("marginTop")) || 0;
4080
 
        offset.left -= parseInt(el.css("marginLeft")) || 0;
4081
 
        
4082
 
        var width = el.outerWidth(true);
4083
 
        var height = el.outerHeight(true);
4084
 
 
4085
 
        for(var i=0;i<rows;i++) { // =
4086
 
                for(var j=0;j<cells;j++) { // ||
4087
 
                        el
4088
 
                                .clone()
4089
 
                                .appendTo('body')
4090
 
                                .wrap('<div></div>')
4091
 
                                .css({
4092
 
                                        position: 'absolute',
4093
 
                                        visibility: 'visible',
4094
 
                                        left: -j*(width/cells),
4095
 
                                        top: -i*(height/rows)
4096
 
                                })
4097
 
                                .parent()
4098
 
                                .addClass('effects-explode')
4099
 
                                .css({
4100
 
                                        position: 'absolute',
4101
 
                                        overflow: 'hidden',
4102
 
                                        width: width/cells,
4103
 
                                        height: height/rows,
4104
 
                                        left: offset.left + j*(width/cells) + (o.options.mode == 'show' ? (j-Math.floor(cells/2))*(width/cells) : 0),
4105
 
                                        top: offset.top + i*(height/rows) + (o.options.mode == 'show' ? (i-Math.floor(rows/2))*(height/rows) : 0),
4106
 
                                        opacity: o.options.mode == 'show' ? 0 : 1
4107
 
                                }).animate({
4108
 
                                        left: offset.left + j*(width/cells) + (o.options.mode == 'show' ? 0 : (j-Math.floor(cells/2))*(width/cells)),
4109
 
                                        top: offset.top + i*(height/rows) + (o.options.mode == 'show' ? 0 : (i-Math.floor(rows/2))*(height/rows)),
4110
 
                                        opacity: o.options.mode == 'show' ? 1 : 0
4111
 
                                }, o.duration || 500);
4112
 
                }
4113
 
        }
4114
 
 
4115
 
        // Set a timeout, to call the callback approx. when the other animations have finished
4116
 
        setTimeout(function() {
4117
 
                
4118
 
                o.options.mode == 'show' ? el.css({ visibility: 'visible' }) : el.css({ visibility: 'visible' }).hide();
4119
 
                                if(o.callback) o.callback.apply(el[0]); // Callback
4120
 
                                el.dequeue();
4121
 
                                
4122
 
                                $('.effects-explode').remove();
4123
 
                
4124
 
        }, o.duration || 500);
4125
 
        
4126
 
                
4127
 
        });
4128
 
        
4129
 
};
4130
 
 
4131
 
})(jQuery);
4132
 
/*
4133
 
 * jQuery UI Effects Fold @VERSION
4134
 
 *
4135
 
 * Copyright (c) 2008 Aaron Eisenberger (aaronchi@gmail.com)
4136
 
 * Dual licensed under the MIT (MIT-LICENSE.txt)
4137
 
 * and GPL (GPL-LICENSE.txt) licenses.
4138
 
 * 
4139
 
 * http://docs.jquery.com/UI/Effects/Fold
4140
 
 *
4141
 
 * Depends:
4142
 
 *      effects.core.js
4143
 
 */
4144
 
(function($) {
4145
 
 
4146
 
$.effects.fold = function(o) {
4147
 
 
4148
 
        return this.queue(function() {
4149
 
 
4150
 
                // Create element
4151
 
                var el = $(this), props = ['position','top','left'];
4152
 
                
4153
 
                // Set options
4154
 
                var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode
4155
 
                var size = o.options.size || 15; // Default fold size
4156
 
                var horizFirst = !(!o.options.horizFirst); // Ensure a boolean value
4157
 
                
4158
 
                // Adjust
4159
 
                $.effects.save(el, props); el.show(); // Save & Show
4160
 
                var wrapper = $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper
4161
 
                var widthFirst = ((mode == 'show') != horizFirst);
4162
 
                var ref = widthFirst ? ['width', 'height'] : ['height', 'width'];
4163
 
                var distance = widthFirst ? [wrapper.width(), wrapper.height()] : [wrapper.height(), wrapper.width()];
4164
 
                var percent = /([0-9]+)%/.exec(size);
4165
 
                if(percent) size = parseInt(percent[1]) / 100 * distance[mode == 'hide' ? 0 : 1];
4166
 
                if(mode == 'show') wrapper.css(horizFirst ? {height: 0, width: size} : {height: size, width: 0}); // Shift
4167
 
                
4168
 
                // Animation
4169
 
                var animation1 = {}, animation2 = {};
4170
 
                animation1[ref[0]] = mode == 'show' ? distance[0] : size;
4171
 
                animation2[ref[1]] = mode == 'show' ? distance[1] : 0;
4172
 
                
4173
 
                // Animate
4174
 
                wrapper.animate(animation1, o.duration / 2, o.options.easing)
4175
 
                .animate(animation2, o.duration / 2, o.options.easing, function() {
4176
 
                        if(mode == 'hide') el.hide(); // Hide
4177
 
                        $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
4178
 
                        if(o.callback) o.callback.apply(el[0], arguments); // Callback
4179
 
                        el.dequeue();
4180
 
                });
4181
 
                
4182
 
        });
4183
 
        
4184
 
};
4185
 
 
4186
 
})(jQuery);
4187
 
/*
4188
 
 * jQuery UI Effects Highlight @VERSION
4189
 
 *
4190
 
 * Copyright (c) 2008 Aaron Eisenberger (aaronchi@gmail.com)
4191
 
 * Dual licensed under the MIT (MIT-LICENSE.txt)
4192
 
 * and GPL (GPL-LICENSE.txt) licenses.
4193
 
 * 
4194
 
 * http://docs.jquery.com/UI/Effects/Highlight
4195
 
 *
4196
 
 * Depends:
4197
 
 *      effects.core.js
4198
 
 */
4199
 
;(function($) {
4200
 
 
4201
 
$.effects.highlight = function(o) {
4202
 
 
4203
 
        return this.queue(function() {
4204
 
                
4205
 
                // Create element
4206
 
                var el = $(this), props = ['backgroundImage','backgroundColor','opacity'];
4207
 
                
4208
 
                // Set options
4209
 
                var mode = $.effects.setMode(el, o.options.mode || 'show'); // Set Mode
4210
 
                var color = o.options.color || "#ffff99"; // Default highlight color
4211
 
                var oldColor = el.css("backgroundColor");
4212
 
                
4213
 
                // Adjust
4214
 
                $.effects.save(el, props); el.show(); // Save & Show
4215
 
                el.css({backgroundImage: 'none', backgroundColor: color}); // Shift
4216
 
                
4217
 
                // Animation
4218
 
                var animation = {backgroundColor: oldColor };
4219
 
                if (mode == "hide") animation['opacity'] = 0;
4220
 
                
4221
 
                // Animate
4222
 
                el.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() {
4223
 
                        if(mode == "hide") el.hide();
4224
 
                        $.effects.restore(el, props);
4225
 
                if (mode == "show" && jQuery.browser.msie) this.style.removeAttribute('filter'); 
4226
 
                        if(o.callback) o.callback.apply(this, arguments);
4227
 
                        el.dequeue();
4228
 
                }});
4229
 
                
4230
 
        });
4231
 
        
4232
 
};
4233
 
 
4234
 
})(jQuery);
4235
 
/*
4236
 
 * jQuery UI Effects Pulsate @VERSION
4237
 
 *
4238
 
 * Copyright (c) 2008 Aaron Eisenberger (aaronchi@gmail.com)
4239
 
 * Dual licensed under the MIT (MIT-LICENSE.txt)
4240
 
 * and GPL (GPL-LICENSE.txt) licenses.
4241
 
 * 
4242
 
 * http://docs.jquery.com/UI/Effects/Pulsate
4243
 
 *
4244
 
 * Depends:
4245
 
 *      effects.core.js
4246
 
 */
4247
 
(function($) {
4248
 
 
4249
 
$.effects.pulsate = function(o) {
4250
 
 
4251
 
        return this.queue(function() {
4252
 
                
4253
 
                // Create element
4254
 
                var el = $(this);
4255
 
                
4256
 
                // Set options
4257
 
                var mode = $.effects.setMode(el, o.options.mode || 'show'); // Set Mode
4258
 
                var times = o.options.times || 5; // Default # of times
4259
 
                
4260
 
                // Adjust
4261
 
                if (mode == 'hide') times--;
4262
 
                if (el.is(':hidden')) { // Show fadeIn
4263
 
                        el.css('opacity', 0);
4264
 
                        el.show(); // Show
4265
 
                        el.animate({opacity: 1}, o.duration / 2, o.options.easing);
4266
 
                        times = times-2;
4267
 
                }
4268
 
                
4269
 
                // Animate
4270
 
                for (var i = 0; i < times; i++) { // Pulsate
4271
 
                        el.animate({opacity: 0}, o.duration / 2, o.options.easing).animate({opacity: 1}, o.duration / 2, o.options.easing);
4272
 
                };
4273
 
                if (mode == 'hide') { // Last Pulse
4274
 
                        el.animate({opacity: 0}, o.duration / 2, o.options.easing, function(){
4275
 
                                el.hide(); // Hide
4276
 
                                if(o.callback) o.callback.apply(this, arguments); // Callback
4277
 
                        });
4278
 
                } else {
4279
 
                        el.animate({opacity: 0}, o.duration / 2, o.options.easing).animate({opacity: 1}, o.duration / 2, o.options.easing, function(){
4280
 
                                if(o.callback) o.callback.apply(this, arguments); // Callback
4281
 
                        });
4282
 
                };
4283
 
                el.queue('fx', function() { el.dequeue(); });
4284
 
                el.dequeue();
4285
 
        });
4286
 
        
4287
 
};
4288
 
 
4289
 
})(jQuery);
4290
 
/*
4291
 
 * jQuery UI Effects Scale @VERSION
4292
 
 *
4293
 
 * Copyright (c) 2008 Aaron Eisenberger (aaronchi@gmail.com)
4294
 
 * Dual licensed under the MIT (MIT-LICENSE.txt)
4295
 
 * and GPL (GPL-LICENSE.txt) licenses.
4296
 
 * 
4297
 
 * http://docs.jquery.com/UI/Effects/Scale
4298
 
 *
4299
 
 * Depends:
4300
 
 *      effects.core.js
4301
 
 */
4302
 
(function($) {
4303
 
 
4304
 
$.effects.puff = function(o) {
4305
 
 
4306
 
        return this.queue(function() {
4307
 
 
4308
 
                // Create element
4309
 
                var el = $(this);
4310
 
        
4311
 
                // Set options
4312
 
                var options = $.extend(true, {}, o.options);
4313
 
                var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode
4314
 
                var percent = parseInt(o.options.percent) || 150; // Set default puff percent
4315
 
                options.fade = true; // It's not a puff if it doesn't fade! :)
4316
 
                var original = {height: el.height(), width: el.width()}; // Save original
4317
 
        
4318
 
                // Adjust
4319
 
                var factor = percent / 100;
4320
 
                el.from = (mode == 'hide') ? original : {height: original.height * factor, width: original.width * factor};
4321
 
        
4322
 
                // Animation
4323
 
                options.from = el.from;
4324
 
                options.percent = (mode == 'hide') ? percent : 100;
4325
 
                options.mode = mode;
4326
 
        
4327
 
                // Animate
4328
 
                el.effect('scale', options, o.duration, o.callback);
4329
 
                el.dequeue();
4330
 
        });
4331
 
        
4332
 
};
4333
 
 
4334
 
$.effects.scale = function(o) {
4335
 
        
4336
 
        return this.queue(function() {
4337
 
        
4338
 
                // Create element
4339
 
                var el = $(this);
4340
 
 
4341
 
                // Set options
4342
 
                var options = $.extend(true, {}, o.options);
4343
 
                var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode
4344
 
                var percent = parseInt(o.options.percent) || (parseInt(o.options.percent) == 0 ? 0 : (mode == 'hide' ? 0 : 100)); // Set default scaling percent
4345
 
                var direction = o.options.direction || 'both'; // Set default axis
4346
 
                var origin = o.options.origin; // The origin of the scaling
4347
 
                if (mode != 'effect') { // Set default origin and restore for show/hide
4348
 
                        options.origin = origin || ['middle','center'];
4349
 
                        options.restore = true;
4350
 
                }
4351
 
                var original = {height: el.height(), width: el.width()}; // Save original
4352
 
                el.from = o.options.from || (mode == 'show' ? {height: 0, width: 0} : original); // Default from state
4353
 
        
4354
 
                // Adjust
4355
 
                var factor = { // Set scaling factor
4356
 
                        y: direction != 'horizontal' ? (percent / 100) : 1,
4357
 
                        x: direction != 'vertical' ? (percent / 100) : 1
4358
 
                };
4359
 
                el.to = {height: original.height * factor.y, width: original.width * factor.x}; // Set to state
4360
 
                
4361
 
                if (o.options.fade) { // Fade option to support puff
4362
 
                        if (mode == 'show') {el.from.opacity = 0; el.to.opacity = 1;};
4363
 
                        if (mode == 'hide') {el.from.opacity = 1; el.to.opacity = 0;};
4364
 
                };
4365
 
        
4366
 
                // Animation
4367
 
                options.from = el.from; options.to = el.to; options.mode = mode;
4368
 
        
4369
 
                // Animate
4370
 
                el.effect('size', options, o.duration, o.callback);
4371
 
                el.dequeue();
4372
 
        });
4373
 
        
4374
 
};
4375
 
 
4376
 
$.effects.size = function(o) {
4377
 
 
4378
 
        return this.queue(function() {
4379
 
                
4380
 
                // Create element
4381
 
                var el = $(this), props = ['position','top','left','width','height','overflow','opacity'];
4382
 
                var props1 = ['position','top','left','overflow','opacity']; // Always restore
4383
 
                var props2 = ['width','height','overflow']; // Copy for children
4384
 
                var cProps = ['fontSize'];
4385
 
                var vProps = ['borderTopWidth', 'borderBottomWidth', 'paddingTop', 'paddingBottom'];
4386
 
                var hProps = ['borderLeftWidth', 'borderRightWidth', 'paddingLeft', 'paddingRight'];
4387
 
                
4388
 
                // Set options
4389
 
                var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode
4390
 
                var restore = o.options.restore || false; // Default restore
4391
 
                var scale = o.options.scale || 'both'; // Default scale mode
4392
 
                var origin = o.options.origin; // The origin of the sizing
4393
 
                var original = {height: el.height(), width: el.width()}; // Save original
4394
 
                el.from = o.options.from || original; // Default from state
4395
 
                el.to = o.options.to || original; // Default to state
4396
 
                // Adjust
4397
 
                if (origin) { // Calculate baseline shifts
4398
 
                        var baseline = $.effects.getBaseline(origin, original);
4399
 
                        el.from.top = (original.height - el.from.height) * baseline.y;
4400
 
                        el.from.left = (original.width - el.from.width) * baseline.x;
4401
 
                        el.to.top = (original.height - el.to.height) * baseline.y;
4402
 
                        el.to.left = (original.width - el.to.width) * baseline.x;
4403
 
                };
4404
 
                var factor = { // Set scaling factor
4405
 
                        from: {y: el.from.height / original.height, x: el.from.width / original.width},
4406
 
                        to: {y: el.to.height / original.height, x: el.to.width / original.width}
4407
 
                };
4408
 
                if (scale == 'box' || scale == 'both') { // Scale the css box
4409
 
                        if (factor.from.y != factor.to.y) { // Vertical props scaling
4410
 
                                props = props.concat(vProps);
4411
 
                                el.from = $.effects.setTransition(el, vProps, factor.from.y, el.from);
4412
 
                                el.to = $.effects.setTransition(el, vProps, factor.to.y, el.to);
4413
 
                        };
4414
 
                        if (factor.from.x != factor.to.x) { // Horizontal props scaling
4415
 
                                props = props.concat(hProps);
4416
 
                                el.from = $.effects.setTransition(el, hProps, factor.from.x, el.from);
4417
 
                                el.to = $.effects.setTransition(el, hProps, factor.to.x, el.to);
4418
 
                        };
4419
 
                };
4420
 
                if (scale == 'content' || scale == 'both') { // Scale the content
4421
 
                        if (factor.from.y != factor.to.y) { // Vertical props scaling
4422
 
                                props = props.concat(cProps);
4423
 
                                el.from = $.effects.setTransition(el, cProps, factor.from.y, el.from);
4424
 
                                el.to = $.effects.setTransition(el, cProps, factor.to.y, el.to);
4425
 
                        };
4426
 
                };
4427
 
                $.effects.save(el, restore ? props : props1); el.show(); // Save & Show
4428
 
                $.effects.createWrapper(el); // Create Wrapper
4429
 
                el.css('overflow','hidden').css(el.from); // Shift
4430
 
                
4431
 
                // Animate
4432
 
                if (scale == 'content' || scale == 'both') { // Scale the children
4433
 
                        vProps = vProps.concat(['marginTop','marginBottom']).concat(cProps); // Add margins/font-size
4434
 
                        hProps = hProps.concat(['marginLeft','marginRight']); // Add margins
4435
 
                        props2 = props.concat(vProps).concat(hProps); // Concat
4436
 
                        el.find("*[width]").each(function(){
4437
 
                                child = $(this);
4438
 
                                if (restore) $.effects.save(child, props2);
4439
 
                                var c_original = {height: child.height(), width: child.width()}; // Save original
4440
 
                                child.from = {height: c_original.height * factor.from.y, width: c_original.width * factor.from.x};
4441
 
                                child.to = {height: c_original.height * factor.to.y, width: c_original.width * factor.to.x};
4442
 
                                if (factor.from.y != factor.to.y) { // Vertical props scaling
4443
 
                                        child.from = $.effects.setTransition(child, vProps, factor.from.y, child.from);
4444
 
                                        child.to = $.effects.setTransition(child, vProps, factor.to.y, child.to);
4445
 
                                };
4446
 
                                if (factor.from.x != factor.to.x) { // Horizontal props scaling
4447
 
                                        child.from = $.effects.setTransition(child, hProps, factor.from.x, child.from);
4448
 
                                        child.to = $.effects.setTransition(child, hProps, factor.to.x, child.to);
4449
 
                                };
4450
 
                                child.css(child.from); // Shift children
4451
 
                                child.animate(child.to, o.duration, o.options.easing, function(){
4452
 
                                        if (restore) $.effects.restore(child, props2); // Restore children
4453
 
                                }); // Animate children
4454
 
                        });
4455
 
                };
4456
 
                
4457
 
                // Animate
4458
 
                el.animate(el.to, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() {
4459
 
                        if(mode == 'hide') el.hide(); // Hide
4460
 
                        $.effects.restore(el, restore ? props : props1); $.effects.removeWrapper(el); // Restore
4461
 
                        if(o.callback) o.callback.apply(this, arguments); // Callback
4462
 
                        el.dequeue();
4463
 
                }}); 
4464
 
                
4465
 
        });
4466
 
 
4467
 
};
4468
 
 
4469
 
})(jQuery);
4470
 
/*
4471
 
 * jQuery UI Effects Shake @VERSION
4472
 
 *
4473
 
 * Copyright (c) 2008 Aaron Eisenberger (aaronchi@gmail.com)
4474
 
 * Dual licensed under the MIT (MIT-LICENSE.txt)
4475
 
 * and GPL (GPL-LICENSE.txt) licenses.
4476
 
 * 
4477
 
 * http://docs.jquery.com/UI/Effects/Shake
4478
 
 *
4479
 
 * Depends:
4480
 
 *      effects.core.js
4481
 
 */
4482
 
(function($) {
4483
 
 
4484
 
$.effects.shake = function(o) {
4485
 
 
4486
 
        return this.queue(function() {
4487
 
 
4488
 
                // Create element
4489
 
                var el = $(this), props = ['position','top','left'];
4490
 
                
4491
 
                // Set options
4492
 
                var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode
4493
 
                var direction = o.options.direction || 'left'; // Default direction
4494
 
                var distance = o.options.distance || 20; // Default distance
4495
 
                var times = o.options.times || 3; // Default # of times
4496
 
                var speed = o.duration || o.options.duration || 140; // Default speed per shake
4497
 
                
4498
 
                // Adjust
4499
 
                $.effects.save(el, props); el.show(); // Save & Show
4500
 
                $.effects.createWrapper(el); // Create Wrapper
4501
 
                var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left';
4502
 
                var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg';
4503
 
                
4504
 
                // Animation
4505
 
                var animation = {}, animation1 = {}, animation2 = {};
4506
 
                animation[ref] = (motion == 'pos' ? '-=' : '+=')  + distance;
4507
 
                animation1[ref] = (motion == 'pos' ? '+=' : '-=')  + distance * 2;
4508
 
                animation2[ref] = (motion == 'pos' ? '-=' : '+=')  + distance * 2;
4509
 
                
4510
 
                // Animate
4511
 
                el.animate(animation, speed, o.options.easing);
4512
 
                for (var i = 1; i < times; i++) { // Shakes
4513
 
                        el.animate(animation1, speed, o.options.easing).animate(animation2, speed, o.options.easing);
4514
 
                };
4515
 
                el.animate(animation1, speed, o.options.easing).
4516
 
                animate(animation, speed / 2, o.options.easing, function(){ // Last shake
4517
 
                        $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
4518
 
                        if(o.callback) o.callback.apply(this, arguments); // Callback
4519
 
                });
4520
 
                el.queue('fx', function() { el.dequeue(); });
4521
 
                el.dequeue();
4522
 
        });
4523
 
        
4524
 
};
4525
 
 
4526
 
})(jQuery);
4527
 
/*
4528
 
 * jQuery UI Effects Slide @VERSION
4529
 
 *
4530
 
 * Copyright (c) 2008 Aaron Eisenberger (aaronchi@gmail.com)
4531
 
 * Dual licensed under the MIT (MIT-LICENSE.txt)
4532
 
 * and GPL (GPL-LICENSE.txt) licenses.
4533
 
 * 
4534
 
 * http://docs.jquery.com/UI/Effects/Slide
4535
 
 *
4536
 
 * Depends:
4537
 
 *      effects.core.js
4538
 
 */
4539
 
(function($) {
4540
 
 
4541
 
$.effects.slide = function(o) {
4542
 
 
4543
 
        return this.queue(function() {
4544
 
 
4545
 
                // Create element
4546
 
                var el = $(this), props = ['position','top','left'];
4547
 
                
4548
 
                // Set options
4549
 
                var mode = $.effects.setMode(el, o.options.mode || 'show'); // Set Mode
4550
 
                var direction = o.options.direction || 'left'; // Default Direction
4551
 
                
4552
 
                // Adjust
4553
 
                $.effects.save(el, props); el.show(); // Save & Show
4554
 
                $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper
4555
 
                var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left';
4556
 
                var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg';
4557
 
                var distance = o.options.distance || (ref == 'top' ? el.outerHeight({margin:true}) : el.outerWidth({margin:true}));
4558
 
                if (mode == 'show') el.css(ref, motion == 'pos' ? -distance : distance); // Shift
4559
 
                
4560
 
                // Animation
4561
 
                var animation = {};
4562
 
                animation[ref] = (mode == 'show' ? (motion == 'pos' ? '+=' : '-=') : (motion == 'pos' ? '-=' : '+=')) + distance;
4563
 
                
4564
 
                // Animate
4565
 
                el.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() {
4566
 
                        if(mode == 'hide') el.hide(); // Hide
4567
 
                        $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
4568
 
                        if(o.callback) o.callback.apply(this, arguments); // Callback
4569
 
                        el.dequeue();
4570
 
                }});
4571
 
                
4572
 
        });
4573
 
        
4574
 
};
4575
 
 
4576
 
})(jQuery);
4577
 
/*
4578
 
 * jQuery UI Effects Transfer @VERSION
4579
 
 *
4580
 
 * Copyright (c) 2008 Aaron Eisenberger (aaronchi@gmail.com)
4581
 
 * Dual licensed under the MIT (MIT-LICENSE.txt)
4582
 
 * and GPL (GPL-LICENSE.txt) licenses.
4583
 
 * 
4584
 
 * http://docs.jquery.com/UI/Effects/Transfer
4585
 
 *
4586
 
 * Depends:
4587
 
 *      effects.core.js
4588
 
 */
4589
 
(function($) {
4590
 
 
4591
 
$.effects.transfer = function(o) {
4592
 
 
4593
 
        return this.queue(function() {
4594
 
 
4595
 
                // Create element
4596
 
                var el = $(this);
4597
 
                
4598
 
                // Set options
4599
 
                var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode
4600
 
                var target = $(o.options.to); // Find Target
4601
 
                var position = el.offset();
4602
 
                var transfer = $('<div class="ui-effects-transfer"></div>').appendTo(document.body);
4603
 
                if(o.options.className) transfer.addClass(o.options.className);
4604
 
                
4605
 
                // Set target css
4606
 
                transfer.addClass(o.options.className);
4607
 
                transfer.css({
4608
 
                        top: position.top,
4609
 
                        left: position.left,
4610
 
                        height: el.outerHeight() - parseInt(transfer.css('borderTopWidth')) - parseInt(transfer.css('borderBottomWidth')),
4611
 
                        width: el.outerWidth() - parseInt(transfer.css('borderLeftWidth')) - parseInt(transfer.css('borderRightWidth')),
4612
 
                        position: 'absolute'
4613
 
                });
4614
 
                
4615
 
                // Animation
4616
 
                position = target.offset();
4617
 
                animation = {
4618
 
                        top: position.top,
4619
 
                        left: position.left,
4620
 
                        height: target.outerHeight() - parseInt(transfer.css('borderTopWidth')) - parseInt(transfer.css('borderBottomWidth')),
4621
 
                        width: target.outerWidth() - parseInt(transfer.css('borderLeftWidth')) - parseInt(transfer.css('borderRightWidth'))
4622
 
                };
4623
 
                
4624
 
                // Animate
4625
 
                transfer.animate(animation, o.duration, o.options.easing, function() {
4626
 
                        transfer.remove(); // Remove div
4627
 
                        if(o.callback) o.callback.apply(el[0], arguments); // Callback
4628
 
                        el.dequeue();
4629
 
                }); 
4630
 
                
4631
 
        });
4632
 
        
4633
 
};
4634
 
 
4635
 
})(jQuery);
4636
 
/*
4637
 
 * jQuery UI Accordion @VERSION
4638
 
 * 
4639
 
 * Copyright (c) 2007, 2008 Jörn Zaefferer
4640
 
 * Dual licensed under the MIT (MIT-LICENSE.txt)
4641
 
 * and GPL (GPL-LICENSE.txt) licenses.
4642
 
 *
4643
 
 * http://docs.jquery.com/UI/Accordion
4644
 
 *
4645
 
 * Depends:
4646
 
 *      ui.core.js
4647
 
 */
4648
 
(function($) {
4649
 
 
4650
 
$.widget("ui.accordion", {
4651
 
        _init: function() {
4652
 
                var options = this.options;
4653
 
                
4654
 
                if ( options.navigation ) {
4655
 
                        var current = this.element.find("a").filter(options.navigationFilter);
4656
 
                        if ( current.length ) {
4657
 
                                if ( current.filter(options.header).length ) {
4658
 
                                        options.active = current;
4659
 
                                } else {
4660
 
                                        options.active = current.parent().parent().prev();
4661
 
                                        current.addClass("current");
4662
 
                                }
4663
 
                        }
4664
 
                }
4665
 
                
4666
 
                // calculate active if not specified, using the first header
4667
 
                options.headers = this.element.find(options.header);
4668
 
                options.active = findActive(options.headers, options.active);
4669
 
                
4670
 
                // IE7-/Win - Extra vertical space in Lists fixed
4671
 
                if ($.browser.msie) {
4672
 
                        this.element.find('a').css('zoom', '1');
4673
 
                }
4674
 
                
4675
 
                if (!this.element.hasClass("ui-accordion")) {
4676
 
                        this.element.addClass("ui-accordion");
4677
 
                        $('<span class="ui-accordion-left"/>').insertBefore(options.headers);
4678
 
                        $('<span class="ui-accordion-right"/>').appendTo(options.headers);
4679
 
                        options.headers.addClass("ui-accordion-header").attr("tabindex", "0");
4680
 
                }
4681
 
                
4682
 
                var maxHeight;
4683
 
                if ( options.fillSpace ) {
4684
 
                        maxHeight = this.element.parent().height();
4685
 
                        options.headers.each(function() {
4686
 
                                maxHeight -= $(this).outerHeight();
4687
 
                        });
4688
 
                        var maxPadding = 0;
4689
 
                        options.headers.next().each(function() {
4690
 
                                maxPadding = Math.max(maxPadding, $(this).innerHeight() - $(this).height());
4691
 
                        }).height(maxHeight - maxPadding);
4692
 
                } else if ( options.autoHeight ) {
4693
 
                        maxHeight = 0;
4694
 
                        options.headers.next().each(function() {
4695
 
                                maxHeight = Math.max(maxHeight, $(this).outerHeight());
4696
 
                        }).height(maxHeight);
4697
 
                }
4698
 
        
4699
 
                options.headers
4700
 
                        .not(options.active || "")
4701
 
                        .next()
4702
 
                        .hide();
4703
 
                options.active.parent().andSelf().addClass(options.selectedClass);
4704
 
                
4705
 
                if (options.event) {
4706
 
                        this.element.bind((options.event) + ".accordion", clickHandler);
4707
 
                }
4708
 
        },
4709
 
        activate: function(index) {
4710
 
                // call clickHandler with custom event
4711
 
                clickHandler.call(this.element[0], {
4712
 
                        target: findActive( this.options.headers, index )[0]
4713
 
                });
4714
 
        },
4715
 
        destroy: function() {
4716
 
                this.options.headers.next().css("display", "");
4717
 
                if ( this.options.fillSpace || this.options.autoHeight ) {
4718
 
                        this.options.headers.next().css("height", "");
4719
 
                }
4720
 
                $.removeData(this.element[0], "accordion");
4721
 
                this.element.removeClass("ui-accordion").unbind(".accordion");
4722
 
        }
4723
 
});
4724
 
 
4725
 
function scopeCallback(callback, scope) {
4726
 
        return function() {
4727
 
                return callback.apply(scope, arguments);
4728
 
        };
4729
 
};
4730
 
 
4731
 
function completed(cancel) {
4732
 
        // if removed while animated data can be empty
4733
 
        if (!$.data(this, "accordion")) {
4734
 
                return;
4735
 
        }
4736
 
        
4737
 
        var instance = $.data(this, "accordion");
4738
 
        var options = instance.options;
4739
 
        options.running = cancel ? 0 : --options.running;
4740
 
        if ( options.running ) {
4741
 
                return;
4742
 
        }
4743
 
        if ( options.clearStyle ) {
4744
 
                options.toShow.add(options.toHide).css({
4745
 
                        height: "",
4746
 
                        overflow: ""
4747
 
                });
4748
 
        }
4749
 
        instance._trigger('change', null, options.data);
4750
 
}
4751
 
 
4752
 
function toggle(toShow, toHide, data, clickedActive, down) {
4753
 
        var options = $.data(this, "accordion").options;
4754
 
        options.toShow = toShow;
4755
 
        options.toHide = toHide;
4756
 
        options.data = data;
4757
 
        var complete = scopeCallback(completed, this);
4758
 
        
4759
 
        $.data(this, "accordion")._trigger("changestart", null, options.data); 
4760
 
        
4761
 
        // count elements to animate
4762
 
        options.running = toHide.size() === 0 ? toShow.size() : toHide.size();
4763
 
        
4764
 
        if ( options.animated ) {
4765
 
                if ( !options.alwaysOpen && clickedActive ) {
4766
 
                        $.ui.accordion.animations[options.animated]({
4767
 
                                toShow: jQuery([]),
4768
 
                                toHide: toHide,
4769
 
                                complete: complete,
4770
 
                                down: down,
4771
 
                                autoHeight: options.autoHeight
4772
 
                        });
4773
 
                } else {
4774
 
                        $.ui.accordion.animations[options.animated]({
4775
 
                                toShow: toShow,
4776
 
                                toHide: toHide,
4777
 
                                complete: complete,
4778
 
                                down: down,
4779
 
                                autoHeight: options.autoHeight
4780
 
                        });
4781
 
                }
4782
 
        } else {
4783
 
                if ( !options.alwaysOpen && clickedActive ) {
4784
 
                        toShow.toggle();
4785
 
                } else {
4786
 
                        toHide.hide();
4787
 
                        toShow.show();
4788
 
                }
4789
 
                complete(true);
4790
 
        }
4791
 
}
4792
 
 
4793
 
function clickHandler(event) {
4794
 
        var options = $.data(this, "accordion").options;
4795
 
        if (options.disabled) {
4796
 
                return false;
4797
 
        }
4798
 
        
4799
 
        // called only when using activate(false) to close all parts programmatically
4800
 
        if ( !event.target && !options.alwaysOpen ) {
4801
 
                options.active.parent().andSelf().toggleClass(options.selectedClass);
4802
 
                var toHide = options.active.next(),
4803
 
                        data = {
4804
 
                                options: options,
4805
 
                                newHeader: jQuery([]),
4806
 
                                oldHeader: options.active,
4807
 
                                newContent: jQuery([]),
4808
 
                                oldContent: toHide
4809
 
                        },
4810
 
                        toShow = (options.active = $([]));
4811
 
                toggle.call(this, toShow, toHide, data );
4812
 
                return false;
4813
 
        }
4814
 
        // get the click target
4815
 
        var clicked = $(event.target);
4816
 
        
4817
 
        // due to the event delegation model, we have to check if one
4818
 
        // of the parent elements is our actual header, and find that
4819
 
        // otherwise stick with the initial target
4820
 
        clicked = $( clicked.parents(options.header)[0] || clicked );
4821
 
        
4822
 
        var clickedActive = clicked[0] == options.active[0];
4823
 
        
4824
 
        // if animations are still active, or the active header is the target, ignore click
4825
 
        if (options.running || (options.alwaysOpen && clickedActive)) {
4826
 
                return false;
4827
 
        }
4828
 
        if (!clicked.is(options.header)) {
4829
 
                return;
4830
 
        }
4831
 
        
4832
 
        // switch classes
4833
 
        options.active.parent().andSelf().toggleClass(options.selectedClass);
4834
 
        if ( !clickedActive ) {
4835
 
                clicked.parent().andSelf().addClass(options.selectedClass);
4836
 
        }
4837
 
        
4838
 
        // find elements to show and hide
4839
 
        var toShow = clicked.next(),
4840
 
                toHide = options.active.next(),
4841
 
                data = {
4842
 
                        options: options,
4843
 
                        newHeader: clickedActive && !options.alwaysOpen ? $([]) : clicked,
4844
 
                        oldHeader: options.active,
4845
 
                        newContent: clickedActive && !options.alwaysOpen ? $([]) : toShow,
4846
 
                        oldContent: toHide
4847
 
                },
4848
 
                down = options.headers.index( options.active[0] ) > options.headers.index( clicked[0] );
4849
 
        
4850
 
        options.active = clickedActive ? $([]) : clicked;
4851
 
        toggle.call(this, toShow, toHide, data, clickedActive, down );
4852
 
 
4853
 
        return false;
4854
 
};
4855
 
 
4856
 
function findActive(headers, selector) {
4857
 
        return selector
4858
 
                ? typeof selector == "number"
4859
 
                        ? headers.filter(":eq(" + selector + ")")
4860
 
                        : headers.not(headers.not(selector))
4861
 
                : selector === false
4862
 
                        ? $([])
4863
 
                        : headers.filter(":eq(0)");
4864
 
}
4865
 
 
4866
 
$.extend($.ui.accordion, {
4867
 
        defaults: {
4868
 
                selectedClass: "selected",
4869
 
                alwaysOpen: true,
4870
 
                animated: 'slide',
4871
 
                event: "click",
4872
 
                header: "a",
4873
 
                autoHeight: true,
4874
 
                running: 0,
4875
 
                navigationFilter: function() {
4876
 
                        return this.href.toLowerCase() == location.href.toLowerCase();
4877
 
                }
4878
 
        },
4879
 
        animations: {
4880
 
                slide: function(options, additions) {
4881
 
                        options = $.extend({
4882
 
                                easing: "swing",
4883
 
                                duration: 300
4884
 
                        }, options, additions);
4885
 
                        if ( !options.toHide.size() ) {
4886
 
                                options.toShow.animate({height: "show"}, options);
4887
 
                                return;
4888
 
                        }
4889
 
                        var hideHeight = options.toHide.height(),
4890
 
                                showHeight = options.toShow.height(),
4891
 
                                difference = showHeight / hideHeight;
4892
 
                        options.toShow.css({ height: 0, overflow: 'hidden' }).show();
4893
 
                        options.toHide.filter(":hidden").each(options.complete).end().filter(":visible").animate({height:"hide"},{
4894
 
                                step: function(now) {
4895
 
                                        var current = (hideHeight - now) * difference;
4896
 
                                        if ($.browser.msie || $.browser.opera) {
4897
 
                                                current = Math.ceil(current);
4898
 
                                        }
4899
 
                                        options.toShow.height( current );
4900
 
                                },
4901
 
                                duration: options.duration,
4902
 
                                easing: options.easing,
4903
 
                                complete: function() {
4904
 
                                        if ( !options.autoHeight ) {
4905
 
                                                options.toShow.css("height", "auto");
4906
 
                                        }
4907
 
                                        options.complete();
4908
 
                                }
4909
 
                        });
4910
 
                },
4911
 
                bounceslide: function(options) {
4912
 
                        this.slide(options, {
4913
 
                                easing: options.down ? "bounceout" : "swing",
4914
 
                                duration: options.down ? 1000 : 200
4915
 
                        });
4916
 
                },
4917
 
                easeslide: function(options) {
4918
 
                        this.slide(options, {
4919
 
                                easing: "easeinout",
4920
 
                                duration: 700
4921
 
                        });
4922
 
                }
4923
 
        }
4924
 
});
4925
 
 
4926
 
})(jQuery);
4927
 
/*
4928
 
 * jQuery UI Autocomplete @VERSION
4929
 
 *
4930
 
 * Copyright (c) 2007, 2008 Dylan Verheul, Dan G. Switzer, Anjesh Tuladhar, Jörn Zaefferer
4931
 
 * Dual licensed under the MIT (MIT-LICENSE.txt)
4932
 
 * and GPL (GPL-LICENSE.txt) licenses.
4933
 
 * 
4934
 
 * http://docs.jquery.com/UI/Autocomplete
4935
 
 *
4936
 
 * Depends:
4937
 
 *      ui.core.js
4938
 
 */
4939
 
(function($) {
4940
 
 
4941
 
$.widget("ui.autocomplete", {
4942
 
        
4943
 
        _init: function() {
4944
 
 
4945
 
                $.extend(this.options, {
4946
 
                        delay: this.options.url ? $.Autocompleter.defaults.delay : 10,
4947
 
                        max: !this.options.scroll ? 10 : 150,
4948
 
                        highlight: this.options.highlight || function(value) { return value; }, // if highlight is set to false, replace it with a do-nothing function
4949
 
                        formatMatch: this.options.formatMatch || this.options.formatItem // if the formatMatch option is not specified, then use formatItem for backwards compatibility
4950
 
                });
4951
 
                
4952
 
                new $.Autocompleter(this.element[0], this.options);
4953
 
                
4954
 
        },
4955
 
        
4956
 
        result: function(handler) {
4957
 
                return this.element.bind("result", handler);
4958
 
        },
4959
 
        search: function(handler) {
4960
 
                return this.element.trigger("search", [handler]);
4961
 
        },
4962
 
        flushCache: function() {
4963
 
                return this.element.trigger("flushCache");
4964
 
        },
4965
 
        setData: function(key, value){
4966
 
                return this.element.trigger("setOptions", [{ key: value }]);
4967
 
        },
4968
 
        destroy: function() {
4969
 
                return this.element.trigger("unautocomplete");
4970
 
        }
4971
 
        
4972
 
});
4973
 
 
4974
 
$.Autocompleter = function(input, options) {
4975
 
 
4976
 
        var KEY = {
4977
 
                UP: 38,
4978
 
                DOWN: 40,
4979
 
                DEL: 46,
4980
 
                TAB: 9,
4981
 
                RETURN: 13,
4982
 
                ESC: 27,
4983
 
                COMMA: 188,
4984
 
                PAGEUP: 33,
4985
 
                PAGEDOWN: 34,
4986
 
                BACKSPACE: 8
4987
 
        };
4988
 
 
4989
 
        // Create $ object for input element
4990
 
        var $input = $(input).attr("autocomplete", "off").addClass(options.inputClass);
4991
 
        if(options.result) $input.bind('result.autocomplete', options.result);
4992
 
 
4993
 
        var timeout;
4994
 
        var previousValue = "";
4995
 
        var cache = $.Autocompleter.Cache(options);
4996
 
        var hasFocus = 0;
4997
 
        var lastKeyPressCode;
4998
 
        var config = {
4999
 
                mouseDownOnSelect: false
5000
 
        };
5001
 
        var select = $.Autocompleter.Select(options, input, selectCurrent, config);
5002
 
        
5003
 
        var blockSubmit;
5004
 
        
5005
 
        // prevent form submit in opera when selecting with return key
5006
 
        $.browser.opera && $(input.form).bind("submit.autocomplete", function() {
5007
 
                if (blockSubmit) {
5008
 
                        blockSubmit = false;
5009
 
                        return false;
5010
 
                }
5011
 
        });
5012
 
        
5013
 
        // only opera doesn't trigger keydown multiple times while pressed, others don't work with keypress at all
5014
 
        $input.bind(($.browser.opera ? "keypress" : "keydown") + ".autocomplete", function(event) {
5015
 
                // track last key pressed
5016
 
                lastKeyPressCode = event.keyCode;
5017
 
                switch(event.keyCode) {
5018
 
                
5019
 
                        case KEY.UP:
5020
 
                                event.preventDefault();
5021
 
                                if ( select.visible() ) {
5022
 
                                        select.prev();
5023
 
                                } else {
5024
 
                                        onChange(0, true);
5025
 
                                }
5026
 
                                break;
5027
 
                                
5028
 
                        case KEY.DOWN:
5029
 
                                event.preventDefault();
5030
 
                                if ( select.visible() ) {
5031
 
                                        select.next();
5032
 
                                } else {
5033
 
                                        onChange(0, true);
5034
 
                                }
5035
 
                                break;
5036
 
                                
5037
 
                        case KEY.PAGEUP:
5038
 
                                event.preventDefault();
5039
 
                                if ( select.visible() ) {
5040
 
                                        select.pageUp();
5041
 
                                } else {
5042
 
                                        onChange(0, true);
5043
 
                                }
5044
 
                                break;
5045
 
                                
5046
 
                        case KEY.PAGEDOWN:
5047
 
                                event.preventDefault();
5048
 
                                if ( select.visible() ) {
5049
 
                                        select.pageDown();
5050
 
                                } else {
5051
 
                                        onChange(0, true);
5052
 
                                }
5053
 
                                break;
5054
 
                        
5055
 
                        // matches also semicolon
5056
 
                        case options.multiple && $.trim(options.multipleSeparator) == "," && KEY.COMMA:
5057
 
                        case KEY.TAB:
5058
 
                        case KEY.RETURN:
5059
 
                                if( selectCurrent() ) {
5060
 
                                        // stop default to prevent a form submit, Opera needs special handling
5061
 
                                        event.preventDefault();
5062
 
                                        blockSubmit = true;
5063
 
                                        return false;
5064
 
                                }
5065
 
                                break;
5066
 
                                
5067
 
                        case KEY.ESC:
5068
 
                                select.hide();
5069
 
                                break;
5070
 
                                
5071
 
                        default:
5072
 
                                clearTimeout(timeout);
5073
 
                                timeout = setTimeout(onChange, options.delay);
5074
 
                                break;
5075
 
                }
5076
 
        }).focus(function(){
5077
 
                // track whether the field has focus, we shouldn't process any
5078
 
                // results if the field no longer has focus
5079
 
                hasFocus++;
5080
 
        }).blur(function() {
5081
 
                hasFocus = 0;
5082
 
                if (!config.mouseDownOnSelect) {
5083
 
                        hideResults();
5084
 
                }
5085
 
        }).click(function() {
5086
 
                // show select when clicking in a focused field
5087
 
                if ( hasFocus++ > 1 && !select.visible() ) {
5088
 
                        onChange(0, true);
5089
 
                }
5090
 
        }).bind("search", function() {
5091
 
                // TODO why not just specifying both arguments?
5092
 
                var fn = (arguments.length > 1) ? arguments[1] : null;
5093
 
                function findValueCallback(q, data) {
5094
 
                        var result;
5095
 
                        if( data && data.length ) {
5096
 
                                for (var i=0; i < data.length; i++) {
5097
 
                                        if( data[i].result.toLowerCase() == q.toLowerCase() ) {
5098
 
                                                result = data[i];
5099
 
                                                break;
5100
 
                                        }
5101
 
                                }
5102
 
                        }
5103
 
                        if( typeof fn == "function" ) fn(result);
5104
 
                        else $input.trigger("result", result && [result.data, result.value]);
5105
 
                }
5106
 
                $.each(trimWords($input.val()), function(i, value) {
5107
 
                        request(value, findValueCallback, findValueCallback);
5108
 
                });
5109
 
        }).bind("flushCache", function() {
5110
 
                cache.flush();
5111
 
        }).bind("setOptions", function() {
5112
 
                $.extend(options, arguments[1]);
5113
 
                // if we've updated the data, repopulate
5114
 
                if ( "data" in arguments[1] )
5115
 
                        cache.populate();
5116
 
        }).bind("unautocomplete", function() {
5117
 
                select.unbind();
5118
 
                $input.unbind();
5119
 
                $(input.form).unbind(".autocomplete");
5120
 
        });
5121
 
        
5122
 
        
5123
 
        function selectCurrent() {
5124
 
                var selected = select.selected();
5125
 
                if( !selected )
5126
 
                        return false;
5127
 
                
5128
 
                var v = selected.result;
5129
 
                previousValue = v;
5130
 
                
5131
 
                if ( options.multiple ) {
5132
 
                        var words = trimWords($input.val());
5133
 
                        if ( words.length > 1 ) {
5134
 
                                v = words.slice(0, words.length - 1).join( options.multipleSeparator ) + options.multipleSeparator + v;
5135
 
                        }
5136
 
                        v += options.multipleSeparator;
5137
 
                }
5138
 
                
5139
 
                $input.val(v);
5140
 
                hideResultsNow();
5141
 
                $input.trigger("result", [selected.data, selected.value]);
5142
 
                return true;
5143
 
        }
5144
 
        
5145
 
        function onChange(crap, skipPrevCheck) {
5146
 
                if( lastKeyPressCode == KEY.DEL ) {
5147
 
                        select.hide();
5148
 
                        return;
5149
 
                }
5150
 
                
5151
 
                var currentValue = $input.val();
5152
 
                
5153
 
                if ( !skipPrevCheck && currentValue == previousValue )
5154
 
                        return;
5155
 
                
5156
 
                previousValue = currentValue;
5157
 
                
5158
 
                currentValue = lastWord(currentValue);
5159
 
                if ( currentValue.length >= options.minChars) {
5160
 
                        $input.addClass(options.loadingClass);
5161
 
                        if (!options.matchCase)
5162
 
                                currentValue = currentValue.toLowerCase();
5163
 
                        request(currentValue, receiveData, hideResultsNow);
5164
 
                } else {
5165
 
                        stopLoading();
5166
 
                        select.hide();
5167
 
                }
5168
 
        };
5169
 
        
5170
 
        function trimWords(value) {
5171
 
                if ( !value ) {
5172
 
                        return [""];
5173
 
                }
5174
 
                var words = value.split( options.multipleSeparator );
5175
 
                var result = [];
5176
 
                $.each(words, function(i, value) {
5177
 
                        if ( $.trim(value) )
5178
 
                                result[i] = $.trim(value);
5179
 
                });
5180
 
                return result;
5181
 
        }
5182
 
        
5183
 
        function lastWord(value) {
5184
 
                if ( !options.multiple )
5185
 
                        return value;
5186
 
                var words = trimWords(value);
5187
 
                return words[words.length - 1];
5188
 
        }
5189
 
        
5190
 
        // fills in the input box w/the first match (assumed to be the best match)
5191
 
        // q: the term entered
5192
 
        // sValue: the first matching result
5193
 
        function autoFill(q, sValue){
5194
 
                // autofill in the complete box w/the first match as long as the user hasn't entered in more data
5195
 
                // if the last user key pressed was backspace, don't autofill
5196
 
                if( options.autoFill && (lastWord($input.val()).toLowerCase() == q.toLowerCase()) && lastKeyPressCode != KEY.BACKSPACE ) {
5197
 
                        // fill in the value (keep the case the user has typed)
5198
 
                        $input.val($input.val() + sValue.substring(lastWord(previousValue).length));
5199
 
                        // select the portion of the value not typed by the user (so the next character will erase)
5200
 
                        $.Autocompleter.Selection(input, previousValue.length, previousValue.length + sValue.length);
5201
 
                }
5202
 
        };
5203
 
 
5204
 
        function hideResults() {
5205
 
                clearTimeout(timeout);
5206
 
                timeout = setTimeout(hideResultsNow, 200);
5207
 
        };
5208
 
 
5209
 
        function hideResultsNow() {
5210
 
                var wasVisible = select.visible();
5211
 
                select.hide();
5212
 
                clearTimeout(timeout);
5213
 
                stopLoading();
5214
 
                if (options.mustMatch) {
5215
 
                        // call search and run callback
5216
 
                        $input.autocomplete("search", function (result){
5217
 
                                        // if no value found, clear the input box
5218
 
                                        if( !result ) {
5219
 
                                                if (options.multiple) {
5220
 
                                                        var words = trimWords($input.val()).slice(0, -1);
5221
 
                                                        $input.val( words.join(options.multipleSeparator) + (words.length ? options.multipleSeparator : "") );
5222
 
                                                }
5223
 
                                                else
5224
 
                                                        $input.val( "" );
5225
 
                                        }
5226
 
                                }
5227
 
                        );
5228
 
                }
5229
 
                if (wasVisible)
5230
 
                        // position cursor at end of input field
5231
 
                        $.Autocompleter.Selection(input, input.value.length, input.value.length);
5232
 
        };
5233
 
 
5234
 
        function receiveData(q, data) {
5235
 
                if ( data && data.length && hasFocus ) {
5236
 
                        stopLoading();
5237
 
                        select.display(data, q);
5238
 
                        autoFill(q, data[0].value);
5239
 
                        select.show();
5240
 
                } else {
5241
 
                        hideResultsNow();
5242
 
                }
5243
 
        };
5244
 
 
5245
 
        function request(term, success, failure) {
5246
 
                if (!options.matchCase)
5247
 
                        term = term.toLowerCase();
5248
 
                var data = cache.load(term);
5249
 
                // recieve the cached data
5250
 
                if (data && data.length) {
5251
 
                        success(term, data);
5252
 
                // if an AJAX url has been supplied, try loading the data now
5253
 
                
5254
 
                } else if( (typeof options.url == "string") && (options.url.length > 0) ){
5255
 
                        
5256
 
                        var extraParams = {
5257
 
                                timestamp: +new Date()
5258
 
                        };
5259
 
                        $.each(options.extraParams, function(key, param) {
5260
 
                                extraParams[key] = typeof param == "function" ? param() : param;
5261
 
                        });
5262
 
                        
5263
 
                        $.ajax({
5264
 
                                // try to leverage ajaxQueue plugin to abort previous requests
5265
 
                                mode: "abort",
5266
 
                                // limit abortion to this input
5267
 
                                port: "autocomplete" + input.name,
5268
 
                                dataType: options.dataType,
5269
 
                                url: options.url,
5270
 
                                data: $.extend({
5271
 
                                        q: lastWord(term),
5272
 
                                        limit: options.max
5273
 
                                }, extraParams),
5274
 
                                success: function(data) {
5275
 
                                        var parsed = options.parse && options.parse(data) || parse(data);
5276
 
                                        cache.add(term, parsed);
5277
 
                                        success(term, parsed);
5278
 
                                }
5279
 
                        });
5280
 
                }
5281
 
 
5282
 
                else if (options.source && typeof options.source == 'function') {
5283
 
                        var resultData = options.source(term);
5284
 
                        var parsed = (options.parse) ? options.parse(resultData) : resultData;
5285
 
 
5286
 
                        cache.add(term, parsed);
5287
 
                        success(term, parsed);
5288
 
                } else {
5289
 
                        // if we have a failure, we need to empty the list -- this prevents the the [TAB] key from selecting the last successful match
5290
 
                        select.emptyList();
5291
 
                        failure(term);
5292
 
                }
5293
 
        };
5294
 
        
5295
 
        function parse(data) {
5296
 
                var parsed = [];
5297
 
                var rows = data.split("\n");
5298
 
                for (var i=0; i < rows.length; i++) {
5299
 
                        var row = $.trim(rows[i]);
5300
 
                        if (row) {
5301
 
                                row = row.split("|");
5302
 
                                parsed[parsed.length] = {
5303
 
                                        data: row,
5304
 
                                        value: row[0],
5305
 
                                        result: options.formatResult && options.formatResult(row, row[0]) || row[0]
5306
 
                                };
5307
 
                        }
5308
 
                }
5309
 
                return parsed;
5310
 
        };
5311
 
 
5312
 
        function stopLoading() {
5313
 
                $input.removeClass(options.loadingClass);
5314
 
        };
5315
 
 
5316
 
};
5317
 
 
5318
 
$.Autocompleter.defaults = {
5319
 
        inputClass: "ui-autocomplete-input",
5320
 
        resultsClass: "ui-autocomplete-results",
5321
 
        loadingClass: "ui-autocomplete-loading",
5322
 
        minChars: 1,
5323
 
        delay: 400,
5324
 
        matchCase: false,
5325
 
        matchSubset: true,
5326
 
        matchContains: false,
5327
 
        cacheLength: 10,
5328
 
        max: 100,
5329
 
        mustMatch: false,
5330
 
        extraParams: {},
5331
 
        selectFirst: true,
5332
 
        formatItem: function(row) { return row[0]; },
5333
 
        formatMatch: null,
5334
 
        autoFill: false,
5335
 
        width: 0,
5336
 
        multiple: false,
5337
 
        multipleSeparator: ", ",
5338
 
        highlight: function(value, term) {
5339
 
                return value.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + term.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi, "\\$1") + ")(?![^<>]*>)(?![^&;]+;)", "gi"), "<strong>$1</strong>");
5340
 
        },
5341
 
    scroll: true,
5342
 
    scrollHeight: 180
5343
 
};
5344
 
 
5345
 
$.extend($.ui.autocomplete, {
5346
 
        defaults: $.Autocompleter.defaults
5347
 
});
5348
 
 
5349
 
$.Autocompleter.Cache = function(options) {
5350
 
 
5351
 
        var data = {};
5352
 
        var length = 0;
5353
 
        
5354
 
        function matchSubset(s, sub) {
5355
 
                if (!options.matchCase) 
5356
 
                        s = s.toLowerCase();
5357
 
                var i = s.indexOf(sub);
5358
 
                if (i == -1) return false;
5359
 
                return i == 0 || options.matchContains;
5360
 
        };
5361
 
        
5362
 
        function add(q, value) {
5363
 
                if (length > options.cacheLength){
5364
 
                        flush();
5365
 
                }
5366
 
                if (!data[q]){ 
5367
 
                        length++;
5368
 
                }
5369
 
                data[q] = value;
5370
 
        }
5371
 
        
5372
 
        function populate(){
5373
 
                if( !options.data ) return false;
5374
 
                // track the matches
5375
 
                var stMatchSets = {},
5376
 
                        nullData = 0;
5377
 
 
5378
 
                // no url was specified, we need to adjust the cache length to make sure it fits the local data store
5379
 
                if( !options.url ) options.cacheLength = 1;
5380
 
                
5381
 
                // track all options for minChars = 0
5382
 
                stMatchSets[""] = [];
5383
 
                
5384
 
                // loop through the array and create a lookup structure
5385
 
                for ( var i = 0, ol = options.data.length; i < ol; i++ ) {
5386
 
                        var rawValue = options.data[i];
5387
 
                        // if rawValue is a string, make an array otherwise just reference the array
5388
 
                        rawValue = (typeof rawValue == "string") ? [rawValue] : rawValue;
5389
 
                        
5390
 
                        var value = options.formatMatch(rawValue, i+1, options.data.length);
5391
 
                        if ( value === false )
5392
 
                                continue;
5393
 
                                
5394
 
                        var firstChar = value.charAt(0).toLowerCase();
5395
 
                        // if no lookup array for this character exists, look it up now
5396
 
                        if( !stMatchSets[firstChar] ) 
5397
 
                                stMatchSets[firstChar] = [];
5398
 
 
5399
 
                        // if the match is a string
5400
 
                        var row = {
5401
 
                                value: value,
5402
 
                                data: rawValue,
5403
 
                                result: options.formatResult && options.formatResult(rawValue) || value
5404
 
                        };
5405
 
                        
5406
 
                        // push the current match into the set list
5407
 
                        stMatchSets[firstChar].push(row);
5408
 
 
5409
 
                        // keep track of minChars zero items
5410
 
                        if ( nullData++ < options.max ) {
5411
 
                                stMatchSets[""].push(row);
5412
 
                        }
5413
 
                };
5414
 
 
5415
 
                // add the data items to the cache
5416
 
                $.each(stMatchSets, function(i, value) {
5417
 
                        // increase the cache size
5418
 
                        options.cacheLength++;
5419
 
                        // add to the cache
5420
 
                        add(i, value);
5421
 
                });
5422
 
        }
5423
 
        
5424
 
        // populate any existing data
5425
 
        setTimeout(populate, 25);
5426
 
        
5427
 
        function flush(){
5428
 
                data = {};
5429
 
                length = 0;
5430
 
        }
5431
 
        
5432
 
        return {
5433
 
                flush: flush,
5434
 
                add: add,
5435
 
                populate: populate,
5436
 
                load: function(q) {
5437
 
                        if (!options.cacheLength || !length)
5438
 
                                return null;
5439
 
                        /* 
5440
 
                         * if dealing w/local data and matchContains than we must make sure
5441
 
                         * to loop through all the data collections looking for matches
5442
 
                         */
5443
 
                        if( !options.url && options.matchContains ){
5444
 
                                // track all matches
5445
 
                                var csub = [];
5446
 
                                // loop through all the data grids for matches
5447
 
                                for( var k in data ){
5448
 
                                        // don't search through the stMatchSets[""] (minChars: 0) cache
5449
 
                                        // this prevents duplicates
5450
 
                                        if( k.length > 0 ){
5451
 
                                                var c = data[k];
5452
 
                                                $.each(c, function(i, x) {
5453
 
                                                        // if we've got a match, add it to the array
5454
 
                                                        if (matchSubset(x.value, q)) {
5455
 
                                                                csub.push(x);
5456
 
                                                        }
5457
 
                                                });
5458
 
                                        }
5459
 
                                }                               
5460
 
                                return csub;
5461
 
                        } else 
5462
 
                        // if the exact item exists, use it
5463
 
                        if (data[q]){
5464
 
                                return data[q];
5465
 
                        } else
5466
 
                        if (options.matchSubset) {
5467
 
                                for (var i = q.length - 1; i >= options.minChars; i--) {
5468
 
                                        var c = data[q.substr(0, i)];
5469
 
                                        if (c) {
5470
 
                                                var csub = [];
5471
 
                                                $.each(c, function(i, x) {
5472
 
                                                        if (matchSubset(x.value, q)) {
5473
 
                                                                csub[csub.length] = x;
5474
 
                                                        }
5475
 
                                                });
5476
 
                                                return csub;
5477
 
                                        }
5478
 
                                }
5479
 
                        }
5480
 
                        return null;
5481
 
                }
5482
 
        };
5483
 
};
5484
 
 
5485
 
$.Autocompleter.Select = function (options, input, select, config) {
5486
 
        var CLASSES = {
5487
 
                ACTIVE: "ui-autocomplete-over"
5488
 
        };
5489
 
        
5490
 
        var listItems,
5491
 
                active = -1,
5492
 
                data,
5493
 
                term = "",
5494
 
                needsInit = true,
5495
 
                element,
5496
 
                list;
5497
 
        
5498
 
        // Create results
5499
 
        function init() {
5500
 
                if (!needsInit)
5501
 
                        return;
5502
 
                element = $("<div/>")
5503
 
                .hide()
5504
 
                .addClass(options.resultsClass)
5505
 
                .css("position", "absolute")
5506
 
                .appendTo(document.body);
5507
 
        
5508
 
                list = $("<ul/>").appendTo(element).mouseover( function(event) {
5509
 
                        if(target(event).nodeName && target(event).nodeName.toUpperCase() == 'LI') {
5510
 
                    active = $("li", list).removeClass(CLASSES.ACTIVE).index(target(event));
5511
 
                            $(target(event)).addClass(CLASSES.ACTIVE);            
5512
 
                }
5513
 
                }).click(function(event) {
5514
 
                        $(target(event)).addClass(CLASSES.ACTIVE);
5515
 
                        select();
5516
 
                        // TODO provide option to avoid setting focus again after selection? useful for cleanup-on-focus
5517
 
                        input.focus();
5518
 
                        return false;
5519
 
                }).mousedown(function() {
5520
 
                        config.mouseDownOnSelect = true;
5521
 
                }).mouseup(function() {
5522
 
                        config.mouseDownOnSelect = false;
5523
 
                });
5524
 
                
5525
 
                if( options.width > 0 )
5526
 
                        element.css("width", options.width);
5527
 
                        
5528
 
                needsInit = false;
5529
 
        } 
5530
 
        
5531
 
        function target(event) {
5532
 
                var element = event.target;
5533
 
                while(element && element.tagName != "LI")
5534
 
                        element = element.parentNode;
5535
 
                // more fun with IE, sometimes event.target is empty, just ignore it then
5536
 
                if(!element)
5537
 
                        return [];
5538
 
                return element;
5539
 
        }
5540
 
 
5541
 
        function moveSelect(step) {
5542
 
                listItems.slice(active, active + 1).removeClass(CLASSES.ACTIVE);
5543
 
                movePosition(step);
5544
 
        var activeItem = listItems.slice(active, active + 1).addClass(CLASSES.ACTIVE);
5545
 
        if(options.scroll) {
5546
 
            var offset = 0;
5547
 
            listItems.slice(0, active).each(function() {
5548
 
                                offset += this.offsetHeight;
5549
 
                        });
5550
 
            if((offset + activeItem[0].offsetHeight - list.scrollTop()) > list[0].clientHeight) {
5551
 
                list.scrollTop(offset + activeItem[0].offsetHeight - list.innerHeight());
5552
 
            } else if(offset < list.scrollTop()) {
5553
 
                list.scrollTop(offset);
5554
 
            }
5555
 
        }
5556
 
        };
5557
 
        
5558
 
        function movePosition(step) {
5559
 
                active += step;
5560
 
                if (active < 0) {
5561
 
                        active = listItems.size() - 1;
5562
 
                } else if (active >= listItems.size()) {
5563
 
                        active = 0;
5564
 
                }
5565
 
        }
5566
 
        
5567
 
        function limitNumberOfItems(available) {
5568
 
                return options.max && options.max < available
5569
 
                        ? options.max
5570
 
                        : available;
5571
 
        }
5572
 
        
5573
 
        function fillList() {
5574
 
                list.empty();
5575
 
                var max = limitNumberOfItems(data.length);
5576
 
                for (var i=0; i < max; i++) {
5577
 
                        if (!data[i])
5578
 
                                continue;
5579
 
                        var formatted = options.formatItem(data[i].data, i+1, max, data[i].value, term);
5580
 
                        if ( formatted === false )
5581
 
                                continue;
5582
 
                        var li = $("<li/>").html( options.highlight(formatted, term) ).addClass(i%2 == 0 ? "ui-autocomplete-even" : "ui-autocomplete-odd").appendTo(list)[0];
5583
 
                        $.data(li, "ui-autocomplete-data", data[i]);
5584
 
                }
5585
 
                listItems = list.find("li");
5586
 
                if ( options.selectFirst ) {
5587
 
                        listItems.slice(0, 1).addClass(CLASSES.ACTIVE);
5588
 
                        active = 0;
5589
 
                }
5590
 
                // apply bgiframe if available
5591
 
                if ( $.fn.bgiframe )
5592
 
                        list.bgiframe();
5593
 
        }
5594
 
        
5595
 
        return {
5596
 
                display: function(d, q) {
5597
 
                        init();
5598
 
                        data = d;
5599
 
                        term = q;
5600
 
                        fillList();
5601
 
                },
5602
 
                next: function() {
5603
 
                        moveSelect(1);
5604
 
                },
5605
 
                prev: function() {
5606
 
                        moveSelect(-1);
5607
 
                },
5608
 
                pageUp: function() {
5609
 
                        if (active != 0 && active - 8 < 0) {
5610
 
                                moveSelect( -active );
5611
 
                        } else {
5612
 
                                moveSelect(-8);
5613
 
                        }
5614
 
                },
5615
 
                pageDown: function() {
5616
 
                        if (active != listItems.size() - 1 && active + 8 > listItems.size()) {
5617
 
                                moveSelect( listItems.size() - 1 - active );
5618
 
                        } else {
5619
 
                                moveSelect(8);
5620
 
                        }
5621
 
                },
5622
 
                hide: function() {
5623
 
                        element && element.hide();
5624
 
                        listItems && listItems.removeClass(CLASSES.ACTIVE)
5625
 
                        active = -1;
5626
 
                        $(input).triggerHandler("autocompletehide", [{}, { options: options }], options["hide"]);
5627
 
                },
5628
 
                visible : function() {
5629
 
                        return element && element.is(":visible");
5630
 
                },
5631
 
                current: function() {
5632
 
                        return this.visible() && (listItems.filter("." + CLASSES.ACTIVE)[0] || options.selectFirst && listItems[0]);
5633
 
                },
5634
 
                show: function() {
5635
 
                        var offset = $(input).offset();
5636
 
                        element.css({
5637
 
                                width: typeof options.width == "string" || options.width > 0 ? options.width : $(input).width(),
5638
 
                                top: offset.top + input.offsetHeight,
5639
 
                                left: offset.left
5640
 
                        }).show();
5641
 
                        
5642
 
            if(options.scroll) {
5643
 
                list.scrollTop(0);
5644
 
                list.css({
5645
 
                                        maxHeight: options.scrollHeight,
5646
 
                                        overflow: 'auto'
5647
 
                                });
5648
 
                                
5649
 
                if($.browser.msie && typeof document.body.style.maxHeight === "undefined") {
5650
 
                                        var listHeight = 0;
5651
 
                                        listItems.each(function() {
5652
 
                                                listHeight += this.offsetHeight;
5653
 
                                        });
5654
 
                                        var scrollbarsVisible = listHeight > options.scrollHeight;
5655
 
                    list.css('height', scrollbarsVisible ? options.scrollHeight : listHeight );
5656
 
                                        if (!scrollbarsVisible) {
5657
 
                                                // IE doesn't recalculate width when scrollbar disappears
5658
 
                                                listItems.width( list.width() - parseInt(listItems.css("padding-left")) - parseInt(listItems.css("padding-right")) );
5659
 
                                        }
5660
 
                }
5661
 
                
5662
 
            }
5663
 
            
5664
 
            $(input).triggerHandler("autocompleteshow", [{}, { options: options }], options["show"]);
5665
 
            
5666
 
                },
5667
 
                selected: function() {
5668
 
                        var selected = listItems && listItems.filter("." + CLASSES.ACTIVE).removeClass(CLASSES.ACTIVE);
5669
 
                        return selected && selected.length && $.data(selected[0], "ui-autocomplete-data");
5670
 
                },
5671
 
                emptyList: function (){
5672
 
                        list && list.empty();
5673
 
                },
5674
 
                unbind: function() {
5675
 
                        element && element.remove();
5676
 
                }
5677
 
        };
5678
 
};
5679
 
 
5680
 
$.Autocompleter.Selection = function(field, start, end) {
5681
 
        if( field.createTextRange ){
5682
 
                var selRange = field.createTextRange();
5683
 
                selRange.collapse(true);
5684
 
                selRange.moveStart("character", start);
5685
 
                selRange.moveEnd("character", end);
5686
 
                selRange.select();
5687
 
        } else if( field.setSelectionRange ){
5688
 
                field.setSelectionRange(start, end);
5689
 
        } else {
5690
 
                if( field.selectionStart ){
5691
 
                        field.selectionStart = start;
5692
 
                        field.selectionEnd = end;
5693
 
                }
5694
 
        }
5695
 
        field.focus();
5696
 
};
5697
 
 
5698
 
})(jQuery);
5699
 
/*
5700
 
 * jQuery UI Color Picker @VERSION
5701
 
 *
5702
 
 * Copyright (c) 2008 Stefan Petre, Paul Bakaus
5703
 
 * Dual licensed under the MIT (MIT-LICENSE.txt)
5704
 
 * and GPL (GPL-LICENSE.txt) licenses.
5705
 
 *
5706
 
 * http://docs.jquery.com/UI/ColorPicker
5707
 
 *
5708
 
 * Depends:
5709
 
 *      ui.core.js
5710
 
 */
5711
 
(function ($) {
5712
 
 
5713
 
$.widget("ui.colorpicker", {
5714
 
 
5715
 
        _init: function() {
5716
 
 
5717
 
                this.charMin = 65;
5718
 
                var o = this.options, self = this,
5719
 
                tpl = '<div class="ui-colorpicker clearfix"><div class="ui-colorpicker-color"><div><div></div></div></div><div class="ui-colorpicker-hue"><div></div></div><div class="ui-colorpicker-new-color"></div><div class="ui-colorpicker-current-color"></div><div class="ui-colorpicker-hex"><label for="ui-colorpicker-hex" title="hex"></label><input type="text" maxlength="6" size="6" /></div><div class="ui-colorpicker-rgb-r ui-colorpicker-field"><label for="ui-colorpicker-rgb-r"></label><input type="text" maxlength="3" size="2" /><span></span></div><div class="ui-colorpicker-rgb-g ui-colorpicker-field"><label for="ui-colorpicker-rgb-g"></label><input type="text" maxlength="3" size="2" /><span></span></div><div class="ui-colorpicker-rgb-b ui-colorpicker-field"><label for="ui-colorpicker-rgb-b"</label><input type="text" maxlength="3" size="2" /><span></span></div><div class="ui-colorpicker-hsb-h ui-colorpicker-field"><label for="ui-colorpicker-hsb-h"></label><input type="text" maxlength="3" size="2" /><span></span></div><div class="ui-colorpicker-hsb-s ui-colorpicker-field"><label for="ui-colorpicker-hsb-s"></label><input type="text" maxlength="3" size="2" /><span></span></div><div class="ui-colorpicker-hsb-b ui-colorpicker-field"><label for="ui-colorpicker-hsb-b"></label><input type="text" maxlength="3" size="2" /><span></span></div><button class="ui-colorpicker-submit ui-default-state" name="submit" type="button">Done</button></div>';
5720
 
 
5721
 
                if (typeof o.color == 'string') {
5722
 
                        this.color = this._HexToHSB(o.color);
5723
 
                } else if (o.color.r != undefined && o.color.g != undefined && o.color.b != undefined) {
5724
 
                        this.color = this._RGBToHSB(o.color);
5725
 
                } else if (o.color.h != undefined && o.color.s != undefined && o.color.b != undefined) {
5726
 
                        this.color = this._fixHSB(o.color);
5727
 
                } else {
5728
 
                        return this;
5729
 
                }
5730
 
 
5731
 
                this.origColor = this.color;
5732
 
                this.picker = $(tpl);
5733
 
 
5734
 
                if (o.flat) {
5735
 
                        this.picker.appendTo(this.element).show();
5736
 
                } else {
5737
 
                        this.picker.appendTo(document.body);
5738
 
                }
5739
 
 
5740
 
                this.fields = this.picker.find('input')
5741
 
                                                .bind('keydown', function(e) { return self._keyDown.call(self, e); })
5742
 
                                                .bind('change', function(e) { return self._change.call(self, e); })
5743
 
                                                .bind('blur', function(e) { return self._blur.call(self, e); })
5744
 
                                                .bind('focus', function(e) { return self._focus.call(self, e); });
5745
 
 
5746
 
                this.picker.find('span').bind('mousedown', function(e) { return self._downIncrement.call(self, e); });
5747
 
 
5748
 
                this.selector = this.picker.find('div.ui-colorpicker-color').bind('mousedown', function(e) { return self._downSelector.call(self, e); });
5749
 
                this.selectorIndic = this.selector.find('div div');
5750
 
                this.hue = this.picker.find('div.ui-colorpicker-hue div');
5751
 
                this.picker.find('div.ui-colorpicker-hue').bind('mousedown', function(e) { return self._downHue.call(self, e); });
5752
 
 
5753
 
                this.newColor = this.picker.find('div.ui-colorpicker-new-color');
5754
 
                this.currentColor = this.picker.find('div.ui-colorpicker-current-color');
5755
 
 
5756
 
                this.picker.find('.ui-colorpicker-submit')
5757
 
                        .bind('mouseenter', function(e) { return self._enterSubmit.call(self, e); })
5758
 
                        .bind('mouseleave', function(e) { return self._leaveSubmit.call(self, e); })
5759
 
                        .bind('click', function(e) { return self._clickSubmit.call(self, e); });
5760
 
 
5761
 
                this._fillRGBFields(this.color);
5762
 
                this._fillHSBFields(this.color);
5763
 
                this._fillHexFields(this.color);
5764
 
                this._setHue(this.color);
5765
 
                this._setSelector(this.color);
5766
 
                this._setCurrentColor(this.color);
5767
 
                this._setNewColor(this.color);
5768
 
 
5769
 
                if (o.flat) {
5770
 
                        this.picker.css({
5771
 
                                position: 'relative',
5772
 
                                display: 'block'
5773
 
                        });
5774
 
                } else {
5775
 
                        $(this.element).bind(o.eventName+".colorpicker", function(e) { return self._show.call(self, e); });
5776
 
                }
5777
 
 
5778
 
        },
5779
 
 
5780
 
        destroy: function() {
5781
 
 
5782
 
                this.picker.remove();
5783
 
                this.element.removeData("colorpicker").unbind(".colorpicker");
5784
 
 
5785
 
        },
5786
 
 
5787
 
        _fillRGBFields: function(hsb) {
5788
 
                var rgb = this._HSBToRGB(hsb);
5789
 
                this.fields
5790
 
                        .eq(1).val(rgb.r).end()
5791
 
                        .eq(2).val(rgb.g).end()
5792
 
                        .eq(3).val(rgb.b).end();
5793
 
        },
5794
 
        _fillHSBFields: function(hsb) {
5795
 
                this.fields
5796
 
                        .eq(4).val(hsb.h).end()
5797
 
                        .eq(5).val(hsb.s).end()
5798
 
                        .eq(6).val(hsb.b).end();
5799
 
        },
5800
 
        _fillHexFields: function (hsb) {
5801
 
                this.fields
5802
 
                        .eq(0).val(this._HSBToHex(hsb)).end();
5803
 
        },
5804
 
        _setSelector: function(hsb) {
5805
 
                this.selector.css('backgroundColor', '#' + this._HSBToHex({h: hsb.h, s: 100, b: 100}));
5806
 
                this.selectorIndic.css({
5807
 
                        left: parseInt(150 * hsb.s/100, 10),
5808
 
                        top: parseInt(150 * (100-hsb.b)/100, 10)
5809
 
                });
5810
 
        },
5811
 
        _setHue: function(hsb) {
5812
 
                this.hue.css('top', parseInt(150 - 150 * hsb.h/360, 10));
5813
 
        },
5814
 
        _setCurrentColor: function(hsb) {
5815
 
                this.currentColor.css('backgroundColor', '#' + this._HSBToHex(hsb));
5816
 
        },
5817
 
        _setNewColor: function(hsb) {
5818
 
                this.newColor.css('backgroundColor', '#' + this._HSBToHex(hsb));
5819
 
        },
5820
 
        _keyDown: function(e) {
5821
 
                var pressedKey = e.charCode || e.keyCode || -1;
5822
 
                if ((pressedKey >= this.charMin && pressedKey <= 90) || pressedKey == 32) {
5823
 
                        return false;
5824
 
                }
5825
 
        },
5826
 
        _change: function(e, target) {
5827
 
 
5828
 
                var col;
5829
 
                target = target || e.target;
5830
 
                if (target.parentNode.className.indexOf('-hex') > 0) {
5831
 
                        this.color = col = this._HexToHSB(this.value);
5832
 
                        this._fillRGBFields(col.color);
5833
 
                        this._fillHSBFields(col);
5834
 
                } else if (target.parentNode.className.indexOf('-hsb') > 0) {
5835
 
                        this.color = col = this._fixHSB({
5836
 
                                h: parseInt(this.fields.eq(4).val(), 10),
5837
 
                                s: parseInt(this.fields.eq(5).val(), 10),
5838
 
                                b: parseInt(this.fields.eq(6).val(), 10)
5839
 
                        });
5840
 
                        this._fillRGBFields(col);
5841
 
                        this._fillHexFields(col);
5842
 
                } else {
5843
 
                        this.color = col = this._RGBToHSB(this._fixRGB({
5844
 
                                r: parseInt(this.fields.eq(1).val(), 10),
5845
 
                                g: parseInt(this.fields.eq(2).val(), 10),
5846
 
                                b: parseInt(this.fields.eq(3).val(), 10)
5847
 
                        }));
5848
 
                        this._fillHexFields(col);
5849
 
                        this._fillHSBFields(col);
5850
 
                }
5851
 
                this._setSelector(col);
5852
 
                this._setHue(col);
5853
 
                this._setNewColor(col);
5854
 
 
5855
 
                this._trigger('change', e, { options: this.options, hsb: col, hex: this._HSBToHex(col), rgb: this._HSBToRGB(col) });
5856
 
        },
5857
 
        _blur: function(e) {
5858
 
 
5859
 
                var col = this.color;
5860
 
                this._fillRGBFields(col);
5861
 
                this._fillHSBFields(col);
5862
 
                this._fillHexFields(col);
5863
 
                this._setHue(col);
5864
 
                this._setSelector(col);
5865
 
                this._setNewColor(col);
5866
 
                this.fields.parent().removeClass('ui-colorpicker-focus');
5867
 
 
5868
 
        },
5869
 
        _focus: function(e) {
5870
 
 
5871
 
                this.charMin = e.target.parentNode.className.indexOf('-hex') > 0 ? 70 : 65;
5872
 
                this.fields.parent().removeClass('ui-colorpicker-focus');
5873
 
                $(e.target.parentNode).addClass('ui-colorpicker-focus');
5874
 
 
5875
 
        },
5876
 
        _downIncrement: function(e) {
5877
 
 
5878
 
                var field = $(e.target).parent().find('input').focus(), self = this;
5879
 
                this.currentIncrement = {
5880
 
                        el: $(e.target).parent().addClass('ui-colorpicker-slider'),
5881
 
                        max: e.target.parentNode.className.indexOf('-hsb-h') > 0 ? 360 : (e.target.parentNode.className.indexOf('-hsb') > 0 ? 100 : 255),
5882
 
                        y: e.pageY,
5883
 
                        field: field,
5884
 
                        val: parseInt(field.val(), 10)
5885
 
                };
5886
 
                $(document).bind('mouseup.cpSlider', function(e) { return self._upIncrement.call(self, e); });
5887
 
                $(document).bind('mousemove.cpSlider', function(e) { return self._moveIncrement.call(self, e); });
5888
 
                return false;
5889
 
 
5890
 
        },
5891
 
        _moveIncrement: function(e) {
5892
 
                this.currentIncrement.field.val(Math.max(0, Math.min(this.currentIncrement.max, parseInt(this.currentIncrement.val + e.pageY - this.currentIncrement.y, 10))));
5893
 
                this._change.apply(this, [e, this.currentIncrement.field.get(0)]);
5894
 
                return false;
5895
 
        },
5896
 
        _upIncrement: function(e) {
5897
 
                this.currentIncrement.el.removeClass('ui-colorpicker-slider').find('input').focus();
5898
 
                this._change.apply(this, [e, this.currentIncrement.field.get(0)]);
5899
 
                $(document).unbind('mouseup.cpSlider');
5900
 
                $(document).unbind('mousemove.cpSlider');
5901
 
                return false;
5902
 
        },
5903
 
        _downHue: function(e) {
5904
 
 
5905
 
                this.currentHue = {
5906
 
                        y: this.picker.find('div.ui-colorpicker-hue').offset().top
5907
 
                };
5908
 
 
5909
 
                this._change.apply(this, [e, this
5910
 
                                .fields
5911
 
                                .eq(4)
5912
 
                                .val(parseInt(360*(150 - Math.max(0,Math.min(150,(e.pageY - this.currentHue.y))))/150, 10))
5913
 
                                .get(0)]);
5914
 
 
5915
 
                var self = this;
5916
 
                $(document).bind('mouseup.cpSlider', function(e) { return self._upHue.call(self, e); });
5917
 
                $(document).bind('mousemove.cpSlider', function(e) { return self._moveHue.call(self, e); });
5918
 
                return false;
5919
 
 
5920
 
        },
5921
 
        _moveHue: function(e) {
5922
 
 
5923
 
                this._change.apply(this, [e, this
5924
 
                                .fields
5925
 
                                .eq(4)
5926
 
                                .val(parseInt(360*(150 - Math.max(0,Math.min(150,(e.pageY - this.currentHue.y))))/150, 10))
5927
 
                                .get(0)]);
5928
 
 
5929
 
                return false;
5930
 
 
5931
 
        },
5932
 
        _upHue: function(e) {
5933
 
                $(document).unbind('mouseup.cpSlider');
5934
 
                $(document).unbind('mousemove.cpSlider');
5935
 
                return false;
5936
 
        },
5937
 
        _downSelector: function(e) {
5938
 
 
5939
 
                var self = this;
5940
 
                this.currentSelector = {
5941
 
                        pos: this.picker.find('div.ui-colorpicker-color').offset()
5942
 
                };
5943
 
 
5944
 
                this._change.apply(this, [e, this
5945
 
                                .fields
5946
 
                                .eq(6)
5947
 
                                .val(parseInt(100*(150 - Math.max(0,Math.min(150,(e.pageY - this.currentSelector.pos.top))))/150, 10))
5948
 
                                .end()
5949
 
                                .eq(5)
5950
 
                                .val(parseInt(100*(Math.max(0,Math.min(150,(e.pageX - this.currentSelector.pos.left))))/150, 10))
5951
 
                                .get(0)
5952
 
                ]);
5953
 
                $(document).bind('mouseup.cpSlider', function(e) { return self._upSelector.call(self, e); });
5954
 
                $(document).bind('mousemove.cpSlider', function(e) { return self._moveSelector.call(self, e); });
5955
 
                return false;
5956
 
 
5957
 
        },
5958
 
        _moveSelector: function(e) {
5959
 
 
5960
 
                this._change.apply(this, [e, this
5961
 
                                .fields
5962
 
                                .eq(6)
5963
 
                                .val(parseInt(100*(150 - Math.max(0,Math.min(150,(e.pageY - this.currentSelector.pos.top))))/150, 10))
5964
 
                                .end()
5965
 
                                .eq(5)
5966
 
                                .val(parseInt(100*(Math.max(0,Math.min(150,(e.pageX - this.currentSelector.pos.left))))/150, 10))
5967
 
                                .get(0)
5968
 
                ]);
5969
 
                return false;
5970
 
 
5971
 
        },
5972
 
        _upSelector: function(e) {
5973
 
                $(document).unbind('mouseup.cpSlider');
5974
 
                $(document).unbind('mousemove.cpSlider');
5975
 
                return false;
5976
 
        },
5977
 
        _enterSubmit: function(e) {
5978
 
                this.picker.find('.ui-colorpicker-submit').addClass('ui-colorpicker-focus');
5979
 
        },
5980
 
        _leaveSubmit: function(e) {
5981
 
                this.picker.find('.ui-colorpicker-submit').removeClass('ui-colorpicker-focus');
5982
 
        },
5983
 
        _clickSubmit: function(e) {
5984
 
 
5985
 
                var col = this.color;
5986
 
                this.origColor = col;
5987
 
                this._setCurrentColor(col);
5988
 
 
5989
 
                this._trigger("submit", e, { options: this.options, hsb: col, hex: this._HSBToHex(col), rgb: this._HSBToRGB(col) });
5990
 
                return false;
5991
 
 
5992
 
        },
5993
 
        _show: function(e) {
5994
 
 
5995
 
                this._trigger("beforeShow", e, { options: this.options, hsb: this.color, hex: this._HSBToHex(this.color), rgb: this._HSBToRGB(this.color) });
5996
 
 
5997
 
                var pos = this.element.offset();
5998
 
                var viewPort = this._getScroll();
5999
 
                var top = pos.top + this.element[0].offsetHeight;
6000
 
                var left = pos.left;
6001
 
                if (top + 176 > viewPort.t + Math.min(viewPort.h,viewPort.ih)) {
6002
 
                        top -= this.element[0].offsetHeight + 176;
6003
 
                }
6004
 
                if (left + 356 > viewPort.l + Math.min(viewPort.w,viewPort.iw)) {
6005
 
                        left -= 356;
6006
 
                }
6007
 
                this.picker.css({left: left + 'px', top: top + 'px'});
6008
 
                if (this._trigger("show", e, { options: this.options, hsb: this.color, hex: this._HSBToHex(this.color), rgb: this._HSBToRGB(this.color) }) != false) {
6009
 
                        this.picker.show();
6010
 
                }
6011
 
 
6012
 
                var self = this;
6013
 
                $(document).bind('mousedown.colorpicker', function(e) { return self._hide.call(self, e); });
6014
 
                return false;
6015
 
 
6016
 
        },
6017
 
        _hide: function(e) {
6018
 
 
6019
 
                if (!this._isChildOf(this.picker[0], e.target, this.picker[0])) {
6020
 
                        if (this._trigger("hide", e, { options: this.options, hsb: this.color, hex: this._HSBToHex(this.color), rgb: this._HSBToRGB(this.color) }) != false) {
6021
 
                                this.picker.hide();
6022
 
                        }
6023
 
                        $(document).unbind('mousedown.colorpicker');
6024
 
                }
6025
 
 
6026
 
        },
6027
 
        _isChildOf: function(parentEl, el, container) {
6028
 
                if (parentEl == el) {
6029
 
                        return true;
6030
 
                }
6031
 
                if (parentEl.contains && !$.browser.safari) {
6032
 
                        return parentEl.contains(el);
6033
 
                }
6034
 
                if ( parentEl.compareDocumentPosition ) {
6035
 
                        return !!(parentEl.compareDocumentPosition(el) & 16);
6036
 
                }
6037
 
                var prEl = el.parentNode;
6038
 
                while(prEl && prEl != container) {
6039
 
                        if (prEl == parentEl)
6040
 
                                return true;
6041
 
                        prEl = prEl.parentNode;
6042
 
                }
6043
 
                return false;
6044
 
        },
6045
 
        _getScroll: function() {
6046
 
                var t,l,w,h,iw,ih;
6047
 
                if (document.documentElement) {
6048
 
                        t = document.documentElement.scrollTop;
6049
 
                        l = document.documentElement.scrollLeft;
6050
 
                        w = document.documentElement.scrollWidth;
6051
 
                        h = document.documentElement.scrollHeight;
6052
 
                } else {
6053
 
                        t = document.body.scrollTop;
6054
 
                        l = document.body.scrollLeft;
6055
 
                        w = document.body.scrollWidth;
6056
 
                        h = document.body.scrollHeight;
6057
 
                }
6058
 
                iw = self.innerWidth||document.documentElement.clientWidth||document.body.clientWidth||0;
6059
 
                ih = self.innerHeight||document.documentElement.clientHeight||document.body.clientHeight||0;
6060
 
                return { t: t, l: l, w: w, h: h, iw: iw, ih: ih };
6061
 
        },
6062
 
        _fixHSB: function(hsb) {
6063
 
                return {
6064
 
                        h: Math.min(360, Math.max(0, hsb.h)),
6065
 
                        s: Math.min(100, Math.max(0, hsb.s)),
6066
 
                        b: Math.min(100, Math.max(0, hsb.b))
6067
 
                };
6068
 
        },
6069
 
        _fixRGB: function(rgb) {
6070
 
                return {
6071
 
                        r: Math.min(255, Math.max(0, rgb.r)),
6072
 
                        g: Math.min(255, Math.max(0, rgb.g)),
6073
 
                        b: Math.min(255, Math.max(0, rgb.b))
6074
 
                };
6075
 
        },
6076
 
        _HexToRGB: function (hex) {
6077
 
                var hex = parseInt(((hex.indexOf('#') > -1) ? hex.substring(1) : hex), 16);
6078
 
                return {r: hex >> 16, g: (hex & 0x00FF00) >> 8, b: (hex & 0x0000FF)};
6079
 
        },
6080
 
        _HexToHSB: function(hex) {
6081
 
                return this._RGBToHSB(this._HexToRGB(hex));
6082
 
        },
6083
 
        _RGBToHSB: function(rgb) {
6084
 
                var hsb = {};
6085
 
                hsb.b = Math.max(Math.max(rgb.r,rgb.g),rgb.b);
6086
 
                hsb.s = (hsb.b <= 0) ? 0 : Math.round(100*(hsb.b - Math.min(Math.min(rgb.r,rgb.g),rgb.b))/hsb.b);
6087
 
                hsb.b = Math.round((hsb.b /255)*100);
6088
 
                if((rgb.r==rgb.g) && (rgb.g==rgb.b)) hsb.h = 0;
6089
 
                else if(rgb.r>=rgb.g && rgb.g>=rgb.b) hsb.h = 60*(rgb.g-rgb.b)/(rgb.r-rgb.b);
6090
 
                else if(rgb.g>=rgb.r && rgb.r>=rgb.b) hsb.h = 60  + 60*(rgb.g-rgb.r)/(rgb.g-rgb.b);
6091
 
                else if(rgb.g>=rgb.b && rgb.b>=rgb.r) hsb.h = 120 + 60*(rgb.b-rgb.r)/(rgb.g-rgb.r);
6092
 
                else if(rgb.b>=rgb.g && rgb.g>=rgb.r) hsb.h = 180 + 60*(rgb.b-rgb.g)/(rgb.b-rgb.r);
6093
 
                else if(rgb.b>=rgb.r && rgb.r>=rgb.g) hsb.h = 240 + 60*(rgb.r-rgb.g)/(rgb.b-rgb.g);
6094
 
                else if(rgb.r>=rgb.b && rgb.b>=rgb.g) hsb.h = 300 + 60*(rgb.r-rgb.b)/(rgb.r-rgb.g);
6095
 
                else hsb.h = 0;
6096
 
                hsb.h = Math.round(hsb.h);
6097
 
                return hsb;
6098
 
        },
6099
 
        _HSBToRGB: function(hsb) {
6100
 
                var rgb = {};
6101
 
                var h = Math.round(hsb.h);
6102
 
                var s = Math.round(hsb.s*255/100);
6103
 
                var v = Math.round(hsb.b*255/100);
6104
 
                if(s == 0) {
6105
 
                        rgb.r = rgb.g = rgb.b = v;
6106
 
                } else {
6107
 
                        var t1 = v;
6108
 
                        var t2 = (255-s)*v/255;
6109
 
                        var t3 = (t1-t2)*(h%60)/60;
6110
 
                        if(h==360) h = 0;
6111
 
                        if(h<60) {rgb.r=t1;     rgb.b=t2; rgb.g=t2+t3;}
6112
 
                        else if(h<120) {rgb.g=t1; rgb.b=t2;     rgb.r=t1-t3;}
6113
 
                        else if(h<180) {rgb.g=t1; rgb.r=t2;     rgb.b=t2+t3;}
6114
 
                        else if(h<240) {rgb.b=t1; rgb.r=t2;     rgb.g=t1-t3;}
6115
 
                        else if(h<300) {rgb.b=t1; rgb.g=t2;     rgb.r=t2+t3;}
6116
 
                        else if(h<360) {rgb.r=t1; rgb.g=t2;     rgb.b=t1-t3;}
6117
 
                        else {rgb.r=0; rgb.g=0; rgb.b=0;}
6118
 
                }
6119
 
                return {r:Math.round(rgb.r), g:Math.round(rgb.g), b:Math.round(rgb.b)};
6120
 
        },
6121
 
        _RGBToHex: function(rgb) {
6122
 
                var hex = [
6123
 
                        rgb.r.toString(16),
6124
 
                        rgb.g.toString(16),
6125
 
                        rgb.b.toString(16)
6126
 
                ];
6127
 
                $.each(hex, function (nr, val) {
6128
 
                        if (val.length == 1) {
6129
 
                                hex[nr] = '0' + val;
6130
 
                        }
6131
 
                });
6132
 
                return hex.join('');
6133
 
        },
6134
 
        _HSBToHex: function(hsb) {
6135
 
                return this._RGBToHex(this._HSBToRGB(hsb));
6136
 
        },
6137
 
        setColor: function(col) {
6138
 
                if (typeof col == 'string') {
6139
 
                        col = this._HexToHSB(col);
6140
 
                } else if (col.r != undefined && col.g != undefined && col.b != undefined) {
6141
 
                        col = this._RGBToHSB(col);
6142
 
                } else if (col.h != undefined && col.s != undefined && col.b != undefined) {
6143
 
                        col = this._fixHSB(col);
6144
 
                } else {
6145
 
                        return this;
6146
 
                }
6147
 
 
6148
 
                this.color = col;
6149
 
                this.origColor = col;
6150
 
                this._fillRGBFields(col);
6151
 
                this._fillHSBFields(col);
6152
 
                this._fillHexFields(col);
6153
 
                this._setHue(col);
6154
 
                this._setSelector(col);
6155
 
                this._setCurrentColor(col);
6156
 
                this._setNewColor(col);
6157
 
 
6158
 
        }
6159
 
 
6160
 
});
6161
 
 
6162
 
$.extend($.ui.colorpicker, {
6163
 
        defaults: {
6164
 
                eventName: 'click',
6165
 
                color: 'ff0000',
6166
 
                flat: false
6167
 
        }
6168
 
});
6169
 
 
6170
 
})(jQuery);/*
6171
 
 * jQuery UI Datepicker @VERSION
6172
 
 *
6173
 
 * Copyright (c) 2006, 2007, 2008 Marc Grabanski
6174
 
 * Dual licensed under the MIT (MIT-LICENSE.txt)
6175
 
 * and GPL (GPL-LICENSE.txt) licenses.
6176
 
 * 
6177
 
 * http://docs.jquery.com/UI/Datepicker
6178
 
 *
6179
 
 * Depends:
6180
 
 *      ui.core.js
6181
 
 *
6182
 
 * Marc Grabanski (m@marcgrabanski.com) and Keith Wood (kbwood@virginbroadband.com.au).
6183
 
 */
6184
 
   
6185
 
(function($) { // hide the namespace
6186
 
 
6187
 
var PROP_NAME = 'datepicker';
6188
 
 
6189
 
/* Date picker manager.
6190
 
   Use the singleton instance of this class, $.datepicker, to interact with the date picker.
6191
 
   Settings for (groups of) date pickers are maintained in an instance object,
6192
 
   allowing multiple different settings on the same page. */
6193
 
 
6194
 
function Datepicker() {
6195
 
        this.debug = false; // Change this to true to start debugging
6196
 
        this._curInst = null; // The current instance in use
6197
 
        this._disabledInputs = []; // List of date picker inputs that have been disabled
6198
 
        this._datepickerShowing = false; // True if the popup picker is showing , false if not
6199
 
        this._inDialog = false; // True if showing within a "dialog", false if not
6200
 
        this._mainDivId = 'ui-datepicker-div'; // The ID of the main datepicker division
6201
 
        this._inlineClass = 'ui-datepicker-inline'; // The name of the inline marker class
6202
 
        this._appendClass = 'ui-datepicker-append'; // The name of the append marker class
6203
 
        this._triggerClass = 'ui-datepicker-trigger'; // The name of the trigger marker class
6204
 
        this._dialogClass = 'ui-datepicker-dialog'; // The name of the dialog marker class
6205
 
        this._promptClass = 'ui-datepicker-prompt'; // The name of the dialog prompt marker class
6206
 
        this._disableClass = 'ui-datepicker-disabled'; // The name of the disabled covering marker class
6207
 
        this._unselectableClass = 'ui-datepicker-unselectable'; // The name of the unselectable cell marker class
6208
 
        this._currentClass = 'ui-datepicker-current-day'; // The name of the current day marker class
6209
 
        this.regional = []; // Available regional settings, indexed by language code
6210
 
        this.regional[''] = { // Default regional settings
6211
 
                clearText: 'Clear', // Display text for clear link
6212
 
                clearStatus: 'Erase the current date', // Status text for clear link
6213
 
                closeText: 'Close', // Display text for close link
6214
 
                closeStatus: 'Close without change', // Status text for close link
6215
 
                prevText: '&#x3c;Prev', // Display text for previous month link
6216
 
                prevStatus: 'Show the previous month', // Status text for previous month link
6217
 
                prevBigText: '&#x3c;&#x3c;', // Display text for previous year link
6218
 
                prevBigStatus: 'Show the previous year', // Status text for previous year link
6219
 
                nextText: 'Next&#x3e;', // Display text for next month link
6220
 
                nextStatus: 'Show the next month', // Status text for next month link
6221
 
                nextBigText: '&#x3e;&#x3e;', // Display text for next year link
6222
 
                nextBigStatus: 'Show the next year', // Status text for next year link
6223
 
                currentText: 'Today', // Display text for current month link
6224
 
                currentStatus: 'Show the current month', // Status text for current month link
6225
 
                monthNames: ['January','February','March','April','May','June',
6226
 
                        'July','August','September','October','November','December'], // Names of months for drop-down and formatting
6227
 
                monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], // For formatting
6228
 
                monthStatus: 'Show a different month', // Status text for selecting a month
6229
 
                yearStatus: 'Show a different year', // Status text for selecting a year
6230
 
                weekHeader: 'Wk', // Header for the week of the year column
6231
 
                weekStatus: 'Week of the year', // Status text for the week of the year column
6232
 
                dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], // For formatting
6233
 
                dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], // For formatting
6234
 
                dayNamesMin: ['Su','Mo','Tu','We','Th','Fr','Sa'], // Column headings for days starting at Sunday
6235
 
                dayStatus: 'Set DD as first week day', // Status text for the day of the week selection
6236
 
                dateStatus: 'Select DD, M d', // Status text for the date selection
6237
 
                dateFormat: 'mm/dd/yy', // See format options on parseDate
6238
 
                firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
6239
 
                initStatus: 'Select a date', // Initial Status text on opening
6240
 
                isRTL: false // True if right-to-left language, false if left-to-right
6241
 
        };
6242
 
        this._defaults = { // Global defaults for all the date picker instances
6243
 
                showOn: 'focus', // 'focus' for popup on focus,
6244
 
                        // 'button' for trigger button, or 'both' for either
6245
 
                showAnim: 'show', // Name of jQuery animation for popup
6246
 
                showOptions: {}, // Options for enhanced animations
6247
 
                defaultDate: null, // Used when field is blank: actual date,
6248
 
                        // +/-number for offset from today, null for today
6249
 
                appendText: '', // Display text following the input box, e.g. showing the format
6250
 
                buttonText: '...', // Text for trigger button
6251
 
                buttonImage: '', // URL for trigger button image
6252
 
                buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
6253
 
                closeAtTop: true, // True to have the clear/close at the top,
6254
 
                        // false to have them at the bottom
6255
 
                mandatory: false, // True to hide the Clear link, false to include it
6256
 
                hideIfNoPrevNext: false, // True to hide next/previous month links
6257
 
                        // if not applicable, false to just disable them
6258
 
                navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
6259
 
                showBigPrevNext: false, // True to show big prev/next links
6260
 
                gotoCurrent: false, // True if today link goes back to current selection instead
6261
 
                changeMonth: true, // True if month can be selected directly, false if only prev/next
6262
 
                changeYear: true, // True if year can be selected directly, false if only prev/next
6263
 
                showMonthAfterYear: false, // True if the year select precedes month, false for month then year
6264
 
                yearRange: '-10:+10', // Range of years to display in drop-down,
6265
 
                        // either relative to current year (-nn:+nn) or absolute (nnnn:nnnn)
6266
 
                changeFirstDay: true, // True to click on day name to change, false to remain as set
6267
 
                highlightWeek: false, // True to highlight the selected week
6268
 
                showOtherMonths: false, // True to show dates in other months, false to leave blank
6269
 
                showWeeks: false, // True to show week of the year, false to omit
6270
 
                calculateWeek: this.iso8601Week, // How to calculate the week of the year,
6271
 
                        // takes a Date and returns the number of the week for it
6272
 
                shortYearCutoff: '+10', // Short year values < this are in the current century,
6273
 
                        // > this are in the previous century, 
6274
 
                        // string value starting with '+' for current year + value
6275
 
                showStatus: false, // True to show status bar at bottom, false to not show it
6276
 
                statusForDate: this.dateStatus, // Function to provide status text for a date -
6277
 
                        // takes date and instance as parameters, returns display text
6278
 
                minDate: null, // The earliest selectable date, or null for no limit
6279
 
                maxDate: null, // The latest selectable date, or null for no limit
6280
 
                duration: 'normal', // Duration of display/closure
6281
 
                beforeShowDay: null, // Function that takes a date and returns an array with
6282
 
                        // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or '', 
6283
 
                        // [2] = cell title (optional), e.g. $.datepicker.noWeekends
6284
 
                beforeShow: null, // Function that takes an input field and
6285
 
                        // returns a set of custom settings for the date picker
6286
 
                onSelect: null, // Define a callback function when a date is selected
6287
 
                onChangeMonthYear: null, // Define a callback function when the month or year is changed
6288
 
                onClose: null, // Define a callback function when the datepicker is closed
6289
 
                numberOfMonths: 1, // Number of months to show at a time
6290
 
                showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
6291
 
                stepMonths: 1, // Number of months to step back/forward
6292
 
                stepBigMonths: 12, // Number of months to step back/forward for the big links
6293
 
                rangeSelect: false, // Allows for selecting a date range on one date picker
6294
 
                rangeSeparator: ' - ', // Text between two dates in a range
6295
 
                altField: '', // Selector for an alternate field to store selected dates into
6296
 
                altFormat: '' // The date format to use for the alternate field
6297
 
        };
6298
 
        $.extend(this._defaults, this.regional['']);
6299
 
        this.dpDiv = $('<div id="' + this._mainDivId + '" style="display: none;"></div>');
6300
 
}
6301
 
 
6302
 
$.extend(Datepicker.prototype, {
6303
 
        /* Class name added to elements to indicate already configured with a date picker. */
6304
 
        markerClassName: 'hasDatepicker',
6305
 
 
6306
 
        /* Debug logging (if enabled). */
6307
 
        log: function () {
6308
 
                if (this.debug)
6309
 
                        console.log.apply('', arguments);
6310
 
        },
6311
 
        
6312
 
        /* Override the default settings for all instances of the date picker. 
6313
 
           @param  settings  object - the new settings to use as defaults (anonymous object)
6314
 
           @return the manager object */
6315
 
        setDefaults: function(settings) {
6316
 
                extendRemove(this._defaults, settings || {});
6317
 
                return this;
6318
 
        },
6319
 
 
6320
 
        /* Attach the date picker to a jQuery selection.
6321
 
           @param  target    element - the target input field or division or span
6322
 
           @param  settings  object - the new settings to use for this date picker instance (anonymous) */
6323
 
        _attachDatepicker: function(target, settings) {
6324
 
                // check for settings on the control itself - in namespace 'date:'
6325
 
                var inlineSettings = null;
6326
 
                for (attrName in this._defaults) {
6327
 
                        var attrValue = target.getAttribute('date:' + attrName);
6328
 
                        if (attrValue) {
6329
 
                                inlineSettings = inlineSettings || {};
6330
 
                                try {
6331
 
                                        inlineSettings[attrName] = eval(attrValue);
6332
 
                                } catch (err) {
6333
 
                                        inlineSettings[attrName] = attrValue;
6334
 
                                }
6335
 
                        }
6336
 
                }
6337
 
                var nodeName = target.nodeName.toLowerCase();
6338
 
                var inline = (nodeName == 'div' || nodeName == 'span');
6339
 
                if (!target.id)
6340
 
                        target.id = 'dp' + (++this.uuid);
6341
 
                var inst = this._newInst($(target), inline);
6342
 
                inst.settings = $.extend({}, settings || {}, inlineSettings || {}); 
6343
 
                if (nodeName == 'input') {
6344
 
                        this._connectDatepicker(target, inst);
6345
 
                } else if (inline) {
6346
 
                        this._inlineDatepicker(target, inst);
6347
 
                }
6348
 
        },
6349
 
 
6350
 
        /* Create a new instance object. */
6351
 
        _newInst: function(target, inline) {
6352
 
                var id = target[0].id.replace(/([:\[\]\.])/g, '\\\\$1'); // escape jQuery meta chars
6353
 
                return {id: id, input: target, // associated target
6354
 
                        selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
6355
 
                        drawMonth: 0, drawYear: 0, // month being drawn
6356
 
                        inline: inline, // is datepicker inline or not
6357
 
                        dpDiv: (!inline ? this.dpDiv : // presentation div
6358
 
                        $('<div class="' + this._inlineClass + '"></div>'))};
6359
 
        },
6360
 
 
6361
 
        /* Attach the date picker to an input field. */
6362
 
        _connectDatepicker: function(target, inst) {
6363
 
                var input = $(target);
6364
 
                if (input.hasClass(this.markerClassName))
6365
 
                        return;
6366
 
                var appendText = this._get(inst, 'appendText');
6367
 
                var isRTL = this._get(inst, 'isRTL');
6368
 
                if (appendText)
6369
 
                        input[isRTL ? 'before' : 'after']('<span class="' + this._appendClass + '">' + appendText + '</span>');
6370
 
                var showOn = this._get(inst, 'showOn');
6371
 
                if (showOn == 'focus' || showOn == 'both') // pop-up date picker when in the marked field
6372
 
                        input.focus(this._showDatepicker);
6373
 
                if (showOn == 'button' || showOn == 'both') { // pop-up date picker when button clicked
6374
 
                        var buttonText = this._get(inst, 'buttonText');
6375
 
                        var buttonImage = this._get(inst, 'buttonImage');
6376
 
                        var trigger = $(this._get(inst, 'buttonImageOnly') ? 
6377
 
                                $('<img/>').addClass(this._triggerClass).
6378
 
                                        attr({ src: buttonImage, alt: buttonText, title: buttonText }) :
6379
 
                                $('<button type="button"></button>').addClass(this._triggerClass).
6380
 
                                        html(buttonImage == '' ? buttonText : $('<img/>').attr(
6381
 
                                        { src:buttonImage, alt:buttonText, title:buttonText })));
6382
 
                        input[isRTL ? 'before' : 'after'](trigger);
6383
 
                        trigger.click(function() {
6384
 
                                if ($.datepicker._datepickerShowing && $.datepicker._lastInput == target)
6385
 
                                        $.datepicker._hideDatepicker();
6386
 
                                else
6387
 
                                        $.datepicker._showDatepicker(target);
6388
 
                                return false;
6389
 
                        });
6390
 
                }
6391
 
                input.addClass(this.markerClassName).keydown(this._doKeyDown).keypress(this._doKeyPress).
6392
 
                        bind("setData.datepicker", function(event, key, value) {
6393
 
                                inst.settings[key] = value;
6394
 
                        }).bind("getData.datepicker", function(event, key) {
6395
 
                                return this._get(inst, key);
6396
 
                        });
6397
 
                $.data(target, PROP_NAME, inst);
6398
 
        },
6399
 
 
6400
 
        /* Attach an inline date picker to a div. */
6401
 
        _inlineDatepicker: function(target, inst) {
6402
 
                var divSpan = $(target);
6403
 
                if (divSpan.hasClass(this.markerClassName))
6404
 
                        return;
6405
 
                divSpan.addClass(this.markerClassName).append(inst.dpDiv).
6406
 
                        bind("setData.datepicker", function(event, key, value){
6407
 
                                inst.settings[key] = value;
6408
 
                        }).bind("getData.datepicker", function(event, key){
6409
 
                                return this._get(inst, key);
6410
 
                        });
6411
 
                $.data(target, PROP_NAME, inst);
6412
 
                this._setDate(inst, this._getDefaultDate(inst));
6413
 
                this._updateDatepicker(inst);
6414
 
        },
6415
 
 
6416
 
        /* Tidy up after displaying the date picker. */
6417
 
        _inlineShow: function(inst) {
6418
 
                var numMonths = this._getNumberOfMonths(inst); // fix width for dynamic number of date pickers
6419
 
                inst.dpDiv.width(numMonths[1] * $('.ui-datepicker', inst.dpDiv[0]).width());
6420
 
        }, 
6421
 
 
6422
 
        /* Pop-up the date picker in a "dialog" box.
6423
 
           @param  input     element - ignored
6424
 
           @param  dateText  string - the initial date to display (in the current format)
6425
 
           @param  onSelect  function - the function(dateText) to call when a date is selected
6426
 
           @param  settings  object - update the dialog date picker instance's settings (anonymous object)
6427
 
           @param  pos       int[2] - coordinates for the dialog's position within the screen or
6428
 
                             event - with x/y coordinates or
6429
 
                             leave empty for default (screen centre)
6430
 
           @return the manager object */
6431
 
        _dialogDatepicker: function(input, dateText, onSelect, settings, pos) {
6432
 
                var inst = this._dialogInst; // internal instance
6433
 
                if (!inst) {
6434
 
                        var id = 'dp' + (++this.uuid);
6435
 
                        this._dialogInput = $('<input type="text" id="' + id +
6436
 
                                '" size="1" style="position: absolute; top: -100px;"/>');
6437
 
                        this._dialogInput.keydown(this._doKeyDown);
6438
 
                        $('body').append(this._dialogInput);
6439
 
                        inst = this._dialogInst = this._newInst(this._dialogInput, false);
6440
 
                        inst.settings = {};
6441
 
                        $.data(this._dialogInput[0], PROP_NAME, inst);
6442
 
                }
6443
 
                extendRemove(inst.settings, settings || {});
6444
 
                this._dialogInput.val(dateText);
6445
 
 
6446
 
                this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null);
6447
 
                if (!this._pos) {
6448
 
                        var browserWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
6449
 
                        var browserHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
6450
 
                        var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
6451
 
                        var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
6452
 
                        this._pos = // should use actual width/height below
6453
 
                                [(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY];
6454
 
                }
6455
 
 
6456
 
                // move input on screen for focus, but hidden behind dialog
6457
 
                this._dialogInput.css('left', this._pos[0] + 'px').css('top', this._pos[1] + 'px');
6458
 
                inst.settings.onSelect = onSelect;
6459
 
                this._inDialog = true;
6460
 
                this.dpDiv.addClass(this._dialogClass);
6461
 
                this._showDatepicker(this._dialogInput[0]);
6462
 
                if ($.blockUI)
6463
 
                        $.blockUI(this.dpDiv);
6464
 
                $.data(this._dialogInput[0], PROP_NAME, inst);
6465
 
                return this;
6466
 
        },
6467
 
 
6468
 
        /* Detach a datepicker from its control.
6469
 
           @param  target    element - the target input field or division or span */
6470
 
        _destroyDatepicker: function(target) {
6471
 
                var $target = $(target);
6472
 
                if (!$target.hasClass(this.markerClassName)) {
6473
 
                        return;
6474
 
                }
6475
 
                var nodeName = target.nodeName.toLowerCase();
6476
 
                $.removeData(target, PROP_NAME);
6477
 
                if (nodeName == 'input') {
6478
 
                        $target.siblings('.' + this._appendClass).remove().end().
6479
 
                                siblings('.' + this._triggerClass).remove().end().
6480
 
                                removeClass(this.markerClassName).
6481
 
                                unbind('focus', this._showDatepicker).
6482
 
                                unbind('keydown', this._doKeyDown).
6483
 
                                unbind('keypress', this._doKeyPress);
6484
 
                } else if (nodeName == 'div' || nodeName == 'span')
6485
 
                        $target.removeClass(this.markerClassName).empty();
6486
 
        },
6487
 
 
6488
 
        /* Enable the date picker to a jQuery selection.
6489
 
           @param  target    element - the target input field or division or span */
6490
 
        _enableDatepicker: function(target) {
6491
 
                var $target = $(target);
6492
 
                if (!$target.hasClass(this.markerClassName)) {
6493
 
                        return;
6494
 
                }
6495
 
                var nodeName = target.nodeName.toLowerCase();
6496
 
                if (nodeName == 'input') {
6497
 
                target.disabled = false;
6498
 
                        $target.siblings('button.' + this._triggerClass).
6499
 
                        each(function() { this.disabled = false; }).end().
6500
 
                                siblings('img.' + this._triggerClass).
6501
 
                                css({opacity: '1.0', cursor: ''});
6502
 
                }
6503
 
                else if (nodeName == 'div' || nodeName == 'span') {
6504
 
                        $target.children('.' + this._disableClass).remove();
6505
 
                }
6506
 
                this._disabledInputs = $.map(this._disabledInputs,
6507
 
                        function(value) { return (value == target ? null : value); }); // delete entry
6508
 
        },
6509
 
 
6510
 
        /* Disable the date picker to a jQuery selection.
6511
 
           @param  target    element - the target input field or division or span */
6512
 
        _disableDatepicker: function(target) {
6513
 
                var $target = $(target);
6514
 
                if (!$target.hasClass(this.markerClassName)) {
6515
 
                        return;
6516
 
                }
6517
 
                var nodeName = target.nodeName.toLowerCase();
6518
 
                if (nodeName == 'input') {
6519
 
                target.disabled = true;
6520
 
                        $target.siblings('button.' + this._triggerClass).
6521
 
                        each(function() { this.disabled = true; }).end().
6522
 
                                siblings('img.' + this._triggerClass).
6523
 
                                css({opacity: '0.5', cursor: 'default'});
6524
 
                }
6525
 
                else if (nodeName == 'div' || nodeName == 'span') {
6526
 
                        var inline = $target.children('.' + this._inlineClass);
6527
 
                        var offset = inline.offset();
6528
 
                        var relOffset = {left: 0, top: 0};
6529
 
                        inline.parents().each(function() {
6530
 
                                if ($(this).css('position') == 'relative') {
6531
 
                                        relOffset = $(this).offset();
6532
 
                                        return false;
6533
 
                                }
6534
 
                        });
6535
 
                        $target.prepend('<div class="' + this._disableClass + '" style="' +
6536
 
                                ($.browser.msie ? 'background-color: transparent; ' : '') +
6537
 
                                'width: ' + inline.width() + 'px; height: ' + inline.height() +
6538
 
                                'px; left: ' + (offset.left - relOffset.left) +
6539
 
                                'px; top: ' + (offset.top - relOffset.top) + 'px;"></div>');
6540
 
                }
6541
 
                this._disabledInputs = $.map(this._disabledInputs,
6542
 
                        function(value) { return (value == target ? null : value); }); // delete entry
6543
 
                this._disabledInputs[this._disabledInputs.length] = target;
6544
 
        },
6545
 
 
6546
 
        /* Is the first field in a jQuery collection disabled as a datepicker?
6547
 
           @param  target    element - the target input field or division or span
6548
 
           @return boolean - true if disabled, false if enabled */
6549
 
        _isDisabledDatepicker: function(target) {
6550
 
                if (!target)
6551
 
                        return false;
6552
 
                for (var i = 0; i < this._disabledInputs.length; i++) {
6553
 
                        if (this._disabledInputs[i] == target)
6554
 
                                return true;
6555
 
                }
6556
 
                return false;
6557
 
        },
6558
 
 
6559
 
        /* Retrieve the instance data for the target control.
6560
 
           @param  target  element - the target input field or division or span
6561
 
           @return  object - the associated instance data
6562
 
           @throws  error if a jQuery problem getting data */
6563
 
        _getInst: function(target) {
6564
 
                try {
6565
 
                        return $.data(target, PROP_NAME);
6566
 
                }
6567
 
                catch (err) {
6568
 
                        throw 'Missing instance data for this datepicker';
6569
 
                }
6570
 
        },
6571
 
 
6572
 
        /* Update the settings for a date picker attached to an input field or division.
6573
 
           @param  target  element - the target input field or division or span
6574
 
           @param  name    object - the new settings to update or
6575
 
                           string - the name of the setting to change or
6576
 
           @param  value   any - the new value for the setting (omit if above is an object) */
6577
 
        _changeDatepicker: function(target, name, value) {
6578
 
                var settings = name || {};
6579
 
                if (typeof name == 'string') {
6580
 
                        settings = {};
6581
 
                        settings[name] = value;
6582
 
                }
6583
 
                var inst = this._getInst(target);
6584
 
                if (inst) {
6585
 
                        if (this._curInst == inst) {
6586
 
                                this._hideDatepicker(null);
6587
 
                        }
6588
 
                        extendRemove(inst.settings, settings);
6589
 
                        var date = new Date();
6590
 
                        extendRemove(inst, {rangeStart: null, // start of range
6591
 
                                endDay: null, endMonth: null, endYear: null, // end of range
6592
 
                                selectedDay: date.getDate(), selectedMonth: date.getMonth(),
6593
 
                                selectedYear: date.getFullYear(), // starting point
6594
 
                                currentDay: date.getDate(), currentMonth: date.getMonth(),
6595
 
                                currentYear: date.getFullYear(), // current selection
6596
 
                                drawMonth: date.getMonth(), drawYear: date.getFullYear()}); // month being drawn
6597
 
                        this._updateDatepicker(inst);
6598
 
                }
6599
 
        },
6600
 
 
6601
 
        /* Redraw the date picker attached to an input field or division.
6602
 
           @param  target  element - the target input field or division or span */
6603
 
        _refreshDatepicker: function(target) {
6604
 
                var inst = this._getInst(target);
6605
 
                if (inst) {
6606
 
                        this._updateDatepicker(inst);
6607
 
                }
6608
 
        },
6609
 
 
6610
 
        /* Set the dates for a jQuery selection.
6611
 
           @param  target   element - the target input field or division or span
6612
 
           @param  date     Date - the new date
6613
 
           @param  endDate  Date - the new end date for a range (optional) */
6614
 
        _setDateDatepicker: function(target, date, endDate) {
6615
 
                var inst = this._getInst(target);
6616
 
                if (inst) {
6617
 
                        this._setDate(inst, date, endDate);
6618
 
                        this._updateDatepicker(inst);
6619
 
                        this._updateAlternate(inst);
6620
 
                }
6621
 
        },
6622
 
 
6623
 
        /* Get the date(s) for the first entry in a jQuery selection.
6624
 
           @param  target  element - the target input field or division or span
6625
 
           @return Date - the current date or
6626
 
                   Date[2] - the current dates for a range */
6627
 
        _getDateDatepicker: function(target) {
6628
 
                var inst = this._getInst(target);
6629
 
                if (inst && !inst.inline)
6630
 
                        this._setDateFromField(inst); 
6631
 
                return (inst ? this._getDate(inst) : null);
6632
 
        },
6633
 
 
6634
 
        /* Handle keystrokes. */
6635
 
        _doKeyDown: function(e) {
6636
 
                var inst = $.datepicker._getInst(e.target);
6637
 
                var handled = true;
6638
 
                if ($.datepicker._datepickerShowing)
6639
 
                        switch (e.keyCode) {
6640
 
                                case 9:  $.datepicker._hideDatepicker(null, '');
6641
 
                                                break; // hide on tab out
6642
 
                                case 13: $.datepicker._selectDay(e.target, inst.selectedMonth, inst.selectedYear,
6643
 
                                                        $('td.ui-datepicker-days-cell-over', inst.dpDiv)[0]);
6644
 
                                                return false; // don't submit the form
6645
 
                                                break; // select the value on enter
6646
 
                                case 27: $.datepicker._hideDatepicker(null, $.datepicker._get(inst, 'duration'));
6647
 
                                                break; // hide on escape
6648
 
                                case 33: $.datepicker._adjustDate(e.target, (e.ctrlKey ?
6649
 
                                                        -$.datepicker._get(inst, 'stepBigMonths') :
6650
 
                                                        -$.datepicker._get(inst, 'stepMonths')), 'M');
6651
 
                                                break; // previous month/year on page up/+ ctrl
6652
 
                                case 34: $.datepicker._adjustDate(e.target, (e.ctrlKey ?
6653
 
                                                        +$.datepicker._get(inst, 'stepBigMonths') :
6654
 
                                                        +$.datepicker._get(inst, 'stepMonths')), 'M');
6655
 
                                                break; // next month/year on page down/+ ctrl
6656
 
                                case 35: if (e.ctrlKey) $.datepicker._clearDate(e.target);
6657
 
                                                handled = e.ctrlKey;
6658
 
                                                break; // clear on ctrl+end
6659
 
                                case 36: if (e.ctrlKey) $.datepicker._gotoToday(e.target);
6660
 
                                                handled = e.ctrlKey;
6661
 
                                                break; // current on ctrl+home
6662
 
                                case 37: if (e.ctrlKey) $.datepicker._adjustDate(e.target, -1, 'D');
6663
 
                                                handled = e.ctrlKey;
6664
 
                                                break; // -1 day on ctrl+left
6665
 
                                case 38: if (e.ctrlKey) $.datepicker._adjustDate(e.target, -7, 'D');
6666
 
                                                handled = e.ctrlKey;
6667
 
                                                break; // -1 week on ctrl+up
6668
 
                                case 39: if (e.ctrlKey) $.datepicker._adjustDate(e.target, +1, 'D');
6669
 
                                                handled = e.ctrlKey;
6670
 
                                                break; // +1 day on ctrl+right
6671
 
                                case 40: if (e.ctrlKey) $.datepicker._adjustDate(e.target, +7, 'D');
6672
 
                                                handled = e.ctrlKey;
6673
 
                                                break; // +1 week on ctrl+down
6674
 
                                default: handled = false;
6675
 
                        }
6676
 
                else if (e.keyCode == 36 && e.ctrlKey) // display the date picker on ctrl+home
6677
 
                        $.datepicker._showDatepicker(this);
6678
 
                else
6679
 
                        handled = false;
6680
 
                if (handled) {
6681
 
                        e.preventDefault();
6682
 
                        e.stopPropagation();
6683
 
                }
6684
 
        },
6685
 
 
6686
 
        /* Filter entered characters - based on date format. */
6687
 
        _doKeyPress: function(e) {
6688
 
                var inst = $.datepicker._getInst(e.target);
6689
 
                var chars = $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat'));
6690
 
                var chr = String.fromCharCode(e.charCode == undefined ? e.keyCode : e.charCode);
6691
 
                return e.ctrlKey || (chr < ' ' || !chars || chars.indexOf(chr) > -1);
6692
 
        },
6693
 
 
6694
 
        /* Pop-up the date picker for a given input field.
6695
 
           @param  input  element - the input field attached to the date picker or
6696
 
                          event - if triggered by focus */
6697
 
        _showDatepicker: function(input) {
6698
 
                input = input.target || input;
6699
 
                if (input.nodeName.toLowerCase() != 'input') // find from button/image trigger
6700
 
                        input = $('input', input.parentNode)[0];
6701
 
                if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput == input) // already here
6702
 
                        return;
6703
 
                var inst = $.datepicker._getInst(input);
6704
 
                var beforeShow = $.datepicker._get(inst, 'beforeShow');
6705
 
                extendRemove(inst.settings, (beforeShow ? beforeShow.apply(input, [input, inst]) : {}));
6706
 
                $.datepicker._hideDatepicker(null, '');
6707
 
                $.datepicker._lastInput = input;
6708
 
                $.datepicker._setDateFromField(inst);
6709
 
                if ($.datepicker._inDialog) // hide cursor
6710
 
                        input.value = '';
6711
 
                if (!$.datepicker._pos) { // position below input
6712
 
                        $.datepicker._pos = $.datepicker._findPos(input);
6713
 
                        $.datepicker._pos[1] += input.offsetHeight; // add the height
6714
 
                }
6715
 
                var isFixed = false;
6716
 
                $(input).parents().each(function() {
6717
 
                        isFixed |= $(this).css('position') == 'fixed';
6718
 
                        return !isFixed;
6719
 
                });
6720
 
                if (isFixed && $.browser.opera) { // correction for Opera when fixed and scrolled
6721
 
                        $.datepicker._pos[0] -= document.documentElement.scrollLeft;
6722
 
                        $.datepicker._pos[1] -= document.documentElement.scrollTop;
6723
 
                }
6724
 
                var offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]};
6725
 
                $.datepicker._pos = null;
6726
 
                inst.rangeStart = null;
6727
 
                // determine sizing offscreen
6728
 
                inst.dpDiv.css({position: 'absolute', display: 'block', top: '-1000px'});
6729
 
                $.datepicker._updateDatepicker(inst);
6730
 
                // fix width for dynamic number of date pickers
6731
 
                inst.dpDiv.width($.datepicker._getNumberOfMonths(inst)[1] *
6732
 
                        $('.ui-datepicker', inst.dpDiv[0])[0].offsetWidth);
6733
 
                // and adjust position before showing
6734
 
                offset = $.datepicker._checkOffset(inst, offset, isFixed);
6735
 
                inst.dpDiv.css({position: ($.datepicker._inDialog && $.blockUI ?
6736
 
                        'static' : (isFixed ? 'fixed' : 'absolute')), display: 'none',
6737
 
                        left: offset.left + 'px', top: offset.top + 'px'});
6738
 
                if (!inst.inline) {
6739
 
                        var showAnim = $.datepicker._get(inst, 'showAnim') || 'show';
6740
 
                        var duration = $.datepicker._get(inst, 'duration');
6741
 
                        var postProcess = function() {
6742
 
                                $.datepicker._datepickerShowing = true;
6743
 
                                if ($.browser.msie && parseInt($.browser.version,10) < 7) // fix IE < 7 select problems
6744
 
                                        $('iframe.ui-datepicker-cover').css({width: inst.dpDiv.width() + 4,
6745
 
                                                height: inst.dpDiv.height() + 4});
6746
 
                        };
6747
 
                        if ($.effects && $.effects[showAnim])
6748
 
                                inst.dpDiv.show(showAnim, $.datepicker._get(inst, 'showOptions'), duration, postProcess);
6749
 
                        else
6750
 
                                inst.dpDiv[showAnim](duration, postProcess);
6751
 
                        if (duration == '')
6752
 
                                postProcess();
6753
 
                        if (inst.input[0].type != 'hidden')
6754
 
                                inst.input[0].focus();
6755
 
                        $.datepicker._curInst = inst;
6756
 
                }
6757
 
        },
6758
 
 
6759
 
        /* Generate the date picker content. */
6760
 
        _updateDatepicker: function(inst) {
6761
 
                var dims = {width: inst.dpDiv.width() + 4,
6762
 
                        height: inst.dpDiv.height() + 4};
6763
 
                inst.dpDiv.empty().append(this._generateHTML(inst)).
6764
 
                        find('iframe.ui-datepicker-cover').
6765
 
                        css({width: dims.width, height: dims.height});
6766
 
                var numMonths = this._getNumberOfMonths(inst);
6767
 
                inst.dpDiv[(numMonths[0] != 1 || numMonths[1] != 1 ? 'add' : 'remove') +
6768
 
                        'Class']('ui-datepicker-multi');
6769
 
                inst.dpDiv[(this._get(inst, 'isRTL') ? 'add' : 'remove') +
6770
 
                        'Class']('ui-datepicker-rtl');
6771
 
                if (inst.input && inst.input[0].type != 'hidden')
6772
 
                        $(inst.input[0]).focus();
6773
 
        },
6774
 
 
6775
 
        /* Check positioning to remain on screen. */
6776
 
        _checkOffset: function(inst, offset, isFixed) {
6777
 
                var pos = inst.input ? this._findPos(inst.input[0]) : null;
6778
 
                var browserWidth = window.innerWidth || document.documentElement.clientWidth;
6779
 
                var browserHeight = window.innerHeight || document.documentElement.clientHeight;
6780
 
                var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
6781
 
                var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
6782
 
                // reposition date picker horizontally if outside the browser window
6783
 
                if (this._get(inst, 'isRTL') || (offset.left + inst.dpDiv.width() - scrollX) > browserWidth)
6784
 
                        offset.left = Math.max((isFixed ? 0 : scrollX),
6785
 
                                pos[0] + (inst.input ? inst.input.width() : 0) - (isFixed ? scrollX : 0) - inst.dpDiv.width() -
6786
 
                                (isFixed && $.browser.opera ? document.documentElement.scrollLeft : 0));
6787
 
                else
6788
 
                        offset.left -= (isFixed ? scrollX : 0);
6789
 
                // reposition date picker vertically if outside the browser window
6790
 
                if ((offset.top + inst.dpDiv.height() - scrollY) > browserHeight)
6791
 
                        offset.top = Math.max((isFixed ? 0 : scrollY),
6792
 
                                pos[1] - (isFixed ? scrollY : 0) - (this._inDialog ? 0 : inst.dpDiv.height()) -
6793
 
                                (isFixed && $.browser.opera ? document.documentElement.scrollTop : 0));
6794
 
                else
6795
 
                        offset.top -= (isFixed ? scrollY : 0);
6796
 
                return offset;
6797
 
        },
6798
 
        
6799
 
        /* Find an object's position on the screen. */
6800
 
        _findPos: function(obj) {
6801
 
        while (obj && (obj.type == 'hidden' || obj.nodeType != 1)) {
6802
 
            obj = obj.nextSibling;
6803
 
        }
6804
 
        var position = $(obj).offset();
6805
 
            return [position.left, position.top];
6806
 
        },
6807
 
 
6808
 
        /* Hide the date picker from view.
6809
 
           @param  input  element - the input field attached to the date picker
6810
 
           @param  duration  string - the duration over which to close the date picker */
6811
 
        _hideDatepicker: function(input, duration) {
6812
 
                var inst = this._curInst;
6813
 
                if (!inst || (input && inst != $.data(input, PROP_NAME)))
6814
 
                        return;
6815
 
                var rangeSelect = this._get(inst, 'rangeSelect');
6816
 
                if (rangeSelect && inst.stayOpen)
6817
 
                        this._selectDate('#' + inst.id, this._formatDate(inst,
6818
 
                                inst.currentDay, inst.currentMonth, inst.currentYear));
6819
 
                inst.stayOpen = false;
6820
 
                if (this._datepickerShowing) {
6821
 
                        duration = (duration != null ? duration : this._get(inst, 'duration'));
6822
 
                        var showAnim = this._get(inst, 'showAnim');
6823
 
                        var postProcess = function() {
6824
 
                                $.datepicker._tidyDialog(inst);
6825
 
                        };
6826
 
                        if (duration != '' && $.effects && $.effects[showAnim])
6827
 
                                inst.dpDiv.hide(showAnim, $.datepicker._get(inst, 'showOptions'),
6828
 
                                        duration, postProcess);
6829
 
                        else
6830
 
                                inst.dpDiv[(duration == '' ? 'hide' : (showAnim == 'slideDown' ? 'slideUp' :
6831
 
                                        (showAnim == 'fadeIn' ? 'fadeOut' : 'hide')))](duration, postProcess);
6832
 
                        if (duration == '')
6833
 
                                this._tidyDialog(inst);
6834
 
                        var onClose = this._get(inst, 'onClose');
6835
 
                        if (onClose)
6836
 
                                onClose.apply((inst.input ? inst.input[0] : null),
6837
 
                                        [(inst.input ? inst.input.val() : ''), inst]);  // trigger custom callback
6838
 
                        this._datepickerShowing = false;
6839
 
                        this._lastInput = null;
6840
 
                        inst.settings.prompt = null;
6841
 
                        if (this._inDialog) {
6842
 
                                this._dialogInput.css({ position: 'absolute', left: '0', top: '-100px' });
6843
 
                                if ($.blockUI) {
6844
 
                                        $.unblockUI();
6845
 
                                        $('body').append(this.dpDiv);
6846
 
                                }
6847
 
                        }
6848
 
                        this._inDialog = false;
6849
 
                }
6850
 
                this._curInst = null;
6851
 
        },
6852
 
 
6853
 
        /* Tidy up after a dialog display. */
6854
 
        _tidyDialog: function(inst) {
6855
 
                inst.dpDiv.removeClass(this._dialogClass).unbind('.ui-datepicker');
6856
 
                $('.' + this._promptClass, inst.dpDiv).remove();
6857
 
        },
6858
 
 
6859
 
        /* Close date picker if clicked elsewhere. */
6860
 
        _checkExternalClick: function(event) {
6861
 
                if (!$.datepicker._curInst)
6862
 
                        return;
6863
 
                var $target = $(event.target);
6864
 
                if (($target.parents('#' + $.datepicker._mainDivId).length == 0) &&
6865
 
                                !$target.hasClass($.datepicker.markerClassName) &&
6866
 
                                !$target.hasClass($.datepicker._triggerClass) &&
6867
 
                                $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI))
6868
 
                        $.datepicker._hideDatepicker(null, '');
6869
 
        },
6870
 
 
6871
 
        /* Adjust one of the date sub-fields. */
6872
 
        _adjustDate: function(id, offset, period) {
6873
 
                var target = $(id);
6874
 
                var inst = this._getInst(target[0]);
6875
 
                this._adjustInstDate(inst, offset, period);
6876
 
                this._updateDatepicker(inst);
6877
 
        },
6878
 
 
6879
 
        /* Action for current link. */
6880
 
        _gotoToday: function(id) {
6881
 
                var target = $(id);
6882
 
                var inst = this._getInst(target[0]);
6883
 
                if (this._get(inst, 'gotoCurrent') && inst.currentDay) {
6884
 
                        inst.selectedDay = inst.currentDay;
6885
 
                        inst.drawMonth = inst.selectedMonth = inst.currentMonth;
6886
 
                        inst.drawYear = inst.selectedYear = inst.currentYear;
6887
 
                }
6888
 
                else {
6889
 
                var date = new Date();
6890
 
                inst.selectedDay = date.getDate();
6891
 
                inst.drawMonth = inst.selectedMonth = date.getMonth();
6892
 
                inst.drawYear = inst.selectedYear = date.getFullYear();
6893
 
                }
6894
 
                this._notifyChange(inst);
6895
 
                this._adjustDate(target);
6896
 
        },
6897
 
 
6898
 
        /* Action for selecting a new month/year. */
6899
 
        _selectMonthYear: function(id, select, period) {
6900
 
                var target = $(id);
6901
 
                var inst = this._getInst(target[0]);
6902
 
                inst._selectingMonthYear = false;
6903
 
                inst['selected' + (period == 'M' ? 'Month' : 'Year')] =
6904
 
                inst['draw' + (period == 'M' ? 'Month' : 'Year')] =
6905
 
                        parseInt(select.options[select.selectedIndex].value,10);
6906
 
                this._notifyChange(inst);
6907
 
                this._adjustDate(target);
6908
 
        },
6909
 
 
6910
 
        /* Restore input focus after not changing month/year. */
6911
 
        _clickMonthYear: function(id) {
6912
 
                var target = $(id);
6913
 
                var inst = this._getInst(target[0]);
6914
 
                if (inst.input && inst._selectingMonthYear && !$.browser.msie)
6915
 
                        inst.input[0].focus();
6916
 
                inst._selectingMonthYear = !inst._selectingMonthYear;
6917
 
        },
6918
 
 
6919
 
        /* Action for changing the first week day. */
6920
 
        _changeFirstDay: function(id, day) {
6921
 
                var target = $(id);
6922
 
                var inst = this._getInst(target[0]);
6923
 
                inst.settings.firstDay = day;
6924
 
                this._updateDatepicker(inst);
6925
 
        },
6926
 
 
6927
 
        /* Action for selecting a day. */
6928
 
        _selectDay: function(id, month, year, td) {
6929
 
                if ($(td).hasClass(this._unselectableClass))
6930
 
                        return;
6931
 
                var target = $(id);
6932
 
                var inst = this._getInst(target[0]);
6933
 
                var rangeSelect = this._get(inst, 'rangeSelect');
6934
 
                if (rangeSelect) {
6935
 
                        inst.stayOpen = !inst.stayOpen;
6936
 
                        if (inst.stayOpen) {
6937
 
                                $('.ui-datepicker td', inst.dpDiv).removeClass(this._currentClass);
6938
 
                                $(td).addClass(this._currentClass);
6939
 
                        } 
6940
 
                }
6941
 
                inst.selectedDay = inst.currentDay = $('a', td).html();
6942
 
                inst.selectedMonth = inst.currentMonth = month;
6943
 
                inst.selectedYear = inst.currentYear = year;
6944
 
                if (inst.stayOpen) {
6945
 
                        inst.endDay = inst.endMonth = inst.endYear = null;
6946
 
                }
6947
 
                else if (rangeSelect) {
6948
 
                        inst.endDay = inst.currentDay;
6949
 
                        inst.endMonth = inst.currentMonth;
6950
 
                        inst.endYear = inst.currentYear;
6951
 
                }
6952
 
                this._selectDate(id, this._formatDate(inst,
6953
 
                        inst.currentDay, inst.currentMonth, inst.currentYear));
6954
 
                if (inst.stayOpen) {
6955
 
                        inst.rangeStart = new Date(inst.currentYear, inst.currentMonth, inst.currentDay);
6956
 
                        this._updateDatepicker(inst);
6957
 
                }
6958
 
                else if (rangeSelect) {
6959
 
                        inst.selectedDay = inst.currentDay = inst.rangeStart.getDate();
6960
 
                        inst.selectedMonth = inst.currentMonth = inst.rangeStart.getMonth();
6961
 
                        inst.selectedYear = inst.currentYear = inst.rangeStart.getFullYear();
6962
 
                        inst.rangeStart = null;
6963
 
                        if (inst.inline)
6964
 
                                this._updateDatepicker(inst);
6965
 
                }
6966
 
        },
6967
 
 
6968
 
        /* Erase the input field and hide the date picker. */
6969
 
        _clearDate: function(id) {
6970
 
                var target = $(id);
6971
 
                var inst = this._getInst(target[0]);
6972
 
                if (this._get(inst, 'mandatory'))
6973
 
                        return;
6974
 
                inst.stayOpen = false;
6975
 
                inst.endDay = inst.endMonth = inst.endYear = inst.rangeStart = null;
6976
 
                this._selectDate(target, '');
6977
 
        },
6978
 
 
6979
 
        /* Update the input field with the selected date. */
6980
 
        _selectDate: function(id, dateStr) {
6981
 
                var target = $(id);
6982
 
                var inst = this._getInst(target[0]);
6983
 
                dateStr = (dateStr != null ? dateStr : this._formatDate(inst));
6984
 
                if (this._get(inst, 'rangeSelect') && dateStr)
6985
 
                        dateStr = (inst.rangeStart ? this._formatDate(inst, inst.rangeStart) :
6986
 
                                dateStr) + this._get(inst, 'rangeSeparator') + dateStr;
6987
 
                if (inst.input)
6988
 
                        inst.input.val(dateStr);
6989
 
                this._updateAlternate(inst);
6990
 
                var onSelect = this._get(inst, 'onSelect');
6991
 
                if (onSelect)
6992
 
                        onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]);  // trigger custom callback
6993
 
                else if (inst.input)
6994
 
                        inst.input.trigger('change'); // fire the change event
6995
 
                if (inst.inline)
6996
 
                        this._updateDatepicker(inst);
6997
 
                else if (!inst.stayOpen) {
6998
 
                        this._hideDatepicker(null, this._get(inst, 'duration'));
6999
 
                        this._lastInput = inst.input[0];
7000
 
                        if (typeof(inst.input[0]) != 'object')
7001
 
                                inst.input[0].focus(); // restore focus
7002
 
                        this._lastInput = null;
7003
 
                }
7004
 
        },
7005
 
        
7006
 
        /* Update any alternate field to synchronise with the main field. */
7007
 
        _updateAlternate: function(inst) {
7008
 
                var altField = this._get(inst, 'altField');
7009
 
                if (altField) { // update alternate field too
7010
 
                        var altFormat = this._get(inst, 'altFormat');
7011
 
                        var date = this._getDate(inst);
7012
 
                        dateStr = (isArray(date) ? (!date[0] && !date[1] ? '' :
7013
 
                                this.formatDate(altFormat, date[0], this._getFormatConfig(inst)) +
7014
 
                                this._get(inst, 'rangeSeparator') + this.formatDate(
7015
 
                                altFormat, date[1] || date[0], this._getFormatConfig(inst))) :
7016
 
                                this.formatDate(altFormat, date, this._getFormatConfig(inst)));
7017
 
                        $(altField).each(function() { $(this).val(dateStr); });
7018
 
                }
7019
 
        },
7020
 
 
7021
 
        /* Set as beforeShowDay function to prevent selection of weekends.
7022
 
           @param  date  Date - the date to customise
7023
 
           @return [boolean, string] - is this date selectable?, what is its CSS class? */
7024
 
        noWeekends: function(date) {
7025
 
                var day = date.getDay();
7026
 
                return [(day > 0 && day < 6), ''];
7027
 
        },
7028
 
        
7029
 
        /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
7030
 
           @param  date  Date - the date to get the week for
7031
 
           @return  number - the number of the week within the year that contains this date */
7032
 
        iso8601Week: function(date) {
7033
 
                var checkDate = new Date(date.getFullYear(), date.getMonth(), date.getDate(),
7034
 
                        (date.getTimezoneOffset() / -60));
7035
 
                var firstMon = new Date(checkDate.getFullYear(), 1 - 1, 4); // First week always contains 4 Jan
7036
 
                var firstDay = firstMon.getDay() || 7; // Day of week: Mon = 1, ..., Sun = 7
7037
 
                firstMon.setDate(firstMon.getDate() + 1 - firstDay); // Preceding Monday
7038
 
                if (firstDay < 4 && checkDate < firstMon) { // Adjust first three days in year if necessary
7039
 
                        checkDate.setDate(checkDate.getDate() - 3); // Generate for previous year
7040
 
                        return $.datepicker.iso8601Week(checkDate);
7041
 
                } else if (checkDate > new Date(checkDate.getFullYear(), 12 - 1, 28)) { // Check last three days in year
7042
 
                        firstDay = new Date(checkDate.getFullYear() + 1, 1 - 1, 4).getDay() || 7;
7043
 
                        if (firstDay > 4 && (checkDate.getDay() || 7) < firstDay - 3) { // Adjust if necessary
7044
 
                                return 1;
7045
 
                        }
7046
 
                }
7047
 
                return Math.floor(((checkDate - firstMon) / 86400000) / 7) + 1; // Weeks to given date
7048
 
        },
7049
 
        
7050
 
        /* Provide status text for a particular date.
7051
 
           @param  date  the date to get the status for
7052
 
           @param  inst  the current datepicker instance
7053
 
           @return  the status display text for this date */
7054
 
        dateStatus: function(date, inst) {
7055
 
                return $.datepicker.formatDate($.datepicker._get(inst, 'dateStatus'),
7056
 
                        date, $.datepicker._getFormatConfig(inst));
7057
 
        },
7058
 
 
7059
 
        /* Parse a string value into a date object.
7060
 
           See formatDate below for the possible formats.
7061
 
 
7062
 
           @param  format    string - the expected format of the date
7063
 
           @param  value     string - the date in the above format
7064
 
           @param  settings  Object - attributes include:
7065
 
                             shortYearCutoff  number - the cutoff year for determining the century (optional)
7066
 
                             dayNamesShort    string[7] - abbreviated names of the days from Sunday (optional)
7067
 
                             dayNames         string[7] - names of the days from Sunday (optional)
7068
 
                             monthNamesShort  string[12] - abbreviated names of the months (optional)
7069
 
                             monthNames       string[12] - names of the months (optional)
7070
 
           @return  Date - the extracted date value or null if value is blank */
7071
 
        parseDate: function (format, value, settings) {
7072
 
                if (format == null || value == null)
7073
 
                        throw 'Invalid arguments';
7074
 
                value = (typeof value == 'object' ? value.toString() : value + '');
7075
 
                if (value == '')
7076
 
                        return null;
7077
 
                var shortYearCutoff = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff;
7078
 
                var dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort;
7079
 
                var dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames;
7080
 
                var monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort;
7081
 
                var monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames;
7082
 
                var year = -1;
7083
 
                var month = -1;
7084
 
                var day = -1;
7085
 
                var doy = -1;
7086
 
                var literal = false;
7087
 
                // Check whether a format character is doubled
7088
 
                var lookAhead = function(match) {
7089
 
                        var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
7090
 
                        if (matches)
7091
 
                                iFormat++;
7092
 
                        return matches; 
7093
 
                };
7094
 
                // Extract a number from the string value
7095
 
                var getNumber = function(match) {
7096
 
                        lookAhead(match);
7097
 
                        var origSize = (match == '@' ? 14 : (match == 'y' ? 4 : (match == 'o' ? 3 : 2)));
7098
 
                        var size = origSize;
7099
 
                        var num = 0;
7100
 
                        while (size > 0 && iValue < value.length &&
7101
 
                                        value.charAt(iValue) >= '0' && value.charAt(iValue) <= '9') {
7102
 
                                num = num * 10 + parseInt(value.charAt(iValue++),10);
7103
 
                                size--;
7104
 
                        }
7105
 
                        if (size == origSize)
7106
 
                                throw 'Missing number at position ' + iValue;
7107
 
                        return num;
7108
 
                };
7109
 
                // Extract a name from the string value and convert to an index
7110
 
                var getName = function(match, shortNames, longNames) {
7111
 
                        var names = (lookAhead(match) ? longNames : shortNames);
7112
 
                        var size = 0;
7113
 
                        for (var j = 0; j < names.length; j++)
7114
 
                                size = Math.max(size, names[j].length);
7115
 
                        var name = '';
7116
 
                        var iInit = iValue;
7117
 
                        while (size > 0 && iValue < value.length) {
7118
 
                                name += value.charAt(iValue++);
7119
 
                                for (var i = 0; i < names.length; i++)
7120
 
                                        if (name == names[i])
7121
 
                                                return i + 1;
7122
 
                                size--;
7123
 
                        }
7124
 
                        throw 'Unknown name at position ' + iInit;
7125
 
                };
7126
 
                // Confirm that a literal character matches the string value
7127
 
                var checkLiteral = function() {
7128
 
                        if (value.charAt(iValue) != format.charAt(iFormat))
7129
 
                                throw 'Unexpected literal at position ' + iValue;
7130
 
                        iValue++;
7131
 
                };
7132
 
                var iValue = 0;
7133
 
                for (var iFormat = 0; iFormat < format.length; iFormat++) {
7134
 
                        if (literal)
7135
 
                                if (format.charAt(iFormat) == "'" && !lookAhead("'"))
7136
 
                                        literal = false;
7137
 
                                else
7138
 
                                        checkLiteral();
7139
 
                        else
7140
 
                                switch (format.charAt(iFormat)) {
7141
 
                                        case 'd':
7142
 
                                                day = getNumber('d');
7143
 
                                                break;
7144
 
                                        case 'D': 
7145
 
                                                getName('D', dayNamesShort, dayNames);
7146
 
                                                break;
7147
 
                                        case 'o':
7148
 
                                                doy = getNumber('o');
7149
 
                                                break;
7150
 
                                        case 'm': 
7151
 
                                                month = getNumber('m');
7152
 
                                                break;
7153
 
                                        case 'M':
7154
 
                                                month = getName('M', monthNamesShort, monthNames); 
7155
 
                                                break;
7156
 
                                        case 'y':
7157
 
                                                year = getNumber('y');
7158
 
                                                break;
7159
 
                                        case '@':
7160
 
                                                var date = new Date(getNumber('@'));
7161
 
                                                year = date.getFullYear();
7162
 
                                                month = date.getMonth() + 1;
7163
 
                                                day = date.getDate();
7164
 
                                                break;
7165
 
                                        case "'":
7166
 
                                                if (lookAhead("'"))
7167
 
                                                        checkLiteral();
7168
 
                                                else
7169
 
                                                        literal = true;
7170
 
                                                break;
7171
 
                                        default:
7172
 
                                                checkLiteral();
7173
 
                                }
7174
 
                }
7175
 
                if (year < 100)
7176
 
                        year += new Date().getFullYear() - new Date().getFullYear() % 100 +
7177
 
                                (year <= shortYearCutoff ? 0 : -100);
7178
 
                if (doy > -1) {
7179
 
                        month = 1;
7180
 
                        day = doy;
7181
 
                        do {
7182
 
                                var dim = this._getDaysInMonth(year, month - 1);
7183
 
                                if (day <= dim)
7184
 
                                        break;
7185
 
                                month++;
7186
 
                                day -= dim;
7187
 
                        } while (true);
7188
 
                }
7189
 
                var date = new Date(year, month - 1, day);
7190
 
                if (date.getFullYear() != year || date.getMonth() + 1 != month || date.getDate() != day)
7191
 
                        throw 'Invalid date'; // E.g. 31/02/*
7192
 
                return date;
7193
 
        },
7194
 
 
7195
 
        /* Standard date formats. */
7196
 
        ATOM: 'yy-mm-dd', // RFC 3339 (ISO 8601)
7197
 
        COOKIE: 'D, dd M yy',
7198
 
        ISO_8601: 'yy-mm-dd',
7199
 
        RFC_822: 'D, d M y',
7200
 
        RFC_850: 'DD, dd-M-y',
7201
 
        RFC_1036: 'D, d M y',
7202
 
        RFC_1123: 'D, d M yy',
7203
 
        RFC_2822: 'D, d M yy',
7204
 
        RSS: 'D, d M y', // RFC 822
7205
 
        TIMESTAMP: '@',
7206
 
        W3C: 'yy-mm-dd', // ISO 8601
7207
 
 
7208
 
        /* Format a date object into a string value.
7209
 
           The format can be combinations of the following:
7210
 
           d  - day of month (no leading zero)
7211
 
           dd - day of month (two digit)
7212
 
           o  - day of year (no leading zeros)
7213
 
           oo - day of year (three digit)
7214
 
           D  - day name short
7215
 
           DD - day name long
7216
 
           m  - month of year (no leading zero)
7217
 
           mm - month of year (two digit)
7218
 
           M  - month name short
7219
 
           MM - month name long
7220
 
           y  - year (two digit)
7221
 
           yy - year (four digit)
7222
 
           @ - Unix timestamp (ms since 01/01/1970)
7223
 
           '...' - literal text
7224
 
           '' - single quote
7225
 
 
7226
 
           @param  format    string - the desired format of the date
7227
 
           @param  date      Date - the date value to format
7228
 
           @param  settings  Object - attributes include:
7229
 
                             dayNamesShort    string[7] - abbreviated names of the days from Sunday (optional)
7230
 
                             dayNames         string[7] - names of the days from Sunday (optional)
7231
 
                             monthNamesShort  string[12] - abbreviated names of the months (optional)
7232
 
                             monthNames       string[12] - names of the months (optional)
7233
 
           @return  string - the date in the above format */
7234
 
        formatDate: function (format, date, settings) {
7235
 
                if (!date)
7236
 
                        return '';
7237
 
                var dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort;
7238
 
                var dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames;
7239
 
                var monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort;
7240
 
                var monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames;
7241
 
                // Check whether a format character is doubled
7242
 
                var lookAhead = function(match) {
7243
 
                        var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
7244
 
                        if (matches)
7245
 
                                iFormat++;
7246
 
                        return matches; 
7247
 
                };
7248
 
                // Format a number, with leading zero if necessary
7249
 
                var formatNumber = function(match, value, len) {
7250
 
                        var num = '' + value;
7251
 
                        if (lookAhead(match))
7252
 
                                while (num.length < len)
7253
 
                                        num = '0' + num;
7254
 
                        return num;
7255
 
                };
7256
 
                // Format a name, short or long as requested
7257
 
                var formatName = function(match, value, shortNames, longNames) {
7258
 
                        return (lookAhead(match) ? longNames[value] : shortNames[value]);
7259
 
                };
7260
 
                var output = '';
7261
 
                var literal = false;
7262
 
                if (date)
7263
 
                        for (var iFormat = 0; iFormat < format.length; iFormat++) {
7264
 
                                if (literal)
7265
 
                                        if (format.charAt(iFormat) == "'" && !lookAhead("'"))
7266
 
                                                literal = false;
7267
 
                                        else
7268
 
                                                output += format.charAt(iFormat);
7269
 
                                else
7270
 
                                        switch (format.charAt(iFormat)) {
7271
 
                                                case 'd':
7272
 
                                                        output += formatNumber('d', date.getDate(), 2);
7273
 
                                                        break;
7274
 
                                                case 'D': 
7275
 
                                                        output += formatName('D', date.getDay(), dayNamesShort, dayNames);
7276
 
                                                        break;
7277
 
                                                case 'o':
7278
 
                                                        var doy = date.getDate();
7279
 
                                                        for (var m = date.getMonth() - 1; m >= 0; m--)
7280
 
                                                                doy += this._getDaysInMonth(date.getFullYear(), m);
7281
 
                                                        output += formatNumber('o', doy, 3);
7282
 
                                                        break;
7283
 
                                                case 'm': 
7284
 
                                                        output += formatNumber('m', date.getMonth() + 1, 2);
7285
 
                                                        break;
7286
 
                                                case 'M':
7287
 
                                                        output += formatName('M', date.getMonth(), monthNamesShort, monthNames); 
7288
 
                                                        break;
7289
 
                                                case 'y':
7290
 
                                                        output += (lookAhead('y') ? date.getFullYear() : 
7291
 
                                                                (date.getYear() % 100 < 10 ? '0' : '') + date.getYear() % 100);
7292
 
                                                        break;
7293
 
                                                case '@':
7294
 
                                                        output += date.getTime(); 
7295
 
                                                        break;
7296
 
                                                case "'":
7297
 
                                                        if (lookAhead("'"))
7298
 
                                                                output += "'";
7299
 
                                                        else
7300
 
                                                                literal = true;
7301
 
                                                        break;
7302
 
                                                default:
7303
 
                                                        output += format.charAt(iFormat);
7304
 
                                        }
7305
 
                        }
7306
 
                return output;
7307
 
        },
7308
 
 
7309
 
        /* Extract all possible characters from the date format. */
7310
 
        _possibleChars: function (format) {
7311
 
                var chars = '';
7312
 
                var literal = false;
7313
 
                for (var iFormat = 0; iFormat < format.length; iFormat++)
7314
 
                        if (literal)
7315
 
                                if (format.charAt(iFormat) == "'" && !lookAhead("'"))
7316
 
                                        literal = false;
7317
 
                                else
7318
 
                                        chars += format.charAt(iFormat);
7319
 
                        else
7320
 
                                switch (format.charAt(iFormat)) {
7321
 
                                        case 'd': case 'm': case 'y': case '@':
7322
 
                                                chars += '0123456789'; 
7323
 
                                                break;
7324
 
                                        case 'D': case 'M':
7325
 
                                                return null; // Accept anything
7326
 
                                        case "'":
7327
 
                                                if (lookAhead("'"))
7328
 
                                                        chars += "'";
7329
 
                                                else
7330
 
                                                        literal = true;
7331
 
                                                break;
7332
 
                                        default:
7333
 
                                                chars += format.charAt(iFormat);
7334
 
                                }
7335
 
                return chars;
7336
 
        },
7337
 
 
7338
 
        /* Get a setting value, defaulting if necessary. */
7339
 
        _get: function(inst, name) {
7340
 
                return inst.settings[name] !== undefined ?
7341
 
                        inst.settings[name] : this._defaults[name];
7342
 
        },
7343
 
 
7344
 
        /* Parse existing date and initialise date picker. */
7345
 
        _setDateFromField: function(inst) {
7346
 
                var dateFormat = this._get(inst, 'dateFormat');
7347
 
                var dates = inst.input ? inst.input.val().split(this._get(inst, 'rangeSeparator')) : null; 
7348
 
                inst.endDay = inst.endMonth = inst.endYear = null;
7349
 
                var date = defaultDate = this._getDefaultDate(inst);
7350
 
                if (dates.length > 0) {
7351
 
                        var settings = this._getFormatConfig(inst);
7352
 
                        if (dates.length > 1) {
7353
 
                                date = this.parseDate(dateFormat, dates[1], settings) || defaultDate;
7354
 
                                inst.endDay = date.getDate();
7355
 
                                inst.endMonth = date.getMonth();
7356
 
                                inst.endYear = date.getFullYear();
7357
 
                        }
7358
 
                        try {
7359
 
                                date = this.parseDate(dateFormat, dates[0], settings) || defaultDate;
7360
 
                        } catch (e) {
7361
 
                                this.log(e);
7362
 
                                date = defaultDate;
7363
 
                        }
7364
 
                }
7365
 
                inst.selectedDay = date.getDate();
7366
 
                inst.drawMonth = inst.selectedMonth = date.getMonth();
7367
 
                inst.drawYear = inst.selectedYear = date.getFullYear();
7368
 
                inst.currentDay = (dates[0] ? date.getDate() : 0);
7369
 
                inst.currentMonth = (dates[0] ? date.getMonth() : 0);
7370
 
                inst.currentYear = (dates[0] ? date.getFullYear() : 0);
7371
 
                this._adjustInstDate(inst);
7372
 
        },
7373
 
        
7374
 
        /* Retrieve the default date shown on opening. */
7375
 
        _getDefaultDate: function(inst) {
7376
 
                var date = this._determineDate(this._get(inst, 'defaultDate'), new Date());
7377
 
                var minDate = this._getMinMaxDate(inst, 'min', true);
7378
 
                var maxDate = this._getMinMaxDate(inst, 'max');
7379
 
                date = (minDate && date < minDate ? minDate : date);
7380
 
                date = (maxDate && date > maxDate ? maxDate : date);
7381
 
                return date;
7382
 
        },
7383
 
 
7384
 
        /* A date may be specified as an exact value or a relative one. */
7385
 
        _determineDate: function(date, defaultDate) {
7386
 
                var offsetNumeric = function(offset) {
7387
 
                        var date = new Date();
7388
 
                        date.setUTCDate(date.getUTCDate() + offset);
7389
 
                        return date;
7390
 
                };
7391
 
                var offsetString = function(offset, getDaysInMonth) {
7392
 
                        var date = new Date();
7393
 
                        var year = date.getFullYear();
7394
 
                        var month = date.getMonth();
7395
 
                        var day = date.getDate();
7396
 
                        var pattern = /([+-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g;
7397
 
                        var matches = pattern.exec(offset);
7398
 
                        while (matches) {
7399
 
                                switch (matches[2] || 'd') {
7400
 
                                        case 'd' : case 'D' :
7401
 
                                                day += parseInt(matches[1],10); break;
7402
 
                                        case 'w' : case 'W' :
7403
 
                                                day += parseInt(matches[1],10) * 7; break;
7404
 
                                        case 'm' : case 'M' :
7405
 
                                                month += parseInt(matches[1],10); 
7406
 
                                                day = Math.min(day, getDaysInMonth(year, month));
7407
 
                                                break;
7408
 
                                        case 'y': case 'Y' :
7409
 
                                                year += parseInt(matches[1],10);
7410
 
                                                day = Math.min(day, getDaysInMonth(year, month));
7411
 
                                                break;
7412
 
                                }
7413
 
                                matches = pattern.exec(offset);
7414
 
                        }
7415
 
                        return new Date(year, month, day);
7416
 
                };
7417
 
                date = (date == null ? defaultDate :
7418
 
                        (typeof date == 'string' ? offsetString(date, this._getDaysInMonth) :
7419
 
                        (typeof date == 'number' ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : date)));
7420
 
                return (date && date.toString() == 'Invalid Date' ? defaultDate : date);
7421
 
        },
7422
 
 
7423
 
        /* Set the date(s) directly. */
7424
 
        _setDate: function(inst, date, endDate) {
7425
 
                var clear = !(date);
7426
 
                var origMonth = inst.selectedMonth;
7427
 
                var origYear = inst.selectedYear;
7428
 
                date = this._determineDate(date, new Date());
7429
 
                inst.selectedDay = inst.currentDay = date.getDate();
7430
 
                inst.drawMonth = inst.selectedMonth = inst.currentMonth = date.getMonth();
7431
 
                inst.drawYear = inst.selectedYear = inst.currentYear = date.getFullYear();
7432
 
                if (this._get(inst, 'rangeSelect')) {
7433
 
                        if (endDate) {
7434
 
                                endDate = this._determineDate(endDate, null);
7435
 
                                inst.endDay = endDate.getDate();
7436
 
                                inst.endMonth = endDate.getMonth();
7437
 
                                inst.endYear = endDate.getFullYear();
7438
 
                        } else {
7439
 
                                inst.endDay = inst.currentDay;
7440
 
                                inst.endMonth = inst.currentMonth;
7441
 
                                inst.endYear = inst.currentYear;
7442
 
                        }
7443
 
                }
7444
 
                if (origMonth != inst.selectedMonth || origYear != inst.selectedYear)
7445
 
                        this._notifyChange(inst);
7446
 
                this._adjustInstDate(inst);
7447
 
                if (inst.input)
7448
 
                        inst.input.val(clear ? '' : this._formatDate(inst) +
7449
 
                                (!this._get(inst, 'rangeSelect') ? '' : this._get(inst, 'rangeSeparator') +
7450
 
                                this._formatDate(inst, inst.endDay, inst.endMonth, inst.endYear)));
7451
 
        },
7452
 
 
7453
 
        /* Retrieve the date(s) directly. */
7454
 
        _getDate: function(inst) {
7455
 
                var startDate = (!inst.currentYear || (inst.input && inst.input.val() == '') ? null :
7456
 
                        new Date(inst.currentYear, inst.currentMonth, inst.currentDay));
7457
 
                if (this._get(inst, 'rangeSelect')) {
7458
 
                        return [inst.rangeStart || startDate,
7459
 
                                (!inst.endYear ? inst.rangeStart || startDate :
7460
 
                                new Date(inst.endYear, inst.endMonth, inst.endDay))];
7461
 
                } else
7462
 
                        return startDate;
7463
 
        },
7464
 
 
7465
 
        /* Generate the HTML for the current state of the date picker. */
7466
 
        _generateHTML: function(inst) {
7467
 
                var today = new Date();
7468
 
                today = new Date(today.getFullYear(), today.getMonth(), today.getDate()); // clear time
7469
 
                var showStatus = this._get(inst, 'showStatus');
7470
 
                var initStatus = this._get(inst, 'initStatus') || '&#xa0;';
7471
 
                var isRTL = this._get(inst, 'isRTL');
7472
 
                // build the date picker HTML
7473
 
                var clear = (this._get(inst, 'mandatory') ? '' :
7474
 
                        '<div class="ui-datepicker-clear"><a onclick="jQuery.datepicker._clearDate(\'#' + inst.id + '\');"' +
7475
 
                        this._addStatus(showStatus, inst.id, this._get(inst, 'clearStatus'), initStatus) + '>' +
7476
 
                        this._get(inst, 'clearText') + '</a></div>');
7477
 
                var controls = '<div class="ui-datepicker-control">' + (isRTL ? '' : clear) +
7478
 
                        '<div class="ui-datepicker-close"><a onclick="jQuery.datepicker._hideDatepicker();"' +
7479
 
                        this._addStatus(showStatus, inst.id, this._get(inst, 'closeStatus'), initStatus) + '>' +
7480
 
                        this._get(inst, 'closeText') + '</a></div>' + (isRTL ? clear : '')  + '</div>';
7481
 
                var prompt = this._get(inst, 'prompt');
7482
 
                var closeAtTop = this._get(inst, 'closeAtTop');
7483
 
                var hideIfNoPrevNext = this._get(inst, 'hideIfNoPrevNext');
7484
 
                var navigationAsDateFormat = this._get(inst, 'navigationAsDateFormat');
7485
 
                var showBigPrevNext = this._get(inst, 'showBigPrevNext');
7486
 
                var numMonths = this._getNumberOfMonths(inst);
7487
 
                var showCurrentAtPos = this._get(inst, 'showCurrentAtPos');
7488
 
                var stepMonths = this._get(inst, 'stepMonths');
7489
 
                var stepBigMonths = this._get(inst, 'stepBigMonths');
7490
 
                var isMultiMonth = (numMonths[0] != 1 || numMonths[1] != 1);
7491
 
                var currentDate = (!inst.currentDay ? new Date(9999, 9, 9) :
7492
 
                        new Date(inst.currentYear, inst.currentMonth, inst.currentDay));
7493
 
                var minDate = this._getMinMaxDate(inst, 'min', true);
7494
 
                var maxDate = this._getMinMaxDate(inst, 'max');
7495
 
                var drawMonth = inst.drawMonth - showCurrentAtPos;
7496
 
                var drawYear = inst.drawYear;
7497
 
                if (drawMonth < 0) {
7498
 
                        drawMonth += 12;
7499
 
                        drawYear--;
7500
 
                }
7501
 
                if (maxDate) {
7502
 
                        var maxDraw = new Date(maxDate.getFullYear(),
7503
 
                                maxDate.getMonth() - numMonths[1] + 1, maxDate.getDate());
7504
 
                        maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw);
7505
 
                        while (new Date(drawYear, drawMonth, 1) > maxDraw) {
7506
 
                                drawMonth--;
7507
 
                                if (drawMonth < 0) {
7508
 
                                        drawMonth = 11;
7509
 
                                        drawYear--;
7510
 
                                }
7511
 
                        }
7512
 
                }
7513
 
                // controls and links
7514
 
                var prevText = this._get(inst, 'prevText');
7515
 
                prevText = (!navigationAsDateFormat ? prevText : this.formatDate(
7516
 
                        prevText, new Date(drawYear, drawMonth - stepMonths, 1), this._getFormatConfig(inst)));
7517
 
                var prevBigText = (showBigPrevNext ? this._get(inst, 'prevBigText') : '');
7518
 
                prevBigText = (!navigationAsDateFormat ? prevBigText : this.formatDate(
7519
 
                        prevBigText, new Date(drawYear, drawMonth - stepBigMonths, 1), this._getFormatConfig(inst)));
7520
 
                var prev = '<div class="ui-datepicker-prev">' + (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ? 
7521
 
                        (showBigPrevNext ? '<a onclick="jQuery.datepicker._adjustDate(\'#' + inst.id + '\', -' + stepBigMonths + ', \'M\');"' +
7522
 
                        this._addStatus(showStatus, inst.id, this._get(inst, 'prevBigStatus'), initStatus) + '>' + prevBigText + '</a>' : '') +
7523
 
                        '<a onclick="jQuery.datepicker._adjustDate(\'#' + inst.id + '\', -' + stepMonths + ', \'M\');"' +
7524
 
                        this._addStatus(showStatus, inst.id, this._get(inst, 'prevStatus'), initStatus) + '>' + prevText + '</a>' :
7525
 
                        (hideIfNoPrevNext ? '' : '<label>' + prevBigText + '</label><label>' + prevText + '</label>')) + '</div>';
7526
 
                var nextText = this._get(inst, 'nextText');
7527
 
                nextText = (!navigationAsDateFormat ? nextText : this.formatDate(
7528
 
                        nextText, new Date(drawYear, drawMonth + stepMonths, 1), this._getFormatConfig(inst)));
7529
 
                var nextBigText = (showBigPrevNext ? this._get(inst, 'nextBigText') : '');
7530
 
                nextBigText = (!navigationAsDateFormat ? nextBigText : this.formatDate(
7531
 
                        nextBigText, new Date(drawYear, drawMonth + stepBigMonths, 1), this._getFormatConfig(inst)));
7532
 
                var next = '<div class="ui-datepicker-next">' + (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ?
7533
 
                        '<a onclick="jQuery.datepicker._adjustDate(\'#' + inst.id + '\', +' + stepMonths + ', \'M\');"' +
7534
 
                        this._addStatus(showStatus, inst.id, this._get(inst, 'nextStatus'), initStatus) + '>' + nextText + '</a>' +
7535
 
                        (showBigPrevNext ? '<a onclick="jQuery.datepicker._adjustDate(\'#' + inst.id + '\', +' + stepBigMonths + ', \'M\');"' +
7536
 
                        this._addStatus(showStatus, inst.id, this._get(inst, 'nextBigStatus'), initStatus) + '>' + nextBigText + '</a>' : '') :
7537
 
                        (hideIfNoPrevNext ? '' : '<label>' + nextText + '</label><label>' + nextBigText + '</label>')) + '</div>';
7538
 
                var currentText = this._get(inst, 'currentText');
7539
 
                var gotoDate = (this._get(inst, 'gotoCurrent') && inst.currentDay ? currentDate : today); 
7540
 
                currentText = (!navigationAsDateFormat ? currentText :
7541
 
                        this.formatDate(currentText, gotoDate, this._getFormatConfig(inst)));
7542
 
                var html = (prompt ? '<div class="' + this._promptClass + '">' + prompt + '</div>' : '') +
7543
 
                        (closeAtTop && !inst.inline ? controls : '') +
7544
 
                        '<div class="ui-datepicker-links">' + (isRTL ? next : prev) +
7545
 
                        (this._isInRange(inst, gotoDate) ? '<div class="ui-datepicker-current">' +
7546
 
                        '<a onclick="jQuery.datepicker._gotoToday(\'#' + inst.id + '\');"' +
7547
 
                        this._addStatus(showStatus, inst.id, this._get(inst, 'currentStatus'), initStatus) + '>' +
7548
 
                        currentText + '</a></div>' : '') + (isRTL ? prev : next) + '</div>';
7549
 
                var firstDay = this._get(inst, 'firstDay');
7550
 
                var changeFirstDay = this._get(inst, 'changeFirstDay');
7551
 
                var dayNames = this._get(inst, 'dayNames');
7552
 
                var dayNamesShort = this._get(inst, 'dayNamesShort');
7553
 
                var dayNamesMin = this._get(inst, 'dayNamesMin');
7554
 
                var monthNames = this._get(inst, 'monthNames');
7555
 
                var beforeShowDay = this._get(inst, 'beforeShowDay');
7556
 
                var highlightWeek = this._get(inst, 'highlightWeek');
7557
 
                var showOtherMonths = this._get(inst, 'showOtherMonths');
7558
 
                var showWeeks = this._get(inst, 'showWeeks');
7559
 
                var calculateWeek = this._get(inst, 'calculateWeek') || this.iso8601Week;
7560
 
                var weekStatus = this._get(inst, 'weekStatus');
7561
 
                var status = (showStatus ? this._get(inst, 'dayStatus') || initStatus : '');
7562
 
                var dateStatus = this._get(inst, 'statusForDate') || this.dateStatus;
7563
 
                var endDate = inst.endDay ? new Date(inst.endYear, inst.endMonth, inst.endDay) : currentDate;
7564
 
                for (var row = 0; row < numMonths[0]; row++)
7565
 
                        for (var col = 0; col < numMonths[1]; col++) {
7566
 
                                var selectedDate = new Date(drawYear, drawMonth, inst.selectedDay);
7567
 
                                html += '<div class="ui-datepicker-one-month' + (col == 0 ? ' ui-datepicker-new-row' : '') + '">' +
7568
 
                                        this._generateMonthYearHeader(inst, drawMonth, drawYear, minDate, maxDate,
7569
 
                                        selectedDate, row > 0 || col > 0, showStatus, initStatus, monthNames) + // draw month headers
7570
 
                                        '<table class="ui-datepicker" cellpadding="0" cellspacing="0"><thead>' + 
7571
 
                                        '<tr class="ui-datepicker-title-row">' +
7572
 
                                        (showWeeks ? '<td' + this._addStatus(showStatus, inst.id, weekStatus, initStatus) + '>' +
7573
 
                                        this._get(inst, 'weekHeader') + '</td>' : '');
7574
 
                                for (var dow = 0; dow < 7; dow++) { // days of the week
7575
 
                                        var day = (dow + firstDay) % 7;
7576
 
                                        var dayStatus = (status.indexOf('DD') > -1 ? status.replace(/DD/, dayNames[day]) :
7577
 
                                                status.replace(/D/, dayNamesShort[day]));
7578
 
                                        html += '<td' + ((dow + firstDay + 6) % 7 >= 5 ? ' class="ui-datepicker-week-end-cell"' : '') + '>' +
7579
 
                                                (!changeFirstDay ? '<span' :
7580
 
                                                '<a onclick="jQuery.datepicker._changeFirstDay(\'#' + inst.id + '\', ' + day + ');"') + 
7581
 
                                                this._addStatus(showStatus, inst.id, dayStatus, initStatus) + ' title="' + dayNames[day] + '">' +
7582
 
                                                dayNamesMin[day] + (changeFirstDay ? '</a>' : '</span>') + '</td>';
7583
 
                                }
7584
 
                                html += '</tr></thead><tbody>';
7585
 
                                var daysInMonth = this._getDaysInMonth(drawYear, drawMonth);
7586
 
                                if (drawYear == inst.selectedYear && drawMonth == inst.selectedMonth)
7587
 
                                        inst.selectedDay = Math.min(inst.selectedDay, daysInMonth);
7588
 
                                var leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7;
7589
 
                                var tzDate = new Date(drawYear, drawMonth, 1 - leadDays);
7590
 
                                var utcDate = new Date(drawYear, drawMonth, 1 - leadDays);
7591
 
                                var printDate = utcDate;
7592
 
                                var numRows = (isMultiMonth ? 6 : Math.ceil((leadDays + daysInMonth) / 7)); // calculate the number of rows to generate
7593
 
                                for (var dRow = 0; dRow < numRows; dRow++) { // create date picker rows
7594
 
                                        html += '<tr class="ui-datepicker-days-row">' +
7595
 
                                                (showWeeks ? '<td class="ui-datepicker-week-col"' +
7596
 
                                                this._addStatus(showStatus, inst.id, weekStatus, initStatus) + '>' +
7597
 
                                                calculateWeek(printDate) + '</td>' : '');
7598
 
                                        for (var dow = 0; dow < 7; dow++) { // create date picker days
7599
 
                                                var daySettings = (beforeShowDay ?
7600
 
                                                        beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, '']);
7601
 
                                                var otherMonth = (printDate.getMonth() != drawMonth);
7602
 
                                                var unselectable = otherMonth || !daySettings[0] ||
7603
 
                                                        (minDate && printDate < minDate) || (maxDate && printDate > maxDate);
7604
 
                                                html += '<td class="ui-datepicker-days-cell' +
7605
 
                                                        ((dow + firstDay + 6) % 7 >= 5 ? ' ui-datepicker-week-end-cell' : '') + // highlight weekends
7606
 
                                                        (otherMonth ? ' ui-datepicker-other-month' : '') + // highlight days from other months
7607
 
                                                        (printDate.getTime() == selectedDate.getTime() && drawMonth == inst.selectedMonth ?
7608
 
                                                        ' ui-datepicker-days-cell-over' : '') + // highlight selected day
7609
 
                                                        (unselectable ? ' ' + this._unselectableClass : '') +  // highlight unselectable days
7610
 
                                                        (otherMonth && !showOtherMonths ? '' : ' ' + daySettings[1] + // highlight custom dates
7611
 
                                                        (printDate.getTime() >= currentDate.getTime() && printDate.getTime() <= endDate.getTime() ?  // in current range
7612
 
                                                        ' ' + this._currentClass : '') + // highlight selected day
7613
 
                                                        (printDate.getTime() == today.getTime() ? ' ui-datepicker-today' : '')) + '"' + // highlight today (if different)
7614
 
                                                        ((!otherMonth || showOtherMonths) && daySettings[2] ? ' title="' + daySettings[2] + '"' : '') + // cell title
7615
 
                                                        (unselectable ? (highlightWeek ? ' onmouseover="jQuery(this).parent().addClass(\'ui-datepicker-week-over\');"' + // highlight selection week
7616
 
                                                        ' onmouseout="jQuery(this).parent().removeClass(\'ui-datepicker-week-over\');"' : '') : // unhighlight selection week
7617
 
                                                        ' onmouseover="jQuery(this).addClass(\'ui-datepicker-days-cell-over\')' + // highlight selection
7618
 
                                                        (highlightWeek ? '.parent().addClass(\'ui-datepicker-week-over\')' : '') + ';' + // highlight selection week
7619
 
                                                        (!showStatus || (otherMonth && !showOtherMonths) ? '' : 'jQuery(\'#ui-datepicker-status-' +
7620
 
                                                        inst.id + '\').html(\'' + (dateStatus.apply((inst.input ? inst.input[0] : null),
7621
 
                                                        [printDate, inst]) || initStatus) +'\');') + '"' +
7622
 
                                                        ' onmouseout="jQuery(this).removeClass(\'ui-datepicker-days-cell-over\')' + // unhighlight selection
7623
 
                                                        (highlightWeek ? '.parent().removeClass(\'ui-datepicker-week-over\')' : '') + ';' + // unhighlight selection week
7624
 
                                                        (!showStatus || (otherMonth && !showOtherMonths) ? '' : 'jQuery(\'#ui-datepicker-status-' +
7625
 
                                                        inst.id + '\').html(\'' + initStatus + '\');') + '" onclick="jQuery.datepicker._selectDay(\'#' +
7626
 
                                                        inst.id + '\',' + drawMonth + ',' + drawYear + ', this);"') + '>' + // actions
7627
 
                                                        (otherMonth ? (showOtherMonths ? printDate.getDate() : '&#xa0;') : // display for other months
7628
 
                                                        (unselectable ? printDate.getDate() : '<a>' + printDate.getDate() + '</a>')) + '</td>'; // display for this month
7629
 
                                                tzDate.setDate(tzDate.getDate() + 1);
7630
 
                                                utcDate.setUTCDate(utcDate.getUTCDate() + 1);
7631
 
                                                printDate = (tzDate > utcDate ? tzDate : utcDate);
7632
 
                                        }
7633
 
                                        html += '</tr>';
7634
 
                                }
7635
 
                                drawMonth++;
7636
 
                                if (drawMonth > 11) {
7637
 
                                        drawMonth = 0;
7638
 
                                        drawYear++;
7639
 
                                }
7640
 
                                html += '</tbody></table></div>';
7641
 
                        }
7642
 
                html += (showStatus ? '<div style="clear: both;"></div><div id="ui-datepicker-status-' + inst.id + 
7643
 
                        '" class="ui-datepicker-status">' + initStatus + '</div>' : '') +
7644
 
                        (!closeAtTop && !inst.inline ? controls : '') +
7645
 
                        '<div style="clear: both;"></div>' + 
7646
 
                        ($.browser.msie && parseInt($.browser.version,10) < 7 && !inst.inline ? 
7647
 
                        '<iframe src="javascript:false;" class="ui-datepicker-cover"></iframe>' : '');
7648
 
                return html;
7649
 
        },
7650
 
        
7651
 
        /* Generate the month and year header. */
7652
 
        _generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate,
7653
 
                        selectedDate, secondary, showStatus, initStatus, monthNames) {
7654
 
                minDate = (inst.rangeStart && minDate && selectedDate < minDate ? selectedDate : minDate);
7655
 
                var showMonthAfterYear = this._get(inst, 'showMonthAfterYear');
7656
 
                var html = '<div class="ui-datepicker-header">';
7657
 
                var monthHtml = '';
7658
 
                // month selection
7659
 
                if (secondary || !this._get(inst, 'changeMonth'))
7660
 
                        monthHtml += monthNames[drawMonth] + '&#xa0;';
7661
 
                else {
7662
 
                        var inMinYear = (minDate && minDate.getFullYear() == drawYear);
7663
 
                        var inMaxYear = (maxDate && maxDate.getFullYear() == drawYear);
7664
 
                        monthHtml += '<select class="ui-datepicker-new-month" ' +
7665
 
                                'onchange="jQuery.datepicker._selectMonthYear(\'#' + inst.id + '\', this, \'M\');" ' +
7666
 
                                'onclick="jQuery.datepicker._clickMonthYear(\'#' + inst.id + '\');"' +
7667
 
                                this._addStatus(showStatus, inst.id, this._get(inst, 'monthStatus'), initStatus) + '>';
7668
 
                        for (var month = 0; month < 12; month++) {
7669
 
                                if ((!inMinYear || month >= minDate.getMonth()) &&
7670
 
                                                (!inMaxYear || month <= maxDate.getMonth()))
7671
 
                                        monthHtml += '<option value="' + month + '"' +
7672
 
                                                (month == drawMonth ? ' selected="selected"' : '') +
7673
 
                                                '>' + monthNames[month] + '</option>';
7674
 
                        }
7675
 
                        monthHtml += '</select>';
7676
 
                }
7677
 
                if (!showMonthAfterYear)
7678
 
                        html += monthHtml;
7679
 
                // year selection
7680
 
                if (secondary || !this._get(inst, 'changeYear'))
7681
 
                        html += drawYear;
7682
 
                else {
7683
 
                        // determine range of years to display
7684
 
                        var years = this._get(inst, 'yearRange').split(':');
7685
 
                        var year = 0;
7686
 
                        var endYear = 0;
7687
 
                        if (years.length != 2) {
7688
 
                                year = drawYear - 10;
7689
 
                                endYear = drawYear + 10;
7690
 
                        } else if (years[0].charAt(0) == '+' || years[0].charAt(0) == '-') {
7691
 
                                year = endYear = new Date().getFullYear();
7692
 
                                year += parseInt(years[0], 10);
7693
 
                                endYear += parseInt(years[1], 10);
7694
 
                        } else {
7695
 
                                year = parseInt(years[0], 10);
7696
 
                                endYear = parseInt(years[1], 10);
7697
 
                        }
7698
 
                        year = (minDate ? Math.max(year, minDate.getFullYear()) : year);
7699
 
                        endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear);
7700
 
                        html += '<select class="ui-datepicker-new-year" ' +
7701
 
                                'onchange="jQuery.datepicker._selectMonthYear(\'#' + inst.id + '\', this, \'Y\');" ' +
7702
 
                                'onclick="jQuery.datepicker._clickMonthYear(\'#' + inst.id + '\');"' +
7703
 
                                this._addStatus(showStatus, inst.id, this._get(inst, 'yearStatus'), initStatus) + '>';
7704
 
                        for (; year <= endYear; year++) {
7705
 
                                html += '<option value="' + year + '"' +
7706
 
                                        (year == drawYear ? ' selected="selected"' : '') +
7707
 
                                        '>' + year + '</option>';
7708
 
                        }
7709
 
                        html += '</select>';
7710
 
                }
7711
 
                if (showMonthAfterYear)
7712
 
                        html += monthHtml;
7713
 
                html += '</div>'; // Close datepicker_header
7714
 
                return html;
7715
 
        },
7716
 
 
7717
 
        /* Provide code to set and clear the status panel. */
7718
 
        _addStatus: function(showStatus, id, text, initStatus) {
7719
 
                return (showStatus ? ' onmouseover="jQuery(\'#ui-datepicker-status-' + id +
7720
 
                        '\').html(\'' + (text || initStatus) + '\');" ' +
7721
 
                        'onmouseout="jQuery(\'#ui-datepicker-status-' + id +
7722
 
                        '\').html(\'' + initStatus + '\');"' : '');
7723
 
        },
7724
 
 
7725
 
        /* Adjust one of the date sub-fields. */
7726
 
        _adjustInstDate: function(inst, offset, period) {
7727
 
                var year = inst.drawYear + (period == 'Y' ? offset : 0);
7728
 
                var month = inst.drawMonth + (period == 'M' ? offset : 0);
7729
 
                var day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) +
7730
 
                        (period == 'D' ? offset : 0);
7731
 
                var date = new Date(year, month, day);
7732
 
                // ensure it is within the bounds set
7733
 
                var minDate = this._getMinMaxDate(inst, 'min', true);
7734
 
                var maxDate = this._getMinMaxDate(inst, 'max');
7735
 
                date = (minDate && date < minDate ? minDate : date);
7736
 
                date = (maxDate && date > maxDate ? maxDate : date);
7737
 
                inst.selectedDay = date.getDate();
7738
 
                inst.drawMonth = inst.selectedMonth = date.getMonth();
7739
 
                inst.drawYear = inst.selectedYear = date.getFullYear();
7740
 
                if (period == 'M' || period == 'Y')
7741
 
                        this._notifyChange(inst);
7742
 
        },
7743
 
 
7744
 
        /* Notify change of month/year. */
7745
 
        _notifyChange: function(inst) {
7746
 
                var onChange = this._get(inst, 'onChangeMonthYear');
7747
 
                if (onChange)
7748
 
                        onChange.apply((inst.input ? inst.input[0] : null),
7749
 
                                [inst.selectedYear, inst.selectedMonth + 1, inst]);
7750
 
        },
7751
 
        
7752
 
        /* Determine the number of months to show. */
7753
 
        _getNumberOfMonths: function(inst) {
7754
 
                var numMonths = this._get(inst, 'numberOfMonths');
7755
 
                return (numMonths == null ? [1, 1] : (typeof numMonths == 'number' ? [1, numMonths] : numMonths));
7756
 
        },
7757
 
 
7758
 
        /* Determine the current maximum date - ensure no time components are set - may be overridden for a range. */
7759
 
        _getMinMaxDate: function(inst, minMax, checkRange) {
7760
 
                var date = this._determineDate(this._get(inst, minMax + 'Date'), null);
7761
 
                if (date) {
7762
 
                        date.setHours(0);
7763
 
                        date.setMinutes(0);
7764
 
                        date.setSeconds(0);
7765
 
                        date.setMilliseconds(0);
7766
 
                }
7767
 
                return (!checkRange || !inst.rangeStart ? date :
7768
 
                        (!date || inst.rangeStart > date ? inst.rangeStart : date));
7769
 
        },
7770
 
 
7771
 
        /* Find the number of days in a given month. */
7772
 
        _getDaysInMonth: function(year, month) {
7773
 
                return 32 - new Date(year, month, 32).getDate();
7774
 
        },
7775
 
 
7776
 
        /* Find the day of the week of the first of a month. */
7777
 
        _getFirstDayOfMonth: function(year, month) {
7778
 
                return new Date(year, month, 1).getDay();
7779
 
        },
7780
 
 
7781
 
        /* Determines if we should allow a "next/prev" month display change. */
7782
 
        _canAdjustMonth: function(inst, offset, curYear, curMonth) {
7783
 
                var numMonths = this._getNumberOfMonths(inst);
7784
 
                var date = new Date(curYear, curMonth + (offset < 0 ? offset : numMonths[1]), 1);
7785
 
                if (offset < 0)
7786
 
                        date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth()));
7787
 
                return this._isInRange(inst, date);
7788
 
        },
7789
 
 
7790
 
        /* Is the given date in the accepted range? */
7791
 
        _isInRange: function(inst, date) {
7792
 
                // during range selection, use minimum of selected date and range start
7793
 
                var newMinDate = (!inst.rangeStart ? null :
7794
 
                        new Date(inst.selectedYear, inst.selectedMonth, inst.selectedDay));
7795
 
                newMinDate = (newMinDate && inst.rangeStart < newMinDate ? inst.rangeStart : newMinDate);
7796
 
                var minDate = newMinDate || this._getMinMaxDate(inst, 'min');
7797
 
                var maxDate = this._getMinMaxDate(inst, 'max');
7798
 
                return ((!minDate || date >= minDate) && (!maxDate || date <= maxDate));
7799
 
        },
7800
 
        
7801
 
        /* Provide the configuration settings for formatting/parsing. */
7802
 
        _getFormatConfig: function(inst) {
7803
 
                var shortYearCutoff = this._get(inst, 'shortYearCutoff');
7804
 
                shortYearCutoff = (typeof shortYearCutoff != 'string' ? shortYearCutoff :
7805
 
                        new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
7806
 
                return {shortYearCutoff: shortYearCutoff,
7807
 
                        dayNamesShort: this._get(inst, 'dayNamesShort'), dayNames: this._get(inst, 'dayNames'),
7808
 
                        monthNamesShort: this._get(inst, 'monthNamesShort'), monthNames: this._get(inst, 'monthNames')};
7809
 
        },
7810
 
 
7811
 
        /* Format the given date for display. */
7812
 
        _formatDate: function(inst, day, month, year) {
7813
 
                if (!day) {
7814
 
                        inst.currentDay = inst.selectedDay;
7815
 
                        inst.currentMonth = inst.selectedMonth;
7816
 
                        inst.currentYear = inst.selectedYear;
7817
 
                }
7818
 
                var date = (day ? (typeof day == 'object' ? day : new Date(year, month, day)) :
7819
 
                        new Date(inst.currentYear, inst.currentMonth, inst.currentDay));
7820
 
                return this.formatDate(this._get(inst, 'dateFormat'), date, this._getFormatConfig(inst));
7821
 
        }
7822
 
});
7823
 
 
7824
 
/* jQuery extend now ignores nulls! */
7825
 
function extendRemove(target, props) {
7826
 
        $.extend(target, props);
7827
 
        for (var name in props)
7828
 
                if (props[name] == null || props[name] == undefined)
7829
 
                        target[name] = props[name];
7830
 
        return target;
7831
 
};
7832
 
 
7833
 
/* Determine whether an object is an array. */
7834
 
function isArray(a) {
7835
 
        return (a && (($.browser.safari && typeof a == 'object' && a.length) ||
7836
 
                (a.constructor && a.constructor.toString().match(/\Array\(\)/))));
7837
 
};
7838
 
 
7839
 
/* Invoke the datepicker functionality.
7840
 
   @param  options  string - a command, optionally followed by additional parameters or
7841
 
                    Object - settings for attaching new datepicker functionality
7842
 
   @return  jQuery object */
7843
 
$.fn.datepicker = function(options){
7844
 
        
7845
 
        /* Initialise the date picker. */
7846
 
        if (!$.datepicker.initialized) {
7847
 
                $(document.body).append($.datepicker.dpDiv).
7848
 
                        mousedown($.datepicker._checkExternalClick);
7849
 
                $.datepicker.initialized = true;
7850
 
        }
7851
 
        
7852
 
        var otherArgs = Array.prototype.slice.call(arguments, 1);
7853
 
        if (typeof options == 'string' && (options == 'isDisabled' || options == 'getDate'))
7854
 
                return $.datepicker['_' + options + 'Datepicker'].
7855
 
                        apply($.datepicker, [this[0]].concat(otherArgs));
7856
 
        return this.each(function() {
7857
 
                typeof options == 'string' ?
7858
 
                        $.datepicker['_' + options + 'Datepicker'].
7859
 
                                apply($.datepicker, [this].concat(otherArgs)) :
7860
 
                        $.datepicker._attachDatepicker(this, options);
7861
 
        });
7862
 
};
7863
 
 
7864
 
$.datepicker = new Datepicker(); // singleton instance
7865
 
$.datepicker.initialized = false;
7866
 
$.datepicker.uuid = new Date().getTime();
7867
 
 
7868
 
})(jQuery);
7869
 
/*
7870
 
 * jQuery UI Dialog @VERSION
7871
 
 *
7872
 
 * Copyright (c) 2008 Richard D. Worth (rdworth.org)
7873
 
 * Dual licensed under the MIT (MIT-LICENSE.txt)
7874
 
 * and GPL (GPL-LICENSE.txt) licenses.
7875
 
 * 
7876
 
 * http://docs.jquery.com/UI/Dialog
7877
 
 *
7878
 
 * Depends:
7879
 
 *      ui.core.js
7880
 
 *      ui.draggable.js
7881
 
 *      ui.resizable.js
7882
 
 */
7883
 
(function($) {
7884
 
 
7885
 
var setDataSwitch = {
7886
 
        dragStart: "start.draggable",
7887
 
        drag: "drag.draggable",
7888
 
        dragStop: "stop.draggable",
7889
 
        maxHeight: "maxHeight.resizable",
7890
 
        minHeight: "minHeight.resizable",
7891
 
        maxWidth: "maxWidth.resizable",
7892
 
        minWidth: "minWidth.resizable",
7893
 
        resizeStart: "start.resizable",
7894
 
        resize: "drag.resizable",
7895
 
        resizeStop: "stop.resizable"
7896
 
};
7897
 
 
7898
 
$.widget("ui.dialog", {
7899
 
        _init: function() {
7900
 
                this.originalTitle = this.element.attr('title');
7901
 
                this.options.title = this.options.title || this.originalTitle;
7902
 
                
7903
 
                var self = this,
7904
 
                        options = this.options,
7905
 
                        
7906
 
                        uiDialogContent = this.element
7907
 
                                .removeAttr('title')
7908
 
                                .addClass('ui-dialog-content')
7909
 
                                .wrap('<div/>')
7910
 
                                .wrap('<div/>'),
7911
 
                        
7912
 
                        uiDialogContainer = (this.uiDialogContainer = uiDialogContent.parent())
7913
 
                                .addClass('ui-dialog-container')
7914
 
                                .css({
7915
 
                                        position: 'relative',
7916
 
                                        width: '100%',
7917
 
                                        height: '100%'
7918
 
                                }),
7919
 
                        
7920
 
                        uiDialogTitlebar = (this.uiDialogTitlebar = $('<div/>'))
7921
 
                                .addClass('ui-dialog-titlebar')
7922
 
                                .append('<a href="#" class="ui-dialog-titlebar-close"><span>X</span></a>')
7923
 
                                .prependTo(uiDialogContainer),
7924
 
                        
7925
 
                        title = options.title || '&nbsp;',
7926
 
                        titleId = $.ui.dialog.getTitleId(this.element),
7927
 
                        uiDialogTitle = $('<span/>')
7928
 
                                .addClass('ui-dialog-title')
7929
 
                                .attr('id', titleId)
7930
 
                                .html(title)
7931
 
                                .prependTo(uiDialogTitlebar),
7932
 
                        
7933
 
                        uiDialog = (this.uiDialog = uiDialogContainer.parent())
7934
 
                                .appendTo(document.body)
7935
 
                                .hide()
7936
 
                                .addClass('ui-dialog')
7937
 
                                .addClass(options.dialogClass)
7938
 
                                // add content classes to dialog
7939
 
                                // to inherit theme at top level of element
7940
 
                                .addClass(uiDialogContent.attr('className'))
7941
 
                                        .removeClass('ui-dialog-content')
7942
 
                                .css({
7943
 
                                        position: 'absolute',
7944
 
                                        width: options.width,
7945
 
                                        height: options.height,
7946
 
                                        overflow: 'hidden',
7947
 
                                        zIndex: options.zIndex
7948
 
                                })
7949
 
                                // setting tabIndex makes the div focusable
7950
 
                                // setting outline to 0 prevents a border on focus in Mozilla
7951
 
                                .attr('tabIndex', -1).css('outline', 0).keydown(function(ev) {
7952
 
                                        (options.closeOnEscape && ev.keyCode
7953
 
                                                && ev.keyCode == $.keyCode.ESCAPE && self.close());
7954
 
                                })
7955
 
                                .mousedown(function() {
7956
 
                                        self._moveToTop();
7957
 
                                }),
7958
 
                        
7959
 
                        uiDialogButtonPane = (this.uiDialogButtonPane = $('<div/>'))
7960
 
                                .addClass('ui-dialog-buttonpane')
7961
 
                                .css({
7962
 
                                        position: 'absolute',
7963
 
                                        bottom: 0
7964
 
                                })
7965
 
                                .appendTo(uiDialog);
7966
 
                
7967
 
                this.uiDialogTitlebarClose = $('.ui-dialog-titlebar-close', uiDialogTitlebar)
7968
 
                        .hover(
7969
 
                                function() {
7970
 
                                        $(this).addClass('ui-dialog-titlebar-close-hover');
7971
 
                                },
7972
 
                                function() {
7973
 
                                        $(this).removeClass('ui-dialog-titlebar-close-hover');
7974
 
                                }
7975
 
                        )
7976
 
                        .mousedown(function(ev) {
7977
 
                                ev.stopPropagation();
7978
 
                        })
7979
 
                        .click(function() {
7980
 
                                self.close();
7981
 
                                return false;
7982
 
                        });
7983
 
                
7984
 
                uiDialogTitlebar.find("*").add(uiDialogTitlebar).each(function() {
7985
 
                        $.ui.disableSelection(this);
7986
 
                });
7987
 
                
7988
 
                (options.draggable && $.fn.draggable && this._makeDraggable());
7989
 
                (options.resizable && $.fn.resizable && this._makeResizable());
7990
 
                
7991
 
                this._createButtons(options.buttons);
7992
 
                this._isOpen = false;
7993
 
                
7994
 
                (options.bgiframe && $.fn.bgiframe && uiDialog.bgiframe());
7995
 
                (options.autoOpen && this.open());
7996
 
        },
7997
 
        
7998
 
        destroy: function() {
7999
 
                (this.overlay && this.overlay.destroy());
8000
 
                this.uiDialog.hide();
8001
 
                this.element
8002
 
                        .unbind('.dialog')
8003
 
                        .removeData('dialog')
8004
 
                        .removeClass('ui-dialog-content')
8005
 
                        .hide().appendTo('body');
8006
 
                this.uiDialog.remove();
8007
 
                
8008
 
                (this.originalTitle && this.element.attr('title', this.originalTitle));
8009
 
        },
8010
 
        
8011
 
        close: function() {
8012
 
                if (false === this._trigger('beforeclose', null, { options: this.options })) {
8013
 
                        return;
8014
 
                }
8015
 
                
8016
 
                (this.overlay && this.overlay.destroy());
8017
 
                this.uiDialog
8018
 
                        .hide(this.options.hide)
8019
 
                        .unbind('keypress.ui-dialog');
8020
 
                
8021
 
                this._trigger('close', null, { options: this.options });
8022
 
                $.ui.dialog.overlay.resize();
8023
 
                
8024
 
                this._isOpen = false;
8025
 
        },
8026
 
        
8027
 
        isOpen: function() {
8028
 
                return this._isOpen;
8029
 
        },
8030
 
        
8031
 
        open: function() {
8032
 
                if (this._isOpen) { return; }
8033
 
                
8034
 
                this.overlay = this.options.modal ? new $.ui.dialog.overlay(this) : null;
8035
 
                (this.uiDialog.next().length && this.uiDialog.appendTo('body'));
8036
 
                this._position(this.options.position);
8037
 
                this.uiDialog.show(this.options.show);
8038
 
                (this.options.autoResize && this._size());
8039
 
                this._moveToTop(true);
8040
 
                
8041
 
                // prevent tabbing out of modal dialogs
8042
 
                (this.options.modal && this.uiDialog.bind('keypress.ui-dialog', function(e) {
8043
 
                        if (e.keyCode != $.keyCode.TAB) {
8044
 
                                return;
8045
 
                        }
8046
 
                        
8047
 
                        var tabbables = $(':tabbable', this),
8048
 
                                first = tabbables.filter(':first')[0],
8049
 
                                last  = tabbables.filter(':last')[0];
8050
 
                        
8051
 
                        if (e.target == last && !e.shiftKey) {
8052
 
                                setTimeout(function() {
8053
 
                                        first.focus();
8054
 
                                }, 1);
8055
 
                        } else if (e.target == first && e.shiftKey) {
8056
 
                                setTimeout(function() {
8057
 
                                        last.focus();
8058
 
                                }, 1);
8059
 
                        }
8060
 
                }));
8061
 
                
8062
 
                this.uiDialog.find(':tabbable:first').focus();
8063
 
                this._trigger('open', null, { options: this.options });
8064
 
                this._isOpen = true;
8065
 
        },
8066
 
        
8067
 
        _createButtons: function(buttons) {
8068
 
                var self = this,
8069
 
                        hasButtons = false,
8070
 
                        uiDialogButtonPane = this.uiDialogButtonPane;
8071
 
                
8072
 
                // remove any existing buttons
8073
 
                uiDialogButtonPane.empty().hide();
8074
 
                
8075
 
                $.each(buttons, function() { return !(hasButtons = true); });
8076
 
                if (hasButtons) {
8077
 
                        uiDialogButtonPane.show();
8078
 
                        $.each(buttons, function(name, fn) {
8079
 
                                $('<button type="button"></button>')
8080
 
                                        .text(name)
8081
 
                                        .click(function() { fn.apply(self.element[0], arguments); })
8082
 
                                        .appendTo(uiDialogButtonPane);
8083
 
                        });
8084
 
                }
8085
 
        },
8086
 
        
8087
 
        _makeDraggable: function() {
8088
 
                var self = this,
8089
 
                        options = this.options;
8090
 
                
8091
 
                this.uiDialog.draggable({
8092
 
                        cancel: '.ui-dialog-content',
8093
 
                        helper: options.dragHelper,
8094
 
                        handle: '.ui-dialog-titlebar',
8095
 
                        start: function() {
8096
 
                                self._moveToTop();
8097
 
                                (options.dragStart && options.dragStart.apply(self.element[0], arguments));
8098
 
                        },
8099
 
                        drag: function() {
8100
 
                                (options.drag && options.drag.apply(self.element[0], arguments));
8101
 
                        },
8102
 
                        stop: function() {
8103
 
                                (options.dragStop && options.dragStop.apply(self.element[0], arguments));
8104
 
                                $.ui.dialog.overlay.resize();
8105
 
                        }
8106
 
                });
8107
 
        },
8108
 
        
8109
 
        _makeResizable: function(handles) {
8110
 
                handles = (handles === undefined ? this.options.resizable : handles);
8111
 
                var self = this,
8112
 
                        options = this.options,
8113
 
                        resizeHandles = typeof handles == 'string'
8114
 
                                ? handles
8115
 
                                : 'n,e,s,w,se,sw,ne,nw';
8116
 
                
8117
 
                this.uiDialog.resizable({
8118
 
                        cancel: '.ui-dialog-content',
8119
 
                        helper: options.resizeHelper,
8120
 
                        maxWidth: options.maxWidth,
8121
 
                        maxHeight: options.maxHeight,
8122
 
                        minWidth: options.minWidth,
8123
 
                        minHeight: options.minHeight,
8124
 
                        start: function() {
8125
 
                                (options.resizeStart && options.resizeStart.apply(self.element[0], arguments));
8126
 
                        },
8127
 
                        resize: function() {
8128
 
                                (options.autoResize && self._size.apply(self));
8129
 
                                (options.resize && options.resize.apply(self.element[0], arguments));
8130
 
                        },
8131
 
                        handles: resizeHandles,
8132
 
                        stop: function() {
8133
 
                                (options.autoResize && self._size.apply(self));
8134
 
                                (options.resizeStop && options.resizeStop.apply(self.element[0], arguments));
8135
 
                                $.ui.dialog.overlay.resize();
8136
 
                        }
8137
 
                });
8138
 
        },
8139
 
        
8140
 
        // the force parameter allows us to move modal dialogs to their correct
8141
 
        // position on open
8142
 
        _moveToTop: function(force) {
8143
 
                
8144
 
                if ((this.options.modal && !force)
8145
 
                        || (!this.options.stack && !this.options.modal)) {
8146
 
                        return this._trigger('focus', null, { options: this.options });
8147
 
                }
8148
 
                
8149
 
                var maxZ = this.options.zIndex, options = this.options;
8150
 
                $('.ui-dialog:visible').each(function() {
8151
 
                        maxZ = Math.max(maxZ, parseInt($(this).css('z-index'), 10) || options.zIndex);
8152
 
                });
8153
 
                (this.overlay && this.overlay.$el.css('z-index', ++maxZ));
8154
 
                this.uiDialog.css('z-index', ++maxZ);
8155
 
                
8156
 
                this._trigger('focus', null, { options: this.options });
8157
 
        },
8158
 
        
8159
 
        _position: function(pos) {
8160
 
                var wnd = $(window), doc = $(document),
8161
 
                        pTop = doc.scrollTop(), pLeft = doc.scrollLeft(),
8162
 
                        minTop = pTop;
8163
 
                
8164
 
                if ($.inArray(pos, ['center','top','right','bottom','left']) >= 0) {
8165
 
                        pos = [
8166
 
                                pos == 'right' || pos == 'left' ? pos : 'center',
8167
 
                                pos == 'top' || pos == 'bottom' ? pos : 'middle'
8168
 
                        ];
8169
 
                }
8170
 
                if (pos.constructor != Array) {
8171
 
                        pos = ['center', 'middle'];
8172
 
                }
8173
 
                if (pos[0].constructor == Number) {
8174
 
                        pLeft += pos[0];
8175
 
                } else {
8176
 
                        switch (pos[0]) {
8177
 
                                case 'left':
8178
 
                                        pLeft += 0;
8179
 
                                        break;
8180
 
                                case 'right':
8181
 
                                        pLeft += wnd.width() - this.uiDialog.width();
8182
 
                                        break;
8183
 
                                default:
8184
 
                                case 'center':
8185
 
                                        pLeft += (wnd.width() - this.uiDialog.width()) / 2;
8186
 
                        }
8187
 
                }
8188
 
                if (pos[1].constructor == Number) {
8189
 
                        pTop += pos[1];
8190
 
                } else {
8191
 
                        switch (pos[1]) {
8192
 
                                case 'top':
8193
 
                                        pTop += 0;
8194
 
                                        break;
8195
 
                                case 'bottom':
8196
 
                                        pTop += wnd.height() - this.uiDialog.height();
8197
 
                                        break;
8198
 
                                default:
8199
 
                                case 'middle':
8200
 
                                        pTop += (wnd.height() - this.uiDialog.height()) / 2;
8201
 
                        }
8202
 
                }
8203
 
                
8204
 
                // prevent the dialog from being too high (make sure the titlebar
8205
 
                // is accessible)
8206
 
                pTop = Math.max(pTop, minTop);
8207
 
                this.uiDialog.css({top: pTop, left: pLeft});
8208
 
        },
8209
 
        
8210
 
        _setData: function(key, value){
8211
 
                (setDataSwitch[key] && this.uiDialog.data(setDataSwitch[key], value));
8212
 
                switch (key) {
8213
 
                        case "buttons":
8214
 
                                this._createButtons(value);
8215
 
                                break;
8216
 
                        case "draggable":
8217
 
                                (value
8218
 
                                        ? this._makeDraggable()
8219
 
                                        : this.uiDialog.draggable('destroy'));
8220
 
                                break;
8221
 
                        case "height":
8222
 
                                this.uiDialog.height(value);
8223
 
                                break;
8224
 
                        case "position":
8225
 
                                this._position(value);
8226
 
                                break;
8227
 
                        case "resizable":
8228
 
                                var uiDialog = this.uiDialog,
8229
 
                                        isResizable = this.uiDialog.is(':data(resizable)');
8230
 
                                
8231
 
                                // currently resizable, becoming non-resizable
8232
 
                                (isResizable && !value && uiDialog.resizable('destroy'));
8233
 
                                
8234
 
                                // currently resizable, changing handles
8235
 
                                (isResizable && typeof value == 'string' &&
8236
 
                                        uiDialog.resizable('option', 'handles', value));
8237
 
                                
8238
 
                                // currently non-resizable, becoming resizable
8239
 
                                (isResizable || this._makeResizable(value));
8240
 
                                
8241
 
                                break;
8242
 
                        case "title":
8243
 
                                $(".ui-dialog-title", this.uiDialogTitlebar).html(value || '&nbsp;');
8244
 
                                break;
8245
 
                        case "width":
8246
 
                                this.uiDialog.width(value);
8247
 
                                break;
8248
 
                }
8249
 
                
8250
 
                $.widget.prototype._setData.apply(this, arguments);
8251
 
        },
8252
 
        
8253
 
        _size: function() {
8254
 
                var container = this.uiDialogContainer,
8255
 
                        titlebar = this.uiDialogTitlebar,
8256
 
                        content = this.element,
8257
 
                        tbMargin = (parseInt(content.css('margin-top'), 10) || 0)
8258
 
                                + (parseInt(content.css('margin-bottom'), 10) || 0),
8259
 
                        lrMargin = (parseInt(content.css('margin-left'), 10) || 0)
8260
 
                                + (parseInt(content.css('margin-right'), 10) || 0);
8261
 
                content.height(container.height() - titlebar.outerHeight() - tbMargin);
8262
 
                content.width(container.width() - lrMargin);
8263
 
        }
8264
 
});
8265
 
 
8266
 
$.extend($.ui.dialog, {
8267
 
        defaults: {
8268
 
                autoOpen: true,
8269
 
                autoResize: true,
8270
 
                bgiframe: false,
8271
 
                buttons: {},
8272
 
                closeOnEscape: true,
8273
 
                draggable: true,
8274
 
                height: 200,
8275
 
                minHeight: 100,
8276
 
                minWidth: 150,
8277
 
                modal: false,
8278
 
                overlay: {},
8279
 
                position: 'center',
8280
 
                resizable: true,
8281
 
                stack: true,
8282
 
                width: 300,
8283
 
                zIndex: 1000
8284
 
        },
8285
 
        
8286
 
        getter: 'isOpen',
8287
 
        
8288
 
        uuid: 0,
8289
 
        getTitleId: function($el) {
8290
 
                return 'ui-dialog-title-' + ($el.attr('id') || ++this.uuid);
8291
 
        },
8292
 
        
8293
 
        overlay: function(dialog) {
8294
 
                this.$el = $.ui.dialog.overlay.create(dialog);
8295
 
        }
8296
 
});
8297
 
 
8298
 
$.extend($.ui.dialog.overlay, {
8299
 
        instances: [],
8300
 
        events: $.map('focus,mousedown,mouseup,keydown,keypress,click'.split(','),
8301
 
                function(e) { return e + '.dialog-overlay'; }).join(' '),
8302
 
        create: function(dialog) {
8303
 
                if (this.instances.length === 0) {
8304
 
                        // prevent use of anchors and inputs
8305
 
                        // we use a setTimeout in case the overlay is created from an
8306
 
                        // event that we're going to be cancelling (see #2804)
8307
 
                        setTimeout(function() {
8308
 
                                $('a, :input').bind($.ui.dialog.overlay.events, function() {
8309
 
                                        // allow use of the element if inside a dialog and
8310
 
                                        // - there are no modal dialogs
8311
 
                                        // - there are modal dialogs, but we are in front of the topmost modal
8312
 
                                        var allow = false;
8313
 
                                        var $dialog = $(this).parents('.ui-dialog');
8314
 
                                        if ($dialog.length) {
8315
 
                                                var $overlays = $('.ui-dialog-overlay');
8316
 
                                                if ($overlays.length) {
8317
 
                                                        var maxZ = parseInt($overlays.css('z-index'), 10);
8318
 
                                                        $overlays.each(function() {
8319
 
                                                                maxZ = Math.max(maxZ, parseInt($(this).css('z-index'), 10));
8320
 
                                                        });
8321
 
                                                        allow = parseInt($dialog.css('z-index'), 10) > maxZ;
8322
 
                                                } else {
8323
 
                                                        allow = true;
8324
 
                                                }
8325
 
                                        }
8326
 
                                        return allow;
8327
 
                                });
8328
 
                        }, 1);
8329
 
                        
8330
 
                        // allow closing by pressing the escape key
8331
 
                        $(document).bind('keydown.dialog-overlay', function(e) {
8332
 
                                (dialog.options.closeOnEscape && e.keyCode
8333
 
                                                && e.keyCode == $.keyCode.ESCAPE && dialog.close());
8334
 
                        });
8335
 
                        
8336
 
                        // handle window resize
8337
 
                        $(window).bind('resize.dialog-overlay', $.ui.dialog.overlay.resize);
8338
 
                }
8339
 
                
8340
 
                var $el = $('<div/>').appendTo(document.body)
8341
 
                        .addClass('ui-dialog-overlay').css($.extend({
8342
 
                                borderWidth: 0, margin: 0, padding: 0,
8343
 
                                position: 'absolute', top: 0, left: 0,
8344
 
                                width: this.width(),
8345
 
                                height: this.height()
8346
 
                        }, dialog.options.overlay));
8347
 
                
8348
 
                (dialog.options.bgiframe && $.fn.bgiframe && $el.bgiframe());
8349
 
                
8350
 
                this.instances.push($el);
8351
 
                return $el;
8352
 
        },
8353
 
        
8354
 
        destroy: function($el) {
8355
 
                this.instances.splice($.inArray(this.instances, $el), 1);
8356
 
                
8357
 
                if (this.instances.length === 0) {
8358
 
                        $('a, :input').add([document, window]).unbind('.dialog-overlay');
8359
 
                }
8360
 
                
8361
 
                $el.remove();
8362
 
        },
8363
 
        
8364
 
        height: function() {
8365
 
                // handle IE 6
8366
 
                if ($.browser.msie && $.browser.version < 7) {
8367
 
                        var scrollHeight = Math.max(
8368
 
                                document.documentElement.scrollHeight,
8369
 
                                document.body.scrollHeight
8370
 
                        );
8371
 
                        var offsetHeight = Math.max(
8372
 
                                document.documentElement.offsetHeight,
8373
 
                                document.body.offsetHeight
8374
 
                        );
8375
 
                        
8376
 
                        if (scrollHeight < offsetHeight) {
8377
 
                                return $(window).height() + 'px';
8378
 
                        } else {
8379
 
                                return scrollHeight + 'px';
8380
 
                        }
8381
 
                // handle Opera
8382
 
                } else if ($.browser.opera) {
8383
 
                        return Math.max(
8384
 
                                window.innerHeight,
8385
 
                                $(document).height()
8386
 
                        ) + 'px';
8387
 
                // handle "good" browsers
8388
 
                } else {
8389
 
                        return $(document).height() + 'px';
8390
 
                }
8391
 
        },
8392
 
        
8393
 
        width: function() {
8394
 
                // handle IE 6
8395
 
                if ($.browser.msie && $.browser.version < 7) {
8396
 
                        var scrollWidth = Math.max(
8397
 
                                document.documentElement.scrollWidth,
8398
 
                                document.body.scrollWidth
8399
 
                        );
8400
 
                        var offsetWidth = Math.max(
8401
 
                                document.documentElement.offsetWidth,
8402
 
                                document.body.offsetWidth
8403
 
                        );
8404
 
                        
8405
 
                        if (scrollWidth < offsetWidth) {
8406
 
                                return $(window).width() + 'px';
8407
 
                        } else {
8408
 
                                return scrollWidth + 'px';
8409
 
                        }
8410
 
                // handle Opera
8411
 
                } else if ($.browser.opera) {
8412
 
                        return Math.max(
8413
 
                                window.innerWidth,
8414
 
                                $(document).width()
8415
 
                        ) + 'px';
8416
 
                // handle "good" browsers
8417
 
                } else {
8418
 
                        return $(document).width() + 'px';
8419
 
                }
8420
 
        },
8421
 
        
8422
 
        resize: function() {
8423
 
                /* If the dialog is draggable and the user drags it past the
8424
 
                 * right edge of the window, the document becomes wider so we
8425
 
                 * need to stretch the overlay. If the user then drags the
8426
 
                 * dialog back to the left, the document will become narrower,
8427
 
                 * so we need to shrink the overlay to the appropriate size.
8428
 
                 * This is handled by shrinking the overlay before setting it
8429
 
                 * to the full document size.
8430
 
                 */
8431
 
                var $overlays = $([]);
8432
 
                $.each($.ui.dialog.overlay.instances, function() {
8433
 
                        $overlays = $overlays.add(this);
8434
 
                });
8435
 
                
8436
 
                $overlays.css({
8437
 
                        width: 0,
8438
 
                        height: 0
8439
 
                }).css({
8440
 
                        width: $.ui.dialog.overlay.width(),
8441
 
                        height: $.ui.dialog.overlay.height()
8442
 
                });
8443
 
        }
8444
 
});
8445
 
 
8446
 
$.extend($.ui.dialog.overlay.prototype, {
8447
 
        destroy: function() {
8448
 
                $.ui.dialog.overlay.destroy(this.$el);
8449
 
        }
8450
 
});
8451
 
 
8452
 
})(jQuery);
8453
 
/*
8454
 
 * jQuery UI Magnifier @VERSION
8455
 
 *
8456
 
 * Copyright (c) 2008 jQuery
8457
 
 * Dual licensed under the MIT (MIT-LICENSE.txt)
8458
 
 * and GPL (GPL-LICENSE.txt) licenses.
8459
 
 *
8460
 
 * http://docs.jquery.com/UI/Magnifier
8461
 
 *
8462
 
 * Depends:
8463
 
 *  ui.core.js
8464
 
 */
8465
 
(function($) {
8466
 
 
8467
 
var counter = 0;
8468
 
 
8469
 
$.widget("ui.magnifier", {
8470
 
        _init: function() {
8471
 
                var self = this,
8472
 
                        o = this.options;
8473
 
                
8474
 
                this.element
8475
 
                        .addClass("ui-magnifier")
8476
 
                        .bind('click.magnifier', function(e) {
8477
 
                                (!self.disabled && o.click && o.click.apply(this, [e, {
8478
 
                                        options: self.options,
8479
 
                                        current: self.current[0],
8480
 
                                        currentOffset: self.current[1]
8481
 
                                }]));
8482
 
                        });
8483
 
                
8484
 
                // the element must have relative or absolute positioning
8485
 
                if (!(/^(r|a)/).test(this.element.css("position"))) {
8486
 
                        this.element.css("position", "relative");
8487
 
                }
8488
 
                
8489
 
                this.items = [];
8490
 
                this.element.find(o.items).each(function() {
8491
 
                        var $this = $(this);
8492
 
                        // TODO: use a hash so references to this data is readable
8493
 
                        self.items.push([
8494
 
                                this,
8495
 
                                $this.offset(),
8496
 
                                [$this.width(),$this.height()],
8497
 
                                (o.overlap ? $this.position() : null)
8498
 
                        ]);
8499
 
                        
8500
 
                        (o.opacity && $this.css('opacity', o.opacity.min));
8501
 
                });
8502
 
                
8503
 
                // absolutize
8504
 
                (o.overlap && $.each(this.items, function() {
8505
 
                        $(this[0]).css({
8506
 
                                position: "absolute",
8507
 
                                top: this[3].top,
8508
 
                                left: this[3].left
8509
 
                        });
8510
 
                }));
8511
 
                
8512
 
                this.identifier = ++counter;
8513
 
                $(document).bind("mousemove.magnifier"+this.identifier, function(e) {
8514
 
                        (self.disabled || self._magnify.apply(self, [e]));
8515
 
                });
8516
 
                
8517
 
                this.pp = this.element.offset();
8518
 
        },
8519
 
        
8520
 
        destroy: function() {
8521
 
                this.reset();
8522
 
                this.element
8523
 
                        .removeClass("ui-magnifier ui-magnifier-disabled")
8524
 
                        .unbind(".magnifier");
8525
 
                $(document).unbind("mousemove.magnifier"+this.identifier);
8526
 
        },
8527
 
        
8528
 
        disable: function() {
8529
 
                this.reset();
8530
 
                $.widget.prototype.disable.apply(this, arguments);
8531
 
        },
8532
 
        
8533
 
        reset: function(e) {
8534
 
                var o = this.options;
8535
 
                
8536
 
                $.each(this.items, function() {
8537
 
                        var item = this;
8538
 
                        $(item[0]).css({
8539
 
                                width: item[2][0],
8540
 
                                height: item[2][1],
8541
 
                                top: (item[3] ? item[3].top : 0),
8542
 
                                left: (item[3] ? item[3].left : 0)
8543
 
                        });
8544
 
                        
8545
 
                        (o.opacity && $(item[0]).css('opacity', o.opacity.min));
8546
 
                        (o.zIndex && $(item[0]).css("z-index", ""));
8547
 
                });
8548
 
        },
8549
 
        
8550
 
        _magnify: function(e) {
8551
 
                var p = [e.pageX,e.pageY], o = this.options, c, distance = 1;
8552
 
                this.current = this.items[0];
8553
 
                
8554
 
                // Compute the parent's distance
8555
 
                // we don't need to fire anything if we are not near the parent
8556
 
                var overlap = ((p[0] > this.pp.left-o.distance) &&
8557
 
                        (p[0] < this.pp.left + this.element[0].offsetWidth + o.distance) &&
8558
 
                        (p[1] > this.pp.top-o.distance) &&
8559
 
                        (p[1] < this.pp.top + this.element[0].offsetHeight + o.distance));
8560
 
                if (!overlap) { return false; }
8561
 
                
8562
 
                for (var i=0; i<this.items.length; i++) {
8563
 
                        c = this.items[i];
8564
 
                        
8565
 
                        var olddistance = distance;
8566
 
                        if (!o.axis) {
8567
 
                                distance = Math.sqrt(
8568
 
                                          Math.pow(p[0] - ((c[3] ? this.pp.left : c[1].left) + parseInt(c[0].style.left,10)) - (c[0].offsetWidth/2), 2)
8569
 
                                        + Math.pow(p[1] - ((c[3] ? this.pp.top  : c[1].top ) + parseInt(c[0].style.top,10)) - (c[0].offsetHeight/2), 2)
8570
 
                                );
8571
 
                        } else {
8572
 
                                if(o.axis == "y") {
8573
 
                                        distance = Math.abs(p[1] - ((c[3] ? this.pp.top  : c[1].top ) + parseInt(c[0].style.top,10)) - (c[0].offsetHeight/2));
8574
 
                                } else {
8575
 
                                        distance = Math.abs(p[0] - ((c[3] ? this.pp.left : c[1].left) + parseInt(c[0].style.left,10)) - (c[0].offsetWidth/2));
8576
 
                                }
8577
 
                        }
8578
 
                        
8579
 
                        if (distance < o.distance) {
8580
 
                                this.current = distance < olddistance ? c : this.current;
8581
 
                                
8582
 
                                if (!o.axis || o.axis != "y") {
8583
 
                                        $(c[0]).css({
8584
 
                                                width: c[2][0]+ (c[2][0] * (o.magnification-1)) - (((distance/o.distance)*c[2][0]) * (o.magnification-1)),
8585
 
                                                left: (c[3] ? (c[3].left + o.verticalLine * ((c[2][1] * (o.magnification-1)) - (((distance/o.distance)*c[2][1]) * (o.magnification-1)))) : 0)
8586
 
                                        });
8587
 
                                }
8588
 
                                
8589
 
                                if (!o.axis || o.axis != "x") {
8590
 
                                        $(c[0]).css({
8591
 
                                                height: c[2][1]+ (c[2][1] * (o.magnification-1)) - (((distance/o.distance)*c[2][1]) * (o.magnification-1)),
8592
 
                                                top: (c[3] ? c[3].top : 0) + (o.baseline-0.5) * ((c[2][0] * (o.magnification-1)) - (((distance/o.distance)*c[2][0]) * (o.magnification-1)))
8593
 
                                        });
8594
 
                                }
8595
 
                                
8596
 
                                if (o.opacity) {
8597
 
                                        $(c[0]).css('opacity', o.opacity.max-(distance/o.distance) < o.opacity.min ? o.opacity.min : o.opacity.max-(distance/o.distance));
8598
 
                                }
8599
 
                        } else {
8600
 
                                $(c[0]).css({
8601
 
                                        width: c[2][0],
8602
 
                                        height: c[2][1],
8603
 
                                        top: (c[3] ? c[3].top : 0),
8604
 
                                        left: (c[3] ? c[3].left : 0)
8605
 
                                });
8606
 
                                
8607
 
                                (o.opacity && $(c[0]).css('opacity', o.opacity.min));
8608
 
                        }
8609
 
                        
8610
 
                        (o.zIndex && $(c[0]).css("z-index", ""));
8611
 
                }
8612
 
                
8613
 
                (o.zIndex && $(this.current[0]).css("z-index", o.zIndex));
8614
 
        }
8615
 
});
8616
 
 
8617
 
$.extend($.ui.magnifier, {
8618
 
        defaults: {
8619
 
                distance: 150,
8620
 
                magnification: 2,
8621
 
                baseline: 0,
8622
 
                verticalLine: -0.5,
8623
 
                items: "> *"
8624
 
        }
8625
 
});
8626
 
 
8627
 
})(jQuery);
8628
 
/*
8629
 
 * jQuery UI ProgressBar @VERSION
8630
 
 *
8631
 
 * Copyright (c) 2008 Eduardo Lundgren
8632
 
 * Dual licensed under the MIT (MIT-LICENSE.txt)
8633
 
 * and GPL (GPL-LICENSE.txt) licenses.
8634
 
 *
8635
 
 * http://docs.jquery.com/UI/ProgressBar
8636
 
 *
8637
 
 * Depends:
8638
 
 *   ui.core.js
8639
 
 */
8640
 
(function($) {
8641
 
 
8642
 
$.widget("ui.progressbar", {
8643
 
        _init: function() {
8644
 
 
8645
 
                this._interval = this.options.interval;
8646
 
 
8647
 
                var self = this,
8648
 
                        options = this.options,
8649
 
                        id = (new Date()).getTime()+Math.random(),
8650
 
                        text = options.text || '0%';
8651
 
 
8652
 
                this.element.addClass("ui-progressbar").width(options.width);
8653
 
 
8654
 
                $.extend(this, {
8655
 
                        active: false,
8656
 
                        pixelState: 0,
8657
 
                        percentState: 0,
8658
 
                        identifier: id,
8659
 
                        bar: $('<div class="ui-progressbar-bar ui-hidden"></div>').css({
8660
 
                                width: '0px', overflow: 'hidden', zIndex: 100
8661
 
                        }),
8662
 
                        textElement: $('<div class="ui-progressbar-text"></div>').html(text).css({
8663
 
                                width: '0px', overflow: 'hidden'
8664
 
                        }),
8665
 
                        textBg: $('<div class="ui-progressbar-text ui-progressbar-text-back"></div>').html(text).css({
8666
 
                                        width: this.element.width()
8667
 
                        }),
8668
 
                        wrapper: $('<div class="ui-progressbar-wrap"></div>')
8669
 
                });
8670
 
 
8671
 
                this.wrapper
8672
 
                        .append(this.bar.append(this.textElement.addClass(options.textClass)), this.textBg)
8673
 
                        .appendTo(this.element);
8674
 
        },
8675
 
 
8676
 
        plugins: {},
8677
 
        ui: function(e) {
8678
 
                return {
8679
 
                        instance: this,
8680
 
                        identifier: this.identifier,
8681
 
                        options: this.options,
8682
 
                        element: this.bar,
8683
 
                        textElement: this.textElement,
8684
 
                        pixelState: this.pixelState,
8685
 
                        percentState: this.percentState
8686
 
                };
8687
 
        },
8688
 
 
8689
 
        _propagate: function(n,e) {
8690
 
                $.ui.plugin.call(this, n, [e, this.ui()]);
8691
 
                this.element.triggerHandler(n == "progressbar" ? n : ["progressbar", n].join(""), [e, this.ui()], this.options[n]);
8692
 
        },
8693
 
 
8694
 
        destroy: function() {
8695
 
                this.stop();
8696
 
 
8697
 
                this.element
8698
 
                        .removeClass("ui-progressbar ui-progressbar-disabled")
8699
 
                        .removeData("progressbar").unbind(".progressbar")
8700
 
                        .find('.ui-progressbar-wrap').remove();
8701
 
 
8702
 
                delete jQuery.easing[this.identifier];
8703
 
        },
8704
 
 
8705
 
        enable: function() {
8706
 
                this.element.removeClass("ui-progressbar-disabled");
8707
 
                this.disabled = false;
8708
 
        },
8709
 
 
8710
 
        disable: function() {
8711
 
                this.element.addClass("ui-progressbar-disabled");
8712
 
                this.disabled = true;
8713
 
        },
8714
 
 
8715
 
        start: function() {
8716
 
                var self = this, options = this.options;
8717
 
 
8718
 
                if (this.disabled) {
8719
 
                        return;
8720
 
                }
8721
 
 
8722
 
                jQuery.easing[this.identifier] = function (x, t, b, c, d) {
8723
 
                        var inc = options.increment,
8724
 
                                width = options.width,
8725
 
                                step = ((inc > width ? width : inc)/width),
8726
 
                                state = Math.round(x/step)*step;
8727
 
                        return state > 1 ? 1 : state;
8728
 
                };
8729
 
 
8730
 
                self.active = true;
8731
 
 
8732
 
                setTimeout(
8733
 
                        function() {
8734
 
                                self.active = false;
8735
 
                        },
8736
 
                        options.duration
8737
 
                );
8738
 
 
8739
 
                this._animate();
8740
 
 
8741
 
                this._propagate('start', this.ui());
8742
 
                return false;
8743
 
        },
8744
 
 
8745
 
        _animate: function() {
8746
 
                var self = this,
8747
 
                        options = this.options,
8748
 
                        interval = options.interval;
8749
 
 
8750
 
                this.bar.animate(
8751
 
                        {
8752
 
                                width: options.width
8753
 
                        },
8754
 
                        {
8755
 
                                duration: interval,
8756
 
                                easing: this.identifier,
8757
 
                                step: function(step, b) {
8758
 
                                        self.progress((step/options.width)*100);
8759
 
                                        var timestamp = new Date().getTime(), elapsedTime  = (timestamp - b.startTime);
8760
 
                                        options.interval = interval - elapsedTime;
8761
 
                                },
8762
 
                                complete: function() {
8763
 
                                        delete jQuery.easing[self.identifier];
8764
 
                                        self.pause();
8765
 
 
8766
 
                                        if (self.active) {
8767
 
                                                /*TODO*/
8768
 
                                        }
8769
 
                                }
8770
 
                        }
8771
 
                );
8772
 
        },
8773
 
 
8774
 
        pause: function() {
8775
 
                if (this.disabled) return;
8776
 
                this.bar.stop();
8777
 
                this._propagate('pause', this.ui());
8778
 
        },
8779
 
 
8780
 
        stop: function() {
8781
 
                this.bar.stop();
8782
 
                this.bar.width(0);
8783
 
                this.textElement.width(0);
8784
 
                this.bar.addClass('ui-hidden');
8785
 
                this.options.interval = this._interval;
8786
 
                this._propagate('stop', this.ui());
8787
 
        },
8788
 
 
8789
 
        text: function(text){
8790
 
                this.textElement.html(text);
8791
 
                this.textBg.html(text);
8792
 
        },
8793
 
 
8794
 
        progress: function(percentState) {
8795
 
                if (this.bar.is('.ui-hidden')) {
8796
 
                        this.bar.removeClass('ui-hidden');
8797
 
                }
8798
 
 
8799
 
                this.percentState = percentState > 100 ? 100 : percentState;
8800
 
                this.pixelState = (this.percentState/100)*this.options.width;
8801
 
                this.bar.width(this.pixelState);
8802
 
                this.textElement.width(this.pixelState);
8803
 
 
8804
 
                if (this.options.range && !this.options.text) {
8805
 
                        this.textElement.html(Math.round(this.percentState) + '%');
8806
 
                }
8807
 
                this._propagate('progress', this.ui());
8808
 
        }
8809
 
});
8810
 
 
8811
 
$.ui.progressbar.defaults = {
8812
 
        width: 300,
8813
 
        duration: 3000,
8814
 
        interval: 200,
8815
 
        increment: 1,
8816
 
        range: true,
8817
 
        text: '',
8818
 
        addClass: '',
8819
 
        textClass: ''
8820
 
};
8821
 
 
8822
 
})(jQuery);/*
8823
 
 * jQuery UI Slider @VERSION
8824
 
 *
8825
 
 * Copyright (c) 2008 Paul Bakaus
8826
 
 * Dual licensed under the MIT (MIT-LICENSE.txt)
8827
 
 * and GPL (GPL-LICENSE.txt) licenses.
8828
 
 * 
8829
 
 * http://docs.jquery.com/UI/Slider
8830
 
 *
8831
 
 * Depends:
8832
 
 *      ui.core.js
8833
 
 */
8834
 
(function($) {
8835
 
 
8836
 
$.fn.unwrap = $.fn.unwrap || function(expr) {
8837
 
  return this.each(function(){
8838
 
     $(this).parents(expr).eq(0).after(this).remove();
8839
 
  });
8840
 
};
8841
 
 
8842
 
$.widget("ui.slider", {
8843
 
        plugins: {},
8844
 
        ui: function(e) {
8845
 
                return {
8846
 
                        options: this.options,
8847
 
                        handle: this.currentHandle,
8848
 
                        value: this.options.axis != "both" || !this.options.axis ? Math.round(this.value(null,this.options.axis == "vertical" ? "y" : "x")) : {
8849
 
                                x: Math.round(this.value(null,"x")),
8850
 
                                y: Math.round(this.value(null,"y"))
8851
 
                        },
8852
 
                        range: this._getRange()
8853
 
                };
8854
 
        },
8855
 
        _propagate: function(n,e) {
8856
 
                $.ui.plugin.call(this, n, [e, this.ui()]);
8857
 
                this.element.triggerHandler(n == "slide" ? n : "slide"+n, [e, this.ui()], this.options[n]);
8858
 
        },
8859
 
        destroy: function() {
8860
 
                
8861
 
                this.element
8862
 
                        .removeClass("ui-slider ui-slider-disabled")
8863
 
                        .removeData("slider")
8864
 
                        .unbind(".slider");
8865
 
                
8866
 
                if(this.handle && this.handle.length) {
8867
 
                        this.handle
8868
 
                                .unwrap("a");
8869
 
                        this.handle.each(function() {
8870
 
                                $(this).data("mouse")._mouseDestroy();
8871
 
                        });
8872
 
                }
8873
 
                
8874
 
                this.generated && this.generated.remove();
8875
 
                
8876
 
        },
8877
 
        _setData: function(key, value) {
8878
 
                $.widget.prototype._setData.apply(this, arguments);
8879
 
                if (/min|max|steps/.test(key)) {
8880
 
                        this._initBoundaries();
8881
 
                }
8882
 
                
8883
 
                if(key == "range") {
8884
 
                        value ? this.handle.length == 2 && this._createRange() : this._removeRange();
8885
 
                }
8886
 
                
8887
 
        },
8888
 
 
8889
 
        _init: function() {
8890
 
                
8891
 
                var self = this;
8892
 
                this.element.addClass("ui-slider");
8893
 
                this._initBoundaries();
8894
 
                
8895
 
                // Initialize mouse and key events for interaction
8896
 
                this.handle = $(this.options.handle, this.element);
8897
 
                if (!this.handle.length) {
8898
 
                        self.handle = self.generated = $(self.options.handles || [0]).map(function() {
8899
 
                                var handle = $("<div/>").addClass("ui-slider-handle").appendTo(self.element);
8900
 
                                if (this.id)
8901
 
                                        handle.attr("id", this.id);
8902
 
                                return handle[0];
8903
 
                        });
8904
 
                }
8905
 
                
8906
 
                
8907
 
                var handleclass = function(el) {
8908
 
                        this.element = $(el);
8909
 
                        this.element.data("mouse", this);
8910
 
                        this.options = self.options;
8911
 
                        
8912
 
                        this.element.bind("mousedown", function() {
8913
 
                                if(self.currentHandle) this.blur(self.currentHandle);
8914
 
                                self._focus(this, true);
8915
 
                        });
8916
 
                        
8917
 
                        this._mouseInit();
8918
 
                };
8919
 
                
8920
 
                $.extend(handleclass.prototype, $.ui.mouse, {
8921
 
                        _mouseStart: function(e) { return self._start.call(self, e, this.element[0]); },
8922
 
                        _mouseStop: function(e) { return self._stop.call(self, e, this.element[0]); },
8923
 
                        _mouseDrag: function(e) { return self._drag.call(self, e, this.element[0]); },
8924
 
                        _mouseCapture: function() { return true; },
8925
 
                        trigger: function(e) { this._mouseDown(e); }
8926
 
                });
8927
 
                
8928
 
                
8929
 
                $(this.handle)
8930
 
                        .each(function() {
8931
 
                                new handleclass(this);
8932
 
                        })
8933
 
                        .wrap('<a href="#" style="outline:none;border:none;"></a>')
8934
 
                        .parent()
8935
 
                                .bind('click', function() { return false; })
8936
 
                                .bind('focus', function(e) { self._focus(this.firstChild); })
8937
 
                                .bind('blur', function(e) { self._blur(this.firstChild); })
8938
 
                                .bind('keydown', function(e) { if(!self.options.noKeyboard) return self._keydown(e.keyCode, this.firstChild); })
8939
 
                ;
8940
 
                
8941
 
                // Bind the click to the slider itself
8942
 
                this.element.bind('mousedown.slider', function(e) {
8943
 
                        self._click.apply(self, [e]);
8944
 
                        self.currentHandle.data("mouse").trigger(e);
8945
 
                        self.firstValue = self.firstValue + 1; //This is for always triggering the change event
8946
 
                });
8947
 
                
8948
 
                // Move the first handle to the startValue
8949
 
                $.each(this.options.handles || [], function(index, handle) {
8950
 
                        self.moveTo(handle.start, index, true);
8951
 
                });
8952
 
                if (!isNaN(this.options.startValue))
8953
 
                        this.moveTo(this.options.startValue, 0, true);
8954
 
 
8955
 
                this.previousHandle = $(this.handle[0]); //set the previous handle to the first to allow clicking before selecting the handle
8956
 
                if(this.handle.length == 2 && this.options.range) this._createRange();
8957
 
        },
8958
 
        _initBoundaries: function() {
8959
 
                
8960
 
                var element = this.element[0], o = this.options;
8961
 
                this.actualSize = { width: this.element.outerWidth() , height: this.element.outerHeight() };                    
8962
 
                
8963
 
                $.extend(o, {
8964
 
                        axis: o.axis || (element.offsetWidth < element.offsetHeight ? 'vertical' : 'horizontal'),
8965
 
                        max: !isNaN(parseInt(o.max,10)) ? { x: parseInt(o.max, 10), y: parseInt(o.max, 10) } : ({ x: o.max && o.max.x || 100, y: o.max && o.max.y || 100 }),
8966
 
                        min: !isNaN(parseInt(o.min,10)) ? { x: parseInt(o.min, 10), y: parseInt(o.min, 10) } : ({ x: o.min && o.min.x || 0, y: o.min && o.min.y || 0 })
8967
 
                });
8968
 
                //Prepare the real maxValue
8969
 
                o.realMax = {
8970
 
                        x: o.max.x - o.min.x,
8971
 
                        y: o.max.y - o.min.y
8972
 
                };
8973
 
                //Calculate stepping based on steps
8974
 
                o.stepping = {
8975
 
                        x: o.stepping && o.stepping.x || parseInt(o.stepping, 10) || (o.steps ? o.realMax.x/(o.steps.x || parseInt(o.steps, 10) || o.realMax.x) : 0),
8976
 
                        y: o.stepping && o.stepping.y || parseInt(o.stepping, 10) || (o.steps ? o.realMax.y/(o.steps.y || parseInt(o.steps, 10) || o.realMax.y) : 0)
8977
 
                };
8978
 
        },
8979
 
 
8980
 
        
8981
 
        _keydown: function(keyCode, handle) {
8982
 
                var k = keyCode;
8983
 
                if(/(33|34|35|36|37|38|39|40)/.test(k)) {
8984
 
                        var o = this.options, xpos, ypos;
8985
 
                        if (/(35|36)/.test(k)) {
8986
 
                                xpos = (k == 35) ? o.max.x : o.min.x;
8987
 
                                ypos = (k == 35) ? o.max.y : o.min.y;
8988
 
                        } else {
8989
 
                                var oper = /(34|37|40)/.test(k) ? "-=" : "+=";
8990
 
                                var step = /(37|38|39|40)/.test(k) ? "_oneStep" : "_pageStep";
8991
 
                                xpos = oper + this[step]("x");
8992
 
                                ypos = oper + this[step]("y");
8993
 
                        }
8994
 
                        this.moveTo({
8995
 
                                x: xpos,
8996
 
                                y: ypos
8997
 
                        }, handle);
8998
 
                        return false;
8999
 
                }
9000
 
                return true;
9001
 
        },
9002
 
        _focus: function(handle,hard) {
9003
 
                this.currentHandle = $(handle).addClass('ui-slider-handle-active');
9004
 
                if (hard)
9005
 
                        this.currentHandle.parent()[0].focus();
9006
 
        },
9007
 
        _blur: function(handle) {
9008
 
                $(handle).removeClass('ui-slider-handle-active');
9009
 
                if(this.currentHandle && this.currentHandle[0] == handle) { this.previousHandle = this.currentHandle; this.currentHandle = null; };
9010
 
        },
9011
 
        _click: function(e) {
9012
 
                // This method is only used if:
9013
 
                // - The user didn't click a handle
9014
 
                // - The Slider is not disabled
9015
 
                // - There is a current, or previous selected handle (otherwise we wouldn't know which one to move)
9016
 
                
9017
 
                var pointer = [e.pageX,e.pageY];
9018
 
                
9019
 
                var clickedHandle = false;
9020
 
                this.handle.each(function() {
9021
 
                        if(this == e.target)
9022
 
                                clickedHandle = true;
9023
 
                });
9024
 
                if (clickedHandle || this.options.disabled || !(this.currentHandle || this.previousHandle))
9025
 
                        return;
9026
 
 
9027
 
                // If a previous handle was focussed, focus it again
9028
 
                if (!this.currentHandle && this.previousHandle)
9029
 
                        this._focus(this.previousHandle, true);
9030
 
                
9031
 
                // propagate only for distance > 0, otherwise propagation is done my drag
9032
 
                this.offset = this.element.offset();
9033
 
 
9034
 
                this.moveTo({
9035
 
                        y: this._convertValue(e.pageY - this.offset.top - this.currentHandle[0].offsetHeight/2, "y"),
9036
 
                        x: this._convertValue(e.pageX - this.offset.left - this.currentHandle[0].offsetWidth/2, "x")
9037
 
                }, null, !this.options.distance);
9038
 
        },
9039
 
        
9040
 
 
9041
 
 
9042
 
        _createRange: function() {
9043
 
                if(this.rangeElement) return;
9044
 
                this.rangeElement = $('<div></div>')
9045
 
                        .addClass('ui-slider-range')
9046
 
                        .css({ position: 'absolute' })
9047
 
                        .appendTo(this.element);
9048
 
                this._updateRange();
9049
 
        },
9050
 
        _removeRange: function() {
9051
 
                this.rangeElement.remove();
9052
 
                this.rangeElement = null;
9053
 
        },
9054
 
        _updateRange: function() {
9055
 
                var prop = this.options.axis == "vertical" ? "top" : "left";
9056
 
                var size = this.options.axis == "vertical" ? "height" : "width";
9057
 
                this.rangeElement.css(prop, (parseInt($(this.handle[0]).css(prop),10) || 0) + this._handleSize(0, this.options.axis == "vertical" ? "y" : "x")/2);
9058
 
                this.rangeElement.css(size, (parseInt($(this.handle[1]).css(prop),10) || 0) - (parseInt($(this.handle[0]).css(prop),10) || 0));
9059
 
        },
9060
 
        _getRange: function() {
9061
 
                return this.rangeElement ? this._convertValue(parseInt(this.rangeElement.css(this.options.axis == "vertical" ? "height" : "width"),10), this.options.axis == "vertical" ? "y" : "x") : null;
9062
 
        },
9063
 
 
9064
 
        _handleIndex: function() {
9065
 
                return this.handle.index(this.currentHandle[0]);
9066
 
        },
9067
 
        value: function(handle, axis) {
9068
 
                if(this.handle.length == 1) this.currentHandle = this.handle;
9069
 
                if(!axis) axis = this.options.axis == "vertical" ? "y" : "x";
9070
 
 
9071
 
                var curHandle = $(handle != undefined && handle !== null ? this.handle[handle] || handle : this.currentHandle);
9072
 
                
9073
 
                if(curHandle.data("mouse").sliderValue) {
9074
 
                        return parseInt(curHandle.data("mouse").sliderValue[axis],10);
9075
 
                } else {
9076
 
                        return parseInt(((parseInt(curHandle.css(axis == "x" ? "left" : "top"),10) / (this.actualSize[axis == "x" ? "width" : "height"] - this._handleSize(handle,axis))) * this.options.realMax[axis]) + this.options.min[axis],10);
9077
 
                }
9078
 
 
9079
 
        },
9080
 
        _convertValue: function(value,axis) {
9081
 
                return this.options.min[axis] + (value / (this.actualSize[axis == "x" ? "width" : "height"] - this._handleSize(null,axis))) * this.options.realMax[axis];
9082
 
        },
9083
 
        
9084
 
        _translateValue: function(value,axis) {
9085
 
                return ((value - this.options.min[axis]) / this.options.realMax[axis]) * (this.actualSize[axis == "x" ? "width" : "height"] - this._handleSize(null,axis));
9086
 
        },
9087
 
        _translateRange: function(value,axis) {
9088
 
                if (this.rangeElement) {
9089
 
                        if (this.currentHandle[0] == this.handle[0] && value >= this._translateValue(this.value(1),axis))
9090
 
                                value = this._translateValue(this.value(1,axis) - this._oneStep(axis), axis);
9091
 
                        if (this.currentHandle[0] == this.handle[1] && value <= this._translateValue(this.value(0),axis))
9092
 
                                value = this._translateValue(this.value(0,axis) + this._oneStep(axis), axis);
9093
 
                }
9094
 
                if (this.options.handles) {
9095
 
                        var handle = this.options.handles[this._handleIndex()];
9096
 
                        if (value < this._translateValue(handle.min,axis)) {
9097
 
                                value = this._translateValue(handle.min,axis);
9098
 
                        } else if (value > this._translateValue(handle.max,axis)) {
9099
 
                                value = this._translateValue(handle.max,axis);
9100
 
                        }
9101
 
                }
9102
 
                return value;
9103
 
        },
9104
 
        _translateLimits: function(value,axis) {
9105
 
                if (value >= this.actualSize[axis == "x" ? "width" : "height"] - this._handleSize(null,axis))
9106
 
                        value = this.actualSize[axis == "x" ? "width" : "height"] - this._handleSize(null,axis);
9107
 
                if (value <= 0)
9108
 
                        value = 0;
9109
 
                return value;
9110
 
        },
9111
 
        _handleSize: function(handle,axis) {
9112
 
                return $(handle != undefined && handle !== null ? this.handle[handle] : this.currentHandle)[0]["offset"+(axis == "x" ? "Width" : "Height")];    
9113
 
        },
9114
 
        _oneStep: function(axis) {
9115
 
                return this.options.stepping[axis] || 1;
9116
 
        },
9117
 
        _pageStep: function(axis) {
9118
 
                return /* this.options.paging[axis] ||*/ 10;
9119
 
        },
9120
 
 
9121
 
 
9122
 
        _start: function(e, handle) {
9123
 
        
9124
 
                var o = this.options;
9125
 
                if(o.disabled) return false;
9126
 
 
9127
 
                // Prepare the outer size
9128
 
                this.actualSize = { width: this.element.outerWidth() , height: this.element.outerHeight() };
9129
 
        
9130
 
                // This is a especially ugly fix for strange blur events happening on mousemove events
9131
 
                if (!this.currentHandle)
9132
 
                        this._focus(this.previousHandle, true); 
9133
 
 
9134
 
                this.offset = this.element.offset();
9135
 
                
9136
 
                this.handleOffset = this.currentHandle.offset();
9137
 
                this.clickOffset = { top: e.pageY - this.handleOffset.top, left: e.pageX - this.handleOffset.left };
9138
 
                
9139
 
                this.firstValue = this.value();
9140
 
                
9141
 
                this._propagate('start', e);
9142
 
                this._drag(e, handle);
9143
 
                return true;
9144
 
                                        
9145
 
        },
9146
 
        _stop: function(e) {
9147
 
                this._propagate('stop', e);
9148
 
                if (this.firstValue != this.value())
9149
 
                        this._propagate('change', e);
9150
 
                // This is a especially ugly fix for strange blur events happening on mousemove events
9151
 
                this._focus(this.currentHandle, true);
9152
 
                return false;
9153
 
        },
9154
 
        _drag: function(e, handle) {
9155
 
 
9156
 
                var o = this.options;
9157
 
                var position = { top: e.pageY - this.offset.top - this.clickOffset.top, left: e.pageX - this.offset.left - this.clickOffset.left};
9158
 
                if(!this.currentHandle) this._focus(this.previousHandle, true); //This is a especially ugly fix for strange blur events happening on mousemove events
9159
 
 
9160
 
                position.left = this._translateLimits(position.left, "x");
9161
 
                position.top = this._translateLimits(position.top, "y");
9162
 
                
9163
 
                if (o.stepping.x) {
9164
 
                        var value = this._convertValue(position.left, "x");
9165
 
                        value = Math.round(value / o.stepping.x) * o.stepping.x;
9166
 
                        position.left = this._translateValue(value, "x");       
9167
 
                }
9168
 
                if (o.stepping.y) {
9169
 
                        var value = this._convertValue(position.top, "y");
9170
 
                        value = Math.round(value / o.stepping.y) * o.stepping.y;
9171
 
                        position.top = this._translateValue(value, "y");        
9172
 
                }
9173
 
                
9174
 
                position.left = this._translateRange(position.left, "x");
9175
 
                position.top = this._translateRange(position.top, "y");
9176
 
 
9177
 
                if(o.axis != "vertical") this.currentHandle.css({ left: position.left });
9178
 
                if(o.axis != "horizontal") this.currentHandle.css({ top: position.top });
9179
 
                
9180
 
                //Store the slider's value
9181
 
                this.currentHandle.data("mouse").sliderValue = {
9182
 
                        x: Math.round(this._convertValue(position.left, "x")) || 0,
9183
 
                        y: Math.round(this._convertValue(position.top, "y")) || 0
9184
 
                };
9185
 
                
9186
 
                if (this.rangeElement)
9187
 
                        this._updateRange();
9188
 
                this._propagate('slide', e);
9189
 
                return false;
9190
 
        },
9191
 
        
9192
 
        moveTo: function(value, handle, noPropagation) {
9193
 
 
9194
 
                var o = this.options;
9195
 
 
9196
 
                // Prepare the outer size
9197
 
                this.actualSize = { width: this.element.outerWidth() , height: this.element.outerHeight() };
9198
 
 
9199
 
                //If no handle has been passed, no current handle is available and we have multiple handles, return false
9200
 
                if (handle == undefined && !this.currentHandle && this.handle.length != 1)
9201
 
                        return false; 
9202
 
                
9203
 
                //If only one handle is available, use it
9204
 
                if (handle == undefined && !this.currentHandle)
9205
 
                        handle = 0;
9206
 
                
9207
 
                if (handle != undefined)
9208
 
                        this.currentHandle = this.previousHandle = $(this.handle[handle] || handle);
9209
 
 
9210
 
 
9211
 
                if(value.x !== undefined && value.y !== undefined) {
9212
 
                        var x = value.x, y = value.y;
9213
 
                } else {
9214
 
                        var x = value, y = value;
9215
 
                }
9216
 
 
9217
 
                if(x !== undefined && x.constructor != Number) {
9218
 
                        var me = /^\-\=/.test(x), pe = /^\+\=/.test(x);
9219
 
                        if(me || pe) {
9220
 
                                x = this.value(null, "x") + parseInt(x.replace(me ? '=' : '+=', ''), 10);
9221
 
                        } else {
9222
 
                                x = isNaN(parseInt(x, 10)) ? undefined : parseInt(x, 10);
9223
 
                        }
9224
 
                }
9225
 
                
9226
 
                if(y !== undefined && y.constructor != Number) {
9227
 
                        var me = /^\-\=/.test(y), pe = /^\+\=/.test(y);
9228
 
                        if(me || pe) {
9229
 
                                y = this.value(null, "y") + parseInt(y.replace(me ? '=' : '+=', ''), 10);
9230
 
                        } else {
9231
 
                                y = isNaN(parseInt(y, 10)) ? undefined : parseInt(y, 10);
9232
 
                        }
9233
 
                }
9234
 
 
9235
 
                if(o.axis != "vertical" && x !== undefined) {
9236
 
                        if(o.stepping.x) x = Math.round(x / o.stepping.x) * o.stepping.x;
9237
 
                        x = this._translateValue(x, "x");
9238
 
                        x = this._translateLimits(x, "x");
9239
 
                        x = this._translateRange(x, "x");
9240
 
 
9241
 
                        o.animate ? this.currentHandle.stop().animate({ left: x }, (Math.abs(parseInt(this.currentHandle.css("left")) - x)) * (!isNaN(parseInt(o.animate)) ? o.animate : 5)) : this.currentHandle.css({ left: x });
9242
 
                }
9243
 
 
9244
 
                if(o.axis != "horizontal" && y !== undefined) {
9245
 
                        if(o.stepping.y) y = Math.round(y / o.stepping.y) * o.stepping.y;
9246
 
                        y = this._translateValue(y, "y");
9247
 
                        y = this._translateLimits(y, "y");
9248
 
                        y = this._translateRange(y, "y");
9249
 
                        o.animate ? this.currentHandle.stop().animate({ top: y }, (Math.abs(parseInt(this.currentHandle.css("top")) - y)) * (!isNaN(parseInt(o.animate)) ? o.animate : 5)) : this.currentHandle.css({ top: y });
9250
 
                }
9251
 
                
9252
 
                if (this.rangeElement)
9253
 
                        this._updateRange();
9254
 
                        
9255
 
                //Store the slider's value
9256
 
                this.currentHandle.data("mouse").sliderValue = {
9257
 
                        x: Math.round(this._convertValue(x, "x")) || 0,
9258
 
                        y: Math.round(this._convertValue(y, "y")) || 0
9259
 
                };
9260
 
        
9261
 
                if (!noPropagation) {
9262
 
                        this._propagate('start', null);
9263
 
                        this._propagate('stop', null);
9264
 
                        this._propagate('change', null);
9265
 
                        this._propagate("slide", null);
9266
 
                }
9267
 
        }
9268
 
});
9269
 
 
9270
 
$.ui.slider.getter = "value";
9271
 
 
9272
 
$.ui.slider.defaults = {
9273
 
        handle: ".ui-slider-handle",
9274
 
        distance: 1,
9275
 
        animate: false
9276
 
};
9277
 
 
9278
 
})(jQuery);
9279
 
/*
9280
 
 * jQuery UI Spinner @VERSION
9281
 
 *
9282
 
 * Copyright (c) 2008 jQuery
9283
 
 * Dual licensed under the MIT (MIT-LICENSE.txt)
9284
 
 * and GPL (GPL-LICENSE.txt) licenses.
9285
 
 *
9286
 
 * http://docs.jquery.com/UI/Spinner
9287
 
 *
9288
 
 * Depends:
9289
 
 *  ui.core.js
9290
 
 */
9291
 
(function($) {
9292
 
 
9293
 
$.widget('ui.spinner', {
9294
 
        _init: function() {
9295
 
                // terminate initialization if spinner already applied to current element
9296
 
                if($.data(this.element[0], 'spinner')) return;
9297
 
                
9298
 
                // check for onInit callback
9299
 
                if (this.options.init) {
9300
 
                        this.options.init(this.ui(null));
9301
 
                }
9302
 
                
9303
 
                // check for decimals in steppinng and set _decimals as internal (needs cleaning up)
9304
 
                this._decimals = 0;
9305
 
                if (this.options.stepping.toString().indexOf('.') != -1) {
9306
 
                        var s = this.options.stepping.toString();
9307
 
                        this._decimals = s.slice(s.indexOf('.')+1, s.length).length;
9308
 
                }
9309
 
                
9310
 
                //Initialize needed constants
9311
 
                var self = this;
9312
 
                this.element
9313
 
                        .addClass('ui-spinner-box')
9314
 
                        .attr('autocomplete', 'off'); // switch off autocomplete in opera
9315
 
                
9316
 
                this._setValue( isNaN(this._getValue()) ? this.options.start : this._getValue() );
9317
 
                
9318
 
                this.element
9319
 
                .wrap('<div>')
9320
 
                .parent()
9321
 
                        .addClass('ui-spinner')
9322
 
                        .append('<button class="ui-spinner-up" type="button">&#9650;</button>')
9323
 
                        .find('.ui-spinner-up')
9324
 
                                .bind('mousedown', function(e) {
9325
 
                                        $(this).addClass('ui-spinner-pressed');
9326
 
                                        if(!self.counter) self.counter = 1;
9327
 
                                        self._mousedown(100, '_up', e);
9328
 
                                })
9329
 
                                .bind('mouseup', function(e) {
9330
 
                                        $(this).removeClass('ui-spinner-pressed');
9331
 
                                        if(self.counter == 1) self._up(e);
9332
 
                                        self._mouseup(e);
9333
 
                                })
9334
 
                                .bind('mouseout', function(e) {
9335
 
                                        $(this).removeClass('ui-spinner-pressed');
9336
 
                                        self._mouseup(e);
9337
 
                                })
9338
 
                                // mousedown/mouseup capture first click, now handle second click
9339
 
                                .bind('dblclick', function(e) {
9340
 
                                        $(this).removeClass('ui-spinner-pressed');
9341
 
                                        self._up(e);
9342
 
                                })
9343
 
                                .bind('keydown.spinner', function(e) {
9344
 
                                        var KEYS = $.keyCode;
9345
 
                                        if (e.keyCode == KEYS.SPACE || e.keyCode == KEYS.ENTER) {
9346
 
                                                $(this).addClass('ui-spinner-pressed');
9347
 
                                                if(!self.counter) self.counter = 1;
9348
 
                                                self._up.call(self, e);
9349
 
                                        } else if (e.keyCode == KEYS.DOWN || e.keyCode == KEYS.RIGHT) {
9350
 
                                                self.element.siblings('.ui-spinner-down').focus();
9351
 
                                        } else if (e.keyCode == KEYS.LEFT) {
9352
 
                                                self.element.focus();
9353
 
                                        }
9354
 
                                })
9355
 
                                .bind('keyup.spinner', function(e) {
9356
 
                                        $(this).removeClass('ui-spinner-pressed');
9357
 
                                        self.counter = 0;
9358
 
                                        self._propagate('change', e);
9359
 
                                })
9360
 
                        .end()
9361
 
                        .append('<button class="ui-spinner-down" type="button">&#9660;</button>')
9362
 
                        .find('.ui-spinner-down')
9363
 
                                .bind('mousedown', function(e) {
9364
 
                                        $(this).addClass('ui-spinner-pressed');
9365
 
                                        if(!self.counter) self.counter = 1;
9366
 
                                        self._mousedown(100, '_down', e);
9367
 
                                })
9368
 
                                .bind('mouseup', function(e) {
9369
 
                                        $(this).removeClass('ui-spinner-pressed');
9370
 
                                        if(self.counter == 1) self._down();
9371
 
                                        self._mouseup(e);
9372
 
                                })
9373
 
                                .bind('mouseout', function(e) {
9374
 
                                        $(this).removeClass('ui-spinner-pressed');
9375
 
                                        self._mouseup(e);
9376
 
                                })
9377
 
                                // mousedown/mouseup capture first click, now handle second click
9378
 
                                .bind('dblclick', function(e) {
9379
 
                                        $(this).removeClass('ui-spinner-pressed');
9380
 
                                        self._down(e);
9381
 
                                })
9382
 
                                .bind('keydown.spinner', function(e) {
9383
 
                                        var KEYS = $.keyCode;
9384
 
                                        if (e.keyCode == KEYS.SPACE || e.keyCode == KEYS.ENTER) {
9385
 
                                                $(this).addClass('ui-spinner-pressed');
9386
 
                                                if(!self.counter) self.counter = 1;
9387
 
                                                self._down.call(self, e);
9388
 
                                        } else if (e.keyCode == KEYS.UP || e.keyCode == KEYS.LEFT) {
9389
 
                                                self.element.siblings('.ui-spinner-up').focus();
9390
 
                                        }
9391
 
                                })
9392
 
                                .bind('keyup.spinner', function(e) {
9393
 
                                        $(this).removeClass('ui-spinner-pressed');
9394
 
                                        self.counter = 0;
9395
 
                                        self._propagate('change', e);
9396
 
                                })
9397
 
                        .end();
9398
 
                
9399
 
                
9400
 
                // DataList: Set contraints for object length and step size. 
9401
 
                // Manipulate height of spinner.
9402
 
                this._items = this.element.children().length;
9403
 
                if (this._items > 1) {
9404
 
                        this.element
9405
 
                        .addClass('ui-spinner-list')
9406
 
                        .css('height', this.element.outerHeight()/this._items)
9407
 
                        .children()
9408
 
                                .addClass('ui-spinner-listitem')
9409
 
                        .end()
9410
 
                        .parent()
9411
 
                                .css('height', this.element.outerHeight())
9412
 
                        .end();
9413
 
                        this.options.stepping = 1;
9414
 
                        this.options.min = 0;
9415
 
                        this.options.max = this._items-1;
9416
 
                }
9417
 
                
9418
 
                this.element
9419
 
                .bind('keydown.spinner', function(e) {
9420
 
                        if(!self.counter) self.counter = 1;
9421
 
                        return self._keydown.call(self, e);
9422
 
                })
9423
 
                .bind('keyup.spinner', function(e) {
9424
 
                        self.counter = 0;
9425
 
                        self._propagate('change', e);
9426
 
                })
9427
 
                .bind('blur.spinner', function(e) {
9428
 
                        self._cleanUp();
9429
 
                });
9430
 
                
9431
 
                if ($.fn.mousewheel) {
9432
 
                        this.element.mousewheel(function(e, delta) {
9433
 
                                self._mousewheel(e, delta);
9434
 
                        });
9435
 
                }
9436
 
        },
9437
 
        
9438
 
        
9439
 
        _constrain: function() {
9440
 
                if(this.options.min != undefined && this._getValue() < this.options.min) this._setValue(this.options.min);
9441
 
                if(this.options.max != undefined && this._getValue() > this.options.max) this._setValue(this.options.max);
9442
 
        },
9443
 
        _cleanUp: function() {
9444
 
                this._setValue(this._getValue());
9445
 
                this._constrain();
9446
 
        },
9447
 
        _spin: function(d, e) {
9448
 
                if (this.disabled) return;
9449
 
                
9450
 
                if(isNaN(this._getValue())) this._setValue(this.options.start);
9451
 
                this._setValue(this._getValue() + (d == 'up' ? 1:-1) * (this.options.incremental && this.counter > 100 ? (this.counter > 200 ? 100 : 10) : 1) * this.options.stepping);
9452
 
                this._animate(d);
9453
 
                this._constrain();
9454
 
                if(this.counter) this.counter++;
9455
 
                this._propagate('spin', e);
9456
 
        },
9457
 
        _down: function(e) {
9458
 
                this._spin('down', e);
9459
 
                this._propagate('down', e);
9460
 
        },
9461
 
        _up: function(e) {
9462
 
                this._spin('up', e);
9463
 
                this._propagate('up', e);
9464
 
        },
9465
 
        _mousedown: function(i, d, e) {
9466
 
                var self = this;
9467
 
                i = i || 100;
9468
 
                if(this.timer) window.clearInterval(this.timer);
9469
 
                this.timer = window.setInterval(function() {
9470
 
                        self[d](e);
9471
 
                        if(self.counter > 20) self._mousedown(20, d, e);
9472
 
                }, i);
9473
 
        },
9474
 
        _mouseup: function(e) {
9475
 
                this.counter = 0;
9476
 
                if(this.timer) window.clearInterval(this.timer);
9477
 
                this.element[0].focus();
9478
 
                this._propagate('change', e);
9479
 
        },
9480
 
        _keydown: function(e) {
9481
 
                var KEYS = $.keyCode;
9482
 
                
9483
 
                if(e.keyCode == KEYS.UP) this._up(e);
9484
 
                if(e.keyCode == KEYS.DOWN) this._down(e);
9485
 
                if(e.keyCode == KEYS.HOME) this._setValue(this.options.min || this.options.start); //Home key goes to min, if defined, else to start
9486
 
                if(e.keyCode == KEYS.END && this.options.max != undefined) this._setValue(this.options.max); //End key goes to maximum
9487
 
                return (e.keyCode == KEYS.TAB || e.keyCode == KEYS.BACKSPACE ||
9488
 
                        e.keyCode == KEYS.LEFT || e.keyCode == KEYS.RIGHT || e.keyCode == KEYS.PERIOD || 
9489
 
                        e.keyCode == KEYS.NUMPAD_DECIMAL || e.keyCode == KEYS.NUMPAD_SUBTRACT || 
9490
 
                        (e.keyCode >= 96 && e.keyCode <= 105) || // add support for numeric keypad 0-9
9491
 
                        (/[0-9\-\.]/).test(String.fromCharCode(e.keyCode))) ? true : false;
9492
 
        },
9493
 
        _mousewheel: function(e, delta) {
9494
 
                delta = ($.browser.opera ? -delta / Math.abs(delta) : delta);
9495
 
                delta > 0 ? this._up(e) : this._down(e);
9496
 
                e.preventDefault();
9497
 
        },
9498
 
        _getValue: function() {
9499
 
                return parseFloat(this.element.val().replace(/[^0-9\-\.]/g, ''));
9500
 
        },
9501
 
        _setValue: function(newVal) {
9502
 
                if(isNaN(newVal)) newVal = this.options.start;
9503
 
                this.element.val(
9504
 
                        this.options.currency ? 
9505
 
                                $.ui.spinner.format.currency(newVal, this.options.currency) : 
9506
 
                                $.ui.spinner.format.number(newVal, this._decimals)
9507
 
                );
9508
 
        },
9509
 
        _animate: function(d) {
9510
 
                if (this.element.hasClass('ui-spinner-list') && ((d == 'up' && this._getValue() <= this.options.max) || (d == 'down' && this._getValue() >= this.options.min)) ) {
9511
 
                        this.element.animate({marginTop: '-' + this._getValue() * this.element.outerHeight() }, {
9512
 
                                duration: 'fast', 
9513
 
                                queue: false
9514
 
                        });
9515
 
                }
9516
 
        },
9517
 
        _addItem: function(html) {
9518
 
                if (!this.element.is('input')) {
9519
 
                        var wrapper = 'div';
9520
 
                        if (this.element.is('ol') || this.element.is('ul')) {
9521
 
                                wrapper = 'li';
9522
 
                        }
9523
 
                        this.element.append('<'+ wrapper +' class="ui-spinner-dyn">'+ html + '</'+ wrapper +'>');
9524
 
                }
9525
 
        },
9526
 
        
9527
 
        
9528
 
        plugins: {},
9529
 
        ui: function(e) {
9530
 
                return {
9531
 
                        options: this.options,
9532
 
                        element: this.element,
9533
 
                        value: this._getValue(),
9534
 
                        add: this._addItem
9535
 
                };
9536
 
        },
9537
 
        _propagate: function(n,e) {
9538
 
                $.ui.plugin.call(this, n, [e, this.ui()]);
9539
 
                return this.element.triggerHandler(n == 'spin' ? n : 'spin'+n, [e, this.ui()], this.options[n]);
9540
 
        },
9541
 
        destroy: function() {
9542
 
                if(!$.data(this.element[0], 'spinner')) return;
9543
 
                if ($.fn.mousewheel) {
9544
 
                        this.element.unmousewheel();
9545
 
                }
9546
 
                this.element
9547
 
                        .removeClass('ui-spinner-box ui-spinner-list')
9548
 
                        .removeAttr('disabled')
9549
 
                        .removeAttr('autocomplete')
9550
 
                        .removeData('spinner')
9551
 
                        .unbind('.spinner')
9552
 
                        .siblings()
9553
 
                                .remove()
9554
 
                        .end()
9555
 
                        .children()
9556
 
                                .removeClass('ui-spinner-listitem')
9557
 
                                .remove('.ui-spinner-dyn')
9558
 
                        .end()
9559
 
                        .parent()
9560
 
                                .removeClass('ui-spinner ui-spinner-disabled')
9561
 
                                .before(this.element.clone())
9562
 
                                .remove()
9563
 
                        .end();
9564
 
        },
9565
 
        enable: function() {
9566
 
                this.element
9567
 
                        .removeAttr('disabled')
9568
 
                        .siblings()
9569
 
                                .removeAttr('disabled')
9570
 
                        .parent()
9571
 
                                .removeClass('ui-spinner-disabled');
9572
 
                this.disabled = false;
9573
 
        },
9574
 
        disable: function() {
9575
 
                this.element
9576
 
                        .attr('disabled', true)
9577
 
                        .siblings()
9578
 
                                .attr('disabled', true)
9579
 
                        .parent()
9580
 
                                .addClass('ui-spinner-disabled');
9581
 
                this.disabled = true;
9582
 
        }
9583
 
});
9584
 
 
9585
 
$.extend($.ui.spinner, {
9586
 
        defaults: {
9587
 
                stepping: 1,
9588
 
                start: 0,
9589
 
                incremental: true,
9590
 
                currency: false
9591
 
        },
9592
 
        format: {
9593
 
                number: function(num, dec) {
9594
 
                        return this.round(num, dec);
9595
 
                },
9596
 
                currency: function(num, sym) {
9597
 
                        return (num !== Math.abs(num) ? '-' : '') + sym + this.round(Math.abs(num), 2);
9598
 
                },
9599
 
                round: function(num, dec) {
9600
 
                        var s = Math.round(parseFloat(num)*Math.pow(10, dec)) / Math.pow(10, dec); // round off weird decimals
9601
 
                        if (dec > 0) {
9602
 
                                s = s + ((s.toString().indexOf('.') == -1) ? '.' : '') + '0000000001';
9603
 
                                s = s.substr(0, s.indexOf('.')+1+dec);
9604
 
                        } else {
9605
 
                                s = Math.round(s);
9606
 
                        }
9607
 
                        return s;
9608
 
                }
9609
 
        }
9610
 
});
9611
 
 
9612
 
})(jQuery);
9613
 
/*
9614
 
 * jQuery UI Tabs @VERSION
9615
 
 *
9616
 
 * Copyright (c) 2007, 2008 Klaus Hartl (stilbuero.de)
9617
 
 * Dual licensed under the MIT (MIT-LICENSE.txt)
9618
 
 * and GPL (GPL-LICENSE.txt) licenses.
9619
 
 *
9620
 
 * http://docs.jquery.com/UI/Tabs
9621
 
 *
9622
 
 * Depends:
9623
 
 *      ui.core.js
9624
 
 */
9625
 
(function($) {
9626
 
 
9627
 
$.widget("ui.tabs", {
9628
 
        _init: function() {
9629
 
                this.options.event += '.tabs'; // namespace event
9630
 
                
9631
 
                // create tabs
9632
 
                this._tabify(true);
9633
 
        },
9634
 
        _setData: function(key, value) {
9635
 
                if ((/^selected/).test(key))
9636
 
                        this.select(value);
9637
 
                else {
9638
 
                        this.options[key] = value;
9639
 
                        this._tabify();
9640
 
                }
9641
 
        },
9642
 
        length: function() {
9643
 
                return this.$tabs.length;
9644
 
        },
9645
 
        _tabId: function(a) {
9646
 
                return a.title && a.title.replace(/\s/g, '_').replace(/[^A-Za-z0-9\-_:\.]/g, '')
9647
 
                        || this.options.idPrefix + $.data(a);
9648
 
        },
9649
 
        ui: function(tab, panel) {
9650
 
                return {
9651
 
                        options: this.options,
9652
 
                        tab: tab,
9653
 
                        panel: panel,
9654
 
                        index: this.$tabs.index(tab)
9655
 
                };
9656
 
        },
9657
 
        _tabify: function(init) {
9658
 
 
9659
 
                this.$lis = $('li:has(a[href])', this.element);
9660
 
                this.$tabs = this.$lis.map(function() { return $('a', this)[0]; });
9661
 
                this.$panels = $([]);
9662
 
 
9663
 
                var self = this, o = this.options;
9664
 
 
9665
 
                this.$tabs.each(function(i, a) {
9666
 
                        // inline tab
9667
 
                        if (a.hash && a.hash.replace('#', '')) // Safari 2 reports '#' for an empty hash
9668
 
                                self.$panels = self.$panels.add(a.hash);
9669
 
                        // remote tab
9670
 
                        else if ($(a).attr('href') != '#') { // prevent loading the page itself if href is just "#"
9671
 
                                $.data(a, 'href.tabs', a.href); // required for restore on destroy
9672
 
                                $.data(a, 'load.tabs', a.href); // mutable
9673
 
                                var id = self._tabId(a);
9674
 
                                a.href = '#' + id;
9675
 
                                var $panel = $('#' + id);
9676
 
                                if (!$panel.length) {
9677
 
                                        $panel = $(o.panelTemplate).attr('id', id).addClass(o.panelClass)
9678
 
                                                .insertAfter( self.$panels[i - 1] || self.element );
9679
 
                                        $panel.data('destroy.tabs', true);
9680
 
                                }
9681
 
                                self.$panels = self.$panels.add( $panel );
9682
 
                        }
9683
 
                        // invalid tab href
9684
 
                        else
9685
 
                                o.disabled.push(i + 1);
9686
 
                });
9687
 
 
9688
 
                // initialization from scratch
9689
 
                if (init) {
9690
 
 
9691
 
                        // attach necessary classes for styling if not present
9692
 
                        this.element.addClass(o.navClass);
9693
 
                        this.$panels.each(function() {
9694
 
                                var $this = $(this);
9695
 
                                $this.addClass(o.panelClass);
9696
 
                        });
9697
 
 
9698
 
                        // Selected tab
9699
 
                        // use "selected" option or try to retrieve:
9700
 
                        // 1. from fragment identifier in url
9701
 
                        // 2. from cookie
9702
 
                        // 3. from selected class attribute on <li>
9703
 
                        if (o.selected === undefined) {
9704
 
                                if (location.hash) {
9705
 
                                        this.$tabs.each(function(i, a) {
9706
 
                                                if (a.hash == location.hash) {
9707
 
                                                        o.selected = i;
9708
 
                                                        // prevent page scroll to fragment
9709
 
                                                        if ($.browser.msie || $.browser.opera) { // && !o.remote
9710
 
                                                                var $toShow = $(location.hash), toShowId = $toShow.attr('id');
9711
 
                                                                $toShow.attr('id', '');
9712
 
                                                                setTimeout(function() {
9713
 
                                                                        $toShow.attr('id', toShowId); // restore id
9714
 
                                                                }, 500);
9715
 
                                                        }
9716
 
                                                        scrollTo(0, 0);
9717
 
                                                        return false; // break
9718
 
                                                }
9719
 
                                        });
9720
 
                                }
9721
 
                                else if (o.cookie) {
9722
 
                                        var index = parseInt($.cookie('ui-tabs-' + $.data(self.element[0])), 10);
9723
 
                                        if (index && self.$tabs[index])
9724
 
                                                o.selected = index;
9725
 
                                }
9726
 
                                else if (self.$lis.filter('.' + o.selectedClass).length)
9727
 
                                        o.selected = self.$lis.index( self.$lis.filter('.' + o.selectedClass)[0] );
9728
 
                        }
9729
 
                        o.selected = o.selected === null || o.selected !== undefined ? o.selected : 0; // first tab selected by default
9730
 
 
9731
 
                        // Take disabling tabs via class attribute from HTML
9732
 
                        // into account and update option properly.
9733
 
                        // A selected tab cannot become disabled.
9734
 
                        o.disabled = $.unique(o.disabled.concat(
9735
 
                                $.map(this.$lis.filter('.' + o.disabledClass),
9736
 
                                        function(n, i) { return self.$lis.index(n); } )
9737
 
                        )).sort();
9738
 
                        if ($.inArray(o.selected, o.disabled) != -1)
9739
 
                                o.disabled.splice($.inArray(o.selected, o.disabled), 1);
9740
 
                        
9741
 
                        // highlight selected tab
9742
 
                        this.$panels.addClass(o.hideClass);
9743
 
                        this.$lis.removeClass(o.selectedClass);
9744
 
                        if (o.selected !== null) {
9745
 
                                this.$panels.eq(o.selected).show().removeClass(o.hideClass); // use show and remove class to show in any case no matter how it has been hidden before
9746
 
                                this.$lis.eq(o.selected).addClass(o.selectedClass);
9747
 
                                
9748
 
                                // seems to be expected behavior that the show callback is fired
9749
 
                                var onShow = function() {
9750
 
                                        self._trigger('show', null,
9751
 
                                                self.ui(self.$tabs[o.selected], self.$panels[o.selected]));
9752
 
                                };
9753
 
 
9754
 
                                // load if remote tab
9755
 
                                if ($.data(this.$tabs[o.selected], 'load.tabs'))
9756
 
                                        this.load(o.selected, onShow);
9757
 
                                // just trigger show event
9758
 
                                else
9759
 
                                        onShow();
9760
 
                        }
9761
 
                        
9762
 
                        // clean up to avoid memory leaks in certain versions of IE 6
9763
 
                        $(window).bind('unload', function() {
9764
 
                                self.$tabs.unbind('.tabs');
9765
 
                                self.$lis = self.$tabs = self.$panels = null;
9766
 
                        });
9767
 
 
9768
 
                }
9769
 
                // update selected after add/remove
9770
 
                else
9771
 
                        o.selected = this.$lis.index( this.$lis.filter('.' + o.selectedClass)[0] );
9772
 
 
9773
 
                // set or update cookie after init and add/remove respectively
9774
 
                if (o.cookie)
9775
 
                        $.cookie('ui-tabs-' + $.data(self.element[0]), o.selected, o.cookie);
9776
 
                
9777
 
                // disable tabs
9778
 
                for (var i = 0, li; li = this.$lis[i]; i++)
9779
 
                        $(li)[$.inArray(i, o.disabled) != -1 && !$(li).hasClass(o.selectedClass) ? 'addClass' : 'removeClass'](o.disabledClass);
9780
 
 
9781
 
                // reset cache if switching from cached to not cached
9782
 
                if (o.cache === false)
9783
 
                        this.$tabs.removeData('cache.tabs');
9784
 
                
9785
 
                // set up animations
9786
 
                var hideFx, showFx, baseFx = { 'min-width': 0, duration: 1 }, baseDuration = 'normal';
9787
 
                if (o.fx && o.fx.constructor == Array)
9788
 
                        hideFx = o.fx[0] || baseFx, showFx = o.fx[1] || baseFx;
9789
 
                else
9790
 
                        hideFx = showFx = o.fx || baseFx;
9791
 
 
9792
 
                // reset some styles to maintain print style sheets etc.
9793
 
                var resetCSS = { display: '', overflow: '', height: '' };
9794
 
                if (!$.browser.msie) // not in IE to prevent ClearType font issue
9795
 
                        resetCSS.opacity = '';
9796
 
 
9797
 
                // Hide a tab, animation prevents browser scrolling to fragment,
9798
 
                // $show is optional.
9799
 
                function hideTab(clicked, $hide, $show) {
9800
 
                        $hide.animate(hideFx, hideFx.duration || baseDuration, function() { //
9801
 
                                $hide.addClass(o.hideClass).css(resetCSS); // maintain flexible height and accessibility in print etc.
9802
 
                                if ($.browser.msie && hideFx.opacity)
9803
 
                                        $hide[0].style.filter = '';
9804
 
                                if ($show)
9805
 
                                        showTab(clicked, $show, $hide);
9806
 
                        });
9807
 
                }
9808
 
 
9809
 
                // Show a tab, animation prevents browser scrolling to fragment,
9810
 
                // $hide is optional.
9811
 
                function showTab(clicked, $show, $hide) {
9812
 
                        if (showFx === baseFx)
9813
 
                                $show.css('display', 'block'); // prevent occasionally occuring flicker in Firefox cause by gap between showing and hiding the tab panels
9814
 
                        $show.animate(showFx, showFx.duration || baseDuration, function() {
9815
 
                                $show.removeClass(o.hideClass).css(resetCSS); // maintain flexible height and accessibility in print etc.
9816
 
                                if ($.browser.msie && showFx.opacity)
9817
 
                                        $show[0].style.filter = '';
9818
 
 
9819
 
                                // callback
9820
 
                                self._trigger('show', null, self.ui(clicked, $show[0]));
9821
 
                        });
9822
 
                }
9823
 
 
9824
 
                // switch a tab
9825
 
                function switchTab(clicked, $li, $hide, $show) {
9826
 
                        /*if (o.bookmarkable && trueClick) { // add to history only if true click occured, not a triggered click
9827
 
                                $.ajaxHistory.update(clicked.hash);
9828
 
                        }*/
9829
 
                        $li.addClass(o.selectedClass)
9830
 
                                .siblings().removeClass(o.selectedClass);
9831
 
                        hideTab(clicked, $hide, $show);
9832
 
                }
9833
 
 
9834
 
                // attach tab event handler, unbind to avoid duplicates from former tabifying...
9835
 
                this.$tabs.unbind('.tabs').bind(o.event, function() {
9836
 
 
9837
 
                        //var trueClick = e.clientX; // add to history only if true click occured, not a triggered click
9838
 
                        var $li = $(this).parents('li:eq(0)'),
9839
 
                                $hide = self.$panels.filter(':visible'),
9840
 
                                $show = $(this.hash);
9841
 
 
9842
 
                        // If tab is already selected and not unselectable or tab disabled or 
9843
 
                        // or is already loading or click callback returns false stop here.
9844
 
                        // Check if click handler returns false last so that it is not executed
9845
 
                        // for a disabled or loading tab!
9846
 
                        if (($li.hasClass(o.selectedClass) && !o.unselect)
9847
 
                                || $li.hasClass(o.disabledClass) 
9848
 
                                || $(this).hasClass(o.loadingClass)
9849
 
                                || self._trigger('select', null, self.ui(this, $show[0])) === false
9850
 
                                ) {
9851
 
                                this.blur();
9852
 
                                return false;
9853
 
                        }
9854
 
 
9855
 
                        self.options.selected = self.$tabs.index(this);
9856
 
 
9857
 
                        // if tab may be closed
9858
 
                        if (o.unselect) {
9859
 
                                if ($li.hasClass(o.selectedClass)) {
9860
 
                                        self.options.selected = null;
9861
 
                                        $li.removeClass(o.selectedClass);
9862
 
                                        self.$panels.stop();
9863
 
                                        hideTab(this, $hide);
9864
 
                                        this.blur();
9865
 
                                        return false;
9866
 
                                } else if (!$hide.length) {
9867
 
                                        self.$panels.stop();
9868
 
                                        var a = this;
9869
 
                                        self.load(self.$tabs.index(this), function() {
9870
 
                                                $li.addClass(o.selectedClass).addClass(o.unselectClass);
9871
 
                                                showTab(a, $show);
9872
 
                                        });
9873
 
                                        this.blur();
9874
 
                                        return false;
9875
 
                                }
9876
 
                        }
9877
 
 
9878
 
                        if (o.cookie)
9879
 
                                $.cookie('ui-tabs-' + $.data(self.element[0]), self.options.selected, o.cookie);
9880
 
 
9881
 
                        // stop possibly running animations
9882
 
                        self.$panels.stop();
9883
 
 
9884
 
                        // show new tab
9885
 
                        if ($show.length) {
9886
 
 
9887
 
                                // prevent scrollbar scrolling to 0 and than back in IE7, happens only if bookmarking/history is enabled
9888
 
                                /*if ($.browser.msie && o.bookmarkable) {
9889
 
                                        var showId = this.hash.replace('#', '');
9890
 
                                        $show.attr('id', '');
9891
 
                                        setTimeout(function() {
9892
 
                                                $show.attr('id', showId); // restore id
9893
 
                                        }, 0);
9894
 
                                }*/
9895
 
 
9896
 
                                var a = this;
9897
 
                                self.load(self.$tabs.index(this), $hide.length ? 
9898
 
                                        function() {
9899
 
                                                switchTab(a, $li, $hide, $show);
9900
 
                                        } :
9901
 
                                        function() {
9902
 
                                                $li.addClass(o.selectedClass);
9903
 
                                                showTab(a, $show);
9904
 
                                        }
9905
 
                                );
9906
 
 
9907
 
                                // Set scrollbar to saved position - need to use timeout with 0 to prevent browser scroll to target of hash
9908
 
                                /*var scrollX = window.pageXOffset || document.documentElement && document.documentElement.scrollLeft || document.body.scrollLeft || 0;
9909
 
                                var scrollY = window.pageYOffset || document.documentElement && document.documentElement.scrollTop || document.body.scrollTop || 0;
9910
 
                                setTimeout(function() {
9911
 
                                        scrollTo(scrollX, scrollY);
9912
 
                                }, 0);*/
9913
 
 
9914
 
                        } else
9915
 
                                throw 'jQuery UI Tabs: Mismatching fragment identifier.';
9916
 
 
9917
 
                        // Prevent IE from keeping other link focussed when using the back button
9918
 
                        // and remove dotted border from clicked link. This is controlled in modern
9919
 
                        // browsers via CSS, also blur removes focus from address bar in Firefox
9920
 
                        // which can become a usability and annoying problem with tabsRotate.
9921
 
                        if ($.browser.msie)
9922
 
                                this.blur();
9923
 
 
9924
 
                        //return o.bookmarkable && !!trueClick; // convert trueClick == undefined to Boolean required in IE
9925
 
                        return false;
9926
 
 
9927
 
                });
9928
 
 
9929
 
                // disable click if event is configured to something else
9930
 
                if (!(/^click/).test(o.event))
9931
 
                        this.$tabs.bind('click.tabs', function() { return false; });
9932
 
 
9933
 
        },
9934
 
        add: function(url, label, index) {
9935
 
                if (index == undefined) 
9936
 
                        index = this.$tabs.length; // append by default
9937
 
 
9938
 
                var o = this.options;
9939
 
                var $li = $(o.tabTemplate.replace(/#\{href\}/g, url).replace(/#\{label\}/g, label));
9940
 
                $li.data('destroy.tabs', true);
9941
 
 
9942
 
                var id = url.indexOf('#') == 0 ? url.replace('#', '') : this._tabId( $('a:first-child', $li)[0] );
9943
 
 
9944
 
                // try to find an existing element before creating a new one
9945
 
                var $panel = $('#' + id);
9946
 
                if (!$panel.length) {
9947
 
                        $panel = $(o.panelTemplate).attr('id', id)
9948
 
                                .addClass(o.hideClass)
9949
 
                                .data('destroy.tabs', true);
9950
 
                }
9951
 
                $panel.addClass(o.panelClass);
9952
 
                if (index >= this.$lis.length) {
9953
 
                        $li.appendTo(this.element);
9954
 
                        $panel.appendTo(this.element[0].parentNode);
9955
 
                } else {
9956
 
                        $li.insertBefore(this.$lis[index]);
9957
 
                        $panel.insertBefore(this.$panels[index]);
9958
 
                }
9959
 
                
9960
 
                o.disabled = $.map(o.disabled,
9961
 
                        function(n, i) { return n >= index ? ++n : n });
9962
 
                        
9963
 
                this._tabify();
9964
 
 
9965
 
                if (this.$tabs.length == 1) {
9966
 
                        $li.addClass(o.selectedClass);
9967
 
                        $panel.removeClass(o.hideClass);
9968
 
                        var href = $.data(this.$tabs[0], 'load.tabs');
9969
 
                        if (href)
9970
 
                                this.load(index, href);
9971
 
                }
9972
 
 
9973
 
                // callback
9974
 
                this._trigger('add', null, this.ui(this.$tabs[index], this.$panels[index]));
9975
 
        },
9976
 
        remove: function(index) {
9977
 
                var o = this.options, $li = this.$lis.eq(index).remove(),
9978
 
                        $panel = this.$panels.eq(index).remove();
9979
 
 
9980
 
                // If selected tab was removed focus tab to the right or
9981
 
                // in case the last tab was removed the tab to the left.
9982
 
                if ($li.hasClass(o.selectedClass) && this.$tabs.length > 1)
9983
 
                        this.select(index + (index + 1 < this.$tabs.length ? 1 : -1));
9984
 
 
9985
 
                o.disabled = $.map($.grep(o.disabled, function(n, i) { return n != index; }),
9986
 
                        function(n, i) { return n >= index ? --n : n });
9987
 
 
9988
 
                this._tabify();
9989
 
 
9990
 
                // callback
9991
 
                this._trigger('remove', null, this.ui($li.find('a')[0], $panel[0]));
9992
 
        },
9993
 
        enable: function(index) {
9994
 
                var o = this.options;
9995
 
                if ($.inArray(index, o.disabled) == -1)
9996
 
                        return;
9997
 
                        
9998
 
                var $li = this.$lis.eq(index).removeClass(o.disabledClass);
9999
 
                if ($.browser.safari) { // fix disappearing tab (that used opacity indicating disabling) after enabling in Safari 2...
10000
 
                        $li.css('display', 'inline-block');
10001
 
                        setTimeout(function() {
10002
 
                                $li.css('display', 'block');
10003
 
                        }, 0);
10004
 
                }
10005
 
 
10006
 
                o.disabled = $.grep(o.disabled, function(n, i) { return n != index; });
10007
 
 
10008
 
                // callback
10009
 
                this._trigger('enable', null, this.ui(this.$tabs[index], this.$panels[index]));
10010
 
        },
10011
 
        disable: function(index) {
10012
 
                var self = this, o = this.options;
10013
 
                if (index != o.selected) { // cannot disable already selected tab
10014
 
                        this.$lis.eq(index).addClass(o.disabledClass);
10015
 
 
10016
 
                        o.disabled.push(index);
10017
 
                        o.disabled.sort();
10018
 
 
10019
 
                        // callback
10020
 
                        this._trigger('disable', null, this.ui(this.$tabs[index], this.$panels[index]));
10021
 
                }
10022
 
        },
10023
 
        select: function(index) {
10024
 
                if (typeof index == 'string')
10025
 
                        index = this.$tabs.index( this.$tabs.filter('[href$=' + index + ']')[0] );
10026
 
                this.$tabs.eq(index).trigger(this.options.event);
10027
 
        },
10028
 
        load: function(index, callback) { // callback is for internal usage only
10029
 
                
10030
 
                var self = this, o = this.options, $a = this.$tabs.eq(index), a = $a[0],
10031
 
                                bypassCache = callback == undefined || callback === false, url = $a.data('load.tabs');
10032
 
 
10033
 
                callback = callback || function() {};
10034
 
                
10035
 
                // no remote or from cache - just finish with callback
10036
 
                if (!url || !bypassCache && $.data(a, 'cache.tabs')) {
10037
 
                        callback();
10038
 
                        return;
10039
 
                }
10040
 
 
10041
 
                // load remote from here on
10042
 
                
10043
 
                var inner = function(parent) {
10044
 
                        var $parent = $(parent), $inner = $parent.find('*:last');
10045
 
                        return $inner.length && $inner.is(':not(img)') && $inner || $parent;
10046
 
                };
10047
 
                var cleanup = function() {
10048
 
                        self.$tabs.filter('.' + o.loadingClass).removeClass(o.loadingClass)
10049
 
                                                .each(function() {
10050
 
                                                        if (o.spinner)
10051
 
                                                                inner(this).parent().html(inner(this).data('label.tabs'));
10052
 
                                                });
10053
 
                        self.xhr = null;
10054
 
                };
10055
 
                
10056
 
                if (o.spinner) {
10057
 
                        var label = inner(a).html();
10058
 
                        inner(a).wrapInner('<em></em>')
10059
 
                                .find('em').data('label.tabs', label).html(o.spinner);
10060
 
                }
10061
 
 
10062
 
                var ajaxOptions = $.extend({}, o.ajaxOptions, {
10063
 
                        url: url,
10064
 
                        success: function(r, s) {
10065
 
                                $(a.hash).html(r);
10066
 
                                cleanup();
10067
 
                                
10068
 
                                if (o.cache)
10069
 
                                        $.data(a, 'cache.tabs', true); // if loaded once do not load them again
10070
 
 
10071
 
                                // callbacks
10072
 
                                self._trigger('load', null, self.ui(self.$tabs[index], self.$panels[index]));
10073
 
                                o.ajaxOptions.success && o.ajaxOptions.success(r, s);
10074
 
                                
10075
 
                                // This callback is required because the switch has to take
10076
 
                                // place after loading has completed. Call last in order to 
10077
 
                                // fire load before show callback...
10078
 
                                callback();
10079
 
                        }
10080
 
                });
10081
 
                if (this.xhr) {
10082
 
                        // terminate pending requests from other tabs and restore tab label
10083
 
                        this.xhr.abort();
10084
 
                        cleanup();
10085
 
                }
10086
 
                $a.addClass(o.loadingClass);
10087
 
                setTimeout(function() { // timeout is again required in IE, "wait" for id being restored
10088
 
                        self.xhr = $.ajax(ajaxOptions);
10089
 
                }, 0);
10090
 
 
10091
 
        },
10092
 
        url: function(index, url) {
10093
 
                this.$tabs.eq(index).removeData('cache.tabs').data('load.tabs', url);
10094
 
        },
10095
 
        destroy: function() {
10096
 
                var o = this.options;
10097
 
                this.element.unbind('.tabs')
10098
 
                        .removeClass(o.navClass).removeData('tabs');
10099
 
                this.$tabs.each(function() {
10100
 
                        var href = $.data(this, 'href.tabs');
10101
 
                        if (href)
10102
 
                                this.href = href;
10103
 
                        var $this = $(this).unbind('.tabs');
10104
 
                        $.each(['href', 'load', 'cache'], function(i, prefix) {
10105
 
                                $this.removeData(prefix + '.tabs');
10106
 
                        });
10107
 
                });
10108
 
                this.$lis.add(this.$panels).each(function() {
10109
 
                        if ($.data(this, 'destroy.tabs'))
10110
 
                                $(this).remove();
10111
 
                        else
10112
 
                                $(this).removeClass([o.selectedClass, o.unselectClass,
10113
 
                                        o.disabledClass, o.panelClass, o.hideClass].join(' '));
10114
 
                });
10115
 
        }
10116
 
});
10117
 
 
10118
 
$.ui.tabs.defaults = {
10119
 
        // basic setup
10120
 
        unselect: false,
10121
 
        event: 'click',
10122
 
        disabled: [],
10123
 
        cookie: null, // e.g. { expires: 7, path: '/', domain: 'jquery.com', secure: true }
10124
 
        // TODO history: false,
10125
 
 
10126
 
        // Ajax
10127
 
        spinner: 'Loading&#8230;',
10128
 
        cache: false,
10129
 
        idPrefix: 'ui-tabs-',
10130
 
        ajaxOptions: {},
10131
 
 
10132
 
        // animations
10133
 
        fx: null, // e.g. { height: 'toggle', opacity: 'toggle', duration: 200 }
10134
 
 
10135
 
        // templates
10136
 
        tabTemplate: '<li><a href="#{href}"><span>#{label}</span></a></li>',
10137
 
        panelTemplate: '<div></div>',
10138
 
 
10139
 
        // CSS classes
10140
 
        navClass: 'ui-tabs-nav',
10141
 
        selectedClass: 'ui-tabs-selected',
10142
 
        unselectClass: 'ui-tabs-unselect',
10143
 
        disabledClass: 'ui-tabs-disabled',
10144
 
        panelClass: 'ui-tabs-panel',
10145
 
        hideClass: 'ui-tabs-hide',
10146
 
        loadingClass: 'ui-tabs-loading'
10147
 
};
10148
 
 
10149
 
$.ui.tabs.getter = "length";
10150
 
 
10151
 
/*
10152
 
 * Tabs Extensions
10153
 
 */
10154
 
 
10155
 
/*
10156
 
 * Rotate
10157
 
 */
10158
 
$.extend($.ui.tabs.prototype, {
10159
 
        rotation: null,
10160
 
        rotate: function(ms, continuing) {
10161
 
                
10162
 
                continuing = continuing || false;
10163
 
                
10164
 
                var self = this, t = this.options.selected;
10165
 
                
10166
 
                function start() {
10167
 
                        self.rotation = setInterval(function() {
10168
 
                                t = ++t < self.$tabs.length ? t : 0;
10169
 
                                self.select(t);
10170
 
                        }, ms); 
10171
 
                }
10172
 
                
10173
 
                function stop(e) {
10174
 
                        if (!e || e.clientX) { // only in case of a true click
10175
 
                                clearInterval(self.rotation);
10176
 
                        }
10177
 
                }
10178
 
                
10179
 
                // start interval
10180
 
                if (ms) {
10181
 
                        start();
10182
 
                        if (!continuing)
10183
 
                                this.$tabs.bind(this.options.event, stop);
10184
 
                        else
10185
 
                                this.$tabs.bind(this.options.event, function() {
10186
 
                                        stop();
10187
 
                                        t = self.options.selected;
10188
 
                                        start();
10189
 
                                });
10190
 
                }
10191
 
                // stop interval
10192
 
                else {
10193
 
                        stop();
10194
 
                        this.$tabs.unbind(this.options.event, stop);
10195
 
                }
10196
 
        }
10197
 
});
10198
 
 
10199
 
})(jQuery);