(function(a){a.ui.plugin.add("draggable","stop","effect",function(d,c){var b=c.helper;if(c.options.effect[1]){if(b!=this){c.options.beQuietAtEnd=true;switch(c.options.effect[1]){case"fade":a(b).fadeOut(300,function(){a(this).remove()});break;default:a(b).remove();break}}}});a.ui.plugin.add("draggable","start","effect",function(c,b){if(b.options.effect[0]){switch(b.options.effect[0]){case"fade":a(b.helper).hide().fadeIn(300);break}}});a.ui.plugin.add("draggable","start","cursor",function(d,c){var b=a("body");if(b.css("cursor")){c.options.ocursor=b.css("cursor")}b.css("cursor",c.options.cursor)});a.ui.plugin.add("draggable","stop","cursor",function(c,b){if(b.options.ocursor){a("body").css("cursor",b.options.ocursor)}});a.ui.plugin.add("draggable","start","zIndex",function(d,c){var b=a(c.helper);if(b.css("zIndex")){c.options.ozIndex=b.css("zIndex")}b.css("zIndex",c.options.zIndex)});a.ui.plugin.add("draggable","stop","zIndex",function(c,b){if(b.options.ozIndex){a(b.helper).css("zIndex",b.options.ozIndex)}});a.ui.plugin.add("draggable","start","opacity",function(d,c){var b=a(c.helper);if(b.css("opacity")){c.options.oopacity=b.css("opacity")}b.css("opacity",c.options.opacity)});a.ui.plugin.add("draggable","stop","opacity",function(c,b){if(b.options.oopacity){a(b.helper).css("opacity",b.options.oopacity)}});a.ui.plugin.add("draggable","stop","revert",function(g,f){var i=f.options;var h={left:0,top:0};i.beQuietAtEnd=true;if(f.helper!=this){h=a(f.draggable.sorthelper||this).offset({border:false});var b=h.left-i.po.left-i.margins.left;var d=h.top-i.po.top-i.margins.top}else{var b=i.co.left-(i.po?i.po.left:0);var d=i.co.top-(i.po?i.po.top:0)}var c=f.draggable;a(f.helper).animate({left:b,top:d},500,function(){if(i.wasPositioned){a(c.element).css("position",i.wasPositioned)}if(i.stop){i.stop.apply(c.element,[c.helper,c.pos,[i.co.left-i.po.left,i.co.top-i.po.top],c])}if(c.helper!=c.element){window.setTimeout(function(){a(c.helper).remove()},0)}})});a.ui.plugin.add("draggable","start","iframeFix",function(d,c){var g=c.options;if(!c.draggable.slowMode){if(g.iframeFix.constructor==Array){for(var b=0;b<g.iframeFix.length;b++){var f=a(g.iframeFix[b]).offset({border:false});a("<div class='DragDropIframeFix' style='background: #fff;'></div>").css("width",a(g.iframeFix[b])[0].offsetWidth+"px").css("height",a(g.iframeFix[b])[0].offsetHeight+"px").css("position","absolute").css("opacity","0.001").css("z-index","1000").css("top",f.top+"px").css("left",f.left+"px").appendTo("body")}}else{a("iframe").each(function(){var e=a(this).offset({border:false});a("<div class='DragDropIframeFix' style='background: #fff;'></div>").css("width",this.offsetWidth+"px").css("height",this.offsetHeight+"px").css("position","absolute").css("opacity","0.001").css("z-index","1000").css("top",e.top+"px").css("left",e.left+"px").appendTo("body")})}}});a.ui.plugin.add("draggable","stop","iframeFix",function(c,b){if(b.options.iframeFix){a("div.DragDropIframeFix").each(function(){this.parentNode.removeChild(this)})}});a.ui.plugin.add("draggable","start","containment",function(d,b){var g=b.options;if(!g.cursorAtIgnore||g.containment.left!=undefined||g.containment.constructor==Array){return}if(g.containment=="parent"){g.containment=this.parentNode}if(g.containment=="document"){g.containment=[0-g.margins.left,0-g.margins.top,a(document).width()-g.margins.right,(a(document).height()||document.body.parentNode.scrollHeight)-g.margins.bottom]}else{var c=a(g.containment)[0];var f=a(g.containment).offset({border:false});g.containment=[f.left-g.margins.left,f.top-g.margins.top,f.left+(c.offsetWidth||c.scrollWidth)-g.margins.right,f.top+(c.offsetHeight||c.scrollHeight)-g.margins.bottom]}});a.ui.plugin.add("draggable","drag","containment",function(g,d){var i=d.options;if(!i.cursorAtIgnore){return}var b=a(d.helper);var j=i.containment;if(j.constructor==Array){if((d.draggable.pos[0]<j[0]-i.po.left)){d.draggable.pos[0]=j[0]-i.po.left}if((d.draggable.pos[1]<j[1]-i.po.top)){d.draggable.pos[1]=j[1]-i.po.top}if(d.draggable.pos[0]+b[0].offsetWidth>j[2]-i.po.left){d.draggable.pos[0]=j[2]-i.po.left-b[0].offsetWidth}if(d.draggable.pos[1]+b[0].offsetHeight>j[3]-i.po.top){d.draggable.pos[1]=j[3]-i.po.top-b[0].offsetHeight}}else{if(j.left&&(d.draggable.pos[0]<j.left)){d.draggable.pos[0]=j.left}if(j.top&&(d.draggable.pos[1]<j.top)){d.draggable.pos[1]=j.top}var f=a(i.pp);if(j.right&&d.draggable.pos[0]+b[0].offsetWidth>f[0].offsetWidth-j.right){d.draggable.pos[0]=(f[0].offsetWidth-j.right)-b[0].offsetWidth}if(j.bottom&&d.draggable.pos[1]+b[0].offsetHeight>f[0].offsetHeight-j.bottom){d.draggable.pos[1]=(f[0].offsetHeight-j.bottom)-b[0].offsetHeight}}});a.ui.plugin.add("draggable","drag","grid",function(c,b){var d=b.options;if(!d.cursorAtIgnore){return}b.draggable.pos[0]=d.co.left+d.margins.left-d.po.left+Math.round((b.draggable.pos[0]-d.co.left-d.margins.left+d.po.left)/d.grid[0])*d.grid[0];b.draggable.pos[1]=d.co.top+d.margins.top-d.po.top+Math.round((b.draggable.pos[1]-d.co.top-d.margins.top+d.po.top)/d.grid[1])*d.grid[1]});a.ui.plugin.add("draggable","drag","axis",function(c,b){var d=b.options;if(!d.cursorAtIgnore){return}if(d.constraint){d.axis=d.constraint}d.axis?(d.axis=="x"?b.draggable.pos[1]=d.co.top-d.margins.top-d.po.top:b.draggable.pos[0]=d.co.left-d.margins.left-d.po.left):null});a.ui.plugin.add("draggable","drag","scroll",function(c,b){var d=b.options;d.scrollSensitivity=d.scrollSensitivity||20;d.scrollSpeed=d.scrollSpeed||20;if(d.pp&&d.ppOverflow){}else{if((b.draggable.rpos[1]-a(window).height())-a(document).scrollTop()>-d.scrollSensitivity){window.scrollBy(0,d.scrollSpeed)}if(b.draggable.rpos[1]-a(document).scrollTop()<d.scrollSensitivity){window.scrollBy(0,-d.scrollSpeed)}if((b.draggable.rpos[0]-a(window).width())-a(document).scrollLeft()>-d.scrollSensitivity){window.scrollBy(d.scrollSpeed,0)}if(b.draggable.rpos[0]-a(document).scrollLeft()<d.scrollSensitivity){window.scrollBy(-d.scrollSpeed,0)}}});a.ui.plugin.add("draggable","drag","wrapHelper",function(g,f){var i=f.options;if(i.cursorAtIgnore){return}var b=f.helper;if(!i.pp||!i.ppOverflow){var d=a(window).width()-(a.browser.mozilla?20:0);var j=a(document).scrollLeft();var c=a(window).height();var h=a(document).scrollTop()}else{var d=i.pp.offsetWidth+i.po.left-20;var j=i.pp.scrollLeft;var c=i.pp.offsetHeight+i.po.top-20;var h=i.pp.scrollTop}f.draggable.pos[0]-=((f.draggable.rpos[0]-i.cursorAt.left-d+b.offsetWidth+i.margins.right)-j>0||(f.draggable.rpos[0]-i.cursorAt.left+i.margins.left)-j<0)?(b.offsetWidth+i.margins.left+i.margins.right-i.cursorAt.left*2):0;f.draggable.pos[1]-=((f.draggable.rpos[1]-i.cursorAt.top-c+b.offsetHeight+i.margins.bottom)-h>0||(f.draggable.rpos[1]-i.cursorAt.top+i.margins.top)-h<0)?(b.offsetHeight+i.margins.top+i.margins.bottom-i.cursorAt.top*2):0})})(jQuery);
