function mcs_help(action,cback_fig)
%
%
% COPYRIGHT (c) 2008
% 
% Applied Research Laboratories, The University of Texas at Austin
% (ARL:UT)
% All rights reserved.
% 
% This material may be reproduced by or for the U.S. Government
% only. This notice must appear in all copies of this file and its
% derivatives. Further distribution outside the U.S. Government is
% prohibited without the explicit written authorization from the
% Director of the Environmental Sciences Laboratory, ARL:UT.
% 
% THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
% EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE
% IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
% PURPOSE, OR NONINFRINGEMENT.
% 
% IN NO EVENT WILL ARL:UT BE LIABLE FOR ANY DAMAGES WHATSOEVER ARISING
% OUT OF THE USE OR INABILITY TO USE THIS SOFTWARE, EVEN IF ARL:UT HAS
% BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
mcs_global
%
if nargin<2, cback_fig=gcbf; end
%
if isempty(cback_fig), cback_fig=MBOX.figno; end
hval=findobj(cback_fig,'Tag',action);
hlab=findobj(cback_fig,'Tag',[action,'lab']);
val=get(hval,'Value');
str=get(hval,'String');
%
iispec=0; iitrack=0;
disp(' ');
disp(['HELP for box labeled "',action,'": ']);
disp(' ');
switch action
%MBOX.progs={'LGRAM';'SGRAM';'Matched X-Spectra';'Measured TL/AN';'MC'; ...
%	'CTS-to-FFT';'Make FFTs';'CGRAM';'FFT-to-CTS';'RGRAM CTS'; ...
%	'Make Replicas';'RGRAM FFT';'Combine CTS Files'};
case 'Program',
	h1=findobj(cback_fig,'Tag','Program'); iip=get(h1,'Value');
    iiprog=MBOX.prog_order(iip);
	prog=MBOX.progs{MBOX.prog_order(iip)};
%	disp(['Select program you want to run from this pop-up menu. ']); disp(' ');
	disp(['Current program is "',prog,'"']); disp(' ');
	switch iiprog
    case 1,
        disp('   This program is for creating lofargrams from FFT files.  Output is in structure LGRAM,');
        disp('which may be viewed using "view5(LGRAM)".  Execute "help lgram_3d" for details.');
    case 2,
        disp('   This program is for creating seismograms from FFT files.  Output is in structure SGRAM,');
        disp('which may be viewed using "view5(SGRAM)".  Execute "help sgram_3d" for details.');
    case 3,
        disp('   This program is under construction.');
    case 4,
        disp('   This program is for producing estimates of TL and AN from measured data ');
        disp('in FFT files.  Outputs are in structures TLm and ANm, respectively,');
        disp('which may be viewed using "view5(TLm)".  Execute "help tlm_calc" for details.');
    case 5,
        disp('   This program is under construction.');
    case 6,
        disp('   This program makes an FFT file from a complex time series CTS file. ');
        disp('Execute "help cts2fft" for details.');
    case 7,
        disp('   This program makes an FFT file from various types of data files. ');
        disp('Execute "help fft_make" for details.');
    case 8,
        disp('   This program is for creating correlograms from FFT files.  Output is in structure CGRAM,');
        disp('which may be viewed using "view5(CGRAM)".  Execute "help cgram_3d" for details.');
    case 9,
        disp('   This program makes a complex time series CTS file from an FFT file. ');
        disp('Execute "help fft2cts" for details.');
    case 10,
        disp('   This program is for creating replica-correlated seismograms from FFT files.  The replica ');
        disp('is read from a CTS file.  Output is in structure RGRAM, which may be viewed using ');
        disp('"view5(RGRAM)".  Execute "help rgram2_3d" for details.');
    case 11,
        disp('   This program is for making FFT files of replicas from a CTS file.  It is not in use now.');
    case 12,
        disp('   This program is for creating replica-correlated seismograms from FFT files.  The replica ');
        disp('is read from an FFT file.  Output is in structure RGRAM, which may be viewed using ');
        disp('"view5(RGRAM)".  Execute "help rgram_3d" for details.');
    case 13,
		disp('   This program is for combining CTS files while optionally applying new levels to ');
        disp('each of the combined files.  Set "CTS New Levels n" to -999 to keep old level for file n.');
        disp('Execute "help cts_combine" for more information.');
    case 14,
        disp('   This program is for viewing HDF files.  See ''help view5'' for more information.')
        disp('Use option ''Copy Data to Mdat.xx'' to place imaged data in workspace.');
    end
case 're-init',
	disp('Re-initialize lists of available files. ');
	disp('Do this after changing directories or creating new files.')
case 'FFT root',
	disp('FFT files are outputs of adfftx, for example, and have suffix _fft.');
case 'Freqs to BF',
	disp('Enter frequency interval to beamform as [fmin,fmax] or [f1;f2; ...fn].');
	iispec=1;
case 'HDF File',
    MCS.hdf_files=gui_pop_update(cback_fig,'*.hdf',4,'HDF File',MCS.hdf_root,MCS.dir);
    disp(['Updated HDF File List']);
case 'FFT Files',
    sufs={'*_fft','*_fft.lnk'}; lsufs=[4,8];
    MCS.fft_files=gui_pop_update(cback_fig,sufs,lsufs,'FFT Files',MCS.fft_root,MCS.dir);
    disp(['Updated FFT File List']);
case 'Cal Files',
    MCS.TAPE.cal_files=gui_pop_update(cback_fig,'*_CAL.mat',4,'Cal Files',MCS.TAPE.cal_root,MCS.dir);    
    disp(['Updated Cal File List']); disp(' ');
    disp('_CAL.mat files may be generated in the "Measured TL/SL/AN" program from existing ');
    disp('_AN.mat files.  Cal files are used to apply phone-dependent calibrations in addition ');
    disp('to the calibrations programmed into the xxxx_open.m array-specific M-files.');
    disp('The numbers stored in the _CAL.mat file are AN.  The median over phone is taken ');
    disp('as 0 dB, and deviations from the median are applied when making the FFTs for each phone. ');
case 'SRC CTS File',
% Update list of CTS files in MCS.wf_dir:
    MCS.src_files=gui_pop_update(cback_fig,'*.cts',4,'SRC CTS File',MCS.src_root,MCS.wf_dir);
    disp(['Updated SRC CTS Files in Waveform directory ',MCS.wf_dir]);
    disp('Use ''Set WF Dir'' to change directory.')
case 'Input Directory'
    disp('Enter or use Find to browse to an input directory.')
    disp('Output files are written to the current working directory.')
case 'Day,Hour'
    disp('Informational.  Shows begin and end time of chosen input files.')
    disp('For tapes, end time is set to begin time.')
case 'Data Files'
    disp('Input time series files.')
    disp('SWAMI data type uses ''.dat'' suffix.  All others use ''.bin''.')
case 'Last Data File'
    disp('fft_make will process smoothly across file boundaries.')
    disp('Data are assumed to be continuous.')
case 'Output File Root'
    disp('Prefix to describe this job.  Not required for all programs.')
    disp('Click ''Save MCS'' to store run paramters in [out_root ''_mcs.mat''].')
    disp('Restore previous run with ''Load _mcs root''.')
case 'Julian Day'
    disp('Day of year to begin processing')
case 'Type of Data'
    disp('Choose known input time series format or ''User Defined''.')
    disp('User Defined will process any data format with this basic structure:')
    disp('  File Header')
    disp('      Record Header')
    disp('       Multiplexed Data Block')
    disp('        Record Footer')
    disp('      Record Header')
    disp('       Multiplexed Data Block')
    disp('        Record Footer')
    disp('      ...')
    disp('  File Footer')
    disp('Headers and footers may have zero length.')
    disp('Headers and footers are not read, just skipped over.')
    disp('Time is reckoned by counting samples, starting from a user supplied file start time.')
case 'Time Specification'
    disp('Choose method of specifying time interval(s) to process.')
case 'SWAMI calfac'
    disp('19400 = HCE99, SWAMI 52');
    disp('121 = GCT 2001, SWAMI 32');
    disp('1995 = HCE02, SWAMI 52');
    disp('3990 = CT03, SWAMI 52 (-6 dB gain)');
case 'Phone Numbers'
    disp('Format examples:')
    disp('  2 3 5')
    disp('  [7:22]''    (Note transpose '')')
case 'Frequencies'
    disp('Desired Frequency Range.')
    disp('Program fft_make will create an FFT file for each frequency pair (range).')
    disp('  Enter frequency pairs separated by semicolons or carriage returns (separate lines).')
    disp('  For example:  10,150;250,300;308 310')
case 'T_fft,T_step'
    disp('FFT length in seconds, Time step between FFT starts in percent or in seconds.')
    disp('T_fft < 0:  FFT length in seconds;  fft_make will chose a power of 2 length >= abs(T_fft).')
    disp('T_fft > 0;  Similar, but fft_make will use exactly T_fft seconds of data,')
    disp('  then zero pad to a power of two length.')
    disp('T_step < 0:  Time step in percent of FFT length.  Percent overlap = 100 - abs(T_step).')
    disp('T_step > 0;  Time step in seconds.')
case 'zpfac,ii_hann'
    disp('zpfac = Zero padding factor: increase FFT length by factor of 2^zpfac.')
    disp('ii_hann = 1 to shade with a Hann window in time domain.')
case 'Spike Threshold (dB)'
    disp('Zero noise spikes in input time series')
case 'Init Jday,Jhour'
    disp('Start time of input data for User Defined data type.')
    disp('  Day of Year, Decimal Hour of Day')
case 'fs, calfac'
    disp('Sample rate (Hz), Calibration Factor (micropascals/count)')
case 'File Header,Footer Bytes'
    disp('Size in bytes of single file header, file footer.')
    disp('  May be zero.')
    disp('See help for ''Type of Data''.')
case 'Record Header,Footer Bytes'
    disp('Size in bytes of each record header, record footer.')
    disp('  May be zero.')
    disp('See help for ''Type of Data''.')
case 'Data Word Format'
    disp('Matlab data type that describes the data word of input time series.')
case 'Number of Channels'
    disp('Number of channels in multiplexed data block')
    disp('See help for ''Type of Data''.')
case 'Samples per Channel'
    disp('Number of samples per channel in multiplexed data block')
    disp('See help for ''Type of Data''.')
    disp('HLAB GCT, HCE02 = 500')
case 'Byte Swap'
    disp('Byte swap input time series')
case 'HLAB Endian'
    disp('HLAB GCT Tapes are Little Endian')
    disp('HLAB GCT DataDisk files are Big Endian')
    disp('HLAB HCE02 Tapes and DataDisk files are Big Endian')
case 'HLA-B fs'
    disp('HLAB sample rate.')
    disp('  HCE99 = 1200 ?')
    disp('  GCT 2001, HCE02 = 2000')
case 'nrec,nseq,%step'
    disp('Information about FFT file.')
    disp('  Number of Receivers, Number of Sequences, Percent Step (Overlap = 100 - %step)')
case 'FFT f1,f2,iihann'
    disp('Information about FFT file.')
    disp('  First, Last Frequency, iihann=1 mean a Hann window was applied.')
case 'FFT df,Tw,Tstep'
    disp('Information about FFT file.')
    disp('  Frequency Bin Width (Hz), FFT Length (sec.), Time Step Between FFTs (sec.)')
case 'Plot Size [w,h]'
    disp('Plot size.  Can be changed after image is displayed.')
    disp('  Image is displayed using view5.m.  Use ''s'' option to change plot size.')
    disp('  Also, see '' '' (space) option in view5.m for more help manipulating images.')
    disp('      Place crosshairs over image and press space, ''s'', etc. to control view5.m')
case 'Cmin,Cmax'
    disp('Color scale limits.  Depricated feature.  Set after image is displayed.')
    disp('  Image is displayed using view5.m.  Use ''c'' option to change color scale.')
    disp('  Also, see '' '' (space) option in view5.m for more help manipulating images.')
    disp('      Place crosshairs over image and press space, ''c'', etc. to control view5.m')
case '[taumin,taumax]'
    disp('Correlation time limits (sec.)')
case 'Enveloping'
    disp('How to display complex result.')
case 'Zero Pad by 2^N'
    disp('Zero padding factor: increase inverse FFT length by factor of 2^zpfac.')
case '# Seq to Avg (def=1)'
    disp('Number of output sequences to average')
case 'PRI'
    disp('Length in seconds of replica waveform')
case 'XC Pairs [nx2]'
    disp('Phone pairs to correlate')
    disp('  Multiple pairs may be specified, separated by semicolons or carriage returns (separate lines).')
    disp('  For example:  1 2;2 4;6,7;8,9')
case 'Delay Time Limits'
    disp('Correlation delay limits in seconds.')
case 'XCmin,XCmax'
    disp('Color scale limits.  Depricated feature.  Set after image is displayed.')
    disp('  Image is displayed using view5.m.  Use ''c'' option to change color scale.')
    disp('  Also, see '' '' (space) option in view5.m for more help manipulating images.')
    disp('      Place crosshairs over image and press space, ''c'', etc. to control view5.m')
case 'TL Frequency Band(s)'
    disp('Transmission Loss Desired Frequency Range.')
    disp('  Enter frequency pairs separated by semicolons or carriage returns (separate lines).')
    disp('  For example:  10,150;250,300;308 310')
case 'AN Frequency Band(s)'
    disp('Ambient Noise Desired Frequency Range.')
    disp('  Enter frequency pairs separated by semicolons or carriage returns (separate lines).')
    disp('  For example:  10,150;250,300;308 310')
case 'CTS Files'
    disp('Updated list of .cts (complex time series) format files')
case 'HDF Set Names'
    disp('Choose HDF Set to display.')
case 'HDF Set Rank'
    disp('Informational.  Number of dimentions in HDF Set.')
case 'Set Dim Names'
    disp('Informational.  Dimension names in HDF Set.')
case 'Dims [min,max]'
    disp('Informational.  Dimension limits.')
case 'Dim Limits'
    disp('Choose limits on each dimension.  Default is all.  Image can be manipulated after it is displayed.')
    disp('  Image is displayed using view5.m')
    disp('  After image is display, place crosshairs over image and enter '' '' (space) for view5.m help')
otherwise,
	disp(['UNKNOWN ACTION in mcs_help: ',action]); 
%
end
if iispec,
	disp('NOTE: Values of frequencies, etc. may be specified in the following ways:')
	disp('      [f1;f2; ...fn] (col vector); [fmin,fmax,nf] (row vector); OR [fmin,fmax,-df] (row vector).')
end
%
disp(' ');
disp(['END OF HELP for box labeled "',action,'": ']);
disp(' ');
%
