function dat=bridgeit(nfirstbad,nlastbad,lgap,nbefore,nafter,dat)

% Modified from a FORTRAN program by jpx on 7-15-99

% c	SET up parameters for bridge
lxtnd=round(0.75*lgap);
if lxtnd<=0
	lxtnd=1;
elseif lgap==2
	lxtnd=-2;
end;

% c	CALL bridge with points before gap
nbefore=min(nbefore,200);
istart=nfirstbad-nbefore;
nb2=floor(nbefore/2);
ii=1;
dat=bridge(dat,istart,nbefore,nb2,lxtnd,ii);

% c	CALL bridge with points after gap
istart=nlastbad+1;
nafter=min(nafter,200);
na2=floor(nafter/2);
ii=2;
dat=bridge(dat,istart,nafter,na2,lxtnd,ii);

return
