function iduibn(arg,nu,ny)
%IDUIBN Handles model estimation for model that are defined By Name.
%	NU and NY are the number of inouts and outputs in the data set.
%	The argument ARG takes the following values:
% 	 open  Opens the dialog box
%	 close Closes the dialog box
%	All estimation is handled by IDUIIO.

%	L. Ljung 4-4-94
%	Copyright (c) 1986-95 by the MathWorks, Inc.
%	$Revision: 1.4 $  $Date: 1995/05/02 16:32:08 $

global XIDss XIDparest XIDmse XIDmen XIDplotw XIDlayout


if strcmp(arg,'open')
   FigName='MODEL BY NAME';
   if ~figflag(FigName,0)
       iduistat('Opening model structure editor ...')
       eval('pepos=get(XIDparest(1),''pos'');','pepos=[50 200 204 187];')
       layout
       butwh=[mStdButtonWidth mStdButtonHeight];%butw=55;buth=25;
       butw=butwh(1);buth=butwh(2);
       ftb=2;  % Frame to button
       bb = 2; % between buttons
       etf = mEdgeToFrame;
       lev1=etf; % Level for bottommost frame-buttons
       lev2=lev1+2*ftb+buth+2*bb;  %Level for Method
       PW=3*butw+4*bb+4*ftb;PH=lev2+4*ftb+2.5*buth;
       FigWH=[PW PH];
       XIDmse(4)=figure('pos',[pepos(1)+pepos(3) pepos(2) FigWH],...
       'NumberTitle','off','Vis',ondef,'Name',FigName,'NextPlot','New',...
       'Color',get(0,'DefaultUIControlBackgroundColor'),'userdata',[nu,ny]);
       set(XIDmse(4),'Menubar','none');

% ******************
       % LEVEL 1
       pos = iduilay(FigWH,butwh,ftb,bb,bb,etf,lev1,2);
       uicontrol(XIDmse(4),'pos',pos(1,:),'style','frame');
       uicontrol(XIDmse(4),'pos',pos(2,:),'string','Close','style','push',...
                 'callback','iduibn(''close'');');
       uicontrol(XIDmse(4),'pos',pos(3,:),'string','Help','style','push',...
                 'callback','iduihelp(''iduibn.hlp'',''Defining Model Structure by Name'');');


       %LEVEL 2 CHOICE ARX -IV
      
       text=str2mat(...
             'Enter the chosen model',...
             'structure in the ESTIMATING',...
             'MODELS window');
       uicontrol(XIDmse(4),'pos',...
               [etf+3*bb lev2 PW-2*(etf+3*bb) 2.5*buth+ftb],'style','edit',...
                 'max',2,'string',text); 
       set(XIDparest(4),'value',4);
       set(get(XIDmse(3),'children'),'units','normal')
       if length(XIDlayout)>23,if XIDlayout(24,3)
          eval('set(XIDmse(4),''pos'',XIDlayout(24,1:4))','')
       end,end
       iduistat('Done.',1)
   end
   set(get(XIDmse(4),'children'),'units','normal')
   set(XIDmse(4),'vis','on')
elseif strcmp(arg,'close')
   set(XIDmse(4),'vis','off')
%   set(XIDparest(6),'value',0)
end
