<!--#include virtual="/NR/System/Access/Resolution.inc"-->
<%

'Cover.asp: The default cover page for the Content Management Server system.  Displays
'	the channel name and description.

'---- define some global variables
Dim g_ThisChannel

'==================================================================

'---- Get the Channel object for the Channel Passed in
Set g_ThisChannel = AutoSession.ThisChannel

%>

<html>
<head>
<title>Content Management Server Channel: <%= Server.HTMLEncode(g_ThisChannel.Name) %></title>
<style>
	td {font-family: Verdana; font-weight: bold; font-size: 16pt; color: #000033}
	.desc {font-size: 11pt}
</style>
<% Call EmbedTmplHeadHook() %>
</head>
<body bgcolor=#FFFFFF>
<% Call EmbedBodyBeginHook() %>
<br>



<table border=0>
	<tr>
		<td>&nbsp;</td>
		<td colspan=2><img src="<%=AutoSession.ResolveURL("/NR/Shared/welcome.gif")%>"></td>
	</tr>
	<tr>
		<td width=20>&nbsp;</td>
		<td width=200>&nbsp;</td>
		<td align=left><%=g_ThisChannel.Name%></td>
	</tr>
</table>
<br>
<table width=800 align=center cellspacing=5 cellpadding=5>
	<tr>
		<td width=340 valign=top class=desc>

        <%
		call ShowHierarchy( g_ThisChannel )
        %>		
		</td>
		<td width=260><img src="<%=AutoSession.ResolveURL("/NR/Shared/about.gif")%>"></td>
		<td valign=top>
		<% Call ShowSiteModeSwitch() %>
		<br>
		<% Call EmbedEditSiteConsole() %>
		</td>
	</tr>
</table>
<% Call EmbedBodyEndHook() %>
</body>
</html>

<%

'
' Shows the hierarchy of channels immediately surrounding the current channel
' The parent channel is shown and immediate child channels are shown
' If there is no parent channel (the current channel is the root) only the
' child channels are shown
'
Sub ShowHierarchy( currentChannel )

	Dim parentChannel
	set parentChannel = g_ThisChannel.Parent
	
	Dim indent
	indent = 0
	
	if not parentChannel is Nothing Then

		' if there is a parent channel of the current channel, show the parent 
		' then show the parent's children - highlighting this channel, and drilling
		' down one level in this channel.
	
		call DisplayParentAndChildren( parentChannel, indent )
	
	Else
		' if there is not a parent, show this node and one level down
		
		call DisplayCurrentAndChildren( g_ThisChannel, indent )
	End If

End Sub


'
' Displays a hyperlink to the parent channel passed in and to each child 
' channel. If any of the child channels is the current channel, then the
' immediate set of channels below the current channel is also shown.
'
Sub DisplayParentAndChildren( parentChannel, byval indent )
	
	call DisplayChannelAsLink( parentChannel, indent )
		
	Dim Children
	set Children = parentChannel.Channels
	
	indent = indent + 1
	
	Dim ChannelIter
	for each ChannelIter in Children

		if ChannelIter.GUID = g_ThisChannel.GUID then
			
			call makeNewline()
			call DisplayCurrentAndChildren( ChannelIter, indent )
	
		Else
			call makeNewline()
			call DisplayChannelAsLink( ChannelIter, indent )
		
		End If
	Next

End Sub


'
' Displays the channel passed in as a Name without a hyperlink and then
' displays a link for each of its child channels.
'
Sub DisplayCurrentAndChildren( theChannel, byval indent )

	call DisplayChannelNoLink( theChannel, indent )

	Dim currentChildChannels
	set currentChildChannels = theChannel.Channels
	
	' increase indent for displaying the child channels
	indent = indent + 1
	
	Dim ChannelIter
	for each ChannelIter in currentChildChannels

		call makeNewline()
		call DisplayChannelAsLink( ChannelIter, indent )
	
	Next

End Sub


'
' Displays the channel as a name without a hyperlink
'
Sub DisplayChannelNoLink( theChannel, byval indent )

	call makeIndent( indent )
	Response.Write( theChannel.Name )

End Sub


'
' Displays the channel as a hyperlink
'
Sub DisplayChannelAsLink( theChannel, byval indent )

	call makeIndent( indent )

	Response.Write("<a href='" & theChannel.URL & "'>" & theChannel.Name & "</a>")

End Sub


'
' inserts HTML hard spaces into the response stream
'
Sub makeIndent( byval numTabs )

	Dim i
	For i = 0 to numTabs
		Response.Write("&nbsp;")
		Response.Write("&nbsp;")
	Next

End Sub


'
' Inserts a new HTML line into the response stream
'
sub makeNewline()

	Response.Write("<br>")

End Sub

%>
