96b2ea624a1ce4abaaa6ff3ae2c48e354c7199ac
[ikiwiki.git] / underlays / attachment / ikiwiki / jquery-ui.full.js
1 /*!
2  * jQuery UI 1.8.14
3  *
4  * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
5  * Dual licensed under the MIT or GPL Version 2 licenses.
6  * http://jquery.org/license
7  *
8  * http://docs.jquery.com/UI
9  */
10 (function( $, undefined ) {
11
12 // prevent duplicate loading
13 // this is only a problem because we proxy existing functions
14 // and we don't want to double proxy them
15 $.ui = $.ui || {};
16 if ( $.ui.version ) {
17         return;
18 }
19
20 $.extend( $.ui, {
21         version: "1.8.14",
22
23         keyCode: {
24                 ALT: 18,
25                 BACKSPACE: 8,
26                 CAPS_LOCK: 20,
27                 COMMA: 188,
28                 COMMAND: 91,
29                 COMMAND_LEFT: 91, // COMMAND
30                 COMMAND_RIGHT: 93,
31                 CONTROL: 17,
32                 DELETE: 46,
33                 DOWN: 40,
34                 END: 35,
35                 ENTER: 13,
36                 ESCAPE: 27,
37                 HOME: 36,
38                 INSERT: 45,
39                 LEFT: 37,
40                 MENU: 93, // COMMAND_RIGHT
41                 NUMPAD_ADD: 107,
42                 NUMPAD_DECIMAL: 110,
43                 NUMPAD_DIVIDE: 111,
44                 NUMPAD_ENTER: 108,
45                 NUMPAD_MULTIPLY: 106,
46                 NUMPAD_SUBTRACT: 109,
47                 PAGE_DOWN: 34,
48                 PAGE_UP: 33,
49                 PERIOD: 190,
50                 RIGHT: 39,
51                 SHIFT: 16,
52                 SPACE: 32,
53                 TAB: 9,
54                 UP: 38,
55                 WINDOWS: 91 // COMMAND
56         }
57 });
58
59 // plugins
60 $.fn.extend({
61         _focus: $.fn.focus,
62         focus: function( delay, fn ) {
63                 return typeof delay === "number" ?
64                         this.each(function() {
65                                 var elem = this;
66                                 setTimeout(function() {
67                                         $( elem ).focus();
68                                         if ( fn ) {
69                                                 fn.call( elem );
70                                         }
71                                 }, delay );
72                         }) :
73                         this._focus.apply( this, arguments );
74         },
75
76         scrollParent: function() {
77                 var scrollParent;
78                 if (($.browser.msie && (/(static|relative)/).test(this.css('position'))) || (/absolute/).test(this.css('position'))) {
79                         scrollParent = this.parents().filter(function() {
80                                 return (/(relative|absolute|fixed)/).test($.curCSS(this,'position',1)) && (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));
81                         }).eq(0);
82                 } else {
83                         scrollParent = this.parents().filter(function() {
84                                 return (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));
85                         }).eq(0);
86                 }
87
88                 return (/fixed/).test(this.css('position')) || !scrollParent.length ? $(document) : scrollParent;
89         },
90
91         zIndex: function( zIndex ) {
92                 if ( zIndex !== undefined ) {
93                         return this.css( "zIndex", zIndex );
94                 }
95
96                 if ( this.length ) {
97                         var elem = $( this[ 0 ] ), position, value;
98                         while ( elem.length && elem[ 0 ] !== document ) {
99                                 // Ignore z-index if position is set to a value where z-index is ignored by the browser
100                                 // This makes behavior of this function consistent across browsers
101                                 // WebKit always returns auto if the element is positioned
102                                 position = elem.css( "position" );
103                                 if ( position === "absolute" || position === "relative" || position === "fixed" ) {
104                                         // IE returns 0 when zIndex is not specified
105                                         // other browsers return a string
106                                         // we ignore the case of nested elements with an explicit value of 0
107                                         // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
108                                         value = parseInt( elem.css( "zIndex" ), 10 );
109                                         if ( !isNaN( value ) && value !== 0 ) {
110                                                 return value;
111                                         }
112                                 }
113                                 elem = elem.parent();
114                         }
115                 }
116
117                 return 0;
118         },
119
120         disableSelection: function() {
121                 return this.bind( ( $.support.selectstart ? "selectstart" : "mousedown" ) +
122                         ".ui-disableSelection", function( event ) {
123                                 event.preventDefault();
124                         });
125         },
126
127         enableSelection: function() {
128                 return this.unbind( ".ui-disableSelection" );
129         }
130 });
131
132 $.each( [ "Width", "Height" ], function( i, name ) {
133         var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
134                 type = name.toLowerCase(),
135                 orig = {
136                         innerWidth: $.fn.innerWidth,
137                         innerHeight: $.fn.innerHeight,
138                         outerWidth: $.fn.outerWidth,
139                         outerHeight: $.fn.outerHeight
140                 };
141
142         function reduce( elem, size, border, margin ) {
143                 $.each( side, function() {
144                         size -= parseFloat( $.curCSS( elem, "padding" + this, true) ) || 0;
145                         if ( border ) {
146                                 size -= parseFloat( $.curCSS( elem, "border" + this + "Width", true) ) || 0;
147                         }
148                         if ( margin ) {
149                                 size -= parseFloat( $.curCSS( elem, "margin" + this, true) ) || 0;
150                         }
151                 });
152                 return size;
153         }
154
155         $.fn[ "inner" + name ] = function( size ) {
156                 if ( size === undefined ) {
157                         return orig[ "inner" + name ].call( this );
158                 }
159
160                 return this.each(function() {
161                         $( this ).css( type, reduce( this, size ) + "px" );
162                 });
163         };
164
165         $.fn[ "outer" + name] = function( size, margin ) {
166                 if ( typeof size !== "number" ) {
167                         return orig[ "outer" + name ].call( this, size );
168                 }
169
170                 return this.each(function() {
171                         $( this).css( type, reduce( this, size, true, margin ) + "px" );
172                 });
173         };
174 });
175
176 // selectors
177 function focusable( element, isTabIndexNotNaN ) {
178         var nodeName = element.nodeName.toLowerCase();
179         if ( "area" === nodeName ) {
180                 var map = element.parentNode,
181                         mapName = map.name,
182                         img;
183                 if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
184                         return false;
185                 }
186                 img = $( "img[usemap=#" + mapName + "]" )[0];
187                 return !!img && visible( img );
188         }
189         return ( /input|select|textarea|button|object/.test( nodeName )
190                 ? !element.disabled
191                 : "a" == nodeName
192                         ? element.href || isTabIndexNotNaN
193                         : isTabIndexNotNaN)
194                 // the element and all of its ancestors must be visible
195                 && visible( element );
196 }
197
198 function visible( element ) {
199         return !$( element ).parents().andSelf().filter(function() {
200                 return $.curCSS( this, "visibility" ) === "hidden" ||
201                         $.expr.filters.hidden( this );
202         }).length;
203 }
204
205 $.extend( $.expr[ ":" ], {
206         data: function( elem, i, match ) {
207                 return !!$.data( elem, match[ 3 ] );
208         },
209
210         focusable: function( element ) {
211                 return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) );
212         },
213
214         tabbable: function( element ) {
215                 var tabIndex = $.attr( element, "tabindex" ),
216                         isTabIndexNaN = isNaN( tabIndex );
217                 return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
218         }
219 });
220
221 // support
222 $(function() {
223         var body = document.body,
224                 div = body.appendChild( div = document.createElement( "div" ) );
225
226         $.extend( div.style, {
227                 minHeight: "100px",
228                 height: "auto",
229                 padding: 0,
230                 borderWidth: 0
231         });
232
233         $.support.minHeight = div.offsetHeight === 100;
234         $.support.selectstart = "onselectstart" in div;
235
236         // set display to none to avoid a layout bug in IE
237         // http://dev.jquery.com/ticket/4014
238         body.removeChild( div ).style.display = "none";
239 });
240
241
242
243
244
245 // deprecated
246 $.extend( $.ui, {
247         // $.ui.plugin is deprecated.  Use the proxy pattern instead.
248         plugin: {
249                 add: function( module, option, set ) {
250                         var proto = $.ui[ module ].prototype;
251                         for ( var i in set ) {
252                                 proto.plugins[ i ] = proto.plugins[ i ] || [];
253                                 proto.plugins[ i ].push( [ option, set[ i ] ] );
254                         }
255                 },
256                 call: function( instance, name, args ) {
257                         var set = instance.plugins[ name ];
258                         if ( !set || !instance.element[ 0 ].parentNode ) {
259                                 return;
260                         }
261         
262                         for ( var i = 0; i < set.length; i++ ) {
263                                 if ( instance.options[ set[ i ][ 0 ] ] ) {
264                                         set[ i ][ 1 ].apply( instance.element, args );
265                                 }
266                         }
267                 }
268         },
269         
270         // will be deprecated when we switch to jQuery 1.4 - use jQuery.contains()
271         contains: function( a, b ) {
272                 return document.compareDocumentPosition ?
273                         a.compareDocumentPosition( b ) & 16 :
274                         a !== b && a.contains( b );
275         },
276         
277         // only used by resizable
278         hasScroll: function( el, a ) {
279         
280                 //If overflow is hidden, the element might have extra content, but the user wants to hide it
281                 if ( $( el ).css( "overflow" ) === "hidden") {
282                         return false;
283                 }
284         
285                 var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
286                         has = false;
287         
288                 if ( el[ scroll ] > 0 ) {
289                         return true;
290                 }
291         
292                 // TODO: determine which cases actually cause this to happen
293                 // if the element doesn't have the scroll set, see if it's possible to
294                 // set the scroll
295                 el[ scroll ] = 1;
296                 has = ( el[ scroll ] > 0 );
297                 el[ scroll ] = 0;
298                 return has;
299         },
300         
301         // these are odd functions, fix the API or move into individual plugins
302         isOverAxis: function( x, reference, size ) {
303                 //Determines when x coordinate is over "b" element axis
304                 return ( x > reference ) && ( x < ( reference + size ) );
305         },
306         isOver: function( y, x, top, left, height, width ) {
307                 //Determines when x, y coordinates is over "b" element
308                 return $.ui.isOverAxis( y, top, height ) && $.ui.isOverAxis( x, left, width );
309         }
310 });
311
312 })( jQuery );
313 /*!
314  * jQuery UI Widget 1.8.14
315  *
316  * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
317  * Dual licensed under the MIT or GPL Version 2 licenses.
318  * http://jquery.org/license
319  *
320  * http://docs.jquery.com/UI/Widget
321  */
322 (function( $, undefined ) {
323
324 // jQuery 1.4+
325 if ( $.cleanData ) {
326         var _cleanData = $.cleanData;
327         $.cleanData = function( elems ) {
328                 for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
329                         $( elem ).triggerHandler( "remove" );
330                 }
331                 _cleanData( elems );
332         };
333 } else {
334         var _remove = $.fn.remove;
335         $.fn.remove = function( selector, keepData ) {
336                 return this.each(function() {
337                         if ( !keepData ) {
338                                 if ( !selector || $.filter( selector, [ this ] ).length ) {
339                                         $( "*", this ).add( [ this ] ).each(function() {
340                                                 $( this ).triggerHandler( "remove" );
341                                         });
342                                 }
343                         }
344                         return _remove.call( $(this), selector, keepData );
345                 });
346         };
347 }
348
349 $.widget = function( name, base, prototype ) {
350         var namespace = name.split( "." )[ 0 ],
351                 fullName;
352         name = name.split( "." )[ 1 ];
353         fullName = namespace + "-" + name;
354
355         if ( !prototype ) {
356                 prototype = base;
357                 base = $.Widget;
358         }
359
360         // create selector for plugin
361         $.expr[ ":" ][ fullName ] = function( elem ) {
362                 return !!$.data( elem, name );
363         };
364
365         $[ namespace ] = $[ namespace ] || {};
366         $[ namespace ][ name ] = function( options, element ) {
367                 // allow instantiation without initializing for simple inheritance
368                 if ( arguments.length ) {
369                         this._createWidget( options, element );
370                 }
371         };
372
373         var basePrototype = new base();
374         // we need to make the options hash a property directly on the new instance
375         // otherwise we'll modify the options hash on the prototype that we're
376         // inheriting from
377 //      $.each( basePrototype, function( key, val ) {
378 //              if ( $.isPlainObject(val) ) {
379 //                      basePrototype[ key ] = $.extend( {}, val );
380 //              }
381 //      });
382         basePrototype.options = $.extend( true, {}, basePrototype.options );
383         $[ namespace ][ name ].prototype = $.extend( true, basePrototype, {
384                 namespace: namespace,
385                 widgetName: name,
386                 widgetEventPrefix: $[ namespace ][ name ].prototype.widgetEventPrefix || name,
387                 widgetBaseClass: fullName
388         }, prototype );
389
390         $.widget.bridge( name, $[ namespace ][ name ] );
391 };
392
393 $.widget.bridge = function( name, object ) {
394         $.fn[ name ] = function( options ) {
395                 var isMethodCall = typeof options === "string",
396                         args = Array.prototype.slice.call( arguments, 1 ),
397                         returnValue = this;
398
399                 // allow multiple hashes to be passed on init
400                 options = !isMethodCall && args.length ?
401                         $.extend.apply( null, [ true, options ].concat(args) ) :
402                         options;
403
404                 // prevent calls to internal methods
405                 if ( isMethodCall && options.charAt( 0 ) === "_" ) {
406                         return returnValue;
407                 }
408
409                 if ( isMethodCall ) {
410                         this.each(function() {
411                                 var instance = $.data( this, name ),
412                                         methodValue = instance && $.isFunction( instance[options] ) ?
413                                                 instance[ options ].apply( instance, args ) :
414                                                 instance;
415                                 // TODO: add this back in 1.9 and use $.error() (see #5972)
416 //                              if ( !instance ) {
417 //                                      throw "cannot call methods on " + name + " prior to initialization; " +
418 //                                              "attempted to call method '" + options + "'";
419 //                              }
420 //                              if ( !$.isFunction( instance[options] ) ) {
421 //                                      throw "no such method '" + options + "' for " + name + " widget instance";
422 //                              }
423 //                              var methodValue = instance[ options ].apply( instance, args );
424                                 if ( methodValue !== instance && methodValue !== undefined ) {
425                                         returnValue = methodValue;
426                                         return false;
427                                 }
428                         });
429                 } else {
430                         this.each(function() {
431                                 var instance = $.data( this, name );
432                                 if ( instance ) {
433                                         instance.option( options || {} )._init();
434                                 } else {
435                                         $.data( this, name, new object( options, this ) );
436                                 }
437                         });
438                 }
439
440                 return returnValue;
441         };
442 };
443
444 $.Widget = function( options, element ) {
445         // allow instantiation without initializing for simple inheritance
446         if ( arguments.length ) {
447                 this._createWidget( options, element );
448         }
449 };
450
451 $.Widget.prototype = {
452         widgetName: "widget",
453         widgetEventPrefix: "",
454         options: {
455                 disabled: false
456         },
457         _createWidget: function( options, element ) {
458                 // $.widget.bridge stores the plugin instance, but we do it anyway
459                 // so that it's stored even before the _create function runs
460                 $.data( element, this.widgetName, this );
461                 this.element = $( element );
462                 this.options = $.extend( true, {},
463                         this.options,
464                         this._getCreateOptions(),
465                         options );
466
467                 var self = this;
468                 this.element.bind( "remove." + this.widgetName, function() {
469                         self.destroy();
470                 });
471
472                 this._create();
473                 this._trigger( "create" );
474                 this._init();
475         },
476         _getCreateOptions: function() {
477                 return $.metadata && $.metadata.get( this.element[0] )[ this.widgetName ];
478         },
479         _create: function() {},
480         _init: function() {},
481
482         destroy: function() {
483                 this.element
484                         .unbind( "." + this.widgetName )
485                         .removeData( this.widgetName );
486                 this.widget()
487                         .unbind( "." + this.widgetName )
488                         .removeAttr( "aria-disabled" )
489                         .removeClass(
490                                 this.widgetBaseClass + "-disabled " +
491                                 "ui-state-disabled" );
492         },
493
494         widget: function() {
495                 return this.element;
496         },
497
498         option: function( key, value ) {
499                 var options = key;
500
501                 if ( arguments.length === 0 ) {
502                         // don't return a reference to the internal hash
503                         return $.extend( {}, this.options );
504                 }
505
506                 if  (typeof key === "string" ) {
507                         if ( value === undefined ) {
508                                 return this.options[ key ];
509                         }
510                         options = {};
511                         options[ key ] = value;
512                 }
513
514                 this._setOptions( options );
515
516                 return this;
517         },
518         _setOptions: function( options ) {
519                 var self = this;
520                 $.each( options, function( key, value ) {
521                         self._setOption( key, value );
522                 });
523
524                 return this;
525         },
526         _setOption: function( key, value ) {
527                 this.options[ key ] = value;
528
529                 if ( key === "disabled" ) {
530                         this.widget()
531                                 [ value ? "addClass" : "removeClass"](
532                                         this.widgetBaseClass + "-disabled" + " " +
533                                         "ui-state-disabled" )
534                                 .attr( "aria-disabled", value );
535                 }
536
537                 return this;
538         },
539
540         enable: function() {
541                 return this._setOption( "disabled", false );
542         },
543         disable: function() {
544                 return this._setOption( "disabled", true );
545         },
546
547         _trigger: function( type, event, data ) {
548                 var callback = this.options[ type ];
549
550                 event = $.Event( event );
551                 event.type = ( type === this.widgetEventPrefix ?
552                         type :
553                         this.widgetEventPrefix + type ).toLowerCase();
554                 data = data || {};
555
556                 // copy original event properties over to the new event
557                 // this would happen if we could call $.event.fix instead of $.Event
558                 // but we don't have a way to force an event to be fixed multiple times
559                 if ( event.originalEvent ) {
560                         for ( var i = $.event.props.length, prop; i; ) {
561                                 prop = $.event.props[ --i ];
562                                 event[ prop ] = event.originalEvent[ prop ];
563                         }
564                 }
565
566                 this.element.trigger( event, data );
567
568                 return !( $.isFunction(callback) &&
569                         callback.call( this.element[0], event, data ) === false ||
570                         event.isDefaultPrevented() );
571         }
572 };
573
574 })( jQuery );
575 /*!
576  * jQuery UI Mouse 1.8.14
577  *
578  * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
579  * Dual licensed under the MIT or GPL Version 2 licenses.
580  * http://jquery.org/license
581  *
582  * http://docs.jquery.com/UI/Mouse
583  *
584  * Depends:
585  *      jquery.ui.widget.js
586  */
587 (function( $, undefined ) {
588
589 var mouseHandled = false;
590 $(document).mousedown(function(e) {
591         mouseHandled = false;
592 });
593
594 $.widget("ui.mouse", {
595         options: {
596                 cancel: ':input,option',
597                 distance: 1,
598                 delay: 0
599         },
600         _mouseInit: function() {
601                 var self = this;
602
603                 this.element
604                         .bind('mousedown.'+this.widgetName, function(event) {
605                                 return self._mouseDown(event);
606                         })
607                         .bind('click.'+this.widgetName, function(event) {
608                                 if (true === $.data(event.target, self.widgetName + '.preventClickEvent')) {
609                                     $.removeData(event.target, self.widgetName + '.preventClickEvent');
610                                         event.stopImmediatePropagation();
611                                         return false;
612                                 }
613                         });
614
615                 this.started = false;
616         },
617
618         // TODO: make sure destroying one instance of mouse doesn't mess with
619         // other instances of mouse
620         _mouseDestroy: function() {
621                 this.element.unbind('.'+this.widgetName);
622         },
623
624         _mouseDown: function(event) {
625                 // don't let more than one widget handle mouseStart
626                 if(mouseHandled) {return};
627
628                 // we may have missed mouseup (out of window)
629                 (this._mouseStarted && this._mouseUp(event));
630
631                 this._mouseDownEvent = event;
632
633                 var self = this,
634                         btnIsLeft = (event.which == 1),
635                         elIsCancel = (typeof this.options.cancel == "string" ? $(event.target).closest(this.options.cancel).length : false);
636                 if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
637                         return true;
638                 }
639
640                 this.mouseDelayMet = !this.options.delay;
641                 if (!this.mouseDelayMet) {
642                         this._mouseDelayTimer = setTimeout(function() {
643                                 self.mouseDelayMet = true;
644                         }, this.options.delay);
645                 }
646
647                 if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
648                         this._mouseStarted = (this._mouseStart(event) !== false);
649                         if (!this._mouseStarted) {
650                                 event.preventDefault();
651                                 return true;
652                         }
653                 }
654
655                 // Click event may never have fired (Gecko & Opera)
656                 if (true === $.data(event.target, this.widgetName + '.preventClickEvent')) {
657                         $.removeData(event.target, this.widgetName + '.preventClickEvent');
658                 }
659
660                 // these delegates are required to keep context
661                 this._mouseMoveDelegate = function(event) {
662                         return self._mouseMove(event);
663                 };
664                 this._mouseUpDelegate = function(event) {
665                         return self._mouseUp(event);
666                 };
667                 $(document)
668                         .bind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
669                         .bind('mouseup.'+this.widgetName, this._mouseUpDelegate);
670
671                 event.preventDefault();
672                 
673                 mouseHandled = true;
674                 return true;
675         },
676
677         _mouseMove: function(event) {
678                 // IE mouseup check - mouseup happened when mouse was out of window
679                 if ($.browser.msie && !(document.documentMode >= 9) && !event.button) {
680                         return this._mouseUp(event);
681                 }
682
683                 if (this._mouseStarted) {
684                         this._mouseDrag(event);
685                         return event.preventDefault();
686                 }
687
688                 if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
689                         this._mouseStarted =
690                                 (this._mouseStart(this._mouseDownEvent, event) !== false);
691                         (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
692                 }
693
694                 return !this._mouseStarted;
695         },
696
697         _mouseUp: function(event) {
698                 $(document)
699                         .unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
700                         .unbind('mouseup.'+this.widgetName, this._mouseUpDelegate);
701
702                 if (this._mouseStarted) {
703                         this._mouseStarted = false;
704
705                         if (event.target == this._mouseDownEvent.target) {
706                             $.data(event.target, this.widgetName + '.preventClickEvent', true);
707                         }
708
709                         this._mouseStop(event);
710                 }
711
712                 return false;
713         },
714
715         _mouseDistanceMet: function(event) {
716                 return (Math.max(
717                                 Math.abs(this._mouseDownEvent.pageX - event.pageX),
718                                 Math.abs(this._mouseDownEvent.pageY - event.pageY)
719                         ) >= this.options.distance
720                 );
721         },
722
723         _mouseDelayMet: function(event) {
724                 return this.mouseDelayMet;
725         },
726
727         // These are placeholder methods, to be overriden by extending plugin
728         _mouseStart: function(event) {},
729         _mouseDrag: function(event) {},
730         _mouseStop: function(event) {},
731         _mouseCapture: function(event) { return true; }
732 });
733
734 })(jQuery);
735 /*
736  * jQuery UI Position 1.8.14
737  *
738  * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
739  * Dual licensed under the MIT or GPL Version 2 licenses.
740  * http://jquery.org/license
741  *
742  * http://docs.jquery.com/UI/Position
743  */
744 (function( $, undefined ) {
745
746 $.ui = $.ui || {};
747
748 var horizontalPositions = /left|center|right/,
749         verticalPositions = /top|center|bottom/,
750         center = "center",
751         _position = $.fn.position,
752         _offset = $.fn.offset;
753
754 $.fn.position = function( options ) {
755         if ( !options || !options.of ) {
756                 return _position.apply( this, arguments );
757         }
758
759         // make a copy, we don't want to modify arguments
760         options = $.extend( {}, options );
761
762         var target = $( options.of ),
763                 targetElem = target[0],
764                 collision = ( options.collision || "flip" ).split( " " ),
765                 offset = options.offset ? options.offset.split( " " ) : [ 0, 0 ],
766                 targetWidth,
767                 targetHeight,
768                 basePosition;
769
770         if ( targetElem.nodeType === 9 ) {
771                 targetWidth = target.width();
772                 targetHeight = target.height();
773                 basePosition = { top: 0, left: 0 };
774         // TODO: use $.isWindow() in 1.9
775         } else if ( targetElem.setTimeout ) {
776                 targetWidth = target.width();
777                 targetHeight = target.height();
778                 basePosition = { top: target.scrollTop(), left: target.scrollLeft() };
779         } else if ( targetElem.preventDefault ) {
780                 // force left top to allow flipping
781                 options.at = "left top";
782                 targetWidth = targetHeight = 0;
783                 basePosition = { top: options.of.pageY, left: options.of.pageX };
784         } else {
785                 targetWidth = target.outerWidth();
786                 targetHeight = target.outerHeight();
787                 basePosition = target.offset();
788         }
789
790         // force my and at to have valid horizontal and veritcal positions
791         // if a value is missing or invalid, it will be converted to center 
792         $.each( [ "my", "at" ], function() {
793                 var pos = ( options[this] || "" ).split( " " );
794                 if ( pos.length === 1) {
795                         pos = horizontalPositions.test( pos[0] ) ?
796                                 pos.concat( [center] ) :
797                                 verticalPositions.test( pos[0] ) ?
798                                         [ center ].concat( pos ) :
799                                         [ center, center ];
800                 }
801                 pos[ 0 ] = horizontalPositions.test( pos[0] ) ? pos[ 0 ] : center;
802                 pos[ 1 ] = verticalPositions.test( pos[1] ) ? pos[ 1 ] : center;
803                 options[ this ] = pos;
804         });
805
806         // normalize collision option
807         if ( collision.length === 1 ) {
808                 collision[ 1 ] = collision[ 0 ];
809         }
810
811         // normalize offset option
812         offset[ 0 ] = parseInt( offset[0], 10 ) || 0;
813         if ( offset.length === 1 ) {
814                 offset[ 1 ] = offset[ 0 ];
815         }
816         offset[ 1 ] = parseInt( offset[1], 10 ) || 0;
817
818         if ( options.at[0] === "right" ) {
819                 basePosition.left += targetWidth;
820         } else if ( options.at[0] === center ) {
821                 basePosition.left += targetWidth / 2;
822         }
823
824         if ( options.at[1] === "bottom" ) {
825                 basePosition.top += targetHeight;
826         } else if ( options.at[1] === center ) {
827                 basePosition.top += targetHeight / 2;
828         }
829
830         basePosition.left += offset[ 0 ];
831         basePosition.top += offset[ 1 ];
832
833         return this.each(function() {
834                 var elem = $( this ),
835                         elemWidth = elem.outerWidth(),
836                         elemHeight = elem.outerHeight(),
837                         marginLeft = parseInt( $.curCSS( this, "marginLeft", true ) ) || 0,
838                         marginTop = parseInt( $.curCSS( this, "marginTop", true ) ) || 0,
839                         collisionWidth = elemWidth + marginLeft +
840                                 ( parseInt( $.curCSS( this, "marginRight", true ) ) || 0 ),
841                         collisionHeight = elemHeight + marginTop +
842                                 ( parseInt( $.curCSS( this, "marginBottom", true ) ) || 0 ),
843                         position = $.extend( {}, basePosition ),
844                         collisionPosition;
845
846                 if ( options.my[0] === "right" ) {
847                         position.left -= elemWidth;
848                 } else if ( options.my[0] === center ) {
849                         position.left -= elemWidth / 2;
850                 }
851
852                 if ( options.my[1] === "bottom" ) {
853                         position.top -= elemHeight;
854                 } else if ( options.my[1] === center ) {
855                         position.top -= elemHeight / 2;
856                 }
857
858                 // prevent fractions (see #5280)
859                 position.left = Math.round( position.left );
860                 position.top = Math.round( position.top );
861
862                 collisionPosition = {
863                         left: position.left - marginLeft,
864                         top: position.top - marginTop
865                 };
866
867                 $.each( [ "left", "top" ], function( i, dir ) {
868                         if ( $.ui.position[ collision[i] ] ) {
869                                 $.ui.position[ collision[i] ][ dir ]( position, {
870                                         targetWidth: targetWidth,
871                                         targetHeight: targetHeight,
872                                         elemWidth: elemWidth,
873                                         elemHeight: elemHeight,
874                                         collisionPosition: collisionPosition,
875                                         collisionWidth: collisionWidth,
876                                         collisionHeight: collisionHeight,
877                                         offset: offset,
878                                         my: options.my,
879                                         at: options.at
880                                 });
881                         }
882                 });
883
884                 if ( $.fn.bgiframe ) {
885                         elem.bgiframe();
886                 }
887                 elem.offset( $.extend( position, { using: options.using } ) );
888         });
889 };
890
891 $.ui.position = {
892         fit: {
893                 left: function( position, data ) {
894                         var win = $( window ),
895                                 over = data.collisionPosition.left + data.collisionWidth - win.width() - win.scrollLeft();
896                         position.left = over > 0 ? position.left - over : Math.max( position.left - data.collisionPosition.left, position.left );
897                 },
898                 top: function( position, data ) {
899                         var win = $( window ),
900                                 over = data.collisionPosition.top + data.collisionHeight - win.height() - win.scrollTop();
901                         position.top = over > 0 ? position.top - over : Math.max( position.top - data.collisionPosition.top, position.top );
902                 }
903         },
904
905         flip: {
906                 left: function( position, data ) {
907                         if ( data.at[0] === center ) {
908                                 return;
909                         }
910                         var win = $( window ),
911                                 over = data.collisionPosition.left + data.collisionWidth - win.width() - win.scrollLeft(),
912                                 myOffset = data.my[ 0 ] === "left" ?
913                                         -data.elemWidth :
914                                         data.my[ 0 ] === "right" ?
915                                                 data.elemWidth :
916                                                 0,
917                                 atOffset = data.at[ 0 ] === "left" ?
918                                         data.targetWidth :
919                                         -data.targetWidth,
920                                 offset = -2 * data.offset[ 0 ];
921                         position.left += data.collisionPosition.left < 0 ?
922                                 myOffset + atOffset + offset :
923                                 over > 0 ?
924                                         myOffset + atOffset + offset :
925                                         0;
926                 },
927                 top: function( position, data ) {
928                         if ( data.at[1] === center ) {
929                                 return;
930                         }
931                         var win = $( window ),
932                                 over = data.collisionPosition.top + data.collisionHeight - win.height() - win.scrollTop(),
933                                 myOffset = data.my[ 1 ] === "top" ?
934                                         -data.elemHeight :
935                                         data.my[ 1 ] === "bottom" ?
936                                                 data.elemHeight :
937                                                 0,
938                                 atOffset = data.at[ 1 ] === "top" ?
939                                         data.targetHeight :
940                                         -data.targetHeight,
941                                 offset = -2 * data.offset[ 1 ];
942                         position.top += data.collisionPosition.top < 0 ?
943                                 myOffset + atOffset + offset :
944                                 over > 0 ?
945                                         myOffset + atOffset + offset :
946                                         0;
947                 }
948         }
949 };
950
951 // offset setter from jQuery 1.4
952 if ( !$.offset.setOffset ) {
953         $.offset.setOffset = function( elem, options ) {
954                 // set position first, in-case top/left are set even on static elem
955                 if ( /static/.test( $.curCSS( elem, "position" ) ) ) {
956                         elem.style.position = "relative";
957                 }
958                 var curElem   = $( elem ),
959                         curOffset = curElem.offset(),
960                         curTop    = parseInt( $.curCSS( elem, "top",  true ), 10 ) || 0,
961                         curLeft   = parseInt( $.curCSS( elem, "left", true ), 10)  || 0,
962                         props     = {
963                                 top:  (options.top  - curOffset.top)  + curTop,
964                                 left: (options.left - curOffset.left) + curLeft
965                         };
966                 
967                 if ( 'using' in options ) {
968                         options.using.call( elem, props );
969                 } else {
970                         curElem.css( props );
971                 }
972         };
973
974         $.fn.offset = function( options ) {
975                 var elem = this[ 0 ];
976                 if ( !elem || !elem.ownerDocument ) { return null; }
977                 if ( options ) { 
978                         return this.each(function() {
979                                 $.offset.setOffset( this, options );
980                         });
981                 }
982                 return _offset.call( this );
983         };
984 }
985
986 }( jQuery ));
987 /*
988  * jQuery UI Draggable 1.8.14
989  *
990  * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
991  * Dual licensed under the MIT or GPL Version 2 licenses.
992  * http://jquery.org/license
993  *
994  * http://docs.jquery.com/UI/Draggables
995  *
996  * Depends:
997  *      jquery.ui.core.js
998  *      jquery.ui.mouse.js
999  *      jquery.ui.widget.js
1000  */
1001 (function( $, undefined ) {
1002
1003 $.widget("ui.draggable", $.ui.mouse, {
1004         widgetEventPrefix: "drag",
1005         options: {
1006                 addClasses: true,
1007                 appendTo: "parent",
1008                 axis: false,
1009                 connectToSortable: false,
1010                 containment: false,
1011                 cursor: "auto",
1012                 cursorAt: false,
1013                 grid: false,
1014                 handle: false,
1015                 helper: "original",
1016                 iframeFix: false,
1017                 opacity: false,
1018                 refreshPositions: false,
1019                 revert: false,
1020                 revertDuration: 500,
1021                 scope: "default",
1022                 scroll: true,
1023                 scrollSensitivity: 20,
1024                 scrollSpeed: 20,
1025                 snap: false,
1026                 snapMode: "both",
1027                 snapTolerance: 20,
1028                 stack: false,
1029                 zIndex: false
1030         },
1031         _create: function() {
1032
1033                 if (this.options.helper == 'original' && !(/^(?:r|a|f)/).test(this.element.css("position")))
1034                         this.element[0].style.position = 'relative';
1035
1036                 (this.options.addClasses && this.element.addClass("ui-draggable"));
1037                 (this.options.disabled && this.element.addClass("ui-draggable-disabled"));
1038
1039                 this._mouseInit();
1040
1041         },
1042
1043         destroy: function() {
1044                 if(!this.element.data('draggable')) return;
1045                 this.element
1046                         .removeData("draggable")
1047                         .unbind(".draggable")
1048                         .removeClass("ui-draggable"
1049                                 + " ui-draggable-dragging"
1050                                 + " ui-draggable-disabled");
1051                 this._mouseDestroy();
1052
1053                 return this;
1054         },
1055
1056         _mouseCapture: function(event) {
1057
1058                 var o = this.options;
1059
1060                 // among others, prevent a drag on a resizable-handle
1061                 if (this.helper || o.disabled || $(event.target).is('.ui-resizable-handle'))
1062                         return false;
1063
1064                 //Quit if we're not on a valid handle
1065                 this.handle = this._getHandle(event);
1066                 if (!this.handle)
1067                         return false;
1068                 
1069                 $(o.iframeFix === true ? "iframe" : o.iframeFix).each(function() {
1070                         $('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>')
1071                         .css({
1072                                 width: this.offsetWidth+"px", height: this.offsetHeight+"px",
1073                                 position: "absolute", opacity: "0.001", zIndex: 1000
1074                         })
1075                         .css($(this).offset())
1076                         .appendTo("body");
1077                 });
1078
1079                 return true;
1080
1081         },
1082
1083         _mouseStart: function(event) {
1084
1085                 var o = this.options;
1086
1087                 //Create and append the visible helper
1088                 this.helper = this._createHelper(event);
1089
1090                 //Cache the helper size
1091                 this._cacheHelperProportions();
1092
1093                 //If ddmanager is used for droppables, set the global draggable
1094                 if($.ui.ddmanager)
1095                         $.ui.ddmanager.current = this;
1096
1097                 /*
1098                  * - Position generation -
1099                  * This block generates everything position related - it's the core of draggables.
1100                  */
1101
1102                 //Cache the margins of the original element
1103                 this._cacheMargins();
1104
1105                 //Store the helper's css position
1106                 this.cssPosition = this.helper.css("position");
1107                 this.scrollParent = this.helper.scrollParent();
1108
1109                 //The element's absolute position on the page minus margins
1110                 this.offset = this.positionAbs = this.element.offset();
1111                 this.offset = {
1112                         top: this.offset.top - this.margins.top,
1113                         left: this.offset.left - this.margins.left
1114                 };
1115
1116                 $.extend(this.offset, {
1117                         click: { //Where the click happened, relative to the element
1118                                 left: event.pageX - this.offset.left,
1119                                 top: event.pageY - this.offset.top
1120                         },
1121                         parent: this._getParentOffset(),
1122                         relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
1123                 });
1124
1125                 //Generate the original position
1126                 this.originalPosition = this.position = this._generatePosition(event);
1127                 this.originalPageX = event.pageX;
1128                 this.originalPageY = event.pageY;
1129
1130                 //Adjust the mouse offset relative to the helper if 'cursorAt' is supplied
1131                 (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
1132
1133                 //Set a containment if given in the options
1134                 if(o.containment)
1135                         this._setContainment();
1136
1137                 //Trigger event + callbacks
1138                 if(this._trigger("start", event) === false) {
1139                         this._clear();
1140                         return false;
1141                 }
1142
1143                 //Recache the helper size
1144                 this._cacheHelperProportions();
1145
1146                 //Prepare the droppable offsets
1147                 if ($.ui.ddmanager && !o.dropBehaviour)
1148                         $.ui.ddmanager.prepareOffsets(this, event);
1149
1150                 this.helper.addClass("ui-draggable-dragging");
1151                 this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
1152                 
1153                 //If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003)
1154                 if ( $.ui.ddmanager ) $.ui.ddmanager.dragStart(this, event);
1155                 
1156                 return true;
1157         },
1158
1159         _mouseDrag: function(event, noPropagation) {
1160
1161                 //Compute the helpers position
1162                 this.position = this._generatePosition(event);
1163                 this.positionAbs = this._convertPositionTo("absolute");
1164
1165                 //Call plugins and callbacks and use the resulting position if something is returned
1166                 if (!noPropagation) {
1167                         var ui = this._uiHash();
1168                         if(this._trigger('drag', event, ui) === false) {
1169                                 this._mouseUp({});
1170                                 return false;
1171                         }
1172                         this.position = ui.position;
1173                 }
1174
1175                 if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px';
1176                 if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px';
1177                 if($.ui.ddmanager) $.ui.ddmanager.drag(this, event);
1178
1179                 return false;
1180         },
1181
1182         _mouseStop: function(event) {
1183
1184                 //If we are using droppables, inform the manager about the drop
1185                 var dropped = false;
1186                 if ($.ui.ddmanager && !this.options.dropBehaviour)
1187                         dropped = $.ui.ddmanager.drop(this, event);
1188
1189                 //if a drop comes from outside (a sortable)
1190                 if(this.dropped) {
1191                         dropped = this.dropped;
1192                         this.dropped = false;
1193                 }
1194                 
1195                 //if the original element is removed, don't bother to continue if helper is set to "original"
1196                 if((!this.element[0] || !this.element[0].parentNode) && this.options.helper == "original")
1197                         return false;
1198
1199                 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))) {
1200                         var self = this;
1201                         $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() {
1202                                 if(self._trigger("stop", event) !== false) {
1203                                         self._clear();
1204                                 }
1205                         });
1206                 } else {
1207                         if(this._trigger("stop", event) !== false) {
1208                                 this._clear();
1209                         }
1210                 }
1211
1212                 return false;
1213         },
1214         
1215         _mouseUp: function(event) {
1216                 if (this.options.iframeFix === true) {
1217                         $("div.ui-draggable-iframeFix").each(function() { 
1218                                 this.parentNode.removeChild(this); 
1219                         }); //Remove frame helpers
1220                 }
1221                 
1222                 //If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003)
1223                 if( $.ui.ddmanager ) $.ui.ddmanager.dragStop(this, event);
1224                 
1225                 return $.ui.mouse.prototype._mouseUp.call(this, event);
1226         },
1227         
1228         cancel: function() {
1229                 
1230                 if(this.helper.is(".ui-draggable-dragging")) {
1231                         this._mouseUp({});
1232                 } else {
1233                         this._clear();
1234                 }
1235                 
1236                 return this;
1237                 
1238         },
1239
1240         _getHandle: function(event) {
1241
1242                 var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false;
1243                 $(this.options.handle, this.element)
1244                         .find("*")
1245                         .andSelf()
1246                         .each(function() {
1247                                 if(this == event.target) handle = true;
1248                         });
1249
1250                 return handle;
1251
1252         },
1253
1254         _createHelper: function(event) {
1255
1256                 var o = this.options;
1257                 var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event])) : (o.helper == 'clone' ? this.element.clone().removeAttr('id') : this.element);
1258
1259                 if(!helper.parents('body').length)
1260                         helper.appendTo((o.appendTo == 'parent' ? this.element[0].parentNode : o.appendTo));
1261
1262                 if(helper[0] != this.element[0] && !(/(fixed|absolute)/).test(helper.css("position")))
1263                         helper.css("position", "absolute");
1264
1265                 return helper;
1266
1267         },
1268
1269         _adjustOffsetFromHelper: function(obj) {
1270                 if (typeof obj == 'string') {
1271                         obj = obj.split(' ');
1272                 }
1273                 if ($.isArray(obj)) {
1274                         obj = {left: +obj[0], top: +obj[1] || 0};
1275                 }
1276                 if ('left' in obj) {
1277                         this.offset.click.left = obj.left + this.margins.left;
1278                 }
1279                 if ('right' in obj) {
1280                         this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
1281                 }
1282                 if ('top' in obj) {
1283                         this.offset.click.top = obj.top + this.margins.top;
1284                 }
1285                 if ('bottom' in obj) {
1286                         this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
1287                 }
1288         },
1289
1290         _getParentOffset: function() {
1291
1292                 //Get the offsetParent and cache its position
1293                 this.offsetParent = this.helper.offsetParent();
1294                 var po = this.offsetParent.offset();
1295
1296                 // This is a special case where we need to modify a offset calculated on start, since the following happened:
1297                 // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
1298                 // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
1299                 //    the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
1300                 if(this.cssPosition == 'absolute' && this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) {
1301                         po.left += this.scrollParent.scrollLeft();
1302                         po.top += this.scrollParent.scrollTop();
1303                 }
1304
1305                 if((this.offsetParent[0] == document.body) //This needs to be actually done for all browsers, since pageX/pageY includes this information
1306                 || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.browser.msie)) //Ugly IE fix
1307                         po = { top: 0, left: 0 };
1308
1309                 return {
1310                         top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
1311                         left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
1312                 };
1313
1314         },
1315
1316         _getRelativeOffset: function() {
1317
1318                 if(this.cssPosition == "relative") {
1319                         var p = this.element.position();
1320                         return {
1321                                 top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
1322                                 left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
1323                         };
1324                 } else {
1325                         return { top: 0, left: 0 };
1326                 }
1327
1328         },
1329
1330         _cacheMargins: function() {
1331                 this.margins = {
1332                         left: (parseInt(this.element.css("marginLeft"),10) || 0),
1333                         top: (parseInt(this.element.css("marginTop"),10) || 0),
1334                         right: (parseInt(this.element.css("marginRight"),10) || 0),
1335                         bottom: (parseInt(this.element.css("marginBottom"),10) || 0)
1336                 };
1337         },
1338
1339         _cacheHelperProportions: function() {
1340                 this.helperProportions = {
1341                         width: this.helper.outerWidth(),
1342                         height: this.helper.outerHeight()
1343                 };
1344         },
1345
1346         _setContainment: function() {
1347
1348                 var o = this.options;
1349                 if(o.containment == 'parent') o.containment = this.helper[0].parentNode;
1350                 if(o.containment == 'document' || o.containment == 'window') this.containment = [
1351                         o.containment == 'document' ? 0 : $(window).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
1352                         o.containment == 'document' ? 0 : $(window).scrollTop() - this.offset.relative.top - this.offset.parent.top,
1353                         (o.containment == 'document' ? 0 : $(window).scrollLeft()) + $(o.containment == 'document' ? document : window).width() - this.helperProportions.width - this.margins.left,
1354                         (o.containment == 'document' ? 0 : $(window).scrollTop()) + ($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
1355                 ];
1356
1357                 if(!(/^(document|window|parent)$/).test(o.containment) && o.containment.constructor != Array) {
1358                         var c = $(o.containment);
1359                         var ce = c[0]; if(!ce) return;
1360                         var co = c.offset();
1361                         var over = ($(ce).css("overflow") != 'hidden');
1362
1363                         this.containment = [
1364                                 (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0),
1365                                 (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0),
1366                                 (over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left - this.margins.right,
1367                                 (over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top  - this.margins.bottom
1368                         ];
1369                         this.relative_container = c;
1370
1371                 } else if(o.containment.constructor == Array) {
1372                         this.containment = o.containment;
1373                 }
1374
1375         },
1376
1377         _convertPositionTo: function(d, pos) {
1378
1379                 if(!pos) pos = this.position;
1380                 var mod = d == "absolute" ? 1 : -1;
1381                 var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
1382
1383                 return {
1384                         top: (
1385                                 pos.top                                                                                                                                 // The absolute mouse position
1386                                 + this.offset.relative.top * mod                                                                                // Only for relative positioned nodes: Relative offset from element to offset parent
1387                                 + this.offset.parent.top * mod                                                                                  // The offsetParent's offset without borders (offset + border)
1388                                 - ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
1389                         ),
1390                         left: (
1391                                 pos.left                                                                                                                                // The absolute mouse position
1392                                 + this.offset.relative.left * mod                                                                               // Only for relative positioned nodes: Relative offset from element to offset parent
1393                                 + this.offset.parent.left * mod                                                                                 // The offsetParent's offset without borders (offset + border)
1394                                 - ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
1395                         )
1396                 };
1397
1398         },
1399
1400         _generatePosition: function(event) {
1401
1402                 var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
1403                 var pageX = event.pageX;
1404                 var pageY = event.pageY;
1405
1406                 /*
1407                  * - Position constraining -
1408                  * Constrain the position to a mix of grid, containment.
1409                  */
1410
1411                 if(this.originalPosition) { //If we are not dragging yet, we won't check for options
1412                          var containment;
1413                          if(this.containment) {
1414                                  if (this.relative_container){
1415                                      var co = this.relative_container.offset();
1416                                      containment = [ this.containment[0] + co.left,
1417                                                      this.containment[1] + co.top,
1418                                                      this.containment[2] + co.left,
1419                                                      this.containment[3] + co.top ];
1420                                  }
1421                                  else {
1422                                      containment = this.containment;
1423                                  }
1424
1425                                 if(event.pageX - this.offset.click.left < containment[0]) pageX = containment[0] + this.offset.click.left;
1426                                 if(event.pageY - this.offset.click.top < containment[1]) pageY = containment[1] + this.offset.click.top;
1427                                 if(event.pageX - this.offset.click.left > containment[2]) pageX = containment[2] + this.offset.click.left;
1428                                 if(event.pageY - this.offset.click.top > containment[3]) pageY = containment[3] + this.offset.click.top;
1429                         }
1430
1431                         if(o.grid) {
1432                                 //Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950)
1433                                 var top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY;
1434                                 pageY = containment ? (!(top - this.offset.click.top < containment[1] || top - this.offset.click.top > containment[3]) ? top : (!(top - this.offset.click.top < containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
1435
1436                                 var left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX;
1437                                 pageX = containment ? (!(left - this.offset.click.left < containment[0] || left - this.offset.click.left > containment[2]) ? left : (!(left - this.offset.click.left < containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
1438                         }
1439
1440                 }
1441
1442                 return {
1443                         top: (
1444                                 pageY                                                                                                                           // The absolute mouse position
1445                                 - this.offset.click.top                                                                                                 // Click offset (relative to the element)
1446                                 - this.offset.relative.top                                                                                              // Only for relative positioned nodes: Relative offset from element to offset parent
1447                                 - this.offset.parent.top                                                                                                // The offsetParent's offset without borders (offset + border)
1448                                 + ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
1449                         ),
1450                         left: (
1451                                 pageX                                                                                                                           // The absolute mouse position
1452                                 - this.offset.click.left                                                                                                // Click offset (relative to the element)
1453                                 - this.offset.relative.left                                                                                             // Only for relative positioned nodes: Relative offset from element to offset parent
1454                                 - this.offset.parent.left                                                                                               // The offsetParent's offset without borders (offset + border)
1455                                 + ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
1456                         )
1457                 };
1458
1459         },
1460
1461         _clear: function() {
1462                 this.helper.removeClass("ui-draggable-dragging");
1463                 if(this.helper[0] != this.element[0] && !this.cancelHelperRemoval) this.helper.remove();
1464                 //if($.ui.ddmanager) $.ui.ddmanager.current = null;
1465                 this.helper = null;
1466                 this.cancelHelperRemoval = false;
1467         },
1468
1469         // From now on bulk stuff - mainly helpers
1470
1471         _trigger: function(type, event, ui) {
1472                 ui = ui || this._uiHash();
1473                 $.ui.plugin.call(this, type, [event, ui]);
1474                 if(type == "drag") this.positionAbs = this._convertPositionTo("absolute"); //The absolute position has to be recalculated after plugins
1475                 return $.Widget.prototype._trigger.call(this, type, event, ui);
1476         },
1477
1478         plugins: {},
1479
1480         _uiHash: function(event) {
1481                 return {
1482                         helper: this.helper,
1483                         position: this.position,
1484                         originalPosition: this.originalPosition,
1485                         offset: this.positionAbs
1486                 };
1487         }
1488
1489 });
1490
1491 $.extend($.ui.draggable, {
1492         version: "1.8.14"
1493 });
1494
1495 $.ui.plugin.add("draggable", "connectToSortable", {
1496         start: function(event, ui) {
1497
1498                 var inst = $(this).data("draggable"), o = inst.options,
1499                         uiSortable = $.extend({}, ui, { item: inst.element });
1500                 inst.sortables = [];
1501                 $(o.connectToSortable).each(function() {
1502                         var sortable = $.data(this, 'sortable');
1503                         if (sortable && !sortable.options.disabled) {
1504                                 inst.sortables.push({
1505                                         instance: sortable,
1506                                         shouldRevert: sortable.options.revert
1507                                 });
1508                                 sortable.refreshPositions();    // Call the sortable's refreshPositions at drag start to refresh the containerCache since the sortable container cache is used in drag and needs to be up to date (this will ensure it's initialised as well as being kept in step with any changes that might have happened on the page).
1509                                 sortable._trigger("activate", event, uiSortable);
1510                         }
1511                 });
1512
1513         },
1514         stop: function(event, ui) {
1515
1516                 //If we are still over the sortable, we fake the stop event of the sortable, but also remove helper
1517                 var inst = $(this).data("draggable"),
1518                         uiSortable = $.extend({}, ui, { item: inst.element });
1519
1520                 $.each(inst.sortables, function() {
1521                         if(this.instance.isOver) {
1522
1523                                 this.instance.isOver = 0;
1524
1525                                 inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance
1526                                 this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work)
1527
1528                                 //The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: 'valid/invalid'
1529                                 if(this.shouldRevert) this.instance.options.revert = true;
1530
1531                                 //Trigger the stop of the sortable
1532                                 this.instance._mouseStop(event);
1533
1534                                 this.instance.options.helper = this.instance.options._helper;
1535
1536                                 //If the helper has been the original item, restore properties in the sortable
1537                                 if(inst.options.helper == 'original')
1538                                         this.instance.currentItem.css({ top: 'auto', left: 'auto' });
1539
1540                         } else {
1541                                 this.instance.cancelHelperRemoval = false; //Remove the helper in the sortable instance
1542                                 this.instance._trigger("deactivate", event, uiSortable);
1543                         }
1544
1545                 });
1546
1547         },
1548         drag: function(event, ui) {
1549
1550                 var inst = $(this).data("draggable"), self = this;
1551
1552                 var checkPos = function(o) {
1553                         var dyClick = this.offset.click.top, dxClick = this.offset.click.left;
1554                         var helperTop = this.positionAbs.top, helperLeft = this.positionAbs.left;
1555                         var itemHeight = o.height, itemWidth = o.width;
1556                         var itemTop = o.top, itemLeft = o.left;
1557
1558                         return $.ui.isOver(helperTop + dyClick, helperLeft + dxClick, itemTop, itemLeft, itemHeight, itemWidth);
1559                 };
1560
1561                 $.each(inst.sortables, function(i) {
1562                         
1563                         //Copy over some variables to allow calling the sortable's native _intersectsWith
1564                         this.instance.positionAbs = inst.positionAbs;
1565                         this.instance.helperProportions = inst.helperProportions;
1566                         this.instance.offset.click = inst.offset.click;
1567                         
1568                         if(this.instance._intersectsWith(this.instance.containerCache)) {
1569
1570                                 //If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once
1571                                 if(!this.instance.isOver) {
1572
1573                                         this.instance.isOver = 1;
1574                                         //Now we fake the start of dragging for the sortable instance,
1575                                         //by cloning the list group item, appending it to the sortable and using it as inst.currentItem
1576                                         //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)
1577                                         this.instance.currentItem = $(self).clone().removeAttr('id').appendTo(this.instance.element).data("sortable-item", true);
1578                                         this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it
1579                                         this.instance.options.helper = function() { return ui.helper[0]; };
1580
1581                                         event.target = this.instance.currentItem[0];
1582                                         this.instance._mouseCapture(event, true);
1583                                         this.instance._mouseStart(event, true, true);
1584
1585                                         //Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes
1586                                         this.instance.offset.click.top = inst.offset.click.top;
1587                                         this.instance.offset.click.left = inst.offset.click.left;
1588                                         this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left;
1589                                         this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top;
1590
1591                                         inst._trigger("toSortable", event);
1592                                         inst.dropped = this.instance.element; //draggable revert needs that
1593                                         //hack so receive/update callbacks work (mostly)
1594                                         inst.currentItem = inst.element;
1595                                         this.instance.fromOutside = inst;
1596
1597                                 }
1598
1599                                 //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
1600                                 if(this.instance.currentItem) this.instance._mouseDrag(event);
1601
1602                         } else {
1603
1604                                 //If it doesn't intersect with the sortable, and it intersected before,
1605                                 //we fake the drag stop of the sortable, but make sure it doesn't remove the helper by using cancelHelperRemoval
1606                                 if(this.instance.isOver) {
1607
1608                                         this.instance.isOver = 0;
1609                                         this.instance.cancelHelperRemoval = true;
1610                                         
1611                                         //Prevent reverting on this forced stop
1612                                         this.instance.options.revert = false;
1613                                         
1614                                         // The out event needs to be triggered independently
1615                                         this.instance._trigger('out', event, this.instance._uiHash(this.instance));
1616                                         
1617                                         this.instance._mouseStop(event, true);
1618                                         this.instance.options.helper = this.instance.options._helper;
1619
1620                                         //Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size
1621                                         this.instance.currentItem.remove();
1622                                         if(this.instance.placeholder) this.instance.placeholder.remove();
1623
1624                                         inst._trigger("fromSortable", event);
1625                                         inst.dropped = false; //draggable revert needs that
1626                                 }
1627
1628                         };
1629
1630                 });
1631
1632         }
1633 });
1634
1635 $.ui.plugin.add("draggable", "cursor", {
1636         start: function(event, ui) {
1637                 var t = $('body'), o = $(this).data('draggable').options;
1638                 if (t.css("cursor")) o._cursor = t.css("cursor");
1639                 t.css("cursor", o.cursor);
1640         },
1641         stop: function(event, ui) {
1642                 var o = $(this).data('draggable').options;
1643                 if (o._cursor) $('body').css("cursor", o._cursor);
1644         }
1645 });
1646
1647 $.ui.plugin.add("draggable", "opacity", {
1648         start: function(event, ui) {
1649                 var t = $(ui.helper), o = $(this).data('draggable').options;
1650                 if(t.css("opacity")) o._opacity = t.css("opacity");
1651                 t.css('opacity', o.opacity);
1652         },
1653         stop: function(event, ui) {
1654                 var o = $(this).data('draggable').options;
1655                 if(o._opacity) $(ui.helper).css('opacity', o._opacity);
1656         }
1657 });
1658
1659 $.ui.plugin.add("draggable", "scroll", {
1660         start: function(event, ui) {
1661                 var i = $(this).data("draggable");
1662                 if(i.scrollParent[0] != document && i.scrollParent[0].tagName != 'HTML') i.overflowOffset = i.scrollParent.offset();
1663         },
1664         drag: function(event, ui) {
1665
1666                 var i = $(this).data("draggable"), o = i.options, scrolled = false;
1667
1668                 if(i.scrollParent[0] != document && i.scrollParent[0].tagName != 'HTML') {
1669
1670                         if(!o.axis || o.axis != 'x') {
1671                                 if((i.overflowOffset.top + i.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity)
1672                                         i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop + o.scrollSpeed;
1673                                 else if(event.pageY - i.overflowOffset.top < o.scrollSensitivity)
1674                                         i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop - o.scrollSpeed;
1675                         }
1676
1677                         if(!o.axis || o.axis != 'y') {
1678                                 if((i.overflowOffset.left + i.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity)
1679                                         i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft + o.scrollSpeed;
1680                                 else if(event.pageX - i.overflowOffset.left < o.scrollSensitivity)
1681                                         i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft - o.scrollSpeed;
1682                         }
1683
1684                 } else {
1685
1686                         if(!o.axis || o.axis != 'x') {
1687                                 if(event.pageY - $(document).scrollTop() < o.scrollSensitivity)
1688                                         scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
1689                                 else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity)
1690                                         scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
1691                         }
1692
1693                         if(!o.axis || o.axis != 'y') {
1694                                 if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity)
1695                                         scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
1696                                 else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity)
1697                                         scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
1698                         }
1699
1700                 }
1701
1702                 if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour)
1703                         $.ui.ddmanager.prepareOffsets(i, event);
1704
1705         }
1706 });
1707
1708 $.ui.plugin.add("draggable", "snap", {
1709         start: function(event, ui) {
1710
1711                 var i = $(this).data("draggable"), o = i.options;
1712                 i.snapElements = [];
1713
1714                 $(o.snap.constructor != String ? ( o.snap.items || ':data(draggable)' ) : o.snap).each(function() {
1715                         var $t = $(this); var $o = $t.offset();
1716                         if(this != i.element[0]) i.snapElements.push({
1717                                 item: this,
1718                                 width: $t.outerWidth(), height: $t.outerHeight(),
1719                                 top: $o.top, left: $o.left
1720                         });
1721                 });
1722
1723         },
1724         drag: function(event, ui) {
1725
1726                 var inst = $(this).data("draggable"), o = inst.options;
1727                 var d = o.snapTolerance;
1728
1729                 var x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
1730                         y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
1731
1732                 for (var i = inst.snapElements.length - 1; i >= 0; i--){
1733
1734                         var l = inst.snapElements[i].left, r = l + inst.snapElements[i].width,
1735                                 t = inst.snapElements[i].top, b = t + inst.snapElements[i].height;
1736
1737                         //Yes, I know, this is insane ;)
1738                         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))) {
1739                                 if(inst.snapElements[i].snapping) (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
1740                                 inst.snapElements[i].snapping = false;
1741                                 continue;
1742                         }
1743
1744                         if(o.snapMode != 'inner') {
1745                                 var ts = Math.abs(t - y2) <= d;
1746                                 var bs = Math.abs(b - y1) <= d;
1747                                 var ls = Math.abs(l - x2) <= d;
1748                                 var rs = Math.abs(r - x1) <= d;
1749                                 if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
1750                                 if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top - inst.margins.top;
1751                                 if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left - inst.margins.left;
1752                                 if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left - inst.margins.left;
1753                         }
1754
1755                         var first = (ts || bs || ls || rs);
1756
1757                         if(o.snapMode != 'outer') {
1758                                 var ts = Math.abs(t - y1) <= d;
1759                                 var bs = Math.abs(b - y2) <= d;
1760                                 var ls = Math.abs(l - x1) <= d;
1761                                 var rs = Math.abs(r - x2) <= d;
1762                                 if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top - inst.margins.top;
1763                                 if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
1764                                 if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left - inst.margins.left;
1765                                 if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left - inst.margins.left;
1766                         }
1767
1768                         if(!inst.snapElements[i].snapping && (ts || bs || ls || rs || first))
1769                                 (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
1770                         inst.snapElements[i].snapping = (ts || bs || ls || rs || first);
1771
1772                 };
1773
1774         }
1775 });
1776
1777 $.ui.plugin.add("draggable", "stack", {
1778         start: function(event, ui) {
1779
1780                 var o = $(this).data("draggable").options;
1781
1782                 var group = $.makeArray($(o.stack)).sort(function(a,b) {
1783                         return (parseInt($(a).css("zIndex"),10) || 0) - (parseInt($(b).css("zIndex"),10) || 0);
1784                 });
1785                 if (!group.length) { return; }
1786                 
1787                 var min = parseInt(group[0].style.zIndex) || 0;
1788                 $(group).each(function(i) {
1789                         this.style.zIndex = min + i;
1790                 });
1791
1792                 this[0].style.zIndex = min + group.length;
1793
1794         }
1795 });
1796
1797 $.ui.plugin.add("draggable", "zIndex", {
1798         start: function(event, ui) {
1799                 var t = $(ui.helper), o = $(this).data("draggable").options;
1800                 if(t.css("zIndex")) o._zIndex = t.css("zIndex");
1801                 t.css('zIndex', o.zIndex);
1802         },
1803         stop: function(event, ui) {
1804                 var o = $(this).data("draggable").options;
1805                 if(o._zIndex) $(ui.helper).css('zIndex', o._zIndex);
1806         }
1807 });
1808
1809 })(jQuery);
1810 /*
1811  * jQuery UI Droppable 1.8.14
1812  *
1813  * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
1814  * Dual licensed under the MIT or GPL Version 2 licenses.
1815  * http://jquery.org/license
1816  *
1817  * http://docs.jquery.com/UI/Droppables
1818  *
1819  * Depends:
1820  *      jquery.ui.core.js
1821  *      jquery.ui.widget.js
1822  *      jquery.ui.mouse.js
1823  *      jquery.ui.draggable.js
1824  */
1825 (function( $, undefined ) {
1826
1827 $.widget("ui.droppable", {
1828         widgetEventPrefix: "drop",
1829         options: {
1830                 accept: '*',
1831                 activeClass: false,
1832                 addClasses: true,
1833                 greedy: false,
1834                 hoverClass: false,
1835                 scope: 'default',
1836                 tolerance: 'intersect'
1837         },
1838         _create: function() {
1839
1840                 var o = this.options, accept = o.accept;
1841                 this.isover = 0; this.isout = 1;
1842
1843                 this.accept = $.isFunction(accept) ? accept : function(d) {
1844                         return d.is(accept);
1845                 };
1846
1847                 //Store the droppable's proportions
1848                 this.proportions = { width: this.element[0].offsetWidth, height: this.element[0].offsetHeight };
1849
1850                 // Add the reference and positions to the manager
1851                 $.ui.ddmanager.droppables[o.scope] = $.ui.ddmanager.droppables[o.scope] || [];
1852                 $.ui.ddmanager.droppables[o.scope].push(this);
1853
1854                 (o.addClasses && this.element.addClass("ui-droppable"));
1855
1856         },
1857
1858         destroy: function() {
1859                 var drop = $.ui.ddmanager.droppables[this.options.scope];
1860                 for ( var i = 0; i < drop.length; i++ )
1861                         if ( drop[i] == this )
1862                                 drop.splice(i, 1);
1863
1864                 this.element
1865                         .removeClass("ui-droppable ui-droppable-disabled")
1866                         .removeData("droppable")
1867                         .unbind(".droppable");
1868
1869                 return this;
1870         },
1871
1872         _setOption: function(key, value) {
1873
1874                 if(key == 'accept') {
1875                         this.accept = $.isFunction(value) ? value : function(d) {
1876                                 return d.is(value);
1877                         };
1878                 }
1879                 $.Widget.prototype._setOption.apply(this, arguments);
1880         },
1881
1882         _activate: function(event) {
1883                 var draggable = $.ui.ddmanager.current;
1884                 if(this.options.activeClass) this.element.addClass(this.options.activeClass);
1885                 (draggable && this._trigger('activate', event, this.ui(draggable)));
1886         },
1887
1888         _deactivate: function(event) {
1889                 var draggable = $.ui.ddmanager.current;
1890                 if(this.options.activeClass) this.element.removeClass(this.options.activeClass);
1891                 (draggable && this._trigger('deactivate', event, this.ui(draggable)));
1892         },
1893
1894         _over: function(event) {
1895
1896                 var draggable = $.ui.ddmanager.current;
1897                 if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return; // Bail if draggable and droppable are same element
1898
1899                 if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
1900                         if(this.options.hoverClass) this.element.addClass(this.options.hoverClass);
1901                         this._trigger('over', event, this.ui(draggable));
1902                 }
1903
1904         },
1905
1906         _out: function(event) {
1907
1908                 var draggable = $.ui.ddmanager.current;
1909                 if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return; // Bail if draggable and droppable are same element
1910
1911                 if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
1912                         if(this.options.hoverClass) this.element.removeClass(this.options.hoverClass);
1913                         this._trigger('out', event, this.ui(draggable));
1914                 }
1915
1916         },
1917
1918         _drop: function(event,custom) {
1919
1920                 var draggable = custom || $.ui.ddmanager.current;
1921                 if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return false; // Bail if draggable and droppable are same element
1922
1923                 var childrenIntersection = false;
1924                 this.element.find(":data(droppable)").not(".ui-draggable-dragging").each(function() {
1925                         var inst = $.data(this, 'droppable');
1926                         if(
1927                                 inst.options.greedy
1928                                 && !inst.options.disabled
1929                                 && inst.options.scope == draggable.options.scope
1930                                 && inst.accept.call(inst.element[0], (draggable.currentItem || draggable.element))
1931                                 && $.ui.intersect(draggable, $.extend(inst, { offset: inst.element.offset() }), inst.options.tolerance)
1932                         ) { childrenIntersection = true; return false; }
1933                 });
1934                 if(childrenIntersection) return false;
1935
1936                 if(this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
1937                         if(this.options.activeClass) this.element.removeClass(this.options.activeClass);
1938                         if(this.options.hoverClass) this.element.removeClass(this.options.hoverClass);
1939                         this._trigger('drop', event, this.ui(draggable));
1940                         return this.element;
1941                 }
1942
1943                 return false;
1944
1945         },
1946
1947         ui: function(c) {
1948                 return {
1949                         draggable: (c.currentItem || c.element),
1950                         helper: c.helper,
1951                         position: c.position,
1952                         offset: c.positionAbs
1953                 };
1954         }
1955
1956 });
1957
1958 $.extend($.ui.droppable, {
1959         version: "1.8.14"
1960 });
1961
1962 $.ui.intersect = function(draggable, droppable, toleranceMode) {
1963
1964         if (!droppable.offset) return false;
1965
1966         var x1 = (draggable.positionAbs || draggable.position.absolute).left, x2 = x1 + draggable.helperProportions.width,
1967                 y1 = (draggable.positionAbs || draggable.position.absolute).top, y2 = y1 + draggable.helperProportions.height;
1968         var l = droppable.offset.left, r = l + droppable.proportions.width,
1969                 t = droppable.offset.top, b = t + droppable.proportions.height;
1970
1971         switch (toleranceMode) {
1972                 case 'fit':
1973                         return (l <= x1 && x2 <= r
1974                                 && t <= y1 && y2 <= b);
1975                         break;
1976                 case 'intersect':
1977                         return (l < x1 + (draggable.helperProportions.width / 2) // Right Half
1978                                 && x2 - (draggable.helperProportions.width / 2) < r // Left Half
1979                                 && t < y1 + (draggable.helperProportions.height / 2) // Bottom Half
1980                                 && y2 - (draggable.helperProportions.height / 2) < b ); // Top Half
1981                         break;
1982                 case 'pointer':
1983                         var draggableLeft = ((draggable.positionAbs || draggable.position.absolute).left + (draggable.clickOffset || draggable.offset.click).left),
1984                                 draggableTop = ((draggable.positionAbs || draggable.position.absolute).top + (draggable.clickOffset || draggable.offset.click).top),
1985                                 isOver = $.ui.isOver(draggableTop, draggableLeft, t, l, droppable.proportions.height, droppable.proportions.width);
1986                         return isOver;
1987                         break;
1988                 case 'touch':
1989                         return (
1990                                         (y1 >= t && y1 <= b) || // Top edge touching
1991                                         (y2 >= t && y2 <= b) || // Bottom edge touching
1992                                         (y1 < t && y2 > b)              // Surrounded vertically
1993                                 ) && (
1994                                         (x1 >= l && x1 <= r) || // Left edge touching
1995                                         (x2 >= l && x2 <= r) || // Right edge touching
1996                                         (x1 < l && x2 > r)              // Surrounded horizontally
1997                                 );
1998                         break;
1999                 default:
2000                         return false;
2001                         break;
2002                 }
2003
2004 };
2005
2006 /*
2007         This manager tracks offsets of draggables and droppables
2008 */
2009 $.ui.ddmanager = {
2010         current: null,
2011         droppables: { 'default': [] },
2012         prepareOffsets: function(t, event) {
2013
2014                 var m = $.ui.ddmanager.droppables[t.options.scope] || [];
2015                 var type = event ? event.type : null; // workaround for #2317
2016                 var list = (t.currentItem || t.element).find(":data(droppable)").andSelf();
2017
2018                 droppablesLoop: for (var i = 0; i < m.length; i++) {
2019
2020                         if(m[i].options.disabled || (t && !m[i].accept.call(m[i].element[0],(t.currentItem || t.element)))) continue;   //No disabled and non-accepted
2021                         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
2022                         m[i].visible = m[i].element.css("display") != "none"; if(!m[i].visible) continue;                                                                       //If the element is not visible, continue
2023
2024                         if(type == "mousedown") m[i]._activate.call(m[i], event); //Activate the droppable if used directly from draggables
2025
2026                         m[i].offset = m[i].element.offset();
2027                         m[i].proportions = { width: m[i].element[0].offsetWidth, height: m[i].element[0].offsetHeight };
2028
2029                 }
2030
2031         },
2032         drop: function(draggable, event) {
2033
2034                 var dropped = false;
2035                 $.each($.ui.ddmanager.droppables[draggable.options.scope] || [], function() {
2036
2037                         if(!this.options) return;
2038                         if (!this.options.disabled && this.visible && $.ui.intersect(draggable, this, this.options.tolerance))
2039                                 dropped = dropped || this._drop.call(this, event);
2040
2041                         if (!this.options.disabled && this.visible && this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
2042                                 this.isout = 1; this.isover = 0;
2043                                 this._deactivate.call(this, event);
2044                         }
2045
2046                 });
2047                 return dropped;
2048
2049         },
2050         dragStart: function( draggable, event ) {
2051                 //Listen for scrolling so that if the dragging causes scrolling the position of the droppables can be recalculated (see #5003)
2052                 draggable.element.parentsUntil( "body" ).bind( "scroll.droppable", function() {
2053                         if( !draggable.options.refreshPositions ) $.ui.ddmanager.prepareOffsets( draggable, event );
2054                 });
2055         },
2056         drag: function(draggable, event) {
2057
2058                 //If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse.
2059                 if(draggable.options.refreshPositions) $.ui.ddmanager.prepareOffsets(draggable, event);
2060
2061                 //Run through all droppables and check their positions based on specific tolerance options
2062                 $.each($.ui.ddmanager.droppables[draggable.options.scope] || [], function() {
2063
2064                         if(this.options.disabled || this.greedyChild || !this.visible) return;
2065                         var intersects = $.ui.intersect(draggable, this, this.options.tolerance);
2066
2067                         var c = !intersects && this.isover == 1 ? 'isout' : (intersects && this.isover == 0 ? 'isover' : null);
2068                         if(!c) return;
2069
2070                         var parentInstance;
2071                         if (this.options.greedy) {
2072                                 var parent = this.element.parents(':data(droppable):eq(0)');
2073                                 if (parent.length) {
2074                                         parentInstance = $.data(parent[0], 'droppable');
2075                                         parentInstance.greedyChild = (c == 'isover' ? 1 : 0);
2076                                 }
2077                         }
2078
2079                         // we just moved into a greedy child
2080                         if (parentInstance && c == 'isover') {
2081                                 parentInstance['isover'] = 0;
2082                                 parentInstance['isout'] = 1;
2083                                 parentInstance._out.call(parentInstance, event);
2084                         }
2085
2086                         this[c] = 1; this[c == 'isout' ? 'isover' : 'isout'] = 0;
2087                         this[c == "isover" ? "_over" : "_out"].call(this, event);
2088
2089                         // we just moved out of a greedy child
2090                         if (parentInstance && c == 'isout') {
2091                                 parentInstance['isout'] = 0;
2092                                 parentInstance['isover'] = 1;
2093                                 parentInstance._over.call(parentInstance, event);
2094                         }
2095                 });
2096
2097         },
2098         dragStop: function( draggable, event ) {
2099                 draggable.element.parentsUntil( "body" ).unbind( "scroll.droppable" );
2100                 //Call prepareOffsets one final time since IE does not fire return scroll events when overflow was caused by drag (see #5003)
2101                 if( !draggable.options.refreshPositions ) $.ui.ddmanager.prepareOffsets( draggable, event );
2102         }
2103 };
2104
2105 })(jQuery);
2106 /*
2107  * jQuery UI Resizable 1.8.14
2108  *
2109  * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
2110  * Dual licensed under the MIT or GPL Version 2 licenses.
2111  * http://jquery.org/license
2112  *
2113  * http://docs.jquery.com/UI/Resizables
2114  *
2115  * Depends:
2116  *      jquery.ui.core.js
2117  *      jquery.ui.mouse.js
2118  *      jquery.ui.widget.js
2119  */
2120 (function( $, undefined ) {
2121
2122 $.widget("ui.resizable", $.ui.mouse, {
2123         widgetEventPrefix: "resize",
2124         options: {
2125                 alsoResize: false,
2126                 animate: false,
2127                 animateDuration: "slow",
2128                 animateEasing: "swing",
2129                 aspectRatio: false,
2130                 autoHide: false,
2131                 containment: false,
2132                 ghost: false,
2133                 grid: false,
2134                 handles: "e,s,se",
2135                 helper: false,
2136                 maxHeight: null,
2137                 maxWidth: null,
2138                 minHeight: 10,
2139                 minWidth: 10,
2140                 zIndex: 1000
2141         },
2142         _create: function() {
2143
2144                 var self = this, o = this.options;
2145                 this.element.addClass("ui-resizable");
2146
2147                 $.extend(this, {
2148                         _aspectRatio: !!(o.aspectRatio),
2149                         aspectRatio: o.aspectRatio,
2150                         originalElement: this.element,
2151                         _proportionallyResizeElements: [],
2152                         _helper: o.helper || o.ghost || o.animate ? o.helper || 'ui-resizable-helper' : null
2153                 });
2154
2155                 //Wrap the element if it cannot hold child nodes
2156                 if(this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)) {
2157
2158                         //Opera fix for relative positioning
2159                         if (/relative/.test(this.element.css('position')) && $.browser.opera)
2160                                 this.element.css({ position: 'relative', top: 'auto', left: 'auto' });
2161
2162                         //Create a wrapper element and set the wrapper to the new current internal element
2163                         this.element.wrap(
2164                                 $('<div class="ui-wrapper" style="overflow: hidden;"></div>').css({
2165                                         position: this.element.css('position'),
2166                                         width: this.element.outerWidth(),
2167                                         height: this.element.outerHeight(),
2168                                         top: this.element.css('top'),
2169                                         left: this.element.css('left')
2170                                 })
2171                         );
2172
2173                         //Overwrite the original this.element
2174                         this.element = this.element.parent().data(
2175                                 "resizable", this.element.data('resizable')
2176                         );
2177
2178                         this.elementIsWrapper = true;
2179
2180                         //Move margins to the wrapper
2181                         this.element.css({ marginLeft: this.originalElement.css("marginLeft"), marginTop: this.originalElement.css("marginTop"), marginRight: this.originalElement.css("marginRight"), marginBottom: this.originalElement.css("marginBottom") });
2182                         this.originalElement.css({ marginLeft: 0, marginTop: 0, marginRight: 0, marginBottom: 0});
2183
2184                         //Prevent Safari textarea resize
2185                         this.originalResizeStyle = this.originalElement.css('resize');
2186                         this.originalElement.css('resize', 'none');
2187
2188                         //Push the actual element to our proportionallyResize internal array
2189                         this._proportionallyResizeElements.push(this.originalElement.css({ position: 'static', zoom: 1, display: 'block' }));
2190
2191                         // avoid IE jump (hard set the margin)
2192                         this.originalElement.css({ margin: this.originalElement.css('margin') });
2193
2194                         // fix handlers offset
2195                         this._proportionallyResize();
2196
2197                 }
2198
2199                 this.handles = o.handles || (!$('.ui-resizable-handle', this.element).length ? "e,s,se" : { n: '.ui-resizable-n', e: '.ui-resizable-e', s: '.ui-resizable-s', w: '.ui-resizable-w', se: '.ui-resizable-se', sw: '.ui-resizable-sw', ne: '.ui-resizable-ne', nw: '.ui-resizable-nw' });
2200                 if(this.handles.constructor == String) {
2201
2202                         if(this.handles == 'all') this.handles = 'n,e,s,w,se,sw,ne,nw';
2203                         var n = this.handles.split(","); this.handles = {};
2204
2205                         for(var i = 0; i < n.length; i++) {
2206
2207                                 var handle = $.trim(n[i]), hname = 'ui-resizable-'+handle;
2208                                 var axis = $('<div class="ui-resizable-handle ' + hname + '"></div>');
2209
2210                                 // increase zIndex of sw, se, ne, nw axis
2211                                 //TODO : this modifies original option
2212                                 if(/sw|se|ne|nw/.test(handle)) axis.css({ zIndex: ++o.zIndex });
2213
2214                                 //TODO : What's going on here?
2215                                 if ('se' == handle) {
2216                                         axis.addClass('ui-icon ui-icon-gripsmall-diagonal-se');
2217                                 };
2218
2219                                 //Insert into internal handles object and append to element
2220                                 this.handles[handle] = '.ui-resizable-'+handle;
2221                                 this.element.append(axis);
2222                         }
2223
2224                 }
2225
2226                 this._renderAxis = function(target) {
2227
2228                         target = target || this.element;
2229
2230                         for(var i in this.handles) {
2231
2232                                 if(this.handles[i].constructor == String)
2233                                         this.handles[i] = $(this.handles[i], this.element).show();
2234
2235                                 //Apply pad to wrapper element, needed to fix axis position (textarea, inputs, scrolls)
2236                                 if (this.elementIsWrapper && this.originalElement[0].nodeName.match(/textarea|input|select|button/i)) {
2237
2238                                         var axis = $(this.handles[i], this.element), padWrapper = 0;
2239
2240                                         //Checking the correct pad and border
2241                                         padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth();
2242
2243                                         //The padding type i have to apply...
2244                                         var padPos = [ 'padding',
2245                                                 /ne|nw|n/.test(i) ? 'Top' :
2246                                                 /se|sw|s/.test(i) ? 'Bottom' :
2247                                                 /^e$/.test(i) ? 'Right' : 'Left' ].join("");
2248
2249                                         target.css(padPos, padWrapper);
2250
2251                                         this._proportionallyResize();
2252
2253                                 }
2254
2255                                 //TODO: What's that good for? There's not anything to be executed left
2256                                 if(!$(this.handles[i]).length)
2257                                         continue;
2258
2259                         }
2260                 };
2261
2262                 //TODO: make renderAxis a prototype function
2263                 this._renderAxis(this.element);
2264
2265                 this._handles = $('.ui-resizable-handle', this.element)
2266                         .disableSelection();
2267
2268                 //Matching axis name
2269                 this._handles.mouseover(function() {
2270                         if (!self.resizing) {
2271                                 if (this.className)
2272                                         var axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);
2273                                 //Axis, default = se
2274                                 self.axis = axis && axis[1] ? axis[1] : 'se';
2275                         }
2276                 });
2277
2278                 //If we want to auto hide the elements
2279                 if (o.autoHide) {
2280                         this._handles.hide();
2281                         $(this.element)
2282                                 .addClass("ui-resizable-autohide")
2283                                 .hover(function() {
2284                                         if (o.disabled) return;
2285                                         $(this).removeClass("ui-resizable-autohide");
2286                                         self._handles.show();
2287                                 },
2288                                 function(){
2289                                         if (o.disabled) return;
2290                                         if (!self.resizing) {
2291                                                 $(this).addClass("ui-resizable-autohide");
2292                                                 self._handles.hide();
2293                                         }
2294                                 });
2295                 }
2296
2297                 //Initialize the mouse interaction
2298                 this._mouseInit();
2299
2300         },
2301
2302         destroy: function() {
2303
2304                 this._mouseDestroy();
2305
2306                 var _destroy = function(exp) {
2307                         $(exp).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing")
2308                                 .removeData("resizable").unbind(".resizable").find('.ui-resizable-handle').remove();
2309                 };
2310
2311                 //TODO: Unwrap at same DOM position
2312                 if (this.elementIsWrapper) {
2313                         _destroy(this.element);
2314                         var wrapper = this.element;
2315                         wrapper.after(
2316                                 this.originalElement.css({
2317                                         position: wrapper.css('position'),
2318                                         width: wrapper.outerWidth(),
2319                                         height: wrapper.outerHeight(),
2320                                         top: wrapper.css('top'),
2321                                         left: wrapper.css('left')
2322                                 })
2323                         ).remove();
2324                 }
2325
2326                 this.originalElement.css('resize', this.originalResizeStyle);
2327                 _destroy(this.originalElement);
2328
2329                 return this;
2330         },
2331
2332         _mouseCapture: function(event) {
2333                 var handle = false;
2334                 for (var i in this.handles) {
2335                         if ($(this.handles[i])[0] == event.target) {
2336                                 handle = true;
2337                         }
2338                 }
2339
2340                 return !this.options.disabled && handle;
2341         },
2342
2343         _mouseStart: function(event) {
2344
2345                 var o = this.options, iniPos = this.element.position(), el = this.element;
2346
2347                 this.resizing = true;
2348                 this.documentScroll = { top: $(document).scrollTop(), left: $(document).scrollLeft() };
2349
2350                 // bugfix for http://dev.jquery.com/ticket/1749
2351                 if (el.is('.ui-draggable') || (/absolute/).test(el.css('position'))) {
2352                         el.css({ position: 'absolute', top: iniPos.top, left: iniPos.left });
2353                 }
2354
2355                 //Opera fixing relative position
2356                 if ($.browser.opera && (/relative/).test(el.css('position')))
2357                         el.css({ position: 'relative', top: 'auto', left: 'auto' });
2358
2359                 this._renderProxy();
2360
2361                 var curleft = num(this.helper.css('left')), curtop = num(this.helper.css('top'));
2362
2363                 if (o.containment) {
2364                         curleft += $(o.containment).scrollLeft() || 0;
2365                         curtop += $(o.containment).scrollTop() || 0;
2366                 }
2367
2368                 //Store needed variables
2369                 this.offset = this.helper.offset();
2370                 this.position = { left: curleft, top: curtop };
2371                 this.size = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
2372                 this.originalSize = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
2373                 this.originalPosition = { left: curleft, top: curtop };
2374                 this.sizeDiff = { width: el.outerWidth() - el.width(), height: el.outerHeight() - el.height() };
2375                 this.originalMousePosition = { left: event.pageX, top: event.pageY };
2376
2377                 //Aspect Ratio
2378                 this.aspectRatio = (typeof o.aspectRatio == 'number') ? o.aspectRatio : ((this.originalSize.width / this.originalSize.height) || 1);
2379
2380             var cursor = $('.ui-resizable-' + this.axis).css('cursor');
2381             $('body').css('cursor', cursor == 'auto' ? this.axis + '-resize' : cursor);
2382
2383                 el.addClass("ui-resizable-resizing");
2384                 this._propagate("start", event);
2385                 return true;
2386         },
2387
2388         _mouseDrag: function(event) {
2389
2390                 //Increase performance, avoid regex
2391                 var el = this.helper, o = this.options, props = {},
2392                         self = this, smp = this.originalMousePosition, a = this.axis;
2393
2394                 var dx = (event.pageX-smp.left)||0, dy = (event.pageY-smp.top)||0;
2395                 var trigger = this._change[a];
2396                 if (!trigger) return false;
2397
2398                 // Calculate the attrs that will be change
2399                 var data = trigger.apply(this, [event, dx, dy]), ie6 = $.browser.msie && $.browser.version < 7, csdif = this.sizeDiff;
2400
2401                 // Put this in the mouseDrag handler since the user can start pressing shift while resizing
2402                 this._updateVirtualBoundaries(event.shiftKey);
2403                 if (this._aspectRatio || event.shiftKey)
2404                         data = this._updateRatio(data, event);
2405
2406                 data = this._respectSize(data, event);
2407
2408                 // plugins callbacks need to be called first
2409                 this._propagate("resize", event);
2410
2411                 el.css({
2412                         top: this.position.top + "px", left: this.position.left + "px",
2413                         width: this.size.width + "px", height: this.size.height + "px"
2414                 });
2415
2416                 if (!this._helper && this._proportionallyResizeElements.length)
2417                         this._proportionallyResize();
2418
2419                 this._updateCache(data);
2420
2421                 // calling the user callback at the end
2422                 this._trigger('resize', event, this.ui());
2423
2424                 return false;
2425         },
2426
2427         _mouseStop: function(event) {
2428
2429                 this.resizing = false;
2430                 var o = this.options, self = this;
2431
2432                 if(this._helper) {
2433                         var pr = this._proportionallyResizeElements, ista = pr.length && (/textarea/i).test(pr[0].nodeName),
2434                                 soffseth = ista && $.ui.hasScroll(pr[0], 'left') /* TODO - jump height */ ? 0 : self.sizeDiff.height,
2435                                 soffsetw = ista ? 0 : self.sizeDiff.width;
2436
2437                         var s = { width: (self.helper.width()  - soffsetw), height: (self.helper.height() - soffseth) },
2438                                 left = (parseInt(self.element.css('left'), 10) + (self.position.left - self.originalPosition.left)) || null,
2439                                 top = (parseInt(self.element.css('top'), 10) + (self.position.top - self.originalPosition.top)) || null;
2440
2441                         if (!o.animate)
2442                                 this.element.css($.extend(s, { top: top, left: left }));
2443
2444                         self.helper.height(self.size.height);
2445                         self.helper.width(self.size.width);
2446
2447                         if (this._helper && !o.animate) this._proportionallyResize();
2448                 }
2449
2450                 $('body').css('cursor', 'auto');
2451
2452                 this.element.removeClass("ui-resizable-resizing");
2453
2454                 this._propagate("stop", event);
2455
2456                 if (this._helper) this.helper.remove();
2457                 return false;
2458
2459         },
2460
2461     _updateVirtualBoundaries: function(forceAspectRatio) {
2462         var o = this.options, pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b;
2463
2464         b = {
2465             minWidth: isNumber(o.minWidth) ? o.minWidth : 0,
2466             maxWidth: isNumber(o.maxWidth) ? o.maxWidth : Infinity,
2467             minHeight: isNumber(o.minHeight) ? o.minHeight : 0,
2468             maxHeight: isNumber(o.maxHeight) ? o.maxHeight : Infinity
2469         };
2470
2471         if(this._aspectRatio || forceAspectRatio) {
2472             // We want to create an enclosing box whose aspect ration is the requested one
2473             // First, compute the "projected" size for each dimension based on the aspect ratio and other dimension
2474             pMinWidth = b.minHeight * this.aspectRatio;
2475             pMinHeight = b.minWidth / this.aspectRatio;
2476             pMaxWidth = b.maxHeight * this.aspectRatio;
2477             pMaxHeight = b.maxWidth / this.aspectRatio;
2478
2479             if(pMinWidth > b.minWidth) b.minWidth = pMinWidth;
2480             if(pMinHeight > b.minHeight) b.minHeight = pMinHeight;
2481             if(pMaxWidth < b.maxWidth) b.maxWidth = pMaxWidth;
2482             if(pMaxHeight < b.maxHeight) b.maxHeight = pMaxHeight;
2483         }
2484         this._vBoundaries = b;
2485     },
2486
2487         _updateCache: function(data) {
2488                 var o = this.options;
2489                 this.offset = this.helper.offset();
2490                 if (isNumber(data.left)) this.position.left = data.left;
2491                 if (isNumber(data.top)) this.position.top = data.top;
2492                 if (isNumber(data.height)) this.size.height = data.height;
2493                 if (isNumber(data.width)) this.size.width = data.width;
2494         },
2495
2496         _updateRatio: function(data, event) {
2497
2498                 var o = this.options, cpos = this.position, csize = this.size, a = this.axis;
2499
2500                 if (isNumber(data.height)) data.width = (data.height * this.aspectRatio);
2501                 else if (isNumber(data.width)) data.height = (data.width / this.aspectRatio);
2502
2503                 if (a == 'sw') {
2504                         data.left = cpos.left + (csize.width - data.width);
2505                         data.top = null;
2506                 }
2507                 if (a == 'nw') {
2508                         data.top = cpos.top + (csize.height - data.height);
2509                         data.left = cpos.left + (csize.width - data.width);
2510                 }
2511
2512                 return data;
2513         },
2514
2515         _respectSize: function(data, event) {
2516
2517                 var el = this.helper, o = this._vBoundaries, pRatio = this._aspectRatio || event.shiftKey, a = this.axis,
2518                                 ismaxw = isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width), ismaxh = isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height),
2519                                         isminw = isNumber(data.width) && o.minWidth && (o.minWidth > data.width), isminh = isNumber(data.height) && o.minHeight && (o.minHeight > data.height);
2520
2521                 if (isminw) data.width = o.minWidth;
2522                 if (isminh) data.height = o.minHeight;
2523                 if (ismaxw) data.width = o.maxWidth;
2524                 if (ismaxh) data.height = o.maxHeight;
2525
2526                 var dw = this.originalPosition.left + this.originalSize.width, dh = this.position.top + this.size.height;
2527                 var cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a);
2528
2529                 if (isminw && cw) data.left = dw - o.minWidth;
2530                 if (ismaxw && cw) data.left = dw - o.maxWidth;
2531                 if (isminh && ch)       data.top = dh - o.minHeight;
2532                 if (ismaxh && ch)       data.top = dh - o.maxHeight;
2533
2534                 // fixing jump error on top/left - bug #2330
2535                 var isNotwh = !data.width && !data.height;
2536                 if (isNotwh && !data.left && data.top) data.top = null;
2537                 else if (isNotwh && !data.top && data.left) data.left = null;
2538
2539                 return data;
2540         },
2541
2542         _proportionallyResize: function() {
2543
2544                 var o = this.options;
2545                 if (!this._proportionallyResizeElements.length) return;
2546                 var element = this.helper || this.element;
2547
2548                 for (var i=0; i < this._proportionallyResizeElements.length; i++) {
2549
2550                         var prel = this._proportionallyResizeElements[i];
2551
2552                         if (!this.borderDif) {
2553                                 var b = [prel.css('borderTopWidth'), prel.css('borderRightWidth'), prel.css('borderBottomWidth'), prel.css('borderLeftWidth')],
2554                                         p = [prel.css('paddingTop'), prel.css('paddingRight'), prel.css('paddingBottom'), prel.css('paddingLeft')];
2555
2556                                 this.borderDif = $.map(b, function(v, i) {
2557                                         var border = parseInt(v,10)||0, padding = parseInt(p[i],10)||0;
2558                                         return border + padding;
2559                                 });
2560                         }
2561
2562                         if ($.browser.msie && !(!($(element).is(':hidden') || $(element).parents(':hidden').length)))
2563                                 continue;
2564
2565                         prel.css({
2566                                 height: (element.height() - this.borderDif[0] - this.borderDif[2]) || 0,
2567                                 width: (element.width() - this.borderDif[1] - this.borderDif[3]) || 0
2568                         });
2569
2570                 };
2571
2572         },
2573
2574         _renderProxy: function() {
2575
2576                 var el = this.element, o = this.options;
2577                 this.elementOffset = el.offset();
2578
2579                 if(this._helper) {
2580
2581                         this.helper = this.helper || $('<div style="overflow:hidden;"></div>');
2582
2583                         // fix ie6 offset TODO: This seems broken
2584                         var ie6 = $.browser.msie && $.browser.version < 7, ie6offset = (ie6 ? 1 : 0),
2585                         pxyoffset = ( ie6 ? 2 : -1 );
2586
2587                         this.helper.addClass(this._helper).css({
2588                                 width: this.element.outerWidth() + pxyoffset,
2589                                 height: this.element.outerHeight() + pxyoffset,
2590                                 position: 'absolute',
2591                                 left: this.elementOffset.left - ie6offset +'px',
2592                                 top: this.elementOffset.top - ie6offset +'px',
2593                                 zIndex: ++o.zIndex //TODO: Don't modify option
2594                         });
2595
2596                         this.helper
2597                                 .appendTo("body")
2598                                 .disableSelection();
2599
2600                 } else {
2601                         this.helper = this.element;
2602                 }
2603
2604         },
2605
2606         _change: {
2607                 e: function(event, dx, dy) {
2608                         return { width: this.originalSize.width + dx };
2609                 },
2610                 w: function(event, dx, dy) {
2611                         var o = this.options, cs = this.originalSize, sp = this.originalPosition;
2612                         return { left: sp.left + dx, width: cs.width - dx };
2613                 },
2614                 n: function(event, dx, dy) {
2615                         var o = this.options, cs = this.originalSize, sp = this.originalPosition;
2616                         return { top: sp.top + dy, height: cs.height - dy };
2617                 },
2618                 s: function(event, dx, dy) {
2619                         return { height: this.originalSize.height + dy };
2620                 },
2621                 se: function(event, dx, dy) {
2622                         return $.extend(this._change.s.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
2623                 },
2624                 sw: function(event, dx, dy) {
2625                         return $.extend(this._change.s.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
2626                 },
2627                 ne: function(event, dx, dy) {
2628                         return $.extend(this._change.n.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
2629                 },
2630                 nw: function(event, dx, dy) {
2631                         return $.extend(this._change.n.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
2632                 }
2633         },
2634
2635         _propagate: function(n, event) {
2636                 $.ui.plugin.call(this, n, [event, this.ui()]);
2637                 (n != "resize" && this._trigger(n, event, this.ui()));
2638         },
2639
2640         plugins: {},
2641
2642         ui: function() {
2643                 return {
2644                         originalElement: this.originalElement,
2645                         element: this.element,
2646                         helper: this.helper,
2647                         position: this.position,
2648                         size: this.size,
2649                         originalSize: this.originalSize,
2650                         originalPosition: this.originalPosition
2651                 };
2652         }
2653
2654 });
2655
2656 $.extend($.ui.resizable, {
2657         version: "1.8.14"
2658 });
2659
2660 /*
2661  * Resizable Extensions
2662  */
2663
2664 $.ui.plugin.add("resizable", "alsoResize", {
2665
2666         start: function (event, ui) {
2667                 var self = $(this).data("resizable"), o = self.options;
2668
2669                 var _store = function (exp) {
2670                         $(exp).each(function() {
2671                                 var el = $(this);
2672                                 el.data("resizable-alsoresize", {
2673                                         width: parseInt(el.width(), 10), height: parseInt(el.height(), 10),
2674                                         left: parseInt(el.css('left'), 10), top: parseInt(el.css('top'), 10),
2675                                         position: el.css('position') // to reset Opera on stop()
2676                                 });
2677                         });
2678                 };
2679
2680                 if (typeof(o.alsoResize) == 'object' && !o.alsoResize.parentNode) {
2681                         if (o.alsoResize.length) { o.alsoResize = o.alsoResize[0]; _store(o.alsoResize); }
2682                         else { $.each(o.alsoResize, function (exp) { _store(exp); }); }
2683                 }else{
2684                         _store(o.alsoResize);
2685                 }
2686         },
2687
2688         resize: function (event, ui) {
2689                 var self = $(this).data("resizable"), o = self.options, os = self.originalSize, op = self.originalPosition;
2690
2691                 var delta = {
2692                         height: (self.size.height - os.height) || 0, width: (self.size.width - os.width) || 0,
2693                         top: (self.position.top - op.top) || 0, left: (self.position.left - op.left) || 0
2694                 },
2695
2696                 _alsoResize = function (exp, c) {
2697                         $(exp).each(function() {
2698                                 var el = $(this), start = $(this).data("resizable-alsoresize"), style = {}, 
2699                                         css = c && c.length ? c : el.parents(ui.originalElement[0]).length ? ['width', 'height'] : ['width', 'height', 'top', 'left'];
2700
2701                                 $.each(css, function (i, prop) {
2702                                         var sum = (start[prop]||0) + (delta[prop]||0);
2703                                         if (sum && sum >= 0)
2704                                                 style[prop] = sum || null;
2705                                 });
2706
2707                                 // Opera fixing relative position
2708                                 if ($.browser.opera && /relative/.test(el.css('position'))) {
2709                                         self._revertToRelativePosition = true;
2710                                         el.css({ position: 'absolute', top: 'auto', left: 'auto' });
2711                                 }
2712
2713                                 el.css(style);
2714                         });
2715                 };
2716
2717                 if (typeof(o.alsoResize) == 'object' && !o.alsoResize.nodeType) {
2718                         $.each(o.alsoResize, function (exp, c) { _alsoResize(exp, c); });
2719                 }else{
2720                         _alsoResize(o.alsoResize);
2721                 }
2722         },
2723
2724         stop: function (event, ui) {
2725                 var self = $(this).data("resizable"), o = self.options;
2726
2727                 var _reset = function (exp) {
2728                         $(exp).each(function() {
2729                                 var el = $(this);
2730                                 // reset position for Opera - no need to verify it was changed
2731                                 el.css({ position: el.data("resizable-alsoresize").position });
2732                         });
2733                 };
2734
2735                 if (self._revertToRelativePosition) {
2736                         self._revertToRelativePosition = false;
2737                         if (typeof(o.alsoResize) == 'object' && !o.alsoResize.nodeType) {
2738                                 $.each(o.alsoResize, function (exp) { _reset(exp); });
2739                         }else{
2740                                 _reset(o.alsoResize);
2741                         }
2742                 }
2743
2744                 $(this).removeData("resizable-alsoresize");
2745         }
2746 });
2747
2748 $.ui.plugin.add("resizable", "animate", {
2749
2750         stop: function(event, ui) {
2751                 var self = $(this).data("resizable"), o = self.options;
2752
2753                 var pr = self._proportionallyResizeElements, ista = pr.length && (/textarea/i).test(pr[0].nodeName),
2754                                         soffseth = ista && $.ui.hasScroll(pr[0], 'left') /* TODO - jump height */ ? 0 : self.sizeDiff.height,
2755                                                 soffsetw = ista ? 0 : self.sizeDiff.width;
2756
2757                 var style = { width: (self.size.width - soffsetw), height: (self.size.height - soffseth) },
2758                                         left = (parseInt(self.element.css('left'), 10) + (self.position.left - self.originalPosition.left)) || null,
2759                                                 top = (parseInt(self.element.css('top'), 10) + (self.position.top - self.originalPosition.top)) || null;
2760
2761                 self.element.animate(
2762                         $.extend(style, top && left ? { top: top, left: left } : {}), {
2763                                 duration: o.animateDuration,
2764                                 easing: o.animateEasing,
2765                                 step: function() {
2766
2767                                         var data = {
2768                                                 width: parseInt(self.element.css('width'), 10),
2769                                                 height: parseInt(self.element.css('height'), 10),
2770                                                 top: parseInt(self.element.css('top'), 10),
2771                                                 left: parseInt(self.element.css('left'), 10)
2772                                         };
2773
2774                                         if (pr && pr.length) $(pr[0]).css({ width: data.width, height: data.height });
2775
2776                                         // propagating resize, and updating values for each animation step
2777                                         self._updateCache(data);
2778                                         self._propagate("resize", event);
2779
2780                                 }
2781                         }
2782                 );
2783         }
2784
2785 });
2786
2787 $.ui.plugin.add("resizable", "containment", {
2788
2789         start: function(event, ui) {
2790                 var self = $(this).data("resizable"), o = self.options, el = self.element;
2791                 var oc = o.containment, ce = (oc instanceof $) ? oc.get(0) : (/parent/.test(oc)) ? el.parent().get(0) : oc;
2792                 if (!ce) return;
2793
2794                 self.containerElement = $(ce);
2795
2796                 if (/document/.test(oc) || oc == document) {
2797                         self.containerOffset = { left: 0, top: 0 };
2798                         self.containerPosition = { left: 0, top: 0 };
2799
2800                         self.parentData = {
2801                                 element: $(document), left: 0, top: 0,
2802                                 width: $(document).width(), height: $(document).height() || document.body.parentNode.scrollHeight
2803                         };
2804                 }
2805
2806                 // i'm a node, so compute top, left, right, bottom
2807                 else {
2808                         var element = $(ce), p = [];
2809                         $([ "Top", "Right", "Left", "Bottom" ]).each(function(i, name) { p[i] = num(element.css("padding" + name)); });
2810
2811                         self.containerOffset = element.offset();
2812                         self.containerPosition = element.position();
2813                         self.containerSize = { height: (element.innerHeight() - p[3]), width: (element.innerWidth() - p[1]) };
2814
2815                         var co = self.containerOffset, ch = self.containerSize.height,  cw = self.containerSize.width,
2816                                                 width = ($.ui.hasScroll(ce, "left") ? ce.scrollWidth : cw ), height = ($.ui.hasScroll(ce) ? ce.scrollHeight : ch);
2817
2818                         self.parentData = {
2819                                 element: ce, left: co.left, top: co.top, width: width, height: height
2820                         };
2821                 }
2822         },
2823
2824         resize: function(event, ui) {
2825                 var self = $(this).data("resizable"), o = self.options,
2826                                 ps = self.containerSize, co = self.containerOffset, cs = self.size, cp = self.position,
2827                                 pRatio = self._aspectRatio || event.shiftKey, cop = { top:0, left:0 }, ce = self.containerElement;
2828
2829                 if (ce[0] != document && (/static/).test(ce.css('position'))) cop = co;
2830
2831                 if (cp.left < (self._helper ? co.left : 0)) {
2832                         self.size.width = self.size.width + (self._helper ? (self.position.left - co.left) : (self.position.left - cop.left));
2833                         if (pRatio) self.size.height = self.size.width / o.aspectRatio;
2834                         self.position.left = o.helper ? co.left : 0;
2835                 }
2836
2837                 if (cp.top < (self._helper ? co.top : 0)) {
2838                         self.size.height = self.size.height + (self._helper ? (self.position.top - co.top) : self.position.top);
2839                         if (pRatio) self.size.width = self.size.height * o.aspectRatio;
2840                         self.position.top = self._helper ? co.top : 0;
2841                 }
2842
2843                 self.offset.left = self.parentData.left+self.position.left;
2844                 self.offset.top = self.parentData.top+self.position.top;
2845
2846                 var woset = Math.abs( (self._helper ? self.offset.left - cop.left : (self.offset.left - cop.left)) + self.sizeDiff.width ),
2847                                         hoset = Math.abs( (self._helper ? self.offset.top - cop.top : (self.offset.top - co.top)) + self.sizeDiff.height );
2848
2849                 var isParent = self.containerElement.get(0) == self.element.parent().get(0),
2850                     isOffsetRelative = /relative|absolute/.test(self.containerElement.css('position'));
2851
2852                 if(isParent && isOffsetRelative) woset -= self.parentData.left;
2853
2854                 if (woset + self.size.width >= self.parentData.width) {
2855                         self.size.width = self.parentData.width - woset;
2856                         if (pRatio) self.size.height = self.size.width / self.aspectRatio;
2857                 }
2858
2859                 if (hoset + self.size.height >= self.parentData.height) {
2860                         self.size.height = self.parentData.height - hoset;
2861                         if (pRatio) self.size.width = self.size.height * self.aspectRatio;
2862                 }
2863         },
2864
2865         stop: function(event, ui){
2866                 var self = $(this).data("resizable"), o = self.options, cp = self.position,
2867                                 co = self.containerOffset, cop = self.containerPosition, ce = self.containerElement;
2868
2869                 var helper = $(self.helper), ho = helper.offset(), w = helper.outerWidth() - self.sizeDiff.width, h = helper.outerHeight() - self.sizeDiff.height;
2870
2871                 if (self._helper && !o.animate && (/relative/).test(ce.css('position')))
2872                         $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
2873
2874                 if (self._helper && !o.animate && (/static/).test(ce.css('position')))
2875                         $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
2876
2877         }
2878 });
2879
2880 $.ui.plugin.add("resizable", "ghost", {
2881
2882         start: function(event, ui) {
2883
2884                 var self = $(this).data("resizable"), o = self.options, cs = self.size;
2885
2886                 self.ghost = self.originalElement.clone();
2887                 self.ghost
2888                         .css({ opacity: .25, display: 'block', position: 'relative', height: cs.height, width: cs.width, margin: 0, left: 0, top: 0 })
2889                         .addClass('ui-resizable-ghost')
2890                         .addClass(typeof o.ghost == 'string' ? o.ghost : '');
2891
2892                 self.ghost.appendTo(self.helper);
2893
2894         },
2895
2896         resize: function(event, ui){
2897                 var self = $(this).data("resizable"), o = self.options;
2898                 if (self.ghost) self.ghost.css({ position: 'relative', height: self.size.height, width: self.size.width });
2899         },
2900
2901         stop: function(event, ui){
2902                 var self = $(this).data("resizable"), o = self.options;
2903                 if (self.ghost && self.helper) self.helper.get(0).removeChild(self.ghost.get(0));
2904         }
2905
2906 });
2907
2908 $.ui.plugin.add("resizable", "grid", {
2909
2910         resize: function(event, ui) {
2911                 var self = $(this).data("resizable"), o = self.options, cs = self.size, os = self.originalSize, op = self.originalPosition, a = self.axis, ratio = o._aspectRatio || event.shiftKey;
2912                 o.grid = typeof o.grid == "number" ? [o.grid, o.grid] : o.grid;
2913                 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);
2914
2915                 if (/^(se|s|e)$/.test(a)) {
2916                         self.size.width = os.width + ox;
2917                         self.size.height = os.height + oy;
2918                 }
2919                 else if (/^(ne)$/.test(a)) {
2920                         self.size.width = os.width + ox;
2921                         self.size.height = os.height + oy;
2922                         self.position.top = op.top - oy;
2923                 }
2924                 else if (/^(sw)$/.test(a)) {
2925                         self.size.width = os.width + ox;
2926                         self.size.height = os.height + oy;
2927                         self.position.left = op.left - ox;
2928                 }
2929                 else {
2930                         self.size.width = os.width + ox;
2931                         self.size.height = os.height + oy;
2932                         self.position.top = op.top - oy;
2933                         self.position.left = op.left - ox;
2934                 }
2935         }
2936
2937 });
2938
2939 var num = function(v) {
2940         return parseInt(v, 10) || 0;
2941 };
2942
2943 var isNumber = function(value) {
2944         return !isNaN(parseInt(value, 10));
2945 };
2946
2947 })(jQuery);
2948 /*
2949  * jQuery UI Selectable 1.8.14
2950  *
2951  * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
2952  * Dual licensed under the MIT or GPL Version 2 licenses.
2953  * http://jquery.org/license
2954  *
2955  * http://docs.jquery.com/UI/Selectables
2956  *
2957  * Depends:
2958  *      jquery.ui.core.js
2959  *      jquery.ui.mouse.js
2960  *      jquery.ui.widget.js
2961  */
2962 (function( $, undefined ) {
2963
2964 $.widget("ui.selectable", $.ui.mouse, {
2965         options: {
2966                 appendTo: 'body',
2967                 autoRefresh: true,
2968                 distance: 0,
2969                 filter: '*',
2970                 tolerance: 'touch'
2971         },
2972         _create: function() {
2973                 var self = this;
2974
2975                 this.element.addClass("ui-selectable");
2976
2977                 this.dragged = false;
2978
2979                 // cache selectee children based on filter
2980                 var selectees;
2981                 this.refresh = function() {
2982                         selectees = $(self.options.filter, self.element[0]);
2983                         selectees.each(function() {
2984                                 var $this = $(this);
2985                                 var pos = $this.offset();
2986                                 $.data(this, "selectable-item", {
2987                                         element: this,
2988                                         $element: $this,
2989                                         left: pos.left,
2990                                         top: pos.top,
2991                                         right: pos.left + $this.outerWidth(),
2992                                         bottom: pos.top + $this.outerHeight(),
2993                                         startselected: false,
2994                                         selected: $this.hasClass('ui-selected'),
2995                                         selecting: $this.hasClass('ui-selecting'),
2996                                         unselecting: $this.hasClass('ui-unselecting')
2997                                 });
2998                         });
2999                 };
3000                 this.refresh();
3001
3002                 this.selectees = selectees.addClass("ui-selectee");
3003
3004                 this._mouseInit();
3005
3006                 this.helper = $("<div class='ui-selectable-helper'></div>");
3007         },
3008
3009         destroy: function() {
3010                 this.selectees
3011                         .removeClass("ui-selectee")
3012                         .removeData("selectable-item");
3013                 this.element
3014                         .removeClass("ui-selectable ui-selectable-disabled")
3015                         .removeData("selectable")
3016                         .unbind(".selectable");
3017                 this._mouseDestroy();
3018
3019                 return this;
3020         },
3021
3022         _mouseStart: function(event) {
3023                 var self = this;
3024
3025                 this.opos = [event.pageX, event.pageY];
3026
3027                 if (this.options.disabled)
3028                         return;
3029
3030                 var options = this.options;
3031
3032                 this.selectees = $(options.filter, this.element[0]);
3033
3034                 this._trigger("start", event);
3035
3036                 $(options.appendTo).append(this.helper);
3037                 // position helper (lasso)
3038                 this.helper.css({
3039                         "left": event.clientX,
3040                         "top": event.clientY,
3041                         "width": 0,
3042                         "height": 0
3043                 });
3044
3045                 if (options.autoRefresh) {
3046                         this.refresh();
3047                 }
3048
3049                 this.selectees.filter('.ui-selected').each(function() {
3050                         var selectee = $.data(this, "selectable-item");
3051                         selectee.startselected = true;
3052                         if (!event.metaKey) {
3053                                 selectee.$element.removeClass('ui-selected');
3054                                 selectee.selected = false;
3055                                 selectee.$element.addClass('ui-unselecting');
3056                                 selectee.unselecting = true;
3057                                 // selectable UNSELECTING callback
3058                                 self._trigger("unselecting", event, {
3059                                         unselecting: selectee.element
3060                                 });
3061                         }
3062                 });
3063
3064                 $(event.target).parents().andSelf().each(function() {
3065                         var selectee = $.data(this, "selectable-item");
3066                         if (selectee) {
3067                                 var doSelect = !event.metaKey || !selectee.$element.hasClass('ui-selected');
3068                                 selectee.$element
3069                                         .removeClass(doSelect ? "ui-unselecting" : "ui-selected")
3070                                         .addClass(doSelect ? "ui-selecting" : "ui-unselecting");
3071                                 selectee.unselecting = !doSelect;
3072                                 selectee.selecting = doSelect;
3073                                 selectee.selected = doSelect;
3074                                 // selectable (UN)SELECTING callback
3075                                 if (doSelect) {
3076                                         self._trigger("selecting", event, {
3077                                                 selecting: selectee.element
3078                                         });
3079                                 } else {
3080                                         self._trigger("unselecting", event, {
3081                                                 unselecting: selectee.element
3082                                         });
3083                                 }
3084                                 return false;
3085                         }
3086                 });
3087
3088         },
3089
3090         _mouseDrag: function(event) {
3091                 var self = this;
3092                 this.dragged = true;
3093
3094                 if (this.options.disabled)
3095                         return;
3096
3097                 var options = this.options;
3098
3099                 var x1 = this.opos[0], y1 = this.opos[1], x2 = event.pageX, y2 = event.pageY;
3100                 if (x1 > x2) { var tmp = x2; x2 = x1; x1 = tmp; }
3101                 if (y1 > y2) { var tmp = y2; y2 = y1; y1 = tmp; }
3102                 this.helper.css({left: x1, top: y1, width: x2-x1, height: y2-y1});
3103
3104                 this.selectees.each(function() {
3105                         var selectee = $.data(this, "selectable-item");
3106                         //prevent helper from being selected if appendTo: selectable
3107                         if (!selectee || selectee.element == self.element[0])
3108                                 return;
3109                         var hit = false;
3110                         if (options.tolerance == 'touch') {
3111                                 hit = ( !(selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1) );
3112                         } else if (options.tolerance == 'fit') {
3113                                 hit = (selectee.left > x1 && selectee.right < x2 && selectee.to