function dirjg(d)

unix(['/data/globec/bin/transfer "http://globec.whoi.edu/jg/dir?',d,'" >! /tmp/jgd']);

fil=fopen('/tmp/jgd','rt');

mode=0;

jgd0=uimenu(gcf,'label',d);

while ~feof(fil)
  s=fgetl(fil);
  if strcmp(s,'SUBDIRECTORIES')==1
    mode=1;
    s=fgetl(fil);
    end
  if findstr(s,'OBJECTS')==1
    mode=2;
    s=fgetl(fil);
    uimenu(jgd0,'Separator','on')
    end
  if mode==1
    i=findstr(s,'?');
    if i>1
      j=findstr(s,'">');
      uimenu(jgd0,'label',s(i+1:j-1),'callback',['dirjg(''',s(i+1:j-1),''')']);
    end
  elseif mode==2
    i=findstr(s,'">');
    if i>1
      j=findstr(s,'</a>');
      s1=[s(i+2:j-1),s(j+4:length(s))];
      i=findstr(s1,'<a');
      if i>1
        j=findstr(s1,'">');
        s1=[s1(1:i-1),s1(j+2:length(s1)-4)];
        end
      i=findstr(s,'http:');
      j=findstr(s,'/jg/serv');
      s2=[s(i+5:j-1),s(j+8:length(s))];
      j=findstr(s2,'.html');
      s2=s2(1:j-1);
      uimenu(jgd0,'label',s1,'callback',['object=''',s2,'''']);
      end
  end
end

fclose(fil);
