function at_stordat_html3
% AT_STORDAT_HTML3 - Creates the main html page used by at_stordat

% Brian Schlining
% 30 Aug 1999

outPath = 'D:\web\extern\bog\';

fid = fopen([outPath 'at_stordat_main.html'],'wt');

fprintf(fid,'<HTML><HEAD>');
fprintf(fid,'   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">');
fprintf(fid,'   <meta name="Author" content="Brian Schlining">');
fprintf(fid,'   <LINK rel="stylesheet" type="text/css" href="styles.css" title="style1">');
fprintf(fid,'<TITLE>Stordat Quality Control Plots</TITLE></HEAD><BODY>');
fprintf(fid,'<!--This is the Navigation bar-->');
fprintf(fid,'<DIV class="leftbarbig"><img  SRC="images/hl_buoy.gif" NOSAVE></DIV>');
fprintf(fid,'<DIV class="rightbar"><img SRC="images/hr.gif" NOSAVE></DIV>');
fprintf(fid,'<DIV class="title">Stordat Quality Control</DIV>');
fprintf(fid,'<DIV class="menu">');
fprintf(fid,'   <A HREF="http://www.mbari.org">');
fprintf(fid,'      <IMG SRC="images/mbarilogo-120_sh.gif" NOSAVE HEIGHT=35 WIDTH=60 BORDER=0 ALIGN=ABSCENTER>');
fprintf(fid,'   </A> >');
fprintf(fid,'   <A HREF="http://www.mbari.org/~brian/default.html">Schlining</A> >');
fprintf(fid,'   <A HREF="mooring.html">Oasis</A> > Stordat');
fprintf(fid,'</DIV>');
fprintf(fid,'<IMG SRC="images/pixel.gif" NOSAVE VSPACE=65 HSPACE=511><BR>');

fprintf(fid,'<!--Content-->');
fprintf(fid,'<TABLE BORDER="0">');
fprintf(fid,'  <TR>');
fprintf(fid,'     <TD ALIGN="left">');
fprintf(fid,'        <IMG SRC="images/pixel.gif" NOSAVE HSPACE=10>');
fprintf(fid,'     </TD>');
fprintf(fid,'     <TD>');
fprintf(fid,'In addition to the equatorial Pacific moorings, ep1 and ep2, MBARI measures');
fprintf(fid,' spectral characteristics using STORDATs at several other sites. The following links are');
fprintf(fid,' plots of the complete time series we have recieved from STORDAT units located at each station');
fprintf(fid,'<BR><BR>');

f = getfname('\\tsunami.shore.mbari.org\oasis\eqpac\stordat\');
for i = 1:length(f)


end


for i = 1:length(s)
   % Process the Position
   lat(i)  = strmatch('Latitude',s(i).fields);
   long(i) = strmatch('Longitude',s(i).fields);
   try
      mlat(i) = round(nanmedian(s(i).data(:,lat(i))));
   catch
      mlat(i) = NaN;
   end

   if mlat(i) >= 0
      elat(i) = 'N';
   elseif mlat(i) < 0
      elat(i) = 'S';
   else
      elat(i) = ' ';
   end

   try
      mlon(i) = round(nanmedian(s(i).data(:,long(i))));
   catch
      mlon(i) = NaN;
   end

end


alat = abs(mlat);
alon = abs(mlon);

ulat = unique(mlat);
ulon = unique(mlon);

% Write out links for known positions
for ilat = 1:length(ulat)
   for ilon = 1:length(ulon)
      good = find(mlat == ulat(ilat) & mlon == ulon(ilon));
      if ~isempty(good)
         fprintf(fid,'<B>%02i%1s %03iW</B><BR>\n',alat(min(good)),elat(min(good)),alon(min(good)));
         for n = 1:length(good)
            [pth nm ext] = fileparts(s(good(n)).filename);
            d = strmatch('Date',s(good(n)).fields,'exact');
            fprintf(fid,'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
            at_stordat_html2(s(good(n)),nm,min(s(good(n)).data(:,d)));
            fprintf(fid,'<A HREF="%s.html">',nm);
            fprintf(fid,'File:%s, Deployed: %s</A><BR>\n', nm, datestr(min(s(good(n)).data(:,d))));
         end
         fprintf(fid,'<BR>');
      end
   end
end

% Write out links for unknown positions
good = find(isnan(mlat) | isnan(mlon));
if ~isempty(good)
   fprintf(fid,'<B>Position Unknown</B><BR>\n');
   for n = 1:length(good)
      [pth nm ext] = fileparts(s(good(n)).filename);
      d = strmatch('Date',s(good(n)).fields,'exact');
      fprintf(fid,'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
      at_stordat_html2(s(good(n)),nm,min(s(good(n)).data(:,d)));
      fprintf(fid,'<A HREF="%s.html">',nm);
      fprintf(fid,'File:%s, Deployed: %s</A><BR>\n', nm, datestr(min(s(good(n)).data(:,d))));
   end
   fprintf(fid,'<BR>');
end



% Group links by Positions, order by date


fprintf(fid,'     </TD>');
fprintf(fid,'  </TR>');
fprintf(fid,'</TABLE>');

fprintf(fid,'<!--Footer for Oasis pages-->');
fprintf(fid,'<DIV class="footer">');
fprintf(fid,'   Copyright 1999, Monterey Bay Aquarium Marine Institute');
fprintf(fid,'</DIV>');

fprintf(fid,'</body>');
fprintf(fid,'</html>');

fclose(fid);