%-----------------------------------------------------------------------
% $Id: generateTitleHTML.m,v 1.2 2008/03/26 19:01:38 vnadkar Exp $
% Copyright Trimble 2008
%
% Provides the HTML output for posAnalyze. 
%-----------------------------------------------------------------------

function generateTitleHTML( fid, parameters, statistics, verticalView )

if verticalView
  viewString = 'Vertical';
  otherViewString = 'Standard';
  otherFileName = 'positionAnalysis.html';
else
  viewString = 'Standard';
  otherViewString = 'Vertical';
  otherFileName = 'positionAnalysisVertical.html';
end

generateHeaderHTML( fid ); 


fprintf(fid,'<title>AnalyzePos Results %s View</title>\n', viewString ...
        );
fprintf(fid,'<h1 align="center">AnalyzePos Results %s View</h1>\n', ...
        viewString );
fprintf(fid,'<p align="center"> %s </p>\n', parameters.fileName );
fprintf(fid,'<p align="center"> Processed on %s with %s %s Build</p>\n', ...
  date, parameters.versionTag, parameters.releaseTag );

fprintf(fid,'<table align="center" width=50%%>\n');
fprintf(fid,'<tr>\n');

fprintf(fid, ...
        ['<td align="center"><b>Reference Position</b><br/>\n' ...
         'Latitude=%.8f&#176 <br/> Longitude=%.8f&#176 ' ...
         '<br/> Height=%.3fm</td>\n'], ...
        parameters.refLLA(1), parameters.refLLA(2), parameters.refLLA(3) );

fprintf(fid, ...
        ['<td align="center"><b>Logging Time</b> <br/>\n' ...
         'Start: Week %d Time %06.3f <br/> ' ...
         'End: Week %d Time %06.3f <br/> Epochs: %d </td>'], ...
        statistics.startWeekNum, statistics.startTime, ...
        statistics.endWeekNum, statistics.endTime, ...
        statistics.epochs );
fprintf(fid,'</tr></table>\n');

fprintf(fid,'<p align="center">Click on any image to view a zoomed version of the image.\n');
fprintf(fid,'For best results view fullscreen. </p>\n');

fprintf(fid, ...
        [ '<p align="center"><a href=' ...
          '"%s">Click here to ' ...
          'switch to %s View</a></p>\n' ...
        ], ...
        otherFileName, ...
        otherViewString ...
        );

end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Print XHTML Header
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function generateHeaderHTML( fid )

% Print XHTML header - thanks Andrew Ansell
fprintf(fid, ...
        [ '<?xml version="1.1" encoding="iso-8859-1"?> \n' ...
          '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" \n' ...
          '"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> \n' ...
          '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">\n' ...
          '<head>\n' ...
          '<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=ISO-8859-1" />\n' ...
          '</head>\n' ...
        ]);

fprintf(fid,'<body>\n');

end