function out = skylineToHTML(in,versions)

% This ingests the results structure from skyline_in_v3 and spits out an
% HTML string that is the results web page.  Various arguments. 
%
% Greg Balco - Berkeley Geochronology Center - April, 2018.
% Development, not licensed for use or distribution. 

if nargin < 2; versions = []; end;

load /var/www/html/math/v3/consts_v3;

dstring = [];

nl = char(10);

twidth = int2str(1000);
snwidth = int2str(100);

% Write header

out = ['<!DOCTYPE html>' nl '<html>' nl '<head>' nl '<title>Online topographic shielding calculator results</title>' nl ...       
    '<style>' nl '<!--table {}' nl '.title2{font-family:Arial;font-size:12.0pt;}' nl ...
    '.title{font-family:Arial;font-size:10.0pt;}' nl '.standard{font-family:Arial;font-size:8.0pt;}' nl ... 
    '-->' nl  '</style>' nl '</head>'];

out = [out nl nl '<body><center>'];

% Start table
out = [out nl '<table width=' twidth '>' nl];

% Horiz line
out = [out nl '<tr><td colspan=2><hr></td></tr>'];

% Title block
out = [out nl  '<tr>' nl '<td colspan=2 class="title2" colspan="2">' nl ...
    '<i><b><p>Online topographic shielding calculator results</p></b></i>' nl '</td>' nl '</tr>'];

% Horiz line
out = [out nl '<tr><td colspan=2><hr></td></tr>'];

% Version block

out = [out nl '<tr>' nl '<td class=standard width=200 valign=top>' ];
out = [out nl 'Version info:' nl '</td>' nl '<td class=standard>'];
fns = fieldnames(versions);
for a = 1:length(fns);
    thisstr = [nl fns{a} ': ' eval(['versions.' fns{a}]) nl '<br>' nl];
    out = [out thisstr];
end;
out = [out nl '</td>' nl '</tr>'];

% Horiz line
out = [out nl '<tr><td colspan=2><hr></td></tr>'];

% Result block

out = [out nl '<tr>' nl '<td class=title width=200 valign=top>' ];
out = [out nl 'Shielding factor:' nl '</td>' nl '<td class=title>'];
out = [out nl sprintf('%0.6f',in.sf)];
out = [out nl '</td>' nl '</tr>'];

% Horiz line
out = [out nl '<tr><td colspan=2><hr></td></tr>'];

% Plot block
% Insert text describing plot...

out = [out nl  '<tr>' nl '<td colspan=2 class="standard" colspan="2">'];
out = [out nl '<center><p>This plot is mainly just to check that you entered the data correctly.</p>'];
out = [out nl '<p><img src="' consts.plotURL in.plotName '.png"></p>'];
out = [out nl '<a href="' consts.plotURL in.plotName '.gmt">GMT</a> <a href="' consts.plotURL in.plotName '.ps">Postscript</a>'];
out = [out nl '<p>The blue line is the far-field horizon; red is the near-field horizon implied by the surface dip; black is the combined horizon.<br>'];
out = [out nl 'If you can''t see any blue or red, it''s under the black line.</p>'];
out = [out nl '</center></td></tr>'];

% Horiz line
out = [out nl '<tr><td colspan=2><hr></td></tr>'];

% end table
out = [out nl '</table>'];


% End HTML
out = [out nl '</center></body>' nl '</html>'];



