(function(){tinymce.PluginManager.requireLangPack("grappelli");var a=tinymce.DOM;tinymce.create("tinymce.plugins.Grappelli",{init:function(b,c){var d=this;tb=b.getParam("grappelli_adv_toolbar","toolbar2");documentstructure_css=c+"../../../themes/advanced/skins/grappelli/content_documentstructure_"+b.settings.language+".css";cookie_date=new Date();var e=cookie_date.getFullYear();cookie_date.setYear(e+1);cookie_grappelli_show_documentstructure=tinymce.util.Cookie.get("grappelli_show_documentstructure");if(cookie_grappelli_show_documentstructure!=null){b.settings.grappelli_show_documentstructure=cookie_grappelli_show_documentstructure}else{tinymce.util.Cookie.set("grappelli_show_documentstructure",b.settings.grappelli_show_documentstructure,cookie_date,"/")}b.onInit.add(function(){if("mce_fullscreen"==b.id){b.dom.addClass(b.dom.select("body"),"fullscreen")}if(b.settings.grappelli_adv_hidden){d._hide_adv_menu(b)}else{d._show_adv_menu(b)}if(b.settings.grappelli_show_documentstructure=="on"){d._show_documentstructure(b)}else{d._hide_documentstructure(b)}});b.addCommand("Grappelli_Adv",function(){if(a.isHidden(b.controlManager.get(tb).id)){d._show_adv_menu(b)}else{d._hide_adv_menu(b)}});b.addCommand("Grappelli_DocumentStructure",function(){i=b.controlManager;if(b.settings.grappelli_show_documentstructure=="on"){d._hide_documentstructure(b)}else{d._show_documentstructure(b)}});b.addButton("grappelli_adv",{title:"grappelli.grappelli_adv_desc",cmd:"Grappelli_Adv"});b.addButton("grappelli_documentstructure",{title:"grappelli.grappelli_documentstructure_desc",cmd:"Grappelli_DocumentStructure"});b.onBeforeExecCommand.add(function(f,h,g,j){if("mceFullScreen"!=h){return}if("mce_fullscreen"==f.id){base_ed=tinyMCE.get(f.settings.fullscreen_editor_id);if(!f.settings.grappelli_adv_hidden){d._show_adv_menu(base_ed)}else{d._hide_adv_menu(base_ed)}if(f.settings.grappelli_show_documentstructure=="on"){d._show_documentstructure(base_ed)}else{d._hide_documentstructure(base_ed)}}});b.addShortcut("alt+shift+z",b.getLang("grappelli_adv_desc"),"Grappelli_Adv")},_resizeIframe:function(e,d,c){var f=e.getContentAreaContainer().firstChild;a.setStyle(f,"height",f.clientHeight+c);e.theme.deltaHeight+=c},_show_documentstructure:function(b){head=b.getBody().previousSibling;var c=head.childNodes;for(var d=0;d<c.length;d++){if(c[d].nodeName=="LINK"&&c[d].getAttribute("href")==documentstructure_css){return}}var e=document.createElement("link");e.rel="stylesheet";e.mce_href=documentstructure_css;e.href=documentstructure_css;head.appendChild(e);b.settings.grappelli_show_documentstructure="on";tinymce.util.Cookie.set("grappelli_show_documentstructure","on",cookie_date,"/");b.controlManager.setActive("grappelli_documentstructure",true)},_hide_documentstructure:function(b){head=b.getBody().previousSibling;vs_link=null;var c=head.childNodes;for(var d=0;d<c.length;d++){if(c[d].nodeName=="LINK"&&c[d].getAttribute("href")==documentstructure_css){vs_link=c[d];break}}if(vs_link!==null){head.removeChild(vs_link);b.settings.grappelli_show_documentstructure="off";tinymce.util.Cookie.set("grappelli_show_documentstructure","off",cookie_date,"/");b.controlManager.setActive("grappelli_documentstructure",false)}},_show_adv_menu:function(b){b.controlManager.setActive("grappelli_adv",1);a.show(b.controlManager.get(tb).id);this._resizeIframe(b,tb,-28);b.settings.grappelli_adv_hidden=0},_hide_adv_menu:function(b){b.controlManager.setActive("grappelli_adv",0);a.hide(b.controlManager.get(tb).id);this._resizeIframe(b,tb,28);b.settings.grappelli_adv_hidden=1},getInfo:function(){return{longname:"Grappelli Plugin",author:"vonautomatisch (patrick kranzlmueller)",authorurl:"http://vonautomatisch.at",infourl:"http://code.google.com/p/django-grappelli/",version:"1.0"}}});tinymce.PluginManager.add("grappelli",tinymce.plugins.Grappelli)})();