!function(){function e(e){return CKEDITOR.env.ie?e.$.clientWidth:parseInt(e.getComputedStyle("width"),10)}function t(e,t){var n=e.getComputedStyle("border-"+t+"-width"),o={thin:"0px",medium:"1px",thick:"2px"};return 0>n.indexOf("px")&&(n=n in o&&"none"!=e.getComputedStyle("border-style")?o[n]:0),parseInt(n,10)}function n(e){(e.data||e).preventDefault()}function o(o){function i(){f=0,c.setOpacity(0),p&&l();var e=m.table;setTimeout((function(){e.removeCustomData("_cke_table_pillars")}),0),h.removeListener("dragstart",n)}function l(){for(var n=m.rtl,i=n?b.length:y.length,r=0,l=0;l<i;l++){var s=y[l],u=b[l],d=m.table;CKEDITOR.tools.setTimeout((function(e,t,l,s,u,m){e&&e.setStyle("width",a(Math.max(t+m,1))),l&&l.setStyle("width",a(Math.max(s-m,1))),u&&d.setStyle("width",a(u+m*(n?-1:1))),++r==i&&o.fire("saveSnapshot")}),0,this,[s,s&&e(s),u,u&&e(u),(!s||!u)&&e(d)+t(d,"left")+t(d,"right"),p])}}function s(t){n(t),o.fire("saveSnapshot"),t=m.index;for(var i=CKEDITOR.tools.buildTableMap(m.table),a=[],r=[],l=Number.MAX_VALUE,s=l,v=m.rtl,C=0,T=i.length;C<T;C++){var E=(O=i[C])[t+(v?1:0)],O=O[t+(v?0:1)];E=E&&new CKEDITOR.dom.element(E),O=O&&new CKEDITOR.dom.element(O);E&&O&&E.equals(O)||(E&&(l=Math.min(l,e(E))),O&&(s=Math.min(s,e(O))),a.push(E),r.push(O))}y=a,b=r,D=m.x-l,x=m.x+s,c.setOpacity(.5),g=parseInt(c.getStyle("left"),10),p=0,f=1,c.on("mousemove",d),h.on("dragstart",n),h.on("mouseup",u,this)}function u(e){e.removeListener(),i()}function d(e){v(e.data.getPageOffset().x)}var m,h,c,f,g,p,v,y,b,D,x;h=o.document,c=CKEDITOR.dom.element.createFromHtml('<div data-cke-temp=1 contenteditable=false unselectable=on style="position:absolute;cursor:col-resize;filter:alpha(opacity=0);opacity:0;padding:0;background-color:#004;background-image:none;border:0px none;z-index:10"></div>',h),o.on("destroy",(function(){c.remove()})),r||h.getDocumentElement().append(c),this.attachTo=function(e){var t,n,o;f||(r&&(h.getBody().append(c),p=0),t=(m=e).alignedPillars[0],n=m.alignedPillars[m.alignedPillars.length-1],o=t.y,t=n.height+n.y-t.y,c.setStyles({width:a(e.width),height:a(t),left:a(e.x),top:a(o)}),r&&c.setOpacity(.25),c.on("mousedown",s,this),h.getBody().setStyle("cursor","col-resize"),c.show())},v=this.move=function(e,t){if(!m)return 0;if(!(f||e>=m.x&&e<=m.x+m.width&&t>=m.y&&t<=m.y+m.height))return m=null,f=p=0,h.removeListener("mouseup",u),c.removeListener("mousedown",s),c.removeListener("mousemove",d),h.getBody().setStyle("cursor","auto"),r?c.remove():c.hide(),0;var n=e-Math.round(c.$.offsetWidth/2);if(f){if(n==D||n==x)return 1;n=Math.max(n,D),n=Math.min(n,x),p=n-g}return c.setStyle("left",a(n)),1}}function i(e){var t=e.data.getTarget();if("mouseout"==e.name){if(!t.is("table"))return;for(var n=new CKEDITOR.dom.element(e.data.$.relatedTarget||e.data.$.toElement);n&&n.$&&!n.equals(t)&&!n.is("body");)n=n.getParent();if(!n||n.equals(t))return}t.getAscendant("table",1).removeCustomData("_cke_table_pillars"),e.removeListener()}var a=CKEDITOR.tools.cssLength,r=CKEDITOR.env.ie&&(CKEDITOR.env.ie7Compat||CKEDITOR.env.quirks);CKEDITOR.plugins.add("tableresize",{requires:"tabletools",init:function(e){e.on("contentDom",(function(){var a,r=e.editable();r.attachListener(r.isInline()?r:e.document,"mousemove",(function(r){if((u=(r=r.data).getTarget()).type==CKEDITOR.NODE_ELEMENT){var l=r.getPageOffset().x,s=r.getPageOffset().y;if(a&&a.move(l,s))n(r);else if((u.is("table")||u.getAscendant({thead:1,tbody:1,tfoot:1},1))&&(r=u.getAscendant("table",1),e.editable().contains(r))){(u=r.getCustomData("_cke_table_pillars"))||(r.setCustomData("_cke_table_pillars",u=function(e){var n=[],o={},i="rtl"==e.getComputedStyle("direction");return CKEDITOR.tools.array.forEach(e.$.rows,(function(a,r){var l=-1,s=0,u=null;u=a?{height:(s=new CKEDITOR.dom.element(a)).$.offsetHeight,position:s.getDocumentPosition()}:void 0,s=u.height,u=u.position;for(var d=0,m=a.cells.length;d<m;d++){var h,c,f=new CKEDITOR.dom.element(a.cells[d]),g=a.cells[d+1]&&new CKEDITOR.dom.element(a.cells[d+1]),p=(l+=f.$.colSpan||1,f.getDocumentPosition().x);i?c=p+t(f,"left"):h=p+f.$.offsetWidth-t(f,"right"),g?(p=g.getDocumentPosition().x,i?h=p+g.$.offsetWidth-t(g,"right"):c=p+t(g,"left")):(p=e.getDocumentPosition().x,i?h=p:c=p+e.$.offsetWidth),f=Math.max(c-h,3),f={table:e,index:l,x:h,y:u.y,width:f,height:s,rtl:i},o[l]=o[l]||[],o[l].push(f),f.alignedPillars=o[l],n.push(f)}})),n}(r)),r.on("mouseout",i),r.on("mousedown",i));e:{r=u;for(var u=0,d=r.length;u<d;u++){var m=r[u];if(l>=m.x&&l<=m.x+m.width&&s>=m.y&&s<=m.y+m.height){l=m;break e}}l=null}l&&(!a&&(a=new o(e)),a.attachTo(l))}}}))}))}})}();