function delay = testifodelay(detId, sampFreq, varargin)

% $Id: testifodelay.m,v 1.6 2004/05/11 15:08:06 stuver Exp $

addpath ../

if length(varargin) ~= 0
    if length(varargin) == 1
        plotSwitch = varargin{:};
        if strcmp(lower(plotSwitch), 'off')
            off = true;
        else
            off = ~true;
        end
        
    else
        error('testdetproj: varargin = plotSwitch')
    end
else
    off = ~true;
end

xx = 0:pi/100:pi;
yy = -pi:pi/50:pi;

b=waitbar(0,['Calculating delay for ' detId '...']);

for m = 1:length(xx)
    for n = 1:length(yy)
        delay(m,n) = ifodelay(detId,cos(xx(m)),yy(n), sampFreq);
        waitbar(m/length(xx),b)
    end
end

close(b)

if ~off
    ligomap(-pi:pi/50:pi,pi/2:-pi/100:-pi/2,delay);
    
    figure(1)
    title(['Samples to Add - ' detId])
    figure(2)
    title(['Samples to Add - ' detId])
end

return