function contourmaster(fctn, varargin)
%%% contour switchyard function
global XYDATA
global UVDATA
global CONTFIG

switch(fctn)
   case 'setup'                  % from plotmaster - orig. call
      close(gcf);
      CONTFIG.webflag = 0;
      figcontoursetup;
   case 'configsetup'        % from plotmaster via gplotconfig
      close(gcf);
      CONTFIG.webflag = 0;
      configsetup(varargin);
   case 'websetup'            % from mksecplt2 - via webmaster
      CONTFIG.webflag = 1;
      webfigsetup;
   case 'radio'                  % from gplotcontour - radio buttons
      strarg = char(varargin(1));
      radioreset(strarg);
   case 'readfigcontour'	       % from gplotcontour - btnOK
      readfigcontour;      
   case 'xytsection'             % from gplotcontour - btnXYTzoom
      xytsection;
   case 'llrange'                % from gplotcontour - chkllrange
      fixtitle;
   case 'calendar'             % from gplotcontour - chkcalendar
      fixtitle;
   case 'decimal'               % from gplotcontour- chkdecimal
      fixtitle;
   case 'savenow'             % from gplotcontour - btnSave
      cnffs = findobj(gcf,'tag','txtboxsavepath');
      pname = get(cnffs,'string');
      CONTFIG.savepath = pname;
      cnffs = findobj(gcf,'tag','txtboxsavefn');
      fname = get(cnffs,'string');
      if isempty(findstr(fname, 'cfg'))
         msg = sprintf('\nOnly files with "cfg" in name \ncan be recoved. ');
         noticeOK(msg)
         return
      end
      CONTFIG.savefn = fname;
      fn = fullfile(pname, fname);
      save6(fn, 'CONTFIG');
      contourmaster('renewloadfn')
      notice(' Finished ');
   case 'renewloadfn'     % from gplotcontour - editbox for load path
      curdir =  pwd;         % new path -> new set of potential cfg files
      rn = findobj(gcf,'tag','txtboxloadpath');
      lp = get(rn,'string');
      if exist(lp, 'dir')
         CONTFIG.loadpath = lp;
      else
         noticeOK('Error in load path. ')
         return
      end
      cd(CONTFIG.loadpath)
      files = what;
      str_b = files.mat;
      for i = length(str_b):-1:1
         chary = char(str_b(i));
         if isempty(findstr(chary, 'cfg'))
            str_b(i) = [];
         end
      end
      CONTFIG.loadfn = str_b;
      if isempty(str_b); CONTFIG.loadfn = {'None'}; end;
      cd(curdir)
      pop = findobj(gcf,'tag','popuploadfn');
      set(pop,'value',length(CONTFIG.loadfn))
      set(pop,'string',CONTFIG.loadfn)
   case 'loadnow'              % from gplotcontour - btnLoad
      loadnow(0);    % 0=normal load, i.e layout only, data present
   case 'printfile'              % from gplotcontour - toggle chkbox for print
      ckp = findobj(gcf,'tag','chkboxprint');
      if get(ckp,'value')  % may be disabling instead of activating
         pfn = findobj(gcf,'tag','txtboxprintfn');
         CONTFIG.printfilefn = get(pfn,'string');
         if isempty(CONTFIG.printfilefn)
            noticeOK('File name undefined')
            return
         end
      end
   case 'cancel'     % from gplotcontour - btnCancel
      close
      if CONTFIG.webflag == 0, gplot; end
   case 'help'
      noticeOK('Help is on the way...')         
   end

%%%%%%%%%%%

function radioreset(n)

global CONTFIG
hlat = findobj(gcbf,'tag','radiolatitude');
hlon = findobj(gcbf,'tag','radiolongitude');
htim = findobj(gcbf,'tag','radiotime');

switch(n)
   case '1'
      set(hlat,'value',0);
      set(htim,'value',0);
      CONTFIG.reftype = 1;
   case '2'
      set(hlon,'value',0);
      set(htim,'value',0);
      CONTFIG.reftype = 2;
   case '3'
      set(hlat,'value',0);
      set(hlon,'value',0);
      CONTFIG.reftype = 3;
end

%%%%%%%%%%%%

function figcontoursetup

global UVDATA
global XYDATA
global CONTFIG

loaderrorflag = 0;
uvdatapath = [CONTFIG.xydatapath(1:end-6), 'uv.mat'];
eval('UVDATA = load(uvdatapath);', 'loaderrorflag = 1;');
eval('XYDATA = load(CONTFIG.xydatapath);', 'loaderrorflag = 1;');

if loaderrorflag
   msg = sprintf('\nError trying to load:\n%s  --\nPlease start over.\nSelect *.mat type for both xyt & uv data.  ', CONTFIG.xydatapath);
   noticeOK(msg)
   uiwait
   loaderrorflag = 0;
   if CONTFIG.webflag == 0, gplot; end
   return
end
preparedata

if isfield(XYDATA,'year_base')
   CONTFIG.year_base = XYDATA.year_base;
else
   CONTFIG.year_base = '???';
end
CONTFIG.dbname = XYDATA.dbname;

gplotcontour;  % display main contour dialog window

% check or reset a few of the items
df = findobj(gcf,'tag','textdata');
set(df,'string', 'uv.mat, _xy.mat');
yb = findobj(gcf,'tag','txtboxyear');
set(yb,'string',num2str(CONTFIG.year_base));
ophh = findobj(gcf,'tag','txtboxoutpath');
set(ophh,'string',CONTFIG.outpath);
hlat = findobj(gcbf,'tag','radiolatitude');
set(hlat,'value',1);
CONTFIG.reftype = 2;
pp = CONTFIG.xydatapath;
marks = findstr(pp,filesep);
CONTFIG.cruiseID = upper(pp(marks(end-2)+1:marks(end-1)-1));
if length(CONTFIG.cruiseID) == 6 & ~isletter(CONTFIG.cruiseID(end)) 
   CONTFIG.title = CONTFIG.cruiseID;
else
   pp = what;
   marks = findstr(pp.path,filesep);
   CONTFIG.cruiseID = upper(pp.path(marks(end)+1:end));
   if length(CONTFIG.cruiseID) == 6 & ~isletter(CONTFIG.cruiseID(end))
      CONTFIG.title = CONTFIG.cruiseID;
   else
      CONTFIG.title = 'contour';
   end
end;
tbt = findobj(gcf,'tag','txtboxtitle');
set(tbt,'string',CONTFIG.title);

determine_ranges;

ii = 1:length(XYDATA.DDAY);
CONTFIG.ii = ii;  
u = UVDATA.U; v = UVDATA.V;
uv=0*[u(:,ii) v(:,ii)];
uv(:,1:2:end)=u(:,ii);
uv(:,2:2:end)=v(:,ii);
maxuv=100*max(max(abs(uv)));
if maxuv > 300
   levstr = '[-500:50:500]';
elseif maxuv > 200
   levstr = '[-300:20:300]';
elseif maxuv > 100
   levstr = '[-200:20:200]';
elseif maxuv > 50
   levstr = '[-100:10:100]';
else
   levstr = '[-50:5:50]';
end

CONTFIG.custlevstr = levstr;      % = condensed (readable) notation
tbl = findobj(gcf,'tag','txtboxlevs');
set(tbl,'string', CONTFIG.custlevstr);
CONTFIG.outline = 1;
out = findobj('tag','chkoutline');
set(out,'value',CONTFIG.outline);
CONTFIG.boldlevs = '0';
tbb = findobj(gcf,'tag','txtboxboldlevs');
set(tbb,'string', CONTFIG.boldlevs);
hdp = findobj(gcf,'tag','txtboxdepths');
%CONTFIG.depthstr = sprintf('[ %d  %d ]', XYDATA.ZC(1), XYDATA.ZC(end));
CONTFIG.depthstr = '[ 0  450 ]';
set(hdp,'string', CONTFIG.depthstr);
CONTFIG.printfilefn = [CONTFIG.title, '.ps'];
pnm = findobj(gcf,'tag','txtboxprintfn');
set(pnm,'string',CONTFIG.printfilefn);
pst = findobj(gcf,'tag','txtboxsavepath');
ptx = findobj(gcf,'tag','txtboxloadpath');
set(pst,'string',CONTFIG.outpath);
set(ptx,'string',CONTFIG.outpath); 
cnffs = findobj(gcf,'tag','txtboxsavefn');
set(cnffs,'string', 'cont_cfg');
cnffl = findobj(gcf,'tag','popuploadfn');
CONTFIG.loadpath = CONTFIG.outpath;
curdir =  pwd;
cd(CONTFIG.loadpath)
files = what;
str_b = files.mat;
for i = length(str_b):-1:1
   chary = char(str_b(i));
   if isempty(findstr(chary, 'cfg'))
      str_b(i) = [];
   end
end
CONTFIG.loadfn = str_b;
if isempty(str_b); CONTFIG.loadfn = {'None'}; end;
cd(curdir)
set(cnffl,'value',length(CONTFIG.loadfn))
set(cnffl,'string',CONTFIG.loadfn);

CONTFIG.blkwht = 0;
CONTFIG.printfile = 0;
fixtitle

%%%%%%%%%%%%%%%

function configsetup(varargin)

global UVDATA
global XYDATA
global CONTFIG   

fname = char(varargin{1});  % cell to str
trouble = 0;
eval('load(fname)', 'trouble = 1')
if trouble == 1
   noticeOK('Problems loading file')
   return
end

if CONTFIG.webflag == 0; [CONTFIG.loadpath, cfn] = fileparts(fname); end; %was just overwritten

curdir =  pwd;
cd(CONTFIG.loadpath)
files = what;
str_b = files.mat;
for i = length(str_b):-1:1
   chary = char(str_b(i));
   if isempty(findstr(chary, 'cfg'))
      str_b(i) = [];
   end
end
CONTFIG.loadfn = str_b;   
if isempty(str_b); CONTFIG.loadfn = {'None'}; end;
cd(curdir)

if CONTFIG.webflag == 0
   uvdatapath = [CONTFIG.xydatapath(1:end-6), 'uv.mat'];
   UVDATA = load(uvdatapath);
   XYDATA = load(CONTFIG.xydatapath);
else
   UVDATA = load('c_sect_uv.mat');
   XYDATA = load('c_sect_xy.mat');
end
preparedata

gplotcontour
loadnow(1)  % 1=continue loading with new data, skip prelims

%%%%%%%%%%%%%%%

function loadnow(skip)
% to re-establishment of previous layout
global CONTFIG
global XYDATA
global UVDATA

if isempty(CONTFIG.ii)
   msg = sprintf('Data set (lat-longs) must be \nselected before loading config.');
   noticeOK(msg);
   return
end

if ~skip   % normal load doesn't skip; skip if initializing with config.
   % save some new data vbls before overwritten
   cID = CONTFIG.cruiseID;
   wbfg = CONTFIG.webflag;
   ttl = CONTFIG.title;
   iinow = CONTFIG.ii;
   latr = CONTFIG.latrange;
   lonr = CONTFIG.lonrange;
   opath = CONTFIG.outpath;
   
   ptx = findobj(gcf,'tag','txtboxloadpath');
   ldpath = get(ptx,'string');
   cnffl = findobj(gcf,'tag','popuploadfn');
   pv = get(cnffl,'value');
   pstr = get(cnffl,'string');
   fname1 = pstr{pv};
   fname = fullfile(ldpath, fname1);
   
   goodload = 1;
   eval('load(fname);', 'goodload = 0;');
   if ~goodload
      noticeOK('Unable to load requested file.  ');
      return
   end
    
   CONTFIG.loadfn = pstr;
   CONTFIG.loadpath = ldpath;
   CONTFIG.cruiseID = cID;
   CONTFIG.webflag = wbfg;
   CONTFIG.title = ttl;
   CONTFIG.ii = iinow;
   CONTFIG.latrange = latr;
   CONTFIG.lonrange = lonr;
   CONTFIG.outpath = opath;
end

% re-establish new layout
cnffs = findobj(gcf,'tag','txtboxsavefn');
fname = CONTFIG.savefn; 
if isempty(findstr(fname, 'cfg')), 
   set(cnffs,'string', 'webcont_cfg');
else
   set(cnffs,'string', CONTFIG.savefn); 
end
ophh = findobj(gcf,'tag','txtboxoutpath');
set(ophh,'string',CONTFIG.outpath);
dstr = findobj(gcf,'tag','txtboxsavepath');
set(dstr,'string',CONTFIG.savepath);
cnffl = findobj(gcf,'tag','popuploadfn');
set(cnffl,'value',length(CONTFIG.loadfn));
set(cnffl,'string',CONTFIG.loadfn);
ptx = findobj(gcf,'tag','txtboxloadpath');
set(ptx,'string',CONTFIG.loadpath);
yb = findobj(gcf,'tag','txtboxyear');   
set(yb,'string',num2str(CONTFIG.year_base));
tbt = findobj(gcf,'tag','txtboxtitle'); 
set(tbt,'string',CONTFIG.title);
df = findobj(gcf,'tag','textdata');
set(df,'string','custom load');
tbl = findobj(gcf,'tag','txtboxlevs');
set(tbl,'string',CONTFIG.custlevstr);
di = findobj(gcf,'tag','chkboxdate');
set(di,'value',CONTFIG.datestamp);
omt = findobj('tag','chktitle');
set(omt,'value',CONTFIG.showtitle);
tbb = findobj(gcf,'tag','txtboxboldlevs');
set(tbb,'string', CONTFIG.boldlevs);
out = findobj('tag','chkoutline');
set(out,'value',CONTFIG.outline);
bdh = findobj(gcf,'tag','chkbold');
set(bdh,'value',CONTFIG.bold);
pfh = findobj(gcf,'tag','chkboxprint');
set(pfh,'value', CONTFIG.printfile);
pfn = findobj(gcf,'tag','txtboxprintfn');
if CONTFIG.webflag == 0
    set(pfn,'string',CONTFIG.printfilefn);
else
    set(pfn,'string',[CONTFIG.printfilefn, '.eps']);
end
bwf = findobj(gcf,'tag','chkblkwht');
set(bwf,'value', CONTFIG.blkwht);
hdp = findobj(gcf,'tag','txtboxdepths');
set(hdp,'string', CONTFIG.depthstr);

llh = findobj(gcf,'tag','chkllrange');
ch = findobj(gcf,'tag','chkcalendar');
dh = findobj(gcf,'tag','chkdecimal');
set(llh,'value',CONTFIG.titlebtnstatus(1));
set(ch,'value',CONTFIG.titlebtnstatus(2));
set(dh,'value',CONTFIG.titlebtnstatus(3));

hlat = findobj(gcf,'tag','radiolatitude');
hlon = findobj(gcf,'tag','radiolongitude');
htim = findobj(gcf,'tag','radiotime');
n = CONTFIG.reftype;
if n > 3; n = n - 4; end;
n = num2str(n);
switch(n)
   case '1'
      set(hlat,'value',0);
      set(htim,'value',0);
      set(hlon,'value',1);
   case '2'
      set(hlon,'value',0);
      set(htim,'value',0);
      set(hlat,'value',1);
   case '3'
      set(hlat,'value',0);
      set(hlon,'value',0);
      set(htim,'value',1);
end

XYDATA.X=XYDATA.x(CONTFIG.ii);
XYDATA.Y=XYDATA.y(CONTFIG.ii);
XYDATA.DDAY=XYDATA.dday(CONTFIG.ii);
UVDATA.U=UVDATA.u(:,CONTFIG.ii);
UVDATA.V=UVDATA.v(:,CONTFIG.ii);

fixtitle;

%%%%%%%%%%%%%%

function determine_ranges

global UVDATA
global XYDATA
global CONTFIG

lonrange = [min(XYDATA.X) max(XYDATA.X)];
latrange = [min(XYDATA.Y) max(XYDATA.Y)];
max_llr = max(diff(lonrange), diff(latrange));
lat_lon_pad = (max_llr / 5) * max(max(abs(UVDATA.U(:))),max(abs(UVDATA.V(:))));
lonrange = lonrange + (lat_lon_pad * [-1 1]);
latrange = latrange + (lat_lon_pad * [-1 1]);
latrange=[floor(latrange(1)) ceil(latrange(2))];
lonrange=[floor(lonrange(1)) ceil(lonrange(2))];
CONTFIG.latrange=latrange;
CONTFIG.lonrange=lonrange;

%%%%%%%%%%%%%%%%

function xytsection
% this simply obtains the new data set from xytzoom

global UVDATA
global XYDATA
global CONTFIG

if ~isempty(CONTFIG.ii) & CONTFIG.ii(end) <= length(XYDATA.x) 
   CONTFIG.ii = gxytzoom2(XYDATA.x, XYDATA.y, XYDATA.dday, CONTFIG.ii);
else
   CONTFIG.ii = gxytzoom2(XYDATA.x, XYDATA.y, XYDATA.dday);
end
% Use only the relevant indices
if isempty(CONTFIG.ii), return; end;
XYDATA.X=XYDATA.x(CONTFIG.ii);
XYDATA.Y=XYDATA.y(CONTFIG.ii);
XYDATA.DDAY=XYDATA.dday(CONTFIG.ii);
UVDATA.U=UVDATA.u(:,CONTFIG.ii);
UVDATA.V=UVDATA.v(:,CONTFIG.ii);

determine_ranges;
fixtitle;

%%%%%%%%%%%%%%%%

function readfigcontour

notice('Working ...',1.0);
hhfig = figure;

global UVDATA
global XYDATA
global CONTFIG

% retreive almost all dialog data
tbt = findobj(gcbf,'tag','txtboxtitle');
CONTFIG.title = get(tbt,'string');
ophp = findobj(gcbf,'tag','txtboxoutpath');
CONTFIG.outpath = get(ophp,'string');
oph = findobj(gcbf,'tag','txtboxsavepath');
CONTFIG.savepath = get(oph,'string');
oph = findobj(gcbf,'tag','txtboxloadpath');
CONTFIG.loadpath = get(oph,'string');
oph = findobj(gcbf,'tag','txtboxsavefn');
CONTFIG.savefn = get(oph,'string');
oph = findobj(gcbf,'tag','popuploadfn');
CONTFIG.loadfn = get(oph,'string');
hst = findobj(gcbf,'tag','chktitle');
CONTFIG.showtitle = get(hst,'value');
olh = findobj(gcbf,'tag','chkoutline');
CONTFIG.outline = get(olh,'value');
hbb = findobj(gcbf,'tag','chkbold');
CONTFIG.bold = get(hbb,'value');
tbl = findobj(gcbf,'tag','txtboxlevs'); 
CONTFIG.custlevstr = get(tbl,'string');
tbd = findobj(gcbf,'tag','txtboxboldlevs'); 
CONTFIG.boldlevs = get(tbd,'string');
hdp = findobj(gcbf,'tag','txtboxdepths');
CONTFIG.depthstr = get(hdp,'string');
bwf = findobj(gcbf,'tag','chkblkwht');
CONTFIG.blkwht = get(bwf,'value');
pfn = findobj(gcbf,'tag','txtboxprintfn');
CONTFIG.printfilefn = get(pfn,'string');
cbp = findobj(gcbf,'tag','chkboxprint');
CONTFIG.printfile = get(cbp,'value');

gcontour; % call to perform actual plotting

di = findobj(gcbf,'tag','chkboxdate');
if get(di,'value'), date_it, end;
CONTFIG.datestamp = get(di,'value');

if CONTFIG.printfile % print & possibly save webcspecs file
   [CONTFIG.printfilefn, sfix] = strtok(CONTFIG.printfilefn, '.');
   if isempty(sfix), sfix = '.ps'; end;
   if CONTFIG.webflag == 1, sfix = '.eps'; end;
   pfname = fullfile(CONTFIG.outpath, [CONTFIG.printfilefn, sfix]);
   orient tall; 
   if CONTFIG.blkwht & strcmp(sfix, '.ps'), print( '-dps2',  '-append', pfname); end;
   if CONTFIG.blkwht & strcmp(sfix, '.eps'), print( '-deps2', pfname); end;
   if strcmp(sfix, '.ps') & ~CONTFIG.blkwht, print( '-dpsc2',  '-append', pfname); end;
   if strcmp(sfix, '.eps') & ~CONTFIG.blkwht, print( '-depsc2', pfname); end;
   if CONTFIG.webflag == 1
      fname = CONTFIG.title;
      gaps = findstr(fname, ' ');
      sufx = fname(gaps(3)+1:gaps(4)-2);
      fname = sprintf('webcspecs_%s', sufx);
      CONTFIG.savefn = fname;
      CONTFIG.DDAY = XYDATA.DDAY;
      save6(fname, 'CONTFIG');
      % save mat file with xyt, uv, & zc
      fname2 = sprintf('sect%s', sufx);
      j1 = find(XYDATA.xyt(3,:)>=CONTFIG.DDAY(1));
      j2 = find(XYDATA.xyt(3,:)<=CONTFIG.DDAY(end));
      xyt = XYDATA.xyt(:,j1(1):j2(end));
      uvj1 = j1(1)*2 - 1;
      uvj2 = j2(end)*2;
      uv = UVDATA.uv(:,uvj1:uvj2);
      zc = XYDATA.zc;
      save6(fname2, 'xyt', 'uv', 'zc')
   end
end % printing

%%%%%%%%%%%%%%%

function fixtitle

global XYDATA
global CONTFIG

dp = findobj(gcf,'tag','chkllrange');
ch = findobj(gcf,'tag','chkcalendar');
dh = findobj(gcf,'tag','chkdecimal');
tti = findobj(gcf,'tag','txtboxtitle');

llrangeflag = get(dp,'value');
calendarflag = get(ch,'value');
decimalflag = get(dh,'value');
CONTFIG.title = get(tti,'string');
CONTFIG.titlebtnstatus = [llrangeflag calendarflag decimalflag];

[cruiseID, rest] = strtok(CONTFIG.title,';');
part1 = cruiseID;

if llrangeflag
   part2 = sprintf('; Lat.(%.0f, %.0f) Lon.(%.0f, %.0f)', ...
      CONTFIG.latrange(1),CONTFIG.latrange(2), ...
      CONTFIG.lonrange(1),CONTFIG.lonrange(2));
else
   part2 = '';
end
if calendarflag
   cal1 = to_date(CONTFIG.year_base, min(XYDATA.DDAY),'s');
   cal2 = to_date(CONTFIG.year_base, max(XYDATA.DDAY),'s');
   cal1 = cal1(6:10); cal2 = cal2(6:10);
   part3 = sprintf('; %s-%s, %d', cal1, cal2, CONTFIG.year_base);
else
   part3 = '';
end
if decimalflag
   part4 = sprintf('; %.2f - %.2f dd', min(XYDATA.DDAY), max(XYDATA.DDAY));
else
   part4 = '';
end

CONTFIG.title = strcat(part1, part2, part3, part4);
set(tti,'string',CONTFIG.title);

%%%%%%%%%%%%%%%

function webfigsetup   % called from mksecplt2

global XYDATA
global UVDATA
global CONTFIG

CONTFIG.year_base = XYDATA.year_base;
CONTFIG.dbpath = XYDATA.dbname;

gplotcontour;  % display main contour dialog window

% check or reset a few of the items
df = findobj(gcf,'tag','textdata');
set(df,'string','from web section'); 
yb = findobj(gcf,'tag','txtboxyear');
set(yb,'string',num2str(CONTFIG.year_base));
ophh = findobj(gcf,'tag','txtboxoutpath');
set(ophh,'string',CONTFIG.outpath);
hlat = findobj(gcf,'tag','radiolatitude');
hlon = findobj(gcf,'tag','radiolongitude');
htim = findobj(gcf,'tag','radiotime');
if CONTFIG.reftype > 4
   chk = CONTFIG.reftype - 4; 
else
   chk = CONTFIG.reftype;
end;
switch chk
   case 1
      set(hlat,'value',0);
      set(htim,'value',0);
      set(hlon,'value',1);
   case 2
      set(hlon,'value',0);
      set(htim,'value',0);
      set(hlat,'value',1);
   case 3
      set(hlat,'value',0);
      set(hlon,'value',0);
      set(htim,'value',1);
   end
tbt = findobj(gcf,'tag','txtboxtitle');
set(tbt,'string',CONTFIG.title);
pp = pwd;
marks = findstr(pp,filesep);
CONTFIG.cruiseID = upper(pp(marks(end)+1:end));
ii = CONTFIG.ii;
determine_ranges;

u = UVDATA.u; v = UVDATA.v; 
uv=0*[u(:,ii) v(:,ii)];
uv(:,1:2:end)=u(:,ii);
uv(:,2:2:end)=v(:,ii);
maxuv=100*max(max(abs(uv)));
if maxuv > 300
   levstr = '[-500:50:500]'; 
elseif maxuv > 200
   levstr = '[-300:20:300]';
elseif maxuv > 100
   levstr = '[-200:20:200]';
elseif maxuv > 50
   levstr = '[-100:10:100]';
else
   levstr = '[-50:5:50]';
end
CONTFIG.custlevstr = levstr;      % = condensed (readable) notation
tbl = findobj(gcf,'tag','txtboxlevs');
set(tbl,'string', CONTFIG.custlevstr);
CONTFIG.outline = 0;
out = findobj('tag','chkoutline');
set(out,'value',CONTFIG.outline);
CONTFIG.boldlevs = '0';
tbb = findobj(gcf,'tag','txtboxboldlevs');
set(tbb,'string', CONTFIG.boldlevs);
hdp = findobj(gcf,'tag','txtboxdepths');
%CONTFIG.depthstr = sprintf('[ %d  %d ]', XYDATA.zc(1), XYDATA.zc(end));
CONTFIG.depthstr = '[ 0  450 ]'; 
set(hdp,'string', CONTFIG.depthstr);
ccd = findobj(gcf,'tag','chkboxdate');
set(ccd,'value',0);
pnm = findobj(gcf,'tag','txtboxprintfn');
set(pnm,'string',[CONTFIG.printfilefn, '.eps']);
cbp = findobj(gcf,'tag','chkboxprint');
set(cbp,'value', 1); 

pst = findobj(gcf,'tag','txtboxsavepath');
set(pst,'string',CONTFIG.outpath);
CONTFIG.loadpath = CONTFIG.outpath;
ptx = findobj(gcf,'tag','txtboxloadpath');
set(ptx,'string',CONTFIG.loadpath);

cnffs = findobj(gcf,'tag','txtboxsavefn');
set(cnffs,'string', 'webcont_cfg');
cnffl = findobj(gcf,'tag','popuploadfn');
curdir =  pwd;
cd(CONTFIG.loadpath)
files = what;
str_b = files.mat;
for i = length(str_b):-1:1
   chary = char(str_b(i));
   if isempty(findstr(chary, 'cfg'))
      str_b(i) = [];
   end
end
CONTFIG.loadfn = str_b;
if isempty(str_b); CONTFIG.loadfn = {'None'}; end;
cd(curdir)
set(cnffl,'value',length(CONTFIG.loadfn));
set(cnffl,'string',CONTFIG.loadfn);
CONTFIG.blkwht = 0;
ch = findobj(gcf,'tag','chkcalendar');
set(ch,'value',1);

determine_ranges;
fixtitle;

%%%%%%%%%%%%%%%%%%%% EOF