includes/clientside/tinymce/themes/advanced/editor_template_src.js
changeset 335 67bd3121a12e
parent 1 fe660c52c48f
child 395 fa4c5ecb7c9a
equal deleted inserted replaced
334:c72b545f1304 335:67bd3121a12e
     1 /**
     1 /**
     2  * $Id: editor_template_src.js 218 2007-02-13 11:08:01Z spocke $
     2  * $Id: editor_template_src.js 492 2007-12-13 14:11:51Z spocke $
     3  *
     3  *
     4  * @author Moxiecode
     4  * @author Moxiecode
     5  * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.
     5  * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.
     6  */
     6  */
     7 
     7 
     8 /* Import theme specific language pack */
     8 (function() {
     9 tinyMCE.importThemeLanguagePack('advanced');
     9 	var DOM = tinymce.DOM, Event = tinymce.dom.Event, extend = tinymce.extend, each = tinymce.each, Cookie = tinymce.util.Cookie, lastExtID;
    10 
    10 
    11 var TinyMCE_AdvancedTheme = {
    11 	// Tell it to load theme specific language pack(s)
    12 	// Private theme fields
    12 	tinymce.ThemeManager.requireLangPack('advanced');
    13 	_defColors : "000000,993300,333300,003300,003366,000080,333399,333333,800000,FF6600,808000,008000,008080,0000FF,666699,808080,FF0000,FF9900,99CC00,339966,33CCCC,3366FF,800080,999999,FF00FF,FFCC00,FFFF00,00FF00,00FFFF,00CCFF,993366,C0C0C0,FF99CC,FFCC99,FFFF99,CCFFCC,CCFFFF,99CCFF,CC99FF,FFFFFF",
    13 
    14 	_autoImportCSSClasses : true,
    14 	tinymce.create('tinymce.themes.AdvancedTheme', {
    15 	_resizer : {},
    15 		// Control name lookup, format: title, command
    16 	_buttons : [
    16 		controls : {
    17 		// Control id, button img, button title, command, user_interface, value
    17 			bold : ['bold_desc', 'Bold'],
    18 		['bold', '{$lang_bold_img}', 'lang_bold_desc', 'Bold'],
    18 			italic : ['italic_desc', 'Italic'],
    19 		['italic', '{$lang_italic_img}', 'lang_italic_desc', 'Italic'],
    19 			underline : ['underline_desc', 'Underline'],
    20 		['underline', '{$lang_underline_img}', 'lang_underline_desc', 'Underline'],
    20 			strikethrough : ['striketrough_desc', 'Strikethrough'],
    21 		['strikethrough', 'strikethrough.gif', 'lang_striketrough_desc', 'Strikethrough'],
    21 			justifyleft : ['justifyleft_desc', 'JustifyLeft'],
    22 		['justifyleft', 'justifyleft.gif', 'lang_justifyleft_desc', 'JustifyLeft'],
    22 			justifycenter : ['justifycenter_desc', 'JustifyCenter'],
    23 		['justifycenter', 'justifycenter.gif', 'lang_justifycenter_desc', 'JustifyCenter'],
    23 			justifyright : ['justifyright_desc', 'JustifyRight'],
    24 		['justifyright', 'justifyright.gif', 'lang_justifyright_desc', 'JustifyRight'],
    24 			justifyfull : ['justifyfull_desc', 'JustifyFull'],
    25 		['justifyfull', 'justifyfull.gif', 'lang_justifyfull_desc', 'JustifyFull'],
    25 			bullist : ['bullist_desc', 'InsertUnorderedList'],
    26 		['bullist', 'bullist.gif', 'lang_bullist_desc', 'InsertUnorderedList'],
    26 			numlist : ['numlist_desc', 'InsertOrderedList'],
    27 		['numlist', 'numlist.gif', 'lang_numlist_desc', 'InsertOrderedList'],
    27 			outdent : ['outdent_desc', 'Outdent'],
    28 		['outdent', 'outdent.gif', 'lang_outdent_desc', 'Outdent'],
    28 			indent : ['indent_desc', 'Indent'],
    29 		['indent', 'indent.gif', 'lang_indent_desc', 'Indent'],
    29 			cut : ['cut_desc', 'Cut'],
    30 		['cut', 'cut.gif', 'lang_cut_desc', 'Cut'],
    30 			copy : ['copy_desc', 'Copy'],
    31 		['copy', 'copy.gif', 'lang_copy_desc', 'Copy'],
    31 			paste : ['paste_desc', 'Paste'],
    32 		['paste', 'paste.gif', 'lang_paste_desc', 'Paste'],
    32 			undo : ['undo_desc', 'Undo'],
    33 		['undo', 'undo.gif', 'lang_undo_desc', 'Undo'],
    33 			redo : ['redo_desc', 'Redo'],
    34 		['redo', 'redo.gif', 'lang_redo_desc', 'Redo'],
    34 			link : ['link_desc', 'mceLink'],
    35 		['link', 'link.gif', 'lang_link_desc', 'mceLink', true],
    35 			unlink : ['unlink_desc', 'unlink'],
    36 		['unlink', 'unlink.gif', 'lang_unlink_desc', 'unlink'],
    36 			image : ['image_desc', 'mceImage'],
    37 		['image', 'image.gif', 'lang_image_desc', 'mceImage', true],
    37 			cleanup : ['cleanup_desc', 'mceCleanup'],
    38 		['cleanup', 'cleanup.gif', 'lang_cleanup_desc', 'mceCleanup'],
    38 			help : ['help_desc', 'mceHelp'],
    39 		['help', 'help.gif', 'lang_help_desc', 'mceHelp'],
    39 			code : ['code_desc', 'mceCodeEditor'],
    40 		['code', 'code.gif', 'lang_theme_code_desc', 'mceCodeEditor'],
    40 			hr : ['hr_desc', 'InsertHorizontalRule'],
    41 		['hr', 'hr.gif', 'lang_theme_hr_desc', 'inserthorizontalrule'],
    41 			removeformat : ['removeformat_desc', 'RemoveFormat'],
    42 		['removeformat', 'removeformat.gif', 'lang_theme_removeformat_desc', 'removeformat'],
    42 			sub : ['sub_desc', 'subscript'],
    43 		['sub', 'sub.gif', 'lang_theme_sub_desc', 'subscript'],
    43 			sup : ['sup_desc', 'superscript'],
    44 		['sup', 'sup.gif', 'lang_theme_sup_desc', 'superscript'],
    44 			forecolor : ['forecolor_desc', 'ForeColor'],
    45 		['forecolor', 'forecolor.gif', 'lang_theme_forecolor_desc', 'forecolor', true],
    45 			forecolorpicker : ['forecolor_desc', 'mceForeColor'],
    46 		['forecolorpicker', 'forecolor.gif', 'lang_theme_forecolor_desc', 'forecolorpicker', true],
    46 			backcolor : ['backcolor_desc', 'HiliteColor'],
    47 		['backcolor', 'backcolor.gif', 'lang_theme_backcolor_desc', 'HiliteColor', true],
    47 			backcolorpicker : ['backcolor_desc', 'mceBackColor'],
    48 		['backcolorpicker', 'backcolor.gif', 'lang_theme_backcolor_desc', 'backcolorpicker', true],
    48 			charmap : ['charmap_desc', 'mceCharMap'],
    49 		['charmap', 'charmap.gif', 'lang_theme_charmap_desc', 'mceCharMap'],
    49 			visualaid : ['visualaid_desc', 'mceToggleVisualAid'],
    50 		['visualaid', 'visualaid.gif', 'lang_theme_visualaid_desc', 'mceToggleVisualAid'],
    50 			anchor : ['anchor_desc', 'mceInsertAnchor'],
    51 		['anchor', 'anchor.gif', 'lang_theme_anchor_desc', 'mceInsertAnchor'],
    51 			newdocument : ['newdocument_desc', 'mceNewDocument'],
    52 		['newdocument', 'newdocument.gif', 'lang_newdocument_desc', 'mceNewDocument']
    52 			blockquote : ['blockquote_desc', 'mceBlockQuote']
    53 	],
    53 		},
    54 
    54 
    55 	_buttonMap : 'anchor,backcolor,bold,bullist,charmap,cleanup,code,copy,cut,forecolor,help,hr,image,indent,italic,justifycenter,justifyfull,justifyleft,justifyright,link,newdocument,numlist,outdent,paste,redo,removeformat,strikethrough,sub,sup,underline,undo,unlink,visualaid,advhr,ltr,rtl,emotions,flash,fullpage,fullscreen,iespell,insertdate,inserttime,pastetext,pasteword,selectall,preview,print,save,replace,search,table,cell_props,delete_col,delete_row,col_after,col_before,row_after,row_before,merge_cells,row_props,split_cells,delete_table',
    55 		stateControls : ['bold', 'italic', 'underline', 'strikethrough', 'bullist', 'numlist', 'justifyleft', 'justifycenter', 'justifyright', 'justifyfull', 'sub', 'sup', 'blockquote'],
    56 
    56 
    57 	/**
    57 		init : function(ed, url) {
    58 	 * Returns HTML code for the specificed control.
    58 			var t = this, s;
    59 	 */
    59 
    60 	getControlHTML : function(button_name) {
    60 			t.editor = ed;
    61 		var i, x, but;
    61 			t.url = url;
    62 
    62 			t.onResolveName = new tinymce.util.Dispatcher(this);
    63 		// Lookup button in button list
    63 
    64 		for (i=0; i<TinyMCE_AdvancedTheme._buttons.length; i++) {
    64 			// Default settings
    65 			but = TinyMCE_AdvancedTheme._buttons[i];
    65 			t.settings = s = extend({
    66 
    66 				theme_advanced_path : true,
    67 			if (but[0] == button_name && (button_name == "forecolor" || button_name == "backcolor"))
    67 				theme_advanced_toolbar_location : 'bottom',
    68 				return tinyMCE.getMenuButtonHTML(but[0], but[2], '{$themeurl}/images/' + but[1], but[3] + "Menu", but[3], (but.length > 4 ? but[4] : false), (but.length > 5 ? but[5] : null));
    68 				theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect",
    69 
    69 				theme_advanced_buttons2 : "bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code",
    70 			if (but[0] == button_name)
    70 				theme_advanced_buttons3 : "hr,removeformat,visualaid,|,sub,sup,|,charmap",
    71 				return tinyMCE.getButtonHTML(but[0], but[2], '{$themeurl}/images/' + but[1], but[3], (but.length > 4 ? but[4] : false), (but.length > 5 ? but[5] : null));
    71 				theme_advanced_blockformats : "p,address,pre,h1,h2,h3,h4,h5,h6",
    72 		}
    72 				theme_advanced_toolbar_align : "center",
    73 
    73 				theme_advanced_fonts : "Andale Mono=andale mono,times;Arial=arial,helvetica,sans-serif;Arial Black=arial black,avant garde;Book Antiqua=book antiqua,palatino;Comic Sans MS=comic sans ms,sans-serif;Courier New=courier new,courier;Georgia=georgia,palatino;Helvetica=helvetica;Impact=impact,chicago;Symbol=symbol;Tahoma=tahoma,arial,helvetica,sans-serif;Terminal=terminal,monaco;Times New Roman=times new roman,times;Trebuchet MS=trebuchet ms,geneva;Verdana=verdana,geneva;Webdings=webdings;Wingdings=wingdings,zapf dingbats",
    74 		// Custom controlls other than buttons
    74 				theme_advanced_font_sizes : "1,2,3,4,5,6,7",
    75 		switch (button_name) {
    75 				theme_advanced_more_colors : 1,
    76 			case "formatselect":
    76 				theme_advanced_row_height : 23,
    77 				var html = '<select id="{$editor_id}_formatSelect" name="{$editor_id}_formatSelect" onfocus="tinyMCE.addSelectAccessibility(event, this, window);" onchange="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'FormatBlock\',false,this.options[this.selectedIndex].value);" class="mceSelectList">';
    77 				theme_advanced_resize_horizontal : 1,
    78 				var formats = tinyMCE.getParam("theme_advanced_blockformats", "p,address,pre,h1,h2,h3,h4,h5,h6", true).split(',');
    78 				theme_advanced_resizing_use_cookie : 1
    79 				var lookup = [
    79 			}, ed.settings);
    80 					['p', '{$lang_theme_paragraph}'],
    80 
    81 					['address', '{$lang_theme_address}'],
    81 			// Init editor
    82 					['pre', '{$lang_theme_pre}'],
    82 			ed.onInit.add(function() {
    83 					['h1', '{$lang_theme_h1}'],
    83 				ed.onNodeChange.add(t._nodeChanged, t);
    84 					['h2', '{$lang_theme_h2}'],
    84 				ed.dom.loadCSS(ed.baseURI.toAbsolute("themes/advanced/skins/" + ed.settings.skin + "/content.css"));
    85 					['h3', '{$lang_theme_h3}'],
    85 			});
    86 					['h4', '{$lang_theme_h4}'],
    86 
    87 					['h5', '{$lang_theme_h5}'],
    87 			ed.onSetProgressState.add(function(ed, b, ti) {
    88 					['h6', '{$lang_theme_h6}'],
    88 				var co, id = ed.id, tb;
    89 					['div', '{$lang_theme_div}'],
    89 
    90 					['blockquote', '{$lang_theme_blockquote}'],
    90 				if (b) {
    91 					['code', '{$lang_theme_code}'],
    91 					t.progressTimer = setTimeout(function() {
    92 					['dt', '{$lang_theme_dt}'],
    92 						co = ed.getContainer();
    93 					['dd', '{$lang_theme_dd}'],
    93 						co = co.insertBefore(DOM.create('DIV', {style : 'position:relative'}), co.firstChild);
    94 					['samp', '{$lang_theme_samp}']
    94 						tb = DOM.get(ed.id + '_tbl');
    95 				];
    95 
    96 
    96 						DOM.add(co, 'div', {id : id + '_blocker', 'class' : 'mceBlocker', style : {width : tb.clientWidth + 2, height : tb.clientHeight + 2}});
    97 				html += '<option value="">{$lang_theme_block}</option>';
    97 						DOM.add(co, 'div', {id : id + '_progress', 'class' : 'mceProgress', style : {left : tb.clientWidth / 2, top : tb.clientHeight / 2}});
    98 
    98 					}, ti || 0);
    99 				// Build format select
    99 				} else {
   100 				for (var i=0; i<formats.length; i++) {
   100 					DOM.remove(id + '_blocker');
   101 					for (var x=0; x<lookup.length; x++) {
   101 					DOM.remove(id + '_progress');
   102 						if (formats[i] == lookup[x][0])
   102 					clearTimeout(t.progressTimer);
   103 							html += '<option value="&lt;' + lookup[x][0] + '&gt;">' + lookup[x][1] + '</option>';
   103 				}
       
   104 			});
       
   105 
       
   106 			DOM.loadCSS(ed.baseURI.toAbsolute(s.editor_css || "themes/advanced/skins/" + ed.settings.skin + "/ui.css"));
       
   107 		},
       
   108 
       
   109 		createControl : function(n, cf) {
       
   110 			var cd, c;
       
   111 
       
   112 			if (c = cf.createControl(n))
       
   113 				return c;
       
   114 
       
   115 			switch (n) {
       
   116 				case "styleselect":
       
   117 					return this._createStyleSelect();
       
   118 
       
   119 				case "formatselect":
       
   120 					return this._createBlockFormats();
       
   121 
       
   122 				case "fontselect":
       
   123 					return this._createFontSelect();
       
   124 
       
   125 				case "fontsizeselect":
       
   126 					return this._createFontSizeSelect();
       
   127 
       
   128 				case "forecolor":
       
   129 					return this._createForeColorMenu();
       
   130 
       
   131 				case "backcolor":
       
   132 					return this._createBackColorMenu();
       
   133 			}
       
   134 
       
   135 			if ((cd = this.controls[n]))
       
   136 				return cf.createButton(n, {title : "advanced." + cd[0], cmd : cd[1], ui : cd[2], value : cd[3]});
       
   137 		},
       
   138 
       
   139 		execCommand : function(cmd, ui, val) {
       
   140 			var f = this['_' + cmd];
       
   141 
       
   142 			if (f) {
       
   143 				f.call(this, ui, val);
       
   144 				return true;
       
   145 			}
       
   146 
       
   147 			return false;
       
   148 		},
       
   149 
       
   150 		_importClasses : function() {
       
   151 			var ed = this.editor, c = ed.controlManager.get('styleselect');
       
   152 
       
   153 			if (c.getLength() == 0) {
       
   154 				each(ed.dom.getClasses(), function(o) {
       
   155 					c.add(o['class'], o['class']);
       
   156 				});
       
   157 			}
       
   158 		},
       
   159 
       
   160 		_createStyleSelect : function(n) {
       
   161 			var t = this, ed = t.editor, cf = ed.controlManager, c = cf.createListBox('styleselect', {
       
   162 				title : 'advanced.style_select',
       
   163 				onselect : function(v) {
       
   164 					if (c.selectedValue === v) {
       
   165 						ed.execCommand('mceSetStyleInfo', 0, {command : 'removeformat'});
       
   166 						c.select();
       
   167 						return false;
       
   168 					} else
       
   169 						ed.execCommand('mceSetCSSClass', 0, v);
       
   170 				}
       
   171 			});
       
   172 
       
   173 			each((t.settings.theme_advanced_styles || '').split(';'), function(v) {
       
   174 				var p = v.split('=');
       
   175 
       
   176 				if (v)
       
   177 					c.add(t.editor.translate(p[0]), p[1]);
       
   178 			});
       
   179 
       
   180 			c.onPostRender.add(function(ed, n) {
       
   181 				Event.add(n, 'focus', t._importClasses, t);
       
   182 				Event.add(n, 'mousedown', t._importClasses, t);
       
   183 			});
       
   184 
       
   185 			return c;
       
   186 		},
       
   187 
       
   188 		_createFontSelect : function() {
       
   189 			var c, t = this;
       
   190 
       
   191 			c = t.editor.controlManager.createListBox('fontselect', {title : 'advanced.fontdefault', cmd : 'FontName'});
       
   192 
       
   193 			each(t.settings.theme_advanced_fonts.split(';'), function(v) {
       
   194 				var p = v.split('='), st;
       
   195 
       
   196 				if (p[1].indexOf('dings') == -1)
       
   197 					st = 'font-family:' + p[1];
       
   198 
       
   199 				c.add(t.editor.translate(p[0]), p[1], {style : st});
       
   200 			});
       
   201 
       
   202 			return c;
       
   203 		},
       
   204 
       
   205 		_createFontSizeSelect : function() {
       
   206 			var c, t = this, lo = [
       
   207 				"1 (8 pt)",
       
   208 				"2 (10 pt)",
       
   209 				"3 (12 pt)",
       
   210 				"4 (14 pt)",
       
   211 				"5 (18 pt)",
       
   212 				"6 (24 pt)",
       
   213 				"7 (36 pt)"
       
   214 			], fz = [8, 10, 12, 14, 18, 24, 36];
       
   215 
       
   216 			c = t.editor.controlManager.createListBox('fontsizeselect', {title : 'advanced.font_size', cmd : 'FontSize'});
       
   217 
       
   218 			each(t.settings.theme_advanced_font_sizes.split(','), function(v) {
       
   219 				c.add(lo[parseInt(v) - 1], v, {'style' : 'font-size:' + fz[v - 1] + 'pt', 'class' : 'fontSize' + v});
       
   220 			});
       
   221 
       
   222 			return c;
       
   223 		},
       
   224 
       
   225 		_createBlockFormats : function() {
       
   226 			var c, fmts = {
       
   227 				p : 'advanced.paragraph',
       
   228 				address : 'advanced.address',
       
   229 				pre : 'advanced.pre',
       
   230 				h1 : 'advanced.h1',
       
   231 				h2 : 'advanced.h2',
       
   232 				h3 : 'advanced.h3',
       
   233 				h4 : 'advanced.h4',
       
   234 				h5 : 'advanced.h5',
       
   235 				h6 : 'advanced.h6',
       
   236 				div : 'advanced.div',
       
   237 				blockquote : 'advanced.blockquote',
       
   238 				code : 'advanced.code',
       
   239 				dt : 'advanced.dt',
       
   240 				dd : 'advanced.dd',
       
   241 				samp : 'advanced.samp'
       
   242 			}, t = this;
       
   243 
       
   244 			c = t.editor.controlManager.createListBox('formatselect', {title : 'advanced.block', cmd : 'FormatBlock'});
       
   245 
       
   246 			each(t.settings.theme_advanced_blockformats.split(','), function(v) {
       
   247 				c.add(t.editor.translate(fmts[v]), v, {element : v, 'class' : v.indexOf('h') == 0 ? '' : 'preview'});
       
   248 			});
       
   249 
       
   250 			return c;
       
   251 		},
       
   252 
       
   253 		_createForeColorMenu : function() {
       
   254 			var c, t = this, s = t.settings, o = {}, v;
       
   255 
       
   256 			if (s.theme_advanced_more_colors) {
       
   257 				o.more_colors_func = function() {
       
   258 					t._mceColorPicker(0, {
       
   259 						color : c.value,
       
   260 						func : function(co) {
       
   261 							c.setColor(co);
       
   262 						}
       
   263 					});
       
   264 				};
       
   265 			}
       
   266 
       
   267 			if (v = s.theme_advanced_text_colors)
       
   268 				o.colors = v;
       
   269 
       
   270 			o.title = 'advanced.forecolor_desc';
       
   271 			o.cmd = 'ForeColor';
       
   272 			o.scope = this;
       
   273 
       
   274 			c = t.editor.controlManager.createColorSplitButton('forecolor', o);
       
   275 
       
   276 			return c;
       
   277 		},
       
   278 
       
   279 		_createBackColorMenu : function() {
       
   280 			var c, t = this, s = t.settings, o = {}, v;
       
   281 
       
   282 			if (s.theme_advanced_more_colors) {
       
   283 				o.more_colors_func = function() {
       
   284 					t._mceColorPicker(0, {
       
   285 						color : c.value,
       
   286 						func : function(co) {
       
   287 							c.setColor(co);
       
   288 						}
       
   289 					});
       
   290 				};
       
   291 			}
       
   292 
       
   293 			if (v = s.theme_advanced_background_colors)
       
   294 				o.colors = v;
       
   295 
       
   296 			o.title = 'advanced.backcolor_desc';
       
   297 			o.cmd = 'HiliteColor';
       
   298 			o.scope = this;
       
   299 
       
   300 			c = t.editor.controlManager.createColorSplitButton('backcolor', o);
       
   301 
       
   302 			return c;
       
   303 		},
       
   304 
       
   305 		renderUI : function(o) {
       
   306 			var n, ic, tb, t = this, ed = t.editor, s = t.settings, sc, p, nl;
       
   307 
       
   308 			n = p = DOM.create('div', {id : ed.id + '_parent', 'class' : 'mceEditor ' + ed.settings.skin + 'Skin'});
       
   309 
       
   310 			if (!DOM.boxModel)
       
   311 				n = DOM.add(n, 'div', {'class' : 'mceOldBoxModel'});
       
   312 
       
   313 			n = sc = DOM.add(n, 'table', {id : ed.id + '_tbl', 'class' : 'mceLayout', cellSpacing : 0, cellPadding : 0});
       
   314 			n = tb = DOM.add(n, 'tbody');
       
   315 
       
   316 			switch ((s.theme_advanced_layout_manager || '').toLowerCase()) {
       
   317 				case "rowlayout":
       
   318 					ic = t._rowLayout(s, tb, o);
       
   319 					break;
       
   320 
       
   321 				case "customlayout":
       
   322 					ic = ed.execCallback("theme_advanced_custom_layout", s, tb, o, p);
       
   323 					break;
       
   324 
       
   325 				default:
       
   326 					ic = t._simpleLayout(s, tb, o, p);
       
   327 			}
       
   328 
       
   329 			n = o.targetNode;
       
   330 
       
   331 			// Add classes to first and last TRs
       
   332 			nl = sc.rows;
       
   333 			DOM.addClass(nl[0], 'first');
       
   334 			DOM.addClass(nl[nl.length - 1], 'last');
       
   335 
       
   336 			// Add classes to first and last TDs
       
   337 			each(DOM.select('tr', tb), function(n) {
       
   338 				DOM.addClass(n.firstChild, 'first');
       
   339 				DOM.addClass(n.childNodes[n.childNodes.length - 1], 'last');
       
   340 			});
       
   341 
       
   342 			if (DOM.get(s.theme_advanced_toolbar_container))
       
   343 				DOM.get(s.theme_advanced_toolbar_container).appendChild(p);
       
   344 			else
       
   345 				DOM.insertAfter(p, n);
       
   346 
       
   347 			Event.add(ed.id + '_path_row', 'click', function(e) {
       
   348 				e = e.target;
       
   349 
       
   350 				if (e.nodeName == 'A') {
       
   351 					t._sel(e.href.replace(/^[^#]*#/, ''));
       
   352 
       
   353 					return Event.cancel(e);
       
   354 				}
       
   355 			});
       
   356 /*
       
   357 			if (DOM.get(ed.id + '_path_row')) {
       
   358 				Event.add(ed.id + '_tbl', 'mouseover', function(e) {
       
   359 					var re;
       
   360 	
       
   361 					e = e.target;
       
   362 
       
   363 					if (e.nodeName == 'SPAN' && DOM.hasClass(e.parentNode, 'mceButton')) {
       
   364 						re = DOM.get(ed.id + '_path_row');
       
   365 						t.lastPath = re.innerHTML;
       
   366 						DOM.setHTML(re, e.parentNode.title);
   104 					}
   367 					}
       
   368 				});
       
   369 
       
   370 				Event.add(ed.id + '_tbl', 'mouseout', function(e) {
       
   371 					if (t.lastPath) {
       
   372 						DOM.setHTML(ed.id + '_path_row', t.lastPath);
       
   373 						t.lastPath = 0;
       
   374 					}
       
   375 				});
       
   376 			}
       
   377 */
       
   378 			if (s.theme_advanced_toolbar_location == 'external')
       
   379 				o.deltaHeight = 0;
       
   380 
       
   381 			t.deltaHeight = o.deltaHeight;
       
   382 			o.targetNode = null;
       
   383 
       
   384 			return {
       
   385 				iframeContainer : ic,
       
   386 				editorContainer : ed.id + '_parent',
       
   387 				sizeContainer : sc,
       
   388 				deltaHeight : o.deltaHeight
       
   389 			};
       
   390 		},
       
   391 
       
   392 		getInfo : function() {
       
   393 			return {
       
   394 				longname : 'Simple theme',
       
   395 				author : 'Moxiecode Systems AB',
       
   396 				authorurl : 'http://tinymce.moxiecode.com',
       
   397 				version : tinymce.majorVersion + "." + tinymce.minorVersion
       
   398 			}
       
   399 		},
       
   400 
       
   401 		_simpleLayout : function(s, tb, o, p) {
       
   402 			var t = this, ed = t.editor, lo = s.theme_advanced_toolbar_location, sl = s.theme_advanced_statusbar_location, n, ic, etb, c;
       
   403 
       
   404 			// Create toolbar container at top
       
   405 			if (lo == 'top')
       
   406 				t._addToolbars(tb, o);
       
   407 
       
   408 			// Create external toolbar
       
   409 			if (lo == 'external') {
       
   410 				n = c = DOM.create('div', {style : 'position:relative'});
       
   411 				n = DOM.add(n, 'div', {id : ed.id + '_external', 'class' : 'mceExternalToolbar'});
       
   412 				DOM.add(n, 'a', {id : ed.id + '_external_close', href : 'javascript:;', 'class' : 'mceExternalClose'});
       
   413 				n = DOM.add(n, 'table', {id : ed.id + '_tblext', cellSpacing : 0, cellPadding : 0});
       
   414 				etb = DOM.add(n, 'tbody');
       
   415 
       
   416 				if (p.firstChild.className == 'mceOldBoxModel')
       
   417 					p.firstChild.appendChild(c);
       
   418 				else
       
   419 					p.insertBefore(c, p.firstChild);
       
   420 
       
   421 				t._addToolbars(etb, o);
       
   422 
       
   423 				ed.onMouseUp.add(function() {
       
   424 					var e = DOM.get(ed.id + '_external');
       
   425 					DOM.show(e);
       
   426 
       
   427 					DOM.hide(lastExtID);
       
   428 
       
   429 					var f = Event.add(ed.id + '_external_close', 'click', function() {
       
   430 						DOM.hide(ed.id + '_external');
       
   431 						Event.remove(ed.id + '_external_close', 'click', f);
       
   432 					});
       
   433 
       
   434 					DOM.show(e);
       
   435 					DOM.setStyle(e, 'top', 0 - DOM.getRect(ed.id + '_tblext').h - 1);
       
   436 
       
   437 					// Fixes IE rendering bug
       
   438 					DOM.hide(e);
       
   439 					DOM.show(e);
       
   440 					e.style.filter = '';
       
   441 
       
   442 					lastExtID = ed.id + '_external';
       
   443 
       
   444 					e = null;
       
   445 				});
       
   446 			}
       
   447 
       
   448 			if (sl == 'top')
       
   449 				t._addStatusBar(tb, o);
       
   450 
       
   451 			// Create iframe container
       
   452 			if (!s.theme_advanced_toolbar_container) {
       
   453 				n = DOM.add(tb, 'tr');
       
   454 				n = ic = DOM.add(n, 'td', {'class' : 'mceIframeContainer'});
       
   455 			}
       
   456 
       
   457 			// Create toolbar container at bottom
       
   458 			if (lo == 'bottom')
       
   459 				t._addToolbars(tb, o);
       
   460 
       
   461 			if (sl == 'bottom')
       
   462 				t._addStatusBar(tb, o);
       
   463 
       
   464 			return ic;
       
   465 		},
       
   466 
       
   467 		_rowLayout : function(s, tb, o) {
       
   468 			var t = this, ed = t.editor, dc, da, cf = ed.controlManager, n, ic, to;
       
   469 
       
   470 			dc = s.theme_advanced_containers_default_class || '';
       
   471 			da = s.theme_advanced_containers_default_align || 'center';
       
   472 
       
   473 			each((s.theme_advanced_containers || '').split(','), function(c, i) {
       
   474 				var v = s['theme_advanced_container_' + c].toLowerCase();
       
   475 
       
   476 				switch (v) {
       
   477 					case 'mceeditor':
       
   478 						n = DOM.add(tb, 'tr');
       
   479 						n = ic = DOM.add(n, 'td', {'class' : 'mceIframeContainer'});
       
   480 						break;
       
   481 
       
   482 					case 'mceelementpath':
       
   483 						t._addStatusBar(tb, o);
       
   484 						break;
       
   485 
       
   486 					default:
       
   487 						n = DOM.add(DOM.add(tb, 'tr'), 'td', {
       
   488 							'class' : 'mceToolbar ' + (s['theme_advanced_container_' + c + '_class'] || dc),
       
   489 							align : s['theme_advanced_container_' + c + '_align'] || da
       
   490 						});
       
   491 
       
   492 						to = cf.createToolbar("toolbar" + i);
       
   493 						t._addControls(v, to);
       
   494 						n.innerHTML = to.renderHTML();
       
   495 						o.deltaHeight -= s.theme_advanced_row_height;
   105 				}
   496 				}
   106 
   497 			});
   107 				html += '</select>';
   498 
   108 
   499 			return ic;
   109 				return html;
   500 		},
   110 
   501 
   111 			case "styleselect":
   502 		_addControls : function(v, tb) {
   112 				return '<select id="{$editor_id}_styleSelect" onmousedown="tinyMCE.themes.advanced._setupCSSClasses(\'{$editor_id}\');" name="{$editor_id}_styleSelect" onfocus="tinyMCE.addSelectAccessibility(event,this,window);" onchange="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceSetCSSClass\',false,this.options[this.selectedIndex].value);" class="mceSelectList">{$style_select_options}</select>';
   503 			var t = this, s = t.settings, di, cf = t.editor.controlManager;
   113 
   504 
   114 			case "fontselect":
   505 			if (s.theme_advanced_disable && !t._disabled) {
   115 				var fontHTML = '<select id="{$editor_id}_fontNameSelect" name="{$editor_id}_fontNameSelect" onfocus="tinyMCE.addSelectAccessibility(event, this, window);" onchange="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'FontName\',false,this.options[this.selectedIndex].value);" class="mceSelectList"><option value="">{$lang_theme_fontdefault}</option>';
   506 				di = {};
   116 				var iFonts = 'Arial=arial,helvetica,sans-serif;Courier New=courier new,courier,monospace;Georgia=georgia,times new roman,times,serif;Tahoma=tahoma,arial,helvetica,sans-serif;Times New Roman=times new roman,times,serif;Verdana=verdana,arial,helvetica,sans-serif;Impact=impact;WingDings=wingdings';
   507 
   117 				var nFonts = 'Andale Mono=andale mono,times;Arial=arial,helvetica,sans-serif;Arial Black=arial black,avant garde;Book Antiqua=book antiqua,palatino;Comic Sans MS=comic sans ms,sand;Courier New=courier new,courier;Georgia=georgia,palatino;Helvetica=helvetica;Impact=impact,chicago;Symbol=symbol;Tahoma=tahoma,arial,helvetica,sans-serif;Terminal=terminal,monaco;Times New Roman=times new roman,times;Trebuchet MS=trebuchet ms,geneva;Verdana=verdana,geneva;Webdings=webdings;Wingdings=wingdings,zapf dingbats';
   508 				each(s.theme_advanced_disable.split(','), function(v) {
   118 				var fonts = tinyMCE.getParam("theme_advanced_fonts", nFonts).split(';');
   509 					di[v] = 1;
   119 				for (i=0; i<fonts.length; i++) {
   510 				});
   120 					if (fonts[i] != '') {
   511 
   121 						var parts = fonts[i].split('=');
   512 				t._disabled = di;
   122 						fontHTML += '<option value="' + parts[1] + '">' + parts[0] + '</option>';
   513 			} else
       
   514 				di = t._disabled;
       
   515 
       
   516 			each(v.split(','), function(n) {
       
   517 				var c;
       
   518 
       
   519 				if (di && di[n])
       
   520 					return;
       
   521 
       
   522 				// Compatiblity with 2.x
       
   523 				if (n == 'tablecontrols') {
       
   524 					each(["table","|","row_props","cell_props","|","row_before","row_after","delete_row","|","col_before","col_after","delete_col","|","split_cells","merge_cells"], function(n) {
       
   525 						n = t.createControl(n, cf);
       
   526 
       
   527 						if (n)
       
   528 							tb.add(n);
       
   529 					});
       
   530 
       
   531 					return;
       
   532 				}
       
   533 
       
   534 				c = t.createControl(n, cf);
       
   535 
       
   536 				if (c)
       
   537 					tb.add(c);
       
   538 			});
       
   539 		},
       
   540 
       
   541 		_addToolbars : function(c, o) {
       
   542 			var t = this, i, tb, ed = t.editor, s = t.settings, v, cf = ed.controlManager, di, n, h = [];
       
   543 
       
   544 			n = DOM.add(DOM.add(c, 'tr'), 'td', {'class' : 'mceToolbar', align : s.theme_advanced_toolbar_align});
       
   545 
       
   546 			if (!ed.getParam('accessibility_focus') || ed.getParam('tab_focus'))
       
   547 				h.push(DOM.createHTML('a', {href : '#', onfocus : 'tinyMCE.get(\'' + ed.id + '\').focus();'}, '<!-- IE -->'));
       
   548 
       
   549 			h.push(DOM.createHTML('a', {href : '#', accesskey : 'q', title : ed.getLang("advanced.toolbar_focus")}, '<!-- IE -->'));
       
   550 
       
   551 			// Create toolbar and add the controls
       
   552 			for (i=1; (v = s['theme_advanced_buttons' + i]); i++) {
       
   553 				tb = cf.createToolbar("toolbar" + i);
       
   554 
       
   555 				if (s['theme_advanced_buttons' + i + '_add'])
       
   556 					v += ',' + s['theme_advanced_buttons' + i + '_add'];
       
   557 
       
   558 				if (s['theme_advanced_buttons' + i + '_add_before'])
       
   559 					v = s['theme_advanced_buttons' + i + '_add_before'] + ',' + v;
       
   560 
       
   561 				t._addControls(v, tb, di);
       
   562 
       
   563 				//n.appendChild(n = tb.render());
       
   564 				h.push(tb.renderHTML());
       
   565 
       
   566 				o.deltaHeight -= s.theme_advanced_row_height;
       
   567 			}
       
   568 
       
   569 			h.push(DOM.createHTML('a', {href : '#', accesskey : 'z', title : ed.getLang("advanced.toolbar_focus"), onfocus : 'tinyMCE.getInstanceById(\'' + ed.id + '\').focus();'}, '<!-- IE -->'));
       
   570 
       
   571 			n.innerHTML = h.join('');
       
   572 		},
       
   573 
       
   574 		_addStatusBar : function(tb, o) {
       
   575 			var n, t = this, ed = t.editor, s = t.settings, r, mf, me, td;
       
   576 
       
   577 			n = DOM.add(tb, 'tr');
       
   578 			n = td = DOM.add(n, 'td', {'class' : 'mceStatusbar'});
       
   579 			n = DOM.add(n, 'div', {id : ed.id + '_path_row'}, s.theme_advanced_path ? ed.translate('advanced.path') + ': ' : '&nbsp;');
       
   580 			DOM.add(n, 'a', {href : '#', accesskey : 'x'});
       
   581 
       
   582 			if (s.theme_advanced_resizing && !tinymce.isOldWebKit) {
       
   583 				DOM.add(td, 'a', {id : ed.id + '_resize', href : 'javascript:;', onclick : "return false;", 'class' : 'resize'});
       
   584 
       
   585 				if (s.theme_advanced_resizing_use_cookie) {
       
   586 					ed.onPostRender.add(function() {
       
   587 						var o = Cookie.getHash("TinyMCE_" + ed.id + "_size"), c = DOM.get(ed.id + '_tbl');
       
   588 
       
   589 						if (!o)
       
   590 							return;
       
   591 
       
   592 						if (s.theme_advanced_resize_horizontal)
       
   593 							c.style.width = o.cw + 'px';
       
   594 
       
   595 						c.style.height = o.ch + 'px';
       
   596 						DOM.get(ed.id + '_ifr').style.height = (parseInt(o.ch) + t.deltaHeight) + 'px';
       
   597 					});
       
   598 				}
       
   599 
       
   600 				ed.onPostRender.add(function() {
       
   601 					Event.add(ed.id + '_resize', 'mousedown', function(e) {
       
   602 						var c, p, w, h, n, pa;
       
   603 
       
   604 						// Measure container
       
   605 						c = DOM.get(ed.id + '_tbl');
       
   606 						w = c.clientWidth;
       
   607 						h = c.clientHeight;
       
   608 
       
   609 						miw = s.theme_advanced_resizing_min_width || 100;
       
   610 						mih = s.theme_advanced_resizing_min_height || 100;
       
   611 						maw = s.theme_advanced_resizing_max_width || 0xFFFF;
       
   612 						mah = s.theme_advanced_resizing_max_height || 0xFFFF;
       
   613 
       
   614 						// Setup placeholder
       
   615 						p = DOM.add(DOM.get(ed.id + '_parent'), 'div', {'class' : 'mcePlaceHolder'});
       
   616 						DOM.setStyles(p, {width : w, height : h});
       
   617 
       
   618 						// Replace with placeholder
       
   619 						DOM.hide(c);
       
   620 						DOM.show(p);
       
   621 
       
   622 						// Create internal resize obj
       
   623 						r = {
       
   624 							x : e.screenX,
       
   625 							y : e.screenY,
       
   626 							w : w,
       
   627 							h : h,
       
   628 							dx : null,
       
   629 							dy : null
       
   630 						};
       
   631 
       
   632 						// Start listening
       
   633 						mf = Event.add(document, 'mousemove', function(e) {
       
   634 							var w, h;
       
   635 
       
   636 							// Calc delta values
       
   637 							r.dx = e.screenX - r.x;
       
   638 							r.dy = e.screenY - r.y;
       
   639 
       
   640 							// Boundery fix box
       
   641 							w = Math.max(miw, r.w + r.dx);
       
   642 							h = Math.max(mih, r.h + r.dy);
       
   643 							w = Math.min(maw, w);
       
   644 							h = Math.min(mah, h);
       
   645 
       
   646 							// Resize placeholder
       
   647 							if (s.theme_advanced_resize_horizontal)
       
   648 								p.style.width = w + 'px';
       
   649 
       
   650 							p.style.height = h + 'px';
       
   651 
       
   652 							return Event.cancel(e);
       
   653 						});
       
   654 
       
   655 						me = Event.add(document, 'mouseup', function(e) {
       
   656 							var ifr;
       
   657 
       
   658 							// Stop listening
       
   659 							Event.remove(document, 'mousemove', mf);
       
   660 							Event.remove(document, 'mouseup', me);
       
   661 
       
   662 							c.style.display = '';
       
   663 							DOM.remove(p);
       
   664 
       
   665 							if (r.dx === null)
       
   666 								return;
       
   667 
       
   668 							ifr = DOM.get(ed.id + '_ifr');
       
   669 
       
   670 							if (s.theme_advanced_resize_horizontal)
       
   671 								c.style.width = (r.w + r.dx) + 'px';
       
   672 
       
   673 							c.style.height = (r.h + r.dy) + 'px';
       
   674 							ifr.style.height = (ifr.clientHeight + r.dy) + 'px';
       
   675 
       
   676 							if (s.theme_advanced_resizing_use_cookie) {
       
   677 								Cookie.setHash("TinyMCE_" + ed.id + "_size", {
       
   678 									cw : r.w + r.dx,
       
   679 									ch : r.h + r.dy
       
   680 								});
       
   681 							}
       
   682 						});
       
   683 
       
   684 						return Event.cancel(e);
       
   685 					});
       
   686 				});
       
   687 			}
       
   688 
       
   689 			o.deltaHeight -= 21;
       
   690 			n = tb = null;
       
   691 		},
       
   692 
       
   693 		_nodeChanged : function(ed, cm, n, co) {
       
   694 			var t = this, p, de = 0, v, c, s = t.settings;
       
   695 
       
   696 			tinymce.each(t.stateControls, function(c) {
       
   697 				cm.setActive(c, ed.queryCommandState(t.controls[c][1]));
       
   698 			});
       
   699 
       
   700 			cm.setActive('visualaid', ed.hasVisual);
       
   701 			cm.setDisabled('undo', !ed.undoManager.hasUndo() && !ed.typing);
       
   702 			cm.setDisabled('redo', !ed.undoManager.hasRedo());
       
   703 			cm.setDisabled('outdent', !ed.queryCommandState('Outdent'));
       
   704 
       
   705 			p = DOM.getParent(n, 'A');
       
   706 			if (c = cm.get('link')) {
       
   707 				if (!p || !p.name) {
       
   708 					c.setDisabled(!p && co);
       
   709 					c.setActive(!!p);
       
   710 				}
       
   711 			}
       
   712 
       
   713 			if (c = cm.get('unlink')) {
       
   714 				c.setDisabled(!p && co);
       
   715 				c.setActive(!!p && !p.name);
       
   716 			}
       
   717 
       
   718 			if (c = cm.get('anchor')) {
       
   719 				c.setActive(!!p && p.name);
       
   720 
       
   721 				if (tinymce.isWebKit) {
       
   722 					p = DOM.getParent(n, 'IMG');
       
   723 					c.setActive(!!p && DOM.getAttrib(p, 'mce_name') == 'a');
       
   724 				}
       
   725 			}
       
   726 
       
   727 			p = DOM.getParent(n, 'IMG');
       
   728 			if (c = cm.get('image'))
       
   729 				c.setActive(!!p && n.className.indexOf('mceItem') == -1);
       
   730 
       
   731 			if (c = cm.get('styleselect')) {
       
   732 				if (n.className) {
       
   733 					t._importClasses();
       
   734 					c.select(n.className);
       
   735 				} else
       
   736 					c.select();
       
   737 			}
       
   738 
       
   739 			if (c = cm.get('formatselect')) {
       
   740 				p = DOM.getParent(n, DOM.isBlock);
       
   741 
       
   742 				if (p)
       
   743 					c.select(p.nodeName.toLowerCase());
       
   744 			}
       
   745 
       
   746 			if (c = cm.get('fontselect'))
       
   747 				c.select(ed.queryCommandValue('FontName'));
       
   748 
       
   749 			if (c = cm.get('fontsizeselect'))
       
   750 				c.select(ed.queryCommandValue('FontSize'));
       
   751 
       
   752 			if (s.theme_advanced_path && s.theme_advanced_statusbar_location) {
       
   753 				p = DOM.get(ed.id + '_path') || DOM.add(ed.id + '_path_row', 'span', {id : ed.id + '_path'});
       
   754 				p.innerHTML = '';
       
   755 
       
   756 				ed.dom.getParent(n, function(n) {
       
   757 					var na = n.nodeName.toLowerCase(), u, pi, ti = '';
       
   758 
       
   759 					// Ignore non element and hidden elements
       
   760 					if (n.nodeType != 1 || (DOM.hasClass(n, 'mceItemHidden') || DOM.hasClass(n, 'mceItemRemoved')))
       
   761 						return;
       
   762 
       
   763 					// Fake name
       
   764 					if (v = DOM.getAttrib(n, 'mce_name'))
       
   765 						na = v;
       
   766 	
       
   767 					// Handle prefix
       
   768 					if (tinymce.isIE && n.scopeName !== 'HTML')
       
   769 						na = n.scopeName + ':' + na;
       
   770 
       
   771 					// Remove internal prefix
       
   772 					na = na.replace(/mce\:/g, '');
       
   773 
       
   774 					// Handle node name
       
   775 					switch (na) {
       
   776 						case 'b':
       
   777 							na = 'strong';
       
   778 							break;
       
   779 
       
   780 						case 'i':
       
   781 							na = 'em';
       
   782 							break;
       
   783 
       
   784 						case 'img':
       
   785 							if (v = DOM.getAttrib(n, 'src'))
       
   786 								ti += 'src: ' + v + ' ';
       
   787 
       
   788 							break;
       
   789 
       
   790 						case 'a':
       
   791 							if (v = DOM.getAttrib(n, 'name')) {
       
   792 								ti += 'name: ' + v + ' ';
       
   793 								na += '#' + v;
       
   794 							}
       
   795 
       
   796 							if (v = DOM.getAttrib(n, 'href'))
       
   797 								ti += 'href: ' + v + ' ';
       
   798 
       
   799 							break;
       
   800 
       
   801 						case 'font':
       
   802 							if (s.convert_fonts_to_spans)
       
   803 								na = 'span';
       
   804 
       
   805 							if (v = DOM.getAttrib(n, 'face'))
       
   806 								ti += 'font: ' + v + ' ';
       
   807 
       
   808 							if (v = DOM.getAttrib(n, 'size'))
       
   809 								ti += 'size: ' + v + ' ';
       
   810 
       
   811 							if (v = DOM.getAttrib(n, 'color'))
       
   812 								ti += 'color: ' + v + ' ';
       
   813 
       
   814 							break;
       
   815 
       
   816 						case 'span':
       
   817 							if (v = DOM.getAttrib(n, 'style'))
       
   818 								ti += 'style: ' + v + ' ';
       
   819 
       
   820 							break;
   123 					}
   821 					}
   124 				}
   822 
   125 
   823 					if (v = DOM.getAttrib(n, 'id'))
   126 				fontHTML += '</select>';
   824 						ti += 'id: ' + v + ' ';
   127 				return fontHTML;
   825 
   128 
   826 					if (v = n.className) {
   129 			case "fontsizeselect":
   827 						v = v.replace(/(webkit-[\w\-]+|Apple-[\w\-]+|mceItem\w+|mceVisualAid)/g, '');
   130 				return '<select id="{$editor_id}_fontSizeSelect" name="{$editor_id}_fontSizeSelect" onfocus="tinyMCE.addSelectAccessibility(event, this, window);" onchange="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'FontSize\',false,this.options[this.selectedIndex].value);" class="mceSelectList">'+
   828 
   131 						'<option value="0">{$lang_theme_font_size}</option>'+
   829 						if (v && v.indexOf('mceItem') == -1) {
   132 						'<option value="1">1 (8 pt)</option>'+
   830 							ti += 'class: ' + v + ' ';
   133 						'<option value="2">2 (10 pt)</option>'+
   831 
   134 						'<option value="3">3 (12 pt)</option>'+
   832 							if (DOM.isBlock(n) || na == 'img' || na == 'span')
   135 						'<option value="4">4 (14 pt)</option>'+
   833 								na += '.' + v;
   136 						'<option value="5">5 (18 pt)</option>'+
       
   137 						'<option value="6">6 (24 pt)</option>'+
       
   138 						'<option value="7">7 (36 pt)</option>'+
       
   139 						'</select>';
       
   140 
       
   141 			case "|":
       
   142 			case "separator":
       
   143 				return '<img src="{$themeurl}/images/separator.gif" width="2" height="20" class="mceSeparatorLine" />';
       
   144 
       
   145 			case "spacer":
       
   146 				return '<img src="{$themeurl}/images/separator.gif" width="2" height="15" border="0" class="mceSeparatorLine" style="vertical-align: middle" />';
       
   147 
       
   148 			case "rowseparator":
       
   149 				return '<br />';
       
   150 		}
       
   151 
       
   152 		return "";
       
   153 	},
       
   154 
       
   155 	/**
       
   156 	 * Theme specific execcommand handling.
       
   157 	 */
       
   158 	execCommand : function(editor_id, element, command, user_interface, value) {
       
   159 		switch (command) {
       
   160 			case 'mceHelp':
       
   161 				tinyMCE.openWindow({
       
   162 					file : 'about.htm',
       
   163 					width : 480,
       
   164 					height : 380
       
   165 				}, {
       
   166 					tinymce_version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion,
       
   167 					tinymce_releasedate : tinyMCE.releaseDate,
       
   168 					inline : "yes"
       
   169 				});
       
   170 			return true;
       
   171 
       
   172 			case "mceLink":
       
   173 				var inst = tinyMCE.getInstanceById(editor_id);
       
   174 				var doc = inst.getDoc();
       
   175 				var selectedText = "";
       
   176 
       
   177 				if (tinyMCE.isMSIE) {
       
   178 					var rng = doc.selection.createRange();
       
   179 					selectedText = rng.text;
       
   180 				} else
       
   181 					selectedText = inst.getSel().toString();
       
   182 
       
   183 				if (!tinyMCE.linkElement) {
       
   184 					if ((tinyMCE.selectedElement.nodeName.toLowerCase() != "img") && (selectedText.length <= 0))
       
   185 						return true;
       
   186 				}
       
   187 
       
   188 				var href = "", target = "", title = "", onclick = "", action = "insert", style_class = "";
       
   189 
       
   190 				if (tinyMCE.selectedElement.nodeName.toLowerCase() == "a")
       
   191 					tinyMCE.linkElement = tinyMCE.selectedElement;
       
   192 
       
   193 				// Is anchor not a link
       
   194 				if (tinyMCE.linkElement != null && tinyMCE.getAttrib(tinyMCE.linkElement, 'href') == "")
       
   195 					tinyMCE.linkElement = null;
       
   196 
       
   197 				if (tinyMCE.linkElement) {
       
   198 					href = tinyMCE.getAttrib(tinyMCE.linkElement, 'href');
       
   199 					target = tinyMCE.getAttrib(tinyMCE.linkElement, 'target');
       
   200 					title = tinyMCE.getAttrib(tinyMCE.linkElement, 'title');
       
   201 					onclick = tinyMCE.getAttrib(tinyMCE.linkElement, 'onclick');
       
   202 					style_class = tinyMCE.getAttrib(tinyMCE.linkElement, 'class');
       
   203 
       
   204 					// Try old onclick to if copy/pasted content
       
   205 					if (onclick == "")
       
   206 						onclick = tinyMCE.getAttrib(tinyMCE.linkElement, 'onclick');
       
   207 
       
   208 					onclick = tinyMCE.cleanupEventStr(onclick);
       
   209 
       
   210 					href = eval(tinyMCE.settings['urlconverter_callback'] + "(href, tinyMCE.linkElement, true);");
       
   211 
       
   212 					// Use mce_href if defined
       
   213 					mceRealHref = tinyMCE.getAttrib(tinyMCE.linkElement, 'mce_href');
       
   214 					if (mceRealHref != "") {
       
   215 						href = mceRealHref;
       
   216 
       
   217 						if (tinyMCE.getParam('convert_urls'))
       
   218 							href = eval(tinyMCE.settings['urlconverter_callback'] + "(href, tinyMCE.linkElement, true);");
       
   219 					}
       
   220 
       
   221 					action = "update";
       
   222 				}
       
   223 
       
   224 				var template = new Array();
       
   225 
       
   226 				template['file'] = 'link.htm';
       
   227 				template['width'] = 310;
       
   228 				template['height'] = 200;
       
   229 
       
   230 				// Language specific width and height addons
       
   231 				template['width'] += tinyMCE.getLang('lang_insert_link_delta_width', 0);
       
   232 				template['height'] += tinyMCE.getLang('lang_insert_link_delta_height', 0);
       
   233 
       
   234 				if (inst.settings['insertlink_callback']) {
       
   235 					var returnVal = eval(inst.settings['insertlink_callback'] + "(href, target, title, onclick, action, style_class);");
       
   236 					if (returnVal && returnVal['href'])
       
   237 						TinyMCE_AdvancedTheme._insertLink(returnVal['href'], returnVal['target'], returnVal['title'], returnVal['onclick'], returnVal['style_class']);
       
   238 				} else {
       
   239 					tinyMCE.openWindow(template, {href : href, target : target, title : title, onclick : onclick, action : action, className : style_class, inline : "yes"});
       
   240 				}
       
   241 
       
   242 				return true;
       
   243 
       
   244 			case "mceImage":
       
   245 				var src = "", alt = "", border = "", hspace = "", vspace = "", width = "", height = "", align = "";
       
   246 				var title = "", onmouseover = "", onmouseout = "", action = "insert";
       
   247 				var img = tinyMCE.imgElement;
       
   248 				var inst = tinyMCE.getInstanceById(editor_id);
       
   249 
       
   250 				if (tinyMCE.selectedElement != null && tinyMCE.selectedElement.nodeName.toLowerCase() == "img") {
       
   251 					img = tinyMCE.selectedElement;
       
   252 					tinyMCE.imgElement = img;
       
   253 				}
       
   254 
       
   255 				if (img) {
       
   256 					// Is it a internal MCE visual aid image, then skip this one.
       
   257 					if (tinyMCE.getAttrib(img, 'name').indexOf('mce_') == 0)
       
   258 						return true;
       
   259 
       
   260 					src = tinyMCE.getAttrib(img, 'src');
       
   261 					alt = tinyMCE.getAttrib(img, 'alt');
       
   262 
       
   263 					// Try polling out the title
       
   264 					if (alt == "")
       
   265 						alt = tinyMCE.getAttrib(img, 'title');
       
   266 
       
   267 					// Fix width/height attributes if the styles is specified
       
   268 					if (tinyMCE.isGecko) {
       
   269 						var w = img.style.width;
       
   270 						if (w != null && w != "")
       
   271 							img.setAttribute("width", w);
       
   272 
       
   273 						var h = img.style.height;
       
   274 						if (h != null && h != "")
       
   275 							img.setAttribute("height", h);
       
   276 					}
       
   277 
       
   278 					border = tinyMCE.getAttrib(img, 'border');
       
   279 					hspace = tinyMCE.getAttrib(img, 'hspace');
       
   280 					vspace = tinyMCE.getAttrib(img, 'vspace');
       
   281 					width = tinyMCE.getAttrib(img, 'width');
       
   282 					height = tinyMCE.getAttrib(img, 'height');
       
   283 					align = tinyMCE.getAttrib(img, 'align');
       
   284 					onmouseover = tinyMCE.getAttrib(img, 'onmouseover');
       
   285 					onmouseout = tinyMCE.getAttrib(img, 'onmouseout');
       
   286 					title = tinyMCE.getAttrib(img, 'title');
       
   287 
       
   288 					// Is realy specified?
       
   289 					if (tinyMCE.isMSIE) {
       
   290 						width = img.attributes['width'].specified ? width : "";
       
   291 						height = img.attributes['height'].specified ? height : "";
       
   292 					}
       
   293 
       
   294 					//onmouseover = tinyMCE.getImageSrc(tinyMCE.cleanupEventStr(onmouseover));
       
   295 					//onmouseout = tinyMCE.getImageSrc(tinyMCE.cleanupEventStr(onmouseout));
       
   296 
       
   297 					src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, img, true);");
       
   298 
       
   299 					// Use mce_src if defined
       
   300 					mceRealSrc = tinyMCE.getAttrib(img, 'mce_src');
       
   301 					if (mceRealSrc != "") {
       
   302 						src = mceRealSrc;
       
   303 
       
   304 						if (tinyMCE.getParam('convert_urls'))
       
   305 							src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, img, true);");
       
   306 					}
       
   307 
       
   308 					//if (onmouseover != "")
       
   309 					//	onmouseover = eval(tinyMCE.settings['urlconverter_callback'] + "(onmouseover, img, true);");
       
   310 
       
   311 					//if (onmouseout != "")
       
   312 					//	onmouseout = eval(tinyMCE.settings['urlconverter_callback'] + "(onmouseout, img, true);");
       
   313 
       
   314 					action = "update";
       
   315 				}
       
   316 
       
   317 				var template = new Array();
       
   318 
       
   319 				template['file'] = 'image.htm?src={$src}';
       
   320 				template['width'] = 355;
       
   321 				template['height'] = 265 + (tinyMCE.isMSIE ? 25 : 0);
       
   322 
       
   323 				// Language specific width and height addons
       
   324 				template['width'] += tinyMCE.getLang('lang_insert_image_delta_width', 0);
       
   325 				template['height'] += tinyMCE.getLang('lang_insert_image_delta_height', 0);
       
   326 
       
   327 				if (inst.settings['insertimage_callback']) {
       
   328 					var returnVal = eval(inst.settings['insertimage_callback'] + "(src, alt, border, hspace, vspace, width, height, align, title, onmouseover, onmouseout, action);");
       
   329 					if (returnVal && returnVal['src'])
       
   330 						TinyMCE_AdvancedTheme._insertImage(returnVal['src'], returnVal['alt'], returnVal['border'], returnVal['hspace'], returnVal['vspace'], returnVal['width'], returnVal['height'], returnVal['align'], returnVal['title'], returnVal['onmouseover'], returnVal['onmouseout']);
       
   331 				} else
       
   332 					tinyMCE.openWindow(template, {src : src, alt : alt, border : border, hspace : hspace, vspace : vspace, width : width, height : height, align : align, title : title, onmouseover : onmouseover, onmouseout : onmouseout, action : action, inline : "yes"});
       
   333 
       
   334 				return true;
       
   335 
       
   336 			case "forecolor":
       
   337 				var fcp = new TinyMCE_Layer(editor_id + '_fcPreview', false), p, img, elm;
       
   338 
       
   339 				TinyMCE_AdvancedTheme._hideMenus(editor_id);
       
   340 
       
   341 				if (!fcp.exists()) {
       
   342 					fcp.create('div', 'mceColorPreview', document.getElementById(editor_id + '_toolbar'));
       
   343 					elm = fcp.getElement();
       
   344 					elm._editor_id = editor_id;
       
   345 					elm._command = "forecolor";
       
   346 					elm._switchId = editor_id + "_forecolor";
       
   347 					tinyMCE.addEvent(elm, 'click', TinyMCE_AdvancedTheme._handleMenuEvent);
       
   348 					tinyMCE.addEvent(elm, 'mouseover', TinyMCE_AdvancedTheme._handleMenuEvent);
       
   349 					tinyMCE.addEvent(elm, 'mouseout', TinyMCE_AdvancedTheme._handleMenuEvent);
       
   350 				}
       
   351 
       
   352 				img = tinyMCE.selectNodes(document.getElementById(editor_id + "_forecolor"), function(n) {return n.nodeName == "IMG";})[0];
       
   353 				p = tinyMCE.getAbsPosition(img, document.getElementById(editor_id + '_toolbar'));
       
   354 
       
   355 				fcp.moveTo(p.absLeft, p.absTop);
       
   356 				fcp.getElement().style.backgroundColor = value != null ? value : tinyMCE.getInstanceById(editor_id).foreColor;
       
   357 				fcp.show();
       
   358 
       
   359 				return false;
       
   360 
       
   361 			case "forecolorpicker":
       
   362 				this._pickColor(editor_id, 'forecolor');
       
   363 				return true;
       
   364 
       
   365 			case "forecolorMenu":
       
   366 				TinyMCE_AdvancedTheme._hideMenus(editor_id);
       
   367 
       
   368 				// Create color layer
       
   369 				var ml = new TinyMCE_Layer(editor_id + '_fcMenu');
       
   370 
       
   371 				if (!ml.exists())
       
   372 					ml.create('div', 'mceMenu', document.body, TinyMCE_AdvancedTheme._getColorHTML(editor_id, 'theme_advanced_text_colors', 'forecolor'));
       
   373 
       
   374 				tinyMCE.switchClass(editor_id + '_forecolor', 'mceMenuButtonFocus');
       
   375 				ml.moveRelativeTo(document.getElementById(editor_id + "_forecolor"), 'bl');
       
   376 
       
   377 				ml.moveBy(tinyMCE.isMSIE && !tinyMCE.isOpera ? -1 : 1, -1);
       
   378 
       
   379 				if (tinyMCE.isOpera)
       
   380 					ml.moveBy(0, -2);
       
   381 
       
   382 				ml.show();
       
   383 			return true;
       
   384 
       
   385 			case "HiliteColor":
       
   386 				var bcp = new TinyMCE_Layer(editor_id + '_bcPreview', false), p, img;
       
   387 
       
   388 				TinyMCE_AdvancedTheme._hideMenus(editor_id);
       
   389 
       
   390 				if (!bcp.exists()) {
       
   391 					bcp.create('div', 'mceColorPreview', document.getElementById(editor_id + '_toolbar'));
       
   392 					elm = bcp.getElement();
       
   393 					elm._editor_id = editor_id;
       
   394 					elm._command = "HiliteColor";
       
   395 					elm._switchId = editor_id + "_backcolor";
       
   396 					tinyMCE.addEvent(elm, 'click', TinyMCE_AdvancedTheme._handleMenuEvent);
       
   397 					tinyMCE.addEvent(elm, 'mouseover', TinyMCE_AdvancedTheme._handleMenuEvent);
       
   398 					tinyMCE.addEvent(elm, 'mouseout', TinyMCE_AdvancedTheme._handleMenuEvent);
       
   399 				}
       
   400 
       
   401 				img = tinyMCE.selectNodes(document.getElementById(editor_id + "_backcolor"), function(n) {return n.nodeName == "IMG";})[0];
       
   402 				p = tinyMCE.getAbsPosition(img, document.getElementById(editor_id + '_toolbar'));
       
   403 
       
   404 				bcp.moveTo(p.absLeft, p.absTop);
       
   405 				bcp.getElement().style.backgroundColor = value != null ? value : tinyMCE.getInstanceById(editor_id).backColor;
       
   406 				bcp.show();
       
   407 
       
   408 				return false;
       
   409 
       
   410 			case "HiliteColorMenu":
       
   411 				TinyMCE_AdvancedTheme._hideMenus(editor_id);
       
   412 
       
   413 				// Create color layer
       
   414 				var ml = new TinyMCE_Layer(editor_id + '_bcMenu');
       
   415 
       
   416 				if (!ml.exists())
       
   417 					ml.create('div', 'mceMenu', document.body, TinyMCE_AdvancedTheme._getColorHTML(editor_id, 'theme_advanced_background_colors', 'HiliteColor'));
       
   418 
       
   419 				tinyMCE.switchClass(editor_id + '_backcolor', 'mceMenuButtonFocus');
       
   420 				ml.moveRelativeTo(document.getElementById(editor_id + "_backcolor"), 'bl');
       
   421 
       
   422 				ml.moveBy(tinyMCE.isMSIE && !tinyMCE.isOpera ? -1 : 1, -1);
       
   423 
       
   424 				if (tinyMCE.isOpera)
       
   425 					ml.moveBy(0, -2);
       
   426 
       
   427 				ml.show();
       
   428 			return true;
       
   429 	
       
   430 			case "backcolorpicker":
       
   431 				this._pickColor(editor_id, 'HiliteColor');
       
   432 				return true;
       
   433 
       
   434 			case "mceColorPicker":
       
   435 				if (user_interface) {
       
   436 					var template = [];
       
   437 	
       
   438 					if (!value['callback'] && !value['color'])
       
   439 						value['color'] = value['document'].getElementById(value['element_id']).value;
       
   440 
       
   441 					template['file'] = 'color_picker.htm';
       
   442 					template['width'] = 380;
       
   443 					template['height'] = 250;
       
   444 					template['close_previous'] = "no";
       
   445 
       
   446 					template['width'] += tinyMCE.getLang('lang_theme_advanced_colorpicker_delta_width', 0);
       
   447 					template['height'] += tinyMCE.getLang('lang_theme_advanced_colorpicker_delta_height', 0);
       
   448 
       
   449 					if (typeof(value['store_selection']) == "undefined")
       
   450 						value['store_selection'] = true;
       
   451 
       
   452 					tinyMCE.lastColorPickerValue = value;
       
   453 					tinyMCE.openWindow(template, {editor_id : editor_id, mce_store_selection : value['store_selection'], inline : "yes", command : "mceColorPicker", input_color : value['color']});
       
   454 				} else {
       
   455 					var savedVal = tinyMCE.lastColorPickerValue, elm;
       
   456 
       
   457 					if (savedVal['callback']) {
       
   458 						savedVal['callback'](value);
       
   459 						return true;
       
   460 					}
       
   461 
       
   462 					elm = savedVal['document'].getElementById(savedVal['element_id']);
       
   463 					elm.value = value;
       
   464 
       
   465 					if (elm.onchange != null && elm.onchange != '')
       
   466 						eval('elm.onchange();');
       
   467 				}
       
   468 			return true;
       
   469 
       
   470 			case "mceCodeEditor":
       
   471 				var template = new Array();
       
   472 
       
   473 				template['file'] = 'source_editor.htm';
       
   474 				template['width'] = parseInt(tinyMCE.getParam("theme_advanced_source_editor_width", 720));
       
   475 				template['height'] = parseInt(tinyMCE.getParam("theme_advanced_source_editor_height", 580));
       
   476 
       
   477 				tinyMCE.openWindow(template, {editor_id : editor_id, resizable : "yes", scrollbars : "no", inline : "yes"});
       
   478 				return true;
       
   479 
       
   480 			case "mceCharMap":
       
   481 				var template = new Array();
       
   482 
       
   483 				template['file'] = 'charmap.htm';
       
   484 				template['width'] = 550 + (tinyMCE.isOpera ? 40 : 0);
       
   485 				template['height'] = 250;
       
   486 
       
   487 				template['width'] += tinyMCE.getLang('lang_theme_advanced_charmap_delta_width', 0);
       
   488 				template['height'] += tinyMCE.getLang('lang_theme_advanced_charmap_delta_height', 0);
       
   489 
       
   490 				tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes"});
       
   491 				return true;
       
   492 
       
   493 			case "mceInsertAnchor":
       
   494 				var template = new Array();
       
   495 
       
   496 				template['file'] = 'anchor.htm';
       
   497 				template['width'] = 320;
       
   498 				template['height'] = 90 + (tinyMCE.isNS7 ? 30 : 0);
       
   499 
       
   500 				template['width'] += tinyMCE.getLang('lang_theme_advanced_anchor_delta_width', 0);
       
   501 				template['height'] += tinyMCE.getLang('lang_theme_advanced_anchor_delta_height', 0);
       
   502 
       
   503 				tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes"});
       
   504 				return true;
       
   505 
       
   506 			case "mceNewDocument":
       
   507 				if (confirm(tinyMCE.getLang('lang_newdocument')))
       
   508 					tinyMCE.execInstanceCommand(editor_id, 'mceSetContent', false, ' ');
       
   509 
       
   510 				return true;
       
   511 		}
       
   512 
       
   513 		return false;
       
   514 	},
       
   515 
       
   516 	/**
       
   517 	 * Editor instance template function.
       
   518 	 */
       
   519 	getEditorTemplate : function(settings, editorId) {
       
   520 		function removeFromArray(in_array, remove_array) {
       
   521 			var outArray = new Array(), skip;
       
   522 			
       
   523 			for (var i=0; i<in_array.length; i++) {
       
   524 				skip = false;
       
   525 
       
   526 				for (var j=0; j<remove_array.length; j++) {
       
   527 					if (in_array[i] == remove_array[j]) {
       
   528 						skip = true;
       
   529 					}
       
   530 				}
       
   531 
       
   532 				if (!skip) {
       
   533 					outArray[outArray.length] = in_array[i];
       
   534 				}
       
   535 			}
       
   536 
       
   537 			return outArray;
       
   538 		}
       
   539 
       
   540 		function addToArray(in_array, add_array) {
       
   541 			for (var i=0; i<add_array.length; i++) {
       
   542 				in_array[in_array.length] = add_array[i];
       
   543 			}
       
   544 
       
   545 			return in_array;
       
   546 		}
       
   547 
       
   548 		var template = new Array();
       
   549 		var deltaHeight = 0;
       
   550 		var resizing = tinyMCE.getParam("theme_advanced_resizing", false);
       
   551 		var path = tinyMCE.getParam("theme_advanced_path", true);
       
   552 		var statusbarHTML = '<div id="{$editor_id}_path" class="mceStatusbarPathText" style="display: ' + (path ? "block" : "none") + '">&#160;</div><div id="{$editor_id}_resize" class="mceStatusbarResize" style="display: ' + (resizing ? "block" : "none") + '" onmousedown="tinyMCE.themes.advanced._setResizing(event,\'{$editor_id}\',true);"></div><br style="clear: both" />';
       
   553 		var layoutManager = tinyMCE.getParam("theme_advanced_layout_manager", "SimpleLayout");
       
   554 
       
   555 		// Setup style select options -- MOVED UP FOR EXTERNAL TOOLBAR COMPATABILITY!
       
   556 		var styleSelectHTML = '<option value="">{$lang_theme_style_select}</option>';
       
   557 		if (settings['theme_advanced_styles']) {
       
   558 			var stylesAr = settings['theme_advanced_styles'].split(';');
       
   559 			
       
   560 			for (var i=0; i<stylesAr.length; i++) {
       
   561 				var key, value;
       
   562 
       
   563 				key = stylesAr[i].split('=')[0];
       
   564 				value = stylesAr[i].split('=')[1];
       
   565 
       
   566 				styleSelectHTML += '<option value="' + value + '">' + key + '</option>';
       
   567 			}
       
   568 
       
   569 			TinyMCE_AdvancedTheme._autoImportCSSClasses = false;
       
   570 		}
       
   571 
       
   572 		switch(layoutManager) {
       
   573 			case "SimpleLayout" : //the default TinyMCE Layout (for backwards compatibility)...
       
   574 				var toolbarHTML = "";
       
   575 				var toolbarLocation = tinyMCE.getParam("theme_advanced_toolbar_location", "bottom");
       
   576 				var toolbarAlign = tinyMCE.getParam("theme_advanced_toolbar_align", "center");
       
   577 				var pathLocation = tinyMCE.getParam("theme_advanced_path_location", "none"); // Compatiblity
       
   578 				var statusbarLocation = tinyMCE.getParam("theme_advanced_statusbar_location", pathLocation);
       
   579 				var defVals = {
       
   580 					theme_advanced_buttons1 : "bold,italic,underline,strikethrough,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,styleselect,formatselect",
       
   581 					theme_advanced_buttons2 : "bullist,numlist,separator,outdent,indent,separator,undo,redo,separator,link,unlink,anchor,image,cleanup,help,code",
       
   582 					theme_advanced_buttons3 : "hr,removeformat,visualaid,separator,sub,sup,separator,charmap"
       
   583 				};
       
   584 
       
   585 				// Add accessibility control
       
   586 				toolbarHTML += '<a href="#" accesskey="q" title="' + tinyMCE.getLang("lang_toolbar_focus") + '"';
       
   587 
       
   588 				if (!tinyMCE.getParam("accessibility_focus"))
       
   589 					toolbarHTML += ' onfocus="tinyMCE.getInstanceById(\'' + editorId + '\').getWin().focus();"';
       
   590 
       
   591 				toolbarHTML += '></a>';
       
   592 
       
   593 				// Render rows
       
   594 				for (var i=1; i<100; i++) {
       
   595 					var def = defVals["theme_advanced_buttons" + i];
       
   596 
       
   597 					var buttons = tinyMCE.getParam("theme_advanced_buttons" + i, def == null ? '' : def, true, ',');
       
   598 					if (buttons.length == 0)
       
   599 						break;
       
   600 
       
   601 					buttons = removeFromArray(buttons, tinyMCE.getParam("theme_advanced_disable", "", true, ','));
       
   602 					buttons = addToArray(buttons, tinyMCE.getParam("theme_advanced_buttons" + i + "_add", "", true, ','));
       
   603 					buttons = addToArray(tinyMCE.getParam("theme_advanced_buttons" + i + "_add_before", "", true, ','), buttons);
       
   604 
       
   605 					for (var b=0; b<buttons.length; b++)
       
   606 						toolbarHTML += tinyMCE.getControlHTML(buttons[b]);
       
   607 
       
   608 					if (buttons.length > 0) {
       
   609 						toolbarHTML += "<br />";
       
   610 						deltaHeight -= 23;
       
   611 					}
       
   612 				}
       
   613 
       
   614 				// Add accessibility control
       
   615 				toolbarHTML += '<a href="#" accesskey="z" onfocus="tinyMCE.getInstanceById(\'' + editorId + '\').getWin().focus();"></a>';
       
   616 
       
   617 				// Setup template html
       
   618 				template['html'] = '<table class="mceEditor" border="0" cellpadding="0" cellspacing="0" width="{$width}" height="{$height}" style="width:{$width_style};height:{$height_style}"><tbody>';
       
   619 
       
   620 				if (toolbarLocation == "top")
       
   621 					template['html'] += '<tr><td dir="ltr" class="mceToolbarTop" align="' + toolbarAlign + '" height="1" nowrap="nowrap"><span id="' + editorId + '_toolbar" class="mceToolbarContainer">' + toolbarHTML + '</span></td></tr>';
       
   622 
       
   623 				if (statusbarLocation == "top") {
       
   624 					template['html'] += '<tr><td class="mceStatusbarTop" height="1">' + statusbarHTML + '</td></tr>';
       
   625 					deltaHeight -= 23;
       
   626 				}
       
   627 
       
   628 				template['html'] += '<tr><td align="center"><span id="{$editor_id}"></span></td></tr>';
       
   629 
       
   630 				if (toolbarLocation == "bottom")
       
   631 					template['html'] += '<tr><td dir="ltr" class="mceToolbarBottom" align="' + toolbarAlign + '" height="1"><span id="' + editorId + '_toolbar" class="mceToolbarContainer">' + toolbarHTML + '</span></td></tr>';
       
   632 
       
   633 				// External toolbar changes
       
   634 				if (toolbarLocation == "external") {
       
   635 					var bod = document.body;
       
   636 					var elm = document.createElement ("div");
       
   637 
       
   638 					toolbarHTML = tinyMCE.replaceVar(toolbarHTML, 'style_select_options', styleSelectHTML);
       
   639 					toolbarHTML = tinyMCE.applyTemplate(toolbarHTML, {editor_id : editorId});
       
   640 
       
   641 					elm.className = "mceToolbarExternal";
       
   642 					elm.id = editorId+"_toolbar";
       
   643 					elm.innerHTML = '<table width="100%" border="0" align="center"><tr><td align="center">'+toolbarHTML+'</td></tr></table>';
       
   644 					bod.appendChild (elm);
       
   645 					// bod.style.marginTop = elm.offsetHeight + "px";
       
   646 
       
   647 					deltaHeight = 0;
       
   648 					tinyMCE.getInstanceById(editorId).toolbarElement = elm;
       
   649 
       
   650 					//template['html'] = '<div id="mceExternalToolbar" align="center" class="mceToolbarExternal"><table width="100%" border="0" align="center"><tr><td align="center">'+toolbarHTML+'</td></tr></table></div>' + template["html"];
       
   651 				} else {
       
   652 					tinyMCE.getInstanceById(editorId).toolbarElement = null;
       
   653 				}
       
   654 
       
   655 				if (statusbarLocation == "bottom") {
       
   656 					template['html'] += '<tr><td class="mceStatusbarBottom" height="1">' + statusbarHTML + '</td></tr>';
       
   657 					deltaHeight -= 23;
       
   658 				}
       
   659 
       
   660 				template['html'] += '</tbody></table>';
       
   661 				//"SimpleLayout"
       
   662 			break;
       
   663 
       
   664 			case "RowLayout" : //Container Layout - containers defined in "theme_advanced_containers" are rendered from top to bottom.
       
   665 				template['html'] = '<table class="mceEditor" border="0" cellpadding="0" cellspacing="0" width="{$width}" height="{$height}" style="width:{$width}px;height:{$height}px"><tbody>';
       
   666 
       
   667 				var containers = tinyMCE.getParam("theme_advanced_containers", "", true, ",");
       
   668 				var defaultContainerCSS = tinyMCE.getParam("theme_advanced_containers_default_class", "container");
       
   669 				var defaultContainerAlign = tinyMCE.getParam("theme_advanced_containers_default_align", "center");
       
   670 
       
   671 				//Render Containers:
       
   672 				for (var i = 0; i < containers.length; i++)
       
   673 				{
       
   674 					if (containers[i] == "mceEditor") //Exceptions for mceEditor and ...
       
   675 						template['html'] += '<tr><td align="center" class="mceEditor_border"><span id="{$editor_id}"></span></td></tr>';
       
   676 					else if (containers[i] == "mceElementpath" || containers[i] == "mceStatusbar") // ... mceElementpath:
       
   677 					{
       
   678 						var pathClass = "mceStatusbar";
       
   679 
       
   680 						if (i == containers.length-1)
       
   681 						{
       
   682 							pathClass = "mceStatusbarBottom";
       
   683 						}
       
   684 						else if (i == 0)
       
   685 						{
       
   686 							pathClass = "mceStatusbar";
       
   687 						}
       
   688 						else
       
   689 						{
       
   690 							deltaHeight-=2;
       
   691 						}
       
   692 
       
   693 						template['html'] += '<tr><td class="' + pathClass + '" height="1">' + statusbarHTML + '</td></tr>';
       
   694 						deltaHeight -= 22;
       
   695 					} else { // Render normal Container
       
   696 						var curContainer = tinyMCE.getParam("theme_advanced_container_"+containers[i], "", true, ',');
       
   697 						var curContainerHTML = "";
       
   698 						var curAlign = tinyMCE.getParam("theme_advanced_container_"+containers[i]+"_align", defaultContainerAlign);
       
   699 						var curCSS = tinyMCE.getParam("theme_advanced_container_"+containers[i]+"_class", defaultContainerCSS);
       
   700 
       
   701 						curContainer = removeFromArray(curContainer, tinyMCE.getParam("theme_advanced_disable", "", true, ','));
       
   702 
       
   703 						for (var j=0; j<curContainer.length; j++)
       
   704 							curContainerHTML += tinyMCE.getControlHTML(curContainer[j]);
       
   705 
       
   706 						if (curContainer.length > 0) {
       
   707 							curContainerHTML += "<br />";
       
   708 							deltaHeight -= 23;
       
   709 						}
       
   710 
       
   711 						template['html'] += '<tr><td class="' + curCSS + '" align="' + curAlign + '" height="1">' + curContainerHTML + '</td></tr>';
       
   712 					}
       
   713 				}
       
   714 
       
   715 				template['html'] += '</tbody></table>';
       
   716 				//RowLayout
       
   717 			break;
       
   718 
       
   719 			case "CustomLayout" : //User defined layout callback...
       
   720 				var customLayout = tinyMCE.getParam("theme_advanced_custom_layout","");
       
   721 
       
   722 				if (customLayout != "" && eval("typeof(" + customLayout + ")") != "undefined") {
       
   723 					template = eval(customLayout + "(template);");
       
   724 				}
       
   725 			break;
       
   726 		}
       
   727 
       
   728 		if (resizing)
       
   729 			template['html'] += '<span id="{$editor_id}_resize_box" class="mceResizeBox"></span>';
       
   730 
       
   731 		template['html'] = tinyMCE.replaceVar(template['html'], 'style_select_options', styleSelectHTML);
       
   732 
       
   733 		// Set to default values
       
   734 		if (!template['delta_width'])
       
   735 			template['delta_width'] = 0;
       
   736 
       
   737 		if (!template['delta_height'])
       
   738 			template['delta_height'] = deltaHeight;
       
   739 
       
   740 		return template;
       
   741 	},
       
   742 
       
   743 	initInstance : function(inst) {
       
   744 		if (tinyMCE.getParam("theme_advanced_resizing", false)) {
       
   745 			if (tinyMCE.getParam("theme_advanced_resizing_use_cookie", true)) {
       
   746 				var w = TinyMCE_AdvancedTheme._getCookie("TinyMCE_" + inst.editorId + "_width");
       
   747 				var h = TinyMCE_AdvancedTheme._getCookie("TinyMCE_" + inst.editorId + "_height");
       
   748 
       
   749 				TinyMCE_AdvancedTheme._resizeTo(inst, w, h, tinyMCE.getParam("theme_advanced_resize_horizontal", true));
       
   750 			}
       
   751 		}
       
   752 
       
   753 		inst.addShortcut('ctrl', 'k', 'lang_link_desc', 'mceLink');
       
   754 	},
       
   755 
       
   756 	removeInstance : function(inst) {
       
   757 		new TinyMCE_Layer(inst.editorId + '_fcMenu').remove();
       
   758 		new TinyMCE_Layer(inst.editorId + '_bcMenu').remove();
       
   759 	},
       
   760 
       
   761 	hideInstance : function(inst) {
       
   762 		TinyMCE_AdvancedTheme._hideMenus(inst.editorId);
       
   763 	},
       
   764 
       
   765 	_handleMenuEvent : function(e) {
       
   766 		var te = tinyMCE.isMSIE ? window.event.srcElement : e.target;
       
   767 		tinyMCE._menuButtonEvent(e.type == "mouseover" ? "over" : "out", document.getElementById(te._switchId));
       
   768 
       
   769 		if (e.type == "click")
       
   770 			tinyMCE.execInstanceCommand(te._editor_id, te._command);
       
   771 	},
       
   772 
       
   773 	_hideMenus : function(id) {
       
   774 		var fcml = new TinyMCE_Layer(id + '_fcMenu'), bcml = new TinyMCE_Layer(id + '_bcMenu');
       
   775 
       
   776 		if (fcml.exists() && fcml.isVisible()) {
       
   777 			tinyMCE.switchClass(id + '_forecolor', 'mceMenuButton');
       
   778 			fcml.hide();
       
   779 		}
       
   780 
       
   781 		if (bcml.exists() && bcml.isVisible()) {
       
   782 			tinyMCE.switchClass(id + '_backcolor', 'mceMenuButton');
       
   783 			bcml.hide();
       
   784 		}
       
   785 	},
       
   786 
       
   787 	/**
       
   788 	 * Node change handler.
       
   789 	 */
       
   790 	handleNodeChange : function(editor_id, node, undo_index, undo_levels, visual_aid, any_selection, setup_content) {
       
   791 		var alignNode, breakOut, classNode;
       
   792 
       
   793 		function selectByValue(select_elm, value, first_index) {
       
   794 			first_index = typeof(first_index) == "undefined" ? false : true;
       
   795 
       
   796 			if (select_elm) {
       
   797 				for (var i=0; i<select_elm.options.length; i++) {
       
   798 					var ov = "" + select_elm.options[i].value;
       
   799 
       
   800 					if (first_index && ov.toLowerCase().indexOf(value.toLowerCase()) == 0) {
       
   801 						select_elm.selectedIndex = i;
       
   802 						return true;
       
   803 					}
       
   804 
       
   805 					if (ov == value) {
       
   806 						select_elm.selectedIndex = i;
       
   807 						return true;
       
   808 					}
       
   809 				}
       
   810 			}
       
   811 
       
   812 			return false;
       
   813 		};
       
   814 
       
   815 		// No node provided
       
   816 		if (node == null)
       
   817 			return;
       
   818 
       
   819 		// Update path
       
   820 		var pathElm = document.getElementById(editor_id + "_path");
       
   821 		var inst = tinyMCE.getInstanceById(editor_id);
       
   822 		var doc = inst.getDoc();
       
   823 		TinyMCE_AdvancedTheme._hideMenus(editor_id);
       
   824 
       
   825 		if (pathElm) {
       
   826 			// Get node path
       
   827 			var parentNode = node;
       
   828 			var path = new Array();
       
   829 			
       
   830 			while (parentNode != null) {
       
   831 				if (parentNode.nodeName.toUpperCase() == "BODY") {
       
   832 					break;
       
   833 				}
       
   834 
       
   835 				// Only append element nodes to path
       
   836 				if (parentNode.nodeType == 1 && tinyMCE.getAttrib(parentNode, "class").indexOf('mceItemHidden') == -1) {
       
   837 					path[path.length] = parentNode;
       
   838 				}
       
   839 
       
   840 				parentNode = parentNode.parentNode;
       
   841 			}
       
   842 
       
   843 			// Setup HTML
       
   844 			var html = "";
       
   845 			for (var i=path.length-1; i>=0; i--) {
       
   846 				var nodeName = path[i].nodeName.toLowerCase();
       
   847 				var nodeData = "";
       
   848 
       
   849 				if (nodeName.indexOf("html:") == 0)
       
   850 					nodeName = nodeName.substring(5);
       
   851 
       
   852 				if (nodeName == "b") {
       
   853 					nodeName = "strong";
       
   854 				}
       
   855 
       
   856 				if (nodeName == "i") {
       
   857 					nodeName = "em";
       
   858 				}
       
   859 
       
   860 				if (nodeName == "span") {
       
   861 					var cn = tinyMCE.getAttrib(path[i], "class");
       
   862 					if (cn != "" && cn.indexOf('mceItem') == -1)
       
   863 						nodeData += "class: " + cn + " ";
       
   864 
       
   865 					var st = tinyMCE.getAttrib(path[i], "style");
       
   866 					if (st != "") {
       
   867 						st = tinyMCE.serializeStyle(tinyMCE.parseStyle(st));
       
   868 						nodeData += "style: " + tinyMCE.xmlEncode(st) + " ";
       
   869 					}
       
   870 				}
       
   871 
       
   872 				if (nodeName == "font") {
       
   873 					if (tinyMCE.getParam("convert_fonts_to_spans"))
       
   874 						nodeName = "span";
       
   875 
       
   876 					var face = tinyMCE.getAttrib(path[i], "face");
       
   877 					if (face != "")
       
   878 						nodeData += "font: " + tinyMCE.xmlEncode(face) + " ";
       
   879 
       
   880 					var size = tinyMCE.getAttrib(path[i], "size");
       
   881 					if (size != "")
       
   882 						nodeData += "size: " + tinyMCE.xmlEncode(size) + " ";
       
   883 
       
   884 					var color = tinyMCE.getAttrib(path[i], "color");
       
   885 					if (color != "")
       
   886 						nodeData += "color: " + tinyMCE.xmlEncode(color) + " ";
       
   887 				}
       
   888 
       
   889 				if (tinyMCE.getAttrib(path[i], 'id') != "") {
       
   890 					nodeData += "id: " + path[i].getAttribute('id') + " ";
       
   891 				}
       
   892 
       
   893 				var className = tinyMCE.getVisualAidClass(tinyMCE.getAttrib(path[i], "class"), false);
       
   894 				if (className != "" && className.indexOf('mceItem') == -1)
       
   895 					nodeData += "class: " + className + " ";
       
   896 
       
   897 				if (tinyMCE.getAttrib(path[i], 'src') != "") {
       
   898 					var src = tinyMCE.getAttrib(path[i], "mce_src");
       
   899 
       
   900 					if (src == "")
       
   901 						 src = tinyMCE.getAttrib(path[i], "src");
       
   902 
       
   903 					nodeData += "src: " + tinyMCE.xmlEncode(src) + " ";
       
   904 				}
       
   905 
       
   906 				if (path[i].nodeName == 'A' && tinyMCE.getAttrib(path[i], 'href') != "") {
       
   907 					var href = tinyMCE.getAttrib(path[i], "mce_href");
       
   908 
       
   909 					if (href == "")
       
   910 						 href = tinyMCE.getAttrib(path[i], "href");
       
   911 
       
   912 					nodeData += "href: " + tinyMCE.xmlEncode(href) + " ";
       
   913 				}
       
   914 
       
   915 				className = tinyMCE.getAttrib(path[i], "class");
       
   916 				if ((nodeName == "img" || nodeName == "span") && className.indexOf('mceItem') != -1) {
       
   917 					nodeName = className.replace(/mceItem([a-z]+)/gi, '$1').toLowerCase();
       
   918 					nodeData = path[i].getAttribute('title');
       
   919 				}
       
   920 
       
   921 				if (nodeName == "a" && (anchor = tinyMCE.getAttrib(path[i], "name")) != "") {
       
   922 					nodeName = "a";
       
   923 					nodeName += "#" + tinyMCE.xmlEncode(anchor);
       
   924 					nodeData = "";
       
   925 				}
       
   926 
       
   927 				if (tinyMCE.getAttrib(path[i], 'name').indexOf("mce_") != 0) {
       
   928 					var className = tinyMCE.getVisualAidClass(tinyMCE.getAttrib(path[i], "class"), false);
       
   929 					if (className != "" && className.indexOf('mceItem') == -1) {
       
   930 						nodeName += "." + className;
       
   931 					}
       
   932 				}
       
   933 
       
   934 				var cmd = 'tinyMCE.execInstanceCommand(\'' + editor_id + '\',\'mceSelectNodeDepth\',false,\'' + i + '\');';
       
   935 				html += '<a title="' + nodeData + '" href="javascript:' + cmd + '" onclick="' + cmd + 'return false;" onmousedown="return false;" target="_self" class="mcePathItem">' + nodeName + '</a>';
       
   936 
       
   937 				if (i > 0) {
       
   938 					html += " &raquo; ";
       
   939 				}
       
   940 			}
       
   941 
       
   942 			pathElm.innerHTML = '<a href="#" accesskey="x"></a>' + tinyMCE.getLang('lang_theme_path') + ": " + html + '&#160;';
       
   943 		}
       
   944 
       
   945 		// Reset old states
       
   946 		tinyMCE.switchClass(editor_id + '_justifyleft', 'mceButtonNormal');
       
   947 		tinyMCE.switchClass(editor_id + '_justifyright', 'mceButtonNormal');
       
   948 		tinyMCE.switchClass(editor_id + '_justifycenter', 'mceButtonNormal');
       
   949 		tinyMCE.switchClass(editor_id + '_justifyfull', 'mceButtonNormal');
       
   950 		tinyMCE.switchClass(editor_id + '_bold', 'mceButtonNormal');
       
   951 		tinyMCE.switchClass(editor_id + '_italic', 'mceButtonNormal');
       
   952 		tinyMCE.switchClass(editor_id + '_underline', 'mceButtonNormal');
       
   953 		tinyMCE.switchClass(editor_id + '_strikethrough', 'mceButtonNormal');
       
   954 		tinyMCE.switchClass(editor_id + '_bullist', 'mceButtonNormal');
       
   955 		tinyMCE.switchClass(editor_id + '_numlist', 'mceButtonNormal');
       
   956 		tinyMCE.switchClass(editor_id + '_sub', 'mceButtonNormal');
       
   957 		tinyMCE.switchClass(editor_id + '_sup', 'mceButtonNormal');
       
   958 		tinyMCE.switchClass(editor_id + '_anchor', 'mceButtonNormal');
       
   959 		tinyMCE.switchClass(editor_id + '_link', 'mceButtonDisabled');
       
   960 		tinyMCE.switchClass(editor_id + '_unlink', 'mceButtonDisabled');
       
   961 		tinyMCE.switchClass(editor_id + '_outdent', 'mceButtonDisabled');
       
   962 		tinyMCE.switchClass(editor_id + '_image', 'mceButtonNormal');
       
   963 		tinyMCE.switchClass(editor_id + '_hr', 'mceButtonNormal');
       
   964 
       
   965 		if (node.nodeName == "A" && tinyMCE.getAttrib(node, "class").indexOf('mceItemAnchor') != -1)
       
   966 			tinyMCE.switchClass(editor_id + '_anchor', 'mceButtonSelected');
       
   967 
       
   968 		// Get link
       
   969 		var anchorLink = tinyMCE.getParentElement(node, "a", "href");
       
   970 
       
   971 		if (anchorLink || any_selection) {
       
   972 			tinyMCE.switchClass(editor_id + '_link', anchorLink ? 'mceButtonSelected' : 'mceButtonNormal');
       
   973 			tinyMCE.switchClass(editor_id + '_unlink', anchorLink ? 'mceButtonSelected' : 'mceButtonNormal');
       
   974 		}
       
   975 
       
   976 		// Handle visual aid
       
   977 		tinyMCE.switchClass(editor_id + '_visualaid', visual_aid ? 'mceButtonSelected' : 'mceButtonNormal');
       
   978 
       
   979 		if (undo_levels != -1) {
       
   980 			tinyMCE.switchClass(editor_id + '_undo', 'mceButtonDisabled');
       
   981 			tinyMCE.switchClass(editor_id + '_redo', 'mceButtonDisabled');
       
   982 		}
       
   983 
       
   984 		// Within li, blockquote
       
   985 		if (tinyMCE.getParentElement(node, "li,blockquote"))
       
   986 			tinyMCE.switchClass(editor_id + '_outdent', 'mceButtonNormal');
       
   987 
       
   988 		// Has redo levels
       
   989 		if (undo_index != -1 && (undo_index < undo_levels-1 && undo_levels > 0))
       
   990 			tinyMCE.switchClass(editor_id + '_redo', 'mceButtonNormal');
       
   991 
       
   992 		// Has undo levels
       
   993 		if (undo_index != -1 && (undo_index > 0 && undo_levels > 0))
       
   994 			tinyMCE.switchClass(editor_id + '_undo', 'mceButtonNormal');
       
   995 
       
   996 		// Select class in select box
       
   997 		var selectElm = document.getElementById(editor_id + "_styleSelect");
       
   998 		
       
   999 		if (selectElm) {
       
  1000 			TinyMCE_AdvancedTheme._setupCSSClasses(editor_id);
       
  1001 
       
  1002 			classNode = node;
       
  1003 			breakOut = false;
       
  1004 			var index = 0;
       
  1005 
       
  1006 			do {
       
  1007 				if (classNode && classNode.className) {
       
  1008 					for (var i=0; i<selectElm.options.length; i++) {
       
  1009 						if (selectElm.options[i].value == classNode.className) {
       
  1010 							index = i;
       
  1011 							breakOut = true;
       
  1012 							break;
       
  1013 						}
   834 						}
  1014 					}
   835 					}
       
   836 
       
   837 					na = na.replace(/(html:)/g, '');
       
   838 					na = {name : na, node : n, title : ti};
       
   839 					t.onResolveName.dispatch(t, na);
       
   840 					ti = na.title;
       
   841 					na = na.name;
       
   842 
       
   843 					//u = "javascript:tinymce.EditorManager.get('" + ed.id + "').theme._sel('" + (de++) + "');";
       
   844 					pi = DOM.create('a', {'href' : "#" + (de++) + "", onmousedown : "return false;", title : ti}, na);
       
   845 
       
   846 					if (p.hasChildNodes()) {
       
   847 						p.insertBefore(document.createTextNode(' \u00bb '), p.firstChild);
       
   848 						p.insertBefore(pi, p.firstChild);
       
   849 					} else
       
   850 						p.appendChild(pi);
       
   851 				}, ed.getBody());
       
   852 			}
       
   853 		},
       
   854 
       
   855 		// Commands gets called by execCommand
       
   856 
       
   857 		_sel : function(v) {
       
   858 			this.editor.execCommand('mceSelectNodeDepth', false, v);
       
   859 		},
       
   860 
       
   861 		_mceInsertAnchor : function(ui, v) {
       
   862 			var ed = this.editor;
       
   863 
       
   864 			ed.windowManager.open({
       
   865 				url : tinymce.baseURL + '/themes/advanced/anchor.htm',
       
   866 				width : 320 + Number(ed.getLang('advanced.anchor_delta_width', 0)),
       
   867 				height : 90 + Number(ed.getLang('advanced.anchor_delta_height', 0)),
       
   868 				inline : true
       
   869 			}, {
       
   870 				theme_url : this.url
       
   871 			});
       
   872 		},
       
   873 
       
   874 		_mceCharMap : function() {
       
   875 			var ed = this.editor;
       
   876 
       
   877 			ed.windowManager.open({
       
   878 				url : tinymce.baseURL + '/themes/advanced/charmap.htm',
       
   879 				width : 550 + Number(ed.getLang('advanced.charmap_delta_width', 0)),
       
   880 				height : 250 + Number(ed.getLang('advanced.charmap_delta_height', 0)),
       
   881 				inline : true
       
   882 			}, {
       
   883 				theme_url : this.url
       
   884 			});
       
   885 		},
       
   886 
       
   887 		_mceHelp : function() {
       
   888 			var ed = this.editor;
       
   889 
       
   890 			ed.windowManager.open({
       
   891 				url : tinymce.baseURL + '/themes/advanced/about.htm',
       
   892 				width : 480,
       
   893 				height : 380,
       
   894 				inline : true
       
   895 			}, {
       
   896 				theme_url : this.url
       
   897 			});
       
   898 		},
       
   899 
       
   900 		_mceColorPicker : function(u, v) {
       
   901 			var ed = this.editor;
       
   902 
       
   903 			v = v || {};
       
   904 
       
   905 			ed.windowManager.open({
       
   906 				url : tinymce.baseURL + '/themes/advanced/color_picker.htm',
       
   907 				width : 375 + Number(ed.getLang('advanced.colorpicker_delta_width', 0)),
       
   908 				height : 250 + Number(ed.getLang('advanced.colorpicker_delta_height', 0)),
       
   909 				close_previous : false,
       
   910 				inline : true
       
   911 			}, {
       
   912 				input_color : v.color,
       
   913 				func : v.func,
       
   914 				theme_url : this.url
       
   915 			});
       
   916 		},
       
   917 
       
   918 		_mceCodeEditor : function(ui, val) {
       
   919 			var ed = this.editor;
       
   920 
       
   921 			ed.windowManager.open({
       
   922 				url : tinymce.baseURL + '/themes/advanced/source_editor.htm',
       
   923 				width : parseInt(ed.getParam("theme_advanced_source_editor_width", 720)),
       
   924 				height : parseInt(ed.getParam("theme_advanced_source_editor_height", 580)),
       
   925 				inline : true,
       
   926 				resizable : true,
       
   927 				maximizable : true
       
   928 			}, {
       
   929 				theme_url : this.url
       
   930 			});
       
   931 		},
       
   932 
       
   933 		_mceImage : function(ui, val) {
       
   934 			var ed = this.editor;
       
   935 
       
   936 			ed.windowManager.open({
       
   937 				url : tinymce.baseURL + '/themes/advanced/image.htm',
       
   938 				width : 355 + Number(ed.getLang('advanced.image_delta_width', 0)),
       
   939 				height : 275 + Number(ed.getLang('advanced.image_delta_height', 0)),
       
   940 				inline : true
       
   941 			}, {
       
   942 				theme_url : this.url
       
   943 			});
       
   944 		},
       
   945 
       
   946 		_mceLink : function(ui, val) {
       
   947 			var ed = this.editor;
       
   948 
       
   949 			ed.windowManager.open({
       
   950 				url : tinymce.baseURL + '/themes/advanced/link.htm',
       
   951 				width : 310 + Number(ed.getLang('advanced.link_delta_width', 0)),
       
   952 				height : 200 + Number(ed.getLang('advanced.link_delta_height', 0)),
       
   953 				inline : true
       
   954 			}, {
       
   955 				theme_url : this.url
       
   956 			});
       
   957 		},
       
   958 
       
   959 		_mceNewDocument : function() {
       
   960 			var ed = this.editor;
       
   961 
       
   962 			ed.windowManager.confirm('advanced.newdocument', function(s) {
       
   963 				if (s)
       
   964 					ed.execCommand('mceSetContent', false, '');
       
   965 			});
       
   966 		},
       
   967 
       
   968 		_mceForeColor : function() {
       
   969 			var t = this;
       
   970 
       
   971 			this._mceColorPicker(0, {
       
   972 				func : function(co) {
       
   973 					t.editor.execCommand('ForeColor', false, co);
  1015 				}
   974 				}
  1016 			} while (!breakOut && classNode != null && (classNode = classNode.parentNode) != null);
   975 			});
  1017 
   976 		},
  1018 			selectElm.selectedIndex = index;
   977 
       
   978 		_mceBackColor : function() {
       
   979 			var t = this;
       
   980 
       
   981 			this._mceColorPicker(0, {
       
   982 				func : function(co) {
       
   983 					t.editor.execCommand('HiliteColor', false, co);
       
   984 				}
       
   985 			});
  1019 		}
   986 		}
  1020 
   987 	});
  1021 		// Select formatblock
   988 
  1022 		var selectElm = document.getElementById(editor_id + "_formatSelect");
   989 	tinymce.ThemeManager.add('advanced', tinymce.themes.AdvancedTheme);
  1023 		if (selectElm) {
   990 }());
  1024 			var elm = tinyMCE.getParentElement(node, "p,div,h1,h2,h3,h4,h5,h6,pre,address");
       
  1025 
       
  1026 			if (elm)
       
  1027 				selectByValue(selectElm, "<" + elm.nodeName.toLowerCase() + ">");
       
  1028 			else
       
  1029 				selectByValue(selectElm, "");
       
  1030 		}
       
  1031 
       
  1032 		// Select fontselect
       
  1033 		var selectElm = document.getElementById(editor_id + "_fontNameSelect");
       
  1034 		if (selectElm) {
       
  1035 			if (!tinyMCE.isSafari && !(tinyMCE.isMSIE && !tinyMCE.isOpera)) {
       
  1036 				var face = inst.queryCommandValue('FontName');
       
  1037 
       
  1038 				face = face == null || face == "" ? "" : face;
       
  1039 
       
  1040 				selectByValue(selectElm, face, face != "");
       
  1041 			} else {
       
  1042 				var elm = tinyMCE.getParentElement(node, "font", "face");
       
  1043 
       
  1044 				if (elm) {
       
  1045 					var family = tinyMCE.getAttrib(elm, "face");
       
  1046 
       
  1047 					if (family == '')
       
  1048 						family = '' + elm.style.fontFamily;
       
  1049 
       
  1050 					if (!selectByValue(selectElm, family, family != ""))
       
  1051 						selectByValue(selectElm, "");
       
  1052 				} else
       
  1053 					selectByValue(selectElm, "");
       
  1054 			}
       
  1055 		}
       
  1056 
       
  1057 		// Select fontsize
       
  1058 		var selectElm = document.getElementById(editor_id + "_fontSizeSelect");
       
  1059 		if (selectElm) {
       
  1060 			if (!tinyMCE.isSafari && !tinyMCE.isOpera) {
       
  1061 				var size = inst.queryCommandValue('FontSize');
       
  1062 				selectByValue(selectElm, size == null || size == "" ? "0" : size);
       
  1063 			} else {
       
  1064 				var elm = tinyMCE.getParentElement(node, "font", "size");
       
  1065 				if (elm) {
       
  1066 					var size = tinyMCE.getAttrib(elm, "size");
       
  1067 
       
  1068 					if (size == '') {
       
  1069 						var sizes = new Array('', '8px', '10px', '12px', '14px', '18px', '24px', '36px');
       
  1070 
       
  1071 						size = '' + elm.style.fontSize;
       
  1072 
       
  1073 						for (var i=0; i<sizes.length; i++) {
       
  1074 							if (('' + sizes[i]) == size) {
       
  1075 								size = i;
       
  1076 								break;
       
  1077 							}
       
  1078 						}
       
  1079 					}
       
  1080 
       
  1081 					if (!selectByValue(selectElm, size))
       
  1082 						selectByValue(selectElm, "");
       
  1083 				} else
       
  1084 					selectByValue(selectElm, "0");
       
  1085 			}
       
  1086 		}
       
  1087 
       
  1088 		// Handle align attributes
       
  1089 		alignNode = node;
       
  1090 		breakOut = false;
       
  1091 		do {
       
  1092 			if (!alignNode.getAttribute || !alignNode.getAttribute('align'))
       
  1093 				continue;
       
  1094 
       
  1095 			switch (alignNode.getAttribute('align').toLowerCase()) {
       
  1096 				case "left":
       
  1097 					tinyMCE.switchClass(editor_id + '_justifyleft', 'mceButtonSelected');
       
  1098 					breakOut = true;
       
  1099 				break;
       
  1100 
       
  1101 				case "right":
       
  1102 					tinyMCE.switchClass(editor_id + '_justifyright', 'mceButtonSelected');
       
  1103 					breakOut = true;
       
  1104 				break;
       
  1105 
       
  1106 				case "middle":
       
  1107 				case "center":
       
  1108 					tinyMCE.switchClass(editor_id + '_justifycenter', 'mceButtonSelected');
       
  1109 					breakOut = true;
       
  1110 				break;
       
  1111 
       
  1112 				case "justify":
       
  1113 					tinyMCE.switchClass(editor_id + '_justifyfull', 'mceButtonSelected');
       
  1114 					breakOut = true;
       
  1115 				break;
       
  1116 			}
       
  1117 		} while (!breakOut && (alignNode = alignNode.parentNode) != null);
       
  1118 
       
  1119 		// Div justification
       
  1120 		var div = tinyMCE.getParentElement(node, "div");
       
  1121 		if (div && div.style.textAlign == "center")
       
  1122 			tinyMCE.switchClass(editor_id + '_justifycenter', 'mceButtonSelected');
       
  1123 
       
  1124 		// Do special text
       
  1125 		if (!setup_content) {
       
  1126 			// , "JustifyLeft", "_justifyleft", "JustifyCenter", "justifycenter", "JustifyRight", "justifyright", "JustifyFull", "justifyfull", "InsertUnorderedList", "bullist", "InsertOrderedList", "numlist", "InsertUnorderedList", "bullist", "Outdent", "outdent", "Indent", "indent", "subscript", "sub"
       
  1127 			var ar = new Array("Bold", "_bold", "Italic", "_italic", "Strikethrough", "_strikethrough", "superscript", "_sup", "subscript", "_sub");
       
  1128 			for (var i=0; i<ar.length; i+=2) {
       
  1129 				if (inst.queryCommandState(ar[i]))
       
  1130 					tinyMCE.switchClass(editor_id + ar[i+1], 'mceButtonSelected');
       
  1131 			}
       
  1132 
       
  1133 			if (inst.queryCommandState("Underline") && (node.parentNode == null || node.parentNode.nodeName != "A"))
       
  1134 				tinyMCE.switchClass(editor_id + '_underline', 'mceButtonSelected');
       
  1135 		}
       
  1136 
       
  1137 		// Handle elements
       
  1138 		do {
       
  1139 			switch (node.nodeName) {
       
  1140 				case "UL":
       
  1141 					tinyMCE.switchClass(editor_id + '_bullist', 'mceButtonSelected');
       
  1142 				break;
       
  1143 
       
  1144 				case "OL":
       
  1145 					tinyMCE.switchClass(editor_id + '_numlist', 'mceButtonSelected');
       
  1146 				break;
       
  1147 
       
  1148 				case "HR":
       
  1149 					 tinyMCE.switchClass(editor_id + '_hr', 'mceButtonSelected');
       
  1150 				break;
       
  1151 
       
  1152 				case "IMG":
       
  1153 				if (tinyMCE.getAttrib(node, 'name').indexOf('mce_') != 0 && tinyMCE.getAttrib(node, 'class').indexOf('mceItem') == -1) {
       
  1154 					tinyMCE.switchClass(editor_id + '_image', 'mceButtonSelected');
       
  1155 				}
       
  1156 				break;
       
  1157 			}
       
  1158 		} while ((node = node.parentNode) != null);
       
  1159 	},
       
  1160 
       
  1161 	// Private theme internal functions
       
  1162 
       
  1163 	// This function auto imports CSS classes into the class selection droplist
       
  1164 	_setupCSSClasses : function(editor_id) {
       
  1165 		var i, selectElm;
       
  1166 
       
  1167 		if (!TinyMCE_AdvancedTheme._autoImportCSSClasses)
       
  1168 			return;
       
  1169 
       
  1170 		selectElm = document.getElementById(editor_id + '_styleSelect');
       
  1171 
       
  1172 		if (selectElm && selectElm.getAttribute('cssImported') != 'true') {
       
  1173 			var csses = tinyMCE.getCSSClasses(editor_id);
       
  1174 			if (csses && selectElm)	{
       
  1175 				for (i=0; i<csses.length; i++)
       
  1176 					selectElm.options[selectElm.options.length] = new Option(csses[i], csses[i]);
       
  1177 			}
       
  1178 
       
  1179 			// Only do this once
       
  1180 			if (csses != null && csses.length > 0)
       
  1181 				selectElm.setAttribute('cssImported', 'true');
       
  1182 		}
       
  1183 	},
       
  1184 
       
  1185 	_setCookie : function(name, value, expires, path, domain, secure) {
       
  1186 		var curCookie = name + "=" + escape(value) +
       
  1187 			((expires) ? "; expires=" + expires.toGMTString() : "") +
       
  1188 			((path) ? "; path=" + escape(path) : "") +
       
  1189 			((domain) ? "; domain=" + domain : "") +
       
  1190 			((secure) ? "; secure" : "");
       
  1191 
       
  1192 		document.cookie = curCookie;
       
  1193 	},
       
  1194 
       
  1195 	_getCookie : function(name) {
       
  1196 		var dc = document.cookie;
       
  1197 		var prefix = name + "=";
       
  1198 		var begin = dc.indexOf("; " + prefix);
       
  1199 
       
  1200 		if (begin == -1) {
       
  1201 			begin = dc.indexOf(prefix);
       
  1202 
       
  1203 			if (begin != 0)
       
  1204 				return null;
       
  1205 		} else
       
  1206 			begin += 2;
       
  1207 
       
  1208 		var end = document.cookie.indexOf(";", begin);
       
  1209 
       
  1210 		if (end == -1)
       
  1211 			end = dc.length;
       
  1212 
       
  1213 		return unescape(dc.substring(begin + prefix.length, end));
       
  1214 	},
       
  1215 
       
  1216 	_resizeTo : function(inst, w, h, set_w) {
       
  1217 		var editorContainer = document.getElementById(inst.editorId + '_parent');
       
  1218 		var tableElm = editorContainer.firstChild;
       
  1219 		var iframe = inst.iframeElement;
       
  1220 
       
  1221 		if (w == null || w == "null") {
       
  1222 			set_w = false;
       
  1223 			w = 0;
       
  1224 		}
       
  1225 
       
  1226 		if (h == null || h == "null")
       
  1227 			return;
       
  1228 
       
  1229 		w = parseInt(w);
       
  1230 		h = parseInt(h);
       
  1231 
       
  1232 		if (tinyMCE.isGecko) {
       
  1233 			w += 2;
       
  1234 			h += 2;
       
  1235 		}
       
  1236 
       
  1237 		var dx = w - tableElm.clientWidth;
       
  1238 		var dy = h - tableElm.clientHeight;
       
  1239 
       
  1240 		w = w < 1 ? 30 : w;
       
  1241 		h = h < 1 ? 30 : h;
       
  1242 
       
  1243 		if (set_w)
       
  1244 			tableElm.style.width = w + "px";
       
  1245 
       
  1246 		tableElm.style.height = h + "px";
       
  1247 
       
  1248 		iw = iframe.clientWidth + dx;
       
  1249 		ih = iframe.clientHeight + dy;
       
  1250 
       
  1251 		iw = iw < 1 ? 30 : iw;
       
  1252 		ih = ih < 1 ? 30 : ih;
       
  1253 
       
  1254 		if (tinyMCE.isGecko) {
       
  1255 			iw -= 2;
       
  1256 			ih -= 2;
       
  1257 		}
       
  1258 
       
  1259 		if (set_w)
       
  1260 			iframe.style.width = iw + "px";
       
  1261 
       
  1262 		iframe.style.height = ih + "px";
       
  1263 
       
  1264 		// Is it to small, make it bigger again
       
  1265 		if (set_w) {
       
  1266 			var tableBodyElm = tableElm.firstChild;
       
  1267 			var minIframeWidth = tableBodyElm.scrollWidth;
       
  1268 			if (inst.iframeElement.clientWidth < minIframeWidth) {
       
  1269 				dx = minIframeWidth - inst.iframeElement.clientWidth;
       
  1270 
       
  1271 				inst.iframeElement.style.width = (iw + dx) + "px";
       
  1272 			}
       
  1273 		}
       
  1274 
       
  1275 		// Remove pesky table controls
       
  1276 		inst.useCSS = false;
       
  1277 	},
       
  1278 
       
  1279 	/**
       
  1280 	 * Handles resizing events.
       
  1281 	 */
       
  1282 	_resizeEventHandler : function(e) {
       
  1283 		var resizer = TinyMCE_AdvancedTheme._resizer;
       
  1284 
       
  1285 		// Do nothing
       
  1286 		if (!resizer.resizing)
       
  1287 			return;
       
  1288 
       
  1289 		e = typeof(e) == "undefined" ? window.event : e;
       
  1290 
       
  1291 		var dx = e.screenX - resizer.downX;
       
  1292 		var dy = e.screenY - resizer.downY;
       
  1293 		var resizeBox = resizer.resizeBox;
       
  1294 		var editorId = resizer.editorId;
       
  1295 
       
  1296 		switch (e.type) {
       
  1297 			case "mousemove":
       
  1298 				var w, h;
       
  1299 
       
  1300 				w = resizer.width + dx;
       
  1301 				h = resizer.height + dy;
       
  1302 
       
  1303 				w = w < 1 ? 1 : w;
       
  1304 				h = h < 1 ? 1 : h;
       
  1305 
       
  1306 				if (resizer.horizontal)
       
  1307 					resizeBox.style.width = w + "px";
       
  1308 
       
  1309 				resizeBox.style.height = h + "px";
       
  1310 				break;
       
  1311 
       
  1312 			case "mouseup":
       
  1313 				TinyMCE_AdvancedTheme._setResizing(e, editorId, false);
       
  1314 				TinyMCE_AdvancedTheme._resizeTo(tinyMCE.getInstanceById(editorId), resizer.width + dx, resizer.height + dy, resizer.horizontal);
       
  1315 
       
  1316 				// Expire in a month
       
  1317 				if (tinyMCE.getParam("theme_advanced_resizing_use_cookie", true)) {
       
  1318 					var expires = new Date();
       
  1319 					expires.setTime(expires.getTime() + 3600000 * 24 * 30);
       
  1320 
       
  1321 					// Set the cookies
       
  1322 					TinyMCE_AdvancedTheme._setCookie("TinyMCE_" + editorId + "_width", "" + (resizer.horizontal ? resizer.width + dx : ""), expires);
       
  1323 					TinyMCE_AdvancedTheme._setCookie("TinyMCE_" + editorId + "_height", "" + (resizer.height + dy), expires);
       
  1324 				}
       
  1325 				break;
       
  1326 		}
       
  1327 	},
       
  1328 
       
  1329 	/**
       
  1330 	 * Starts/stops the editor resizing.
       
  1331 	 */
       
  1332 	_setResizing : function(e, editor_id, state) {
       
  1333 		e = typeof(e) == "undefined" ? window.event : e;
       
  1334 
       
  1335 		var resizer = TinyMCE_AdvancedTheme._resizer;
       
  1336 		var editorContainer = document.getElementById(editor_id + '_parent');
       
  1337 		var editorArea = document.getElementById(editor_id + '_parent').firstChild;
       
  1338 		var resizeBox = document.getElementById(editor_id + '_resize_box');
       
  1339 		var inst = tinyMCE.getInstanceById(editor_id);
       
  1340 
       
  1341 		if (state) {
       
  1342 			// Place box over editor area
       
  1343 			var width = editorArea.clientWidth;
       
  1344 			var height = editorArea.clientHeight;
       
  1345 
       
  1346 			resizeBox.style.width = width + "px";
       
  1347 			resizeBox.style.height = height + "px";
       
  1348 
       
  1349 			resizer.iframeWidth = inst.iframeElement.clientWidth;
       
  1350 			resizer.iframeHeight = inst.iframeElement.clientHeight;
       
  1351 
       
  1352 			// Hide editor and show resize box
       
  1353 			editorArea.style.display = "none";
       
  1354 			resizeBox.style.display = "block";
       
  1355 
       
  1356 			// Add event handlers, only once
       
  1357 			if (!resizer.eventHandlers) {
       
  1358 				if (tinyMCE.isMSIE)
       
  1359 					tinyMCE.addEvent(document, "mousemove", TinyMCE_AdvancedTheme._resizeEventHandler);
       
  1360 				else
       
  1361 					tinyMCE.addEvent(window, "mousemove", TinyMCE_AdvancedTheme._resizeEventHandler);
       
  1362 
       
  1363 				tinyMCE.addEvent(document, "mouseup", TinyMCE_AdvancedTheme._resizeEventHandler);
       
  1364 
       
  1365 				resizer.eventHandlers = true;
       
  1366 			}
       
  1367 
       
  1368 			resizer.resizing = true;
       
  1369 			resizer.downX = e.screenX;
       
  1370 			resizer.downY = e.screenY;
       
  1371 			resizer.width = parseInt(resizeBox.style.width);
       
  1372 			resizer.height = parseInt(resizeBox.style.height);
       
  1373 			resizer.editorId = editor_id;
       
  1374 			resizer.resizeBox = resizeBox;
       
  1375 			resizer.horizontal = tinyMCE.getParam("theme_advanced_resize_horizontal", true);
       
  1376 		} else {
       
  1377 			resizer.resizing = false;
       
  1378 			resizeBox.style.display = "none";
       
  1379 			editorArea.style.display = tinyMCE.isMSIE && !tinyMCE.isOpera ? "block" : "table";
       
  1380 			tinyMCE.execCommand('mceResetDesignMode');
       
  1381 		}
       
  1382 	},
       
  1383 
       
  1384 	_getColorHTML : function(id, n, cm) {
       
  1385 		var i, h, cl;
       
  1386 
       
  1387 		h = '<span class="mceMenuLine"></span>';
       
  1388 		cl = tinyMCE.getParam(n, TinyMCE_AdvancedTheme._defColors).split(',');
       
  1389 
       
  1390 		h += '<table class="mceColors"><tr>';
       
  1391 		for (i=0; i<cl.length; i++) {
       
  1392 			c = 'tinyMCE.execInstanceCommand(\'' + id + '\', \'' + cm + '\', false, \'#' + cl[i] + '\');';
       
  1393 			h += '<td><a href="javascript:' + c + '" style="background-color: #' + cl[i] + '" onclick="' + c + ';return false;"></a></td>';
       
  1394 
       
  1395 			if ((i+1) % 8 == 0)
       
  1396 				h += '</tr><tr>';
       
  1397 		}
       
  1398 
       
  1399 		h += '</tr></table>';
       
  1400 
       
  1401 		if (tinyMCE.getParam("theme_advanced_more_colors", true))
       
  1402 			h += '<a href="#" onclick="TinyMCE_AdvancedTheme._pickColor(\'' + id + '\',\'' + cm + '\');" class="mceMoreColors">' + tinyMCE.getLang('lang_more_colors') + '</a>';
       
  1403 
       
  1404 		return h;
       
  1405 	},
       
  1406 
       
  1407 	_pickColor : function(id, cm) {
       
  1408 		var inputColor, inst = tinyMCE.selectedInstance;
       
  1409 
       
  1410 		if (cm == 'forecolor' && inst)
       
  1411 			inputColor = inst.foreColor;
       
  1412 
       
  1413 		if ((cm == 'backcolor' || cm == 'HiliteColor') && inst)
       
  1414 			inputColor = inst.backColor;
       
  1415 
       
  1416 		tinyMCE.execCommand('mceColorPicker', true, {color : inputColor, callback : function(c) {
       
  1417 			tinyMCE.execInstanceCommand(id, cm, false, c);
       
  1418 		}});
       
  1419 	},
       
  1420 
       
  1421 	_insertImage : function(src, alt, border, hspace, vspace, width, height, align, title, onmouseover, onmouseout) {
       
  1422 		tinyMCE.execCommand('mceBeginUndoLevel');
       
  1423 
       
  1424 		if (src == "")
       
  1425 			return;
       
  1426 
       
  1427 		if (!tinyMCE.imgElement && tinyMCE.isSafari) {
       
  1428 			var html = "";
       
  1429 
       
  1430 			html += '<img src="' + src + '" alt="' + alt + '"';
       
  1431 			html += ' border="' + border + '" hspace="' + hspace + '"';
       
  1432 			html += ' vspace="' + vspace + '" width="' + width + '"';
       
  1433 			html += ' height="' + height + '" align="' + align + '" title="' + title + '" onmouseover="' + onmouseover + '" onmouseout="' + onmouseout + '" />';
       
  1434 
       
  1435 			tinyMCE.execCommand("mceInsertContent", false, html);
       
  1436 		} else {
       
  1437 			if (!tinyMCE.imgElement && tinyMCE.selectedInstance) {
       
  1438 				if (tinyMCE.isSafari)
       
  1439 					tinyMCE.execCommand("mceInsertContent", false, '<img src="' + tinyMCE.uniqueURL + '" />');
       
  1440 				else
       
  1441 					tinyMCE.selectedInstance.contentDocument.execCommand("insertimage", false, tinyMCE.uniqueURL);
       
  1442 
       
  1443 				tinyMCE.imgElement = tinyMCE.getElementByAttributeValue(tinyMCE.selectedInstance.contentDocument.body, "img", "src", tinyMCE.uniqueURL);
       
  1444 			}
       
  1445 		}
       
  1446 
       
  1447 		if (tinyMCE.imgElement) {
       
  1448 			var needsRepaint = false;
       
  1449 			var msrc = src;
       
  1450 
       
  1451 			src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, tinyMCE.imgElement);");
       
  1452 
       
  1453 			if (tinyMCE.getParam('convert_urls'))
       
  1454 				msrc = src;
       
  1455 
       
  1456 			if (onmouseover && onmouseover != "")
       
  1457 				onmouseover = "this.src='" + eval(tinyMCE.settings['urlconverter_callback'] + "(onmouseover, tinyMCE.imgElement);") + "';";
       
  1458 
       
  1459 			if (onmouseout && onmouseout != "")
       
  1460 				onmouseout = "this.src='" + eval(tinyMCE.settings['urlconverter_callback'] + "(onmouseout, tinyMCE.imgElement);") + "';";
       
  1461 
       
  1462 			// Use alt as title if it's undefined
       
  1463 			if (typeof(title) == "undefined")
       
  1464 				title = alt;
       
  1465 
       
  1466 			if (width != tinyMCE.imgElement.getAttribute("width") || height != tinyMCE.imgElement.getAttribute("height") || align != tinyMCE.imgElement.getAttribute("align"))
       
  1467 				needsRepaint = true;
       
  1468 
       
  1469 			tinyMCE.setAttrib(tinyMCE.imgElement, 'src', src);
       
  1470 			tinyMCE.setAttrib(tinyMCE.imgElement, 'mce_src', msrc);
       
  1471 			tinyMCE.setAttrib(tinyMCE.imgElement, 'alt', alt);
       
  1472 			tinyMCE.setAttrib(tinyMCE.imgElement, 'title', title);
       
  1473 			tinyMCE.setAttrib(tinyMCE.imgElement, 'align', align);
       
  1474 			tinyMCE.setAttrib(tinyMCE.imgElement, 'border', border, true);
       
  1475 			tinyMCE.setAttrib(tinyMCE.imgElement, 'hspace', hspace, true);
       
  1476 			tinyMCE.setAttrib(tinyMCE.imgElement, 'vspace', vspace, true);
       
  1477 			tinyMCE.setAttrib(tinyMCE.imgElement, 'width', width, true);
       
  1478 			tinyMCE.setAttrib(tinyMCE.imgElement, 'height', height, true);
       
  1479 			tinyMCE.setAttrib(tinyMCE.imgElement, 'onmouseover', onmouseover);
       
  1480 			tinyMCE.setAttrib(tinyMCE.imgElement, 'onmouseout', onmouseout);
       
  1481 
       
  1482 			// Fix for bug #989846 - Image resize bug
       
  1483 			if (width && width != "")
       
  1484 				tinyMCE.imgElement.style.pixelWidth = width;
       
  1485 
       
  1486 			if (height && height != "")
       
  1487 				tinyMCE.imgElement.style.pixelHeight = height;
       
  1488 
       
  1489 			if (needsRepaint)
       
  1490 				tinyMCE.selectedInstance.repaint();
       
  1491 		}
       
  1492 
       
  1493 		tinyMCE.execCommand('mceEndUndoLevel');
       
  1494 	},
       
  1495 
       
  1496 	_insertLink : function(href, target, title, onclick, style_class) {
       
  1497 		tinyMCE.execCommand('mceBeginUndoLevel');
       
  1498 
       
  1499 		if (tinyMCE.selectedInstance && tinyMCE.selectedElement && tinyMCE.selectedElement.nodeName.toLowerCase() == "img") {
       
  1500 			var doc = tinyMCE.selectedInstance.getDoc();
       
  1501 			var linkElement = tinyMCE.getParentElement(tinyMCE.selectedElement, "a");
       
  1502 			var newLink = false;
       
  1503 
       
  1504 			if (!linkElement) {
       
  1505 				linkElement = doc.createElement("a");
       
  1506 				newLink = true;
       
  1507 			}
       
  1508 
       
  1509 			var mhref = href;
       
  1510 			var thref = eval(tinyMCE.settings['urlconverter_callback'] + "(href, linkElement);");
       
  1511 			mhref = tinyMCE.getParam('convert_urls') ? href : mhref;
       
  1512 
       
  1513 			tinyMCE.setAttrib(linkElement, 'href', thref);
       
  1514 			tinyMCE.setAttrib(linkElement, 'mce_href', mhref);
       
  1515 			tinyMCE.setAttrib(linkElement, 'target', target);
       
  1516 			tinyMCE.setAttrib(linkElement, 'title', title);
       
  1517 			tinyMCE.setAttrib(linkElement, 'onclick', onclick);
       
  1518 			tinyMCE.setAttrib(linkElement, 'class', style_class);
       
  1519 
       
  1520 			if (newLink) {
       
  1521 				linkElement.appendChild(tinyMCE.selectedElement.cloneNode(true));
       
  1522 				tinyMCE.selectedElement.parentNode.replaceChild(linkElement, tinyMCE.selectedElement);
       
  1523 			}
       
  1524 
       
  1525 			return;
       
  1526 		}
       
  1527 
       
  1528 		if (!tinyMCE.linkElement && tinyMCE.selectedInstance) {
       
  1529 			if (tinyMCE.isSafari) {
       
  1530 				tinyMCE.execCommand("mceInsertContent", false, '<a href="' + tinyMCE.uniqueURL + '">' + tinyMCE.selectedInstance.selection.getSelectedHTML() + '</a>');
       
  1531 			} else
       
  1532 				tinyMCE.selectedInstance.contentDocument.execCommand("createlink", false, tinyMCE.uniqueURL);
       
  1533 
       
  1534 			tinyMCE.linkElement = tinyMCE.getElementByAttributeValue(tinyMCE.selectedInstance.contentDocument.body, "a", "href", tinyMCE.uniqueURL);
       
  1535 
       
  1536 			var elementArray = tinyMCE.getElementsByAttributeValue(tinyMCE.selectedInstance.contentDocument.body, "a", "href", tinyMCE.uniqueURL);
       
  1537 
       
  1538 			for (var i=0; i<elementArray.length; i++) {
       
  1539 				var mhref = href;
       
  1540 				var thref = eval(tinyMCE.settings['urlconverter_callback'] + "(href, elementArray[i]);");
       
  1541 				mhref = tinyMCE.getParam('convert_urls') ? href : mhref;
       
  1542 
       
  1543 				tinyMCE.setAttrib(elementArray[i], 'href', thref);
       
  1544 				tinyMCE.setAttrib(elementArray[i], 'mce_href', mhref);
       
  1545 				tinyMCE.setAttrib(elementArray[i], 'target', target);
       
  1546 				tinyMCE.setAttrib(elementArray[i], 'title', title);
       
  1547 				tinyMCE.setAttrib(elementArray[i], 'onclick', onclick);
       
  1548 				tinyMCE.setAttrib(elementArray[i], 'class', style_class);
       
  1549 			}
       
  1550 
       
  1551 			tinyMCE.linkElement = elementArray[0];
       
  1552 		}
       
  1553 
       
  1554 		if (tinyMCE.linkElement) {
       
  1555 			var mhref = href;
       
  1556 			href = eval(tinyMCE.settings['urlconverter_callback'] + "(href, tinyMCE.linkElement);");
       
  1557 			mhref = tinyMCE.getParam('convert_urls') ? href : mhref;
       
  1558 
       
  1559 			tinyMCE.setAttrib(tinyMCE.linkElement, 'href', href);
       
  1560 			tinyMCE.setAttrib(tinyMCE.linkElement, 'mce_href', mhref);
       
  1561 			tinyMCE.setAttrib(tinyMCE.linkElement, 'target', target);
       
  1562 			tinyMCE.setAttrib(tinyMCE.linkElement, 'title', title);
       
  1563 			tinyMCE.setAttrib(tinyMCE.linkElement, 'onclick', onclick);
       
  1564 			tinyMCE.setAttrib(tinyMCE.linkElement, 'class', style_class);
       
  1565 		}
       
  1566 
       
  1567 		tinyMCE.execCommand('mceEndUndoLevel');
       
  1568 	}
       
  1569 };
       
  1570 
       
  1571 tinyMCE.addTheme("advanced", TinyMCE_AdvancedTheme);
       
  1572 
       
  1573 // Add default buttons maps for advanced theme and all internal plugins
       
  1574 tinyMCE.addButtonMap(TinyMCE_AdvancedTheme._buttonMap);