diff --git a/fnn.m b/fnn.m
index 1f32d3a5defbe32911719c43c6ed9181e29868b3..f63942e0bc643bb4148948954ec22b8076b924ff 100644
--- a/fnn.m
+++ b/fnn.m
@@ -6,11 +6,14 @@ function out=fnn(varargin)
 %    Y=FNN(X,M), where M is a scalar, computes the FNN up to dimension M.
 %    The defeault is M=10.
 %
-%    Y=FNN(X,M,R,S), where R and S are scalars, applies the neighbourhood
+%    Y=FNN(X,M,T), where T is a scalar, computes the FNN using delay T.
+%    The defeault is T=1.
+%
+%    Y=FNN(X,M,T,R,S), where R and S are scalars, applies the neighbourhood
 %    criterion R and the size of the neighbourhood S. The defeault is R=2
 %    and S=Inf.
 %
-%    Y=FNN(X,M,R,S,N), where N is a scalar, uses N random samples for
+%    Y=FNN(X,M,T,R,S,N), where N is a scalar, uses N random samples for
 %    the determination of the FNNs. This speeds up the estimation, 
 %    especially for long data series. The defeault is N=length(X) if
 %    the data length is smaller than 500, else N=200.
@@ -31,7 +34,7 @@ function out=fnn(varargin)
 %    below).
 %
 %    Examples: x = sin(0:.2:8*pi)' + .1*randn(126,1);
-%              fnn(x,10,5)
+%              fnn(x,10,[],5)
 %
 %    See also PHASESPACE, PSS, MI.
 %
@@ -48,6 +51,9 @@ function out=fnn(varargin)
 % $Revision$
 %
 % $Log$
+% Revision 5.2  2007/05/15 17:33:13  marwan
+% new neighbourhood criterion: fixed RR
+%
 % Revision 5.1  2006/10/24 14:17:47  marwan
 % *** empty log message ***
 %
@@ -74,7 +80,7 @@ if nargout>2, error('Too many output arguments'), end
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% splash the GPL
 
-splash_gpl('fnn');
+splash_gpl('crp');
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% error control
 try 
@@ -86,6 +92,7 @@ set(0,'ShowHidden','on')
 delete(findobj('Tag','msgbox'))
 nogui=0;
 maxM_init = 10;
+t = 1;
 maxM=maxM_init; % maximal dimension
 r_init = 10;
 r=r_init; % r-criterion for neighbours distance
@@ -109,16 +116,22 @@ if nargin & isnumeric(varargin{1})
         maxM = varargin{i_x};
       case 2
         maxM = varargin{i_x(1)};
-        r = varargin{i_x(2)};
+        t = varargin{i_x(2)};
       case 3
         maxM = varargin{i_x(1)};
-        r = varargin{i_x(2)};
-        s = varargin{i_x(3)};
+        t = varargin{i_x(2)};
+        r = varargin{i_x(3)};
       case 4
         maxM = varargin{i_x(1)};
         r = varargin{i_x(2)};
-        s = varargin{i_x(3)};
-        maxN = varargin{i_x(4)};
+        t = varargin{i_x(3)};
+        s = varargin{i_x(4)};
+      case 5
+        maxM = varargin{i_x(1)};
+        r = varargin{i_x(2)};
+        t = varargin{i_x(3)};
+        s = varargin{i_x(4)};
+        maxN = varargin{i_x(5)};
     end
 
     % check the char input
@@ -159,6 +172,8 @@ elseif nargin & ischar(varargin{1}) & ~isempty(varargin{1})
         N=size(x,2);
         h=findobj('Tag','maxM');
         maxM=str2num(get(h(1),'String'));
+        h=findobj('Tag','delay');
+        t=str2num(get(h(1),'String'));
         h=findobj('Tag','r');
         r=str2num(get(h(1),'String'));
         h=findobj('Tag','s');
@@ -174,7 +189,7 @@ end
 
 if ~nargin
       x=sin(0:.2:8*pi)'+.1*randn(126,1); 
-      maxM=10;
+      maxM=10; t = 1;
       r=5; s = Inf;
       nogui=0;
 else
@@ -228,7 +243,7 @@ case 'init'
     end
 
     h=axes(props.axes,...
-            'Position',[89 24.8 6.8 3.5]);    
+            'Position',[89 24.8+.5 6.8 3.5]);    
     logo=load('logo');
     h2=imagesc([logo.logo fliplr(logo.logo)]);
     set(h2,'Tag','uniLogo')
@@ -236,7 +251,7 @@ case 'init'
     h=uicontrol(props.text,...
             'Tag','text_logo',...
             'String','Uni Potsdam',...
-            'Position',[97 24.2143 23  3.5714]);    
+            'Position',[97 24.2143+.5 23  3.5714]);    
     h2=textwrap(h,{[char(169),' AGNLD'],'University of Potsdam','2006'});
     set(h,'String',h2)
 
@@ -248,68 +263,80 @@ case 'init'
     % frame around parameter settings
     h=uicontrol(props.frame,...
             'Tag','frame',...
-            'Position',[91.5000  1.3571 23.5000 21.5]);    
+            'Position',[91.5000  1.3571 23.5000 22.8]);    
 
     % dimension
     h=uicontrol(props.text,...
             'Tag','text',...
             'String','Max. Dim.',...
-            'Position',[93.8333 20.3 14 1.5000]);    
+            'Position',[93.8333 22.3-.6 14 1.5000]);    
  
     h=uicontrol(props.edit,...
             'Tag','maxM',...
             'String',num2str(maxM),...
             'ToolTip','False nearest neighbours will be computed up to this dimension.',...
-            'Position',[105.1666 20.55 6.5 1.5000]);    
+            'Position',[105.1666 22.55-.6 6.5 1.5000]);    
+
+    % delay
+    h=uicontrol(props.text,...
+            'Tag','text',...
+            'String','Delay',...
+            'Position',[93.8333 20.3-.6 14 1.5000]);    
+ 
+    h=uicontrol(props.edit,...
+            'Tag','delay',...
+            'String',num2str(t),...
+            'ToolTip','Delay for embedding.',...
+            'Position',[105.1666 20.55-.6 6.5 1.5000]);    
 
     % falseness criterion
     h=uicontrol(props.text,...
             'Tag','text',...
             'String','Falseness',...
-            'Position',[93.8333 18.3 20.5  1.5000]);    
+            'Position',[93.8333 18.3-.6 20.5  1.5000]);    
 
     h=uicontrol(props.edit,...
             'Tag','r',...
 	        'String',num2str(r),...
 	        'ToolTip','Criterion value (suggested: >1).',...
-            'Position',[105.1666 18.55 6.5  1.5000]);    
+            'Position',[105.1666 18.55-.6 6.5  1.5000]);    
  
     % neigbourhood range
     h=uicontrol(props.text,...
             'Tag','text',...
 	        'String','Neigbourh.',...
-            'Position',[93.8333 16.3 20.5  1.5000]);    
+            'Position',[93.8333 16.3-.6 20.5  1.5000]);    
 
     h=uicontrol(props.edit,...
             'Tag','s',...
 	        'String',num2str(s),...
 	        'ToolTip','Maximal distance between neighbours (in multiples of standard deviation).',...
-            'Position',[105.1666 16.55 6.5  1.5000]);    
+            'Position',[105.1666 16.55-.6 6.5  1.5000]);    
  
     % norm
     h=uicontrol(props.text,...
             'Tag','text',...
 	        'String','Norm',...
-            'Position',[93.8333 14.1 15  1.5000]);    
+            'Position',[93.8333 13.7 15  1.5000]);    
 
     h=uicontrol(props.popup,...
             'Tag','method',...
 	        'String','Max|Euc|Min',...
             'Value',method,...
 	        'ToolTip','Norm used for the computation of the distance.',...
-            'Position',[101.1666 14.35 10.5  1.5000]);    
+            'Position',[101.1666 13.95 10.5  1.5000]);    
  
     % number of samples
     h=uicontrol(props.text,...
             'Tag','text',...
 	        'String','Number of samples',...
-            'Position',[93.8333 11.75+.4 19  1.5000]);    
+            'Position',[93.8333 11.75+.2 19  1.5000]);    
 
     h=uicontrol(props.edit,...
             'Tag','maxN',...
 	        'String',num2str(maxN),...
 	        'ToolTip','Number of randomly chosen samples.',...
-            'Position',[93.8333 10.5+.4 17.8333  1.5000]);    
+            'Position',[93.8333 10.5+.2 17.8333  1.5000]);    
  
 
     % buttons
@@ -441,7 +468,6 @@ case 'compute'
         end
         
         FNN(m,1) = 0;
-        t=1;
         NX=N-t*(m-1);
 
         % create phase space vectors