(function(C){C.ui=C.ui||{};C.extend(C.ui,{plugin:{add:function(F,I,H,G){var E=C.ui[F].prototype;if(!E.plugins[I]){E.plugins[I]=[]}E.plugins[I].push([H,G])},call:function(E,F,H){var K=E.plugins[F];if(!K){return }var J=E.interaction?E.interaction.options:E.options;var I=E.interaction?E.interaction.element:E.element;for(var G=0;G<K.length;G++){if(J[K[G][0]]){K[G][1].apply(I,H)}}}}});C.fn.mouseInteractionDestroy=function(){this.each(function(){if(C.data(this,"ui-mouse")){C.data(this,"ui-mouse").destroy()}})};C.ui.mouseInteraction=function(F,G){if(!G){var G={}}this.element=F;C.data(this.element,"ui-mouse",this);this.options={};C.extend(this.options,G);C.extend(this.options,{handle:G.handle?(C(G.handle,F)[0]?C(G.handle,F):C(F)):C(F),helper:G.helper||"original",preventionDistance:G.preventionDistance||0,dragPrevention:G.dragPrevention?G.dragPrevention.toLowerCase().split(","):["input","textarea","button","select","option"],cursorAt:{top:((G.cursorAt&&G.cursorAt.top)?G.cursorAt.top:0),left:((G.cursorAt&&G.cursorAt.left)?G.cursorAt.left:0),bottom:((G.cursorAt&&G.cursorAt.bottom)?G.cursorAt.bottom:0),right:((G.cursorAt&&G.cursorAt.right)?G.cursorAt.right:0)},cursorAtIgnore:(!G.cursorAt)?true:false,appendTo:G.appendTo||"parent"});G=this.options;if(!this.options.nonDestructive&&(G.helper=="clone"||G.helper=="original")){G.margins={top:parseInt(C(F).css("marginTop"))||0,left:parseInt(C(F).css("marginLeft"))||0,bottom:parseInt(C(F).css("marginBottom"))||0,right:parseInt(C(F).css("marginRight"))||0};if(G.cursorAt.top!=0){G.cursorAt.top=G.margins.top}if(G.cursorAt.left!=0){G.cursorAt.left+=G.margins.left}if(G.cursorAt.bottom!=0){G.cursorAt.bottom+=G.margins.bottom}if(G.cursorAt.right!=0){G.cursorAt.right+=G.margins.right}if(G.helper=="original"){G.wasPositioned=C(F).css("position")}}else{G.margins={top:0,left:0,right:0,bottom:0}}var E=this;this.mousedownfunc=function(H){return E.click.apply(E,[H])};G.handle.bind("mousedown",this.mousedownfunc);if(C.browser.msie){C(this.element).attr("unselectable","on")}};C.extend(C.ui.mouseInteraction.prototype,{plugins:{},currentTarget:null,lastTarget:null,timer:null,slowMode:false,init:false,destroy:function(){this.options.handle.unbind("mousedown",this.mousedownfunc)},trigger:function(E){return this.click.apply(this,arguments)},click:function(H){var I=this.options;window.focus();if(H.which!=1){return true}var G=(H.target)?H.target.nodeName.toLowerCase():H.srcElement.nodeName.toLowerCase();for(var F=0;F<I.dragPrevention.length;F++){if(G==I.dragPrevention[F]){return true}}if(I.startCondition&&!I.startCondition.apply(this,[H])){return true}var E=this;this.mouseup=function(K){return E.stop.apply(E,[K])};this.mousemove=function(K){return E.drag.apply(E,[K])};var J=function(){C(document).bind("mouseup",E.mouseup);C(document).bind("mousemove",E.mousemove);E.opos=[H.pageX,H.pageY]};if(I.preventionTimeout){if(this.timer){clearInterval(this.timer)}this.timer=setTimeout(function(){J()},I.preventionTimeout);return false}J();return false},start:function(G){var H=this.options;var E=this.element;H.co=C(E).offset();this.helper=typeof H.helper=="function"?C(H.helper.apply(E,[G,this]))[0]:(H.helper=="clone"?C(E).clone()[0]:E);if(H.appendTo=="parent"){var F=E.parentNode;while(F){if(F.style&&(C(F).css("position")=="relative"||C(F).css("position")=="absolute")){H.pp=F;H.po=C(F).offset();H.ppOverflow=!!(C(H.pp).css("overflow")=="auto"||C(H.pp).css("overflow")=="scroll");break}F=F.parentNode?F.parentNode:null}if(!H.pp){H.po={top:0,left:0}}}this.pos=[this.opos[0],this.opos[1]];this.rpos=[this.pos[0],this.pos[1]];if(H.cursorAtIgnore){H.cursorAt.left=this.pos[0]-H.co.left+H.margins.left;H.cursorAt.top=this.pos[1]-H.co.top+H.margins.top}if(H.pp){this.pos[0]-=H.po.left;this.pos[1]-=H.po.top}this.slowMode=(H.cursorAt&&(H.cursorAt.top-H.margins.top>0||H.cursorAt.bottom-H.margins.bottom>0)&&(H.cursorAt.left-H.margins.left>0||H.cursorAt.right-H.margins.right>0))?true:false;if(!H.nonDestructive){C(this.helper).css("position","absolute")}if(H.helper!="original"){C(this.helper).appendTo((H.appendTo=="parent"?E.parentNode:H.appendTo)).show()}if(H.cursorAt.right&&!H.cursorAt.left){H.cursorAt.left=this.helper.offsetWidth+H.margins.right+H.margins.left-H.cursorAt.right}if(H.cursorAt.bottom&&!H.cursorAt.top){H.cursorAt.top=this.helper.offsetHeight+H.margins.top+H.margins.bottom-H.cursorAt.bottom}this.init=true;if(H._start){H._start.apply(E,[this.helper,this.pos,H.cursorAt,this,G])}this.helperSize={width:D(this.helper),height:B(this.helper)};return false},stop:function(G){var H=this.options;var E=this.element;var F=this;C(document).unbind("mouseup",F.mouseup);C(document).unbind("mousemove",F.mousemove);if(this.init==false){return this.opos=this.pos=null}if(H._beforeStop){H._beforeStop.apply(E,[this.helper,this.pos,H.cursorAt,this,G])}if(this.helper!=E&&!H.beQuietAtEnd){C(this.helper).remove();this.helper=null}if(!H.beQuietAtEnd){if(H._stop){H._stop.apply(E,[this.helper,this.pos,H.cursorAt,this,G])}}this.init=false;this.opos=this.pos=null;return false},drag:function(E){if(!this.opos||(C.browser.msie&&!E.button)){return this.stop.apply(this,[E])}var F=this.options;this.pos=[E.pageX,E.pageY];if(this.rpos&&this.rpos[0]==this.pos[0]&&this.rpos[1]==this.pos[1]){return false}this.rpos=[this.pos[0],this.pos[1]];if(F.pp){this.pos[0]-=F.po.left;this.pos[1]-=F.po.top}if((Math.abs(this.rpos[0]-this.opos[0])>F.preventionDistance||Math.abs(this.rpos[1]-this.opos[1])>F.preventionDistance)&&this.init==false){this.start.apply(this,[E])}else{if(this.init==false){return false}}if(F._drag){F._drag.apply(this.element,[this.helper,this.pos,F.cursorAt,this,E])}return false}});var A=function(E,F){return parseInt(C.css(E.jquery?E[0]:E,F))||0};function D(I){var G=C(I),E=G.width();for(var F=0,H=["borderLeftWidth","paddingLeft","paddingRight","borderRightWidth"];F<H.length;F++){E+=A(G,H[F])}return E}function B(H){var F=C(H),I=F.width();for(var E=0,G=["borderTopWidth","paddingTop","paddingBottom","borderBottomWidth"];E<G.length;E++){I+=A(F,G[E])}return I}})(jQuery);

