(function(){var a={editorFocus:false,modes:{wysiwyg:1,source:1}},b={exec:function(e){e.container.focusNext(true,e.tabIndex);}},c={exec:function(e){e.container.focusPrevious(true,e.tabIndex);}};function d(e){return{editorFocus:false,canUndo:false,modes:{wysiwyg:1},exec:function(f){if(f.focusManager.hasFocus){var g=f.getSelection(),h=g.getCommonAncestor(),i;if(i=h.getAscendant('td',true)||h.getAscendant('th',true)){var j=new CKEDITOR.dom.range(f.document),k=CKEDITOR.tools.tryThese(function(){var r=i.getParent(),s=r.$.cells[i.$.cellIndex+(e?-1:1)];s.parentNode.parentNode;return s;},function(){var r=i.getParent(),s=r.getAscendant('table'),t=s.$.rows[r.$.rowIndex+(e?-1:1)];return t.cells[e?t.cells.length-1:0];});if(!(k||e)){var l=i.getAscendant('table').$,m=i.getParent().$.cells,n=new CKEDITOR.dom.element(l.insertRow(-1),f.document);for(var o=0,p=m.length;o<p;o++){var q=n.append(new CKEDITOR.dom.element(m[o],f.document).clone(false,false));!CKEDITOR.env.ie&&q.appendBogus();}j.moveToElementEditStart(n);}else if(k){k=new CKEDITOR.dom.element(k);j.moveToElementEditStart(k);if(!(j.checkStartOfBlock()&&j.checkEndOfBlock()))j.selectNodeContents(k);}else return true;j.select(true);return true;}}return false;}};};CKEDITOR.plugins.add('tab',{requires:['keystrokes'],init:function(e){var f=e.config.enableTabKeyTools!==false,g=e.config.tabSpaces||0,h=e.config.tabText||'\xa0',i='';while(g--)i+=h;if(f)e.on('key',function(j){if(j.data.keyCode==9&&e.execCommand('selectNextCell')||j.data.keyCode==CKEDITOR.SHIFT+9&&e.execCommand('selectPreviousCell'))j.cancel();});if(i)e.on('key',function(j){if(j.data.keyCode==9){e.insertHtml(i);j.cancel();}});if(f)e.on('key',function(j){if(j.data.keyCode==9&&e.execCommand('selectNextCell')||j.data.keyCode==CKEDITOR.SHIFT+9&&e.execCommand('selectPreviousCell'))j.cancel();});if(CKEDITOR.env.webkit||CKEDITOR.env.gecko)e.on('key',function(j){var k=j.data.keyCode;if(k==9&&!i){j.cancel();e.execCommand('blur');}if(k==CKEDITOR.SHIFT+9){e.execCommand('blurBack');j.cancel();}});e.addCommand('blur',CKEDITOR.tools.extend(b,a));e.addCommand('blurBack',CKEDITOR.tools.extend(c,a));e.addCommand('selectNextCell',d());e.addCommand('selectPreviousCell',d(true));}});})();CKEDITOR.dom.element.prototype.focusNext=function(a,b){var k=this;var c=k.$,d=b===undefined?k.getTabIndex():b,e,f,g,h,i,j;if(d<=0){i=k.getNextSourceNode(a,CKEDITOR.NODE_ELEMENT);while(i){if(i.isVisible()&&i.getTabIndex()===0){g=i;break;}i=i.getNextSourceNode(false,CKEDITOR.NODE_ELEMENT);}}else{i=k.getDocument().getBody().getFirst();
while(i=i.getNextSourceNode(false,CKEDITOR.NODE_ELEMENT)){if(!e)if(!f&&i.equals(k)){f=true;if(a){if(!(i=i.getNextSourceNode(true,CKEDITOR.NODE_ELEMENT)))break;e=1;}}else if(f&&!k.contains(i))e=1;if(!i.isVisible()||(j=i.getTabIndex())<0)continue;if(e&&j==d){g=i;break;}if(j>d&&(!g||!h||j<h)){g=i;h=j;}else if(!g&&j===0){g=i;h=j;}}}if(g)g.focus();};CKEDITOR.dom.element.prototype.focusPrevious=function(a,b){var k=this;var c=k.$,d=b===undefined?k.getTabIndex():b,e,f,g,h=0,i,j=k.getDocument().getBody().getLast();while(j=j.getPreviousSourceNode(false,CKEDITOR.NODE_ELEMENT)){if(!e)if(!f&&j.equals(k)){f=true;if(a){if(!(j=j.getPreviousSourceNode(true,CKEDITOR.NODE_ELEMENT)))break;e=1;}}else if(f&&!k.contains(j))e=1;if(!j.isVisible()||(i=j.getTabIndex())<0)continue;if(d<=0){if(e&&i===0){g=j;break;}if(i>h){g=j;h=i;}}else{if(e&&i==d){g=j;break;}if(i<d&&(!g||i>h)){g=j;h=i;}}}if(g)g.focus();};
