<% option explicit
Dim AESession
Dim arrDomains
Dim DomainCount


Set AESession = Server.CreateObject("AeSession.AeSession.1")
 %>

Option Explicit

<!--#include virtual="/NR/Shared/ASPUtils.inc"-->

Const GLOBALPARAM_ADMINWINDOW = "AdminToolWindow:<%Response.Write(Request.ServerVariables.Item("HTTP_HOST"))%>"

Const TITLBAR_IMAGES_PATH = "Titlebar/"

sub window_onLoad

	'	bring the admin tool to the top if it exists
	if GlobalParameters.Exists(GLOBALPARAM_ADMINWINDOW) then
		on error resume next
		call GlobalParameters(GLOBALPARAM_ADMINWINDOW).BringToTop
		err.Clear
		call FireClose
		exit sub
	end if

	' 	bring the login window to the top if it exists
	if GlobalParameters.Exists("LoginWindow") then
		if GlobalParameters.Exists("LoginWindowHandle") then
			call GlobalParameters("LoginWindowHandle").BringToTop
		end if
		call FireClose
		exit sub
	end if

	' only fire up login window once
	GlobalParameters("LoginWindow") = true
	' save the handle so we can pop up the window later
	set GlobalParameters("LoginWindowHandle") = window

	FrameOcxCLSID = "AdmnTool.RELogin"

	Toolbars.Visible = false
	WindowIcon = TITLBAR_IMAGES_PATH + "Resolution.ico"
	WindowTitle = "Site Manager - Microsoft Content Management Server"

	WindowOptions("MINIMIZEBOX") = True
	WindowOptions("MAXIMIZEBOX") = False
	WindowOptions("SYSMENU") = True
	WindowOptions("POPUP") = True
	WindowOptions("BORDER") = True
	WindowOptions("THICKFRAME") = False
	WindowOptions("DLGFRAME") = True
	WindowOptions("POPUP") = True
	WindowOptions("OVERLAPPED") = True
	WindowOptions("HEIGHT_TWIPS") = 3585
	WindowOptions("WIDTH_TWIPS") = 5960
	StatusBar.Visible = False

	Parameters("IsWindows2000Server") = <%
			dim strServerVersion
			strServerVersion = Request.ServerVariables("SERVER_SOFTWARE")

			if GetMajorVersion(mid(strServerVersion, instr(strServerVersion, "/")+1)) >= 5 then
				Response.write "true"
			else
				Response.write "false"
			end if

%>

	Parameters("ServerUrl") = ResolveRelativeURL("/NR/System/Marshalling/")
	Parameters("AdminUrl") = ResolveRelativeURL("aecm.asp")

end sub

sub window_OnActivate
	call Frame.Init( (window) )
<%
	on error resume next
	' Add all the current domains to the dialog
	Dim strName, i
	Dim strWINNT

	' Use the Aesssion to get the list of domains selected in Install and Maintence Wizard, fixed bug 2221, 2206
	arrDomains =  AESession.GetConfiguredDirectories(False)
	if err.Number <> 0 then
%>	call msgbox("The list of domains is not available due to the following error: " & vbCrlf & vbCrlf & "<%=err.Description%>",  0, "Microsoft Content Management Server")
<%
		err.Clear
	else
	For i = 0 to UBound(arrDomains)
	%>		call Frame.AddDomain("<%= arrDomains(i) %>")
	<%
		next
	end if

%>
end sub

sub window_OnUnload
	call Frame.Uninit()
	call GlobalParameters.Remove("LoginWindowHandle")
end sub