function [URL, loaddodsbool, infotext, times, Pass_Times, ...
      Pass_Depths, lats, lons,num_url] = focusnbc (getarchive, ...
    getranges, getmode)

%, getvariablelist, getserverlist, passtimes, ...
%    passdepths, whichurl)

%
%    This function will build focusnb file name and return infotext and url
%    to the browser
%

% The preceding empty line is important
% $Log: focusnbc.m,v $
% Revision 1.4  2000/03/17 08:49:48  dbyrne
%
%
% Fixed a lot of bugs & klugdes.  -- dbyrne 00/03/17
%
% Revision 1.3  2000/02/24 17:07:21  kwoklin
% Fix passdepths error.   klee
%
% Revision 1.2  2000/01/12 18:51:14  kwoklin
% Second checkup.  klee
%
% Revision 1.1  1999/12/01 18:58:42  kwoklin
% Added NB Focus data set.    klee
%

% $Id: focusnbc.m,v 1.4 2000/03/17 08:49:48 dbyrne Exp $
% klee  11/10/99

% initiate
  infotext = []; times = []; Pass_Times = []; 
  Pass_Depths = []; lats = []; lons = [];
  URL = ''; loaddodsbool = 0; num_url = 0;
% To prevent named file conflict, force variable names to appear as variables.  
  wlon = []; elon = []; slat = []; nlat = []; sectors = [];

% reading selected ranges

  if exist(getarchive) == 2
    eval(getarchive)
  else
    dodsmsg('Metadata not found!')
    return
  end

  [times, Pass_Times] = monthly(TimeRange, getranges);
  if min(Pass_Times(:,1)) == max(Pass_Times(:,1))
    cycle = 1;
  else
    cycle = 2;
  end

% Find the geographic range selected by user and build the constraint

  % for upper and lower lat
  Ulat = getranges(2,2);
  Llat = getranges(2,1);
  URLlat = sprintf('%s','&slat<=',num2str(Ulat,7),'&nlat>=',num2str(Llat,9)); 
  % for left and right lon
  Llon = getranges(1,1); 
  Rlon = getranges(1,2); 
  % for [-180, 180]  
  URLlon = sprintf('%s','&wlon<=',num2str(Rlon,7),'&elon>=',num2str(Llon,9));

  % builds constraints 
  returned_var = [];
  infotext = [];
  if strcmp(getmode, 'cat') | strcmp(getmode, 'datasize')
      Constraint = sprintf('%s','sectors,slat,nlat,wlon,elon', URLlat, URLlon);
      URL = sprintf( '%s', CatalogServer, '?', Constraint);

      loaddods('-F',URL);

      if sectors(1) > 1e-10 
        lats = [lats; (slat+nlat)/2];
        lons = [lons; (wlon+elon)/2];
        Pass_Depths = sectors;
        s = size(sectors,1);
        for i = 1:size(Pass_Times,1)
          for j = 1:s
            tmpPass_Depths(j+s*(i-1)) = Pass_Depths(j);
          end
        end
        Pass_Depths = tmpPass_Depths;
        for i = 1:size(Pass_Times,1)
          for j = 1:s
            tmpPass_Times(j+s*(i-1),:) = Pass_Times(i,:);
          end
        end
        Pass_Times = tmpPass_Times;
        num_url = size(Pass_Times,1);
      else
        num_url = 0;
      end
      loaddodsbool = 0;
      %infotext = sprintf('%s\n\n%s\n\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n\n%s',...
      %           ['The plus sign on the browser map marks the center position of ',...
      %            'each sector.'],...
      %           ['The sector number corresponds to the sectors code ',...
      %            'in NBDS system is as the following:'],...
      %           ['sector 1  -> GB,  Greenwich Bay'],...
      %           ['sector 2  -> UNB, Upper Narragansett Bay'],...
      %           ['sector 3  -> MHB, Mt. Hope Bay'],...
      %           ['sector 4  -> UWP, Upper West Passage'],...
      %           ['sector 5  -> UEP, Upper East Passage'],...
      %           ['sector 6  -> SAK, Sakonnet River'],...
      %           ['sector 7  -> LWP, Lower West Passage'],...
      %           ['sector 8  -> LEP, Lower East Passage'],...
      %           ['sector 9  -> SAK, Sakonnet River'],...
      %           ['sector 10 -> RIS, RI Sound'],...
      %           ['For more geographical information, please look up the ',...
      %            'Metadata Point of Contact']); 
  end
  return