/*
 * jQuery UI Resizable 1.7.2
 *
 * Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * http://docs.jquery.com/UI/Resizables
 *
 * Depends:
 *	ui.core.js
 */
(function($){$.widget("ui.resizable",$.extend({},$.ui.mouse,{_init:function(){var d=this,o=this.options;this.element.addClass("ui-resizable");$.extend(this,{_aspectRatio:!!(o.aspectRatio),aspectRatio:o.aspectRatio,originalElement:this.element,_proportionallyResizeElements:[],_helper:o.helper||o.ghost||o.animate?o.helper||'ui-resizable-helper':null});if(this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)){if(/relative/.test(this.element.css('position'))&&$.browser.opera)this.element.css({position:'relative',top:'auto',left:'auto'});this.element.wrap($('<div class="ui-wrapper" style="overflow: hidden;"></div>').css({position:this.element.css('position'),width:this.element.outerWidth(),height:this.element.outerHeight(),top:this.element.css('top'),left:this.element.css('left')}));this.element=this.element.parent().data("resizable",this.element.data('resizable'));this.elementIsWrapper=true;this.element.css({marginLeft:this.originalElement.css("marginLeft"),marginTop:this.originalElement.css("marginTop"),marginRight:this.originalElement.css("marginRight"),marginBottom:this.originalElement.css("marginBottom")});this.originalElement.css({marginLeft:0,marginTop:0,marginRight:0,marginBottom:0});this.originalResizeStyle=this.originalElement.css('resize');this.originalElement.css('resize','none');this._proportionallyResizeElements.push(this.originalElement.css({position:'static',zoom:1,display:'block'}));this.originalElement.css({margin:this.originalElement.css('margin')});this._proportionallyResize()}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'});if(this.handles.constructor==String){if(this.handles=='all')this.handles='n,e,s,w,se,sw,ne,nw';var n=this.handles.split(",");this.handles={};for(var i=0;i<n.length;i++){var e=$.trim(n[i]),hname='ui-resizable-'+e;var f=$('<div class="ui-resizable-handle '+hname+'"></div>');if(/sw|se|ne|nw/.test(e))f.css({zIndex:++o.zIndex});if('se'==e){f.addClass('ui-icon ui-icon-gripsmall-diagonal-se')};this.handles[e]='.ui-resizable-'+e;this.element.append(f)}}this._renderAxis=function(a){a=a||this.element;for(var i in this.handles){if(this.handles[i].constructor==String)this.handles[i]=$(this.handles[i],this.element).show();if(this.elementIsWrapper&&this.originalElement[0].nodeName.match(/textarea|input|select|button/i)){var b=$(this.handles[i],this.element),padWrapper=0;padWrapper=/sw|ne|nw|se|n|s/.test(i)?b.outerHeight():b.outerWidth();var c=['padding',/ne|nw|n/.test(i)?'Top':/se|sw|s/.test(i)?'Bottom':/^e$/.test(i)?'Right':'Left'].join("");a.css(c,padWrapper);this._proportionallyResize()}if(!$(this.handles[i]).length)continue}};this._renderAxis(this.element);this._handles=$('.ui-resizable-handle',this.element).disableSelection();this._handles.mouseover(function(){if(!d.resizing){if(this.className)var a=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);d.axis=a&&a[1]?a[1]:'se'}});if(o.autoHide){this._handles.hide();$(this.element).addClass("ui-resizable-autohide").hover(function(){$(this).removeClass("ui-resizable-autohide");d._handles.show()},function(){if(!d.resizing){$(this).addClass("ui-resizable-autohide");d._handles.hide()}})}this._mouseInit()},destroy:function(){this._mouseDestroy();var b=function(a){$(a).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing").removeData("resizable").unbind(".resizable").find('.ui-resizable-handle').remove()};if(this.elementIsWrapper){b(this.element);var c=this.element;c.parent().append(this.originalElement.css({position:c.css('position'),width:c.outerWidth(),height:c.outerHeight(),top:c.css('top'),left:c.css('left')})).end().remove()}this.originalElement.css('resize',this.originalResizeStyle);b(this.originalElement)},_mouseCapture:function(a){var b=false;for(var i in this.handles){if($(this.handles[i])[0]==a.target)b=true}return this.options.disabled||!!b},_mouseStart:function(a){var o=this.options,iniPos=this.element.position(),el=this.element;this.resizing=true;this.documentScroll={top:$(document).scrollTop(),left:$(document).scrollLeft()};if(el.is('.ui-draggable')||(/absolute/).test(el.css('position'))){el.css({position:'absolute',top:iniPos.top,left:iniPos.left})}if($.browser.opera&&(/relative/).test(el.css('position')))el.css({position:'relative',top:'auto',left:'auto'});this._renderProxy();var b=k(this.helper.css('left')),curtop=k(this.helper.css('top'));if(o.containment){b+=$(o.containment).scrollLeft()||0;curtop+=$(o.containment).scrollTop()||0}this.offset=this.helper.offset();this.position={left:b,top:curtop};this.size=this._helper?{width:el.outerWidth(),height:el.outerHeight()}:{width:el.width(),height:el.height()};this.originalSize=this._helper?{width:el.outerWidth(),height:el.outerHeight()}:{width:el.width(),height:el.height()};this.originalPosition={left:b,top:curtop};this.sizeDiff={width:el.outerWidth()-el.width(),height:el.outerHeight()-el.height()};this.originalMousePosition={left:a.pageX,top:a.pageY};this.aspectRatio=(typeof o.aspectRatio=='number')?o.aspectRatio:((this.originalSize.width/this.originalSize.height)||1);var c=$('.ui-resizable-'+this.axis).css('cursor');$('body').css('cursor',c=='auto'?this.axis+'-resize':c);el.addClass("ui-resizable-resizing");this._propagate("start",a);return true},_mouseDrag:function(b){var c=this.helper,o=this.options,props={},self=this,smp=this.originalMousePosition,a=this.axis;var d=(b.pageX-smp.left)||0,dy=(b.pageY-smp.top)||0;var e=this._change[a];if(!e)return false;var f=e.apply(this,[b,d,dy]),ie6=$.browser.msie&&$.browser.version<7,csdif=this.sizeDiff;if(this._aspectRatio||b.shiftKey)f=this._updateRatio(f,b);f=this._respectSize(f,b);this._propagate("resize",b);c.css({top:this.position.top+"px",left:this.position.left+"px",width:this.size.width+"px",height:this.size.height+"px"});if(!this._helper&&this._proportionallyResizeElements.length)this._proportionallyResize();this._updateCache(f);this._trigger('resize',b,this.ui());return false},_mouseStop:function(a){this.resizing=false;var o=this.options,self=this;if(this._helper){var b=this._proportionallyResizeElements,ista=b.length&&(/textarea/i).test(b[0].nodeName),soffseth=ista&&$.ui.hasScroll(b[0],'left')?0:self.sizeDiff.height,soffsetw=ista?0:self.sizeDiff.width;var s={width:(self.size.width-soffsetw),height:(self.size.height-soffseth)},left=(parseInt(self.element.css('left'),10)+(self.position.left-self.originalPosition.left))||null,top=(parseInt(self.element.css('top'),10)+(self.position.top-self.originalPosition.top))||null;if(!o.animate)this.element.css($.extend(s,{top:top,left:left}));self.helper.height(self.size.height);self.helper.width(self.size.width);if(this._helper&&!o.animate)this._proportionallyResize()}$('body').css('cursor','auto');this.element.removeClass("ui-resizable-resizing");this._propagate("stop",a);if(this._helper)this.helper.remove();return false},_updateCache:function(a){var o=this.options;this.offset=this.helper.offset();if(l(a.left))this.position.left=a.left;if(l(a.top))this.position.top=a.top;if(l(a.height))this.size.height=a.height;if(l(a.width))this.size.width=a.width},_updateRatio:function(b,c){var o=this.options,cpos=this.position,csize=this.size,a=this.axis;if(b.height)b.width=(csize.height*this.aspectRatio);else if(b.width)b.height=(csize.width/this.aspectRatio);if(a=='sw'){b.left=cpos.left+(csize.width-b.width);b.top=null}if(a=='nw'){b.top=cpos.top+(csize.height-b.height);b.left=cpos.left+(csize.width-b.width)}return b},_respectSize:function(b,c){var d=this.helper,o=this.options,pRatio=this._aspectRatio||c.shiftKey,a=this.axis,ismaxw=l(b.width)&&o.maxWidth&&(o.maxWidth<b.width),ismaxh=l(b.height)&&o.maxHeight&&(o.maxHeight<b.height),isminw=l(b.width)&&o.minWidth&&(o.minWidth>b.width),isminh=l(b.height)&&o.minHeight&&(o.minHeight>b.height);if(isminw)b.width=o.minWidth;if(isminh)b.height=o.minHeight;if(ismaxw)b.width=o.maxWidth;if(ismaxh)b.height=o.maxHeight;var e=this.originalPosition.left+this.originalSize.width,dh=this.position.top+this.size.height;var f=/sw|nw|w/.test(a),ch=/nw|ne|n/.test(a);if(isminw&&f)b.left=e-o.minWidth;if(ismaxw&&f)b.left=e-o.maxWidth;if(isminh&&ch)b.top=dh-o.minHeight;if(ismaxh&&ch)b.top=dh-o.maxHeight;var g=!b.width&&!b.height;if(g&&!b.left&&b.top)b.top=null;else if(g&&!b.top&&b.left)b.left=null;return b},_proportionallyResize:function(){var o=this.options;if(!this._proportionallyResizeElements.length)return;var c=this.helper||this.element;for(var i=0;i<this._proportionallyResizeElements.length;i++){var d=this._proportionallyResizeElements[i];if(!this.borderDif){var b=[d.css('borderTopWidth'),d.css('borderRightWidth'),d.css('borderBottomWidth'),d.css('borderLeftWidth')],p=[d.css('paddingTop'),d.css('paddingRight'),d.css('paddingBottom'),d.css('paddingLeft')];this.borderDif=$.map(b,function(v,i){var a=parseInt(v,10)||0,padding=parseInt(p[i],10)||0;return a+padding})}if($.browser.msie&&!(!($(c).is(':hidden')||$(c).parents(':hidden').length)))continue;d.css({height:(c.height()-this.borderDif[0]-this.borderDif[2])||0,width:(c.width()-this.borderDif[1]-this.borderDif[3])||0})}},_renderProxy:function(){var a=this.element,o=this.options;this.elementOffset=a.offset();if(this._helper){this.helper=this.helper||$('<div style="overflow:hidden;"></div>');var b=$.browser.msie&&$.browser.version<7,ie6offset=(b?1:0),pxyoffset=(b?2:-1);this.helper.addClass(this._helper).css({width:this.element.outerWidth()+pxyoffset,height:this.element.outerHeight()+pxyoffset,position:'absolute',left:this.elementOffset.left-ie6offset+'px',top:this.elementOffset.top-ie6offset+'px',zIndex:++o.zIndex});this.helper.appendTo("body").disableSelection()}else{this.helper=this.element}},_change:{e:function(a,b,c){return{width:this.originalSize.width+b}},w:function(a,b,c){var o=this.options,cs=this.originalSize,sp=this.originalPosition;return{left:sp.left+b,width:cs.width-b}},n:function(a,b,c){var o=this.options,cs=this.originalSize,sp=this.originalPosition;return{top:sp.top+c,height:cs.height-c}},s:function(a,b,c){return{height:this.originalSize.height+c}},se:function(a,b,c){return $.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[a,b,c]))},sw:function(a,b,c){return $.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[a,b,c]))},ne:function(a,b,c){return $.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[a,b,c]))},nw:function(a,b,c){return $.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[a,b,c]))}},_propagate:function(n,a){$.ui.plugin.call(this,n,[a,this.ui()]);(n!="resize"&&this._trigger(n,a,this.ui()))},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,originalSize:this.originalSize,originalPosition:this.originalPosition}}}));$.extend($.ui.resizable,{version:"1.7.2",eventPrefix:"resize",defaults:{alsoResize:false,animate:false,animateDuration:"slow",animateEasing:"swing",aspectRatio:false,autoHide:false,cancel:":input,option",containment:false,delay:0,distance:1,ghost:false,grid:false,handles:"e,s,se",helper:false,maxHeight:null,maxWidth:null,minHeight:10,minWidth:10,zIndex:1000}});$.ui.plugin.add("resizable","alsoResize",{start:function(b,d){var e=$(this).data("resizable"),o=e.options;_store=function(a){$(a).each(function(){$(this).data("resizable-alsoresize",{width:parseInt($(this).width(),10),height:parseInt($(this).height(),10),left:parseInt($(this).css('left'),10),top:parseInt($(this).css('top'),10)})})};if(typeof(o.alsoResize)=='object'&&!o.alsoResize.parentNode){if(o.alsoResize.length){o.alsoResize=o.alsoResize[0];_store(o.alsoResize)}else{$.each(o.alsoResize,function(a,c){_store(a)})}}else{_store(o.alsoResize)}},resize:function(f,g){var h=$(this).data("resizable"),o=h.options,os=h.originalSize,op=h.originalPosition;var j={height:(h.size.height-os.height)||0,width:(h.size.width-os.width)||0,top:(h.position.top-op.top)||0,left:(h.position.left-op.left)||0},_alsoResize=function(e,c){$(e).each(function(){var d=$(this),start=$(this).data("resizable-alsoresize"),style={},css=c&&c.length?c:['width','height','top','left'];$.each(css||['width','height','top','left'],function(i,a){var b=(start[a]||0)+(j[a]||0);if(b&&b>=0)style[a]=b||null});if(/relative/.test(d.css('position'))&&$.browser.opera){h._revertToRelativePosition=true;d.css({position:'absolute',top:'auto',left:'auto'})}d.css(style)})};if(typeof(o.alsoResize)=='object'&&!o.alsoResize.nodeType){$.each(o.alsoResize,function(a,c){_alsoResize(a,c)})}else{_alsoResize(o.alsoResize)}},stop:function(a,b){var c=$(this).data("resizable");if(c._revertToRelativePosition&&$.browser.opera){c._revertToRelativePosition=false;el.css({position:'relative'})}$(this).removeData("resizable-alsoresize-start")}});$.ui.plugin.add("resizable","animate",{stop:function(b,c){var d=$(this).data("resizable"),o=d.options;var e=d._proportionallyResizeElements,ista=e.length&&(/textarea/i).test(e[0].nodeName),soffseth=ista&&$.ui.hasScroll(e[0],'left')?0:d.sizeDiff.height,soffsetw=ista?0:d.sizeDiff.width;var f={width:(d.size.width-soffsetw),height:(d.size.height-soffseth)},left=(parseInt(d.element.css('left'),10)+(d.position.left-d.originalPosition.left))||null,top=(parseInt(d.element.css('top'),10)+(d.position.top-d.originalPosition.top))||null;d.element.animate($.extend(f,top&&left?{top:top,left:left}:{}),{duration:o.animateDuration,easing:o.animateEasing,step:function(){var a={width:parseInt(d.element.css('width'),10),height:parseInt(d.element.css('height'),10),top:parseInt(d.element.css('top'),10),left:parseInt(d.element.css('left'),10)};if(e&&e.length)$(e[0]).css({width:a.width,height:a.height});d._updateCache(a);d._propagate("resize",b)}})}});$.ui.plugin.add("resizable","containment",{start:function(b,c){var d=$(this).data("resizable"),o=d.options,el=d.element;var e=o.containment,ce=(e instanceof $)?e.get(0):(/parent/.test(e))?el.parent().get(0):e;if(!ce)return;d.containerElement=$(ce);if(/document/.test(e)||e==document){d.containerOffset={left:0,top:0};d.containerPosition={left:0,top:0};d.parentData={element:$(document),left:0,top:0,width:$(document).width(),height:$(document).height()||document.body.parentNode.scrollHeight}}else{var f=$(ce),p=[];$(["Top","Right","Left","Bottom"]).each(function(i,a){p[i]=k(f.css("padding"+a))});d.containerOffset=f.offset();d.containerPosition=f.position();d.containerSize={height:(f.innerHeight()-p[3]),width:(f.innerWidth()-p[1])};var g=d.containerOffset,ch=d.containerSize.height,cw=d.containerSize.width,width=($.ui.hasScroll(ce,"left")?ce.scrollWidth:cw),height=($.ui.hasScroll(ce)?ce.scrollHeight:ch);d.parentData={element:ce,left:g.left,top:g.top,width:width,height:height}}},resize:function(a,b){var c=$(this).data("resizable"),o=c.options,ps=c.containerSize,co=c.containerOffset,cs=c.size,cp=c.position,pRatio=c._aspectRatio||a.shiftKey,cop={top:0,left:0},ce=c.containerElement;if(ce[0]!=document&&(/static/).test(ce.css('position')))cop=co;if(cp.left<(c._helper?co.left:0)){c.size.width=c.size.width+(c._helper?(c.position.left-co.left):(c.position.left-cop.left));if(pRatio)c.size.height=c.size.width/o.aspectRatio;c.position.left=o.helper?co.left:0}if(cp.top<(c._helper?co.top:0)){c.size.height=c.size.height+(c._helper?(c.position.top-co.top):c.position.top);if(pRatio)c.size.width=c.size.height*o.aspectRatio;c.position.top=c._helper?co.top:0}c.offset.left=c.parentData.left+c.position.left;c.offset.top=c.parentData.top+c.position.top;var d=Math.abs((c._helper?c.offset.left-cop.left:(c.offset.left-cop.left))+c.sizeDiff.width),hoset=Math.abs((c._helper?c.offset.top-cop.top:(c.offset.top-co.top))+c.sizeDiff.height);var e=c.containerElement.get(0)==c.element.parent().get(0),isOffsetRelative=/relative|absolute/.test(c.containerElement.css('position'));if(e&&isOffsetRelative)d-=c.parentData.left;if(d+c.size.width>=c.parentData.width){c.size.width=c.parentData.width-d;if(pRatio)c.size.height=c.size.width/c.aspectRatio}if(hoset+c.size.height>=c.parentData.height){c.size.height=c.parentData.height-hoset;if(pRatio)c.size.width=c.size.height*c.aspectRatio}},stop:function(a,b){var c=$(this).data("resizable"),o=c.options,cp=c.position,co=c.containerOffset,cop=c.containerPosition,ce=c.containerElement;var d=$(c.helper),ho=d.offset(),w=d.outerWidth()-c.sizeDiff.width,h=d.outerHeight()-c.sizeDiff.height;if(c._helper&&!o.animate&&(/relative/).test(ce.css('position')))$(this).css({left:ho.left-cop.left-co.left,width:w,height:h});if(c._helper&&!o.animate&&(/static/).test(ce.css('position')))$(this).css({left:ho.left-cop.left-co.left,width:w,height:h})}});$.ui.plugin.add("resizable","ghost",{start:function(a,b){var c=$(this).data("resizable"),o=c.options,cs=c.size;c.ghost=c.originalElement.clone();c.ghost.css({opacity:.25,display:'block',position:'relative',height:cs.height,width:cs.width,margin:0,left:0,top:0}).addClass('ui-resizable-ghost').addClass(typeof o.ghost=='string'?o.ghost:'');c.ghost.appendTo(c.helper)},resize:function(a,b){var c=$(this).data("resizable"),o=c.options;if(c.ghost)c.ghost.css({position:'relative',height:c.size.height,width:c.size.width})},stop:function(a,b){var c=$(this).data("resizable"),o=c.options;if(c.ghost&&c.helper)c.helper.get(0).removeChild(c.ghost.get(0))}});$.ui.plugin.add("resizable","grid",{resize:function(b,c){var d=$(this).data("resizable"),o=d.options,cs=d.size,os=d.originalSize,op=d.originalPosition,a=d.axis,ratio=o._aspectRatio||b.shiftKey;o.grid=typeof o.grid=="number"?[o.grid,o.grid]:o.grid;var e=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);if(/^(se|s|e)$/.test(a)){d.size.width=os.width+e;d.size.height=os.height+oy}else if(/^(ne)$/.test(a)){d.size.width=os.width+e;d.size.height=os.height+oy;d.position.top=op.top-oy}else if(/^(sw)$/.test(a)){d.size.width=os.width+e;d.size.height=os.height+oy;d.position.left=op.left-e}else{d.size.width=os.width+e;d.size.height=os.height+oy;d.position.top=op.top-oy;d.position.left=op.left-e}}});var k=function(v){return parseInt(v,10)||0};var l=function(a){return!isNaN(parseInt(a,10))}})(jQuery);

