(function(){var h=tinymce.DOM,f=tinymce.dom.Event,g=tinymce.each,e=tinymce.explode;tinymce.create("tinymce.plugins.TabFocusPlugin",{init:function(c,b){function d(l,k){if(k.keyCode===9){return f.cancel(k)}}function a(r,v){var t,i,w,x,s;function u(j){w=h.getParent(r.id,"form");x=w.elements;if(w){g(x,function(k,l){if(k.id==r.id){t=l;return false}});if(j>0){for(i=t+1;i<x.length;i++){if(x[i].type!="hidden"){return x[i]}}}else{for(i=t-1;i>=0;i--){if(x[i].type!="hidden"){return x[i]}}}}return null}if(v.keyCode===9){s=e(r.getParam("tab_focus",r.getParam("tabfocus_elements",":prev,:next")));if(s.length==1){s[1]=s[0];s[0]=":prev"}if(v.shiftKey){if(s[0]==":prev"){x=u(-1)}else{x=h.get(s[0])}}else{if(s[1]==":next"){x=u(1)}else{x=h.get(s[1])}}if(x){if(r=tinymce.get(x.id||x.name)){r.focus()}else{window.setTimeout(function(){window.focus();x.focus()},10)}return f.cancel(v)}}}c.onKeyUp.add(d);if(tinymce.isGecko){c.onKeyPress.add(a);c.onKeyDown.add(d)}else{c.onKeyDown.add(a)}c.onInit.add(function(){g(h.select("a:first,a:last",c.getContainer()),function(j){f.add(j,"focus",function(){c.focus()})})})},getInfo:function(){return{longname:"Tabfocus",author:"Moxiecode Systems AB",authorurl:"http://tinymce.moxiecode.com",infourl:"http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/tabfocus",version:tinymce.majorVersion+"."+tinymce.minorVersion}}});tinymce.PluginManager.add("tabfocus",tinymce.plugins.TabFocusPlugin)})();