// _lcid="3082" _version="12.0.6505"
// _localBinding
// Version: "12.0.6505"
// Copyright (c) Microsoft Corporation.  All rights reserved.
var g_strRTE2UnlinkMnemonic="Unlink";
var g_strRTE2SpellCheckMnemonic="spell_check";
var g_strRTE2FindMnemonic="RTE2_ToggleFind";
var g_strRTE2SaveHtmlMnemonic="save_html";
var g_strRTE2InsertReusableTextMnemonic="reusable_text";
var g_strRTE2InsertTableMnemonic="insert_table";
var g_strRTE2EditTableMnemonic="edit_table";
var g_strRTE2ShowTableBordersMnemonic="show_table_borders";
var g_strRTE2ViewSourceMnemonic="view_source";
var g_strRTE2RemoveStylesMnemonic="remove_styles";
var g_strRTE2SelectElementMnemonic="select_element";
var g_strRTE2CustomStylesMnemonic="custom_styles";
var g_strRTE2TableMnemonic="table";
var g_strRTE2TableCellSizingMnemonic="cell_sizing";
var g_strRTE2OnPasteMnemonic="on_paste";
var g_strRTE2OnCellMnemonic="on_cell";
var g_strRTE2PasteTextMnemonic="RTE2_ChangePasteToText";
var g_strRTE2PasteStripMnemonic="RTE2_ChangePasteToStrip";
var g_strRTE2PasteHtmlMnemonic="RTE2_ChangePasteToHtml";
var g_strRTE2HelpMnemonic="RTE2_help";
var g_strRTE2IncreaseTableColumnWidthFunction="RTE2_IncreaseTableColumnWidth";
var g_strRTE2DecreaseTableColumnWidthFunction="RTE2_DecreaseTableColumnWidth";
var g_strRTE2IncreaseTableRowHeightFunction="RTE2_IncreaseTableRowHeight";
var g_strRTE2DecreaseTableRowHeightFunction="RTE2_DecreaseTableRowHeight";
var g_strRTE2ModifyRowColSizeFunction="RTE2_ModifyRowColSize";
var g_strRTE2SelectElementFunction="RTE2_SelectElement";
var g_strRTE2ApplyCustomStyleFunction="RTE2_ApplyCustomStyle";
var g_strRTE2RemoveStylesFunction="RTE2_RemoveStyles";
var g_strRTE2ReusableFragmentCommonToken="__publishingReusableFragment";
var g_strIconSizeAttributes=" width=16 height=16 ";
var g_extraButtons=new Array();
var g_countExtraButtons;
var g_maximumExtraButtons=12;
var g_maxPercentage=10000;
var g_maxPixel=100000;
var g_MaxDomSearchWalk=3000;
var g_strRTE2MergeCellRightMnemonic="RTE_MergeWithRight";
var g_strRTE2MergeCellLeftMnemonic="RTE_MergeWithLeft";
var g_strRTE2MergeCellAboveMnemonic="RTE_MergeWithAbove";
var g_strRTE2MergeCellBelowMnemonic="RTE_MergeWithBelow";
var g_aBlockElementNames=new Array("H1", "H2", "H3", "H4", "H5", "H6", "P", "PRE", "TD", "DIV", "BLOCKQUOTE", "DT", "DD", "TABLE", "HR", "IMG", "BODY", "TR", "UL", "OL");
var L_MergeCellSelectedLabel_TEXT="Combinar celdas seleccionadas";
var L_MergeCellLeftLabel_TEXT="Combinar con celda izquierda";
var L_MergeCellRightLabel_TEXT="Combinar con celda derecha";
var L_MergeCellAboveLabel_TEXT="Combinar con celda superior";
var L_MergeCellBelowLabel_TEXT="Combinar con celda inferior";
var L_EditPropertiesToolTip_TEXT="Editar propiedades";
var L_UnlinkToolTip_TEXT="Quitar hipervínculo";
var L_InsertAttachmentToolTip_TEXT="Insertar datos adjuntos";
var L_RemoveStylesToolTip_TEXT="Quitar estilos en línea";
var L_RemoveStylesLabel_TEXT="Quitar estilos en línea";
var L_SpellCheckToolTip_TEXT="Abrir una nueva ventana para revisar la ortografía";
var L_SaveHtmlToolTip_TEXT="Guardar HTML";
var L_InsertTableToolTip_TEXT="Abrir una nueva ventana para insertar una tabla";
var L_EditTableToolTip_TEXT="Abrir una nueva ventana para editar una tabla";
var L_TableOperationsToolTip_TEXT="Operaciones de tabla";
var L_ShowTableBordersToolTip_TEXT="Mostrar/Ocultar líneas de la cuadrícula";
var L_ViewSourceToolTip_TEXT="Editar origen HTML";
var L_InsertReusableTextToolTip_TEXT="Abrir una nueva ventana para insertar contenido reutilizable";
var L_EditLinkToolTip_TEXT="Abrir una nueva ventana para editar un hipervínculo";
var L_EditImageToolTip_TEXT="Abrir una nueva ventana para editar una imagen";
var L_HelpToolTip_TEXT="Ayuda";
var L_SelectAllKey_TEXT="A";
var L_SelectAllShiftKey_TEXT="false";
var L_SelectAllAltKey_TEXT="false";
var L_BackspaceKey_VALUE=0x08;
var L_DeleteKey_VALUE=0x2E;
var L_TabKey_VALUE=0x09;
var L_CtrlKey_VALUE=0x11;
var L_SpellCheckKey_VALUE=0x76;
var L_SpellCheckShiftKey_TEXT="false";
var L_SpellCheckAltKey_TEXT="false";
var L_CreateLinkKey_TEXT="K";
var L_CreateLinkShiftKey_TEXT="false";
var L_CreateLinkAltKey_TEXT="false";
var L_RemoveLinkKey_TEXT="U";
var L_RemoveLinkShiftKey_TEXT="false";
var L_RemoveLinkAltKey_TEXT="true";
var L_EditTablePropertyKey_TEXT="P";
var L_EditTablePropertyShiftKey_TEXT="false";
var L_EditTablePropertyAltKey_TEXT="true";
var L_ShowHideTableBorderKey_TEXT="S";
var L_ShowHideTableBorderShiftKey_TEXT="true";
var L_ShowHideTableBorderAltKey_TEXT="true";
var L_ChangeColumnWidthAndRowHeightKey_TEXT="W";
var L_ChangeColumnWidthAndRowHeightShiftKey_TEXT="false";
var L_ChangeColumnWidthAndRowHeightAltKey_TEXT="false";
var L_IncWidthKey_TEXT="D";
var L_IncWidthShiftKey_TEXT="false";
var L_IncWidthAltKey_TEXT="true";
var L_DecWidthKey_TEXT="D";
var L_DecWidthShiftKey_TEXT="true";
var L_DecWidthAltKey_TEXT="false";
var L_IncHeightKey_TEXT="H";
var L_IncHeightShiftKey_TEXT="false";
var L_IncHeightAltKey_TEXT="true";
var L_DecHeightKey_TEXT="H";
var L_DecHeightShiftKey_TEXT="true";
var L_DecHeightAltKey_TEXT="false";
var L_SelectKey_TEXT="S";
var L_SelectShiftKey_TEXT="false";
var L_SelectAltKey_TEXT="false";
var L_CustomStylesKey_TEXT="S";
var L_CustomStylesShiftKey_TEXT="true";
var L_CustomStylesAltKey_TEXT="false";
var L_FormatKey_TEXT="F";
var L_FormatShiftKey_TEXT="true";
var L_FormatAltKey_TEXT="false";
var L_RemoveInlineStyleKey_TEXT="I";
var L_RemoveInlineStyleShiftKey_TEXT="false";
var L_RemoveInlineStyleAltKey_TEXT="true";
var L_TabNextKey_TEXT="N";
var L_TabNextShiftKey_TEXT="false";
var L_TabNextAltKey_TEXT="false";
var L_TabBackKey_TEXT="N";
var L_TabBackShiftKey_TEXT="true";
var L_TabBackAltKey_TEXT="false";
var L_UndoKey_TEXT="Z";
var L_UndoShiftKey_TEXT="false";
var L_UndoAltKey_TEXT="false";
var L_RedoKey_TEXT="Y";
var L_RedoShiftKey_TEXT="false";
var L_RedoAltKey_TEXT="false";
var L_FindKey_TEXT="F";
var L_FindShiftKey_TEXT="false";
var L_FindAltKey_TEXT="false";
var L_SelectElementToolTip_TEXT="Seleccionar elemento de formato";
var L_CustomStylesToolTip_TEXT="Aplicar estilo"
var L_ParagraphStylesToolTip_TEXT="Aplicar formato de párrafo";
var L_TableCellSizingToolTip_TEXT="Cambiar ancho de columna y alto de fila";
var L_IncreaseTableColumnWidthToolTip_TEXT="Aumentar un 10 por ciento el ancho de columna";
var L_DecreaseTableColumnWidthToolTip_TEXT="Disminuir un 10 por ciento el ancho de columna";
var L_IncreaseTableRowHeightToolTip_TEXT="Aumentar un 10 por ciento el alto de fila";
var L_DecreaseTableRowHeightToolTip_TEXT="Disminuir un 10 por ciento el alto de fila";
var L_ContainsLocalReferences_TEXT="El contenido pegado contiene vínculos o imágenes que hacen referencia a archivos locales. Después de pegar, estas referencias de archivos locales se quitarán, porque quedarían inaccesibles en el servidor.\nSi desea mantener los vínculos e imágenes que hacen referencia a los archivos locales, debe cargar los archivos en las bibliotecas adecuadas e incluir una referencia en el contenido.";
var L_NoSelectionAvailable_TEXT="No se ha encontrado ninguna selección.";
var L_NoAppliciableCustomStyles_TEXT="No se han encontrado estilos aplicables.";
var L_CurrentSelection_TEXT="Selección actual: ";
var L_CurrentSelectionTypeText_TEXT="Texto";
var L_CurrentSelectionTypeNone_TEXT="Ninguna";
var L_CurrentSelectionTypeControl_TEXT="Elemento";
var L_ExpandedTagNameP="Párrafo";
var L_ExpandedTagNameSPAN="Contenido con formato";
var L_ExpandedTagNameFONT="Contenido con formato";
var L_ExpandedTagNameOL="Lista numerada";
var L_ExpandedTagNameUL="Lista con viñetas";
var L_ExpandedTagNameLI="Elemento de lista";
var L_ExpandedTagNameTABLE="Tabla";
var L_ExpandedTagNameIMG="Imagen";
var L_ExpandedTagNameA="Vínculo";
var L_ExpandedTagNameTR="Fila de tabla";
var L_ExpandedTagNameTD="Celda de tabla";
var L_ExpandedTagNameH1="Título 1";
var L_ExpandedTagNameH2="Título 2";
var L_ExpandedTagNameH3="Título 3";
var L_ExpandedTagNameH4="Título 4";
var L_ExpandedTagNameH5="Título 5";
var L_ExpandedTagNameH6="Título 6";
var L_ExpandedTagNameH7="Título 7";
var L_ExpandedTagNameBODY="Todo el contenido";
var L_ExpandedTagNamePRE="Texto de ancho fijo";
var L_ExpandedTagNameDefault="Bloque de formato ( ### )";
var L_ElementStylesSuccesslyRemoved_TEXT="### instancias de estilos de elemento se quitaron correctamente.";
var L_NoElementStylesWereRemoved_TEXT="La selección no contiene ninguna instancia de estilos de elemento que quitar.";
var L_ScriptAndEventHandlersRemoved_TEXT="Se ha encontrado y quitado script incrustado y controladores de eventos. ### elementos afectados.";
var L_ErrorProcessingImage_TEXT="Error inesperado al insertar o editar una imagen. Para guardar los cambios, cierre el editor, vuelva a abrirlo e inténtelo de nuevo. Si este problema persiste, póngase en contacto con el administrador.";
var L_ClipboardTextTooLarge_TEXT="No se pueden pegar más de 100K caracteres a la vez. Vuelva a intentarlo con una cantidad de caracteres menor.";
var L_SelectElementLabel_TEXT="Seleccionar";
var L_StylesLabel_TEXT="Estilos";
var L_OnPasteToolTip_TEXT="Opciones de pegado";
var L_PasteTextLabel_TEXT="Conservar sólo el texto";
var L_PasteStripLabel_TEXT="Quitar estilos en línea";
var L_PasteHtmlLabel_TEXT="Conservar estilos en línea";
var L_OnCellToolTip_TEXT="Menú de celda";
var L_DeleteRowLabel_TEXT="Eliminar fila";
var L_DeleteColumnLabel_TEXT="Eliminar columna";
var L_MergeCellLabel_TEXT="Combinar celda";
var L_SplitCellLabel_TEXT="Dividir celda";
var L_EditTableLabel_TEXT="Editar tabla...";
var L_ModifyRowColSizeLabel_TEXT="Alto y ancho...";
var L_ModifyRowColSizeToolTip_TEXT="Abrir una nueva ventana para ajustar el alto de fila y el ancho de columna";
var L_HtmlEditorIFrameTitle_TEXT="Editor HTML";
var L_FindLabel_TEXT="Buscar: ";
var L_FindButtonLabel_TEXT="Buscar siguiente";
var L_FindToolTip_TEXT="Buscar";
var L_FindFinished_TEXT="Búsqueda en documento finalizada.";
var L_NoSelectionLabel_TEXT="No hay nada seleccionado";
var L_NoSelectionToolTip_TEXT="No hay nada seleccionado";
var L_InvalidBrowser_TEXT="La edición de este contenido no es compatible con su explorador Web actual. Vuelva a intentarlo con un explorador compatible.";
var L_InvalidURL_TEXT="Una o más direcciones URL no eran válidas y se ha cambiado su formato. Revise los vínculos antes de dejar esta página.";
var L_DoYouWannaWaitForLongPaste_TEXT="Pegar el contenido copiado podría llevar varios minutos. ¿Desea continuar?";
function RTE2_InitializeInstanceVariables(instanceVariables)
{
	instanceVariables.overrides.DisableToolBar=RTE2_DisableToolBar;
	instanceVariables.overrides.ResetAllToolBarStates=RTE2_ResetAllToolBarStates;
	instanceVariables.overrides.GetEditorDocument=RTE2_GetEditorDocument;
	instanceVariables.overrides.OnKeyDown=RTE2_OnKeyDown;
	instanceVariables.overrides.RestoreSelection=RTE2_RestoreSelection;
	instanceVariables.overrides.SaveSelection=RTE2_SaveSelection;
	instanceVariables.overrides.GiveEditorFocus=RTE2_GiveEditorFocus;
	instanceVariables.overrides.InsertColumnLeft=RTE2_InsertColumnLeft;
	instanceVariables.overrides.InsertColumnRight=RTE2_InsertColumnRight;
	instanceVariables.overrides.InsertRowAbove=RTE2_InsertRowAbove;
	instanceVariables.overrides.InsertRowBelow=RTE2_InsertRowBelow;
	instanceVariables.overrides.InsertCellLeft=RTE2_InsertCellLeft;
	instanceVariables.overrides.InsertCellRight=RTE2_InsertCellRight;
	instanceVariables.overrides.GetToolBarDefinition=RTE2_GetToolBarDefinition;
	instanceVariables.overrides.ApplyFontFace=RTE2_ApplyFontFace;
	instanceVariables.overrides.ApplyFontSize=RTE2_ApplyFontSize;
	instanceVariables.overrides.SetDirectionOfSelection=RTE2_SetDirectionOfSelection;
	for (var i=0;i< instanceVariables.aSettings.length;i++)
	{
		var dictionaryItem=instanceVariables.aSettings[i];
		if (dictionaryItem[0]=="ValidationContext")
		{
			instanceVariables.restrictions=new Object();
			AP_PopulateFromSerializedObjectQString(instanceVariables.restrictions, dictionaryItem[1]);
		}
	}
	instanceVariables.RenderFontNamesAsText=true;
	instanceVariables.hoverButton=null;
	instanceVariables.fToolbarNavigate=false;
	instanceVariables.fToolbarNavigateSkip=false;
	instanceVariables.toolbarDefinition=new Array();
	instanceVariables.isSourceView=false;
	instanceVariables.selectingPastedText=false;
	instanceVariables.rangeBefore=null;
	instanceVariables.rangeAfter=null;
	instanceVariables.modeChangeNotification=null;
	instanceVariables.isShowingHiddenTables=false;
	instanceVariables.shouldShowHiddenTables=true;
	instanceVariables.selectedElement=null;
	instanceVariables.disregardSelectionChange=0;
	instanceVariables.menuHtml=new Array();
	var instanceVariables_aSettings_length=instanceVariables.aSettings.length;
	var settingsItem=null;
	for (var i=0; i < instanceVariables_aSettings_length;++i)
	{
		settingsItem=instanceVariables.aSettings[i];
		if (settingsItem !=null)
		{
			switch (settingsItem[0])
			{
				case "AllowHtmlSourceEditing":
					instanceVariables.AllowHtmlSourceEditing=RTE2_BoolFromString(settingsItem[1]);
					break;
				case "DisableCustomStyles":
					instanceVariables.DisableCustomStyles=RTE2_BoolFromString(settingsItem[1]);
					break;
				case "DisableBasicFormattingButtons":
					instanceVariables.DisableBasicFormattingButtons=RTE2_BoolFromString(settingsItem[1]);
				case "PrefixStyleSheet":
					instanceVariables.prefixStyleSheet=settingsItem[1];
					break;
				case "EditorBackgroundColor":
					instanceVariables.editorBackgroundColor=settingsItem[1];
					break;
				case "EditorOpenFromWebPart":
					instanceVariables.EditorOpenFromWebPart=settingsItem[1];
					break;
				case "EnableExtensions":
					instanceVariables.EnableExtensions=RTE2_BoolFromString(settingsItem[1]);
					break;
			}
		}
	}
	instanceVariables.htmlStateBuffer=RTE2_CircularArrayCreate(10);
	instanceVariables.htmlStateBuffer.currentUndoRedoPosition=-1;
	instanceVariables.htmlStateBuffer.currentSameAsEditor=false;
	instanceVariables.pasteData=new Object();
}
function RTE2_ConvertTextAreaToRichEdit(strBaseElementID)
{
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	var elemTextArea=RTE_GetEditorTextArea(strBaseElementID);
	RTE2_ConvertToRichEdit(strBaseElementID, elemTextArea);
}
function RTE2_GetEditorContainer(strBaseElementID)
{
	if (RTE2_PopupMode(strBaseElementID))
	{
		return RTE_GetEditorDocument(strBaseElementID).body;
	}
	else
	{
		var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
		return instanceVariables.displayContentElement;
	}
}
function RTE2_ConvertToRichEdit(strBaseElementID, element)
{
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	var strHtmlToAppend="";
	var docEditor;
	if (RTE2_PopupMode(strBaseElementID))
	{
		strHtmlToAppend+=RTE2_GenerateToolBarHtml(strBaseElementID, instanceVariables.lcid, "100%", instanceVariables);
		strHtmlToAppend+=RTE2_GenerateIFrameEditorHtml(strBaseElementID);
		element.insertAdjacentHTML("afterEnd", strHtmlToAppend);
		var strEditorHtml="<html><head><title>"+L_HtmlEditorIFrameTitle_TEXT+"</title></head><body>";
		strEditorHtml+="</body></html>";
		docEditor=RTE_GetEditorDocument(strBaseElementID);
		docEditor.open("text/html", "replace");
		docEditor.write(strEditorHtml);
		docEditor.close();
		try
		{
			docEditor=RTE_GetEditorDocument(strBaseElementID);
			docEditor.attachEvent("onselectionchange", new Function("RTE2_OnSelectionChange('"+strBaseElementID+"', this);"));
		}
		catch(e){}
	}
	else
	{
		strHtmlToAppend+="<div style=\"position:absolute;cursor:move\" onmousedown=\"RTE2_ToolbarDragStart('"+strBaseElementID+"');\">";
		strHtmlToAppend+=RTE2_GenerateToolBarHtml(strBaseElementID, instanceVariables.lcid, "*", instanceVariables);
		strHtmlToAppend+="</div>";
		strHtmlToAppend+=RTE2_GenerateEditorToolsHtml(strBaseElementID);
		element.insertAdjacentHTML("beforeBegin", strHtmlToAppend);
		element.style.display='';
		var toolbar=RTE2_GetToolbar(strBaseElementID);
		RTE2_OnSelectionChange(strBaseElementID);
		toolbar.style.position='absolute';
		toolbar.style.top="0px";
		toolbar.style.left="0px";
		var toolbarYPos=- toolbar.clientHeight - 4;
		var toolbarXPos=0;
		if (RTE2_GetDocumentDirection(document)=="rtl") toolbarXPos=-toolbar.clientWidth;
		toolbar.style.top=toolbarYPos;
		toolbar.style.left=toolbarXPos;
		var toolbarIFrame=RTE2_GetToolbarIFrame(strBaseElementID);
		toolbarIFrame.style.width=toolbar.clientWidth+4;
		toolbarIFrame.style.height=toolbar.clientHeight+4;
		toolbarIFrame.style.top=toolbarYPos;
		toolbarIFrame.style.left=toolbarXPos;
		toolbarIFrame.style.display='';
		var sourceTextArea=RTE2_GetSourceEditorTextArea(strBaseElementID);
		sourceTextArea.style.height="500px";
		document.attachEvent("onbeforeactivate", new Function("RTE2_OnBeforeActivate('"+strBaseElementID+"', this);"));
		document.attachEvent("onselectionchange", new Function("RTE2_OnSelectionChange('"+strBaseElementID+"', this);"));
	}
	var docContainer=RTE2_GetEditorContainer(strBaseElementID);
	docContainer.designMode="on";
	docContainer.scroll="yes";
	docContainer.contentEditable=true;
	docContainer.wordWrap=false;
	docContainer.runtimeStyle.backgroundColor=instanceVariables.editorBackgroundColor;
	docContainer.oncontextmenu=new Function("return false");
	docContainer.onpaste=new Function("RTE2_OnPaste('"+strBaseElementID+"', this);");
	docContainer.oncut=new Function("RTE2_OnCut('"+strBaseElementID+"', this);");
	docContainer.oncopy=new Function("RTE2_OnCopy('"+strBaseElementID+"', this);");
	docContainer.onkeydown=new Function("RTE_OnKeyDown('"+strBaseElementID+"', this)");
	docContainer.onkeyup=new Function("RTE2_OnKeyUp('"+strBaseElementID+"', this)");
	docContainer.onmouseup=new Function("RTE_OnMouseUp('"+strBaseElementID+"')");
	docContainer.ondblclick=new Function("RTE2_OnDoubleClick('"+strBaseElementID+"')");
	docContainer.ondragstart=new Function("RTE2_OnDragStart('"+strBaseElementID+"', this);");
	docContainer.ondragend=new Function("RTE2_OnDragEnd('"+strBaseElementID+"', this);");
	docContainer.ondrop=new Function("RTE2_OnDrop('"+strBaseElementID+"', this);");
	docEditor=RTE_GetEditorDocument(strBaseElementID);
	window.attachEvent("onscroll", new Function("RTE2_OnScroll('"+strBaseElementID+"');"));
	window.attachEvent("onblur", new Function("RTE2_OnBlur('"+strBaseElementID+"');"));
	window.attachEvent("onfocus", new Function("RTE2_OnFocus('"+strBaseElementID+"');"));
	var sourceTextArea=RTE2_GetSourceEditorTextArea(strBaseElementID);
	sourceTextArea.onselect=new Function("RTE2_OnSelectionChange('"+strBaseElementID+"', this);");
	sourceTextArea.wrap="soft";
	sourceTextArea.onkeydown=new Function("RTE_OnKeyDown('"+strBaseElementID+"', this)");
	sourceTextArea.onkeyup=new Function("RTE_OnKeyUp('"+strBaseElementID+"', this)");
	sourceTextArea.onmouseup=new Function("RTE_OnMouseUp('"+strBaseElementID+"')");
	sourceTextArea.oncontextmenu=new Function("return false");
	sourceTextArea.onblur=new Function("RTE2_OnBlur('"+strBaseElementID+"');");
	sourceTextArea.onfocus=new Function("RTE2_OnFocus('"+strBaseElementID+"');");
	sourceTextArea.onpaste=new Function("RTE2_OnPaste_Restricted('"+strBaseElementID+"', this);");
	var safeHtmlDocument=RTE2_GetSafeHtmlDocument(strBaseElementID);
	safeHtmlDocument.canHaveHTML=true;
	safeHtmlDocument=RTE2_GetSafeHtmlDocument(strBaseElementID)
	RTE2_ResetSafeHtmlDocument(safeHtmlDocument);
	safeHtmlDocument=RTE2_GetSafeHtmlDocument(strBaseElementID)
	safeHtmlDocument.body.contentEditable=true;
	safeHtmlDocument.body.scroll="";
	safeHtmlDocument.body.designMode="on";
	if (RTE2_PopupMode(strBaseElementID))
	{
		if(instanceVariables.strDirection !="")
		{
			docEditor.dir=instanceVariables.strDirection;
			sourceTextArea.dir=instanceVariables.strDirection;
		}
		else
		{
			docEditor.dir=document.dir;
			sourceTextArea.dir=document.dir;
		}
		RTE2_TextAreaWindow_OnLoad(strBaseElementID);
	}
	else
	{
		if(instanceVariables.strDirection !="")
		{
			sourceTextArea.dir=instanceVariables.strDirection;
		}
		else
		{
			sourceTextArea.dir=document.dir;
		}
		g_elemRTELastTextAreaConverted=docContainer;
	}
}
function RTE2_ResetSafeHtmlDocument(safeHtmlDocument)
{
	safeHtmlDocument.open("text/html", "replace");
	safeHtmlDocument.write("<html><head></head><body>Error<script>window.onerror=RTE2_OnError;function RTE2_OnError() { window.event.returnValue=true; }</script>Script</body></html>");
	safeHtmlDocument.close();
}
function RTE2_TextAreaWindow_OnLoad(strBaseElementID)
{
	var elemTextArea=RTE_GetEditorTextArea(strBaseElementID);
	g_elemRTELastTextAreaConverted=elemTextArea;
	RTE2_SetRichContent(strBaseElementID, elemTextArea.innerText);
}
function RTE2_GenerateToolBarDefinition(strBaseElementID, strWebLanguage, instanceVariables)
{
	RTE2_AddToolBarButtonDefinition(
		strBaseElementID,
		g_strRTE2OnPasteMnemonic,
		RTE2_GenerateOnPasteToolBarButtonHtml(strBaseElementID, strWebLanguage),
		false);
	RTE2_AddToolBarButtonDefinition(
		strBaseElementID,
		g_strRTE2OnCellMnemonic,
		RTE2_GenerateOnCellToolBarButtonHtml(strBaseElementID, strWebLanguage),
		false);
	if (RTE2_PopupMode(strBaseElementID))
	{
		if (!instanceVariables.EditorOpenFromWebPart)
		{
			RTE2_AddToolBarButtonDefinition(
				strBaseElementID,
				g_strRTE2SaveHtmlMnemonic,
				RTE2_TB_GenerateToolBarButtonHtmlWithSaveHtmlState(strBaseElementID, g_strRTE2SaveHtmlMnemonic, "RTE2_SaveButton('"+strBaseElementID+"');", RTE_GetServerRelativeUnlocalizedImageUrl("rte2save.gif"), "", L_SaveHtmlToolTip_TEXT));
			RTE2_AddToolBarButtonDefinition(strBaseElementID, null, RTE_TB_GenerateToolBarSeparatorHtml());
		}
		RTE2_AddToolBarButtonDefinition(
			strBaseElementID,
			g_strRTE2SpellCheckMnemonic,
			RTE2_TB_GenerateToolBarButtonHtmlWithSaveHtmlState(strBaseElementID, g_strRTE2SpellCheckMnemonic, "RTE2_SpellCheck('"+strBaseElementID+"');", RTE_GetServerRelativeImageUrl("rte2spchk.gif"), "", L_SpellCheckToolTip_TEXT));
		RTE2_AddToolBarButtonDefinition(
			strBaseElementID,
			g_strRTE2FindMnemonic,
			RTE2_TB_GenerateToolBarButtonHtmlWithSaveHtmlState(strBaseElementID, g_strRTE2FindMnemonic, "RTE2_ToggleFind('"+strBaseElementID+"');", RTE_GetServerRelativeUnlocalizedImageUrl("rte2find.gif"), "", L_FindToolTip_TEXT));
		RTE2_AddToolBarButtonDefinition(strBaseElementID, null, RTE_TB_GenerateToolBarSeparatorHtml());
	}
	RTE2_AddToolBarButtonDefinition(
		strBaseElementID,
		g_strRTECutMnemonic,
		RTE2_TB_GenerateExecCommandToolBarButtonHtmlWithSaveHtmlState(strBaseElementID, g_strRTECutMnemonic, false, RTE_GetServerRelativeImageUrl("rtecut.gif"), "", L_CutToolTip_TEXT, true, "null"));
	RTE2_AddToolBarButtonDefinition(
		strBaseElementID,
		g_strRTECopyMnemonic,
		RTE_TB_GenerateExecCommandToolBarButtonHtml(strBaseElementID, g_strRTECopyMnemonic, false, RTE_GetServerRelativeImageUrl("rtecopy.gif"), "", L_CopyToolTip_TEXT, true, "null"));
	RTE2_AddToolBarButtonDefinition(
		strBaseElementID,
		g_strRTEPasteMnemonic,
		RTE2_TB_GenerateExecCommandToolBarButtonHtmlWithSaveHtmlState(strBaseElementID, g_strRTEPasteMnemonic, false, RTE_GetServerRelativeImageUrl("rtepaste.gif"), "", L_PasteToolTip_TEXT, false, "null"));
	RTE2_AddToolBarButtonDefinition(strBaseElementID, null, RTE_TB_GenerateToolBarSeparatorHtml());
	RTE2_AddToolBarButtonDefinition(
		strBaseElementID,
		g_strRTEUndoMnemonic,
		RTE_TB_GenerateToolBarButtonHtml(strBaseElementID, g_strRTEUndoMnemonic, "RTE2_Undo('"+strBaseElementID+"');", RTE_GetServerRelativeUnlocalizedImageUrl("rte2undo.gif"), "", L_UndoToolTip_TEXT));
	RTE2_AddToolBarButtonDefinition(
		strBaseElementID,
		g_strRTERedoMnemonic,
		RTE_TB_GenerateToolBarButtonHtml(strBaseElementID, g_strRTERedoMnemonic, "RTE2_Redo('"+strBaseElementID+"');", RTE_GetServerRelativeUnlocalizedImageUrl("rte2redo.gif"), "", L_RedoToolTip_TEXT));
	RTE2_AddToolBarButtonDefinition(strBaseElementID, null, RTE_TB_GenerateToolBarSeparatorHtml());
	RTE2_AddToolBarButtonDefinition(
		strBaseElementID,
		g_strRTECreateLinkMnemonic,
		RTE2_TB_GenerateToolBarButtonHtmlWithSaveHtmlState(strBaseElementID, g_strRTECreateLinkMnemonic, "RTE2_InsertOrChangeHyperLink('"+strBaseElementID+"');", RTE_GetServerRelativeImageUrl("rtelnk.gif"), "", L_CreateLinkToolTip_TEXT));
	RTE2_AddToolBarButtonDefinition(
		strBaseElementID,
		g_strRTE2UnlinkMnemonic,
		RTE2_TB_GenerateExecCommandToolBarButtonHtmlWithSaveHtmlState(strBaseElementID, g_strRTE2UnlinkMnemonic, false, RTE_GetServerRelativeUnlocalizedImageUrl("rte2unlink.gif"), "", L_UnlinkToolTip_TEXT, false, "null"));
	RTE2_AddToolBarButtonDefinition(
		strBaseElementID,
		g_strRTEInsertImageMnemonic,
		RTE2_TB_GenerateToolBarButtonHtmlWithSaveHtmlState(strBaseElementID, g_strRTEInsertImageMnemonic, "RTE2_InsertOrChangeImage('"+strBaseElementID+"');", RTE_GetServerRelativeImageUrl("rteimg.gif"), "", L_InsertImageToolTip_TEXT));
	if (!instanceVariables.EditorOpenFromWebPart)
	{
		RTE2_AddToolBarButtonDefinition(
			strBaseElementID,
			g_strRTE2InsertReusableTextMnemonic,
			RTE2_TB_GenerateToolBarButtonHtmlWithSaveHtmlState(strBaseElementID, g_strRTE2InsertReusableTextMnemonic, "RTE2_InsertOrChangeReusableText('"+strBaseElementID+"');", RTE_GetServerRelativeUnlocalizedImageUrl("merge.gif"), "", L_InsertReusableTextToolTip_TEXT));
	}
	RTE2_AddToolBarButtonDefinition(strBaseElementID, null, RTE_TB_GenerateToolBarSeparatorHtml());
	RTE2_AddToolBarButtonDefinition(
		strBaseElementID,
		g_strRTE2InsertTableMnemonic,
		RTE2_TB_GenerateToolBarButtonHtmlWithSaveHtmlState(strBaseElementID, g_strRTE2InsertTableMnemonic, "RTE2_InsertTable('"+strBaseElementID+"');", RTE_GetServerRelativeImageUrl("rteitbl.gif"), "", L_InsertTableToolTip_TEXT));
	RTE2_AddToolBarButtonDefinition(
		strBaseElementID,
		g_strRTE2EditTableMnemonic,
		RTE2_TB_GenerateToolBarButtonHtmlWithSaveHtmlState(strBaseElementID, g_strRTE2EditTableMnemonic, "RTE2_EditTable('"+strBaseElementID+"');", RTE_GetServerRelativeUnlocalizedImageUrl("rte2etbl.gif"), "", L_EditTableToolTip_TEXT));
	RTE2_AddToolBarButtonDefinition(
		strBaseElementID,
		g_strRTE2ShowTableBordersMnemonic,
		RTE_TB_GenerateToolBarButtonHtml(strBaseElementID, g_strRTE2ShowTableBordersMnemonic, "RTE2_ToggleTableBorders('"+strBaseElementID+"');", RTE_GetServerRelativeUnlocalizedImageUrl("rte2sgrid.gif"), "", L_ShowTableBordersToolTip_TEXT));
	RTE2_AddToolBarButtonDefinition(strBaseElementID, null, RTE_TB_GenerateToolBarSeparatorHtml());
	RTE2_AddToolBarButtonDefinition(
		strBaseElementID,
		g_strRTE2TableMnemonic,
		RTE2_GenerateTableToolBarButtonHtml(strBaseElementID, strWebLanguage));
	RTE2_AddToolBarButtonDefinition(
		strBaseElementID,
		g_strRTEMergeCellMnemonic,
		RTE2_GenerateMergeCellToolBarButtonHtml(strBaseElementID, strWebLanguage));
	RTE2_AddToolBarButtonDefinition(
		strBaseElementID,
		g_strRTE2TableCellSizingMnemonic,
		RTE2_GenerateTableCellSizingToolBarButtonHtml(strBaseElementID, strWebLanguage));
	RTE2_AddToolBarButtonDefinition(strBaseElementID, null, RTE_TB_GenerateToolBarSeparatorHtml());
	RTE2_AddToolBarButtonDefinition(
		strBaseElementID,
		g_strRTE2ViewSourceMnemonic,
		RTE_TB_GenerateToolBarButtonHtml(strBaseElementID, g_strRTE2ViewSourceMnemonic, "RTE2_ViewSource('"+strBaseElementID+"');", RTE_GetServerRelativeUnlocalizedImageUrl("rte2editSource.gif"), "", L_ViewSourceToolTip_TEXT));
	RTE2_AddToolBarButtonDefinition(
		strBaseElementID,
		g_strRTE2RemoveStylesMnemonic,
		RTE_TB_GenerateToolBarButtonHtml(strBaseElementID, g_strRTE2RemoveStylesMnemonic, "RTE2_RemoveStyles('"+strBaseElementID+"');", RTE_GetServerRelativeImageUrl("rte2rstyl.gif"), "", L_RemoveStylesToolTip_TEXT));
	if (RTE_ShouldShowDirection())
	{
		RTE2_AddToolBarButtonDefinition(strBaseElementID, null, RTE_TB_GenerateToolBarSeparatorHtml());
		if (strWebLanguage=="1025" || strWebLanguage=="1037")
		{
			RTE2_AddToolBarButtonDefinition(
				strBaseElementID,
				"rtl",
				RTE2_TB_GenerateToolBarButtonHtmlWithSaveHtmlState(strBaseElementID, "rtl", "RTE_SetDirectionOfSelection('"+strBaseElementID+"', 'rtl');", RTE_GetServerRelativeImageUrl("rtertl.gif"), "", L_RTLToolTip_TEXT));
			RTE2_AddToolBarButtonDefinition(
				strBaseElementID,
				"ltr",
				RTE2_TB_GenerateToolBarButtonHtmlWithSaveHtmlState(strBaseElementID, "ltr", "RTE_SetDirectionOfSelection('"+strBaseElementID+"', 'ltr');", RTE_GetServerRelativeImageUrl("rteltr.gif"), "", L_LTRToolTip_TEXT));
		}
		else
		{
			RTE2_AddToolBarButtonDefinition(
				strBaseElementID,
				"ltr",
				RTE2_TB_GenerateToolBarButtonHtmlWithSaveHtmlState(strBaseElementID, "ltr", "RTE_SetDirectionOfSelection('"+strBaseElementID+"', 'ltr');", RTE_GetServerRelativeImageUrl("rteltr.gif"), "", L_LTRToolTip_TEXT));
			RTE2_AddToolBarButtonDefinition(
				strBaseElementID,
				"rtl",
				RTE2_TB_GenerateToolBarButtonHtmlWithSaveHtmlState(strBaseElementID, "rtl", "RTE_SetDirectionOfSelection('"+strBaseElementID+"', 'rtl');", RTE_GetServerRelativeImageUrl("rtertl.gif"), "", L_RTLToolTip_TEXT));
		}
	}
	RTE2_AddToolBarButtonDefinition(strBaseElementID, null, RTE_TB_GenerateToolBarSeparatorHtml());
	RTE2_AddToolBarButtonDefinition(strBaseElementID,
									g_strRTE2HelpMnemonic,
									RTE_TB_GenerateToolBarButtonHtml(strBaseElementID,
																	 g_strRTE2HelpMnemonic,
																	 "HelpWindowKey('WCMHTMLEditor');",
																	 RTE_GetServerRelativeUnlocalizedImageUrl("helpicon.gif"),
																	 "",
																	 L_HelpToolTip_TEXT)
									);
	RTE2_AddToolBarButtonDefinition(strBaseElementID, null, RTE_TB_GenerateToolBarLineBreakHtml());
	RTE2_AddToolBarButtonDefinition(
		strBaseElementID,
		g_strRTE2SelectElementMnemonic,
		RTE2_GenerateSelectElementToolBarButtonHtml(strBaseElementID, strWebLanguage));
	RTE2_AddToolBarButtonDefinition(strBaseElementID, null, RTE_TB_GenerateToolBarSeparatorHtml());
	RTE2_AddToolBarButtonDefinition(
		strBaseElementID,
		g_strRTE2CustomStylesMnemonic,
		RTE2_GenerateCustomStylesToolBarButtonHtml(strBaseElementID, strWebLanguage));
	RTE2_AddToolBarButtonDefinition(
		strBaseElementID,
		g_strRTEStylesMnemonic,
		RTE2_GenerateParagraphStylesToolBarButtonHtml(strBaseElementID, strWebLanguage));
	RTE2_AddToolBarButtonDefinition(strBaseElementID, null, RTE_TB_GenerateToolBarSeparatorHtml());
	RTE2_AddToolBarButtonDefinition(
		strBaseElementID,
		g_strRTEFontNameMnemonic,
		RTE_GenerateFontNameToolBarButtonHtml(strBaseElementID, strWebLanguage, false, true));
	RTE2_AddToolBarButtonDefinition(
		strBaseElementID,
		g_strRTEFontSizeMnemonic,
		RTE_GenerateFontSizeToolBarButtonHtml(strBaseElementID, strWebLanguage, false, true));
	RTE2_AddToolBarButtonDefinition(strBaseElementID, null, RTE_TB_GenerateToolBarSeparatorHtml());
	RTE2_AddToolBarButtonDefinition(
		strBaseElementID,
		g_strRTEBoldMnemonic,
		RTE2_TB_GenerateExecCommandToolBarButtonHtmlWithSaveHtmlStateAndFixReusableContent(strBaseElementID, g_strRTEBoldMnemonic, false, RTE_GetServerRelativeImageUrl("rtebold.gif"), "", L_BoldToolTip_TEXT, false, "null", "STRONG"));
	RTE2_AddToolBarButtonDefinition(
		strBaseElementID,
		g_strRTEItalicMnemonic,
		RTE2_TB_GenerateExecCommandToolBarButtonHtmlWithSaveHtmlStateAndFixReusableContent(strBaseElementID, g_strRTEItalicMnemonic, false, RTE_GetServerRelativeImageUrl("rteital.gif"), "", L_ItalicToolTip_TEXT, false, "null", "EM"));
	RTE2_AddToolBarButtonDefinition(
		strBaseElementID,
		g_strRTEUnderlineMnemonic,
		RTE2_TB_GenerateExecCommandToolBarButtonHtmlWithSaveHtmlStateAndFixReusableContent(strBaseElementID, g_strRTEUnderlineMnemonic, false, RTE_GetServerRelativeImageUrl("rteundl.gif"), "", L_UnderlineToolTip_TEXT, false, "null", "U"));
	RTE2_AddToolBarButtonDefinition(strBaseElementID, null, RTE_TB_GenerateToolBarSeparatorHtml());
	if (strWebLanguage=="1025" || strWebLanguage=="1037")
	{
		RTE2_AddToolBarButtonDefinition(
			strBaseElementID,
			g_strRTEJustifyRightMnemonic,
			RTE2_TB_GenerateToolBarButtonHtmlWithSaveHtmlState(strBaseElementID, g_strRTEJustifyRightMnemonic, "RTE2_Align('"+strBaseElementID+"','"+g_strRTEJustifyRightMnemonic+"');", RTE_GetServerRelativeImageUrl("rtertal.gif"), "", L_JustifyRightToolTip_TEXT));
		RTE2_AddToolBarButtonDefinition(
			strBaseElementID,
			g_strRTEJustifyCenterMnemonic,
			RTE2_TB_GenerateToolBarButtonHtmlWithSaveHtmlState(strBaseElementID, g_strRTEJustifyCenterMnemonic, "RTE2_Align('"+strBaseElementID+"','"+g_strRTEJustifyCenterMnemonic+"');", RTE_GetServerRelativeImageUrl("rtectral.gif"), "", L_JustifyCenterToolTip_TEXT));
		RTE2_AddToolBarButtonDefinition(
			strBaseElementID,
			g_strRTEJustifyLeftMnemonic,
			RTE2_TB_GenerateToolBarButtonHtmlWithSaveHtmlState(strBaseElementID, g_strRTEJustifyLeftMnemonic, "RTE2_Align('"+strBaseElementID+"','"+g_strRTEJustifyLeftMnemonic+"');", RTE_GetServerRelativeImageUrl("rteltal.gif"), "", L_JustifyLeftToolTip_TEXT));
	}
	else
	{
		RTE2_AddToolBarButtonDefinition(
			strBaseElementID,
			g_strRTEJustifyLeftMnemonic,
			RTE2_TB_GenerateToolBarButtonHtmlWithSaveHtmlState(strBaseElementID, g_strRTEJustifyLeftMnemonic, "RTE2_Align('"+strBaseElementID+"','"+g_strRTEJustifyLeftMnemonic+"');", RTE_GetServerRelativeImageUrl("rteltal.gif"), "", L_JustifyLeftToolTip_TEXT));
		RTE2_AddToolBarButtonDefinition(
			strBaseElementID,
			g_strRTEJustifyCenterMnemonic,
			RTE2_TB_GenerateToolBarButtonHtmlWithSaveHtmlState(strBaseElementID, g_strRTEJustifyCenterMnemonic, "RTE2_Align('"+strBaseElementID+"','"+g_strRTEJustifyCenterMnemonic+"');", RTE_GetServerRelativeImageUrl("rtectral.gif"), "", L_JustifyCenterToolTip_TEXT));
		RTE2_AddToolBarButtonDefinition(
			strBaseElementID,
			g_strRTEJustifyRightMnemonic,
			RTE2_TB_GenerateToolBarButtonHtmlWithSaveHtmlState(strBaseElementID, g_strRTEJustifyRightMnemonic, "RTE2_Align('"+strBaseElementID+"','"+g_strRTEJustifyRightMnemonic+"');", RTE_GetServerRelativeImageUrl("rtertal.gif"), "", L_JustifyRightToolTip_TEXT));
	}
	RTE2_AddToolBarButtonDefinition(strBaseElementID, null, RTE_TB_GenerateToolBarSeparatorHtml());
	RTE2_AddToolBarButtonDefinition(
		strBaseElementID,
		g_strRTEOrderedListMnemonic,
		RTE2_TB_GenerateExecCommandToolBarButtonHtmlWithSaveHtmlState(strBaseElementID, g_strRTEOrderedListMnemonic, false, RTE_GetServerRelativeImageUrl("rtenlst.gif"), "", L_OrderedListToolTip_TEXT, false, "null"));
	RTE2_AddToolBarButtonDefinition(
		strBaseElementID,
		g_strRTEUnorderedListMnemonic,
		RTE2_TB_GenerateExecCommandToolBarButtonHtmlWithSaveHtmlState(strBaseElementID, g_strRTEUnorderedListMnemonic, false, RTE_GetServerRelativeImageUrl("rteblst.gif"), "", L_UnorderedListToolTip_TEXT, false, "null"));
	RTE2_AddToolBarButtonDefinition(strBaseElementID, null, RTE_TB_GenerateToolBarSeparatorHtml());
	if (strWebLanguage=="1025" || strWebLanguage=="1037")
	{
		RTE2_AddToolBarButtonDefinition(
			strBaseElementID,
			g_strRTEIndentMnemonic,
			RTE2_TB_GenerateExecCommandToolBarButtonHtmlWithSaveHtmlState(strBaseElementID, g_strRTEIndentMnemonic, false, RTE_GetServerRelativeImageUrl("rteidt.gif"), "", L_IndentToolTip_TEXT, false, "null"));
		RTE2_AddToolBarButtonDefinition(
			strBaseElementID,
			g_strRTEOutdentMnemonic,
			RTE2_TB_GenerateExecCommandToolBarButtonHtmlWithSaveHtmlState(strBaseElementID, g_strRTEOutdentMnemonic, false, RTE_GetServerRelativeImageUrl("rteuidt.gif"), "", L_OutdentToolTip_TEXT, false, "null"));
	}
	else
	{
		RTE2_AddToolBarButtonDefinition(
			strBaseElementID,
			g_strRTEOutdentMnemonic,
			RTE2_TB_GenerateExecCommandToolBarButtonHtmlWithSaveHtmlState(strBaseElementID, g_strRTEOutdentMnemonic, false, RTE_GetServerRelativeImageUrl("rteuidt.gif"), "", L_OutdentToolTip_TEXT, false, "null"));
		RTE2_AddToolBarButtonDefinition(
			strBaseElementID,
			g_strRTEIndentMnemonic,
			RTE2_TB_GenerateExecCommandToolBarButtonHtmlWithSaveHtmlState(strBaseElementID, g_strRTEIndentMnemonic, false, RTE_GetServerRelativeImageUrl("rteidt.gif"), "", L_IndentToolTip_TEXT, false, "null"));
	}
	RTE2_AddToolBarButtonDefinition(strBaseElementID, null, RTE_TB_GenerateToolBarSeparatorHtml());
	RTE2_AddToolBarButtonDefinition(
		strBaseElementID,
		g_strRTEForeColorMnemonic,
		RTE2_TB_GenerateToolBarButtonHtmlWithSaveHtmlState(strBaseElementID, g_strRTEForeColorMnemonic, "RTE2_ChooseForeColor('"+strBaseElementID+"');", RTE_GetServerRelativeImageUrl("rtetxclr.gif"), "", L_ForeColorToolTip_TEXT));
	RTE2_AddToolBarButtonDefinition(
		strBaseElementID,
		g_strRTEBackColorMnemonic,
		RTE2_TB_GenerateToolBarButtonHtmlWithSaveHtmlState(strBaseElementID, g_strRTEBackColorMnemonic, "RTE2_ChooseBackColor('"+strBaseElementID+"');", RTE_GetServerRelativeImageUrl("rtebkclr.gif"), "", L_BackColorToolTip_TEXT));
	var extraButtonsToolbarStarted=false;
	if ((null !=g_extraButtons) && instanceVariables.EnableExtensions)
	{
		var g_extraButtonsLength=g_extraButtons.length;
		g_countExtraButtons=0;
		for (var i=0; i < g_extraButtonsLength && g_countExtraButtons <=g_maximumExtraButtons;++i)
		{
			var extraButton=g_extraButtons[i];
			if (null==extraButton || RTE2_IsNullOrEmpty(extraButton.Mnemonic) || null==extraButton.OnClick
				|| null==extraButton.OnResetState)
			{
				continue;
			}
			if (RTE2_IsNullOrEmpty(extraButton.Text) && RTE2_IsNullOrEmpty(extraButton.IconUrl))
			{
				continue;
			}
			if (null==extraButton.Text)
			{
				extraButton.Text="";
			}
			if (null==extraButton.ToolTip)
			{
				extraButton.ToolTip="";
			}
			if (false==extraButtonsToolbarStarted)
			{
				RTE2_AddToolBarButtonDefinition(strBaseElementID, null, RTE_TB_GenerateToolBarLineBreakHtml());
				extraButtonsToolbarStarted=true;
			}
			RTE2_AddToolBarButtonDefinition(
				strBaseElementID,
				extraButton.Mnemonic,
				RTE_TB_GenerateToolBarButtonHtml(strBaseElementID, extraButton.Mnemonic, "RTE2_ExtraButtonOnClick('"+strBaseElementID+"', "+i+");", extraButton.IconUrl, extraButton.Text, extraButton.ToolTip));
			extraButton._addedToToolbar=true;
++g_countExtraButtons;
		}
	}
}
function RTE2_GenerateToolBarHtml(strBaseElementID, strWebLanguage, toolbarWidth, instanceVariables)
{
	RTE2_GenerateToolBarDefinition(strBaseElementID, strWebLanguage, instanceVariables);
	var strHtmlRet="";
	var strClassAttribute=" class=\"ms-rtetoolbarmenu\" ";
	var strWidthAttribute=" width=\""+toolbarWidth+"\" ";
	strHtmlRet+="<iframe id='"+strBaseElementID+"_toolbarIFrame' style=\"position:absolute;display:none;filter:alpha(opacity=0);z-index:99\" unselectable=\"on\" src=\""+RTE_GetServerRelativeUnlocalizedImageUrl("blank.gif")+"\"></iframe>";
	strHtmlRet+="<table id='"+strBaseElementID+"_toolbar' cellpadding=0 cellspacing=0 "+strClassAttribute+strWidthAttribute+"  style=\"border-collapse:collapse;z-index:100;border:solid 2px #c4c4c4;\" unselectable=\"on\" onclick=\"RTE_DD_CloseMenu();\">";
	strHtmlRet+="<tr unselectable=\"on\">";
	if (!RTE2_PopupMode(strBaseElementID))
	{
		strHtmlRet+="<td unselectable=\"on\" rowspan=20 style=\"border:solid 1px #c4c4c4;\">";
		strHtmlRet+="<img src=\""+RTE_GetServerRelativeUnlocalizedImageUrl("SMT_GRIPPY.GIF")+"\" border=0 hspace=3 unselectable=\"on\"/>";
		strHtmlRet+="</td>";
	}
	strHtmlRet+="<td unselectable=\"on\">";
	strHtmlRet+="<table cellspacing=0 cellpadding=0 border=0 unselectable=\"on\">";
	strHtmlRet+="<tr unselectable=\"on\">";
	var buttons=RTE2_GetToolBarDefinition(strBaseElementID);
	for (var i=0; i<buttons.length; i++)
	{
		if (buttons[i].standardToolbar)
			strHtmlRet+=buttons[i].html;
	}
	strHtmlRet+="</tr>";
	strHtmlRet+="</table></td></tr>";
	var findButton=document.getElementById('find_button');
	if (findButton !=null)
	{
		strHtmlRet+="<tr unselectable=\"on\"><td unselectable=\"on\"><table cellspacing=0 cellpadding=0 border=0 unselectable=\"on\">";
		strHtmlRet+="<tr unselectable=\"on\" id=\""+strBaseElementID+"_find_toolbar_\" style=\"display:none;\">";
		strHtmlRet+="<td class=ms-rtetoolbarmenu unselectable=\"on\" valign=\"middle\" style=\"padding:0px 5px\">";
		strHtmlRet+="<label for=\""+strBaseElementID+"_find_box\" unselectable='on'>"+L_FindLabel_TEXT+"</label>";
		strHtmlRet+="</td><td class=ms-rtetoolbarmenu style=\"width:70%\" unselectable='on'>";
		strHtmlRet+="<input type=text id=\""+strBaseElementID+"_find_box\" style=\"width:100%\" onkeyup=\"RTE2_OnKeyUpMenuAccess('"+strBaseElementID+"', this)\" onkeydown=\"RTE2_FindOnKeyDown('"+strBaseElementID+"', this)\" />";
		strHtmlRet+="</td><td class=ms-rtetoolbarmenu style=\"padding:0px 5px\" unselectable='on'>";
		var findButtonHtml=findButton.outerHTML;
		findButtonHtml=findButtonHtml.replace("find_button",strBaseElementID+"_find_button");
		findButtonHtml=findButtonHtml.replace("{0}",L_FindButtonLabel_TEXT);
		findButtonHtml=findButtonHtml.replace("{1}",strBaseElementID);
		strHtmlRet+=findButtonHtml;
		strHtmlRet+="</td></tr>";
		strHtmlRet+="</table></td></tr>";
	}
	strHtmlRet+="<tr unselectable=\"on\"><td unselectable=\"on\"><table cellspacing=0 cellpadding=0 border=0 unselectable=\"on\">";
	strHtmlRet+="<tr unselectable=\"on\">";
	strHtmlRet+="<td class=ms-rtetoolbarmenu id=\""+strBaseElementID+"_selection_status_\" unselectable=\"on\"></td>";
	strHtmlRet+="</tr>";
	strHtmlRet+="</table></td></tr>";
	strHtmlRet+="</table>";
	strHtmlRet+="<div style='position:absolute;left:0px;top:0px;' unselectable='on'>";
	strHtmlRet+="<div style='position:absolute;visibility:hidden;z-index:0' id=\""+RTE2_GetOnPasteMenuID(strBaseElementID)+"\" unselectable='on'>";
	strHtmlRet+="<table cellpadding=0 cellspacing=0 "+strClassAttribute+" unselectable='on'>";
	strHtmlRet+="<tr unselectable='on'>";
	strHtmlRet+=RTE2_GenerateOnPasteToolBarButtonHtml(strBaseElementID, strWebLanguage);
	strHtmlRet+="</tr></table></div>";
	strHtmlRet+="</div>";
	strHtmlRet+="<div style='position:absolute;left:0px;top:0px;' unselectable='on'>";
	strHtmlRet+="<div style='position:absolute;visibility:hidden;z-index:0' id=\""+RTE2_GetOnCellMenuID(strBaseElementID)+"\" unselectable='on'>";
	strHtmlRet+="<table cellpadding=0 cellspacing=0 "+strClassAttribute;
	strHtmlRet+=" style='filter:alpha(opacity=70)' onmouseover=\"RTE2_OnMouseOverMenu(this)\"  onmouseout=\"RTE2_OnMouseOutMenu(this)\" unselectable='on'>";
	strHtmlRet+="<tr unselectable='on'>";
	strHtmlRet+=RTE2_GenerateOnCellToolBarButtonHtml(strBaseElementID, strWebLanguage);
	strHtmlRet+="</tr></table></div>";
	strHtmlRet+="</div>";
	return strHtmlRet;
}
function RTE2_DisableToolBar(strBaseElementID)
{
	var buttons=RTE2_GetToolBarDefinition(strBaseElementID);
	for (var i=0; i<buttons.length; i++)
	{
		if (buttons[i].strMnemonic !=undefined && buttons[i].standardToolbar)
		{
			RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, buttons[i].strMnemonic));
		}
	}
}
function RTE2_ResetAllToolBarStates(strBaseElementID)
{
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	RTE_TB_SetEnabledFromCondition(strBaseElementID, instanceVariables.AllowHtmlSourceEditing, g_strRTE2ViewSourceMnemonic)
	if (RTE2_PopupMode(strBaseElementID))
	{
		RTE_TB_ClearButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTE2FindMnemonic));
	}
	RTE_TB_ClearButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTE2HelpMnemonic));
	if (RTE2_IsSourceView(strBaseElementID))
	{
		var doc=window.document;
		RTE_TB_SetEnabledFromCommandEnabled(strBaseElementID, doc, g_strRTECutMnemonic, g_strRTECutMnemonic);
		RTE_TB_SetEnabledFromCommandEnabled(strBaseElementID, doc, g_strRTECopyMnemonic, g_strRTECopyMnemonic);
		RTE_TB_SetEnabledFromCommandEnabled(strBaseElementID, doc, g_strRTEPasteMnemonic, g_strRTEPasteMnemonic);
		RTE_TB_SetEnabledFromCommandEnabled(strBaseElementID, doc, g_strRTEUndoMnemonic, g_strRTEUndoMnemonic);
		RTE_TB_SetEnabledFromCommandEnabled(strBaseElementID, doc, g_strRTERedoMnemonic, g_strRTERedoMnemonic);
		RTE2_TB_SetCheckFromCondition(strBaseElementID, RTE2_IsSourceView(strBaseElementID), g_strRTE2ViewSourceMnemonic);
		if (!instanceVariables.EditorOpenFromWebPart)
		{
			RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTE2SaveHtmlMnemonic));
			RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTE2InsertReusableTextMnemonic));
		}
		RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTE2SpellCheckMnemonic));
		RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTECreateLinkMnemonic));
		RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTE2UnlinkMnemonic));
		RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEInsertImageMnemonic));
		RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTE2InsertTableMnemonic));
		RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTE2EditTableMnemonic));
		RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTE2ShowTableBordersMnemonic));
		RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTE2TableMnemonic));
		RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEMergeCellMnemonic));
		RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTE2TableCellSizingMnemonic));
		RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTE2SelectElementMnemonic));
		RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTE2CustomStylesMnemonic));
		RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEStylesMnemonic));
		RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEOrderedListMnemonic));
		RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEUnorderedListMnemonic));
		RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEFontNameMnemonic));
		RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEFontSizeMnemonic));
		RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEForeColorMnemonic));
		RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEBackColorMnemonic));
		RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEBoldMnemonic));
		RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEItalicMnemonic));
		RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEUnderlineMnemonic));
		RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEOutdentMnemonic));
		RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEIndentMnemonic));
		RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEJustifyLeftMnemonic));
		RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEJustifyCenterMnemonic));
		RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEJustifyRightMnemonic));
		RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTE2RemoveStylesMnemonic));
		RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTELTRMnemonic));
		RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTERTLMnemonic));
	}
	else
	{
		var aElemChain=RTE_GetCurrentSelectionChain(strBaseElementID);
		var docEditor=RTE_GetEditorDocument(strBaseElementID);
		var hasActiveSelection=RTE_HasActiveSelection(docEditor);
		var restrictions=instanceVariables.restrictions;
		if (!instanceVariables.EditorOpenFromWebPart)
		{
			if (RTE2_PopupMode(strBaseElementID))
			{
				RTE_TB_ClearButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTE2SaveHtmlMnemonic));
			}
			if (restrictions.REUSABLECONTENT && restrictions.REUSABLECONTENT=="true")
			{
				RTE_TB_ClearButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTE2InsertReusableTextMnemonic));
			}
			else
			{
				RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTE2InsertReusableTextMnemonic));
			}
		}
		if (RTE2_PopupMode(strBaseElementID))
		{
			RTE_TB_ClearButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTE2SpellCheckMnemonic));
		}
		RTE_TB_SetEnabledFromCommandEnabled(strBaseElementID, docEditor, g_strRTECutMnemonic, g_strRTECutMnemonic);
		RTE_TB_SetEnabledFromCommandEnabled(strBaseElementID, docEditor, g_strRTECopyMnemonic, g_strRTECopyMnemonic);
		RTE_TB_SetEnabledFromCommandEnabled(strBaseElementID, docEditor, g_strRTEPasteMnemonic, g_strRTEPasteMnemonic);
		RTE2_TB_SetEnabledFromCondition(strBaseElementID, RTE2_CanUndo(instanceVariables.htmlStateBuffer), g_strRTEUndoMnemonic);
		RTE2_TB_SetEnabledFromCondition(strBaseElementID, RTE2_CanRedo(instanceVariables.htmlStateBuffer), g_strRTERedoMnemonic);
		var tableElemInChain=RTE_IsElementInChain(aElemChain, "TABLE");
		var trElemInChain=RTE_IsElementInChain(aElemChain, "TR");
		var cellElemInChain=RTE_IsAnyElementInChain(aElemChain, g_aTableCellTagNames);
		var imgElemInChain=RTE_IsElementInChain(aElemChain, "IMG");
		var linkElemInChain=RTE_IsElementInChain(aElemChain, "A");
		var multipleCellsSelected=false;
		if (aElemChain.length > 0)
		{
			var selectionParentTag=aElemChain[0].tagName.toUpperCase();
			if (selectionParentTag=="TR" || selectionParentTag=="TBODY")
			{
				multipleCellsSelected=true;
			}
		}
		var controlSelected=false;
		var tableControlSelected=false;
		if (hasActiveSelection)
		{
			var selection=RTE_GetCurrentSelection(strBaseElementID);
			if (selection.type=="Control")
			{
				controlSelected=true;
				var currentElem=RTE_GetCurrentElement(strBaseElementID);
				if (currentElem !=null && currentElem.tagName=="TABLE")
				{
					tableControlSelected=true;
				}
			}
		}
		if (restrictions.HYPERLINKS && restrictions.HYPERLINKS=="true" && !tableControlSelected)
		{
			if (linkElemInChain)
			{
				RTE2_TB_ChangeToolTip(strBaseElementID, g_strRTECreateLinkMnemonic, L_EditLinkToolTip_TEXT);
			}
			else
			{
				RTE2_TB_ChangeToolTip(strBaseElementID, g_strRTECreateLinkMnemonic, L_CreateLinkToolTip_TEXT);
			}
			RTE_TB_ClearButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTECreateLinkMnemonic));
		}
		else
		{
			RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTECreateLinkMnemonic));
		}
		RTE_TB_SetEnabledFromCommandEnabled(strBaseElementID, docEditor, g_strRTE2UnlinkMnemonic, g_strRTE2UnlinkMnemonic);
		if (restrictions.IMAGES && restrictions.IMAGES=="true")
		{
			if (imgElemInChain)
			{
				RTE2_TB_ChangeToolTip(strBaseElementID, g_strRTEInsertImageMnemonic, L_EditImageToolTip_TEXT);
			}
			else
			{
				RTE2_TB_ChangeToolTip(strBaseElementID, g_strRTEInsertImageMnemonic, L_InsertImageToolTip_TEXT);
			}
			RTE_TB_ClearButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEInsertImageMnemonic));
		}
		else
		{
			RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEInsertImageMnemonic));
		}
		if (restrictions.TABLES && restrictions.TABLES=="true")
		{
			RTE_TB_SetEnabledFromCondition(strBaseElementID, !multipleCellsSelected, g_strRTE2InsertTableMnemonic);
			RTE2_TB_SetEnabledFromCondition(strBaseElementID, tableElemInChain, g_strRTE2EditTableMnemonic);
			RTE_TB_ClearButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTE2ShowTableBordersMnemonic));
			RTE2_TB_SetCheckFromCondition(strBaseElementID, RTE2_ShouldTableBordersBeVisible(strBaseElementID), g_strRTE2ShowTableBordersMnemonic);
			RTE2_TB_SetEnabledFromCondition(strBaseElementID, trElemInChain, g_strRTE2TableMnemonic);
			RTE2_TB_SetEnabledFromCondition(strBaseElementID, trElemInChain, g_strRTEMergeCellMnemonic);
			RTE2_TB_SetEnabledFromCondition(strBaseElementID, cellElemInChain, g_strRTE2TableCellSizingMnemonic);
		}
		else
		{
			RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTE2InsertTableMnemonic));
			RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTE2EditTableMnemonic));
			RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTE2ShowTableBordersMnemonic));
			RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTE2TableMnemonic));
			RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEMergeCellMnemonic));
			RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTE2TableCellSizingMnemonic));
		}
		RTE_TB_ClearButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTE2SelectElementMnemonic));
		RTE_TB_SetEnabledFromCondition(strBaseElementID, !instanceVariables.DisableCustomStyles, g_strRTE2CustomStylesMnemonic);
		RTE_TB_SetEnabledFromCondition(strBaseElementID, RTE2_ShowParagraphStyles(strBaseElementID), g_strRTEStylesMnemonic);
		if (!controlSelected && restrictions.LISTS && restrictions.LISTS=="true")
		{
			RTE_TB_ClearButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEOrderedListMnemonic));
			RTE_TB_SetCheckFromCommandValue(strBaseElementID, docEditor, g_strRTEOrderedListMnemonic);
			RTE_TB_ClearButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEUnorderedListMnemonic));
			RTE_TB_SetCheckFromCommandValue(strBaseElementID, docEditor, g_strRTEUnorderedListMnemonic);
		}
		else
		{
			RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEOrderedListMnemonic));
			RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEUnorderedListMnemonic));
		}
		if (!controlSelected && restrictions.FONTS && restrictions.FONTS=="true" && !instanceVariables.DisableBasicFormattingButtons)
		{
			RTE_TB_ClearButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEFontNameMnemonic));
			RTE_TB_ClearButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEFontSizeMnemonic));
			RTE_TB_ClearButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEForeColorMnemonic));
			RTE_TB_ClearButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEBackColorMnemonic));
		}
		else
		{
			RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEFontNameMnemonic));
			RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEFontSizeMnemonic));
			RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEForeColorMnemonic));
			RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEBackColorMnemonic));
		}
		if (!controlSelected && restrictions.TEXTMARKUP && restrictions.TEXTMARKUP=="true" && !instanceVariables.DisableBasicFormattingButtons)
		{
			RTE_TB_ClearButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEBoldMnemonic));
			RTE_TB_SetCheckFromCommandValue(strBaseElementID, docEditor, g_strRTEBoldMnemonic);
			RTE_TB_ClearButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEItalicMnemonic));
			RTE_TB_SetCheckFromCommandValue(strBaseElementID, docEditor, g_strRTEItalicMnemonic);
			RTE_TB_ClearButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEUnderlineMnemonic));
			RTE_TB_SetCheckFromCommandValue(strBaseElementID, docEditor, g_strRTEUnderlineMnemonic);
			RTE_TB_ClearButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEOutdentMnemonic));
			RTE_TB_ClearButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEIndentMnemonic));
		}
		else
		{
			RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEBoldMnemonic));
			RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEItalicMnemonic));
			RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEUnderlineMnemonic));
			RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEOutdentMnemonic));
			RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEIndentMnemonic));
		}
		if (!instanceVariables.DisableBasicFormattingButtons)
		{
			RTE_TB_ClearButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEJustifyLeftMnemonic));
			RTE2_TB_SetCheckFromCondition(strBaseElementID, RTE2_IsAligned(strBaseElementID, g_strRTEJustifyLeftMnemonic, "left"), g_strRTEJustifyLeftMnemonic);
			RTE_TB_ClearButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEJustifyCenterMnemonic));
			RTE2_TB_SetCheckFromCondition(strBaseElementID, RTE2_IsAligned(strBaseElementID, g_strRTEJustifyCenterMnemonic, "center"), g_strRTEJustifyCenterMnemonic);
			RTE_TB_ClearButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEJustifyRightMnemonic));
			RTE2_TB_SetCheckFromCondition(strBaseElementID, RTE2_IsAligned(strBaseElementID, g_strRTEJustifyRightMnemonic, "right"), g_strRTEJustifyRightMnemonic);
		}
		else
		{
			RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEJustifyLeftMnemonic));
			RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEJustifyCenterMnemonic));
			RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEJustifyRightMnemonic));
		}
		RTE2_TB_SetCheckFromCondition(strBaseElementID, RTE2_IsSourceView(strBaseElementID), g_strRTE2ViewSourceMnemonic);
		RTE2_TB_SetEnabledFromCondition(strBaseElementID, hasActiveSelection, g_strRTE2RemoveStylesMnemonic);
		if (RTE2_ShouldEnableDirection(strBaseElementID))
		{
			RTE_TB_ClearButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTELTRMnemonic));
			RTE_TB_ClearButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTERTLMnemonic));
		}
		else
		{
			RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTELTRMnemonic));
			RTE_TB_SetButtonDisabled(RTE_TB_GetToolBarButton(strBaseElementID, g_strRTERTLMnemonic));
		}
	}
	if ((null !=g_extraButtons) && instanceVariables.EnableExtensions)
	{
		var g_extraButtonsLength=g_extraButtons.length;
		for (var i=0; i < g_extraButtonsLength;++i)
		{
			var extraButton=g_extraButtons[i];
			if (null !=extraButton && null !=extraButton._addedToToolbar && true==extraButton._addedToToolbar)
			{
				RTE_TB_SetEnabledFromCondition(strBaseElementID, RTE2_ExtraButtonOnResetState(strBaseElementID, i), g_strRTE2CustomStylesMnemonic);
			}
		}
	}
}
function RTE2_StopReusableTextFragmentResizes()
{
	window.event.returnValue=false;
	return;
}
function RTE2_TB_SetEnabledFromCondition(strBaseElementID, fCondition, strCommand)
{
	var btn=RTE_TB_GetToolBarButton(strBaseElementID, strCommand);
	if (fCondition)
	{
		RTE_TB_ClearButtonDisabled(btn);
	}
	else
	{
		RTE_TB_SetButtonDisabled(btn);
	}
}
function RTE2_TB_SetCheckFromCondition(strBaseElementID, fCondition, strCommand)
{
	var btn=RTE_TB_GetToolBarButton(strBaseElementID, strCommand);
	if (fCondition==true)
	{
		RTE_TB_SetButtonCheck(btn);
	}
	else
	{
		RTE_TB_ClearButtonCheck(btn);
	}
}
function RTE2_IsSourceView(strBaseElementID)
{
	if (g_oExtendedRichTextSupport.editors[strBaseElementID] !=null)
	{
		return g_oExtendedRichTextSupport.editors[strBaseElementID].isSourceView;
	}
	return false;
}
function RTE2_GenerateIFrameEditorHtml(strBaseElementID)
{
	var strHtmlRet="";
	var strWidthNameAndAttribute=" width=\"100%\"";
	var strHeightNameAndAttribute=" height=\"90%\"";
	var strClassNameAndAttribute="";
	strHtmlRet+="<div>";
	strHtmlRet+="<iframe "+strWidthNameAndAttribute+strHeightNameAndAttribute+strClassNameAndAttribute+			" id=\""+RTE_GetEditorIFrameID(strBaseElementID)+"\" title=\""+L_HtmlEditorIFrameTitle_TEXT+			"\" src=\""+RTE_GetServerRelativeUnlocalizedImageUrl("blank.gif")+"\" TABINDEX=1></iframe>";
	strHtmlRet+="</div>";
	strHtmlRet+=RTE2_GenerateEditorToolsHtml(strBaseElementID);
	return strHtmlRet;
}
function RTE2_GenerateEditorToolsHtml(strBaseElementID)
{
	var strHtmlRet="";
	if (RTE_GetDialogHelper()==null)
	{
		g_fRTEFirstTimeGenerateCalled=false;
		document.body.insertAdjacentHTML("afterBegin", "<object id=\"RTEDialogHelper\" name=\"RTEDialogHelper\" classid=\"clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b\" style=\"width:0px; height:0px;\" TABINDEX=-1></OBJECT>");
	}
	if (RTE_DD_GetMenuFrame()==null)
	{
		strHtmlRet+="<iframe id=\""+g_strRTETextEditorPullDownMenuID+"\"  src=\""+RTE_GetServerRelativeUnlocalizedImageUrl("blank.gif")+			"\" class=\"ms-rtetoolbarmenu\" TABINDEX=-1 style=\"display:none; position:absolute;z-index:10\" "+g_strRTEBaseElementIDAttributeName+"=\"x\" "+g_strRTEWebLocaleAttributeName+"=\"x\" "+			g_strRTEButtonMnemonicAttributeName+"=\"x\"></iframe>";
	}
	strHtmlRet+=RTE2_GenerateEditorSource(strBaseElementID);
	strHtmlRet+=RTE2_GenerateIFrameSafeHtml(strBaseElementID);
	return strHtmlRet;
}
function RTE2_GenerateEditorSource(strBaseElementID)
{
	var strHtmlRet="";
	var strTextAreaStyleAttribute="width:100%;position:relative;";
	var strDivStyleAttribute="display:none;";
	strHtmlRet+="<div id=\""+RTE2_GetSourceEditorDivID(strBaseElementID)+"\" style=\""+strDivStyleAttribute+"\">";
	strHtmlRet+="<textarea id=\""+RTE2_GetSourceEditorID(strBaseElementID)+"\" title=\""+L_HtmlEditorIFrameTitle_TEXT+			"\" TABINDEX=1 style=\""+strTextAreaStyleAttribute+"\"></textarea>";
	strHtmlRet+="</div>";
	return strHtmlRet;
}
function RTE2_GenerateIFrameSafeHtml(strBaseElementID)
{
	var strHtmlRet="";
	strHtmlRet+="<div>";
	strHtmlRet+="<iframe id=\""+RTE_GetEditorIFrameID(strBaseElementID)+			"_safe\" style=\"width:1px;height:1px;z-index:-100;position:absolute;\" tabindex=-1 src=\"/_layouts/blank.html\"></iframe>";
	strHtmlRet+="</div>";
	return strHtmlRet;
}
function RTE2_NotImplemented(strBaseElementID)
{
	alert("Not implemented");
}
function RTE2_EditTable(strBaseElementID)
{
	var docEditor=RTE_GetEditorDocument(strBaseElementID);
	if (docEditor==null) { return; }
	var table=RTE_GetNearestContainingElementOfType(strBaseElementID, "TABLE");
	if (table==null) return;
	var dialogArguments=new Object();
	dialogArguments["table"]=table;
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	var prefix=instanceVariables.prefixStyleSheet+"Table";
	dialogArguments["tablePrefix"]=prefix;
	dialogArguments["tableAllRules"]=RTE_GetReservedStyleRules(docEditor, prefix, "-");
	dialogArguments["tableValidRules"]=RTE2_GetReservedTableStyleRules(strBaseElementID, prefix, docEditor);
	var dialogUrl=RTE2_GetServerRelativeDialogUrl(strBaseElementID, "RTE2ETable.aspx");
	commonShowModalDialog(dialogUrl, "resizable: yes; status: no; scroll: no; help: no; dialogHeight: 740px; dialogWidth: 580px", null, dialogArguments);
	RTE2_ConvertTableToOriginalBorder(table);
	RTE2_AddHtmlEditorTags(strBaseElementID);
	RTE_StartUpdateOnCellMenuPositionTimer(strBaseElementID);
}
function RTE2_InsertTable(strBaseElementID)
{
	var docEditor=RTE_GetEditorDocument(strBaseElementID);
	if (docEditor==null) { return; }
	RTE_RestoreSelection(strBaseElementID);
	var selection=docEditor.selection;
	if (selection==null) { return; }
	var rngSelection=selection.createRange();
	if (rngSelection !=null)
	{
		var dialogArguments=new Object();
		dialogArguments["table"]=null;
		var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
		var prefix=instanceVariables.prefixStyleSheet+"Table";
		dialogArguments["tablePrefix"]=prefix;
		dialogArguments["tableAllRules"]=RTE_GetReservedStyleRules(docEditor, prefix, "-");
		dialogArguments["tableValidRules"]=RTE2_GetReservedTableStyleRules(strBaseElementID, prefix, docEditor);
		dialogArguments["ShouldTableBordersBeVisible"]=RTE2_ShouldTableBordersBeVisible(strBaseElementID);
		var callback=function (dlgResult)
		{
			if (dlgResult !=null)
			{
				if (selection.type=="Control") {
					selection.clear();
					rngSelection=selection.createRange();
					if (rngSelection==null) { return; }
				}
				rngSelection.pasteHTML(dlgResult);
				RTE2_AddHtmlEditorTags(strBaseElementID);
			}
		}
		var dialogUrl=RTE2_GetServerRelativeDialogUrl(strBaseElementID, "RTE2ETable.aspx");
		commonShowModalDialog(dialogUrl, "resizable: yes; status: no; scroll: no; help: no; dialogHeight: 740px; dialogWidth: 580px", callback, dialogArguments);
	}
	RTE_GiveEditorFocus(strBaseElementID);
}
function RTE2_InsertColumnLeft(strBaseElementID)
{
	RTE2_SaveHtmlStateIfChanged(strBaseElementID);
	if (RTE_GetDirectionOfSelection(strBaseElementID)=="rtl")
	{
		return RTE_InsertColumnBase(strBaseElementID, "afterEnd");
	}
	else
	{
		return RTE_InsertColumnBase(strBaseElementID, "beforeBegin");
	}
	RTE2_SaveHtmlState(strBaseElementID);
}
function RTE2_InsertColumnRight(strBaseElementID)
{
	RTE2_SaveHtmlStateIfChanged(strBaseElementID);
	if (RTE_GetDirectionOfSelection(strBaseElementID)=="rtl")
	{
		return RTE_InsertColumnBase(strBaseElementID, "beforeBegin");
	}
	else
	{
		return RTE_InsertColumnBase(strBaseElementID, "afterEnd");
	}
	RTE2_SaveHtmlState(strBaseElementID);
}
function RTE2_InsertRowAbove(strBaseElementID)
{
	RTE2_SaveHtmlStateIfChanged(strBaseElementID);
	RTE_InsertRowBase(strBaseElementID, "beforeBegin");
	RTE2_SaveHtmlState(strBaseElementID);
}
function RTE2_InsertRowBelow(strBaseElementID)
{
	RTE2_SaveHtmlStateIfChanged(strBaseElementID);
	RTE_InsertRowBase(strBaseElementID, "afterEnd");
	RTE2_SaveHtmlState(strBaseElementID);
}
function RTE2_InsertCellLeft(strBaseElementID)
{
	RTE2_SaveHtmlStateIfChanged(strBaseElementID);
	if (RTE_GetDirectionOfSelection(strBaseElementID)=="rtl")
	{
		return RTE_InsertCellBase(strBaseElementID, "afterEnd");
	}
	else
	{
		return RTE_InsertCellBase(strBaseElementID, "beforeBegin");
	}
	RTE2_SaveHtmlState(strBaseElementID);
}
function RTE2_InsertCellRight(strBaseElementID)
{
	RTE2_SaveHtmlStateIfChanged(strBaseElementID);
	if (RTE_GetDirectionOfSelection(strBaseElementID)=="rtl")
	{
		return RTE_InsertCellBase(strBaseElementID, "beforeBegin");
	}
	else
	{
		return RTE_InsertCellBase(strBaseElementID, "afterEnd");
	}
	RTE2_SaveHtmlState(strBaseElementID);
}
function RTE2_ClearUnknownAttributesAndStyleFromTable(table)
{
	RTE2_ClearUnknownAttributesAndStyle(table);
	for (var i=0; i<table.cells.length;i++)
	{
		var currentCell=table.cells(i);
		RTE2_ClearUnknownAttributesAndStyle(currentCell);
	}
}
function RTE2_ClearUnknownAttributesAndStyle(element)
{
	var attributes=RTE2_GetSpecifiedAttributes(element);
	var attributes_length=attributes.length;
	for (var j=0; j<attributes_length;j++)
	{
		var currentAttribute=attributes[j];
		var attributeName=currentAttribute.nodeName.toLowerCase();
		if (attributeName=="id") continue;
		else if (attributeName=="rowspan") continue;
		else if (attributeName=="colspan") continue;
		else if (attributeName=="width") continue;
		else if (attributeName=="height") continue;
		element.removeAttribute(attributeName, 0);
	}
}
function RTE2_ChooseForeColor(strBaseElementID)
{
	var docEditor=RTE_GetEditorDocument(strBaseElementID);
	if (docEditor==null) { return; }
	RTE_RestoreSelection(strBaseElementID);
	var selection=docEditor.selection;
	if (selection==null || selection.type=="Control") { return; }
	var dlgHelper=RTE_GetDialogHelper();
	if (dlgHelper !=null)
	{
		var initForeColor=docEditor.queryCommandValue("ForeColor");
		var foreColor=dlgHelper.ChooseColorDlg(initForeColor);
		foreColor=foreColor.toString(16);
		if (foreColor.length < 6)
		{
			var tempString="000000".substring(0,6-foreColor.length);
			foreColor=tempString.concat(foreColor);
		}
		RTE2_ToggleReusableFragmentsDummy(strBaseElementID, true);
		docEditor.execCommand("ForeColor", false, foreColor);
		RTE2_ToggleReusableFragmentsDummy(strBaseElementID, false);
	}
	RTE_GiveEditorFocus(strBaseElementID);
}
function RTE2_ChooseBackColor(strBaseElementID)
{
	var docEditor=RTE_GetEditorDocument(strBaseElementID);
	if (docEditor==null) { return; }
	RTE_RestoreSelection(strBaseElementID);
	var selection=docEditor.selection;
	if (selection==null || selection.type=="Control") { return; }
	var dlgHelper=RTE_GetDialogHelper();
	if (dlgHelper !=null)
	{
		var initBackColor=docEditor.queryCommandValue("BackColor");
		var backColor=dlgHelper.ChooseColorDlg(initBackColor);
		backColor=backColor.toString(16);
		if (backColor.length < 6)
		{
			var tempString="000000".substring(0,6-backColor.length);
			backColor=tempString.concat(backColor);
		}
		RTE2_ToggleReusableFragmentsDummy(strBaseElementID, true);
		docEditor.execCommand("BackColor", false, backColor);
		RTE2_ToggleReusableFragmentsDummy(strBaseElementID, false);
	}
	RTE_GiveEditorFocus(strBaseElementID);
}
function RTE2_RemoveEditorPathFromUrls(strBaseElementID)
{
	var editorDocument=RTE_GetEditorDocument(strBaseElementID);
	RTE2_RemoveEditorPathFromUrlsInElement(editorDocument);
}
function RTE2_RemoveEditorPathFromUrlsInElement(elementToClean)
{
	var elements=RTE2_GetAllElements(elementToClean)
	var invalidURLFound=false;
	if (elements !=null)
	{
		var editorPath=window.location.href;
		editorPath=editorPath.toLowerCase();
		var numElementsAffected=0;
		for (var i=0; i<elements.length; i++)
		{
			var element=elements[i];
			if (element==null) continue;
			try
			{
				if (element.src !=null && element.src !="")
				{
					var src=element.src.toLowerCase();
					if (src.indexOf(editorPath)==0)
					{
						element.src=src.slice(editorPath.length);
					}
				}
			}
			catch(ex)
			{
				invalidURLFound=true;
			}
			if (element.background !=null && element.background !="")
			{
				var background=element.background.toLowerCase();
				if (background.indexOf(editorPath)==0)
				{
					element.background=background.slice(editorPath.length);
				}
			}
			if (element.datasource !=null && element.datasource !="")
			{
				var datasource=element.datasource.toLowerCase();
				if (datasource.indexOf(editorPath)==0)
				{
					element.datasource=datasource.slice(editorPath.length);
				}
			}
			if (element.dynsrc !=null && element.dynsrc !="")
			{
				var dynsource=element.dynsource.toLowerCase();
				if (dynsource.indexOf(editorPath)==0)
				{
					element.dynsource=dynsource.slice(editorPath.length);
				}
			}
			try
			{
				if (element.href !=null && element.href !="")
				{
					var href=element.href.toLowerCase();
					if (href.indexOf(editorPath)==0)
					{
						try { element.href=href.slice(editorPath.length); } catch (ex) {}
					}
				}
			}
			catch(ex)
			{
				invalidURLFound=true;
			}
			if (element.lowsrc !=null && element.lowsrc !="")
			{
				var lowsrc=element.lowsrc.toLowerCase();
				if (lowsrc.indexOf(editorPath)==0)
				{
					element.lowsrc=lowsrc.slice(editorPath.length);
				}
			}
		}
	}
	if (invalidURLFound)
	{
		alert(L_InvalidURL_TEXT);
	}
}
function RTE2_RemoveStyles(strBaseElementID)
{
	RTE2_SaveHtmlStateIfChanged(strBaseElementID)
	var docContainer=RTE2_GetEditorContainer(strBaseElementID);
	var containedElements=RTE_GetContainedElements(strBaseElementID);
	var containedElementsInEditor=new Array();
	for (var i=0;i<containedElements.length;i++)
	{
		if (RTE2_ElementInContentArea(strBaseElementID, containedElements[i]))
		{
			if (containedElements[i]==docContainer)
			{
				for (var j=0; j<docContainer.children.length;j++)
				{
					containedElementsInEditor[containedElementsInEditor.length]=docContainer.children[j];
				}
			}
			else
			{
				containedElementsInEditor[containedElementsInEditor.length]=containedElements[i];
			}
		}
	}
	var htmlModified=RTE2_RemoveElementStyles(containedElementsInEditor);
	if (htmlModified)
	{
		RTE2_SaveHtmlState(strBaseElementID)
	}
}
function RTE2_ElementInReusableText(element)
{
	while (element !=null)
	{
		if (element.id==g_strRTE2ReusableFragmentCommonToken)
		{
			return true;
		}
		element=element.parentElement;
	}
	return false;
}
function RTE2_RemoveElementStyles(elements)
{
	if (elements !=null)
	{
		var numElementsAffected=0;
		for (var i=0; i<elements.length; i++)
		{
			var elementAffected=false;
			var elementRemoved=false;
			var currentElement=elements[i];
			if (RTE2_ElementInReusableText(currentElement))
			{
				continue;
			}
			if (currentElement==null) continue;
			if (!elementRemoved &&
				 (currentElement.tagName=="FONT" ||
				  currentElement.tagUrn !=null && currentElement.tagUrn !=""))
			{
				currentElement.removeNode(false);
				elementRemoved=true;
				elementAffected=true;
			}
			var tableWidth="";
			var tableHeight="";
			if (currentElement.tagName=="TABLE")
			{
				if (currentElement.style !=null)
				{
					tableWidth=currentElement.style.width;
					tableHeight=currentElement.style.height;
					currentElement.style.removeAttribute("width", 0);
					currentElement.style.removeAttribute("height", 0);
				}
			}
			if (!elementRemoved && currentElement.getAttributeNode("style") !=null)
			{
				var attribute=currentElement.getAttributeNode("style");
				if (attribute.specified)
				{
					currentElement.removeAttribute("style", 0);
					elementAffected=true;
				}
			}
			if (tableWidth !="")
			{
				currentElement.style.setAttribute("width", tableWidth);
			}
			if (tableHeight !="")
			{
				currentElement.style.setAttribute("height", tableHeight);
			}
			if (!elementRemoved && currentElement.getAttributeNode("class") !=null)
			{
				var attribute=currentElement.getAttributeNode("class");
				if (attribute.specified)
				{
					var cacheSpecialEditClass="";
					if((new RegExp(CONST_AssetBoommarkOnlyClassName,"i")).test(attribute.value))
					{
						cacheSpecialEditClass=CONST_AssetBoommarkOnlyClassName;
					}
					else if((new RegExp(CONST_AssetIconClassName,"i")).test(attribute.value))
					{
						cacheSpecialEditClass=CONST_AssetIconClassName;
					}
					if(""==cacheSpecialEditClass)
					{
						currentElement.removeAttribute("className", 0);
						elementAffected=true;
					}
					else if(attribute.value !=cacheSpecialEditClass)
					{
						attribute.value=cacheSpecialEditClass;
						elementAffected=true;
					}
				}
			}
			if (elementAffected)
			{
				numElementsAffected++;
			}
		}
		if (numElementsAffected > 0)
		{
			alert(L_ElementStylesSuccesslyRemoved_TEXT.replace("###", numElementsAffected));
			return true;
		}
		else
		{
			alert(L_NoElementStylesWereRemoved_TEXT);
			return false;
		}
	}
}
function RTE2_GetDialogParameter(strBaseElementID, paramName)
{
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	if(instanceVariables.aSettings)
	{
		var aSettings=instanceVariables.aSettings;
		for(eachIndex in aSettings)
		{
			if(aSettings[eachIndex][0]==paramName)
			{
				return aSettings[eachIndex][1];
			}
		}
	}
	return "";
}
function RTE2_ShouldAllowExternalUrls(strBaseElementID)
{
	var shouldAllowExternalUrls=true;
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	if(instanceVariables &&
	   instanceVariables.restrictions &&
	   "true"==instanceVariables.restrictions.RESTRICTURLSTOSITECOLLECTION)
	{
		shouldAllowExternalUrls=false;
	}
	return shouldAllowExternalUrls;
}
function RTE2_InsertOrChangeImage(strBaseElementID)
{
	var docEditor=RTE_GetEditorDocument(strBaseElementID);
	if (docEditor==null) return;
	RTE_RestoreSelection(strBaseElementID);
	var configObj=new AssetPickerConfig("");
	configObj.ClientID=strBaseElementID;
	configObj.DefaultAssetLocation=RTE2_GetDialogParameter(strBaseElementID, "DefaultAssetLocation");
	configObj.DefaultAssetImageLocation=RTE2_GetDialogParameter(strBaseElementID, "DefaultAssetImageLocation");
	configObj.CurrentWebBaseUrl=RTE2_GetDialogParameter(strBaseElementID, "CurrentWebBaseUrl");
	configObj.ManageHyperlink=false;
	configObj.AllowExternalUrls=RTE2_ShouldAllowExternalUrls(strBaseElementID);
	var bInserting=false;
	var elemToReplace=null;
	var imageAssetObj=new ImageAsset("");
	var selectionType=RTE_GetCurrentSelectionType(strBaseElementID);
	if (selectionType==null) {return;}
	if (selectionType=="Control")
	{
		elemToReplace=RTE_GetCurrentElement(strBaseElementID);
		if (elemToReplace==null) {return;}
	}
	var elemImage=RTE_GetNearestContainingElementOfType(strBaseElementID, "IMG");
	if( !elemImage )
	{
		bInserting=true;
		elemImage=docEditor.createElement("IMG");
		elemImage.border=0;
		if (elemImage==null) {return;}
	}
	configObj.ReturnCallback=function(newAssetUrl, newAssetText, currentConfig, dialogReturnedData)
	{
		if (dialogReturnedData)
		{
			if (elemToReplace !=null)
			{
				elemToReplace.replaceNode(elemImage);
				return;
			}
			else if (bInserting)
			{
				var selection=docEditor.selection;
				if (selection !=null)
				{
					var textRange=selection.createRange();
					if (textRange !=null)
					{
						try
						{
							textRange.pasteHTML(elemImage.outerHTML);
						}
						catch(e)
						{
							alert(L_ErrorProcessingImage_TEXT);
						}
					}
				}
			}
		}
		RTE_GiveEditorFocus(strBaseElementID);
	}
	var dialogReturnedData=imageAssetObj.LaunchModalDialogOnElement(configObj, elemImage, true, !bInserting );
}
function RTE2_InsertOrChangeHyperLink(strBaseElementID)
{
	var docEditor=RTE_GetEditorDocument(strBaseElementID);
	if (docEditor==null) return;
	RTE_RestoreSelection(strBaseElementID);
	var configObj=new AssetPickerConfig("");
	configObj.ClientID=strBaseElementID;
	configObj.DefaultAssetLocation=RTE2_GetDialogParameter(strBaseElementID, "DefaultAssetLocation");
	configObj.DefaultAssetImageLocation=RTE2_GetDialogParameter(strBaseElementID, "DefaultAssetImageLocation");
	configObj.CurrentWebBaseUrl=RTE2_GetDialogParameter(strBaseElementID, "CurrentWebBaseUrl");
	configObj.AllowExternalUrls=RTE2_ShouldAllowExternalUrls(strBaseElementID);
	var bInserting=false;
	var elemToReplace=null;
	var linkAsset=new LinkAsset("");
	var innerLinkHTML=null;
	linkAsset.ManageLinkDisplayText=false;
	var elemLink=RTE_GetNearestContainingElementOfType(strBaseElementID, "A");
	if( !elemLink )
	{
		bInserting=true;
		elemLink=docEditor.createElement("A");
		if (elemLink==null) {    return; }
		var selectionType=RTE_GetCurrentSelectionType(strBaseElementID);
		if (selectionType==null) {return;}
		if (selectionType=="Control")
		{
			elemToReplace=RTE_GetCurrentElement(strBaseElementID);
			if (elemToReplace==null) {return;}
		}
	}
	else
	{
		innerLinkHTML=elemLink.innerHTML;
	}
	configObj.ReturnCallback=function(newAssetUrl, newAssetText, currentConfig, dialogReturnedData)
	{
		if (dialogReturnedData)
		{
			if(innerLinkHTML && innerLinkHTML !="")
			{
				elemLink.innerHTML=innerLinkHTML;
			}
			else if(elemLink.innerHTML=="")
			{
				if(linkAsset.AssetText && linkAsset.AssetText !="")
				{
					elemLink.innerText=linkAsset.AssetText
				}
				else
				{
					elemLink.innerText=linkAsset.AssetUrl;
				}
			}
			if (elemToReplace !=null)
			{
				elemToReplace.applyElement(elemLink);
				linkAsset.FixupIconsAndEmptyAnchors(elemLink)
				return;
			}
			else if (bInserting)
			{
				var selection=docEditor.selection;
				if (selection !=null)
				{
					var textRange=selection.createRange();
					if (textRange !=null)
					{
						var text=textRange.text;
						if (text && text !="" && !text.match(/^\s+$/))
						{
							textRange.execCommand("Unlink");
							elemLink.innerHTML=textRange.htmlText;
							linkAsset.FixupIconsAndEmptyAnchors(elemLink)
						}
						textRange.pasteHTML(elemLink.outerHTML);
					}
				}
			}
			else
			{
				linkAsset.FixupIconsAndEmptyAnchors(elemLink)
			}
		}
		RTE_GiveEditorFocus(strBaseElementID);
	}
	linkAsset.LaunchModalDialogOnElement(configObj, elemLink, true, !bInserting );
}
function RTE2_EditImageOrLinkProperties(strBaseElementID)
{
	var docEditor=RTE_GetEditorDocument(strBaseElementID);
	if (docEditor==null) return;
	RTE_RestoreSelection(strBaseElementID);
	var configObj=new AssetPickerConfig("");
	configObj.ClientID=strBaseElementID;
	configObj.DefaultAssetLocation=RTE2_GetDialogParameter(strBaseElementID, "DefaultAssetLocation");
	configObj.DefaultAssetImageLocation=RTE2_GetDialogParameter(strBaseElementID, "DefaultAssetImageLocation");
	configObj.CurrentWebBaseUrl=RTE2_GetDialogParameter(strBaseElementID, "CurrentWebBaseUrl");
	configObj.AllowExternalUrls=RTE2_ShouldAllowExternalUrls(strBaseElementID);
	configObj.ReturnCallback=function()
	{
		RTE_GiveEditorFocus(strBaseElementID);
	}
	var bInserting=false;
	var elemToReplace=null;
	var elemImageToEdit=RTE_GetNearestContainingElementOfType(strBaseElementID, "IMG");
	if ( elemImageToEdit )
	{
		var imageAsset=new ImageAsset("");
		configObj.ManageHyperlink=false;
		imageAsset.LaunchModalDialogOnElement(configObj, elemImageToEdit, true, true );
	}
	else
	{
		var elemLinkToEdit=RTE_GetNearestContainingElementOfType(strBaseElementID, "A");
		if( elemLinkToEdit )
		{
			var linkAsset=new LinkAsset("");
			linkAsset.ManageLinkDisplayText=false;
			linkAsset.LaunchModalDialogOnElement(configObj, elemLinkToEdit, true, true );
		}
	}
}
function RTE2_GetServerRelativeDialogUrl(strBaseElementID, strScriptFileName)
{
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	var webUrl=instanceVariables.webUrl;
	return webUrl+"_layouts/"+strScriptFileName;
}
function RTE2_GetSourceEditorTextArea(strBaseElementID)
{
	var item=document.getElementById(RTE2_GetSourceEditorID(strBaseElementID));
	return item;
}
function RTE2_GetSourceEditorDiv(strBaseElementID)
{
	var item=document.getElementById(RTE2_GetSourceEditorDivID(strBaseElementID));
	return item;
}
function RTE2_GetSourceEditorID(strBaseElementID)
{
	return strBaseElementID+"_source";
}
function RTE2_GetSourceEditorDivID(strBaseElementID)
{
	return strBaseElementID+"_source_div";
}
function RTE2_GetSafeHtmlIFrame(strBaseElementID)
{
	var ifmSafeHtml=null;
	if ((null !=document.frames) && (document.frames.length > 0))
	{
		var ifmContainer=RTE2_GetSafeHtmlElement(strBaseElementID);
		if (ifmContainer !=null)
		{
			ifmSafeHtml=document.frames(RTE2_GetSafeHtmlIFrameID(strBaseElementID));
		}
	}
	return ifmSafeHtml;
}
function RTE2_GetSafeHtmlElement(strBaseElementID)
{
	var elemSafeHtmlIFrame=document.getElementById(RTE2_GetSafeHtmlIFrameID(strBaseElementID));
	return elemSafeHtmlIFrame;
}
function RTE2_GetSafeHtmlDocument(strBaseElementID)
{
	var ifmSafeHtml=RTE2_GetSafeHtmlIFrame(strBaseElementID);
	if (null==ifmSafeHtml)
	{
		return null;
	}
	var docSafeHtml=ifmSafeHtml.document;
	return docSafeHtml;
}
function RTE2_GetSafeHtmlIFrameID(strBaseElementID)
{
	return strBaseElementID+"_iframe_safe";
}
function RTE2_OnPaste(strBaseElementID, body)
{
	if (!RTE2_IsSourceView(strBaseElementID))
	{
		var clipboardText=body.document.parentWindow.clipboardData.getData("Text");
		if (clipboardText !=null && clipboardText.length > 100000)
		{
			alert(L_ClipboardTextTooLarge_TEXT);
			body.document.parentWindow.event.returnValue=false;
		}
		else
		{
			var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
			if (clipboardText==null) clipboardText="";
			var safeHtmlDocument=RTE2_GetSafeHtmlDocument(strBaseElementID);
			if (safeHtmlDocument==null) return;
			var selection=RTE_GetCurrentSelection(strBaseElementID);
			if (selection !=null)
			{
				if (selection.type !="Control")
				{
					var textRange=selection.createRange();
					if (textRange !=null)
					{
						RTE2_ResetSafeHtmlDocument(safeHtmlDocument);
						var safeRange=safeHtmlDocument.body.createTextRange();
						safeRange.execCommand("Paste")
						var elements=RTE2_GetAllElements(safeHtmlDocument);
						if (elements.length > 2000)
						{
							var userWantsToWait=confirm(L_DoYouWannaWaitForLongPaste_TEXT);
							if (!userWantsToWait)
							{
								body.document.parentWindow.event.returnValue=false;
								return;
							}
						}
						RTE2_ApplyContentFilters(elements, instanceVariables);
						var clipboardTextReturns=clipboardText.replace(/\n/g,"<BR>");
						instanceVariables.pasteData.text=clipboardTextReturns;
						instanceVariables.pasteData.stripped=null;
						instanceVariables.pasteData.html=safeHtmlDocument.body.innerHTML;
						RTE_RestoreSelection(strBaseElementID);
						RTE2_SaveHtmlStateIfChanged(strBaseElementID);
						instanceVariables.pasteData.textRange=textRange;
						textRange.pasteHTML("");
						var pasteTextRange=textRange.duplicate();
						pasteTextRange.collapse();
						pasteTextRange.pasteHTML(safeHtmlDocument.body.innerHTML);
						body.document.parentWindow.event.returnValue=false;
						RTE2_RemoveEditorPathFromUrls(strBaseElementID);
						RTE2_AddHtmlEditorTags(strBaseElementID);
						RTE2_SaveHtmlState(strBaseElementID);
						var pasteHtmlNoReturns=safeHtmlDocument.body.innerHTML;
						pasteHtmlNoReturns=pasteHtmlNoReturns.replace(/<P>/g,"");
						pasteHtmlNoReturns=pasteHtmlNoReturns.replace(/<\/P>/g,"");
						pasteHtmlNoReturns=pasteHtmlNoReturns.replace(/<BR>/g,"");
						pasteHtmlNoReturns=pasteHtmlNoReturns.replace(/&nbsp;/g,"");
						pasteHtmlNoReturns=pasteHtmlNoReturns.replace(/\r/g,"");
						pasteHtmlNoReturns=pasteHtmlNoReturns.replace(/\n/g,"");
						pasteHtmlNoReturns=pasteHtmlNoReturns.replace(/ /g,"");
						var clipboardTextNoReturns=clipboardText;
						clipboardTextNoReturns=clipboardTextNoReturns.replace(/\r/g,"");
						clipboardTextNoReturns=clipboardTextNoReturns.replace(/\n/g,"");
						clipboardTextNoReturns=clipboardTextNoReturns.replace(/ /g,"");
						if (clipboardTextNoReturns !=pasteHtmlNoReturns)
						{
							RTE2_ShowOnPasteMenu(strBaseElementID, textRange);
						}
						RTE_SaveSelection(strBaseElementID);
					}
				}
			}
		}
	}
}
var g_allowUnsafeDrop=false;
function RTE2_OnDragStart(strBaseElementID)
{
	g_allowUnsafeDrop=true;
	RTE2_SaveHtmlStateIfChanged(strBaseElementID);
}
function RTE2_OnDragEnd(strBaseElementID)
{
	g_allowUnsafeDrop=false;
	RTE2_AddHtmlEditorTags(strBaseElementID);
	RTE2_SaveHtmlState(strBaseElementID);
}
function RTE2_OnDrop(strBaseElementID, body)
{
	if (!RTE2_IsSourceView(strBaseElementID))
	{
		if (!g_allowUnsafeDrop)
		{
			RTE2_SaveHtmlStateIfChanged(strBaseElementID);
			var strFromClipboard=body.document.parentWindow.event.dataTransfer.getData("Text");
			var x=body.document.parentWindow.event.x;
			var y=body.document.parentWindow.event.y;
			var docEditor=RTE_GetEditorDocument(strBaseElementID);
			var textRange=docEditor.body.createTextRange();
			textRange.moveToPoint(x,y);
			textRange.pasteHTML(strFromClipboard);
			body.document.parentWindow.event.returnValue=false;
			RTE2_SaveHtmlState(strBaseElementID);
		}
	}
}
function RTE2_OnPaste_Restricted(strBaseElementID, elem)
{
	var rngSelection=RTE_GetCurrentSelectionRange(strBaseElementID);
	var strFromClipboard=window.clipboardData.getData("Text");
	if ((null !=rngSelection) && (null !=strFromClipboard))
	{
		if (strFromClipboard.length > 100000)
		{
			alert(L_ClipboardTextTooLarge_TEXT);
		}
		else
		{
			rngSelection.text=strFromClipboard;
		}
	}
}
function RTE2_ApplyContentFilters(elements, instanceVariables)
{
	if (instanceVariables.EditorOpenFromWebPart)
		return;
	var containsLocalReferences=true;
	try
	{
		containsLocalReferences=RTE2_ContainsLocalReferences(elements);
	}
	catch (e) {}
	RTE2_RemoveScriptsAndHandlersFromElements(elements);
	if (containsLocalReferences)
	{
		var message=L_ContainsLocalReferences_TEXT;
		alert(message);
	}
	if (instanceVariables.DisableCustomStyles)
	{
		RTE2_RemoveCustomStyles(elements);
	}
}
function RTE2_GiveEditorFocus(strBaseElementID)
{
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	instanceVariables.disregardSelectionChange++;
	var docContainer=RTE2_GetEditorContainer(strBaseElementID);
	docContainer.setActive();
	if (RTE2_PopupMode(strBaseElementID))
	{
		docContainer.focus();
	}
	var editorDocument=RTE_GetEditorDocument(strBaseElementID);
	var textRange=editorDocument.selection.createRange();
	if (textRange.offsetTop >=editorDocument.body.clientHeight+editorDocument.body.scrollTop
		|| textRange.offsetLeft >=editorDocument.body.clientWidth+editorDocument.body.scrollLeft)
	{
		textRange.scrollIntoView();
	}
	instanceVariables.disregardSelectionChange--;
}
function RTE2_GetToolbar(strBaseElementID)
{
	var toolbar=document.getElementById(strBaseElementID+"_toolbar");
	return toolbar;
}
function RTE2_GetToolbarIFrame(strBaseElementID)
{
	var toolbarIFrame=document.getElementById(strBaseElementID+"_toolbarIFrame");
	return toolbarIFrame;
}
function RTE2_HideToolbar(strBaseElementID)
{
	var toolbar=RTE2_GetToolbar(strBaseElementID);
	toolbar.style.display='none';
	var toolbarIFrame=RTE2_GetToolbarIFrame(strBaseElementID);
	toolbarIFrame.style.display='none';
}
function RTE2_ShowToolbar(strBaseElementID)
{
	var toolbar=RTE2_GetToolbar(strBaseElementID);
	toolbar.style.display='';
	var toolbarIFrame=RTE2_GetToolbarIFrame(strBaseElementID);
	toolbarIFrame.style.display='';
}
function RTE2_OnBeforeActivate(strBaseElementID, element)
{
	if (!RTE2_PopupMode(strBaseElementID))
	{
		if (RTE2_ElementInContentArea(strBaseElementID, event.srcElement)
			|| RTE2_ElementInDropDownMenu(strBaseElementID, event.srcElement)
			|| (event.srcElement.tagName.toUpperCase()=="HTML"
			&& event.fromElement && RTE2_ElementInContentArea(strBaseElementID, event.fromElement)))
		{
			RTE2_ShowToolbar(strBaseElementID);
			RTE2_OnFocus(strBaseElementID);
			var docContainer=RTE2_GetEditorContainer(strBaseElementID);
			var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
			docContainer.runtimeStyle.backgroundColor=instanceVariables.editorBackgroundColor;
		}
		else
		{
			RTE2_HideToolbar(strBaseElementID);
			RTE2_HideSource(strBaseElementID);
			RTE2_OnBlur(strBaseElementID);
			var docContainer=RTE2_GetEditorContainer(strBaseElementID);
			docContainer.runtimeStyle.backgroundColor="";
			return;
		}
	}
}
function RTE2_ActiveElementInContentArea(strBaseElementID)
{
	var editorDocument=RTE_GetEditorDocument(strBaseElementID);
	return RTE2_ElementInContentArea(strBaseElementID, editorDocument.activeElement);
}
function RTE2_ElementInContentArea(strBaseElementID, element)
{
	if (RTE2_IsSourceView(strBaseElementID))
	{
		var sourceTextArea=RTE2_GetSourceEditorTextArea(strBaseElementID);
		if (sourceTextArea==null) return;
		return (element==sourceTextArea)
	}
	else
	{
		var editorDocument=RTE_GetEditorDocument(strBaseElementID);
		var elementRange=editorDocument.body.createTextRange();
		if (element.tagName !="HTML")
		{
			try
			{
				elementRange.moveToElementText(element);
			}
			catch(e)
			{
				return false;
			}
		}
		return RTE2_TextRangeInContentArea(strBaseElementID, elementRange);
	}
}
function RTE2_ElementInDropDownMenu(strBaseElementID, element)
{
	var editorDocument=RTE_GetEditorDocument(strBaseElementID);
	var elementRange=editorDocument.body.createTextRange();
	if (element.tagName !="HTML")
	{
	    elementRange.moveToElementText(element);
	}
	var menu=RTE_DD_GetMenuElement();
	var docRange=editorDocument.body.createTextRange();
	docRange.moveToElementText(menu);
	return docRange.inRange(elementRange);
}
function RTE2_TextRangeInContentArea(strBaseElementID, elementRange)
{
	var editorDocument=RTE_GetEditorDocument(strBaseElementID);
	var docContainer=RTE2_GetEditorContainer(strBaseElementID);
	var docRange=editorDocument.body.createTextRange();
	docRange.moveToElementText(docContainer);
	return docRange.inRange(elementRange);
}
function RTE2_OnSelectionChange(strBaseElementID, elemDocument)
{
	RTE_DD_CloseMenu();
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	if (instanceVariables.disregardSelectionChange==0)
	{
		var editorDocument=RTE_GetEditorDocument(strBaseElementID);
		var selection=editorDocument.selection;
		if (selection.type=="Control")
		{
			var controls=editorDocument.selection.createRange();
			if (controls.length==1)
			{
				instanceVariables.selectedElement=controls.item(0);
			}
			else
			{
				instanceVariables.selectedElement=null;
			}
		}
		else
		{
			instanceVariables.selectedElement=null;
		}
		RTE_SaveSelection(strBaseElementID);
		RTE_StartResetToolBarTimer(strBaseElementID);
	}
	var selectionStatus=RTE2_GetSelectionStatus(strBaseElementID);
	if (selectionStatus==null) return;
	var selectionStatusOriginalHeight=selectionStatus.clientHeight;
	if (!RTE2_IsSourceView(strBaseElementID))
	{
		var strSelectionInformation=L_CurrentSelection_TEXT;
		if (instanceVariables.selectedElement !=null)
		{
			strSelectionInformation+=RTE2_GetExpandedTagName(instanceVariables.selectedElement.tagName);
		}
		else
		{
			var selection=RTE_GetCurrentSelection(strBaseElementID);
			if (selection !=null)
			{
				switch (selection.type)
				{
					case "Text":
					{
						var rngSelection=RTE_GetCurrentSelectionRange(strBaseElementID);
						if (rngSelection !=null)
						{
							var htmlText=rngSelection.htmlText;
							if (htmlText !=null)
							{
								var length=htmlText.length;
								if (length==0)
								{
									strSelectionInformation+=L_CurrentSelectionTypeNone_TEXT;
									break;
								}
							}
						}
						strSelectionInformation+=L_CurrentSelectionTypeText_TEXT;
						break;
					}
					case "None":
					{
						strSelectionInformation+=L_CurrentSelectionTypeNone_TEXT;
						break;
					}
					case "Control":
					{
						strSelectionInformation+=L_CurrentSelectionTypeControl_TEXT;
						break;
					}
				}
			}
		}
		;
		selectionStatus.innerHTML=strSelectionInformation;
	}
	if (RTE2_PopupMode(strBaseElementID))
	{
		var selectionStatusNewHeight=selectionStatus.clientHeight;
		if (selectionStatusOriginalHeight !=selectionStatusNewHeight)
		{
			var iframeEditor=RTE_GetEditorIFrame(strBaseElementID);
			var frameHeight=iframeEditor.frameElement.clientHeight;
			iframeEditor.frameElement.height=frameHeight - selectionStatusNewHeight+selectionStatusOriginalHeight;
		}
	}
	RTE_StartUpdateOnCellMenuPositionTimer(strBaseElementID);
	RTE_TB_RemoveLastToolBarHover(strBaseElementID);
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	instanceVariables.fToolbarNavigate=false;
}
function RTE2_GetSelectionStatus(strBaseElementID)
{
	var selectionStatus=document.getElementById(strBaseElementID+"_selection_status_");
	return selectionStatus;
}
function RTE2_GetCurrentTextRange(strBaseElementID)
{
	var textRange=null;
	var editorDocument=RTE_GetEditorDocument(strBaseElementID);
	var selection=editorDocument.selection;
	if (selection.type=="Control")
	{
		textRange=editorDocument.body.createTextRange();
		var controls=editorDocument.selection.createRange();
		for (var i=0; i<controls.length; i++)
		{
			var control=controls.item(i);
			var controlRange=editorDocument.body.createTextRange();
			controlRange.moveToElementText(control);
			if (i==0)
			{
				textRange.setEndPoint("StartToStart", controlRange);
			}
			textRange.setEndPoint("EndToEnd", controlRange);
		}
	}
	else
	{
		textRange=editorDocument.selection.createRange();
	}
	return textRange;
}
function RTE2_ContainsLocalReferences(elements)
{
	var containsLocalReferences=false;
	var invalidURLFound=false;
	if (elements !=null)
	{
		for (var i=0; i<elements.length; i++)
		{
			var element=elements[i];
			if (element==null) continue;
			try
			{
				if (element.src !=null && element.src !="" && RTE2_IsLocalUrl(element.src))
				{
					containsLocalReferences=true;
					break;
				}
			}
			catch(ex)
			{
				invalidURLFound=true;
			}
			if (element.background !=null && element.background !="" && RTE2_IsLocalUrl(element.background))
			{
				containsLocalReferences=true;
				break;
			}
			if (element.datasource !=null && element.datasource !="" && RTE2_IsLocalUrl(element.datasource))
			{
				containsLocalReferences=true;
				break;
			}
			if (element.dynsrc !=null && element.dynsrc !="" && RTE2_IsLocalUrl(element.dynsrc))
			{
				containsLocalReferences=true;
				break;
			}
			try
			{
				if (element.href !=null && element.href !="" && RTE2_IsLocalUrl(element.href))
				{
					containsLocalReferences=true;
					break;
				}
			}
			catch(ex)
			{
				invalidURLFound=true;
			}
			if (element.lowsrc !=null && element.lowsrc !="" && RTE2_IsLocalUrl(element.lowsrc))
			{
				containsLocalReferences=true;
				break;
			}
		}
	}
	if (invalidURLFound)
	{
		alert(L_InvalidURL_TEXT);
	}
	return containsLocalReferences;
}
function RTE2_RemoveCustomStyles(elements)
{
	if (elements !=null)
	{
		var elements_length=elements.length;
		for (var i=0; i < elements_length;++i)
		{
			var element=elements[i];
			if (element !=null)
			{
				element.removeAttribute("className", 0);
			}
		}
	}
}
function RTE2_IsLocalUrl(url)
{
	var tempUrl=url.toLowerCase();
	if (RTE2_IsSimpleURL(tempUrl))
	{
		return false;
	}
	else
	{
		if (tempUrl.indexOf("file:///")==0) return true;
		if (tempUrl.match("^file://[a-zA-Z]:\\\\")) return true;
		if (tempUrl.indexOf("\\\\")==0) return true;
		if (tempUrl.indexOf("//")==0) return true;
		if (tempUrl.indexOf("/\\")==0) return true;
		if (tempUrl.indexOf("\\/")==0) return true;
	}
	return false;
}
function RTE2_InstantiateStaticSafeHtmlRules()
{
	if (g_safeHtmlRules==null)
	{
		g_safeHtmlRules=new Array();
	}
	var tempRuleArray=new Array(
		"!--","DB","!--_class","A","!--_dir","A","!--_id","A","!--_lang","A","!--_msallowclip","A","!--_style","A",
		"!--_title","A","A","A","ABBR","A","ABBR_class","A","ABBR_dir","A","ABBR_id","A",
		"ABBR_lang","A","ABBR_msallowclip","A","ABBR_style","A","ABBR_title","A","ACRONYM","A","ACRONYM_class","A",
		"ACRONYM_dir","A","ACRONYM_id","A","ACRONYM_lang","A","ACRONYM_msallowclip","A","ACRONYM_style","A","ACRONYM_title","A",
		"ADDRESS","A","ADDRESS_class","A","ADDRESS_dir","A","ADDRESS_id","A","ADDRESS_lang","A","ADDRESS_msallowclip","A",
		"ADDRESS_style","A","ADDRESS_title","A","APPLET","DB","APPLET_align","A","APPLET_alt","A","APPLET_class","A",
		"APPLET_hspace","A","APPLET_id","A","APPLET_msallowclip","A","APPLET_style","A","APPLET_title","A","APPLET_vspace","A",
		"AREA","A","AREA_accesskey","A","AREA_alt","A","AREA_class","A","AREA_coords","A","AREA_dir","A",
		"AREA_href","DTURL","AREA_id","A","AREA_lang","A","AREA_msallowclip","A","AREA_shape","A","AREA_style","A",
		"AREA_tabindex","A","AREA_target","A","AREA_title","A","A_accesskey","A","A_charset","A","A_class","A",
		"A_coords","A","A_dir","A","A_href","DTURL","A_hreflang","A","A_id","A","A_lang","A",
		"A_msallowclip","A","A_name","A","A_rel","A","A_rev","A","A_shape","A","A_style","A",
		"A_tabindex","A","A_target","A","A_title","A","A_type","A","B","A","BASEFONT","A",
		"BASEFONT_class","A","BASEFONT_color","A","BASEFONT_dir","A","BASEFONT_face","A","BASEFONT_id","A","BASEFONT_lang","A",
		"BASEFONT_msallowclip","A","BASEFONT_size","A","BASEFONT_style","A","BASEFONT_title","A","BDO","A","BDO_class","A",
		"BDO_dir","A","BDO_id","A","BDO_lang","A","BDO_msallowclip","A","BDO_style","A","BDO_title","A",
		"BGSOUND","A","BGSOUND_class","A","BGSOUND_dir","A","BGSOUND_id","A","BGSOUND_lang","A","BGSOUND_loop","A",
		"BGSOUND_msallowclip","A","BGSOUND_src","DAURL","BGSOUND_style","A","BGSOUND_title","A","BIG","A","BIG_class","A",
		"BIG_dir","A","BIG_id","A","BIG_lang","A","BIG_msallowclip","A","BIG_style","A","BIG_title","A",
		"BLOCKQUOTE","A","BLOCKQUOTE_cite","A","BLOCKQUOTE_class","A","BLOCKQUOTE_dir","A","BLOCKQUOTE_id","A","BLOCKQUOTE_lang","A",
		"BLOCKQUOTE_msallowclip","A","BLOCKQUOTE_style","A","BLOCKQUOTE_title","A","BODY","A","BODY_alink","A","BODY_background","DAURL",
		"BODY_bgcolor","A","BODY_bgproperties","A","BODY_class","A","BODY_dir","A","BODY_id","A","BODY_lang","A",
		"BODY_leftmargin","A","BODY_link","A","BODY_msallowclip","A","BODY_style","A","BODY_text","A","BODY_title","A",
		"BODY_topmargin","A","BODY_vlink","A","BR","A","BR_class","A","BR_clear","A","BR_id","A",
		"BR_msallowclip","A","BR_style","A","BR_title","A","B_class","A","B_dir","A","B_id","A",
		"B_lang","A","B_msallowclip","A","B_style","A","B_title","A","CAPTION","A","CAPTION_accesskey","A",
		"CAPTION_align","A","CAPTION_class","A","CAPTION_dir","A","CAPTION_id","A","CAPTION_lang","A","CAPTION_msallowclip","A",
		"CAPTION_style","A","CAPTION_title","A","CAPTION_valign","A","CENTER","A","CENTER_class","A","CENTER_dir","A",
		"CENTER_id","A","CENTER_lang","A","CENTER_msallowclip","A","CENTER_style","A","CENTER_title","A","CITE","A",
		"CITE_class","A","CITE_dir","A","CITE_id","A","CITE_lang","A","CITE_msallowclip","A","CITE_style","A",
		"CITE_title","A","CODE","A","CODE_class","A","CODE_dir","A","CODE_id","A","CODE_lang","A",
		"CODE_msallowclip","A","CODE_style","A","CODE_title","A","COL","A","COLGROUP","A","COLGROUP_align","A",
		"COLGROUP_char","A","COLGROUP_charoff","A","COLGROUP_class","A","COLGROUP_dir","A","COLGROUP_id","A","COLGROUP_lang","A",
		"COLGROUP_msallowclip","A","COLGROUP_span","A","COLGROUP_style","A","COLGROUP_title","A","COLGROUP_valign","A","COLGROUP_width","A",
		"COL_align","A","COL_char","A","COL_charoff","A","COL_class","A","COL_dir","A","COL_id","A",
		"COL_lang","A","COL_msallowclip","A","COL_span","A","COL_style","A","COL_title","A","COL_valign","A",
		"COL_width","A","COMMENT","DB","COMMENT_class","A","COMMENT_dir","A","COMMENT_id","A","COMMENT_lang","A",
		"COMMENT_msallowclip","A","COMMENT_style","A","COMMENT_title","A","DD","A","DD_class","A","DD_dir","A",
		"DD_id","A","DD_lang","A","DD_msallowclip","A","DD_style","A","DD_title","A","DEL","A",
		"DEL_cite","A","DEL_class","A","DEL_datetime","A","DEL_dir","A","DEL_id","A","DEL_lang","A",
		"DEL_msallowclip","A","DEL_style","A","DEL_title","A","DFN","A","DFN_class","A","DFN_dir","A",
		"DFN_id","A","DFN_lang","A","DFN_msallowclip","A","DFN_style","A","DFN_title","A","DIR","A",
		"DIR_class","A","DIR_compact","A","DIR_dir","A","DIR_id","A","DIR_lang","A","DIR_msallowclip","A",
		"DIR_style","A","DIR_title","A","DIV","A","DIV_align","A","DIV_class","A","DIV_datasrc","DAURL",
		"DIV_dir","A","DIV_id","A","DIV_lang","A","DIV_msallowclip","A","DIV_style","A","DIV_title","A",
		"DIV_webpartid","A","DL","A","DL_class","A","DL_compact","A","DL_dir","A","DL_id","A",
		"DL_lang","A","DL_msallowclip","A","DL_style","A","DL_title","A","DT","A","DT_class","A",
		"DT_dir","A","DT_id","A","DT_lang","A","DT_msallowclip","A","DT_style","A","DT_title","A",
		"EM","A","EM_class","A","EM_dir","A","EM_id","A","EM_lang","A","EM_msallowclip","A",
		"EM_style","A","EM_title","A","EVENT","DB","EVENT_class","A","EVENT_dir","A","EVENT_id","A",
		"EVENT_lang","A","EVENT_msallowclip","A","EVENT_style","A","EVENT_title","A","FIELDSET","A","FIELDSET_class","A",
		"FIELDSET_dir","A","FIELDSET_id","A","FIELDSET_lang","A","FIELDSET_msallowclip","A","FIELDSET_style","A","FIELDSET_tabindex","A",
		"FIELDSET_title","A","FONT","A","FONT_class","A","FONT_color","A","FONT_dir","A","FONT_face","A",
		"FONT_id","A","FONT_lang","A","FONT_msallowclip","A","FONT_size","A","FONT_style","A","FONT_title","A",
		"FRAMESET","DB","FRAMESET_bordercolor","A","FRAMESET_class","A","FRAMESET_id","A","FRAMESET_msallowclip","A","FRAMESET_style","A",
		"FRAMESET_title","A","H1","A","H1_align","A","H1_class","A","H1_dir","A","H1_id","A",
		"H1_lang","A","H1_msallowclip","A","H1_style","A","H1_title","A","H2","A","H2_align","A",
		"H2_class","A","H2_dir","A","H2_id","A","H2_lang","A","H2_msallowclip","A","H2_style","A",
		"H2_title","A","H3","A","H3_align","A","H3_class","A","H3_dir","A","H3_id","A",
		"H3_lang","A","H3_msallowclip","A","H3_style","A","H3_title","A","H4","A","H4_align","A",
		"H4_class","A","H4_dir","A","H4_id","A","H4_lang","A","H4_msallowclip","A","H4_style","A",
		"H4_title","A","H5","A","H5_align","A","H5_class","A","H5_dir","A","H5_id","A",
		"H5_lang","A","H5_msallowclip","A","H5_style","A","H5_title","A","H6","A","H6_align","A",
		"H6_class","A","H6_dir","A","H6_id","A","H6_lang","A","H6_msallowclip","A","H6_style","A",
		"H6_title","A","HEAD","DB","HEAD_dir","A","HEAD_lang","A","HEAD_msallowclip","A","HR","A",
		"HR_align","A","HR_class","A","HR_color","A","HR_dir","A","HR_id","A","HR_lang","A",
		"HR_msallowclip","A","HR_noshade","A","HR_size","A","HR_style","A","HR_title","A","HR_width","A",
		"I","A","IMG","A","IMG_align","A","IMG_alt","A","IMG_border","A","IMG_class","A",
		"IMG_dir","A","IMG_dynsrc","DAURL","IMG_height","A","IMG_hspace","A","IMG_id","A","IMG_lang","A",
		"IMG_longdesc","A","IMG_loop","A","IMG_lowsrc","DAURL","IMG_msallowclip","A","IMG_mstagchanged","A","IMG_src","DAURL",
		"IMG_start","A","IMG_style","A","IMG_title","A","IMG_usemap","A","IMG_vspace","A","IMG_width","A",
		"INS","A","INS_cite","A","INS_class","A","INS_datetime","A","INS_dir","A","INS_id","A",
		"INS_lang","A","INS_msallowclip","A","INS_style","A","INS_title","A","I_class","A","I_dir","A",
		"I_id","A","I_lang","A","I_msallowclip","A","I_style","A","I_title","A","LABEL","A",
		"LABEL_accesskey","A","LABEL_class","A","LABEL_dir","A","LABEL_for","A","LABEL_id","A","LABEL_lang","A",
		"LABEL_msallowclip","A","LABEL_style","A","LABEL_title","A","LEGEND","A","LEGEND_accesskey","A","LEGEND_align","A",
		"LEGEND_class","A","LEGEND_dir","A","LEGEND_id","A","LEGEND_lang","A","LEGEND_msallowclip","A","LEGEND_style","A",
		"LEGEND_title","A","LI","A","LISTING","A","LISTING_class","A","LISTING_dir","A","LISTING_id","A",
		"LISTING_lang","A","LISTING_msallowclip","A","LISTING_style","A","LISTING_title","A","LI_class","A","LI_dir","A",
		"LI_id","A","LI_lang","A","LI_msallowclip","A","LI_style","A","LI_title","A","LI_type","A",
		"LI_value","A","MAP","A","MAP_class","A","MAP_dir","A","MAP_id","A","MAP_lang","A",
		"MAP_msallowclip","A","MAP_style","A","MAP_title","A","MARQUEE","A","MARQUEE_behavior","A","MARQUEE_bgcolor","A",
		"MARQUEE_class","A","MARQUEE_dir","A","MARQUEE_direction","A","MARQUEE_height","A","MARQUEE_hspace","A","MARQUEE_id","A",
		"MARQUEE_lang","A","MARQUEE_loop","A","MARQUEE_msallowclip","A","MARQUEE_scrollamount","A","MARQUEE_scrolldelay","A","MARQUEE_style","A",
		"MARQUEE_title","A","MARQUEE_vspace","A","MARQUEE_width","A","MENU","A","MENU_class","A","MENU_compact","A",
		"MENU_dir","A","MENU_id","A","MENU_lang","A","MENU_msallowclip","A","MENU_style","A","MENU_title","A",
		"NOBR","A","NOBR_class","A","NOBR_dir","A","NOBR_id","A","NOBR_lang","A","NOBR_msallowclip","A",
		"NOBR_style","A","NOBR_title","A","NOFRAMES","DB","NOFRAMES_class","A","NOFRAMES_dir","A","NOFRAMES_id","A",
		"NOFRAMES_lang","A","NOFRAMES_msallowclip","A","NOFRAMES_style","A","NOFRAMES_title","A","OL","A","OL_class","A",
		"OL_compact","A","OL_dir","A","OL_id","A","OL_lang","A","OL_msallowclip","A","OL_start","A",
		"OL_style","A","OL_title","A","OL_type","A","P","A","PLAINTEXT","A","PLAINTEXT_class","A",
		"PLAINTEXT_dir","A","PLAINTEXT_id","A","PLAINTEXT_lang","A","PLAINTEXT_msallowclip","A","PLAINTEXT_style","A","PLAINTEXT_title","A",
		"PRE","A","PRE_class","A","PRE_dir","A","PRE_id","A","PRE_lang","A","PRE_msallowclip","A",
		"PRE_style","A","PRE_title","A","PRE_width","A","P_align","A","P_class","A","P_dir","A",
		"P_id","A","P_lang","A","P_msallowclip","A","P_style","A","P_title","A","Q","A",
		"Q_cite","A","Q_class","A","Q_dir","A","Q_id","A","Q_lang","A","Q_msallowclip","A",
		"Q_style","A","Q_title","A","RT","A","RT_class","A","RT_dir","A","RT_id","A",
		"RT_lang","A","RT_msallowclip","A","RT_style","A","RT_title","A","RUBY","A","RUBY_class","A",
		"RUBY_dir","A","RUBY_id","A","RUBY_lang","A","RUBY_msallowclip","A","RUBY_style","A","RUBY_title","A",
		"S","A","SAMP","A","SAMP_class","A","SAMP_dir","A","SAMP_id","A","SAMP_lang","A",
		"SAMP_msallowclip","A","SAMP_style","A","SAMP_title","A","SCRIPT","DB","SCRIPT_msallowclip","A","SMALL","A",
		"SMALL_class","A","SMALL_dir","A","SMALL_id","A","SMALL_lang","A","SMALL_msallowclip","A","SMALL_style","A",
		"SMALL_title","A","SPAN","A","SPAN_class","A","SPAN_dir","A","SPAN_fragmentid","A","SPAN_id","A",
		"SPAN_lang","A","SPAN_msallowclip","A","SPAN_style","A","SPAN_title","A","STRIKE","A","STRIKE_class","A",
		"STRIKE_dir","A","STRIKE_id","A","STRIKE_lang","A","STRIKE_msallowclip","A","STRIKE_style","A","STRIKE_title","A",
		"STRONG","A","STRONG_class","A","STRONG_dir","A","STRONG_id","A","STRONG_lang","A","STRONG_msallowclip","A",
		"STRONG_style","A","STRONG_title","A","STYLE","A","STYLE_dir","A","STYLE_lang","A","STYLE_msallowclip","A",
		"STYLE_title","A","SUB","A","SUB_class","A","SUB_dir","A","SUB_id","A","SUB_lang","A",
		"SUB_msallowclip","A","SUB_style","A","SUB_title","A","SUP","A","SUP_class","A","SUP_dir","A",
		"SUP_id","A","SUP_lang","A","SUP_msallowclip","A","SUP_style","A","SUP_title","A","S_class","A",
		"S_dir","A","S_id","A","S_lang","A","S_msallowclip","A","S_style","A","S_title","A",
		"TABLE","A","TABLE_align","A","TABLE_background","DAURL","TABLE_bgcolor","A","TABLE_border","A","TABLE_bordercolor","A",
		"TABLE_bordercolordark","A","TABLE_bordercolorlight","A","TABLE_cellpadding","A","TABLE_cellspacing","A","TABLE_class","A","TABLE_dir","A",
		"TABLE_height","A","TABLE_id","A","TABLE_lang","A","TABLE_msallowclip","A","TABLE_rules","A","TABLE_style","A",
		"TABLE_summary","A","TABLE_title","A","TABLE_width","A","TBODY","A","TBODY_align","A","TBODY_char","A",
		"TBODY_charoff","A","TBODY_class","A","TBODY_dir","A","TBODY_id","A","TBODY_lang","A","TBODY_msallowclip","A",
		"TBODY_style","A","TBODY_title","A","TBODY_valign","A","TD","A","TD_abbr","A","TD_align","A",
		"TD_background","DAURL","TD_bgcolor","A","TD_bordercolor","A","TD_bordercolordark","A","TD_bordercolorlight","A","TD_char","A",
		"TD_charoff","A","TD_class","A","TD_colspan","A","TD_dir","A","TD_headers","A","TD_height","A",
		"TD_id","A","TD_lang","A","TD_msallowclip","A","TD_nowrap","A","TD_rowspan","A","TD_scope","A",
		"TD_style","A","TD_title","A","TD_valign","A","TD_width","A","TFOOT","A","TFOOT_align","A",
		"TFOOT_char","A","TFOOT_charoff","A","TFOOT_class","A","TFOOT_dir","A","TFOOT_id","A","TFOOT_lang","A",
		"TFOOT_msallowclip","A","TFOOT_style","A","TFOOT_title","A","TFOOT_valign","A","TH","A","THEAD","A",
		"THEAD_align","A","THEAD_char","A","THEAD_charoff","A","THEAD_class","A","THEAD_dir","A","THEAD_id","A",
		"THEAD_lang","A","THEAD_msallowclip","A","THEAD_style","A","THEAD_title","A","THEAD_valign","A","TH_abbr","A",
		"TH_align","A","TH_background","DAURL","TH_bgcolor","A","TH_bordercolor","A","TH_bordercolordark","A","TH_bordercolorlight","A",
		"TH_char","A","TH_charoff","A","TH_class","A","TH_colspan","A","TH_dir","A","TH_headers","A",
		"TH_height","A","TH_id","A","TH_lang","A","TH_msallowclip","A","TH_nowrap","A","TH_rowspan","A",
		"TH_scope","A","TH_style","A","TH_title","A","TH_valign","A","TH_width","A","TITLE","DB",
		"TITLE_dir","A","TITLE_lang","A","TITLE_msallowclip","A","TR","A","TR_align","A","TR_bgcolor","A",
		"TR_bordercolor","A","TR_bordercolordark","A","TR_bordercolorlight","A","TR_char","A","TR_charoff","A","TR_class","A",
		"TR_dir","A","TR_height","A","TR_id","A","TR_lang","A","TR_msallowclip","A","TR_style","A",
		"TR_title","A","TR_valign","A","TT","A","TT_class","A","TT_dir","A","TT_id","A",
		"TT_lang","A","TT_msallowclip","A","TT_style","A","TT_title","A","U","A","UL","A",
		"UL_class","A","UL_compact","A","UL_dir","A","UL_id","A","UL_lang","A","UL_msallowclip","A",
		"UL_style","A","UL_title","A","UL_type","A","U_class","A","U_dir","A","U_id","A",
		"U_lang","A","U_msallowclip","A","U_style","A","U_title","A","WBR","A","WBR_class","A",
		"WBR_dir","A","WBR_id","A","WBR_lang","A","WBR_msallowclip","A","WBR_style","A","WBR_title","A",
		"XML","DB","XML_class","A","XML_dir","A","XML_id","A","XML_lang","A","XML_msallowclip","A",
		"XML_style","A","XML_title","A","XMP","A","XMP_class","A","XMP_dir","A","XMP_id","A",
		"XMP_lang","A","XMP_msallowclip","A","XMP_style","A","XMP_title","A" );
	if (tempRuleArray.length > 0)
	{
		var safeHtmlRule;
		for(var i=0; i<tempRuleArray.length; i+=2)
		{
			safeHtmlRule=new Object();
			safeHtmlRule.key=tempRuleArray[i];
			safeHtmlRule.value=tempRuleArray[i+1];
			g_safeHtmlRules.push(safeHtmlRule);
		}
	}
}
var g_safeHtmlRules;
function RTE2_CompareSafeRules(first, second)
{
	if (first.key > second.key)
	{
		return 1;
	}
	if (first.key < second.key)
	{
		return -1;
	}
	else
	{
		return 0;
	}
}
function RTE2_RemoveScriptsAndHandlersFromElements(elements)
{
	if (elements !=null && elements.length>0)
	{
		var elementWithStyles=new Object();
		elementWithStyles.elements=new Array();
		elementWithStyles.cssTexts=new Array();
		var elements_length=elements.length;
		for (var i=0; i<elements_length; i++)
		{
			var currentElement=elements[i];
			if (currentElement==null) continue;
			if (currentElement.scopeName!=null && currentElement.scopeName!="HTML")
			{
				elements[i].removeNode(false);
				continue;
			}
			var removeNode=false;
			var removeChildren=false;
			var currentElementTagName=currentElement.tagName.toUpperCase();
			var tagSecurityRule=RTE2_GetTagSecurityRule(currentElementTagName, "DT");
			switch (tagSecurityRule)
			{
				case  "A" : removeNode=false; removeChildren=false; break;
				case "DT" : removeNode=true; removeChildren=false; break;
				case "DB" : removeNode=true; removeChildren=true; break;
			}
			if (currentElement.tagUrn!=null && currentElement.tagUrn!="")
			{
				removeNode=true;
				removeChildren=false;
			}
			if (removeNode)
			{
				if (elements[i].tagName=='LINK')
				{
					for (var j=0;j<elements[i].document.styleSheets.length; j++)
					{
						elements[i].document.styleSheets[j].cssText='';
					}
				}
				elements[i].removeNode(removeChildren);
				elements[i]=null;
				continue;
			}
			if (!RTE2_IsNullOrEmpty(currentElement.style.cssText))
			{
				elementWithStyles.elements.push(currentElement);
				elementWithStyles.cssTexts.push(currentElement.style.cssText);
			}
			currentElement.removeAttribute("style", 0);
			var attributes=RTE2_GetSpecifiedAttributes(currentElement);
			if (attributes !=null && attributes.length > 0)
			{
				var attributesClass=new Array();
				attributesClass["DA"]=new Array();
				attributesClass["DANV"]=new Array();
				attributesClass["DAURL"]=new Array();
				attributesClass["DTURL"]=new Array();
				attributesClass["RAV"]=new Array();
				attributesClass["A"]=new Array();
				var attributes_length=attributes.length;
				for (var j=0; j<attributes_length;j++)
				{
					var currentAttribute=attributes[j];
					if (currentAttribute.specified)
					{
						var attributeName=currentAttribute.nodeName.toLowerCase();
						if (attributeName !=null)
						{
							var attributeSafenessRule=RTE2_GetAttributeSafenessRule(currentElementTagName, attributeName, "DA");
							attributesClass[attributeSafenessRule].push(currentAttribute);
						}
					}
				}
				var dropAttributes=attributesClass["DA"];
				for (var j=0; j<dropAttributes.length;j++)
				{
					var currentAttribute=dropAttributes[j];
					var attributeName=currentAttribute.nodeName;
					currentElement.setAttribute(attributeName, "", 0);
					currentElement.removeAttribute(attributeName, 0);
				}
				var replaceAttributesValue=attributesClass["RAV"];
				for (var j=0; j<replaceAttributesValue.length;j++)
				{
					var currentAttribute=replaceAttributesValue[j];
					var attributeName=currentAttribute.nodeName;
					currentElement.setAttribute(attributeName, "", 0);
					currentElement.removeAttribute(attributeName, 0);
				}
				var dropAttributesWithNoValue=attributesClass["DANV"];
				for (var j=0; j<dropAttributesWithNoValue.length;j++)
				{
					var currentAttribute=dropAttributesWithNoValue[j];
					var attributeValue=currentElement.getAttribute(attributeName, 2);
					if (attributeValue==null)
					{
						var attributeName=currentAttribute.nodeName;
						currentElement.setAttribute(attributeName, "", 0);
						currentElement.removeAttribute(attributeName, 0);
					}
				}
				var dropAttributesWithUnsafeURL=attributesClass["DAURL"];
				for (var j=0; j<dropAttributesWithUnsafeURL.length;j++)
				{
					var currentAttribute=dropAttributesWithUnsafeURL[j];
					var attributeValue=currentElement.getAttribute(attributeName, 2);
					if (attributeValue !=null && typeof(attributeValue)=="string")
					{
						attributeValue=attributeValue.toLowerCase();
						if (!RTE2_IsSafeURL(attributeValue))
						{
							var attributeName=currentAttribute.nodeName;
							currentElement.setAttribute(attributeName, "", 0);
							currentElement.removeAttribute(attributeName, 0);
						}
					}
				}
				var dropTagsWithUnsafeURL=attributesClass["DTURL"];
				for (var j=0; j<dropTagsWithUnsafeURL.length;j++)
				{
					var currentAttribute=dropTagsWithUnsafeURL[j];
					var attributeValue=currentElement.getAttribute(attributeName, 2);
					if (attributeValue !=null && typeof(attributeValue)=="string")
					{
						attributeValue=attributeValue.toLowerCase();
						if (!RTE2_IsSafeURL(attributeValue))
						{
							elements[i].removeNode(false);
							elements[i]=null;
						}
					}
				}
			}
		}
		for (var i=0; i<elementWithStyles.elements.length; i++)
		{
			var currentElement=elementWithStyles.elements[i];
			var oldStyle=elementWithStyles.cssTexts[i];
			var newStyle=RTE2_CleanStyleText(oldStyle);
			currentElement.style.cssText=newStyle;
		}
	}
}
function RTE2_GetTagSecurityRule(tagName, defaultSecurityRule)
{
	var safeHtmlRule=new Object();
	safeHtmlRule.key=tagName;
	safeHtmlRule=RTE2_BinaryFind(safeHtmlRule, g_safeHtmlRules, RTE2_CompareSafeRules);
	if (safeHtmlRule !=null)
	{
		return safeHtmlRule.value;
	}
	return defaultSecurityRule;
}
function RTE2_GetAttributeSafenessRule(tagName, attributeName, defaultSafenessRule)
{
	var safeHtmlRule=new Object();
	safeHtmlRule.key=tagName+"_"+attributeName;
	safeHtmlRule=RTE2_BinaryFind(safeHtmlRule, g_safeHtmlRules, RTE2_CompareSafeRules);
	if (safeHtmlRule !=null)
	{
		return safeHtmlRule.value;
	}
	return defaultSafenessRule;
}
function RTE2_IsSafeURL(url)
{
	var tempUrl=url.toLowerCase();
	var containsAtSign=false;
	if (tempUrl.indexOf("@") !=-1) containsAtSign=true;
	if (tempUrl.indexOf("http://")==0) return !containsAtSign;
	if (tempUrl.indexOf("https://")==0) return !containsAtSign;
	if (tempUrl.indexOf("ftp://")==0) return !containsAtSign;
	if (tempUrl.indexOf("gopher:")==0) return false;
	if (tempUrl.indexOf("mailto:")==0) return true;
	if (tempUrl.indexOf("news:")==0) return !containsAtSign;
	if (tempUrl.indexOf("file:///")==0) return false;
	if (tempUrl.match("^file://[a-zA-Z]:\\\\")) return false;
	if (tempUrl.indexOf("file://")==0) return true;
	if (tempUrl.indexOf("mhtml:")==0) return false;
	if (tempUrl.indexOf("cdi:")==0) return false;
	if (tempUrl.indexOf("\\\\")==0) return false;
	if (tempUrl.indexOf("//")==0) return false;
	if (tempUrl.indexOf("/\\")==0) return false;
	if (tempUrl.indexOf("\\/")==0) return false;
	if (RTE2_IsSimpleURL(tempUrl)) return true;
	return false;
}
function RTE2_IsSimpleURL(url)
{
	var urlTemp=url;
	var hashIndex=urlTemp.indexOf("#");
	if (hashIndex !=-1)
	{
		urlTemp=urlTemp.slice(0, hashIndex);
	}
	var queryIndex=urlTemp.indexOf("?");
	if (queryIndex !=-1)
	{
		urlTemp=urlTemp.slice(0, queryIndex);
	}
	var colonIndex=urlTemp.indexOf(":");
	if (colonIndex==-1)
	{
		return true;
	}
	return false;
}
function RTE2_CleanStyleText(styleText)
{
	var newStyleText="";
	var styleElements=styleText.split(";");
	for (var i=0; i<styleElements.length; i++)
	{
		var styleElement=styleElements[i].replace(/=/,":");
		var styleElementParts=styleElement.split(":");
		var styleName=null;
		var styleValue="";
		if (styleElementParts.length > 0)
		{
			styleName=styleElementParts[0];
			styleName=styleName.replace(/^[ \t]+/g, "");
			styleName=styleName.replace(/[ \t]+$/g, "");
			styleName=styleName.replace(/[ \t]+/g, " ");
			styleName=styleName.toLowerCase();
		}
		var dropStyle=false;
		if (styleName.indexOf("mso-")==0)
		{
			dropStyle=true;
		}
		if (!dropStyle)
		{
			switch (styleName)
			{
				case "behavior":
				{
					dropStyle=true;
					break;
				}
			}
		}
		if (dropStyle)
		{
			continue;
		}
		for (var j=1; j<styleElementParts.length; j++)
		{
			styleValue+=styleElementParts[j];
			if (j+1 < styleElementParts.length)
			{
				styleValue+=":";
			}
		}
		styleValue=styleValue.replace(/^[ \t]+/g, "");
		styleValue=styleValue.replace(/[ \t]+$/g, "");
		styleValue=styleValue.replace(/[ \t]+/g, " ");
		styleValue=styleValue.toLowerCase();
		if (!dropStyle && styleValue !="")
		{
			var functionParametersIndex=styleValue.indexOf("(");
			if ( functionParametersIndex !=-1)
			{
				dropStyle=true;
				var functionName=styleValue.slice(0, functionParametersIndex);
				switch (functionName.toLowerCase())
				{
					case "rect":
					{
						dropStyle=false;
						break;
					}
				}
			}
		}
		if (!dropStyle)
		{
			newStyleText+=styleName;
			if (styleValue !="")
			{
				newStyleText+=":"+styleValue;
			}
			newStyleText+=";";
		}
	}
	return newStyleText;
}
function RTE2_AreTableBordersVisible(strBaseElementID)
{
	return g_oExtendedRichTextSupport.editors[strBaseElementID].isShowingHiddenTables;
}
function RTE2_ShouldTableBordersBeVisible(strBaseElementID)
{
	return g_oExtendedRichTextSupport.editors[strBaseElementID].shouldShowHiddenTables;
}
function RTE2_ShowTableBorders(strBaseElementID)
{
	RTE2_SetGridlineVisibility(strBaseElementID, true);
}
function RTE2_HideTableBorders(strBaseElementID)
{
	RTE2_SetGridlineVisibility(strBaseElementID, false);
}
function RTE2_ToggleTableBorders(strBaseElementID)
{
	g_oExtendedRichTextSupport.editors[strBaseElementID].shouldShowHiddenTables=		!g_oExtendedRichTextSupport.editors[strBaseElementID].shouldShowHiddenTables
	RTE2_SetGridlineVisibility(strBaseElementID, g_oExtendedRichTextSupport.editors[strBaseElementID].shouldShowHiddenTables);
	RTE_GiveEditorFocus(strBaseElementID);
	RTE_StartUpdateOnCellMenuPositionTimer(strBaseElementID);
}
function RTE2_SetGridlineVisibility(strBaseElementID, showHiddenTables)
{
	var tablesAffected=false;
	var docContainer=RTE2_GetEditorContainer(strBaseElementID);
	if (showHiddenTables==true)
	{
		tablesAffected=RTE2_ConvertTablesShowBorder(docContainer);
	}
	else
	{
		RTE2_ConvertTablesToOriginalBorder(docContainer);
	}
	if (showHiddenTables==true && tablesAffected==false)
	{
		g_oExtendedRichTextSupport.editors[strBaseElementID].isShowingHiddenTables=false;
	}
	else
	{
		g_oExtendedRichTextSupport.editors[strBaseElementID].isShowingHiddenTables=showHiddenTables;
	}
	RTE2_ResetAllToolBarStates(strBaseElementID);
	RTE_SaveSelection(strBaseElementID);
}
function RTE2_ConvertTablesToOriginalBorder(element)
{
	if (element.tagName=="TABLE" || element.tagName=="TD" || element.tagName=="TH" )
	{
		element.runtimeStyle.cssText="";
	}
	var childIndex;
	for (childIndex=0; childIndex < element.children.length; childIndex++)
	{
		var childElement=element.children.item(childIndex);
		RTE2_ConvertTablesToOriginalBorder(childElement);
	}
}
function RTE2_ConvertTableToOriginalBorder(table)
{
	table.runtimeStyle.cssText="";
	for(var j=0; j<table.cells.length;j++)
	{
		table.cells[j].runtimeStyle.cssText="";
	}
}
function RTE2_SetRuntimeStyleBorders(item)
{
	var affected=false;
	item.runtimeStyle.borderCollapse="separate";
	if (item.currentStyle.borderBottomStyle=="none" || parseInt(item.currentStyle.borderBottomWidth)==0)
	{
		item.runtimeStyle.borderBottom="2px dashed";
		affected=true;
	}
	if (item.currentStyle.borderTopStyle=="none" || parseInt(item.currentStyle.borderTopWidth)==0)
	{
		item.runtimeStyle.borderTop="2px dashed";
		affected=true;
	}
	if (item.currentStyle.borderLeftStyle=="none" || parseInt(item.currentStyle.borderLeftWidth)==0)
	{
		item.runtimeStyle.borderLeft="2px dashed";
		affected=true;
	}
	if (item.currentStyle.borderRightStyle=="none" || parseInt(item.currentStyle.borderRightWidth)==0)
	{
		item.runtimeStyle.borderRight="2px dashed";
		affected=true;
	}
	return affected;
}
function RTE2_ConvertTablesShowBorder(element)
{
	var elementAffected=false;
	if (element.tagName=="TABLE" || element.tagName=="TD" || element.tagName=="TH" )
	{
		elementAffected=RTE2_SetRuntimeStyleBorders(element);
	}
	var childIndex;
	for (childIndex=0; childIndex < element.children.length; childIndex++)
	{
		var childElement=element.children.item(childIndex);
		var childAffected=RTE2_ConvertTablesShowBorder(childElement);
		if (childAffected) elementAffected=true;
	}
	return elementAffected;
}
function RTE2_ConvertTableShowBorder(tableElement)
{
	if (tableElement.tagName !="TABLE") return;
	var elementAffected=RTE2_SetRuntimeStyleBorders(tableElement);
	for (var i=0; i < tableElement.cells.length; i++)
	{
		var cellAffected=RTE2_ConvertTablesShowBorder(tableElement.cells[i]);
		if (cellAffected) elementAffected=true;
	}
	return elementAffected;
}
function RTE2_HideSource(strBaseElementID)
{
	if (RTE2_IsSourceView(strBaseElementID))
	{
		RTE2_ViewSource(strBaseElementID);
	}
}
function RTE2_ViewSource(strBaseElementID, saveState)
{
	if (null==saveState)
	{
		saveState=true;
	}
	if (!RTE2_PopupMode(strBaseElementID))
	{
		if (saveState)
		{
			RTE2_SaveHtmlStateIfChanged(strBaseElementID);
		}
		var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
		RTE2_LaunchEditor( instanceVariables.aSettings
						 , instanceVariables.clientId
						 , instanceVariables.displayContentElement.id
						 , instanceVariables.emptyPanel.id
						 , instanceVariables.hiddenInputField.id
						 , instanceVariables.webUrl
						 , 'True'
						 , true
						 , true);
	}
	else
	{
		if (RTE2_IsSourceView(strBaseElementID))
		{
			if (saveState)
			{
				RTE2_SaveHtmlStateIfChanged(strBaseElementID);
			}
			var safeHtmlDocument=RTE2_GetSafeHtmlDocument(strBaseElementID);
			if (safeHtmlDocument==null) return;
			var docContainer=RTE2_GetEditorContainer(strBaseElementID);
			if (docContainer==null) return;
			var sourceTextArea=RTE2_GetSourceEditorTextArea(strBaseElementID);
			if (sourceTextArea==null) return;
			var sourceDiv=RTE2_GetSourceEditorDiv(strBaseElementID);
			if (sourceDiv==null) return;
			var selectionStatus=RTE2_GetSelectionStatus(strBaseElementID);
			if (selectionStatus==null) return;
			safeHtmlDocument.body.innerHTML=sourceTextArea.value;
			var elements=RTE2_GetAllElements(safeHtmlDocument);
			var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
			RTE2_ApplyContentFilters(elements, instanceVariables);
			safeHtmlDocument.body.innerHTML=safeHtmlDocument.body.innerHTML;
			g_oExtendedRichTextSupport.editors[strBaseElementID].isSourceView=false;
			RTE2_RemoveEditorPathFromUrls(strBaseElementID);
			sourceDiv.style.display="none";
			selectionStatus.style.display="";
			if (RTE2_PopupMode(strBaseElementID))
			{
				var iframeEditor=RTE_GetEditorIFrame(strBaseElementID);
				if (iframeEditor==null) return;
				iframeEditor.frameElement.style.display="";
				iframeEditor.document.body.innerHTML=safeHtmlDocument.body.innerHTML;
			}
			else
			{
				docContainer.style.display="";
				docContainer.innerHTML=safeHtmlDocument.body.innerHTML;
			}
			RTE2_AddHtmlEditorTags(strBaseElementID);
			RTE_GiveEditorFocus(strBaseElementID);
			RTE_SaveSelection(strBaseElementID);
		}
		else
		{
			RTE2_RemoveHtmlEditorTags(strBaseElementID);
			var docContainer=RTE2_GetEditorContainer(strBaseElementID);
			if (docContainer==null) return;
			var sourceTextArea=RTE2_GetSourceEditorTextArea(strBaseElementID);
			if (sourceTextArea==null) return;
			var sourceDiv=RTE2_GetSourceEditorDiv(strBaseElementID);
			if (sourceDiv==null) return;
			var selectionStatus=RTE2_GetSelectionStatus(strBaseElementID);
			if (selectionStatus==null) return;
			sourceTextArea.value=docContainer.innerHTML;
			var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
			instanceVariables.selectedElement=null;
			sourceDiv.style.display="";
			selectionStatus.style.display="none";
			var iframeEditor=RTE_GetEditorIFrame(strBaseElementID);
			if (iframeEditor==null) return;
			iframeEditor.frameElement.style.display="none";
			g_oExtendedRichTextSupport.editors[strBaseElementID].isSourceView=true;
			sourceTextArea.focus();
		}
		RTE_StartUpdateOnCellMenuPositionTimer(strBaseElementID);
		RTE2_HideOnPasteMenu(strBaseElementID);
		RTE2_ResetAllToolBarStates(strBaseElementID);
		if (g_oExtendedRichTextSupport.editors[strBaseElementID].modeChangeNotification !=null)
		{
			g_oExtendedRichTextSupport.editors[strBaseElementID].modeChangeNotification(strBaseElementID);
		}
	}
}
function RTE2_PopupMode(strBaseElementID)
{
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	return instanceVariables.popupMode=='True';
}
function RTE2_GetEditorDocument(strBaseElementID)
{
	if (!RTE2_PopupMode(strBaseElementID))
	{
		return window.document;
	}
	if (RTE2_IsSourceView(strBaseElementID))
	{
		return window.document;
	}
	var ifmEditor=RTE_GetEditorIFrame(strBaseElementID);
	if (null==ifmEditor)
	{
		return null;
	}
	var docEditor=ifmEditor.document;
	return docEditor;
}
function RTE2_OnKeyDown(strBaseElementID, elem)
{
	RTE_SaveSelection(strBaseElementID);
	var elemDocument=elem.document;
	var evtSource=elem.document.parentWindow.event;
	var nKeyCode=evtSource.keyCode;
	var fAltKey=evtSource.altKey;
	var fCtrlKey=evtSource.ctrlKey;
	var fShiftKey=evtSource.shiftKey;
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	if (instanceVariables==null) return;
	if (typeof(RTE_ToggleEnableShortcuts) !="undefined") RTE_ToggleEnableShortcuts(evtSource);
	if (!fCtrlKey && !fAltKey && fShiftKey)
	{
		if (nKeyCode==L_TabKey_VALUE)
		{
			if (!instanceVariables.fToolbarNavigate)
			{
				evtSource.returnValue=RTE2_OnShiftTab(strBaseElementID, elemDocument);
			}
			else
			{
				evtSource.returnValue=RTE_MoveFocusBackwards(strBaseElementID, elemDocument.activeElement);
			}
		}
	}
	else if (!fCtrlKey && !fAltKey && !fShiftKey)
	{
		switch (nKeyCode)
		{
			case L_TabKey_VALUE:
				if (instanceVariables.fToolbarNavigate)
				{
					evtSource.returnValue=RTE_MoveFocusForwards(strBaseElementID, elemDocument.activeElement);
				}
				else
				{
					evtSource.returnValue=RTE2_OnTab(strBaseElementID, elemDocument);
				}
				break;
			case 13:
				if (instanceVariables.fToolbarNavigate && instanceVariables.hoverButton !=null)
				{
					evtSource.returnValue=false;
					instanceVariables.hoverButton.children(0).click();
					instanceVariables.fToolbarNavigate=false;
					RTE_TB_RemoveLastToolBarHover(strBaseElementID);
				}
				break;
			case 27:
				if (instanceVariables.fToolbarNavigate)
				{
					evtSource.returnValue=false;
					instanceVariables.fToolbarNavigate=false;
					RTE_TB_RemoveLastToolBarHover(strBaseElementID);
				}
				break;
			case 40:
				if (RTE_GetCurrentSelectionType(strBaseElementID)=="Control")
				{
					var currentElem=RTE_GetCurrentElement(strBaseElementID);
					if (currentElem !=null && currentElem.tagName=="TABLE")
					{
						var textRange=elemDocument.body.createTextRange();
						textRange.moveToElementText(currentElem.rows[0].cells[0]);
						textRange.select();
						evtSource.returnValue=false;
					}
				}
				break;
			case 38:
				if (RTE_GetCurrentSelectionType(strBaseElementID)=="Control")
				{
					var currentElem=RTE_GetCurrentElement(strBaseElementID);
					if (currentElem !=null && currentElem.tagName=="TABLE")
					{
						var textRange=elemDocument.body.createTextRange();
						var lastRow=currentElem.rows[currentElem.rows.length - 1];
						textRange.moveToElementText(lastRow.cells[0]);
						textRange.select();
						evtSource.returnValue=false;
					}
				}
				break;
		}
	}
	if (fCtrlKey && (typeof(RTE_ShortcutsEnabled)=="undefined" || RTE_ShortcutsEnabled()))
	{
		if (nKeyCode !=L_CtrlKey_VALUE)
		{
			instanceVariables.fToolbarNavigateSkip=true;
			instanceVariables.fToolbarNavigate=false;
			RTE_TB_RemoveLastToolBarHover(strBaseElementID);
		}
		if ((L_BoldKey_TEXT.charCodeAt(0)==nKeyCode)
			&& (RTE_FInterpretTextAsBoolean(L_BoldShiftKey_TEXT)==fShiftKey)
			&& (RTE_FInterpretTextAsBoolean(L_BoldAltKey_TEXT )==fAltKey))
		{
			evtSource.returnValue=false;
			var toolBarButton=RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEBoldMnemonic);
			if (toolBarButton !=null && !toolBarButton.disabled)
			{
				toolBarButton.children(0).click();
			}
		}
		else if (( L_ItalicKey_TEXT.charCodeAt(0)==nKeyCode)
			&& (RTE_FInterpretTextAsBoolean(L_ItalicShiftKey_TEXT)==fShiftKey)
			&& (RTE_FInterpretTextAsBoolean(L_ItalicAltKey_TEXT)==fAltKey))
		{
			evtSource.returnValue=false;
			var toolBarButton=RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEItalicMnemonic);
			if (toolBarButton !=null && !toolBarButton.disabled)
			{
				toolBarButton.children(0).click();
			}
		}
		else if (( L_UnderlineKey_TEXT.charCodeAt(0)==nKeyCode)
			&& (RTE_FInterpretTextAsBoolean(L_UnderlineShiftKey_TEXT)==fShiftKey)
			&& (RTE_FInterpretTextAsBoolean(L_UnderlineAltKey_TEXT)==fAltKey))
		{
			evtSource.returnValue=false;
			var toolBarButton=RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEUnderlineMnemonic);
			if (toolBarButton !=null && !toolBarButton.disabled)
			{
				toolBarButton.children(0).click();
			}
		}
		else if (( L_JustifyLeftKey_TEXT.charCodeAt(0)==nKeyCode)
			&& (RTE_FInterpretTextAsBoolean(L_JustifyLeftShiftKey_TEXT)==fShiftKey)
			&& (RTE_FInterpretTextAsBoolean(L_JustifyLeftAltKey_TEXT)==fAltKey))
		{
			evtSource.returnValue=false;
			var toolBarButton=RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEJustifyLeftMnemonic);
			if (toolBarButton !=null && !toolBarButton.disabled)
			{
				toolBarButton.children(0).click();
			}
		}
		else if (( L_JustifyCenterKey_TEXT.charCodeAt(0)==nKeyCode)
			&& (RTE_FInterpretTextAsBoolean(L_JustifyCenterShiftKey_TEXT)==fShiftKey)
			&& (RTE_FInterpretTextAsBoolean(L_JustifyCenterAltKey_TEXT)==fAltKey))
		{
			evtSource.returnValue=false;
			var toolBarButton=RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEJustifyCenterMnemonic);
			if (toolBarButton !=null && !toolBarButton.disabled)
			{
				toolBarButton.children(0).click();
			}
		}
		else if (( L_JustifyRightKey_TEXT.charCodeAt(0)==nKeyCode)
			&& (RTE_FInterpretTextAsBoolean(L_JustifyRightShiftKey_TEXT)==fShiftKey)
			&& (RTE_FInterpretTextAsBoolean(L_JustifyRightAltKey_TEXT)==fAltKey))
		{
			evtSource.returnValue=false;
			var toolBarButton=RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEJustifyRightMnemonic);
			if (toolBarButton !=null && !toolBarButton.disabled)
			{
				toolBarButton.children(0).click();
			}
		}
		else if (( L_IndentKey_TEXT.charCodeAt(0)==nKeyCode)
			&& (RTE_FInterpretTextAsBoolean(L_IndentShiftKey_TEXT)==fShiftKey)
			&& (RTE_FInterpretTextAsBoolean(L_IndentAltKey_TEXT)==fAltKey))
		{
			evtSource.returnValue=false;
			var toolBarButton=RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEIndentMnemonic);
			if (toolBarButton !=null && !toolBarButton.disabled)
			{
				toolBarButton.children(0).click();
			}
		}
		else if (( L_CreateLinkKey_TEXT.charCodeAt(0)==nKeyCode)
			&& (RTE_FInterpretTextAsBoolean(L_CreateLinkShiftKey_TEXT)==fShiftKey)
			&& (RTE_FInterpretTextAsBoolean(L_CreateLinkAltKey_TEXT)==fAltKey))
		{
			evtSource.returnValue=false;
			var toolBarButton=RTE_TB_GetToolBarButton(strBaseElementID, g_strRTECreateLinkMnemonic);
			if (toolBarButton !=null && !toolBarButton.disabled)
			{
				toolBarButton.children(0).click();
			}
		}
		else if (( L_SelectFontNameKey_TEXT.charCodeAt(0)==nKeyCode)
			&& (RTE_FInterpretTextAsBoolean(L_SelectFontNameShiftKey_TEXT)==fShiftKey)
			&& (RTE_FInterpretTextAsBoolean(L_SelectFontNameAltKey_TEXT)==fAltKey))
		{
			evtSource.returnValue=false;
			var toolBarButton=RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEFontNameMnemonic);
			if (toolBarButton !=null && !toolBarButton.disabled)
			{
				toolBarButton.children(0).click();
			}
		}
		else if (( L_SelectFontSizeKey_TEXT.charCodeAt(0)==nKeyCode)
			&& (RTE_FInterpretTextAsBoolean(L_SelectFontSizeShiftKey_TEXT)==fShiftKey)
			&& (RTE_FInterpretTextAsBoolean(L_SelectFontSizeAltKey_TEXT)==fAltKey))
		{
			evtSource.returnValue=false;
			var toolBarButton=RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEFontSizeMnemonic);
			if (toolBarButton !=null && !toolBarButton.disabled)
			{
				toolBarButton.children(0).click();
			}
		}
		else if (( L_SelectForeColorKey_TEXT.charCodeAt(0)==nKeyCode)
			&& (RTE_FInterpretTextAsBoolean(L_SelectForeColorShiftKey_TEXT)==fShiftKey)
			&& (RTE_FInterpretTextAsBoolean(L_SelectForeColorAltKey_TEXT)==fAltKey))
		{
			evtSource.returnValue=false;
			var toolBarButton=RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEForeColorMnemonic);
			if (toolBarButton !=null && !toolBarButton.disabled)
			{
				toolBarButton.children(0).click();
			}
		}
		else if (( L_SelectBackColorKey_TEXT.charCodeAt(0)==nKeyCode)
			&& (RTE_FInterpretTextAsBoolean(L_SelectBackColorShiftKey_TEXT)==fShiftKey)
			&& (RTE_FInterpretTextAsBoolean(L_SelectBackColorAltKey_TEXT)==fAltKey))
		{
			evtSource.returnValue=false;
			var toolBarButton=RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEBackColorMnemonic);
			if (toolBarButton !=null && !toolBarButton.disabled)
			{
				toolBarButton.children(0).click();
			}
		}
		else if (( L_UnorderedListKey_TEXT.charCodeAt(0)==nKeyCode)
			&& (RTE_FInterpretTextAsBoolean(L_UnorderedListShiftKey_TEXT)==fShiftKey)
			&& (RTE_FInterpretTextAsBoolean(L_UnorderedListAltKey_TEXT)==fAltKey))
		{
			evtSource.returnValue=false;
			var toolBarButton=RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEUnorderedListMnemonic);
			if (toolBarButton !=null && !toolBarButton.disabled)
			{
				toolBarButton.children(0).click();
			}
		}
		else if (( L_OrderedListKey_TEXT.charCodeAt(0)==nKeyCode)
			&& (RTE_FInterpretTextAsBoolean(L_OrderedListShiftKey_TEXT)==fShiftKey)
			&& (RTE_FInterpretTextAsBoolean(L_OrderedListAltKey_TEXT)==fAltKey))
		{
			evtSource.returnValue=false;
			var toolBarButton=RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEOrderedListMnemonic);
			if (toolBarButton !=null && !toolBarButton.disabled)
			{
				toolBarButton.children(0).click();
			}
		}
		else if (( L_OutdentKey_TEXT.charCodeAt(0)==nKeyCode)
			&& (RTE_FInterpretTextAsBoolean(L_OutdentShiftKey_TEXT)==fShiftKey)
			&& (RTE_FInterpretTextAsBoolean(L_OutdentAltKey_TEXT)==fAltKey))
		{
			evtSource.returnValue=false;
			var toolBarButton=RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEOutdentMnemonic);
			if (toolBarButton !=null && !toolBarButton.disabled)
			{
				toolBarButton.children(0).click();
			}
		}
		else if (( L_InsertImageKey_TEXT.charCodeAt(0)==nKeyCode)
			&& (RTE_FInterpretTextAsBoolean(L_InsertImageShiftKey_TEXT)==fShiftKey)
			&& (RTE_FInterpretTextAsBoolean(L_InsertImageAltKey_TEXT)==fAltKey))
		{
			evtSource.returnValue=false;
			var toolBarButton=RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEInsertImageMnemonic);
			if (toolBarButton !=null && !toolBarButton.disabled)
			{
				toolBarButton.children(0).click();
			}
		}
		else if (( L_LTRKey_VALUE==nKeyCode)
			&& (fShiftKey))
		{
			evtSource.returnValue=false;
			var toolBarButton=RTE_TB_GetToolBarButton(strBaseElementID, g_strRTELTRMnemonic);
			if (toolBarButton !=null && !toolBarButton.disabled)
			{
				toolBarButton.children(0).click();
			}
		}
		else if (( L_RTLKey_VALUE==nKeyCode)
			&& (fShiftKey))
		{
			evtSource.returnValue=false;
			var toolBarButton=RTE_TB_GetToolBarButton(strBaseElementID, g_strRTERTLMnemonic);
			if (toolBarButton !=null && !toolBarButton.disabled)
			{
				toolBarButton.children(0).click();
			}
		}
		else if (( nKeyCode==L_RemoveLinkKey_TEXT.charCodeAt(0))
			&& (RTE_FInterpretTextAsBoolean(L_RemoveLinkShiftKey_TEXT)==fShiftKey)
			&& (RTE_FInterpretTextAsBoolean(L_RemoveLinkAltKey_TEXT)==fAltKey))
		{
			evtSource.returnValue=false;
			var toolBarButton=RTE_TB_GetToolBarButton(strBaseElementID, g_strRTE2UnlinkMnemonic);
			if (toolBarButton !=null && !toolBarButton.disabled)
			{
				toolBarButton.children(0).click();
			}
		}
		else if (( nKeyCode==L_InsertImageKey_TEXT.charCodeAt(0))
			&& (RTE_FInterpretTextAsBoolean(L_InsertImageShiftKey_TEXT)==fShiftKey)
			&& (RTE_FInterpretTextAsBoolean(L_InsertImageAltKey_TEXT)==fAltKey))
		{
			evtSource.returnValue=false;
			var toolBarButton=RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEInsertImageMnemonic);
			if (toolBarButton !=null && !toolBarButton.disabled)
			{
				toolBarButton.children(0).click();
			}
		}
		else if (( nKeyCode==L_InsertTableKey_TEXT.charCodeAt(0))
			&& (RTE_FInterpretTextAsBoolean(L_InsertTableShiftKey_TEXT)==fShiftKey)
			&& (RTE_FInterpretTextAsBoolean(L_InsertTableAltKey_TEXT)==fAltKey))
		{
			evtSource.returnValue=false;
			var toolBarButton=RTE_TB_GetToolBarButton(strBaseElementID, g_strRTE2InsertTableMnemonic);
			if (toolBarButton !=null && !toolBarButton.disabled)
			{
				toolBarButton.children(0).click();
			}
		}
		else if (( nKeyCode==L_EditTablePropertyKey_TEXT.charCodeAt(0))
			&& (RTE_FInterpretTextAsBoolean(L_EditTablePropertyShiftKey_TEXT)==fShiftKey)
			&& (RTE_FInterpretTextAsBoolean(L_EditTablePropertyAltKey_TEXT)==fAltKey))
		{
			evtSource.returnValue=false;
			var toolBarButton=RTE_TB_GetToolBarButton(strBaseElementID, g_strRTE2EditTableMnemonic);
			if (toolBarButton !=null && !toolBarButton.disabled)
			{
				toolBarButton.children(0).click();
			}
		}
		else if (( nKeyCode==L_ShowHideTableBorderKey_TEXT.charCodeAt(0))
			&& (RTE_FInterpretTextAsBoolean(L_ShowHideTableBorderShiftKey_TEXT)==fShiftKey)
			&& (RTE_FInterpretTextAsBoolean(L_ShowHideTableBorderAltKey_TEXT)==fAltKey))
		{
			evtSource.returnValue=false;
			var toolBarButton=RTE_TB_GetToolBarButton(strBaseElementID, g_strRTE2ShowTableBordersMnemonic);
			if (toolBarButton !=null && !toolBarButton.disabled)
			{
				toolBarButton.children(0).click();
			}
		}
		else if (( parseInt(L_DeleteColumnKeyCode_TEXT)==nKeyCode)
		   && (RTE_FInterpretTextAsBoolean(L_DeleteColumnShiftKey_TEXT)==fShiftKey)
		   && (RTE_FInterpretTextAsBoolean(L_DeleteColumnAltKey_TEXT)==fAltKey))
		{
			evtSource.returnValue=false;
			var toolBarButton=RTE_TB_GetToolBarButton(strBaseElementID, g_strRTE2TableMnemonic);
			if (toolBarButton !=null && !toolBarButton.disabled)
			{
				RTE_DeleteColumn(strBaseElementID);
			}
		}
		else if (( parseInt(L_DeleteRowKeyCode_TEXT)==nKeyCode)
		   && (RTE_FInterpretTextAsBoolean(L_DeleteRowShiftKey_TEXT)==fShiftKey)
		   && (RTE_FInterpretTextAsBoolean(L_DeleteRowAltKey_TEXT)==fAltKey))
		{
			evtSource.returnValue=false;
			var toolBarButton=RTE_TB_GetToolBarButton(strBaseElementID, g_strRTE2TableMnemonic);
			if (toolBarButton !=null && !toolBarButton.disabled)
			{
				RTE_DeleteRow(strBaseElementID);
			}
		}
		else if (( L_InsertCellLeftKey_TEXT.charCodeAt(0)==nKeyCode)
		   && (RTE_FInterpretTextAsBoolean(L_InsertCellLeftShiftKey_TEXT)==fShiftKey)
		   && (RTE_FInterpretTextAsBoolean(L_InsertCellLeftAltKey_TEXT)==fAltKey))
		{
			evtSource.returnValue=false;
			var toolBarButton=RTE_TB_GetToolBarButton(strBaseElementID, g_strRTE2TableMnemonic);
			if (toolBarButton !=null && !toolBarButton.disabled)
			{
				RTE_InsertCellLeft(strBaseElementID);
			}
		}
		else if (( L_InsertCellRightKey_TEXT.charCodeAt(0)==nKeyCode)
		   && (RTE_FInterpretTextAsBoolean(L_InsertCellRightShiftKey_TEXT)==fShiftKey)
		   && (RTE_FInterpretTextAsBoolean(L_InsertCellRightAltKey_TEXT)==fAltKey))
		{
			evtSource.returnValue=false;
			var toolBarButton=RTE_TB_GetToolBarButton(strBaseElementID, g_strRTE2TableMnemonic);
			if (toolBarButton !=null && !toolBarButton.disabled)
			{
				RTE_InsertCellRight(strBaseElementID);
			}
		}
		else if (( parseInt(L_InsertColumnLeftKeyCode_TEXT)==nKeyCode)
		   && (RTE_FInterpretTextAsBoolean(L_InsertColumnLeftShiftKey_TEXT)==fShiftKey)
		   && (RTE_FInterpretTextAsBoolean(L_InsertColumnLeftAltKey_TEXT)==fAltKey))
		{
			evtSource.returnValue=false;
			var toolBarButton=RTE_TB_GetToolBarButton(strBaseElementID, g_strRTE2TableMnemonic);
			if (toolBarButton !=null && !toolBarButton.disabled)
			{
				RTE_InsertColumnLeft(strBaseElementID);
			}
		}
		else if (( parseInt(L_InsertColumnRightKeyCode_TEXT)==nKeyCode)
		   && (RTE_FInterpretTextAsBoolean(L_InsertColumnRightShiftKey_TEXT)==fShiftKey)
		   && (RTE_FInterpretTextAsBoolean(L_InsertColumnRightAltKey_TEXT)==fAltKey))
		{
			evtSource.returnValue=false;
			var toolBarButton=RTE_TB_GetToolBarButton(strBaseElementID, g_strRTE2TableMnemonic);
			if (toolBarButton !=null && !toolBarButton.disabled)
			{
				RTE_InsertColumnRight(strBaseElementID);
			}
		}
		else if (( parseInt(L_InsertRowAboveKeyCode_TEXT)==nKeyCode)
		   && (RTE_FInterpretTextAsBoolean(L_InsertRowAboveShiftKey_TEXT)==fShiftKey)
		   && (RTE_FInterpretTextAsBoolean(L_InsertRowAboveAltKey_TEXT)==fAltKey))
		{
			evtSource.returnValue=false;
			var toolBarButton=RTE_TB_GetToolBarButton(strBaseElementID, g_strRTE2TableMnemonic);
			if (toolBarButton !=null && !toolBarButton.disabled)
			{
				RTE_InsertRowAbove(strBaseElementID);
			}
		}
		else if (( parseInt(L_InsertRowBelowKeyCode_TEXT)==nKeyCode)
		   && (RTE_FInterpretTextAsBoolean(L_InsertRowBelowShiftKey_TEXT)==fShiftKey)
		   && (RTE_FInterpretTextAsBoolean(L_InsertRowBelowAltKey_TEXT)==fAltKey))
		{
			evtSource.returnValue=false;
			var toolBarButton=RTE_TB_GetToolBarButton(strBaseElementID, g_strRTE2TableMnemonic);
			if (toolBarButton !=null && !toolBarButton.disabled)
			{
				RTE_InsertRowBelow(strBaseElementID);
			}
		}
		else if (( nKeyCode==L_SplitCellKey_TEXT.charCodeAt(0))
			&& (RTE_FInterpretTextAsBoolean(L_SplitCellShiftKey_TEXT)==fShiftKey)
			&& (RTE_FInterpretTextAsBoolean(L_SplitCellAltKey_TEXT)==fAltKey))
		{
			evtSource.returnValue=false;
			var toolBarButton=RTE_TB_GetToolBarButton(strBaseElementID, g_strRTESplitCellMnemonic);
			if (toolBarButton !=null && !toolBarButton.disabled)
			{
				toolBarButton.children(0).click();
			}
		}
		else if (( nKeyCode==L_MergeCellKey_TEXT.charCodeAt(0))
			&& (RTE_FInterpretTextAsBoolean(L_MergeCellShiftKey_TEXT)==fShiftKey)
			&& (RTE_FInterpretTextAsBoolean(L_MergeCellAltKey_TEXT)==fAltKey))
		{
			evtSource.returnValue=false;
			var toolBarButton=RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEMergeCellMnemonic);
			if (toolBarButton !=null && !toolBarButton.disabled)
			{
				toolBarButton.children(0).click();
			}
		}
		else if (( nKeyCode==L_ChangeColumnWidthAndRowHeightKey_TEXT.charCodeAt(0))
			&& (RTE_FInterpretTextAsBoolean(L_ChangeColumnWidthAndRowHeightShiftKey_TEXT)==fShiftKey)
			&& (RTE_FInterpretTextAsBoolean(L_ChangeColumnWidthAndRowHeightAltKey_TEXT)==fAltKey))
		{
			evtSource.returnValue=false;
			var toolBarButton=RTE_TB_GetToolBarButton(strBaseElementID, g_strRTE2TableCellSizingMnemonic);
			if (toolBarButton !=null && !toolBarButton.disabled)
			{
				toolBarButton.children(0).click();
			}
		}
		else if (( nKeyCode==L_IncWidthKey_TEXT.charCodeAt(0))
			&& (RTE_FInterpretTextAsBoolean(L_IncWidthShiftKey_TEXT)==fShiftKey)
			&& (RTE_FInterpretTextAsBoolean(L_IncWidthAltKey_TEXT)==fAltKey))
		{
			evtSource.returnValue=false;
			var toolBarButton=RTE_TB_GetToolBarButton(strBaseElementID, g_strRTE2TableCellSizingMnemonic);
			if (toolBarButton !=null && !toolBarButton.disabled)
			{
				RTE_ExecuteFunctionOnSelection(strBaseElementID, g_strRTE2IncreaseTableColumnWidthFunction, strBaseElementID);
			}
		}
		else if (( nKeyCode==L_DecWidthKey_TEXT.charCodeAt(0))
			&& (RTE_FInterpretTextAsBoolean(L_DecWidthShiftKey_TEXT)==fShiftKey)
			&& (RTE_FInterpretTextAsBoolean(L_DecWidthAltKey_TEXT)==fAltKey))
		{
			evtSource.returnValue=false;
			var toolBarButton=RTE_TB_GetToolBarButton(strBaseElementID, g_strRTE2TableCellSizingMnemonic);
			if (toolBarButton !=null && !toolBarButton.disabled)
			{
				RTE_ExecuteFunctionOnSelection(strBaseElementID, g_strRTE2DecreaseTableColumnWidthFunction, strBaseElementID);
			}
		}
		else if (( nKeyCode==L_IncHeightKey_TEXT.charCodeAt(0))
			&& (RTE_FInterpretTextAsBoolean(L_IncHeightShiftKey_TEXT)==fShiftKey)
			&& (RTE_FInterpretTextAsBoolean(L_IncHeightAltKey_TEXT)==fAltKey))
		{
			evtSource.returnValue=false;
			var toolBarButton=RTE_TB_GetToolBarButton(strBaseElementID, g_strRTE2TableCellSizingMnemonic);
			if (toolBarButton !=null && !toolBarButton.disabled)
			{
				RTE_ExecuteFunctionOnSelection(strBaseElementID, g_strRTE2IncreaseTableRowHeightFunction, strBaseElementID);
			}
		}
		else if (( nKeyCode==L_DecHeightKey_TEXT.charCodeAt(0))
			&& (RTE_FInterpretTextAsBoolean(L_DecHeightShiftKey_TEXT)==fShiftKey)
			&& (RTE_FInterpretTextAsBoolean(L_DecHeightAltKey_TEXT)==fAltKey))
		{
			evtSource.returnValue=false;
			var toolBarButton=RTE_TB_GetToolBarButton(strBaseElementID, g_strRTE2TableCellSizingMnemonic);
			if (toolBarButton !=null && !toolBarButton.disabled)
			{
				RTE_ExecuteFunctionOnSelection(strBaseElementID, g_strRTE2DecreaseTableRowHeightFunction, strBaseElementID);
			}
		}
		else if (( nKeyCode==L_SelectKey_TEXT.charCodeAt(0))
			&& (RTE_FInterpretTextAsBoolean(L_SelectShiftKey_TEXT)==fShiftKey)
			&& (RTE_FInterpretTextAsBoolean(L_SelectAltKey_TEXT)==fAltKey))
		{
			evtSource.returnValue=false;
			var toolBarButton=RTE_TB_GetToolBarButton(strBaseElementID, g_strRTE2SelectElementMnemonic);
			if (toolBarButton !=null && !toolBarButton.disabled)
			{
				toolBarButton.children(0).click();
			}
		}
		else if (( nKeyCode==L_CustomStylesKey_TEXT.charCodeAt(0))
			&& (RTE_FInterpretTextAsBoolean(L_CustomStylesShiftKey_TEXT)==fShiftKey)
			&& (RTE_FInterpretTextAsBoolean(L_CustomStylesAltKey_TEXT)==fAltKey))
		{
			evtSource.returnValue=false;
			var toolBarButton=RTE_TB_GetToolBarButton(strBaseElementID, g_strRTE2CustomStylesMnemonic);
			if (toolBarButton !=null && !toolBarButton.disabled)
			{
				toolBarButton.children(0).click();
			}
		}
		else if (( nKeyCode==L_FormatKey_TEXT.charCodeAt(0))
			&& (RTE_FInterpretTextAsBoolean(L_FormatShiftKey_TEXT)==fShiftKey)
			&& (RTE_FInterpretTextAsBoolean(L_FormatAltKey_TEXT)==fAltKey))
		{
			evtSource.returnValue=false;
			var toolBarButton=RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEStylesMnemonic);
			if (toolBarButton !=null && !toolBarButton.disabled)
			{
				toolBarButton.children(0).click();
			}
		}
		else if (( nKeyCode==L_HtmlSourceKey_TEXT.charCodeAt(0))
			&& (RTE_FInterpretTextAsBoolean(L_HtmlSourceShiftKey_TEXT)==fShiftKey)
			&& (RTE_FInterpretTextAsBoolean(L_HtmlSourceAltKey_TEXT)==fAltKey))
		{
			evtSource.returnValue=false;
			var toolBarButton=RTE_TB_GetToolBarButton(strBaseElementID, g_strRTE2ViewSourceMnemonic);
			if (toolBarButton !=null && !toolBarButton.disabled)
			{
				toolBarButton.children(0).click();
			}
		}
		else if (( nKeyCode==L_RemoveInlineStyleKey_TEXT.charCodeAt(0))
			&& (RTE_FInterpretTextAsBoolean(L_RemoveInlineStyleShiftKey_TEXT)==fShiftKey)
			&& (RTE_FInterpretTextAsBoolean(L_RemoveInlineStyleAltKey_TEXT)==fAltKey))
		{
			evtSource.returnValue=false;
			var toolBarButton=RTE_TB_GetToolBarButton(strBaseElementID, g_strRTE2RemoveStylesMnemonic);
			if (toolBarButton !=null && !toolBarButton.disabled)
			{
				toolBarButton.children(0).click();
			}
		}
		else if (( nKeyCode==L_UndoKey_TEXT.charCodeAt(0))
			&& (RTE_FInterpretTextAsBoolean(L_UndoShiftKey_TEXT)==fShiftKey)
			&& (RTE_FInterpretTextAsBoolean(L_UndoAltKey_TEXT)==fAltKey))
		{
			evtSource.returnValue=false;
			var toolBarButton=RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEUndoMnemonic);
			if (toolBarButton !=null && !toolBarButton.disabled)
			{
				toolBarButton.children(0).click();
			}
		}
		else if (( nKeyCode==L_RedoKey_TEXT.charCodeAt(0))
			&& (RTE_FInterpretTextAsBoolean(L_RedoShiftKey_TEXT)==fShiftKey)
			&& (RTE_FInterpretTextAsBoolean(L_RedoAltKey_TEXT)==fAltKey))
		{
			evtSource.returnValue=false;
			var toolBarButton=RTE_TB_GetToolBarButton(strBaseElementID, g_strRTERedoMnemonic);
			if (toolBarButton !=null && !toolBarButton.disabled)
			{
				toolBarButton.children(0).click();
			}
		}
		else if ((L_SelectAllKey_TEXT.charCodeAt(0)==nKeyCode)
			&& (RTE_FInterpretTextAsBoolean(L_SelectAllShiftKey_TEXT)==fShiftKey)
			&& (RTE_FInterpretTextAsBoolean(L_SelectAllAltKey_TEXT )==fAltKey))
		{
			if (!RTE2_IsSourceView(strBaseElementID))
			{
				evtSource.returnValue=false;
				var textRange=elemDocument.body.createTextRange();
				var docContainer=RTE2_GetEditorContainer(strBaseElementID);
				var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
				textRange.moveToElementText(docContainer);
				textRange.select();
				instanceVariables.selectedElement=docContainer;
			}
		}
	}
	else if (( L_SpellCheckKey_VALUE==nKeyCode)
		&& (RTE_FInterpretTextAsBoolean(L_SpellCheckShiftKey_TEXT)==fShiftKey)
		&& (RTE_FInterpretTextAsBoolean(L_SpellCheckAltKey_TEXT)==fAltKey))
	{
		evtSource.returnValue=false;
		var toolBarButton=RTE_TB_GetToolBarButton(strBaseElementID, g_strRTE2SpellCheckMnemonic);
		if (toolBarButton !=null && !toolBarButton.disabled)
		{
			toolBarButton.children(0).click();
		}
	}
	else if (((L_DeleteKey_VALUE==nKeyCode && !fShiftKey) || L_BackspaceKey_VALUE==nKeyCode) && !fAltKey)
	{
		var selection=RTE_GetCurrentSelection(strBaseElementID);
		if (selection !=null && selection.type !="None")
		{
			RTE2_SaveHtmlStateIfChanged(strBaseElementID);
		}
		var selectedElement=RTE2_GetSelectedElement(strBaseElementID)
		if (instanceVariables !=null && selectedElement !=null)
		{
			var docContainer=RTE2_GetEditorContainer(strBaseElementID);
			if (selectedElement==docContainer)
			{
				docContainer.innerHTML="";
			}
			else
			{
				selectedElement.removeNode(true);
			}
			evtSource.returnValue=false;
			RTE_SaveSelection(strBaseElementID);
			RTE2_SaveHtmlStateIfChanged(strBaseElementID);
			instanceVariables.selectedElement=null;
		}
	}
	else if ((L_BackspaceKey_VALUE==nKeyCode) && fAltKey)
	{
		evtSource.returnValue=false;
		var toolBarButton=RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEUndoMnemonic);
		if (toolBarButton !=null && !toolBarButton.disabled)
		{
			toolBarButton.children(0).click();
		}
	}
	RTE2_FindOnKeyDown(strBaseElementID, elem);
}
function RTE2_OnTab(strBaseElementID, elemDocument)
{
	if (elemDocument==null) return true;
	if (RTE_GetCurrentSelectionType(strBaseElementID)=="Control") return true;
	var aElemChain=RTE_GetCurrentSelectionChain(strBaseElementID);
	if (aElemChain==null) return true;
	var elemSelected=RTE_GetCurrentElement(strBaseElementID);
	if (elemSelected==null) return true;
	if (!RTE2_ElementInContentArea(strBaseElementID, elemSelected)) return true;
	var cellElemInChain=RTE_IsAnyElementInChain(aElemChain, g_aTableCellTagNames);
	if (cellElemInChain)
	{
		var elemCellSelected=RTE_GetNearestContainingParentElementOfType(strBaseElementID, elemSelected, "TD");
		if (elemCellSelected !=null)
		{
			var elemRowSelected=RTE_GetNearestContainingParentElementOfType(strBaseElementID, elemCellSelected, "TR");
			if (elemRowSelected !=null)
			{
				var elemRowSelectedCells=elemRowSelected.cells;
				var elemRowSelectedLength=elemRowSelectedCells.length;
				var elemCellSelectedIndex=elemCellSelected.cellIndex;
				if (elemCellSelectedIndex+1 < elemRowSelectedLength)
				{
					var textRange=elemDocument.body.createTextRange();
					textRange.moveToElementText(elemRowSelectedCells[elemCellSelectedIndex+1]);
					textRange.select();
					return false;
				}
				var elemTableSelected=RTE_GetNearestContainingParentElementOfType(strBaseElementID, elemRowSelected, "TABLE");
				if (elemTableSelected !=null)
				{
					var elemRowSelectedIndex=elemRowSelected.rowIndex;
					var elemTableSelectedLength=elemTableSelected.rows.length;
					if (elemRowSelectedIndex+1 < elemTableSelectedLength)
					{
						var textRange=elemDocument.body.createTextRange();
						textRange.moveToElementText(elemTableSelected.rows[elemRowSelectedIndex+1].cells[0]);
						textRange.select();
						return false;
					}
					RTE_InsertRowBelow(strBaseElementID);
					return false;
				}
			}
		}
	}
	else
	{
		var nextControl=RTE2_FindNextControl(elemDocument, elemSelected);
		if (nextControl !=null)
		{
			var controlRange=elemDocument.body.createControlRange();
			controlRange.add(nextControl);
			controlRange.select();
			return false;
		}
		else
		{
			var lastControl=RTE2_FindLastControl(elemDocument);
			if (lastControl !=null)
			{
				var controlRange=elemDocument.body.createControlRange();
				controlRange.add(lastControl);
				controlRange.select();
			}
		}
	}
	return true;
}
function RTE2_OnShiftTab(strBaseElementID, elemDocument)
{
	if (elemDocument==null) return true;
	if (RTE_GetCurrentSelectionType(strBaseElementID)=="Control") return true;
	var aElemChain=RTE_GetCurrentSelectionChain(strBaseElementID);
	if (aElemChain==null) return true;
	var elemSelected=RTE_GetCurrentElement(strBaseElementID);
	if (elemSelected==null) return true;
	var cellElemInChain=RTE_IsAnyElementInChain(aElemChain, g_aTableCellTagNames);
	if (cellElemInChain)
	{
		var elemCellSelected=RTE_GetNearestContainingParentElementOfType(strBaseElementID, elemSelected, "TD");
		if (elemCellSelected !=null)
		{
			var elemRowSelected=RTE_GetNearestContainingParentElementOfType(strBaseElementID, elemCellSelected, "TR");
			if (elemRowSelected !=null)
			{
				var elemRowSelectedCells=elemRowSelected.cells;
				var elemRowSelectedLength=elemRowSelectedCells.length;
				var elemCellSelectedIndex=elemCellSelected.cellIndex;
				if (elemCellSelectedIndex-1 >=0)
				{
					var textRange=elemDocument.body.createTextRange();
					textRange.moveToElementText(elemRowSelectedCells[elemCellSelectedIndex-1]);
					textRange.select();
					return false;
				}
				var elemTableSelected=RTE_GetNearestContainingParentElementOfType(strBaseElementID, elemRowSelected, "TABLE");
				if (elemTableSelected !=null)
				{
					var elemRowSelectedIndex=elemRowSelected.rowIndex;
					var elemTableSelectedLength=elemTableSelected.rows.length;
					if (elemRowSelectedIndex-1 >=0)
					{
						var textRange=elemDocument.body.createTextRange();
						var prevRowNumCells=elemTableSelected.rows[elemRowSelectedIndex-1].cells.length;
						textRange.moveToElementText(elemTableSelected.rows[elemRowSelectedIndex-1].cells[prevRowNumCells-1]);
						textRange.select();
						return false;
					}
					var controlRange=elemDocument.body.createControlRange();
					controlRange.add(elemTableSelected);
					controlRange.select();
					return false;
				}
			}
		}
	}
	else
	{
		var prevControl=RTE2_FindPrevControl(elemDocument, elemSelected);
		if (prevControl !=null)
		{
			var controlRange=elemDocument.body.createControlRange();
			controlRange.add(prevControl);
			controlRange.select();
			return false;
		}
	}
	return true;
}
function RTE2_FindSelectionNode(elemDocument, elemSelected, dir)
{
	var selectedNode=elemSelected;
	var selectRange=elemDocument.selection.createRange();
	var textRange=elemDocument.body.createTextRange();
	textRange.moveToElementText(elemSelected);
	var currentTextRangePosition=textRange.getBookmark();
	var child=elemSelected.firstChild;
	var count=0;
	while (child !=null && child !=elemSelected && count < g_MaxDomSearchWalk)
	{
	count++;
		while (child.firstChild !=null)
		{
			child=child.firstChild;
		}
		textRange.moveToBookmark(currentTextRangePosition);
		if (child.nodeType==3)
		{
			textRange.findText(child.data);
		}
		else
		{
			textRange.moveToElementText(child);
		}
		var childRange=textRange.duplicate();
		currentTextRangePosition=textRange.getBookmark();
		textRange.moveEnd('textedit');
		if (textRange.inRange(selectRange))
		{
			selectedNode=child;
		}
		else if (dir=="next" && selectRange.inRange(childRange))
		{
			selectedNode=child;
		}
		while (child.nextSibling==null)
		{
			child=child.parentNode;
			if (child==null || child==elemSelected) return selectedNode;
		}
		child=child.nextSibling;
	}
	return selectedNode;
}
function RTE2_ElementIsControl(elemNode)
{
	return (elemNode.tagName=='IMG' || elemNode.tagName=='TABLE');
}
function RTE2_FindNextControl(elemDocument, elemSelected)
{
	elemNode=RTE2_FindSelectionNode(elemDocument, elemSelected, "next");
	var firstIterance=true;
	while (elemNode !=null && (!RTE2_ElementIsControl(elemNode) || firstIterance))
	{
		if (!firstIterance && elemNode.childNodes && elemNode.childNodes.length > 0)
		{
			elemNode=elemNode.childNodes(0);
		}
		else
		{
			if (elemNode.nextSibling==null)
			{
				while (elemNode.parentNode !=null && elemNode.parentNode.nextSibling==null)
				{
					elemNode=elemNode.parentNode;
				}
				if (elemNode.parentNode==null) return null;
				elemNode=elemNode.parentNode.nextSibling;
			}
			else
			{
				elemNode=elemNode.nextSibling;
			}
		}
		firstIterance=false;
	}
	return elemNode;
}
function RTE2_FindPrevControl(elemDocument, elemSelected)
{
	elemNode=RTE2_FindSelectionNode(elemDocument, elemSelected, "prev");
	var firstIterance=true;
	while (elemNode !=null && (firstIterance || !RTE2_ElementIsControl(elemNode)))
	{
		if (elemNode.previousSibling==null)
		{
			elemNode=elemNode.parentNode;
		}
		else
		{
			elemNode=elemNode.previousSibling;
			while (elemNode.childNodes && elemNode.childNodes.length > 0)
			{
				elemNode=elemNode.childNodes(elemNode.childNodes.length - 1);
			}
		}
		firstIterance=false;
	}
	return elemNode;
}
function RTE2_FindLastControl(elemDocument)
{
	elemNode=elemDocument;
	while (elemNode.childNodes && elemNode.childNodes.length > 0)
	{
		elemNode=elemNode.childNodes(elemNode.childNodes.length - 1);
	}
	while (elemNode !=null && !RTE2_ElementIsControl(elemNode))
	{
		if (elemNode.previousSibling==null)
		{
			elemNode=elemNode.parentNode;
		}
		else
		{
			elemNode=elemNode.previousSibling;
			while (elemNode.childNodes && elemNode.childNodes.length > 0)
			{
				elemNode=elemNode.childNodes(elemNode.childNodes.length - 1);
			}
		}
	}
	return elemNode;
}
function RTE2_OnDoubleClick(strBaseElementID)
{
	var docEditor=RTE_GetEditorDocument(strBaseElementID);
	var selection=docEditor.selection;
	if (selection==null) { return; }
	if (selection.type=="Control")
	{
		var controls=selection.createRange();
		if (controls.length==1)
		{
			var controlTagName=controls.item(0).tagName.toUpperCase();
			switch(controlTagName)
			{
				case "TABLE":
					RTE2_EditTable(strBaseElementID);
					break;
				case "IMG":
					RTE2_EditImageOrLinkProperties(strBaseElementID);
					break;
				case "SPAN":
					if (controls.item(0).id==g_strRTE2ReusableFragmentCommonToken)
					{
						RTE2_InsertOrChangeReusableText(strBaseElementID);
					}
					break;
			}
		}
	}
}
function RTE2_SaveSelection(strBaseElementID)
{
	if (!RTE2_IsSourceView(strBaseElementID))
	{
		var docEditor=RTE_GetEditorDocument(strBaseElementID);
		g_rgrngRTETextEditorSelection[strBaseElementID]=docEditor.selection.createRange();
		g_rgstRTETextEditorSelectionType[strBaseElementID]=docEditor.selection.type;
	}
}
function RTE2_RestoreSelection(strBaseElementID)
{
	var sel=g_rgrngRTETextEditorSelection[strBaseElementID];
	if (sel==null) return;
	var type=g_rgstRTETextEditorSelectionType[strBaseElementID];
	if (type !=null && type=="None") sel.collapse(false);
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	instanceVariables.disregardSelectionChange++;
	sel.select();
	instanceVariables.disregardSelectionChange--;
}
var g_currentStyleNames;
function RTE2_CopyStyles(source, target)
{
	if (source==null || target==null) return;
	if (g_currentStyleNames==null)
	{
		g_currentStyleNames=new Array
		(
			"color",
			"fontFamily",
			"fontSize",
			"fontStyle",
			"fontVariant",
			"fontWeight",
			"lineHeight",
			"listStyleImage",
			"listStylePosition",
			"listStyleType",
			"textAlign",
			"textIndent",
			"textTransform",
			"textUnderlinePosition",
			"whiteSpace",
			"wordSpacing"
		);
	}
	var currentStyleNames_length=g_currentStyleNames.length;
	for (var i=0; i<currentStyleNames_length; i++)
	{
		var styleName=g_currentStyleNames[i];
		if (source[styleName] !=null && target[styleName] !=null)
		{
			target[styleName]=source[styleName];
		}
	}
}
function RTE2_GenerateMergeCellToolBarButtonHtml(strBaseElementID, strWebLanguage)
{
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	instanceVariables.functions[g_strRTEMergeCellMnemonic]=RTE_MergeCells;
	instanceVariables.functions[g_strRTE2MergeCellRightMnemonic]=RTE_MergeWithRight;
	instanceVariables.functions[g_strRTE2MergeCellLeftMnemonic]=RTE_MergeWithLeft;
	instanceVariables.functions[g_strRTE2MergeCellAboveMnemonic]=RTE_MergeWithAbove;
	instanceVariables.functions[g_strRTE2MergeCellBelowMnemonic]=RTE_MergeWithBelow;
	var strHtmlRet="";
	strHtmlRet+=RTE_TB_GenerateOpenCellButtonHtml(strBaseElementID, g_strRTEMergeCellMnemonic, "RTE2_DD_OpenMergeCellSelector('"+strBaseElementID+"' ,'"+strWebLanguage+"')");
	strHtmlRet+="<img src=\""+RTE_GetServerRelativeImageUrl("rtemcell.gif")+"\" alt=\""+L_MergeCellToolTip_TEXT+"\" border=0"+g_strIconSizeAttributes+"unselectable=\"on\">";
	strHtmlRet+="<img alt=\""+L_MergeCellToolTip_TEXT+"\" src=\""+RTE_GetServerRelativeUnlocalizedImageUrl("menudark.gif")+"\" border=0 width=13 height=13 unselectable=\"on\">";
	strHtmlRet+=RTE_TB_GenerateCloseCellButtonHtml();
	return strHtmlRet;
}
function RTE2_DD_OpenMergeCellSelector(strBaseElementID, strWebLanguage)
{
	var strMnemonic=g_strRTEMergeCellMnemonic;
	var rgoMenuInfo=RTE2_DD_GetMergeCellSelectorUnformattedHtml(strBaseElementID, strWebLanguage);
	var strMenuHtml=rgoMenuInfo[0];
	var cMenuItems=rgoMenuInfo[1];
	RTE_DD_OpenMenu(strBaseElementID, strMnemonic, strMenuHtml, strWebLanguage, cMenuItems);
}
function RTE2_DD_GetMergeCellSelectorUnformattedHtml(strBaseElementID, strWebLanguage)
{
	var strCommandToPerform=g_strRTEMergeCellMnemonic;
	var strMenuHtml=g_rgstrRTEMenuHtml[strCommandToPerform];
	if (null !=strMenuHtml)
	{
		return strMenuHtml;
	}
	strMenuHtml=RTE_DD_GenerateMenuOpenHtml(strWebLanguage);
	var rgstrItemNames=new Array();
	rgstrItemNames.push(L_MergeCellSelectedLabel_TEXT);
	rgstrItemNames.push(L_MergeCellRightLabel_TEXT);
	rgstrItemNames.push(L_MergeCellLeftLabel_TEXT);
	rgstrItemNames.push(L_MergeCellAboveLabel_TEXT);
	rgstrItemNames.push(L_MergeCellBelowLabel_TEXT);
	var cMenuItems=rgstrItemNames.length;
	var mnemonicsName=new Array(g_strRTEMergeCellMnemonic, g_strRTE2MergeCellRightMnemonic,g_strRTE2MergeCellLeftMnemonic, g_strRTE2MergeCellAboveMnemonic, g_strRTE2MergeCellBelowMnemonic);
	for (var i=0; i<mnemonicsName.length; i++)
	{
		strMenuHtml+=RTE2_DD_GenerateMenuItemScriptHtmlWithSaveHtmlState(strBaseElementID, 1, i,
			mnemonicsName[i],
			strBaseElementID,
			rgstrItemNames[i],
			rgstrItemNames[i],
			strWebLanguage);
	}
	strMenuHtml+=RTE_DD_GenerateMenuCloseHtml();
	g_rgstrRTEMenuHtml[strCommandToPerform]=new Array(strMenuHtml, cMenuItems);
	return g_rgstrRTEMenuHtml[strCommandToPerform];
}
function RTE2_GenerateTableToolBarButtonHtml(strBaseElementID, strWebLanguage)
{
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	instanceVariables.functions[g_strRTEInsertRowAbove]=RTE_InsertRowAbove;
	instanceVariables.functions[g_strRTEInsertRowBelow]=RTE_InsertRowBelow;
	instanceVariables.functions[g_strRTEInsertColumnLeft]=RTE_InsertColumnLeft;
	instanceVariables.functions[g_strRTEInsertColumnRight]=RTE_InsertColumnRight;
	instanceVariables.functions[g_strRTEInsertCellLeft]=RTE_InsertCellLeft;
	instanceVariables.functions[g_strRTEInsertCellRight]=RTE_InsertCellRight;
	instanceVariables.functions[g_strRTEDeleteRow]=RTE_DeleteRow;
	instanceVariables.functions[g_strRTEDeleteColumn]=RTE_DeleteColumn;
	instanceVariables.functions[g_strRTESplitCellMnemonic]=RTE2_SplitCell;
	var strHtmlRet="";
	strHtmlRet+=RTE_TB_GenerateOpenCellButtonHtml(strBaseElementID, g_strRTE2TableMnemonic, "RTE2_DD_OpenTableSelector('"+strBaseElementID+"' ,'"+strWebLanguage+"');");
	strHtmlRet+="<img src=\""+RTE_GetServerRelativeImageUrl("rteirow.gif")+"\" alt=\""+L_TableOperationsToolTip_TEXT+"\" border=0 width=16 height=16 unselectable=\"on\">";
	strHtmlRet+="<img alt=\""+L_TableOperationsToolTip_TEXT+"\" src=\""+RTE_GetServerRelativeUnlocalizedImageUrl("menudark.gif")+"\" border=0 width=13 height=13 unselectable=\"on\">";
	strHtmlRet+=RTE_TB_GenerateCloseCellButtonHtml();
	return strHtmlRet;
}
function RTE2_DD_OpenTableSelector(strBaseElementID, strWebLanguage)
{
	var strMnemonic=g_strRTE2TableMnemonic;
	var rgoMenuInfo=RTE2_DD_GetTableSelectorUnformattedHtml(strBaseElementID, strWebLanguage);
	var strMenuHtml=rgoMenuInfo[0];
	var cMenuItems=rgoMenuInfo[1];
	RTE_DD_OpenMenu(strBaseElementID, strMnemonic, strMenuHtml, strWebLanguage, cMenuItems);
}
function RTE2_DD_GetTableSelectorUnformattedHtml(strBaseElementID, strWebLanguage)
{
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	var strMenuHtml=instanceVariables.menuHtml[g_strRTE2TableMnemonic];
	if (null !=strMenuHtml)
	{
		return strMenuHtml;
	}
	strMenuHtml=RTE_DD_GenerateMenuOpenHtml(strWebLanguage);
	var rgstrItemNames=new Array();
	rgstrItemNames.push(L_InsertRowAboveLabel_TEXT);
	rgstrItemNames.push(L_InsertRowBelowLabel_TEXT);
	rgstrItemNames.push(L_InsertColumnLeftLabel_TEXT);
	rgstrItemNames.push(L_InsertColumnRightLabel_TEXT);
	rgstrItemNames.push("-");
	rgstrItemNames.push(L_InsertCellLeftLabel_TEXT);
	rgstrItemNames.push(L_InsertCellRightLabel_TEXT);
	rgstrItemNames.push("-");
	rgstrItemNames.push(L_DeleteRowLabel_TEXT);
	rgstrItemNames.push(L_DeleteColumnLabel_TEXT);
	rgstrItemNames.push("-");
	rgstrItemNames.push(L_SplitCellLabel_TEXT);
	var mnemonicsName=new Array();
	mnemonicsName.push(g_strRTEInsertRowAbove);
	mnemonicsName.push(g_strRTEInsertRowBelow);
	mnemonicsName.push(g_strRTEInsertColumnLeft);
	mnemonicsName.push(g_strRTEInsertColumnRight);
	mnemonicsName.push("-");
	mnemonicsName.push(g_strRTEInsertCellLeft);
	mnemonicsName.push(g_strRTEInsertCellRight);
	mnemonicsName.push("-");
	mnemonicsName.push(g_strRTEDeleteRow);
	mnemonicsName.push(g_strRTEDeleteColumn);
	mnemonicsName.push("-");
	mnemonicsName.push(g_strRTESplitCellMnemonic);
	var navigablePosition=0;
	for (var i=0; i<mnemonicsName.length; i++)
	{
		if (mnemonicsName[i] !="-")
		{
			strMenuHtml+=RTE2_DD_GenerateMenuItemScriptHtmlWithSaveHtmlState(strBaseElementID, 1, navigablePosition,
				mnemonicsName[i],
				strBaseElementID,
				rgstrItemNames[i],
				rgstrItemNames[i]);
			navigablePosition++;
		}
		else
		{
			strMenuHtml+=RTE2_DD_GenerateMenuBarItem();
		}
	}
	strMenuHtml+=RTE_DD_GenerateMenuCloseHtml();
	instanceVariables.menuHtml[g_strRTE2TableMnemonic]=new Array(strMenuHtml, navigablePosition);
	return instanceVariables.menuHtml[g_strRTE2TableMnemonic];
}
function RTE2_GenerateSelectElementToolBarButtonHtml(strBaseElementID, strWebLanguage)
{
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	instanceVariables.functions[g_strRTE2SelectElementFunction]=RTE2_SelectElement;
	var strHtmlRet="";
	strHtmlRet+=RTE_TB_GenerateOpenCellButtonHtml(strBaseElementID, g_strRTE2SelectElementMnemonic, "RTE2_DD_OpenSelectElementSelector('"+strBaseElementID+"' ,'"+strWebLanguage+"', true)");
	strHtmlRet+=L_SelectElementLabel_TEXT+"&nbsp;<img alt=\""+L_SelectElementToolTip_TEXT+"\" src=\""+RTE_GetServerRelativeUnlocalizedImageUrl("menudark.gif")+"\" border=0 width=13 height=13 unselectable=\"on\">";
	strHtmlRet+=RTE_TB_GenerateCloseCellButtonHtml();
	return strHtmlRet;
}
function RTE2_DD_OpenSelectElementSelector(strBaseElementID, strWebLanguage)
{
	var strMnemonic=g_strRTE2SelectElementMnemonic;
	var rgoMenuInfo=RTE2_DD_GetSelectElementSelectorUnformattedHtml(strBaseElementID, strWebLanguage);
	var strMenuHtml=rgoMenuInfo[0];
	var cMenuItems=rgoMenuInfo[1];
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	instanceVariables.disregardSelectionChange++;
	RTE_DD_OpenMenu(strBaseElementID, strMnemonic, strMenuHtml, strWebLanguage, cMenuItems);
	instanceVariables.disregardSelectionChange--;
}
function RTE2_GetSelectedElement(strBaseElementID)
{
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	if (instanceVariables==null) return null;
	var selectedElement=instanceVariables.selectedElement;
	if (selectedElement==null) return null;
	if (!RTE2_ElementInContentArea(strBaseElementID, selectedElement))
	{
		return null;
	}
	return selectedElement;
}
function RTE2_DD_GetSelectElementSelectorUnformattedHtml(strBaseElementID, strWebLanguage)
{
	strMenuHtml=RTE_DD_GenerateMenuOpenHtml(strWebLanguage);
	var tagNameCounters=RTE2_GenerateDictionary();
	var aParentChain=RTE_GetCurrentSelectionChain(strBaseElementID);
	var aParentChain_length=aParentChain.length;
	if (aParentChain_length > 0)
	{
		var selectedElement=RTE2_GetSelectedElement(strBaseElementID)
		var selectedElementFound=(selectedElement==null)? true: false;
		var addedMenuItemsCounter=0;
		for (var i=0; i < aParentChain_length; i++)
		{
			if (!selectedElementFound)
			{
				if (aParentChain[i]==selectedElement)
				{
					selectedElementFound=true;
				}
				else
				{
					continue;
				}
			}
			var tagName=aParentChain[i].tagName;
			var expandedTagName=RTE2_GetExpandedTagName(tagName);
			if (expandedTagName==null)
			{
				expandedTagName=tagName;
			}
			var tagNameCounter=RTE2_FindInDictionary(tagName, tagNameCounters);
			if (tagNameCounter !=null)
			{
				tagNameCounter.value++;
				expandedTagName+="&nbsp;"+tagNameCounter.value;
			}
			else
			{
				RTE2_AddToDictionary(tagName, 1, tagNameCounters);
			}
			strMenuHtml+=RTE_DD_GenerateMenuItemScriptHtml(1, addedMenuItemsCounter,
				"return RTE_DD_StartAction('"+g_strRTE2SelectElementFunction+"', '"+strBaseElementID+","+i+"')",
				expandedTagName,
				tagName, null, null, strWebLanguage);
			addedMenuItemsCounter++;
		}
	}
	else
	{
		var iMenuItem=0;
		strMenuHtml+=			"<td unselectable='on' class=\"ms-toolbar "+g_strRTEUnselectedClassName+"\" "+				"nowrap id=\""+g_strRTEMenuItemBaseName+iMenuItem+"\" "+				g_strRTEMenuItemAttributeName+"=\""+iMenuItem+"\" "+				"<font unselectable='on'>"+					L_NoSelectionAvailable_TEXT+				"</font>"+			"</td>";
		aCustomStyles_length=1;
	}
	strMenuHtml+=RTE_DD_GenerateMenuCloseHtml();
	return new Array(strMenuHtml, aParentChain_length);
}
function RTE2_SelectElement(parameterText)
{
	if (parameterText==null || parameterText.length==0) {return;}
	var parameters=parameterText.split(",");
	if (parameters.length !=2) {return;}
	var strBaseElementID=parameters[0];
	var parentChainIndex=parameters[1];
	var aParentChain=RTE_GetCurrentSelectionChain(strBaseElementID);
	if (aParentChain==null || parentChainIndex >=aParentChain.length) {return;}
	var selectedElement=aParentChain[parentChainIndex];
	var editorDocument=RTE_GetEditorDocument(strBaseElementID);
	var range;
	if (selectedElement.tagName=='TABLE'
		|| selectedElement.tagName=='IMG')
	{
		range=editorDocument.body.createControlRange();
		range.add(selectedElement);
	}
	else
	{
		range=editorDocument.body.createTextRange();
		range.moveToElementText(selectedElement);
	}
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	instanceVariables.selectedElement=selectedElement;
	instanceVariables.disregardSelectionChange++;
	range.select();
	instanceVariables.disregardSelectionChange--;
	RTE_SaveSelection(strBaseElementID);
	RTE_StartResetToolBarTimer(strBaseElementID);
}
var g_aExpandedTagNames;
function RTE2_CompareExpandedTagNames(first, second)
{
	if (first[0] < second[0]) {return -1;}
	else if (first[0] > second[0]) {return 1;}
	else {return 0;}
}
function RTE2_GetExpandedTagName(tagName)
{
	if (g_aExpandedTagNames==null)
	{
		g_aExpandedTagNames=new Array();
		g_aExpandedTagNames.push(new Array("P", L_ExpandedTagNameP));
		g_aExpandedTagNames.push(new Array("SPAN", L_ExpandedTagNameSPAN));
		g_aExpandedTagNames.push(new Array("FONT", L_ExpandedTagNameFONT));
		g_aExpandedTagNames.push(new Array("OL", L_ExpandedTagNameOL));
		g_aExpandedTagNames.push(new Array("UL", L_ExpandedTagNameUL));
		g_aExpandedTagNames.push(new Array("LI", L_ExpandedTagNameLI));
		g_aExpandedTagNames.push(new Array("TABLE", L_ExpandedTagNameTABLE));
		g_aExpandedTagNames.push(new Array("IMG", L_ExpandedTagNameIMG));
		g_aExpandedTagNames.push(new Array("A", L_ExpandedTagNameA));
		g_aExpandedTagNames.push(new Array("TR", L_ExpandedTagNameTR));
		g_aExpandedTagNames.push(new Array("TD", L_ExpandedTagNameTD));
		g_aExpandedTagNames.push(new Array("H1", L_ExpandedTagNameH1));
		g_aExpandedTagNames.push(new Array("H2", L_ExpandedTagNameH2));
		g_aExpandedTagNames.push(new Array("H3", L_ExpandedTagNameH3));
		g_aExpandedTagNames.push(new Array("H4", L_ExpandedTagNameH4));
		g_aExpandedTagNames.push(new Array("H5", L_ExpandedTagNameH5));
		g_aExpandedTagNames.push(new Array("H6", L_ExpandedTagNameH6));
		g_aExpandedTagNames.push(new Array("H7", L_ExpandedTagNameH7));
		g_aExpandedTagNames.push(new Array("BODY", L_ExpandedTagNameBODY));
		g_aExpandedTagNames.push(new Array("PRE", L_ExpandedTagNamePRE));
		g_aExpandedTagNames.sort(RTE2_CompareExpandedTagNames);
	}
	var expandedTagName=new Array(tagName, "");
	expandedTagName=RTE2_BinaryFind(expandedTagName, g_aExpandedTagNames, RTE2_CompareExpandedTagNames);
	if (expandedTagName !=null)
	{
		return expandedTagName[1];
	}
	return L_ExpandedTagNameDefault.replace("###", tagName);
}
function RTE2_GenerateCustomStylesToolBarButtonHtml(strBaseElementID, strWebLanguage)
{
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	instanceVariables.functions[g_strRTE2ApplyCustomStyleFunction]=RTE2_ApplyCustomStyle;
	instanceVariables.functions[g_strRTE2RemoveStylesFunction]=RTE2_RemoveStyles;
	var strHtmlRet="";
	strHtmlRet+=RTE_TB_GenerateOpenCellButtonHtml(strBaseElementID, g_strRTE2CustomStylesMnemonic, "RTE2_DD_OpenCustomStylesSelector('"+strBaseElementID+"' ,'"+strWebLanguage+"')");
	strHtmlRet+=L_StylesLabel_TEXT+"&nbsp;";
	strHtmlRet+="<img alt=\""+L_CustomStylesToolTip_TEXT+"\" src=\""+RTE_GetServerRelativeUnlocalizedImageUrl("menudark.gif")+"\" border=0 width=13 height=13 unselectable=\"on\">";
	strHtmlRet+=RTE_TB_GenerateCloseCellButtonHtml();
	return strHtmlRet;
}
function RTE2_DD_OpenCustomStylesSelector(strBaseElementID, strWebLanguage)
{
	var strMnemonic=g_strRTE2CustomStylesMnemonic;
	var rgoMenuInfo=RTE2_DD_GetCustomStylesSelectorUnformattedHtml(strBaseElementID, strWebLanguage);
	var strMenuHtml=rgoMenuInfo[0];
	var cMenuItems=rgoMenuInfo[1];
	RTE_DD_OpenMenu(strBaseElementID, strMnemonic, strMenuHtml, strWebLanguage, cMenuItems);
}
function RTE2_DD_GetCustomStylesSelectorUnformattedHtml(strBaseElementID, strWebLanguage)
{
	strMenuHtml=RTE_DD_GenerateMenuOpenHtml(strWebLanguage);
	var selectedElementClassName=null;
	var selectedElement=RTE2_GetSelectedElement(strBaseElementID);
	if (selectedElement !=null)
	{
		selectedElementClassName=selectedElement.className;
	}
	var aCustomStyles=RTE2_GetCustomStyles(strBaseElementID);
	var aCustomStyles_length=0;
	var docEditor=RTE_GetEditorDocument(strBaseElementID);
	if (docEditor.selection.type !='None')
	{
		if (aCustomStyles !=null && aCustomStyles.length > 0)
		{
			aCustomStyles_length=aCustomStyles.length;
			var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
			for (var i=0; i < aCustomStyles_length; i++)
			{
				var menuItemImage="blank16.gif";
				if (selectedElementClassName !=null  && selectedElementClassName==aCustomStyles[i].specifier.className)
				{
					menuItemImage="chkmrk.gif";
				}
				var displayName=aCustomStyles[i].specifier.className;
				displayName=displayName.replace(instanceVariables.prefixStyleSheet+"Custom-","");
				strMenuHtml+=RTE2_DD_GenerateMenuItemScriptHtmlWithSaveHtmlState(strBaseElementID, 1, i,
					g_strRTE2ApplyCustomStyleFunction,
					strBaseElementID+","+aCustomStyles[i].specifier.className,
					"<img alt=\"\" src=\""+RTE_GetServerRelativeUnlocalizedImageUrl(menuItemImage)+"\" border=0 unselectable='on'> "+displayName,
					aCustomStyles[i].styleRule.style.cssText, strWebLanguage);
			}
		}
	}
	else
	{
		strMenuHtml+=RTE_DD_GenerateMenuItemScriptHtml(1, aCustomStyles_length, "", L_NoSelectionLabel_TEXT, L_NoSelectionToolTip_TEXT, null, null, strWebLanguage);
		aCustomStyles_length++;
	}
	strMenuHtml+=RTE2_DD_GenerateMenuItemScriptHtmlWithSaveHtmlState(strBaseElementID, 1, aCustomStyles_length,
		g_strRTE2RemoveStylesFunction, strBaseElementID,
		"<img alt=\"\" src=\""+RTE_GetServerRelativeImageUrl("rte2rstyl.gif")+"\" border=0"+g_strIconSizeAttributes+" unselectable='on'> "+L_RemoveStylesLabel_TEXT,
		L_RemoveStylesToolTip_TEXT, strWebLanguage);
	aCustomStyles_length++;
	strMenuHtml+=RTE_DD_GenerateMenuCloseHtml();
	return new Array(strMenuHtml, aCustomStyles_length);
}
var g_customStyleLists;
function RTE2_GetCustomStyles(strBaseElementID)
{
	var aCustomStyles=null;
	if (g_customStyleLists==null)
	{
		g_customStyleLists=new Array();
	}
	if (g_customStyleLists[strBaseElementID]==null)
	{
		g_customStyleLists[strBaseElementID]=RTE2_CreateCustomStyleList(strBaseElementID);
	}
	var aSelectionChain=RTE_GetCurrentSelectionChain(strBaseElementID);
	if (aSelectionChain !=null && aSelectionChain.length > 0)
	{
		aCustomStyles=RTE2_GetApplicableStyles(strBaseElementID, aSelectionChain, g_customStyleLists[strBaseElementID]);
	}
	return aCustomStyles;
}
function RTE2_CreateCustomStyleList(strBaseElementID)
{
	var docEditor=RTE_GetEditorDocument(strBaseElementID);
	if (docEditor==null) { return; }
	var styleRules=RTE2_GetReservedCustomStyleRules(strBaseElementID, docEditor);
	if (styleRules==null)    styleRules=new Array();
	var selectors=new Array();
	var whiteSpace=new RegExp("[ \t]+");
	var styleRules_length=styleRules.length;
	for (var i=0; i<styleRules_length; i++)
	{
		var styleSelectors=styleRules[i].selectorText.split(",");
		var styleSelectors_length=styleSelectors.length;
		for (var j=0; j<styleSelectors_length; j++)
		{
			var selectorText=styleSelectors[j];
			var specifier=new Object();
			specifier.text="";
			specifier.tagName="";
			specifier.className="";
			specifier.id="";
			var qualifiers=new Array();
			var selectorElements=selectorText.split(whiteSpace);
			selectorElements=selectorElements.reverse();
			var selectorElements_length=selectorElements.length;
			if (selectorElements_length==0)
			{
				continue;
			}
			else
			{
				specifier.text=selectorElements[0];
				if (selectorElements_length > 1)
				{
					for (var k=1; k<selectorElements_length; k++)
					{
						var qualifier=new Object();
						qualifier.text=selectorElements[k];
						qualifier.tagName="";
						qualifier.className="";
						qualifier.id="";
						qualifiers.push(qualifier);
					}
				}
			}
			if (specifier !=null && specifier.text !="")
			{
				var specifier_text=specifier.text;
				var periodIndex=specifier_text.indexOf(".");
				if (periodIndex==0)
				{
					specifier.className=specifier_text.substr(1);
				}
				else if (periodIndex > 0)
				{
					var aTemp=specifier_text.split(".");
					specifier.tagName=aTemp[0].toUpperCase();
					specifier.className=aTemp[1];
				}
				else
				{
					var poundIndex=specifier_text.indexOf("#");
					if (poundIndex==0)
					{
						specifier.id=specifier_text.substr(1);
					}
					else if (poundIndex > 0)
					{
						var aTemp=specifier_text.split("#");
						specifier.tagName=aTemp[0].toUpperCase();
						specifier.id=aTemp[1];
					}
				}
				var colonIndex=specifier.className.indexOf(":");
				if (colonIndex !=-1){specifier.className=specifier.className.substr(0, colonIndex);}
				colonIndex=specifier.id.indexOf(":");
				if (colonIndex !=-1) {specifier.id=specifier.id.substr(0, colonIndex);}
				colonIndex=specifier.tagName.indexOf(":");
				if (colonIndex !=-1) {specifier.tagName=specifier.tagName.substr(0, colonIndex);}
				specifier.tagName=specifier.tagName.toUpperCase();
			}
			var qualifiers_length=qualifiers.length;
			for (var k=0; k<qualifiers_length; k++)
			{
				var qualifier=qualifiers[k];
				if (qualifier !=null && qualifier.text !="")
				{
					var qualifier_text=qualifier.text;
					var periodIndex=qualifier_text.indexOf(".");
					if (periodIndex==0)
					{
						qualifier.className=qualifier_text.substr(1);
					}
					else if (periodIndex > 0)
					{
						var aTemp=qualifier_text.split(".");
						qualifier.tagName=aTemp[0].toUpperCase();
						qualifier.className=aTemp[1];
					}
					else
					{
						var poundIndex=qualifier_text.indexOf("#");
						if (poundIndex==0)
						{
							qualifier.id=qualifier_text.substr(1);
						}
						else if (poundIndex > 0)
						{
							var aTemp=qualifier_text.split("#");
							qualifier.tagName=aTemp[0].toUpperCase();
							qualifier.id=aTemp[1];
						}
					}
					var colonIndex=qualifier.className.indexOf(":");
					if (colonIndex !=-1){qualifier.className=qualifier.className.substr(0, colonIndex);}
					colonIndex=qualifier.id.indexOf(":");
					if (colonIndex !=-1) {qualifier.id=qualifier.id.substr(0, colonIndex);}
					colonIndex=qualifier.tagName.indexOf(":");
					if (colonIndex !=-1) {qualifier.tagName=qualifier.tagName.substr(0, colonIndex);}
					qualifier.tagName=qualifier.tagName.toUpperCase();
				}
			}
			var selector=new Object();
			selector.specifier=specifier;
			selector.qualifiers=qualifiers;
			selector.styleRule=styleRules[i];
			RTE2_InsertStyleSelector(selector, selectors);
		}
	}
	var tagNameOffsets=new Array();
	var selectors_length=selectors.length;
	if (selectors_length > 0)
	{
		var currentTagName=selectors[0].specifier.tagName;
		tagNameOffsets[currentTagName]=0;
		for (var i=1; i<selectors_length; i++)
		{
			if (currentTagName !=selectors[i].specifier.tagName)
			{
				currentTagName=selectors[i].specifier.tagName;
				tagNameOffsets[currentTagName]=i;
			}
		}
	}
	var styleList=new Object();
	styleList.selectors=selectors;
	styleList.tagNameOffsets=tagNameOffsets;
	return styleList;
}
function RTE2_BinaryInsert(item, sortedItems, comparisonFunction)
{
	var start=0
	var end=sortedItems.length-1;
	var current=0;
	var itemExists=false;
	while (start <=end)
	{
		current=Math.floor((start+end)/2);
		var comparison=comparisonFunction(item, sortedItems[current]);
		if (comparison < 0)
		{
			if (current > start){current--;}
			if (end==start){break;}
			end=current;
		}
		else if (comparison > 0)
		{
			if (current <=end) {current++;}
			if (start==end){break;}
			start=current;
		}
		else
		{
			itemExists=true;
			break;
		}
	}
	if (itemExists)
	{
		sortedItems[current]=item;
	}
	else
	{
		sortedItems.splice(current, 0, item);
	}
}
function RTE2_GenerateDictionaryItem(key, value)
{
	var item=new Object();
	item.key=key;
	item.value=value;
	return item;
}
function RTE2_GenerateDictionary()
{
	var dictionary=new Object();
	dictionary.sortedItems=new Array();
	return dictionary;
}
function RTE2_FindInDictionary(key, dictionary)
{
	var itemKey=RTE2_GenerateDictionaryItem(key, null);
	return RTE2_BinaryFind(itemKey, dictionary.sortedItems, RTE2_CompareDictionaryItems);
}
function RTE2_AddToDictionary(key, value, dictionary)
{
	var item=RTE2_FindInDictionary(key, dictionary);
	if (item !=null)
	{
		item.value=value;
	}
	else
	{
		item=RTE2_GenerateDictionaryItem(key, value);
		RTE2_BinaryInsert(item, dictionary.sortedItems, RTE2_CompareDictionaryItems);
	}
	return item;
}
function RTE2_CompareDictionaryItems(first, second)
{
	var first_key=first.key;
	var second_key=second.key;
	if (first_key > second_key)
	{
		return 1;
	}
	else if (first_key < second_key)
	{
		return -1;
	}
	else
	{
		return 0;
	}
}
function RTE2_BinaryFind(item, sortedItems, comparisonFunction)
{
	var start=0
	var end=sortedItems.length-1;
	var current=0;
	var itemExists=false;
	while (start <=end)
	{
		current=Math.floor((start+end)/2);
		var comparison=comparisonFunction(item, sortedItems[current]);
		if (comparison < 0)
		{
			if (current > start)
			{
				current--;
			}
			if (end==start)
			{
				break;
			}
			end=current;
		}
		else if (comparison > 0)
		{
			current++;
			if (start==end)
			{
				break;
			}
			start=current;
		}
		else
		{
			itemExists=true;
			break;
		}
	}
	if (itemExists)
	{
		return sortedItems[current];
	}
	else
	{
		return null;
	}
}
function RTE2_InsertStyleSelector(selector, sortedSelectors)
{
	RTE2_BinaryInsert(selector, sortedSelectors, RTE2_CompareSelectors);
}
function RTE2_CompareSelectors(first, second)
{
	var first_tagName=first.specifier.tagName.toUpperCase();
	var second_tagName=second.specifier.tagName.toUpperCase();
	if (first_tagName > second_tagName)
	{
		return 1;
	}
	else if (first_tagName < second_tagName)
	{
		return -1;
	}
	else
	{
		var first_id=first.specifier.id.toLowerCase();
		var second_id=second.specifier.id.toLowerCase();
		if (first_id > second_id)
		{
			return 1;
		}
		else if (first_id < second_id)
		{
			return -1;
		}
		else
		{
			var first_className=first.specifier.className.toLowerCase();
			var second_className=second.specifier.className.toLowerCase();
			if (first_className > second_className)
			{
				return 1;
			}
			else if (first_className < second_className)
			{
				return -1;
			}
			else
			{
				return 0;
			}
		}
	}
}
function RTE2_GetApplicableStyles(strBaseElementID, aParentChain, styleSelector)
{
	var appliciableStyles=new Array();
	var elem_tagName="";
	var elem_id="";
	var selectedElement=RTE2_GetSelectedElement(strBaseElementID);
	if (selectedElement !=null)
	{
		aParentChain=aParentChain.reverse();
		while (aParentChain.length > 0 && aParentChain[aParentChain.length-1] !=selectedElement)
		{
			aParentChain.pop();
		}
		aParentChain=aParentChain.reverse();
		elem_tagName=selectedElement.tagName;
		elem_id=selectedElement.id;
	}
	else
	{
		elem_tagName="FONT";
		elem_id="";
	}
	var targetTagNames=new Array(elem_tagName, "");
	var styleSelector_selectors=styleSelector.selectors;
	for (var i=0; i<targetTagNames.length; i++)
	{
		var specifierIndex=styleSelector.tagNameOffsets[targetTagNames[i]];
		if (specifierIndex !=null)
		{
			var whiteSpace=new RegExp("[ \t]+");
			var selector=styleSelector_selectors[specifierIndex];
			while (selector.specifier.tagName==targetTagNames[i])
			{
				var identifiersMatch=false;
				var qualifiersMatch=false;
				if (selector.specifier.id.length==0 || selector.specifier.id.toLowerCase()==elem_id.toLowerCase())
				{
					identifiersMatch=true;
				}
				if (selector.qualifiers.length==0)
				{
					qualifiersMatch=true;
				}
				else
				{
					var qualifierIndex=0;
					var finished=false;
					for (var j=1; j<aParentChain.length; j++)
					{
						var qualifier=selector.qualifiers[qualifierIndex];
						var parentElement=aParentChain[j];
						var qualifier_tagNamesMatch=false;
						var qualifier_identifiersMatch=false;
						var qualifier_classNamesMatch=false;
						if (qualifier.tagName.length==0 || qualifier.tagName==parentElement.tagName)
						{
							qualifier_tagNamesMatch=true;
						}
						if (qualifier.id.length==0 || qualifier.id==parentElement.id)
						{
							qualifier_identifiersMatch=true;
						}
						if (qualifier.className.length==0 || qualifier.className==parentElement.className)
						{
							qualifier_classNamesMatch=true;
						}
						else
						{
							if (parentElement.className.length > 0)
							{
								var parentClassNames=parentElement.className.split(whiteSpace);
								for (var k=0; k<parentClassNames.length; k++)
								{
									if (qualifier.className.toLowerCase()==parentClassNames[k].toLowerCase())
									{
										qualifier_classNamesMatch=true;
										break;
									}
								}
							}
						}
						if (qualifier_tagNamesMatch && qualifier_identifiersMatch && qualifier_classNamesMatch)
						{
							qualifierIndex++;
						}
						if (qualifierIndex >=selector.qualifiers.length)
						{
							qualifiersMatch=true;
							break;
						}
					}
				}
				if (identifiersMatch && qualifiersMatch)
				{
					appliciableStyles.push(styleSelector_selectors[specifierIndex]);
				}
				if (styleSelector_selectors.length==++specifierIndex)
				{
					break;
				}
				selector=styleSelector_selectors[specifierIndex];
			}
		}
	}
	return appliciableStyles;
}
var g_msRteReservedFontName="ms-rteReservedFontName";
function RTE2_ApplyCustomStyle(parameterText)
{
	if (parameterText==null || parameterText.length==0) {return;}
	var parameters=parameterText.split(",");
	if (parameters.length !=2) {return;}
	var strBaseElementID=parameters[0];
	var customStyleName=parameters[1];
	var selectedElement=RTE2_GetSelectedElement(strBaseElementID);
	if (selectedElement !=null && selectedElement.id !=strBaseElementID)
	{
		if (selectedElement.className !=customStyleName)
		{
			selectedElement.className=customStyleName;
		}
		else
		{
			selectedElement.className="";
		}
	}
	else
	{
		var textRange=RTE2_GetCurrentTextRange(strBaseElementID);
		if (textRange !=null)
		{
			textRange.execCommand("FontName", false, g_msRteReservedFontName);
			var reservedFontElements=RTE2_GetReservedFontElements(strBaseElementID);
			for (var i=0; i<reservedFontElements.length; i++)
			{
				var fontElement=reservedFontElements[i];
				if (fontElement !=null)
				{
					if ((fontElement.parentElement !=null) && (fontElement.parentElement.tagName=="SPAN") && (fontElement.parentElement.id==g_strRTE2ReusableFragmentCommonToken))
					{
						var parentElement=fontElement.parentElement;
						fontElement.outerHTML=fontElement.innerHTML;
						parentElement.outerHTML="<SPAN class=\""+customStyleName+"\">"+parentElement.outerHTML+"</SPAN>";
					}
					else
					{
						fontElement.removeAttribute("face");
						var spanElement=document.createElement("SPAN");
						spanElement.className=customStyleName;
						spanElement.innerHTML=fontElement.innerHTML;
						fontElement.outerHTML=spanElement.outerHTML;
					}
				}
			}
			if (reservedFontElements.length==1)
			{
				var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
				instanceVariables.selectedElement=reservedFontElements[0];
			}
		}
	}
}
function RTE2_GetReservedFontElements(strBaseElementID)
{
	var reservedFontElements=new Array();
	var editor=RTE_GetEditorDocument(strBaseElementID);
	var elements=RTE2_GetAllElements(editor);
	for (var i=0; i<elements.length; i++)
	{
		var currentElement=elements[i];
		if (currentElement.tagName=="FONT")
		{
			if (currentElement.face==g_msRteReservedFontName)
			{
				reservedFontElements.push(currentElement);
			}
		}
	}
	return reservedFontElements;
}
function RTE2_GenerateParagraphStylesToolBarButtonHtml(strBaseElementID, strWebLanguage)
{
	var strHtmlRet="";
	strHtmlRet+=RTE_TB_GenerateOpenCellButtonHtml(strBaseElementID, g_strRTEStylesMnemonic, "RTE2_DD_OpenParagraphStylesSelector('"+strBaseElementID+"' ,'"+strWebLanguage+"')");
	strHtmlRet+="<img src=\""+RTE_GetServerRelativeImageUrl("rte2paragraphformat.gif")+"\" alt=\""+L_ParagraphStylesToolTip_TEXT+"\" border=0"+g_strIconSizeAttributes+" align=\"absmiddle\" unselectable=\"on\">";
	strHtmlRet+="<img alt=\""+L_ParagraphStylesToolTip_TEXT+"\" src=\""+RTE_GetServerRelativeUnlocalizedImageUrl("menudark.gif")+"\" border=0 width=13 height=13 align=\"absmiddle\" unselectable=\"on\">";
	strHtmlRet+=RTE_TB_GenerateCloseCellButtonHtml();
	return strHtmlRet;
}
function RTE2_DD_OpenParagraphStylesSelector(strBaseElementID, strWebLanguage)
{
	var strMnemonic=g_strRTEStylesMnemonic;
	var rgoMenuInfo=RTE2_DD_GetParagraphStylesSelectorUnformattedHtml(strBaseElementID, strWebLanguage);
	var strMenuHtml=rgoMenuInfo[0];
	var cMenuItems=rgoMenuInfo[1];
	RTE_DD_OpenMenu(strBaseElementID, strMnemonic, strMenuHtml, strWebLanguage, cMenuItems);
}
function RTE2_DD_GetParagraphStylesSelectorUnformattedHtml(strBaseElementID, strWebLanguage)
{
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	var strMenuHtml=instanceVariables.menuHtml[g_strRTEStylesMnemonic];
	if (null !=strMenuHtml)
	{
		return strMenuHtml;
	}
	var strCommandToPerform=g_strRTEFormatBlockMnemonic;
	strMenuHtml=RTE_DD_GenerateMenuOpenHtml(strWebLanguage);
	var rgstrItemNames=RTE_GetBlockFormatNames();
	var restrictions=instanceVariables.restrictions;
	var cMenuItems=rgstrItemNames.length;
	var currentItem=0;
	for (var iItem=0; iItem < cMenuItems; iItem++)
	{
		if (RTE2_IsStyleAllowed(rgstrItemNames[iItem], restrictions))
		{
			strMenuHtml+=RTE2_DD_GenerateMenuItemHtmlWithSaveHtmlState(strBaseElementID, 1, currentItem, strCommandToPerform, rgstrItemNames[iItem],
						rgstrItemNames[iItem], "", strWebLanguage);
++currentItem;
		}
	}
	strMenuHtml+=RTE_DD_GenerateMenuCloseHtml();
	instanceVariables.menuHtml[g_strRTEStylesMnemonic]=new Array(strMenuHtml, currentItem);
	return instanceVariables.menuHtml[g_strRTEStylesMnemonic];
}
function RTE2_IsStyleAllowed(styleName, validationContext)
{
	if (styleName.indexOf("List") !=-1 || styleName.indexOf("Definition") !=-1)
	{
		return (validationContext.LISTS && validationContext.LISTS=="true");
	}
	else if (styleName.indexOf("Heading") !=-1 || styleName=="Address")
	{
		return (validationContext.HEADINGS && validationContext.HEADINGS=="true");
	}
	else if (styleName=="Formatted")
	{
		return (validationContext.TEXTMARKUP && validationContext.TEXTMARKUP=="true")
	}
	return true;
}
function RTE2_SpellCheck(strBaseElementID)
{
	var chunk=new Object();
	chunk.Html=RTE2_GetRichContent(strBaseElementID);
	chunk.Text=null;
	chunk.Id="HtmlPuEditor";
	chunk.DisplayName="Content";
	chunk.FieldType="Html";
	var features=SpellCheckerDialogFeaturesString();
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	var webUrl=instanceVariables.webUrl;
	var args=new Object();
	args.chunks=new Array(chunk);
	args.lang=L_Language_Text;
	args.webServiceUrl=decodeURI(webUrl)+"_vti_bin/SpellCheck.asmx";
	var callback=function(spelledChunks)
	{
		if (null !=spelledChunks && null !=spelledChunks[0] && null !=spelledChunks[0].Html)
		{
			RTE2_SetRichContent(strBaseElementID, spelledChunks[0].Html);
			RTE2_AddHtmlEditorTags(strBaseElementID);
		}
		RTE2_RestoreSelection(strBaseElementID);
	}
	var dialogUrl=RTE2_GetServerRelativeDialogUrl(strBaseElementID, "SpellChecker.aspx");
	RTE2_SaveSelection(strBaseElementID);
	commonShowModalDialog(dialogUrl, features, callback, args);
}
function RTE2_SaveButton(strBaseElementID)
{
	var onlySaveHtmlField=window.document.getElementById("onlySaveHtml");
	onlySaveHtmlField.value="true";
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	if (instanceVariables !=null)
	{
		instanceVariables.selectedElement=null;
	}
	RTE2_Callback();
}
function RTE2_GetRichContentForReturn(strBaseElementID)
{
	if (!RTE2_IsBrowserSupported())
	{
		return document.getElementById(strBaseElementID).value;
	}
	else
	{
		var htmlContainer=RTE2_GetEditorContainer(strBaseElementID);
		if (htmlContainer==null) return null;
		RTE2_RemoveHtmlEditorTagsFromElement(strBaseElementID, htmlContainer);
		return RTE2_GetRichContent(strBaseElementID);
	}
}
function RTE2_GetRichContent(strBaseElementID)
{
	if (!RTE2_IsBrowserSupported())
	{
		return document.getElementById(strBaseElementID).value;
	}
	else
	{
		var richContent="";
		if (RTE2_IsSourceView(strBaseElementID))
		{
			var sourceTextArea=RTE2_GetSourceEditorTextArea(strBaseElementID);
			if (sourceTextArea !=null)
			{
				richContent=sourceTextArea.value;
			}
		}
		else
		{
			var htmlContainer=RTE2_GetEditorContainer(strBaseElementID);
			richContent=htmlContainer.innerHTML;
		}
		if (richContent=="<DIV></DIV>")
		{
			richContent="";
		}
		return richContent;
	}
}
function RTE2_SetRichContent(strBaseElementID, newContent)
{
	if (!RTE2_IsBrowserSupported())
	{
		document.getElementById(strBaseElementID).value=newContent;
	}
	else
	{
		if ((null==newContent) || (0==newContent.length))
		{
			newContent="";
		}
		if (RTE2_IsSourceView(strBaseElementID))
		{
			var sourceTextArea=RTE2_GetSourceEditorTextArea(strBaseElementID);
			if (sourceTextArea !=null)
			{
				sourceTextArea.value=newContent;
			}
		}
		else
		{
			var htmlContainer=RTE2_GetEditorContainer(strBaseElementID);
			htmlContainer.innerHTML=newContent;
			RTE2_RemoveEditorPathFromUrls(strBaseElementID);
		}
	}
}
function RTE2_GetSourceContent(strBaseElementID)
{
	var sourceContent="";
	var sourceTextArea=RTE2_GetSourceEditorTextArea(strBaseElementID);
	if (sourceTextArea !=null)
	{
		sourceContent=sourceTextArea.value;
	}
	return sourceContent;
}
function RTE2_SetSourceContent(strBaseElementID, newSourceContent)
{
	var editor=RTE2_GetSourceEditorTextArea(strBaseElementID);
	if (editor !=null)
	{
		editor.value=newSourceContent;
	}
}
function RTE2_GenerateTableCellSizingToolBarButtonHtml(strBaseElementID, strWebLanguage)
{
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	instanceVariables.functions[g_strRTE2IncreaseTableColumnWidthFunction]=RTE2_IncreaseTableColumnWidth;
	instanceVariables.functions[g_strRTE2DecreaseTableColumnWidthFunction]=RTE2_DecreaseTableColumnWidth;
	instanceVariables.functions[g_strRTE2IncreaseTableRowHeightFunction]=RTE2_IncreaseTableRowHeight;
	instanceVariables.functions[g_strRTE2DecreaseTableRowHeightFunction]=RTE2_DecreaseTableRowHeight;
	instanceVariables.functions[g_strRTE2ModifyRowColSizeFunction]=RTE2_ModifyRowColSize;
	var strHtmlRet="";
	strHtmlRet+=RTE_TB_GenerateOpenCellButtonHtml(strBaseElementID, g_strRTE2TableCellSizingMnemonic, "RTE2_DD_OpenTableCellSizingSelector('"+strBaseElementID+"' ,'"+strWebLanguage+"')");
	strHtmlRet+="<img src=\""+RTE2_GetControlImage(g_strRTE2TableCellSizingMnemonic)+"\" alt=\""+L_TableCellSizingToolTip_TEXT+"\" border=0"+g_strIconSizeAttributes+"unselectable=\"on\">";
	strHtmlRet+="<img alt=\""+L_TableCellSizingToolTip_TEXT+"\" src=\""+RTE_GetServerRelativeUnlocalizedImageUrl("menudark.gif")+"\" border=0 width=13 height=13 unselectable=\"on\">";
	strHtmlRet+=RTE_TB_GenerateCloseCellButtonHtml();
	return strHtmlRet;
}
function RTE2_DD_OpenTableCellSizingSelector(strBaseElementID, strWebLanguage)
{
	var strMnemonic=g_strRTE2TableCellSizingMnemonic;
	var rgoMenuInfo=RTE2_DD_GetTableCellSizingSelectorUnformattedHtml(strBaseElementID, strWebLanguage);
	var strMenuHtml=rgoMenuInfo[0];
	var cMenuItems=rgoMenuInfo[1];
	RTE_DD_OpenMenu(strBaseElementID, strMnemonic, strMenuHtml, strWebLanguage, cMenuItems);
}
function RTE2_DD_GetTableCellSizingSelectorUnformattedHtml(strBaseElementID, strWebLanguage)
{
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	var strMenuHtml=instanceVariables.menuHtml[g_strRTE2TableCellSizingMnemonic];
	if (null !=strMenuHtml)
	{
		return strMenuHtml;
	}
	strMenuHtml=RTE_DD_GenerateMenuOpenHtml(strWebLanguage);
	strMenuHtml+="<td unselectable='on'><table unselectable='on'><tr unselectable='on'>"
	var iItem=0;
	strMenuHtml+=RTE2_DD_GenerateMenuItemScriptHtmlWithSaveHtmlState(
		strBaseElementID,
		5,
		iItem,
		g_strRTE2IncreaseTableColumnWidthFunction,
		strBaseElementID,
		"<img alt=\""+L_IncreaseTableColumnWidthToolTip_TEXT+"\" src=\""+RTE2_GetControlImage(g_strRTE2IncreaseTableColumnWidthFunction)+"\" border=0 "+g_strIconSizeAttributes+" unselectable='on' >",
		"", strWebLanguage);
	iItem=1;
	strMenuHtml+=RTE2_DD_GenerateMenuItemScriptHtmlWithSaveHtmlState(
		strBaseElementID,
		5,
		iItem,
		g_strRTE2DecreaseTableColumnWidthFunction,
		strBaseElementID,
		"<img alt=\""+L_DecreaseTableColumnWidthToolTip_TEXT+"\" src=\""+RTE2_GetControlImage(g_strRTE2DecreaseTableColumnWidthFunction)+"\" border=0 "+g_strIconSizeAttributes+" unselectable='on' >",
		"", strWebLanguage);
	iItem=2;
	strMenuHtml+=RTE2_DD_GenerateMenuItemScriptHtmlWithSaveHtmlState(
		strBaseElementID,
		5,
		iItem,
		g_strRTE2IncreaseTableRowHeightFunction,
		strBaseElementID,
		"<img alt=\""+L_IncreaseTableRowHeightToolTip_TEXT+"\" src=\""+RTE2_GetControlImage(g_strRTE2IncreaseTableRowHeightFunction)+"\" border=0 "+g_strIconSizeAttributes+" unselectable='on' >",
		"", strWebLanguage);
	iItem=3;
	strMenuHtml+=RTE2_DD_GenerateMenuItemScriptHtmlWithSaveHtmlState(
		strBaseElementID,
		5,
		iItem,
		g_strRTE2DecreaseTableRowHeightFunction,
		strBaseElementID,
		"<img alt=\""+L_DecreaseTableRowHeightToolTip_TEXT+"\" src=\""+RTE2_GetControlImage(g_strRTE2DecreaseTableRowHeightFunction)+"\" border=0 "+g_strIconSizeAttributes+" unselectable='on' >",
		"", strWebLanguage);
	strMenuHtml+="</tr></table></td></tr><tr>"
	iItem=4;
	strMenuHtml+=RTE2_DD_GenerateMenuItemScriptHtmlWithSaveHtmlState(
		strBaseElementID,
		1,
		iItem,
		g_strRTE2ModifyRowColSizeFunction,
		strBaseElementID,
		"<font style=\"text-align:center;\" unselectable='on'>"+L_ModifyRowColSizeLabel_TEXT+"</font>",
		L_ModifyRowColSizeToolTip_TEXT, strWebLanguage);
	strMenuHtml+=RTE_DD_GenerateMenuCloseHtml();
	instanceVariables.menuHtml[g_strRTE2TableCellSizingMnemonic]=new Array(strMenuHtml, 4);
	return instanceVariables.menuHtml[g_strRTE2TableCellSizingMnemonic];
}
function RTE2_DecreaseTableColumnWidth(parameterText)
{
	if (parameterText==null || parameterText.length==0) {return;}
	var strBaseElementID=parameterText;
	var widthAdjustment=-10;
	RTE2_AdjustTableColumnWidth(strBaseElementID, widthAdjustment, true);
}
function RTE2_IncreaseTableColumnWidth(parameterText)
{
	if (parameterText==null || parameterText.length==0) {return;}
	var strBaseElementID=parameterText;
	var widthAdjustment=10;
	RTE2_AdjustTableColumnWidth(strBaseElementID, widthAdjustment, true);
}
function RTE2_DecreaseTableRowHeight(parameterText)
{
	if (parameterText==null || parameterText.length==0) {return;}
	var strBaseElementID=parameterText;
	var heightAdjustment=-10;
	RTE2_AdjustTableRowHeight(strBaseElementID, heightAdjustment, true);
}
function RTE2_IncreaseTableRowHeight(parameterText)
{
	if (parameterText==null || parameterText.length==0) {return;}
	var strBaseElementID=parameterText;
	var heightAdjustment=10;
	RTE2_AdjustTableRowHeight(strBaseElementID, heightAdjustment, true);
}
function RTE2_ModifyRowColSize(strBaseElementID)
{
	var targetTableCell=RTE_GetNearestContainingElementOfTypes(strBaseElementID, g_aTableCellTagNames);
	if (targetTableCell==null) {return;}
	var table=RTE_GetNearestContainingElementOfType(strBaseElementID, "TABLE");
	if (table==null) return;
	var dialogArguments=new Object();
	dialogArguments["table"]=table;
	dialogArguments["targetTableCell"]=targetTableCell;
	dialogArguments["tableBorderVisible"]=RTE2_ShouldTableBordersBeVisible(strBaseElementID);
	var dialogUrl=RTE2_GetServerRelativeDialogUrl(strBaseElementID, "RTE2ERowColSize.aspx");
	commonShowModalDialog(dialogUrl, "resizable: yes; help: no; status:off;scroll:off;dialogHeight:250px;dialogWidth:450px", null, dialogArguments);
}
function RTE2_AdjustTableColumnWidth(strBaseElementID, widthAdjustment, isPercentage)
{
	var targetCell=RTE_GetNearestContainingElementOfTypes(strBaseElementID, g_aTableCellTagNames);
	if (targetCell==null) {return;}
	var table=RTE_GetNearestContainingParentElementOfType(strBaseElementID, targetCell, "TABLE");
	if (table==null) {return;}
	var spanGrid=RTE_GenerateSpanGridUpToTarget(table, targetCell);
	if (RTE2_AreTableBordersVisible(strBaseElementID))
	{
		RTE2_ConvertTableToOriginalBorder(table);
	}
	if (isPercentage==true)
	{
		var widthInfo=RTE2_GetColWidth(table, targetCell, spanGrid);
		widthAdjustment=Math.round(widthInfo.px * (widthAdjustment/100));
	}
	RTE2_AdjustTableCellWidths(table, targetCell, spanGrid, widthAdjustment);
	if (RTE2_ShouldTableBordersBeVisible(strBaseElementID))
	{
		RTE2_ConvertTableShowBorder(table);
	}
}
function RTE2_AdjustTableRowHeight(strBaseElementID, heightAdjustment, isPercentage)
{
	var targetCell=RTE_GetNearestContainingElementOfTypes(strBaseElementID, g_aTableCellTagNames);
	if (targetCell==null) {return;}
	var table=RTE_GetNearestContainingParentElementOfType(strBaseElementID, targetCell, "TABLE");
	if (table==null) {return;}
	var spanGrid=RTE_GenerateSpanGridUpToTarget(table, targetCell);
	if (RTE2_AreTableBordersVisible(strBaseElementID))
	{
		RTE2_ConvertTableToOriginalBorder(table);
	}
	if (isPercentage==true)
	{
		var heightInfo=RTE2_GetRowHeight(table, targetCell, spanGrid);
		heightAdjustment=Math.round(heightInfo.px * (heightAdjustment/100));
	}
	RTE2_AdjustTableCellHeights(table, targetCell, spanGrid, heightAdjustment);
	if (RTE2_ShouldTableBordersBeVisible(strBaseElementID))
	{
		RTE2_ConvertTableShowBorder(table);
	}
}
function RTE2_GetRowHeight(table, targetCell)
{
	var rowHeightInfo=RTE2_GetCellHeightInfo(table, targetCell);
	if (rowHeightInfo.value==null)
	{
		rowHeightInfo=RTE2_GetMaxRowHeight(table, targetCell);
	}
	return rowHeightInfo;
}
function RTE2_GetColWidth(table, targetCell, spanGrid)
{
	var colWidthInfo=RTE2_GetCellWidthInfo(table, targetCell);
	if (colWidthInfo.value==null)
	{
		colWidthInfo=RTE2_GetMaxColWidth(table, targetCell, spanGrid);
	}
	return colWidthInfo;
}
function RTE2_GetMaxColWidth(table, targetCell, spanGrid)
{
	var maxInfo=new Object();
	maxInfo.px=0;
	maxInfo.unit="px";
	maxInfo.value="";
	for (var rowIndex=0; rowIndex < spanGrid.columns[spanGrid.targetCellColSpanIndex].cells.length; rowIndex++)
	{
		var currentSpanInfo=spanGrid.columns[spanGrid.targetCellColSpanIndex].cells[rowIndex];
		if (currentSpanInfo !=null
			&& currentSpanInfo.colSpanIndex==spanGrid.targetCellColSpanIndex
			&& currentSpanInfo.cell.colSpan==targetCell.colSpan)
		{
			var cellWidthInfo=RTE2_GetCellWidthInfo(table, currentSpanInfo.cell);
			if (cellWidthInfo.px > maxInfo.px)
			{
				maxInfo=cellWidthInfo;
			}
		}
	}
	if (maxInfo.value==null)
	{
		maxInfo.value=maxInfo.px;
		maxInfo.unit="px";
	}
	return maxInfo;
}
function RTE2_GetMaxRowHeight(table, targetCell)
{
	var targetRow=targetCell.parentNode;
	var maxInfo=new Object();
	maxInfo.px=0;
	maxInfo.unit="px";
	maxInfo.value="";
	for (var colIndex=0; colIndex<targetRow.cells.length; colIndex++)
	{
		var currentCell=targetRow.cells[colIndex];
		if (currentCell.rowSpan==targetCell.rowSpan)
		{
			var cellHeightInfo=RTE2_GetCellHeightInfo(table, currentCell);
			if (cellHeightInfo.px > maxInfo.px)
			{
				maxInfo=cellHeightInfo;
			}
		}
	}
	if (maxInfo.value==null)
	{
		maxInfo.value=maxInfo.px;
		maxInfo.unit="px";
	}
	return maxInfo;
}
function RTE2_GetCellWidth(table, cell)
{
	var padding=parseInt(table.cellPadding);
	if (isNaN(padding)) padding=1;
	var leftPadding=padding;
	if (cell.style.paddingLeft !="")
	{
		leftPadding=RTE2_RemoveUnitSpecifier(cell.style.paddingLeft);
		if (RTE2_GetUnitSpecifier(cell.style.paddingLeft)=="%")
		{
			leftPadding=Math.round(cell.clientWidth * leftPadding / 100);
		}
	}
	var rightPadding=padding;
	if (cell.style.paddingRight !="")
	{
		rightPadding=RTE2_RemoveUnitSpecifier(cell.style.paddingRight);
		if (RTE2_GetUnitSpecifier(cell.style.paddingRight)=="%")
		{
			rightPadding=Math.round(cell.clientWidth * rightPadding / 100);
		}
	}
	return cell.clientWidth - leftPadding - rightPadding;
}
function RTE2_GetCellWidthInfo(table, cell)
{
	var cellWidthInfo=new Object();
	cellWidthInfo.value=RTE2_RemoveUnitSpecifier(cell.width);
	cellWidthInfo.unit=RTE2_GetUnitSpecifier(cell.width);
	cellWidthInfo.px=RTE2_GetCellWidth(table, cell);
	return cellWidthInfo;
}
function RTE2_GetCellHeight(table, cell)
{
	var padding=parseInt(table.cellPadding, 10);
	if (isNaN(padding)) padding=1;
	var topPadding=padding;
	if (cell.style.paddingTop !="")
	{
		topPadding=RTE2_RemoveUnitSpecifier(cell.style.paddingTop);
		if (RTE2_GetUnitSpecifier(cell.style.paddingTop)=="%")
		{
			topPadding=Math.round(cell.clientHeight * topPadding / 100);
		}
	}
	var bottomPadding=padding;
	if (cell.style.paddingBottom !="")
	{
		bottomPadding=RTE2_RemoveUnitSpecifier(cell.style.paddingBottom);
		if (RTE2_GetUnitSpecifier(cell.style.paddingBottom)=="%")
		{
			bottomPadding=Math.round(cell.clientHeight * bottomPadding / 100);
		}
	}
	return cell.clientHeight - topPadding - bottomPadding;
}
function RTE2_GetCellHeightInfo(table, cell)
{
	var cellHeightInfo=new Object();
	cellHeightInfo.value=RTE2_RemoveUnitSpecifier(cell.height);
	cellHeightInfo.unit=RTE2_GetUnitSpecifier(cell.height);
	cellHeightInfo.px=RTE2_GetCellHeight(table, cell);
	return cellHeightInfo;
}
function RTE2_AdjustTableCellWidths(table, targetCell, spanGrid, widthAdjustment)
{
	var targetColSpanIndex=spanGrid.targetCellColSpanIndex;
	var targetColSpanLength=targetCell.colSpan;
	var targetColumn=spanGrid.columns[targetColSpanIndex+targetColSpanLength - 1];
	var tableCellAdjustments=new Array();
	for (var j=0; j<targetColumn.cells.length; j++)
	{
		var cellSpanInfo=targetColumn.cells[j];
		if (cellSpanInfo !=null)
		{
			var currentWidth=RTE2_GetCellWidth(table, cellSpanInfo.cell);
			var newWidthPx=currentWidth+widthAdjustment;
			var tableCellAdjustment=new Object();
			tableCellAdjustment.tableCell=cellSpanInfo.cell;
			tableCellAdjustment.newWidth=newWidthPx;
			tableCellAdjustments.push(tableCellAdjustment);
		}
	}
	for (i=0; i<tableCellAdjustments.length; i++)
	{
		var tableCellAdjustment=tableCellAdjustments[i];
		if (tableCellAdjustment.newWidth > 0)
		{
			tableCellAdjustment.tableCell.width=tableCellAdjustment.newWidth;
		}
		else
		{
			tableCellAdjustment.tableCell.width=null;
		}
	}
}
function RTE2_AdjustTableCellHeights(table, targetCell, spanGrid, heightAdjustment)
{
	var targetRowSpanIndex=targetCell.parentNode.rowIndex;
	var targetRowSpanLength=targetCell.rowSpan;
	var targetRowAdjustIndex=targetRowSpanIndex+targetRowSpanLength - 1;
	var tableCellAdjustments=new Array();
	for (var j=0; j<spanGrid.columns.length; j++)
	{
		var rowCellInfo=spanGrid.columns[j].cells[targetRowAdjustIndex];
		if (rowCellInfo !=null)
		{
			var currentHeight=RTE2_GetCellHeight(table, rowCellInfo.cell);
			var newHeight=currentHeight+heightAdjustment;
			var tableCellAdjustment=new Object();
			tableCellAdjustment.tableCell=rowCellInfo.cell;
			tableCellAdjustment.newHeight=newHeight;
			tableCellAdjustments.push(tableCellAdjustment);
		}
	}
	for(i=0; i<tableCellAdjustments.length; i++)
	{
		var tableCellAdjustment=tableCellAdjustments[i];
		if (tableCellAdjustment.newHeight > 0)
		{
			tableCellAdjustment.tableCell.height=tableCellAdjustment.newHeight;
		}
		else
		{
			tableCellAdjustment.tableCell.height=null;
		}
	}
}
function RTE2_SetTableCellWidths(table, targetCell, spanGrid, newWidth)
{
	var targetColSpanIndex=spanGrid.targetCellColSpanIndex;
	var targetColSpanLength=targetCell.colSpan;
	var targetColumn=spanGrid.columns[targetColSpanIndex];
	for (var j=0; j<targetColumn.cells.length; j++)
	{
		var cellSpanInfo=targetColumn.cells[j];
		if (cellSpanInfo !=null && cellSpanInfo.cell.colSpan==targetColSpanLength)
		{
			cellSpanInfo.cell.width=newWidth;
		}
	}
}
function RTE2_SetTableCellHeights(table, targetCell, spanGrid, newHeight)
{
	var targetRow=targetCell.parentNode;
	var targetRowSpanIndex=targetRow.rowIndex;
	var targetRowSpanLength=targetCell.rowSpan;
	for (var j=0; j<targetRow.cells.length; j++)
	{
		var rowCell=targetRow.cells[j];
		if (rowCell.rowSpan==targetRowSpanLength)
		{
			rowCell.height=newHeight;
		}
	}
}
function RTE2_GetControlImage(imageID)
{
	switch (imageID)
	{
		case g_strRTE2CustomStylesMnemonic :
			imageName="rte2custstyles.gif";
			RTE_GetServerRelativeImageUrl(imageName);
			break;
		case g_strRTE2TableCellSizingMnemonic : imageName="rte2cellresize.gif"; break;
		case g_strRTE2IncreaseTableColumnWidthFunction : imageName="rte2incwidth.gif"; break;
		case g_strRTE2DecreaseTableColumnWidthFunction : imageName="rte2decwidth.gif"; break;
		case g_strRTE2IncreaseTableRowHeightFunction : imageName="rte2incheight.gif"; break;
		case g_strRTE2DecreaseTableRowHeightFunction : imageName="rte2decheight.gif"; break;
		case g_strRTE2OnPasteMnemonic : imageName="paste.gif"; break;
	}
	return RTE_GetServerRelativeUnlocalizedImageUrl(imageName);
}
function RTE2_GetAllElements(element)
{
	var allElements=new Array();
	var element_all=element.all;
	if (element_all !=null)
	{
		var element_all_length=element_all.length;
		for (var i=0; i<element_all_length; i++)
		{
			allElements.push(element_all[i]);
		}
	}
	return allElements;
}
function RTE2_GetSpecifiedAttributes(element)
{
	var specifiedAttributes=new Array();
	var element_attributes=element.attributes;
	var element_attributes_length=element_attributes.length;
	for (var i=0; i<element_attributes_length; i++)
	{
		if (element_attributes[i].specified)
		{
			specifiedAttributes.push(element_attributes[i]);
		}
	}
	return specifiedAttributes;
}
function RTE2_InsertOrChangeReusableText(strBaseElementID)
{
	var docEditor=RTE_GetEditorDocument(strBaseElementID);
	if (docEditor==null) return;
	RTE_RestoreSelection(strBaseElementID);
	var configObj=new AssetPickerConfig("");
	configObj.ClientID=strBaseElementID;
	configObj.DefaultAssetLocation="";
	configObj.CurrentWebBaseUrl=RTE2_GetDialogParameter(strBaseElementID, "CurrentWebBaseUrl");
	configObj.AllowExternalUrls=RTE2_ShouldAllowExternalUrls(strBaseElementID);
	var bInserting=false;
	var elemToReplace=null;
	var fragmentId=null;
	var elemViewToEdit=RTE_GetNearestContainingElementOfType(strBaseElementID, "SPAN");
	if ((elemViewToEdit !=null) && (elemViewToEdit.id==g_strRTE2ReusableFragmentCommonToken))
	{
		fragmentId=elemViewToEdit.getAttribute("fragmentid");
	}
	var dialogInput=new Object();
	dialogInput.fragmentId=fragmentId;
	var callback=function(dialogOutput)
	{
		if ((dialogOutput !=null) && (dialogOutput.fragmentView !=null))
		{
			var selection=RTE_GetCurrentSelection(strBaseElementID);
			if (selection !=null)
			{
				if (selection.type=="Control")
				{
					var controlRange=selection.createRange();
					if (controlRange !=null)
					{
						controlRange.execCommand("Delete");
					}
				}
				if (selection.type !="Control")
				{
					var textRange=selection.createRange();
					if (textRange !=null)
					{
		                var safeHtmlDocument=RTE2_GetSafeHtmlDocument(strBaseElementID);
		                if (safeHtmlDocument==null) return;
		                safeHtmlDocument.body.innerHTML=dialogOutput.fragmentView;
		                var elements=RTE2_GetAllElements(safeHtmlDocument);
		                var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
		                RTE2_ApplyContentFilters(elements, instanceVariables);
						textRange.pasteHTML(safeHtmlDocument.body.innerHTML);
						RTE2_AddHtmlEditorTags(strBaseElementID);
					}
				}
			}
		}
	};
	var dialogUrl=RTE2_GetServerRelativeDialogUrl(strBaseElementID, "ReusableTextPicker.aspx");
	commonShowModalDialog(dialogUrl, "dialogHeight:600px; dialogWidth:800px; center:yes; resizable:yes; scroll:no; status:no;", callback, dialogInput);
	RTE_GiveEditorFocus(strBaseElementID);
}
function RTE2_ConvertViewHtmlToStorageHtml(viewHtml)
{
	var temporaryDiv=document.createElement("div");
	temporaryDiv.innerHTML=viewHtml;
	RTE2_RemoveEditorPathFromUrlsInElement(temporaryDiv);
	var fragmentIds=new Array();
	RTE2_ConvertViewHtmlToStorageHtml_Inner(temporaryDiv, fragmentIds);
	var header="";
	if (fragmentIds.length > 0)
	{
		header="<div id=\""+g_strRTE2ReusableFragmentCommonToken+"IdSection\">";
		var index;
		for (index=0; index < fragmentIds.length; index++)
		{
			var fragmentId=fragmentIds[index];
			if (fragmentId !=null)
			{
				header+="<a href=\""+STSHtmlEncode(fragmentId)+"\">a</a>";
			}
		}
		header+="</div>";
	}
	var storageHtml=header+temporaryDiv.innerHTML;
	return storageHtml;
}
function RTE2_ConvertViewHtmlToStorageHtml_Inner(topElement, fragmentIds)
{
	var elements=RTE2_GetAllElements(topElement);
	for (var i=0; i < elements.length;++i)
	{
		var element=elements[i];
		if (element==null)
			continue;
		if (element.id==g_strRTE2ReusableFragmentCommonToken)
		{
			var fragmentId=element.getAttribute("fragmentid");
			if (fragmentId !=null)
			{
				fragmentIds.push(fragmentId);
				element.outerHTML="<"+element.tagName+" id=\""+element.id+"\"></"+element.tagName+">";
			}
			else
			{
				element.removeAttribute("id", false);
			}
		}
	}
}
function RTE2_AlterReusableFragmentHighlights(topElement, newClassName)
{
	var elements=RTE2_GetAllElements(topElement);
	for (var i=0; i < elements.length;++i)
	{
		var element=elements[i];
		if (null !=element && element.id==g_strRTE2ReusableFragmentCommonToken)
		{
			element.className=newClassName;
			RTE2_SetReusableTextFragmentSizes(element);
		}
	}
}
function RTE2_SetReusableTextFragmentSizes(element)
{
	element.onresizestart=RTE2_StopReusableTextFragmentResizes;
	element.contentEditable=false;
	var childIndex;
	for (childIndex=0; childIndex < element.children.length; childIndex++)
	{
		RTE2_SetReusableTextFragmentSizes(element.children[childIndex]);
	}
}
function RTE2_DisplayElementFromInputElement(inputElementId)
{
	var displayContentId=inputElementId.replace(/\$/g, "_");
	displayContentId+="_displayContent";
	var displayContentWrapper=document.getElementById(displayContentId);
	return displayContentWrapper;
}
function RTE2_HiddenDisplayElementFromInputElement(inputElementId)
{
	var displayContentId=inputElementId.replace(/\$/g, "_");
	displayContentId+="_hiddenDisplay";
	var displayContentWrapper=document.getElementById(displayContentId);
	return displayContentWrapper;
}
function RTE2_GetExtension(szHref)
{
	var sz=new String(szHref);
	var re=/^.*\.([^\.]*)$/;
	return sz.replace(re, "$1").toLowerCase();
}
function RTE2_EditSource(sourceDocumentUrl, sourceDocumentProgId)
{
	try
	{
		if (RTE2_GetExtension(sourceDocumentUrl)=="xml")
		{
			o=new ActiveXObject("SharePoint.OpenXMLDocuments");
		}
		else
		{
			o=new ActiveXObject("SharePoint.OpenDocuments.2");
		}
	}
	catch (e)
	{
		var w=window.open(sourceDocumentUrl);
		w.focus();
		return;
	}
	if (o)
	{
		o.EditDocument2(window, sourceDocumentUrl, sourceDocumentProgId);
	}
}
function RTE2_RepublishSource(confirmationMessage, postBackScript)
{
	if (confirm(confirmationMessage))
	{
		eval(postBackScript);
	}
}
function RTE2_GenerateLaunchArguments(parameterArray, webUrl, containerID)
{
	var args=new Object();
	args.parameters=parameterArray;
	if (webUrl.charAt(webUrl.length - 1) !="/")
	{
		webUrl+="/";
	}
	args.webUrl=webUrl;
	var styleRules=new Array();
	var styleRulesUrl=new Array();
	for (var i=0; i<document.styleSheets.length; i++)
	{
		var styleSheet_href=document.styleSheets[i].href;
		if (styleSheet_href !="")
		{
			styleRulesUrl[styleRulesUrl.length]=styleSheet_href;
		}
		else
		{
			var rules=document.styleSheets[i].rules;
			for (var j=0; j<rules.length; j++)
			{
				styleRules[styleRules.length]=rules[j];
			}
		}
	}
	args.styleRules=styleRules;
	args.styleRulesUrl=styleRulesUrl;
	args.classNames="";
	elem=document.getElementById(containerID);
	if (elem !=null)
	{
		var controlWrapper=RTE2_GetControlWrapper(elem);
		args.currentStyle=controlWrapper.currentStyle;
		var currentElem=controlWrapper;
		while(currentElem !=null)
		{
			if (currentElem.className)
			{
				args.classNames=currentElem.className+" "+args.classNames;
			}
			currentElem=currentElem.parentNode;
		}
	}
	return args;
}
function RTE2_PageLoadScript(clientId)
{
	if (!RTE2_IsBrowserSupported()) return;
	var displayContentElement=document.getElementById(clientId+"_displayContent");
	displayContentElement.designMode="on";
	displayContentElement.contentEditable=true;
	var emptyPanel=document.getElementById(clientId+"_EmptyHtmlPanel");
	if (emptyPanel.children.length==3)
	{
		var emptyChildren=emptyPanel.children[1];
		emptyChildren.designMode="on";
		emptyChildren.contentEditable=true;
	}
	var controlWrapper=RTE2_GetControlWrapper(displayContentElement);
	controlWrapper.style.display="inline-block";
	var findForm=displayContentElement;
	while (findForm.tagName!="FORM" && findForm.tagName!="WINDOW")
	{
		findForm=findForm.parentElement;
	}
	findForm.attachEvent("onsubmit",new Function("RTE2_TransferContentsToTextArea('"+clientId+"');"));
}
function RTE2_LaunchEditor(parameterArray, clientId, displayPanelClientId, emptyPanelClientId, hiddenInputFieldId, webUrl, popupMode, sourceMode, fromInlineMode)
{
	parameterArray[parameterArray.length]=new Array('Lcid', L_Language_Text);
	parameterArray[parameterArray.length]=new Array('Dir', '');
	var args=RTE2_GenerateLaunchArguments(parameterArray, webUrl, clientId+"_container");
	var displayPanel=document.getElementById(displayPanelClientId);
	var emptyPanel=document.getElementById(emptyPanelClientId);
	var hiddenInputField=document.getElementById(hiddenInputFieldId);
	var hiddenFieldInDisplayFormat=document.getElementById(clientId+"_hiddenDisplay")
	var displayContentElement=document.getElementById(clientId+"_displayContent")
	var statusBar=document.getElementById(clientId+"_StatusBar");
	args.innerHTML=displayContentElement.innerHTML;
	args.clientId=clientId;
	args.displayPanel=displayPanel;
	args.emptyPanel=emptyPanel;
	args.hiddenInputField=hiddenInputField;
	args.hiddenFieldInDisplayFormat=hiddenFieldInDisplayFormat;
	args.displayContentElement=displayContentElement;
	args.statusBar=statusBar;
	args.fromInlineMode=fromInlineMode;
	if (RTE2_IsBrowserSupported())
	{
		args.popupMode=popupMode;
		args.sourceMode=sourceMode;
	}
	else
	{
		args.popupMode='True';
		args.sourceMode=true;
	}
	if (args.popupMode=='True')
	{
		var callback=function(newHtmlArray)
		{
			RTE2_SaveHtml(displayPanel, emptyPanel, hiddenInputField, hiddenFieldInDisplayFormat, displayContentElement, statusBar, newHtmlArray, fromInlineMode);
		};
		RTE2_LaunchEditorDialog(args, callback);
	}
	else
	{
		RTE2_LaunchEditorInline(args);
	}
}
function WP_LaunchAlternativeRichTextEditor(args)
{
	if (!RTE2_IsBrowserSupported())
	{
		alert(L_InvalidBrowser_TEXT);
		return;
	}
	var params=new Array();
	params[params.length]=new Array('ValidationContext', 'FONTS=true\u0026REUSABLECONTENT=false\u0026HEADINGS=true\u0026HYPERLINKS=true\u0026IMAGES=true\u0026LISTS=true\u0026TABLES=true\u0026TEXTMARKUP=true\u0026ISREQUIRED=false\u0026RESTRICTURLSTOSITECOLLECTION=false\u0026');
	var currentWebBaseUrl=args.webUrl;
	if (currentWebBaseUrl.charAt(currentWebBaseUrl.length - 1)=='/')
	{
		currentWebBaseUrl=currentWebBaseUrl.substring(0,currentWebBaseUrl.length - 1);
	}
	params[params.length]=new Array('CurrentWebBaseUrl', currentWebBaseUrl);
	params[params.length]=new Array('DefaultAssetLocation', '');
	params[params.length]=new Array('DefaultAssetImageLocation', '');
	params[params.length]=new Array('AllowHtmlSourceEditing', 'True');
	params[params.length]=new Array('EnableExtensions', 'True');
	params[params.length]=new Array('DisableCustomStyles', 'False');
	params[params.length]=new Array('DisableBasicFormattingButtons', 'False');
	params[params.length]=new Array('PrefixStyleSheet', 'ms-rte');
	params[params.length]=new Array('EditorOpenFromWebPart', 'True');
	params[params.length]=new Array('Lcid', args.lcid);
	if (!args.webPart.Properties.PropertiesLoaded)
		args.webPart.Properties.LoadProperties();
	var dir="";
	for (var i=0; i< args.webPart.Properties.length; i++)
	{
		if (args.webPart.Properties[i].SchemaElement=="Dir")
			dir=args.webPart.Properties[i].Value;
	}
	params[params.length]=new Array('Dir', WP_ConvertStrDir(dir));
	var dialogArguments=RTE2_GenerateLaunchArguments(params, args.webUrl, args.webPart.DOMObject.id);
	dialogArguments.innerHTML=args.html;
	dialogArguments.popupMode='True';
	var elem=args.webPart.DOMObject;
	while (elem.currentStyle.backgroundColor=="transparent")
	{
		elem=elem.parentElement;
	}
	if (elem !=null)
	{
		params[params.length]=new Array('EditorBackgroundColor', elem.currentStyle.backgroundColor);
	}
	else
	{
		params[params.length]=new Array('EditorBackgroundColor', '');
	}
	var callback=function(newHtmlArray)
	{
		if (newHtmlArray !=null)
		{
			args.html=newHtmlArray[0];
			WP_SaveHtml(args);
		}
	};
	RTE2_LaunchEditorDialog(dialogArguments, callback);
}
function WP_ConvertStrDir(dir)
{
	if (dir=="RightToLeft") return "rtl";
	if (dir=="LeftToRight") return "ltr";
	return "";
}
function RTE2_LaunchEditorDialog(args, callback)
{
	var fullUrl=args.webUrl+"_layouts/RTE2PUEditor.aspx";
	commonShowModalDialog(fullUrl, "help:no;dialogHeight:550px;dialogWidth:750px;resizable:yes;status:off;scroll:off;", callback, args);
}
function RTE2_LaunchEditorInline(args)
{
	var strBaseElementID=args.displayContentElement.id;
	if (RTE2_IsEditorLoaded(strBaseElementID))
	{
		var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
		RTE2_StartEditor(strBaseElementID, instanceVariables);
		return;
	}
	RTE2_InitializeEditor(strBaseElementID, args);
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	RTE2_ConvertToRichEdit(strBaseElementID, instanceVariables.displayPanel);
	var docEditor=RTE_GetEditorDocument(strBaseElementID);
	RTE2_FinalizeEditor(strBaseElementID, docEditor, instanceVariables);
}
function RTE2_InitializeEditor(strBaseElementID, args)
{
	var aSettings=null;
	var strDirection='';
	var lcid=L_Language_Text;
	if (args !=null)
	{
		if (args.parameters !=null)
		{
			aSettings=args.parameters;
			for (var i=0;i< aSettings.length;i++)
			{
				var dictionaryItem=aSettings[i];
				if (dictionaryItem[0]=="Dir")
				{
					strDirection=dictionaryItem[1];
				}
				else if (dictionaryItem[0]=="Lcid")
				{
					lcid=dictionaryItem[1];
				}
			}
		}
		RTE_InitializeExtendedRichTextSupport(strBaseElementID);
		var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
		if (instanceVariables !=null)
		{
			instanceVariables.webUrl=args.webUrl;
			instanceVariables.strDirection=strDirection;
			instanceVariables.lcid=lcid;
			instanceVariables.aSettings=aSettings;
			instanceVariables.displayPanel=args.displayPanel;
			instanceVariables.emptyPanel=args.emptyPanel;
			instanceVariables.hiddenInputField=args.hiddenInputField;
			instanceVariables.hiddenFieldInDisplayFormat=args.hiddenFieldInDisplayFormat;
			instanceVariables.displayContentElement=args.displayContentElement;
			instanceVariables.statusBar=args.statusBar;
			instanceVariables.popupMode=args.popupMode;
			instanceVariables.sourceMode=args.sourceMode;
			instanceVariables.clientId=args.clientId;
			instanceVariables.fromInlineMode=args.fromInlineMode;
		}
		RTE2_InitializeInstanceVariables(instanceVariables);
	}
	RTE2_InstantiateStaticSafeHtmlRules();
}
function RTE2_FinalizeEditor(strBaseElementID, docEditor, instanceVariables)
{
	docEditor.body.setAttribute(g_strRTEWebLocaleAttributeName, instanceVariables.lcid);
	g_rgstrRTEAllEditorsInThePage[g_rgstrRTEAllEditorsInThePage.length]=strBaseElementID;
	var buttons=RTE2_GetToolBarDefinition(strBaseElementID);
	for (var i=0; i < buttons.length; i++)
	{
		if (buttons[i].strMnemonic !=undefined)
		{
			var btn=RTE_TB_GetToolBarButton(strBaseElementID, buttons[i].strMnemonic);
			btn.toolbarButtonIndex=i;
			btn.strBaseElementID=strBaseElementID;
		}
	}
	RTE2_StartEditor(strBaseElementID, instanceVariables);
}
function RTE2_StartEditor(strBaseElementID, instanceVariables)
{
	if (!RTE2_PopupMode(strBaseElementID))
	{
		instanceVariables.displayPanel.onkeydown=null;
		instanceVariables.displayPanel.onclick=null;
		instanceVariables.displayPanel.ondragenter=null;
		instanceVariables.displayPanel.oncontrolselect=null;
		instanceVariables.displayPanel.style.display='';
	}
	RTE2_RemoveEditorPathFromUrls(strBaseElementID);
	RTE2_AddHtmlEditorTags(strBaseElementID);
	RTE2_SaveHtmlState(strBaseElementID);
	RTE2_OnSelectionChange(strBaseElementID);
	RTE_GiveEditorFocus(strBaseElementID);
	RTE_SaveSelection(strBaseElementID);
	if (!RTE2_PopupMode(strBaseElementID))
	{
		instanceVariables.emptyPanel.style.display='none';
	}
}
function RTE2_SaveHtml(displayPanel, emptyPanel, hiddenInputField, hiddenFieldInDisplayFormat, displayContentElement, statusBar, newHtmlArray, fromInlineMode)
{
	if(newHtmlArray !=null && newHtmlArray[0] !=null && newHtmlArray[1] !=null )
	{
		var newHtmlViewMode=newHtmlArray[0];
		var newHtmlStorageMode=newHtmlArray[1];
		if (newHtmlStorageMode=="" && !fromInlineMode)
		{
			displayPanel.style.display="none";
			emptyPanel.style.display="inline";
		}
		else
		{
			displayPanel.style.display="inline";
			emptyPanel.style.display="none";
		}
		hiddenInputField.value=newHtmlStorageMode;
		hiddenFieldInDisplayFormat.value=newHtmlViewMode;
		if (displayContentElement.innerHTML !=newHtmlViewMode)
		{
			displayContentElement.innerHTML=newHtmlViewMode;
		}
		if (statusBar !=null)
		{
			statusBar.style.display="inline";
		}
	}
}
function RTE2_OnCut(strBaseElementID, body)
{
	var rngSelection=RTE_GetCurrentSelectionRange(strBaseElementID);
	if (rngSelection==null) return;
	var safeHtmlDocument=RTE2_GetSafeHtmlDocument(strBaseElementID);
	if (safeHtmlDocument==null) return;
	body.document.parentWindow.event.returnValue=false;
	safeHtmlDocument.body.innerHTML=RTE2_GetCorrectedHtmlFromSelectedRange(strBaseElementID, rngSelection);
	RTE2_SaveHtmlStateIfChanged(strBaseElementID);
	RTE2_RemoveHtmlEditorTagsFromElement(strBaseElementID, safeHtmlDocument.body);
	var range=safeHtmlDocument.body.createTextRange();
	range.execCommand("Copy");
	rngSelection.execCommand("Delete");
	RTE2_SaveHtmlState(strBaseElementID);
	RTE_SaveSelection(strBaseElementID);
}
function RTE2_OnCopy(strBaseElementID, body)
{
	var rngSelection=RTE_GetCurrentSelectionRange(strBaseElementID);
	if (rngSelection==null) return;
	var safeHtmlDocument=RTE2_GetSafeHtmlDocument(strBaseElementID);
	if (safeHtmlDocument==null) return;
	body.document.parentWindow.event.returnValue=false;
	safeHtmlDocument.body.innerHTML=RTE2_GetCorrectedHtmlFromSelectedRange(strBaseElementID, rngSelection);
	RTE2_RemoveHtmlEditorTagsFromElement(strBaseElementID, safeHtmlDocument.body);
	var range=safeHtmlDocument.body.createTextRange();
	range.execCommand("Copy");
	RTE_SaveSelection(strBaseElementID);
}
function RTE2_GetCorrectedHtmlFromSelectedRange(strBaseElementID, range)
{
	if (RTE_GetCurrentSelectionType(strBaseElementID)=="Control")
	{
		return range.item(0).outerHTML;
	}
	var htmlText=range.htmlText;
	if (RTE_IsElementSelected(strBaseElementID, "TR"))
	{
		if (htmlText.indexOf("<TR")==-1)
		{
			var elem=RTE_GetNearestContainingElementOfType(strBaseElementID, "TR");
			if (elem !=null)
			{
				var clone=elem.cloneNode(false);
				htmlText=clone.outerHTML.replace("></",">"+htmlText+"</");
			}
		}
		var elem=RTE_GetNearestContainingElementOfType(strBaseElementID, "TBODY");
		if (elem !=null)
		{
			var clone=elem.cloneNode(false);
			htmlText=clone.outerHTML.replace("></",">"+htmlText+"</");
		}
	}
	if (RTE_IsElementSelected(strBaseElementID, "TR") || RTE_IsElementSelected(strBaseElementID, "TBODY"))
	{
		var elem=RTE_GetNearestContainingElementOfType(strBaseElementID, "TABLE");
		if (elem !=null)
		{
			var clone=elem.cloneNode(false);
			htmlText=clone.outerHTML.replace("></",">"+htmlText+"</");
		}
	}
	if (RTE_IsElementSelected(strBaseElementID, "LI"))
	{
		var elem=RTE_GetNearestContainingElementOfTypes(strBaseElementID, new Array("UL", "OL", "DIR"));
		if (elem !=null)
		{
			var clone=elem.cloneNode(false);
			htmlText=clone.outerHTML.replace("></",">"+htmlText+"</");
		}
	}
	if (RTE_IsElementSelected(strBaseElementID, "DD") || RTE_IsElementSelected(strBaseElementID, "DT"))
	{
		var elem=RTE_GetNearestContainingElementOfType(strBaseElementID, "DL");
		if (elem !=null)
		{
			var clone=elem.cloneNode(false);
			htmlText=clone.outerHTML.replace("></",">"+htmlText+"</");
		}
	}
	return htmlText;
}
function RTE2_RemoveHtmlEditorTagsFromElement(strBaseElementID, element)
{
	RTE2_AlterReusableFragmentHighlights(element, "");
}
function RTE2_AddHtmlEditorTagsToElement(strBaseElementID, element)
{
	RTE2_SetGridlineVisibility(strBaseElementID, RTE2_ShouldTableBordersBeVisible(strBaseElementID))
	RTE2_AlterReusableFragmentHighlights(element, "ms-reusableTextView");
}
function RTE2_AddHtmlEditorTags(strBaseElementID)
{
	var htmlDocument=RTE_GetEditorDocument(strBaseElementID);
	if (htmlDocument==null) return;
	RTE2_AddHtmlEditorTagsToElement(strBaseElementID, htmlDocument.body);
}
function RTE2_RemoveHtmlEditorTags(strBaseElementID)
{
	var htmlDocument=RTE_GetEditorDocument(strBaseElementID);
	if (htmlDocument==null) return;
	RTE2_RemoveHtmlEditorTagsFromElement(strBaseElementID, htmlDocument.body);
}
function RTE2_GetUnitSpecifier(measurement)
{
	var cleanMeasurement=measurement.toLowerCase();
	cleanMeasurement=cleanMeasurement.replace("%","");
	if (cleanMeasurement !=measurement)
	{
		return "%";
	}
	else
	{
		cleanMeasurement=cleanMeasurement.replace("px","");
		if (cleanMeasurement !=measurement)
		{
			return "px";
		}
		else
		{
			cleanMeasurement=parseInt(cleanMeasurement, 10);
			if (!isNaN(cleanMeasurement))
			{
				return "px";
			}
		}
	}
	return null;
}
function RTE2_RemoveUnitSpecifier(measurement)
{
	var cleanMeasurement=measurement.toLowerCase();
	cleanMeasurement=cleanMeasurement.replace("px","");
	if (cleanMeasurement==measurement)
	{
		cleanMeasurement=cleanMeasurement.replace("%","");
	}
	cleanMeasurement=parseInt(cleanMeasurement, 10);
	if (!isNaN(cleanMeasurement))
	{
		return cleanMeasurement;
	}
	return null;
}
function RTE2_BoolFromString(str)
{
	var boolToReturn=(str.match(/^(t(rue)?)|(y(es)?)$/i))? true: false;
	return boolToReturn;
}
function RTE2_ExtraButtonOnClick(strBaseElementID, i)
{
	if (null !=g_extraButtons[i] && null !=g_extraButtons[i].OnClick)
	{
		var extraButton=g_extraButtons[i];
		if (null !=extraButton._addedToToolbar && true==extraButton._addedToToolbar)
		{
			extraButton.OnClick(strBaseElementID, extraButton.Arguments);
		}
	}
}
function RTE2_ExtraButtonOnResetState(strBaseElementID, i)
{
	var shouldButtonBeEnabled=false;
	if (null !=g_extraButtons[i] && null !=g_extraButtons[i].OnResetState)
	{
		var extraButton=g_extraButtons[i];
		if (null !=extraButton._addedToToolbar && true==extraButton._addedToToolbar)
		{
			shouldButtonBeEnabled=extraButton.OnResetState(strBaseElementID, extraButton.Arguments);
		}
	}
	return shouldButtonBeEnabled;
}
function RTE2_RegisterToolbarButton(mnemonic, iconUrl, text, toolTip, onClickCallback, onResetStateCallback, args)
{
	var argumentsOk=true;
	if (RTE2_IsNullOrEmpty(mnemonic))
	{
		argumentsOk=false;
	}
	if (RTE2_IsNullOrEmpty(iconUrl) && RTE2_IsNullOrEmpty(text))
	{
		argumentsOk=false;
	}
	if (null==toolTip)
	{
		toolTip="";
	}
	if (null==onClickCallback || null==onResetStateCallback)
	{
		argumentsOk=false;
	}
	if (argumentsOk)
	{
		var extraButton=new Object();
		extraButton.Mnemonic=mnemonic;
		extraButton.IconUrl=iconUrl;
		extraButton.Text=text;
		extraButton.ToolTip=toolTip;
		extraButton.OnClick=onClickCallback;
		extraButton.OnResetState=onResetStateCallback;
		extraButton.Arguments=args;
		g_extraButtons.push(extraButton);
	}
	return argumentsOk;
}
function RTE2_IsNullOrEmpty(str)
{
	return (null==str) || (""==str);
}
function RTE2_PutCursorInEditor(strBaseElementID, selectContent)
{
	var docEditor=RTE_GetEditorDocument(strBaseElementID);
	var textRange=docEditor.body.createTextRange();
	docEditor.focus();
	if (!selectContent) textRange.collapse(false);
	textRange.select();
}
function RTE2_PutCursorInTable(strBaseElementID, tablePosition, rowPosition, cellPosition, selectContent)
{
	var docEditor=RTE_GetEditorDocument(strBaseElementID);
	var tables=docEditor.body.getElementsByTagName("TABLE");
	var table=tables[tablePosition];
	var row=table.rows[rowPosition];
	var cell=row.cells[cellPosition];
	var textRange=docEditor.body.createTextRange();
	textRange.moveToElementText(cell);
	if (!selectContent) textRange.collapse(false);
	textRange.select();
}
function RTE2_CircularArrayCreate(maxAmount)
{
	var circularArray=new Object();
	circularArray.items=new Array();
	circularArray.count=0;
	circularArray.start=0;
	circularArray.maxAmount=maxAmount;
	return circularArray;
}
function RTE2_CircularArrayGetElement(circularArray, queuePosition)
{
	if (queuePosition >=circularArray.count) return null;
	var arrayPosition=(circularArray.start+queuePosition) % circularArray.maxAmount;
	return circularArray.items[arrayPosition];
}
function RTE2_CircularArrayAddAsLastElement(circularArray, queuePosition, value, removeFirstElementWhenFull)
{
	if (circularArray.count==circularArray.maxAmount)
	{
		if (!removeFirstElementWhenFull) return false;
		circularArray.start=(circularArray.start+1) % circularArray.maxAmount;
	}
	else
	{
		circularArray.count=queuePosition+1;
	}
	var arrayPosition=(circularArray.start+queuePosition) % circularArray.maxAmount;
	circularArray.items[arrayPosition]=value;
	return true;
}
function RTE2_CircularArrayDeleteAfterPosition(circularArray, queuePosition)
{
	circularArray.count=queuePosition+1;
}
function RTE2_CanUndo(htmlStateBuffer)
{
	return (htmlStateBuffer.currentUndoRedoPosition > 0 || htmlStateBuffer.currentSameAsEditor==false);
}
function RTE2_CanRedo(htmlStateBuffer)
{
	return (htmlStateBuffer.currentUndoRedoPosition+1 < htmlStateBuffer.count);
}
function RTE2_GetHtmlStateBuffer(strBaseElementID, p_htmlStateBuffer)
{
	if (p_htmlStateBuffer) return p_htmlStateBuffer;
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	return instanceVariables.htmlStateBuffer;
}
function RTE2_CheckHtmlState(strBaseElementID, p_htmlStateBuffer)
{
	var htmlStateBuffer=RTE2_GetHtmlStateBuffer(strBaseElementID, p_htmlStateBuffer);
	if (htmlStateBuffer.currentSameAsEditor==false) return;
	var isSourceView=RTE2_IsSourceView(strBaseElementID);
	var htmlEditorContent="";
	if (isSourceView)
	{
		var sourceTextArea=RTE2_GetSourceEditorTextArea(strBaseElementID);
		htmlEditorContent=sourceTextArea.value;
	}
	else
	{
		htmlEditorContent=RTE2_GetRichContent(strBaseElementID);
	}
	var htmlBuffer=RTE2_CircularArrayGetElement(htmlStateBuffer, htmlStateBuffer.currentUndoRedoPosition);
	if (htmlEditorContent !=htmlBuffer[0] || isSourceView !=htmlBuffer[1])
	{
		RTE2_SetHtmlStateBufferOutdated(strBaseElementID, p_htmlStateBuffer)
	}
}
function RTE2_SetHtmlStateBufferOutdated(strBaseElementID, p_htmlStateBuffer)
{
	var htmlStateBuffer=RTE2_GetHtmlStateBuffer(strBaseElementID, p_htmlStateBuffer);
	if (htmlStateBuffer.currentSameAsEditor !=false)
	{
		htmlStateBuffer.currentSameAsEditor=false;
		RTE2_CircularArrayDeleteAfterPosition(htmlStateBuffer, htmlStateBuffer.currentUndoRedoPosition);
	}
}
function RTE2_SaveHtmlStateIfChanged(strBaseElementID, p_htmlStateBuffer)
{
	var htmlStateBuffer=RTE2_GetHtmlStateBuffer(strBaseElementID, p_htmlStateBuffer);
	RTE2_CheckHtmlState(strBaseElementID, htmlStateBuffer);
	if (htmlStateBuffer.currentSameAsEditor==true) return;
	RTE2_SaveHtmlState(strBaseElementID, htmlStateBuffer);
}
function RTE2_SaveHtmlState(strBaseElementID, p_htmlStateBuffer)
{
	var htmlStateBuffer=RTE2_GetHtmlStateBuffer(strBaseElementID, p_htmlStateBuffer);
	if (htmlStateBuffer.currentUndoRedoPosition+1 < htmlStateBuffer.maxAmount)
	{
		htmlStateBuffer.currentUndoRedoPosition++;
	}
	var isSourceView=RTE2_IsSourceView(strBaseElementID);
	var html="";
	if (isSourceView)
	{
		var sourceTextArea=RTE2_GetSourceEditorTextArea(strBaseElementID);
		html=sourceTextArea.value;
	}
	else
	{
		html=RTE2_GetRichContent(strBaseElementID);
	}
	var htmlState=new Array(html, isSourceView);
	RTE2_CircularArrayAddAsLastElement(htmlStateBuffer, htmlStateBuffer.currentUndoRedoPosition, htmlState, true);
	htmlStateBuffer.currentSameAsEditor=true;
	RTE2_HideOnPasteMenu(strBaseElementID);
	RTE_StartUpdateOnCellMenuPositionTimer(strBaseElementID);
}
function RTE2_RestoreHtmlState(strBaseElementID, p_htmlStateBuffer)
{
	var htmlStateBuffer=RTE2_GetHtmlStateBuffer(strBaseElementID, p_htmlStateBuffer);
	var htmlState=RTE2_CircularArrayGetElement(htmlStateBuffer, htmlStateBuffer.currentUndoRedoPosition);
	var html=htmlState[0];
	var isSourceViewSaved=htmlState[1];
	var isSourceView=RTE2_IsSourceView(strBaseElementID);
	if (isSourceView)
	{
		var sourceTextArea=RTE2_GetSourceEditorTextArea(strBaseElementID);
		sourceTextArea.value=html;
	}
	else
	{
		RTE2_SetRichContent(strBaseElementID, html);
		RTE2_AddHtmlEditorTags(strBaseElementID);
	}
	RTE2_ResetAllToolBarStates(strBaseElementID);
	RTE2_HideOnPasteMenu(strBaseElementID);
	RTE_StartUpdateOnCellMenuPositionTimer(strBaseElementID);
	if (isSourceView !=isSourceViewSaved)
	{
		RTE2_ViewSource(strBaseElementID, false);
	}
	htmlStateBuffer.currentSameAsEditor=true;
}
function RTE2_Undo(strBaseElementID, p_htmlStateBuffer)
{
	var htmlStateBuffer=RTE2_GetHtmlStateBuffer(strBaseElementID, p_htmlStateBuffer);
	if (RTE2_CanUndo(htmlStateBuffer))
	{
		RTE2_SaveHtmlStateIfChanged(strBaseElementID, htmlStateBuffer)
		htmlStateBuffer.currentUndoRedoPosition--;
		RTE2_RestoreHtmlState(strBaseElementID, htmlStateBuffer);
	}
}
function RTE2_Redo(strBaseElementID, p_htmlStateBuffer)
{
	if (RTE2_IsSourceView(strBaseElementID))
	{
		var docEditor=RTE_GetEditorDocument(strBaseElementID);
		docEditor.execCommand("Redo");
		RTE2_ResetAllToolBarStates(strBaseElementID);
	}
	else
	{
		var htmlStateBuffer=RTE2_GetHtmlStateBuffer(strBaseElementID, p_htmlStateBuffer);
		htmlStateBuffer.currentUndoRedoPosition++;
		RTE2_RestoreHtmlState(strBaseElementID, htmlStateBuffer);
	}
}
function RTE2_TB_GenerateToolBarButtonHtmlWithSaveHtmlState(strBaseElementID, strButtonMnemonic, strOnClickJScript, strImageUrl, strText, strToolTip)
{
	return RTE_TB_GenerateToolBarButtonHtml( strBaseElementID, strButtonMnemonic, "RTE2_SaveHtmlStateIfChanged('"+strBaseElementID+"');"+strOnClickJScript+";RTE2_SaveHtmlStateIfChanged('"+strBaseElementID+"');", strImageUrl, strText, strToolTip);
}
function RTE2_TB_GenerateExecCommandToolBarButtonHtmlWithSaveHtmlState(
	strBaseElementID,
	strCommand,
	fUserInterface,
	strImageUrl,
	strText,
	strToolTip,
	fOnlyIfSelectionActive,
	strValueExpression)
{
	return RTE_TB_GenerateExecCommandToolBarButtonHtml(strBaseElementID, strCommand, fUserInterface, strImageUrl, strText, strToolTip, fOnlyIfSelectionActive, strValueExpression, "RTE2_SaveHtmlStateIfChanged('"+strBaseElementID+"');", "RTE2_SaveHtmlStateIfChanged('"+strBaseElementID+"');");
}
function RTE2_TB_GenerateExecCommandToolBarButtonHtmlWithSaveHtmlStateAndFixReusableContent(
	strBaseElementID,
	strCommand,
	fUserInterface,
	strImageUrl,
	strText,
	strToolTip,
	fOnlyIfSelectionActive,
	strValueExpression,
	strTagName)
{
	var beforeExecJavascript="RTE2_SaveHtmlStateIfChanged('"+strBaseElementID+"'); RTE2_ToggleReusableFragmentsDummy('"+strBaseElementID+"', true);";
	var afterExecJavascript="RTE2_ToggleReusableFragmentsDummy('"+strBaseElementID+"', false); RTE2_SaveHtmlStateIfChanged('"+strBaseElementID+"');"
	return RTE_TB_GenerateExecCommandToolBarButtonHtml(strBaseElementID, strCommand, fUserInterface, strImageUrl, strText, strToolTip, fOnlyIfSelectionActive, strValueExpression, beforeExecJavascript, afterExecJavascript);
}
function RTE2_AddToolBarButtonDefinition(strBaseElementID, mnemonic, html, standardToolbar)
{
	btnInfo=new Object();
	btnInfo.strMnemonic=mnemonic;
	btnInfo.html=html;
	btnInfo.standardToolbar=true;
	if (standardToolbar !=undefined) btnInfo.standardToolbar=standardToolbar;
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	instanceVariables.toolbarDefinition.push(btnInfo);
}
function RTE2_GetToolBarDefinition(strBaseElementID)
{
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	return instanceVariables.toolbarDefinition;
}
function RTE2_DD_GenerateMenuItemScriptHtmlWithSaveHtmlState(strBaseElementID, cColumns, iMenuItem, p_strFunctionName, p_strParameter, strMenuItemHtml, strMenuItemToolTip, strWebLanguage)
{
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	instanceVariables.functions[g_strRTE2PerformFunctionWithSaveHtmlState]=RTE2_DD_PerformFunctionWithSaveHtmlState;
	strParameter=p_strParameter.replace(/'/g,"\\\'");
	strFunctionName=p_strFunctionName.replace(/'/g,"\\\'");
	return RTE_DD_GenerateMenuItemScriptHtml(
				cColumns,
				iMenuItem,
				"return RTE_DD_StartAction('"+g_strRTE2PerformFunctionWithSaveHtmlState+"', new Array('"+strBaseElementID+"','"+strFunctionName+"','"+strParameter+"'))",
				strMenuItemHtml,
				strMenuItemToolTip,
				null, null, strWebLanguage);
}
var g_strRTE2PerformFunctionWithSaveHtmlState="RTE2_DD_PerformFunctionWithSaveHtmlState";
function RTE2_DD_PerformFunctionWithSaveHtmlState(parameters)
{
	if (parameters.length !=3) return;
	var strBaseElementID=parameters[0];
	var strFunctionName=parameters[1];
	var strParameter=parameters[2];
	RTE2_SaveHtmlStateIfChanged(strBaseElementID);
	RTE_ExecuteFunctionOnSelection(RTE_DD_GetMenuBaseElementID(), strFunctionName, strParameter);
	RTE2_SaveHtmlStateIfChanged(strBaseElementID);
}
function RTE2_DD_GenerateMenuItemHtmlWithSaveHtmlState(strBaseElementID, cColumns, iMenuItem, strCommandToPerform, strCommandValue, strMenuItemHtml, strMenuItemToolTip, strWebLanguage)
{
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	instanceVariables.functions[g_strRTE2PerformActionWithSaveHtmlState]=RTE2_DD_PerformActionWithSaveHtmlState;
	return RTE_DD_GenerateMenuItemScriptHtml(
				cColumns,
				iMenuItem,
				"return RTE_DD_StartAction('"+g_strRTE2PerformActionWithSaveHtmlState+"', new Array('"+strBaseElementID+"','"+strCommandToPerform+"','"+strCommandValue+"'))",
				strMenuItemHtml,
				strMenuItemToolTip,
				null, null, strWebLanguage);
}
var g_strRTE2PerformActionWithSaveHtmlState="RTE2_DD_PerformActionWithSaveHtmlState";
function RTE2_DD_PerformActionWithSaveHtmlState(parameters)
{
	if (parameters.length !=3) return;
	var strBaseElementID=parameters[0];
	var strCommandToPerform=parameters[1];
	var strCommandValue=parameters[2];
	RTE2_SaveHtmlStateIfChanged(strBaseElementID);
	RTE_ExecuteCommandOnSelection(RTE_DD_GetMenuBaseElementID(), strCommandToPerform, false, strCommandValue);
	RTE2_SaveHtmlStateIfChanged(strBaseElementID);
}
function RTE2_GenerateOnPasteToolBarButtonHtml(strBaseElementID, strWebLanguage)
{
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	instanceVariables.functions[g_strRTE2PasteTextMnemonic]=RTE2_ChangePasteToText;
	instanceVariables.functions[g_strRTE2PasteStripMnemonic]=RTE2_ChangePasteToStrip;
	instanceVariables.functions[g_strRTE2PasteHtmlMnemonic]=RTE2_ChangePasteToHtml;
	var strHtmlRet="";
	strHtmlRet+=RTE_TB_GenerateOpenCellButtonHtml(strBaseElementID, g_strRTE2OnPasteMnemonic, "RTE2_DD_OpenOnPasteSelector('"+strBaseElementID+"' ,'"+strWebLanguage+"');");
	strHtmlRet+="<img src=\""+RTE2_GetControlImage(g_strRTE2OnPasteMnemonic)+"\" alt=\""+L_OnPasteToolTip_TEXT+"\" border=0"+g_strIconSizeAttributes+"unselectable=\"on\">";
	strHtmlRet+="<img alt=\""+L_OnPasteToolTip_TEXT+"\" src=\""+RTE_GetServerRelativeUnlocalizedImageUrl("menudark.gif")+"\" border=0 width=13 height=13 unselectable=\"on\">";
	strHtmlRet+=RTE_TB_GenerateCloseCellButtonHtml();
	return strHtmlRet;
}
function RTE2_DD_OpenOnPasteSelector(strBaseElementID, strWebLanguage)
{
	var strMnemonic=g_strRTE2OnPasteMnemonic;
	var rgoMenuInfo=RTE2_DD_GetOnPasteSelectorUnformattedHtml(strBaseElementID, strWebLanguage);
	var strMenuHtml=rgoMenuInfo[0];
	var cMenuItems=rgoMenuInfo[1];
	RTE_DD_OpenMenu(strBaseElementID, strMnemonic, strMenuHtml, strWebLanguage, cMenuItems);
}
function RTE2_DD_GetOnPasteSelectorUnformattedHtml(strBaseElementID, strWebLanguage)
{
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	var strMenuHtml=instanceVariables.menuHtml[g_strRTE2OnPasteMnemonic];
	if (null !=strMenuHtml)
	{
		return strMenuHtml;
	}
	strMenuHtml=RTE_DD_GenerateMenuOpenHtml(strWebLanguage);
	var rgstrItemNames=new Array();
	rgstrItemNames.push(L_PasteStripLabel_TEXT);
	rgstrItemNames.push(L_PasteTextLabel_TEXT);
	rgstrItemNames.push(L_PasteHtmlLabel_TEXT);
	var mnemonicsName=new Array();
	mnemonicsName.push(g_strRTE2PasteStripMnemonic);
	mnemonicsName.push(g_strRTE2PasteTextMnemonic);
	mnemonicsName.push(g_strRTE2PasteHtmlMnemonic);
	for (var i=0; i<mnemonicsName.length; i++)
	{
		strMenuHtml+=RTE_DD_GenerateMenuItemScriptHtml(
				1,
				i,
				"return RTE_DD_StartAction('"+mnemonicsName[i]+"','"+strBaseElementID+"','"+i+"')",
				rgstrItemNames[i],
				rgstrItemNames[i],
				null, null, strWebLanguage);
	}
	strMenuHtml+=RTE_DD_GenerateMenuCloseHtml();
	instanceVariables.menuHtml[g_strRTE2OnPasteMnemonic]=new Array(strMenuHtml, rgstrItemNames.length);
	return instanceVariables.menuHtml[g_strRTE2OnPasteMnemonic];
}
function RTE2_ChangePasteToText(strBaseElementID)
{
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	RTE2_ChangePaste(strBaseElementID, instanceVariables, instanceVariables.pasteData.text);
}
function RTE2_ChangePasteToStrip(strBaseElementID)
{
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	if (instanceVariables.pasteData.stripped==null)
	{
		var safeHtmlDocument=RTE2_GetSafeHtmlDocument(strBaseElementID);
		if (safeHtmlDocument==null) return;
		safeHtmlDocument.body.innerHTML=instanceVariables.pasteData.html;
		var elements=RTE2_GetAllElements(safeHtmlDocument);
		RTE2_RemoveElementStyles(elements);
		instanceVariables.pasteData.stripped=safeHtmlDocument.body.innerHTML;
	}
	RTE2_ChangePaste(strBaseElementID, instanceVariables, instanceVariables.pasteData.stripped);
}
function RTE2_ChangePasteToHtml(strBaseElementID)
{
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	RTE2_ChangePaste(strBaseElementID, instanceVariables, instanceVariables.pasteData.html);
}
function RTE2_ChangePaste(strBaseElementID, instanceVariables, data)
{
	RTE2_SaveHtmlStateIfChanged(strBaseElementID);
	var textRange=instanceVariables.pasteData.textRange;
	textRange.pasteHTML("");
	var pasteTextRange=textRange.duplicate();
	pasteTextRange.collapse();
	pasteTextRange.pasteHTML(data);
	RTE2_AddHtmlEditorTags(strBaseElementID);
	RTE2_SaveHtmlState(strBaseElementID);
	RTE2_ShowOnPasteMenu(strBaseElementID, textRange)
}
function RTE2_GetOnPasteMenuID(strBaseElementID)
{
	return strBaseElementID+"_onpaste_menu";
}
function RTE2_GetOnPasteMenu(strBaseElementID)
{
	var item=document.getElementById(RTE2_GetOnPasteMenuID(strBaseElementID));
	return item;
}
function RTE2_ShowOnPasteMenu(strBaseElementID, pasteTextRange)
{
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	instanceVariables.pasteData.visible=true;
	RTE2_UpdateOnPasteMenuPosition(strBaseElementID, pasteTextRange);
}
function RTE2_GetPasteTextRange(strBaseElementID, p_pasteTextRange)
{
	if (p_pasteTextRange !=null) return p_pasteTextRange;
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	return instanceVariables.pasteData.textRange;
}
var g_menuWidthFromText=7;
function RTE2_UpdateOnPasteMenuPosition(strBaseElementID, p_pasteTextRange)
{
	if (RTE2_OnPasteMenuShouldBeVisible(strBaseElementID))
	{
		var pasteTextRange=RTE2_GetPasteTextRange(strBaseElementID, p_pasteTextRange);
		var textRange=pasteTextRange.duplicate()
		textRange.collapse(false);
		var elemMenu=RTE2_GetOnPasteMenu(strBaseElementID);
		elemMenu.style.top="0px";
		elemMenu.style.left="0px";
		var elemTop=textRange.offsetTop - RTE2_GetOffsetTop(elemMenu, 0);
		if (RTE2_PopupMode(strBaseElementID))
		{
			var toolbar=RTE2_GetToolbar(strBaseElementID);
			elemTop+=toolbar.clientHeight;
		}
		var elemMenuXPosition=textRange.offsetLeft - RTE2_GetOffsetLeft(elemMenu, 0);
		var elemHeight=textRange.boundingHeight;
	    if (RTE2_GetElementDirection(strBaseElementID, textRange)=="rtl")
		{
			elemMenuXPosition -=elemMenu.offsetWidth;
			elemMenuXPosition -=g_menuWidthFromText;
		}
		else
		{
			elemMenuXPosition+=elemMenu.offsetWidth;
			elemMenuXPosition+=textRange.boundingWidth
			elemMenuXPosition+=g_menuWidthFromText;
		}
		RTE2_UpdateMenuPosition(strBaseElementID, elemMenu, elemTop, elemMenuXPosition, elemHeight, true, false);
	}
}
function RTE2_GetElementDirection(strBaseElementID, elem)
{
	while (elem!=null && elem.dir !="ltr" && elem.dir !="rtl" )
	{
		elem=elem.parentElement;
	}
	if (elem)
	{
		if (elem.dir=="ltr")
		{
			return "ltr";
		}
		else if (elem.dir=="rtl")
		{
			return "rtl";
		}
	}
	var docEditor=RTE_GetEditorDocument(strBaseElementID);
	return RTE2_GetDocumentDirection(docEditor);
}
function RTE2_GetDocumentDirection(docEditor)
{
	if (docEditor.body.dir=="rtl" || docEditor.body.dir=="" && docEditor.dir=="rtl")
	{
		return "rtl";
	}
	return "ltr";
}
var g_menuMinY=5;
var g_menuHeightFromElem=4;
var g_scrollbarWidth=16;
function RTE2_UpdateMenuPosition(strBaseElementID, elemMenu, elemTop, elemMenuXPosition, elemHeight, menuOverCursorGoLower, positionDocumentRelative)
{
	var docEditor=RTE_GetEditorDocument(strBaseElementID);
	var menuOutOfBound=false;
	var menuYPosition=elemTop;
	var menuXPosition=elemMenuXPosition;
	if (RTE2_PopupMode(strBaseElementID))
	{
		var minXPosition=0;
		var maxXPosition=docEditor.body.clientWidth+docEditor.body.scrollLeft;
		if (docEditor.body.dir=="rtl" || docEditor.body.dir=="" && docEditor.dir=="rtl")
		{
			if (positionDocumentRelative)
			{
				elemMenuXPosition+=g_scrollbarWidth;
				elemMenuXPosition+=docEditor.body.scrollWidth;
				elemMenuXPosition -=docEditor.body.clientWidth;
			}
			minXPosition+=g_scrollbarWidth;
			maxXPosition+=g_scrollbarWidth;
		}
		var menuWidth=elemMenu.offsetWidth;
		var menuHeight=elemMenu.offsetHeight;
		if (menuXPosition+menuWidth >=maxXPosition)
		{
			menuXPosition=maxXPosition - menuWidth;
			if (menuOverCursorGoLower) menuYPosition+=elemHeight;
		}
		else if (menuXPosition <=minXPosition)
		{
			menuXPosition=minXPosition;
			if (menuOverCursorGoLower) menuYPosition+=elemHeight;
		}
		if (elemTop+elemHeight - g_menuHeightFromElem < 0
			|| elemTop > docEditor.body.clientHeight+docEditor.body.scrollTop)
		{
			menuOutOfBound=true;
		}
		else if (menuYPosition < g_menuMinY)
		{
			menuYPosition=g_menuMinY;
		}
		else if (menuYPosition+menuHeight >=docEditor.body.clientHeight+docEditor.body.scrollTop)
		{
			menuYPosition=docEditor.body.clientHeight+docEditor.body.scrollTop - menuHeight;
		}
	}
	if (menuOutOfBound)
	{
		elemMenu.style.visibility='hidden';
	}
	else
	{
		elemMenu.style.visibility='visible';
		elemMenu.style.left=menuXPosition;
		elemMenu.style.top=menuYPosition;
	}
}
function RTE2_OnMouseOverMenu(menu)
{
	menu.style.filter="alpha(opacity=100)";
}
function RTE2_OnMouseOutMenu(menu)
{
	menu.style.filter="alpha(opacity=70)";
}
function RTE2_OnPasteMenuShouldBeVisible(strBaseElementID)
{
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	return instanceVariables.pasteData.visible;
}
function RTE2_OnScroll(strBaseElementID)
{
	RTE2_UpdateOnPasteMenuPosition(strBaseElementID);
	RTE_StartUpdateOnCellMenuPositionTimer(strBaseElementID);
}
function RTE2_OnKeyUp(strBaseElementID, elem)
{
	RTE_OnKeyUp(strBaseElementID, elem);
	RTE2_CheckHtmlState(strBaseElementID);
	var htmlStateBuffer=RTE2_GetHtmlStateBuffer(strBaseElementID);
	if (htmlStateBuffer.currentSameAsEditor==false)
	{
		RTE2_HideOnPasteMenu(strBaseElementID);
		RTE_StartUpdateOnCellMenuPositionTimer(strBaseElementID);
	}
	RTE2_OnKeyUpMenuAccess(strBaseElementID, elem);
}
function RTE2_OnKeyUpMenuAccess(strBaseElementID, elem)
{
	var evtSource=elem.document.parentWindow.event;
	var nKeyCode=evtSource.keyCode;
	if (nKeyCode==L_CtrlKey_VALUE)
	{
		var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
		if (instanceVariables.fToolbarNavigateSkip)
		{
			instanceVariables.fToolbarNavigateSkip=false;
		}
		else if (instanceVariables.fToolbarNavigate)
		{
			instanceVariables.fToolbarNavigate=false;
			RTE_TB_RemoveLastToolBarHover(strBaseElementID);
		}
		else
		{
			instanceVariables.fToolbarNavigate=true;
			RTE_MoveFocusForwards(strBaseElementID, elem.document.activeElement)
		}
		evtSource.returnValue=false;
	}
}
function RTE2_HideOnPasteMenu(strBaseElementID)
{
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	instanceVariables.pasteData.visible=false;
	var onPasteMenu=RTE2_GetOnPasteMenu(strBaseElementID);
	onPasteMenu.style.visibility='hidden';
}
function RTE2_GenerateOnCellToolBarButtonHtml(strBaseElementID, strWebLanguage)
{
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	instanceVariables.functions[g_strRTEInsertRowAbove]=RTE_InsertRowAbove;
	instanceVariables.functions[g_strRTEInsertRowBelow]=RTE_InsertRowBelow;
	instanceVariables.functions[g_strRTEInsertColumnLeft]=RTE_InsertColumnLeft;
	instanceVariables.functions[g_strRTEInsertColumnRight]=RTE_InsertColumnRight;
	instanceVariables.functions[g_strRTEInsertCellLeft]=RTE_InsertCellLeft;
	instanceVariables.functions[g_strRTEInsertCellRight]=RTE_InsertCellRight;
	instanceVariables.functions[g_strRTEDeleteRow]=RTE_DeleteRow;
	instanceVariables.functions[g_strRTEDeleteColumn]=RTE_DeleteColumn;
	instanceVariables.functions[g_strRTEMergeCellMnemonic]=RTE_MergeCells;
	instanceVariables.functions[g_strRTESplitCellMnemonic]=RTE2_SplitCell;
	instanceVariables.functions[g_strRTE2ModifyRowColSizeFunction]=RTE2_ModifyRowColSize;
	instanceVariables.functions[g_strRTE2EditTableMnemonic]=RTE2_EditTable;
	var strHtmlRet="";
	strHtmlRet+=RTE_TB_GenerateOpenCellButtonHtml(strBaseElementID, g_strRTE2OnCellMnemonic, "RTE2_DD_OpenOnCellSelector('"+strBaseElementID+"' ,'"+strWebLanguage+"');");
	strHtmlRet+="<img alt=\""+L_OnCellToolTip_TEXT+"\" src=\""+RTE_GetServerRelativeUnlocalizedImageUrl("menudark.gif")+"\" border=0"+g_strIconSizeAttributes+"unselectable=\"on\">";
	strHtmlRet+=RTE_TB_GenerateCloseCellButtonHtml();
	return strHtmlRet;
}
function RTE2_DD_OpenOnCellSelector(strBaseElementID, strWebLanguage)
{
	var strMnemonic=g_strRTE2OnCellMnemonic;
	var rgoMenuInfo=RTE2_DD_GetOnCellSelectorUnformattedHtml(strBaseElementID, strWebLanguage);
	var strMenuHtml=rgoMenuInfo[0];
	var cMenuItems=rgoMenuInfo[1];
	RTE_DD_OpenMenu(strBaseElementID, strMnemonic, strMenuHtml, strWebLanguage, cMenuItems);
}
function RTE2_DD_GetOnCellSelectorUnformattedHtml(strBaseElementID, strWebLanguage)
{
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	var strMenuHtml=instanceVariables.menuHtml[g_strRTE2OnCellMnemonic];
	if (null !=strMenuHtml)
	{
		return strMenuHtml;
	}
	strMenuHtml=RTE_DD_GenerateMenuOpenHtml(strWebLanguage);
	var rgstrItemNames=new Array();
	rgstrItemNames.push(L_InsertRowAboveLabel_TEXT);
	rgstrItemNames.push(L_InsertRowBelowLabel_TEXT);
	rgstrItemNames.push(L_InsertColumnLeftLabel_TEXT);
	rgstrItemNames.push(L_InsertColumnRightLabel_TEXT);
	rgstrItemNames.push("-");
	rgstrItemNames.push(L_DeleteRowLabel_TEXT);
	rgstrItemNames.push(L_DeleteColumnLabel_TEXT);
	rgstrItemNames.push("-");
	rgstrItemNames.push(L_MergeCellLabel_TEXT);
	rgstrItemNames.push(L_SplitCellLabel_TEXT);
	rgstrItemNames.push(L_ModifyRowColSizeLabel_TEXT);
	rgstrItemNames.push("-");
	rgstrItemNames.push(L_EditTableLabel_TEXT);
	var mnemonicsName=new Array();
	mnemonicsName.push(g_strRTEInsertRowAbove);
	mnemonicsName.push(g_strRTEInsertRowBelow);
	mnemonicsName.push(g_strRTEInsertColumnLeft);
	mnemonicsName.push(g_strRTEInsertColumnRight);
	mnemonicsName.push("-");
	mnemonicsName.push(g_strRTEDeleteRow);
	mnemonicsName.push(g_strRTEDeleteColumn);
	mnemonicsName.push("-");
	mnemonicsName.push(g_strRTEMergeCellMnemonic);
	mnemonicsName.push(g_strRTESplitCellMnemonic);
	mnemonicsName.push(g_strRTE2ModifyRowColSizeFunction);
	mnemonicsName.push("-");
	mnemonicsName.push(g_strRTE2EditTableMnemonic);
	var navigablePosition=0;
	for (var i=0; i<mnemonicsName.length; i++)
	{
		if (mnemonicsName[i] !="-")
		{
			strMenuHtml+=RTE2_DD_GenerateMenuItemScriptHtmlWithSaveHtmlState(strBaseElementID, 1, navigablePosition,
				mnemonicsName[i],
				strBaseElementID,
				rgstrItemNames[i],
				rgstrItemNames[i],
				strWebLanguage);
			navigablePosition++;
		}
		else
		{
			strMenuHtml+=RTE2_DD_GenerateMenuBarItem();
		}
	}
	strMenuHtml+=RTE_DD_GenerateMenuCloseHtml();
	instanceVariables.menuHtml[g_strRTE2OnCellMnemonic]=new Array(strMenuHtml, navigablePosition);
	return instanceVariables.menuHtml[g_strRTE2OnCellMnemonic];
}
function RTE2_DD_GenerateMenuBarItem()
{
	var strHtmlRet="</tr><tr>";
	strHtmlRet+="<td class=\"ms-toolbar\" nowrap unselectable='on'><HR unselectable='on'></td>";
	return strHtmlRet;
}
function RTE2_HideOnCellMenu(strBaseElementID)
{
	var onCellMenu=RTE2_GetOnCellMenu(strBaseElementID);
	onCellMenu.style.visibility='hidden';
	if (onCellMenu.elemCell !=null)
	{
		onCellMenu.elemCell.runtimeStyle.paddingRight="";
	}
}
function RTE2_GetOnCellMenuID(strBaseElementID)
{
	return strBaseElementID+"_onCell_menu";
}
function RTE2_GetOnCellMenu(strBaseElementID)
{
	var item=document.getElementById(RTE2_GetOnCellMenuID(strBaseElementID));
	return item;
}
var g_cRTE2UpdateOnCellMenuPositionTimerQueue;
function RTE_StartUpdateOnCellMenuPositionTimer(strBaseElementID)
{
	if (g_cRTE2UpdateOnCellMenuPositionTimerQueue==null)
	{
		g_cRTE2UpdateOnCellMenuPositionTimerQueue=new Array();
	}
	if (g_cRTE2UpdateOnCellMenuPositionTimerQueue[strBaseElementID]==null)
	{
		g_cRTE2UpdateOnCellMenuPositionTimerQueue[strBaseElementID]=0;
	}
++g_cRTE2UpdateOnCellMenuPositionTimerQueue[strBaseElementID];
	window.setTimeout("RTE2_OnUpdateOnCellMenuPositionTimer(\""+strBaseElementID+"\")", 40);
}
function RTE2_OnUpdateOnCellMenuPositionTimer(strBaseElementID)
{
	--g_cRTE2UpdateOnCellMenuPositionTimerQueue[strBaseElementID];
	if (0==g_cRTE2UpdateOnCellMenuPositionTimerQueue[strBaseElementID])
	{
		RTE2_UpdateOnCellMenuPosition(strBaseElementID);
	}
}
function RTE2_UpdateOnCellMenuPosition(strBaseElementID)
{
	var elemCell=RTE_GetNearestContainingElementOfTypes(strBaseElementID, g_aTableCellTagNames);
	if (elemCell==null
		|| RTE2_IsSourceView(strBaseElementID)
		|| !RTE2_ElementInContentArea(strBaseElementID, elemCell) )
	{
		RTE2_HideOnCellMenu(strBaseElementID);
		return;
	}
	var elemMenu=RTE2_GetOnCellMenu(strBaseElementID);
	var leftShift=0;
	var rightBorderWidth=parseInt(elemCell.runtimeStyle.borderRightWidth);
	if (!isNaN(rightBorderWidth)) leftShift -=rightBorderWidth;
	var leftBorderWidth=parseInt(elemCell.runtimeStyle.borderLeftWidth);
	if (!isNaN(leftBorderWidth)) leftShift -=leftBorderWidth;
	elemMenu.style.top="0px";
	elemMenu.style.left="0px";
	if (elemMenu.elemCell !=elemCell)
	{
		if (elemMenu.elemCell !=null)
		{
			elemMenu.elemCell.runtimeStyle.paddingRight="";
		}
		var cellPadding=parseInt(elemCell.currentStyle.paddingRight);
		if (cellPadding < elemMenu.clientWidth)
		{
			elemCell.runtimeStyle.paddingRight=elemMenu.clientWidth;
		}
		elemMenu.elemCell=elemCell;
	}
	var elemTop=RTE2_GetOffsetTop(elemCell, 1) - RTE2_GetOffsetTop(elemMenu, 0);
	if (RTE2_PopupMode(strBaseElementID))
	{
		var toolbar=RTE2_GetToolbar(strBaseElementID);
		elemTop+=toolbar.clientHeight;
	}
	var elemMenuXPosition=RTE2_GetOffsetLeft(elemCell, 1) - RTE2_GetOffsetLeft(elemMenu, 0);
	var elemHeight=elemCell.offsetHeight;
	if (RTE2_GetElementDirection(strBaseElementID, elemCell) !="rtl")
	{
		elemMenuXPosition+=elemCell.offsetWidth - elemMenu.offsetWidth+leftShift;
	}
	RTE2_UpdateMenuPosition(strBaseElementID, elemMenu, elemTop, elemMenuXPosition, elemHeight, false, true);
}
function RTE2_GetOffsetTop(elem, value)
{
	if (elem==null) return value;
	if (elem.tagName !=null && elem.tagName.toUpperCase()=="TD" && elem.runtimeStyle.borderTopStyle !="none")
	{
		var shift=parseInt(elem.runtimeStyle.borderTopWidth);
		if (!isNaN(shift))
		{
			value+=shift;
		}
	}
	return RTE2_GetOffsetTop(elem.offsetParent, elem.offsetTop+value);
}
function RTE2_GetOffsetLeft(elem, value)
{
	if (elem==null) return value;
	if (elem.tagName !=null && elem.tagName.toUpperCase()=="TD" && elem.runtimeStyle.borderLeftStyle !="none")
	{
		var shift=parseInt(elem.runtimeStyle.borderLeftWidth);
		if (!isNaN(shift)) {
			value+=shift;
		}
	}
	return RTE2_GetOffsetLeft(elem.offsetParent, elem.offsetLeft+value);
}
function RTE2_SplitCell(strBaseElementID)
{
	RTE_SplitCell(strBaseElementID);
	RTE_StartUpdateOnCellMenuPositionTimer(strBaseElementID);
}
function RTE2_IsAligned(strBaseElementID, strRTEJustifyMnemonic, alignText)
{
	var docEditor=RTE_GetEditorDocument(strBaseElementID);
	var selection=RTE_GetCurrentSelection(strBaseElementID);
	if (selection.type=="Control")
	{
		var currentElem=RTE_GetCurrentElement(strBaseElementID);
		if (currentElem !=null && currentElem.tagName=="IMG")
		{
			if (alignText=="center")
			{
				if (currentElem.align=="left") return false;
				if (currentElem.align=="right") return false;
				if (docEditor.queryCommandSupported(strRTEJustifyMnemonic))
				{
					return docEditor.queryCommandValue(strRTEJustifyMnemonic);
				}
			}
			else
			{
				return currentElem.align==alignText;
			}
		}
	}
	if (docEditor.queryCommandSupported(strRTEJustifyMnemonic))
	{
		return docEditor.queryCommandValue(strRTEJustifyMnemonic);
	}
	return false;
}
function RTE2_Align(strBaseElementID, strRTEJustifyMnemonic)
{
	var selection=RTE_GetCurrentSelection(strBaseElementID);
	if (selection.type=="Control")
	{
		var currentElem=RTE_GetCurrentElement(strBaseElementID);
		if (currentElem !=null && currentElem.tagName=="IMG")
		{
			switch(strRTEJustifyMnemonic)
			{
			  case g_strRTEJustifyLeftMnemonic:
					currentElem.align="left";
					break;
			  case g_strRTEJustifyRightMnemonic:
					currentElem.align="right";
					break;
			  case g_strRTEJustifyCenterMnemonic:
					currentElem.align="";
					break;
			}
		}
	}
	RTE_ExecuteCommandOnSelection(strBaseElementID, strRTEJustifyMnemonic, false, "");
	RTE_StartResetToolBarTimer(strBaseElementID);
}
function RTE2_TB_ChangeToolTip(strBaseElementID, strButtonMnemonic, strToolTip)
{
	var buttonElem=RTE_TB_GetToolBarButton(strBaseElementID, strButtonMnemonic);
	for (var i=0; i<buttonElem.children.length; i++)
	{
		if (buttonElem.children[i].tagName.toUpperCase()=="IMG")
		{
			buttonElem.children[i].alt=strToolTip;
		}
	}
}
function RTE2_ShowParagraphStyles(strBaseElementID)
{
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	if (instanceVariables.showBlockFormatNames)
	{
		return instanceVariables.showBlockFormatNames;
	}
	instanceVariables.showBlockFormatNames=true;
	var rgstrItemNames=RTE_GetBlockFormatNames();
	if (rgstrItemNames.length==0 || rgstrItemNames.length==1 && rgstrItemNames[0]=='Normal')
	{
		instanceVariables.showBlockFormatNames=false;
	}
	return instanceVariables.showBlockFormatNames;
}
function RTE2_Find(strBaseElementID)
{
	var docEditor=RTE_GetEditorDocument(strBaseElementID);
	var findBox=document.getElementById(strBaseElementID+"_find_box");
	var findNextButton=document.getElementById(strBaseElementID+"_find_button");
	if (findBox==null
		|| findNextButton==null) return;
	if (findBox.value=='') return;
	var findRange=null;
	var selection=null;
	if (RTE2_IsSourceView(strBaseElementID))
	{
		var sourceTextArea=RTE2_GetSourceEditorTextArea(strBaseElementID);
		findRange=document.body.createTextRange();
		findRange.moveToElementText(sourceTextArea);
		selection=document.selection;
	}
	else
	{
		findRange=docEditor.body.createTextRange();
		selection=RTE_GetCurrentSelection(strBaseElementID);
	}
	var selectionRange=selection.createRange();
	if (findRange.inRange(selectionRange))
	{
		var findBookmark=selectionRange.getBookmark();
		findRange.moveToBookmark(findBookmark);
		if (selection.type !='None')
		{
			findRange.move('character');
		}
	}
	if (findRange.findText(findBox.value))
	{
		findRange.select();
	}
	else
	{
		alert(L_FindFinished_TEXT);
	}
}
function RTE2_ToggleFind(strBaseElementID)
{
	if (RTE2_FindVisible(strBaseElementID))
	{
		RTE2_HideFind(strBaseElementID);
	}
	else
	{
		RTE2_ShowFind(strBaseElementID);
	}
}
function RTE2_ShowFind(strBaseElementID)
{
	var findToolbar=document.getElementById(strBaseElementID+"_find_toolbar_");
	var findBox=document.getElementById(strBaseElementID+"_find_box");
	if (findToolbar==null
		|| findBox==null) return;
	findToolbar.style.display='';
	findBox.select();
	Window_OnResize();
}
function RTE2_FindVisible(strBaseElementID)
{
	var findToolbar=document.getElementById(strBaseElementID+"_find_toolbar_");
	if (findToolbar==null) return false;
	return findToolbar.style.display !='none';
}
function RTE2_HideFind(strBaseElementID)
{
	var findToolbar=document.getElementById(strBaseElementID+"_find_toolbar_");
	if (findToolbar==null) return;
	findToolbar.style.display='none';
	RTE_GiveEditorFocus(strBaseElementID);
	Window_OnResize();
}
function RTE2_FindKey(strBaseElementID)
{
	var findBox=document.getElementById(strBaseElementID+"_find_box");
	if (findBox==null) return;
	if (RTE2_FindVisible(strBaseElementID) && findBox.value !='')
	{
		RTE2_Find(strBaseElementID);
	}
	else
	{
		RTE2_ShowFind(strBaseElementID);
	}
}
function RTE2_FindOnKeyDown(strBaseElementID, elem)
{
	var evtSource=elem.document.parentWindow.event;
	var nKeyCode=evtSource.keyCode;
	var fShiftKey=evtSource.shiftKey;
	var fCtrlKey=evtSource.ctrlKey;
	var fAltKey=evtSource.altKey;
	var command=false;
	if (( nKeyCode==L_FindKey_TEXT.charCodeAt(0))
		&& (RTE_FInterpretTextAsBoolean(L_FindShiftKey_TEXT)==fShiftKey)
		&& (RTE_FInterpretTextAsBoolean(L_FindAltKey_TEXT)==fAltKey)
		&& (fCtrlKey)
		&& (typeof(RTE_ShortcutsEnabled)=="undefined" || RTE_ShortcutsEnabled()))
	{
		RTE2_FindKey(strBaseElementID);
		evtSource.keyCode=0;
		evtSource.returnValue=false;
		command=true;
	}
	else
	{
		switch(nKeyCode)
		{
			case 27:
				RTE2_HideFind(strBaseElementID);
				evtSource.returnValue=false;
				command=true;
				break;
		}
	}
	if (command)
	{
		var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
		instanceVariables.fToolbarNavigateSkip=true;
		instanceVariables.fToolbarNavigate=false;
		RTE_TB_RemoveLastToolBarHover(strBaseElementID);
	}
}
function RTE2_GetReservedTableStyleRules(strBaseElementID, prefix, targetDocument)
{
	return RTE_GetReservedStyleRules(targetDocument, prefix, "HtmlEditorTableFormats.css");
}
function RTE2_GetReservedCustomStyleRules(strBaseElementID, targetDocument)
{
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	var prefix="."+instanceVariables.prefixStyleSheet+"Custom";
	return RTE_GetReservedStyleRules(targetDocument, prefix, "HtmlEditorCustomStyles.css");
}
function RTE2_ValidateSize(valueText, valueInt, unit, error_nan, error_minrange, error_maxpercrange, error_maxpixelrange)
{
	if (valueText !=null && valueText.length > 0)
	{
		if (valueInt==null)
		{
			return error_nan;
		}
		else if (valueInt <=0)
		{
			return error_minrange;
		}
		else if (unit=="%" && valueInt > g_maxPercentage)
		{
			return error_maxpercrange;
		}
		else if (unit=="px" && valueInt > g_maxPixel)
		{
			return error_maxpixelrange;
		}
	}
	return "";
}
var g_OnOkCallbacks=new Array();
function RTE2_RegisterOnOkCallback(callback)
{
	g_OnOkCallbacks.push(callback);
}
function RTE2_CallOnOkCallbacks(strBaseElementID)
{
	var callbacksCount=g_OnOkCallbacks.length;
	for (var i=0; i < callbacksCount;++i)
	{
		if (false==g_OnOkCallbacks[i].call(window, strBaseElementID))
		{
			return false;
		}
	}
	return true;
}
function RTE2_OnFocus(strBaseElementID)
{
	RTE_StartResetToolBarTimer(strBaseElementID);
}
function RTE2_OnBlur(strBaseElementID)
{
	RTE_SaveSelection(strBaseElementID);
	RTE_StartResetToolBarTimer(strBaseElementID);
	RTE_DD_CloseMenu();
	if (!g_fRTEDialogIsOpen)
	{
		RTE_DisableToolBar(strBaseElementID);
	}
}
function RTE2_IsEditorLoaded(strBaseElementID)
{
	var toolbar=RTE2_GetToolbar(strBaseElementID);
	return toolbar !=null;
}
function RTE2_TransferContentsToTextArea(strBaseElementID)
{
	if (!RTE2_IsBrowserSupported() || !RTE2_IsEditorLoaded(strBaseElementID)) return;
	var newHtmlArray=new Array();
	newHtmlArray[0]=RTE2_GetRichContentForReturn(strBaseElementID);
	newHtmlArray[1]=RTE2_ConvertViewHtmlToStorageHtml(newHtmlArray[0]);
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	if (instanceVariables !=null)
	{
		var displayPanel=instanceVariables.displayPanel;
		var emptyPanel=instanceVariables.emptyPanel;
		var hiddenInputField=instanceVariables.hiddenInputField;
		var hiddenFieldInDisplayFormat=instanceVariables.hiddenFieldInDisplayFormat;
		var displayContentElement=instanceVariables.displayContentElement;
		var statusBar=instanceVariables.statusBar;
		var fromInlineMode=instanceVariables.fromInlineMode;
		RTE2_SaveHtml(displayPanel, emptyPanel, hiddenInputField, hiddenFieldInDisplayFormat, displayContentElement, statusBar, newHtmlArray, fromInlineMode);
	}
}
function RTE2_IsBrowserSupported()
{
	return browseris.ie55up;
}
function RTE2_GetControlWrapper(elem)
{
	var currentElem=elem;
	while(currentElem !=null && (currentElem.id==undefined || currentElem.id.indexOf("ControlWrapper")==-1))
	{
		currentElem=currentElem.parentNode;
	}
	if (currentElem==null) currentElem=elem;
	return currentElem;
}
function RTE2_ToolbarDragStart(strBaseElementID)
{
	var toolbar=RTE2_GetToolbar(strBaseElementID);
	var toolbarIFrame=RTE2_GetToolbarIFrame(strBaseElementID);
	var currentElem=event.srcElement;
	while (currentElem !=toolbar)
	{
		if (currentElem==null) return;
		if (currentElem.onclick !=null) return;
		currentElem=currentElem.parentElement;
	}
	RTE_DD_CloseMenu();
	toolbar.startMouseX=window.event.clientX;
	toolbar.startMouseY=window.event.clientY;
	toolbar.startX=parseInt(toolbar.style.left, 10);
	toolbar.startY=parseInt(toolbar.style.top, 10);
	if (toolbar.onmousemovehandler==null)
	{
		toolbar.onmousemovehandler=new Function("RTE2_ToolbarDragMove('"+strBaseElementID+"');");
		toolbar.onmouseuphandler=new Function("RTE2_ToolbarDragEnd('"+strBaseElementID+"');");
		document.attachEvent("onmousemove",toolbar.onmousemovehandler);
		document.attachEvent("onmouseup",toolbar.onmouseuphandler);
	}
}
function RTE2_ToolbarDragMove(strBaseElementID)
{
	var toolbar=RTE2_GetToolbar(strBaseElementID);
	var toolbarIFrame=RTE2_GetToolbarIFrame(strBaseElementID);
	RTE2_ToolbarDragSetPosition(toolbar, toolbarIFrame);
	if (event.button==0)
	{
		RTE2_ToolbarDragEnd(strBaseElementID);
	}
}
function RTE2_ToolbarDragEnd(strBaseElementID)
{
	var toolbar=RTE2_GetToolbar(strBaseElementID);
	var toolbarIFrame=RTE2_GetToolbar(strBaseElementID);
	RTE2_ToolbarDragSetPosition(toolbar, toolbarIFrame);
	document.detachEvent("onmousemove",toolbar.onmousemovehandler);
	document.detachEvent("onmouseup",toolbar.onmouseuphandler);
	toolbar.onmousemovehandler=null;
	toolbar.onmouseuphandler=null;
}
function RTE2_ToolbarDragSetPosition(toolbar, toolbarIFrame)
{
	var newX=toolbar.startX+(window.event.clientX - toolbar.startMouseX);
	var newY=toolbar.startY+(window.event.clientY - toolbar.startMouseY);
	toolbar.style.left=newX;
	toolbar.style.top=newY;
	toolbarIFrame.style.left=newX;
	toolbarIFrame.style.top=newY;
}
function RTE2_ReplaceContent(inputId, newHtml)
{
	document.getElementById(inputId).value=RTE2_ConvertViewHtmlToStorageHtml(newHtml);
	var displayContentWrapper=RTE2_DisplayElementFromInputElement(inputId);
	if (null !=displayContentWrapper)
	{
		displayContentWrapper.innerHTML=newHtml;
	}
	var hiddenDisplayContent=RTE2_HiddenDisplayElementFromInputElement(inputId);
	if (null !=hiddenDisplayContent)
	{
		hiddenDisplayContent.value=newHtml;
	}
}
function RTE2_ApplyFontFace(strCommandToPerform,strCommandValue)
{
	var strBaseElementID=RTE_DD_GetMenuBaseElementID();
	RTE2_ToggleReusableFragmentsDummy(strBaseElementID, true);
	var elements=RTE_GetContainedElements(strBaseElementID);
	for (var i=0; i<elements.length;i++)
	{
		RTE_RemoveFontFamilyStyle(elements[i]);
	}
	RTE_DD_ExecuteCommand(strCommandToPerform,strCommandValue);
	RTE2_ToggleReusableFragmentsDummy(strBaseElementID, false);
}
function RTE2_ApplyFontSize(strCommandToPerform,strCommandValue)
{
	var strBaseElementID=RTE_DD_GetMenuBaseElementID();
	RTE2_ToggleReusableFragmentsDummy(strBaseElementID, true);
	var elements=RTE_GetContainedElements(strBaseElementID);
	for (var i=0; i<elements.length;i++)
	{
		RTE_RemoveFontSizeStyle(elements[i]);
	}
	RTE_DD_ExecuteCommand(strCommandToPerform,strCommandValue);
	RTE2_ToggleReusableFragmentsDummy(strBaseElementID, false);
}
function RTE2_SetDirectionOfSelection(strBaseElementID, strDirection)
{
	RTE_SaveSelection(strBaseElementID);
	var rngSelection=RTE_GetSelection(strBaseElementID);
	RTE_RestoreSelection(strBaseElementID);
	var containingBlockElem=RTE_GetNearestContainingElementOfTypes(strBaseElementID, g_aBlockElementNames);
	if (containingBlockElem && containingBlockElem.id !=strBaseElementID)
	{
		RTE_SetDirectionOnElement(containingBlockElem, strDirection);
	}
	else if (rngSelection && rngSelection.item)
	{
		var rngLength=rngSelection.length;
		for (var i=0; i < rngLength;++i)
		{
			var elemCurrent=rngSelection.item(i);
			if ((elemCurrent !=null) && RTE_IsBlockElementName(elemCurrent.tagName))
			{
				RTE_SetDirectionOnElement(elemCurrent, strDirection);
			}
		}
	}
}
function RTE2_ShouldEnableDirection(strBaseElementID)
{
	var containingBlockElem=RTE_GetNearestContainingElementOfTypes(strBaseElementID, g_aBlockElementNames);
	var rngSelection=RTE_GetSelection(strBaseElementID);
	if (containingBlockElem && containingBlockElem.id !=strBaseElementID)
	{
		return true;
	}
	else if (rngSelection && rngSelection.item)
	{
		return true;
	}
	return false;
}
var g_reusableFragments;
var g_reusableFragmentsIds;
function RTE2_ToggleReusableFragmentsDummy(strBaseElementID, switchToDummy)
{
	RTE_SaveSelection(strBaseElementID);
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	instanceVariables.disregardSelectionChange++;
	if (switchToDummy)
	{
		g_reusableFragments=new Array();
		g_reusableFragmentsIds=new Array();
	}
	var editor=RTE2_GetEditorContainer(strBaseElementID);
	var elements=editor.getElementsByTagName("SPAN");
	for (var i=0; i < elements.length;++i)
	{
		var span=elements[i];
		if (span.id==g_strRTE2ReusableFragmentCommonToken)
		{
			if (switchToDummy)
			{
				g_reusableFragments.push(span.innerHTML);
				g_reusableFragmentsIds.push(span.getAttribute("fragmentid"));
				span.removeAttribute("className");
				span.removeAttribute("contentEditable");
				span.removeAttribute("fragmentid");
				span.innerHTML="foo";
			}
			else
			{
				if (span.firstChild.nodeName !="#text")
				{
					var newOuterNode=span.firstChild.cloneNode(false);
					span.parentNode.replaceChild(newOuterNode, span);
					newOuterNode.appendChild(span);
				}
				span.innerHTML=g_reusableFragments.shift();
				span.setAttribute("className", "ms-reusableTextView");
				span.setAttribute("contentEditable", false);
				span.setAttribute("fragmentid", g_reusableFragmentsIds.shift());
			}
		}
	}
	if (!switchToDummy)
	{
		g_reusableFragments=null;
		g_reusableFragmentsIds=null;
	}
	instanceVariables.disregardSelectionChange--;
	RTE_RestoreSelection(strBaseElementID);
}
function RTE2_HideValidationError(inputId)
{
	var autoCorrectButton=document.getElementById(inputId+"____autoCorrect");
	if (autoCorrectButton)
	{
		if (autoCorrectButton.parentElement)
		{
			autoCorrectButton.parentElement.style.display="none";
			if (autoCorrectButton.parentElement.previousSibling)
			{
				autoCorrectButton.parentElement.previousSibling.style.display="none";
			}
		}
	}
	var redHr=document.getElementById(inputId+"_hr");
	if (redHr !=null)
	{
		redHr.style.display="none";
	}
	try
	{
		var outerSpan=document.getElementById(inputId).parentElement.parentElement.parentElement.parentElement;
		var innerSpans=outerSpan.getElementsByTagName("SPAN");
		for (var i=0; i < innerSpans.length;++i)
		{
			if (innerSpans[i].className=="ms-formvalidation")
			{
				innerSpans[i].style.display="none";
			}
		}
	}
	catch (e) {}
}

