% DIRECTORY = '/d20/www/mrs/newcodar/1998/';
DIRECTORY = '/web/arctic/mrs/newcodar/1998/';

period = '.';
ext    = 'gif';
suffix = ['raw';'tid';'det';'low';'hyp';'div';'vor'];
fnRaw = dir([DIRECTORY '*' period suffix(1,:) period ext]);

fid = fopen(['animate.head'], 'w');
fprintf(fid,'%s\n','function animate(startDate, endDate, type)');
fprintf(fid,'%s\n','{');
fprintf(fid,'%s\n','var');
fprintf(fid,'%s\n','index = 0,');
fprintf(fid,'%s\n','delay=150,');
fprintf(fid,'%s\n','animationStrings = "";');

  i = 1;
  filenames = [];
  for f = 1:length(fnRaw)
    filename = [fnRaw(f).name(1:11) period suffix(i,:) period ext];
    filenames = [filenames filename]; 
  end;
  fprintf(fid, ['String ' suffix(i,:) ' = ''%s'';\n'], filenames');
fclose(fid);

[s,w] = unix(['cat animate.raw.head animate.raw animate.raw.tail animate.tid.head animate.tid animate.tid.tail animate.det.head animate.det animate.det.tail animate.low.head animate.low animate.low.tail animate.hyp.head animate.hyp animate.hyp.tail animate.div.head animate.div animate.div.tail animate.vor.head animate.vor animate.vor.tail > animate.list']);

[s,w] = unix(['cat animate.js.head animate.list animate js.tail > animate.js2']);





