function prodfit(action)
%PRODFIT - callback and cursor change for how the products fit
%          window.

%   Yama Habibzai
%   Copyright (c) 1984-98 by The MathWorks, Inc. All Rights Reserved
%   $Revision: 1.12 $
%   $Date: 1997/12/03 17:30:02 $

if nargin < 1
  action = 'movement';
end

% The Image locations
%  [LEFT RIGHT BOTTOM TOP]

polyloc=zeros(12,4);
polyloc(1,:) = [44 298 289 350];    % MATLAB
polyloc(2,:) = [60 206 229 283];    % Toolboxes
polyloc(3,:) = [222 407 208 287];   % Simulink
polyloc(4,:) = [238 373 154 205];   % Blocksets
polyloc(5,:) = [239 374 84 138];    % Real-Time Workshop
polyloc(6,:) = [61 206 166 216];    % Compiler
polyloc(7,:) = [77 358 16 68];      % Third Party Products
polyloc(8,:) = [61 206 85 152];     % C and C++ Libraries 
polyloc(9,:) = [435 499 11 32];     % Close button
polyloc(10,:) = [433 500 36 56];    % Info button
polyloc(11,:) = [391 520 142 217];  % Stateflow 
polyloc(12,:) = [405 505 87 140];   % SF Coder 


%If this mouse is moved over the figure
switch action
case 'movement',
  figNumber = findall(0, 'Name', 'How the products fit');
  pos = get(figNumber, 'CurrentPoint');
  X = pos(1);
  Y = pos(2);
  
  % Check to see if X and Y are withing the squares
  inRect = (polyloc(:,1) <= X) & (X <= polyloc(:, 2)) & ...
      (polyloc(:, 3)<= Y) & (Y <= polyloc(:, 4));
  
  out = find(inRect);
  if ~isempty(out)
    set(figNumber, 'Pointer', 'custom');
  else
    set(figNumber, 'Pointer', 'arrow');
  end
  
  % When the area is clicked
case 'click',
  figNumber = findall(0, 'Name', 'How the products fit');
  pos = get(figNumber, 'CurrentPoint');
  X = pos(1);
  Y = pos(2);
  
  % Check to see if X and Y are withing the squares
  out = find(polyloc(:,1)<=X & polyloc(:,2)>=X & polyloc(:,3)<=Y & polyloc(:,4)>=Y);
  if isempty(out)
    out = 0;
  end
  
  switch out
  case 1,
    tour aboutmatlab;

  case 2,
    tour abouttoolboxes;

  case 3, 
    str = about('simulinknew');
    ttl = 'SIMULINK';
    helpwin(str, ttl);

  case 4,
    tour aboutblockset;

  case 5,
    str = about('rtw');
    tll = 'Real-Time Workshop';
    helpwin(str, tll);

  case 6,  
    str = about('compiler');
    ttl ='MATLAB Compiler';
    helpwin(str, ttl);

  case 7,
    str = about('connections');
    ttl = 'Third Party Products';
    helpwin(str, ttl);

  case 8,  
    str = about('cmath');
    ttl = 'C Math Library';
    helpwin(str, ttl);

  case 11, 
    str = about('stateflow');
    ttl ='Stateflow';
    helpwin(str, ttl);

  case 12,
    str =about('sfcoder');
    ttl='Stateflow Coder';
    helpwin(str, ttl);
  
  end % switch ...  
end % switch ...
    
    
