<%
var
	sProjectTitle, sDefaultTopicId: string;
	
begin
	// Need BOM for UTF8 files
	HndGeneratorInfo.BOMOutput := True;
	
	HndGeneratorInfo.CurrentFile := ExtractFileName(HndGeneratorInfo.OutputFile);
	sProjectTitle := HndProjects.GetProjectTitle();
	
	// Try to get the default topic
	sDefaultTopicId := HndProjectsMeta.GetItemMetaStringValue('DefaultTopic', '');
	// None defined: the first one is the default topic
	if (sDefaultTopicId = '') then
		sDefaultTopicId := HndTopics.GetTopicNextVisible(HndTopics.GetProjectTopic());
	if (sDefaultTopicId <> '') then
		sDefaultTopicId := HndTopics.GetTopicHelpId(sDefaultTopicId);
%>
	
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>

<head>

	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="generator" content="<% print(HTMLEncode(HndGeneratorInfo.HelpNDocVersion)); %>">
    <title><% print(HTMLEncode(sProjectTitle)); %></title>
    <script type="text/javascript">
      function escapeHtml(unsafe) {
        return unsafe.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;").replace(/:/g, "");
      }
      var sTopic = "";
      if (top.location.href.lastIndexOf("?") > 0)
        sTopic = top.location.href.substring(top.location.href.lastIndexOf("?") + 1, top.location.href.length);
      if (sTopic == "") sTopic = "<% print(sDefaultTopicId); %>.html";
	  sTopic = escapeHtml(sTopic);
      document.write('<frameset cols="<% print(HndGeneratorInfo.GetCustomSettingValue('TocWidth')); %>,*">');
      document.write('<frame src="toc.html" name="FrameTOC">');
      document.write('<frame src="' + sTopic + '" name="FrameMain">');
      document.write('</frameset>');
    </script>

</head>

<noscript>
	<frameset cols="<% print(HndGeneratorInfo.GetCustomSettingValue('TocWidth')); %>,*">
		<frame src="toc.html" name="FrameTOC">
		<frame src="<% print(sDefaultTopicId); %>.html" name="FrameMain">
	</frameset>
</noscript>

</html>

<%
end.
%>