var L_CutToolTip_TEXT="Cut (Ctrl+X)";
var L_CopyToolTip_TEXT="Copy (Ctrl+C)";
var L_PasteToolTip_TEXT="Paste (Ctrl+V)";
var L_RemoveFormatToolTip_TEXT="Clear Format (Ctrl+Space)";
var L_BoldToolTip_TEXT="Bold (Ctrl+B)";
var L_ItalicToolTip_TEXT="Italic (Ctrl+I)";
var L_UnderlineToolTip_TEXT="Underline (Ctrl+U)";
var L_JustifyLeftToolTip_TEXT="Align Left (Ctrl+L)";
var L_JustifyCenterToolTip_TEXT="Center (Ctrl+E)";
var L_JustifyRightToolTip_TEXT="Align Right (Ctrl+R)";
var L_OrderedListToolTip_TEXT="Numbered List (Ctrl+Shift+E)";
var L_UnorderedListToolTip_TEXT="Bulleted List (Ctrl+Shift+L)";
var L_OutdentToolTip_TEXT="Decrease Indent (Ctrl+Shift+M)";
var L_IndentToolTip_TEXT="Increase Indent (Ctrl+M)";
var L_ForeColorToolTip_TEXT="Text Color (Ctrl+Shift+C)";
var L_BackColorToolTip_TEXT="Text Highlight Color (Ctrl+Shift+W)";
var L_LTRToolTip_TEXT="Left-to-Right (Ctrl+Shift+>)";
var L_RTLToolTip_TEXT="Right-to-Left (Ctrl+Shift+<)";
var L_CreateLinkToolTip_TEXT="Open a new window to Insert Hyperlink (Ctrl+K)";
var L_InsertImageToolTip_TEXT="Open a new window to Insert Image (Ctrl+Shift+G)";
var L_HtmlSourceToolTip_TEXT="Edit HTML Source";
var L_FontNameLabel_TEXT="Font";
var L_FontNameToolTip_TEXT="Font (Ctrl+Shift+F)";
var L_FontSizeLabel_TEXT="Size";
var L_FontSizeToolTip_TEXT="Font Size (Ctrl+Shift+P)";
var L_InsertTableToolTip_TEXT="Open a new window to Insert Table (Ctrl+Alt+T)";
var L_InsertTableElementToolTip_TEXT="Insert Table Element";
var L_DeleteTableElementToolTip_TEXT="Delete Table Element";
var L_InsertRowToolTip_TEXT="Insert Row";
var L_InsertRowLabel_TEXT="";
var L_InsertRowAboveLabel_TEXT="Insert Row Above (Ctrl+Alt+Up)";
var L_InsertRowBelowLabel_TEXT="Insert Row Below (Ctrl+Alt+Down)";
var L_InsertColumnToolTip_TEXT="Insert Column";
var L_InsertColumnLabel_TEXT="";
var L_InsertColumnLeftLabel_TEXT="Insert Column Left (Ctrl+Alt+Left)";
var L_InsertColumnRightLabel_TEXT="Insert Column Right (Ctrl+Alt+Right)";
var L_InsertCellToolTip_TEXT="Insert Cell";
var L_InsertCellLabel_TEXT="";
var L_InsertCellLeftLabel_TEXT="Insert Cell Left (Ctrl+Alt+L)";
var L_InsertCellRightLabel_TEXT="Insert Cell Right (Ctrl+Alt+R)";
var L_MergeCellToolTip_TEXT="Merge Cell (Ctrl+Alt+M)";
var L_InvalidMerge_TEXT="Cannot merge cell because the adjacent cells do not have the same height or width of the selected cell. Change the size of the adjacent cells to match the selected cell before attempting to merge the cell again.";
var L_SplitCellToolTip_TEXT="Split Cell (Ctrl+Alt+S)";
var L_DeleteRowToolTip_TEXT="Delete Row (Ctrl+Alt+MINUS SIGN)";
var L_DeleteColumnToolTip_TEXT="Delete Column (Ctrl+Alt+BACKSLASH)";
var L_UndoToolTip_TEXT="Undo (Ctrl+Z)";
var L_RedoToolTip_TEXT="Redo (Ctrl+Y)";
var L_StylesToolTip_TEXT="Styles";
var L_StylesLabel_TEXT="Styles";
var L_ExampleText_TEXT="Example Text";
var L_EditorIFrameTitle_TEXT="Rich Text Editor";
var L_Black_TEXT="Black";
var L_Brown_TEXT="Brown";
var L_OliveGreen_TEXT="Olive Green";
var L_DarkGreen_TEXT="Dark Green";
var L_DarkTeal_TEXT="Dark Teal";
var L_DarkBlue_TEXT="Dark Blue";
var L_Indigo_TEXT="Indigo";
var L_Gray80_TEXT="Gray 80%";
var L_DarkRed_TEXT="Dark Red";
var L_Orange_TEXT="Orange";
var L_DarkYellow_TEXT="Dark Yellow";
var L_Green_TEXT="Green";
var L_Teal_TEXT="Teal";
var L_Blue_TEXT="Blue";
var L_BlueGray_TEXT="Blue Gray";
var L_Gray50_TEXT="Gray 50%";
var L_Red_TEXT="Red";
var L_LightOrange_TEXT="Light Orange";
var L_Lime_TEXT="Lime";
var L_SeaGreen_TEXT="Sea Green";
var L_Aqua_TEXT="Aqua";
var L_LightBlue_TEXT="Light Blue";
var L_Violet_TEXT="Violet";
var L_Gray40_TEXT="Gray 40%";
var L_Pink_TEXT="Pink";
var L_Gold_TEXT="Gold";
var L_Yellow_TEXT="Yellow";
var L_BrightGreen_TEXT="Bright Green";
var L_Turquoise_TEXT="Turquoise";
var L_SkyBlue_TEXT="Sky Blue";
var L_Plum_TEXT="Plum";
var L_Gray25_TEXT="Gray 25%";
var L_Rose_TEXT="Rose";
var L_Tan_TEXT="Tan";
var L_LightYellow_TEXT="Light Yellow";
var L_LightGreen_TEXT="Light Green";
var L_LightTurquoise_TEXT="Light Turquoise";
var L_PaleBlue_TEXT="Pale Blue";
var L_Lavender_TEXT="Lavender";
var L_White_TEXT="White";
var L_Font1_TEXT="Arial";
var L_Font2_TEXT="Courier";
var L_Font3_TEXT="Tahoma";
var L_Font4_TEXT="Times";
var L_Font5_TEXT="Verdana";
var L_Font6_TEXT="";
var L_Font7_TEXT="";
var L_Font8_TEXT="";
var L_BoldKey_TEXT="B";
var L_SelectAllKey_TEXT="A";
var L_BoldShiftKey_TEXT="false";
var L_BoldAltKey_TEXT="false";
var L_ItalicKey_TEXT="I";
var L_ItalicShiftKey_TEXT="false";
var L_ItalicAltKey_TEXT="false";
var L_UnderlineKey_TEXT="U";
var L_UnderlineShiftKey_TEXT="false";
var L_UnderlineAltKey_TEXT="false";
var L_JustifyLeftKey_TEXT="L";
var L_JustifyLeftShiftKey_TEXT="false";
var L_JustifyLeftAltKey_TEXT="false";
var L_JustifyCenterKey_TEXT="E";
var L_JustifyCenterShiftKey_TEXT="false";
var L_JustifyCenterAltKey_TEXT="false";
var L_JustifyRightKey_TEXT="R";
var L_JustifyRightShiftKey_TEXT="false";
var L_JustifyRightAltKey_TEXT="false";
var L_SelectFontNameKey_TEXT="F";
var L_SelectFontNameShiftKey_TEXT="true";
var L_SelectFontNameAltKey_TEXT="false";
var L_SelectFontSizeKey_TEXT="P";
var L_SelectFontSizeShiftKey_TEXT="true";
var L_SelectFontSizeAltKey_TEXT="false";
var L_InsertTableKey_TEXT="T";
var L_InsertTableShiftKey_TEXT="false";
var L_InsertTableAltKey_TEXT="true";
var L_SplitCellKey_TEXT="S";
var L_SplitCellShiftKey_TEXT="false";
var L_SplitCellAltKey_TEXT="true";
var L_MergeCellKey_TEXT="M";
var L_MergeCellShiftKey_TEXT="false";
var L_MergeCellAltKey_TEXT="true";
var L_InsertRowAboveKeyCode_TEXT="38";
var L_InsertRowAboveShiftKey_TEXT="false";
var L_InsertRowAboveAltKey_TEXT="true";
var L_InsertRowBelowKeyCode_TEXT="40";
var L_InsertRowBelowShiftKey_TEXT="false";
var L_InsertRowBelowAltKey_TEXT="true";
var L_InsertColumnLeftKeyCode_TEXT="37";
var L_InsertColumnLeftShiftKey_TEXT="false";
var L_InsertColumnLeftAltKey_TEXT="true";
var L_InsertColumnRightKeyCode_TEXT="39";
var L_InsertColumnRightShiftKey_TEXT="false";
var L_InsertColumnRightAltKey_TEXT="true";
var L_InsertCellLeftKey_TEXT="L";
var L_InsertCellLeftShiftKey_TEXT="false";
var L_InsertCellLeftAltKey_TEXT="true";
var L_InsertCellRightKey_TEXT="R";
var L_InsertCellRightShiftKey_TEXT="false";
var L_InsertCellRightAltKey_TEXT="true";
var L_DeleteColumnKeyCode_TEXT="220";
var L_DeleteColumnShiftKey_TEXT="false";
var L_DeleteColumnAltKey_TEXT="true";
var L_DeleteRowKeyCode_TEXT="189";
var L_DeleteRowShiftKey_TEXT="false";
var L_DeleteRowAltKey_TEXT="true";
var L_OutdentKey_TEXT="M";
var L_OutdentShiftKey_TEXT="true";
var L_OutdentAltKey_TEXT="false";
var L_IndentKey_TEXT="M";
var L_IndentShiftKey_TEXT="false";
var L_IndentAltKey_TEXT="false";
var L_UnorderedListKey_TEXT="L";
var L_UnorderedListShiftKey_TEXT="true";
var L_UnorderedListAltKey_TEXT="false";
var L_OrderedListKey_TEXT="E";
var L_OrderedListShiftKey_TEXT="true";
var L_OrderedListAltKey_TEXT="false";
var L_CreateLinkKey_TEXT="K";
var L_CreateLinkShiftKey_TEXT="false";
var L_CreateLinkAltKey_TEXT="false";
var L_SelectForeColorKey_TEXT="C";
var L_SelectForeColorShiftKey_TEXT="true";
var L_SelectForeColorAltKey_TEXT="false";
var L_SelectBackColorKey_TEXT="W";
var L_SelectBackColorShiftKey_TEXT="true";
var L_SelectBackColorAltKey_TEXT="false";
var L_InsertImageKey_TEXT="G";
var L_InsertImageShiftKey_TEXT="true";
var L_InsertImageAltKey_TEXT="false";
var L_HtmlSourceKey_TEXT="S";
var L_HtmlSourceShiftKey_TEXT="true";
var L_HtmlSourceAltKey_TEXT="false";
var L_LTRKey_VALUE=190;
var L_RTLKey_VALUE=188;
var g_strRTEToolbarClassName="ms-rtetoolbarmenu";
var g_strRTEUnselectedClassName="ms-rtetoolbarunsel";
var g_strRTESelectedClassName="ms-rtetoolbarsel";
var g_strRTEDisabledClassName="ms-rtetoolbardis";
var g_strRTEHoverClassName="ms-rtetoolbarhov";
var g_strRTETextEditorPullDownMenuID="RTETextEditorPullDownMenu";
var g_strRTEDialogHelperID="RTEDialogHelper";
var g_strRTECutMnemonic="Cut";
var g_strRTECopyMnemonic="Copy";
var g_strRTEPasteMnemonic="Paste";
var g_strRTERemoveFormatMnemonic="RemoveFormat";
var g_strRTEFontNameMnemonic="FontName";
var g_strRTEFontSizeMnemonic="FontSize";
var g_strRTEBoldMnemonic="Bold";
var g_strRTEItalicMnemonic="Italic";
var g_strRTEUnderlineMnemonic="Underline";
var g_strRTEJustifyLeftMnemonic="JustifyLeft";
var g_strRTEJustifyCenterMnemonic="JustifyCenter";
var g_strRTEJustifyRightMnemonic="JustifyRight";
var g_strRTEOrderedListMnemonic="InsertOrderedList";
var g_strRTEUnorderedListMnemonic="InsertUnorderedList";
var g_strRTEOutdentMnemonic="Outdent";
var g_strRTEIndentMnemonic="Indent";
var g_strRTEForeColorMnemonic="ForeColor";
var g_strRTEBackColorMnemonic="BackColor";
var g_strRTELTRMnemonic="LTR";
var g_strRTERTLMnemonic="RTL";
var g_strRTECreateLinkMnemonic="CreateLink";
var g_strRTEInsertImageMnemonic="InsertImage";
var g_strRTEHtmlSourceMnemonic="HtmlSource";
var g_strRTEInsertTableMnemonic="insert_table";
var g_strRTEInsertTableElementMnemonic="InsertTableElement";
var g_strRTEDeleteTableElementMnemonic="DeleteTableElement";
var g_strRTEInsertRowMnemonic="insert_row";
var g_strRTEInsertRowAbove="InsertRowAbove";
var g_strRTEInsertRowBelow="InsertRowBelow";
var g_strRTEInsertColumnMnemonic="insert_column";
var g_strRTEInsertColumnLeft="InsertColumnLeft";
var g_strRTEInsertColumnRight="InsertColumnRight";
var g_strRTEInsertCellMnemonic="insert_cell";
var g_strRTEInsertCellLeft="InsertCellLeft";
var g_strRTEInsertCellRight="InsertCellRight";
var g_strRTEDeleteRow="delete_row";
var g_strRTEDeleteColumn="delete_column";
var g_strRTEMergeCellMnemonic="merge_cell";
var g_strRTESplitCellMnemonic="split_cell";
var g_strRTEFormatBlockMnemonic="FormatBlock";
var g_strRTEStylesMnemonic="styles";
var g_strRTEUndoMnemonic="Undo";
var g_strRTERedoMnemonic="Redo";
var g_strRTERestrictedModeAttributeName="RestrictedMode";
var g_strRTESimpleTextOnlyAttributeName="SimpleTextOnly";
var g_strRTEUseDynamicHeightSizing="UseDynamicHeightSizing";
var g_strRTEUseDynamicWidthSizing="UseDynamicWidthSizing";
var g_strRTEMaxHeightSizeAttributeName="MaxHeightSize";
var g_strRTEMinHeightSizeAttributeName="MinHeightSize";
var g_strRTEMaxWidthSizeAttributeName="MaxWidthSize";
var g_strRTEMinWidthSizeAttributeName="MinWidthSize";
var g_strRTEAllowHyperlinkAttributeName="AllowHyperlink";
var g_strRTEBaseElementIDAttributeName="BaseElementID";
var g_strRTEWebLocaleAttributeName="WebLocale";
var g_strRTEButtonMnemonicAttributeName="ButtonMnemonic";
var g_strRTECommandToExecuteAttributeName="CommandToExecute";
var g_strRTECommandValueAttributeName="CommandValue";
var g_strRTEFunctionToExecuteAttributeName="FunctionToExecute";
var g_strRTEFunctionParameterToExecuteAttributeName="FunctionParameterToExecute";
var g_strRTEMenuItemBaseName="MenuItem";
var g_strRTEMenuItemAttributeName="MenuItem";
var g_strRTEMenuOpeningAttributeName="MenuOpening";
var g_strRTEMenuTableElementName="MenuTable";
var g_strRTEBegBoldItalicToken="%BEGBI%";
var g_strRTEEndBoldItalicToken="%ENDBI%";
var g_strRTEFontNameToken="%FONTNAME%";
var g_strRTEFontSizeToken="%FONTSIZE%";
var g_ntRTEElement=1;
var g_ntRTEText=3;
var g_iLineHeight=14;
var g_iCharWidth=7;
var g_iDefaultMaxHeightSize=10;
var g_iDefaultMaxWidthSize=10;
var g_iDefaultMinWidthSize=0;
var g_iDefaultMinHeightSize=0;
var g_rgstRTETextEditorSelectionType=new Array();
var g_rgrngRTETextEditorSelection=new Array();
var g_RTE_Dialog_Width="400";
var g_RTE_Dialog_Height="152";
function RTE_DialogResize()
{
	var w=window.document.body;
	if (w.scrollWidth > g_RTE_Dialog_Width)
	{
		window.dialogWidth=w.scrollWidth+"px";
	}
	if (w.scrollHeight > g_RTE_Dialog_Height)
	{
		 window.dialogHeight=w.scrollHeight+"px";
	}
}
function RTE_SaveSelection(strBaseElementID)
{
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	if (instanceVariables !=null && instanceVariables.overrides.SaveSelection !=null)
	{
		return instanceVariables.overrides.SaveSelection(strBaseElementID);
	}
	var docEditor=RTE_GetEditorDocument(strBaseElementID);
	g_rgrngRTETextEditorSelection[strBaseElementID]=docEditor.selection.createRange();
	g_rgstRTETextEditorSelectionType[strBaseElementID]=docEditor.selection.type;
}
var g_fRestoreSelection=false;
function RTE_RestoreSelection(strBaseElementID)
{
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	if (instanceVariables !=null && instanceVariables.overrides.RestoreSelection !=null)
	{
		return instanceVariables.overrides.RestoreSelection(strBaseElementID);
	}
	var sel=g_rgrngRTETextEditorSelection[strBaseElementID];
	if (null==sel)
	{
		try
		{
			 sel=parent.g_rgrngRTETextEditorSelection[strBaseElementID];
		}
		catch (e) {}
	}
	if (null !=sel)
	{
		g_fRestoreSelection=true;
		sel.select();
		g_fRestoreSelection=false;
	}
}
function RTE_GetSelection(strBaseElementID)
{
	return g_rgrngRTETextEditorSelection[strBaseElementID];
}
var g_oExtendedRichTextSupport;
function RTE_GetEditorInstanceVariables(strBaseElementID)
{
	if (parent.g_oExtendedRichTextSupport !=null)
	{
		g_oExtendedRichTextSupport=parent.g_oExtendedRichTextSupport
	}
	if (g_oExtendedRichTextSupport !=null)
	{
		if (g_oExtendedRichTextSupport.editors[strBaseElementID] !=null)
		{
			return g_oExtendedRichTextSupport.editors[strBaseElementID];
		}
	}
	return null;
}
function RTE_InitializeExtendedRichTextSupport(strBaseElementID)
{
	if (g_oExtendedRichTextSupport==null)
	{
		g_oExtendedRichTextSupport=new Object;
		g_oExtendedRichTextSupport.editors=new Array();
	}
	g_oExtendedRichTextSupport.editors[strBaseElementID]=new Object;
	g_oExtendedRichTextSupport.editors[strBaseElementID].overrides=new Object;
	g_oExtendedRichTextSupport.editors[strBaseElementID].overrides.DisableToolBar=null;
	g_oExtendedRichTextSupport.editors[strBaseElementID].overrides.ResetAllToolBarStates=null;
	g_oExtendedRichTextSupport.editors[strBaseElementID].overrides.GetEditorDocument=null;
	g_oExtendedRichTextSupport.editors[strBaseElementID].overrides.OnKeyDown=null;
	g_oExtendedRichTextSupport.editors[strBaseElementID].overrides.RestoreSelection=null;
	g_oExtendedRichTextSupport.editors[strBaseElementID].overrides.GiveEditorFocus=null;
	g_oExtendedRichTextSupport.editors[strBaseElementID].overrides.GetToolBarDefinition=null;
	g_oExtendedRichTextSupport.editors[strBaseElementID].RenderFontNamesAsText=false;
	g_oExtendedRichTextSupport.editors[strBaseElementID].hoverButton=null;
	g_oExtendedRichTextSupport.editors[strBaseElementID].functions=new Array();
}
var g_elemRTELastTextAreaConverted=null;
var g_strRTETextEditorWithTheFocus=null;
var g_strRTEPrevTextEditor=null;
var g_strRTEEditorFirstFocus=null;
var g_rgstrRTEAllEditorsInThePage=new Array();
var g_fRTEDialogIsOpen=false;
function RTE_GetEditorIFrameID(strBaseElementID)
{
	return strBaseElementID+"_iframe";
}
function RTE_GetEditorTextArea(strBaseElementID)
{
	var elemTextArea=document.getElementById(strBaseElementID);
	return elemTextArea;
}
function RTE_GetEditorIFrame(strBaseElementID)
{
	var ifmEditor=null;
	var doc=document;
	if ((null !=doc.frames) && (doc.frames.length==0) && (doc.parentWindow.parent !=null))
	{
		doc=doc.parentWindow.parent.document;
	}
	if ((null !=doc.frames) && (doc.frames.length > 0))
	{
		var ifmContainer=doc.getElementById(RTE_GetEditorIFrameID(strBaseElementID));
		if (ifmContainer !=null)
		{
			ifmEditor=doc.frames(RTE_GetEditorIFrameID(strBaseElementID));
		}
	}
	return ifmEditor;
}
function RTE_GetEditorElement(strBaseElementID)
{
	var doc=document;
	try
	{
		if ((null !=doc.frames) && (doc.frames.length==0) && (doc.parentWindow.parent !=null))
		{
			doc=doc.parentWindow.parent.document;
		}
	}
	catch(e)
	{
		doc=document;
	}
	var elemEditorIFrame=doc.getElementById(RTE_GetEditorIFrameID(strBaseElementID));
	return elemEditorIFrame;
}
function RTE_GetEditorToolBar(strBaseElementID)
{
	var strToolBarElementID=strBaseElementID+"_toolbar";
	var toolbarObject=document.getElementById(strToolBarElementID);
	return toolbarObject;
}
function RTE_GetEditorDocument(strBaseElementID)
{
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	if (instanceVariables !=null && instanceVariables.overrides.GetEditorDocument !=null)
	{
		return instanceVariables.overrides.GetEditorDocument(strBaseElementID);
	}
	var ifmEditor=RTE_GetEditorIFrame(strBaseElementID);
	if (null==ifmEditor)
	{
		return null;
	}
	var docEditor=ifmEditor.document;
	return docEditor;
}
function RTE_GetWebLocale(strBaseElementID)
{
	return RTE_GetEditorDocument(strBaseElementID).body.getAttribute(g_strRTEWebLocaleAttributeName);
}
function RTE_IsInRestrictedMode(strBaseElementID)
{
	var docEditor=RTE_GetEditorDocument(strBaseElementID);
	if (null !=docEditor.body.getAttribute(g_strRTERestrictedModeAttributeName))
	{
		return true;
	}
	return false;
}
function RTE_IsSimpleTextOnly(strBaseElementID)
{
	var docEditor=RTE_GetEditorDocument(strBaseElementID);
	if (null !=docEditor.body.getAttribute(g_strRTESimpleTextOnlyAttributeName))
	{
		return true;
	}
	return false;
}
function RTE_UseDynamicHeightSizing(strBaseElementID)
{
	var docEditor=RTE_GetEditorDocument(strBaseElementID);
	if (null !=docEditor.body.getAttribute(g_strRTEUseDynamicHeightSizing))
	{
		return true;
	}
	return false;
}
function RTE_MaxHeightSize(strBaseElementID)
{
	var docEditor=RTE_GetEditorDocument(strBaseElementID);
	var nMaxHeightSize=docEditor.body.getAttribute(g_strRTEMaxHeightSizeAttributeName);
	if (null !=nMaxHeightSize)
	{
		return nMaxHeightSize;
	}
	return g_iDefaultMaxHeightSize;
}
function RTE_MaxWidthSize(strBaseElementID)
{
	var docEditor=RTE_GetEditorDocument(strBaseElementID);
	var nMaxWidthSize=docEditor.body.getAttribute(g_strRTEMaxWidthSizeAttributeName);
	if (null !=nMaxWidthSize)
	{
		return nMaxWidthSize;
	}
	return g_iDefaultMaxWidthSize;
}
function RTE_MinHeightSize(strBaseElementID)
{
	var docEditor=RTE_GetEditorDocument(strBaseElementID);
	var nMinHeightSize=docEditor.body.getAttribute(g_strRTEMinHeightSizeAttributeName);
	if (null !=nMinHeightSize)
	{
		return nMinHeightSize;
	}
	return g_iDefaultMinHeightSize;
}
function RTE_MinWidthSize(strBaseElementID)
{
	var docEditor=RTE_GetEditorDocument(strBaseElementID);
	var nMinWidthSize=docEditor.body.getAttribute(g_strRTEMinWidthSizeAttributeName);
	if (null !=nMinWidthSize)
	{
		return nMinWidthSize;
	}
	return g_iDefaultMinWidthSize;
}
function RTE_IsHyperlinkAllowed(strBaseElementID)
{
	var docEditor=RTE_GetEditorDocument(strBaseElementID);
	if (null !=docEditor.body.getAttribute(g_strRTEAllowHyperlinkAttributeName))
	{
		return true;
	}
	return false;
}
function RTE_ShouldShowDirection()
{
	return true;
}
function RTE_EditorWithTheFocus()
{
	return g_strRTETextEditorWithTheFocus;
}
function RTE_PrevEditor()
{
	return g_strRTEPrevTextEditor;
}
function RTE_GetRichEditTextOnly(strBaseElementID)
{
	return RTE_GetEditorDocument(strBaseElementID).body.innerText;
}
function RTE_DocEditor_AdjustHeight(strBaseElementID)
{
	var iMaxHeightSize=RTE_MaxHeightSize(strBaseElementID);
	var iMinHeightSize=RTE_MinHeightSize(strBaseElementID);
	var ifmContainer=RTE_GetEditorElement(strBaseElementID);
	if (ifmContainer !=null)
	{
		var ifmEditor=RTE_GetEditorIFrame(strBaseElementID);
		var contentheight=ifmEditor.document.body.scrollHeight;
		var clientHeight=ifmEditor.document.body.clientHeight;
		var bodyHeight=ifmEditor.document.body.offsetHeight;
		var MaxHeightPixelSize=iMaxHeightSize * g_iLineHeight;
		var MinHeightPixelSize=iMinHeightSize * g_iLineHeight;
		contentheight=((contentheight < g_iLineHeight)? g_iLineHeight: contentheight);
		if (clientHeight !=contentheight && (contentheight <=MaxHeightPixelSize || clientHeight < MaxHeightPixelSize) && (contentheight >=MinHeightPixelSize || clientHeight > MinHeightPixelSize))
		{
			var newHeight=bodyHeight+((contentheight > MaxHeightPixelSize)? MaxHeightPixelSize : contentheight)   - clientHeight;
			if (newHeight < MinHeightPixelSize)
			{
				newHeight=MinHeightPixelSize;
			}
			ifmContainer.style.height=newHeight;
		}
	}
}
function RTE_DocEditor_AdjustWidth(strBaseElementID)
{
	var iMaxWidthSize=RTE_MaxWidthSize(strBaseElementID);
	var iMinWidthSize=RTE_MinWidthSize(strBaseElementID);
	var ifmContainer=RTE_GetEditorElement(strBaseElementID);
	if (ifmContainer !=null)
	{
		var ifmEditor=RTE_GetEditorIFrame(strBaseElementID);
		var contentWidth=ifmEditor.document.body.scrollWidth;
		var clientWidth=ifmEditor.document.body.clientWidth;
		var bodyWidth=ifmEditor.document.body.offsetWidth;
		var MaxWidthPixelSize=iMaxWidthSize * g_iCharWidth;
		var MinWidthPixelSize=iMinWidthSize * g_iCharWidth;
		contentWidth=((contentWidth < g_iCharWidth)? g_iCharWidth: contentWidth);
		if (clientWidth !=contentWidth && (contentWidth <=MaxWidthPixelSize || clientWidth < MaxWidthPixelSize) && (contentWidth >=MinWidthPixelSize || clientWidth > MinWidthPixelSize))
		{
			var newWidth=ifmContainer.style.width=bodyWidth+((contentWidth > MaxWidthPixelSize)? MaxWidthPixelSize : contentWidth)   - clientWidth;
			if (newWidth < MinWidthPixelSize)
			{
				newWidth=MinWidthPixelSize;
			}
			ifmContainer.style.width=newWidth;
		}
	}
}
function RTE_SetVisibiltyStyle(strBaseElementID,strVisiblity)
{
	var ifmContainer=RTE_GetEditorElement(strBaseElementID);
	var toolbarObject=RTE_GetEditorToolBar(strBaseElementID);
	if (null !=ifmContainer && null !=toolbarObject)
	{
		toolbarObject.style.visibility=strVisiblity;
		ifmContainer.style.visibility=strVisiblity;
	}
}
function RTE_SetWidthHeight(strBaseElementID,width,height)
{
	var ifmContainer=RTE_GetEditorElement(strBaseElementID);
	var toolbarObject=RTE_GetEditorToolBar(strBaseElementID);
	if (null !=toolbarObject && null !=ifmContainer)
	{
		if (width < 0)
		{
			width=0;
		}
		ifmContainer.style.width=width;
		var containterHeight=height - toolbarObject.offsetHeight;
		if (containterHeight < 0)
		{
			containterHeight=0;
		}
		ifmContainer.style.height=containterHeight;
	}
}
function RTE_GetMinimumHeight(strBaseElementID)
{
	var toolbarHeight=0;
	var toolbarObject=RTE_GetEditorToolBar(strBaseElementID);
	if (null !=toolbarObject)
	{
		toolbarHeight=toolbarObject.offsetHeight;
	}
	return toolbarHeight;
}
function RTE_GetMinimumWidth(strBaseElementID)
{
	var toolbarWidth=0;
	var toolbarObject=RTE_GetEditorToolBar(strBaseElementID);
	if (null !=toolbarObject)
	{
		toolbarWidth=toolbarObject.offsetWidth;
	}
	return toolbarWidth;
}
function RTE_GetIFrameContents(strBaseElementID)
{
	var strHtml, strText;
	var docEditor=RTE_GetEditorDocument(strBaseElementID);
	if (null==docEditor)
		return;
	strHtml=docEditor.body.innerHTML;
	return strHtml;
}
function RTE_GiveEditorFocus(strBaseElementID)
{
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	if (instanceVariables !=null && instanceVariables.overrides.GiveEditorFocus !=null)
	{
		return instanceVariables.overrides.GiveEditorFocus(strBaseElementID);
	}
	RTE_GetEditorIFrame(strBaseElementID).focus();
}
function RTE_GiveEditorFirstFocus(strBaseElementID)
{
	RTE_GiveEditorFocus(strBaseElementID);
	g_strRTEEditorFirstFocus=strBaseElementID;
}
function RTE_ConvertTextAreaToRichEdit(
			strBaseElementID,
			fRestrictedMode,
			fAllowHyperlink,
			strDirection,
			strWebLocale,
			fSimpleTextOnly,
			fEditable,
			fUseDynamicHeightSizing,
			iMaxHeightSize,
			iMinHeightSize,
			strMode,
			urlWebRoot,
			strThemeUrl,
			strBodyClassName,
			fAllowRelativeLinks,
			strBaseUrl,
			fUseDynamicWidthSizing,
			iMaxWidthSize,
			iMinWidthSize,
			fEnforceAccessibilityMode,
			fPreserveScript,
			fHookUpEvents,
			fGenerateToolbar
			)
{
	;
	if (!(browseris.ie5up && browseris.win32))
	{
		return;
	}
	fEnforceAccessibilityMode=(fEnforceAccessibilityMode==null || fEnforceAccessibilityMode);
	if (IsAccessibilityFeatureEnabled() && fEnforceAccessibilityMode)
	{
		return;
	}
	fSimpleTextOnly=(fSimpleTextOnly !=null && fSimpleTextOnly);
	fRestrictedMode=(fSimpleTextOnly)? true : fRestrictedMode;
	fEditable=(null==fEditable)?true:fEditable;
	fUseDynamicHeightSizing=		(fUseDynamicHeightSizing !=null && fUseDynamicHeightSizing);
	iMaxHeightSize=		(null==iMaxHeightSize || iMaxHeightSize <=0) ?
		g_iDefaultMaxHeightSize : iMaxHeightSize;
	iMinHeightSize=		(null==iMinHeightSize || iMinHeightSize <=0 || iMinHeightSize > iMaxHeightSize) ?
		g_iDefaultMinHeightSize : iMinHeightSize;
	fUseDynamicWidthSizing=(fUseDynamicWidthSizing !=null && fUseDynamicWidthSizing);
	iMaxWidthSize=(null==iMaxWidthSize || iMaxWidthSize <=0) ?
		g_iDefaultMaxWidthSize : iMaxWidthSize;
	iMinWidthSize=(null==iMinWidthSize || iMinWidthSize <=0 || iMinWidthSize > iMaxWidthSize) ?
		g_iDefaultMinWidthSize : iMinWidthSize;
	fHookUpEvents=(null==fHookUpEvents || fHookUpEvents);
	fGenerateToolbar=(null==fGenerateToolbar || fGenerateToolbar);
	if (strMode !="FullHtml")
		strMode="Compatible";
	if (null==strBodyClassName)
	{
		strBodyClassName="ms-formbody";
	}
	aSettings=new Array();
	RTE_InitializeExtendedRichTextSupport(strBaseElementID);
	var variables=RTE_GetEditorInstanceVariables(strBaseElementID);
	var fFullHtml=false;
	if (strMode=="FullHtml")
	{
		fFullHtml=true;
		fAllowHyperlink=false;
		variables.overrides.GetToolBarDefinition=			RTE_FullHtmlToolBarDefinitionFactory(
				fEnforceAccessibilityMode );
		aSettings.fRestrictedMode=true;
		aSettings.fAllowHyperlink=false;
		aSettings.fIsVisible=true;
	}
	else
	{
		aSettings.fRestrictedMode=fRestrictedMode;
		aSettings.fAllowHyperlink=fAllowHyperlink;
		aSettings.fIsVisible=!fSimpleTextOnly;
	}
	aSettings.urlWebRoot=(urlWebRoot==null || urlWebRoot=="/") ?
		"" : urlWebRoot;
	aSettings.fAllowRelativeLinks=(fAllowRelativeLinks==null) ? false : fAllowRelativeLinks;
	aSettings.fPreserveScript=(fPreserveScript==null) ? false : fPreserveScript;
	variables.aSettings=aSettings;
	var elemTextArea=RTE_GetEditorTextArea(strBaseElementID);
	var strHtmlToEdit=elemTextArea.innerText;
	if ((null==strHtmlToEdit) || (0==strHtmlToEdit.length))
	{
		strHtmlToEdit="<div></div>";
	}
	g_elemRTELastTextAreaConverted=elemTextArea;
	window.attachEvent("onload",
		new Function(
			"RTE_TextAreaWindow_OnLoad('"+strBaseElementID+"');"));
	var aHtmlToAppend=new Array();
	if (fGenerateToolbar)
	{
		aHtmlToAppend.push(RTE_GenerateToolBarHtmlFromSettings(
			strBaseElementID, strWebLocale, elemTextArea, aSettings));
	}
	aHtmlToAppend.push(RTE_GenerateIFrameEditorHtml(
		strBaseElementID, elemTextArea, fRestrictedMode, fAllowHyperlink));
	var strHtmlToAppend=aHtmlToAppend.join("");
	elemTextArea.insertAdjacentHTML("afterEnd", strHtmlToAppend);
	if (fHookUpEvents)
	{
		elemTextArea.onfocus=			new Function("RTE_TextArea_OnFocus('"+strBaseElementID+"')");
		elemTextArea.style.display="none";
		variables.onBeforeUnloadFunc=			new Function(
				"RTE_TransferIFrameContentsToTextArea('"+				strBaseElementID+"');");
		window.attachEvent("onbeforeunload", variables.onBeforeUnloadFunc);
		var findForm=elemTextArea;
		while (findForm.tagName!="FORM" && findForm.tagName!="WINDOW")
		{
			findForm=findForm.parentElement;
		}
		findForm.attachEvent("onsubmit",
			new Function(
				"RTE_TransferIFrameContentsToTextArea('"+strBaseElementID+"');"));
	}
	var aEditorHtml=new Array();
	aEditorHtml.push("<html><head>");
	if (null !=strBaseUrl && true==fAllowRelativeLinks)
	{
		 aEditorHtml.push("<base href=\"");
		 aEditorHtml.push(strBaseUrl);
		 aEditorHtml.push("\"/>");
	}
	aEditorHtml.push("<link rel=\"stylesheet\" type=\"text/css\" href=\"");
	aEditorHtml.push(RTE_GetServerRelativeStylesheetUrl("core.css", strWebLocale));
	aEditorHtml.push("\">");
	if (null !=strThemeUrl)
	{
		aEditorHtml.push("<link rel=\"stylesheet\" type=\"text/css\" href=\"");
		aEditorHtml.push(strThemeUrl);
		aEditorHtml.push("\">");
	}
	aEditorHtml.push("</head><body class=\"");
	aEditorHtml.push(strBodyClassName);
	aEditorHtml.push("\" style=\"background-color: white;border:none;\"></body></html>");
	var strEditorHtml=aEditorHtml.join("");
	var docEditor=RTE_GetEditorDocument(strBaseElementID);
	docEditor.designMode=(fEditable?"on":"off");
	docEditor=RTE_GetEditorDocument(strBaseElementID);
	docEditor.open("text/html", "replace");
	docEditor.write(strEditorHtml);
	docEditor.close();
	docEditor.body.scroll="yes";
	docEditor.body.wordWrap=false;
	docEditor.body.contentEditable=true;
	docEditor.body.innerHTML=strEditorHtml;
   	if (fHookUpEvents)
	{
		RTE_EventHookUp(strBaseElementID);
	}
	if (fRestrictedMode)
	{
		docEditor.body.ondragenter=new Function("RTE_OnDragEnter(this);");
		docEditor.body.ondragover=new Function("RTE_OnDragOver(this);");
		docEditor.body.ondragdrop=new Function("RTE_OnDrop(this);");
	}
	if (strDirection !="" &&
		strDirection !="None")
	{
		docEditor.dir=strDirection;
	}
	else
	{
		docEditor.dir=document.dir;
	}
	if (fRestrictedMode && !fFullHtml)
	{
		docEditor.body.setAttribute(
			g_strRTERestrictedModeAttributeName, "true");
		docEditor.body.onpaste=			new Function("RTE_OnPaste_Restricted('"+				strBaseElementID+"', this);");
	}
	if (fSimpleTextOnly)
	{
		docEditor.body.setAttribute(
			g_strRTESimpleTextOnlyAttributeName, "true");
	}
	if (fUseDynamicHeightSizing || fUseDynamicWidthSizing)
	{
		var strFuncCall="";
		if (fUseDynamicHeightSizing)
		{
			docEditor.body.style.wordWrap="break-word";
			docEditor.body.setAttribute(g_strRTEUseDynamicHeightSizing, "true");
			docEditor.body.setAttribute(
				g_strRTEMinHeightSizeAttributeName, iMinHeightSize);
			docEditor.body.setAttribute(
				g_strRTEMaxHeightSizeAttributeName, iMaxHeightSize);
		   strFuncCall="RTE_DocEditor_AdjustHeight('"+strBaseElementID+"');";
		}
		if (fUseDynamicWidthSizing)
		{
			docEditor.body.style.wordWrap="normal";
			docEditor.body.setAttribute(g_strRTEUseDynamicWidthSizing, "true");
			docEditor.body.setAttribute(
				g_strRTEMaxWidthSizeAttributeName, iMaxHeightSize);
			docEditor.body.setAttribute(
				g_strRTEMinWidthSizeAttributeName, iMinHeightSize);
			strFuncCall+="RTE_DocEditor_AdjustWidth('"+strBaseElementID+"');";
		}
		var ifmEditor=RTE_GetEditorIFrame(strBaseElementID);
		docEditor.attachEvent(
			"onkeydown",
			new Function(
			strFuncCall));
		ifmEditor.attachEvent(
			"onscroll",
			new Function(
			strFuncCall));
		window.attachEvent(
			 "onload",
			 new Function(
			strFuncCall));
		if (fHookUpEvents)
		{
			if (fUseDynamicHeightSizing)
			{
				RTE_DocEditor_AdjustHeight(strBaseElementID);
			}
			if (fUseDynamicWidthSizing)
			{
				RTE_DocEditor_AdjustWidth(strBaseElementID);
			}
		}
	}
	if (fAllowHyperlink)
	{
		docEditor.body.setAttribute(
			g_strRTEAllowHyperlinkAttributeName, "true");
	}
	docEditor.body.setAttribute(
		g_strRTEBaseElementIDAttributeName, strBaseElementID);
	docEditor.body.setAttribute(
		g_strRTEWebLocaleAttributeName, strWebLocale);
	g_rgstrRTEAllEditorsInThePage[g_rgstrRTEAllEditorsInThePage.length]=		strBaseElementID;
	if (fGenerateToolbar)
	{
		RTE_DisableToolBar(strBaseElementID);
			var ifmEditorObj=RTE_GetEditorElement(strBaseElementID);
			ifmEditorObj.tabIndex=elemTextArea.tabIndex;
		RTE_ToolBarMnemonicInitialization(strBaseElementID);
	}
}
function RTE_ToolBarMnemonicInitialization(strBaseElementID)
{
	var buttons=RTE_GetToolBarDefinition(strBaseElementID);
	if (buttons !=null)
	{
		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;
			}
		}
	}
}
function RTE_DeleteEditor(
	strBaseElementID)
{
	var variables=RTE_GetEditorInstanceVariables(strBaseElementID);
	window.detachEvent("onbeforeunload", variables.onBeforeUnloadFunc);
}
function RTE_DisableToolBar(strBaseElementID)
{
	var variables=RTE_GetEditorInstanceVariables(strBaseElementID);
	if (variables !=null && variables.overrides.DisableToolBar !=null)
	{
		return variables.overrides.DisableToolBar(strBaseElementID);
	}
	var buttons=RTE_GetToolBarDefinition(strBaseElementID);
	if (buttons !=null)
	{
		for (var i=0; i < buttons.length; i++)
		{
			if (buttons[i].strMnemonic !=undefined)
			{
				RTE_TB_SetButtonDisabled(
					RTE_TB_GetToolBarButton(
						strBaseElementID, buttons[i].strMnemonic));
			}
		}
	}
}
function RTE_ResetAllToolBarStates(strBaseElementID)
{
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	if (instanceVariables !=		null && instanceVariables.overrides.ResetAllToolBarStates !=null)
	{
		return instanceVariables.overrides.ResetAllToolBarStates(
			strBaseElementID);
	}
	ifmMenu=RTE_DD_GetMenuFrame();
	if (ifmMenu && ifmMenu.document==document)
	{
		return;
	}
	if ((browseris.ie55up) &&
		(RTE_EditorWithTheFocus() !=strBaseElementID) &&
		(RTE_ToolBarButtonWithTheFocus()==null) &&
		(!RTE_DD_MenuIsOpen()) &&
		(!g_fRTEDialogIsOpen))
	{
		RTE_DisableToolBar(strBaseElementID);
		return;
	}
	var aElemChain=RTE_GetCurrentSelectionChain(strBaseElementID);
	var docEditor=RTE_GetEditorDocument(strBaseElementID);
	var hasActiveSelection=RTE_HasActiveSelection(docEditor);
	var buttons=RTE_GetToolBarDefinition(strBaseElementID);
	if (buttons !=null)
	{
		for (var i=0; i < buttons.length; i++)
		{
			if (buttons[i].enabler !=undefined)
			{
				buttons[i].enabler.SetEnabled(
					strBaseElementID, docEditor, aElemChain,
					buttons[i].strMnemonic);
			}
		}
	}
}
function RTE_EventHookUp(strBaseElementID)
{
	var docEditor=RTE_GetEditorDocument(strBaseElementID);
	docEditor.body.onkeydown=		new Function("RTE_OnKeyDown('"+strBaseElementID+"', this)");
	docEditor.body.onkeyup=		new Function("RTE_OnKeyUp('"+strBaseElementID+"', this)");
	docEditor.body.onmouseup=		new Function("RTE_OnMouseUp('"+strBaseElementID+"')");
	docEditor.body.onselectstart=		new Function("RTE_OnSelectStart('"+strBaseElementID+"', this)");
	docEditor.body.oncontextmenu=new Function("return false");
	RTE_GetEditorElement(strBaseElementID).onblur=		new Function("RTE_OnBlur('"+strBaseElementID+"');");
	RTE_GetEditorElement(strBaseElementID).onfocus=		new Function("RTE_OnFocus('"+strBaseElementID+"');");
}
function RTE_TransferTextAreaContentsToIFrame(strBaseElementID)
{
	var elemTextArea=RTE_GetEditorTextArea(strBaseElementID);
	var strHtmlToEdit=elemTextArea.innerText;
	var elemSave=document.getElementById(strBaseElementID+"_spSave");
	if (elemSave !=null && elemSave.value !="")
		strHtmlToEdit=elemSave.value;
	var docEditor=RTE_GetEditorDocument(strBaseElementID);
	if (null==docEditor)
		return;
	if ((null==strHtmlToEdit) || (0==strHtmlToEdit.length))
	{
		strHtmlToEdit="<div></div>";
	}
	var fPreserveScript=false;
	var variables=RTE_GetEditorInstanceVariables(strBaseElementID);
	if (variables !=null && variables.aSettings !=null)
	{
		fPreserveScript=aSettings.fPreserveScript;
	}
	if (fPreserveScript)
	{
		strHtmlToEdit="<body>"+strHtmlToEdit;
	}
	docEditor.body.innerHTML=strHtmlToEdit;
	if (strBaseElementID==g_strRTEEditorFirstFocus)
	{
	   var tr=docEditor.body.createTextRange();
	   tr.collapse(true);
	   tr.select();
	   g_strRTEEditorFirstFocus=null;
	}
}
function RTE_TransferIFrameContentsToTextArea(strBaseElementID)
{
	var strHtml, strText;
	var elemTextArea=RTE_GetEditorTextArea(strBaseElementID);
	var docEditor=RTE_GetEditorDocument(strBaseElementID);
	if (null==docEditor)
		return;
	strHtml=docEditor.body.innerHTML;
	var elemSave=document.getElementById(strBaseElementID+"_spSave");
	if (elemSave !=null)
	{
		elemSave.value=strHtml;
		elemTextArea.innerText="<div></div>";
	}
	else
	{
		elemTextArea.innerText=strHtml;
	}
}
function RTE_TextAreaWindow_OnLoad(strBaseElementID)
{
	;
	RTE_TransferTextAreaContentsToIFrame(strBaseElementID);
	RTE_SaveSelection(strBaseElementID);
}
function RTE_TextArea_OnFocus(strBaseElementID)
{
	;
	RTE_GiveEditorFocus(strBaseElementID);
}
function RTE_OnFocus(strBaseElementID)
{
	;
	g_strRTETextEditorWithTheFocus=strBaseElementID;
	RTE_GetEditorDocument(strBaseElementID).body.contentEditable=true;
	if ((g_strRTEPrevTextEditor !=null) && (g_strRTEPrevTextEditor.length > 0) && (g_strRTEPrevTextEditor !=strBaseElementID))
	{
		RTE_DisableToolBar(g_strRTEPrevTextEditor);
	}
	RTE_StartResetToolBarTimer(strBaseElementID);
}
function RTE_OnBlur(strBaseElementID)
{
	;
	try
	{
		RTE_SaveSelection(strBaseElementID);
	}
	catch (e)
	{
	}
	g_strRTEPrevTextEditor=g_strRTETextEditorWithTheFocus;
	g_strRTETextEditorWithTheFocus=null;
	RTE_StartResetToolBarTimer(strBaseElementID);
	RTE_DD_CloseMenu();
	if ((RTE_ToolBarButtonWithTheFocus()==null) &&
		(!g_fRTEDialogIsOpen))
	{
		RTE_DisableToolBar(strBaseElementID);
		RTE_DD_CloseMenu();
	}
}
function RTE_OnDragEnter(elemThis)
{
	;
	var evtThis=elemThis.document.parentWindow.event;
	if (null !=evtThis)
	{
		evtThis.dataTransfer.dropEffect="none";
		evtThis.returnValue=false;
	}
}
function RTE_OnDragOver(elemThis)
{
	;
	var evtThis=elemThis.document.parentWindow.event;
	if (null !=evtThis)
	{
		evtThis.dataTransfer.dropEffect="none";
		evtThis.returnValue=false;
	}
}
function RTE_OnDrop(elemThis)
{
	;
	var evtThis=elemThis.document.parentWindow.event;
	if (null !=evtThis)
	{
		evtThis.dataTransfer.dropEffect="none";
		evtThis.returnValue=false;
	}
}
function RTE_FInterpretTextAsBoolean(strBoolVal)
{
   if (strBoolVal.toLowerCase()=="true")
	  return true;
   else
	  return false;
}
function RTE_OnKeyDown(strBaseElementID, elem)
{
	if (RTE_DD_MenuIsOpen())
	{
		RTE_DD_OnKeyDown(elem);
		return;
	}
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	if (instanceVariables !=null && instanceVariables.overrides.OnKeyDown !=null)
	{
		return instanceVariables.overrides.OnKeyDown(strBaseElementID, elem);
	}
	RTE_SaveSelection(strBaseElementID);
	var fRestrictedMode=RTE_IsInRestrictedMode(strBaseElementID);
	var fSimpleTextOnly=RTE_IsSimpleTextOnly(strBaseElementID);
	var fAllowHyperlink=RTE_IsHyperlinkAllowed(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 fToolbarNavigate=false;
   if (browseris.ie5up && !browseris.ie55up && (!fCtrlKey && !fAltKey && !fShiftKey))
   {
	  switch (nKeyCode)
	  {
		 case 9:
			var tr=RTE_GetEditorDocument(strBaseElementID).body.createTextRange();
			tr.collapse(true);
			tr.select();
			break;
	  }
   }
	if (!fCtrlKey && !fAltKey && fShiftKey)
	{
		switch (nKeyCode)
		{
			case 9:
				RTE_GetEditorDocument(strBaseElementID).body.contentEditable=false;
				var tr=RTE_GetEditorDocument(strBaseElementID).body.createTextRange();
				tr.collapse(true);
				tr.select();
				break;
		}
	}
	else if (!fCtrlKey && !fAltKey && !fShiftKey)
	{
		switch (nKeyCode)
		{
			case 13:
				if (instanceVariables.hoverButton !=null)
				{
					evtSource.returnValue=false;
					instanceVariables.hoverButton.children(0).click();
				}
				break;
		}
	}
	else if (fCtrlKey)
	{
		switch (nKeyCode)
		{
			case 192:
				fToolbarNavigate=true;
				evtSource.returnValue=RTE_MoveFocusBackwards(strBaseElementID, elemDocument.activeElement);
				break;
			case 49:
				fToolbarNavigate=true;
				evtSource.returnValue=RTE_MoveFocusForwards(strBaseElementID, elemDocument.activeElement);
				break;
		}
		if ((L_BoldKey_TEXT.charCodeAt(0)==nKeyCode)
		   && (RTE_FInterpretTextAsBoolean(L_BoldShiftKey_TEXT)==fShiftKey)
		   && (RTE_FInterpretTextAsBoolean(L_BoldAltKey_TEXT )==fAltKey))
		{
			evtSource.returnValue=false;
			if (!fSimpleTextOnly)
			{
				RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEBoldMnemonic).children(0).click();
			}
		}
		else if ((L_SelectAllKey_TEXT.charCodeAt(0)==nKeyCode)
			&& (RTE_FInterpretTextAsBoolean(L_BoldShiftKey_TEXT)==fShiftKey)
			&& (RTE_FInterpretTextAsBoolean(L_BoldAltKey_TEXT )==fAltKey))
		{
			evtSource.returnValue=false;
			var docEditor=RTE_GetEditorDocument(strBaseElementID);
			var docTextRange=docEditor.body.createTextRange();
			docTextRange.select();
		}
		else if (( L_ItalicKey_TEXT.charCodeAt(0)==nKeyCode)
		   && (RTE_FInterpretTextAsBoolean(L_ItalicShiftKey_TEXT)==fShiftKey)
		   && (RTE_FInterpretTextAsBoolean(L_ItalicAltKey_TEXT)==fAltKey))
		{
			evtSource.returnValue=false;
			if (!fSimpleTextOnly)
			{
				RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEItalicMnemonic).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;
			if (!fSimpleTextOnly)
			{
				RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEUnderlineMnemonic).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;
			if (!fSimpleTextOnly)
			{
				RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEJustifyLeftMnemonic).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;
			if (!fSimpleTextOnly)
			{
				RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEJustifyCenterMnemonic).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;
			if (!fSimpleTextOnly)
			{
				RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEJustifyRightMnemonic).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;
			if (!fSimpleTextOnly)
			{
				RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEIndentMnemonic).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;
		   if (!fSimpleTextOnly && (!fRestrictedMode || fAllowHyperlink))
		   {
				RTE_TB_GetToolBarButton(strBaseElementID, g_strRTECreateLinkMnemonic).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;
			if (!fSimpleTextOnly)
			{
				RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEFontNameMnemonic).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;
			if (!fSimpleTextOnly)
			{
				RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEFontSizeMnemonic).children(0).click();
			}
		}
		else if (( L_InsertTableKey_TEXT.charCodeAt(0)==nKeyCode)
		   && (RTE_FInterpretTextAsBoolean(L_InsertTableShiftKey_TEXT)==fShiftKey)
		   && (RTE_FInterpretTextAsBoolean(L_InsertTableAltKey_TEXT)==fAltKey))
		{
			evtSource.returnValue=false;
			if (!fSimpleTextOnly)
			{
				RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEInsertTableMnemonic).children(0).click();
			}
		}
		else if (( L_SplitCellKey_TEXT.charCodeAt(0)==nKeyCode)
		   && (RTE_FInterpretTextAsBoolean(L_SplitCellShiftKey_TEXT)==fShiftKey)
		   && (RTE_FInterpretTextAsBoolean(L_SplitCellAltKey_TEXT)==fAltKey))
		{
			evtSource.returnValue=false;
			if (!fSimpleTextOnly)
			{
				RTE_TB_GetToolBarButton(strBaseElementID, g_strRTESplitCellMnemonic).children(0).click();
			}
		}
		else if (( L_MergeCellKey_TEXT.charCodeAt(0)==nKeyCode)
		   && (RTE_FInterpretTextAsBoolean(L_MergeCellShiftKey_TEXT)==fShiftKey)
		   && (RTE_FInterpretTextAsBoolean(L_MergeCellAltKey_TEXT)==fAltKey))
		{
			evtSource.returnValue=false;
			if (!fSimpleTextOnly)
			{
				RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEMergeCellMnemonic).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;
			if (!fSimpleTextOnly)
			{
				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;
			if (!fSimpleTextOnly)
			{
				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;
			if (!fSimpleTextOnly)
			{
				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;
			if (!fSimpleTextOnly)
			{
				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;
			if (!fSimpleTextOnly)
			{
				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;
			if (!fSimpleTextOnly)
			{
				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;
			if (!fSimpleTextOnly)
			{
				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;
			if (!fSimpleTextOnly)
			{
				RTE_InsertRowBelow(strBaseElementID);
			}
		}
	  else if (( L_SelectForeColorKey_TEXT.charCodeAt(0)==nKeyCode)
		   && (RTE_FInterpretTextAsBoolean(L_SelectForeColorShiftKey_TEXT)==fShiftKey)
		   && (RTE_FInterpretTextAsBoolean(L_SelectForeColorAltKey_TEXT)==fAltKey))
	  {
			evtSource.returnValue=false;
			if (!fSimpleTextOnly)
			{
				RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEForeColorMnemonic).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;
			if (!fSimpleTextOnly)
			{
				RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEBackColorMnemonic).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;
			if (!fSimpleTextOnly)
			{
				RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEUnorderedListMnemonic).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;
			if (!fSimpleTextOnly)
			{
				RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEOrderedListMnemonic).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;
			if (!fSimpleTextOnly)
			{
				RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEOutdentMnemonic).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;
			if (!fRestrictedMode)
			{
				RTE_TB_GetToolBarButton(strBaseElementID, g_strRTEInsertImageMnemonic).children(0).click();
			}
	  }
		else if (( L_LTRKey_VALUE==nKeyCode)
		   && (fShiftKey))
		{
			evtSource.returnValue=false;
			RTE_TB_GetToolBarButton(strBaseElementID, g_strRTELTRMnemonic).children(0).click();
		}
		else if (( L_RTLKey_VALUE==nKeyCode)
		   && (fShiftKey))
		{
			evtSource.returnValue=false;
			RTE_TB_GetToolBarButton(strBaseElementID, g_strRTERTLMnemonic).children(0).click();
		}
	}
	if (!fToolbarNavigate)
	{
		RTE_TB_RemoveLastToolBarHover(strBaseElementID);
	}
}
function RTE_OnKeyUp(strBaseElementID, elem)
{
	;
	RTE_StartResetToolBarTimer(strBaseElementID);
	var evtSource=elem.document.parentWindow.event;
	var nKeyCode=evtSource.keyCode;
	if (nKeyCode==16  ||
		nKeyCode==17  ||
		nKeyCode==9 )
		RTE_SaveSelection(strBaseElementID);
}
function RTE_OnSelectStart(strBaseElementID, elem)
{
	var aChain=RTE_GetCurrentSelectionChain(strBaseElementID);
	if (elem.document.parentWindow.event.ctrlKey &&
		!elem.document.parentWindow.event.shiftKey &&
		RTE_IsElementInChain(aChain, "A"))
	{
		RTE_ClickLink(strBaseElementID);
	}
}
function RTE_OnMouseUp(strBaseElementID)
{
	;
	RTE_SaveSelection(strBaseElementID);
	RTE_DD_CloseMenu();
	RTE_TB_RemoveLastToolBarHover(strBaseElementID);
	RTE_StartResetToolBarTimer(strBaseElementID);
}
function RTE_OnPaste_Restricted(strBaseElementID, elem)
{
	;
	RTE_SaveSelection(strBaseElementID);
	elem.document.parentWindow.event.returnValue=false;
	RTE_RestoreSelection(strBaseElementID);
	var rngSelection=RTE_GetSelection(strBaseElementID);
	var strFromClipboard=window.clipboardData.getData("Text");
	if ((null !=rngSelection) && (null !=strFromClipboard))
	{
		rngSelection.text=strFromClipboard;
	}
}
var g_cRTEResetToolBarTimerQueue;
function RTE_StartResetToolBarTimer(strBaseElementID)
{
	if (g_cRTEResetToolBarTimerQueue==null)
	{
		g_cRTEResetToolBarTimerQueue=new Array();
	}
	if (g_cRTEResetToolBarTimerQueue[strBaseElementID]==null)
	{
		g_cRTEResetToolBarTimerQueue[strBaseElementID]=0;
	}
++g_cRTEResetToolBarTimerQueue[strBaseElementID];
	window.setTimeout("RTE_OnResetToolBarTimer(\""+strBaseElementID+"\")", 200);
}
function RTE_OnResetToolBarTimer(strBaseElementID)
{
	;
	--g_cRTEResetToolBarTimerQueue[strBaseElementID];
	if (0==g_cRTEResetToolBarTimerQueue[strBaseElementID])
	{
		RTE_ResetAllToolBarStates(strBaseElementID);
	}
}
var g_fRTEFirstTimeGenerateCalled=true;
function RTE_GenerateIFrameEditorHtml(strBaseElementID, elemTextArea, fRestrictedMode, fAllowHyperlink)
{
	var aHtmlRet=new Array();
	if (g_fRTEFirstTimeGenerateCalled)
	{
		g_fRTEFirstTimeGenerateCalled=false;
		aHtmlRet.push("<iframe id=\"");
		aHtmlRet.push(g_strRTETextEditorPullDownMenuID);
		aHtmlRet.push("\"  src=\"");
		aHtmlRet.push(RTE_GetServerRelativeUnlocalizedImageUrl("blank.gif"));
		aHtmlRet.push("\" class=\"");
		aHtmlRet.push(g_strRTEToolbarClassName);
		aHtmlRet.push("\" TABINDEX=-1 style=\"display:none; position:absolute;\" ");
		aHtmlRet.push(g_strRTEBaseElementIDAttributeName);
		aHtmlRet.push("=\"x\" ");
		aHtmlRet.push(g_strRTEWebLocaleAttributeName);
		aHtmlRet.push("=\"x\" ");
		aHtmlRet.push(g_strRTEButtonMnemonicAttributeName);
		aHtmlRet.push("=\"x\"></iframe>");
		document.body.insertAdjacentHTML("afterBegin", "<object id=\"RTEDialogHelper\" name=\"RTEDialogHelper\" classid=\"clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b\" style=\"width:0px; height:0px;\" TABINDEX=-1></OBJECT>");
	}
	var strWidthNameAndAttribute=""
	var strHeightNameAndAttribute=""
	var strClassNameAndAttribute="";
	var cRows=elemTextArea.getAttribute("rows");
	if ((fRestrictedMode) && (null !=cRows) && (cRows > 0))
	{
		strWidthNameAndAttribute="";
		strHeightNameAndAttribute=" height=\""+cRows * g_iLineHeight+"\"";
		if (fAllowHyperlink)
		{
			strClassNameAndAttribute=" class=\"ms-rtelonger\"";
		}
		else
		{
			strClassNameAndAttribute=" class=\"ms-rtelong\"";
		}
	}
	else
	{
		strWidthNameAndAttribute=" width=\""+(g_iCharWidth*elemTextArea.cols)+"\"";
		strHeightNameAndAttribute=" height=\""+(g_iLineHeight*elemTextArea.rows)+"\"";
		strClassNameAndAttribute="";
	}
	aHtmlRet.push("<div><iframe ");
	aHtmlRet.push(strWidthNameAndAttribute);
	aHtmlRet.push(strHeightNameAndAttribute);
	aHtmlRet.push(strClassNameAndAttribute);
	aHtmlRet.push(" id=\"");
	aHtmlRet.push(RTE_GetEditorIFrameID(strBaseElementID));
	aHtmlRet.push("\" title=\"");
	aHtmlRet.push(L_EditorIFrameTitle_TEXT);
	aHtmlRet.push("\" src=\"");
	aHtmlRet.push(RTE_GetServerRelativeUnlocalizedImageUrl("blank.gif"));
	aHtmlRet.push("\"></iframe></div>");
	return aHtmlRet.join("");
}
function RTE_TB_GenerateSimpleToolBarButtonHtml(
	strBaseElementID, strButtonMnemonic,
	strOnClickJScriptFunction, strOnClickArg,
	strImageUrl, strText, strToolTip)
{
	strJs="if (!(RTE_TB_GetToolBarButton('"+strBaseElementID+		"', '"+strButtonMnemonic+"').disabled)) { ";
	strJs+=strOnClickJScriptFunction+"('"+strBaseElementID+"'";
	if (strOnClickArg !=null)
		strJs+=", "+strOnClickArg;
	strJs+="); }";
	return RTE_TB_GenerateToolBarButtonHtml(
		strBaseElementID, strButtonMnemonic, strJs,
		strImageUrl, strText, strToolTip);
}
function RTE_GenerateFontNameToolBarButtonHtml(strBaseElementID, strWebLanguage, fRestrictedMode, fShowImageWithDropArrow)
{
	var strHtmlRet="";
	strHtmlRet+=RTE_TB_GenerateOpenCellButtonHtml(strBaseElementID, g_strRTEFontNameMnemonic, "RTE_SaveSelection('"+strBaseElementID+"'); RTE_DD_OpenFontNameOrSizeSelector('"+strBaseElementID+"' ,'"+strWebLanguage+"', true)");
	if (fRestrictedMode || fShowImageWithDropArrow)
	{
		strHtmlRet+="<img src=\""+RTE_GetServerRelativeImageUrl("rtefnt.gif")+"\" alt=\""+L_FontNameToolTip_TEXT+"\" border=0 width=16 height=16 unselectable=\"on\">";
		if (fShowImageWithDropArrow)
		{
			strHtmlRet+="<img alt=\""+L_FontSizeToolTip_TEXT+"\" src=\""+RTE_GetServerRelativeUnlocalizedImageUrl("menudark.gif")+"\" border=0 width=13 height=13 unselectable=\"on\">";
		}
	}
	else
	{
		strHtmlRet+="<label style=\"margin-left: 2px; margin-right: 2px;\">"+L_FontNameLabel_TEXT+"</label>&nbsp;<img alt=\""+				L_FontNameToolTip_TEXT+"\" src=\""+RTE_GetServerRelativeImageUrl("rtednar.gif")+"\" border=0 width=13 height=13 unselectable=\"on\">";
	}
	strHtmlRet+=RTE_TB_GenerateCloseCellButtonHtml();
	return strHtmlRet;
}
function RTE_GenerateFontSizeToolBarButtonHtml(strBaseElementID, strWebLanguage, fRestrictedMode, fShowImageWithDropArrow)
{
	var strHtmlRet="";
	strHtmlRet+=RTE_TB_GenerateOpenCellButtonHtml(strBaseElementID, g_strRTEFontSizeMnemonic, "RTE_SaveSelection('"+strBaseElementID+"'); RTE_DD_OpenFontNameOrSizeSelector('"+strBaseElementID+"', '"+strWebLanguage+"', false)");
	if (fRestrictedMode || fShowImageWithDropArrow)
	{
		strHtmlRet+="<img src=\""+RTE_GetServerRelativeImageUrl("rtefntsz.gif")+"\" alt=\""+L_FontSizeToolTip_TEXT+"\" border=0 width=16 height=16 unselectable=\"on\">";
		if (fShowImageWithDropArrow)
		{
			strHtmlRet+="<img alt=\""+L_FontSizeToolTip_TEXT+"\" src=\""+RTE_GetServerRelativeUnlocalizedImageUrl("menudark.gif")+"\" border=0 width=13 height=13 unselectable=\"on\">";
		}
	}
	else
	{
		strHtmlRet+="<label style=\"margin-left: 2px; margin-right: 2px;\">"+L_FontSizeLabel_TEXT+"</label>&nbsp;<img alt=\""+				L_FontSizeToolTip_TEXT+"\" src=\""+RTE_GetServerRelativeImageUrl("rtednar.gif")+"\" border=0 width=13 height=13 unselectable=\"on\">";
	}
	strHtmlRet+=RTE_TB_GenerateCloseCellButtonHtml();
	return strHtmlRet;
}
function RTE_GenerateForeColorToolBarButtonHtml(strBaseElementID, strWebLanguage)
{
	var strHtmlRet="";
	strHtmlRet+=RTE_TB_GenerateOpenCellButtonHtml(strBaseElementID, g_strRTEForeColorMnemonic);
	strHtmlRet+="<a TABINDEX=-1 href=\"#\" onfocus=\"RTE_TB_OnFocus('"+strBaseElementID+"', this);\" onblur=\"RTE_TB_OnBlur('"+strBaseElementID+"', this);\" onclick=\"RTE_DD_OpenForeColorSelector('"+strBaseElementID+"', '"+strWebLanguage+"'); return false;\" unselectable=\"on\"><img src=\""+RTE_GetServerRelativeImageUrl("rtetxclr.gif")+"\" alt=\""+			L_ForeColorToolTip_TEXT+"\" border=0 width=16 height=16 unselectable=\"on\"></a>";
	strHtmlRet+=RTE_TB_GenerateCloseCellButtonHtml();
	return strHtmlRet;
}
function RTE_GenerateToolBarHtml(
	strBaseElementID, strWebLanguage, elemTextArea,
	fRestrictedMode, fAllowHyperlink, fIsVisible)
{
	aSettings=new Array();
	aSettings.fRestrictedMode=fRestrictedMode;
	aSettings.fAllowHyperlink=fAllowHyperlink;
	aSettings.fIsVisible=fIsVisible;
	RTE_GenerateToolBarHtmlFromSettings(
		strBaseElementID, strWebLanguage, elemTextArea, aSettings);
}
function RTE_GenerateToolBarHtmlFromSettings(
	strBaseElementID, strWebLanguage, elemTextArea, aSettings)
{
	var strClassAttribute=" class=\""+g_strRTEToolbarClassName+"\" ";
	var strWidthAttribute=		" width=\""+elemTextArea.currentStyle.width+"\" ";
	var strDisplayStyle=		aSettings.fIsVisible ? " style=\"border:solid 1px #c4c4c4;\"" : " style=\"display:none;\" ";
	if (aSettings.fRestrictedMode)
	{
		if (aSettings.fAllowHyperlink)
		{
			strClassAttribute=" class=\""+g_strRTEToolbarClassName+" ms-longer\" ";
		}
		else
		{
			strClassAttribute=" class=\""+g_strRTEToolbarClassName+" ms-long\" ";
		}
		strWidthAttribute="";
	}
	var aHtmlRet=new Array();
	aHtmlRet.push("<table cellpadding=0 cellspacing=0 id='");
	aHtmlRet.push(strBaseElementID);
	aHtmlRet.push("_toolbar' ");
	aHtmlRet.push(strClassAttribute);
	aHtmlRet.push(strWidthAttribute);
	aHtmlRet.push(strDisplayStyle);
	aHtmlRet.push("><tr><td><table cellspacing=0 cellpadding=0 border=0><tr>");
	var buttons=RTE_GetToolBarDefinition(strBaseElementID, strWebLanguage);
	if (buttons !=null)
	{
		for (var i=0; i < buttons.length; i++)
		{
			aHtmlRet.push(buttons[i].Generate(strBaseElementID, strWebLanguage));
		}
	}
	aHtmlRet.push("</tr></table></td></tr></table>");
	return aHtmlRet.join("");
}
function RTE_GenerateBackColorToolBarButtonHtml(strBaseElementID, strWebLanguage)
{
	var strHtmlRet="";
	strHtmlRet+=RTE_TB_GenerateOpenCellButtonHtml(strBaseElementID, g_strRTEBackColorMnemonic);
	strHtmlRet+="<a TABINDEX=-1 href=\"#\" onfocus=\"RTE_TB_OnFocus('"+strBaseElementID+"', this);\" onblur=\"RTE_TB_OnBlur('"+strBaseElementID+"', this);\" onclick=\"RTE_DD_OpenBackColorSelector('"+strBaseElementID+"', '"+strWebLanguage+"'); return false;\" unselectable=\"on\"><img src=\""+RTE_GetServerRelativeImageUrl("rtebkclr.gif")+"\" alt=\""+			L_BackColorToolTip_TEXT+"\" border=0 width=16 height=16 unselectable=\"on\"></a>";
	strHtmlRet+=RTE_TB_GenerateCloseCellButtonHtml();
	return strHtmlRet;
}
function RTE_InsertTable(strBaseElementID)
{
	var tableOpts=RTE_ModalDialog(
		strBaseElementID, 'InsertTable', g_RTE_Dialog_Width, g_RTE_Dialog_Height, null );
	if (tableOpts !=null)
	{
		var cols=tableOpts[0];
		var rows=tableOpts[1];
		var tableHtml='<TABLE STYLE="display: inline; font-size: 1em; border-collapse: collapse" BORDER="1">';
		for (var i=0; i < rows;++i)
		{
			tableHtml+='<TR>';
			for (var j=0; j < cols;++j)
			{
				tableHtml+='<TD style="vertical-align:TOP;" CLASS="ms-rtetablecells"><div></div></TD>';
			}
			tableHtml+="</TR>";
		}
		tableHtml+="</TABLE>";
		RTE_GetSelection(strBaseElementID).pasteHTML(tableHtml);
		if (RTE_UseDynamicHeightSizing(strBaseElementID))
		{
			RTE_DocEditor_AdjustHeight(strBaseElementID);
		}
	}
}
function RTE_CreateLink(strBaseElementID)
{
	RTE_SaveSelection(strBaseElementID);
	var fAllowRelativeLinks=false;
	var variables=RTE_GetEditorInstanceVariables(strBaseElementID);
	if (variables !=null && variables.aSettings !=null)
	{
		fAllowRelativeLinks=variables.aSettings.fAllowRelativeLinks;
	}
	var dialogArgs=new Array();
	dialogArgs.text=RTE_GetCurrentSelectionRange(strBaseElementID).text;
	dialogArgs.allowRelativeLinks=fAllowRelativeLinks;
	var opts=RTE_ModalDialog(
		strBaseElementID,
		'CreateLink',
		g_RTE_Dialog_Width,
		g_RTE_Dialog_Height,
		dialogArgs);
	if (opts !=null)
	{
		var href=STSHtmlEncode(opts[1]);
		var text=STSHtmlEncode(opts[0]);
		if (IsSafeHrefAlert(href,fAllowRelativeLinks))
		{
			RTE_GetSelection(strBaseElementID).pasteHTML(
				'<a href="'+href+'">'+text+'</a>');
		}
	}
}
function RTE_ClickLink(strBaseElementID)
{
	if (g_fRestoreSelection)
	{
		return;
	}
	RTE_SaveSelection(strBaseElementID);
	var aChain=RTE_GetCurrentSelectionChain(strBaseElementID);
	var aElem=null;
	for (var iChain=0; iChain < aChain.length; iChain++)
	{
		aElem=aChain[iChain];
		if (aElem.tagName=="A")
		{
			open(aElem.href);
			break;
		}
	}
}
function RTE_InsertImage(strBaseElementID)
{
	RTE_SaveSelection(strBaseElementID);
	var opts=RTE_ModalDialog(
		strBaseElementID, 'InsertImage', g_RTE_Dialog_Width, g_RTE_Dialog_Height, null );
	if (opts !=null)
	{
		var href=STSHtmlEncode(opts[1]);
		var altText=STSHtmlEncode(opts[0]);
		var fAllowRelativeLinks=false;
		var variables=RTE_GetEditorInstanceVariables(strBaseElementID);
		if (variables !=null && variables.aSettings !=null)
		{
			fAllowRelativeLinks=variables.aSettings.fAllowRelativeLinks;
		}
		if (IsSafeHrefAlert(href,fAllowRelativeLinks))
		{
			var imgHtml='<IMG SRC="'+href+'" ALT="'+altText+'">';
			RTE_GetSelection(strBaseElementID).pasteHTML(imgHtml);
		}
		if(RTE_UseDynamicHeightSizing(strBaseElementID))
		{
			RTE_DocEditor_AdjustHeight(strBaseElementID);
		}
	}
}
function RTE_HtmlSource(strBaseElementID)
{
	var docEditor=RTE_GetEditorDocument(strBaseElementID);
	var currentContent=new Array;
	currentContent.value=docEditor.body.innerHTML;
	currentContent.dir=docEditor.dir;
	var variables=RTE_GetEditorInstanceVariables(strBaseElementID);
	docEditor.body.innerHTML=showModalDialog(
		variables.aSettings.urlWebRoot+'/_layouts/zoombldr.aspx',
		currentContent,
		'dialogHeight: 550px; dialogWidth:500px; help: no; status:no; '+			'resizable: yes');
	var docTextRange=docEditor.body.createTextRange();
	docTextRange.select();
	docTextRange.scrollIntoView(false);
	if (RTE_UseDynamicHeightSizing(strBaseElementID))
	{
		RTE_DocEditor_AdjustHeight(strBaseElementID);
	}
}
function RTE_GenerateInsertTableElementToolBarButtonHtml(
	strBaseElementID, strWebLanguage)
{
	var variables=RTE_GetEditorInstanceVariables(strBaseElementID);
	variables.functions[g_strRTEInsertRowAbove]=RTE_InsertRowAbove;
	variables.functions[g_strRTEInsertRowBelow]=RTE_InsertRowBelow;
	variables.functions[g_strRTEInsertColumnLeft]=RTE_InsertColumnLeft;
	variables.functions[g_strRTEInsertColumnRight]=RTE_InsertColumnRight;
	variables.functions[g_strRTEInsertCellLeft]=RTE_InsertCellLeft;
	variables.functions[g_strRTEInsertCellRight]=RTE_InsertCellRight;
	return RTE_GenerateTableToolBarButtonHtml(
		strBaseElementID, strWebLanguage, g_strRTEInsertTableElementMnemonic,
		L_InsertTableElementToolTip_TEXT, "rteirow.gif");
}
function RTE_GenerateDeleteTableElementToolBarButtonHtml(
	strBaseElementID, strWebLanguage)
{
	var variables=RTE_GetEditorInstanceVariables(strBaseElementID);
	variables.functions[g_strRTEDeleteRow]=RTE_DeleteRow;
	variables.functions[g_strRTEDeleteColumn]=RTE_DeleteColumn;
	return RTE_GenerateTableToolBarButtonHtml(
		strBaseElementID, strWebLanguage, g_strRTEDeleteTableElementMnemonic,
		L_DeleteTableElementToolTip_TEXT, "rtedrow.gif");
}
function RTE_GenerateTableToolBarButtonHtml(
	strBaseElementID, strWebLanguage, strMnemonic, strToolTip, strImage)
{
	strHtmlRet=		RTE_TB_GenerateOpenCellButtonHtml(
			strBaseElementID, strMnemonic)+		"<a TABINDEX=-1 href=\"#\" "+		"onfocus=\"RTE_TB_OnFocus('"+strBaseElementID+"', this);\" "+		"onblur=\"RTE_TB_OnBlur('"+strBaseElementID+"', this);\" "+		"onclick=\"RTE_DD_OpenTableOperationSelector('"+		strBaseElementID+"' ,'"+strWebLanguage+"', '"+strMnemonic+		"'); return false;\" "+		"title=\""+strToolTip+"\" "+		"style=\"margin-left: 2px; margin-right: 2px;\" unselectable=\"on\">"+		"<img src=\""+RTE_GetServerRelativeImageUrl(strImage)+		"\" alt=\""+strToolTip+"\" border=0 width=16 height=16 unselectable=\"on\">"+		"<img alt=\""+strToolTip+"\" src=\""+		RTE_GetServerRelativeUnlocalizedImageUrl("menudark.gif")+"\" border=0 width=13 height=13 unselectable=\"on\"></a>"+		RTE_TB_GenerateCloseCellButtonHtml();
	return strHtmlRet;
}
function RTE_DD_OpenTableOperationSelector(
	strBaseElementID, strWebLanguage, strMnemonic)
{
	var rgoMenuInfo=RTE_DD_GetTableOperationSelectorUnformattedHtml(
		strBaseElementID, strWebLanguage, strMnemonic);
	var strMenuHtml=rgoMenuInfo[0];
	var cMenuItems=rgoMenuInfo[1];
	RTE_DD_OpenMenu(strBaseElementID, strMnemonic, strMenuHtml, cMenuItems);
}
function RTE_DD_InsertItemAndGenerateScript(
	strBaseElementID, iItem, strCommand, strLabel, rgstrItemNames, strWebLanguage)
{
	rgstrItemNames[iItem]=strLabel;
	return RTE_DD_GenerateMenuItemScriptHtml(
		1, iItem,
		"RTE_DD_StartAction('"+strCommand+"', '"+strBaseElementID+"')",
		rgstrItemNames[iItem], rgstrItemNames[iItem], null, null, strWebLanguage);
}
function RTE_DD_GetTableOperationSelectorUnformattedHtml(
	strBaseElementID, strWebLanguage, strMnemonic)
{
	strMenuHtml=RTE_DD_GenerateMenuOpenHtml(strWebLanguage);
	var rgstrItemNames=new Array();
	switch (strMnemonic)
	{
		case g_strRTEInsertTableElementMnemonic:
		{
			strMenuHtml+=RTE_DD_InsertItemAndGenerateScript(strBaseElementID,
				0, g_strRTEInsertRowAbove, L_InsertRowAboveLabel_TEXT,
				rgstrItemNames, strWebLanguage);
			strMenuHtml+=RTE_DD_InsertItemAndGenerateScript(strBaseElementID,
				1, g_strRTEInsertRowBelow, L_InsertRowBelowLabel_TEXT,
				rgstrItemNames, strWebLanguage);
			strMenuHtml+=RTE_DD_InsertItemAndGenerateScript(strBaseElementID,
				2, g_strRTEInsertColumnLeft, L_InsertColumnLeftLabel_TEXT,
				rgstrItemNames, strWebLanguage);
			strMenuHtml+=RTE_DD_InsertItemAndGenerateScript(strBaseElementID,
				3, g_strRTEInsertColumnRight, L_InsertColumnRightLabel_TEXT,
				rgstrItemNames, strWebLanguage);
			strMenuHtml+=RTE_DD_InsertItemAndGenerateScript(strBaseElementID,
				4, g_strRTEInsertCellLeft, L_InsertCellLeftLabel_TEXT,
				rgstrItemNames, strWebLanguage);
			strMenuHtml+=RTE_DD_InsertItemAndGenerateScript(strBaseElementID,
				5, g_strRTEInsertCellRight, L_InsertCellRightLabel_TEXT,
				rgstrItemNames, strWebLanguage);
			break;
		}
		case g_strRTEDeleteTableElementMnemonic:
		{
			strMenuHtml+=RTE_DD_InsertItemAndGenerateScript(strBaseElementID,
				0, g_strRTEDeleteRow, L_DeleteRowToolTip_TEXT, rgstrItemNames, strWebLanguage);
			strMenuHtml+=RTE_DD_InsertItemAndGenerateScript(strBaseElementID,
				1, g_strRTEDeleteColumn, L_DeleteColumnToolTip_TEXT,
				rgstrItemNames, strWebLanguage);
			break;
		}
	}
	var cMenuItems=rgstrItemNames.length;
	strMenuHtml+=RTE_DD_GenerateMenuCloseHtml();
	return new Array(strMenuHtml, cMenuItems);
}
function RTE_MoveFocus(strBaseElementID, elemStart, offset)
{
	var docEditor=RTE_GetEditorDocument(strBaseElementID);
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	if (RTE_HasActiveSelection(docEditor))
	{
		var selection=RTE_GetCurrentSelection(strBaseElementID);
		if (selection.type=="Control")
		{
			return true;
		}
	}
	var buttons=RTE_GetToolBarDefinition(strBaseElementID);
	var newIndex=0;
	if (instanceVariables.hoverButton==null)
	{
		if (offset==-1 && buttons !=null)
		{
			newIndex=buttons.length - 1;
		}
		else
		{
			newIndex=0;
		}
	}
	else
	{
		newIndex=instanceVariables.hoverButton.toolbarButtonIndex+offset;
	}
	while (true)
	{
		if (newIndex < 0 || newIndex==buttons.length)
		{
			RTE_TB_RemoveLastToolBarHover(strBaseElementID);
			var selection=RTE_GetCurrentSelection(strBaseElementID);
			var textRange=selection.createRange();
			textRange.collapse();
			textRange.select();
			return true;
		}
		if (buttons[newIndex].strMnemonic !=null)
		{
			var toolBarButton=RTE_TB_GetToolBarButton(strBaseElementID, buttons[newIndex].strMnemonic);
			if (toolBarButton !=null
				&& !toolBarButton.disabled
				&& RTE_IsVisible(toolBarButton))
			{
				RTE_TB_OnMouseOver(toolBarButton);
				return false;
			}
		}
		if (offset < 0)
		{
			newIndex--;
		}
		else
		{
			newIndex++;
		}
	}
}
function RTE_IsVisible(element)
{
	if (element==null) return true;
	if (element.currentStyle.visibility=='inherit')
	{
		return RTE_IsVisible(element.parentElement);
	}
	else if (element.currentStyle.visibility=='hidden')
	{
		return false;
	}
	return true;
}
function RTE_TB_RemoveLastToolBarHover(strBaseElementID)
{
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	if (instanceVariables.hoverButton !=null)
	{
		RTE_TB_OnMouseOut(instanceVariables.hoverButton);
	}
}
function RTE_TB_SetLastToolBarHover(strBaseElementID, elemButton)
{
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	instanceVariables.hoverButton=elemButton;
}
function RTE_MoveFocusBackwards(strBaseElementID, elemStart)
{
	return RTE_MoveFocus(strBaseElementID, elemStart, -1);
}
function RTE_MoveFocusForwards(strBaseElementID, elemStart)
{
	return RTE_MoveFocus(strBaseElementID, elemStart, 1);
}
function RTE_ExecuteCommandOnSelection(strBaseElementID, strCommand, fUserInterface, strValue)
{
	var docEditor=RTE_GetEditorDocument(strBaseElementID);
	RTE_RestoreSelection(strBaseElementID);
	if ((strCommand==g_strRTECreateLinkMnemonic) || (strCommand==g_strRTEInsertImageMnemonic))
	{
		g_fRTEDialogIsOpen=true;
	}
	docEditor.execCommand(strCommand, fUserInterface, strValue);
	if (g_fRTEDialogIsOpen)
	{
		g_fRTEDialogIsOpen=false;
		 RTE_OnFocus(strBaseElementID);
	}
	RTE_StartResetToolBarTimer(strBaseElementID);
	var fUseDynamicHeightSizing=RTE_UseDynamicHeightSizing(strBaseElementID);
	if (fUseDynamicHeightSizing)
	{
		RTE_DocEditor_AdjustHeight(strBaseElementID);
	}
}
function RTE_ExecuteFunctionOnSelection(strBaseElementID, strFunctionName, strParameter)
{
	var docEditor=RTE_GetEditorDocument(strBaseElementID);
	RTE_RestoreSelection(strBaseElementID);
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	var functionToExecute=instanceVariables.functions[strFunctionName];
	if (functionToExecute !=null)
	{
		functionToExecute(strParameter);
		if (g_fRTEDialogIsOpen)
		{
			g_fRTEDialogIsOpen=false;
			RTE_OnFocus(strBaseElementID);
		}
	}
	RTE_StartResetToolBarTimer(strBaseElementID);
}
function RTE_SetDirectionOfSelection(strBaseElementID, strDirection)
{
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	if (instanceVariables !=null && instanceVariables.overrides.SetDirectionOfSelection !=null)
	{
		return instanceVariables.overrides.SetDirectionOfSelection(strBaseElementID, strDirection);
	}
	RTE_SaveSelection(strBaseElementID);
	var rngSelection=RTE_GetSelection(strBaseElementID);
	RTE_RestoreSelection(strBaseElementID);
	var strTagNames;
	strTagNames="|H1|H2|H3|H4|H5|H6|P|PRE|TD|DIV|BLOCKQUOTE|DT|DD|TABLE|HR|IMG|BODY|TR|UL|OL|";
	if (rngSelection.parentElement)
	{
		var elemSelectionParent=rngSelection.parentElement();
		while ((elemSelectionParent !=null) && (strTagNames.indexOf("|"+elemSelectionParent.tagName+"|")==-1))
		{
			elemSelectionParent=elemSelectionParent.parentElement;
		}
		if (elemSelectionParent)
		{
			RTE_SetDirectionOnElement(elemSelectionParent, strDirection);
		}
	}
	else
	{
		var rngLength=rngSelection.length;
		for (var i=0; i < rngLength;++i)
		{
			var elemCurrent=rngSelection.item(i);
			if ((elemCurrent !=null) && (strTagNames.indexOf("|"+elemCurrent.tagName+"|")!=-1))
			{
				RTE_SetDirectionOnElement(elemCurrent, strDirection);
			}
		}
	}
}
function RTE_SetDirectionOnElement(element, strDirection)
{
	if ("ltr"==strDirection)
	{
		element.dir="ltr"    ;
		element.align="left";
	}
	else if ("rtl"==strDirection)
	{
		element.dir="rtl";
		element.align="right";
	}
}
function RTE_GetDirectionOfSelection(strBaseElementID)
{
	var direction="";
	var rngSelection=RTE_GetSelection(strBaseElementID);
	if (!(null !=rngSelection)) { return direction; }
	var strTagNames="|H1|H2|H3|H4|H5|H6|P|PRE|LI|TD|DIV|BLOCKQUOTE|DT|DD|TABLE|HR|IMG|TR|UL|OL|BODY|HTML|";
	var elemSelectionParent=rngSelection.parentElement();
	while ((elemSelectionParent !=null)
	   && ((strTagNames.indexOf("|"+elemSelectionParent.tagName+"|")==-1)
		   || (elemSelectionParent.dir !="ltr") && (elemSelectionParent.dir !="rtl" )))
	{
		elemSelectionParent=elemSelectionParent.parentElement;
	}
	if (elemSelectionParent)
	{
		if (elemSelectionParent.dir=="ltr")
		{
			direction="ltr";
		}
		else if (elemSelectionParent.dir=="rtl")
		{
			direction="rtl";
		}
	}
	return direction;
}
var g_strRTEToolBarButtonWithTheFocus=null;
function RTE_ToolBarButtonWithTheFocus()
{
	return g_strRTEToolBarButtonWithTheFocus;
}
var g_aToolBarButtons;
function RTE_TB_GetToolBarButton(strBaseElementID, strButtonMnemonic)
{
	if (g_aToolBarButtons==null)
	{
		g_aToolBarButtons=new Array();
	}
	var elemToolBarButton=g_aToolBarButtons[strBaseElementID+"_"+strButtonMnemonic];
	if (elemToolBarButton==null)
	{
		elemToolBarButton=document.getElementById(strBaseElementID+"_"+strButtonMnemonic);
		g_aToolBarButtons[strBaseElementID+"_"+strButtonMnemonic]=elemToolBarButton;
	}
	return elemToolBarButton;
}
function RTE_TB_GenerateOpenCellButtonHtml(strBaseElementID, strButtonMnemonic, strOnClickJScript, strTooltip)
{
	var aHtmlRet=new Array();
	aHtmlRet.push("<td class=\"");
	aHtmlRet.push(g_strRTEToolbarClassName);
	aHtmlRet.push("\" unselectable=\"on\"><table cellpadding=1 cellspacing=0 border=0 unselectable=\"on\"><tr unselectable=\"on\"><td class=\"");
	aHtmlRet.push(g_strRTEToolbarClassName);
	aHtmlRet.push(" ");
	aHtmlRet.push(g_strRTEUnselectedClassName);
	aHtmlRet.push("\" nowrap id=\"");
	aHtmlRet.push(strBaseElementID);
	aHtmlRet.push("_");
	aHtmlRet.push(strButtonMnemonic);
	aHtmlRet.push("\" onmouseover=\"RTE_TB_OnMouseOver(this);\" onmouseout=\"RTE_TB_OnMouseOut(this);\"");
	if (strOnClickJScript)
	{
		aHtmlRet.push(" onClick=\"RTE_DD_CloseMenu();");
		aHtmlRet.push(strOnClickJScript);
		aHtmlRet.push("\"");
	}
	if (strTooltip)
	{
		aHtmlRet.push(" title=\"");
		aHtmlRet.push(strTooltip);
		aHtmlRet.push("\"");
	}
	aHtmlRet.push("unselectable=\"on\">");
	return aHtmlRet.join("");
}
function RTE_TB_GenerateCloseCellButtonHtml()
{
	return "</td></tr></table></td>";
}
function RTE_TB_GenerateToolBarSeparatorHtml()
{
	return "<td class=ms-separator unselectable=\"on\">|</td>";
}
function RTE_TB_GenerateToolBarLineBreakHtml()
{
	return "</tr></table></td></tr><tr unselectable=\"on\"><td unselectable=\"on\"><table cellspacing=0 cellpadding=0 border=0 unselectable=\"on\"><tr unselectable=\"on\">";
}
function RTE_TB_GenerateToolBarButtonHtml(strBaseElementID, strButtonMnemonic, strOnClickJScript, strImageUrl, strText, strToolTip)
{
	var aHtmlRet=new Array();
	aHtmlRet.push(RTE_TB_GenerateOpenCellButtonHtml(strBaseElementID, strButtonMnemonic, strOnClickJScript, strToolTip));
	if (0 < strImageUrl.length)
	{
		aHtmlRet.push("<img border=0 width=16 height=16 src=\"");
		aHtmlRet.push(strImageUrl);
		aHtmlRet.push("\" alt=\"");
		aHtmlRet.push(strToolTip);
		aHtmlRet.push("\" unselectable=\"on\">");
	}
	if (0 < strText.length)
	{
		aHtmlRet.push(" ");
		aHtmlRet.push(strText);
	}
	aHtmlRet.push(RTE_TB_GenerateCloseCellButtonHtml());
	return aHtmlRet.join("");
}
function RTE_TB_GenerateExecCommandToolBarButtonHtml(
	strBaseElementID,
	strCommand,
	fUserInterface,
	strImageUrl,
	strText,
	strToolTip,
	fOnlyIfSelectionActive,
	strValueExpression,
	strBeforeExecJScript,
	strAfterExecJScript)
{
	var aOnClickJScript=new Array();
	aOnClickJScript.push("RTE_DD_CloseMenu();");
	if (fOnlyIfSelectionActive)
	{
		aOnClickJScript.push("var sel=RTE_GetEditorDocument('");
		aOnClickJScript.push(strBaseElementID);
		aOnClickJScript.push("').selection; if ((null !=sel) && ('None' !=sel.type)) { ");
	}
	aOnClickJScript.push("RTE_SaveSelection('"+strBaseElementID+"');");
	aOnClickJScript.push("var argValue=");
	aOnClickJScript.push(strValueExpression);
	aOnClickJScript.push(";");
	if (strValueExpression !="null")
	{
		aOnClickJScript.push("if (argValue !=null) { ");
	}
	if (strBeforeExecJScript)
	{
		aOnClickJScript.push(strBeforeExecJScript);
	}
	aOnClickJScript.push("RTE_ExecuteCommandOnSelection('");
	aOnClickJScript.push(strBaseElementID);
	aOnClickJScript.push("', '");
	aOnClickJScript.push(strCommand);
	aOnClickJScript.push("', ");
	aOnClickJScript.push(fUserInterface);
	aOnClickJScript.push(", argValue);");
	if (strAfterExecJScript)
	 aOnClickJScript.push(strAfterExecJScript);
	if (strValueExpression !="null")
	{
		aOnClickJScript.push("}");
	}
	if (fOnlyIfSelectionActive)
	{
		aOnClickJScript.push("}");
	}
	var strOnClickJScript=aOnClickJScript.join("");
	return RTE_TB_GenerateToolBarButtonHtml(strBaseElementID, strCommand, strOnClickJScript, strImageUrl, strText, strToolTip);
}
function RTE_TB_SetButtonCheck(elemButton)
{
	elemButton.className=RTE_RemoveClassFromClassList(elemButton.className, g_strRTEUnselectedClassName);
	elemButton.className=RTE_AddClassToClassList(elemButton.className, g_strRTESelectedClassName);
}
function RTE_TB_ClearButtonCheck(elemButton)
{
	elemButton.className=RTE_RemoveClassFromClassList(elemButton.className, g_strRTESelectedClassName);
	elemButton.className=RTE_AddClassToClassList(elemButton.className, g_strRTEUnselectedClassName);
}
function RTE_TB_SetButtonDisabled(elemButton)
{
	elemButton.className=RTE_AddClassToClassList(elemButton.className, g_strRTEDisabledClassName);
	elemButton.disabled=true;
	var elemChildLink=elemButton.children(0);
	if ((elemChildLink !=null) && (elemChildLink.tagName=="A"))
	{
		elemChildLink.disabled=true;
	}
}
function RTE_TB_ClearButtonDisabled(elemButton)
{
	elemButton.disabled=false;
	var elemChildLink=elemButton.children(0);
	if ((elemChildLink !=null) && (elemChildLink.tagName=="A"))
	{
		elemChildLink.disabled=false;
	}
	elemButton.className=RTE_RemoveClassFromClassList(elemButton.className, g_strRTEDisabledClassName);
}
function RTE_TB_SetButtonHover(elemButton)
{
	RTE_TB_RemoveLastToolBarHover(elemButton.strBaseElementID);
	RTE_TB_SetLastToolBarHover(elemButton.strBaseElementID, elemButton);
	elemButton.className=RTE_AddClassToClassList(elemButton.className, g_strRTEHoverClassName);
}
function RTE_TB_ClearButtonHover(elemButton)
{
	RTE_TB_SetLastToolBarHover(elemButton.strBaseElementID, null);
	elemButton.className=RTE_RemoveClassFromClassList(elemButton.className, g_strRTEHoverClassName);
}
function RTE_TB_SetCheckFromCommandValue(strBaseElementID, docEditor, strCommand)
{
	var btn=RTE_TB_GetToolBarButton(strBaseElementID, strCommand);
	if (docEditor.queryCommandSupported(strCommand) && docEditor.queryCommandValue(strCommand))
	{
		RTE_TB_SetButtonCheck(btn);
	}
	else
	{
		RTE_TB_ClearButtonCheck(btn);
	}
}
function RTE_TB_SetCheckForDirectionButton(strBaseElementID, strCommand)
{
	var btn=RTE_TB_GetToolBarButton(strBaseElementID, strCommand);
	if (((RTE_GetDirectionOfSelection(strBaseElementID)=="ltr") && (strCommand==g_strRTELTRMnemonic))
		|| ((RTE_GetDirectionOfSelection(strBaseElementID)=="rtl") && (strCommand==g_strRTERTLMnemonic)))
	{
		RTE_TB_SetButtonCheck(btn);
	}
	else
	{
		RTE_TB_ClearButtonCheck(btn);
	}
}
function RTE_HasActiveSelection(docEditor)
{
	var fSelectionTestResults=true;
	var sel=docEditor.selection;
	if ((null==sel) || ('none'==sel.type))
	{
		fSelectionTestResults=false;
	}
	else
	{
		var rngSel=docEditor.selection.createRange();
		if ((rngSel !=null) && (rngSel.text !=null) && (0 >=rngSel.text.length))
		{
			fSelectionTestResults=false;
		}
	}
	return fSelectionTestResults;
}
function RTE_TB_SetEnabledFromCommandEnabled(
	strBaseElementID,
	docEditor,
	strCommandToEnable,
	strCommandToCheck)
{
	var btn=RTE_TB_GetToolBarButton(strBaseElementID, strCommandToEnable);
	if (docEditor.queryCommandEnabled(strCommandToCheck))
	{
		RTE_TB_ClearButtonDisabled(btn);
	}
	else
	{
		RTE_TB_SetButtonDisabled(btn);
	}
}
function RTE_TB_SetEnabledIfInElement(
	strBaseElementID, aElemChain, strMnemonic, strElement)
{
	RTE_TB_SetEnabledFromCondition(strBaseElementID,
		RTE_IsElementInChain(aElemChain, strElement), strMnemonic);
}
function RTE_TB_SetEnabledFromCondition(
	strBaseElementID, fCondition, strCommand)
{
	var btn=RTE_TB_GetToolBarButton(strBaseElementID, strCommand);
	if (fCondition)
	{
		RTE_TB_ClearButtonDisabled(btn);
	}
	else
	{
		RTE_TB_SetButtonDisabled(btn);
	}
}
function RTE_TB_OnMouseOver(elemButton)
{
	if (0 > elemButton.className.indexOf(g_strRTEDisabledClassName))
	{
		elemButton.style.cursor="pointer";
		RTE_TB_SetButtonHover(elemButton);
	}
}
function RTE_TB_OnMouseOut(elemButton)
{
	RTE_TB_ClearButtonHover(elemButton);
}
function RTE_TB_OnFocus(strBaseElementID, elemButton)
{
	g_strRTEToolBarButtonWithTheFocus=elemButton.parentElement.id;
}
function RTE_TB_OnBlur(strBaseElementID, elemButton)
{
	g_strRTEToolBarButtonWithTheFocus=null;
}
var g_strRTEDDBaseElementID=null;
var g_strRTEDDButtonMnemonic=null;
var g_fRTEFirstCallToGetMenu=true;
var g_elemRTEHighlightedMenuItem=null;
var g_iRTEHighlightedMenuItem=-1;
var g_iRTEMenuItemMax=-1;
function RTE_DD_GetMenuElement()
{
	var elemMenu=document.getElementById(g_strRTETextEditorPullDownMenuID);
	if ((null==elemMenu) && (document.parentWindow !=null) && (document.parentWindow.document !=null))
	{
		elemMenu=document.parentWindow.parent.document.getElementById(g_strRTETextEditorPullDownMenuID);
	}
	return elemMenu;
}
function RTE_DD_GetMenuFrame()
{
	var ifmMenu=null;
	var elemMenu=RTE_DD_GetMenuElement();
	if (null !=elemMenu)
	{
		if (document.frames.length > 0)
		{
			ifmMenu=document.frames(g_strRTETextEditorPullDownMenuID);
		}
		else
		{
			if ((document.parentWindow !=null) && (document.parentWindow.frames !=null))
			{
				ifmMenu=document.parentWindow.parent.document.frames(g_strRTETextEditorPullDownMenuID);
			}
		}
	}
	if (null==ifmMenu)
	{
		if (g_fRTEFirstCallToGetMenu)
		{
			g_fRTEFirstCallToGetMenu=false;
			return null;
		}
	}
	return ifmMenu;
}
function RTE_DD_GetMenuBaseElementID()
{
	return RTE_DD_GetMenuElement().getAttribute(g_strRTEBaseElementIDAttributeName);
}
function RTE_DD_GetMenuButtonMnemonic()
{
	return RTE_DD_GetMenuElement().getAttribute(g_strRTEButtonMnemonicAttributeName);
}
function RTE_DD_MenuIsOpen()
{
	var elemMenu=RTE_DD_GetMenuElement();
	if (elemMenu !=null && ""==elemMenu.style.display)
	{
		return true;
	}
	return false;
}
var g_fRTEMenuMoved=false;
function RTE_DD_OpenMenu(strBaseElementID, strButtonMnemonic, strMenuHtml, strWebLanguage, cMenuItems)
{
	var elemMenu=RTE_DD_GetMenuElement();
	var ifmMenu=RTE_DD_GetMenuFrame();
	if (!g_fRTEMenuMoved)
	{
		g_elemRTELastTextAreaConverted.insertAdjacentElement("afterEnd", elemMenu);
		elemMenu=RTE_DD_GetMenuElement();
		ifmMenu=RTE_DD_GetMenuFrame();
	}
	if ((g_strRTEDDBaseElementID==strBaseElementID) && (g_strRTEDDButtonMnemonic==strButtonMnemonic))
	{
		RTE_DD_CloseMenu();
		RTE_RestoreSelection(strBaseElementID);
		return;
	}
	if ((null !=g_strRTEDDBaseElementID) && (null !=g_strRTEDDButtonMnemonic))
	{
		RTE_DD_CloseMenu();
	}
	g_strRTEDDBaseElementID=strBaseElementID;
	g_strRTEDDButtonMnemonic=strButtonMnemonic;
	g_iRTEMenuItemMax=cMenuItems - 1;
	RTE_SaveSelection(strBaseElementID);
	var elemToolBarButton=RTE_TB_GetToolBarButton(strBaseElementID, strButtonMnemonic);
	elemMenu.setAttribute(g_strRTEBaseElementIDAttributeName, strBaseElementID);
	elemMenu.setAttribute(g_strRTEButtonMnemonicAttributeName, strButtonMnemonic);
	elemMenu.setAttribute(g_strRTEMenuOpeningAttributeName, "1");
	elemMenu.style.top="0px";
	elemMenu.style.left="0px";
	elemMenu.style.height="";
	elemMenu.style.width="";
	var scriptFile="bform.js"
	var strWebLocale=RTE_GetWebLocale(strBaseElementID);
	ifmMenu.document.open("text/html", "replace");
	ifmMenu.document.write("<html><head><link rel=\"stylesheet\" type=\"text/css\" href=\""+RTE_GetServerRelativeStylesheetUrl("core.css", strWebLocale)+			"\"><script language=\"javascript\" src=\""+RTE_GetServerRelativeScriptUrl(scriptFile, strWebLocale)+"\"></script></head>"+			"<body class=\""+g_strRTEToolbarClassName+"\""+g_strRTECommandToExecuteAttributeName+"=\"x\" "+g_strRTECommandValueAttributeName+"=\"x\" "+g_strRTEFunctionToExecuteAttributeName+"=\"x\" "+g_strRTEFunctionParameterToExecuteAttributeName+"=\"x\" unselectable='on'><div class=\""+g_strRTEToolbarClassName+"\" id=\"divAroundMenu\" unselectable='on'>"+			strMenuHtml+"</div></body></html>");
	ifmMenu.document.close();
	elemMenu=RTE_DD_GetMenuElement();
	ifmMenu=RTE_DD_GetMenuFrame();
	ifmMenu.document.body.onkeydown=new Function("RTE_DD_OnKeyDown(this);");
	elemMenu.style.border="0px";
	ifmMenu.document.body.style.border="1px solid black";
	elemMenu.style.display="";
	var elemMenuDivInFrame=ifmMenu.document.all("divAroundMenu");
	var elemMenuTable=ifmMenu.document.all(g_strRTEMenuTableElementName);
	var cyDropDownMax=300;
	var rgnMenuRelativeCoordinates=RTE_GetElementWindowCoordinates(elemMenu);
	var rgnToolBarButtonCoordinates=RTE_GetElementWindowCoordinates(elemToolBarButton);
	var xToolBarButton=rgnToolBarButtonCoordinates[g_iRTELeft];
	var yToolBarButton=rgnToolBarButtonCoordinates[g_iRTETop];
	var cxToolBarButton=elemToolBarButton.offsetWidth;
	var cyToolBarButton=elemToolBarButton.offsetHeight;
	var cxDropDown=elemMenuTable.scrollWidth+4;
	var cyDropDown=elemMenuTable.scrollHeight+4;
	var cxBody=document.body.clientWidth;
	var cyBody=document.body.clientHeight;
	var yDropDown=rgnToolBarButtonCoordinates[g_iRTETop]+elemToolBarButton.offsetHeight - rgnMenuRelativeCoordinates[g_iRTETop];
	var objEditor=RTE_GetEditorDocument(strBaseElementID);
	var xDropDown;
	if (strWebLanguage=="1037" || strWebLanguage=="1025" || objEditor.dir=="rtl")
	{
		xDropDown=rgnToolBarButtonCoordinates[g_iRTERight]-cxDropDown - rgnMenuRelativeCoordinates[g_iRTELeft];
	}
	else
	{
		xDropDown=rgnToolBarButtonCoordinates[g_iRTELeft] - rgnMenuRelativeCoordinates[g_iRTELeft];
	}
	var fNeedVerticalScrollBar=false;
	if (cyDropDown > cyDropDownMax)
	{
		fNeedVerticalScrollBar=true;
		cyDropDown=cyDropDownMax;
	}
	if (cyDropDown > cyBody)
	{
		fNeedVerticalScrollBar=true;
		cyDropDown=cyBody - 30;
	}
	var scrollTopAdjustment=document.body.scrollTop;
	scrollTopAdjustment+=document.body.parentElement.scrollTop;
	if (yDropDown+cyDropDown > cyBody+scrollTopAdjustment)
	{
		yDropDown=rgnToolBarButtonCoordinates[g_iRTETop] - cyDropDown;
		if (scrollTopAdjustment > yDropDown)
		{
			yDropDown=scrollTopAdjustment;
		}
	}
	objEditor=RTE_GetEditorDocument(strBaseElementID);
	if (strWebLanguage=="1037" || strWebLanguage=="1025" || objEditor.dir=="rtl")
	{
		ifmMenu.document.body.dir="rtl";
	}
	if (fNeedVerticalScrollBar)
	{
		ifmMenu.document.body.scroll="yes";
		cxDropDown+=22;
		if (ifmMenu.document.body.dir=="rtl")
		{
			xDropDown -=22;
			if (scrollLeftAdjustment > xDropDown)
			{
				xDropDown=scrollLeftAdjustment;
			}
		}
	}
	else
	{
		ifmMenu.document.body.scroll="";
	}
	var scrollLeftAdjustment=document.body.scrollLeft;
	scrollLeftAdjustment+=document.body.parentElement.scrollLeft;
	if (xDropDown+cxDropDown > cxBody+scrollLeftAdjustment)
	{
	  if (ifmMenu.document.body.dir !="rtl")
	  {
		xDropDown=cxBody+scrollLeftAdjustment - cxDropDown;
	  }
	  if (scrollLeftAdjustment > xDropDown)
	  {
		  xDropDown=scrollLeftAdjustment;
	  }
	}
	elemMenu.style.zIndex=500;
	elemMenu.style.left=xDropDown;
	elemMenu.style.top=yDropDown;
	elemMenu.style.width=cxDropDown;
	elemMenu.style.height=cyDropDown;
	RTE_DD_SetHighlightOnMenuItem(RTE_DD_GetMenuItem(0));
	event.cancelBubble=true;
}
function RTE_DD_CloseMenu()
{
	var elemMenu=RTE_DD_GetMenuElement();
	if (null==elemMenu)
	{
		return;
	}
	elemMenu.style.display="none";
	if ((g_strRTEDDBaseElementID !=null) && (g_strRTEDDButtonMnemonic !=null))
	{
		RTE_TB_ClearButtonHover(RTE_TB_GetToolBarButton(g_strRTEDDBaseElementID, g_strRTEDDButtonMnemonic));
	}
	g_strRTEDDBaseElementID=null;
	g_strRTEDDButtonMnemonic=null;
	g_elemRTEHighlightedMenuItem=null;
	g_iRTEHighlightedMenuItem=-1;
	g_iRTEMenuItemMax=-1;
	var parentDoc=document.parentWindow.parent;
	if (parentDoc)
	{
		try
		{
			parentDoc.g_strRTEDDBaseElementID=null;
			parentDoc.g_strRTEDDButtonMnemonic=null;
			parentDoc.g_elemRTEHighlightedMenuItem=null;
			parentDoc.g_iRTEHighlightedMenuItem=-1;
			parentDoc.g_iRTEMenuItemMax=-1;
		}
		catch (e) {}
	}
}
function RTE_DD_GenerateMenuOpenHtml()
{
	return "<table class=\"ms-rtedropdown\" id=\""+g_strRTEMenuTableElementName+"\"cellspacing=0 border=0 unselectable=\"on\"><tr unselectable=\"on\">";
}
function RTE_DD_GenerateMenuCloseHtml()
{
	return "</tr></table>";
}
function RTE_DD_GenerateMenuItemHtml(cColumns, iMenuItem, strCommandToPerform, strCommandValue, strMenuItemHtml, strMenuItemToolTip, strJSOnMouseOver, strJSOnMouseOut, strWebLanguage)
{
	return RTE_DD_GenerateMenuItemScriptHtml(cColumns, iMenuItem, "return RTE_DD_ExecuteCommand('"+strCommandToPerform+"', '"+STSScriptEncode(strCommandValue)+"')", strMenuItemHtml, strMenuItemToolTip, strJSOnMouseOver, strJSOnMouseOut, strWebLanguage);
}
function RTE_DD_GenerateMenuItemScriptHtml(cColumns, iMenuItem, strScript, strMenuItemHtml, strMenuItemToolTip, strJSOnMouseOver, strJSOnMouseOut, strWebLanguage)
{
	var strHtmlRet="";
	if (((1 >=cColumns) || ((1 < cColumns) && (0==(iMenuItem % cColumns)))) && (0 !=iMenuItem))
	{
		strHtmlRet="</tr><tr unselectable=\"on\">";
	}
	var direction;
	if (strWebLanguage=="1037" || strWebLanguage=="1025")
	{
		direction="rtl";
	}
	else
	{
		direction="ltr";
	}
	strHtmlRet+=		"<td dir=\""+direction+"\" class=\""+g_strRTEToolbarClassName+" "+g_strRTEUnselectedClassName+"\" "+			"nowrap id=\""+g_strRTEMenuItemBaseName+iMenuItem+"\" "+			g_strRTEMenuItemAttributeName+"=\""+iMenuItem+"\" "+			"onfocus=\"if (document.readyState=='complete') {RTE_DD_Item_OnFocus(this)}\" "+			"onclick=\""+strScript+"\" "+			"unselectable=\"on\" "+			"onmouseover=\"if (document.readyState=='complete') {RTE_DDItem_OnMouseOver(this);";
	if (strJSOnMouseOver) strHtmlRet+=strJSOnMouseOver;
	strHtmlRet+="}\" "+			"onmouseout=\"if (document.readyState=='complete') {RTE_DDItem_OnMouseOut(this);";
	if (strJSOnMouseOut) strHtmlRet+=strJSOnMouseOut;
	strHtmlRet+="}\">"+			"<a TABINDEX=-1 href=\"#\" "+				"class=\""+g_strRTEUnselectedClassName+"\" "+				"style=\"text-decoration: none; color: black; cursor: pointer;\" "+				"title=\""+strMenuItemToolTip+"\" "+				"unselectable=\"on\" "+				"onblur=\"if (document.readyState=='complete') {RTE_DD_Item_OnBlur()}\" "+				"onfocus=\"if (document.readyState=='complete') {RTE_DD_Item_OnFocus(this.parentElement)}\">"+				strMenuItemHtml+			"</a>"+		"</td>";
	return strHtmlRet;
}
function RTE_DD_GetMenuItem(iMenuItem)
{
	var elemMenuItem=RTE_DD_GetMenuFrame().document.all(g_strRTEMenuItemBaseName+iMenuItem);
	return elemMenuItem;
}
function RTE_DD_GetHighlightedMenuItem()
{
	return RTE_DD_GetMenuFrame().g_elemRTEHighlightedMenuItem;
}
function RTE_DD_SetHighlightedMenuItem(elem)
{
	var menuFrame=RTE_DD_GetMenuFrame();
	if (menuFrame !=null)
	{
		menuFrame.g_elemRTEHighlightedMenuItem=elem;
	}
	else
	{
		g_elemRTEHighlightedMenuItem=elem;
	}
}
function RTE_DD_ClearHighlightOnMenuItem(elemMenuItem)
{
	elemMenuItem.className=RTE_RemoveClassFromClassList(elemMenuItem.className, g_strRTEHoverClassName);
}
function RTE_DD_HighlightOnMenuItem(elemMenuItem)
{
	elemMenuItem.className=RTE_AddClassToClassList(elemMenuItem.className, g_strRTEHoverClassName);
}
function RTE_DD_ClearHighlightedMenuItem()
{
	RTE_DD_ClearHighlightOnMenuItem(RTE_DD_GetHighlightedMenuItem());
}
function RTE_DD_SetHighlightOnMenuItem(elemMenuItem)
{
	if (!RTE_DD_MenuIsOpen())
	{
		return;
	}
	var strMenuItemAttributeValue=elemMenuItem.getAttribute(g_strRTEMenuItemAttributeName);
	var highlightedElem=RTE_DD_GetHighlightedMenuItem();
	if (null !=highlightedElem)
	{
		RTE_DD_ClearHighlightOnMenuItem(highlightedElem);
		g_iRTEHighlightedMenuItem=-1;
	}
	RTE_DD_HighlightOnMenuItem(elemMenuItem);
	RTE_DD_SetHighlightedMenuItem(elemMenuItem);
	g_iRTEHighlightedMenuItem=parseInt(strMenuItemAttributeValue);
}
function RTE_DD_SetHighlightOnPrevMenuItem(cItemsToMove)
{
	var elemHighlighted=RTE_DD_GetHighlightedMenuItem();
	if (elemHighlighted==null) elemHighlighted=RTE_DD_GetMenuItem(0);
	var strMenuItemAttributeValue=elemHighlighted.getAttribute(g_strRTEMenuItemAttributeName);
	var iMenuItem=parseInt(strMenuItemAttributeValue);
	if (iMenuItem > 0)
	{
		var iNewMenuItem=Math.max(iMenuItem - cItemsToMove, 0);
		var elemPrev=RTE_DD_GetMenuItem(iNewMenuItem);
		elemHighlighted.onmouseout();
		RTE_DD_SetHighlightOnMenuItem(elemPrev);
		elemPrev.onmouseover();
	}
}
function RTE_DD_SetHighlightOnNextMenuItem(cItemsToMove)
{
	var elemHighlighted=RTE_DD_GetHighlightedMenuItem();
	if (elemHighlighted==null) elemHighlighted=RTE_DD_GetMenuItem(0);
	var strMenuItemAttributeValue=elemHighlighted.getAttribute(g_strRTEMenuItemAttributeName);
	var iMenuItem=parseInt(strMenuItemAttributeValue);
	if (iMenuItem < g_iRTEMenuItemMax)
	{
		var iNewMenuItem=Math.min(iMenuItem+cItemsToMove, g_iRTEMenuItemMax);
		var elemNext=RTE_DD_GetMenuItem(iNewMenuItem);
		elemHighlighted.onmouseout();
		RTE_DD_SetHighlightOnMenuItem(elemNext);
		elemNext.onmouseover();
	}
}
function RTE_DD_ExecuteCommand(strCommandToPerform, strCommandValue)
{
	var strBaseElementID=RTE_DD_GetMenuBaseElementID();
	RTE_DD_CloseMenu();
	RTE_GiveEditorFocus(strBaseElementID);
	RTE_RestoreSelection(strBaseElementID);
	RTE_ExecuteCommandOnSelection(RTE_DD_GetMenuBaseElementID(), strCommandToPerform, false, strCommandValue);
}
function RTE_DD_StartAction(strFunctionName, strParameter)
{
	var strBaseElementID=RTE_DD_GetMenuBaseElementID();
	RTE_DD_CloseMenu();
	RTE_GiveEditorFocus(strBaseElementID);
	RTE_RestoreSelection(strBaseElementID);
	RTE_ExecuteFunctionOnSelection(RTE_DD_GetMenuBaseElementID(), strFunctionName, strParameter);
}
function RTE_DD_Item_OnFocus(elemMenuItemCell)
{
	var elemMenu=RTE_DD_GetMenuElement();
	elemMenu.setAttribute(g_strRTEMenuOpeningAttributeName, "0");
	RTE_DD_SetHighlightOnMenuItem(elemMenuItemCell);
}
function RTE_DD_Item_OnBlur()
{
	g_iRTEHighlightedMenuItem=-1;
	window.setTimeout("RTE_OnItemBlurTestCloseMenu()", 30);
}
function RTE_OnItemBlurTestCloseMenu()
{
	if (null==RTE_DD_GetHighlightedMenuItem())
	{
		RTE_DD_CloseMenu();
	}
}
function RTE_DD_OnKeyDown(elem)
{
	var evtSource=elem.document.parentWindow.event;
	var nKeyCode=evtSource.keyCode;
	var fAltKey=evtSource.altKey;
	var fCtrlKey=evtSource.ctrlKey;
	var fShiftKey=evtSource.shiftKey;
	if (!fCtrlKey && !fAltKey && !fShiftKey)
	{
		switch (nKeyCode)
		{
			case 27:
				var strBaseElementID=g_strRTEDDBaseElementID;
				RTE_DD_CloseMenu();
				RTE_GiveEditorFocus(strBaseElementID);
				RTE_StartResetToolBarTimer(strBaseElementID);
				break;
			case 38:
				evtSource.returnValue=false;
				RTE_DD_SetHighlightOnPrevMenuItem(1);
				break;
			case 9:
			   evtSource.returnValue=false;
			   break;
			case 13:
				var menuItem=RTE_DD_GetHighlightedMenuItem();
				if (menuItem !=null)
				{
					menuItem.onclick();
				}
				evtSource.returnValue=false;
				break;
			case 40:
				evtSource.returnValue=false;
				RTE_DD_SetHighlightOnNextMenuItem(1);
				break;
			case 33:
				evtSource.returnValue=false;
				RTE_DD_SetHighlightOnPrevMenuItem(12);
				break;
			case 34:
				evtSource.returnValue=false;
				RTE_DD_SetHighlightOnNextMenuItem(12);
				break;
			case 36:
				evtSource.returnValue=false;
				break;
			case 35:
				evtSource.returnValue=false;
				break;
		}
	}
	if (!fCtrlKey && !fAltKey && fShiftKey)
	{
		switch (nKeyCode)
		{
			case 9:
				evtSource.returnValue=false;
				break;
		}
	}
}
function RTE_DDItem_OnMouseOver(elemTD)
{
	if (null !=elemTD)
	{
		RTE_DD_SetHighlightOnMenuItem(elemTD);
	}
}
function RTE_DDItem_OnMouseOut(elemTD)
{
	if (null !=elemTD)
	{
		RTE_DD_ClearHighlightOnMenuItem(elemTD);
	}
}
var g_rgstrRTEMenuHtml=new Array();
var g_strRTEColorMatrixMenuItemPrefixHtml="<div unselectable=\"on\" style=\"width: 10px; height: 10px; background-color: ";
var g_strRTEColorMatrixMenuItemSufffixHtml=";\"><img unselectable=\"on\" width=10 height=10 src=\""+RTE_GetServerRelativeUnlocalizedImageUrl("blank.gif")+"\" alt=\"%TOOLTIP%\"></div>";
function RTE_DD_OpenFontNameOrSizeSelector(strBaseElementID, strWebLanguage, fGeneratingFontNameSelector)
{
	RTE_RestoreSelection(strBaseElementID);
	var rngSelection=RTE_GetSelection(strBaseElementID);
	if (rngSelection==null)
	{
		return;
	}
	var strSelectionFontName=rngSelection.queryCommandValue(g_strRTEFontNameMnemonic);
	if (null==strSelectionFontName)
	{
		strSelectionFontName="";
	}
	var strSelectionFontSize=rngSelection.queryCommandValue(g_strRTEFontSizeMnemonic);
	var fSelectionBold=rngSelection.queryCommandValue(g_strRTEBoldMnemonic);
	var fSelectionItalic=rngSelection.queryCommandValue(g_strRTEItalicMnemonic);
	var strMenuHtml="";
	var cMenuItems=-1;
	var strButtonMnemonic="";
	var rgoMenuInfo=RTE_DD_GetFontNameOrSizeSelectorUnformattedHtml(strBaseElementID, fGeneratingFontNameSelector, strWebLanguage);
	strMenuHtml=rgoMenuInfo[0];
	cMenuItems=rgoMenuInfo[1];
	if (fGeneratingFontNameSelector)
	{
		strMenuHtml=strMenuHtml.replace(new RegExp(g_strRTEFontSizeToken, "g"), 2);
		strButtonMnemonic=g_strRTEFontNameMnemonic;
	}
	else
	{
		strMenuHtml=strMenuHtml.replace(new RegExp(g_strRTEFontNameToken, "g"), STSHtmlEncode(strSelectionFontName));
		strButtonMnemonic=g_strRTEFontSizeMnemonic;
	}
	var strBegBoldItalicInsert="";
	var strEndBoldItalicInsert="";
	if (fSelectionBold)
	{
		strBegBoldItalicInsert="<b unselectable='on'>";
		strEndBoldItalicInsert="</b>";
	}
	if (fSelectionItalic)
	{
		strBegBoldItalicInsert+="<i unselectable='on'>";
		strEndBoldItalicInsert+="</i>";
	}
	strMenuHtml=strMenuHtml.replace(new RegExp(g_strRTEBegBoldItalicToken, "g"), strBegBoldItalicInsert);
	strMenuHtml=strMenuHtml.replace(new RegExp(g_strRTEEndBoldItalicToken, "g"), strEndBoldItalicInsert);
	RTE_DD_OpenMenu(strBaseElementID, strButtonMnemonic, strMenuHtml, strWebLanguage, cMenuItems);
}
function RTE_DD_GetFontNameOrSizeSelectorUnformattedHtml(strBaseElementID, fGeneratingFontNameSelector, strWebLanguage)
{
	var strCommandToPerform;
	if (fGeneratingFontNameSelector)
	{
		strCommandToPerform=g_strRTEFontNameMnemonic;
	}
	else
	{
		strCommandToPerform=g_strRTEFontSizeMnemonic;
	}
	var strMenuHtml=null;
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	if (instanceVariables !=null && instanceVariables.RenderFontNamesAsText !=null && instanceVariables.RenderFontNamesAsText)
	{
		strMenuHtml=g_rgstrRTEMenuHtml[strCommandToPerform+"_text"]
	}
	else
	{
		strMenuHtml=g_rgstrRTEMenuHtml[strCommandToPerform];
	}
	if (null !=strMenuHtml)
	{
		return strMenuHtml;
	}
	strMenuHtml=RTE_DD_GenerateMenuOpenHtml();
	var cMenuItems=-1;
	if (fGeneratingFontNameSelector)
	{
		var rgstrClientFonts=RTE_GetSortedFontNames();
		cMenuItems=rgstrClientFonts.length;
		var iFont;
		for (iFont=0; iFont < cMenuItems; iFont++)
		{
			if (instanceVariables !=null && instanceVariables.RenderFontNamesAsText !=null && instanceVariables.RenderFontNamesAsText)
			{
				strMenuHtml+=RTE_DD_GenerateMenuItemScriptHtml(1, iFont, "return RTE_ApplyFontFace('"+strCommandToPerform+"', '"+rgstrClientFonts[iFont]+"')",
						g_strRTEBegBoldItalicToken+"<font face='' style='height:18px' unselectable='on'>"+						STSHtmlEncode(rgstrClientFonts[iFont])+"</font>"+g_strRTEEndBoldItalicToken, rgstrClientFonts[iFont], "RTE_DD_FontNameOnMouseOver(this);", "RTE_DD_FontNameOnMouseOut(this);", strWebLanguage);
			}
			else
			{
				strMenuHtml+=RTE_DD_GenerateMenuItemScriptHtml(1, iFont, "return RTE_ApplyFontFace('"+strCommandToPerform+"', '"+rgstrClientFonts[iFont]+"')",
						g_strRTEBegBoldItalicToken+"<font size=\""+g_strRTEFontSizeToken+"\" face=\""+rgstrClientFonts[iFont]+"\" unselectable='on'>"+						rgstrClientFonts[iFont]+"</font>"+g_strRTEEndBoldItalicToken, rgstrClientFonts[iFont], null, null, strWebLanguage);
			}
		}
	}
	else
	{
		cMenuItems=7;
		var nFontSize;
		for (nFontSize=1; nFontSize <=cMenuItems; nFontSize++)
		{
			strMenuHtml+=RTE_DD_GenerateMenuItemScriptHtml(1, nFontSize - 1, "return RTE_ApplyFontSize('"+strCommandToPerform+"', '"+nFontSize+"')",
					g_strRTEBegBoldItalicToken+"<font size=\""+nFontSize+"\" face=\""+g_strRTEFontNameToken+"\" unselectable='on'>"+					nFontSize+" - "+L_ExampleText_TEXT+"</font>"+g_strRTEEndBoldItalicToken, nFontSize, null, null, strWebLanguage);
		}
	}
	strMenuHtml+=RTE_DD_GenerateMenuCloseHtml();
	if (instanceVariables !=null && instanceVariables.RenderFontNamesAsText !=null && instanceVariables.RenderFontNamesAsText)
	{
		g_rgstrRTEMenuHtml[strCommandToPerform+"_text"]=new Array(strMenuHtml, cMenuItems);
		return g_rgstrRTEMenuHtml[strCommandToPerform+"_text"];
	}
	else
	{
		g_rgstrRTEMenuHtml[strCommandToPerform]=new Array(strMenuHtml, cMenuItems);;
		return g_rgstrRTEMenuHtml[strCommandToPerform];
	}
}
function RTE_ApplyFontFace(strCommandToPerform,strCommandValue)
{
	var strBaseElementID=RTE_DD_GetMenuBaseElementID();
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	if (instanceVariables !=null && instanceVariables.overrides.ApplyFontFace !=null)
	{
		return instanceVariables.overrides.ApplyFontFace(strCommandToPerform,strCommandValue);
	}
	var elements=RTE_GetContainedElements(strBaseElementID);
	for (var i=0; i<elements.length;i++)
	{
		RTE_RemoveFontFamilyStyle(elements[i]);
	}
	return RTE_DD_ExecuteCommand(strCommandToPerform,strCommandValue);
}
function RTE_RemoveFontFamilyStyle(element)
{
	if (element !=null)
	{
		if (element.style !=null && element.style.fontFamily)
		{
			element.style.removeAttribute("fontFamily");
		}
		for (var i=0; i<element.childNodes.length;i++)
		{
			RTE_RemoveFontFamilyStyle(element.childNodes(i));
		}
	}
}
function RTE_ApplyFontSize(strCommandToPerform,strCommandValue)
{
	var strBaseElementID=RTE_DD_GetMenuBaseElementID();
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	if (instanceVariables !=null && instanceVariables.overrides.ApplyFontSize !=null)
	{
		return instanceVariables.overrides.ApplyFontSize(strCommandToPerform,strCommandValue);
	}
	var elements=RTE_GetContainedElements(strBaseElementID);
	for (var i=0; i<elements.length;i++)
	{
		RTE_RemoveFontSizeStyle(elements[i]);
	}
	return RTE_DD_ExecuteCommand(strCommandToPerform,strCommandValue);
}
function RTE_RemoveFontSizeStyle(element)
{
	if (element !=null)
	{
		if (element.style !=null && element.style.fontSize)
		{
			element.style.removeAttribute("fontSize");
		}
		for (var i=0; i<element.childNodes.length;i++)
		{
			RTE_RemoveFontSizeStyle(element.childNodes(i));
		}
	}
}
function RTE_DD_FontNameOnMouseOver(elem)
{
	for (var i=0; i<elem.all.length; i++)
	{
		if (elem.all(i).tagName.toUpperCase()=="FONT")
		{
			elem.all(i).face=elem.all(i).innerText;
		}
	}
}
function RTE_DD_FontNameOnMouseOut(elem)
{
	for (var i=0; i<elem.all.length; i++)
	{
		if (elem.all(i).tagName.toUpperCase()=="FONT")
		{
			elem.all(i).face=null;
		}
	}
}
function RTE_DD_OpenForeColorSelector(strBaseElementID, strWebLanguage)
{
	RTE_DD_OpenMenu(strBaseElementID, g_strRTEForeColorMnemonic, RTE_DD_GetColorSelectorHtml(g_strRTEForeColorMnemonic, strWebLanguage), strWebLanguage, g_rgrgstrRTEColorMatrix.length);
}
function RTE_DD_OpenBackColorSelector(strBaseElementID, strWebLanguage)
{
	RTE_DD_OpenMenu(strBaseElementID, g_strRTEBackColorMnemonic, RTE_DD_GetColorSelectorHtml(g_strRTEBackColorMnemonic, strWebLanguage), strWebLanguage, g_rgrgstrRTEColorMatrix.length);
}
function RTE_DD_GetColorSelectorHtml(strCommandToPerform, strWebLanguage)
{
	var strMenuHtml=g_rgstrRTEMenuHtml[strCommandToPerform];
	if (null==strMenuHtml)
	{
		strMenuHtml=RTE_DD_GenerateMenuOpenHtml();
		var iColor;
		for (iColor=0; iColor < g_rgrgstrRTEColorMatrix.length; iColor++)
		{
			strMenuHtml+=RTE_DD_GenerateMenuItemHtml(g_cRTEColorMatrixColumns, iColor, strCommandToPerform,
					g_rgrgstrRTEColorMatrix[iColor][1], g_strRTEColorMatrixMenuItemPrefixHtml+g_rgrgstrRTEColorMatrix[iColor][1]+					g_strRTEColorMatrixMenuItemSufffixHtml.replace("%TOOLTIP%", g_rgrgstrRTEColorMatrix[iColor][0]), "",
					null, null, strWebLanguage);
		}
		strMenuHtml+=RTE_DD_GenerateMenuCloseHtml();
		g_rgstrRTEMenuHtml[strCommandToPerform]=strMenuHtml;
	}
	return strMenuHtml;
}
var g_cRTEColorMatrixColumns=8;
var g_rgrgstrRTEColorMatrix=new Array(
	new Array(L_Black_TEXT, "#000000"), new Array(L_Brown_TEXT, "#993300"), new Array(L_OliveGreen_TEXT, "#333300"), new Array(L_DarkGreen_TEXT, "#003300"),
	new Array(L_DarkTeal_TEXT, "#003366"), new Array(L_DarkBlue_TEXT, "#000080"), new Array(L_Indigo_TEXT, "#333399"), new Array(L_Gray80_TEXT, "#333333"),
	new Array(L_DarkRed_TEXT, "#800000"), new Array(L_Orange_TEXT, "#ff6600"), new Array(L_DarkYellow_TEXT, "#808000"), new Array(L_Green_TEXT, "#008000"),
	new Array(L_Teal_TEXT, "#008080"), new Array(L_Blue_TEXT, "#0000FF"), new Array(L_BlueGray_TEXT, "#666699"), new Array(L_Gray50_TEXT, "#808080"),
	new Array(L_Red_TEXT, "#FF0000"), new Array(L_LightOrange_TEXT, "#ff9900"), new Array(L_Lime_TEXT, "#99cc00"), new Array(L_SeaGreen_TEXT, "#339966"),
	new Array(L_Aqua_TEXT, "#33cccc"), new Array(L_LightBlue_TEXT, "#3366ff"), new Array(L_Violet_TEXT, "#800080"), new Array(L_Gray40_TEXT, "#969696"),
	new Array(L_Pink_TEXT, "#FF00FF"), new Array(L_Gold_TEXT, "#ffcc00"), new Array(L_Yellow_TEXT, "#FFFF00"), new Array(L_BrightGreen_TEXT, "#00FF00"),
	new Array(L_Turquoise_TEXT, "#00FFFF"), new Array(L_SkyBlue_TEXT, "#00ccff"), new Array(L_Plum_TEXT, "#993366"), new Array(L_Gray25_TEXT, "#C0C0C0"),
	new Array(L_Rose_TEXT, "#ff99cc"), new Array(L_Tan_TEXT, "#ffcc99"), new Array(L_LightYellow_TEXT, "#ffff99"), new Array(L_LightGreen_TEXT, "#ccffcc"),
	new Array(L_LightTurquoise_TEXT, "#ccffff"), new Array(L_PaleBlue_TEXT, "#99ccff"), new Array(L_Lavender_TEXT, "#cc99ff"), new Array(L_White_TEXT, "#FFFFFF") );
function RTE_CaseInsensitiveCompare(str1, str2)
{
	strU1=str1.toUpperCase();
	strU2=str2.toUpperCase();
	if (strU1 > strU2)
		return 1;
	else if (strU1 < strU2)
		return -1;
	else
		return 0;
}
function RTE_GetDialogHelper()
{
	return document.all(g_strRTEDialogHelperID);
}
function RTE_GetSortedFontNames()
{
	var rgstrFontNamesRet=new Array();
	var dh=RTE_GetDialogHelper();
	if ((null !=dh) && (null !=dh.fonts) && (0 < dh.fonts.count))
	{
		var iFont;
		for (iFont=1; iFont < dh.fonts.count; iFont++)
		{
			if (!RTE_StringIsNullOrEmpty(dh.fonts(iFont)))
			{
				rgstrFontNamesRet.push(dh.Fonts(iFont));
			}
		}
		return rgstrFontNamesRet.sort(RTE_CaseInsensitiveCompare);
	}
	else
	{
		RTE_InsertIntoSortedArrayIfValid(L_Font1_TEXT, rgstrFontNamesRet);
		RTE_InsertIntoSortedArrayIfValid(L_Font2_TEXT, rgstrFontNamesRet);
		RTE_InsertIntoSortedArrayIfValid(L_Font3_TEXT, rgstrFontNamesRet);
		RTE_InsertIntoSortedArrayIfValid(L_Font4_TEXT, rgstrFontNamesRet);
		RTE_InsertIntoSortedArrayIfValid(L_Font5_TEXT, rgstrFontNamesRet);
		RTE_InsertIntoSortedArrayIfValid(L_Font6_TEXT, rgstrFontNamesRet);
		RTE_InsertIntoSortedArrayIfValid(L_Font7_TEXT, rgstrFontNamesRet);
		RTE_InsertIntoSortedArrayIfValid(L_Font8_TEXT, rgstrFontNamesRet);
	}
	return rgstrFontNamesRet;
}
function RTE_IsChildOfElement(elemSearchingFor, elemToSearch)
{
	var rgelemChildren=elemToSearch.children;
	if ((null==rgelemChildren) || (0 >=rgelemChildren.length))
	{
		return false;
	}
	var iChild=0;
	for (iChild=0; iChild < rgelemChildren.length; iChild++)
	{
		var elemChild=rgelemChildren[iChild];
		if (elemChild==elemSearchingFor)
		{
			return true;
		}
		if (RTE_IsChildOfElement(elemSearchingFor, elemChild))
		{
			return true;
		}
	}
	return false;
}
function RTE_FindParentElementWithTag(elem, strTagName)
{
	if (null==elem.parentElement)
	{
		return null;
	}
	return RTE_FindParentElementOrSelfWithTag(elem.parentElement, strTagName);
}
function RTE_FindParentElementOrSelfWithTag(elem, strTagName)
{
	if (elem.tagName==strTagName)
	{
		return elem;
	}
	else
	{
		if (null==elem.parentElement)
		{
			return null;
		}
		return RTE_FindParentElementOrSelfWithTag(elem.parentElement, strTagName);
	}
}
var g_iRTELeft=0;
var g_iRTETop=1;
var g_iRTEWidth=2;
var g_iRTEHeight=3;
var g_iRTERight=4;
var g_iRTEBottom=5;
function RTE_GetElementWindowCoordinates(elem)
{
	var xLeft=0;
	var yTop=0;
	var cxWidth=elem.offsetWidth;
	var cyHeight=elem.offsetHeight;
	do
	{
		if (elem.currentStyle.position !="relative")
		{
			xLeft+=elem.offsetLeft;
			yTop+=elem.offsetTop;
		}
		if (null==elem.offsetParent)
		{
			var mLeft=parseInt(elem.currentStyle.marginLeft);
			var mTop=parseInt(elem.currentStyle.marginTop);
			if (!isNaN(mLeft))
			{
				xLeft+=mLeft;
			}
			if (!isNaN(mTop))
			{
				yTop+=mTop;
			}
		}
		elem=elem.offsetParent;
	}
	while (elem !=null);
	var rgnRet=new Array();
	rgnRet[g_iRTELeft]=xLeft;
	rgnRet[g_iRTETop]=yTop;
	rgnRet[g_iRTEWidth]=cxWidth;
	rgnRet[g_iRTEHeight]=cyHeight;
	rgnRet[g_iRTERight]=xLeft+cxWidth - 1;
	rgnRet[g_iRTEBottom]=yTop+cyHeight - 1;
	return rgnRet;
}
function RTE_GetServerRelativeUnlocalizedImageUrl(strImageFileName)
{
   return "/_layouts/images/"+strImageFileName;
}
function RTE_GetServerRelativeImageUrl(strImageFileName)
{
	return "/_layouts/"+L_Language_Text+"/images/"+strImageFileName;
}
function RTE_GetServerRelativeStylesheetUrl(strStylesheetFileName, strWebLocale)
{
   return "/_layouts/"+strWebLocale+"/styles/"+strStylesheetFileName;
}
function RTE_GetServerRelativeScriptUrl(strScriptFileName, strWebLocale)
{
   return "/_layouts/"+strWebLocale+"/"+strScriptFileName;
}
function RTE_StripDoubleSpaces(str)
{
	while (str.indexOf("  ") !=-1)
	{
		str=str.replace(/  /g, " ");
	}
	return str;
}
function RTE_AddClassToClassList(strClassList, strNewClass)
{
	if (0 <=strClassList.indexOf(strNewClass))
	{
		return strClassList;
	}
	return RTE_StripDoubleSpaces(strClassList+" "+strNewClass);
}
function RTE_ReplaceClassInClassList(strClassList, strOldClass, strNewClass)
{
	var iSel=strClassList.indexOf(strOldClass);
	var strAheadOfOldClass="";
	if (0 < iSel)
	{
		return RTE_StripDoubleSpaces(strClassList.substr(0, iSel)+" "+strNewClass+" "+strClassList.substr(iSel+strOldClass.length));
	}
	return RTE_AddClassToClassList(strClassList, strNewClass);
}
function RTE_RemoveClassFromClassList(strClassList, strClass)
{
	return RTE_ReplaceClassInClassList(strClassList, strClass, "");
}
function RTE_AddOrRemoveClassFromClassList(fAdd, strClassList, strClass)
{
	if (fAdd)
	{
		return RTE_AddClassToClassList(strClassList, strClass);
	}
	return RTE_RemoveClassFromClassList(strClassList, strClass);
}
function RTE_StringIsNullOrEmpty(str)
{
	return ((str==null) ||
			(str.length==0));
}
function RTE_InsertIntoSortedArrayIfValid(strInsert, rgstrDest)
{
	if (RTE_StringIsNullOrEmpty(strInsert))
	{
		return;
	}
	var i=0;
	for (i=rgstrDest.length; i >=0; i--)
	{
		if ((0==i) || (rgstrDest[i - 1] < strInsert))
		{
			rgstrDest[i]=strInsert;
			return;
		}
		else
		{
			rgstrDest[i]=rgstrDest[i - 1];
		}
	}
}
function RTE_GenerateStylesToolBarButtonHtml(strBaseElementID, strWebLanguage)
{
	var strHtmlRet="";
	strHtmlRet+=RTE_TB_GenerateOpenCellButtonHtml(strBaseElementID, g_strRTEStylesMnemonic);
	strHtmlRet+="<a TABINDEX=-1 href=\"#\" onfocus=\"RTE_TB_OnFocus('"+strBaseElementID+"', this);\" onblur=\"RTE_TB_OnBlur('"+strBaseElementID+"', this);\" onclick=\"RTE_DD_OpenStylesSelector('"+strBaseElementID+"' ,'"+strWebLanguage+"', true); return false;\" title=\""+			L_StylesToolTip_TEXT+"\"";
	strHtmlRet+=" style=\"margin-left: 2px; margin-right: 2px;\" unselectable=\"on\">"+L_StylesLabel_TEXT+"&nbsp;<img alt=\""+			L_StylesToolTip_TEXT+"\" src=\""+RTE_GetServerRelativeUnlocalizedImageUrl("menudark.gif")+"\" border=0 width=13 height=13 unselectable=\"on\">";
	strHtmlRet+="</a>";
	strHtmlRet+=RTE_TB_GenerateCloseCellButtonHtml();
	return strHtmlRet;
}
function RTE_DD_OpenStylesSelector(strBaseElementID, strWebLanguage)
{
	var strMnemonic=g_strRTEStylesMnemonic;
	var rgoMenuInfo=RTE_DD_GetStylesSelectorUnformattedHtml(strWebLanguage);
	var strMenuHtml=rgoMenuInfo[0];
	var cMenuItems=rgoMenuInfo[1];
	RTE_DD_OpenMenu(strBaseElementID, strMnemonic, strMenuHtml, cMenuItems);
}
function RTE_DD_GetStylesSelectorUnformattedHtml(strWebLanguage)
{
	var strMenuHtml=g_rgstrRTEMenuHtml[g_strRTEStylesMnemonic];
	if (null !=strMenuHtml)
	{
		return strMenuHtml;
	}
	var strCommandToPerform=g_strRTEFormatBlockMnemonic;
	strMenuHtml=RTE_DD_GenerateMenuOpenHtml(strWebLanguage);
	var rgstrItemNames=RTE_GetBlockFormatNames();
	var cMenuItems=rgstrItemNames.length;
	for (var iItem=0; iItem < cMenuItems; iItem++)
	{
		strMenuHtml+=RTE_DD_GenerateMenuItemHtml(1, iItem, strCommandToPerform, rgstrItemNames[iItem],
				rgstrItemNames[iItem], "", null, null, strWebLanguage);
	}
	strMenuHtml+=RTE_DD_GenerateMenuCloseHtml();
	g_rgstrRTEMenuHtml[g_strRTEStylesMnemonic]=new Array(strMenuHtml, cMenuItems);
	return g_rgstrRTEMenuHtml[g_strRTEStylesMnemonic];
}
function RTE_GetBlockFormatNames()
{
	var rgstrItemNamesRet=new Array();
	var dh=RTE_GetDialogHelper();
	if ((null !=dh) && (null !=dh.blockFormats) && (0 < dh.blockFormats.count))
	{
		var iItem;
		for (iItem=1; iItem < dh.blockFormats.count; iItem++)
		{
			RTE_InsertIntoSortedArrayIfValid(dh.blockFormats(iItem), rgstrItemNamesRet);
		}
	}
	return rgstrItemNamesRet;
}
function RTE_GenerateInsertRowToolBarButtonHtml(strBaseElementID, strWebLanguage)
{
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	instanceVariables.functions[g_strRTEInsertRowAbove]=RTE_InsertRowAbove;
	instanceVariables.functions[g_strRTEInsertRowBelow]=RTE_InsertRowBelow;
	var strHtmlRet="";
	strHtmlRet+=RTE_TB_GenerateOpenCellButtonHtml(strBaseElementID, g_strRTEInsertRowMnemonic, "RTE_DD_OpenInsertRowSelector('"+strBaseElementID+"' ,'"+strWebLanguage+"')");
	strHtmlRet+=L_InsertRowLabel_TEXT;
	strHtmlRet+="<img src=\""+RTE_GetServerRelativeImageUrl("rteirow.gif")+"\" alt=\""+L_InsertRowToolTip_TEXT+"\" border=0 width=16 height=16 unselectable=\"on\">";
	strHtmlRet+="<img alt=\""+L_InsertRowToolTip_TEXT+"\" src=\""+RTE_GetServerRelativeUnlocalizedImageUrl("menudark.gif")+"\" border=0 width=13 height=13 unselectable=\"on\">";
	strHtmlRet+=RTE_TB_GenerateCloseCellButtonHtml();
	return strHtmlRet;
}
function RTE_DD_OpenInsertRowSelector(strBaseElementID, strWebLanguage)
{
	var strMnemonic=g_strRTEInsertRowMnemonic;
	var rgoMenuInfo=RTE_DD_GetInsertRowSelectorUnformattedHtml(strBaseElementID, strWebLanguage);
	var strMenuHtml=rgoMenuInfo[0];
	var cMenuItems=rgoMenuInfo[1];
	RTE_DD_OpenMenu(strBaseElementID, strMnemonic, strMenuHtml, cMenuItems);
}
function RTE_DD_GetInsertRowSelectorUnformattedHtml(strBaseElementID, strWebLanguage)
{
	var strCommandToPerform=g_strRTEInsertRowMnemonic;
	var strMenuHtml=g_rgstrRTEMenuHtml[strCommandToPerform];
	if (null !=strMenuHtml)
	{
		return strMenuHtml;
	}
	strMenuHtml=RTE_DD_GenerateMenuOpenHtml(strWebLanguage);
	var rgstrItemNames=new Array();
	rgstrItemNames.push(L_InsertRowAboveLabel_TEXT);
	rgstrItemNames.push(L_InsertRowBelowLabel_TEXT);
	var cMenuItems=rgstrItemNames.length;
	var iItem=0;
	strMenuHtml+=RTE_DD_GenerateMenuItemScriptHtml(1, iItem,
		"RTE_DD_StartAction('"+g_strRTEInsertRowAbove+"', '"+strBaseElementID+"')",
		rgstrItemNames[iItem],
		rgstrItemNames[iItem],
		null, null, strWebLanguage);
	iItem=1;
	strMenuHtml+=RTE_DD_GenerateMenuItemScriptHtml(1, iItem,
		"RTE_DD_StartAction('"+g_strRTEInsertRowBelow+"', '"+strBaseElementID+"')",
		rgstrItemNames[iItem],
		rgstrItemNames[iItem],
		null, null, strWebLanguage);
	strMenuHtml+=RTE_DD_GenerateMenuCloseHtml();
	g_rgstrRTEMenuHtml[strCommandToPerform]=new Array(strMenuHtml, cMenuItems);
	return g_rgstrRTEMenuHtml[strCommandToPerform];
}
function RTE_GenerateInsertColumnToolBarButtonHtml(strBaseElementID, strWebLanguage)
{
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	instanceVariables.functions[g_strRTEInsertColumnLeft]=RTE_InsertColumnLeft;
	instanceVariables.functions[g_strRTEInsertColumnRight]=RTE_InsertColumnRight;
	var strHtmlRet="";
	strHtmlRet+=RTE_TB_GenerateOpenCellButtonHtml(strBaseElementID, g_strRTEInsertColumnMnemonic, "RTE_DD_OpenInsertColumnSelector('"+strBaseElementID+"' ,'"+strWebLanguage+"')");
	strHtmlRet+=L_InsertColumnLabel_TEXT;
	strHtmlRet+="<img src=\""+RTE_GetServerRelativeImageUrl("rteicol.gif")+"\" alt=\""+L_InsertColumnToolTip_TEXT+"\" border=0 width=16 height=16 unselectable=\"on\">";
	strHtmlRet+="<img alt=\""+L_InsertColumnToolTip_TEXT+"\" src=\""+RTE_GetServerRelativeUnlocalizedImageUrl("menudark.gif")+"\" border=0 width=13 height=13 unselectable=\"on\">";
	strHtmlRet+=RTE_TB_GenerateCloseCellButtonHtml();
	return strHtmlRet;
}
function RTE_DD_OpenInsertColumnSelector(strBaseElementID, strWebLanguage)
{
	var strMnemonic=g_strRTEInsertColumnMnemonic;
	var rgoMenuInfo=RTE_DD_GetInsertColumnSelectorUnformattedHtml(strBaseElementID, strWebLanguage);
	var strMenuHtml=rgoMenuInfo[0];
	var cMenuItems=rgoMenuInfo[1];
	RTE_DD_OpenMenu(strBaseElementID, strMnemonic, strMenuHtml, cMenuItems);
}
function RTE_DD_GetInsertColumnSelectorUnformattedHtml(strBaseElementID, strWebLanguage)
{
	var strCommandToPerform=g_strRTEInsertColumnMnemonic;
	var strMenuHtml=g_rgstrRTEMenuHtml[strCommandToPerform];
	if (null !=strMenuHtml)
	{
		return strMenuHtml;
	}
	strMenuHtml=RTE_DD_GenerateMenuOpenHtml(strWebLanguage);
	var rgstrItemNames=new Array();
	rgstrItemNames.push(L_InsertColumnLeftLabel_TEXT);
	rgstrItemNames.push(L_InsertColumnRightLabel_TEXT);
	var cMenuItems=rgstrItemNames.length;
	var iItem=0;
	strMenuHtml+=RTE_DD_GenerateMenuItemScriptHtml(1, iItem,
		"RTE_DD_StartAction('"+g_strRTEInsertColumnLeft+"', '"+strBaseElementID+"')",
		rgstrItemNames[iItem],
		rgstrItemNames[iItem],
		null, null, strWebLanguage);
	var iItem=1;
	strMenuHtml+=RTE_DD_GenerateMenuItemScriptHtml(1, iItem,
		"RTE_DD_StartAction('"+g_strRTEInsertColumnRight+"', '"+strBaseElementID+"')",
		rgstrItemNames[iItem],
		rgstrItemNames[iItem],
		null, null, strWebLanguage);
	strMenuHtml+=RTE_DD_GenerateMenuCloseHtml();
	g_rgstrRTEMenuHtml[strCommandToPerform]=new Array(strMenuHtml, cMenuItems);
	return g_rgstrRTEMenuHtml[strCommandToPerform];
}
function RTE_GenerateInsertCellToolBarButtonHtml(strBaseElementID, strWebLanguage)
{
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	instanceVariables.functions[g_strRTEInsertCellLeft]=RTE_InsertCellLeft;
	instanceVariables.functions[g_strRTEInsertCellRight]=RTE_InsertCellRight;
	var strHtmlRet="";
	strHtmlRet+=RTE_TB_GenerateOpenCellButtonHtml(strBaseElementID, g_strRTEInsertCellMnemonic, "RTE_DD_OpenInsertCellSelector('"+strBaseElementID+"' ,'"+strWebLanguage+"')");
	strHtmlRet+=L_InsertCellLabel_TEXT;
	strHtmlRet+="<img src=\""+RTE_GetServerRelativeImageUrl("rteicell.gif")+"\" alt=\""+L_InsertCellToolTip_TEXT+"\" border=0 width=16 height=16 unselectable=\"on\">";
	strHtmlRet+="<img alt=\""+L_InsertCellToolTip_TEXT+"\" src=\""+RTE_GetServerRelativeUnlocalizedImageUrl("menudark.gif")+"\" border=0 width=13 height=13 unselectable=\"on\">";
	strHtmlRet+=RTE_TB_GenerateCloseCellButtonHtml();
	return strHtmlRet;
}
function RTE_DD_OpenInsertCellSelector(strBaseElementID, strWebLanguage)
{
	var strMnemonic=g_strRTEInsertCellMnemonic;
	var rgoMenuInfo=RTE_DD_GetInsertCellSelectorUnformattedHtml(strBaseElementID, strWebLanguage);
	var strMenuHtml=rgoMenuInfo[0];
	var cMenuItems=rgoMenuInfo[1];
	RTE_DD_OpenMenu(strBaseElementID, strMnemonic, strMenuHtml, cMenuItems);
}
function RTE_DD_GetInsertCellSelectorUnformattedHtml(strBaseElementID, strWebLanguage)
{
	var strCommandToPerform=g_strRTEInsertCellMnemonic;
	var strMenuHtml=g_rgstrRTEMenuHtml[strCommandToPerform];
	if (null !=strMenuHtml)
	{
		return strMenuHtml;
	}
	strMenuHtml=RTE_DD_GenerateMenuOpenHtml(strWebLanguage);
	var rgstrItemNames=new Array();
	rgstrItemNames.push(L_InsertCellLeftLabel_TEXT);
	rgstrItemNames.push(L_InsertCellRightLabel_TEXT);
	var cMenuItems=rgstrItemNames.length;
	var iItem=0;
	strMenuHtml+=RTE_DD_GenerateMenuItemScriptHtml(1, iItem,
		"RTE_DD_StartAction('"+g_strRTEInsertCellLeft+"', '"+strBaseElementID+"')",
		rgstrItemNames[iItem],
		rgstrItemNames[iItem],
		null, null, strWebLanguage);
	var iItem=1;
	strMenuHtml+=RTE_DD_GenerateMenuItemScriptHtml(1, iItem,
		"RTE_DD_StartAction('"+g_strRTEInsertCellRight+"', '"+strBaseElementID+"')",
		rgstrItemNames[iItem],
		rgstrItemNames[iItem],
		null, null, strWebLanguage);
	strMenuHtml+=RTE_DD_GenerateMenuCloseHtml();
	g_rgstrRTEMenuHtml[strCommandToPerform]=new Array(strMenuHtml, cMenuItems);
	return g_rgstrRTEMenuHtml[strCommandToPerform];
}
function RTE_GetCurrentSelectionChain(strBaseElementID)
{
	var aChain=new Array();
	var elem=RTE_GetCurrentElement(strBaseElementID);
	while (elem !=null)
	{
		aChain[aChain.length]=elem;
		if (elem.id==strBaseElementID || elem.tagName=="BODY")
		{
			break;
		}
		elem=elem.parentElement;
	}
	return aChain;
}
function RTE_IsElementInChain(aChain, strTagName)
{
	if (aChain==null || aChain.length==0)
	{
		return false;
	}
	var aChain_length=aChain.length;
	if (strTagName==null || strTagName.length==0)
	{
		return false;
	}
	for (var i=0; i<aChain_length; i++)
	{
		if (aChain[i].tagName==strTagName)
		{
			return true;
		}
	}
	return false;
}
var g_aTableCellTagNames;
if (g_aTableCellTagNames==null)
{
	g_aTableCellTagNames=new Array("TD", "TH");
}
function RTE_IsAnyElementInChain(aChain, aTagNames)
{
	if (aChain==null || aChain.length==0)
	{
		return false;
	}
	var aChain_length=aChain.length;
	if (aTagNames==null || aTagNames.length==0)
	{
		return false;
	}
	var aTagNames_length=aTagNames.length;
	for (var i=0; i<aChain_length; i++)
	{
		var currentTagName=aChain[i].tagName;
		for (var j=0; j<aTagNames_length; j++)
		{
			if (currentTagName==aTagNames[j])
			{
				return true;
			}
		}
	}
	return false;
}
function RTE_GetCurrentSelection(strBaseElementID)
{
	var docEditor=RTE_GetEditorDocument(strBaseElementID);
	if (docEditor !=null)
	{
		return docEditor.selection;
	}
	return null;
}
function RTE_GetCurrentSelectionType(strBaseElementID)
{
	var selection=RTE_GetCurrentSelection(strBaseElementID);
	if (selection !=null)
	{
		return selection.type;
	}
	return null;
}
function RTE_GetCurrentSelectionRange(strBaseElementID)
{
	var selection=RTE_GetCurrentSelection(strBaseElementID);
	if (selection !=null)
	{
		return selection.createRange();
	}
	return null;
}
function RTE_GetCurrentElement(strBaseElementID)
{
	var selection=RTE_GetCurrentSelection(strBaseElementID);
	if (selection==null) {return null;}
	var range=selection.createRange();
	if (range==null) {return null;}
	if (selection.type.toLowerCase()=="control")
	{
		if (range.length !=1) {return null;}
		return range.item(0);
	}
	else
	{
		var elemParent=range.parentElement();
		if (elemParent !=null)
		{
			var editorDocument=RTE_GetEditorDocument(strBaseElementID);
			if (editorDocument.body.contains(elemParent))
			{
				return elemParent;
			}
		}
	}
	return null;
}
function RTE_IsElementSelected(strBaseElementID, strTagName)
{
	var currentElement=RTE_GetCurrentElement(strBaseElementID);
	if (currentElement !=null)
	{
		if (currentElement.tagName==strTagName)
		{
			return true;
		}
	}
	return false;
}
function RTE_GetNearestContainingParentElementOfType(strBaseElementID, elem, strTagName)
{
	return RTE_GetNearestContainingParentElementOfTypes(strBaseElementID, elem, new Array(strTagName))
}
function RTE_GetNearestContainingParentElementOfTypes(strBaseElementID, elem, aTagNames)
{
	var aTagNames_length=aTagNames.length;
	if (elem==null) return null;
	for (var i=0; i<aTagNames_length; i++)
	{
		if (elem.tagName==aTagNames[i])
		{
			return elem;
		}
	}
	var elemParent=elem.parentElement;
	while (elemParent !=null)
	{
		if (elemParent.id==strBaseElementID)
		{
			return null;
		}
		for (var i=0; i<aTagNames_length; i++)
		{
			if (elemParent.tagName==aTagNames[i])
			{
				return elemParent;
			}
		}
		elemParent=elemParent.parentElement;
	}
	return null;
}
function RTE_GetNearestContainingElementOfType(strBaseElementID, strTagName)
{
	var elem=RTE_GetCurrentElement(strBaseElementID);
	return RTE_GetNearestContainingParentElementOfType(strBaseElementID, elem, strTagName);
}
function RTE_GetNearestContainingElementOfTypes(strBaseElementID, aTagNames)
{
	var elem=RTE_GetCurrentElement(strBaseElementID);
	return RTE_GetNearestContainingParentElementOfTypes(strBaseElementID, elem, aTagNames);
}
function RTE_GetContainedElements(strBaseElementID)
{
	var containedElements=new Array();
	var selection=RTE_GetCurrentSelection(strBaseElementID);
	if (selection !=null && selection.type.toLowerCase()=="control")
	{
		var elemParent=RTE_GetCurrentElement(strBaseElementID);
		var elemParentAll=elemParent.all;
		for (var i=0; i<elemParentAll.length; i++)
		{
			containedElements[containedElements.length]=elemParentAll(i);
		}
		containedElements[containedElements.length]=elemParent;
	}
	else
	{
		var rngSelection=RTE_GetCurrentSelectionRange(strBaseElementID);
		if (rngSelection !=null)
		{
			var elemParent=RTE_GetOutermostSelectionElement(strBaseElementID);
			if (elemParent !=null)
			{
				var elemParentAll=elemParent.all;
				if (rngSelection.text==elemParent.outerText)
				{
					for (var i=0; i<elemParentAll.length; i++)
					{
						containedElements[containedElements.length]=elemParentAll(i);
					}
					containedElements[containedElements.length]=elemParent;
				}
				else
				{
					var rngContainedElement=rngSelection.duplicate();
					for (var i=0; i<elemParentAll.length; i++)
					{
						rngContainedElement.moveToElementText(elemParentAll(i));
						if (rngSelection.inRange(rngContainedElement))
						{
							containedElements[containedElements.length]=elemParentAll(i);
						}
					}
				}
			}
		}
	}
	return containedElements;
}
function RTE_GetOutermostSelectionElement(strBaseElementID)
{
	var elemParent=null;
	var selection=RTE_GetCurrentSelection(strBaseElementID);
	if (selection !=null && selection.type.toLowerCase()=="control")
	{
		elemParent=RTE_GetCurrentElement(strBaseElementID);
		containedElements=elemParent.all;
		containedElements[containedElements.length]=elemParent;
	}
	else
	{
		var rngSelection=RTE_GetCurrentSelectionRange(strBaseElementID);
		if (rngSelection !=null)
		{
			var elemParent=RTE_GetInnerMostContainingElement(rngSelection);
			if (elemParent !=null)
			{
				var elemFullyContainedParent=null;
				while (elemParent !=null && elemParent.tagName !="BODY" && rngSelection.text==elemParent.outerText)
				{
					elemFullyContainedParent=elemParent;
					elemParent=elemParent.parentElement;
				}
				if (elemFullyContainedParent !=null)
				{
					elemParent=elemFullyContainedParent;
				}
			}
		}
	}
	return elemParent;
}
function RTE_GetInnerMostContainingElement(range)
{
	var element=RTE_GetContainingParent(range);
	if (element !=null)
	{
		var rangeElement=range.duplicate();
		var elementFound=false;
		while (!elementFound)
		{
			var containingChildFound=false;
			var elementChildren=element.children;
			for (var i=0; i<elementChildren.length; i++)
			{
				rangeElement.moveToElementText(elementChildren[i]);
				if (rangeElement.inRange(range))
				{
					containingChildFound=true;
					element=elementChildren[i];
					break;
				}
			}
			if (!containingChildFound)
			{
				elementFound=true;
			}
		}
	}
	return element;
}
function RTE_GetContainingParent(range)
{
	var element=range.parentElement();
	if (element !=null)
	{
		var rangeElement=range.duplicate();
		rangeElement.moveToElementText(element);
		while (element !=null && element.tagName !="BODY" && !rangeElement.inRange(range))
		{
			element=element.parentElement;
			rangeElement.moveToElementText(element);
		}
	}
	return element;
}
function RTE_GetSelectedCells(strBaseElementID)
{
	var selectedCells=new Array();
	if (RTE_IsElementSelected(strBaseElementID, "TR"))
	{
		var elemRowCurrent=RTE_GetCurrentElement(strBaseElementID);
		if (elemRowCurrent !=null)
		{
			var rngSelection=RTE_GetCurrentSelectionRange(strBaseElementID);
			var rngContainedElement=rngSelection.duplicate();
			for (var i=0; i<elemRowCurrent.cells.length; i++)
			{
				rngContainedElement.moveToElementText(elemRowCurrent.cells(i));
				if (rngSelection.inRange(rngContainedElement))
				{
					selectedCells[selectedCells.length]=elemRowCurrent.cells(i);
				}
				else if ((rngSelection.compareEndPoints("StartToStart", rngContainedElement)==1)
					&& (rngSelection.compareEndPoints("StartToEnd", rngContainedElement)==-1))
				{
					selectedCells[selectedCells.length]=elemRowCurrent.cells(i);
				}
				else if ((rngSelection.compareEndPoints("EndToStart", rngContainedElement)==1)
					&& (rngSelection.compareEndPoints("EndToEnd", rngContainedElement)==-1))
				{
					selectedCells[selectedCells.length]=elemRowCurrent.cells(i);
				}
			}
		}
	}
	return selectedCells;
}
function RTE_InsertCellLeft(strBaseElementID)
{
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	if (instanceVariables !=null && instanceVariables.overrides.InsertCellLeft !=null)
	{
		return instanceVariables.overrides.InsertCellLeft(strBaseElementID);
	}
	if (RTE_GetDirectionOfSelection(strBaseElementID)=="rtl")
	{
		RTE_InsertCellBase(strBaseElementID, "afterEnd");
	}
	else
	{
		RTE_InsertCellBase(strBaseElementID, "beforeBegin");
	}
}
function RTE_InsertCellRight(strBaseElementID)
{
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	if (instanceVariables !=null && instanceVariables.overrides.InsertCellRight !=null)
	{
		return instanceVariables.overrides.InsertCellRight(strBaseElementID);
	}
	if (RTE_GetDirectionOfSelection(strBaseElementID)=="rtl")
	{
		RTE_InsertCellBase(strBaseElementID, "beforeBegin");
	}
	else
	{
		RTE_InsertCellBase(strBaseElementID, "afterEnd");
	}
}
function RTE_InsertCellBase(strBaseElementID, strWhere)
{
	var elemCellCurrent=RTE_GetNearestContainingElementOfTypes(strBaseElementID, g_aTableCellTagNames);
	if (elemCellCurrent==null)
	{
		return;
	}
	var docEditor=RTE_GetEditorDocument(strBaseElementID);
	if (docEditor==null)
	{
		return;
	}
	var elemCellNew=docEditor.createElement(elemCellCurrent.tagName);
	if (elemCellNew==null)
	{
		return;
	}
	elemCellNew.mergeAttributes(elemCellCurrent, true);
	elemCellNew.runtimeStyle.cssText=elemCellCurrent.runtimeStyle.cssText;
	elemCellCurrent.insertAdjacentElement(strWhere, elemCellNew);
	var textRange=docEditor.body.createTextRange();
	textRange.moveToElementText(elemCellNew);
	textRange.select();
	var elemTableCurrent=RTE_GetNearestContainingParentElementOfType(strBaseElementID, elemCellCurrent, "TABLE");
	if (elemTableCurrent)
	{
		RTE_ReapplyTableStyles(elemTableCurrent);
	}
}
function RTE_InsertRowAbove(strBaseElementID)
{
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	if (instanceVariables !=null && instanceVariables.overrides.InsertRowAbove !=null)
	{
		return instanceVariables.overrides.InsertRowAbove(strBaseElementID);
	}
	RTE_InsertRowBase(strBaseElementID, "beforeBegin");
}
function RTE_InsertRowBelow(strBaseElementID)
{
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	if (instanceVariables !=null && instanceVariables.overrides.InsertRowBelow !=null)
	{
		return instanceVariables.overrides.InsertRowBelow(strBaseElementID);
	}
	RTE_InsertRowBase(strBaseElementID, "afterEnd");
}
function RTE_InsertRowBase(strBaseElementID, strWhere)
{
	var elemRowSelected=RTE_GetNearestContainingElementOfType(strBaseElementID, "TR");
	if (elemRowSelected==null)
	{
		return;
	}
	var docEditor=RTE_GetEditorDocument(strBaseElementID);
	if (docEditor==null)
	{
		return;
	}
	var elemRowNew=docEditor.createElement("TR");
	if (elemRowNew==null)
	{
		return;
	}
	elemRowNew.mergeAttributes(elemRowSelected, true);
	elemRowNew.runtimeStyle.cssText=elemRowSelected.runtimeStyle.cssText;
	elemRowSelected.insertAdjacentElement(strWhere, elemRowNew);
	var cells=elemRowSelected.cells;
	for (var i=0; i<cells.length; i++)
	{
		var elemCellNew=elemRowNew.insertCell();
		elemCellNew.mergeAttributes(cells(i), true);
		elemCellNew.runtimeStyle.cssText=cells(i).runtimeStyle.cssText;
	}
	var textRange=docEditor.body.createTextRange();
	var dir=RTE_GetDirectionOfSelection(strBaseElementID);
	if (dir=="ltr")
	{
		textRange.moveToElementText(elemRowNew.cells(0));
	}
	else
	{
		textRange.moveToElementText(elemRowNew.cells(elemRowNew.cells.length - 1));
	}
	textRange.select();
	var elemTableSelected=RTE_GetNearestContainingParentElementOfType(strBaseElementID, elemRowSelected, "TABLE");
	if (elemTableSelected)
	{
		RTE_ReapplyTableStyles(elemTableSelected);
	}
}
function RTE_InsertColumnLeft(strBaseElementID)
{
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	if (instanceVariables !=null && instanceVariables.overrides.InsertColumnLeft !=null)
	{
		return instanceVariables.overrides.InsertColumnLeft(strBaseElementID);
	}
	if (RTE_GetDirectionOfSelection(strBaseElementID)=="rtl")
	{
		return RTE_InsertColumnBase(strBaseElementID, "afterEnd");
	}
	else
	{
		return RTE_InsertColumnBase(strBaseElementID, "beforeBegin");
	}
}
function RTE_InsertColumnRight(strBaseElementID)
{
	var instanceVariables=RTE_GetEditorInstanceVariables(strBaseElementID);
	if (instanceVariables !=null && instanceVariables.overrides.InsertColumnRight !=null)
	{
		return instanceVariables.overrides.InsertColumnRight(strBaseElementID);
	}
	if (RTE_GetDirectionOfSelection(strBaseElementID)=="rtl")
	{
		return RTE_InsertColumnBase(strBaseElementID, "beforeBegin");
	}
	else
	{
		return RTE_InsertColumnBase(strBaseElementID, "afterEnd");
	}
}
function RTE_InsertColumnBase(strBaseElementID, strWhere)
{
	var elemCellSelected=RTE_GetNearestContainingElementOfTypes(strBaseElementID, g_aTableCellTagNames);
	if (elemCellSelected==null)
	{
		return;
	}
	var elemTableSelected=RTE_GetNearestContainingParentElementOfType(strBaseElementID, elemCellSelected, "TABLE");
	if (elemTableSelected==null)
	{
		return false;
	}
	var docEditor=RTE_GetEditorDocument(strBaseElementID);
	if (docEditor==null) return;
	var colSpanIndex=0;
	var colSpanCount=0;
	var elemRowSelected=RTE_GetNearestContainingParentElementOfType(strBaseElementID, elemCellSelected, "TR");
	if (elemRowSelected !=null)
	{
		var elemRowSelectedCells=elemRowSelected.cells;
		var elemRowSelectedCellsLength=elemRowSelectedCells.length;
		for (var i=0; i<elemRowSelectedCellsLength; i++)
		{
			colSpanCount=elemRowSelectedCells[i].colSpan;
			if (elemRowSelectedCells[i]==elemCellSelected)
			{
				currentCellPosition=i;
				break;
			}
			colSpanIndex+=colSpanCount;
		}
	}
	var elemTableSelectedRows=elemTableSelected.rows;
	var elemTableSelectedRowsLength=elemTableSelectedRows.length;
	for (var i=0; i<elemTableSelectedRowsLength; i++)
	{
		var elemRow=elemTableSelectedRows[i];
		if (elemRow !=null)
		{
			var currentColSpanIndex=0;
			var currentColSpanCount=0;
			var elemRowCells=elemRow.cells;
			var elemRowCellsLength=elemRowCells.length;
			for (var j=0; j<elemRowCellsLength; j++)
			{
				var elemCell=elemRowCells[j];
				currentColSpanCount=elemCell.colSpan;
				if (strWhere=="beforeBegin")
				{
					if (currentColSpanIndex==colSpanIndex)
					{
						var elemCellNew=docEditor.createElement(elemCell.tagName);
						if (elemCellNew !=null)
						{
							elemCellNew.mergeAttributes(elemCell, true);
							elemCellNew.runtimeStyle.cssText=elemCell.runtimeStyle.cssText;
							elemCellNew.colSpan=1;
							elemCell.insertAdjacentElement(strWhere, elemCellNew);
							if (i==0)
							{
								var textRange=docEditor.body.createTextRange();
								if (textRange !=null)
								{
									textRange.moveToElementText(elemCellNew);
									textRange.select();
								}
							}
						}
						break;
					}
					else if (currentColSpanIndex+currentColSpanCount > colSpanIndex)
					{
						elemCell.colSpan++;
						break;
					}
				}
				else if (strWhere=="afterEnd")
				{
					if (currentColSpanIndex+currentColSpanCount==colSpanIndex+colSpanCount)
					{
						var elemCellNew=docEditor.createElement(elemCell.tagName);
						if (elemCellNew !=null)
						{
							elemCellNew.mergeAttributes(elemCell, true);
							elemCellNew.runtimeStyle.cssText=elemCell.runtimeStyle.cssText;
							elemCellNew.colSpan=1;
							elemCell.insertAdjacentElement(strWhere, elemCellNew);
							if (i==0)
							{
								var textRange=docEditor.body.createTextRange();
								if (textRange !=null)
								{
									textRange.moveToElementText(elemCellNew);
									textRange.select();
								}
							}
						}
						break;
					}
					else if (currentColSpanIndex+currentColSpanCount > colSpanIndex+colSpanCount)
					{
						elemCell.colSpan++;
						break;
					}
				}
				currentColSpanIndex+=currentColSpanCount;
			}
		}
	}
	RTE_ReapplyTableStyles(elemTableSelected);
}
function RTE_DeleteColumn(strBaseElementID)
{
	var elemCellSelected=RTE_GetNearestContainingElementOfTypes(strBaseElementID, g_aTableCellTagNames);
	if (elemCellSelected==null) {    return;    }
	var elemTableSelected=RTE_GetNearestContainingParentElementOfType(strBaseElementID, elemCellSelected, "TABLE");
	if (elemTableSelected==null) { return; }
	var elemCellSelectedIndex=elemCellSelected.cellIndex;
	var colSpanIndex=0;
	var colSpanCount=0;
	var elemRowSelected=RTE_GetNearestContainingParentElementOfType(strBaseElementID, elemCellSelected, "TR");
	if (elemRowSelected !=null)
	{
		var elemRowSelectedCells=elemRowSelected.cells;
		var elemRowSelectedCellsLength=elemRowSelectedCells.length;
		for (var i=0; i<elemRowSelectedCellsLength; i++)
		{
			colSpanCount=elemRowSelectedCells[i].colSpan;
			if (elemRowSelectedCells[i]==elemCellSelected)
			{
				currentCellPosition=i;
				break;
			}
			colSpanIndex+=colSpanCount;
		}
	}
	var elemTableSelectedRows=elemTableSelected.rows;
	var elemTableSelectedRowsLength=elemTableSelectedRows.length;
	for (var i=0; i<elemTableSelectedRowsLength; i++)
	{
		var elemRow=elemTableSelectedRows[i];
		if (elemRow !=null)
		{
			var currentColSpanIndex=0;
			var currentColSpanCount=0;
			var cellsToModify=new Array();
			var elemRowCells=elemRow.cells;
			var elemRowCellsLength=elemRowCells.length;
			for (var j=0; j<=elemRowCellsLength; j++)
			{
				if (currentColSpanIndex >=colSpanIndex+colSpanCount)
				{
					for (var k=0; k<cellsToModify.length; k++)
					{
						var cell=cellsToModify[k][0];
						var decrement=cellsToModify[k][1];
						if (decrement==cell.colSpan)
						{
							cell.removeNode(true);
						}
						else
						{
							cell.colSpan -=decrement;
						}
					}
					break;
				}
				var elemCell=elemRowCells[j];
				currentColSpanCount=elemCell.colSpan;
				if (currentColSpanIndex+currentColSpanCount <=colSpanIndex)
				{
					currentColSpanIndex+=currentColSpanCount;
					continue;
				}
				else
				{
					var colSpanDecrement=0;
					if ((currentColSpanIndex >=colSpanIndex) && (currentColSpanIndex+currentColSpanCount <=colSpanIndex+colSpanCount))
					{
						colSpanDecrement=currentColSpanCount;
					}
					else if ((currentColSpanIndex <=colSpanIndex) && (currentColSpanIndex+currentColSpanCount >=colSpanIndex+colSpanCount))
					{
						colSpanDecrement=colSpanCount;
					}
					else if ((currentColSpanIndex <=colSpanIndex) && (currentColSpanIndex+currentColSpanCount < colSpanIndex+colSpanCount))
					{
						colSpanDecrement=currentColSpanIndex+currentColSpanCount - colSpanIndex;
					}
					else if ((currentColSpanIndex > colSpanIndex)  && (currentColSpanIndex+currentColSpanCount > colSpanIndex+colSpanCount))
					{
						colSpanDecrement=colSpanIndex+colSpanCount - currentColSpanIndex;
					}
					cellsToModify[cellsToModify.length]=new Array(elemCell, colSpanDecrement);
				}
				currentColSpanIndex+=currentColSpanCount;
			}
		}
	}
	var rows=elemTableSelected.rows;
	var rowsLength=rows.length;
	for(var i=rowsLength; i>0; i--)
	{
		if (rows(i-1).cells.length==0)
		{
			rows(i-1).removeNode(true);
		}
	}
	if (elemTableSelected.rows.length==0)
	{
		elemTableSelected.removeNode(true);
	}
	else
	{
		var moveSelectionToCellIndex=0;
		var moveSelectionToSpanCount=0;
		var elemTableTopRowCells=rows[0].cells;
		for (var i=0; i<elemTableTopRowCells.length; i++)
		{
			moveSelectionToCellIndex=i;
			var currentSpanCount=elemTableTopRowCells[i].colSpan;
			if (moveSelectionToSpanCount+currentSpanCount > colSpanIndex)
				break;
			moveSelectionToSpanCount+=currentSpanCount;
		}
		var editorDocument=RTE_GetEditorDocument(strBaseElementID);
		var textRange=editorDocument.body.createTextRange();
		var cellToSelect=elemTableTopRowCells[moveSelectionToCellIndex];
		textRange.moveToElementText(cellToSelect);
		textRange.select();
		textRange.collapse(true);
		RTE_ReapplyTableStyles(elemTableSelected);
	}
	RTE_StartResetToolBarTimer(strBaseElementID);
}
function RTE_DeleteRow(strBaseElementID)
{
	var elemRowSelected=RTE_GetNearestContainingElementOfType(strBaseElementID, "TR");
	if (elemRowSelected !=null)
	{
		var elemTableSelected=RTE_GetNearestContainingParentElementOfType(strBaseElementID, elemRowSelected, "TABLE");
		var elemTableNewSelectionRowIndex=elemRowSelected.rowIndex;
		elemRowSelected.removeNode(true);
		if (elemTableSelected)
		{
			if (elemTableSelected.rows.length > 0)
			{
				if (elemTableNewSelectionRowIndex >=elemTableSelected.rows.length)
				{
					elemTableNewSelectionRowIndex=elemTableSelected.rows.length - 1;
				}
				var elemTableNewSelectionRowCells=elemTableSelected.rows[elemTableNewSelectionRowIndex].cells;
				var editorDocument=RTE_GetEditorDocument(strBaseElementID);
				var textRange=editorDocument.body.createTextRange();
				if (elemTableNewSelectionRowCells.length > 0)
				{
					var cellToSelect=elemTableNewSelectionRowCells[0];
					textRange.moveToElementText(cellToSelect);
					textRange.select();
					textRange.collapse(true);
				}
				RTE_ReapplyTableStyles(elemTableSelected);
			}
			else
			{
				elemTableSelected.removeNode(true);
			}
		}
	}
	RTE_StartResetToolBarTimer(strBaseElementID);
}
function RTE_SplitCell(strBaseElementID)
{
	var elemCellSelected=RTE_GetNearestContainingElementOfTypes(strBaseElementID, g_aTableCellTagNames);
	if (elemCellSelected==null)
	{
		return;
	}
	var currentCellPosition=-1;
	var colSpanCount=0;
	var elemRowSelected=RTE_GetNearestContainingParentElementOfType(strBaseElementID, elemCellSelected, "TR");
	if (elemRowSelected !=null)
	{
		for (var i=0; i<elemRowSelected.cells.length; i++)
		{
			colSpanCount+=elemRowSelected.cells[i].colSpan;
			if (elemRowSelected.cells[i]==elemCellSelected)
			{
				currentCellPosition=i;
				break;
			}
		}
	}
	var elemCellNew=document.createElement(elemCellSelected.tagName);
	if (elemCellNew !=null)
	{
		elemCellNew.mergeAttributes(elemCellSelected, true);
		elemCellNew.runtimeStyle.cssText=elemCellSelected.runtimeStyle.cssText;
		if (elemCellSelected.colSpan > 1)
		{
			elemCellNew.colSpan=elemCellSelected.colSpan/2;
			elemCellSelected.colSpan -=elemCellNew.colSpan;
		}
		else
		{
			elemCellNew.colSpan=1;
			var elemTableSelected=RTE_GetNearestContainingParentElementOfType(strBaseElementID, elemRowSelected, "TABLE");
			for (var i=0; i<elemTableSelected.rows.length; i++)
			{
				var currentColSpanCount=0;
				var elemRow=elemTableSelected.rows[i];
				if (elemRow !=null && elemRow !=elemRowSelected)
				{
					for (var j=0; j<elemRow.cells.length; j++)
					{
						var elemCell=elemRow.cells[j];
						currentColSpanCount+=elemCell.colSpan;
						if (currentColSpanCount >=colSpanCount)
						{
							elemCell.colSpan++;
							break;
						}
					}
				}
			}
		}
		elemCellSelected.insertAdjacentElement("afterEnd", elemCellNew);
		var elemTableSelected=RTE_GetNearestContainingElementOfType(strBaseElementID, "TABLE");
		if (elemTableSelected)
		{
			RTE_ReapplyTableStyles(elemTableSelected);
		}
		RTE_StartResetToolBarTimer(strBaseElementID);
	}
}
function RTE_MergeCells(strBaseElementID)
{
	if (RTE_IsElementSelected(strBaseElementID, "TR"))
	{
		RTE_MergeSelected(strBaseElementID);
	}
	else
	{
		RTE_MergeWithDirection(strBaseElementID, "none");
	}
	RTE_StartResetToolBarTimer(strBaseElementID);
}
function RTE_MergeSelected(strBaseElementID)
{
	var elemRowSelected=RTE_GetCurrentElement(strBaseElementID);
	if (elemRowSelected.tagName !="TR") return;
	if (elemRowSelected !=null)
	{
		var selectedCells=RTE_GetSelectedCells(strBaseElementID);
		if (selectedCells.length > 1)
		{
			for (var i=1; i<selectedCells.length; i++)
			{
				if (selectedCells[i].innerText.length > 0)
				{
					selectedCells[0].innerHTML+=" ";
				}
				selectedCells[0].innerHTML+=selectedCells[i].innerHTML;
				selectedCells[0].colSpan+=selectedCells[i].colSpan;
				elemRowSelected.removeChild(selectedCells[i]);
			}
			var elemTableSelected=RTE_GetNearestContainingParentElementOfType(strBaseElementID, elemRowSelected, "TABLE");
			if (elemTableSelected)
			{
				RTE_ReapplyTableStyles(elemTableSelected);
			}
			if (RTE_GetCurrentElement(strBaseElementID) !=selectedCells[0])
			{
				var editorDocument=RTE_GetEditorDocument(strBaseElementID);
				var textRange=editorDocument.body.createTextRange();
				textRange.moveToElementText(selectedCells[0]);
				textRange.select();
			}
		}
	}
}
function RTE_MergeWithRight(strBaseElementID)
{
	RTE_MergeWithDirection(strBaseElementID, "right");
}
function RTE_MergeWithLeft(strBaseElementID)
{
	RTE_MergeWithDirection(strBaseElementID, "left");
}
function RTE_MergeWithAbove(strBaseElementID)
{
	RTE_MergeWithDirection(strBaseElementID, "above");
}
function RTE_MergeWithBelow(strBaseElementID)
{
	RTE_MergeWithDirection(strBaseElementID, "below");
}
function RTE_MergeWithDirection(strBaseElementID, dir)
{
	RTE_MergeSelected(strBaseElementID);
	var elemSelected=RTE_GetCurrentElement(strBaseElementID);
	if (elemSelected==null) return;
	var elemCellSelected=RTE_GetNearestContainingParentElementOfTypes(strBaseElementID, elemSelected, g_aTableCellTagNames);	
	if (elemCellSelected==null) return;
	var elemRowSelected=RTE_GetNearestContainingParentElementOfType(strBaseElementID, elemCellSelected, "TR");
	if (elemRowSelected==null) return;
	var elemTable=RTE_GetNearestContainingParentElementOfType(strBaseElementID, elemRowSelected, "TABLE");
	if (RTE_GetDirectionOfSelection(strBaseElementID)=="rtl")
	{
		if (dir=="right")
		{
			dir="left";
		}
		else if (dir=="left")
		{
			dir="right";
		}
	}
	switch(dir)
	{
		case "right":
			var mergeFromIndex=elemCellSelected.cellIndex;
			var rowCells=elemRowSelected.cells;
			if (mergeFromIndex+1 >=rowCells.length) return;
			if (rowCells[mergeFromIndex+1].rowSpan==rowCells[mergeFromIndex].rowSpan)
			{
				RTE_MergeHorizontal(strBaseElementID, elemRowSelected, mergeFromIndex);
			}
			else
			{
				alert(L_InvalidMerge_TEXT);
			}
			break;
		case "left":
			var mergeFromIndex=elemCellSelected.cellIndex-1;
			var rowCells=elemRowSelected.cells;
			if (mergeFromIndex < 0) return;
			if (rowCells[mergeFromIndex+1].rowSpan==rowCells[mergeFromIndex].rowSpan)
			{
				RTE_MergeHorizontal(strBaseElementID, elemRowSelected, mergeFromIndex);
				RTE_PutSelectionInCell(strBaseElementID, elemRowSelected.cells[mergeFromIndex]);
			}
			else
			{
				alert(L_InvalidMerge_TEXT);
			}
			break;
		case "above":
			if (elemTable==null) return;
			if (elemRowSelected.rowIndex==0) return;
			var rowBelow=elemRowSelected;
			var rowBelowCells=rowBelow.cells;
			var rowBelowCell=elemCellSelected;
			var spanGrid=RTE_GenerateSpanGridUpToTarget(elemTable, elemCellSelected);
			var rowBelowCellColSpanIndex=spanGrid.targetCellColSpanIndex;
			var spanGridAboveTarget=spanGrid.columns[rowBelowCellColSpanIndex].cells[elemRowSelected.rowIndex-1];
			var rowAboveCell=spanGridAboveTarget.cell;
			if (rowBelowCell.colSpan==rowAboveCell.colSpan && spanGridAboveTarget.colSpanIndex==rowBelowCellColSpanIndex)
			{
				RTE_MergeVertical(strBaseElementID, rowBelow, rowBelowCell, rowAboveCell)
				RTE_PutSelectionInCell(strBaseElementID, rowAboveCell);
			}
			else
			{
				alert(L_InvalidMerge_TEXT);
			}
			break;
		case "below":
			if (elemTable==null) return;
			var rowAboveCell=elemCellSelected;
			var spanGrid=RTE_GenerateSpanGridUpToTarget(elemTable, rowAboveCell);
			var rowAboveCellColSpanIndex=spanGrid.targetCellColSpanIndex;
			var spanGridBelowTarget=spanGrid.columns[rowAboveCellColSpanIndex].cells[elemRowSelected.rowIndex+rowAboveCell.rowSpan];
			if (spanGridBelowTarget==null) return;
			var rowBelowCell=spanGridBelowTarget.cell;
			var rowBelow=RTE_GetNearestContainingParentElementOfType(strBaseElementID, rowBelowCell, "TR");
			if (rowBelow==null) return;
			if (rowBelowCell.colSpan==rowAboveCell.colSpan && spanGridBelowTarget.colSpanIndex==rowAboveCellColSpanIndex)
			{
				RTE_MergeVertical(strBaseElementID, rowBelow, rowBelowCell, rowAboveCell)
			}
			else
			{
				alert(L_InvalidMerge_TEXT);
			}
			break;
		case "none":
			if (elemRowSelected.cells[elemCellSelected.cellIndex] !=null &&
				elemRowSelected.cells[elemCellSelected.cellIndex+1] !=null)
			{
				var dir=RTE_GetDirectionOfSelection(elemCellSelected);
				if (   (dir !="rtl" && elemCellSelected.cellIndex==elemRowSelected.cells.length - 1 )
					|| (dir=="rtl" && elemCellSelected.cellIndex !=0))
				{
					var mergeFromCellIndex=elemCellSelected.cellIndex-1;
					if (mergeFromCellIndex < 0) return;
					RTE_MergeHorizontal(strBaseElementID, elemRowSelected, mergeFromCellIndex);
					RTE_PutSelectionInCell(strBaseElementID, elemRowSelected.cells[mergeFromCellIndex]);
				}
				else
				{
					if (elemCellSelected.cellIndex+1 >=elemRowSelected.length) return;
					RTE_MergeHorizontal(strBaseElementID, elemRowSelected, elemCellSelected.cellIndex);
				}
			}
			break;
	}
	if (elemTable)
	{
		RTE_ReapplyTableStyles(elemTable);
	}
	RTE_StartResetToolBarTimer(strBaseElementID);
}
function RTE_MergeHorizontal(strBaseElementID, elemRow, mergeFromIndex)
{
	var rowCells=elemRow.cells;
	if (rowCells[mergeFromIndex].innerText.length > 0)
	{
		rowCells[mergeFromIndex].innerHTML+=" ";
	}
	rowCells[mergeFromIndex].innerHTML+=rowCells[mergeFromIndex+1].innerHTML;
	rowCells[mergeFromIndex].colSpan+=rowCells[mergeFromIndex+1].colSpan;
	elemRow.removeChild(rowCells[mergeFromIndex+1]);
}
function RTE_MergeVertical(strBaseElementID, rowBelow, rowBelowCell, rowAboveCell)
{
	if (rowAboveCell.innerText.length > 0)
	{
		rowAboveCell.innerHTML+=" ";
	}
	rowAboveCell.innerHTML+=rowBelowCell.innerHTML;
	rowAboveCell.rowSpan+=rowBelowCell.rowSpan;
	rowBelow.removeChild(rowBelowCell);
}
function RTE_PutSelectionInCell(strBaseElementID, newCell)
{
	if (RTE_GetCurrentElement(strBaseElementID) !=newCell)
	{
		var editorDocument=RTE_GetEditorDocument(strBaseElementID);
		var textRange=editorDocument.body.createTextRange();
		textRange.moveToElementText(newCell);
		textRange.select();
	}
}
function RTE_GenerateSpanGridUpToTarget(table, targetCell)
{
	var spanGrid=new Object();
	spanGrid.columns=new Array();
	spanGrid.targetCellColSpanIndex=-1;
	for (var rowIndex=0; rowIndex<table.rows.length; rowIndex++)
	{
		var colSpanIndex=0;
		for (cellIndex=0; cellIndex<table.rows[rowIndex].cells.length; cellIndex++)
		{
			while (spanGrid.columns[colSpanIndex] !=null && spanGrid.columns[colSpanIndex].cells[rowIndex] !=null)
			{
				colSpanIndex++;
			}
			if (spanGrid.columns[colSpanIndex]==null)
			{
				spanGrid.columns[colSpanIndex]=new Object();
				spanGrid.columns[colSpanIndex].cells=new Array();
			}
			var currentCell=table.rows[rowIndex].cells[cellIndex];
			if (currentCell==targetCell) spanGrid.targetCellColSpanIndex=colSpanIndex;
			spanGrid.columns[colSpanIndex].cells[rowIndex]=new Object();
			spanGrid.columns[colSpanIndex].cells[rowIndex].cell=currentCell;
			spanGrid.columns[colSpanIndex].cells[rowIndex].colSpanIndex=colSpanIndex;
			for(var j=0; j<currentCell.colSpan; j++)
			{
				if (spanGrid.columns[colSpanIndex+j]==null)
				{
					spanGrid.columns[colSpanIndex+j]=new Array();
					spanGrid.columns[colSpanIndex+j].cells=new Array();
				}
				for(var i=0; i<currentCell.rowSpan; i++)
				{
					spanGrid.columns[colSpanIndex+j].cells[rowIndex+i]=new Object();
					spanGrid.columns[colSpanIndex+j].cells[rowIndex+i].cell=currentCell;
					spanGrid.columns[colSpanIndex+j].cells[rowIndex+i].colSpanIndex=colSpanIndex;
				}
			}
			colSpanIndex+=currentCell.colSpan;
			if (spanGrid.targetCellColSpanIndex !=-1
			   && colSpanIndex > spanGrid.targetCellColSpanIndex+targetCell.colSpan
			   && rowIndex !=targetCell.parentNode.rowIndex+targetCell.rowSpan - 1) break;
		}
	}
	return spanGrid;
}
function RTE_UrlFileName(href)
{
	var filePath=href;
	filePath=filePath.split("#")[0];
	filePath=filePath.split("?")[0];
	var lastSlashPos=filePath.lastIndexOf('/');
	return filePath.substring(lastSlashPos+1);
}
var g_reservedTablePrefix=".ms-rteTable";
function RTE_GetReservedTableStyleRules(targetDocument)
{
	return RTE_GetReservedStyleRules(targetDocument, g_reservedTablePrefix, "-");
}
function RTE_GetReservedStyleRules(targetDocument, prefix, defaultStyleSheetHref)
{
	var reservedUserRules=new Array();
	var reservedDefaultRules=new Array();
	for (var i=0; i<targetDocument.styleSheets.length; i++)
	{
		var styleSheet=targetDocument.styleSheets[i];
		if (RTE_UrlFileName(styleSheet.href) !=defaultStyleSheetHref)
		{
			RTE_GetReservedStyleRulesFromStyleSheet(styleSheet, prefix, reservedUserRules);
		}
		else
		{
			RTE_GetReservedStyleRulesFromStyleSheet(styleSheet, prefix, reservedDefaultRules);
		}
	}
	if (reservedUserRules.length > 0)
	{
		return reservedUserRules;
	}
	else
	{
		return reservedDefaultRules;
	}
}
function RTE_GetReservedStyleRulesFromStyleSheet(styleSheet, prefix, reservedRules)
{
	try
	{
		var rules=styleSheet.rules;
		for (var j=0; j<rules.length; j++)
		{
			if (rules[j].selectorText.indexOf(prefix) >=0)
			{
				reservedRules.push(rules[j]);
			}
		}
	}
	catch (e) {}
}
var msTableStylePrefix="ms-rteTable";
var msTableClass="-";
var msTableClassHeadingRow="HeaderRow-";
var msTableClassHeadingFirstCol="HeaderFirstCol-";
var msTableClassHeadingOddCol="HeaderOddCol-";
var msTableClassHeadingEvenCol="HeaderEvenCol-";
var msTableClassHeadingLastCol="HeaderLastCol-";
var msTableClassOddRow="OddRow-";
var msTableClassEvenRow="EvenRow-";
var msTableClassFirstCol="FirstCol-";
var msTableClassOddCol="OddCol-";
var msTableClassEvenCol="EvenCol-";
var msTableClassLastCol="LastCol-";
var msTableClassFootingRow="FooterRow-";
var msTableClassFootingFirstCol="FooterFirstCol-";
var msTableClassFootingOddCol="FooterOddCol-";
var msTableClassFootingEvenCol="FooterEvenCol-";
var msTableClassFootingLastCol="FooterLastCol-";
function RTE_ApplyTableStyle(tableStyleSuffix, table, formatHeadingRow, formatLastRow, formatFirstColumn, formatLastColumn, prefix)
{
	if (prefix==null) prefix=msTableStylePrefix;
	if (table !=null)
	{
		RTE_AppendClassName(table, prefix+msTableClass+tableStyleSuffix);
		var rows=table.rows;
		var rowStartIndex=0;
		var rowEndIndex=rows.length-1;
		var doFormatHeadingRow=false;
		var doFormatLastRow=false;
		if (rows.length==1)
		{
			if (formatHeadingRow)
			{
				doFormatHeadingRow=true;
				rowStartIndex++;
			}
			rowEnd=0;
		}
		else
		{
			if (formatHeadingRow)
			{
				doFormatHeadingRow=true;
				rowStartIndex++;
			}
			if (formatLastRow)
			{
				doFormatLastRow=true;
				rowEndIndex--;
			}
		}
		if (doFormatHeadingRow)
		{
			var headingRow=rows(0);
			RTE_AppendClassName(headingRow, prefix+msTableClassHeadingRow+tableStyleSuffix);
			var oddEvenColumnSpecifier=0;
			for (var i=0; i<headingRow.cells.length; i++)
			{
				if (i==0 && formatFirstColumn)
				{
					RTE_AppendClassName(headingRow.cells(i), prefix+msTableClassHeadingFirstCol+tableStyleSuffix);
					oddEvenColumnSpecifier=1;
				}
				else if (i==headingRow.cells.length-1 && formatLastColumn)
				{
					RTE_AppendClassName(headingRow.cells(i), prefix+msTableClassHeadingLastCol+tableStyleSuffix);
				}
				else
				{
					if (i%2==oddEvenColumnSpecifier)
					{
						RTE_AppendClassName(headingRow.cells(i), prefix+msTableClassHeadingOddCol+tableStyleSuffix);
					}
					else
					{
						RTE_AppendClassName(headingRow.cells(i), prefix+msTableClassHeadingEvenCol+tableStyleSuffix);
					}
				}
			}
		}
		if (doFormatLastRow)
		{
			var lastRow=rows(rowEndIndex+1);
			RTE_AppendClassName(lastRow, prefix+msTableClassFootingRow+tableStyleSuffix);
			var oddEvenColumnSpecifier=0;
			for (var i=0; i<lastRow.cells.length; i++)
			{
				if (i==0 && formatFirstColumn)
				{
					RTE_AppendClassName(lastRow.cells(i), prefix+msTableClassFootingFirstCol+tableStyleSuffix);
					oddEvenColumnSpecifier=1;
				}
				else if (i==lastRow.cells.length-1 && formatLastColumn)
				{
					RTE_AppendClassName(lastRow.cells(i), prefix+msTableClassFootingLastCol+tableStyleSuffix);
				}
				else
				{
					if (i%2==oddEvenColumnSpecifier)
					{
						RTE_AppendClassName(lastRow.cells(i), prefix+msTableClassFootingOddCol+tableStyleSuffix);
					}
					else
					{
						RTE_AppendClassName(lastRow.cells(i), prefix+msTableClassFootingEvenCol+tableStyleSuffix);
					}
				}
			}
		}
		var oddEvenRowSpecifier=0;
		if (doFormatHeadingRow)
		{
			oddEvenRowSpecifier=1;
		}
		for (var i=rowStartIndex; i<=rowEndIndex; i++)
		{
			var currentRow=rows(i);
			if (i%2==oddEvenRowSpecifier)
			{
				RTE_AppendClassName(currentRow, prefix+msTableClassOddRow+tableStyleSuffix);
			}
			else
			{
				RTE_AppendClassName(currentRow, prefix+msTableClassEvenRow+tableStyleSuffix);
			}
			var oddEvenColumnSpecifier=0;
			for (var j=0; j<currentRow.cells.length; j++)
			{
				if (j==0 && formatFirstColumn)
				{
					RTE_AppendClassName(currentRow.cells(j), prefix+msTableClassFirstCol+tableStyleSuffix);
					oddEvenColumnSpecifier=1;
				}
				else if (j==currentRow.cells.length-1 && formatLastColumn)
				{
					RTE_AppendClassName(currentRow.cells(j), prefix+msTableClassLastCol+tableStyleSuffix);
				}
				else
				{
					if (j%2==oddEvenColumnSpecifier)
					{
						RTE_AppendClassName(currentRow.cells(j), prefix+msTableClassOddCol+tableStyleSuffix);
					}
					else
					{
						RTE_AppendClassName(currentRow.cells(j), prefix+msTableClassEvenCol+tableStyleSuffix);
					}
				}
			}
		}
	}
}
function RTE_ClearReservedTableStyles(table, prefix)
{
	if (prefix==null) prefix=msTableStylePrefix;
	if (table !=null && table.tagName=="TABLE")
	{
		RTE_ClearReservedTableStylesFromElement(table, prefix);
		for (var i=0; i<table.rows.length; i++)
		{
			var row=table.rows[i];
			RTE_ClearReservedTableStylesFromElement(row, prefix);
			for (var j=0; j<row.cells.length; j++)
			{
				var cell=row.cells[j];
				RTE_ClearReservedTableStylesFromElement(cell, prefix);
			}
		}
	}
}
function RTE_ClearReservedTableStylesFromElement(element, prefix)
{
	if (prefix==null) prefix=msTableStylePrefix;
	if (element.className !=null && element.className.length > 0)
	{
		var classNames=element.className.split(" ");
		var revisedClassNames=new Array();
		for(var i=0; i<classNames.length; i++)
		{
			var className=classNames[i];
			if (className.indexOf(prefix)!=0)
			{
				revisedClassNames[revisedClassNames.length]=className;
			}
		}
		element.className="";
		for (var i=0; i<revisedClassNames.length; i++)
		{
			RTE_AppendClassName(element, revisedClassNames[i]);
		}
	}
}
function RTE_AppendClassName(element, className)
{
	if (element !=null)
	{
		var newClassName=element.className;
		if (newClassName !=null && newClassName.length > 0)
		{
			newClassName+=" ";
		}
		newClassName+=className;
		element.className=newClassName;
	}
}
function RTE_GetReservedTableStyleNumbers(table, prefix)
{
	if (prefix==null) prefix=msTableStylePrefix;
	var styleNumbers=new Array();
	if (table!=null && table.tagName=="TABLE")
	{
		var tableClasses=table.className.split(" ");
		for(var i=0; i<tableClasses.length; i++)
		{
			var tableClassName=tableClasses[i];
			var styleNameIndex=tableClassName.indexOf(prefix+msTableClass);
			if (styleNameIndex >=0)
			{
				var tableStyleNumber=tableClassName.substr(styleNameIndex+prefix.length+msTableClass.length);
				styleNumbers[styleNumbers.length]=tableStyleNumber;
			}
		}
	}
	return styleNumbers;
}
function RTE_ReapplyTableStyles(table, prefix)
{
	if (prefix==null)
	{
		var pos=table.className.indexOf("Table");
		if (pos >=0)
		{
			prefix=table.className.substring(0,pos+5);
		}
		else
		{
			prefix=msTableStylePrefix;
		}
	}
	if (table !=null && table.rows.length > 0)
	{
		var reservedTableStyleNumbers=RTE_GetReservedTableStyleNumbers(table, prefix);
		if (reservedTableStyleNumbers.length > 0)
		{
			var tableStyleSettings=new Array();
			for (var i=0; i<reservedTableStyleNumbers.length; i++)
			{
				var settings=new Array();
				var tableStyleNumber=reservedTableStyleNumbers[i];
				settings["tableStyleNumber"]=tableStyleNumber;
				settings["formatHeadingRow"]=RTE_ShouldFormatHeadingRow(tableStyleNumber, table, prefix);
				settings["formatLastRow"]=RTE_ShouldFormatLastRow(tableStyleNumber, table, prefix);
				settings["formatFirstColumn"]=RTE_ShouldFormatFirstColumn(tableStyleNumber, table, prefix);
				settings["formatLastColumn"]=RTE_ShouldFormatLastColumn(tableStyleNumber, table, prefix);
				tableStyleSettings[tableStyleSettings.length]=settings;
			}
			RTE_ClearReservedTableStyles(table, prefix);
			for (var i=0; i<tableStyleSettings.length; i++)
			{
				var settings=tableStyleSettings[i];
				RTE_ApplyTableStyle(
					settings["tableStyleNumber"],
					table,
					settings["formatHeadingRow"],
					settings["formatLastRow"],
					settings["formatFirstColumn"],
					settings["formatLastColumn"],
					prefix);
			}
		}
	}
}
function RTE_ShouldFormatHeadingRow(tableStyleNumber, table, prefix)
{
	if (prefix==null) prefix=msTableStylePrefix;
	var shouldFormatHeadingRow=false;
	if (tableStyleNumber !=null && table !=null && table.rows.length > 0)
	{
		var headingRow=table.rows.item(0);
		if (headingRow.className !=null && headingRow.className.length > 0)
		{
			var headingRowClasses=headingRow.className.split(" ");
			for(var i=0; i<headingRowClasses.length; i++)
			{
				var rowClassName=headingRowClasses[i];
				var reservedRowClassName=prefix+msTableClassHeadingRow+tableStyleNumber;
				if (rowClassName==reservedRowClassName)
				{
					shouldFormatHeadingRow=true;
					break;
				}
			}
		}
	}
	return shouldFormatHeadingRow;
}
function RTE_ShouldFormatLastRow(tableStyleNumber, table, prefix)
{
	if (prefix==null) prefix=msTableStylePrefix;
	var shouldFormatLastRow=false;
	if (tableStyleNumber !=null && table !=null && table.rows.length > 0)
	{
		if (!(table.rows.length==1 && RTE_ShouldFormatHeadingRow(tableStyleNumber, table, prefix)))
		{
			var lastRow=table.rows.item(table.rows.length-1);
			if (lastRow.className !=null && lastRow.className.length > 0)
			{
				var lastRowClasses=lastRow.className.split(" ");
				for(var i=0; i<lastRowClasses.length; i++)
				{
					var rowClassName=lastRowClasses[i];
					var reservedRowClassName=prefix+msTableClassFootingRow+tableStyleNumber;
					if (rowClassName==reservedRowClassName)
					{
						shouldFormatLastRow=true;
						break;
					}
				}
			}
		}
	}
	return shouldFormatLastRow;
}
function RTE_ShouldFormatFirstColumn(tableStyleNumber, table, prefix)
{
	if (prefix==null) prefix=msTableStylePrefix;
	var shouldFormatFirstColumn=false;
	if (tableStyleNumber !=null && table !=null && table.rows.length > 0)
	{
		var reservedColClassName=prefix+msTableClassFirstCol;
		var testRow=table.rows.item(0);
		if (RTE_ShouldFormatHeadingRow(tableStyleNumber, table, prefix))
		{
			reservedColClassName=prefix+msTableClassHeadingFirstCol;
		}
		else if (table.rows.length==1 && RTE_ShouldFormatLastRow(tableStyleNumber, table, prefix))
		{
			reservedColClassName=prefix+msTableClassFootingFirstCol;
		}
		if (testRow.cells.length > 0)
		{
			reservedColClassName+=tableStyleNumber;
			var firstCell=testRow.cells.item(0);
			if (firstCell.className !=null && firstCell.className.length > 0)
			{
				var firstCellClasses=firstCell.className.split(" ");
				for(var i=0; i<firstCellClasses.length; i++)
				{
					var cellClassName=firstCellClasses[i];
					if (cellClassName==reservedColClassName)
					{
						shouldFormatFirstColumn=true;
						break;
					}
				}
			}
		}
	}
	return shouldFormatFirstColumn;
}
function RTE_ShouldFormatLastColumn(tableStyleNumber, table, prefix)
{
	if (prefix==null) prefix=msTableStylePrefix;
	var shouldFormatLastColumn=false;
	if (tableStyleNumber !=null && table !=null && table.rows.length > 0)
	{
		var reservedColClassName=prefix+msTableClassLastCol;
		var testRow=table.rows.item(0);
		if (RTE_ShouldFormatHeadingRow(tableStyleNumber, table, prefix))
		{
			reservedColClassName=prefix+msTableClassHeadingLastCol;
		}
		else if (table.rows.length==1 && RTE_ShouldFormatLastRow(tableStyleNumber, table, prefix))
		{
			reservedColClassName=prefix+msTableClassFootingLastCol;
		}
		if (testRow.cells.length > 0)
		{
			reservedColClassName+=tableStyleNumber;
			if (!(testRow.cells.length==1 && RTE_ShouldFormatFirstColumn(tableStyleNumber, table, prefix)))
			{
				var lastCell=testRow.cells.item(testRow.cells.length-1);
				if (lastCell.className !=null && lastCell.className.length > 0)
				{
					var lastCellClasses=lastCell.className.split(" ");
					for(var i=0; i<lastCellClasses.length; i++)
					{
						if (lastCellClasses[i]==reservedColClassName)
						{
							shouldFormatLastColumn=true;
							break;
						}
					}
				}
			}
		}
	}
	return shouldFormatLastColumn;
}
function C_RTE_TB_ExecCmdButton(
	mnemonic, tooltip, ui, image, imageloc, onlyif, valueexpr, enable)
{
	function methodGenerate(strBaseElementID, strWebLanguage)
	{
		var strImagePath;
		if (this.fImageLoc)
		{
			strImagePath=RTE_GetServerRelativeImageUrl(this.strImage);
		}
		else
		{
			strImagePath=				RTE_GetServerRelativeUnlocalizedImageUrl(this.strImage);
		}
		return RTE_TB_GenerateExecCommandToolBarButtonHtml(
			strBaseElementID, this.strMnemonic, this.fUi,
			strImagePath, "", this.strToolTip, this.fOnlyIf,
			this.strValueExpr);
	}
	this.strMnemonic=mnemonic;
	this.strToolTip=tooltip;
	this.fUi=ui;
	this.strImage=image;
	this.fImageLoc=imageloc;
	this.fOnlyIf=onlyif;
	this.enabler=enable;
	this.enabler.button=this;
	this.strValueExpr=valueexpr;
	this.Generate=methodGenerate;
}
function C_RTE_TB_JScriptButton(mnemonic, tooltip, func, arg, image, enable)
{
	function methodGenerate(strBaseElementID, strWebLanguage)
	{
		return RTE_TB_GenerateSimpleToolBarButtonHtml(
			strBaseElementID, this.strMnemonic,
			this.strFunction, this.strArgument,
			RTE_GetServerRelativeImageUrl(this.strImage), "", this.strToolTip);
	}
	this.strMnemonic=mnemonic;
	this.strToolTip=tooltip;
	this.strFunction=func;
	this.strArgument=arg;
	this.strImage=image;
	this.enabler=enable;
	this.enabler.button=this;
	this.Generate=methodGenerate;
}
function C_RTE_TB_SpecialButton(mnemonic, func, fRestricted, enable)
{
	function methodGenerate(strBaseElementID, strWebLanguage)
	{
		return this.specialFunction(
			strBaseElementID, strWebLanguage, fRestricted);
	}
	this.specialFunction=func;
	this.strMnemonic=mnemonic;
	this.fRestricted=fRestricted;
	this.enabler=enable;
	this.enabler.button=this;
	this.Generate=methodGenerate;
}
function C_RTE_TB_Separator()
{
	function methodGenerate(strBaseElementID, strWebLanguage)
	{
		return RTE_TB_GenerateToolBarSeparatorHtml();
	}
	this.Generate=methodGenerate;
}
function C_RTE_TB_LineBreak()
{
	function methodGenerate(strBaseElementID, strWebLanguage)
	{
		return RTE_TB_GenerateToolBarLineBreakHtml();
	}
	this.Generate=methodGenerate;
}
function C_RTE_TB_SetEnabledAlways()
{
	function methodSetEnabled(strBaseElementID, docEditor, aElemChain)
	{
		RTE_TB_ClearButtonDisabled(RTE_TB_GetToolBarButton(
			strBaseElementID, this.button.strMnemonic));
	}
	this.SetEnabled=methodSetEnabled;
}
function C_RTE_TB_SetEnabledWhenRemoveFormatEnabled()
{
	function methodSetEnabled(strBaseElementID, docEditor, aElemChain)
	{
		var btn=RTE_TB_GetToolBarButton(
			strBaseElementID, this.button.strMnemonic);
		if (docEditor.queryCommandEnabled("Delete") &&
			docEditor.queryCommandEnabled(g_strRTERemoveFormatMnemonic))
		{
			RTE_TB_ClearButtonDisabled(btn);
		}
		else
		{
			RTE_TB_SetButtonDisabled(btn);
		}
	}
	this.SetEnabled=methodSetEnabled;
}
function C_RTE_TB_SetEnabledFromCommandEnabled()
{
	function methodSetEnabled(strBaseElementID, docEditor, aElemChain)
	{
		RTE_TB_SetEnabledFromCommandEnabled(
			strBaseElementID, docEditor,
			this.button.strMnemonic, this.button.strMnemonic);
	}
	this.SetEnabled=methodSetEnabled;
}
function C_RTE_TB_SetEnabledFromCommandValue()
{
	function methodSetEnabled(strBaseElementID, docEditor, aElemChain)
	{
		RTE_TB_ClearButtonDisabled(RTE_TB_GetToolBarButton(
			strBaseElementID, this.button.strMnemonic));
		RTE_TB_SetCheckFromCommandValue(
			strBaseElementID, docEditor, this.button.strMnemonic);
	}
	this.SetEnabled=methodSetEnabled;
}
function C_RTE_TB_SetEnabledFromCommandValueIfNotInTable()
{
	function methodSetEnabled(strBaseElementID, docEditor, aElemChain)
	{
		if (aElemChain[0] !="TABLE" && aElemChain[0] !="TR")
		{
			RTE_TB_ClearButtonDisabled(RTE_TB_GetToolBarButton(
				strBaseElementID, this.button.strMnemonic));
			RTE_TB_SetCheckFromCommandValue(
				strBaseElementID, docEditor, this.button.strMnemonic);
		}
	}
	this.SetEnabled=methodSetEnabled;
}
function C_RTE_TB_SetEnabledIfInElement(strElement)
{
	function methodSetEnabled(strBaseElementID, docEditor, aElemChain)
	{
		RTE_TB_SetEnabledIfInElement(strBaseElementID, aElemChain,
			this.button.strMnemonic, this.strElement);
	}
	this.strElement=strElement;
	this.SetEnabled=methodSetEnabled;
}
function RTE_GetToolBarDefinition(strBaseElementID, strWebLanguage)
{
	var variables=RTE_GetEditorInstanceVariables(strBaseElementID);
	if (variables !=null && variables.overrides.GetToolBarDefinition !=null)
	{
		return variables.overrides.GetToolBarDefinition(strBaseElementID, strWebLanguage);
	}
	else if (variables !=null)
	{
		return RTE_GetCompatibleToolBarDefinition(
			strWebLanguage,
			variables.aSettings.fRestrictedMode,
			variables.aSettings.fAllowHyperlink,
			variables.aSettings.fIsVisible);
	}
	else
	{
		return null;
	}
}
var g_rgCompatibleToolBarDefinition;
function RTE_GetCompatibleToolBarDefinition(
	strWebLanguage, fRestrictedMode, fAllowHyperlink, fIsVisible)
{
	if (g_rgCompatibleToolBarDefinition==undefined)
	{
		toolBar=new Array();
		if (!fRestrictedMode)
		{
			toolBar.push(
				new C_RTE_TB_ExecCmdButton(
					g_strRTECutMnemonic,
					L_CutToolTip_TEXT,
					false, "rtecut.gif", true, true, "null",
					new C_RTE_TB_SetEnabledFromCommandEnabled()));
			toolBar.push(
				new C_RTE_TB_ExecCmdButton(
					g_strRTECopyMnemonic,
					L_CopyToolTip_TEXT,
					false, "rtecopy.gif", true, true, "null",
					new C_RTE_TB_SetEnabledFromCommandEnabled()));
			toolBar.push(
				new C_RTE_TB_ExecCmdButton(
					g_strRTEPasteMnemonic,
					L_PasteToolTip_TEXT,
					false, "rtepaste.gif", true, false, "null",
					new C_RTE_TB_SetEnabledFromCommandEnabled()));
			toolBar.push(new C_RTE_TB_Separator());
		}
		toolBar.push(
			new C_RTE_TB_SpecialButton(
				g_strRTEFontNameMnemonic,
				RTE_GenerateFontNameToolBarButtonHtml,
				fRestrictedMode,
				new C_RTE_TB_SetEnabledAlways()));
		toolBar.push(
			new C_RTE_TB_SpecialButton(
				g_strRTEFontSizeMnemonic,
				RTE_GenerateFontSizeToolBarButtonHtml,
				fRestrictedMode,
				new C_RTE_TB_SetEnabledAlways()));
		toolBar.push(new C_RTE_TB_Separator());
		toolBar.push(
			new C_RTE_TB_ExecCmdButton(
				g_strRTEBoldMnemonic,
				L_BoldToolTip_TEXT,
				false, "rtebold.gif", true, false, "null",
				new C_RTE_TB_SetEnabledFromCommandValue()));
		toolBar.push(
			new C_RTE_TB_ExecCmdButton(
				g_strRTEItalicMnemonic,
				L_ItalicToolTip_TEXT,
				false, "rteital.gif", true, false, "null",
				new C_RTE_TB_SetEnabledFromCommandValue()));
		toolBar.push(
			new C_RTE_TB_ExecCmdButton(
				g_strRTEUnderlineMnemonic,
				L_UnderlineToolTip_TEXT,
				false, "rteundl.gif", true, false, "null",
				new C_RTE_TB_SetEnabledFromCommandValue()));
		toolBar.push(new C_RTE_TB_Separator());
		if (strWebLanguage=="1025" || strWebLanguage=="1037")
		{
			toolBar.push(
				new C_RTE_TB_ExecCmdButton(
					g_strRTEJustifyRightMnemonic,
					L_JustifyRightToolTip_TEXT,
					false, "rtertal.gif", true, false, "null",
					new C_RTE_TB_SetEnabledFromCommandValue()));
			toolBar.push(
				new C_RTE_TB_ExecCmdButton(
					g_strRTEJustifyCenterMnemonic,
					L_JustifyCenterToolTip_TEXT,
					false, "rtectral.gif", true, false, "null",
					new C_RTE_TB_SetEnabledFromCommandValue()));
			toolBar.push(
				new C_RTE_TB_ExecCmdButton(
					g_strRTEJustifyLeftMnemonic,
					L_JustifyLeftToolTip_TEXT,
					false, "rteltal.gif", true, false, "null",
					new C_RTE_TB_SetEnabledFromCommandValue()));
		}
		else
		{
			toolBar.push(
				new C_RTE_TB_ExecCmdButton(
					g_strRTEJustifyLeftMnemonic,
					L_JustifyLeftToolTip_TEXT,
					false, "rteltal.gif", true, false, "null",
					new C_RTE_TB_SetEnabledFromCommandValue()));
			toolBar.push(
				new C_RTE_TB_ExecCmdButton(
					g_strRTEJustifyCenterMnemonic,
					L_JustifyCenterToolTip_TEXT,
					false, "rtectral.gif", true, false, "null",
					new C_RTE_TB_SetEnabledFromCommandValue()));
			toolBar.push(
				new C_RTE_TB_ExecCmdButton(
					g_strRTEJustifyRightMnemonic,
					L_JustifyRightToolTip_TEXT,
					false, "rtertal.gif", true, false, "null",
					new C_RTE_TB_SetEnabledFromCommandValue()));
		}
		toolBar.push(new C_RTE_TB_Separator());
		toolBar.push(
			new C_RTE_TB_ExecCmdButton(
				g_strRTEOrderedListMnemonic,
				L_OrderedListToolTip_TEXT,
				false, "rtenlst.gif", true, false, "null",
				new C_RTE_TB_SetEnabledFromCommandValueIfNotInTable()));
		toolBar.push(
			new C_RTE_TB_ExecCmdButton(
				g_strRTEUnorderedListMnemonic,
				L_UnorderedListToolTip_TEXT,
				false, "rteblst.gif", true, false, "null",
				new C_RTE_TB_SetEnabledFromCommandValueIfNotInTable()));
		if (!fRestrictedMode)
		{
			toolBar.push(new C_RTE_TB_Separator);
		}
		toolBar.push(
			new C_RTE_TB_ExecCmdButton(
				g_strRTEOutdentMnemonic,
				L_OutdentToolTip_TEXT,
				false, "rteuidt.gif", true, false, "null",
				new C_RTE_TB_SetEnabledAlways()));
		toolBar.push(
			new C_RTE_TB_ExecCmdButton(
				g_strRTEIndentMnemonic,
				L_IndentToolTip_TEXT,
				false, "rteidt.gif", true, false, "null",
				new C_RTE_TB_SetEnabledAlways()));
		if (!fRestrictedMode)
		{
			toolBar.push(new C_RTE_TB_Separator);
		}
		if (!fRestrictedMode || fAllowHyperlink)
		{
			toolBar.push(
				new C_RTE_TB_JScriptButton(
					g_strRTECreateLinkMnemonic,
					L_CreateLinkToolTip_TEXT,
					"RTE_CreateLink", null, "rtelnk.gif",
					new C_RTE_TB_SetEnabledWhenRemoveFormatEnabled()));
		}
		if (!fRestrictedMode)
		{
			toolBar.push(
				new C_RTE_TB_ExecCmdButton(
					g_strRTEInsertImageMnemonic,
					L_InsertImageToolTip_TEXT,
					true, "rteimg.gif", true, false, "null",
					new C_RTE_TB_SetEnabledWhenRemoveFormatEnabled()));
		}
		toolBar.push(new C_RTE_TB_Separator);
		toolBar.push(
			new C_RTE_TB_SpecialButton(
				g_strRTEForeColorMnemonic,
				RTE_GenerateForeColorToolBarButtonHtml,
				fRestrictedMode,
				new C_RTE_TB_SetEnabledAlways()));
		toolBar.push(
			new C_RTE_TB_SpecialButton(
				g_strRTEBackColorMnemonic,
				RTE_GenerateBackColorToolBarButtonHtml,
				fRestrictedMode,
				new C_RTE_TB_SetEnabledAlways()));
		if (RTE_ShouldShowDirection())
		{
			if (!fRestrictedMode)
			{
				toolBar.push(new C_RTE_TB_Separator);
			}
			if (strWebLanguage=="1025" || strWebLanguage=="1037")
			{
				toolBar.push(
					new C_RTE_TB_JScriptButton(
						"rtl", L_RTLToolTip_TEXT,
						"RTE_SetDirectionOfSelection", "'rtl'", "rtertl.gif",
						new C_RTE_TB_SetEnabledAlways()));
				toolBar.push(
					new C_RTE_TB_JScriptButton(
						"ltr", L_LTRToolTip_TEXT,
						"RTE_SetDirectionOfSelection", "'ltr'", "rteltr.gif",
						new C_RTE_TB_SetEnabledAlways()));
			}
			else
			{
				toolBar.push(
					new C_RTE_TB_JScriptButton(
						"ltr", L_LTRToolTip_TEXT,
						"RTE_SetDirectionOfSelection", "'ltr'", "rteltr.gif",
						new C_RTE_TB_SetEnabledAlways()));
				toolBar.push(
					new C_RTE_TB_JScriptButton(
						"rtl", L_RTLToolTip_TEXT,
						"RTE_SetDirectionOfSelection", "'rtl'", "rtertl.gif",
						new C_RTE_TB_SetEnabledAlways()));
			}
		}
		g_rgCompatibleToolBarDefinition=toolBar;
	}
	return g_rgCompatibleToolBarDefinition;
}
function RTE_ModalDialog(
	strBaseElementID,
	strDialogName,
	width,
	height,
	dialogArg)
{
	var variables=RTE_GetEditorInstanceVariables(strBaseElementID);
	return showModalDialog(
		variables.aSettings.urlWebRoot+			"/_layouts/RteDialog.aspx?Dialog="+			strDialogName+			"&LCID="+RTE_GetWebLocale(strBaseElementID),
		dialogArg,
		"resizable: yes; status: no; help: no; "+			"center: yes; dialogWidth:"+width+"px; "+			"dialogHeight:"+height+"px;");
}
function RTE_FullHtmlToolBarDefinitionFactory(editSource)
{
	var rgFullToolBarDefinition;
	return function(strWebLanguage)
	{
		if (rgFullToolBarDefinition==undefined)
		{
			toolBar=new Array();
			toolBar.push(
				new C_RTE_TB_ExecCmdButton(
					g_strRTECutMnemonic,
					L_CutToolTip_TEXT,
					false, "rtecut.gif", true, true, "null",
					new C_RTE_TB_SetEnabledFromCommandEnabled()));
			toolBar.push(
				new C_RTE_TB_ExecCmdButton(
					g_strRTECopyMnemonic,
					L_CopyToolTip_TEXT,
					false, "rtecopy.gif", true, true, "null",
					new C_RTE_TB_SetEnabledFromCommandEnabled()));
			toolBar.push(
				new C_RTE_TB_ExecCmdButton(
					g_strRTEPasteMnemonic,
					L_PasteToolTip_TEXT,
					false, "rtepaste.gif", true, false, "null",
					new C_RTE_TB_SetEnabledFromCommandEnabled()));
			toolBar.push(
				new C_RTE_TB_ExecCmdButton(
					g_strRTERemoveFormatMnemonic,
					L_RemoveFormatToolTip_TEXT,
					false, "rteclear.gif", true, false, "null",
					new C_RTE_TB_SetEnabledFromCommandEnabled()));
			toolBar.push(new C_RTE_TB_Separator());
			if (strWebLanguage=="1025" || strWebLanguage=="1037")
			{
				toolBar.push(
					new C_RTE_TB_ExecCmdButton(
						g_strRTERedoMnemonic,
						L_RedoToolTip_TEXT,
						false, "redo.gif", false, false, "null",
						new C_RTE_TB_SetEnabledFromCommandEnabled()));
				toolBar.push(
					new C_RTE_TB_ExecCmdButton(
						g_strRTEUndoMnemonic,
						L_UndoToolTip_TEXT,
						false, "undo.gif", false, false, "null",
						new C_RTE_TB_SetEnabledFromCommandEnabled()));
			}
			else
			{
				toolBar.push(
					new C_RTE_TB_ExecCmdButton(
						g_strRTEUndoMnemonic,
						L_UndoToolTip_TEXT,
						false, "undo.gif", false, false, "null",
						new C_RTE_TB_SetEnabledFromCommandEnabled()));
				toolBar.push(
					new C_RTE_TB_ExecCmdButton(
						g_strRTERedoMnemonic,
						L_RedoToolTip_TEXT,
						false, "redo.gif", false, false, "null",
						new C_RTE_TB_SetEnabledFromCommandEnabled()));
			}
			toolBar.push(new C_RTE_TB_Separator());
			toolBar.push(
				new C_RTE_TB_JScriptButton(
					g_strRTEInsertTableMnemonic,
					L_InsertTableToolTip_TEXT,
					"RTE_InsertTable", null, "rteitbl.gif",
					new C_RTE_TB_SetEnabledWhenRemoveFormatEnabled()));
			toolBar.push(
				new C_RTE_TB_SpecialButton(
					g_strRTEInsertTableElementMnemonic,
					RTE_GenerateInsertTableElementToolBarButtonHtml,
					true,
					new C_RTE_TB_SetEnabledIfInElement("TR")));
			toolBar.push(
				new C_RTE_TB_SpecialButton(
					g_strRTEDeleteTableElementMnemonic,
					RTE_GenerateDeleteTableElementToolBarButtonHtml,
					true,
					new C_RTE_TB_SetEnabledIfInElement("TR")));
			toolBar.push(
				new C_RTE_TB_JScriptButton(
					g_strRTESplitCellMnemonic, L_SplitCellToolTip_TEXT,
					"RTE_SplitCell",
					null,
					"rtescell.gif",
					new C_RTE_TB_SetEnabledIfInElement("TR")));
			toolBar.push(
				new C_RTE_TB_JScriptButton(
				g_strRTEMergeCellMnemonic,
				L_MergeCellToolTip_TEXT,
				"RTE_MergeCells",
				null,
				"rtemcell.gif",
				new C_RTE_TB_SetEnabledIfInElement("TR")));
			toolBar.push(new C_RTE_TB_Separator());
			toolBar.push(
				new C_RTE_TB_JScriptButton(
					g_strRTECreateLinkMnemonic,
					L_CreateLinkToolTip_TEXT,
					"RTE_CreateLink", null, "rtelnk.gif",
					new C_RTE_TB_SetEnabledWhenRemoveFormatEnabled()));
			toolBar.push(
				new C_RTE_TB_JScriptButton(
					g_strRTEInsertImageMnemonic,
					L_InsertImageToolTip_TEXT,
					"RTE_InsertImage", null, "rteimg.gif",
					new C_RTE_TB_SetEnabledWhenRemoveFormatEnabled()));
			if (editSource)
			{
				toolBar.push(
					new C_RTE_TB_JScriptButton(
						g_strRTEHtmlSourceMnemonic,
						L_HtmlSourceToolTip_TEXT,
						"RTE_HtmlSource", null, "rtesrced.gif",
						new C_RTE_TB_SetEnabledAlways()));
			}
			toolBar.push(new C_RTE_TB_LineBreak());
			toolBar.push(
				new C_RTE_TB_SpecialButton(
					g_strRTEFontNameMnemonic,
					RTE_GenerateFontNameToolBarButtonHtml,
					true,
					new C_RTE_TB_SetEnabledAlways()));
			toolBar.push(
				new C_RTE_TB_SpecialButton(
					g_strRTEFontSizeMnemonic,
					RTE_GenerateFontSizeToolBarButtonHtml,
					true,
					new C_RTE_TB_SetEnabledAlways()));
			toolBar.push(new C_RTE_TB_Separator());
			toolBar.push(
				new C_RTE_TB_ExecCmdButton(
					g_strRTEBoldMnemonic,
					L_BoldToolTip_TEXT,
					false, "rtebold.gif", true, false, "null",
					new C_RTE_TB_SetEnabledFromCommandValue()));
			toolBar.push(
				new C_RTE_TB_ExecCmdButton(
					g_strRTEItalicMnemonic,
					L_ItalicToolTip_TEXT,
					false, "rteital.gif", true, false, "null",
					new C_RTE_TB_SetEnabledFromCommandValue()));
			toolBar.push(
				new C_RTE_TB_ExecCmdButton(
					g_strRTEUnderlineMnemonic,
					L_UnderlineToolTip_TEXT,
					false, "rteundl.gif", true, false, "null",
					new C_RTE_TB_SetEnabledFromCommandValue()));
			toolBar.push(new C_RTE_TB_Separator());
			if (strWebLanguage=="1025" || strWebLanguage=="1037")
			{
				toolBar.push(
					new C_RTE_TB_ExecCmdButton(
						g_strRTEJustifyRightMnemonic,
						L_JustifyRightToolTip_TEXT,
						false, "rtertal.gif", true, false, "null",
						new C_RTE_TB_SetEnabledFromCommandValue()));
				toolBar.push(
					new C_RTE_TB_ExecCmdButton(
						g_strRTEJustifyCenterMnemonic,
						L_JustifyCenterToolTip_TEXT,
						false, "rtectral.gif", true, false, "null",
						new C_RTE_TB_SetEnabledFromCommandValue()));
				toolBar.push(
					new C_RTE_TB_ExecCmdButton(
						g_strRTEJustifyLeftMnemonic,
						L_JustifyLeftToolTip_TEXT,
						false, "rteltal.gif", true, false, "null",
						new C_RTE_TB_SetEnabledFromCommandValue()));
			}
			else
			{
				toolBar.push(
					new C_RTE_TB_ExecCmdButton(
						g_strRTEJustifyLeftMnemonic,
						L_JustifyLeftToolTip_TEXT,
						false, "rteltal.gif", true, false, "null",
						new C_RTE_TB_SetEnabledFromCommandValue()));
				toolBar.push(
					new C_RTE_TB_ExecCmdButton(
						g_strRTEJustifyCenterMnemonic,
						L_JustifyCenterToolTip_TEXT,
						false, "rtectral.gif", true, false, "null",
						new C_RTE_TB_SetEnabledFromCommandValue()));
				toolBar.push(
					new C_RTE_TB_ExecCmdButton(
						g_strRTEJustifyRightMnemonic,
						L_JustifyRightToolTip_TEXT,
						false, "rtertal.gif", true, false, "null",
						new C_RTE_TB_SetEnabledFromCommandValue()));
			}
			toolBar.push(new C_RTE_TB_Separator());
			toolBar.push(
				new C_RTE_TB_ExecCmdButton(
					g_strRTEOrderedListMnemonic,
					L_OrderedListToolTip_TEXT,
					false, "rtenlst.gif", true, false, "null",
					new C_RTE_TB_SetEnabledFromCommandValueIfNotInTable()));
			toolBar.push(
				new C_RTE_TB_ExecCmdButton(
					g_strRTEUnorderedListMnemonic,
					L_UnorderedListToolTip_TEXT,
					false, "rteblst.gif", true, false, "null",
					new C_RTE_TB_SetEnabledFromCommandValueIfNotInTable()));
			toolBar.push(
				new C_RTE_TB_ExecCmdButton(
					g_strRTEOutdentMnemonic,
					L_OutdentToolTip_TEXT,
					false, "rteuidt.gif", true, false, "null",
					new C_RTE_TB_SetEnabledAlways()));
			toolBar.push(
				new C_RTE_TB_ExecCmdButton(
					g_strRTEIndentMnemonic,
					L_IndentToolTip_TEXT,
					false, "rteidt.gif", true, false, "null",
					new C_RTE_TB_SetEnabledAlways()));
			toolBar.push(new C_RTE_TB_Separator());
			toolBar.push(
				new C_RTE_TB_SpecialButton(
					g_strRTEForeColorMnemonic,
					RTE_GenerateForeColorToolBarButtonHtml,
					true,
					new C_RTE_TB_SetEnabledAlways()));
			toolBar.push(
				new C_RTE_TB_SpecialButton(
					g_strRTEBackColorMnemonic,
					RTE_GenerateBackColorToolBarButtonHtml,
					true,
					new C_RTE_TB_SetEnabledAlways()));
			if (RTE_ShouldShowDirection())
			{
				if (strWebLanguage=="1025" || strWebLanguage=="1037")
				{
					toolBar.push(
						new C_RTE_TB_JScriptButton(
							"rtl", L_RTLToolTip_TEXT,
							"RTE_SetDirectionOfSelection", "'rtl'", "rtertl.gif",
							new C_RTE_TB_SetEnabledAlways()));
					toolBar.push(
						new C_RTE_TB_JScriptButton(
							"ltr", L_LTRToolTip_TEXT,
							"RTE_SetDirectionOfSelection", "'ltr'", "rteltr.gif",
							new C_RTE_TB_SetEnabledAlways()));
				}
				else
				{
					toolBar.push(
						new C_RTE_TB_JScriptButton(
							"ltr", L_LTRToolTip_TEXT,
							"RTE_SetDirectionOfSelection", "'ltr'", "rteltr.gif",
							new C_RTE_TB_SetEnabledAlways()));
					toolBar.push(
						new C_RTE_TB_JScriptButton(
							"rtl", L_RTLToolTip_TEXT,
							"RTE_SetDirectionOfSelection", "'rtl'", "rtertl.gif",
							new C_RTE_TB_SetEnabledAlways()));
				}
			}
			rgFullToolBarDefinition=toolBar;
		}
		return rgFullToolBarDefinition;
	}
}
var FileuploadString="fileupload";
var FileUploadIndex=0;
var FileUploadIndexStart;
var attachmentsOnClientToBeRemoved;
var attachmentsOnClientToBeRemovedIndex;
var attachmentsOnServerToBeRemoved;
var attachmentsOnServerToBeRemovedIndex;
function UploadAttachment()
{
		ShowPartAttachment();
}
function ShowPart1()
{
	document.getElementById("partAttachment").style.display="none";
	document.getElementById("part1").style.display="block";
	if (typeof(frm) !="undefined")
		frm.SetFirstFocus(true);
}
function ShowPartAttachment()
{
	if (document.getElementById("part1")==null ||
		typeof(document.getElementById("part1"))=="undefined")
	{
		var L_FormMissingPart1_Text=			"This form was customized not working with attachement.";
		alert(L_FormMissingPart1_Text);
		return;
	}
	document.getElementById("part1").style.display="none";
	document.getElementById("partAttachment").style.display="block";
	GetAttachElement(FileuploadString+FileUploadIndex).focus();
}
function CancelAttach()
{
	fileID=FileuploadString+FileUploadIndex;
	fileInput=GetAttachElement(fileID);
	filename=fileInput.value;
	if (filename)
	{
		fileInput.outerHTML="<input type=file class='ms-longfileinput' name="+fileID+">";
	}
	ShowPart1();
}
function OkAttach()
{
	fileID=FileuploadString+FileUploadIndex;
	fileInput=GetAttachElement(fileID);
	filename=TrimWhiteSpaces(fileInput.value);
	if (!filename)
	{
		var L_FileNameRequired_TXT="You must specify a non-blank value for File Name.";
		alert(L_FileNameRequired_TXT);
		fileInput.focus();
	}
	else
	{
		var L_FileUploadToolTip_text="Name";
		oRow=document.getElementById("idAttachmentsTable").insertRow(-1);
		RowID='attachRow'+FileUploadIndex;
		oRow.id=RowID;
		oCellFileName=oRow.insertCell(-1);
		oCellFileName.className="ms-vb";
		oCellFileName.innerHTML="<span dir=\"ltr\">"+filename+"</span>&nbsp;&nbsp;&nbsp;&nbsp;";
		oCellControl=oRow.insertCell(-1);
		oCellControl.className="ms-propertysheet";
		oCellControl.innerHTML="<IMG SRC='"+document.getElementsByName("RectGifUrl").item(0).value+			"'>&nbsp;<a href='javascript:RemoveLocal("+RowID+",\""+fileID+			"\")'>"+L_Delete_Text+"</a>";
		fileInput.style.display="none";
++FileUploadIndex;
		oAttachments=document.getElementById("attachmentsOnClient");
		var inputNode=document.createElement("input");
		inputNode.tabIndex="1";
		inputNode.type="File";
		inputNode.className="ms-longfileinput";
		inputNode.title=L_FileUploadToolTip_text;
		inputNode.name=FileuploadString+FileUploadIndex;
		inputNode.id=FileuploadString+FileUploadIndex;
		inputNode.size="56";
		oAttachments.appendChild(inputNode);
		var theForm=fileInput.form;
		theForm.encoding='multipart/form-data';
		document.getElementById("idAttachmentsRow").style.display="";
		ShowPart1();
	}
}
function GetAttachElement(elem)
{
	var ret=document.getElementById(elem);
	if (ret==null)
		ret=document.getElementsByName(elem).item(0);
	return ret;
}
function RemoveLocal(RowID, FileID)
{
	document.getElementById("idAttachmentsTable").deleteRow(RowID.rowIndex);
	var nodeForRemoval=GetAttachElement(FileID);
		nodeForRemoval.parentNode.removeChild(nodeForRemoval);
	if (idAttachmentsTable.rows.length==0)
		idAttachmentsRow.style.display='none';
}
function RemoveFromServer(guid)
{
	RemoveAttachmentFromServer(guid, 0)
}
function RemoveAttachmentFromServer(guid, bRecycleBinEnabled)
{
	var L_ConfirmDelete_TXT="Are you sure you want to delete this attachment?";
	var L_ConfirmRecycle_TXT="Are you sure you want to send this attachment to the site Recycle Bin?";
	var strWarning;
	if (bRecycleBinEnabled)
	{
		strWarning=L_ConfirmRecycle_TXT;
	}
	else
	{
		strWarning=L_ConfirmDelete_TXT;
	}
	if (confirm(strWarning))
	{
		document.getElementById("idAttachmentsTable").deleteRow(document.getElementById(guid).rowIndex);
		document.getElementsByName("attachmentsToBeRemovedFromServer").item(0).value+=guid+";";
		if (document.getElementById("idAttachmentsTable").rows.length==0)
		   document.getElementById("idAttachmentsRow").style.display='none';
	}
}
function MsFloorTime(date, ms, exclusive)
{
	var time=date.getTime();
	if (exclusive)
		time=time - 1;
	time=ms * Math.floor(time / ms);
	return time;
}
function Calendar(yr, mon, dopt, stObject)
{
	if (!dopt)
		dopt=new DateOptions;
	this.dopt=dopt;
	var day=1;
	if (yr==null || mon==null)
		{
		var stCalDate=StURLGetVar("CalendarDate");
		if (stCalDate !="")
			{
			yr=stCalDate.substr(0, 4) - 0;
			var idxM2D=stCalDate.indexOf("-",5);
			if (idxM2D==-1)
				{
				mon=stCalDate.substr(5) - 1;
				}
			else
				{
				mon=stCalDate.substr(5, idxM2D-5) - 1;
				day=stCalDate.substr(idxM2D+1);
				}
			}
		if (stCalDate=="" || isNaN(dopt.DateYMD(yr, mon, 1)))
			{
			var dateToday=this.dopt.Today();
			yr=dateToday.getUTCFullYear();
			mon=dateToday.getUTCMonth();
			day=dateToday.getUTCDate();
			}
		}
	var stCalPeriod=StURLGetVar("CalendarPeriod");
	if (stCalPeriod=="week")
	{
		this.period="week";
		this.iperiod=1;
	}	
	else if (stCalPeriod=="day")
	{
		this.period="vday";
		this.iperiod=2;
	}
	else if (stCalPeriod=="vday")
	{
		this.period="vday";
		this.iperiod=2;		
	}
	else if (stCalPeriod=="month")
	{
		this.period="month";
		this.iperiod=0;		
	}
	else
	{
		this.period=dopt.CalendarPeriod;
		if (this.period=="week")
			this.iperiod=1;		
		else if (this.period=="day")
			this.iperiod=2;		
		else if (this.period=="vday")
			this.iperiod=2;		
		else
			this.iperiod=0;		
	}
	this.SetDate(yr, mon, day);
	if (this.iperiod==0 )
	{
		this.cchanMin=4;
		this.cchanMax=4;
	}
	else if (this.iperiod==1 )
	{
		this.cchanMin=20;
		this.cchanMax=20;
	}
	else
	{
		this.cchanMin=3;
		this.cchanMax=100;
	}
	this.ievtMax=0;
	this.rgEvt=new Array;
	this.fUseDHTML=(browseris.ie && browseris.verIEFull > 4.0 && browseris.win32)
					 || browseris.nav6up;
	this.fDatePicker=false;
	this.dateDP=null;
	if (!stObject)
		stObject="cal";
	this.stObject=stObject;
}
Calendar.msMinute=1000*60;
Calendar.msHour=Calendar.msMinute * 60;
Calendar.msDay=Calendar.msHour * 24;
Calendar.msWeek=Calendar.msDay * 7;
var L_rgDOW0_Text="Sun";
var L_rgDOW1_Text="Mon";
var L_rgDOW2_Text="Tue";
var L_rgDOW3_Text="Wed";
var L_rgDOW4_Text="Thur";
var L_rgDOW5_Text="Fri";
var L_rgDOW6_Text="Sat";
Calendar.rgDOW=new Array(L_rgDOW0_Text, L_rgDOW1_Text, L_rgDOW2_Text,
						   L_rgDOW3_Text, L_rgDOW4_Text, L_rgDOW5_Text,
						   L_rgDOW6_Text);
var L_rgDOWLong0_Text="Sunday";
var L_rgDOWLong1_Text="Monday";
var L_rgDOWLong2_Text="Tuesday";
var L_rgDOWLong3_Text="Wednesday";
var L_rgDOWLong4_Text="Thursday";
var L_rgDOWLong5_Text="Friday";
var L_rgDOWLong6_Text="Saturday";
Calendar.rgDOWLong=new Array(L_rgDOWLong0_Text, L_rgDOWLong1_Text, L_rgDOWLong2_Text,
						   L_rgDOWLong3_Text, L_rgDOWLong4_Text, L_rgDOWLong5_Text,
						   L_rgDOWLong6_Text);
var L_rgDOWDP0_Text="S";
var L_rgDOWDP1_Text="M";
var L_rgDOWDP2_Text="T";
var L_rgDOWDP3_Text="W";
var L_rgDOWDP4_Text="Th";
var L_rgDOWDP5_Text="F";
var L_rgDOWDP6_Text="S";
Calendar.rgDOWDP=new Array(L_rgDOWDP0_Text, L_rgDOWDP1_Text, L_rgDOWDP2_Text,
							 L_rgDOWDP3_Text, L_rgDOWDP4_Text, L_rgDOWDP5_Text,
							 L_rgDOWDP6_Text);
var L_rgMonths0_Text="January";
var L_rgMonths1_Text="February";
var L_rgMonths2_Text="March";
var L_rgMonths3_Text="April";
var L_rgMonths4_Text="May";
var L_rgMonths5_Text="June";
var L_rgMonths6_Text="July";
var L_rgMonths7_Text="August";
var L_rgMonths8_Text="September";
var L_rgMonths9_Text="October";
var L_rgMonths10_Text="November";
var L_rgMonths11_Text="December";
Calendar.rgMonths=new Array(L_rgMonths0_Text, L_rgMonths1_Text,
							  L_rgMonths2_Text, L_rgMonths3_Text,
							  L_rgMonths4_Text, L_rgMonths5_Text,
							  L_rgMonths6_Text, L_rgMonths7_Text,
							  L_rgMonths8_Text, L_rgMonths9_Text,
							  L_rgMonths10_Text, L_rgMonths11_Text);
var L_MYDATE_Text="^1 ^2";
var L_YMDATE_Text="^1 ^2";
var L_MDYDATE_Text="^1 ^2, ^3";
var L_DMYDATE_Text="^1 ^2, ^3";
var L_YMDDATE_Text="^1, ^2 ^3";
var L_MDYDATESameYear_Text="^1 ^2";
var L_DMYDATESameYear_Text="^1 ^2";
var L_YMDDATESameYear_Text="^1, ^2 ^3";
var L_DATE1DATE2_Text="^1 - ^2";
var L_MDY_DOW_DATE_Text="^4 ^1 ^2, ^3";
var L_DMY_DOW_DATE_Text="^4 ^1 ^2, ^3";
var L_YMD_DOW_DATE_Text="^4 ^1, ^2 ^3";
Calendar.prototype.StMonthYear=CalStMonthYear;
function CalStMonthYear()
{
	var st="";
	if (this.iperiod !=0 )
		st+='<SPAN style="cursor:pointer;" onmouseover="HighlightText(this, \'red\');" onmouseout="HighlightText(this, \'\');"'+StClickEvent(this.stObject+'.MoveMonth(0)')+'>';
	var stFormat="";
	var param1="";
	var param2="";
	switch (this.dopt.stDateOrder)
		{
	case "MDY":
	case "DMY":
		param1=Calendar.rgMonths[this.mon];
		param2=this.yr;
		stFormat=L_MYDATE_Text;
		break;
	case "YMD":
		param1=this.yr;
		param2=Calendar.rgMonths[this.mon];
		stFormat=L_YMDATE_Text;
		break;
		}
	st+=StBuildParam(stFormat, param1, param2);
	if (this.iperiod !=0 )
		st+="</SPAN>";
	return st;
}
Calendar.prototype.StDaySpanMonthYear=CalDaySpanMonthYear;
function CalDaySpanMonthYear()
{
	var st="";
	var stStart="";
	var stEnd="";
	var stFormat1="";
	var stFormat2="";
	var param1="";
	var param2="";
	var param3="";
	var param4="";
	var param5="";
	var param6="";
	if (this.iperiod !=0 )
		st+='<SPAN style="cursor:pointer;" onmouseover="HighlightText(this, \'red\');" onmouseout="HighlightText(this, \'\');"'+StClickEvent(this.stObject+'.MoveMonth(0)')+'>';
	var bDiffYears=this.dateStart.getUTCFullYear() !=this.dateEnd.getUTCFullYear();	
	switch (this.dopt.stDateOrder)
		{
	case "MDY":
		param1=Calendar.rgMonths[this.dateStart.getUTCMonth()];
		param2=this.dateStart.getUTCDate();
		param3=this.dateStart.getUTCFullYear();
		if (bDiffYears)
			stFormat1=L_MDYDATE_Text;
		else
			stFormat1=L_MDYDATESameYear_Text;
		param4=Calendar.rgMonths[this.dateEnd.getUTCMonth()];
		param5=this.dateEnd.getUTCDate();
		param6=this.dateEnd.getUTCFullYear();
		stFormat2=L_MDYDATE_Text;
		break;
	case "DMY":
		param1=this.dateStart.getUTCDate();
		param2=Calendar.rgMonths[this.dateStart.getUTCMonth()];
		param3=this.dateStart.getUTCFullYear();
		if (bDiffYears)
			stFormat1=L_DMYDATE_Text;
		else
			stFormat1=L_DMYDATESameYear_Text;
		param4=this.dateEnd.getUTCDate();
		param5=Calendar.rgMonths[this.dateEnd.getUTCMonth()];
		param6=this.dateEnd.getUTCFullYear();
		stFormat2=L_DMYDATE_Text;
		break;
	case "YMD":
		param1=this.dateStart.getUTCFullYear();
		param2=Calendar.rgMonths[this.dateStart.getUTCMonth()];
		param3=this.dateStart.getUTCDate();
		if (bDiffYears)
			stFormat1=L_YMDDATE_Text;
		else
			stFormat1=L_YMDDATESameYear_Text;
		param4=this.dateEnd.getUTCFullYear();
		param5=Calendar.rgMonths[this.dateEnd.getUTCMonth()];
		param6=this.dateEnd.getUTCDate();
		stFormat2=L_YMDDATE_Text;
		break;
		}
	stStart=StBuildParam(stFormat1, param1, param2, param3);
	stEnd=StBuildParam(stFormat2, param4, param5, param6);
	st+=StBuildParam(L_DATE1DATE2_Text, stStart, stEnd);
	if (this.iperiod !=0 )
		st+="</SPAN>";
	return st;
}
Calendar.prototype.StDayMonthYear=CalStDayMonthYear;
function CalStDayMonthYear()
{
	var st="";
	st+='<SPAN style="cursor:pointer;" onmouseover="HighlightText(this, \'red\');" onmouseout="HighlightText(this, \'\');"'+StClickEvent(this.stObject+'.MoveMonth(0)')+'>';
	var stFormat="";
	var param1="";
	var param2="";
	var param3="";
	var param4=Calendar.rgDOWLong[this.dow];
	switch (this.dopt.stDateOrder)
		{
	case "MDY":
		param1=Calendar.rgMonths[this.mon];
		param2=this.day;
		param3=this.yr;
		stFormat=L_MDY_DOW_DATE_Text;
		break;
	case "DMY":
		param1=this.day;
		param2=Calendar.rgMonths[this.mon];
		param3=this.yr;
		stFormat=L_DMY_DOW_DATE_Text;
		break;
	case "YMD":
		param1=this.yr;
		param2=Calendar.rgMonths[this.mon];
		param3=this.day;
		stFormat=L_YMD_DOW_DATE_Text;
		break;
		}
	st+=StBuildParam(stFormat, param1, param2, param3, param4);
	st+="</SPAN>";
	return st;
}
function alertDate(st, date)
{
	alert(st+": yr="+date.getUTCFullYear()+" mon="+(date.getUTCMonth()+1)+" day="+date.getUTCDate());
}
Calendar.prototype.SetDate=CalSetDate;
function CalSetDate(yr, mon, day)
{
	var date=new Date(Date.UTC(yr, mon, day));
	this.dateStart=new Date(date.getTime());
	this.dateEnd=new Date(date.getTime());
	this.givenDate=new Date(date.getTime());
	if (this.iperiod==0  )
		{
		this.dateStart.setUTCDate(1);
		this.dateEnd.setTime(Date.UTC(yr, mon+1, 0));
		}
	var irw=0;
	if (this.iperiod !=2 )
		{
		this.dateStart.setUTCDate(this.dateStart.getUTCDate() - (this.dateStart.getUTCDay() -this.dopt.dow+7)%7);
		irw=this.IrwFromDate(this.dateEnd);
		this.dateEnd.setUTCDate(this.dateEnd.getUTCDate()+irw * 7 - 1);
		}
	this.irwMax=irw+1;
	if (this.iperiod==1 )
		{
		this.dateEnd.setTime(this.dateStart.getTime()+6 * Calendar.msDay);
		date=new Date(this.dateStart.getTime()+3 * Calendar.msDay);
		}
	else if (this.iperiod==2 )
		{
		this.dateTodayEnd=new Date(this.dateStart.getTime()+Calendar.msDay - 1);		
		}
	this.day=date.getUTCDate();
	this.mon=date.getUTCMonth();
	this.yr=date.getUTCFullYear();
	this.dow=date.getUTCDay();
}
Calendar.prototype.DayStyle=CalDayStyle;
function CalDayStyle(dateCur, fBottom, fTop, fWeekly)
{
	var st;
	var dateToday=this.dopt.Today();
	if (dateCur.getTime()==dateToday.getTime())
		{
			if (fBottom)
				st=' style="border-color:\'#FFD275\'; border-bottom-style:solid; border-left-style:solid; border-right-style:solid; border-bottom-width:2pt; border-left-width:2pt; border-right-width:2pt" ';
			else if (fTop)
				st=' style="border-color:\'#FFD275\'; border-top-style:solid; border-left-style:solid; border-right-style:solid; border-top-width:2pt; border-left-width:2pt; border-right-width:2pt" ';
			else
				st=' style="border-color:\'#FFD275\'; border-left-style:solid; border-right-style:solid; border-left-width:2pt; border-right-width:2pt" ';
		}
	else if (!fWeekly && dateCur.getUTCMonth() !=this.mon)
		{
			st=' BGCOLOR="#e6e6e6"';
		}
	else
		st="";
	return st;
}
Calendar.prototype.AddFullEvent=CalAddFullEvent;
function CalAddFullEvent(stDateStart, stDateEnd, stLocation, stDesc, stTitle, stURL, rgIcons)
{
	var dateStart;
	var dateEnd;
	if (stDateStart=="")
		return;
	dateStart=DateOptions.ParseISODate(stDateStart);
	if (stDateEnd=="")
		{
		dateEnd=new Date(dateStart.getTime());
		}
	else
		{
		dateEnd=DateOptions.ParseISODate(stDateEnd);
		}
	if (dateEnd < dateStart)
		dateEnd=new Date(dateStart.getTime());
	var displayDateStart=new Date(dateStart.getTime());
	var displayDateEnd=new Date(dateEnd.getTime());
	if (this.iperiod==2 )
	{
		if (dateStart > this.dateTodayEnd || dateEnd < this.dateStart)
			return;
		if (displayDateStart < this.dateStart)
			displayDateStart=this.dateStart;
		var minDisplay=Calendar.msHour/3;	
		if (dateEnd.getTime() < dateStart.getTime()+minDisplay)
			displayDateEnd=new Date(dateStart.getTime()+minDisplay);
	}
	stURL+="&Source="+escapeProperly(window.location.href);
	var evt=new CalEvent(displayDateStart, displayDateEnd, dateStart, dateEnd, stLocation, stDesc, stTitle, stURL, rgIcons);
	this.AddEvent(evt);
}
Calendar.prototype.AddEvent=CalAddEvent;
function CalAddEvent(evt)
{
	this.rgEvt[this.ievtMax++]=evt;
}
Calendar.prototype.AssignChannels=CalAssignChannels;
function CalAssignChannels()
{
	var ievt;
	this.mpSpan=new Object;
	this.mpIchan=new Object;
	this.mpEvents=new Object;
	var fAllDaySeparate=false;
	var dateTodayStart;
	var dateTodayEnd;
	if (this.iperiod==2 )
		{
		fAllDaySeparate=true;
		dateTodayStart=this.dateStart;
		dateTodayEnd=this.dateTodayEnd;
		this.mpNoTimeEvents=new Array;
		this.mpAllDayEvents=new Array;
		var dailyStart=this.dopt.WorkDayStartHour - this.dopt.DailyStartHourDelta;
		var dailyEnd=this.dopt.WorkDayEndHour+this.dopt.DailyEndHourDelta;
		if (dailyStart < 0) dailyStart=0;
		if (dailyEnd > 24) dailyEnd=24;
		this.minQuarterStart=4*dailyStart;
		this.maxQuarterEnd=4*dailyEnd-1;
		for (ievt=0; ievt < this.rgEvt.length; ievt++)
			{
			evt=this.rgEvt[ievt];
			if ((evt.actualDateStart > dateTodayEnd || (evt.actualDateEnd-1) < dateTodayStart)
				|| (evt.actualDateStart <=dateTodayStart && evt.actualDateEnd >=dateTodayEnd))
				continue;
			irwMin=this.IrwFromDate(evt.dateStart);
			if (irwMin < 0)
				irwMin=0;
			irwMax=this.IrwFromDate(evt.dateEnd);
			if (irwMax > this.irwMax)
				irwMax=this.irwMax;
			if (irwMin < this.irwMax && irwMax >=0)
				{
				for (irw=irwMin; irw <=irwMax; irw++)
					{
					var date=new Date;
					this.SetDateFromGrid(date, irw, 0);
					if (date < dateTodayStart || date >=dateTodayEnd)
						continue;
					var quarterRow=date.getTime()/(Calendar.msHour/4);
					var quarterStart=MsFloorTime(evt.dateStart, Calendar.msHour/4, 0)/(Calendar.msHour/4) - quarterRow;
					var quarterEnd=MsFloorTime(evt.dateEnd, Calendar.msHour/4, 1)/(Calendar.msHour/4) - quarterRow+1;
					if (quarterEnd < quarterStart)
						quarterEnd=quarterStart;
					if (quarterStart < this.minQuarterStart)
						this.minQuarterStart=quarterStart;
					if (quarterEnd > this.maxQuarterEnd)
						this.maxQuarterEnd=quarterEnd;
					if (quarterStart > 0 && 95 - quarterStart < 2)
						this.FVdayOverflow=true;
					}
				}
			}
			this.minQuarterStart=Math.floor(this.minQuarterStart/4)*4;
			if (this.minQuarterStart < 0)
				this.minQuarterStart=0;
			if (this.maxQuarterEnd > 95)	
				this.maxQuarterEnd=95;
			else
				this.maxQuarterEnd=4 * (Math.floor(this.maxQuarterEnd/4)+1) - 1;
		}
	if (this.iperiod <=1 )	
		this.rgEvt.sort(CalEvtSort);
	var todayMiliSec=this.dateStart;
	todayMiliSec.setUTCHours(0,0,0,0);
	todayMiliSec=todayMiliSec.getTime();
	for (ievt=0; ievt < this.rgEvt.length; ievt++)
		{
		evt=this.rgEvt[ievt];
		if (fAllDaySeparate)
		{
			if (evt.actualDateStart.getTime()==todayMiliSec
				&& evt.actualDateEnd.getTime()==todayMiliSec)
				{
					this.mpNoTimeEvents[this.mpNoTimeEvents.length]=evt;
					continue;
				}
			if (evt.actualDateStart <=dateTodayStart
				&& evt.actualDateEnd >=dateTodayEnd)
				{
					this.mpAllDayEvents[this.mpAllDayEvents.length]=evt;
					continue;
				}
		}
		irwMin=this.IrwFromDate(evt.dateStart);
		if (irwMin < 0)
			irwMin=0;
		irwMax=this.IrwFromDate(evt.dateEnd);
		if (irwMax > this.irwMax)
			irwMax=this.irwMax;
		if (irwMin < this.irwMax && irwMax >=0)
			{
			for (irw=irwMin; irw <=irwMax; irw++)
				{
				this.PlaceEventInRow(evt, irw);
				}
			}
		}
}
function CalEvtSort(e1, e2)
{
	if (e1.multiDay ^ e2.multiDay)
	{
		if (e1.multiDay)
			return -1;
		else
			return 1;
	}
	else if (e1.multiDay)
	{
		var d1=e1.dateEnd - e1.dateStart;
		var d2=e2.dateEnd - e2.dateStart;
		if (d2 < d1)
			return -1;
		else if (d2 > d1)
			return 1;
		else
			return 0;
	}
	else
	{
		if (e1.dateStart < e2.dateStart)
			return -1;
		else if (e1.dateStart > e2.dateStart)
			return 1;
		else
			return 0;
	}
}
Calendar.prototype.PlaceEventInRow=CalPlaceEventInRow;
function CalPlaceEventInRow(evt, irw)
{
	var span;
	var date=new Date;
	this.SetDateFromGrid(date, irw, 0);
	if (this.iperiod==2 )
		{
		if (irw !=0)	
			return;
		var quarterRow=date.getTime()/(Calendar.msHour/4);
		var quarterStart=MsFloorTime(evt.dateStart, Calendar.msHour/4, 0)/(Calendar.msHour/4) - quarterRow;
		var quarterEnd=MsFloorTime(evt.dateEnd, Calendar.msHour/4, 1)/(Calendar.msHour/4) - quarterRow;
		if (quarterEnd < quarterStart)
			quarterEnd=quarterStart;
		var workdayStart;
		var workdayEnd;
		if (this.iperiod==2 )
			{
			workdayStart=this.minQuarterStart;
			workdayEnd=this.maxQuarterEnd;
			}
		else
			{
			workdayStart=4*this.dopt.WorkDayStartHour;
			workdayEnd=4*this.dopt.WorkDayEndHour-1;
			}
		if (quarterEnd >=workdayStart && quarterStart <=workdayEnd)
			{
			if (this.FVdayOverflow)
				workdayEnd=99;
			quarterStart=Math.max(quarterStart, workdayStart);
			quarterEnd=Math.min(quarterEnd, workdayEnd);
			ichan=this.IchanNext(irw, quarterStart, quarterEnd);
			new Span(this, irw, quarterStart, quarterEnd, ichan, evt);
			}
		}
	else
		{
		var dayRow;
		var dayStart;
		var dayEnd;
		dayRow=date.getTime()/Calendar.msDay;
		dayStart=MsFloorTime(evt.dateStart, Calendar.msDay, 0)/Calendar.msDay - dayRow;
		dayEnd=MsFloorTime(evt.dateEnd, Calendar.msDay, 1)/Calendar.msDay - dayRow;
		if (dayEnd < dayStart
			|| (evt.actualDateEnd.getTime()-evt.actualDateStart.getTime()) < Calendar.msDay)
			{
			dayEnd=dayStart;
			}
		if (dayEnd >=0 && dayStart <=6)
			{
			dayStart=Math.max(dayStart, 0);
			dayEnd=Math.min(dayEnd, 6);
			ichan=this.IchanNext(irw, dayStart, dayEnd);
			new Span(this, irw, dayStart, dayEnd, ichan, evt);
			}
		}
}
function Span(cal, irw, start, end, ichan, evt)
{
	this.evt=evt;
	this.cbucket=end - start+1;
	if (cal.iperiod==2 )
		{
		evt.ichan=ichan;
		evt.ihour=start;
		var maxEnd=cal.maxQuarterEnd;
		if (maxEnd==95)	
			maxEnd=99;
		evt.rowspan=Math.min(this.cbucket, 1+maxEnd - start);
		}
	cal.mpSpan[irw+"."+start+"."+ichan]=this;
	for (bucket=start; bucket <=end; bucket++)
		{
		cal.mpIchan[irw+"."+bucket]=ichan+1;
		var rgevt=cal.mpEvents[irw+"."+bucket];
		if (rgevt==null)
			{
			rgevt=new Array;
			cal.mpEvents[irw+"."+bucket]=rgevt;
			}
		rgevt[rgevt.length]=evt;
		}
}
Calendar.prototype.IchanNext=CalIchanNext;
function CalIchanNext(irw, start, end)
{
	var bucket;
	var ichan=0;
	for (bucket=start; bucket <=end; bucket++)
		{
		if (this.mpIchan[irw+"."+bucket] !=null)
			ichan=Math.max(ichan, this.mpIchan[irw+"."+bucket]);
		}
	return ichan;
}
Calendar.prototype.IrwFromDate=CalIrwFromDate;
function CalIrwFromDate(date)
{
	var irw;
	irw=Math.floor((date.getTime() - this.dateStart.getTime())/Calendar.msWeek);
	return irw;
}
Calendar.prototype.BuildUI=CalBuildUI;
function CalBuildUI()
{
	var st=this.StBuild();
	document.write(st);
}
Calendar.prototype.StBuild=CalStBuild;
function CalStBuild()
{
	this.AssignChannels();
	if (this.fDatePicker)
		return this.StBuildPicker();
	if (!this.fUseDHTML)
		return this.StDownlevelBuild();
	return this.StBuildDHTML();
}
Calendar.prototype.StBuildDHTML=CalStBuildDHTML;
function CalStBuildDHTML()
{
	var st;
	var span;
	var dateCur=new Date;
	var irw;
	var iday;
	var ichan;
	var cchan;
	var ihour;
	var iHourStart;
	var iHourEnd;
	var iGrayStart;	
	var iGrayEnd;	
	iHourStart=iGrayStart=4*this.dopt.WorkDayStartHour;
	iHourEnd=4*this.dopt.WorkDayEndHour;
	iGrayEnd=iHourEnd - 1;
	if (this.iperiod==2 )
		{
		iHourStart=this.minQuarterStart;
		iHourEnd=this.maxQuarterEnd+1;
		if (iHourEnd==96 && this.FVdayOverflow)
			iHourEnd=100;
		}
	var stTDHigh='<th style="cursor:pointer;" onmouseover="HighlightText(this, \'red\');" onmouseout="HighlightText(this, \'\');" ';
	if (this.iperiod==2 )
		{
		cchan=this.IchanNext(0, iHourStart, iHourEnd);
		var cNoTime=this.mpNoTimeEvents.length;
		var cAllDay=this.mpAllDayEvents.length;
		cchan=Math.max(cchan, this.cchanMin);
		if (this.cchanMax > 0)
			cchan=Math.min(cchan, this.cchanMax);
		st="<table width=100% class=ms-cal cellpadding=0 cellspacing=0>";
		st+='<tr>'+stTDHigh+StClickEvent(this.stObject+'.MoveDate(-1)')+' class=ms-calhead style="cursor:pointer;" width=8%>&lt;</th><th width=84% class=ms-calhead nowrap>'+			this.StDayMonthYear()+			'</th>'+stTDHigh+StClickEvent(this.stObject+'.MoveDate(1)')+' class=ms-calhead style="cursor:pointer;" width=8%>&gt;</th></tr>';
		if (cNoTime > 0)
			{
			st+="</table><table width=100% class=ms-cal cellpadding=0 cellspacing=0>\r";
			st+="<tr height=0><td width="+(this.dopt.AllDayWidth+8)+"pt/><td/></tr>\r";
			st+="<tr><td class=ms-CalAllDay rowspan="+(cNoTime+1)+"></td><td width=1%/></tr>";
			for (i=0; i < cNoTime; i++)
				{
					evt=this.mpNoTimeEvents[i];
					st+="<tr><td class=ms-Vapptsingle style='border-top:1px solid black; border-left:1px solid black; border-bottom:1px solid black; border-right:1px solid black;' ";
					st+=" TITLE="+StAttrQuote(evt.StTip(this.dopt))+"><nobr>"+						StRenderVDayEvt(evt, this.dopt, 2)+"</nobr></td></tr>\r";
				}
			}
		if (cAllDay > 0)
			{
			st+="</table><table width=100% class=ms-cal cellpadding=0 cellspacing=0>\r";
			st+="<tr height=0><td width="+(this.dopt.AllDayWidth+8)+"pt/><td/></tr>\r";
			st+="<tr><td class=ms-CalAllDay rowspan="+(cAllDay+1)+">"+this.dopt.L_AllDay_Text+"</td><td width=1%/></tr>";
			for (i=0; i < cAllDay; i++)
				{
					evt=this.mpAllDayEvents[i];
					st+="<tr><td class=ms-Vapptsingle style='border-top:1px solid black; border-left:1px solid black; border-bottom:1px solid black; border-right:1px solid black;' ";
					st+=" TITLE="+StAttrQuote(evt.StTip(this.dopt))+"><nobr>"+						StRenderVDayEvt(evt, this.dopt, 2)+"</nobr></td></tr>\r";
				}
			}
		st+="</table><table width=100% STYLE='table-layout:fixed' class=ms-vcal cellpadding=0 cellspacing=0>\r";
		st+="<tr height=0><td width="+this.dopt.AllDayWidth+"pt/><td width=8pt/>\r";
		for (ichan=1; ichan < cchan; ichan++)
			{
				st+="<td/>\r";
			}
		st+="</tr>\r";
		var LayoutGrid=new Object;
		var HitDetect=new Array(iHourEnd);
		for (ihour=iHourStart; ihour < iHourEnd; ihour++)
			{
			HitDetect[ihour]=0;
			for (ichan=0; ichan < cchan; ichan++)
				LayoutGrid[ihour+"."+ichan]=0;
			}
		for (i=0; i < this.rgEvt.length; i++)
			{
			var evt=this.rgEvt[i];
			var ihour=evt.ihour;
			var ichan=evt.ichan;
			var rowspan=evt.rowspan;
			var max=ichan+1;
			for (irow=0; irow < rowspan; irow++)
				if (HitDetect[ihour+irow] > max)
					max=HitDetect[ihour+irow];
			for (irow=0; irow < rowspan; irow++)
				{
				HitDetect[ihour+irow]=max;
				LayoutGrid[(ihour+irow)+"."+ichan]=1;
				}
			}
		for (i=0; i < this.rgEvt.length; i++)
			{
			var width=0;
			var irow=0;
			ihour=this.rgEvt[i].ihour;
			max=HitDetect[ihour]
			rowspan=this.rgEvt[i].rowspan;
			var hit=0;
			var popMax=false;
			for (irow=1; irow < rowspan; irow++)
				{
				hit=HitDetect[ihour+irow];
				popMax |=hit !=max;
				if (hit > max)
					max=hit;
				}
			if (!popMax)
				continue;
			for (irow=0; irow < rowspan; irow++)
				HitDetect[ihour+irow]=max;
			}
		for (i=this.rgEvt.length-1; i >=0; i--)
			{
			var width=0;
			var irow=0;
			ihour=this.rgEvt[i].ihour;
			max=HitDetect[ihour]
			rowspan=this.rgEvt[i].rowspan;
			var hit=0;
			var popMax=false;
			for (irow=1; irow < rowspan; irow++)
				{
				hit=HitDetect[ihour+irow];
				popMax |=hit !=max;
				if (hit > max)
					max=hit;
				}
			if (!popMax)
				continue;
			for (irow=0; irow < rowspan; irow++)
				HitDetect[ihour+irow]=max;
			}
		for (ihour=iHourStart; ihour < iHourEnd; ihour++)
			{
			st+="<tr>\r";
			if (ihour%4==0)
				{
				var stHour=ihour/4;
				if (stHour==24)
					stHour="&nbsp;";
				else if (this.dopt.f12Hour)
					{
					stHour=((ihour/4+11)%12+1);
					if (this.dopt.TimeMarkPosn==0)
						{
						stHour+=" "+((ihour/4 < 12) ? this.dopt.stAM : this.dopt.stPM);
						}
					else
						stHour=((ihour/4 < 12) ? this.dopt.stAM : this.dopt.stPM)+" "+stHour;
					}
				var stGrayBG="";
				if ((ihour < iGrayStart || ihour > iGrayEnd))
				{
					stGrayBG=' BGCOLOR="#e6e6e6" ';
				}
				if (ihour !=iHourStart || cAllDay > 0 || cNoTime > 0)
					{
					st+="<td class=ms-CalHour rowspan=2"+stGrayBG+"><nobr>"+stHour+"</nobr></td>";
					st+="<td class=ms-calHour"+stGrayBG+">&nbsp;</td>\r";
					}
				else
					{
					st+="<td class=ms-firstCalHour rowspan=2"+stGrayBG+"><nobr>"+stHour+"</nobr></td>";
					st+="<td class=ms-firstCalHour"+stGrayBG+">&nbsp;</td>\r";
					}
				}
			else if (ihour%2==0)
				{
				st+="<td class=ms-CalHalfHour"+stGrayBG+">&nbsp;</td>\r";
				st+="<td class=ms-calHalfHour"+stGrayBG+">&nbsp;</td>\r";
				}
			else if (ihour%4==1)
				{
				st+="<td class=ms-CalQuarterHour"+stGrayBG+">&nbsp;</td>\r";
				}
			else if (ihour%4==3)
				{
				st+="<td class=ms-CalQuarterHour"+stGrayBG+">&nbsp;</td>\r";
				st+="<td class=ms-calQuarterHour"+stGrayBG+">&nbsp;</td>\r";
				}
			for (ichan=0; ichan < cchan; ichan++)
				{
				span=this.mpSpan[0+"."+ihour+"."+ichan];
				if (span !=null)
					{
					var stClass="ms-Vappt";
					var rowspan=span.evt.rowspan;
					var colspan=Math.floor(cchan / HitDetect[ihour]);
					if (colspan > cchan / this.cchanMin)
						colspan=Math.floor(cchan / this.cchanMin);
					var reduceby=colspan - 1;
					if (reduceby > 0)
						for (irow=0; irow < rowspan; irow++)
							{
							reduceby=colspan - 1;
							for (jchan=cchan-1; jchan > ichan && reduceby > 0; jchan--)
								{
								if (LayoutGrid[(ihour+irow)+"."+jchan]==0)
									{
										LayoutGrid[(ihour+irow)+"."+jchan]=1;
										reduceby--;
									}
								}
							}
					st+="<td class="+stClass+						" style='border-top:1px solid black; border-left:1px solid black; border-bottom:2px solid black; border-right:2px solid black;' rowspan="+span.evt.rowspan;
					if (colspan > 1)
						st+=" colspan="+colspan;
					st+=" TITLE="+StAttrQuote(span.evt.StTip(this.dopt))+"><nobr>"+						StRenderVDayEvt(span.evt, this.dopt, span.evt.rowspan)+"</nobr></td>\r";
					}
				else if (LayoutGrid[ihour+"."+ichan]==0)
					{
					if (ihour%4==0)
						{
						if (ihour !=iHourStart || cAllDay > 0 || cNoTime > 0)
							st+="<td class=ms-calHour"+stGrayBG+">&nbsp;</td>\r";
						else
							st+="<td class=ms-firstCalHour"+stGrayBG+">&nbsp;</td>\r";
						}
					else if (ihour%2==0)
						st+="<td class=ms-calHalfHour"+stGrayBG+">&nbsp;</td>\r";
					else
						st+="<td class=ms-calQuarterHour"+stGrayBG+">&nbsp;</td>\r";
					}
				}
			st+="</tr>\r";
			}
		st+="<tr>\r";
		for (ichan=-2; ichan < cchan; ichan++)
			{
			st+="<td class=ms-CalHour>&nbsp;</td>\r";
			}
		st+="</tr>\r";
		}
	else
		{
		var fWeekly=this.iperiod==1;
		st="<table width=100% class=ms-cal cellpadding=0 cellspacing=0>";
		st+='<tr>'+stTDHigh+StClickEvent(this.stObject+'.MoveDate(-1)')+' class=ms-calhead style="cursor:pointer;">&lt;</td><td class=ms-calhead colspan=5>';
		if (this.iperiod==0 )
			st+=this.StMonthYear();
		else
			st+=this.StDaySpanMonthYear();
		st+='</td>'+stTDHigh+StClickEvent(this.stObject+'.MoveDate(1)')+' class=ms-calhead style="cursor:pointer;">&gt;</td></tr>';
		st+="<tr>\r";
		for (iday=0; iday < 7; iday++)
			{
			st+="<td class=ms-calDOW>"+Calendar.rgDOW[(iday+this.dopt.dow)%7]+"</td>\r";
			}
		st+="</tr>";
		for (irw=0; irw < this.irwMax; irw++)
			{
			cchan=Math.max(this.IchanNext(irw, 0, 6), this.cchanMin);
			if (this.cchanMax > 0)
				cchan=Math.min(cchan, this.cchanMax);
			st+="<tr>\r";
			for (iday=0; iday < 7; iday++)
				{
				this.SetDateFromGrid(dateCur, irw, iday);
				st+='<td class=ms-calTop'+this.DayStyle(dateCur, false, true, fWeekly)+					'>&nbsp;<span style="cursor:pointer;" onmouseover="HighlightText(this, \'red\');" onmouseout="HighlightText(this, \'\');"'+StClickEvent(this.stObject+".MoveToDay("+dateCur.getUTCFullYear()+","+(dateCur.getUTCMonth()+1)+","+dateCur.getUTCDate()+")")+">"+dateCur.getUTCDate()+"</span>&nbsp;</td>\r";
				}
			st+="</tr>\r";
			for (ichan=0; ichan < cchan; ichan++)
				{
				if (this.iperiod==1 )
				{	
					st+="<tr>\r";
					for (iday=0; iday < 7; iday++)
						{
						this.SetDateFromGrid(dateCur, irw, iday);
						if (ichan==cchan-1 && this.SpanCheck(irw, iday, ichan, cchan))
							{
								st+="<td class=ms-apptsingle "+this.DayStyle(dateCur, false, false, fWeekly)+">&nbsp;</td>";
							}
						else
							{
							span=this.mpSpan[irw+"."+iday+"."+ichan];
							if (span !=null
								&& !span.evt.multiDay
								&& 0 !=span.evt.actualDateStart.getTime() % Calendar.msDay
								&& 0 !=span.evt.actualDateEnd.getTime() % Calendar.msDay)
								{
								var stClass="ms-apptsingle"+this.DayStyle(dateCur, false, false, fWeekly);
								st+="<td class="+stClass+											" colspan="+span.cbucket+" TITLE="+StAttrQuote(span.evt.StTip(this.dopt))+"><nobr>";
								st+=StEvtTime(span.evt, this.dopt, true);
								st+="&nbsp;</nobr></td>\r";
								iday+=span.cbucket - 1;
								}
							else
								{
								st+="<td class=ms-calMid"+this.DayStyle(dateCur, false, false, fWeekly)+">&nbsp;</td>\r";
								}
							}
						}
					st+="</tr>\r";
				}
				st+="<tr>\r";
				for (iday=0; iday < 7; iday++)
					{
					this.SetDateFromGrid(dateCur, irw, iday);
					if (ichan==cchan-1 && this.SpanCheck(irw, iday, ichan, cchan))
						{
							st+="<td class=ms-apptsingle "+this.DayStyle(dateCur, false, false, fWeekly)+							'><span style="cursor:pointer;" onmouseover="HighlightText(this, \'red\');" onmouseout="HighlightText(this, \'\');"'+StClickEvent(this.stObject+".MoveToDay("+dateCur.getUTCFullYear()+","+(dateCur.getUTCMonth()+1)+","+dateCur.getUTCDate()+")")+							">"+this.dopt.L_More_Text+"</span></td>\r";
						}
					else
						{
						span=this.mpSpan[irw+"."+iday+"."+ichan];
						if (span !=null)
							{
							var stClass="ms-appt";
							if (!span.evt.multiDay)
								stClass="ms-apptsingle"+this.DayStyle(dateCur, false, false, fWeekly);
							st+="<td class="+stClass+								" colspan="+span.cbucket+" TITLE="+StAttrQuote(span.evt.StTip(this.dopt))+"><nobr>"+								StURL(span.evt.stURL, span.evt.stTitle)+"</nobr></td>\r";
							iday+=span.cbucket - 1;
							}
						else
							{
							st+="<td class=ms-calMid"+this.DayStyle(dateCur, false, false, fWeekly)+">&nbsp;</td>\r";
							}
						}
					}
				st+="</tr>\r";
				st+="<tr>\r";
				if (ichan==cchan-1)
					stClass="ms-CalBot";
				else
					stClass="ms-CalSpacer";
				for (iday=0; iday < 7; iday++)
					{
					this.SetDateFromGrid(dateCur, irw, iday);
					st+="<td class="+stClass+this.DayStyle(dateCur, ichan==cchan-1, false, fWeekly)+">&nbsp;</td>\r";
					}
				st+="</tr>\r";
				}
			}
		}
	st+="</table>";
	return st;
}
Calendar.prototype.SpanCheck=CalSpanCheck;
function CalSpanCheck(irw, iday, ichan, cchan)
{
	var span;
	var i;
	var iMax;
	if (this.IchanNext(irw, iday, iday) > cchan)
		return true;
	span=this.mpSpan[irw+"."+iday+"."+ichan];
	if (span !=null)
	{
		iMax=span.cbucket+iday;
		if (iMax > 7)
			iMax=7;
		for (i=iday+1; i<iMax; i++)
		{
			if (this.IchanNext(irw, i, i) > cchan)
				return true;
		}
	}
	return false;
}
function StRenderVDayEvt(evt, dopt, rowSpan)
{
	var st="";
	st+="<table height=12px border='0' cellpadding='0' cellspacing='0' style='border-collapse: collapse; padding-right:6px' ><tr>";
	if (evt.rgIcons && evt.rgIcons.length)
	{
		var i;
		var bAllBlank=true;
		for (i in evt.rgIcons)
			if (evt.rgIcons[i] && evt.rgIcons[i].indexOf("blank.gif") < 0)
			{
				bAllBlank=false;
				break;
			}				
		if (!bAllBlank)
		{
			st+="<td valign=top nowrap>";
			for (i in evt.rgIcons)
				if (evt.rgIcons[i] && evt.rgIcons[i].length)
					st+=evt.rgIcons[i];
			st+="</td>";
		}
	}
	st+="<td nowrap>"+StURL(evt.stURL, evt.stTitle)+"</td></tr></table>";
	if (rowSpan > 2)
		st+="<nobr>"+StEvtTime(evt, dopt, false)+"</nobr>";
	if (rowSpan > 3
		&& evt.stLocation !=null)
		st+="<br><nobr>"+STSHtmlEncode(evt.stLocation)+"</nobr>";
	return st;
}
function StEvtTime(evt, dopt, fAMPM)
{
	var st="";
	if (fAMPM)
		st+=dopt.StTime(evt.actualDateStart);
	else
		st+=dopt.StBareTime(evt.actualDateStart);
	if (evt.actualDateStart.getTime() !=evt.actualDateEnd.getTime()
		&& (MsFloorTime(evt.actualDateStart, Calendar.msDay, 0)==MsFloorTime(evt.actualDateEnd, Calendar.msDay, 0)
			|| (evt.actualDateEnd.getTime() - evt.actualDateStart.getTime()) < Calendar.msDay))
		{
		st+=" - ";
		if (fAMPM)
			st+=dopt.StTime(evt.actualDateEnd);
		else
			st+=dopt.StBareTime(evt.actualDateEnd);
		}
	return st;
}
function StClickEvent(st)
{
	return 'onclick="'+st+'" ondblclick="'+st+'"';
}
var L_TodaysDate_Text="Today's date is ^1";
Calendar.prototype.StBuildPicker=CalStBuildPicker;
function CalStBuildPicker()
{
	var st;
	var dateCur=new Date;
	var dateToday=this.dopt.Today();
	var irw;
	var iday;
	var stClass;
	var ievt;
	var L_LittleRedDiamond_TXT="&loz;"; // This is the little red diamond in the calendar picker. If the diamond doesn't show up for your language you can localize it to e.g. an asterisk.
	st='<TABLE ONSELECTSTART="return false;" CLASS=ms-datepicker CELLPADDING="2" CELLSPACING="0" BORDER="1">\r';
	var stTDHigh='<td style="cursor:pointer;" onmouseover="Highlight(this, \'yellow\', \'black\');" onmouseout="Highlight(this, \'\', \'\');" ';
	st+='<tr>'+stTDHigh+StClickEvent(this.stObject+'.MoveMonth(-1)')+' class=ms-dpnextprev>&lt;</td><td class=ms-dphead colspan=5>'+		this.StMonthYear()+		'</td>'+stTDHigh+StClickEvent(this.stObject+'.MoveMonth(1)')+' class=ms-dpnextprev>&gt;</td></tr>';
	st+="<tr>\r";
	for (iday=0; iday < 7; iday++)
		{
		st+='<TD class=ms-dpdow HEIGHT="20" WIDTH="14%">'+			'&nbsp;'+Calendar.rgDOWDP[(iday+this.dopt.dow)%7]+'&nbsp;</TD>\r';
		}
	st+="</tr>\r";
	for (irw=0; irw < this.irwMax; irw++)
		{
		st+="<tr>\r";
		for (iday=0; iday < 7; iday++)
			{
			this.SetDateFromGrid(dateCur, irw, iday);
			var rgevt=this.mpEvents[irw+"."+iday];
			var fHasEvent=(rgevt !=null);
			var yr=dateCur.getUTCFullYear();
			var mon=dateCur.getUTCMonth();
			var day=dateCur.getUTCDate();
			st+=stTDHigh+StClickEvent(this.stObject+'.ClickDay('+yr+','+mon+','+day+')');
			if (fHasEvent)
				{
				var stTips="";
				for (ievt=0; ievt < rgevt.length; ievt++)
					{
					stTips+=rgevt[ievt].StTip(this.dopt);
					if (ievt < rgevt.length-1)
						stTips+="\r";
					}
				st+=" TITLE="+StAttrQuote(stTips);
				}
			st+=' WIDTH="14%"'+				this.DPDayStyle(dateCur, fHasEvent)+'>&nbsp;'+(fHasEvent ? "<b>" : "")+				dateCur.getUTCDate()+(fHasEvent ? "</b>" : "")+				(dateCur.getTime()==dateToday.getTime() ? "<font color=red>"+L_LittleRedDiamond_TXT+"</font>" : "&nbsp;");
			st+='</TD>\r';
			}
		st+="</tr>\r";
		}
	var stTodayLink="<A HREF='javascript:"+this.stObject+".SetDate("+dateToday.getUTCFullYear()+","+		dateToday.getUTCMonth()+","+dateToday.getUTCDate()+");'>"+this.dopt.StDate(dateToday)+"</A>";
	st+="<tr><td class=ms-DPFoot colspan=7><font color=red>&loz;</font>"+		StBuildParam(L_TodaysDate_Text, stTodayLink)+"</td></tr>";
	st+="</table>";
	return st;
}
Calendar.prototype.MoveDate=CalMoveDate;
function CalMoveDate(delta)
{
	if(this.iperiod==2 )
		this.MoveVDay(delta);
	else if (this.iperiod==1 )
		this.MoveWeek(delta);
	else
		this.MoveMonth(delta);
}
Calendar.prototype.MoveMonth=CalMoveMonth;
function CalMoveMonth(dmon)
{
	var stURL;
	var mon=this.givenDate.getUTCFullYear() * 12+this.givenDate.getUTCMonth()+dmon;
	var yr=Math.floor(mon / 12);
	mon=mon % 12;
	if (dmon !=0)
		stURL=StURLSetVar("CalendarDate", yr+"-"+St2Digits(mon+1)+"-1");
	else
		stURL=StURLSetVar("CalendarDate", yr+"-"+St2Digits(mon+1)+"-"+(this.givenDate.getUTCDate()));
	stURL=StURLSetVar2(stURL, "CalendarPeriod", "month");
	this.Post(stURL);
}
Calendar.prototype.MoveWeek=CalMoveWeek;
function CalMoveWeek(dweek)
{
	var stURL;
	var date=this.givenDate;
	date.setUTCDate(this.givenDate.getUTCDate()+7*dweek);
	stURL=StURLSetVar("CalendarDate", date.getUTCFullYear()+"-"+St2Digits(date.getUTCMonth()+1)+"-"+(date.getUTCDate()));
	stURL=StURLSetVar2(stURL, "CalendarPeriod", "week");
	this.Post(stURL);
}
Calendar.prototype.MoveDay=CalMoveDay;
Calendar.prototype.MoveVDay=CalMoveDay;
function CalMoveDay(dday)
{
	var stURL;
	var date=this.givenDate;
	date.setUTCDate(this.givenDate.getUTCDate()+dday);
	stURL=StURLSetVar("CalendarDate", date.getUTCFullYear()+"-"+St2Digits(date.getUTCMonth()+1)+"-"+(date.getUTCDate()));
	stURL=StURLSetVar2(stURL, "CalendarPeriod", "day");
	this.Post(stURL);
}
Calendar.prototype.MoveToDay=CalMoveToDay;
function CalMoveToDay(yr, mon, day)
{
	var stURL;
	stURL=StURLSetVar("CalendarDate", yr+"-"+St2Digits(mon)+"-"+day);
	stURL=StURLSetVar2(stURL, "CalendarPeriod", "day");
	this.Post(stURL);
}
Calendar.prototype.MoveToToday=CalMoveToToday;
function CalMoveToToday()
{
	var date=this.dopt.Today();
	var stURL=StURLSetVar("CalendarDate", date.getUTCFullYear()+"-"+St2Digits(date.getUTCMonth()+1)+"-"+date.getUTCDate());
	this.Post(stURL);
}
Calendar.prototype.Post=CalDoPost;
function CalDoPost(stURL)
{
	if (this.stViewID && this.stViewID.length)
		stURL=StURLSetVar2(stURL, "View", this.stViewID);
	SubmitFormPost(stURL);
}
function EditSeries(stEditURL)
{
	var stID="";
	if (stEditURL)
		stID=StSearchVar(stEditURL, "ID");
	else
		stID=StURLGetVar("ID");
	if (stID.length)
	{
		var iOccurDate=stID.indexOf(".0.");
		if (iOccurDate > 0)
		{
			var stURL="";
			if (stEditURL)
			{
				stURL=window.location.href;
				var ichQ=stURL.indexOf("?");
				if (ichQ > 0)
					stEditURL+=stURL.substring(ichQ, stURL.length);
				stURL=StURLSetVar2(stEditURL, "ID", stID.substr(0, iOccurDate));
			}
			else
				stURL=StURLSetVar("ID", stID.substr(0, iOccurDate));
			window.location.href=stURL;
		}
	}
}
function EditSeriesID(stMasterID, stEditURL)
{
	if (stMasterID.length)
	{
		var stURL="";
		if (stEditURL)
		{
			stURL=window.location.href;
			var ichQ=stURL.indexOf("?");
			if (ichQ > 0)
				stEditURL+=stURL.substring(ichQ, stURL.length);
			stURL=StURLSetVar2(stEditURL, "ID", stMasterID);
		}
		else
			stURL=StURLSetVar("ID", stMasterID);
		window.location.href=stURL;
	}
}
function StURLSetVar(stVar, stValue)
{
	return StURLSetVar2(window.location.href, stVar, stValue);
}
function StViewURLSetVar(viewPage, stVar, stValue)
{
	stUrl=window.location.href;
	p1=stUrl.lastIndexOf("/");
	if (p1 > 0)
		stUrl=stUrl.substring(0, p1+1)+viewPage;
	return StURLSetVar2(stUrl, stVar, stValue);
}
function StURLSetVar2(stURL, stVar, stValue)
{
	var stNewSet=stVar+"="+stValue;
	var ichQ=stURL.indexOf("?");
	if (ichQ !=-1)
		{
		var ich=stURL.indexOf("?"+stVar+"=", ichQ);
		if (ich==-1)
			{
			ich=stURL.indexOf("&"+stVar+"=", ichQ);
			if (ich !=-1)
				stNewSet="&"+stNewSet;
			}
		else
			{
			stNewSet="?"+stNewSet;
			}
		if (ich !=-1)
			{
			var re=new RegExp("[&?]"+stVar+"=[^&]*", "");
			stURL=stURL.replace(re, stNewSet);
			}
		else
			{
			stURL=stURL+"&"+stNewSet;
			}
		}
	else
		stURL=stURL+"?"+stNewSet;
	return stURL;
}
function StURLGetVar(stVar)
{
	var stURL=document.location.href;
	return StSearchVar(stURL, stVar);
}
function StSearchVar(st, stVar)
{
	var re=new RegExp("[?&]"+stVar+"=", "g");
	var ich=st.search(re);
	if (ich==-1)
		return "";
	ich+=stVar.length+2;
	var ichEnd=st.indexOf("&", ich+1);
	if (ichEnd==-1)
		ichEnd=st.length;
	var stValue=st.substring(ich, ichEnd);
	return stValue;
}
function HighlightText(elt, stText)
{
	if (stText !="")
		{
		elt.colorTextSav=elt.style.color;
		elt.style.color=stText;
		}
	else
		{
		elt.style.color=elt.colorTextSav;
		}
}
function Highlight(elt, stHighlight, stText)
{
	if (stHighlight !="")
		{
		elt.colorBackSav=elt.style.backgroundColor;
		elt.colorTextSav=elt.style.color;
		elt.style.backgroundColor=stHighlight;
		elt.style.color=stText;
		}
	else
		{
		elt.style.backgroundColor=elt.colorBackSav;
		elt.style.color=elt.colorTextSav;
		}
}
Calendar.prototype.DPDayStyle=CalDPDayStyle;
function CalDPDayStyle(dateCur, fHasEvent)
{
	var st="";
	if (dateCur.getTime()==this.dateDP.getTime())
		st+=" class=ms-dpselectedday";
	else if (dateCur.getUTCMonth() !=this.mon)
		st+=" class=ms-dpnonmonth";
	else
		st+=" class=ms-dpday";
	if (fHasEvent)
		{
		st+=' style:"font-weight: bold;"';
		}
	return st;
}
Calendar.prototype.StDownlevelBuild=CalStDownlevelBuild;
function CalStDownlevelBuild()
{
	var st;
	var dateCur=new Date;
	var irw;
	var iday;
	var stClass;
	var ievt;
	st='<TABLE CELLPADDING="2" CELLSPACING="0" WIDTH="100%" BORDER="1">\r';
	st+='<TR><TD class=ms-calhead><A class=ms-calhead TARGET=_self HREF="javascript:'+this.stObject+'.MoveDate(-1);"><B>&lt;</B></A></TD><TD class=ms-calhead colspan=5>'+		this.StMonthYear()+		'</TD><TD class=ms-calhead><A class=ms-calhead TARGET=_self HREF="javascript:'+this.stObject+'.MoveDate(1);"><B>&gt;</B></A></TD></TR>';
	st+="<tr>\r";
	for (iday=0; iday < 7; iday++)
		{
		st+='<TD class=ms-calDOWDown HEIGHT="20" WIDTH="14%">'+			'&nbsp;'+Calendar.rgDOW[(iday+this.dopt.dow)%7]+"&nbsp;</TD>\r";
		}
	st+="</tr>\r";
	for (irw=0; irw < this.irwMax; irw++)
		{
		st+="<tr>\r";
		for (iday=0; iday < 7; iday++)
			{
			this.SetDateFromGrid(dateCur, irw, iday);
			st+='<TD class=ms-calDown HEIGHT="80" WIDTH="14%"'+				this.DayStyle(dateCur)+'>&nbsp;'+dateCur.getUTCDate()+"&nbsp;<br>\r";
			var rgevt=this.mpEvents[irw+"."+iday];
			if (rgevt !=null)
				{
				for (ievt=0; ievt < rgevt.length; ievt++)
					{
					st+=StURL(rgevt[ievt].stURL, rgevt[ievt].stTitle)+'<br>\r';
					}
				}
			st+='</TD>';
			}
		st+="</tr>\r";
		}
	st+="</table>";
	return st;
}
Calendar.prototype.SetDateFromGrid=CalSetDateFromGrid;
function CalSetDateFromGrid(date, irw, iday)
{
	date.setTime(this.dateStart.getTime()+irw * Calendar.msWeek+		iday*Calendar.msDay);
}
var L_NoTitle_Text="(No Title)";
function CalEvent(dateStart, dateEnd, actualDateStart, actualDateEnd, stLocation, stDesc, stTitle, stURL, rgIcons)
{
	this.dateStart=dateStart;
	this.dateEnd=dateEnd;
	this.actualDateStart=actualDateStart;
	this.actualDateEnd=actualDateEnd;
	this.stLocation=stLocation;
	this.stDesc=stDesc;
	this.stTitle=stTitle;
	if (stTitle.length==0)
		this.stTitle=L_NoTitle_Text;
	this.stURL=stURL;
	this.rgIcons=rgIcons;
	var start;
	var end;
	var dayStart=MsFloorTime(dateStart, Calendar.msDay, 0);
	var dayEnd=MsFloorTime(dateEnd, Calendar.msDay, 1);
	if (dayStart < dayEnd
		&& (actualDateEnd.getTime() - actualDateStart.getTime()) >=Calendar.msDay)
	{
		this.multiDay=true;
	}
	else
		this.multiDay=false;
	var quarterStart=MsFloorTime(dateStart, Calendar.msHour/4, 0);
	var quarterEnd=MsFloorTime(dateEnd, Calendar.msHour/4, 1);
	if (quarterStart < quarterEnd)
		this.multiQuarter=true;
}
CalEvent.prototype.FOverlap=EvtFOverlap;
function EvtFOverlap(evt)
{
	return evt.dateStart <=this.dateEnd && evt.dateEnd >=this.dateStart;
}
var L_Tip_Text="^1: ^2";
CalEvent.prototype.StTip=EvtStTip;
function EvtStTip(dopt)
{
	var stT;
	var stTime=StEvtTime(this, dopt, true);
	if (DateOptions.FHasTime(this.actualDateStart) || DateOptions.FHasTime(this.actualDateEnd))
		stT=StBuildParam(L_Tip_Text, stTime, this.stTitle);
	else
		stT=this.stTitle;
	if (!FBlankString(this.stLocation))
		stT+="\r"+this.stLocation;
	if (!FBlankString(this.stDesc))
		stT+="\r"+this.stDesc;
	return stT;
}
var L_strExpand_Text="Expand";
var L_strCollapse_Text="Collapse";
function DiscussionBoard(flag, id)
{
	if (!Array.prototype.push)
	{
		function array_push()
		{
			for (var i=0; i < arguments.length; i++)
				this[this.length]=arguments[i];
			return this.length;
		}
		Array.prototype.push=array_push;
	}
	this.id=id;
	this.name="board"+id;
	this.rootPosts=new Array();
	this.allPosts=new Array();
	this.lastInsert=0;
	this.lastNode=0;
	this.expanded=false;
	this.threaded=flag;
	this.initialized=false;
	this.widgetBaseSrc=null;
	this.init=function()
	{
		this.mainTable=document.getElementById(this.id);
		var childAnchors=this.mainTable.getElementsByTagName("A");
		if(this.threaded)
		{
			for (var counter=0; counter < childAnchors.length; counter++)
			{
				if (childAnchors[counter].name=="post")
					this.insert(new Post(childAnchors[counter], this));
			}
			this.setReplyCountAndIndent();
		} else
		{
			for (var counter=0; counter < childAnchors.length; counter++)
			{
				if (childAnchors[counter].name=="post")
					this.allPosts.push(new Post(childAnchors[counter], this));
			}
		}
		this.initialized=true;
	}
	this.setReplyCountAndIndent=function()
	{
		var nextRoot;
		for(var counter=0; counter < this.rootPosts.length; counter++)
		{
			nextRoot=this.rootPosts[counter];
			nextRoot.setReplyCountAndIndent(true);
		}
	}
	this.insert=function(newNode)
	{
		var nextRoot;
		for(var counter=this.lastInsert; counter < this.rootPosts.length; counter++)
		{
			nextRoot=this.rootPosts[counter];
			if((newNode.id.indexOf(nextRoot.id)==0) && (newNode.id !=nextRoot.id))
			{
				newNode.hide();
				return nextRoot.insert(newNode);
			} else
				this.lastInsert++;
		}
		this.rootPosts.push(newNode);
	}
	this.retrieve=function(id, guid)
	{
		if(this.threaded)
		{
			var nextRoot;
			var node;
			for(var counter=0; counter < this.rootPosts.length; counter++)
			{
				nextRoot=this.rootPosts[counter];
				if(id.indexOf(nextRoot.id)==0)
					if((node=nextRoot.retrieve(id, guid)) !=-1)
						return node;
			}
		} else
		{
			var nextPost;
			for(var counter=0; counter < this.allPosts.length; counter++)
			{
				nextPost=this.allPosts[counter];
				if((id==nextPost.id) && (guid==nextPost.guid))
					return nextPost;
			}
		}
		return -1;
	}
	 this.expandCollapse=function()
	{
		if(!this.initialized)
			return false;
		if(this.expanded)
		{
			var nextRoot;
			for(var counter=0; counter < this.rootPosts.length; counter++)
			{
				nextRoot=this.rootPosts[counter];
				nextRoot.hideTextAndChildren();
			}
			this.expanded=false;
		}
		else
		{
			var nextRoot;
			for(var counter=0; counter < this.rootPosts.length; counter++)
			{
				nextRoot=this.rootPosts[counter];
				nextRoot.showTextAndChildren(true);
			}
			this.expanded=true;
		}
	}
	this.handleClicks=function(evt)
	{
		if(!this.initialized)
			return true;
		evt=(evt) ? evt : ((window.event) ? window.event : "");
		if (evt)
		{
			var elem;
			if (evt.target)
				elem=evt.target;
			else
				elem=evt.srcElement;
			if (evt.type=="keydown")
			{
			   if (String.fromCharCode(evt.keyCode)=='\r')
					elem=elem.firstChild;
				else
					return true;
			}
			if (elem)
			{
				if(elem.name && ("widget"==elem.name.valueOf()))
				{
					srcPath=elem.getAttribute("src");
					if(srcPath)
					{
						index=srcPath.lastIndexOf("/");
						imgName=srcPath.slice(index+1);
						if ((imgName.valueOf()=="discbul.gif") || ((imgName.valueOf()!="plus.gif") && (imgName.valueOf()!="minus.gif")))
							return true;
						var node;
						var action;
						if((evt.type=="click") || (evt.type=="keydown"))
						{
							node=this.retrieve(elem.id, elem.parentNode.parentNode.parentNode.parentNode.parentNode.getAttribute("PostID"));
							this.lastNode=node;
							action=(imgName.valueOf()=="plus.gif") ? "expand" : "collapse";
						} else if(evt.type=="dblclick")
						{
							node=this.lastNode;
							action=(imgName.valueOf()=="plus.gif") ? "collapse" : "expandRecursively";
						}
						switch(action)
						{
							case "expand":
								if(this.threaded)
									node.showTextAndChildren(false);
								else
									node.showText();
								break;
							case "expandRecursively":
								if(this.threaded)
									node.showTextAndChildren(true);
								else
									node.showText();
								break;
							case "collapse":
								if(this.threaded)
								{
									node.hideTextAndChildren();
									this.expanded=false;
								}
								else
									node.hideText();
								break;
						}
					}
			   }
			}
		}
		return true;
	}
}
function Post(elem, discussionBoard)
{
	this.board=discussionBoard;
	this.depth=0;
	this.replyCount=0;
	this.lastInsert=0;
	this.childNodes=new Array();
	this.anchor=elem;
	this.widget=elem.firstChild;
	this.widgetPadding=this.widget.parentNode.parentNode;
	if(!this.board.widgetBaseSrc)
	{
		currentWidgetSrcPath=this.widget.getAttribute("src");
		marker=currentWidgetSrcPath.lastIndexOf("/");
		this.board.widgetBaseSrc=currentWidgetSrcPath.slice(0,marker+1);
	}
	this.id=this.widget.id;
	this.guid=this.widgetPadding.parentNode.parentNode.parentNode.getAttribute("PostID");
	if(this.board.threaded)
	{
		this.indent=elem.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.firstChild;
		if (browseris.ie && !browseris.mac)
			this.body=this.indent.parentNode.childNodes[1].childNodes[1];
		else
			this.body=this.indent.parentNode.childNodes[1].childNodes[2];
		this.row=this.indent.parentNode.parentNode.parentNode.parentNode.parentNode;
		this.reply=this.row.childNodes[1];
		this.bodyPadding=this.body.firstChild.firstChild.firstChild;
		this.bodyPadding.setAttribute("width",8);
	} else
		this.body=elem.parentNode.parentNode.parentNode.parentNode.parentNode.childNodes[1];
	this.insert=function(newNode)
	{
		this.replyCount++;
		newNode.depth++;
		var nextChild;
		for(var counter=this.lastInsert; counter < this.childNodes.length; counter++)
		{
			nextChild=this.childNodes[counter];
			if((newNode.id.indexOf(nextChild.id)==0) && (newNode.id !=nextChild.id))
				return nextChild.insert(newNode);
			else
				this.lastInsert++;
		}
		this.childNodes.push(newNode);
	}
	this.retrieve=function(id, guid)
	{
		var nextChild;
		var node;
		for(var counter=0; counter < this.childNodes.length; counter++)
		{
			nextChild=this.childNodes[counter];
			if(id.indexOf(nextChild.id)==0)
				if((node=nextChild.retrieve(id, guid)) !=-1)
					return node;
		}
		if (this.guid==guid)
			return this;
		else
			return -1;
	}
	this.show=function ()
	{
		this.row.style.display="";
	}
	this.hide=function ()
	{
		this.row.style.display="none";
	}
	this.showTextThreaded=function()
	{
		this.show();
		this.widget.src=this.board.widgetBaseSrc+"minus.gif";
		this.widget.alt=L_strCollapse_Text;
		this.body.style.display="";
	}
	this.showText=function()
	{
		this.widget.src=this.board.widgetBaseSrc+"minus.gif";
		this.widget.alt=L_strCollapse_Text;
		this.body.style.display="";
	}
	this.hideText=function ()
	{
		this.widget.src=this.board.widgetBaseSrc+"plus.gif";
		this.widget.alt=L_strExpand_Text;
		if (browseris.nav6)
			this.body.setAttribute('style', 'display: none');
		else
			this.body.style.display="none";
	}
	this.showTextAndChildren=function(recurse)
	{
		this.showTextThreaded();
		if(recurse)
		{
			var nextChild;
			for(var counter=0; counter < this.childNodes.length; counter++)
			{
				nextChild=this.childNodes[counter];
				nextChild.showTextAndChildren(recurse);
			}
		} else
		{
			var nextChild;
			for(var counter=0; counter < this.childNodes.length; counter++)
			{
				nextChild=this.childNodes[counter];
				nextChild.show();
			}
		}
	}
	this.hideTextAndChildren=function()
	{
		this.hideText();
		var nextChild;
		for(var counter=0; counter < this.childNodes.length; counter++)
		{
			nextChild=this.childNodes[counter];
			nextChild.hide()
			nextChild.hideTextAndChildren();
		}
	}
	this.setReplyCountAndIndent=function(recurse)
	{
		this.reply.innerHTML=this.replyCount;
		this.indent.setAttribute("width",this.depth*16);
		if(recurse)
		{
			var nextChild;
			for(var counter=0; counter < this.childNodes.length; counter++)
			{
				nextChild=this.childNodes[counter];
				nextChild.setReplyCountAndIndent(recurse);
			}
		}
	}
	this.hideText();
	this.widget.parentNode.style.cursor='hand';
	this.widgetPadding.style.paddingTop='2px';
}
function FormTabIndex()
{
	if (window.formTabIndex) {
		if (formTabIndex==-1)
			return "";
		return "tabindex="+formTabIndex;
	}
	return "tabindex=1";
}
function IntlDate(yr, mon, day, hr, min, sec,  caltype)
{
	this.yr=yr;
	this.mon=mon;
	this.day=day;
	this.hr=hr;
	this.min=min;
	this.sec=sec;
	this.caltype=caltype;
}
IntlDate.prototype.valueOf=toIntlValue;
function toIntlValue()
{
	var status=0;
	var maxMonth=11;
	if ((this.caltype==6 || this.caltype==8) && (this.day < 1 || this.day > 30))
		status=Number.NaN;
	if (this.caltype==8)
		if ((((this.yr * 7)+1) % 19) < 7)
			maxMonth=12;
	if (this.mon < 0 || this.mon > maxMonth)
		status=Number.NaN;
	if(this.caltype==7)
	{
		var date=new Date(Date.UTC(this.yr-543, this.mon, this.day));
		if ((this.yr-543) !=date.getUTCFullYear() || this.mon !=date.getUTCMonth() || this.day !=date.getUTCDate())
			status=Number.NaN;
	}
	return status;
}
IntlDate.prototype.setUTCHours=setIntlHours;
function setIntlHours(hr, min, sec, msec)
{
	if (!min) min=0;
	if (!sec) sec=0;
	this.hr=hr;
	this.min=min;
	this.sec=sec;
}
IntlDate.prototype.setSeconds=setIntlSeconds;
function setIntlSeconds(sec)
{
	this.sec=sec;
}
IntlDate.prototype.setTime=setIntlTime;
function setIntlTime(msec)
{
	var date=new Date(msec);
	this.yr=date.getFullYear();
	this.mon=date.getMonth();
	this.day=date.getDate();
	this.hr=date.getHours();
	this.min=date.getMinutes();
	this.sec=date.getSeconds();
}
IntlDate.prototype.getUTCFullYear=getIntlFullYear;
function getIntlFullYear()
{
	return this.yr;
}
IntlDate.prototype.getUTCMonth=getIntlMonth;
function getIntlMonth()
{
	return this.mon;
}
IntlDate.prototype.getUTCDate=getIntlDate;
function getIntlDate()
{
	return this.day;
}
IntlDate.prototype.getUTCHours=getIntlHours;
function getIntlHours()
{
	return this.hr;
}
IntlDate.prototype.getUTCMinutes=getIntlMinutes;
function getIntlMinutes()
{
	return this.min;
}
IntlDate.prototype.getUTCSeconds=getIntlSeconds;
function getIntlSeconds()
{
	return this.sec;
}
IntlDate.prototype.getTime=getIntlTime;
function getIntlTime()
{
	var date=new Date(this.yr, this.mon, this.day, this.hr, this.min, this.sec);
	return date.getTime();
}
function DateOptions()
{
	var L_strAllDay_Text="All Day";
	var L_strMore_Text="more...";
	var strMore=L_strMore_Text;
	var strAllDay=L_strAllDay_Text;
	var L_AllDayWidth_Text=54;	
	var L_StrAM_Text="am";
	var L_StrPM_Text="pm";
	this.stDateOrder="MDY";
	this.f12Hour=true;
	this.stAM=L_StrAM_Text;
	this.stPM=L_StrPM_Text;
	this.TimeMarkPosn=0;
	this.dminControl=5;
	this.chDateSep="/";
	this.chTimeSep=":";
	this.dyrWindow=30;
	this.dow=0;
	this.webTZOffsetMin=0;
	this.WorkDayStartHour=8;
	this.WorkDayEndHour=17;
	this.DailyStartHourDelta=1;	
	this.DailyEndHourDelta=4;
	this.CalendarPeriod="month"
	this.L_AllDay_Text=strAllDay;
	this.AllDayWidth=L_AllDayWidth_Text;
	this.L_More_Text=strMore;
}
DateOptions.prototype.SetTimeFormat=DOSetTimeFormat;
function DOSetTimeFormat(w)
{
	this.f12Hour=(w==0);
}
DateOptions.prototype.SetDateOrder=DOSetDateOrder;
function DOSetDateOrder(w)
{
	switch (w)
		{
	case 0:
		this.stDateOrder="MDY";
		break;
	case 1:
		this.stDateOrder="DMY";
		break;
	case 2:
		this.stDateOrder="YMD";
		break;
		}
}
DateOptions.prototype.SetDOW=DOSetDOW;
function DOSetDOW(dow)
{
	this.dow=(dow+1)%7;
}
DateOptions.prototype.ParseLocaleDate=DOParseLocaleDate;
function DOParseLocaleDate(stDate, caltype)
{
	var chSep=this.chDateSep;
	var ord=this.stDateOrder;
	var ichSlash1=stDate.indexOf(chSep);
	var num1;
	var num2;
	var num3;
	var mon;
	var day;
	var yr;
	if (ichSlash1 < 0)
		{
		chSep="/";
		ichSlash1=stDate.indexOf(chSep);
		if (ichSlash1 < 0)
			{
			chSep="-";
			ichSlash1=stDate.indexOf(chSep);
			}
		}
	if (ichSlash1 < 0)
		return Number.NaN;
	var ichSlash2=stDate.indexOf(chSep, ichSlash1+1);
	num1=stDate.substr(0, ichSlash1) - 0;
	if (ichSlash2 < 0)
		{
		if (caltype !=1)
			return Number.NaN;
		ichSlash2=stDate.length;
		var date=this.Today();
		num3=date.getUTCFullYear();
		if (ord=="YMD")
			ord="MDY";
		}
	else
		{
		num3=stDate.substr(ichSlash2+1) - 0;
		}
	num2=stDate.substr(ichSlash1+1, ichSlash2 - ichSlash1 - 1) - 0;
	if (isNaN(num1) || isNaN(num3) || isNaN(num3))
		return Number.NaN;
	var yrLen;
	switch (ord)
		{
	case "DMY":
		day=num1;
		mon=num2;
		yr=num3;
		yrLen=stDate.length - ichSlash2 - 1;
		break;
	case "YMD":
		yr=num1;
		yrLen=ichSlash1;
		mon=num2;
		day=num3;
		break;
	case "MDY":
		mon=num1;
		day=num2;
		yr=num3;
		yrLen=stDate.length - ichSlash2 - 1;
		break;
		}
	if (yr < 0)
		return Number.NaN;
	if (yrLen < 3)
		yr=this.YrWindow(yr, caltype);
	mon=mon-1;
	   var yrMin=1900;	
	   var yrMax=8900;
	   switch (caltype)
	   {
	   case 6:
			yrMin=1319;
			yrMax=3481;
			break;
	   case 7:
			yrMin=2444;
			yrMax=5043;
			break;
	   case 8:
			yrMin=5662;
			yrMax=5998;
			break;
	   case 16:
			yrMin=1823;
			yrMax=3920;
			break;
	   }
	var minCalGregorian=caltype==1 && yr==1899 && mon==11 && day==31;
	if ((yr < yrMin || yr > yrMax) && !minCalGregorian)
	{
		return Number.NaN;
	}
	switch(caltype)
		{
		case 6:
		case 7:
		case 8:
			var date=this.DateIntlYMD(yr, mon, day, caltype);
			break;
		default:
			var date=this.DateYMD(yr, mon, day);
			break;
		}
	return date;
}
DateOptions.prototype.DateYMD=DODateYMD;
function DODateYMD(yr, mon, day)
{
	if (isNaN(yr) || isNaN(mon) || isNaN(day))
		return Number.NaN;
	var date=new Date(Date.UTC(yr, mon, day));
	if (yr !=date.getUTCFullYear() || mon !=date.getUTCMonth() ||
		day !=date.getUTCDate())
		return Number.NaN;
	return date;
}
DateOptions.prototype.DateIntlYMD=DODateIntlYMD;
function DODateIntlYMD(yr, mon, day, caltype)
{
	if (isNaN(yr) || isNaN(mon) || isNaN(day))
		return Number.NaN;
	var date=new IntlDate(yr, mon, day, 0, 0, 0, caltype);
	return date;
}
DateOptions.prototype.YrWindow=DOYrWindow;
function DOYrWindow(st, caltype)
{
	var yr=st - 0;
	if (isNaN(yr))
		return st;
	if (st < 100)
	{
		switch(caltype)
		{
		case 1:
		    var date=this.Today();
		    var yrCur=date.getUTCFullYear();
		    yr+=WMultiple(yrCur, 100);
		    if (yr > yrCur+this.dyrWindow)
			    yr -=100;
		    else if (yr < yrCur+this.dyrWindow - 100)
			    yr+=100;
		    break;
		case 6:
		    if(yr < 52)
		    	yr+=1400;
		    else
		    	yr+=1300;
		    break;			
		case 7:
		    if(yr < 73)
		    	yr+=2500;
		    else
		    	yr+=2400;
		    break;			
		case 8:
		    if(yr < 91)
		    	yr+=5700;
		    else
		    	yr+=5600;
		    break;			
		case 16:
		    if(yr < 52)
		    	yr+=1900;
		    else
		    	yr+=1800;
		    break;			
		}
		return yr;		
	}
	return st;
}
DateOptions.prototype.StDate=DOStDate;
function DOStDate(date)
{
	return this.StDateString(date.getUTCFullYear(), date.getUTCMonth()+1, date.getUTCDate());
}
DateOptions.prototype.StDateString=DOStDateString;
function DOStDateString(yr, mon, day)
{
	var st;
	switch (this.stDateOrder)
		{
	case "MDY":
		st=mon+this.chDateSep+day+this.chDateSep+yr;
		break;
	case "DMY":
		st=day+this.chDateSep+mon+this.chDateSep+yr;
		break;
	case "YMD":
		st=yr+this.chDateSep+mon+this.chDateSep+day;
		break;
		}
	return st;
}
DateOptions.prototype.StTime=DOStTime;
function DOStTime(date)
{
	var stSuff="";
	var hr=date.getUTCHours();
	var min=date.getUTCMinutes();
	if (this.f12Hour)
		{
		if (hr >=12)
			{
			stSuff=this.stPM;
			if (hr > 12)
				hr -=12;
			}
		else
			{
			if (hr==0)
				hr=12;
			stSuff=this.stAM;
			}
		}
	if(this.TimeMarkPosn==0)
		return hr+this.chTimeSep+St2Digits(min)+" "+stSuff;
	else
		return stSuff+" "+hr+this.chTimeSep+St2Digits(min);
}
DateOptions.prototype.StBareTime=DOStBareTime;
function DOStBareTime(date)
{
	var stSuff="";
	var hr=date.getUTCHours();
	var min=date.getUTCMinutes();
	if (this.f12Hour)
		{
		if (hr >=12)
			{
			if (hr > 12)
				hr -=12;
			}
		else
			{
			if (hr==0)
				hr=12;
			}
		}
	return hr+this.chTimeSep+St2Digits(min);
}
DateOptions.FHasTime=DOFHasTime;
function DOFHasTime(date)
{
	var hr=date.getUTCHours();
	var min=date.getUTCMinutes();
	return (hr !=0 || min !=0);
}
DateOptions.prototype.StTimeControls=DOStTimeControls;
function DOStTimeControls(fld, date)
{
	var st;
	var hr=date.getUTCHours();
	var min=date.getUTCMinutes();
	var hrT;
	var hrTT;
	var stSuff="";
	var hrMax;
	var fPM;
	var L_Hours_Text="Hours";
	var L_Minutes_Text="Minutes";
	var L_Time_Text=":";
	var L_MinutesTime_Text="";
	var L_SmallHour_Text="0";
	st="<span dir=ltr><SELECT TITLE='"+L_Hours_Text+"' "+FormTabIndex()+" class='ms-input' NAME="+StAttrQuote(fld.frm.StFieldName(fld, "Hours"))+">\r";
	for (hrT=0; hrT < 24; hrT++)
		{
		if (hrT==hr)
			stSelected=" SELECTED";
		else
			stSelected="";
		st+="<OPTION VALUE="+hrT+stSelected+">";
		hrTT=hrT;
		if (this.f12Hour)
			{
			if (hrT < 12)
				{
				stSuff=this.stAM;
				}
			else
				{
				stSuff=this.stPM;
				hrTT -=12;
				}
			if (hrTT==0)
				hrTT=12;
			if (this.TimeMarkPosn==0)
				st+=hrTT+" "+stSuff+"\r";
			else
				st+=stSuff+" "+hrTT+"\r";
			}
		else
			{
			if (hrT < 10)
				st+=L_SmallHour_Text;
			st+=hrTT+L_Time_Text+"\r";
			}
		}
	st+="</SELECT>\r";
	st+="&nbsp;<SELECT TITLE='"+L_Minutes_Text+"' "+FormTabIndex()+" NAME="+StAttrQuote(fld.frm.StFieldName(fld, "Minutes"))+">\r";
	min=WMultiple(min, this.dminControl);
	for (minT=0; minT < 60; minT+=this.dminControl)
		{
		if (minT==min)
			stSelected=" Selected=True";
		else
			stSelected="";
		st+="<OPTION VALUE="+minT+stSelected+">";
		st+=St2Digits(minT)+L_MinutesTime_Text+"\r";
		}
	st+="</SELECT></span>\r";
	return st;
}
DateOptions.prototype.SetTimeControls=DOSetTimeControls;
function DOSetTimeControls(fld, date)
{
	var fieldHours=fld.frm.FieldSubPart(fld, "Hours");
	var fieldMinutes=fld.frm.FieldSubPart(fld, "Minutes");
	var hr=date.getUTCHours();
	var min=date.getUTCMinutes();
	var fPM;
	min=WMultiple(min, this.dminControl);
	fieldHours.selectedIndex=hr;
	fieldMinutes.selectedIndex=min/this.dminControl;
}
DateOptions.prototype.Today=DOToday;
function DOToday()
{
	var date=this.Now();
	date.setUTCHours(0,0,0,0);
	return date;
}
DateOptions.prototype.Now=DONow;
function DONow()
{
	var date=new Date();
	date.setTime(date.getTime() - this.webTZOffsetMin * DateOptions.msMinute);
	return date;
}
DateOptions.ClientToday=DOClientToday;
function DOClientToday()
{
	var date=DateOptions.ClientNow();
	date.setUTCHours(0,0,0,0);
	return date;
}
DateOptions.ClientNow=DOClientNow;
function DOClientNow()
{
	var date=new Date();
	date.setTime(date.getTime() - date.getTimezoneOffset() * DateOptions.msMinute);
	return date;
}
DateOptions.ParseISODate=DOParseISODate;
function DOParseISODate(stISO, caltype)
{
	var date="#INVALID";
	if (stISO.length < 19)
	    return date;
	var yr=stISO.substr(0, 4) - 0;
	var mon=stISO.substr(5, 2) - 0;
	var day=stISO.substr(8, 2) - 0;
	var hr=stISO.substr(11, 2) - 0;
	var min=stISO.substr(14, 2) - 0;
	var sec=stISO.substr(17, 2) - 0;
	if (isNaN(yr) || isNaN(mon) || isNaN(day) || isNaN(hr) || isNaN(min) || isNaN(sec))
		return date;
	if (caltype=="undefined")
		caltype=0;
	switch (caltype)
	{
	case 6:
	case 7:
	case 8:
	    date=new IntlDate(yr, mon-1, day, hr, min, sec, caltype);
	    break;
	default:
	    date=new Date(Date.UTC(yr, mon-1, day, hr, min, sec));
	    break;
	}
	return date;
}
DateOptions.prototype.RoundDate=DateRoundDate;
function DateRoundDate(date)
{
	date.setSeconds(0);
	return date;
}
DateOptions.StISODate=DOStISODate;
function DOStISODate(date)
{
	var yr=date.getUTCFullYear();
	var mon=date.getUTCMonth()+1;
	var day=date.getUTCDate();
	var hr=date.getUTCHours();
	var min=date.getUTCMinutes();
	var sec=date.getUTCSeconds();
	return yr+"-"+St2Digits(mon)+"-"+St2Digits(day)+"T"+St2Digits(hr)+":"+		St2Digits(min)+":"+St2Digits(sec)+"Z";
}
DateOptions.msSecond=1000;
DateOptions.msMinute=DateOptions.msSecond*60;
DateOptions.msHour=DateOptions.msMinute * 60;
DateOptions.msDay=DateOptions.msHour * 24;
DateOptions.msWeek=DateOptions.msDay * 7;
DateOptions.cdyYr=365;
DateOptions.cdyQYr=4*DateOptions.cdyYr+1;
DateOptions.cdyC=25*DateOptions.cdyQYr - 1;
DateOptions.cdyQC=4*DateOptions.cdyC+1;
DateOptions.mpMonIdy=new Array(31, 61, 92, 122, 153, 184, 214, 245, 275, 306, 337);
DateOptions.idyJan1=306;
DateOptions.ddayOrigin=135080;
function DateDecode(date)
{
	this.ms=date.getTime();
	this.msDay=this.ms % DateOptions.msDay;
	if (this.sec < 0)
		this.sec+=DateOptions.msDay;
	this.idy=Math.floor(this.ms / DateOptions.msDay)+DateOptions.ddayOrigin;	
	var idyQC=this.idy % DateOptions.cdyQC;			
	var iQC=Math.floor(this.idy / DateOptions.cdyQC);
	var idyC=idyQC % DateOptions.cdyC;			
	var iC=Math.floor(idyQC / DateOptions.cdyC);
	if (iC==4)
		{
		iC=3;
		idyC=DateOptions.cdyC;
		}
	var idyQYr=idyC % DateOptions.cdyQYr;			
	var iQYr=Math.floor(idyC / DateOptions.cdyQYr);
	var idyYr=idyQYr % DateOptions.cdyYr;			
	var iYr=Math.floor(idyQYr / DateOptions.cdyYr);
	if (iYr==4)
		{
		iYr=3;
		idyYr=DateOptions.cdyYr;
		}
	this.yr=1600+iQC * 400+iC * 100+iQYr * 4+iYr;
	if (idyYr >=DateOptions.idyJan1)
		this.yr++;
	var imon;
	for (imon=0; imon < 11; imon++)
		{
		if (idyYr < DateOptions.mpMonIdy[imon])
			break;
		}
	this.mon=(imon+2) % 12;
	this.day=idyYr - ((imon > 0) ? DateOptions.mpMonIdy[imon-1] : 0)+1;
	this.hr=Math.floor(this.msDay/DateOptions.msHour);
	this.min=Math.floor((this.msDay%DateOptions.msHour)/DateOptions.msMinute);
	this.sec=Math.floor((this.msDay%DateOptions.msMinute)/DateOptions.msSecond);
	this.dow=(this.idy+3) % 7;
}
DateDecode.prototype.MsEncode=DDMsEncode;
function DDMsEncode()
{
	this.ms=Date.UTC(this.yr, this.mon, this.day, this.hr, this.min, this.sec);
	return this.ms;
}
DateOptions.fOldDate=typeof(Date.prototype.getUTCHours)=="undefined";
if (DateOptions.fOldDate)
	{
	Date.prototype.getUTCDay=DateGetUTCDay;
	Date.prototype.getUTCDate=DateGetUTCDate;
	Date.prototype.getUTCFullYear=DateGetUTCFullYear;
	Date.prototype.getUTCMonth=DateGetUTCMonth;
	Date.prototype.getUTCHours=DateGetUTCHours;
	Date.prototype.getUTCMinutes=DateGetUTCMinutes;
	Date.prototype.getUTCSeconds=DateGetUTCSeconds;
	Date.prototype.setUTCDate=DateSetUTCDate;
	Date.prototype.setUTCHours=DateSetUTCHours;
	Date.prototype.EnsureDecode=DateEnsureDecode;
	Date.prototype.ResetMs=DateResetMs;
	}
function DateEnsureDecode()
{
	if (this.dd=="undefined" || this.dd.ms !=this.getTime())
		this.dd=new DateDecode(this);
}
function DateResetMs()
{
	this.setTime(this.dd.MsEncode());
}
function DateGetUTCDate()
{
	this.EnsureDecode();
	return this.dd.day;
}
function DateGetUTCDay()
{
	this.EnsureDecode();
	return this.dd.dow;
}
function DateGetUTCFullYear()
{
	this.EnsureDecode();
	return this.dd.yr;
}
function DateGetUTCMonth()
{
	this.EnsureDecode();
	return this.dd.mon;
}
function DateGetUTCHours()
{
	this.EnsureDecode();
	return this.dd.hr;
}
function DateGetUTCMinutes()
{
	this.EnsureDecode();
	return this.dd.min;
}
function DateGetUTCSeconds()
{
	this.EnsureDecode();
	return this.dd.sec;
}
function DateSetUTCDate(day)
{
	this.EnsureDecode();
	this.dd.day=day;
	this.ResetMs();
}
function DateSetUTCHours(hr, min, sec)
{
	this.EnsureDecode();
	if (!min) min=0;
	if (!sec) sec=0;
	this.dd.hr=hr;
	this.dd.min=min;
	this.dd.sec=sec;
	this.ResetMs();
}
DateDecode.prototype.toString=StDateDecode;
function StDateDecode()
{
	return "Date Object\rYear: "+this.yr+		"\rMon: "+(this.mon+1)+		"\rDay: "+this.day+		"\rhr: "+this.hr+		"\rmin: "+this.min+		"\rsec: "+this.sec;
}
function DatePicker(frm)
{
	this.frm=frm;
	if (frm.fUseDHTML)
		{
		document.write('<IFRAME FRAMEBORDER=0 SRC="'+frm.stPagePath+'iframe.htm" SCROLLING=no style="position:absolute;display:none;background:white;" ID=DatePickerWind></IFRAME>');
		this.wnd=DatePickerWind;
		document.body.onclick=DPCancelHandler;
		this.ifrm=document.getElementById("DatePickerWind");
		}
}
function DPCancelHandler()
{
	frmCurrent.dp.Cancel();
}
var L_DatePickerAlt_Text="Choose date from calendar";
DatePicker.prototype.StButton=DPStButton;
function DPStButton(fld, stPopUpOnClick2)
{
	var st="";
	if (this.frm.fUseDHTML)
		{
		st+="<IMG ALT=\""+L_DatePickerAlt_Text+"\" CLASS=ms-button "+			"ONCLICK='{var elt=event.srcElement; "+stPopUpOnClick2+"; if (!elt.disabled) frm.FindField("+STSScriptEncodeWithQuote(fld.stName)+").PopDatePicker(elt);}'"+			"SRC="+StAttrQuote(this.frm.stImagesPath+"calendar.gif")+">";
		}
	return st;
}
DatePicker.prototype.Popup=DPPopup;
function DPPopup(date, field, elt)
{
	if (this.elt !=null && this.elt==elt)
		{
		this.Cancel();
		return;
		}
	this.Cancel();
	this.bRTLAlign=false;
	this.date=new Date(date.getTime());
	this.date.setUTCHours(0,0,0,0);
	this.field=field;
	this.elt=elt;
	var pos=WindowPosition(elt);
	this.ifrm.style.pixelLeft=pos.x+1;
	this.ifrm.style.pixelTop=pos.y+elt.offsetHeight;
	this.SetHTML(this.StBuild());
}
DatePicker.prototype.AdjustFrameSize=DPAdjustFrameSize;
function DPAdjustFrameSize()
{
	this.ifrm.style.display="block";
	var divDP=this.wnd.document.getElementById("DatePickerDiv");
	if (!this.bDidAlign)
	{
		this.bDidAlign=true;
		this.ifrm.style.pixelWidth=divDP.offsetWidth - 100;
	}
	this.ifrm.style.pixelWidth=divDP.offsetWidth;
	this.ifrm.style.pixelHeight=divDP.offsetHeight;
	if (this.ifrm.currentStyle.direction=="rtl" && !this.bRTLAlign)
	{
		this.bRTLAlign=true;
		this.ifrm.style.pixelLeft -=this.ifrm.style.pixelWidth - event.srcElement.offsetWidth+1;
	}
}
DatePicker.prototype.StBuild=DPStBuild;
function DPStBuild()
{
	var st="";
	this.cal=new Calendar(this.date.getUTCFullYear(), this.date.getUTCMonth(), this.frm.dopt, "parent.frm.dp");
	this.cal.fDatePicker=true;
	this.cal.dateDP=this.date;
	st+=this.cal.StBuild();
	return st;
}
DatePicker.prototype.SetHTML=DPSetHTML;
function DPSetHTML(stHTML)
{
	var cssLink=this.wnd.document.getElementById("onetidThemeCSS");
	if (cssLink && this.frm.themeCSSurl)
		cssLink.href=this.frm.themeCSSurl;
	this.wnd.document.body.innerHTML="<DIV ID=DatePickerDiv>"+stHTML+"</DIV>";
	this.wnd.document.selection.empty();
	this.AdjustFrameSize();
}
DatePicker.prototype.ClickDay=DPClickDay;
function DPClickDay(yr, mon, day)
{
	var date=new Date(Date.UTC(yr, mon, day));
	this.field.value=this.frm.dopt.StDate(date);
	this.Cancel();
}
DatePicker.prototype.MoveMonth=DPMoveMonth;
function DPMoveMonth(dmon)
{
	this.cal.SetDate(this.cal.yr, this.cal.mon+dmon, 1);
	this.SetHTML(this.cal.StBuild());
}
DatePicker.prototype.Cancel=DPCancel;
function DPCancel()
{
	if (this.elt !=null)
		{
		this.ifrm.style.display="none";
		this.elt=null;
		}
}
DatePicker.prototype.SetDate=DPSetDate;
function DPSetDate(yr, mon, day)
{
	this.cal.SetDate(yr, mon, day);
	this.SetHTML(this.cal.StBuild());
}
function FrmOnSubmitRetFalse()
{
   return false;
}
var frmCurrent;
function OWSForm(stName, fUseDHTMLOverride, stPagePath)
{
	this.stName=stName;
	this.stFieldPrefix="urn:schemas-microsoft-com:office:office#";
	this.dopt=new DateOptions;
	this.nopt=new NumberOptions;
	this.fUseDHTML=browseris.ie5up && browseris.win32;
	if (!fUseDHTMLOverride)
			this.fUseDHTML=false;
	this.ifldMax=0;
	this.rgfld=new Array;
	this.stError="";
	this.stImagesPath="";
	this.stPagePath=stPagePath+L_Language_Text+"/";
	this.dp=new DatePicker(this);
	this.stInputStyle=((browseris.ie5up && browseris.win32) || browseris.nav6up) ? "CLASS=ms-input" : "";
	this.stLongStyle=((browseris.ie5up && browseris.win32) || browseris.nav6up) ? "CLASS=ms-long" : "";
	this.fPreviewMode=false;
	if (document.forms[this.stName])
		document.forms[this.stName].onsubmit=FrmOnSubmitRetFalse;
	this.form=null;
	this.themeCSSurl=retrieveCurrentThemeLink();
	this.rgcts=new Array;
	this.rgctNames=new Array;
	frmCurrent=this;
}
OWSForm.prototype.AddField=FrmAddField;
function FrmAddField(fld, stName, stDisplay, stValue)
{
	this.rgfld[this.ifldMax++]=fld;
	fld.frm=this;
	fld.stName=stName;
	fld.stDisplay=stDisplay;
	fld.stValue=stValue;
	fld.fRequired=false;
	fld.stError="";
	fld.stAttributes="";
	fld.fCalcCheck=false;
}
OWSForm.prototype.DataBind=FrmDataBind;
function FrmDataBind()
{
	var ifld;
	var fld;
	if (this.form==null)
	    this.form=document.forms[this.stName]
	for (ifld=0; ifld < this.ifldMax; ifld++)
		{
		fld=this.rgfld[ifld];
		fld.DataBind();
		}
}
OWSForm.prototype.FindField=FrmFindField;
function FrmFindField(stField)
{
	var fld;
	for (ifld=0; ifld < this.ifldMax; ifld++)
		{
		fld=this.rgfld[ifld];
		if (fld.stName==stField)
			return fld;
		}
	return null;
}
OWSForm.prototype.ValidateAndSubmit=FrmValidateAndSubmit;
function FrmValidateAndSubmit(fUI)
{
	if (this.fPreviewMode)
	{
		var L_cantSave_Text="This form cannot be saved when previewing this page.";
		window.alert(L_cantSave_Text);
		return;
	}
	if (this.FValidate(fUI)){
		this.FPostProcess();
		this.form.submit();
	}
}
OWSForm.prototype.FValidate=FValidateForm;
function FValidateForm(fUI)
{
	var ifld;
	var fld;
	var bFormValid=true;
	if (this.form==null)
	    this.form=document.forms[this.stName]
	for (ifld=0; ifld < this.ifldMax; ifld++)
		{
		fld=this.rgfld[ifld];
		if (!fld.fSkipValidation && !fld.FValidate())
			{
			if (fld.errFld)
				fld=fld.errFld;
			if (bFormValid)
				{
				this.stError=fld.stError;
				bFormValid=false;
				}
			if (fUI)
				{
				ShowControl(fld, fld.fRequired, 0);
				fld.FieldFocus();
				alert(this.stError);
				return false;
				}
			}
		}
	return bFormValid;
}
OWSForm.prototype.FPostProcess=FPostProcessForm;
function FPostProcessForm()
{
	var ifld;
	var fld;
	this.form=document.forms[this.stName]
	for (ifld=0; ifld < this.ifldMax; ifld++)
		{
		fld=this.rgfld[ifld];
		if (fld.PostProcess)
			fld.PostProcess();
		}
	return true;
}
OWSForm.prototype.SetFirstFocus=FrmSetFirstFocus;
function FrmSetFirstFocus(bAlreadyInitialized)
{
	var i;
	if (bAlreadyInitialized !=true)
		this.InitFormFields();
	if (this.rgcts.length > 1)
		return;
	for (i in this.rgfld)
	{
		var fld=this.rgfld[i];		
		if (!(fld.hasOwnProperty("fHidden")  && fld.fHidden) &&
			fld.FieldFocus && fld.FieldFocus())
		{
			break;
		}
	}
}
OWSForm.prototype.InitFormFields=FrmInitFields;
function FrmInitFields()
{
	var i;
	window.focus();
	this.form=document.forms[this.stName];
	for (i in this.rgfld)
	{
		if (this.rgfld[i].Init)
			this.rgfld[i].Init();
	}
	if (typeof(_g_tp_rgcts) !="undefined")
		this.rgcts=_g_tp_rgcts;
	else
		this.rgcts=new Array;
	DefaultControls();
}
OWSForm.prototype.BuildFieldUI=FrmBuildFieldUI;
function FrmBuildFieldUI(fld, st)
{
	document.write(st);
}
OWSForm.prototype.StFieldPost=FrmStFieldPost;
function FrmStFieldPost(fld)
{
	if (!fld.posted)
	{
		fld.posted=true;
		return "<INPUT TYPE=HIDDEN NAME="+StAttrQuote(this.stFieldPrefix+fld.stName)+">\r";
	}
	else
		return "";
}
OWSForm.prototype.FieldPost=FrmFieldPost;
function FrmFieldPost(fld)
{
	if (this.form==null)
		this.form=document.forms[this.stName];
	return this.form[this.stFieldPrefix+fld.stName];
}
OWSForm.prototype.FilenameFieldPost=FilenameFrmFieldPost;
function FilenameFrmFieldPost(fld)
{
	if (this.form==null)
		this.form=document.forms[this.stName];
	return this.form[fld.stName];
}
OWSForm.prototype.StFieldSubPart=FrmStFieldSubPart;
function FrmStFieldSubPart(fld, stPart, stValue)
{
	var maxLen="MaxLength=255 ";
	var stDir;
	switch(fld.direction)
	{
	case 1:
		stDir=" dir=ltr";
		break;
	case 2:
		stDir=" dir=rtl";
		break;
	default:
		stDir="";
		break;		
	}	
	var strIMEMode=fld.IMEMode ? " style=\"ime-mode:"+fld.IMEMode+"\" " : "";
	return "<INPUT "+FormTabIndex()+" "+maxLen+fld.stAttributes+		" TITLE="+StAttrQuote(fld.stDisplay)+	    " NAME="+StAttrQuote(this.StFieldName(fld, stPart))+	    " id='"+"id"+fld.stName+"'"+	    strIMEMode+		" VALUE="+StAttrQuote(stValue)+stDir+">";
}
OWSForm.prototype.FieldSubPart=FrmFieldSubPart;
function FrmFieldSubPart(fld, stPart)
{
	if (this.form==null)
		this.form=document.forms[this.stName];
	return this.form[this.StFieldName(fld, stPart)];
}
OWSForm.prototype.StFieldName=FrmStFieldName;
function FrmStFieldName(fld, stPart)
{
	return this.StFieldNameFactory(fld.stName, stPart);
}
OWSForm.prototype.StFieldNameFactory=FrmStFieldNameFactory;
function FrmStFieldNameFactory(name, stPart)
{
	return "OWS:"+name+":"+stPart;
}
OWSForm.prototype.GetSelValue=FrmGetSelValue;
function FrmGetSelValue(st)
{
	if (this.form==null)
		this.form=document.forms[this.stName];
	var sel=this.form[st];
	return sel[sel.selectedIndex].value;
}
OWSForm.prototype.TestURL=FormTestURL;
function FormTestURL(stName)
{
	var fld=this.FindField(stName);
	var stURL=StURLNormalize(TrimWhiteSpaces(this.FieldSubPart(fld, "URL").value));
	if (stURL.substr(0, 7)=="mailto:")
		open(stURL, "_self");
	else
		open(stURL, "_blank");
}
OWSForm.prototype.SetRadioValue=FormSetRadioValue;
function FormSetRadioValue(stName, stValue)
{
	var fld=this.FindField(stName);
	if (fld.stAlias)
		fld=this.FindField(fld.stAlias);
	fld.SetValue(stValue);
	return true;
}
OWSForm.prototype.RevertSelect=FormRevertSelect;
function FormRevertSelect(stName, stValue)
{
	var fld=this.FindField(stName);
	fld.RevertSelect(stValue);
}
OWSForm.prototype.SetFillInButton=FormSetFillInButton;
function FormSetFillInButton(stName)
{
	if (event !=null)
	{
		var charCode;
		if (browseris.ie)
			charCode=event.keyCode;
		else
			charCode=event.which;
		if (charCode==9 || charCode==16)
			return;
	}
	var fld=this.FindField(stName);
	fld.SetFillInButton();
}
OWSForm.prototype.UnsetFillInButton=FormUnsetFillInButton;
function FormUnsetFillInButton(stName)
{
	var fld=this.FindField(stName);
	fld.UnsetFillInButton();
}
function NumberOptions()
{
	this.chDigSep=",";
	this.chDecimal=".";
	this.chMinus="-";
	this.iNegNumber=1;
	this.rgcchSep=new Array(3, 0);
}
NumberOptions.prototype.SetGrouping=NoptSetGrouping;
function NoptSetGrouping(stGrouping)
{
	this.rgcchSep=stGrouping.split(";");
}
NumberOptions.prototype.NumParse=NoptNumParse;
function NoptNumParse(st)
{
	var fNeg=false;
	st=st.toUpperCase();
	var re=new RegExp("\\"+this.chDigSep, "g");
	st=st.replace(re, "");
	if (this.chDecimal !="." && st.search(/\./) !=-1)
		return Number.NaN;
	re=new RegExp("\\"+this.chDecimal, "g");
	st=st.replace(re, ".");
	if ((st.search(/\(/) !=-1 && st.search(/\)/) !=-1))
	{
		fNeg=true;
		st=st.replace(/\(/, "").replace(/\)/, "");
	}
	var ix=0;
	var sawE=false;
	var stClean="";
	for (ix=0; ix < st.length; ix++)
	{
		var oneChar=st.charAt(ix);
		if (oneChar=="E")
		{
			sawE=true;
		}
		if (!sawE && oneChar==this.chMinus)
		{
			fNeg=true;
		}
		else
		{
			stClean+=oneChar;
		}
	}
	var num=stClean - 0;
	if (num > 1.79E+308)
		return Number.NaN;
	if (num !=0 && num < 2.23E-308)
		num=0;
	if (fNeg)
		num=-num;
	return num;
}
NumberOptions.prototype.StNumber=NoptStNumber;
function NoptStNumber(numOrig)
{
	var fNeg;
	var ichDigit;
	if (numOrig=="")
		return "";
	var num=numOrig - 0;
	fNeg=num < 0;
	if (fNeg)
		num=-num;
	var stNum=num.toString();
	stNum=stNum.toUpperCase();
	if (isNaN(num))
		{
		return numOrig;
		}
	stNum=stNum.replace(/\./, this.chDecimal);
	var ichDecimal=stNum.indexOf(this.chDecimal);
	if (this.rgcchSep[0] !=0 && (stNum.indexOf("E")==-1))
		{
		if (ichDecimal !=-1)
			ichDigit=ichDecimal - 1;
		else
			ichDigit=stNum.length - 1;
		var icch=0;
		while (icch < this.rgcchSep.length && ichDigit >=this.rgcchSep[icch])
			{
			stNum=StInsertAt(stNum, ichDigit-this.rgcchSep[icch]+1, this.chDigSep);
			ichDigit -=this.rgcchSep[icch];
			icch++;
			if (icch < this.rgcchSep.length && this.rgcchSep[icch]==0)
				icch--;
			}
		}
	if (fNeg)
		{
		switch (this.iNegNumber)
			{
		case 0:
			stNum="("+stNum+")";
			break;
		case 1:
			stNum=this.chMinus+stNum;
			break;
		case 2:
			stNum=this.chMinus+" "+stNum;
			break;
		case 3:
			stNum=stNum+this.chMinus;
			break;
		case 4:
			stNum=stNum+" "+this.chMinus;
			break;
			}
		}
	return stNum;
}
function DateField(frm, stName, stDisplay, stValue)
{
	frm.AddField(this, stName, stDisplay, stValue);
	this.fDateOnly=false;
	this.stAttributes=frm.stInputStyle+" SIZE=12";
	this.caltype=1;
	this.direction=0;
	this.stPopUpOnClick2="";
	this.origDate=null;
	   this.showDatePicker=true;
}
var L_DateOrderYear_Text="YYYY";
var L_DateOrderMonth_Text="M";
var L_DateOrderDay_Text="D";
var L_DateOrderDesc_Text="Enter date in ^2 format^1.";
var L_CalendarHijri_Text=" using Hijri Calendar";
var L_CalendarHebrew_Text=" using Hebrew Lunar Calendar";
var L_CalendarThai_Text=" using Buddhist Calendar";
var L_CalendarSaka_Text=" using Saka Era Calendar";
DateField.prototype.BuildUI=DateBuildUI;
function DateBuildUI()
{
	var st=this.stBuildUI();
	this.frm.BuildFieldUI(this, st+"\r");
}
DateField.prototype.stBuildUI=stDateBuildUI;
function stDateBuildUI()
{
	var st="";
	var date;
	st+=this.frm.StFieldPost(this);
	if (!this.fHideDateSpan)
		st+="<span ID="+StAttrQuote(this.frm.StFieldName(fld, "DateSpan"))+">";
	if (FBlankString(this.stValue))
		{
		st+=this.frm.StFieldSubPart(this, "Date", "");
		date=this.frm.dopt.Today();
		}
	else
		{
		date=DateOptions.ParseISODate(this.stValue, this.caltype);
		if (date=="#INVALID")
			{
			date=this.frm.dopt.Today();
			st+=this.frm.StFieldSubPart(this, "Date", date);
			}
		else
		    {
		        date=this.frm.dopt.RoundDate(date);
				st+=this.frm.StFieldSubPart(this, "Date", this.frm.dopt.StDate(date));
		    }
		}
	this.origDate=date;
	st+="&nbsp;";
	if(this.caltype==1 && this.showDatePicker)
		st+=this.frm.dp.StButton(this, this.stPopUpOnClick2);
	st+="&nbsp;&nbsp;"
	if (!this.fHideDateSpan)
		st+="</span>";
	if (!this.fDateOnly)
		{
		st+=this.frm.dopt.StTimeControls(this, date);
		}
	st+="<IMG alt='' style='vertical-align: bottom' width=1pt height=26pt SRC="
+StAttrQuote(this.frm.stImagesPath+"blank.gif")+">";
	var stCalenarString="";
	var stDateString="";	
	switch (this.caltype)
	{
	case 6:
		stCalenarString=L_CalendarHijri_Text;
		break;
	case 7:
		stCalenarString=L_CalendarThai_Text;
		break;
	case 8:
		stCalenarString=L_CalendarHebrew_Text;
		break;
	case 16:
		stCalenarString=L_CalendarSaka_Text;
		break;
	default:
		stCalenarString="";
	}
	stDateString=this.frm.dopt.StDateString(L_DateOrderYear_Text,
		L_DateOrderMonth_Text, L_DateOrderDay_Text);	
	if (!this.fHideDescription)
		{
		st+="&nbsp;<br><SPAN class=ms-formdescription ID="
+StAttrQuote(this.frm.StFieldName(fld, "DateSpan"))+">"
+StBuildParam(L_DateOrderDesc_Text, stCalenarString, stDateString)
+"</SPAN>";
		}
	return st;
}
DateField.prototype.PopDatePicker=DatePopDatePicker;
function DatePopDatePicker(elt)
{
	this.frm.form=document.forms[this.frm.stName]
	var date;
	var field=this.frm.FieldPost(this);
	var fieldDate=this.frm.FieldSubPart(this, "Date");
	event.cancelBubble=true;
	date=this.frm.dopt.Today();
	if (this.FValidate() && this.date !=null)
		date=this.date;
	this.frm.dp.Popup(date, fieldDate, elt);
	return true;	
}
DateField.prototype.DataBind=DateDataBind;
function DateDataBind()
{
	var date;
	var fieldData=this.frm.FieldPost(this);
	var fieldDate=this.frm.FieldSubPart(this, "Date");
	if (FBlankString(fieldData.value))
		{
		fieldDate.value="";
		date=this.frm.dopt.Today();
		}
	else
		{
		date=DateOptions.ParseISODate(fieldData.value);
		date=this.frm.dopt.RoundDate(date);
		fieldDate.value=this.frm.dopt.StDate(date);
		}
	if (!this.fDateOnly)
		{
		this.frm.dopt.SetTimeControls(this, date);
		}
}
DateField.prototype.FieldFocus=DateFieldFocus;
function DateFieldFocus()
{
	var field=this.frm.FieldSubPart(this, "Date");
	if (!field.disabled)
	{
		field.focus();
		field.select();
		return true;
	}
	return false;
}
var L_DateRequired_Text="You must specify a date for ^1.";
var L_InvalidDate_Text="^1 is not a valid date.";
DateField.prototype.FValidate=DateFValidate;
function DateFValidate()
{
	var field=this.frm.FieldPost(this);
	var formfld=this.frm.FieldSubPart(this, "Date");
	if (!formfld.disabled)
		{
		var stDate=TrimWhiteSpaces(formfld.value);
		if (stDate=="")
			{
			if (this.fRequired)
				{
				this.stError=StBuildParam(L_DateRequired_Text, this.stDisplay);
				return false;
				}
			else
				{
				field.value="";
				this.date=null;
				return true;
				}
			}
		var date=this.frm.dopt.ParseLocaleDate(stDate, this.caltype);
		if (isNaN(date))
			{
			this.stError=StBuildParam(L_InvalidDate_Text, this.stDisplay);
			return false;
			}
		var yrMin=1900;	
		var yrMax=8900;
		switch (this.caltype)
		{
		case 6:
			yrMin=1319;
			yrMax=3481;
			break;
		case 7:
			yrMin=2444;
			yrMax=5043;
			break;
		case 8:
			yrMin=5662;
			yrMax=5998;
			break;
		case 16:
			yrMin=1823;
			yrMax=3920;
			break;
		}
		if (!this.fDateOnly)
			{
			var hr=this.frm.GetSelValue(this.frm.StFieldName(this, "Hours")) - 0;
			var min=this.frm.GetSelValue(this.frm.StFieldName(this, "Minutes"));
			date.setUTCHours(hr, min);
			}
		var yr=date.getUTCFullYear();
		var mon=date.getUTCMonth();
		var day=date.getUTCDate();
		var minCalGregorian=(this.origDate==null
							  || date.getTime() >=this.origDate.getTime())
							  && this.caltype==1 && yr==1899 && mon==11 && day==31;
		if ((yr < yrMin || yr > yrMax) && !minCalGregorian)
			{
			this.stError=StBuildParam(L_InvalidDate_Text, this.stDisplay);
			return false;
			}
		field.value=DateOptions.StISODate(date);
		this.date=date;
		}
	return true;
}
function URLField(frm, stName, stDisplay, stURL, stDesc)
{
	if (FBlankString(stURL))
	{
		stURL="http://";
	}
	frm.AddField(this, stName, stDisplay, stURL);
	this.stDesc=stDesc;
	this.stAttributes=frm.stLongStyle;
}
var L_URLHeading_Text="Type the Web address:";
var L_URLTest_Text="Click here to test";
var L_URLHeadingDesc_Text="Type the description:";
var L_URLDescriptionTooltip_Text="Description";
URLField.prototype.BuildUI=URLBuildUI;
function URLBuildUI()
{
	var st="";
	st+=this.frm.StFieldPost(this);
	st+="<SPAN CLASS=ms-formdescription>"+L_URLHeading_Text+" (";
	st+="<A "+FormTabIndex()+" HREF='javascript:frm.TestURL("+STSScriptEncodeWithQuote(this.stName)+")' target=_self>"+L_URLTest_Text+"</A>)&nbsp;<br></span>\r";
	st+="<SPAN dir=ltr>";
	st+=this.frm.StFieldSubPart(this, "URL", this.stValue);
	st+="</SPAN>";
	st+="&nbsp;<br>\r<SPAN CLASS=ms-formdescription>"+L_URLHeadingDesc_Text+"<br></SPAN>\r";
	var stOldDisplay=this.stDisplay;
	this.stDisplay=L_URLDescriptionTooltip_Text;
	st+=this.frm.StFieldSubPart(this, "Desc", this.stDesc);
	this.stDisplay=stOldDisplay;
	this.frm.BuildFieldUI(this, st);
}
URLField.prototype.DataBind=URLDataBind;
function URLDataBind()
{
	var fieldData=this.frm.FieldPost(this);
	var fieldURL=this.frm.FieldSubPart(this, "URL");
	var fieldDesc=this.frm.FieldSubPart(this, "Desc");
	var st=fieldData.value;
	var stURL, stDesc;
	var ich=st.indexOf(", ");
	if (ich==-1)
	{
		ich=st.lastIndexOf(",");
		if (ich==st.length - 1)
		{
			st+=" ";
		}
	}
	if (ich==-1)
	{
		stURL=st;
		stDesc=st;
	}
	else
	{
		stURL=st.substr(0, ich);
		stDesc=st.substr(ich+2);
	}
	stURL=stURL.replace(/\,\,/, ",");
	if (FBlankString(stURL))
	{
		stURL="http://";
	}
	fieldURL.value=stURL;
	fieldDesc.value=stDesc;
}
URLField.prototype.FieldFocus=URLFieldFocus;
function URLFieldFocus()
{
	var field=this.frm.FieldSubPart(this, "URL");
	if (!field.disabled)
	{
		field.focus();
		field.select();
		return true;
	}
	return false;
}
URLField.prototype.FValidate=URLValidate;
function URLValidate()
{
	var stPost;
	var fieldPost=this.frm.FieldPost(this);
	var stURL=TrimWhiteSpaces(this.frm.FieldSubPart(this, "URL").value);
	var stDesc=TrimWhiteSpaces(this.frm.FieldSubPart(this, "Desc").value);
	if (stURL=="http://")
	{
		stURL="";
	}
	if (this.fRequired && FBlankString(stURL))
	{
		this.stError=StBuildParam(L_FieldRequired_Text, this.stDisplay);
		return false;
	}
	stURL=StURLNormalize(stURL);
	var L_InvalidUrlValue_Text="You cannot type a semicolon (;) immediately followed by a number sign (#) in the Web address of a hyperlink.";
	if (-1 !=stURL.indexOf(";#") || -1 !=stDesc.indexOf(";#"))
	{
		this.stError=L_InvalidUrlValue_Text;
		return false;
	}
	stPost=stURL.replace(/,/g, ",,")+", "+stDesc;
	fieldPost.value=stPost;
	return true;
}
function StURLNormalize(stURL)
{
	if (stURL.substr(0,2)=="\\\\" || stURL.substr(0,2)=="\/\/" )
		stURL="file:"+stURL;
	if (stURL.substr(0,5)=="file:")
		stURL=stURL.replace(/\\/g, "\/");
	return stURL;
}
function NumberField(frm, stName, stDisplay, stValue)
{
	frm.AddField(this, stName, stDisplay, stValue);
	this.fPercent=false;
	this.cchDisplaySize="";
}
NumberField.prototype.BuildUI=NumberBuildUI;
function NumberBuildUI()
{
	var st=this.stBuildUI();
	this.frm.BuildFieldUI(this, st);
}
function StDivideByOneHundred(stNum)
{
	if (stNum=="")
		return stNum;
	var ix;
	ix=stNum.indexOf("E");
	if (ix==-1)
		ix=stNum.indexOf("e");
	var stExponentPart;
	if (ix==-1)
		stExponentPart="";
	else
	{
		stExponentPart=stNum.slice(ix);
		stNum=stNum.substr(0, ix);
	}
	var stSignPart;
	if (stNum.charAt(0)=="-")
	{
		stSignPart="-";
		stNum=stNum.slice(1);
	}
	else
		stSignPart="";
	ix=stNum.indexOf(".");
	if (ix==-1)
	{
		ix=stNum.length;
		stNum+=".";
	}
	stNum=stNum.substr(0, ix)+stNum.slice(ix+1);
	ix -=2;
	if (ix==-1)
	{
		stNum=("0"+stNum);
		ix=0;
	}
	stNum=StInsertAt(stNum, ix, ".");
	stNum=stSignPart+stNum+stExponentPart;
	return stNum;
}
function StMultiplyByOneHundred(stNum)
{
	if (stNum=="")
		return stNum;
	var ix;
	ix=stNum.indexOf("E");
	if (ix==-1)
		ix=stNum.indexOf("e");
	var stExponentPart;
	if (ix==-1)
		stExponentPart="";
	else
	{
		stExponentPart=stNum.slice(ix);
		stNum=stNum.substr(0, ix);
	}
	ix=stNum.indexOf(".");
	if (ix==-1)
	{
		stNum+="00";
	}
	else
	{
		stNum=stNum.substr(0, ix)+stNum.slice(ix+1);
		ix+=2;
		while (ix >=stNum.length+1)
			stNum+="0";
		stNum=StInsertAt(stNum, ix, ".");
	}
	stNum=stNum+stExponentPart;
	return stNum;
}
NumberField.prototype.stBuildUI=stNumberBuildUI;
function stNumberBuildUI()
{
	var nmb=this.stValue - 0;
	if (this.fPercent && !isNaN(nmb))
	{
		if (this.stValue !=0)
		{
			this.stValue=StMultiplyByOneHundred(this.stValue);
		}
		if (this.wMin !=0)
			this.wMin=StMultiplyByOneHundred(this.wMin.toString());
		if (this.wMax !=0)
			this.wMax=StMultiplyByOneHundred(this.wMax.toString());
	}
	var cchSize;
	if (this.cchDisplaySize !="")
		cchSize=this.cchDisplaySize - 0;
	else
		cchSize=11;
	this.stAttributes=this.frm.stInputStyle+" SIZE="+cchSize ;
	var st="";
	st+=this.frm.StFieldPost(this);
	st+=this.frm.StFieldSubPart(this, "Local", this.frm.nopt.StNumber(this.stValue));
	if (this.fPercent && !this.fCalcCheck)
	    st+="&nbsp;%";
	return st;
}
NumberField.prototype.DataBind=NumberDataBind;
function NumberDataBind()
{
	var fieldData=this.frm.FieldPost(this);
	var fieldControl=this.frm.FieldSubPart(this, "Local");
	if (this.fPercent)
	    fieldData.value=StMultiplyByOneHundred(fieldData.value.toString());
	fieldControl.value=this.frm.nopt.StNumber(fieldData.value);
}
NumberField.prototype.FieldFocus=NumberFieldFocus;
function NumberFieldFocus()
{
	var field=this.frm.FieldSubPart(this, "Local");
	if (!field.disabled)
	{
		field.focus();
		field.select();
		return true;
	}
	return false;
}
var L_ValueRequired_Text="You must specify a value for ^1.";
var L_InvalidNumber_Text="^1 is not a valid number.";
var L_InvalidRange_Text="^1 must be between ^2 and ^3.";
var L_InvalidMin_Text="^1 must be greater than or equal to ^2.";
var L_InvalidMax_Text="^1 must be less than or equal to ^2.";
var L_InvalidInteger_Text="^1 must be an integer.";
NumberField.prototype.FValidate=NumberFValidate;
function NumberFValidate()
{
	var field=this.frm.FieldPost(this);
	var stNum=this.frm.FieldSubPart(this, "Local").value;
	if (FBlankString(stNum))
		{
		if (this.fRequired)
			{
			this.stError=StBuildParam(L_ValueRequired_Text, this.stDisplay);
			return false;
			}
		field.value="";
		return true;
		}
	 if (this.fCalcCheck)
		 {
		field.value=stNum;
		return true;
		}
	wValue=this.frm.nopt.NumParse(stNum);
	if (isNaN(wValue))
		{
		this.stError=StBuildParam(L_InvalidNumber_Text, this.stDisplay);
		return false;
		}
	if (FNumber(this.wMin) && FNumber(this.wMax) &&
		(wValue < this.wMin || wValue > this.wMax))
		{
		this.stError=StBuildParam(L_InvalidRange_Text, this.stDisplay, this.frm.nopt.StNumber(this.wMin), this.frm.nopt.StNumber(this.wMax));
		return false;
		}
	if (FNumber(this.wMin) && wValue < this.wMin)
		{
		this.stError=StBuildParam(L_InvalidMin_Text, this.stDisplay, this.frm.nopt.StNumber(this.wMin));
		return false;
		}
	if (FNumber(this.wMax) && wValue > this.wMax)
		{
		this.stError=StBuildParam(L_InvalidMax_Text, this.stDisplay, this.frm.nopt.StNumber(this.wMax));
		return false;
		}
	if (this.fInteger && wValue && (Math.floor(wValue) !=wValue))
		{
		this.stError=StBuildParam(L_InvalidInteger_Text, this.stDisplay);
		return false;
		}
	if (this.fPercent)
		field.value=StDivideByOneHundred(wValue.toString());
	else
		field.value=wValue;
	return true;
}
function FNumber(w)
{
	return (w !="" && w !=null && !isNaN(w));
}
function BooleanField(frm, stName, stDisplay, stValue)
{
	frm.AddField(this, stName, stDisplay, stValue);
}
BooleanField.prototype.BuildUI=BooleanBuildUI;
function BooleanBuildUI()
{
	var st="";
	st+=this.frm.StFieldPost(this);
	st+="<INPUT "+FormTabIndex()+" TYPE=CHECKBOX "+this.stAttributes+	    " TITLE="+StAttrQuote(this.stDisplay)+	    " NAME="+StAttrQuote(this.frm.StFieldName(fld, "Checkbox"));
	if (this.stValue !=0)
		st+=" CHECKED";
	st+=">\r";
	this.frm.BuildFieldUI(this, st);
}
BooleanField.prototype.DataBind=BooleanDataBind;
function BooleanDataBind()
{
	var fieldData=this.frm.FieldPost(this);
	var fieldControl=this.frm.FieldSubPart(this, "Checkbox");
	fieldControl.checked=(fieldData.value !=0);
}
BooleanField.prototype.FieldFocus=BooleanFieldFocus;
function BooleanFieldFocus()
{
	var field=this.frm.FieldSubPart(this, "Checkbox");
	if (!field.disabled)
	{
		field.focus();
		return true;
	}
	return false;
}
BooleanField.prototype.FValidate=BooleanFValidate;
function BooleanFValidate()
{
	var field=this.frm.FieldPost(this);
	var fieldCheckbox=this.frm.FieldSubPart(this, "Checkbox");
	if (fieldCheckbox.checked)
		field.value=1;
	else
		field.value=0;
	return true;
}
BooleanField.prototype.SetValue=BooleanFieldSetValue
function BooleanFieldSetValue(val)
{
	var fieldData=this.frm.FieldPost(this);
	var fieldControl=this.frm.FieldSubPart(this, "Checkbox");
	fieldData.value=val;
	fieldControl.checked=(fieldData.value !=0);
}
function Field(frm, stName, stDisplay)
{
	frm.AddField(this, stName, stDisplay, "");
}
Field.prototype.FieldFocus=FieldFieldFocus;
function FieldFieldFocus()
{
	var field=this.frm.FieldPost(this);
	if (!field.disabled)
	{
		field.focus();
		return true;
	}
	return false;
}
Field.prototype.DataBind=FieldDataBind;
function FieldDataBind()
{
}
var L_FieldRequired_Text="You must specify a non-blank value for ^1.";
Field.prototype.FValidate=FieldFValidate;
function FieldFValidate()
{
	var field=this.frm.FieldPost(this);
	if (this.fRequired && FBlankString(field.value))
		{
		this.stError=StBuildParam(L_FieldRequired_Text, this.stDisplay);
		return false;
		}
	if (this.frm.wBaseType==1 && field.value && field.value.length > 255)
			{
			this.stError=StBuildParam(L_TextFieldMax_Text, this.stDisplay, 255);
			return false;
			}
	return true;
}
Field.prototype.BuildUI=FieldBuildUI;
function FieldBuildUI()
{
}
function NoteField(frm, stName, stDisplay, stValue)
{
	frm.AddField(this, stName, stDisplay, stValue);
	this.stDirection="";
	this.stNumLines="";
}
NoteField.prototype.FieldFocus=NoteFieldFieldFocus;
function NoteFieldFieldFocus()
{
   return NoteFieldFieldFocusCore(this);
}
function NoteFieldFieldFocusCore(fld)
{
	var field=fld.frm.FieldPost(fld);
	if (!field.disabled)
	{
		field.focus();
		return true;
	}
	return false;
}
NoteField.prototype.BuildUI=NoteFieldBuildUI;
function NoteFieldBuildUI()
{
   NoteFieldBuildUICore(this);
}
function NoteFieldBuildUICore(fld)
{
	var st="";
	st+="<TEXTAREA "+FormTabIndex()+" COLS=\"30\""
+" ROWS="+StAttrQuote(fld.stNumLines)
+" TITLE="+StAttrQuote(fld.stDisplay)
+" Name="+StAttrQuote(fld.frm.stFieldPrefix+fld.stName)
+" "+fld.frm.stLongStyle;
	st+=fld.IMEMode ? " style=\"ime-mode:"+fld.IMEMode+"\" " : ""
	st+=">";
	st+=STSHtmlEncode(fld.stValue);
	st+="</TEXTAREA>";
	fld.frm.BuildFieldUI(fld, st);
}
NoteField.prototype.DataBind=FieldDataBind;
NoteField.prototype.FValidate=NoteFieldFValidate;
function NoteFieldFValidate()
{
   return NoteFieldFValidateCore(this)
}
function NoteFieldFValidateCore(fld)
{
	var field=fld.frm.FieldPost(fld);
	if (fld.fRequired && FBlankString(field.value))
		{
		fld.stError=StBuildParam(L_FieldRequired_Text, fld.stDisplay);
		return false;
		}
	if (fld.frm.wBaseType==1 && field.value && field.value.length > 255)
			{
			fld.stError=StBuildParam(L_TextFieldMax_Text, fld.stDisplay, 255);
			return false;
			}
	return true;
}
function RichTextField(frm, stName, stDisplay, stValue)
{
	frm.AddField(this, stName, stDisplay, stValue);
	this.stDirection="";
	this.stNumLines="";
	this.fAllowHyperlink=false;
}
RichTextField.prototype.FieldFocus=RichTextFieldFieldFocus;
function RichTextFieldFieldFocus()
{
   if (browseris.ie5up)
   {
	  RTE_GiveEditorFirstFocus(this.frm.stFieldPrefix+this.stName);
	  return true;
   }
   else
   {
	  return NoteFieldFieldFocusCore(this);
   }
}
RichTextField.prototype.BuildUI=RichTextFieldBuildUI;
function RichTextFieldBuildUI()
{
   var st="";
   var L_strRichTextSupport_Text="You may add HTML formatting. Click <a href='javascript:HelpWindowKey(\"nsrichtext\")'>here</a> for more information.";
   NoteFieldBuildUICore(this);
   if (browseris.ie5up && browseris.win32)
   {
		RTE_ConvertTextAreaToRichEdit(
			  this.frm.stFieldPrefix+this.stName,
			  true,
			  fld.fAllowHyperlink,
			  this.stDirection,
			  L_Language_Text,
			  null,
			  null,
			  null,
			  null,
			  null,
			  null,
			  null,
			  null,
			  null,
			  null,
			  null
			 );
   }
   else
   {
	  st+="&nbsp;<br><SPAN class=ms-formdescription>"+L_strRichTextSupport_Text+"</SPAN>&nbsp;<br>";
	  document.write(st);
   }
}
RichTextField.prototype.DataBind=FieldDataBind;
RichTextField.prototype.FValidate=RichTextFieldFValidate;
function RichTextFieldFValidate()
{
   var fRet=NoteFieldFValidateCore(this);
   if (fRet && !browseris.ie5up)
   {
	  var field=this.frm.FieldPost(this);
	  var stVal=field.value;
	  var len=stVal.length;
	  if (stVal !="")
	  {
		 var finalVal=stVal;
		 var stBegin5=stVal.substr(0,5);
		 var stEnd6=stVal.substr(len-6,6);
		 stBegin5.toLowerCase();
		 stEnd6.toLowerCase();
		 if (stBegin5 !="<div>" || stEnd6 !="</div>")
		 {
			var stBegin4=stVal.substr(0,4);
			var stEnd5=stVal.substr(len-5, 5);
			stBegin4.toLowerCase();
			stEnd5.toLowerCase();
			if (stBegin4 !="<ol>" && stBegin4 !="<ul>"
				&& stEnd5 !="</ol>" && stEnd5 !="</ul>")
			{
			   var stBegin12=stVal.substr(0,12);
			   var stEnd13=stVal.substr(len-13,13);
			   stBegin12.toLowerCase();
			   stEnd13.toLowerCase();
			   if (stBegin12 !="<blockquote>" && stEnd13 !="</blockquote>")
			   {
				  var stBegin3=stVal.substr(0,3);
				  var stEnd4=stVal.substr(len-4,4);
				  stBegin3.toLowerCase();
				  stEnd4.toLowerCase();
				  if (stBegin3 !="<p>" || stEnd4 !="</p>")
				  {
					 finalVal="<div>"+stVal+"</div>";
				  }
			   }
			}
		 }
		 var CRLF=/\n([^<])/g;
		 finalVal=finalVal.replace(CRLF, "\n<br>$1");
		 field.value=finalVal;
	  }
   }
   return fRet;
}
function TextField(frm, stName, stDisplay, stValue)
{
	frm.AddField(this, stName, stDisplay, stValue);
	this.cchMaxLength="";
	this.cchDisplaySize="";
}
TextField.prototype.BuildUI=TextFieldBuildUI;
function TextFieldBuildUI()
{
	var st=this.stBuildUI();
	this.frm.BuildFieldUI(this, st);
}
TextField.prototype.stBuildUI=stTextFieldBuildUI;
function stTextFieldBuildUI()
{
	var st="";
	var cchSize;
	if (this.cchMaxLength=="")
		this.cchMaxLength=255;
	else
		this.cchMaxLength=this.cchMaxLength - 0;
	if (this.cchDisplaySize !="")
		cchSize=this.cchDisplaySize - 0;
	else if (this.cchMaxLength < 32)
		cchSize=this.cchMaxLength - 0;
	st+="<INPUT "+FormTabIndex()+" ";
	if (cchSize)
		st+=this.frm.stInputStyle+" SIZE="+cchSize;
	else
		st+=this.frm.stLongStyle;
	var strIMEMode=this.IMEMode ? " style=\"ime-mode:"+this.IMEMode+"\" " : "";
	st+=" MAXLENGTH="+this.cchMaxLength+" "+this.stAttributes+	    " TITLE="+StAttrQuote(this.stDisplay)+	    " NAME="+StAttrQuote(this.frm.stFieldPrefix+this.stName)+	    strIMEMode+		" VALUE="+StAttrQuote(this.stValue)+">\r";
	return st;
}
TextField.prototype.FieldFocus=TextFieldFieldFocus;
function TextFieldFieldFocus()
{
	var field=this.frm.FieldPost(this);
	if (!field.disabled)
	{
		field.focus();
		field.select();
		return true;
	}
	return false;
}
TextField.prototype.DataBind=FieldDataBind;
var L_TextFieldMax_Text="^1 can have no more than ^2 characters.";
TextField.prototype.FValidate=TextFieldFValidate;
function TextFieldFValidate()
{
	var field=this.frm.FieldPost(this);
	field.value=TrimWhiteSpaces(field.value);
	if (field.value.length > this.cchMaxLength)
		{
		this.stError=StBuildParam(L_TextFieldMax_Text, this.stDisplay, this.cchMaxLength);
		return false;
		}
	if (this.fRequired && field.value=="")
		{
		this.stError=StBuildParam(L_FieldRequired_Text, this.stDisplay);
		return false;
		}
	return true;
}
function FilenameField(frm, stName, stDisplay, stValue)
{
	frm.AddField(this, stName, stDisplay, stValue);
	this.cchMaxLength="";
	this.cchDisplaySize="";
	this.isFileName=true;
}
FilenameField.prototype.BuildUI=FilenameFieldBuildUI;
function FilenameFieldBuildUI()
{
	var st="";
	var cchSize;
	if (this.cchMaxLength=="")
		this.cchMaxLength=255;
	else
		this.cchMaxLength=this.cchMaxLength - 0;
	if (this.cchDisplaySize !="")
		cchSize=this.cchDisplaySize - 0;
	else if (this.cchMaxLength < 32)
		cchSize=this.cchMaxLength - 0;
	st+="<INPUT "+FormTabIndex()+" ";
	if (cchSize)
		st+=this.frm.stInputStyle+" SIZE="+cchSize;
	else
		st+=this.frm.stLongStyle;
	if (this.stValue.length > this.cchMaxLength)
	{
 		this.stValue=this.stValue.substr(0, this.cchMaxLength);
	}
	var strIMEMode=this.IMEMode ? " style=\"ime-mode:"+this.IMEMode+"\" " : "";
	st+=" MAXLENGTH="+this.cchMaxLength+" "+this.stAttributes+" NAME="+StAttrQuote(this.stName)+	      " TITLE="+StAttrQuote(this.stDisplay)+" "+			  strIMEMode+	      " VALUE="+StAttrQuote(this.stValue)+">\r";
	this.frm.BuildFieldUI(this, st);
}
FilenameField.prototype.FieldFocus=FilenameFieldFieldFocus;
function FilenameFieldFieldFocus()
{
	var field=this.frm.FilenameFieldPost(this);
	if (!field.disabled)
	{
		field.focus();
		field.select();
		return true;
	}
	return false;
}
FilenameField.prototype.DataBind=FieldDataBind;
var L_FilenameFieldMax_Text="^1 can have no more than ^2 characters.";
FilenameField.prototype.FValidate=FilenameFieldFValidate;
function FilenameFieldFValidate()
{
		var field=this.frm.FilenameFieldPost(this);
	field.value=TrimWhiteSpaces(field.value);
	if (field.value.length > this.cchMaxLength)
		{
		this.stError=StBuildParam(L_FilenameFieldMax_Text, this.stDisplay, this.cchMaxLength);
		return false;
		}
	if (this.fRequired && field.value=="")
		{
		this.stError=StBuildParam(L_FieldRequired_Text, this.stDisplay);
		return false;
		}
	return true;
}
GridChoiceField.prototype.FieldFocus=GridChoiceFieldFocus;
function GridChoiceFieldFocus()
{
	return true;
}
function GridChoiceField(frm, stName, stDisplay, stValue)
{
	frm.AddField(this, stName, stDisplay, stValue);
	this.rgGridChoices=new Array;
}
GridChoiceField.prototype.BuildUI=GridChoiceBuildUI;
function GridChoiceBuildUI()
{
	var str="";
	var i, j;
	var strDisplay=this.frm.rgfld[this.frm.ifldMax-1].stDisplay;
	var strName=this.frm.rgfld[this.frm.ifldMax-1].stName;
	var strValue=this.frm.rgfld[this.frm.ifldMax-1].stValue;
	var iGridHeight=this.rgGridChoices.length ;
	this.iGridHeight=iGridHeight;
	this.IsNew=(strValue=="");
	var cnt=99;
	var lastTxtRngCell=(STSHtmlEncode(this.GridNATxt)=="") ? "" : "<td align=right class=ms-gridT1>&nbsp;</TD>";
	str+=this.frm.StFieldPost(this);
	str+="<TABLE CELLPADDING=0 CELLSPACING=1 BORDER=0 HEIGHT=95%>\r";
	str+="<tr><TD>&nbsp;</TD><td class=ms-verticaldots>&nbsp;</td>\r";
	str+="<td  class=ms-gridT1>"+STSHtmlEncode(this.GridTxtRng1)+"&nbsp;</TD><td align=center class=ms-gridT1 colspan=";
	str+=this.GridEndNum - 2+">"+STSHtmlEncode(this.GridTxtRng2)+"</TD><td align=right class=ms-gridT1>&nbsp;"+STSHtmlEncode(this.GridTxtRng3)+"</TD>\r";
	str+=lastTxtRngCell+"</tr>\r";
	str+="<tr><TD>&nbsp;</TD><td class=ms-verticaldots>&nbsp;</td>\r";
	for (i=this.GridStartNum; (i <=this.GridEndNum && cnt > 0); i++)
	{
		str+="<td align=center class=ms-gridT1>";
		str+=i;
		str+="</TD>\r";
		cnt--;
	}
	if (STSHtmlEncode(this.GridNATxt) !="")
	{
		str+="<td align=center class=ms-gridT1>";
		str+=STSHtmlEncode(this.GridNATxt);
		str+="</TD>\r";
		str+="</tr>";
	}
	str+="<TR><td class=ms-sectionline colspan=100% height=1><img alt='' src=";
		str+=StAttrQuote(this.frm.stImagesPath+"blank.gif");
		str+="</td></TR>";
	for (i in this.rgGridChoices)
	{
		var choice=this.rgGridChoices[i];
		var num=-999;
		if (!this.IsNew)
		{
			var len=choice.stDisplay.length;
			var p=strValue.indexOf(choice.stDisplay+";#", 0);
			if (p !=-1)
			{
				var q=strValue.indexOf("#", p+len+2);
				if (q > p+len+2)
				    num=strValue.substr(p+len+2, q - (p+len+2));
			}
		}
		str+="<TR><TD align=center class=ms-gridText>";
		str+=STSHtmlEncode(choice.stDisplay);
		str+="</TD><td class=ms-verticaldots>&nbsp;</td>";
	    cnt=99;
	    endNum=(STSHtmlEncode(this.GridNATxt)=="") ? this.GridEndNum -1 : this.GridEndNum;
		for (j=this.GridStartNum; ((j <=endNum) && (cnt > 0)); j++)
		{
			str+="<td align=center><INPUT "+FormTabIndex()+" ";
			if (this.nochange=="yes")
				str+="onclick=\"window.location.reload();\"";
			str+=" TYPE=RADIO NAME=";
			str+=StAttrQuote(this.frm.StFieldName(fld, "RadioButtons:")+i);
			if ((j - 0)==(num - 0))
				str+=" checked ";
			str+="></TD>\r";
			cnt--;
		}
		str+="<td align=center><INPUT "+FormTabIndex()+" ";
		if (this.nochange=="yes")
			str+="onclick=\"window.location.reload();\"";
		str+=" TYPE=RADIO NAME=";
		str+=StAttrQuote(this.frm.StFieldName(fld, "RadioButtons:")+i);
		if ((j - 0)==(num - 0))
			str+=" checked ";
		str+="></TD>\r";
		str+="</tr>\r";
 	}
	str+="</table>";
	this.frm.BuildFieldUI(this, str);
}
GridChoiceField.prototype.FValidate=GridChoiceFValidate;
function GridChoiceFValidate()
{
	var field=this.frm.FieldPost(this);
	field.value="";
	var str="";
	var i;
	for (i in this.rgGridChoices)
	{
		var fieldControl=this.frm.FieldSubPart(this, "RadioButtons:"+i);
		endNum=(this.GridNATxt=="")? this.GridEndNum : this.GridEndNum - 0+1;
		for (j=this.GridStartNum; j <=endNum; j++)
		{
			if (fieldControl[j - this.GridStartNum].checked)
			{
				str+=this.rgGridChoices[i].stValue+";#";
				str+=(j >=0) ? "+"+j : j;
				str+="#";
				break;
			}
		}
	}
	if (this.fRequired && str=="")
	{
		this.stError=StBuildParam(L_FieldRequired_Text, this.stDisplay);
		return false;
	}
	field.value=str;
	return true;
}
GridChoiceField.prototype.AddChoice=GridChoiceAddChoice;
function GridChoiceAddChoice(stDisplay, stValue)
{
	if (stValue==null || stValue=="")
		stValue=stDisplay;
	var choice=new Object;
	choice.stDisplay=stDisplay;
	choice.stValue=stValue;
	this.rgGridChoices[this.rgGridChoices.length]=choice;
}
function ChoiceField(frm, stName, stDisplay, stValue)
{
	frm.AddField(this, stName, stDisplay, stValue);
	this.rgChoices=new Array;
	this.format="Dropdown";
	this.fFillInChoice=false;
	this.radioClass="class=ms-RadioText ";
	this.tableClass="";
}
ChoiceField.prototype.BuildUI=ChoiceBuildUI;
function ChoiceBuildUI()
{
	if (this.rgChoices.length==0)
		return;
	if (this.format !="Dropdown" &&
		this.format !="RadioButtons" &&
		this.format !="Checkboxes")
	        this.format="Dropdown";
	var st=this.stBuildUI();
	this.frm.BuildFieldUI(this, st);
	if (this.stName=="ContentType")
	{
		for (i in this.rgChoices)
		{			
			var choice=this.rgChoices[i];
			this.frm.rgctNames.push(choice.stValue);
		}
	}
}
var L_SpecifyYourOwn_Text="Specify your own value:";
var L_Choose_Text="Choose Option";
var L_FillInValue_Text="Fill-in Value";
ChoiceField.prototype.stBuildUI=stChoiceBuildUI;
function stChoiceBuildUI()
{
	if (this.rgChoices.length==0)
		return;
	var st="";
	var i;
	var stControlName="NAME="+StAttrQuote(this.frm.StFieldName(this, this.format));
	if (this.fFillInChoice)
	{
		var fillin_value="";
		var stFillInButtonName=this.frm.StFieldName(this, "FillInButton");
		if ((this.format=="RadioButtons" || this.format=="Checkboxes"))
			this.AddChoice(L_SpecifyYourOwn_Text);
	}
	st+=this.frm.StFieldPost(this);
	if (this.format=="RadioButtons")
	{
		if (this.radioClass.indexOf("valign")==-1
			&& this.radioClass.indexOf("VALIGN")==-1)
		{
			this.radioClass+=" VALIGN=MIDDLE";
		}
		st+="<TABLE CELLPADDING=0 CELLSPACING=1 "+this.tableClass+" >\r";
		var fValueMatched=false;
		for (i in this.rgChoices)
		{
			var choice=this.rgChoices[i];
			var stRawClickAttr="frm.SetRadioValue("+STSScriptEncodeWithQuote(this.stName)+", "+STSScriptEncodeWithQuote(choice.stValue)+");";
			var stTitle="";
			if (this.stDisplay.length || choice.stDisplay.length)
				stTitle=this.stDisplay+": "+choice.stDisplay;			
			stClickAttr="onclick="+StAttrQuote(stRawClickAttr);
			if (this.fIncludeMouseDown)
			{
				stClickAttr+=" onmousedown="+StAttrQuote(stRawClickAttr);
				stClickAttr+=" onkeypress="+StAttrQuote(stRawClickAttr);
				stClickAttr+=" onmousewheel="+StAttrQuote(stRawClickAttr);
			}				
			st+="<TR "+stClickAttr+">\r<TD VALIGN=TOP>"+			    "<INPUT "+FormTabIndex()+" TYPE=RADIO "+this.stAttributes+" "+stControlName+   			    " TITLE="+StAttrQuote(stTitle)+				" VALUE="+StAttrQuote(choice.stValue);
			if (this.fFillInChoice && ! fValueMatched && i==(this.rgChoices.length-1) && this.stValue !="")
			{
				st+=" CHECKED";
				fillin_value=this.stValue;
			} else if (choice.stValue==this.stValue)
			{
				st+=" CHECKED";
				fValueMatched=true;
			}
			st+="></TD>\r<TD "+this.radioClass+">";
			if (this.nobr)
				st+="<nobr>";
			st+=STSHtmlEncode(choice.stDisplay);
			if (choice.hasLayoutProc)
				st+=eval(choice.stLayoutProc+"(this, stRawClickAttr)");
			if (this.nobr)
				st+="</nobr>";
			st+="</TD>\r</TR>\r";
		}
		if (this.fFillInChoice)
		{
			fillin_value=RemoveReplaceDelimiter(fillin_value);
			var stClickAttr="frm.SetFillInButton("+STSScriptEncodeWithQuote(this.stName)+");";
			var stKeyDownAttr="frm.SetFillInButton("+STSScriptEncodeWithQuote(this.stName)+");";
			stClickAttr="onclick="+StAttrQuote(stClickAttr);
			stKeyDownAttr="onkeydown="+StAttrQuote(stKeyDownAttr);
			stControlName="NAME="+StAttrQuote(this.frm.StFieldName(fld, "FillIn"));
			if (fillin_value.length > 255)
			{
 				fillin_value=fillin_value.substr(0, 255);
			}
			st+="<TR>\r<TD VALIGN=TOP></TD>\r<TD class=ms-RadioText VALIGN=TOP>"+			      "<INPUT "+FormTabIndex()+" MAXLENGTH=255 "+			      stClickAttr+" "+stKeyDownAttr+" "+this.frm.stLongStyle+" "+this.stAttributes+" "+stControlName+   			      " TITLE="+StAttrQuote(this.stDisplay+": "+L_FillInValue_Text);
   			st+=this.IMEMode ? " style=\"ime-mode:"+this.IMEMode+"\" " : "";
   			st+=" VALUE="+STSHtmlEncode(fillin_value)+"></TD>\r</TR>\r";
		}
		st+="</TABLE>\r";
	}
	else if (this.format=="Checkboxes")
	{
		if (this.radioClass.indexOf("valign")==-1
			&& this.radioClass.indexOf("VALIGN")==-1)
		{
			this.radioClass+=" VALIGN=MIDDLE ";
		}
		st+="<TABLE CELLPADDING=0 CELLSPACING=1 "+this.tableClass+" >\r";
		stValue=this.stValue;
		fMultiValue=false;
		if (stValue.charAt(0)==';' && stValue.charAt(1)=='#')
		{
			fMultiValue=true;
		}
		var count=0;
		if (this.horizontal)
			st+="<TR>\r";
		for (i in this.rgChoices)
		{
			var choice=this.rgChoices[i];
			var stClickAttr="frm.RevertSelect("+STSScriptEncodeWithQuote(this.stName)+", "+STSScriptEncodeWithQuote(choice.stValue)+");";
			var stTitle=this.stDisplay+": "+STSHtmlEncode(choice.stDisplay);
			stClickAttr="onclick="+StAttrQuote(stClickAttr);
			if (!this.horizontal)
				st+="<TR>\r";
			st+="<TD VALIGN=TOP>";
			st+="<INPUT "+FormTabIndex()+" TYPE=CHECKBOX "+this.stAttributes+" "+stControlName+   			    " TITLE="+StAttrQuote(stTitle)+			    " VALUE="+StAttrQuote(choice.stValue);
			if (fMultiValue)
			{
				var searchPattern=";#"+choice.stValue+";#";
				var start=stValue.indexOf(searchPattern);
				if (start !=-1)
				{
					st+=" CHECKED";
					end=start+searchPattern.length;
					stValue=stValue.substr(0, start+2)+stValue.substr(end);
					if (stValue==";#;#")
						stValue="";
				}
			}
			else
			{
				if (stValue==choice.stValue)
				{
					st+=" CHECKED";
					stValue="";
				}
			}
			st+="></TD>\r<TD "+this.radioClass;
			st+=stClickAttr+">"+STSHtmlEncode(choice.stDisplay);
			st+="</TD>\r";
			if (!this.horizontal)
				st+="</TR>\r";
			else
			{
				if (this.horizontalBreakEvery
					&& 0==(++count)%this.horizontalBreakEvery)
				{
					st+="</TR>\r<TR>\r";
				}
			}
		}
		if (this.horizontal)
			st+="</TR>\r";
		fillin_value=RemoveReplaceDelimiter(stValue);
		if (this.fFillInChoice)
		{
			var stClickAttr="frm.SetFillInButton("+STSScriptEncodeWithQuote(this.stName)+");";
			var stKeyDownAttr="frm.SetFillInButton("+STSScriptEncodeWithQuote(this.stName)+");";
			stClickAttr="onclick="+StAttrQuote(stClickAttr);
			stKeyDownAttr="onkeydown="+StAttrQuote(stKeyDownAttr);
			stControlName="NAME="+StAttrQuote(this.frm.StFieldName(this, "FillIn"));
	                if (fillin_value > 255)
			{
 				fillin_value=fillin_value.substr(0, 255);
			}
			st+="<TR>\r<TD VALIGN=TOP></TD>\r<TD class=ms-RadioText VALIGN=TOP><INPUT "+FormTabIndex()+" MAXLENGTH=255 "+				  stClickAttr+" "+stKeyDownAttr+" "+this.frm.stLongStyle+" "+this.stAttributes+" "+stControlName+				  " TITLE="+StAttrQuote(this.stDisplay+": "+L_FillInValue_Text)+				  " VALUE="+STSHtmlEncode(fillin_value)+"></TD>\r</TR>\r";
		}
		st+="</TABLE>\r";
	}
	else
	{
		if (!this.horizontal)
			st+="<TABLE CELLPADDING=0 CELLSPACING=1 "+this.tableClass+" >\r";
		var fDropdownSelected=false;
		var L_FillChoice_TXT="Choice Drop Down";
		var stClickAttr="";
		if (this.fFillInChoice)
		{
			stClickAttr="frm.UnsetFillInButton("+STSScriptEncodeWithQuote(this.stName)+");";
			stClickAttr="onclick="+StAttrQuote(stClickAttr);
		}
		else if (this.stName=="ContentType")
		{
			stClickAttr="onchange=\"SwitchControls(this,false,true)\"";
		}
		var stControls="";
		if (!this.horizontal)
			stControls+="<TD";
		else
			stControls+="<SPAN";
		stControls+=" class=ms-RadioText VALIGN=TOP><SELECT TITLE=";
		if(this.fFillInChoice)
			stControls+=StAttrQuote(this.stDisplay+": "+L_FillChoice_TXT);
		else
			stControls+=StAttrQuote(this.stDisplay);
		stControls+=this.IMEMode ? " style=\"ime-mode:"+this.IMEMode+"\" " : "";
		stControls+=" "+FormTabIndex()+" "+this.stAttributes+stClickAttr+stControlName+">\r";
		for (i in this.rgChoices)
		{
			var choice=this.rgChoices[i];
			stControls+="<OPTION "+			" VALUE="+StAttrQuote(choice.stValue);
			if (choice.stValue==this.stValue)
			{
				stControls+=" SELECTED";
				fDropdownSelected=true;
			}
			stControls+=">"+STSHtmlEncode(choice.stDisplay)+"</OPTION>\r";
		}
		stControls+="</SELECT>";
		if (!this.horizontal)
			stControls+="</TD>\r";
		else
			stControls+="</SPAN>\r";
		if (this.fFillInChoice)
		{
			var stDropdownButton="<TR>\r<TD VALIGN=TOP>"+			"<INPUT "+FormTabIndex()+" TITLE="+StAttrQuote(this.stDisplay+": "+L_Choose_Text)+			" TYPE=RADIO NAME="+StAttrQuote(stFillInButtonName);
			if (fDropdownSelected ||  this.stValue=="")
			{
				stDropdownButton+=" CHECKED";
			}
			stDropdownButton+="></TD>\r"+stControls+"</TR>\r";
			stControls=stDropdownButton;
			var stClickAttr="frm.SetFillInButton("+STSScriptEncodeWithQuote(this.stName)+");";
			stClickAttr="onclick="+StAttrQuote(stClickAttr);
			stControls+="<TR "+stClickAttr+">\r<TD VALIGN=TOP><INPUT TITLE=";
			stControls+=StAttrQuote(this.stDisplay+": "+L_SpecifyYourOwn_Text);
			stControls+=this.IMEMode ? " style=\"ime-mode:"+this.IMEMode+"\" " : "";
			stControls+=" "+FormTabIndex()+" TYPE=RADIO NAME="+StAttrQuote(stFillInButtonName);
			if (!fDropdownSelected &&  this.stValue !="")
			{
				stControls+=" CHECKED";
				fillin_value=this.stValue;
			}
			stControls+="></TD>\r<TD class=ms-descriptiontext VALIGN=MIDDLE>"+L_SpecifyYourOwn_Text+"</TD>\r</TR>\r";
			fillin_value=RemoveReplaceDelimiter(fillin_value);
		    stControlName="NAME="+StAttrQuote(this.frm.StFieldName(fld, "FillIn"));
			stControls+="<TR>\r<TD VALIGN=TOP></TD>\r<TD class=ms-RadioText VALIGN=TOP><INPUT ";
			stControls+=this.IMEMode ? " style=\"ime-mode:"+this.IMEMode+"\" " : "";
			stControls+=" TITLE=";
			stControls+=StAttrQuote(this.stDisplay+": "+L_FillInValue_Text);
		    if (fillin_value > 255)
			{
 				fillin_value=fillin_value.substr(0, 255);
			}
			stControls+=" "+FormTabIndex()+" MAXLENGTH=255 "+			      stClickAttr+" "+this.frm.stLongStyle+" "+this.stAttributes+" "+stControlName+			      " VALUE="+STSHtmlEncode(fillin_value)+"></TD>\r</TR>\r";
			st+=stControls;
		}
		else
		{
			if (!this.horizontal)
				st+="<TR>"+stControls+"</TR>\r";
			else
				st+=stControls+"\r";
		}
		if (!this.horizontal)
			st+="</TABLE>\r";
	}
	return st;
}
ChoiceField.prototype.Init=ChoiceInit;
function ChoiceInit()
{
	if (this.rgChoices.length==0)
		return;
	this.SetValue(this.stValue);
}
ChoiceField.prototype.AddChoice=ChoiceAddChoice;
function ChoiceAddChoice(stDisplay, stValue)
{
	if (stValue==null || stValue=="")
		stValue=stDisplay;
	var choice=new Object;
	choice.stDisplay=stDisplay;
	choice.stValue=stValue;
	choice.hasLayoutProc=false;
	this.rgChoices[this.rgChoices.length]=choice;
	return choice;
}
ChoiceField.prototype.AddChoiceWithLayoutProc=ChoiceAddChoiceWithLayoutProc;
function ChoiceAddChoiceWithLayoutProc(stDisplay, stValue, stProc)
{
	choice=this.AddChoice(stDisplay, stValue);
	choice.stLayoutProc=stProc;
	choice.hasLayoutProc=true;
}
ChoiceField.prototype.DataBind=ChoiceDataBind;
function ChoiceDataBind()
{
	if (this.rgChoices.length==0)
		return;
	var field=this.frm.FieldPost(this);
	var fieldControl=this.GetControl();
	this.SetValue(field.value, true );
}
ChoiceField.prototype.SetValue=ChoiceSetValue;
function ChoiceSetValue(stValue, bInitializing)
{
	if (this.rgChoices.length==0)
		return;
	var i;
	var fieldControl=this.frm.FieldSubPart(this, this.format);
	if (FBlankString(stValue) || this.format=="Checkboxes")
	{
		if (this.format=="Dropdown")
			fieldControl.selectedIndex=-1;
		else
		{
			if (this.rgChoices.length !=1)
			{
				for (i in this.rgChoices)
					fieldControl[i].checked=false;
			}
			else
				fieldControl.checked=false;
		}
		if (this.fFillInChoice)
		{
			this.SetFillInValue("");
			this.UnsetFillInButton();
		}
		if (FBlankString(stValue))
  		    return;
	}
	if (this.format=="Checkboxes" &&
		stValue.charAt(0)==';' && stValue.charAt(1)=='#')
	{
		for (i in this.rgChoices)
		{
			var choice=this.rgChoices[i];
			var searchPattern=";#"+choice.stValue+";#";
			var start=stValue.indexOf(searchPattern);
			if (start !=-1)
			{
				var fieldControl=this.GetControl(i);
				fieldControl.checked=true;
				end=start+searchPattern.length;
				stValue=stValue.substr(0, start+2)+stValue.substr(end);
				if (stValue==";#;#")
					break;
			}
		}
		if (this.fFillInChoice)
		{
			if (stValue.length >=4 && stValue.indexOf(";#;#")==stValue.length - 4)
				stValue=stValue.substr(0, stValue.length - 2);
			stValue=RemoveReplaceDelimiter(stValue);
			if (stValue !="")
				this.SetFillInValue(stValue);
			else
			{
				this.UnsetFillInButton();
				if (bInitializing)
					this.GetFillInControl().value="";
			}
		}
		return;
	}
	var fFillInValue=true;
	for (i in this.rgChoices)
	{
		var choice=this.rgChoices[i];
		if (choice.stValue==stValue)
		{
			if (this.format=="Dropdown")
			{
				if (this.stName !="ContentType")
				{
					fieldControl.selectedIndex=i;
				}
				else
				{
					var iopt;
					for (iopt=0; iopt < fieldControl.options.length; iopt++)
					{
						if (fieldControl.options[iopt].value==stValue)
						{
							fieldControl.selectedIndex=iopt;
							break;
						}
					}
				}	
			}
			else
			{
				var fieldControl=this.GetControl(i);
				fieldControl.checked=true;
			}
			fFillInValue=false;
			break;
		}
	}
	if (this.fFillInChoice)
	{
		if (fFillInValue || stValue==L_SpecifyYourOwn_Text)
		{
			if (stValue !=L_SpecifyYourOwn_Text)
				this.SetFillInValue(stValue);
		}
		else
		{
			this.UnsetFillInButton();
			if (bInitializing)
				this.GetFillInControl().value="";
		}
	}
	return;
}
ChoiceField.prototype.GetControl=ChoiceGetControl;
function ChoiceGetControl(i)
{
	var fieldControl=this.frm.FieldSubPart(this, this.format);
	if ((this.format=="RadioButtons" || this.format=="Checkboxes")
		&& this.rgChoices.length !=1)
	{
		if (i !=null)
			return fieldControl[i];
		for (i in this.rgChoices)
		{
			if (fieldControl[i].checked)
				return fieldControl[i];
		}
		return fieldControl[0];
	}
	else
		return fieldControl;
}
ChoiceField.prototype.GetFillInButtonControl=ChoiceGetFillInButtonControl;
function ChoiceGetFillInButtonControl()
{
	if (this.format=="Dropdown")
	{
		var fillInButtonControl=this.frm.FieldSubPart(this, "FillInButton");
		return (fillInButtonControl[1]);
	}
	else
	{
		var fieldControl=this.frm.FieldSubPart(this, this.format);
		return (fieldControl[this.rgChoices.length-1]);
	}
}
ChoiceField.prototype.GetFillInControl=ChoiceGetFillInControl;
function ChoiceGetFillInControl()
{
	return this.frm.FieldSubPart(this, "FillIn");
}
ChoiceField.prototype.FieldFocus=ChoiceFieldFocus;
function ChoiceFieldFocus()
{
	if (this.rgChoices.length==0)
		return false;
	var bSelectedFillInChoice=false;
	if (this.fFillInChoice)
	{
		if (this.format=="RadioButtons" || this.format=="Checkboxes")
		{
			var fieldControl=this.frm.FieldSubPart(this, this.format);
			for (i in this.rgChoices)
			{
				if (fieldControl[i].checked)
					break;
			}
			if (i==(this.rgChoices.length-1))
				bSelectedFillInChoice=true;
		}
		else
		{
			var fillInButton=this.GetFillInButtonControl();
			if (fillInButton.checked)
				bSelectedFillInChoice=true;
		}
	}
	if (bSelectedFillInChoice)
		var field=this.GetFillInControl();
	else
		var field=this.GetControl();
	if (!field.disabled)
	{
		field.focus();
		return true;
	}
	return false;	
}
ChoiceField.prototype.FValidate=ChoiceFValidate;
function ChoiceFValidate()
{
	if (this.rgChoices.length==0)
		return;
	var field=this.frm.FieldPost(this);
	field.value="";
	if (this.fFillInChoice)
	{
		var fillInButtonControl=this.GetFillInButtonControl();
		var fillInControl=this.GetFillInControl();
	}
	if (this.format=="Checkboxes" && this.rgChoices.length !=1)
		var fieldControl=this.frm.FieldSubPart(this, this.format);
	else
		var fieldControl=this.GetControl();
	if (this.format=="Dropdown")
	{
		if (this.fFillInChoice && fillInButtonControl.checked)
		{
			if (-1 !=fillInControl.value.indexOf(";#"))
			{
				var L_InvalidFillIn_Text="Fill in value can't contain string ;#.";
				this.stError=StBuildParam(L_InvalidFillIn_Text, this.stDisplay);
				return false;
			}
			field.value=TrimWhiteSpaces(fillInControl.value);
		}
		else
		{
			if (fieldControl.selectedIndex !=-1)
				field.value=fieldControl[fieldControl.selectedIndex].value;
		}
	}
	else if (this.format=="Checkboxes" && this.rgChoices.length !=1)
	{
		var stValue="";
		var stSingleValue="";
		var numOfValues=0;
		for (var i in this.rgChoices)
		{
			if (fieldControl[i].checked==true)
			{
				if (this.fFillInChoice && i==this.rgChoices.length-1)
				{
					var stFillInValue=TrimWhiteSpaces(fillInControl.value);
					if (stFillInValue=="")
						break;
					if (-1 !=stFillInValue.indexOf(";#"))
					{
						var L_InvalidFillIn_Text="Fill in value can't contain string ;#.";
						this.stError=StBuildParam(L_InvalidFillIn_Text, this.stDisplay);
						return false;
					}
					stSingleValue=stFillInValue;
				}
				else
					stSingleValue=this.rgChoices[i].stValue;
				numOfValues++;
				if (numOfValues==1)
					stValue=stSingleValue;
				else if (numOfValues==2)
					stValue=";#"+stValue+";#"+stSingleValue+";#";
				else
					stValue+=stSingleValue+";#";
			}
		}
		field.value=stValue;
	}
	else
	{
		if (this.fFillInChoice && fillInButtonControl.checked)
		{
			if (-1 !=fillInControl.value.indexOf(";#"))
			{
				var L_InvalidFillIn_Text="Fill in value can't contain string ;#.";
				this.stError=StBuildParam(L_InvalidFillIn_Text, this.stDisplay);
				return false;
			}
			field.value=TrimWhiteSpaces(fillInControl.value);
		}
		else if (fieldControl.checked)
			field.value=fieldControl.value;
	}
	if (this.fRequired && field.value=="")
	{
		this.stError=StBuildParam(L_FieldRequired_Text, this.stDisplay);
		return false;
	}
	if (this.frm.wBaseType==1 && field.value && field.value.length > 255)
	{
		this.stError=StBuildParam(L_TextFieldMax_Text, this.stDisplay, 255);
		return false;
	}
	return true;
}
ChoiceField.prototype.RevertSelect=ChoiceRevertSelect;
function ChoiceRevertSelect(stValue)
{
	if (stValue=="")
		return;
	for (i in this.rgChoices)
	{
		var choice=this.rgChoices[i];
		if (choice.stValue==stValue)
		{
			var fieldControl=this.GetControl(i);
			if (fieldControl.checked)
				fieldControl.checked=false;
			else
			{
				fieldControl.checked=true;
				if (this.fFillInChoice &&
					i==(this.rgChoices.length - 1))
				{
					var field=this.GetFillInControl();
			   		if (!field.disabled)
						field.focus();
				}
			}
			break;
		}
	}
}
ChoiceField.prototype.SetFillInButton=ChoiceFieldSetFillInButton;
function ChoiceFieldSetFillInButton()
{
	var fillInButton=this.GetFillInButtonControl();
	fillInButton.checked=true;
	var fillInControl=this.GetFillInControl();
	fillInControl.focus();
}
ChoiceField.prototype.UnsetFillInButton=ChoiceFieldUnsetFillInButton;
function ChoiceFieldUnsetFillInButton()
{
	if (this.format=="Dropdown")
	{
		var fillInButtonControl=this.frm.FieldSubPart(this, "FillInButton");
		fillInButtonControl[0].checked=true;
	} else
	{
		var fillInButton=this.GetFillInButtonControl();
		fillInButton.checked=false;
	}
}
ChoiceField.prototype.SetFillInValue=ChoiceSetFillInValue;
function ChoiceSetFillInValue(stValue)
{
	var fillInButton=this.GetFillInButtonControl();
	fillInButton.checked=true;
	var fillInControl=this.GetFillInControl();
	fillInControl.value=stValue;
}
function RemoveReplaceDelimiter(stValue)
{
	stValue=stValue.replace(/^;#/g, "");
	stValue=stValue.replace(/;#$/g, "");
	stValue=stValue.replace(/;#/g, "; ");
	return stValue;
}
var _RecurDateRangeDiv="recurDateRangeDiv";
var _RecurPatternTextDiv="recurPatternTextDiv";
var _RecurDailyDiv="recurDailyDiv";
var _RecurWeeklyDiv="recurWeeklyDiv";
var _RecurMonthlyDiv="recurMonthlyDiv";
var _recurFld;	
function RecurrencePattern(frm, stName, stDisplayName)
{
	var L_RecurPatternNone_Text="None";
	var L_RecurPatternCustom_Text="Custom";
	var L_RecurPatternDaily_Text="Daily";
	var L_RecurPatternWeekly_Text="Weekly";
	var L_RecurPatternMonthly_Text="Monthly";
	var L_RecurPatternYearly_Text="Yearly";
	var L_RangeTypeNone_Text="No end date";
	var L_RangeTypeCount_Text="End after: ";
	var L_RangeTypeEndDate_Text="End by: ";
	frm.AddField(this, stName, stDisplayName, "");
	this.fSkipValidation=true;
	this.isModifyException=false;
	this.isNewModifyException=false;
	this.stStartDate="";
	this.stEndDate="";
	this.caltype=1;
	this.todayiso="";
	this.stPrefix="RecurrencePattern#";
	this.iCustom="1";
	this.fDoCustom=false;
	this.rgStRecurType=new Array(
							L_RecurPatternNone_Text,
							L_RecurPatternCustom_Text,
							L_RecurPatternDaily_Text,
							L_RecurPatternWeekly_Text,
							L_RecurPatternMonthly_Text,
							L_RecurPatternYearly_Text);
	var ccRecurType=0;
	for (i in this.rgStRecurType)
		ccRecurType=Math.max(ccRecurType, this.rgStRecurType[i].length);
	this.ccRecurType=ccRecurType+14;
	this.rgStRangeType=new Array(
						L_RangeTypeNone_Text,
						L_RangeTypeCount_Text,
						L_RangeTypeEndDate_Text);
	var L_DayFrequency_Text="1";
	var L_WeekFrequency_Text="1";
	var L_Monthly1DayValue_Text="1";
	var L_MonthFrequency_Text="1";
	var L_DateRangeEndOccurrencesValue_Text="10";
	this.recurrencePatternChoice="0";
	this.monthlyChoiceValue="0";
	this.dateRangeEndChoice="0";
	this.dayFrequency=L_DayFrequency_Text;
	this.weekFrequency=L_WeekFrequency_Text;
	this.monthFrequency1=L_MonthFrequency_Text;
	this.monthFrequency2=L_MonthFrequency_Text;
	this.weeklyDayMultiValue=";#"+frm.dopt.Today().getUTCDay()+";#";
	this.monthly1DayValue=L_Monthly1DayValue_Text;
	this.monthly2DayValue="0";
	this.monthly2WeekValue="0";
	this.dateRangeStart=DateOptions.StISODate(this.frm.dopt.Today());
	this.dateRangeEnd=DateOptions.StISODate(this.frm.dopt.Today());
	this.dateRangeEndOccurrences=L_DateRangeEndOccurrencesValue_Text;
}
RecurrencePattern.prototype.BuildUI=RecurrencePatternBuildUI;
function RecurrencePatternBuildUI()
{
	var L_DateRange_Text="Date Range";
	var L_Pattern_Text="Pattern";
	var L_StartDateRange_Text="Start Date";
	if (this.recurrencePatternChoice < 0
		|| this.recurrencePatternChoice > this.rgStRecurType.length)
		this.recurrencePatternChoice="0";
	if (this.dateRangeEndChoice < 0
		|| this.dateRangeEndChoice > this.rgStRangeType.length)
		this.dateRangeEndChoice="0";
	if (this.monthlyChoiceValue < 0
		|| this.monthlyChoiceValue > 2)
		this.monthlyChoiceValue=0;
	var st="";
	if (this.isModifyException || this.isNewModifyException)
	{
		if (this.isModifyException)
			{
				st+="<INPUT TYPE=HIDDEN NAME="+StAttrQuote(this.frm.stFieldPrefix+this.stPrefix+"Modify:"+this.stName)
+"VALUE='TRUE'>\r";
			}
		else if (this.isNewModifyException)
			{
				st+="<INPUT TYPE=HIDDEN NAME="+StAttrQuote(this.frm.stFieldPrefix+this.stPrefix+"NewModify:"+this.stName)
+"VALUE='TRUE'>\r";
				st+="<INPUT TYPE=HIDDEN NAME="+StAttrQuote(this.frm.stFieldPrefix+fld.stRecurrenceIDName)
+"VALUE="+StAttrQuote(this.stRecurrenceID)+">\r";
				st+="<INPUT TYPE=HIDDEN NAME="+StAttrQuote(this.frm.stFieldPrefix+fld.stUIDName)
+"VALUE="+StAttrQuote(this.stUID)+">\r";
			}
		if (this.stRecurrenceDescription)		
			st+=STSHtmlEncode(this.stRecurrenceDescription);
		document.write(st);
		this.eventHook=new RecurrencePatternEventHooks(this, this.frm, null, this.stStartDate, this.stEndDate);
		this.eventHook.value=0;
		this.eventHook.Init();
		return;
	}
	var dateFld=this.frm.FindField(this.stStartDate);
	if (dateFld)
	{
		st+="<INPUT TYPE=HIDDEN NAME="+StAttrQuote(this.frm.stFieldPrefix+this.stPrefix+"oldStartDate:"+this.stName)
+"VALUE='";
		st+=dateFld.stValue;
		st+="'>\r";
	}
	_recurFld=this;
	st+="<table border='0' cellpadding='0' cellspacing='0' class='ms-formrecurrence'>\r";
	st+="<tr><td rowspan='5' nowrap>\r";
	st+=RecurrencePatternTypes(this);
	st+="</td>";
	st+="<td rowspan='5' nowrap><IMG width=40pt height=1pt SRC="
+StAttrQuote(this.frm.stImagesPath+"blank.gif")+">"	
+"</td></tr>\r";
	st+="<tr><td nowrap valign='top'><div ID='"+_RecurPatternTextDiv+"' ";
	if (this.recurrencePatternChoice > "1")
		st+="style='display:none'";	
	st+=">\r";
	st+="<nobr><span class='ms-formdescription'>"
+L_Pattern_Text
+"</span></nobr>";
	st+="</div></td></tr>\r";
	st+="<tr><td nowrap valign='top' rowspan='4' height=68pt><table border='0' cellpadding='0' cellspacing='0' class='ms-formrecurrence'>";
	st+="<tr><td nowrap><IMG width=12pt height=1pt SRC="
+StAttrQuote(this.frm.stImagesPath+"blank.gif")+"></td></tr>";	
	st+="<tr><td nowrap valign='top'><div ID='"+_RecurDailyDiv+"' ";
	if (this.recurrencePatternChoice !="2")
		st+="style='display:none'";
	st+=">\r";
	st+=RecurrencePatternDaily(this);
	st+="</div></td></tr>\r";
	st+="<tr><td nowrap valign='top'><div ID='"+_RecurWeeklyDiv+"' ";
	if (this.recurrencePatternChoice !="3")
		st+="style='display:none'";
	st+=">\r";
	st+=RecurrencePatternWeekly(this);
	st+="</div></td></tr>\r";
	st+="<tr><td nowrap valign='top'><div ID='"+_RecurMonthlyDiv+"' ";
	if (this.recurrencePatternChoice !="4")
		st+="style='display:none'";
	st+=">\r";
	st+=RecurrencePatternMonthly(this);
	st+="</div></td></tr></table></td></tr></table>\r";
	document.write(st);
	st="<div ID='"+_RecurDateRangeDiv+"' ";
	if (this.recurrencePatternChoice > "1")
		st+="style='display:none'";	
	st+=">\r";
	st+="<table border='0' cellpadding='0' cellspacing='0' class='ms-formrecurrence'><tr>\r";
	st+="<td nowrap><IMG width=116pt height=1pt SRC="
+StAttrQuote(this.frm.stImagesPath+"blank.gif")+">"	
+"</td>";
	st+="<td valign=top nowrap><nobr><span class='ms-formdescription'>"
+L_DateRange_Text
+"</span><br><br>"
+L_StartDateRange_Text
+"</nobr><br>";
	st+=RecurrenceDateRangeStart(this);
	st+="</td>";
	st+="<td nowrap><IMG width=10pt height=1pt SRC="
+StAttrQuote(this.frm.stImagesPath+"blank.gif")+">"	
+"</td><td nowrap><br><br>";
	st+=RecurrenceDateRangeEnd(this);
	st+="</td></tr></table></div>\r";
	document.write(st);
	_recurFld=null;
}
RecurrencePattern.prototype.Init=RecurrencePatternInit;
function RecurrencePatternInit()
{	
	if (this.isModifyException || this.isNewModifyException)
	{
		var dateFld=this.frm.FindField(this.stEndDate);
		if (dateFld)
			dateFld.fRequired=true;
	}
}
function RecurrencePatternTypes(recurFld)
{
	var st="";
	var L_RecurrenceType_Text="Recurrence Type";
	fld=new ChoiceField(recurFld.frm,
								recurFld.stPrefix+"Type:"+recurFld.stName,
								L_RecurrenceType_Text,
								recurFld.recurrencePatternChoice);
	fld.format="RadioButtons";
	fld.radioClass="class=ms-radiotext ";
	for (i in recurFld.rgStRecurType)
	{
		var stI="";
		if (i !=recurFld.iCustom || recurFld.fDoCustom )
		{
			stI=i;
			fld.AddChoice(recurFld.rgStRecurType[i], stI);
		}
	}
	st+=fld.stBuildUI();
	recurFld.eventHook=new RecurrencePatternEventHooks(recurFld, recurFld.frm, fld, recurFld.stStartDate, recurFld.stEndDate);
	recurFld.eventHook.Init();
	return st;
}
function RecurrencePatternDaily(recurFld)
{
	var st="";
	var L_Daily_Text="Recur every ^1 day(s)";
	var L_DailyDisplay_Text="The number of days between recurrences of this event";
	var fld=new NumberField(recurFld.frm,
						recurFld.stPrefix+"daily_dayFrequency:"+recurFld.stName,
						L_DailyDisplay_Text,
						recurFld.dayFrequency);
	fld.cchDisplaySize=3;
	fld.wMin=1;
	fld.wMax=255;
	fld.fInteger=true;
	fld.fSkipValidation=true;
	_recurFld.dayFrequencyFld=fld;
	var cntrl1=fld.stBuildUI();
	st=StBuildParam(L_Daily_Text, cntrl1);
	st+="<p><p>";
	return st;
}
var L_Monday_Text="Monday";
var L_Tuesday_Text="Tuesday";
var L_Wednesday_Text="Wednesday";
var L_Thursday_Text="Thursday";
var L_Friday_Text="Friday";
var L_Saturday_Text="Saturday";
var L_Sunday_Text="Sunday";
function RecurrencePatternWeekly(recurFld)
{
	var L_Weekly_Text="Recur every ^1 week(s) on:^2";
	var L_WeeklyRecurDisplay_Text="The number of weeks between recurrences of this event";
	var L_WeeklyDayChoiceDisplay_Text="the day(s) of the week on which this event occurs";
	var fld=new NumberField(recurFld.frm,
						recurFld.stPrefix+"weekly_weekFrequency:"+recurFld.stName,
						L_WeeklyRecurDisplay_Text,
						recurFld.weekFrequency);
	fld.cchDisplaySize=3;
	fld.wMin=1;
	fld.wMax=52;
	fld.fInteger=true;
	fld.fSkipValidation=true;
	recurFld.weeklyFrequencyFld=fld;
	var cntrl1=fld.stBuildUI();
	var dayChoice=new Array(L_Sunday_Text, L_Monday_Text, L_Tuesday_Text,
							  L_Wednesday_Text, L_Thursday_Text, L_Friday_Text,
							  L_Saturday_Text);
	var stSourceURL=StURLGetVar("Source");
	if (stSourceURL.length)
	{
		stSourceURL=unescape(stSourceURL);
		var stCalDate=StSearchVar(stSourceURL, "CalendarDate");
		var stCalPeriod=StSearchVar(stSourceURL, "CalendarPeriod");
		if (stCalPeriod=="day" && stCalDate.length)
		{
			var isoDate=DateOptions.ParseISODate(stCalDate);
			if (!isNaN(isoDate))
				recurFld.weeklyDayMultiValue=";#"+isoDate.getUTCDay()+";#";
		}
	}
	fld=new ChoiceField(recurFld.frm,
						recurFld.stPrefix+"weekly_multiDays:"+recurFld.stName,
						L_WeeklyDayChoiceDisplay_Text,
						recurFld.weeklyDayMultiValue);
	fld.format="Checkboxes";
	fld.radioClass=" class=ms-input valign=baseline ";
	fld.tableClass=" class=ms-formrecurrence ";
	fld.horizontal=true;
	fld.horizontalBreakEvery=4;
	recurFld.weeklyMultiDayFld=fld;
	var stI="";
	for (i in dayChoice)
	{
		stI=i;
		fld.AddChoice(dayChoice[i], stI);
	}
	var cntrl2="<DIV>"+fld.stBuildUI()+"</DIV>";
	return StBuildParam(L_Weekly_Text, cntrl1, cntrl2);
}
function RecurrencePatternMonthly(recurFld)
{
	fld=new ChoiceField(recurFld.frm,
						recurFld.stPrefix+"MonthlyRecurType:"+recurFld.stName,
						"",
						recurFld.monthlyChoiceValue);
	fld.format="RadioButtons";
	fld.radioClass="class=ms-input valign=baseline";
	fld.tableClass=" class=ms-formrecurrence ";
	fld.fIncludeMouseDown=true;
	fld.nobr=true;
	recurFld.monthlyChoiceFld=fld;
	fld.AddChoiceWithLayoutProc("", "0", "RecurrencePatternMonthly1");
	fld.AddChoiceWithLayoutProc("", "1", "RecurrencePatternMonthly2");
	var st=fld.stBuildUI();
	return st;
}
function RecurrencePatternMonthly1(choiceFld)
{
	var L_Monthly1_Text="Day ^1 of every ^2 month(s)";
	var L_Monthly1DayDisplay_Text="The date each month that this event occurs";
	var L_Monthly1MonthDisplay_Text="The number of months between recurrences";
	var fld=new NumberField(_recurFld.frm,
						_recurFld.stPrefix+"monthly_day:"+_recurFld.stName,
						L_Monthly1DayDisplay_Text,
						_recurFld.monthly1DayValue);
	fld.cchDisplaySize=2;
	fld.wMin=1;
	fld.wMax=31;
	fld.fInteger=true;
	fld.fSkipValidation=true;
	_recurFld.monthlyChoice1DayFld=fld;
	var cntrl1=fld.stBuildUI();
	var fld=new NumberField(_recurFld.frm,
						_recurFld.stPrefix+"monthly_monthFrequency:"+_recurFld.stName,
						L_Monthly1MonthDisplay_Text,
						_recurFld.monthFrequency1);
	fld.cchDisplaySize=2;
	fld.wMin=1;
	fld.wMax=12;
	fld.fInteger=true;
	fld.fSkipValidation=true;
	_recurFld.monthlyChoice1MonthFreqFld=fld;
	var cntrl2=fld.stBuildUI();
	return StBuildParam(L_Monthly1_Text, cntrl1, cntrl2);
}
function RecurrencePatternMonthly2(choiceFld)
{
	var L_Monthly2_Text="The ^1^2 of every ^3 month(s)";
	var L_Monthly2WhichWeekDisplay_Text="The week each month that this event occurs";
	var L_Monthly2DayDisplay_Text="The day of the week on which this event occurs";
	var L_Monthly2MonthDisplay_Text
="The number of months between recurrences";
	var L_FirstWeek_Text="first";
	var L_SecondWeek_Text="second";
	var L_ThirdWeek_Text="third";
	var L_FourthWeek_Text="fourth";
	var L_LastWeek_Text="last";
	var weekChoice=new Array(L_FirstWeek_Text, L_SecondWeek_Text, L_ThirdWeek_Text,
							   L_FourthWeek_Text, L_LastWeek_Text);
	var dayChoice=new Array(L_Sunday_Text, L_Monday_Text, L_Tuesday_Text, L_Wednesday_Text,
							  L_Thursday_Text, L_Friday_Text, L_Saturday_Text);
	fld=new ChoiceField(_recurFld.frm,
								_recurFld.stPrefix+"monthlyByDay_weekOfMonth:"+_recurFld.stName,
								L_Monthly2WhichWeekDisplay_Text,
								_recurFld.monthly2WeekValue);
	fld.horizontal=true;
	for (i in weekChoice)
	{
		var stI="";
		stI=i;
		fld.AddChoice(weekChoice[i], stI);
	}
	var cntrl1=fld.stBuildUI();
	fld=new ChoiceField(_recurFld.frm,
								_recurFld.stPrefix+"monthlyByDay_day:"+_recurFld.stName,
								L_Monthly2DayDisplay_Text,
								_recurFld.monthly2DayValue);
	fld.horizontal=true;
	for (i in dayChoice)
	{
		var stI="";
		stI=i;
		fld.AddChoice(dayChoice[i], stI);
	}
	var cntrl2=fld.stBuildUI();
	var fld=new NumberField(_recurFld.frm,
						_recurFld.stPrefix+"monthlyByDay_monthFrequency:"+_recurFld.stName,
						L_Monthly2MonthDisplay_Text,
						_recurFld.monthFrequency2);
	fld.cchDisplaySize=2;
	fld.wMin=1;
	fld.wMax=12;
	fld.fInteger=true;
	fld.fSkipValidation=true;
	_recurFld.monthlyChoice2MonthFreqFld=fld;
	var cntrl3=fld.stBuildUI();
	return StBuildParam(L_Monthly2_Text, cntrl1, cntrl2, cntrl3);
}
function RecurrenceDateRangeStart(recurFld)
{
	var st="<nobr>\r";
	var L_DateRangeStartDisplay_Text="When this event begins";
	fld=new DateField(recurFld.frm,
					recurFld.stPrefix+"windowStart:"+recurFld.stName,
					L_DateRangeStartDisplay_Text,
					recurFld.todayiso);
	fld.fRequired=true;
	fld.fSkipValidation=true;
	fld.caltype=recurFld.caltype;
	recurFld.dateRangeFldStart=fld;
	fld.fDateOnly=true;
	fld.fHideDateSpan=true;
	st+=fld.stBuildUI();
	st+="</nobr>\r";
	return st;
}
function RecurrenceDateRangeEnd(recurFld)
{
	var L_DateRangeTypeDisplay_Text="The date this event ends";
	fld=new ChoiceField(recurFld.frm,
					recurFld.stPrefix+"EndDateRangeType:"+recurFld.stName,
					L_DateRangeTypeDisplay_Text,
					recurFld.dateRangeEndChoice);
	recurFld.endRangeOptionFld=fld;
	fld.format="RadioButtons";
	fld.tableClass="class='ms-formrecurrence'";
	fld.radioClass="class=ms-input valign=baseline";
	fld.fIncludeMouseDown=true;
	fld.nobr=true;
	fld.AddChoice(recurFld.rgStRangeType[0], "0");
	fld.AddChoiceWithLayoutProc(recurFld.rgStRangeType[1],
								"1",
								"RecurrenceEndDateRange1");
	fld.AddChoiceWithLayoutProc(recurFld.rgStRangeType[2],
								"2",
								"RecurrenceEndDateRange2");
	return fld.stBuildUI();
}
function RecurrenceEndDateRange1(choiceFld)
{
	var L_EndDateRange_Text="^1 occurrence(s)";
	var L_DateRangeOccurrencesDisplay_Text="The number of times this event recurs";
	var fld=new NumberField(_recurFld.frm,
						_recurFld.stPrefix+"repeatInstances:"+_recurFld.stName,
						L_DateRangeOccurrencesDisplay_Text,
						_recurFld.dateRangeEndOccurrences);
	fld.cchDisplaySize=4;
	fld.wMin=1;
	fld.wMax=999;
	fld.fInteger=true;
	fld.fSkipValidation=true;
	_recurFld.dateRangeFldEndOccurrances=fld
	var cntrl1=fld.stBuildUI();
	return StBuildParam(L_EndDateRange_Text, cntrl1);
}
function RecurrenceEndDateRange2(choiceFld, stPopUpOnClick2)
{
	var L_DateRangeEndDisplay_Text="When this event ends";
	var fld=new DateField(_recurFld.frm,
						_recurFld.stPrefix+"windowEnd:"+_recurFld.stName,
						L_DateRangeEndDisplay_Text,
						"");
	fld.fRequired=true;
	fld.fSkipValidation=true;	
	fld.caltype=_recurFld.caltype;
	_recurFld.dateRangeFldEnd=fld;
	fld.fDateOnly=true;
	fld.fHideDateSpan=true;
	fld.stPopUpOnClick2=stPopUpOnClick2;
	return fld.stBuildUI();
}
function RecurrencePatternEventHooks(recurFld, frm, typeFld, stStartDate, stEndDate)
{
	this.recurFld=recurFld;
	this.frm=frm;
	this.typeFld=typeFld;
	this.stStartDate=stStartDate;
	this.stEndDate=stEndDate;
	frm.AddField(this, "RecurrencePatternType", "Date range, end pattern", 0);
	if (typeFld)
		typeFld.stAlias="RecurrencePatternType";
	this.rgStPatternTypes=new Array(
						"",
						"",
						_RecurDailyDiv,
						_RecurWeeklyDiv,
						_RecurMonthlyDiv,
						"" );
	this.value=-1;
}
RecurrencePatternEventHooks.prototype.Init=RecurrencePatternEventHooksInit;
function RecurrencePatternEventHooksInit()
{
	this.dateFldStart=this.frm.FindField(this.recurFld.stStartDate);
	this.dateFldEnd=this.frm.FindField(this.recurFld.stEndDate);
	this.dateRangeFldStart=this.recurFld.dateRangeFldStart;
	this.dateRangeFldEnd=this.recurFld.dateRangeFldEnd;
	var stID="";
	stID=StURLGetVar("ID");
	if (0==stID.length)
	{
		if (this.dateFldStart)
		{
			var stSourceURL=StURLGetVar("Source");
			if (stSourceURL.length)
			{
				stSourceURL=unescape(stSourceURL);
				var stCalDate=StSearchVar(stSourceURL, "CalendarDate");
				var stCalPeriod=StSearchVar(stSourceURL, "CalendarPeriod");
				if (stCalPeriod=="day" && stCalDate.length)
				{
					var isoDate=DateOptions.ParseISODate(stCalDate);
					if (!isNaN(isoDate))
					{
						stCalDate=this.frm.dopt.StDate(isoDate);
						var dateFld=this.frm.FieldSubPart(this.dateFldStart, "Date");
						dateFld.value=stCalDate;
					}
				}
			}
			var disableSave=this.dateFldStart.disabled;
			this.dateFldStart.disabled=false;
			if (this.dateFldStart.FValidate() && this.dateFldStart.date)
			{
				this.dateFldStart.date.setUTCHours(0,0,0,0);		
				this.frm.dopt.SetTimeControls(this.dateFldStart, this.dateFldStart.date);
			}
			this.dateFldStart.disabled=disableSave;
		}
	}	
	this.DateToDateRange();
	this.InitHooks();
}
RecurrencePatternEventHooks.prototype.InitHooks=DoInitRecurrencePatternEventHooks;
function DoInitRecurrencePatternEventHooks()
{
	this.divtags=document.getElementsByTagName("div");
	this.stRecurDateRangeDiv=this.divtags[_RecurDateRangeDiv];
	this.stRecurPatternTextDiv=this.divtags[_RecurPatternTextDiv];
	var spantags=document.getElementsByTagName("span");
	this.stStartDateSpan=spantags[this.frm.StFieldNameFactory(this.stStartDate,"DateSpan")];
	this.stEndDateSpan=spantags[this.frm.StFieldNameFactory(this.stEndDate,"DateSpan")];
	if (this.typeFld)
		this.ToggleDisplay(this.typeFld.stValue, true);
}
RecurrencePatternEventHooks.prototype.FValidate=RecurrencePatternValidate;
function RecurrencePatternValidate()
{
	var L_DateRangeOrdering_Text="The start date and time are after the end date and time.";
	this.errFld=0;
	if (this.value==0)
	{
		if (!this.dateFldEnd.FValidate()
			|| !this.dateFldEnd.date)
		{
			var hr=this.frm.GetSelValue(this.frm.StFieldName(this.dateFldEnd, "Hours")) - 0;
			var min=this.frm.GetSelValue(this.frm.StFieldName(this.dateFldEnd, "Minutes"));
			if (hr !=0 || min !=0)
				this.CopyDateFld(this.dateFldStart, this.dateFldEnd);
		}
		if (this.dateFldStart.FValidate()
			&& this.dateFldEnd.FValidate()
			&& this.dateFldStart.date
			&& this.dateFldEnd.date
			&& this.dateFldEnd.date.getTime() < this.dateFldStart.date.getTime())
		{
			this.errFld=this.dateFldStart;
			this.errFld.stError=L_DateRangeOrdering_Text;
			return false;
		}
	}
	else if (this.value >=2)
	{
		if (!this.dateRangeFldStart.FValidate())
		{
			this.errFld=this.dateRangeFldStart;
			return false;
		}
		if (this.recurFld.endRangeOptionFld
			&& this.recurFld.endRangeOptionFld.FValidate())
		{
			var endRangeOptionFldPost=this.frm.FieldPost(this.recurFld.endRangeOptionFld);
			var fValidEndDate=this.dateRangeFldEnd.FValidate();
			if ( !endRangeOptionFldPost
				|| endRangeOptionFldPost.value=="2")
			{
				if (!fValidEndDate)
				{
					this.errFld=this.dateRangeFldEnd;
					return false;
				}
				if (this.dateRangeFldEnd.date.getTime() <
					this.dateRangeFldStart.date.getTime())
				{
					this.errFld=this.dateRangeFldStart;
					this.errFld.stError=L_DateRangeOrdering_Text;
					return false;
				}
			}
			else if (endRangeOptionFldPost.value=="1")
			{
				if (this.recurFld.dateRangeFldEndOccurrances)
				{
					this.recurFld.dateRangeFldEndOccurrances.fRequired=true;
					var fValid=this.recurFld.dateRangeFldEndOccurrances.FValidate();
					this.recurFld.dateRangeFldEndOccurrances.fRequired=false;
					if (!fValid)
					{
						this.errFld=this.recurFld.dateRangeFldEndOccurrances;
						return false;
					}
				}
				if (!fValidEndDate)
				{
					this.CopyDateFld(this.dateRangeFldStart, this.dateRangeFldEnd);
				}
			}
			else if (!fValidEndDate)
			{
				this.CopyDateFld(this.dateRangeFldStart, this.dateRangeFldEnd);
			}
		}
		if (this.value==2)
		{
			if (this.recurFld.dayFrequencyFld)
			{
				this.recurFld.dayFrequencyFld.fRequired=true;
				var fValid=this.recurFld.dayFrequencyFld.FValidate();
				this.recurFld.dayFrequencyFld.fRequired=false;
				if (!fValid)
				{
					this.errFld=this.recurFld.dayFrequencyFld;
					return false;
				}
			}
		}
		else if (this.value==3)
		{
			if (this.recurFld.weeklyFrequencyFld)
			{
				this.recurFld.weeklyFrequencyFld.fRequired=true;
				var fValid=this.recurFld.weeklyFrequencyFld.FValidate();
				this.recurFld.weeklyFrequencyFld.fRequired=false;
				if (!fValid)
				{
					this.errFld=this.recurFld.weeklyFrequencyFld;
					return false;
				}
			}
			if (this.recurFld.weeklyMultiDayFld)
			{
				this.recurFld.weeklyMultiDayFld.fRequired=true;
				var fValid=this.recurFld.weeklyMultiDayFld.FValidate();
				this.recurFld.weeklyMultiDayFld.fRequired=false;
				if (!fValid)
				{
					this.errFld=this.recurFld.weeklyMultiDayFld;
					return false;
				}
			}
		}
		else if (this.value==4)
		{
			if (this.recurFld.monthlyChoiceFld
				&& this.recurFld.monthlyChoiceFld.FValidate())
			{
				var monthlyChoiceFldPost=this.frm.FieldPost(this.recurFld.monthlyChoiceFld);
				if (monthlyChoiceFldPost)
				{
					if (monthlyChoiceFldPost.value=="0")
					{
						this.recurFld.monthlyChoice1DayFld.fRequired=true;
						var fValid=this.recurFld.monthlyChoice1DayFld.FValidate();
						this.recurFld.monthlyChoice1DayFld.fRequired=false;
						if (!fValid)
						{
							this.errFld=this.recurFld.monthlyChoice1DayFld;
							return false;
						}
						this.recurFld.monthlyChoice1MonthFreqFld.fRequired=true;
						fValid=this.recurFld.monthlyChoice1MonthFreqFld.FValidate();
						this.recurFld.monthlyChoice1MonthFreqFld.fRequired=false;
						if (!fValid)
						{
							this.errFld=this.recurFld.monthlyChoice1MonthFreqFld;
							return false;
						}
					}
					else if (monthlyChoiceFldPost.value=="1")
					{
						this.recurFld.monthlyChoice2MonthFreqFld.fRequired=true;
						var fValid=this.recurFld.monthlyChoice2MonthFreqFld.FValidate();
						this.recurFld.monthlyChoice2MonthFreqFld.fRequired=false;
						if (!fValid)
						{
							this.errFld=this.recurFld.monthlyChoice2MonthFreqFld;
							return false;
						}
					}
				}
			}
		}
	}
	return true;
}
RecurrencePatternEventHooks.prototype.SetValue=RecurrencePatternEventHooksSetValue;
function RecurrencePatternEventHooksSetValue(value)
{
	this.typeFld.SetValue(value);
	this.ToggleDisplay(value, false);
}
function DisplayOff(fld)
{
	if (fld)
	{
		if (!fld.length)
		{
			DoDisplayOff(fld);
			if (fld.children)
				DoDisplayOff(fld.children);
		}
		else
		{
			var i;
			for (i=0; i<fld.length; i++)
			{
				DoDisplayOff(fld[i]);
				if (fld[i].children)
					DoDisplayOff(fld[i].children);
			}
		}
	}
}
function DoDisplayOff(fld)
{
	if (fld)
	{
		if (!fld.length)
		{
			fld.disabled=true;
			if (fld.style)
				fld.style.display="none";
		}
		else
		{
			var i;
			for (i=0; i<fld.length; i++)
			{
				fld[i].disabled=true;
				if (fld[i].style)
					fld[i].style.display="none";
			}
		}
	}
}
function DisplayOn(fld)
{
	if (fld)
	{
		if (!fld.length)
		{
			DoDisplayOn(fld);
			if (fld.children)
				DoDisplayOn(fld.children);
		}
		else
		{
			var i;
			for (i=0; i<fld.length; i++)
			{
				DoDisplayOn(fld[i]);
				if (fld[i].children)
					DoDisplayOn(fld[i].children);
			}
		}
	}
}
function DoDisplayOn(fld)
{
	if (fld)
	{
		if (!fld.length)
		{
			fld.disabled=false;
			if (fld.style)
				fld.style.display="";
		}
		else
		{
			var i;
			for (i=0; i<fld.length; i++)
			{
				fld[i].disabled=false;
				if (fld[i].style)
					fld[i].style.display="";
			}
		}
	}
}
function FieldsDisabled(fld)
{
	if (fld)
	{
		if (!fld.length)
		{
			fld.disabled=true;
			if (fld.style)
				fld.style.visibility="hidden";
		}
		else
		{
			var i;
			for (i=0; i<fld.length; i++)
			{
				fld[i].disabled=true;
				if (fld[i].style)
					fld[i].style.visibility="hidden";
			}
		}
	}
}
function FieldsEnabled(fld)
{
	if (fld)
	{
		if (!fld.length)
		{
			fld.disabled=false;
			if (fld.style)
				fld.style.visibility="visible";
		}
		else
		{
			var i;
			for (i=0; i<fld.length; i++)
			{
				fld[i].disabled=false;
				if (fld[i].style)
					fld[i].style.visibility="visible";
			}
		}
	}
}
RecurrencePatternEventHooks.prototype.DateRangeToDate=FnDateRangeToDate
function FnDateRangeToDate()
{
	this.CopyDateFld(this.dateRangeFldStart, this.dateFldStart);	
	this.CopyDateFld(this.dateRangeFldEnd, this.dateFldEnd);	
}
RecurrencePatternEventHooks.prototype.DateToDateRange=FnDateToDateRange
function FnDateToDateRange()
{
	this.CopyDateFld(this.dateFldStart, this.dateRangeFldStart);	
	this.CopyDateFld(this.dateFldEnd, this.dateRangeFldEnd);	
}
RecurrencePatternEventHooks.prototype.ToggleDisplay=RecurrencePatternEventHooksToggleDisplay;
function RecurrencePatternEventHooksToggleDisplay(value, fForce)
{
	if (!fForce && this.value==value)
		return;
	if (this.value >=0 && this.rgStPatternTypes[this.value] !="")
		DisplayOff(this.divtags[this.rgStPatternTypes[this.value]]);
	var oldValue=this.value;
	this.value=value;
	if (this.value >=0 && this.rgStPatternTypes[this.value] !="")
		DisplayOn(this.divtags[this.rgStPatternTypes[this.value]]);
	if (this.value==0)
	{
		this.DateRangeToDate();
		DisplayOn(this.stStartDateSpan);
		DisplayOn(this.stEndDateSpan);
		DisplayOff(this.stRecurDateRangeDiv);
		DisplayOff(this.stRecurPatternTextDiv);
	}
	else
	{
		if (fForce || oldValue==0)
		{
			this.DateToDateRange();
			if (this.recurFld.endRangeOptionFld
				&& this.recurFld.endRangeOptionFld.FValidate())
			{
				var endRangeOptionFldPost=this.frm.FieldPost(this.recurFld.endRangeOptionFld);
				if (!endRangeOptionFldPost
					|| endRangeOptionFldPost.value !="2")
				{
					var destDateFld=this.frm.FieldSubPart(this.dateRangeFldEnd, "Date");
					destDateFld.value="";
					var disableSave=destDateFld.disabled;
					destDateFld.disabled=false;
					this.dateRangeFldEnd.FValidate();
					destDateFld.disabled=disableSave;
				}
			}
		}
		DisplayOff(this.stStartDateSpan);
		DisplayOff(this.stEndDateSpan);
		DisplayOn(this.stRecurDateRangeDiv);
		DisplayOn(this.stRecurPatternTextDiv);
	}
}
RecurrencePatternEventHooks.prototype.PostProcess=DateFieldPostProcess;
function DateFieldPostProcess()
{
	if (this.value >=2)
		this.DateRangeToDate();
}
RecurrencePatternEventHooks.prototype.CopyDateFld=FnCopyDateFld
function FnCopyDateFld(srcFld, destFld)
{
	if (srcFld && destFld)
	{
		var srcFldPost=srcFld.frm.FieldPost(srcFld);
		var destFldPost=destFld.frm.FieldPost(destFld);
		if (srcFldPost && destFldPost)
		{
			var srcDateFld=this.frm.FieldSubPart(srcFld, "Date");
			var date=this.frm.dopt.ParseLocaleDate(srcDateFld.value, this.recurFld.caltype);
			if (!isNaN(date))
			{
				var destDateFld=this.frm.FieldSubPart(destFld, "Date");
				destDateFld.value=srcDateFld.value;
				var disableSave=destDateFld.disabled;
				destDateFld.disabled=false;
				destFld.FValidate();
				destDateFld.disabled=disableSave;
			}
		}
	}
}
function TelephonePattern(frm, stName, stDisplayName, stValue)
{
	this.frm=frm;
	this.stName=stName;
	if (!stValue)
		stValue="";
	this.stValue=TrimWhiteSpaces(stValue);
	this.fIncludeExtension=false;
	this.fIncludePIN=false;
	var L_CountryCodeValue_Text="";
	var L_NationalCodeValue_Text="";
	var L_NumberValue_Text="";
	var L_NumberExtensionValue_Text="";
	var L_PINValue_Text="";
	if (this.stValue.length)
		this.ParseFieldValues();	
	else
	{								
		this.countryCode=L_CountryCodeValue_Text;
		this.nationalCode=L_NationalCodeValue_Text;
		this.number=L_NumberValue_Text;
		this.numberExtension=L_NumberExtensionValue_Text;
		this.pin=L_PINValue_Text;
	}
	this.countryCodeLen=4;
	this.nationalCodeLen=4;
	this.numberLen=9;
	this.numberExtensionLen=9;
	this.PINLen=6;
	this.stPrefix="TelephonePattern#";
}
TelephonePattern.prototype.ParseFieldValues=FnParseFieldValues
function FnParseFieldValues()
{
	var fldNames=new Array("countryCode",
							"nationalCode",
							"number",
							"numberExtension",
							"pin");		
	var i=0;
	var escape=";#";
	var iDelim1;
	var iDelim2;
	iDelim1=this.stValue.indexOf(escape, 0);
	if (iDelim1 !=-1)
	{
		for (i=0; i < 5; i++)
		{
			iDelim1+=2;
			iDelim2=this.stValue.indexOf(escape, iDelim1);
			if (iDelim2 !=-1)
			{
				var stValue=this.stValue.substr(iDelim1, iDelim2-iDelim1);
				stValue=TrimWhiteSpaces(stValue);
				eval("this."+fldNames[i]+"=stValue");
			}
			else
				break;
			iDelim1=iDelim2;
		}
	}
	if (i !=5)
	{
		this.countryCode="";
		this.nationalCode="";
		this.number=stValue;
		this.numberExtension="";
		this.pin="";
	}		
}
TelephonePattern.prototype.BuildUI=TelephonePatternBuildUI;
function TelephonePatternBuildUI()
{
	var st="<nobr>";
	var L_Telephone_Text="^1 ( ^2) ^3";
	var L_ExtFormat_Text=", ext( ^4)";
	var L_PINFormat_Text=", PIN( ^5)";
	var L_TelephoneCountryCode_Text="";
	var L_TelephoneNationalCode_Text="Telephone Area Code";
	var L_TelephoneNumber_Text="Telephone Number";
	var L_TelephoneNumberExtension_Text="";
	var L_TelephonePIN_Text="";
	var fld=new TextField(this.frm,
						this.stPrefix+"countryCode:"+this.stName,
						L_TelephoneCountryCode_Text,
						this.countryCode);
	fld.cchMaxLength=this.countryCodeLen;
	if (this.countryCode.length > fld.cchMaxLength)
		fld.cchMaxLength=this.countryCode.length;
	var cntrl1=fld.stBuildUI();
	fld=new TextField(this.frm,
						this.stPrefix+"nationalCode:"+this.stName,
						L_TelephoneNationalCode_Text,
						this.nationalCode);
	fld.fRequired=this.fRequired;
	fld.cchMaxLength=this.nationalCodeLen;
	if (this.nationalCode.length > fld.cchMaxLength)
		fld.cchMaxLength=this.nationalCode.length;
	var cntrl2=fld.stBuildUI();
	fld=new TextField(this.frm,
						this.stPrefix+"number:"+this.stName,
						L_TelephoneNumber_Text,
						this.number);
	fld.fRequired=this.fRequired;
	fld.cchMaxLength=this.numberLen;
	if (this.number.length > fld.cchMaxLength)
		fld.cchMaxLength=this.number.length;
	var cntrl3=fld.stBuildUI();
	var cntrl4;
	if (this.fIncludeExtension || this.numberExtension.length > 0)
	{
		L_Telephone_Text+=L_ExtFormat_Text;
		fld=new TextField(this.frm,
							this.stPrefix+"numberExtension:"+this.stName,
							L_TelephoneNumberExtension_Text,
							this.numberExtension);
		fld.cchMaxLength=this.numberExtensionLen;
		if (this.numberExtension.length > fld.cchMaxLength)
			fld.cchMaxLength=this.numberExtension.length;
		cntrl4=fld.stBuildUI();
	}
	else
		cntrl4=0;
	var cntrl5;
	if (this.fIncludePIN || this.pin.length > 0)
	{
		L_Telephone_Text+=L_PINFormat_Text;
		fld=new TextField(this.frm,
							this.stPrefix+"pin:"+this.stName,
							L_TelephonePIN_Text,
							this.pin);
		fld.cchMaxLength=this.PINLen;
		if (this.PIN.length > fld.cchMaxLength)
			fld.cchMaxLength=this.PIN.length;
		cntrl5=fld.stBuildUI();
	}
	else
		cntrl5=0;
	st+=StBuildParam(L_Telephone_Text, cntrl1, cntrl2, cntrl3, cntrl4, cntrl5);
	st+="</nobr>";
	document.write(st);
}
function WindowPosition(elt)
{
	var pos=new Object;
	pos.x=0;
	pos.y=0;
	while (elt.offsetParent !=null && elt.id.search('WebPart') !=0)
		{
		pos.x+=elt.offsetLeft;
		pos.y+=elt.offsetTop;
		elt=elt.offsetParent;
		}
	return pos;
}
function StInsertAt(st, ich, stInsert)
{
	return st.substr(0, ich)+stInsert+st.substr(ich);
}
function  WMultiple(w, wMult)
{
	return Math.round(w/wMult)*wMult;
}
function St2Digits(w)
{
	var st="";
	if (w < 10)
		st+="0";
	st+=w;
	return st;
}
function FBlankString(st)
{
	st=st.toString();
	st=st.replace(/\s/g, "");
	return (st=="");
}
function StURL(stURL, stText)
{
	if (FBlankString(stURL))
		return STSHtmlEncode(stText);
	return "<A HREF="+StAttrQuote(stURL)+">"+STSHtmlEncode(stText)+"</A>";
}
function FrmLocalFieldName(stName)
{
	return FrmStFieldNameFactory(stName, "Local");
}
function fDataLoseConvert(fromType, toType)
{
	switch (fromType)
	{
		case "Text":
		case "Choice":
			switch (toType)
			{
				case "Number":
				case "Currency":
				case "DateTime":
					return true;
			}
			break;
		case "Note":
			switch (toType)
			{
				case "Text":
				case "Choice":
				case "MultiChoice":
				case "Number":
				case "Currency":
				case "DateTime":
					return true;
			}
			break;
		case "MultiChoice":
			switch (toType)
			{
				case "Text":
				case "Note":
				case "Choice":
				case "Number":
				case "Currency":
				case "DateTime":
					return true;
			}
			break;
		case "DateTime":
			switch (toType)
			{
				case "Text":
				case "Note":
				case "Choice":
				case "MultiChoice":
					return true;
			}
			break;
		case "Number":
		case "Currency":
			switch (toType)
			{
				case "Text":
				case "Note":
				case "Choice":
				case "MultiChoice":
				case "Boolean":
					return true;
			}
			break;
	}
	return false;
}
function Belong(elem, rg)
{
	var i;
	for (i=0; i < rg.length; i++)
	{
		if (elem.stName==rg[i].stName)
			return true;
	}
	return false;
}
function RgSetMinus(rg1, rg2)
{
	var i;
	var rgRet=new Array();
	var cRet=0;
	for (i=0; i < rg1.length; i++)
	{
		if (!Belong(rg1[i], rg2))
		{
			rgRet[cRet]=rg1[i];
			cRet++;
		}
	}
	return rgRet;
}
function GetAncestor(elem, tag)
{
	while (elem !=null && elem.tagName !=tag)
	{
		elem=elem.parentNode;
	}
	return elem;
}
function GetTable(elem)
{
	return GetAncestor(elem, "TABLE");
}
function GetTr(elem)
{
	return GetAncestor(elem, "TR");
}
function SetDisplay(fld, disp, stDisplay, fRequired, iTarget)
{
	if (fld==null)
		return;
	fld.fRequired=fRequired;
	var elem=ControlFromFld(fld);
	if (elem==null || (elem.id=="onetidIOFile" && disp=="none"))
		return;
	var tr=GetTr(elem);
	if (tr !=null)
	{
			var rgth=tr.getElementsByTagName("TH");
			var th=null;
			if (rgth.length > 0)
			    th=rgth[0];
		if (iTarget > 0)
		{
			var tbl=GetTable(tr);
			if (tbl !=null)
			{
				var stVal=null;
				var cVal=0;
				var ctrl=null;
				if (fld.hasOwnProperty("rgChoices"))
				{
					if (fld.fFillInChoice)
					{
						ctrl=fld.GetFillInButtonControl();
						if (ctrl.checked)
							stVal=fld.GetFillInControl().value;
						if (stVal !=null)
							cVal++;
					}
					if (stVal==null || fld.format=="Checkboxes")
					{
						var i;
						for (i=0; i < fld.rgChoices.length; i++)
						{
							if (fld.GetControl(i).checked)
							{
								cVal++;
								if (cVal > 1)
									stVal+=";#"+fld.rgChoices[i].stValue;
								else
									stVal=fld.rgChoices[i].stValue
								if (fld.format !="Checkboxes")
									break;
							}
						}
					}
				}
				else
				{
					ctrl=fld.frm.FieldSubPart(fld, "Checkbox");
					if (ctrl !=null)
						stVal=ctrl.checked ? 1 : 0;
				}
				tbl.moveRow(tr.rowIndex, Math.min(iTarget, tbl.rows.length - 1));
				if (fld.format=="Checkboxes" && stVal==null)
					stVal="";
				if (stVal !=null)
				{
					if (cVal > 1)
						fld.SetValue(";#"+stVal+";#;#");
					else
						fld.SetValue(stVal);
				}
			}
		}
		if (th !=null)
		{
			var nobrs=th.getElementsByTagName("NOBR");
			if (nobrs.lengh > 0)
			{
				var nobr=nobrs[0];
				var strSav=nobr.innerHTML;
				if (stDisplay !="")
					nobr.innerText=stDisplay;
				else
					nobr.innerText=fld.stDisplay;
				nobr.innerHTML=nobr.innerHTML+strSav.substr(strSav.indexOf("<"));
			}
		}
		tr.style.display=disp;
		if (disp !="none")
		{
	    		ToogleRequired(tr, fld.fRequired);
		}
	}
}
function HideControl(fld)
{
	SetDisplay(fld, "none", fld.stDisplay, false, 0);
}
function ShowControl(fld, fRequired, stDisplay, iRow)
{
	SetDisplay(fld, "", stDisplay, fRequired, iRow);
}
function ShowListFields(frm)
{
	var rgfld=frm.rgfld;
	var i;
	for (i=0; i < rgfld.length; i++)
	{
		if (rgfld[i].stName !="ContentType")
			ShowControl(rgfld[i], rgfld[i].fRequired, "", 0);
	}
}
function SwitchControls(ctSelect, fSetDefault, fSetFocus)
{
	var ct=ctSelect.options[ctSelect.selectedIndex].value;
	var i;
	var rg=null;
	var rgHide=null;
	var ict;
	var rgcts=frmCurrent.rgcts;
	var rgctNames=frmCurrent.rgctNames;
	var rgflds=frmCurrent.rgfld;
	var ictRow=0;
	var aeSave=document.activeElement;
	for (i=0; i < rgctNames.length; i++)
	{
		if (rgctNames[i]==ct)
		{
			ict=i;
			rg=rgcts[i];
			break;			
		}
	}
	if (rg !=null)
	{
		var bFocus=false;
		var iRow=1;
		for (i=0; i < rg.length; i++)
		{
			var fld=frmCurrent.FindField(rg[i].stName);
			if (fld==null)
				continue;
			if (rg[i].fHidden)
			{
				HideControl(fld);
				continue;
			}
			if (fSetDefault && rg[i].hasOwnProperty("stDefault"))
			{
				SetFormControlValue(fld, rg[i].stDefault);
			}
			ShowControl(fld, rg[i].fRequired, rg[i].stDisplay, iRow+ictRow);
			iRow++;
			if (!bFocus && fSetFocus)
			{
				bFocus=fld.FieldFocus && fld.FieldFocus();
			}
		}
	}
	rgHide=RgSetMinus(rgflds, rgcts[ict]);
	if (rgHide !=null)
	{
		for (i=0; i < rgHide.length; i++)
		{
			if (rgHide[i].stName !="ContentType")
				HideControl(rgHide[i]);
		}
	}
	if (fSetFocus)
	{
		var fld=frmCurrent.FindField("ContentType");
		fld.FieldFocus();
	}
	checkScroll();
}
function ControlFromFld(fld)
{
	if (fld.hasOwnProperty("fDateOnly"))
		return fld.frm.FieldSubPart(fld, "Date");
	if (fld.hasOwnProperty("stDesc"))
		return fld.frm.FieldSubPart(fld, "URL");
	if (fld.hasOwnProperty("fPercent"))
		return fld.frm.FieldSubPart(fld, "Local");
	if (fld.hasOwnProperty("fAllowHyperlink"))
		return fld.frm.FieldPost(fld);
	if (fld.hasOwnProperty("stNumLines"))
		return fld.frm.FieldPost(fld);
	if (fld.hasOwnProperty("isFileName"))
	{
		var ctrl=document.getElementById(fld.stName);
		if (ctrl==null)
			ctrl=document.getElementById("onetidIOFile");
		return ctrl;
	}
	if (fld.hasOwnProperty("cchDisplaySize"))
		return fld.frm.FieldPost(fld);
	if (fld.hasOwnProperty("rgGridChoices"))
		return fld.frm.FieldSubPart(fld, "RadioButtons:0");
	if (fld.hasOwnProperty("rgChoices"))
		return GetTable(fld.GetControl());
	if (fld.hasOwnProperty("recurrencePatternChoice"))
	{
		var stMonth=fld.stPrefix+"MonthlyRecurType:"+fld.stName;
		var fldMonth=fld.frm.FindField(stMonth);
		var ctl=ControlFromFld(fldMonth).parentNode;
		ctl=GetTable(ctl).parentNode;
		ctl=GetTable(ctl);
		return ctl;
	}
	var ctl=fld.frm.FieldPost(fld);
	if (ctl !=null)
		return ctl;
	return fld.frm.FieldSubPart(fld, "Checkbox");;	
}
function DefaultControls()
{	
	var fld=frmCurrent.FindField("ContentType");
	var ict=0;
	var sel=null;
	var rgcts=frmCurrent.rgcts;
	var rgctNames=frmCurrent.rgctNames;
	if (fld !=null)
	{
		sel=fld.GetControl();
		var iopt;
		if (sel !=null)
		{
			for (iopt=0; iopt < sel.options.length; iopt++)
			{
				var ctName=sel.options[iopt].value;
				for (ict=0; ict < rgctNames.length; ict++)
				{
					if (rgctNames[ict]==ctName)
						break;
				}
				var rgfld=rgcts[ict];
				if (rgfld !=null && rgfld.length==0)
				{
					sel.options.remove(iopt);
					iopt--;
				}
			}
		}
	}
	if (sel==null || sel.options.length <=1)
	{
		if (fld !=null)
			fld.fHidden=true;
		ShowListFields(frmCurrent);
	}
	else
	{
		var fFocus=true;
		var fldFN=frmCurrent.FindField("owsnewfileref");
		ShowControl(fld, false, fld.stDisplay, 0);
		SwitchControls(fld.GetControl(), _g_tp_fNewForm, fFocus);
	}
}
function BoolFromString(str)
{
	if (str=="true" || str=="TRUE")
		return true;
	return false;
}
function ToogleRequired(tr, fRequired)
{
	var fonts=tr.getElementsByTagName("FONT");
	if (fonts.length==0)
		return;
	var font=fonts[0];
	if (fRequired)
		font.innerText=" *";
	else
		font.innerText="";
}
function SetFormControlValue(fld, stValue)
{
	fld.stValue=stValue;
	var ctl=ControlFromFld(fld);
	if (ctl==null)
		return;
	ctl.value=stValue;
}
function MoveDisplayRow(tbl, cRow, id)
{
	var tr=document.getElementById(id);
	if (tr !=null && tbl !=null)
	{
		tbl.moveRow(tr.rowIndex, Math.min(cRow, tbl.rows.length - 1));
		tr.style.display="";
	}
}
function DeferCall()
{
	if (arguments.length==0)
		return null;
	var args=arguments;
	var fn=null;
	if (browseris.ie5up || browseris.nav6up)
	{
		eval("if (typeof("+args[0]+")=='function') { fn="+args[0]+"; }");
	}
	if (fn==null)
		return null;
	if (args.length==1) return fn();
	else if (args.length==2) return fn(args[1]);
	else if (args.length==3) return fn(args[1], args[2]);
	else if (args.length==4) return fn(args[1], args[2], args[3]);
	else if (args.length==5) return fn(args[1], args[2], args[3], args[4]);
	else if (args.length==6) return fn(args[1], args[2], args[3], args[4], args[5]);
	else if (args.length==7) return fn(args[1], args[2], args[3], args[4], args[5], args[6]);
	else if (args.length==8) return fn(args[1], args[2], args[3], args[4], args[5], args[6], args[7]);
	else if (args.length==9) return fn(args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8]);
	else if (args.length==10) return fn(args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9]);
	else
	{
		var L_TooManyDefers_Text="Too many arguments passed to DeferCall";
		alert(L_TooManyDefers_Text);
	}
	return null;
}
var L_ContainIllegalChar_Text="^1 contains illegal character \'^2\'.";
var L_ContainIllegalString_Text="^1 contains illegal characters or substring.";
var LegalUrlChars=new Array
(
	false, false, false, false, false, false, false, false,     false, false, false, false, false, false, false, false,
	false, false, false, false, false, false, false, false,     false, false, false, false, false, false, false, false,
	true,  true, false, false, true, false,  false, true,      true,  true, false, true,  true,  true,  true,  true,
	true,  true,  true,  true,  true,  true,  true,  true,      true,  true, false,  true, false,  true, false, false,
	true,  true,  true,  true,  true,  true,  true,  true,      true,  true,  true,  true,  true,  true,  true,  true,
	true,  true,  true,  true,  true,  true,  true,  true,      true,  true,  true, true, false, true,  true,  true,
	true,  true,  true,  true,  true,  true,  true,  true,      true,  true,  true,  true,  true,  true,  true,  true,
	true,  true,  true,  true,  true,  true,  true,  true,      true,  true,  true,  false, false, false, false, false,
	false, false, false, false, false, false, false, false,     false, false, false, false, false, false, false, false,
	false, false, false, false, false, false, false, false,     false, false, false, false, false, false, false, false
);
function AdmBuildParam(stPattern)
{
	var re;
	var i;
	for (i=1; i < AdmBuildParam.arguments.length; i++)
		{
		re=new RegExp("\\^"+i);
		stPattern=stPattern.replace(re, AdmBuildParam.arguments[i]);
		}
	return stPattern;
}
function IndexOfIllegalCharInUrlLeafName(strLeafName)
{
	for(var i=0; i<strLeafName.length; i++)
	{
		var ch=strLeafName.charCodeAt(i);
		if(strLeafName.charAt(i)=='.' && (i==0 || i==(strLeafName.length-1)))
			return i;
		if(ch < 160 && ( strLeafName.charAt(i)=='/' || !LegalUrlChars[ch]) )
			return i;
	}
	return -1;
}
function IndexOfIllegalCharInUrlPath(strPath)
{
	for(var i=0; i<strPath.length; i++)
	{
		var ch=strPath.charCodeAt(i);
		if( ch < 160 && !LegalUrlChars[ch])
			return i;
	}
	return -1;
}
function UrlContainsIllegalStrings(strPath)
{
	if(strPath.indexOf("..") >=0
		|| strPath.indexOf("//") >=0
		|| strPath.indexOf("./") >=0
		|| strPath.indexOf("/.") >=0
		|| strPath.indexOf(".")==0
		|| strPath.lastIndexOf(".")==(strPath.length-1)
		)
	{
		return true;
	}
	return false;
}
function UrlLeafNameValidate(source, args)
{
	var strMessagePrefix="";
	if( typeof(source.MessagePrefix)=="string" )
	{
		strMessagePrefix=source.MessagePrefix;
	}
	else
	{
		strMessagePrefix=source.id;
	}
	var i=IndexOfIllegalCharInUrlLeafName(args.Value);
	if( i >=0 )
	{
		if(typeof(source.errormessage)=="string")
		{
			source.errormessage=AdmBuildParam(L_ContainIllegalChar_Text, strMessagePrefix, args.Value.charAt(i));
		}
		args.IsValid=false;
	}
	else if( UrlContainsIllegalStrings(args.Value) )
	{
		if(typeof(source.errormessage)=="string" )
		{
			source.errormessage=AdmBuildParam(L_ContainIllegalString_Text, strMessagePrefix);
		}
		args.IsValid=false;
	}
	else
	{
		args.IsValid=true;
	}
}
function UrlPathValidate(source, args)
{
	var strMessagePrefix="";
	if( typeof(source.MessagePrefix)=="string" )
	{
		strMessagePrefix=source.MessagePrefix;
	}
	else
	{
		strMessagePrefix=source.id;
	}
	var i=IndexOfIllegalCharInUrlPath(args.Value);
	if( i >=0)
	{
		if(typeof(source.errormessage)=="string")
		{
			source.errormessage=AdmBuildParam(L_ContainIllegalChar_Text, strMessagePrefix, args.Value.charAt(i));
		}
		args.IsValid=false;
	}
	else if( UrlContainsIllegalStrings(args.Value) )
	{
		if(typeof(source.errormessage)=="string" )
		{
			source.errormessage=AdmBuildParam(L_ContainIllegalString_Text, strMessagePrefix);
		}
		args.IsValid=false;
	}
	else
	{
		args.IsValid=true;
	}
}
function IsCheckBoxListSelected(checkboxlist)
{
	if(checkboxlist==null )
		return false;
	var len=checkboxlist.length ;
	if (len==null)
	{
		return checkboxlist.checked;
	}
	else
	{
		for (var i=0; i < len ; i++)
		{
			if (checkboxlist[i].checked)
			{
				return true;
			}
		}
	}
	return false;
}
function STSValidatorEnable(val, bEnable, bSilent)
{
	var objVal=document.getElementById(val);
	if (objVal==null)
		return;
	if (bSilent==true || (objVal.getAttribute("AlwaysEnableSilent")==true))
	{
		objVal.enabled=(bEnable==true);
	}
	else
	{
		ValidatorEnable(objVal, bEnable);
	}
}
function encodeScriptQuote(str)
{
	var strOut="";
	var ix=0;
	for (ix=0; ix < str.length; ix++)
	{
		var ch=str.charAt(ix);
		if (ch=='\'')
			strOut+="%27";
		else
			strOut+=ch;
	}
	return strOut;
}
function STSHtmlEncode(str)
{
	var strOut="";
	var ix=0;
	for (ix=0; ix < str.length; ix++)
	{
		var ch=str.charAt(ix);
		switch (ch)
		{
			case '<':
				strOut+="&lt;";
				break;
			case '>':
				strOut+="&gt;";
				break;
			case '&':
				strOut+="&amp;";
				break;
			case '\"':
				strOut+="&quot;";
				break;
			case '\'':
				strOut+="&#39;";
				break;
			default:
				strOut+=ch;
				break;
		}
   }
   return strOut;
}
function StAttrQuote(st)
{
	st=st.toString();
	st=st.replace(/&/g, '&amp;');
	st=st.replace(/\"/g, '&quot;'); // "
	st=st.replace(/\r/g, '&#13;');
	return '"'+st+'"';
}
function STSScriptEncode(str)
{
	var strOut="";
	var ix=0;
	for (ix=0; ix < str.length; ix++)
	{
		var charCode=str.charCodeAt(ix);
		if (charCode > 0x0fff)
		{
			strOut+=("\\u"+charCode.toString(16).toUpperCase());
		}
		else if (charCode > 0x00ff)
		{
			strOut+=("\\u0"+charCode.toString(16).toUpperCase());
		}
		else if (charCode > 0x007f)
		{
			strOut+=("\\u00"+charCode.toString(16).toUpperCase());
		}
		else
		{
			switch (str.charAt(ix))
			{
			case '\n':
				strOut+="\\n";
				break;
			case '\r':
				strOut+="\\r";
				break;
			case '\"':
				strOut+="\\u0022";
				break;
			case '%':
				strOut+="\\u0025";
				break;
			case '&':
				strOut+="\\u0026";
				break;
			case '\'':
				strOut+="\\u0027";
				break;
			case '(':
				strOut+="\\u0028";
				break;
			case ')':
				strOut+="\\u0029";
				break;
			case '+':
				strOut+="\\u002b";
				break;
			case '/':
				strOut+="\\u002f";
				break;
			case '<':
				strOut+="\\u003c";
				break;
			case '>':
				strOut+="\\u003e";
				break;
			case '\\':
				strOut+="\\\\";
				break;
			default:
				strOut+=str.charAt(ix);
			};
		}
	}
	return strOut;
}
function STSScriptEncodeWithQuote(str)
{
	return '"'+STSScriptEncode(str)+'"';
}
var SPOnError_cachedOriginalOnError=window.onerror;
var L_PleaseWaitForScripts_Text="Please wait while scripts are loaded...";
var g_pageLoadComplete=false;
var previousRSChange='';
if (document.onreadystatechange !=null)
{
	previousRSChange=document.onreadystatechange;
}
document.onreadystatechange=setLoadComplete;
function setLoadComplete()
{
	if(previousRSChange !=null && previousRSChange !='')
	{
		eval(previousRSChange);
	}
	if(document.readyState=='complete')
	{
		g_pageLoadComplete=true;
		window.status="";
		window.onerror=SPOnError_cachedOriginalOnError;
	}
}
function SPOnError_handleErrors(msg,url,line)
{
	var useErrorHandler=false;
	if(!g_pageLoadComplete && document.readyState !="complete")
	{
		useErrorHandler=true;
	}
	if(useErrorHandler)
	{
		try
		{
			window.status=L_PleaseWaitForScripts_Text;
		}
		catch(e)
		{
		}
		return true;
	}
	else
	{
		if(typeof(SPOnError_cachedOriginalOnError)=="function")
		{
			window.onerror=SPOnError_cachedOriginalOnError;
			return SPOnError_cachedOriginalOnError(msg,url,line);
		}
		else
		{
			window.onerror=null;
			return false;
		}
	}
}
window.onerror=SPOnError_handleErrors;
var L_Language_Text="1033";
var L_ClickOnce1_text="You are already attempting to save this item. If you attempt to save this item again, you may create duplicate information. Would you like to save this item again?";
var L_STSRecycleConfirm_Text="Are you sure you want to send this item to the site Recycle Bin?";
var L_STSRecycleConfirm1_Text="Are you sure you want to send this folder and all its contents to the site Recycle Bin?";
var L_STSDelConfirm_Text="Are you sure you want to delete this item?";
var L_STSDelConfirm1_Text="Are you sure you want to delete this folder and all its contents?";
var L_NewDocLibTb1_Text="The document could not be created. \nThe required application may not be installed properly, or the template for this document library cannot be opened.\n\nPlease try the following:\n1. Check the General Settings for this document library for the name of the template, and install the application necessary for opening the template. If the application was set to install on first use, run the application and then try creating a new document again.\n\n2.  If you have permission to modify this document library, go to General Settings for the library and configure a new template.";
var L_NewDocLibTb2_Text="'New Document' requires a Windows SharePoint Services-compatible application and Microsoft Internet Explorer 6.0 or greater. To add a document to this document library, click the 'Upload Document' button.";
var L_NewFormLibTb1_Text="The document could not be created.\nThe required application may not be installed properly, or the template for this document library cannot be opened.\n\nPlease try the following:\n1. Check the General Settings for this document library for the name of the template, and install the application necessary for opening the template. If the application was set to install on first use, run the application and then try creating a new document again.\n\n2.  If you have permission to modify this document library, go to General Settings for the library and configure a new template.";
var L_NewFormLibTb2_Text="This feature requires Microsoft Internet Explorer 6.0 or later and a Windows SharePoint Services-compatible XML editor such as Microsoft Office InfoPath.";
var L_ConfirmCheckout_Text="You must check out this item before making changes.  Do you want to check out this item now?";
var L_CheckOutRetry_Text="Check out failed, do you want to retry to check out from server?";
var L_CannotEditPropertyForLocalCopy_Text="You cannot edit the properties of a document while it is checked out and being modified offline.";
var L_CannotEditPropertyCheckout_Text="You cannot edit the properties of this document while it is checked out or locked for editing by another user.";
var L_NewFormClickOnce1_Text="New Folder";
var L_EnterValidCopyDest_Text="Please enter a valid folder URL and a file name.  Folder URLs must begin with 'http:' or 'https:'.";
var L_ConfirmUnlinkCopy_Text="Because this item is a copy, it may still be receiving updates from its source.  You should make sure that this item is removed from the source's list of items to update, otherwise this item may continue to receive updates.  Are you sure that you want to unlink this item?";
var L_CopyingOfflineVersionWarning_Text="You currently have this document checked out locally.  Only versions stored on the server can be copied.  To copy the most recent minor version, click OK.  To copy the currently checked out version, click Cancel, check in the document and then retry the copy operation.";
var L_Loading_Text="Loading...";
var L_Loading_Error_Text="An error has occurred with the data fetch.  Please refresh the page and retry.";
var L_WarnkOnce_text="This item contains a custom recurrence pattern.  If you save your changes you will not be able to revert to the previous pattern.";
var L_WebFoldersRequired_Text="Please wait while Explorer View is loaded. If Explorer View does not appear, your browser may not support it.";
var L_WebFoldersError_Text="Your client does not support opening this list with Windows Explorer.";
var L_AccessibleMenu_Text="Menu";
var L_NewBlogPost_Text="This feature requires Microsoft Internet Explorer 6.0 or later and a Windows SharePoint Services-compatible blog editor such as Microsoft Office Word 2007 or later.";
var L_NewBlogPostFailed_Text="Unable to connect to the blog program because it may be busy or missing. Check the program, and then try again.";
var recycleBinEnabled=0;
var bIsFileDialogView=false;
var g_ViewIdToViewCounterMap=new Array();
function UpdateAccessibilityUI()
{
	var t1=document.getElementById("TurnOnAccessibility");
	var t2=document.getElementById("TurnOffAccessibility");
	if (IsAccessibilityFeatureEnabled())
	{
		if (t1 !=null)
			t1.style.display="none";
		if (t2 !=null)
			t2.style.display="";
	}
	else
	{
		if (t1 !=null)
			t1.style.display="";
		if (t2 !=null)
			t2.style.display="none";
	}
}
function SetIsAccessibilityFeatureEnabled(f)
{
	if (f)
		document.cookie="WSS_AccessibilityFeature=true;path=;";
	else
		document.cookie="WSS_AccessibilityFeature=false;path=;";
}
function DeleteCookie(sName)
{
	document.cookie=sName+"=; expires=Thu, 01-Jan-70 00:00:01 GMT";
}
function GetCookie(sName)
{
	var aCookie=document.cookie.split("; ");
	for (var i=0; i < aCookie.length; i++)
	{
		var aCrumb=aCookie[i].split("=");
		if (sName==aCrumb[0]) {
			if(aCrumb.length > 1)
				return unescapeProperly(aCrumb[1]);
			else
				return null;
		}
	}
	return null;
}
function IsAccessibilityFeatureEnabled()
{
	return GetCookie("WSS_AccessibilityFeature")=="true";
}
function escapeForSync(str)
{
	var strOut="";
	var ix=0;
	var bDoingUnicode=0;
	var strSyncEscaped="\\&|[]";
	for (ix=0; ix < str.length; ix++)
	{
		var charCode=str.charCodeAt(ix);
		var curChar=str.charAt(ix);
		if (bDoingUnicode && charCode <=0x7f) {
			strOut+="]";
			bDoingUnicode=0;
		}
		if (!bDoingUnicode && charCode > 0x7f) {
			strOut+="[";
			bDoingUnicode=1;
		}
		if(strSyncEscaped.indexOf(curChar) >=0)
			strOut+="|";
		if ( (charCode >=97 && charCode <=122) ||
			 (charCode >=65 && charCode <=90) ||
			 (charCode >=48 && charCode <=57) )
		{
			strOut+=curChar;
		}
		else if (charCode <=0x0f)
		{
			strOut+="%0"+charCode.toString(16).toUpperCase();
		}
		else if (charCode <=0x7f)
		{
			strOut+="%"+charCode.toString(16).toUpperCase();
		}
		else if (charCode <=0x00ff)
		{
			strOut+="00"+charCode.toString(16).toUpperCase();
		}
		else if (charCode <=0x0fff)
		{
			strOut+="0"+charCode.toString(16).toUpperCase();
		}
		else {
			strOut+=charCode.toString(16).toUpperCase();
		}
	}
	if (bDoingUnicode)
		strOut+="]";
	return strOut;
}
var g_rgdwchMinEncoded=new Array([
	0x00000000,
	0x00000080,
	0x00000800,
	0x00010000,
	0x00200000,
	0x04000000,
	0x80000000
	]);
function Vutf8ToUnicode(rgBytes)
{
	var ix=0;
	var strResult="";
	var dwch, wch, uch;
	var nTrailBytes, nTrailBytesOrig;
	while (ix < rgBytes.length)
	{
		if (rgBytes[ix] <=0x007f)
		{
			strResult+=String.fromCharCode(rgBytes[ix++]);
		}
		else
		{
			uch=rgBytes[ix++];
			nTrailBytes=((uch) & 0x20) ? (((uch) & 0x10) ? 3 : 2) : 1;
			dwch=uch & (0xff >>> (2+nTrailBytes));
			while (nTrailBytes && (ix < rgBytes.length))
			{
				--nTrailBytes;
				uch=rgBytes[ix++];
				if (uch==0)
				{
					return strResult;
				}
				if ((uch & 0xC0) !=0x80)
				{
					strResult+='?';
					break;
				}
				dwch=(dwch << 6) | ((uch) & 0x003f);
			}
			if (nTrailBytes)
			{
				strResult+='?';
				break;
			}
			if (dwch < g_rgdwchMinEncoded[nTrailBytesOrig])
			{
				strResult+='?';
				break;
			}
			else if (dwch <=0xffff)
			{
				strResult+=String.fromCharCode(dwch);
			}
			else if (dwch <=0x10ffff)
			{
				dwch -=SURROGATE_OFFSET;
				strResult+=String.fromCharCode(
					HIGH_SURROGATE_BITS | dwch >>> 10);
				strResult+=String.fromCharCode(
					LOW_SURROGATE_BITS | ((dwch) & 0x003FF));
			}
			else
			{
				strResult+='?';
			}
		}
	}
	return strResult;
}
function unescapeProperlyInternal(str)
{
	if (str==null)
		return "null";
	var ix=0, ixEntity=0;
	var strResult="";
	var rgUTF8Bytes=new Array;
	var ixUTF8Bytes=0;
	var hexString, hexCode;
	while (ix < str.length)
	{
		if (str.charAt(ix)=='%')
		{
			if (str.charAt(++ix)=='u')
			{
				hexString="";
				for (ixEntity=0; ixEntity < 4 && ix < str.length;++ixEntity)
				{
					hexString+=str.charAt(++ix);
				}
				while (hexString.length < 4)
				{
					hexString+='0';
				}
				hexCode=parseInt(hexString, 16);
				if (isNaN(hexCode))
				{
					strResult+='?';
				}
				else
				{
					strResult+=String.fromCharCode(hexCode);
				}
			}
			else
			{
				hexString="";
				for (ixEntity=0; ixEntity < 2 && ix < str.length;++ixEntity)
				{
					hexString+=str.charAt(ix++);
				}
				while (hexString.length < 2)
				{
					hexString+='0';
				}
				hexCode=parseInt(hexString, 16);
				if (isNaN(hexCode))
				{
					if (ixUTF8Bytes)
					{
						strResult+=Vutf8ToUnicode(rgUTF8Bytes);
						ixUTF8Bytes=0;
						rgUTF8Bytes.length=ixUTF8Bytes;
					}
					strResult+='?';
				}
				else
				{
					rgUTF8Bytes[ixUTF8Bytes++]=hexCode;
				}
			}
		}
		else
		{
			if (ixUTF8Bytes)
			{
				strResult+=Vutf8ToUnicode(rgUTF8Bytes);
				ixUTF8Bytes=0;
				rgUTF8Bytes.length=ixUTF8Bytes;
			}
			strResult+=str.charAt(ix++);
		}
	}
	if (ixUTF8Bytes)
	{
		strResult+=Vutf8ToUnicode(rgUTF8Bytes);
		ixUTF8Bytes=0;
		rgUTF8Bytes.length=ixUTF8Bytes;
	}
	return strResult;
}
function unescapeProperly(str)
{
	var strResult=null;
	if ((browseris.ie55up || browseris.nav6up) &&
		(typeof(decodeURIComponent) !="undefined"))
	{
		strResult=decodeURIComponent(str);
	}
	else
	{
		strResult=unescapeProperlyInternal(str);
	}
	return strResult;
}
function navigateMailToLink(strUrl)
{
	var strEncoded="";
	for (ix=0; ix < strUrl.length; ix++)
	{
		var curChar=strUrl.charAt(ix);
		var strHexCode;
		var strHexCodeL;
		if (curChar=='%')
		{
			strHexCode=strUrl.charAt(ix+1);
			strHexCode+=strUrl.charAt(ix+2);
			strHexCodeL=strHexCode.toLowerCase();
			if (strHexCodeL=="3a" || strHexCodeL=="2f" ||
				strHexCodeL=="3d")
			{
				strEncoded+=curChar;
			}
			else
			{
				strEncoded+=curChar;
				strEncoded+="25";
			}
		}
		else
		{
			strEncoded+=curChar;
		}
	}
	window.location=strEncoded;
}
function newBlogPostOnClient(strProviderId, strBlogUrl, strBlogName)
{
	var stsOpen;
	var fRet;
	stsOpen=StsOpenEnsureEx("SharePoint.OpenDocuments.3");
	if (stsOpen==null)
	{
		alert(L_NewBlogPost_Text);
		return;
	}
	try
	{
		fRet=stsOpen.NewBlogPost(strProviderId, strBlogUrl, strBlogName);
	}
	catch (e)
	{
		alert(L_NewBlogPostFailed_Text);
	}
}
function GetUrlFromWebUrlAndWebRelativeUrl(webUrl, webRelativeUrl)
{
	var retUrl=(webUrl==null || webUrl.length <=0) ? "/" : webUrl;
	if (retUrl.charAt(retUrl.length - 1) !="/")
	{
		retUrl+="/";
	}
	retUrl+=webRelativeUrl;
	return retUrl;
}
var g_updateFormDigestPageLoaded=new Date();
function UpdateFormDigest(serverRelativeWebUrl, updateInterval)
{
	try
	{
		if ((g_updateFormDigestPageLoaded==null) || (typeof(g_updateFormDigestPageLoaded) !="object"))
		{
			return;
		}
		var now=new Date();
		if (now.getTime() - g_updateFormDigestPageLoaded.getTime() < updateInterval)
		{
			return;
		}
		if ((serverRelativeWebUrl==null) || (serverRelativeWebUrl.length <=0))
		{
			return;
		}
		var formDigestElement=document.getElementsByName("__REQUESTDIGEST")[0];
		if ((formDigestElement==null) || (formDigestElement.tagName.toLowerCase() !="input") || (formDigestElement.type.toLowerCase() !="hidden") ||
			(formDigestElement.value==null) || (formDigestElement.value.length <=0))
		{
			return;
		}
		var request=null;
		try
		{
			request=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (ex)
		{
			request=null;
		}
		if (request==null)
		{
			try
			{
				request=new XMLHttpRequest();
			}
			catch (ex)
			{
				request=null;
			}
		}
		if (request==null)
		{
			return;
		}
		request.open("POST", GetUrlFromWebUrlAndWebRelativeUrl(serverRelativeWebUrl, "_vti_bin/sites.asmx"), false);
		request.setRequestHeader("Content-Type", "text/xml");
		request.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/sharepoint/soap/GetUpdatedFormDigest");
		request.send("<?xml version=\"1.0\" encoding=\"utf-8\"?>"+			"<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"+			"  <soap:Body>"+			"    <GetUpdatedFormDigest xmlns=\"http://schemas.microsoft.com/sharepoint/soap/\" />"+			"  </soap:Body>"+			"</soap:Envelope>");
		var responseText=request.responseText;
		if ((responseText==null) || (responseText.length <=0))
		{
			return;
		}
		var startTag='<GetUpdatedFormDigestResult>';
		var endTag='</GetUpdatedFormDigestResult>';
		var startTagIndex=responseText.indexOf(startTag);
		var endTagIndex=responseText.indexOf(endTag, startTagIndex+startTag.length);
		var newFormDigest=null;
		if ((startTagIndex >=0) && (endTagIndex > startTagIndex))
		{
			var newFormDigest=responseText.substring(startTagIndex+startTag.length, endTagIndex);
		}
		if ((newFormDigest==null) || (newFormDigest.length <=0))
		{
			return;
		}
		var oldValue=formDigestElement.value;
		formDigestElement.value=newFormDigest;
	}
	catch (ex)
	{
	}
}
function GetStssyncHandler(szVersion)
{
	var objStssync;
	try
	{
		objStssync=new ActiveXObject("SharePoint.StssyncHandler"+szVersion);
	}
	catch (e)
	{
		objStssync=null;
	}
	return objStssync;
}
function GetStssyncAppNameForType(strType,strDefault)
{
	if (browseris.ie5up && browseris.win32)
	{
		var strAppName;
		var objStssync=null;
		if (strType !="")
		   objStssync=GetStssyncHandler(".3");
		if (!objStssync)
		{
			if (strType !="" && strType !="calendar" && strType !="contacts")
			{
				return false;
			}
			objStssync=GetStssyncHandler(".2");
			if (!objStssync || !(strAppName=objStssync.GetStssyncAppName()))
			{
				return false;
			}
		}
		else if (!(strAppName=objStssync.GetStssyncAppNameForType(strType)))
		{
			return false;
		}
		var L_LinkToBefore_Text="Connect to ";
		var L_LinkToAfter_Text="";
		return L_LinkToBefore_Text+strAppName+L_LinkToAfter_Text;
	}
	else
	{
		return strDefault;
	}
}
function GetStssyncIconPath(strDefault, strPrefix)
{
	if (browseris.ie5up && browseris.win32)
	{
		var strIconName;
		var objStssync=null;
		objStssync=GetStssyncHandler(".3");
		if (!objStssync)
			return false;
		try
		{
			strIconName=objStssync.GetStssyncIconName();
			return strPrefix+strIconName;
		}
		catch (e)
		{
			return strDefault;
		}
	}
	else
	{
		return strDefault;
	}
}
function GetStssyncAppName(strDefault)
{
	return GetStssyncAppNameForType("",strDefault);
}
function ExportHailStorm(type,weburl,guid,webname,listname,viewurl,passport,listrooturl,folderurl,folderid)
{
	var maxLinkLength=500;
	var maxNameLength=20;
	var link="stssync://sts/?ver=1.1"
+"&type="+escapeProperly(type)
+"&cmd=add-folder"
+"&base-url="+escapeForSync(weburl)
+"&list-url="+escapeForSync("/"+makeAbsUrl(viewurl).substr(weburl.length+1)+"/")
+"&guid="+escapeProperly(guid);
	var names="&site-name="+escapeForSync(webname)
+"&list-name="+escapeForSync(listname);
	var context="";
	if (folderurl)
		context+="&folder-url="+escapeForSync("/"+folderurl.substr(listrooturl.length+1));
	if (folderid)
		context+="&folder-id="+folderid;
	if (link.length+names.length+context.length > maxLinkLength &&
		(webname.length > maxNameLength || listname.length > maxNameLength))
	{
		if (webname.length > maxNameLength)
			webname=webname.substring(0, maxNameLength-1)+"...";
		if (listname.length > maxNameLength)
			listname=listname.substring(0, maxNameLength-1)+"...";
		names="&site-name="+escapeForSync(webname)
+"&list-name="+escapeForSync(listname);
	}
	link=link+names+context;
	var L_StssyncTooLong_Text="The title of the site or list is too long. Shorten the title and try again.";
	if (link.length > maxLinkLength)
		alert(L_StssyncTooLong_Text);
	else
	{
		try
		{
			window.location.href=link;
		}
		catch (e)
		{
		}
	}
}
function GetDiagramLaunchInstalled()
{
	var objDiagramLaunch;
	var bFlag=false;
	try
	{
		objDiagramLaunch=new ActiveXObject("DiagramLaunch.DiagramLauncher");
		var strAppName;
		strAppName=objDiagramLaunch.EnsureDiagramApplication();
	}
	catch (e)
	{
		objDiagramLaunch=null;
	}
	return strAppName;
}
var fSSImporter=false;
var SSImporterObj;
function EnsureSSImporter()
{
	if (!fSSImporter)
	{
		if (browseris.ie5up && browseris.win32)
		{
			var functionBody=				"try"
+"{"
+"    SSImporterObj=new ActiveXObject(\"SharePoint.SpreadsheetLauncher.2\");"
+"    if (SSImporterObj)"
+"        fSSImporter=true;"
+"} catch (e)"
+"{"
+"try"
+"{"
+"    SSImporterObj=new ActiveXObject(\"SharePoint.SpreadsheetLauncher.1\");"
+"    if (SSImporterObj)"
+"        fSSImporter=true;"
+"} catch (e)"
+"{"
+"    fSSImporter=false;"
+"};"
+"};";
			var EnsureSSImportInner=new Function(functionBody);
			EnsureSSImportInner();
		}
	}
	return fSSImporter;
}
function ShowHideSection(sectionid, imgid)
{
	var group=document.getElementById(sectionid);
	var img=document.getElementById(imgid);
	if ((group==null))
		return;
	if (group.style.display !="none")
	{
		group.style.display="none";
		img.src="/_layouts/images/plus.gif";
	}
	else
	{
		group.style.display="";
		img.src="/_layouts/images/minus.gif";
	}
}
function ShowSection(sectionid, imgid)
{
	var group=document.getElementById(sectionid);
	var img=document.getElementById(imgid);
	if ((group==null))
		return;
	if (group.style.display=="none")
	{
		group.style.display="";
		img.src="/_layouts/images/minus.gif";
	}
}
function ShowHideInputFormSection(sectionid, bShow)
{
	var e=document.getElementById(sectionid);
	if (e !=null)
		e.style.display=bShow ? "" : "none";
	for (var i=1; i < 3; i++)
	{
		e=document.getElementById(sectionid+"_tablerow"+i);
		if (e !=null)
			e.style.display=bShow ? "" : "none";
	}
}
function ShowHideInputFormControl(id, bHide, bDisableValidators, bSilent)
{
	var displaySetting="";
	if (bHide==true)
	{
		displaySetting="none";
	}
	var validators=eval(id+'_validators');
	if (validators !=null)
	{
		for(var i=0; i < validators.length; i++)
		{
			STSValidatorEnable(validators[i], !bDisableValidators, bSilent);
		}
	}
	for(var i=1; i<=5; i++)
	{
		var rowId=id+"_tablerow"+i;
		var row=document.getElementById(rowId);
		if ((row !=null) && !browseris.mac)
		{
			row.style.display=displaySetting;
		}
	}
}
function SetControlDisabledStatus(obj, disabledStatus)
{
	try
	{
		if (obj.setAttribute)
			obj.setAttribute('disabled', disabledStatus);
		if (!disabledStatus && obj.removeAttribute)
			obj.removeAttribute('disabled');
	}
	catch(e)
	{
	}
}
function SetControlDisabledStatusRecursively(obj, disabledStatus)
{
	if (obj==null)
		return;
	SetControlDisabledStatus(obj, disabledStatus);
	var objChildren=obj.childNodes;
	for(var i=0; objChildren.length > i; i++)
	{
		SetControlDisabledStatusRecursively(objChildren.item(i), disabledStatus);
	}
}
function SetChildControlsDisabledStatus(obj, disabledStatus)
{
	var objChildren=obj.childNodes;
	for(var i=0; i < objChildren.length; i++)
	{
		SetControlDisabledStatusRecursively(objChildren.item(i), disabledStatus);
	}
}
var g_PNGImageIds;
var g_PNGImageSources;
function displayPNGImage(id,src,width,height,alt)
{
	if (g_PNGImageIds==null)
		g_PNGImageIds=new Array();
	if (g_PNGImageSources==null)
		g_PNGImageSources=new Array();
	var style=null;
	document.write("<IMG id='"+id+"' ");
	if (width && width > 0)
		document.write("width='"+width+"' ");
	if (height && height > 0)
		document.write("height='"+height+"' ");
	document.write("alt='"+alt+"' ");
	if (style)
		document.write("style='"+style+"' ");
	document.write(" src='"+src+"' />");
	g_PNGImageIds.push(id);
	g_PNGImageSources.push(src);
}
function ProcessPNGImages()
{
	var useFilter=browseris.ie &&
				browseris.ie55up &&
				browseris.verIEFull < 7.0;
	if (g_PNGImageIds !=null && useFilter)
	{
		for (var i=0; i < g_PNGImageIds.length; i++)
		{
			var img=document.getElementById(g_PNGImageIds[i]);
			if (img !=null && g_PNGImageSources[i] !=null)
			{
				img.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src="+g_PNGImageSources[i]+"),sizingMethod=scale);";
				img.src="/_layouts/images/blank.gif";
			}
		}
	}
}
var CTXTYPE_EDITMENU=0;
var CTXTYPE_VIEWSELECTOR=1;
function ContextInfo()
{
	this.listBaseType=null;
	this.listTemplate=null;
	this.listName=null;
	this.view=null;
	this.listUrlDir=null;
	this.HttpPath=null;
	this.HttpRoot=null;
	this.serverUrl=null;
	this.imagesPath=null;
	this.PortalUrl=null;
	this.RecycleBinEnabled=null;
	this.isWebEditorPreview=null;
	this.rootFolderForDisplay=null;
	this.isPortalTemplate=null;
	this.isModerated=false;
	this.recursiveView=false;
	this.displayFormUrl=null;
	this.editFormUrl=null;
	this.newFormUrl=null;
	this.ctxId=null;
	this.CurrentUserId=null;
	this.isForceCheckout=false;
	this.EnableMinorVersions=false;
	this.ModerationStatus=0;
	this.verEnabled=0;
	this.isVersions=0;
	this.WorkflowsAssociated=false;
	this.ContentTypesEnabled=false;
	this.SendToLocationName="";
	this.SendToLocationUrl="";
}
function STSPageUrlValidation(url)
{
	return PageUrlValidation(url);
}
function GetSource(defaultSource)
{
	var source=GetUrlKeyValue("Source");
	if (source=="")
	{
		if (defaultSource !=null && defaultSource !="")
			source=defaultSource;
		else
			source=window.location.href;
	}
	return escapeProperly(STSPageUrlValidation(source));
}
function GetUrlKeyValue(keyName, bNoDecode, url)
{
	var keyValue="";
	if (url==null)
		url=window.location.href+"";
	var ndx=url.indexOf("&"+keyName+"=");
	if (ndx==-1)
		ndx=url.indexOf("?"+keyName+"=");
	if (ndx !=-1)
	{
		ndx2=url.indexOf("&", ndx+1);
		if (ndx2==-1)
			ndx2=url.length;
		keyValue=url.substring(ndx+keyName.length+2, ndx2);
	}
	if (bNoDecode)
		return keyValue;
	else
		return unescapeProperlyInternal(keyValue);
}
function LoginAsAnother(url, bUseSource)
{
	document.cookie="loginAsDifferentAttemptCount=0";
	if (bUseSource=="1")
	{
		GoToPage(url);
	}
	else
	{
		var ch=url.indexOf("?") >=0 ? "&" : "?";
		url+=ch+"Source="+escapeProperly(window.location.href);
		STSNavigate(url);
	}
}
function isPortalTemplatePage(Url)
{
	if (GetUrlKeyValue("PortalTemplate")=="1" ||
		GetUrlKeyValue("PortalTemplate", Url)=="1" ||
		(currentCtx !=null && currentCtx.isPortalTemplate))
		return true;
	else
		return false;
}
function STSNavigate(Url)
{
	if (isPortalTemplatePage(Url))
		window.top.location=STSPageUrlValidation(Url);
	else
		window.location=STSPageUrlValidation(Url);
}
function GoToPage(url)
{
	var ch=url.indexOf("?") >=0 ? "&" : "?";
	var srcUrl=GetSource();
	if (srcUrl !=null && srcUrl !="")
		url+=ch+"Source="+srcUrl;
	STSNavigate(url);
}
function TrimSpaces( str )
{
	var start;
	var end;
	str=str.toString();
	var len=str.length;
	for (start=0; start < len; start++)
	{
		if (str.charAt(start) !=' ')
			break;
	}
	if (start==len)
		return "";
	for (end=len - 1; end > start; end --)
	{
		if (str.charAt(end) !=' ')
			break;
	}
	end++;
	return str.substring(start, end);
}
function TrimWhiteSpaces( str )
{
	var start;
	var end;
	str=str.toString();
	var len=str.length;
	for (start=0; start < len; start++)
	{
		ch=str.charAt(start);
		if (ch!=' ' && ch!='\t' && ch!='\n' && ch!='\r' && ch!='\f')
			break;
	}
	if (start==len)
		return "";
	for (end=len - 1; end > start; end --)
	{
		ch=str.charAt(end);
		if (ch!=' ' && ch!='\t' && ch!='\n' && ch!='\r' && ch!='\f')
			break;
	}
	end++;
	return str.substring(start, end);
}
function GetAttributeFromItemTable(itemTable, strAttributeName, strAttributeOldName)
{
	var attrValue=itemTable !=null ? itemTable.getAttribute(strAttributeName) : null;
	if (attrValue==null && itemTable !=null && strAttributeOldName!=null)
		attrValue=itemTable.getAttribute(strAttributeOldName);
	return attrValue;
}
function GetDiagramLaunchInstalled()
{
	var objDiagramLaunch;
	var bFlag=false;
	try
	{
		objDiagramLaunch=new ActiveXObject("DiagramLaunch.DiagramLauncher");
		var strAppName;
		strAppName=objDiagramLaunch.EnsureDiagramApplication();
	}
	catch (e)
	{
		objDiagramLaunch=null;
	}
	return strAppName;
}
function ShowMtgNavigatorPane()
{
	document.getElementById("MeetingNavigatorPane").style.display="block";
}
function HideMtgNavigatorPane()
{
	document.getElementById("MeetingNavigatorPane").style.display="none";
}
function GetMultipleUploadEnabled()
{
	try
	{
		if (browseris.ie5up && !browseris.mac && (new ActiveXObject('STSUpld.UploadCtl')))
			return true;
	}
	catch(e)
	{
	}
	return false;
}
function SetUploadPageTitle()
{
	if (GetUrlKeyValue("Type")==1)
	{
		document.title=L_NewFormClickOnce1_Text;
		if (browseris.ie || browseris.nav6up)
		{
			var titleElt=document.getElementById("onetidTextTitle");
			if (titleElt !=null)
				titleElt.innerHTML=L_NewFormClickOnce1_Text;
		}
	}
}
function GetSelectedValue (frmElem) {
	if (frmElem && (frmElem.selectedIndex >-1)) {
		return frmElem.options[frmElem.selectedIndex].value
	}
	else
		return "";
}
function GetSelectedText(frmElem) {
	if (frmElem && (frmElem.selectedIndex >-1)) {
		return frmElem.options[frmElem.selectedIndex].text
	}
	else
		return "";
}
function MtgShowTimeZone()
{
	if (GetCookie("MtgTimeZone")=="1")
	{
		MtgToggleTimeZone();
	}
}
function FormatDate(sDate, sTime, eDate, eTime)
{
	var L_Date_Text="<b>Date:</b>";
	var L_Time_Text="<b>Time:</b>";
	var L_DateSeparator=" - ";
	if(browseris.win32 && sDate==eDate)
		L_DateSeparator=" -\u200e ";
	if (sDate==eDate)
	{
		document.write(L_Date_Text+" "+sDate);
		if (sTime !=eTime)
			document.write(" "+L_Time_Text+" "+sTime+L_DateSeparator+eTime);
		else
			document.write(" "+L_Time_Text+" "+sTime);
	}
	else
	{
		document.write(L_Date_Text+" "+sDate+" ("+sTime+")"+L_DateSeparator+eDate+" ("+eTime+")");
	}
}
function GetAlertText(isDetached)
{
	var L_DETACHEDSINGLEEXCEPT_Text="This meeting date is no longer associated with a meeting in your calendar and scheduling program. Either this meeting date was canceled, or the link to the workspace was removed from the scheduled meeting.";
	var L_DETACHEDCANCELLEDEXCEPT_Text="This meeting date was canceled from your calendar and scheduling program. To specify what you want to do with the associated information in the workspace, do the following: In the Meeting Series pane, point to the meeting date, and in the drop-down list, click Keep, Delete, or Move.";
	var L_DETACHEDUNLINKEDSINGLE_Text="This meeting date is no longer linked to the associated meeting in your calendar and scheduling program. To specify what you want to do with the information in the workspace, do the following: In the Meeting Series pane, point to the meeting date, and in the drop-down list, click Keep, Delete, or Move.";
	var L_DETACHEDCANCELLEDSERIES_Text="This meeting series was canceled from your calendar and scheduling program.";
	var L_DETACHEDUNLINKEDSERIES_Text="This meeting series is no longer linked to the associated meeting series in your calendar and scheduling program. You can keep or delete the workspace. If you keep the workspace, you will not be able to link it to another scheduled meeting.";
	var L_DETACHEDSERIESNOWSINGLE_Text="This meeting was changed in your calendar and scheduling program from a recurring meeting to a nonrecurring meeting. You can keep or delete the workspace. If you keep the workspace, you will not be able to link it to another scheduled meeting.";
	var L_DETACHEDSINGLENOWSERIES_Text="This meeting was changed in your calendar and scheduling program from a nonrecurring meeting to a recurring meeting. The current workspace does not support a recurring meeting. In your scheduling program, unlink the meeting from the workspace, and then link the meeting again to a new workspace. The new workspace will automatically support a recurring meeting.";
	var L_DETACHEDNONGREGORIANCAL_Text="This meeting was created using a calendar and scheduling program that only supports series updates to the Meeting Workspace. Changes you make to individual occurrences of meetings in that program will not appear in the workspace.";
	var L_DETACHEDPASTEXCPMODIFIED_Text="This past meeting was modified or canceled from your calendar and scheduling program. To keep, delete or move this meeting in the workspace, use the drop-down menu next to its date in the Meeting Series pane. To update the scheduling information for this meeting in the workspace, use your scheduling program to update this specific meeting occurrence.";
	var howOrphaned=isDetached & (0x10 - 1);
	var howDetached=isDetached - howOrphaned;
	if (howOrphaned)
	{
		switch (howOrphaned)
		{
			case 1:	return (g_meetingCount==1) ? L_DETACHEDSINGLEEXCEPT_Text : L_DETACHEDCANCELLEDEXCEPT_Text;
			case 2:	return L_DETACHEDCANCELLEDSERIES_Text;
			case 3: return L_DETACHEDCANCELLEDEXCEPT_Text;
			case 4:	return (g_meetingCount==1) ? L_DETACHEDSINGLEEXCEPT_Text : L_DETACHEDUNLINKEDSINGLE_Text;
			case 5:	return L_DETACHEDUNLINKEDSERIES_Text;
			case 6:	return L_DETACHEDSERIESNOWSINGLE_Text;
			case 7:	return L_DETACHEDSINGLENOWSERIES_Text;
			case 8:	return L_DETACHEDPASTEXCPMODIFIED_Text;
		}
	}
	else if (howDetached)
	{
		switch (howDetached)
		{
			case 16: return L_DETACHEDNONGREGORIANCAL_Text;
		}
	}
	return null;
}
function retrieveCurrentThemeLink()
{
	var cssLink;
	var links=document.getElementsByTagName("link");
	for(var i=0; i<links.length; i++)
	{
		if((links[i].type=="text/css") && (links[i].id=="onetidThemeCSS"))
			cssLink=links[i];
	}
	if(cssLink)
	{
		var re=/(\.\.\/)+/;
		var relativeURL=cssLink.href;
		var newURL=relativeURL.replace(re, "/");
		return newURL;
	}
}
function StBuildParam(stPattern)
{
	var re;
	var i;
	for (i=1; i < StBuildParam.arguments.length; i++)
		{
		re=new RegExp("\\^"+i);
		stPattern=stPattern.replace(re, StBuildParam.arguments[i]);
		}
	return stPattern;
}
JSRequest={
	QueryString : null,
	FileName : null,
	PathName : null,
	EnsureSetup : function()
	{
		if (JSRequest.QueryString !=null) return;
		JSRequest.QueryString=new Array();
		var queryString=window.location.search.substring(1);
		var pairs=queryString.split("&");
		for (var i=0;i<pairs.length;i++)
		{
			var p=pairs[i].indexOf("=");
			if (p > -1)
			{
				var key=pairs[i].substring(0,p);
				var value=pairs[i].substring(p+1);
				JSRequest.QueryString[key]=value;
			}
		}
		var path=JSRequest.PathName=window.location.pathname;
		var p=path.lastIndexOf("/");
		if (p > -1)
		{
			JSRequest.FileName=path.substring(p+1);
		}
		else
		{
			JSRequest.PageName=path;
		}
	}
};
var ExpGroupWPListName="WSS_ExpGroupWPList";
var ExpGroupCookiePrefix="WSS_ExpGroup_";
var ExpGroupCookieDelimiter="&";
var ExpGroupMaxWP=11;
var ExpGroupMaxCookieLength=3960;
var g_ExpGroupQueue=new Array();
var g_ExpGroupInProgress=false;
var g_ExpGroupTable=new Array();
var g_ExpGroupNeedsState=false;
var g_ExpGroupParseStage=false;
function ExpCollGroup(groupName, imgName)
{
	if (document.getElementById("titl"+groupName)==null)
		return;
	viewTable=document.getElementById("titl"+groupName).parentNode;
	if (viewTable==null)
		return;
	tbodyTags=viewTable.getElementsByTagName("TBODY");
	numElts=tbodyTags.length;
	len=groupName.length;
	img=document.getElementById(imgName);
	if (img==null)
		return;
	srcPath=img.src;
	index=srcPath.lastIndexOf("/");
	imgName=srcPath.slice(index+1);
	var fOpen=false;
	if (imgName=='plus.gif')
	{
		fOpen=true;
		displayStr="";
		img.src='/_layouts/images/minus.gif';
	}
	else
	{
		fOpen=false;
		displayStr="none";
		img.src='/_layouts/images/plus.gif';
	}
	for (var i=0;i<numElts;i++)
	{
		var childObj=tbodyTags[i];
		if ( (childObj.id !=null)
					&& (childObj.id.length > len+4)
					&& (groupName==childObj.id.slice(4).substr(0,len)) )
		{
			if (fOpen)
			{
				index=childObj.id.indexOf("_", len+4);
				if (index!=-1)
				{
					index=childObj.id.indexOf("_", index+1);
					if (index!=-1)
						continue;
				}
			}
			childObj.style.display=displayStr;
			if (fOpen && childObj.id.substr(0,4)=="titl")
			{
				imgObj=document.getElementById("img_"+childObj.id.slice(4));
				imgObj.src='/_layouts/images/plus.gif';
			}
		}
	}
	if (!g_ExpGroupParseStage)
	{
		if (g_ExpGroupNeedsState && ExpGroupFetchWebPartID(groupName) !=null)
		{
			if (fOpen)
			{
				AddGroupToCookie(groupName);
			}
			else
			{
				RemoveGroupFromCookie(groupName);
			}
		}
		if (fOpen)
		{
			tbody=document.getElementById("tbod"+groupName+"_");
			if (tbody !=null)
			{
				isLoaded=tbody.getAttribute("isLoaded");
				if (isLoaded=="false")
				{
					ExpGroupFetchData(groupName);
				}
			}
		}
	}
}
function ExpGroupFetchData(groupName)
{
	var loadString="<tr><td></td><td class=\"ms-gbload\">"+L_Loading_Text+"</td></tr>";
	ExpGroupRenderData(loadString, groupName, "false");
	if (!g_ExpGroupInProgress)
	{
		var groupString=ExpGroupFetchGroupString(groupName);
		if (groupString==null)
		{
			var loadString="<tr><td></td><td class=\"ms-gbload\">"+L_Loading_Error_Text+"</td></tr>";
			ExpGroupRenderData(loadString, groupName, "false");
			if (g_ExpGroupQueue.length > 0)
			{
				ExpGroupFetchData(g_ExpGroupQueue.shift());
			}
			return;
		}
		g_ExpGroupInProgress=true;
		if (!ExpGroupCallServer(groupString, groupName))
		{
			if (g_ExpGroupQueue.length > 0)
			{
				ExpGroupFetchData(g_ExpGroupQueue.shift());
			}
		}
	}
	else
	{
		g_ExpGroupQueue.push(groupName);
	}
}
function ExpGroupCallServer(groupString, groupName)
{
	var webPartID=ExpGroupFetchWebPartID(groupName);
	if (webPartID !=null)
	{
		var functionName="ExpGroupCallServer"+webPartID;
		var functionCall=functionName+"('"+groupString+"','"+groupName+"')";
		eval(functionCall);
	}
}
function ExpGroupReceiveData(htmlToRender, groupName)
{
	var ctxId="ctx"+groupName.substring(0, groupName.indexOf("-"));
	var indexBeginCTXName=htmlToRender.indexOf("CTXName=\"");
	if (indexBeginCTXName !=-1)
	{
		if (ctxId !="ctx1")
		{
			htmlToRender=htmlToRender.replace(/ CTXName=\"ctx1\" /g, " CTXName=\""+ctxId+"\" ");
		}
	}
	var needOuterWrap=false;
	if (htmlToRender.length < 4)
	{
		needOuterWrap=true;
	}
	else if (htmlToRender.substring(0,3) !="<tr")
	{
		needOuterWrap=true;
	}
	if (needOuterWrap)
	{
		htmlToRender="<TR><TD>"+htmlToRender+"</TD></TR>";
	}
	ExpGroupRenderData(htmlToRender, groupName, "true");
	g_ExpGroupInProgress=false;
	if (g_ExpGroupQueue.length > 0)
	{
		ExpGroupFetchData(g_ExpGroupQueue.shift());
	}
}
function ExpGroupRenderData(htmlToRender, groupName, isLoaded)
{
	var tbody=document.getElementById("tbod"+groupName+"_");
	var wrapDiv=document.createElement("DIV");
	wrapDiv.innerHTML="<TABLE><TBODY id=\"tbod"+			groupName+"_\" isLoaded=\""+isLoaded+			"\">"+htmlToRender+"</TBODY></TABLE>";
	tbody.parentNode.replaceChild(wrapDiv.firstChild.firstChild,tbody);
}
function ExpGroupFetchGroupString(groupName)
{
	titlTbody=document.getElementById("titl"+groupName);
	if (titlTbody==null)
	{
		return null;
	}
	else
	{
		var groupString=titlTbody.getAttribute("groupString");
		return groupString;
	}
}
function ExpGroupFetchWebPartID(groupName)
{
	var viewCounter=groupName.substring(0, groupName.indexOf("-"));
	var lookupEntry=document.getElementById("GroupByWebPartID"+viewCounter);
	if (lookupEntry==null)
		return null;
	return lookupEntry.getAttribute("webPartID");
}
function RenderActiveX(str)
{
	document.write(str);
}
function OnItem(elm)
{
	DeferCall('OnItemDeferCall', elm);
}
function OnLink(elm)
{
	DeferCall('OnLinkDeferCall', elm);
}
function MMU_PopMenuIfShowing(menuElement)
{
	DeferCall('MMU_PopMenuIfShowingDeferCall', menuElement);
}
function OnMouseOverFilter(elm)
{
	DeferCall('OnMouseOverFilterDeferCall', elm);
}
function MMU_EcbTableMouseOverOut(ecbTable, fMouseOver)
{
	DeferCall('MMU_EcbTableMouseOverOutDeferCall', ecbTable, fMouseOver);
}
function OnMouseOverAdHocFilter(elm, fieldStr)
{
	DeferCall('OnMouseOverAdHocFilterDeferCall', elm, fieldStr);
}
function MMU_EcbLinkOnFocusBlur(menu, ecbLink, fOnFocus)
{
	DeferCall('MMU_EcbLinkOnFocusBlurDeferCall', menu, ecbLink, fOnFocus);
}
function FixTextAlignForBidi(value)
{
	if (!browseris.ie)
		return;
	var cStylesheets=document.styleSheets;
	if (cStylesheets !=null)
	{
		for (var x=0; x < cStylesheets.length; x++) {
			if ((cStylesheets[x] !=null) && (cStylesheets[x].rules !=null))
			{
				for (var y=0; y < cStylesheets[x].rules.length; y++) {
					if (cStylesheets[x].rules[y].selectorText==".ms-vh" ||
						cStylesheets[x].rules[y].selectorText==".ms-vh2" ||
						cStylesheets[x].rules[y].selectorText==".ms-vh-icon" ||
						cStylesheets[x].rules[y].selectorText==".ms-vh-icon-empty" ||
						cStylesheets[x].rules[y].selectorText==".ms-vh2-nograd" ||
						cStylesheets[x].rules[y].selectorText==".ms-vh2-nograd-icon" ||
						cStylesheets[x].rules[y].selectorText==".ms-vh2-nofilter" ||
						cStylesheets[x].rules[y].selectorText==".ms-vh2-nofilter-icon" ||
						cStylesheets[x].rules[y].selectorText==".ms-vhImage") {
						cStylesheets[x].rules[y].style.textAlign=value;
					}
				}
			}
		}
	}
}

