function surfcontour(varargin)
% surfcontour          add 19 contours to surface
% surfcontour(30)      add 30 contours to surface
% surfcontour([-1 1])  add contours f=-1 and f=1 to surface
% surfcontour off      remove contours

p = findobj(gca,'type','surface'); p = p(1);
if nargin==1 && isstr(varargin{1}) && strcmp(lower(varargin{1}),'off') 
  q = get(gca,'Children');
  T = strcmp(get(q,'type'),'line');
  i1 = find(T,1);
  j1 = find(~T(i1:end),1);
  i2 = i1 + j1 - 2;       
  delete(q(i1:i2));    % find contour lines and delete them
else
  a = 19;
  if nargin==1 && isnumeric(varargin{1})
    a = varargin{1};
  end
  set(p,'FaceColor','interp','EdgeColor','none');    
  X = get(p,'XData');
  Y = get(p,'YData');
  Z = get(p,'ZData');
  hs = ishold; hold on
  contour3(X,Y,Z,a,'k');  
  if ~hs
    hold off
  end    
end
  




