function create_thumbnail_page(tripodNumber)
%
%   create_thumbnail_page(tripodNumber)
%
%   Function to look through the THUMBNAILS directory for a given tripod
%   number and create an HTML page with the thumbnails themselves and links
%   to the actual images.

%Soupy Alexander, 12/18/03

%Set up where to look for the images/thumbnails
masterDirectory = 'D:\USGS\TRIPOD_MOVIE\JUST_MOVIES\';
%masterDirectory = 'D:\USGS\TRIPOD_MOVIE\REDO_PUBLISHED\';
thumbnailDirectory = [masterDirectory 'TRIPOD' num2str(tripodNumber, '%3.0f') ...
        '\THUMBNAILS\'];
imageDirectory = [masterDirectory 'TRIPOD' num2str(tripodNumber, '%3.0f') ...
        '\IMAGES'];
webDirectory = [masterDirectory];

%Determine what images exist for the deployment
theFiles = dir(fullfile(imageDirectory, '*.png'));
[fileNames{1:length(theFiles)}] = deal(theFiles.name);
fileNames = sort(fileNames);
%fileNames = fliplr(fileNames);

%Open the HTML page
fileID = fopen(fullfile(webDirectory, ...
    ['t' num2str(tripodNumber, '%3.0f') '_thumb.html']), 'w');

fwrite(fileID, '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">'); fprintf(fileID, '\n');
fwrite(fileID, '<html>'); fprintf(fileID, '\n');
fwrite(fileID, '<head>'); fprintf(fileID, '\n');
fwrite(fileID, ['<title>Thumbnails, Tripod' num2str(tripodNumber, '%3.0f') '</title>']); fprintf(fileID, '\n');
fwrite(fileID, ['<meta name=description content="---Thumbnail images and links to tripod images.">']); fprintf(fileID, '\n');
fwrite(fileID, '<meta name=author content="---Soupy Dalyander">'); fprintf(fileID, '\n');
fwrite(fileID, '<meta name=publisher content="U.S. Geological Survey">'); fprintf(fileID, '\n');
fwrite(fileID, ['<meta name=created content="' date '">']); fprintf(fileID, '\n');
fwrite(fileID, '<meta name=revised content="">'); fprintf(fileID, '\n');
fwrite(fileID, '<meta name=expires content="">'); fprintf(fileID, '\n');
fwrite(fileID, '<meta name=review content="">'); fprintf(fileID, '\n');
fwrite(fileID, '<meta name=geolocation content="">'); fprintf(fileID, '\n\n');
fwrite(fileID, '<STYLE type="text/css"><!--'); fprintf(fileID, '\n\n');
fwrite(fileID, 'BODY {'); fprintf(fileID, '\n');
fwrite(fileID, '      font-family:times,"times new roman",serif;'); fprintf(fileID, '\n');
fwrite(fileID, '      }'); fprintf(fileID, '\n');
fwrite(fileID, '#nav {'); fprintf(fileID, '\n');
fwrite(fileID, '     font-family: "univers condensed",geneva,arial,helvetica,sans-serif;'); fprintf(fileID, '\n');
fwrite(fileID, '     font-weight: bold;'); fprintf(fileID, '\n');
fwrite(fileID, '     font-size: .9em'); fprintf(fileID, '\n');
fwrite(fileID, '     }'); fprintf(fileID, '\n');
fwrite(fileID, '#small      {font-size:.7em}'); fprintf(fileID, '\n');
fwrite(fileID, '#skip  {font-size:1em; color:"#ffffff";}'); fprintf(fileID, '\n');
fwrite(fileID, 'H1, H2, H3, H4, H5, H6 {'); fprintf(fileID, '\n');
fwrite(fileID, '      font-family:"univers condensed",geneva,arial,helvetica,sans-serif;'); fprintf(fileID, '\n');
fwrite(fileID, '      }'); fprintf(fileID, '\n\n');
fwrite(fileID, '--></style>'); fprintf(fileID, '\n');
fwrite(fileID, '<script type="application/javascript" src="http://www.usgs.gov/scripts/analytics/usgs-analytics.js"></script></head>'); fprintf(fileID, '\n\n');
fwrite(fileID, '<body  bgcolor="#99CCFF">'); fprintf(fileID, '\n');
fwrite(fileID, '<table width=650 cellpadding=10 border=0 valign="top" summary="table sets page-width">'); fprintf(fileID, '\n');
fwrite(fileID, '<tr><td>'); fprintf(fileID, '\n\n');
fwrite(fileID, '<a href="#skip_header"><img id=noline src="../OTHER/shim.gif" alt="Skip header" border="0" height="1" width="1"></a><br>'); fprintf(fileID, '\n');
fwrite(fileID, '<a href="http://www.usgs.gov/"><img alt=" Identifier symbol and link to USGS Home page"'); fprintf(fileID, '\n');
fwrite(fileID, 'border=0 src="../OTHER/dark_purple.gif" ></a>'); fprintf(fileID, '\n');
fwrite(fileID, '<br><hr>'); fprintf(fileID, '\n\n');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

fwrite(fileID, ['<h1>Tripod ' num2str(tripodNumber, '%3.0f') '</h1>']); fprintf(fileID, '\n');
fwrite(fileID, '<h2>Thumbnails</h2>'); fprintf(fileID, '\n');
fwrite(fileID, '<hr><br>'); fprintf(fileID, '\n\n');

%Set up the table
fwrite(fileID, '<table cellspacing=2 cellpadding=2 border=1 summary="This table contains the thumbnails and links.">');
fprintf(fileID, '\n');


for indexPic = 1:length(fileNames)
    if rem(indexPic - 1, 6) == 0
        fwrite(fileID, '<tr>'); fprintf(fileID, '\n');
    end
    fwrite(fileID, '<td align="center">');
    fwrite(fileID, ['<a href="../TRIPOD' num2str(tripodNumber, '%3.0f') '/IMAGES/' fileNames{indexPic} '" target="_blank">']);
    fprintf(fileID, '\n');
    fwrite(fileID, ['<img src="../TRIPOD' num2str(tripodNumber, '%3.0f') '/THUMBNAILS/' fileNames{indexPic} '.thmb.jpg">']);
    fwrite(fileID, ['<br>' fileNames{indexPic} '</a></td>']);
    fprintf(fileID, '\n');
    if rem(indexPic, 6) == 0
        fwrite(fileID, '</tr>'); fprintf(fileID, '\n');
    end
end

fwrite(fileID, '</table>'); fprintf(fileID, '\n');


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
fwrite(fileID, '<hr>'); fprintf(fileID, '\n\n');
fwrite(fileID, '<span id="small">'); fprintf(fileID, '\n');
fwrite(fileID, '<!--tail-woodshole.html--><a href="#links"><img src="../OTHER/shim.gif" alt="Skip past USGS  Links" border="0" height="1" width="1"></a>'); fprintf(fileID, '\n');
fwrite(fileID, '<a href="http://www.doi.gov/"><br>Department of Interior</a> &gt; <a'); fprintf(fileID, '\n');
fwrite(fileID, 'href="http://www.usgs.gov/">U.S.'); fprintf(fileID, '\n');
fwrite(fileID, 'Geological Survey</a> &gt; <a href="http://marine.er.usgs.gov">Coastal and Marine Geology</a> &gt;'); fprintf(fileID, '\n');
fwrite(fileID, '<a href="http://woodshole.er.usgs.gov/">Woods Hole Field Center</a></span>'); fprintf(fileID, '\n');
fwrite(fileID, '<br><hr>'); fprintf(fileID, '\n');
fwrite(fileID, '<span id="small">'); fprintf(fileID, '\n');
fwrite(fileID, '<a href="http://www.usgs.gov/privacy.html"  target="_top">USGS Privacy Statement</a> and'); fprintf(fileID, '\n');
fwrite(fileID, '<a href="http://www.usgs.gov/disclaimer.html"  target="_top">Disclaimer</a> and <a href="http://www.usgs.gov/accessibility.html"  target="_top">Accessibility</a><a name="link_group_3"></a><br>'); fprintf(fileID, '\n');
fwrite(fileID, '</span>'); fprintf(fileID, '\n');
fwrite(fileID, '<a name="links"></a>'); fprintf(fileID, '\n');
fwrite(fileID, '<!--end footer-->'); fprintf(fileID, '\n\n');
fprintf(fileID, '\n');
fwrite(fileID, '</table>'); fprintf(fileID, '\n');
fwrite(fileID, '</body>'); fprintf(fileID, '\n');
fwrite(fileID, '</html>'); fprintf(fileID, '\n');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


fclose(fileID);




        
