function [gpslegs] = getGpsLegs(action,value)
% function [gpslegs] = getGpsLegs(action,value)
% action: get - return gpslegs
% 	  set - set next index in gpslegs - num fixes for leg
%	  clear - clear gpslegs, return []
try,

persistent allgps, global behaviorGroup, global mission


gpslegs = allgps;
if strcmp(action,'get'),
	
	if isempty(allgps),
		% need to calculate the gps legs for this survey - must be a loaded file.
		nLegs = getLegs('get',0);
		nLegs = sum(nLegs);
		if ~isempty(nLegs),
			z = 1;
			nGps = 1;
			if isfield(mission{1},'gpsfixesperleg'),
				nGps = mission{1}.gpsfixesperleg;
			end
			for i=1:nLegs,
				if nGps < 0,
					if rem(z,abs(nGps)+1) == 0, gps = 1;
					else, gps = 0; end
					z = z+1;
				else
					gps = nGps;
				end
				allgps = [allgps gps];
			end
		end

	end
	gpslegs = allgps;

elseif strcmp(action,'set'),
	
	allgps = [allgps value];
	gpslegs = allgps;
elseif strcmp(action,'clear'),
	
	allgps = [];
	gpslegs = [];
end
catch, errorbox('getGpsLegs failed'), end
