function fd_reset(flag)

% function fd_reset(flag)
%
% This function is used in conjunction with FD3.  It resets all the menus
% after the user complets or cancels an operation.  When flag==0, no change
% is made to the Save option, when flag==1, the Save option is enabled, and
% when flag==2, the Save option is disabled.
%
% ACP

% Last update:  July 12, 1993
% Author:       Adrian C. Penisson

global FD3MODULES FD3STREAMS FD3MESSAGE FD3NEXT FD3FUNCLEVEL
global FD3LASTPOS FD3OBJECT FD3TEXT FD3BOXES FD3FIGURE FD3STATUS

FD3NEXT=[];
FD3FUNCLEVEL=0;
close([FD3MESSAGE FD3OBJECT]);
FD3OBJECT=[];
FD3MESSAGE=[];
FD3LASTPOS=[];

% Turn off cancel
set_menu(2,'off',9);

% Turn on overhead menus
set_menu(1:6,'on')

% Turn on full page view
set_menu(6,'on',2)

if size(FD3MODULES,2)>1 | length(FD3TEXT)>0 | size(FD3BOXES,2)>1
   % FOLLOW THIS BRANCH IF THE USER HAS ANYTHING ON THE SCREEN.
   % Turn on "Save As", "Print", and "Print To"
   set_menu(1,'on',2:4);
   % Turn on "Delete", "Copy", "Move", "Rotate"s,
   set_menu(2,'on',4:8);
   if flag==1
      % Turn on "Save"
      set_menu(1,'on',5);
      FD3STATUS(4)=1;
   elseif flag==2
      % Turn off "Save"
      set_menu(1,'off',5);
      FD3STATUS(4)=0;
   end
else
   set_menu(1,'off',2:5);
   % Turn off entire "Edit" menu
   set_menu(2,'off');
   FD3STATUS(4)=0;
end

if size(FD3MODULES,2)>1
   % FOLLOW THIS BRANCH IF THERE ARE ANY MODULES.
   % Turn on "Add Label", "Edit Label"
   set_menu(5,'on',5:6);
   % Turn on "Resize"
   set_menu(2,'on',3);
else
   set_menu(5,'off',5:6);
   set_menu(2,'off',3);
end

if size(FD3MODULES,2)>2
   % FOLLOW THIS BRANCH IF THERE ARE TWO OR MORE MODULES
   % Turn "Streams" on
   set_menu(4,'on');
else
   set_menu(4,'off');
end

if length(FD3TEXT)>0
   % FOLLOW THIS BRANCH IF THERE IS ANY TEXT
   % Turn on "Edit Text"
   set_menu(5,'on',3);
else
   set_menu(5,'off',3);
end

if size(FD3STREAMS,2)>1
   % FOLLOW THIS BRANCH IF THERE ARE ANY STREAMS
   % Turn on "Reverse"
   set_menu(2,'on',2);
   % Turn on "Raise".  Have to have bumps, at least 2 streams.
   if FD3STATUS(1) & size(FD3STREAMS,2)>2
      set_menu(2,'on',1)
   else
      set_menu(2,'off',1)
   end
else
   set_menu(2,'off',1:2);
end
