#
# Open a data base and keep the user informed.
#
($_directory) = split(/,/, $html_script_args);

#
# Make sure they specified a directory at all.
#
$_directory = $_saint_dir if $_directory eq "";

if ($_directory eq "") {
	print CLIENT <<EOF;
<HTML>
<HEAD>
<TITLE>Error - Missing input </TITLE>
<LINK REV="made" HREF="mailto:saint\@fish.com">
</HEAD>
<BODY BGCOLOR="white">

<P></P>

<P>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
	<TR>
		<TD COLSPAN="2"><IMG SRC="$HTML_ROOT/images/Data_Mgmt_banner.gif" WIDTH="621" HEIGHT="106" ALIGN="BOTTOM" ALT="Data Management" BORDER="0"></TD>
	</TR>
	<TR>
	  <TD WIDTH="86" VALIGN="TOP">
	    <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
		<TR>
		    <TD WIDTH="86"><A HREF="http://www.saintcorporation.com"><IMG SRC="$HTML_ROOT/images/home.gif" WIDTH="86" HEIGHT="55" ALIGN="BOTTOM" ALT="SAINT Corporation"
			BORDER="0"></A></TD>
		</TR>
		<TR>
		    <TD WIDTH="86"><A HREF="$HTML_ROOT/saint.html"><IMG SRC="$HTML_ROOT/images/home_button.gif" WIDTH="86" HEIGHT="46"
			ALIGN="BOTTOM" ALT="SAINT Home" BORDER="0" STYLE="Background-Image : none"></A></TD>
		</TR>
		<TR>
		    <TD WIDTH="86"><A HREF="$HTML_SERVER/data/saint_data_form.pl"><IMG SRC="$HTML_ROOT/images/data_mgmt_button.gif" WIDTH="86"
			HEIGHT="46" ALIGN="BOTTOM" ALT="Data Management" BORDER="0"></A></TD>
		</TR>
		<TR>
		    <TD WIDTH="86"><A HREF="$HTML_SERVER/running/saint_run_form.pl"><IMG SRC="$HTML_ROOT/images/target_selection_button.gif"
			WIDTH="86" HEIGHT="46" ALIGN="BOTTOM" ALT="Target Selection" BORDER="0"></A></TD>
		</TR>
		<TR>
		    <TD WIDTH="86"><A HREF="$HTML_SERVER/reporting/analysis.pl"><IMG SRC="$HTML_ROOT/images/data_analysis_button.gif" WIDTH="86"
			HEIGHT="46" ALIGN="BOTTOM" ALT="Data Analysis" BORDER="0"></A></TD>
		</TR>
		<TR>
		    <TD WIDTH="86"><A HREF="$HTML_SERVER/admin/saint_cf_form.pl"><IMG SRC="$HTML_ROOT/images/config_mgmt_button.gif" WIDTH="86"
			HEIGHT="46" ALIGN="BOTTOM" ALT="Configuration Management" BORDER="0"></A></TD>
		</TR>
		<TR>
		    <TD WIDTH="86"><A HREF="$HTML_ROOT/saint_documentation.html"><IMG SRC="$HTML_ROOT/images/documentation_button.gif"
			WIDTH="86" HEIGHT="46" ALIGN="BOTTOM" ALT="SAINT Documentation" BORDER="0"></A></TD>
		</TR>
		<TR>
		    <TD WIDTH="86" HEIGHT="46"><A HREF="$HTML_ROOT/docs/FAQ.html#trouble"><IMG SRC="$HTML_ROOT/images/troubleshooting_button.gif" WIDTH="86"
			HEIGHT="46" ALIGN="BOTTOM" ALT="Troubleshooting" BORDER="0"></A></TD>
		</TR>
		<TR>
		    <TD WIDTH="86" HEIGHT="65"><IMG SRC="$HTML_ROOT/images/bottom_border.gif" WIDTH="86" HEIGHT="75" ALIGN="BOTTOM" ALT="--------" BORDER="0"></TD>
		</TR>
	    </TABLE>
	  </TD>
	  <TD VALIGN="TOP">
		<DL>
			<P>
		</DL>
<H1> Error - Missing input </H1>
<hr>
No data base name was specified.
	  </TD>
	</TR>
</TABLE>
</BODY>
</HTML>
EOF
	die "\n";
}

#
# Create data base when it does not exist
#
$saint_data = $_directory;
&init_saint_data();

#
# Read the data base, after resetting the in-core data structures.
#
print CLIENT <<EOF;
<HTML>
<HEAD>
<TITLE>SAINT Data Management</TITLE>
<LINK REV="made" HREF="mailto:saint\@fish.com">
</HEAD>
<BODY BGCOLOR="white">

<P></P>

<P>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
	<TR>
		<TD COLSPAN="2"><IMG SRC="$HTML_ROOT/images/Data_Mgmt_banner.gif" WIDTH="621" HEIGHT="106" ALIGN="BOTTOM" ALT="Data Management" BORDER="0"></TD>
	</TR>
	<TR>
	  <TD WIDTH="86" VALIGN="TOP">
	    <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
		<TR>
		    <TD WIDTH="86"><A HREF="http://www.saintcorporation.com"><IMG SRC="$HTML_ROOT/images/home.gif" WIDTH="86" HEIGHT="55" ALIGN="BOTTOM" ALT="SAINT Corporation"
			BORDER="0"></A></TD>
		</TR>
		<TR>
		    <TD WIDTH="86"><A HREF="$HTML_ROOT/saint.html"><IMG SRC="$HTML_ROOT/images/home_button.gif" WIDTH="86" HEIGHT="46"
			ALIGN="BOTTOM" ALT="SAINT Home" BORDER="0" STYLE="Background-Image : none"></A></TD>
		</TR>
		<TR>
		    <TD WIDTH="86"><A HREF="$HTML_SERVER/data/saint_data_form.pl"><IMG SRC="$HTML_ROOT/images/data_mgmt_button.gif" WIDTH="86"
			HEIGHT="46" ALIGN="BOTTOM" ALT="Data Management" BORDER="0"></A></TD>
		</TR>
		<TR>
		    <TD WIDTH="86"><A HREF="$HTML_SERVER/running/saint_run_form.pl"><IMG SRC="$HTML_ROOT/images/target_selection_button.gif"
			WIDTH="86" HEIGHT="46" ALIGN="BOTTOM" ALT="Target Selection" BORDER="0"></A></TD>
		</TR>
		<TR>
		    <TD WIDTH="86"><A HREF="$HTML_SERVER/reporting/analysis.pl"><IMG SRC="$HTML_ROOT/images/data_analysis_button.gif" WIDTH="86"
			HEIGHT="46" ALIGN="BOTTOM" ALT="Data Analysis" BORDER="0"></A></TD>
		</TR>
		<TR>
		    <TD WIDTH="86"><A HREF="$HTML_SERVER/admin/saint_cf_form.pl"><IMG SRC="$HTML_ROOT/images/config_mgmt_button.gif" WIDTH="86"
			HEIGHT="46" ALIGN="BOTTOM" ALT="Configuration Management" BORDER="0"></A></TD>
		</TR>
		<TR>
		    <TD WIDTH="86"><A HREF="$HTML_ROOT/saint_documentation.html"><IMG SRC="$HTML_ROOT/images/documentation_button.gif"
			WIDTH="86" HEIGHT="46" ALIGN="BOTTOM" ALT="SAINT Documentation" BORDER="0"></A></TD>
		</TR>
		<TR>
		    <TD WIDTH="86" HEIGHT="46"><A HREF="$HTML_ROOT/docs/FAQ.html#trouble"><IMG SRC="$HTML_ROOT/images/troubleshooting_button.gif" WIDTH="86"
			HEIGHT="46" ALIGN="BOTTOM" ALT="Troubleshooting" BORDER="0"></A></TD>
		</TR>
		<TR>
		    <TD WIDTH="86" HEIGHT="65"><IMG SRC="$HTML_ROOT/images/bottom_border.gif" WIDTH="86" HEIGHT="75" ALIGN="BOTTOM" ALT="--------" BORDER="0"></TD>
		</TR>
	    </TABLE>
	  </TD>
	  <TD VALIGN="TOP">
		<DL>
			<P>
		</DL>
EOF

if (-s "$facts_file") {
	print CLIENT <<EOF;
<strong>Loading data from <i> $_directory. </i> This may take some time. <p>
EOF
}

&read_saint_data();

print CLIENT <<EOF;
<strong>Data base selection completed successfully.</strong>
<hr> <a href=$HTML_STARTPAGE> Back to the SAINT start page </a>
| <a href=../reporting/analysis.pl>Continue with report and analysis</a>
	  </TD>
	</TR>
</TABLE>
</BODY>
</HTML>
EOF
