(function(){var a=tinymce.DOM,c=tinymce.dom.Event,b=tinymce.each,d=tinymce.explode;tinymce.create("tinymce.plugins.TabFocusPlugin",{init:function(h,e){function g(i,j){if(j.keyCode===9){return c.cancel(j)}}function f(q,l){var o,n,k,j,p;function m(i){k=a.getParent(q.id,"form");j=k.elements;if(k){b(j,function(s,r){if(s.id==q.id){o=r;return false}});if(i>0){for(n=o+1;n<j.length;n++){if(j[n].type!="hidden"){return j[n]}}}else{for(n=o-1;n>=0;n--){if(j[n].type!="hidden"){return j[n]}}}}return null}if(l.keyCode===9){p=d(q.getParam("tab_focus",q.getParam("tabfocus_elements",":prev,:next")));if(p.length==1){p[1]=p[0];p[0]=":prev"}if(l.shiftKey){if(p[0]==":prev"){j=m(-1)}else{j=a.get(p[0])}}else{if(p[1]==":next"){j=m(1)}else{j=a.get(p[1])}}if(j){if(q=tinymce.get(j.id||j.name)){q.focus()}else{window.setTimeout(function(){window.focus();j.focus()},10)}return c.cancel(l)}}}h.onKeyUp.add(g);if(tinymce.isGecko){h.onKeyPress.add(f);h.onKeyDown.add(g)}else{h.onKeyDown.add(f)}h.onInit.add(function(){b(a.select("a:first,a:last",h.getContainer()),function(i){c.add(i,"focus",function(){h.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)})();