(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(f,g,j){var m=f.plugins[g];if(!m){return}var l=f.interaction?f.interaction.options:f.options;var k=f.interaction?f.interaction.element:f.element;for(var h=0;h<m.length;h++){if(l[m[h][0]]){m[h][1].apply(k,j)}}}}});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(f){return this.click.apply(this,arguments)},click:function(j){var k=this.options;window.focus();if(j.which!=1){return true}var h=(j.target)?j.target.nodeName.toLowerCase():j.srcElement.nodeName.toLowerCase();for(var g=0;g<k.dragPrevention.length;g++){if(h==k.dragPrevention[g]){return true}}if(k.startCondition&&!k.startCondition.apply(this,[j])){return true}var f=this;this.mouseup=function(i){return f.stop.apply(f,[i])};this.mousemove=function(i){return f.drag.apply(f,[i])};var l=function(){c(document).bind("mouseup",f.mouseup);c(document).bind("mousemove",f.mousemove);f.opos=[j.pageX,j.pageY]};if(k.preventionTimeout){if(this.timer){clearInterval(this.timer)}this.timer=setTimeout(function(){l()},k.preventionTimeout);return false}l();return false},start:function(h){var i=this.options;var f=this.element;i.co=c(f).offset();this.helper=typeof i.helper=="function"?c(i.helper.apply(f,[h,this]))[0]:(i.helper=="clone"?c(f).clone()[0]:f);if(i.appendTo=="parent"){var g=f.parentNode;while(g){if(g.style&&(c(g).css("position")=="relative"||c(g).css("position")=="absolute")){i.pp=g;i.po=c(g).offset();i.ppOverflow=!!(c(i.pp).css("overflow")=="auto"||c(i.pp).css("overflow")=="scroll");break}g=g.parentNode?g.parentNode:null}if(!i.pp){i.po={top:0,left:0}}}this.pos=[this.opos[0],this.opos[1]];this.rpos=[this.pos[0],this.pos[1]];if(i.cursorAtIgnore){i.cursorAt.left=this.pos[0]-i.co.left+i.margins.left;i.cursorAt.top=this.pos[1]-i.co.top+i.margins.top}if(i.pp){this.pos[0]-=i.po.left;this.pos[1]-=i.po.top}this.slowMode=(i.cursorAt&&(i.cursorAt.top-i.margins.top>0||i.cursorAt.bottom-i.margins.bottom>0)&&(i.cursorAt.left-i.margins.left>0||i.cursorAt.right-i.margins.right>0))?true:false;if(!i.nonDestructive){c(this.helper).css("position","absolute")}if(i.helper!="original"){c(this.helper).appendTo((i.appendTo=="parent"?f.parentNode:i.appendTo)).show()}if(i.cursorAt.right&&!i.cursorAt.left){i.cursorAt.left=this.helper.offsetWidth+i.margins.right+i.margins.left-i.cursorAt.right}if(i.cursorAt.bottom&&!i.cursorAt.top){i.cursorAt.top=this.helper.offsetHeight+i.margins.top+i.margins.bottom-i.cursorAt.bottom}this.init=true;if(i._start){i._start.apply(f,[this.helper,this.pos,i.cursorAt,this,h])}this.helperSize={width:d(this.helper),height:b(this.helper)};return false},stop:function(h){var i=this.options;var f=this.element;var g=this;c(document).unbind("mouseup",g.mouseup);c(document).unbind("mousemove",g.mousemove);if(this.init==false){return this.opos=this.pos=null}if(i._beforeStop){i._beforeStop.apply(f,[this.helper,this.pos,i.cursorAt,this,h])}if(this.helper!=f&&!i.beQuietAtEnd){c(this.helper).remove();this.helper=null}if(!i.beQuietAtEnd){if(i._stop){i._stop.apply(f,[this.helper,this.pos,i.cursorAt,this,h])}}this.init=false;this.opos=this.pos=null;return false},drag:function(f){if(!this.opos||(c.browser.msie&&!f.button)){return this.stop.apply(this,[f])}var g=this.options;this.pos=[f.pageX,f.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(g.pp){this.pos[0]-=g.po.left;this.pos[1]-=g.po.top}if((Math.abs(this.rpos[0]-this.opos[0])>g.preventionDistance||Math.abs(this.rpos[1]-this.opos[1])>g.preventionDistance)&&this.init==false){this.start.apply(this,[f])}else{if(this.init==false){return false}}if(g._drag){g._drag.apply(this.element,[this.helper,this.pos,g.cursorAt,this,f])}return false}});var a=function(e,f){return parseInt(c.css(e.jquery?e[0]:e,f))||0};function d(j){var g=c(j),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),j=f.width();for(var e=0,g=["borderTopWidth","paddingTop","paddingBottom","borderBottomWidth"];e<g.length;e++){j+=a(f,g[e])}return j}})($);
