function titleString = getCOVISPlotTitle(metadata, datefrom, typeString, searchtypeid)
%---------------------------------------------------------------------
% Purpose:  return string for title of scalar plot
% Input:    metadata structure
%           datefrom  (datenum)
%           typeString (Usually 'Diffuse' or 'Imaging')
%           searchtypeid (1 or 5)
% Output:   titleString
% Modify Date/Author:  20120713 B.Biffard
%---------------------------------------------------------------------
if nargin < 4
    searchtypeid = 1;
end

if strcmpi(typeString,'imaging')  
    if searchtypeid==1
        tit1 = [metadata.deviceName ' plume imaging scan started ' datestr(datefrom)];
    elseif searchtypeid==5
        tit1 = [metadata.deviceCategory ' plume imaging scan started ' datestr(datefrom)];    
    else
        error('searchtypeid is not supported')
    end
    tit2 = 'Red, purple and blue backscatter isosurfaces are at 65, 75, and 85 dB';
    
elseif strcmpi(typeString,'diffuse')   
    if searchtypeid==1
        tit1 = [metadata.deviceName ' diffuse flow scan started ' datestr(datefrom)];
    elseif searchtypeid==5
        tit1 = [metadata.deviceCategory ' diffuse flow scan started ' datestr(datefrom)];    
    else
        error('searchtypeid is not supported')
    end
    tit2 = 'Background surface is the bathymetry, contoured by elevation';
else
    error('NEPTUNE:getCOVISPlotTitle','input typeString must be DIFFUSE or IMAGING');
end

siteString = metadata.locationName;
tit3 = ['Site: ',siteString,'  \bullet  ',num2str(metadata.lat),...
    '^{\circ} N \bullet  ',num2str(-metadata.lon),'^{\circ} W  \bullet  ',...
     num2str(metadata.depth),' m ']; 

titleString = strrep({tit1;tit2;tit3},'_','\_');
