<!-- #include virtual="/NR/System/WBC/Internals/Main/WBCCommonShared.inc" -->
<!-- #include virtual="/NR/System/WBC/Internals/PageTemplate/PlaceholdersSupport/PlaceholdersSupport.inc" -->

<!-- #include virtual="/NR/System/WBC/Customizable/SiteEmbeddedWBCLinks/ConsoleUI.inc" -->
<!-- #include virtual="/NR/System/WBC/Customizable/SiteEmbeddedWBCLinks/SiteModeUI.inc" -->

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

<%
' ********************************************************************
' 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."
' ********************************************************************


' Initialize variables that detect for duplicate calls to hook functions
Dim m_bEmbedTmplHeadHookCalled
Dim m_bEmbedBodyBeginHookCalled
Dim m_bEmbedBodyEndHookCalled
m_bEmbedTmplHeadHookCalled = FALSE
m_bEmbedBodyBeginHookCalled = FALSE
m_bEmbedBodyEndHookCalled = FALSE


' ---- [Public] Implementation of the hook function embedded in the <head>...</head>
'				section of Content Management Server Templates HTML
Sub EmbedTmplHeadHook()
	' guard against being called more than once
	If (Not m_bEmbedTmplHeadHookCalled) Then
		m_bEmbedTmplHeadHookCalled = True

		Response.Write(Chr(13) & Chr(10) & _
						"<!-- Inserted by Content Management Server: BEGIN EmbedTmplHeadHook -->" & _
						Chr(13) & Chr(10))

		' call Internal Hook
		Call OnInternalHTMLHead()

		' call Customizable Hook 
		Call OnHTMLHead()

		' Important: the following call is necessary for WBC-enabling the page.
		Call EmbedWBCHeadSection()

		' report about illegal content stripped out from placeholders, if configured to do so
		If IDB_SHOW_FILTERED_WARNING Then
			Call EmbedWBCAuthPreviewReport()
		End If

        ' Add Robots meta tags for index and follow, if configured to do so
        ' e.g. <META name="ROBOTS" content="FOLLOW,INDEX">
        If IDB_AUTO_EMBED_ROBOTS_META_TAG Then
        	Call EmbedRobotsMetaTag()
        End If

		Response.Write(Chr(13) & Chr(10) & _
						"<!-- Inserted by Content Management Server: END EmbedTmplHeadHook -->" & _
						Chr(13) & Chr(10))
	End If
End Sub

' ---- [Public] Implementation of the hook function embedded after the <body> tag
'				of Content Management Server Templates HTML
Sub EmbedBodyBeginHook()
	' guard against being called more than once
	If (Not m_bEmbedBodyBeginHookCalled) Then
		m_bEmbedBodyBeginHookCalled = True

		Response.Write(Chr(13) & Chr(10) & _
						"<!-- Inserted by Content Management Server: BEGIN EmbedBodyBeginHook -->" & _
						Chr(13) & Chr(10))

		' call Internal Hook
		Call OnInternalHTMLBodyBegin()

		' call Customizable Hook
		Call OnHTMLBodyBegin()

		' make <form> related calls only in WBC Authoring Mode
		If IsAuthoringMode Then

			' Important: the following calls are necessary for WBC-enabling the page.
			Call EmbedWBCAuthFormBegin()

			' call Internal Hook
			Call OnInternalHTMLFormBegin()

			' call Customizable Hook
			Call OnHTMLFormBegin()

		End If

		Response.Write(Chr(13) & Chr(10) & _
						"<!-- Inserted by Content Management Server: END EmbedBodyBeginHook -->" & _
						Chr(13) & Chr(10))
	End If
End Sub

' ---- [Public] Implementation of the hook function embedded before the </body> tag
'				of Content Management Server Templates HTML
Sub EmbedBodyEndHook()
	' guard against being called more than once
	If (Not m_bEmbedBodyEndHookCalled) Then
		m_bEmbedBodyEndHookCalled = True

		Response.Write(Chr(13) & Chr(10) & _
						"<!-- Inserted by Content Management Server: BEGIN EmbedBodyEndHook -->" & _
						Chr(13) & Chr(10))

		' make <form> related calls only in WBC Authoring Mode
		If IsAuthoringMode Then

			' call Internal Hook
			Call OnInternalHTMLFormEnd()

			' call Customizable Hook
			Call OnHTMLFormEnd()

			' Important: the following call is necessary for WBC-enabling the page.
			Call EmbedWBCAuthFormEnd()

			'Due to DHTML problem in events firing, we need to add
			'special handling to make sure contents update is correct
			If (g_bEmitForDHTMLPlaceholder) Then
				Call EmitWindowOnLoadForDHTMLPlaceholder
			End If 


		End If

		' call Internal Hook
		Call OnInternalHTMLBodyEnd()

		' call Customizable Hook
		Call OnHTMLBodyEnd()

		Response.Write(Chr(13) & Chr(10) & _
						"<!-- Inserted by Content Management Server: END EmbedBodyEndHook -->" & _
						Chr(13) & Chr(10))
	End If
End Sub


' ---- [Public] Implementation of the subroutine to embed the Robots meta tag in the
'               <head>...</head> section of Content Management Server Templates HTML
'
' Outputs one of the following robot meta tags based on the IsRobotFollowable and
' IsRobotIndexable values of the Posting or Channel
'
' <META name="ROBOTS" content="FOLLOW,INDEX">
' <META name="ROBOTS" content="FOLLOW,NOINDEX">
' <META name="ROBOTS" content="NOFOLLOW,INDEX">
' <META name="ROBOTS" content="NOFOLLOW,NOINDEX">
'
' Note: no meta tag is generated for frameless Channels because they generally
' redirect to the default Posting
'
Sub EmbedRobotsMetaTag()

    Dim pThis
	set pThis = Autosession.This

	if (pThis.IsPosting or ( pThis.IsChannel and pThis.IsFramed ) ) then

		Dim strRobotTag
		strRobotTag = Chr(9) & "<META name=""ROBOTS"" content="""

		if (pThis.IsRobotFollowable) then
			strRobotTag = strRobotTag & "FOLLOW"
		else
			strRobotTag = strRobotTag & "NOFOLLOW"
		end if

		strRobotTag = strRobotTag & ","


		if (pThis.IsRobotIndexable) then
			strRobotTag = strRobotTag & "INDEX"
		else
			strRobotTag = strRobotTag & "NOINDEX"
		end if

		strRobotTag = strRobotTag & """>" & Chr(10)
		Response.Write( strRobotTag )

	end if

End Sub


' ---- [Public] Implementation of the hook function embedded at the bottom
'				of Content Management Server Templates HTML
Sub EmbedTmplBottom()
	If IsAuthoringMode Then
		' check of each of the 3 necessary calls had been embedded into
		' the Template HTML for proper WBC functioning
		If (Not m_bEmbedTmplHeadHookCalled) Or  (Not m_bEmbedBodyBeginHookCalled) Or _
			(Not m_bEmbedBodyEndHookCalled) Then
%>
		<script language="javascript" type="text/javascript">
		<!--
			// this IDS_TMPL_MISSING_TAGS constant cannot be defined in JavaScriptUIStrings.js since
			// WBCEmbedHeadHook() might not have been called and thus that JS file might not have been pulled in.

			var IDS_TMPL_MISSING_TAGS = "The Template HTML is missing the <HEAD>...</HEAD> pair or <BODY>...</BODY> pair of tags.\n" +
									"Please insert them back into the Template HTML. Otherwise, WBC Authoring will not function properly.\n" +
									"See WBC section in the Site Programmers Guide for details.";

			alert(IDS_TMPL_MISSING_TAGS);
		// -->
		</script>
<%
		End If
	End If
End Sub

' ---- [Public] Returns whether TmplHeadHook has been called
Function IsTmplHeadHookCalled()
	IsTmplHeadHookCalled = m_bEmbedTmplHeadHookCalled
End Function

' ---- [Public] Returns whether BodyBeginHook has been called
Function IsBodyBeginHookCalled()
	IsBodyBeginHookCalled = m_bEmbedBodyBeginHookCalled
End Function

' ---- [Public] Returns whether BodyEndHook has been called
Function IsBodyEndHookCalled()
	IsBodyEndHookCalled = m_bEmbedBodyEndHookCalled
End Function

' Set the ROM query string parameters propogation policy at the beginning of site ASP page
Call SetROMPropagationPolicyForWBCMode()
%>