/*
 * jQuery UI Resizable 1.6rc5
 *
 * Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.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(b){b.widget("ui.resizable",b.extend({},b.ui.mouse,{_init:function(){var q=this,r=this.options;var u=this.element.css("position");this.originalElement=this.element;this.element.addClass("ui-resizable").css({position:/static/.test(u)?"relative":u});b.extend(r,{_aspectRatio:!!(r.aspectRatio),helper:r.helper||r.ghost||r.animate?r.helper||"ui-resizable-helper":null,knobHandles:r.knobHandles===true?"ui-resizable-knob-handle":r.knobHandles});var j="1px solid #DEDEDE";r.defaultTheme={"ui-resizable":{display:"block"},"ui-resizable-handle":{position:"absolute",background:"#F2F2F2",fontSize:"0.1px"},"ui-resizable-n":{cursor:"n-resize",height:"4px",left:"0px",right:"0px",borderTop:j},"ui-resizable-s":{cursor:"s-resize",height:"4px",left:"0px",right:"0px",borderBottom:j},"ui-resizable-e":{cursor:"e-resize",width:"4px",top:"0px",bottom:"0px",borderRight:j},"ui-resizable-w":{cursor:"w-resize",width:"4px",top:"0px",bottom:"0px",borderLeft:j},"ui-resizable-se":{cursor:"se-resize",width:"4px",height:"4px",borderRight:j,borderBottom:j},"ui-resizable-sw":{cursor:"sw-resize",width:"4px",height:"4px",borderBottom:j,borderLeft:j},"ui-resizable-ne":{cursor:"ne-resize",width:"4px",height:"4px",borderRight:j,borderTop:j},"ui-resizable-nw":{cursor:"nw-resize",width:"4px",height:"4px",borderLeft:j,borderTop:j}};r.knobTheme={"ui-resizable-handle":{background:"#F2F2F2",border:"1px solid #808080",height:"8px",width:"8px"},"ui-resizable-n":{cursor:"n-resize",top:"0px",left:"45%"},"ui-resizable-s":{cursor:"s-resize",bottom:"0px",left:"45%"},"ui-resizable-e":{cursor:"e-resize",right:"0px",top:"45%"},"ui-resizable-w":{cursor:"w-resize",left:"0px",top:"45%"},"ui-resizable-se":{cursor:"se-resize",right:"0px",bottom:"0px"},"ui-resizable-sw":{cursor:"sw-resize",left:"0px",bottom:"0px"},"ui-resizable-nw":{cursor:"nw-resize",left:"0px",top:"0px"},"ui-resizable-ne":{cursor:"ne-resize",right:"0px",top:"0px"}};r._nodeName=this.element[0].nodeName;if(r._nodeName.match(/canvas|textarea|input|select|button|img/i)){var c=this.element;if(/relative/.test(c.css("position"))&&b.browser.opera){c.css({position:"relative",top:"auto",left:"auto"})}c.wrap(b('<div class="ui-wrapper"	style="overflow: hidden;"></div>').css({position:c.css("position"),width:c.outerWidth(),height:c.outerHeight(),top:c.css("top"),left:c.css("left")}));var l=this.element;this.element=this.element.parent();this.element.data("resizable",this);this.element.css({marginLeft:l.css("marginLeft"),marginTop:l.css("marginTop"),marginRight:l.css("marginRight"),marginBottom:l.css("marginBottom")});l.css({marginLeft:0,marginTop:0,marginRight:0,marginBottom:0});if(b.browser.safari&&r.preventDefault){l.css("resize","none")}r.proportionallyResize=l.css({position:"static",zoom:1,display:"block"});this.element.css({margin:l.css("margin")});this._proportionallyResize()}if(!r.handles){r.handles=!b(".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(r.handles.constructor==String){r.zIndex=r.zIndex||1000;if(r.handles=="all"){r.handles="n,e,s,w,se,sw,ne,nw"}var s=r.handles.split(",");r.handles={};var h={handle:"position: absolute; display: none; overflow:hidden;",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 v=0;v<s.length;v++){var w=b.trim(s[v]),p=r.defaultTheme,g="ui-resizable-"+w,d=!b.ui.css(g)&&!r.knobHandles,t=b.ui.css("ui-resizable-knob-handle"),x=b.extend(p[g],p["ui-resizable-handle"]),e=b.extend(r.knobTheme[g],!t?r.knobTheme["ui-resizable-handle"]:{});var m=/sw|se|ne|nw/.test(w)?{zIndex:++r.zIndex}:{};var k=(d?h[w]:""),f=b(['<div class="ui-resizable-handle ',g,'" style="',k,h.handle,'"></div>'].join("")).css(m);if("se"==w){f.addClass("ui-icon ui-icon-gripsmall-diagonal-se")}r.handles[w]=".ui-resizable-"+w;this.element.append(f.css(d?x:{}).css(r.knobHandles?e:{}).addClass(r.knobHandles?"ui-resizable-knob-handle":"").addClass(r.knobHandles))}if(r.knobHandles){this.element.addClass("ui-resizable-knob").css(!b.ui.css("ui-resizable-knob")?{}:{})}}this._renderAxis=function(A){A=A||this.element;for(var o in r.handles){if(r.handles[o].constructor==String){r.handles[o]=b(r.handles[o],this.element).show()}if(r.transparent){r.handles[o].css({opacity:0})}if(this.element.is(".ui-wrapper")&&r._nodeName.match(/textarea|input|select|button/i)){var y=b(r.handles[o],this.element),z=0;z=/sw|ne|nw|se|n|s/.test(o)?y.outerHeight():y.outerWidth();var n=["padding",/ne|nw|n/.test(o)?"Top":/se|sw|s/.test(o)?"Bottom":/^e$/.test(o)?"Right":"Left"].join("");if(!r.transparent){A.css(n,z)}this._proportionallyResize()}if(!b(r.handles[o]).length){continue}}};this._renderAxis(this.element);r._handles=b(".ui-resizable-handle",q.element);if(r.disableSelection){r._handles.disableSelection()}r._handles.mouseover(function(){if(!r.resizing){if(this.className){var i=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i)}q.axis=r.axis=i&&i[1]?i[1]:"se"}});if(r.autoHide){r._handles.hide();b(q.element).addClass("ui-resizable-autohide").hover(function(){b(this).removeClass("ui-resizable-autohide");r._handles.show()},function(){if(!r.resizing){b(this).addClass("ui-resizable-autohide");r._handles.hide()}})}this._mouseInit()},destroy:function(){var e=this.element,d=e.children(".ui-resizable").get(0);this._mouseDestroy();var c=function(f){b(f).removeClass("ui-resizable ui-resizable-disabled").removeData("resizable").unbind(".resizable").find(".ui-resizable-handle").remove()};c(e);if(e.is(".ui-wrapper")&&d){e.parent().append(b(d).css({position:e.css("position"),width:e.outerWidth(),height:e.outerHeight(),top:e.css("top"),left:e.css("left")})).end().remove();c(d)}},_mouseCapture:function(d){if(this.options.disabled){return false}var e=false;for(var c in this.options.handles){if(b(this.options.handles[c])[0]==d.target){e=true}}if(!e){return false}return true},_mouseStart:function(d){var e=this.options,c=this.element.position(),f=this.element,j=function(o){return parseInt(o,10)||0},i=b.browser.msie&&b.browser.version<7;e.resizing=true;e.documentScroll={top:b(document).scrollTop(),left:b(document).scrollLeft()};if(f.is(".ui-draggable")||(/absolute/).test(f.css("position"))){var l=b.browser.msie&&!e.containment&&(/absolute/).test(f.css("position"))&&!(/relative/).test(f.parent().css("position"));var m=l?e.documentScroll.top:0,h=l?e.documentScroll.left:0;f.css({position:"absolute",top:(c.top+m),left:(c.left+h)})}if(b.browser.opera&&(/relative/).test(f.css("position"))){f.css({position:"relative",top:"auto",left:"auto"})}this._renderProxy();var n=j(this.helper.css("left")),g=j(this.helper.css("top"));if(e.containment){n+=b(e.containment).scrollLeft()||0;g+=b(e.containment).scrollTop()||0}this.offset=this.helper.offset();this.position={left:n,top:g};this.size=e.helper||i?{width:f.outerWidth(),height:f.outerHeight()}:{width:f.width(),height:f.height()};this.originalSize=e.helper||i?{width:f.outerWidth(),height:f.outerHeight()}:{width:f.width(),height:f.height()};this.originalPosition={left:n,top:g};this.sizeDiff={width:f.outerWidth()-f.width(),height:f.outerHeight()-f.height()};this.originalMousePosition={left:d.pageX,top:d.pageY};e.aspectRatio=(typeof e.aspectRatio=="number")?e.aspectRatio:((this.originalSize.width/this.originalSize.height)||1);if(e.preserveCursor){var k=b(".ui-resizable-"+this.axis).css("cursor");b("body").css("cursor",k=="auto"?this.axis+"-resize":k)}this._propagate("start",d);return true},_mouseDrag:function(c){var f=this.helper,e=this.options,k={},n=this,h=this.originalMousePosition,l=this.axis;var p=(c.pageX-h.left)||0,m=(c.pageY-h.top)||0;var g=this._change[l];if(!g){return false}var j=g.apply(this,[c,p,m]),i=b.browser.msie&&b.browser.version<7,d=this.sizeDiff;if(e._aspectRatio||c.shiftKey){j=this._updateRatio(j,c)}j=this._respectSize(j,c);this._propagate("resize",c);f.css({top:this.position.top+"px",left:this.position.left+"px",width:this.size.width+"px",height:this.size.height+"px"});if(!e.helper&&e.proportionallyResize){this._proportionallyResize()}this._updateCache(j);this._trigger("resize",c,this.ui());return false},_mouseStop:function(f){this.options.resizing=false;var g=this.options,j=function(n){return parseInt(n,10)||0},l=this;if(g.helper){var e=g.proportionallyResize,c=e&&(/textarea/i).test(e.get(0).nodeName),d=c&&b.ui.hasScroll(e.get(0),"left")?0:l.sizeDiff.height,i=c?0:l.sizeDiff.width;var m={width:(l.size.width-i),height:(l.size.height-d)},h=(parseInt(l.element.css("left"),10)+(l.position.left-l.originalPosition.left))||null,k=(parseInt(l.element.css("top"),10)+(l.position.top-l.originalPosition.top))||null;if(!g.animate){this.element.css(b.extend(m,{top:k,left:h}))}if(g.helper&&!g.animate){this._proportionallyResize()}}if(g.preserveCursor){b("body").css("cursor","auto")}this._propagate("stop",f);if(g.helper){this.helper.remove()}return false},_updateCache:function(c){var d=this.options;this.offset=this.helper.offset();if(c.left){this.position.left=c.left}if(c.top){this.position.top=c.top}if(c.height){this.size.height=c.height}if(c.width){this.size.width=c.width}},_updateRatio:function(f,e){var g=this.options,h=this.position,d=this.size,c=this.axis;if(f.height){f.width=(d.height*g.aspectRatio)}else{if(f.width){f.height=(d.width/g.aspectRatio)}}if(c=="sw"){f.left=h.left+(d.width-f.width);f.top=null}if(c=="nw"){f.top=h.top+(d.height-f.height);f.left=h.left+(d.width-f.width)}return f},_respectSize:function(j,e){var h=this.helper,g=this.options,p=g._aspectRatio||e.shiftKey,n=this.axis,r=j.width&&g.maxWidth&&g.maxWidth<j.width,k=j.height&&g.maxHeight&&g.maxHeight<j.height,f=j.width&&g.minWidth&&g.minWidth>j.width,q=j.height&&g.minHeight&&g.minHeight>j.height;if(f){j.width=g.minWidth}if(q){j.height=g.minHeight}if(r){j.width=g.maxWidth}if(k){j.height=g.maxHeight}var d=this.originalPosition.left+this.originalSize.width,m=this.position.top+this.size.height;var i=/sw|nw|w/.test(n),c=/nw|ne|n/.test(n);if(f&&i){j.left=d-g.minWidth}if(r&&i){j.left=d-g.maxWidth}if(q&&c){j.top=m-g.minHeight}if(k&&c){j.top=m-g.maxHeight}var l=!j.width&&!j.height;if(l&&!j.left&&j.top){j.top=null}else{if(l&&!j.top&&j.left){j.left=null}}return j},_proportionallyResize:function(){var g=this.options;if(!g.proportionallyResize){return}var e=g.proportionallyResize,d=this.helper||this.element;if(!g.borderDif){var c=[e.css("borderTopWidth"),e.css("borderRightWidth"),e.css("borderBottomWidth"),e.css("borderLeftWidth")],f=[e.css("paddingTop"),e.css("paddingRight"),e.css("paddingBottom"),e.css("paddingLeft")];g.borderDif=b.map(c,function(h,k){var j=parseInt(h,10)||0,l=parseInt(f[k],10)||0;return j+l})}if(b.browser.msie&&!a(d)){return}e.css({height:(d.height()-g.borderDif[0]-g.borderDif[2])||0,width:(d.width()-g.borderDif[1]-g.borderDif[3])||0})},_renderProxy:function(){var d=this.element,g=this.options;this.elementOffset=d.offset();if(g.helper){this.helper=this.helper||b('<div style="overflow:hidden;"></div>');var c=b.browser.msie&&b.browser.version<7,e=(c?1:0),f=(c?2:-1);this.helper.addClass(g.helper).css({width:d.outerWidth()+f,height:d.outerHeight()+f,position:"absolute",left:this.elementOffset.left-e+"px",top:this.elementOffset.top-e+"px",zIndex:++g.zIndex});this.helper.appendTo("body");if(g.disableSelection){this.helper.disableSelection()}}else{this.helper=d}},_change:{e:function(e,d,c){return{width:this.originalSize.width+d}},w:function(f,d,c){var h=this.options,e=this.originalSize,g=this.originalPosition;return{left:g.left+d,width:e.width-d}},n:function(f,d,c){var h=this.options,e=this.originalSize,g=this.originalPosition;return{top:g.top+c,height:e.height-c}},s:function(e,d,c){return{height:this.originalSize.height+c}},se:function(e,d,c){return b.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[e,d,c]))},sw:function(e,d,c){return b.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[e,d,c]))},ne:function(e,d,c){return b.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[e,d,c]))},nw:function(e,d,c){return b.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[e,d,c]))}},_propagate:function(d,c){b.ui.plugin.call(this,d,[c,this.ui()]);(d!="resize"&&this._trigger(d,c,this.ui()))},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,options:this.options,originalSize:this.originalSize,originalPosition:this.originalPosition}}}));b.extend(b.ui.resizable,{version:"1.6rc5",eventPrefix:"resize",defaults:{alsoResize:false,animate:false,animateDuration:"slow",animateEasing:"swing",aspectRatio:false,autoHide:false,cancel:":input,option",containment:false,delay:0,disableSelection:true,distance:1,ghost:false,grid:false,knobHandles:false,maxHeight:null,maxWidth:null,minHeight:10,minWidth:10,preserveCursor:true,preventDefault:true,proportionallyResize:false,transparent:false}});b.ui.plugin.add("resizable","alsoResize",{start:function(d,e){var g=e.options,c=b(this).data("resizable"),f=function(h){b(h).each(function(){b(this).data("resizable-alsoresize",{width:parseInt(b(this).width(),10),height:parseInt(b(this).height(),10),left:parseInt(b(this).css("left"),10),top:parseInt(b(this).css("top"),10)})})};if(typeof(g.alsoResize)=="object"&&!g.alsoResize.parentNode){if(g.alsoResize.length){g.alsoResize=g.alsoResize[0];f(g.alsoResize)}else{b.each(g.alsoResize,function(h,i){f(h)})}}else{f(g.alsoResize)}},resize:function(e,g){var h=g.options,d=b(this).data("resizable"),f=d.originalSize,j=d.originalPosition;var i={height:(d.size.height-f.height)||0,width:(d.size.width-f.width)||0,top:(d.position.top-j.top)||0,left:(d.position.left-j.left)||0},c=function(k,l){b(k).each(function(){var o=b(this),p=b(this).data("resizable-alsoresize"),n={},m=l&&l.length?l:["width","height","top","left"];b.each(m||["width","height","top","left"],function(q,s){var r=(p[s]||0)+(i[s]||0);if(r&&r>=0){n[s]=r||null}});if(/relative/.test(o.css("position"))&&b.browser.opera){d._revertToRelativePosition=true;o.css({position:"absolute",top:"auto",left:"auto"})}o.css(n)})};if(typeof(h.alsoResize)=="object"&&!h.alsoResize.nodeType){b.each(h.alsoResize,function(k,l){c(k,l)})}else{c(h.alsoResize)}},stop:function(d,e){var c=b(this).data("resizable");if(c._revertToRelativePosition&&b.browser.opera){c._revertToRelativePosition=false;el.css({position:"relative"})}b(this).removeData("resizable-alsoresize-start")}});b.ui.plugin.add("resizable","animate",{stop:function(g,l){var h=l.options,m=b(this).data("resizable");var f=h.proportionallyResize,c=f&&(/textarea/i).test(f.get(0).nodeName),d=c&&b.ui.hasScroll(f.get(0),"left")?0:m.sizeDiff.height,j=c?0:m.sizeDiff.width;var e={width:(m.size.width-j),height:(m.size.height-d)},i=(parseInt(m.element.css("left"),10)+(m.position.left-m.originalPosition.left))||null,k=(parseInt(m.element.css("top"),10)+(m.position.top-m.originalPosition.top))||null;m.element.animate(b.extend(e,k&&i?{top:k,left:i}:{}),{duration:h.animateDuration,easing:h.animateEasing,step:function(){var n={width:parseInt(m.element.css("width"),10),height:parseInt(m.element.css("height"),10),top:parseInt(m.element.css("top"),10),left:parseInt(m.element.css("left"),10)};if(f){f.css({width:n.width,height:n.height})}m._updateCache(n);m._propagate("resize",g)}})}});b.ui.plugin.add("resizable","containment",{start:function(d,l){var g=l.options,n=b(this).data("resizable"),i=n.element;var e=g.containment,h=(e instanceof b)?e.get(0):(/parent/.test(e))?i.parent().get(0):e;if(!h){return}n.containerElement=b(h);if(/document/.test(e)||e==document){n.containerOffset={left:0,top:0};n.containerPosition={left:0,top:0};n.parentData={element:b(document),left:0,top:0,width:b(document).width(),height:b(document).height()||document.body.parentNode.scrollHeight}}else{n.containerOffset=b(h).offset();n.containerPosition=b(h).position();n.containerSize={height:b(h).innerHeight(),width:b(h).innerWidth()};var k=n.containerOffset,c=n.containerSize.height,j=n.containerSize.width,f=(b.ui.hasScroll(h,"left")?h.scrollWidth:j),m=(b.ui.hasScroll(h)?h.scrollHeight:c);n.parentData={element:h,left:k.left,top:k.top,width:f,height:m}}},resize:function(e,l){var g=l.options,p=b(this).data("resizable"),d=p.containerSize,k=p.containerOffset,i=p.size,j=p.position,m=g._aspectRatio||e.shiftKey,c={top:0,left:0},f=p.containerElement;if(f[0]!=document&&(/static/).test(f.css("position"))){c=p.containerPosition}if(j.left<(g.helper?k.left:0)){p.size.width=p.size.width+(g.helper?(p.position.left-k.left):(p.position.left-c.left));if(m){p.size.height=p.size.width/g.aspectRatio}p.position.left=g.helper?k.left:0}if(j.top<(g.helper?k.top:0)){p.size.height=p.size.height+(g.helper?(p.position.top-k.top):p.position.top);if(m){p.size.width=p.size.height*g.aspectRatio}p.position.top=g.helper?k.top:0}var h=Math.abs((g.helper?p.offset.left-c.left:(p.offset.left-c.left))+p.sizeDiff.width),n=Math.abs((g.helper?p.offset.top-c.top:(p.offset.top-k.top))+p.sizeDiff.height);if(h+p.size.width>=p.parentData.width){p.size.width=p.parentData.width-h;if(m){p.size.height=p.size.width/g.aspectRatio}}if(n+p.size.height>=p.parentData.height){p.size.height=p.parentData.height-n;if(m){p.size.width=p.size.height*g.aspectRatio}}},stop:function(d,l){var e=l.options,n=b(this).data("resizable"),j=n.position,k=n.containerOffset,c=n.containerPosition,f=n.containerElement;var g=b(n.helper),p=g.offset(),m=g.outerWidth()-n.sizeDiff.width,i=g.outerHeight()-n.sizeDiff.height;if(e.helper&&!e.animate&&(/relative/).test(f.css("position"))){b(this).css({left:p.left-c.left-k.left,width:m,height:i})}if(e.helper&&!e.animate&&(/static/).test(f.css("position"))){b(this).css({left:p.left-c.left-k.left,width:m,height:i})}}});b.ui.plugin.add("resizable","ghost",{start:function(e,f){var g=f.options,c=b(this).data("resizable"),h=g.proportionallyResize,d=c.size;if(!h){c.ghost=c.element.clone()}else{c.ghost=h.clone()}c.ghost.css({opacity:0.25,display:"block",position:"relative",height:d.height,width:d.width,margin:0,left:0,top:0}).addClass("ui-resizable-ghost").addClass(typeof g.ghost=="string"?g.ghost:"");c.ghost.appendTo(c.helper)},resize:function(d,e){var f=e.options,c=b(this).data("resizable"),g=f.proportionallyResize;if(c.ghost){c.ghost.css({position:"relative",height:c.size.height,width:c.size.width})}},stop:function(d,e){var f=e.options,c=b(this).data("resizable"),g=f.proportionallyResize;if(c.ghost&&c.helper){c.helper.get(0).removeChild(c.ghost.get(0))}}});b.ui.plugin.add("resizable","grid",{resize:function(c,k){var f=k.options,m=b(this).data("resizable"),i=m.size,g=m.originalSize,h=m.originalPosition,l=m.axis,j=f._aspectRatio||c.shiftKey;f.grid=typeof f.grid=="number"?[f.grid,f.grid]:f.grid;var e=Math.round((i.width-g.width)/(f.grid[0]||1))*(f.grid[0]||1),d=Math.round((i.height-g.height)/(f.grid[1]||1))*(f.grid[1]||1);if(/^(se|s|e)$/.test(l)){m.size.width=g.width+e;m.size.height=g.height+d}else{if(/^(ne)$/.test(l)){m.size.width=g.width+e;m.size.height=g.height+d;m.position.top=h.top-d}else{if(/^(sw)$/.test(l)){m.size.width=g.width+e;m.size.height=g.height+d;m.position.left=h.left-e}else{m.size.width=g.width+e;m.size.height=g.height+d;m.position.top=h.top-d;m.position.left=h.left-e}}}}});function a(c){return !(b(c).is(":hidden")||b(c).parents(":hidden").length)}})(jQuery);