function flag = browser_help_menu(h,str,flag)

% browser_help_menu - browser help function menu
% ----------------------------------------------
%
% flag = browser_help_menu(h,str,flag)
%
% Input:
% ------
%  h - figure handle (def: gcf)
%  str - menu command string (def: 'Initialize')
%  flag - enable flag (def: '')
%
% Output:
% -------
%  flag - command execution flag

%--------------------------------
% Author: Harold Figueroa
%--------------------------------
% $Date: 2005-08-25 10:08:44 -0400 (Thu, 25 Aug 2005) $
% $Revision: 1663 $
%--------------------------------

%--
% set info output flag
%--

if ((nargin < 3) | isempty(flag))
	flag = 0;
end

%--
% set command string
%--

if (nargin < 2)
	str = 'Initialize';
end

%--
% perform command sequence
%--

if (iscell(str))
	for k = 1:length(str)
		try
			browser_help_menu(h,str{k}); 
		catch
			disp(' '); 
			warning(['Unable to execute command ''' str{k} '''.']);
		end
	end
	return;
end

%--
% set handle
%--

if (nargin < 1)
	h = gcf;
end

%--
% main switch
%--

switch (str)

%--
% Initialize
%--

case ('Initialize')
	
	%--
	% check for existing menu
	%--
		
	if (get_menu(h,'Help'))
		return;
	end

	%--
	% get userdata
	%--
	
	if (~isempty(get(h,'userdata')))
		data = get(h,'userdata');
	end
	
	%--
	% Help
	%--
	
% 	L = { ...
% 		'Help', ...
% 		'XBAT Help ...', ...
% 		'Sound Browser ...', ...
% 		'Clip Browser ...', ...
% 		'Data Browser ...', ...
% 		'Detectors ...', ...
% 		'Annotations ...', ...
% 		'Measures ...', ...
% 		'About XBAT ...' ...
% 	};
% 	
% 	n = length(L);
% 	
% 	S = bin2str(zeros(1,n));
% 	S{3} = 'on';
% 	S{6} = 'on';
% 	S{end} = 'on';
% 	
% 	A = cell(1,n);
% 	A{2} = 'H';

	L = { ...
		'Help', ...
		'Keyboard Shortcuts ...', ...
		'(BRPSOFT)', ...
		'XBAT ...', ...
		'XBAT Extensions ...', ...
		'Search ...', ...
		'About XBAT ...' ...
	};
	
	n = length(L);
	
	S = bin2str(zeros(1,n));
	S{3} = 'on';
	S{end} = 'on';
	
	A = cell(1,n);
	A{2} = 'K';
	
	mg = menu_group(h,'browser_help_menu',L,S,A);
	
	set(mg(3),'enable','off');

	%--
	% update userdata
	%--
	
	data.browser.help_menu.help = mg;
	
	set(h,'userdata',data);
		
%--
% Keyboard Shortcuts ...
%--

case ('Keyboard Shortcuts ...')
	
	%-------
	% INFO
	%-------
	
	if (flag)
		
		info.name = str;
		info.category = 'Help'; 
		info.description = [ ...
			'Play currently displayed page. ' ...
			'When there is no designated left and right channels are played, ' ...
			'otherwise only the selection channel is played' ...
		];
		
		return;
		
	end
	
	%--
	% generate keyboard shortcut reference
	%--
	
% 	generate_key_reference;
	
	%--
	% display
	%--
	
	web([xbat_root, filesep, 'Docs', filesep, 'xbat-keys-category.html'],'-browser');
	
%--
% BRPSOFT Forum ...
%--

case ('BRPSOFT Forum ...')
	
	%-------
	% INFO
	%-------
	
	if (flag)
		
		info.name = str;
		info.category = 'Help'; 
		info.description = [ ...
			'Play currently displayed page. ' ...
			'When there is no designated left and right channels are played, ' ...
			'otherwise only the selection channel is played' ...
		];
		
		return;
		
	end
	
	web('https://brpsoft.ornith.cornell.edu/forum/index.php','-browser');
	
%--
% XBAT Forum ...
%--

case ('XBAT ...')
	
	%-------
	% INFO
	%-------
	
	if (flag)
		
		info.name = str;
		info.category = 'Help'; 
		info.description = [ ...
			'Play currently displayed page. ' ...
			'When there is no designated left and right channels are played, ' ...
			'otherwise only the selection channel is played' ...
		];
		
		return;
		
	end
	
	web('https://brpsoft.ornith.cornell.edu/forum/viewforum.php?f=2','-browser');
	
%--
% XBAT Extensions Forum ...
%--

case ('XBAT Extensions ...')
	
	%-------
	% INFO
	%-------
	
	if (flag)
		
		info.name = str;
		info.category = 'Help'; 
		info.description = [ ...
			'Play currently displayed page. ' ...
			'When there is no designated left and right channels are played, ' ...
			'otherwise only the selection channel is played' ...
		];
		
		return;
		
	end
	
	web('https://brpsoft.ornith.cornell.edu/forum/viewforum.php?f=4','-browser');
	
%--
% XBAT Help ...
%--

case ('Search ...')
	
	web('https://brpsoft.ornith.cornell.edu/forum/search.php','-browser');
	
%--
% XBAT Help ...
%--

case ('XBAT Help ...')
	
%--
% About XBAT ...
%--

case ('About XBAT ...')
	
	%-------
	% INFO
	%-------
	
	if (flag)
		
		info.name = str;
		info.category = 'Help'; 
		info.description = [ ...
			'Play currently displayed page. ' ...
			'When there is no designated left and right channels are played, ' ...
			'otherwise only the selection channel is played' ...
		];
		
		return;
		
	end
	
	splash_image('xbat_splash_3.png',-1);

end
	
% %--
% % display performance information
% %--
% 
% if (PROFILE)	
% 	try
% 		t = toc;
% 		tmp = strrep(get(h,'name'),'  ',' ');
% 		tmp = tmp(2:end);
% 		sep = char(45*ones(1,length(tmp)));
% 		
% 		disp(tmp);
% 		disp(sep);
% 		disp([mfilename ' : ' str ' (time = ' num2str(t) ')']);
% 		disp(' ');
% 		disp(' ');
% 	end	
% end
