+ window.admin_pages_cur_layout = null
+ function admin_pages_layout(layout) {
+ if (layout === undefined) {
+ layout = document.getElementById('layout').value
+ }
+ if (typeof layout === 'string') {
+ layout = parseInt(layout);
+ }
+ if (layout === window.admin_pages_cur_layout) {
+ return;
+ }
+ // hide/show sidebar editor
+ if (layout === 0) {
+ document.getElementById('sidebar_editor').style.display = 'none'
+ } else {
+ document.getElementById('sidebar_editor').style.display = 'block'
+ }
+ // remove existing ckeditors
+ if (window.admin_pages_cur_layout !== null) {
+ for (name in CKEDITOR.instances) {
+ CKEDITOR.instances[name].destroy();
+ }
+ }
+ // create ckeditors
+ if (layout === 0) {
+ make_wysiwyg('content', 'content_full_main');
+ } else if (layout === 1) {
+ make_wysiwyg('content', 'content_with_sidebar_main');
+ make_wysiwyg('sidebar_content', 'content_with_sidebar_sidebar_plain');
+ } else {
+ make_wysiwyg('content', 'content_with_sidebar_main');
+ make_wysiwyg('sidebar_content', 'content_with_sidebar_sidebar_bordered');
+ }
+
+ window.admin_pages_cur_layout = layout
+ }