%-----------------------------------------------------------------------
% $Id: loadPiHeaderHTM.m,v 1.11 2007/10/10 20:22:39 vnadkar Exp $
% Copyright Trimble 2001
%
% Provides the majority of the HTML output
%
% Stuart Riley
% 12/13/01
%-----------------------------------------------------------------------

function loadPiHeaderHTM(fid, ...
                        L2Present, ...
                        L5Present, ...
                        PlotPNG, ...
                        doACFPlot, ...
                        doFFTPlot, ...
                        SkipCNRTests,...
                        GLONASSInstalled,...
                        L1PPresent, ...
                        GL2_P_present);

FALSE = 0;
TRUE  = 1;

if(PlotPNG == TRUE)
  %
  % Create the links for the elevation/azimuth graphs.
  % 
  fprintf(fid,'<h1>PiLine Analysis Results</h1>\n');
  fprintf(fid,'<p><ul>\n');
  fprintf(fid,'  <li><a href="ALLSVS_RANGE.png">Plot of pseudorange Double Difference residuals for all GPS satellites</A>');
  fprintf(fid,'      <a href="ALLSVS_RANGE_ASCALE.png"> (Autoscaled Version)</A></li>\n');
  fprintf(fid,'  <li><a href="ALLSVS_PHASE.png">Plot of carrier phase Double Difference residuals for all GPS satellites</A>');
  fprintf(fid,'      <a href="ALLSVS_PHASE_ASCALE.png"> (Autoscaled Version)</A></li>\n');
  if(GLONASSInstalled)
    fprintf(fid,'  <li><a href="ALLSVS_RANGE_GLN.png">Plot of pseudorange Double Difference residuals for all GLONASS satellites</A>');
    fprintf(fid,'      <a href="ALLSVS_RANGE_GLN_ASCALE.png"> (Autoscaled Version)</A></li>\n');
    fprintf(fid,'  <li><a href="ALLSVS_PHASE_GLN.png">Plot of carrier phase Double Difference residuals for all GLONASS satellites</A>');
    fprintf(fid,'      <a href="ALLSVS_PHASE_GLN_ASCALE.png"> (Autoscaled Version)</A></li>\n');
  end
  fprintf(fid,'  <li><a href="ElevAzi.png">GPS: Elevation/Azimuth Polar Plot</a></li>\n');
  if(SkipCNRTests == 0)
    fprintf(fid,'  <li><a href="ElevAziCNRL1.png">GPS: Base-Station L1 C/No versus Elevation/Azimuth Polar Plot</a></li>\n');
    
    if(L2Present == TRUE)
      fprintf(fid,'  <li><a href="ElevAziCNRL2.png">GPS: Base-Station L2 C/No versus Elevation/Azimuth Polar Plot</a></li>\n');
    end
    
    if(L5Present == TRUE)
      fprintf(fid,'  <li><a href="ElevAziCNRL5.png">GPS: Base-Station L5 C/No versus Elevation/Azimuth Polar Plot</a></li>\n');
    end
    
    fprintf(fid,'  <li><a href="ElevCNRL1.png">GPS: Base-Station L1 C/No versus Elevation</a></li>\n');
    fprintf(fid,'  <li><a href="RoverElevCNRL1.png">GPS: Rover-Station L1 C/No versus Elevation</a></li>\n');
    fprintf(fid,'  <li><a href="ElevCNRL1Diff.png">GPS: Base minus Rover L1 C/No versus Elevation</a></li>\n');
    fprintf(fid,'  <li><a href="CNRL1Diff.png">GPS: Base minus Rover L1 C/No versus time</a></li>\n');
    
    if(L2Present == TRUE)
      fprintf(fid,'  <li><a href="ElevCNRL2.png">GPS: Base-Station L2 C/No versus Elevation</a></li>\n');
      fprintf(fid,'  <li><a href="RoverElevCNRL2.png">GPS: Rover-Station L2 C/No versus Elevation</a></li>\n');
      fprintf(fid,'  <li><a href="ElevCNRL2Diff.png">GPS: Base minus Rover L2 C/No versus Elevation</a></li>\n');
      fprintf(fid,'  <li><a href="CNRL2Diff.png">GPS: Base minus Rover L2 C/No versus time</a></li>\n');
    end
    
    if(L5Present == TRUE)
      fprintf(fid,'  <li><a href="ElevCNRL5.png">GPS: Base-Station L5 C/No versus Elevation</a></li>\n');
      fprintf(fid,'  <li><a href="RoverElevCNRL5.png">GPS: Rover-Station L5 C/No versus Elevation</a></li>\n');
      fprintf(fid,'  <li><a href="ElevCNRL5Diff.png">GPS: Base minus Rover L5 C/No versus Elevation</a></li>\n');
      fprintf(fid,'  <li><a href="CNRL5Diff.png">GPS: Base minus Rover L5 C/No versus time</a></li>\n');
    end
    fprintf(fid,'  <li><a href="CNRDiff.htm">GPS/GLN Tabulated Base Minus Rover C/No</a></li>\n');
  end

  fprintf(fid,'  <li><a href="Elev.png">GPS: Elevation against time</a></li>\n');
  fprintf(fid,'  <li><a href="Azi.png">GPS: Azimuth against time</a></li>\n');
  fprintf(fid,'  <li><a href="tracking.png">GPS: Satellite Tracking plot</a></li>\n');
  if(GLONASSInstalled)
    fprintf(fid,'  <li><a href="GLNtracking.png">GLN: Satellite Tracking plot</a></li>\n');
  end
    
  if(L2Present == TRUE)
    fprintf(fid,'  <li><a href="DDIono.png">Double Difference Ionospheric plot</a></li>\n');
  end
    
  fprintf(fid,'  <li><a href="DDVersusElev.png">GPS: Double Difference Residuals versus elevation angle</a></li>\n');
  if(SkipCNRTests == 0)
    fprintf(fid,'  <li><a href="DDVersusCNo.png">GPS: Double Difference Residuals versus C/No</a></li>\n');
  end
  fprintf(fid,'  <li><a href="L1PhaseDist.png">GPS: Double Difference L1 Phase distribution</a></li>\n');
    
  if(L2Present == TRUE)
    fprintf(fid,'  <li><a href="L2PhaseDist.png">GPS: Double Difference L2 Phase distribution</a></li>\n');
  end
  
  if(L5Present == TRUE)
    fprintf(fid,'  <li><a href="L5PhaseDist.png">GPS: Double Difference L5 Phase distribution</a></li>\n');
  end

  if(GLONASSInstalled)
    fprintf(fid,'  <li><a href="GLNL1CAPhaseDist.png">GLN: Double Difference L1-C/A Phase distribution</a></li>\n');
     
    if(GL2_P_present == TRUE)
      fprintf(fid,'  <li><a href="GLNL2PhaseDist.png">GLN: Double Difference L2 Phase distribution</a></li>\n');
    end
     
    if(L1PPresent == TRUE)
      fprintf(fid,'  <li><a href="GLNL1PPhaseDist.png">GLN: Double Difference L1-P Phase distribution</a></li>\n');
    end
  end

  fprintf(fid,'  <li><a href="L1RangeDist.png">GPS: Double Difference L1 Range distribution</a></li>\n');
    
  if(L2Present == TRUE)
    fprintf(fid,'  <li><a href="L2RangeDist.png">GPS: Double Difference L2 Range distribution</a></li>\n');
  end
  
  if(L5Present == TRUE)
    fprintf(fid,'  <li><a href="L5RangeDist.png">GPS: Double Difference L5 Range distribution</a></li>\n');
  end
    
  if(GLONASSInstalled)
    fprintf(fid,'  <li><a href="GLNL1CARangeDist.png">GLN: Double Difference L1-C/A Range distribution</a></li>\n');
    
    if(GL2_P_present == TRUE)
      fprintf(fid,'  <li><a href="GLNL2RangeDist.png">GLN: Double Difference L2 Range distribution</a></li>\n');
    end
    
    if(L1PPresent == TRUE)
      fprintf(fid,'  <li><a href="GLNL1PRangeDist.png">GLN: Double Difference L1-P Range distribution</a></li>\n');
    end
  end

  if( (doACFPlot == 1) & (PlotPNG == TRUE) )
    fprintf(fid,'  <li><a href="ALL_ACF.png">Auto-Correlation of the Double Difference Residuals</a></li>\n');
  end
  fprintf(fid,'</ul></p>\n');
end
  
% Define the table
fprintf(fid,'<hr><div align="center"><center>');
fprintf(fid,'<table border="1">');
fprintf(fid,'<tr>\n');
  
% Write out the table header
fprintf(fid,'<th>PRN #</th>\n');
fprintf(fid,'<TH># L1 Epochs</TH>\n');

if(L2Present == TRUE)
  fprintf(fid,'<TH># L2 Epochs</TH>\n');
end

if(L5Present == TRUE)
  fprintf(fid,'<TH># L5 Epochs</TH>\n');
end
  
fprintf(fid,'<th>Pseudorange L1 Mean [cm]</th>\n');
fprintf(fid,'<th>Pseudorange L1 Sigma [cm]</th>\n');
  
if(L2Present == TRUE)
  fprintf(fid,'<th>Pseudorange L2 Mean [cm]</th>\n');
  fprintf(fid,'<th>Pseudorange L2 Sigma [cm]</th>\n');
end

if(L5Present == TRUE)
  fprintf(fid,'<th>Pseudorange L5 Mean [cm]</th>\n');
  fprintf(fid,'<th>Pseudorange L5 Sigma [cm]</th>\n');
end
  
fprintf(fid,'<th>Carrier Phase L1 Mean [mcycle | mm]</th>\n');
fprintf(fid,'<th>Carrier Phase L1 Sigma [mcycle| mm]</th>\n');
  
if(L2Present == TRUE)
  fprintf(fid,'<th>Carrier Phase L2 Mean [mcycle | mm]</th>\n');
  fprintf(fid,'<th>Carrier Phase L2 Sigma [mcycle| mm]</th>\n');
end
  
if(L5Present == TRUE)
  fprintf(fid,'<th>Carrier Phase L5 Mean [mcycle | mm]</th>\n');
  fprintf(fid,'<th>Carrier Phase L5 Sigma [mcycle| mm]</th>\n');
end

% These columns map to the place in load_pi.m where correlation 
% coefficients are computed. See DD = excise_matrix(DD). 
if(L2Present == TRUE)
  fprintf(fid,'<th>L1 / L2 Carrier Phase Correlation Coefficient</th>');
  fprintf(fid,'<th>L1 / L2 Pseudorange Correlation Coefficient</th>');
end

fprintf(fid,'<th>L1 Carrier Phase / Pseudorange Correlation Coefficient</th>');
    
if(L2Present == TRUE)
  fprintf(fid,'<th>L2 Carrier Phase / Pseudorange Correlation Coefficient</th>');
end

if(L5Present == TRUE)
  fprintf(fid,'<th>L1 / L5 Carrier Phase Correlation Coefficient</th>');
  fprintf(fid,'<th>L1 / L5 Pseudorange Correlation Coefficient</th>');
  fprintf(fid,'<th>L5 Carrier Phase / Pseudorange Correlation Coefficient</th>');
end

if( (doFFTPlot == TRUE) & (PlotPNG == TRUE) )
  fprintf(fid,'<th>Frequency Analysis</th>\n');
end
  
if( (doACFPlot == TRUE) & (PlotPNG == TRUE) )
  fprintf(fid,'<th>Pseudorange ACF</th>\n');
  fprintf(fid,'<th>Phase ACF</th>\n');
end
  
fprintf(fid,'</tr>\n');


