includes/clientside/tinymce/themes/advanced/editor_template_src.js
changeset 1 fe660c52c48f
equal deleted inserted replaced
0:902822492a68 1:fe660c52c48f
       
     1 /**
       
     2  * $Id: editor_template_src.js 218 2007-02-13 11:08:01Z spocke $
       
     3  *
       
     4  * @author Moxiecode
       
     5  * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.
       
     6  */
       
     7 
       
     8 /* Import theme specific language pack */
       
     9 tinyMCE.importThemeLanguagePack('advanced');
       
    10 
       
    11 var TinyMCE_AdvancedTheme = {
       
    12 	// Private theme fields
       
    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",
       
    14 	_autoImportCSSClasses : true,
       
    15 	_resizer : {},
       
    16 	_buttons : [
       
    17 		// Control id, button img, button title, command, user_interface, value
       
    18 		['bold', '{$lang_bold_img}', 'lang_bold_desc', 'Bold'],
       
    19 		['italic', '{$lang_italic_img}', 'lang_italic_desc', 'Italic'],
       
    20 		['underline', '{$lang_underline_img}', 'lang_underline_desc', 'Underline'],
       
    21 		['strikethrough', 'strikethrough.gif', 'lang_striketrough_desc', 'Strikethrough'],
       
    22 		['justifyleft', 'justifyleft.gif', 'lang_justifyleft_desc', 'JustifyLeft'],
       
    23 		['justifycenter', 'justifycenter.gif', 'lang_justifycenter_desc', 'JustifyCenter'],
       
    24 		['justifyright', 'justifyright.gif', 'lang_justifyright_desc', 'JustifyRight'],
       
    25 		['justifyfull', 'justifyfull.gif', 'lang_justifyfull_desc', 'JustifyFull'],
       
    26 		['bullist', 'bullist.gif', 'lang_bullist_desc', 'InsertUnorderedList'],
       
    27 		['numlist', 'numlist.gif', 'lang_numlist_desc', 'InsertOrderedList'],
       
    28 		['outdent', 'outdent.gif', 'lang_outdent_desc', 'Outdent'],
       
    29 		['indent', 'indent.gif', 'lang_indent_desc', 'Indent'],
       
    30 		['cut', 'cut.gif', 'lang_cut_desc', 'Cut'],
       
    31 		['copy', 'copy.gif', 'lang_copy_desc', 'Copy'],
       
    32 		['paste', 'paste.gif', 'lang_paste_desc', 'Paste'],
       
    33 		['undo', 'undo.gif', 'lang_undo_desc', 'Undo'],
       
    34 		['redo', 'redo.gif', 'lang_redo_desc', 'Redo'],
       
    35 		['link', 'link.gif', 'lang_link_desc', 'mceLink', true],
       
    36 		['unlink', 'unlink.gif', 'lang_unlink_desc', 'unlink'],
       
    37 		['image', 'image.gif', 'lang_image_desc', 'mceImage', true],
       
    38 		['cleanup', 'cleanup.gif', 'lang_cleanup_desc', 'mceCleanup'],
       
    39 		['help', 'help.gif', 'lang_help_desc', 'mceHelp'],
       
    40 		['code', 'code.gif', 'lang_theme_code_desc', 'mceCodeEditor'],
       
    41 		['hr', 'hr.gif', 'lang_theme_hr_desc', 'inserthorizontalrule'],
       
    42 		['removeformat', 'removeformat.gif', 'lang_theme_removeformat_desc', 'removeformat'],
       
    43 		['sub', 'sub.gif', 'lang_theme_sub_desc', 'subscript'],
       
    44 		['sup', 'sup.gif', 'lang_theme_sup_desc', 'superscript'],
       
    45 		['forecolor', 'forecolor.gif', 'lang_theme_forecolor_desc', 'forecolor', true],
       
    46 		['forecolorpicker', 'forecolor.gif', 'lang_theme_forecolor_desc', 'forecolorpicker', true],
       
    47 		['backcolor', 'backcolor.gif', 'lang_theme_backcolor_desc', 'HiliteColor', true],
       
    48 		['backcolorpicker', 'backcolor.gif', 'lang_theme_backcolor_desc', 'backcolorpicker', true],
       
    49 		['charmap', 'charmap.gif', 'lang_theme_charmap_desc', 'mceCharMap'],
       
    50 		['visualaid', 'visualaid.gif', 'lang_theme_visualaid_desc', 'mceToggleVisualAid'],
       
    51 		['anchor', 'anchor.gif', 'lang_theme_anchor_desc', 'mceInsertAnchor'],
       
    52 		['newdocument', 'newdocument.gif', 'lang_newdocument_desc', 'mceNewDocument']
       
    53 	],
       
    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',
       
    56 
       
    57 	/**
       
    58 	 * Returns HTML code for the specificed control.
       
    59 	 */
       
    60 	getControlHTML : function(button_name) {
       
    61 		var i, x, but;
       
    62 
       
    63 		// Lookup button in button list
       
    64 		for (i=0; i<TinyMCE_AdvancedTheme._buttons.length; i++) {
       
    65 			but = TinyMCE_AdvancedTheme._buttons[i];
       
    66 
       
    67 			if (but[0] == button_name && (button_name == "forecolor" || button_name == "backcolor"))
       
    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));
       
    69 
       
    70 			if (but[0] == button_name)
       
    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));
       
    72 		}
       
    73 
       
    74 		// Custom controlls other than buttons
       
    75 		switch (button_name) {
       
    76 			case "formatselect":
       
    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">';
       
    78 				var formats = tinyMCE.getParam("theme_advanced_blockformats", "p,address,pre,h1,h2,h3,h4,h5,h6", true).split(',');
       
    79 				var lookup = [
       
    80 					['p', '{$lang_theme_paragraph}'],
       
    81 					['address', '{$lang_theme_address}'],
       
    82 					['pre', '{$lang_theme_pre}'],
       
    83 					['h1', '{$lang_theme_h1}'],
       
    84 					['h2', '{$lang_theme_h2}'],
       
    85 					['h3', '{$lang_theme_h3}'],
       
    86 					['h4', '{$lang_theme_h4}'],
       
    87 					['h5', '{$lang_theme_h5}'],
       
    88 					['h6', '{$lang_theme_h6}'],
       
    89 					['div', '{$lang_theme_div}'],
       
    90 					['blockquote', '{$lang_theme_blockquote}'],
       
    91 					['code', '{$lang_theme_code}'],
       
    92 					['dt', '{$lang_theme_dt}'],
       
    93 					['dd', '{$lang_theme_dd}'],
       
    94 					['samp', '{$lang_theme_samp}']
       
    95 				];
       
    96 
       
    97 				html += '<option value="">{$lang_theme_block}</option>';
       
    98 
       
    99 				// Build format select
       
   100 				for (var i=0; i<formats.length; i++) {
       
   101 					for (var x=0; x<lookup.length; x++) {
       
   102 						if (formats[i] == lookup[x][0])
       
   103 							html += '<option value="&lt;' + lookup[x][0] + '&gt;">' + lookup[x][1] + '</option>';
       
   104 					}
       
   105 				}
       
   106 
       
   107 				html += '</select>';
       
   108 
       
   109 				return html;
       
   110 
       
   111 			case "styleselect":
       
   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>';
       
   113 
       
   114 			case "fontselect":
       
   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>';
       
   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';
       
   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';
       
   118 				var fonts = tinyMCE.getParam("theme_advanced_fonts", nFonts).split(';');
       
   119 				for (i=0; i<fonts.length; i++) {
       
   120 					if (fonts[i] != '') {
       
   121 						var parts = fonts[i].split('=');
       
   122 						fontHTML += '<option value="' + parts[1] + '">' + parts[0] + '</option>';
       
   123 					}
       
   124 				}
       
   125 
       
   126 				fontHTML += '</select>';
       
   127 				return fontHTML;
       
   128 
       
   129 			case "fontsizeselect":
       
   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">'+
       
   131 						'<option value="0">{$lang_theme_font_size}</option>'+
       
   132 						'<option value="1">1 (8 pt)</option>'+
       
   133 						'<option value="2">2 (10 pt)</option>'+
       
   134 						'<option value="3">3 (12 pt)</option>'+
       
   135 						'<option value="4">4 (14 pt)</option>'+
       
   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 						}
       
  1014 					}
       
  1015 				}
       
  1016 			} while (!breakOut && classNode != null && (classNode = classNode.parentNode) != null);
       
  1017 
       
  1018 			selectElm.selectedIndex = index;
       
  1019 		}
       
  1020 
       
  1021 		// Select formatblock
       
  1022 		var selectElm = document.getElementById(editor_id + "_formatSelect");
       
  1023 		if (selectElm) {
       
  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);