(function(A){A.fn.resizable=function(B){return this.each(function(){var D=Array.prototype.slice.call(arguments,1);if(typeof B=="string"){var C=A.data(this,"ui-resizable");C[B].apply(C,D)}else{if(!A(this).is(".ui-resizable")){new A.ui.resizable(this,B)}}})};A.ui.resizable=function(K,R){var Q=this;this.element=A(K);A.data(K,"ui-resizable",this);this.element.addClass("ui-resizable");this.options=A.extend({preventDefault:true,transparent:false,minWidth:10,minHeight:10,aspectRatio:false,disableSelection:true,preserveCursor:true,autohide:false},R);this.options._aspectRatio=!!(this.options.aspectRatio);A(K).bind("setData.resizable",function(T,S,U){Q.options[S]=U}).bind("getData.resizable",function(T,S){return Q.options[S]});var C=this.options;var E="1px solid #DEDEDE";C.defaultTheme={"ui-resizable":{display:"block"},"ui-resizable-handle":{position:"absolute",background:"#F5F5F5"},"ui-resizable-n":{cursor:"n-resize",height:"4px",left:"0px",right:"0px",borderTop:E},"ui-resizable-s":{cursor:"s-resize",height:"4px",left:"0px",right:"0px",borderBottom:E},"ui-resizable-e":{cursor:"e-resize",width:"4px",top:"0px",bottom:"0px",borderRight:E},"ui-resizable-w":{cursor:"w-resize",width:"4px",top:"0px",bottom:"0px",borderLeft:E},"ui-resizable-se":{cursor:"se-resize",width:"4px",height:"4px",borderRight:E,borderBottom:E},"ui-resizable-sw":{cursor:"sw-resize",width:"4px",height:"4px",borderBottom:E,borderLeft:E},"ui-resizable-ne":{cursor:"ne-resize",width:"4px",height:"4px",borderRight:E,borderTop:E},"ui-resizable-nw":{cursor:"nw-resize",width:"4px",height:"4px",borderLeft:E,borderTop:E}};if(!C.proxy&&(this.element.css("position")=="static"||this.element.css("position")=="")){this.element.css("position","relative")}var O=K.nodeName;if(O.match(/textarea|input|select|button|img/i)){this.element.wrap('<div class="ui-wrapper"  style="overflow: hidden; position: relative; width: '+this.element.outerWidth()+"px; height: "+this.element.outerHeight()+';"></div>');var I=this.element;K=K.parentNode;this.element=A(K);this.element.css({marginLeft:I.css("marginLeft"),marginTop:I.css("marginTop"),marginRight:I.css("marginRight"),marginBottom:I.css("marginBottom")});I.css({marginLeft:0,marginTop:0,marginRight:0,marginBottom:0});if(A.browser.safari&&C.preventDefault){I.css("resize","none")}C.proportionallyResize=I.css("position","static");this._proportionallyResize()}if(!C.handles){C.handles=!A(".ui-resizable-handle",K).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"}}if(C.handles.constructor==String){if(C.handles=="all"){C.handles="n,e,s,w,se,sw,ne,nw"}var D=C.handles.split(",");C.handles={};C.zIndex=C.zIndex||1000;var H={handle:"overflow:hidden; position:absolute;",n:"top: 0pt; width:100%;",e:"right: 0pt; height:100%;",s:"bottom: 0pt; width:100%;",w:"left: 0pt; height:100%;",se:"bottom: 0pt; right: 0px;",sw:"bottom: 0pt; left: 0px;",ne:"top: 0pt; right: 0px;",nw:"top: 0pt; left: 0px;"};for(var J=0;J<D.length;J++){var M=jQuery.trim(D[J]),P=C.defaultTheme,B="ui-resizable-"+M;var N=A.extend(P[B],P["ui-resizable-handle"]),G=A(['<div class="',B,' ui-resizable-handle" style="',H[M],H.handle,'"></div>'].join("")).css(/sw|se|ne|nw/.test(M)?{zIndex:++C.zIndex}:{});C.handles[M]=".ui-resizable-"+M;this.element.append(G.css(!A.ui.css(B)?N:{}))}}this._renderAxis=function(W){W=W||this.element;for(var T in C.handles){if(C.handles[T].constructor==String){C.handles[T]=A(C.handles[T],K).show()}if(C.transparent){C.handles[T].css({opacity:0})}if(this.element.is(".ui-wrapper")&&O.match(/textarea|input|select|button/i)){var U=A(C.handles[T],K),V=0;V=/sw|ne|nw|se|n|s/.test(T)?U.outerHeight():U.outerWidth();var S=["padding",/ne|nw|n/.test(T)?"Top":/se|sw|s/.test(T)?"Bottom":/^e$/.test(T)?"Right":"Left"].join("");if(!C.transparent){W.css(S,V)}}if(!A(C.handles[T]).length){continue}}};this._renderAxis(this.element);var F=A(".ui-resizable-handle",Q.element);if(C.disableSelection){F.each(function(S,T){A.ui.disableSelection(T)})}F.mouseover(function(){if(!C.resizing){if(this.className){var S=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i)}C.axis=S&&S[1]?S[1]:"se"}});if(C.autohide){var L=A.ui.css("ui-resizable-s")||A.ui.css("ui-resizable-e");if(!L){F.hide()}A(Q.element).addClass("ui-resizable-autohide").hover(function(){if(!L){F.show()}A(this).removeClass("ui-resizable-autohide")},function(){if(!C.resizing){if(!L){F.hide()}A(this).addClass("ui-resizable-autohide")}})}this.element.mouseInteraction({executor:this,delay:0,distance:0,dragPrevention:["input","textarea","button","select","option"],start:this.start,stop:this.stop,drag:this.drag,condition:function(T){if(this.disabled){return false}for(var S in this.options.handles){if(A(this.options.handles[S])[0]==T.target){return true}}return false}})};A.extend(A.ui.resizable.prototype,{plugins:{},ui:function(){return{instance:this,axis:this.options.axis,options:this.options}},_proportionallyResize:function(){var E=this.options;if(!E.proportionallyResize){return}var C=E.proportionallyResize;var B=[C.css("borderTopWidth"),C.css("borderRightWidth"),C.css("borderBottomWidth"),C.css("borderLeftWidth")];var D=[C.css("paddingTop"),C.css("paddingRight"),C.css("paddingBottom"),C.css("paddingLeft")];E.borderDif=E.borderDif||A.map(B,function(F,H){var G=parseInt(F,10)||0,I=parseInt(D[H],10)||0;return G+I});C.css({display:"block",height:(this.element.height()-E.borderDif[0]-E.borderDif[2])+"px",width:(this.element.width()-E.borderDif[1]-E.borderDif[3])+"px"})},_renderProxy:function(){var B=this.element,D=this.options;this.offset=B.offset();if(D.proxy){this.helper=this.helper||A('<div style="overflow:hidden;"></div>');var C=(A.browser.msie&&A.browser.version<7?3:0);this.helper.addClass(D.proxy).css({width:B.outerWidth(),height:B.outerHeight(),position:"absolute",left:this.offset.left-C+"px",top:this.offset.top-C+"px",zIndex:++D.zIndex});this.helper.appendTo("body");if(D.disableSelection){A.ui.disableSelection(this.helper.get(0))}}else{this.helper=B}},propagate:function(C,B){A.ui.plugin.call(this,C,[B,this.ui()]);this.element.triggerHandler(C=="resize"?C:"resize"+C,[B,this.ui()],this.options[C])},destroy:function(){this.element.removeClass("ui-resizable ui-resizable-disabled").removeMouseInteraction().removeData("ui-resizable").unbind(".resizable")},enable:function(){this.element.removeClass("ui-resizable-disabled");this.disabled=false},disable:function(){this.element.addClass("ui-resizable-disabled");this.disabled=true},start:function(L){var G=this.options,C=this.element.position(),H=this.element;G.resizing=true;G.documentScroll={top:A(document).scrollTop(),left:A(document).scrollLeft()};if(H.is(".ui-draggable")||(/absolute/).test(H.css("position"))){var O=A.browser.msie&&!G.containment&&(/absolute/).test(H.css("position"))&&!(/relative/).test(H.parent().css("position"));var P=O?G.documentScroll.top:0,J=O?G.documentScroll.left:0;H.css({position:"absolute",top:(C.top+P),left:(C.left+J)})}if(/relative/.test(H.css("position"))&&A.browser.opera){H.css({position:"relative",top:"auto",left:"auto"})}this._renderProxy();var Q=parseInt(this.helper.css("left"),10)||0,I=parseInt(this.helper.css("top"),10)||0;A.extend(G,{currentSize:{width:H.outerWidth(),height:H.outerHeight()},currentSizeDiff:{width:H.outerWidth()-H.width(),height:H.outerHeight()-H.height()},startMousePosition:{left:L.pageX,top:L.pageY},startPosition:{left:Q,top:I},currentPosition:{left:Q,top:I}});var E=G.currentSize.width<G.currentSize.height;G.aspectRatio=(typeof G.aspectRatio=="number")?G.aspectRatio:Math.pow(G.currentSize.width/G.currentSize.height,E?1:-1);G.aspectRatioTarget=E?"width":"height";if(G.preserveCursor){A("body").css("cursor",G.axis+"-resize")}if(G.containment){var D=G.containment,F=(D instanceof jQuery)?D.get(0):(/parent/.test(D))?H.parent().get(0):null;if(F){var N=function(U,S){var R=/top/.test(S||"top")?"scrollTop":"scrollLeft",T=false;if(U[R]>0){return true}U[R]=1;T=U[R]>0?true:false;U[R]=0;return T};var M=A(F).offset(),B=A(F).innerHeight(),K=A(F).innerWidth();G.cdata={e:F,l:M.left,t:M.top,w:(N(F,"left")?F.scrollWidth:K),h:(N(F)?F.scrollHeight:B)}}if(/document/.test(D)||D==document){G.cdata={e:document,l:0,t:0,w:A(document).width(),h:A(document).height()}}}this.propagate("start",L);return false},stop:function(C){this.options.resizing=false;var D=this.options;if(D.proxy){var B={width:(this.helper.width()-D.currentSizeDiff.width)+"px",height:(this.helper.height()-D.currentSizeDiff.height)+"px",top:((parseInt(this.element.css("top"),10)||0)+((parseInt(this.helper.css("top"),10)-this.offset.top)||0)),left:((parseInt(this.element.css("left"),10)||0)+((parseInt(this.helper.css("left"),10)-this.offset.left)||0))};this.element.css(B);if(D.proxy){this._proportionallyResize()}this.helper.remove()}if(D.preserveCursor){A("body").css("cursor","auto")}this.propagate("stop",C);return false},drag:function(E){var C=this.helper,B=this.options,G={},O=this,K=B._aspectRatio||E.shiftKey;var H=function(V,U){var T=(V=="top"||V=="height"),Q=(V=="width"||V=="height"),X=(B.axis=="se"||B.axis=="s"||B.axis=="e");var S=(E[T?"pageY":"pageX"]-B.startMousePosition[T?"top":"left"])*(U?-1:1);var P=B[Q?"currentSize":"startPosition"][V]-S-(!B.proxy&&X?B.currentSizeDiff.width:0);if(K){var W=P*Math.pow(B.aspectRatio,(T?-1:1)*(B.aspectRatioTarget=="height"?1:-1)),R=false;if(T&&W>=B.maxWidth||!T&&W>=B.maxHeight){R=true}if(T&&W<=B.minWidth||!T&&W<=B.minHeight){R=true}if(Q&&!R){C.css(T?"width":"height",W)}if(V=="top"&&(B.axis=="ne"||B.axis=="nw")){return}}C.css(V,P)};var J=B.axis,I=0,M;if(J=="n"||J=="ne"||J=="nw"){H("height")}if(J=="s"||J=="se"||J=="sw"){H("height",1)}var F=parseInt(C.css("height"),10)||0;if(B.minHeight&&F<=B.minHeight){C.css("height",B.minHeight)}if(B.maxHeight&&F>=B.maxHeight){C.css("height",B.maxHeight)}if(J=="n"||J=="ne"||J=="nw"){H("top",1)}var D=parseInt(C.css("top"),10)||0;I=(B.startPosition.top+(B.currentSize.height-B.minHeight));M=(B.startPosition.top+(B.currentSize.height-B.maxHeight));if(B.minHeight&&D>=I){C.css("top",I)}if(B.maxHeight&&D<=M){C.css("top",M)}if(J=="e"||J=="se"||J=="ne"){H("width",1)}if(J=="sw"||J=="w"||J=="nw"){H("width")}var L=parseInt(C.css("width"),10)||0;if(B.minWidth&&L<=B.minWidth){C.css("width",B.minWidth)}if(B.maxWidth&&L>=B.maxWidth){C.css("width",B.maxWidth)}if(J=="sw"||J=="w"||J=="nw"){H("left",1)}var N=parseInt(C.css("left"),10)||0;I=(B.startPosition.left+(B.currentSize.width-B.minWidth));M=(B.startPosition.left+(B.currentSize.width-B.maxWidth));if(B.minWidth&&N>=I){C.css("left",I)}if(B.maxWidth&&N<=M){C.css("left",M)}if(B.containment&&B.cdata.e){if(N<0){C.css("left",0);C.css("width",L+N)}if(D<0){C.css("top",0);C.css("height",F+D)}if(L+B.currentSizeDiff.width+N>=B.cdata.w){C.css("width",B.cdata.w-B.currentSizeDiff.width-(N<0?0:N))}if(F+B.currentSizeDiff.height+D>=B.cdata.h){C.css("height",B.cdata.h-B.currentSizeDiff.height-(D<0?0:D))}}B.currentPosition={left:N,top:D};if(!B.proxy){this._proportionallyResize()}this.propagate("resize",E);return false}})})(jQuery);

