'#Reference {A3B5C45B-F842-44fc-A5E5-50CED69BA86E}#2.0#0#C:\Program Files\Mindjet\MindManager 6\Mm5WebExport.dll#Mm5webexport 2.0 Type Library
'#Uses "GlobalParameterNames.mmbas"
'#Uses "ParameterNames.mmbas"
'#Uses "GlobalUtilities.mmbas"

Option Explicit

Sub Main

    Dim addin As Mm5WebExportAddIn
    Dim webex As WebExport

    Set addin = WebExportHelper.WebExportAddIn
    Set webex = addin.ActiveWebExport

    Dim bodyString As String
    Dim topicString As String
    Dim OutlineItems As String
    Dim styleSheetPath As String

    On Error GoTo ReportError

    webex.Trace("Entering EndExport " + CStr(webex.GetParameter(WeErrorNumber)), 2)

	' Generate LEGEND page if required
	If webex.GetParameter("Strings.Show.IconLegend") Then
		bodyString = webex.ReadFile("ToolsLg.htm")
		topicString = bodyString
		' Process all commands and parameters
		ProcessString webex, topicString
		bodyString = topicString
		' Write out the result
		webex.WriteFile ("legend.htm", bodyString)
	End If

    ' Generate Overview Map page
    If webex.GetParameter("Strings.Show.OverviewMap") Then
		bodyString = webex.ReadFile("ToolsMap.htm")
		topicString = bodyString

		' Process all commands and parameters
		ProcessString webex, topicString
		bodyString = topicString

		' Write out the result
		webex.WriteFile ("map.htm", bodyString)

		bodyString = webex.ReadFile("ToolsMapCont.htm")
		topicString = bodyString

		' Process all commands and parameters
		ProcessString webex, topicString
		bodyString = topicString

		' Write out the result
		webex.WriteFile ("mapContent.htm", bodyString)

		bodyString = webex.ReadFile("OneToolsMapHd.htm")
		topicString = bodyString

		' Process all commands and parameters
		ProcessString webex, topicString
		bodyString = topicString

		' Write out the result
		webex.WriteFile ("mapHeader.htm", bodyString)

		bodyString = webex.ReadFile("ToolsMapFooter.htm")
		topicString = bodyString

		' Process all commands and parameters
		ProcessString webex, topicString
		bodyString = topicString

		' Write out the result
		webex.WriteFile ("mapFooter.htm", bodyString)
	End If

	' Determine whether partial map images should be shown or hidden in the export
	'If webex.GetParameter("Strings.Show.PartialMaps") = True Then
    If webex.GetParameter("Strings.Show.SubLinks") = "partmaps" Or webex.GetParameter("Strings.Show.SubLinks") = "partmapssingle" Then
        webex.SetParameter("CustomParameter.ShowPartialMapsImage","visible")
	Else
        webex.SetParameter("CustomParameter.ShowPartialMapsImage","none")
	End If

    ' If there's no pending error
    If webex.IsSuccessful Then

       ' Copy our Resources folder
       webex.CopyDirectory(webex.GetParameter(TdFolderResources))
       
       ' Process any parameters in our shared CSS files
       ProcessResourceFile webex, "styles\shared.css"

       ' Process any parameters in boxController.js (so it gets the proper "Resources" folder name)
       ProcessResourceFile webex, "code\boxController.js"

       ' Copy our linked documents to the Linked Documents folder
       webex.CopyLinkedDocuments()

    End If

    webex.Trace("Exiting EndExport " + CStr(webex.GetParameter(WeErrorNumber)), 2)

    Exit Sub
   
ReportError:
    ProcessError(webex)
    Exit Sub
   
End Sub
