<%
' ********************************************************************
' Copyright (C) 2001 Microsoft Corporation. All rights reserved.
'
'	IMPORTANT.  Please read the legal.txt file, located in the
'	"<CMS Install Directory>\Server\httpexec\WBC\Internals"
'	directory, governing the use of this internal file."
' ********************************************************************

Dim g_bScriptGenerated
g_bScriptGenerated = False

' -- Boolean to keep track of whether page is emitting DHTML placeholder.
Dim g_bEmitForDHTMLPlaceholder
g_bEmitForDHTMLPlaceholder = False
' ---- [Public] Emitting DHTML placeholder for IE clients
Sub EmitRichPh( pThisPosting, PlaceholderEmitter )

	If Not g_bScriptGenerated Then
%>

<script language="JavaScript"
	src="<%=IDS_FRAMEWORK_VIRTUAL_PATH%>/Internals/PageTemplate/Authoring/AuthFormClientIE.js"
	type="text/javascript"></script>

<OBJECT ID="ToolbarInterface" CLASSID="CLSID:E99D3E39-5D92-4360-BA86-2C563B3CFFEB"
	CODEBASE="/NR/System/WBC/Internals/PageTemplate/PlaceholdersSupport/NRDHtml.cab#Version=5,0,1555,1" WIDTH=0 HEIGHT=0>
	<PARAM NAME="BaseUrl" VALUE="/NR/System/WBC/Internals/PageTemplate/PlaceholdersSupport/ToolbarImages/">
</OBJECT>

<SCRIPT LANGUAGE=VBScript>

<!--#include virtual="/NR/System/WBC/Customizable/WBCFuncPagesConfig/UIStringConstants/ActiveXAuthoringPlaceholderUIStrings.inc"-->

<!--#include virtual="/NR/System/WBC/Internals/Integration/InternalHooks/ActiveXToolbarHooks.inc"-->
<!--#include virtual="/NR/System/WBC/Customizable/Hooks/ActiveXToolbarHooks.inc"-->

Sub UpdateButton( byval pActiveHtmlEditor, byval strItemName, byval strTrueValue )
	if pActiveHtmlEditor.dom.queryCommandEnabled(strItemName) = true then
		If StrComp(pActiveHtmlEditor.dom.queryCommandValue(strItemName), strTrueValue)=0 Then
			pActiveHtmlEditor.ToolbarState.Item(strItemName).Checked = true
		Else
			pActiveHtmlEditor.ToolbarState.Item(strItemName).Checked = false
		End If
		pActiveHtmlEditor.ToolbarState.Item(strItemName).Enabled = true
	else
		pActiveHtmlEditor.ToolbarState.Item(strItemName).Enabled = false
	end if
End Sub

Sub UpdateEnabledButton( byval pActiveHtmlEditor, byval strItemName )
	pActiveHtmlEditor.ToolbarState.Item(strItemName ).Enabled = pActiveHtmlEditor.dom.queryCommandEnabled(strItemName )
End Sub

Function HtmlToExternalFontSize( byval nFontSize )
	If nFontSize <= 1 Then
		HtmlToExternalFontSize = 8
	ElseIf nFontSize = 2 Then
		HtmlToExternalFontSize = 10
	ElseIf nFontSize = 3 Then
		HtmlToExternalFontSize = 12
	ElseIf nFontSize = 4 Then
		HtmlToExternalFontSize = 14
	ElseIf nFontSize = 5 Then
		HtmlToExternalFontSize = 18
	ElseIf nFontSize = 6 Then
		HtmlToExternalFontSize = 24
	ElseIf nFontSize = 7 Then
		HtmlToExternalFontSize = 36
	End If
End Function

Function ExternalToHtmlFontSize( byval nFontSize )
	If nFontSize > 30 Then
		ExternalToHtmlFontSize = 7
	ElseIf nFontSize > 20 Then
		ExternalToHtmlFontSize = 6
	ElseIf nFontSize > 16 Then
		ExternalToHtmlFontSize = 5
	ElseIf nFontSize > 12 Then
		ExternalToHtmlFontSize = 4
	ElseIf nFontSize > 10 Then
		ExternalToHtmlFontSize = 3
	ElseIf nFontSize > 8 Then
		ExternalToHtmlFontSize = 2
	else
		ExternalToHtmlFontSize = 1
	End If
End Function


Sub UpdateComboBox(byval pActiveHtmlEditor, byval strItemName )
	if pActiveHtmlEditor.dom.queryCommandEnabled(strItemName) = true then
		pActiveHtmlEditor.ToolbarState.Item(strItemName).Enabled = true
		If IsNull(pActiveHtmlEditor.dom.queryCommandValue(strItemName)) Then
			pActiveHtmlEditor.ToolbarState.Item(strItemName).ComboBoxSel = ""
		else
			pActiveHtmlEditor.ToolbarState.Item(strItemName).ComboBoxSel = pActiveHtmlEditor.dom.queryCommandValue(strItemName)
		End If
	else
		pActiveHtmlEditor.ToolbarState.Item(strItemName).Enabled = false
		pActiveHtmlEditor.ToolbarState.Item(strItemName).ComboBoxSel = ""
	end if
End Sub

sub SetHeaderBarColor( byval pActiveHtmlEditor, byval strColor )
	' in case capability bar was turned off, ignore any error
	on error resume next
	pActiveHtmlEditor.OuterHTMLElement.parentElement.parentElement.parentElement.children(0).children(0).bgColor = strColor
end sub

Sub ToolbarInterface_OnChange( byval pActiveHtmlEditor, byval bstrId, byval pItem )
	Dim bChecked

	Select Case bstrId
	Case "GotFocus"
		SetHeaderBarColor pActiveHtmlEditor, "#aeaeae"
	case "LostFocus"
		SetHeaderBarColor pActiveHtmlEditor, "#dedfde"
	Case "UpdateUI"
		pActiveHtmlEditor.ToolbarState.Item("HtmlEdit").Checked = pActiveHtmlEditor.EditingSource

		UpdateEnabledButton	pActiveHtmlEditor, "Cut"
		UpdateEnabledButton	pActiveHtmlEditor, "Copy"
		UpdateEnabledButton	pActiveHtmlEditor, "Paste"

		pActiveHtmlEditor.ToolbarState.Item("Undo").Enabled = pActiveHtmlEditor.CanUndo
		pActiveHtmlEditor.ToolbarState.Item("Redo").Enabled = pActiveHtmlEditor.CanRedo

		if pActiveHtmlEditor.EditingSource = false then
			UpdateComboBox pActiveHtmlEditor, "FontName"
			UpdateComboBox pActiveHtmlEditor, "FormatBlock"

			if pActiveHtmlEditor.dom.queryCommandEnabled("FontSize") = true then
				pActiveHtmlEditor.ToolbarState.Item("FontSize").ComboBoxSel = CStr(HtmlToExternalFontSize(pActiveHtmlEditor.dom.queryCommandValue("FontSize")))
				pActiveHtmlEditor.ToolbarState.Item("FontSize").Enabled = true
			else
				pActiveHtmlEditor.ToolbarState.Item("FontSize").Enabled = false
				pActiveHtmlEditor.ToolbarState.Item("FontSize").ComboBoxSel = ""
			end if

			UpdateButton pActiveHtmlEditor, "Bold", "True"
			UpdateButton pActiveHtmlEditor, "Italic", "True"
			UpdateButton pActiveHtmlEditor, "Underline", "True"

			UpdateButton pActiveHtmlEditor, "JustifyLeft", "True"
			UpdateButton pActiveHtmlEditor, "JustifyCenter", "True"
			UpdateButton pActiveHtmlEditor, "JustifyRight", "True"

			UpdateButton pActiveHtmlEditor, "InsertOrderedList", "True"
			UpdateButton pActiveHtmlEditor, "InsertUnorderedList", "True"
		End If

		' call internal Hook
		Call OnInternalToolbarUpdate( pActiveHtmlEditor, pActiveHtmlEditor.EditingSource )
		' call external Customizable Hook
		Call OnToolbarUpdate( pActiveHtmlEditor, pActiveHtmlEditor.EditingSource )
	Case "FormatBlock"
		pActiveHtmlEditor.dom.execCommand "FormatBlock", false, pItem.CurrentString
		UpdateComboBox pActiveHtmlEditor, "FormatBlock"
	Case "FontSize"
		pActiveHtmlEditor.dom.execCommand "FontSize", false, ExternalToHtmlFontSize(pItem.CurrentString)
		pActiveHtmlEditor.ToolbarState.Item("FontSize").ComboBoxSel = HtmlToExternalFontSize(pActiveHtmlEditor.dom.queryCommandValue("FontSize"))
	Case "FontName"
		pActiveHtmlEditor.dom.execCommand "FontName", false, pItem.CurrentString
		UpdateComboBox pActiveHtmlEditor, "FontName"

	Case "HtmlEdit"
		bChecked = not pActiveHtmlEditor.EditingSource
		If ( bChecked ) Then
			Call WBC_cleanHtml( pActiveHtmlEditor.dom )
		End If
		pActiveHtmlEditor.EditingSource = bChecked
		pActiveHtmlEditor.ToolbarState.Item("HtmlEdit").Checked = bChecked

		pActiveHtmlEditor.ToolbarState.Item("FormatBlock").Enabled = not bChecked
		pActiveHtmlEditor.ToolbarState.Item("FontName").Enabled = not bChecked
		pActiveHtmlEditor.ToolbarState.Item("FontSize").Enabled = not bChecked
		pActiveHtmlEditor.ToolbarState.Item("ForeColor").Enabled = not bChecked
		pActiveHtmlEditor.ToolbarState.Item("BackColor").Enabled = not bChecked
		pActiveHtmlEditor.ToolbarState.Item("InsertImage").Enabled = not bChecked
		pActiveHtmlEditor.ToolbarState.Item("InsertVideo").Enabled = not bChecked
		pActiveHtmlEditor.ToolbarState.Item("InsertAttachment").Enabled = not bChecked
		pActiveHtmlEditor.ToolbarState.Item("JustifyLeft").Enabled = not bChecked
		pActiveHtmlEditor.ToolbarState.Item("JustifyRight").Enabled = not bChecked
		pActiveHtmlEditor.ToolbarState.Item("JustifyCenter").Enabled = not bChecked

		pActiveHtmlEditor.ToolbarState.Item("Outdent").Enabled = not bChecked
		pActiveHtmlEditor.ToolbarState.Item("Indent").Enabled = not bChecked
		pActiveHtmlEditor.ToolbarState.Item("InsertTable").Enabled = not bChecked
		pActiveHtmlEditor.ToolbarState.Item("InsertOrderedList").Enabled = not bChecked
		pActiveHtmlEditor.ToolbarState.Item("InsertUnorderedList").Enabled = not bChecked
		pActiveHtmlEditor.ToolbarState.Item("Bold").Enabled = not bChecked
		pActiveHtmlEditor.ToolbarState.Item("Italic").Enabled = not bChecked
		pActiveHtmlEditor.ToolbarState.Item("Underline").Enabled = not bChecked
		pActiveHtmlEditor.ToolbarState.Item("CreateLink").Enabled = not bChecked
	case "SpellCheck"
		dim pState, elm
		window.status = "Checking spelling..."
		set pState = document.ToolbarInterface.CreateSpellCheckState
		for each elm in document.all
			if pState.CheckPlaceholderSpelling(elm) = true then
				window.status = "Spell check cancelled"
				exit sub
			end if
		next
		window.status = "Spell check complete"
	Case "Undo"
		pActiveHtmlEditor.Undo
		pActiveHtmlEditor.ToolbarState.Item("Undo").Enabled = pActiveHtmlEditor.CanUndo
		pActiveHtmlEditor.ToolbarState.Item("Redo").Enabled = pActiveHtmlEditor.CanRedo
	Case "Redo"
		pActiveHtmlEditor.Redo
		pActiveHtmlEditor.ToolbarState.Item("Undo").Enabled = pActiveHtmlEditor.CanUndo
		pActiveHtmlEditor.ToolbarState.Item("Redo").Enabled = pActiveHtmlEditor.CanRedo
	Case "Bold"
		pActiveHtmlEditor.dom.execCommand "Bold"
		UpdateButton pActiveHtmlEditor, "Bold", "True"
	Case "Italic"
		pActiveHtmlEditor.dom.execCommand "Italic"
		UpdateButton pActiveHtmlEditor, "Italic", "True"
	Case "Underline"
		pActiveHtmlEditor.dom.execCommand "Underline"
		UpdateButton pActiveHtmlEditor, "Underline", "True"

	Case "ForeColor"
		Call WBC_setColor( pActiveHtmlEditor.dom, "ForeColor" )
	Case "BackColor"
		Call WBC_setColor( pActiveHtmlEditor.dom, "BackColor" )

	Case "JustifyLeft"
		pActiveHtmlEditor.dom.execCommand "JustifyLeft"
		UpdateButton pActiveHtmlEditor, "JustifyLeft", "True"
	Case "JustifyCenter"
		pActiveHtmlEditor.dom.execCommand "JustifyCenter"
		UpdateButton pActiveHtmlEditor, "JustifyCenter", "True"
	Case "JustifyRight"
		pActiveHtmlEditor.dom.execCommand "JustifyRight"
		UpdateButton pActiveHtmlEditor, "JustifyRight", "True"

	Case "InsertOrderedList"
		pActiveHtmlEditor.dom.execCommand "InsertOrderedList"
		UpdateButton pActiveHtmlEditor, "InsertOrderedList", "True"
	Case "InsertUnorderedList"
		pActiveHtmlEditor.dom.execCommand "InsertUnorderedList"
		UpdateButton pActiveHtmlEditor, "InsertUnorderedList", "True"

	Case "Outdent"
		pActiveHtmlEditor.dom.execCommand "Outdent"
		UpdateButton pActiveHtmlEditor, "Outdent", "True"
	Case "Indent"
		pActiveHtmlEditor.dom.execCommand "Indent"
		UpdateButton pActiveHtmlEditor, "Indent", "True"

	case "Cut"
		pActiveHtmlEditor.dom.execCommand "Cut"
	case "Copy"
		pActiveHtmlEditor.dom.execCommand "Copy"
	case "Paste"
		pActiveHtmlEditor.dom.execCommand "Paste"
	case else
		' call Internal Hook
		Call OnInternalToolbarEvent( pActiveHtmlEditor, bstrId, pItem, pActiveHtmlEditor.EditingSource )
		' call external Customizable Hook
		Call OnToolbarEvent( pActiveHtmlEditor, bstrId, pItem, pActiveHtmlEditor.EditingSource )
	End Select
End Sub

dim bInitializedToolbar
bInitializedToolbar = false

Sub InitializeToolbar
	If bInitializedToolbar = true Then
		exit Sub
	End If
	bInitializedToolbar = true

	Dim format_toolbar
	set format_toolbar = document.ToolbarInterface.Toolbars.CreateToolbar("Formatting")

	Dim edit_toolbar
	set edit_toolbar = document.ToolbarInterface.Toolbars.CreateToolbar("Editing")

	format_toolbar.IconWidth = 16
	format_toolbar.IconHeight = 15
	format_toolbar.ButtonWidth = 18
	format_toolbar.ButtonHeight = 18
	format_toolbar.Break = false

	edit_toolbar.IconWidth = 16
	edit_toolbar.IconHeight = 15
	edit_toolbar.ButtonWidth = 18
	edit_toolbar.ButtonHeight = 18

	dim myhtmlstyle
	dim myfont
	dim myfontsize
	dim i


	set myhtmlstyle = format_toolbar.AddComboBox("FormatBlock", "HTML Style", 100)
	myhtmlstyle.AllowTextEdit = false
	myhtmlstyle.Sort = False

	dim arrStyles, strStyle
	arrStyles = document.ToolbarInterface.AvailableStyles

	for each strStyle in arrStyles
		myhtmlstyle.AddString strStyle
	next

	myhtmlstyle.CurrentString = "Normal"

	set myfont = format_toolbar.AddComboBox("FontName", "Font Face", 150)
	myfont.AllowTextEdit = false

	dim arrFonts, strFont
	arrFonts = document.ToolbarInterface.AvailableFonts
	for each strFont in arrFonts
		myfont.AddString strFont
	next

	myfont.CurrentString = "Times New Roman"

	set myfontsize = format_toolbar.AddComboBox("FontSize", "Font Size", 80)
	myfontsize.AllowTextEdit = false
	myfontsize.Sort = False
	myfontsize.CurrentString = "12"

	myfontsize.AddString "8"
	myfontsize.AddString "10"
	myfontsize.AddString "12"
	myfontsize.AddString "14"
	myfontsize.AddString "18"
	myfontsize.AddString "24"
	myfontsize.AddString "36"

	call format_toolbar.AddSeperator

	format_toolbar.AddButton "InsertImage", "", "image.gif", IDS_UI_TOOLTIP_ACTIVEX_INSERT_IMAGE
	format_toolbar.AddButton "InsertVideo", "", "video.gif", IDS_UI_TOOLTIP_ACTIVEX_INSERT_VIDEO
	format_toolbar.AddButton "InsertAttachment", "", "attachment.gif", IDS_UI_TOOLTIP_ACTIVEX_INSERT_ATTACHMENT

	call format_toolbar.AddSeperator

	format_toolbar.AddButton "InsertTable", "", "table.gif", IDS_UI_TOOLTIP_ACTIVEX_INSERT_TABLE
	format_toolbar.AddButton "CreateLink", "", "wlink.gif", IDS_UI_TOOLTIP_ACTIVEX_EDIT_HYPERLINK

	call format_toolbar.AddSeperator
	format_toolbar.AddCheckButton "HtmlEdit", "", "HTMLEdit.gif", IDS_UI_TOOLTIP_ACTIVEX_EDIT_SOURCE

	edit_toolbar.AddButton "Cut", "", "cut.gif", IDS_UI_TOOLTIP_ACTIVEX_CUT
	edit_toolbar.AddButton "Copy", "", "copy.gif", IDS_UI_TOOLTIP_ACTIVEX_COPY
	edit_toolbar.AddButton "Paste", "",	"paste.gif", IDS_UI_TOOLTIP_ACTIVEX_PASTE

	call edit_toolbar.AddSeperator
	edit_toolbar.AddButton "Undo", "", "undo.gif", IDS_UI_TOOLTIP_ACTIVEX_UNDO
	edit_toolbar.AddButton "Redo", "", "redo.gif", IDS_UI_TOOLTIP_ACTIVEX_REDO
	call edit_toolbar.AddSeperator

	set p = edit_toolbar.AddButton("SpellCheck", "", "spell.gif", IDS_UI_TOOLTIP_ACTIVEX_SPELL_CHECK)
	p.Global = true
	p.Enabled = document.ToolbarInterface.CanSpellCheck

	call edit_toolbar.AddSeperator
	edit_toolbar.AddCheckButton "Bold", "",	"bold.gif", IDS_UI_TOOLTIP_ACTIVEX_BOLD
	edit_toolbar.AddCheckButton "Italic", "", "italic.gif", IDS_UI_TOOLTIP_ACTIVEX_ITALIC
	edit_toolbar.AddCheckButton "Underline", "", "under.gif", IDS_UI_TOOLTIP_ACTIVEX_UNDERLINE
	call edit_toolbar.AddSeperator

	edit_toolbar.AddButton "ForeColor", "", "tpaint.gif", IDS_UI_TOOLTIP_ACTIVEX_FOREGROUND_COLOR
	edit_toolbar.AddButton "BackColor", "", "parea.gif", IDS_UI_TOOLTIP_ACTIVEX_BACKGROUND_COLOR
	call edit_toolbar.AddSeperator

	edit_toolbar.AddCheckButton "JustifyLeft", "",	"aleft.gif", IDS_UI_TOOLTIP_ACTIVEX_ALIGN_LEFT
	edit_toolbar.AddCheckButton "JustifyCenter", "", "center.gif", IDS_UI_TOOLTIP_ACTIVEX_ALIGN_CENTER
	edit_toolbar.AddCheckButton "JustifyRight", "",	"aright.gif", IDS_UI_TOOLTIP_ACTIVEX_ALIGN_RIGHT
	call edit_toolbar.AddSeperator

	edit_toolbar.AddCheckButton "InsertOrderedList", "", "nlist.gif", IDS_UI_TOOLTIP_ACTIVEX_NUMBERED_LIST
	edit_toolbar.AddCheckButton "InsertUnorderedList", "", "blist.gif", IDS_UI_TOOLTIP_ACTIVEX_BULLETED_LIST
	call edit_toolbar.AddSeperator

	edit_toolbar.AddButton "Outdent", "", "ileft.gif", IDS_UI_TOOLTIP_ACTIVEX_DECREASE_INDENT
	edit_toolbar.AddButton "Indent", "", "iright.gif", IDS_UI_TOOLTIP_ACTIVEX_INCREASE_INDENT

	' Call Internal Hook
	Call OnInternalToolbarInitialize( document.ToolbarInterface )

	' Call External Customizable Hook
	Call OnToolbarInitialize( document.ToolbarInterface )

	document.ToolbarInterface.ShowToolbars
End Sub
</SCRIPT>

<%
		g_bScriptGenerated = True
	End If

%>
<input
	name="NCPH_<%=PlaceholderEmitter.pPlaceholder.Name%>"
	type="hidden"
	placeholderType="activeX"
	value="<%= GetFilteredPhHTML(PlaceholderEmitter.pPlaceholder) %>">
</input>
<%
	Dim nPlaceholderWidth
	Dim nPlaceholderHeight

	nPlaceholderWidth = PlaceholderEmitter.Width

	' this little piece of code figures out the font size and estimates the height
	' of the placeholder accordingly

	dim nPos, nNextPos
	dim strStyle, nScaler, strPoints

	strStyle = PlaceholderEmitter.Style
	nScaler = 12

	If len(strStyle) > 0 Then
		nPos = instr(strStyle, "font-size: ")
		If nPos > 0 Then
			nNextPos = instr(nPos, strStyle, "pt")
			If nNextPos > nPos Then
				nPos = nPos + 11 ' skip the font-size
				strPoints = mid(strStyle, nPos, nNextPos-nPos)
				If IsNumeric(strPoints) Then
					nScaler = CLng(strPoints)
				End If
			End If
		End If
	End If

	nPlaceholderHeight = CLng(PlaceholderEmitter.Rows * (nScaler*1.8) + 55 + 21) ' estimate 12 pixels per row and 55 pixel toolbar

	' limit the placeholder height to 500
	If nPlaceholderHeight > 500 Then
		nPlaceholderHeight = 500
	End If

	Response.Write "<TABLE border=0 cellpadding=0 cellspacing=0>"

	If (OnInternalBeforeRenderWBCAuthoringPhToolbar(pThisPosting, PlaceholderEmitter.pPlaceholder) And _
		OnBeforeRenderWBCAuthoringPhToolbar(pThisPosting, PlaceholderEmitter.pPlaceholder) ) Then

		Response.Write	"<tr><td align=right bgcolor=#dedfde>"
		ShowPhCapIcons(PlaceholderEmitter.pPlaceholder)
		Response.Write "</td></tr>"
	End If

	Response.Write "<TR><TD>"


	' in case we are editing the page and have no rights to the template, we must assume that we already have
	' a real posting
	if AutoSession.This.Template is nothing then
%>
<OBJECT CODEBASE="/NR/System/WBC/Internals/PageTemplate/PlaceholdersSupport/NRDHtml.cab#Version=5,0,1555,1"
ID="NCPHRICH_<%=PlaceholderEmitter.pPlaceholder.Name%>" CLASSID="CLSID:B33422AC-C567-4F7D-BB28-6583371EC4EE" width="<%=nPlaceholderWidth%>" height="<%=nPlaceholderHeight%>">
	<PARAM NAME="PostUrl" VALUE="/NR/System/Marshalling/editorupload.asp?NRMODE=Update&NRNODEGUID=<%=AutoSession.This.GUID %>&ph=<%= Server.URLEncode(PlaceholderEmitter.pPlaceholder.Name) %>">
	<PARAM NAME="HTML" VALUE="<%= GetFilteredPhHTML(PlaceholderEmitter.pPlaceholder) %>">
        <PARAM NAME="CodePage" VALUE="<%= AutoSession.This.CodePage %>">
        <PARAM NAME="Charset" VALUE="<%= AutoSession.This.CharSet %>">
</OBJECT>
<% else %>
<OBJECT CODEBASE="/NR/System/WBC/Internals/PageTemplate/PlaceholdersSupport/NRDHtml.cab#Version=5,0,1555,1"
ID="NCPHRICH_<%=PlaceholderEmitter.pPlaceholder.Name%>" CLASSID="CLSID:B33422AC-C567-4F7D-BB28-6583371EC4EE" width="<%=nPlaceholderWidth%>" height="<%=nPlaceholderHeight%>">
	<PARAM NAME="PostUrl" VALUE="/NR/System/Marshalling/editorupload.asp?NRMODE=Update&NRTEMPLATEGUID=<%=AutoSession.This.Template.GUID %>&NRNODEGUID=<%=AutoSession.This.Template.GUID %>&ph=<%= Server.URLEncode(PlaceholderEmitter.pPlaceholder.Name) %>">
	<PARAM NAME="HTML" VALUE="<%= GetFilteredPhHTML(PlaceholderEmitter.pPlaceholder) %>">
        <PARAM NAME="CodePage" VALUE="<%= AutoSession.This.CodePage %>">
        <PARAM NAME="Charset" VALUE="<%= AutoSession.This.CharSet %>">
</OBJECT>
<%
	end if

   	Response.Write "</TD></TR></TABLE>"
%>

<SCRIPT language="VBScript" for="NCPHRICH_<%=PlaceholderEmitter.pPlaceholder.Name%>" event="OnLoad">
	call InitializeToolbar

	dim pPlaceholder
	set pPlaceholder = document.all("NCPHRICH_<%=PlaceholderEmitter.pPlaceholder.Name%>")

	set pPlaceholder.ToolbarInterface = document.ToolbarInterface

	pPlaceholder.ToolbarState.Item("Cut").Allowed = true
	pPlaceholder.ToolbarState.Item("Copy").Allowed = true
	pPlaceholder.ToolbarState.Item("Paste").Allowed = true
	pPlaceholder.ToolbarState.Item("Undo").Allowed = true
	pPlaceholder.ToolbarState.Item("Redo").Allowed = true

<%	If PlaceholderEmitter.pPlaceholder.AllowsHeadings = true Then %>
	pPlaceholder.ToolbarState.Item("FormatBlock").Allowed = true
<% End If %>
<%  If PlaceholderEmitter.HtmlSrcCodeEditable = true Then %>
	pPlaceholder.ToolbarState.Item("HtmlEdit").Allowed = true
<% End If %>

<%  If PlaceholderEmitter.pPlaceholder.AllowsFonts = true Then %>
	pPlaceholder.ToolbarState.Item("FontName").Allowed = true
	pPlaceholder.ToolbarState.Item("FontSize").Allowed = true
	pPlaceholder.ToolbarState.Item("ForeColor").Allowed = true
	pPlaceholder.ToolbarState.Item("BackColor").Allowed = true
<% End If %>
<% If PlaceholderEmitter.pPlaceholder.AllowsImages = true Then %>
	pPlaceholder.ToolbarState.Item("InsertImage").Allowed = true
<% End If %>
<% If AllowsVideos(PlaceholderEmitter.pPlaceholder) = true Then %>
	pPlaceholder.ToolbarState.Item("InsertVideo").Allowed = true
<% End If %>
<% If AllowsAttachments(PlaceholderEmitter.pPlaceholder) = true Then %>
	pPlaceholder.ToolbarState.Item("InsertAttachment").Allowed = true
<% End If %>
<% If PlaceholderEmitter.pPlaceholder.AllowsFlow = true Then %>
	pPlaceholder.ToolbarState.Item("JustifyLeft").Allowed = true
	pPlaceholder.ToolbarState.Item("JustifyRight").Allowed = true
	pPlaceholder.ToolbarState.Item("JustifyCenter").Allowed = true

	pPlaceholder.ToolbarState.Item("Outdent").Allowed = true
	pPlaceholder.ToolbarState.Item("Indent").Allowed = true
<% End If %>
<% If PlaceholderEmitter.pPlaceholder.AllowsTables = true Then %>
	pPlaceholder.ToolbarState.Item("InsertTable").Allowed = true
<% End If %>
<% If PlaceholderEmitter.pPlaceholder.AllowsFormattedLists = true Then %>
	pPlaceholder.ToolbarState.Item("InsertOrderedList").Allowed = true
	pPlaceholder.ToolbarState.Item("InsertUnorderedList").Allowed = true
<% End If %>
<% If PlaceholderEmitter.pPlaceholder.AllowsTextMarkUp = true Then %>
	pPlaceholder.ToolbarState.Item("Bold").Allowed = true
	pPlaceholder.ToolbarState.Item("Italic").Allowed = true
	pPlaceholder.ToolbarState.Item("Underline").Allowed = true
<% End If %>
<% If PlaceholderEmitter.pPlaceholder.AllowsHyperlinks = true Then %>
	pPlaceholder.ToolbarState.Item("CreateLink").Allowed = true
<% End If %>
	' call Internal Hook
	Call OnInternalToolbarStateInitialize( "<%=PlaceholderEmitter.pPlaceholder.Name%>", pPlaceholder.ToolbarState )

	' call external Customizable Hook
	Call OnToolbarStateInitialize( "<%=PlaceholderEmitter.pPlaceholder.Name%>", pPlaceholder.ToolbarState )

</SCRIPT>

<SCRIPT language="JavaScript" for="NCPHRICH_<%=PlaceholderEmitter.pPlaceholder.Name%>" event="OnToolbarChange(bstrID,item)">
<!--
	if (bstrID == "InsertImage") {
		WBC_launchImageGallery("<%=AutoSession.ThisPosting.QueryString%>", "<%= PlaceholderEmitter.pPlaceholder.Name %>", "<%=IDS_PHTYPE_THINEDITIE%>", <%= Bool2LCaseStr(PlaceholderEmitter.pPlaceholder.XAllowsImageUpload) %>);
	}
	else if (bstrID == "InsertAttachment") {
		WBC_launchAttachmentGallery("<%=AutoSession.ThisPosting.QueryString%>", "<%=PlaceholderEmitter.pPlaceholder.Name%>", "<%=IDS_PHTYPE_THINEDITIE%>", <%= Bool2LCaseStr(PlaceholderEmitter.pPlaceholder.XAllowsAttachmentUpload) %>, <%= Bool2LCaseStr(PlaceholderEmitter.pPlaceholder.XAttachmentsAsIcons) %>, false);
	}
	else if (bstrID == "InsertVideo") {
		WBC_launchVideoGallery("<%=AutoSession.ThisPosting.QueryString%>", "<%=PlaceholderEmitter.pPlaceholder.Name%>", "<%=IDS_PHTYPE_THINEDITIE%>", <%= Bool2LCaseStr(PlaceholderEmitter.pPlaceholder.XAllowsAttachmentUpload) %>, <%= Bool2LCaseStr( LCase(PlaceholderEmitter.pPlaceholder.XEmbeddedVideoElement) = "img") %>);
	}
	else if (bstrID == "InsertTable") {
		// show table dialog
		var strTableURL = IDS_FRAMEWORK_VIRTUAL_PATH + "/Internals/WBCFuncPages/Cross-Browser/Table/table.asp?" + "<%=AutoSession.ThisPosting.QueryString%>" + "&" + IDS_QPARAM_PHNAME + "=" + "<%= Server.URLEncode(PlaceholderEmitter.pPlaceholder.Name) %>" + "&" + IDS_QPARAM_PHTYPE + "=" +  IDS_PHTYPE_THINEDITIE;
		var strDlgRet = window.showModalDialog(strTableURL, "", "dialogWidth:320px;dialogHeight:190px;help:no;status:no");
		if (typeof(strDlgRet) == "undefined") return false;
		if (strDlgRet == "Cancel") return false;

		var aAttributes = strDlgRet.split(";");
		WBC_setTable("<%=PlaceholderEmitter.pPlaceholder.Name%>", "<%=IDS_PHTYPE_THINEDITIE%>", aAttributes[0], aAttributes[1], aAttributes[2]);
	}
	else if (bstrID == "CreateLink") {
		WBC_createLink( document.all["NCPHRICH_<%=PlaceholderEmitter.pPlaceholder.Name%>"].dom );
	}
//-->
</SCRIPT>

<%
End Sub
%>
