function fig = GPSanal()
% This is the machine-generated representation of a Handle Graphics object
% and its children.  Note that handle values may change when these objects
% are re-created. This may cause problems with any callbacks written to
% depend on the value of the handle at the time the object was saved.
%
% To reopen this object, just type the name of the M-file at the MATLAB
% prompt. The M-file and its associated MAT-file must be on your path.

% load GPSanal


% Generate the list of sites that are needed.
d = dir ;
%
% Get the names of all files in the directory
dnames = {d.name};
% get all file names with mb_ in the first three characters
dnames = dnames(strncmp(dnames,'mb_',3));
% Now sort the names
dnames = sort(dnames)';

% Reduce the names further by getting only the site names
j = 0 ; sites = [];
for i = 1:length(dnames)
	tname = cell2struct(dnames(i),'name');
	if findstr(tname.name,'.dat1')
		j = j + 1;
		st = tname.name;
		sites = [sites;st(4:11)];
	end
end

%	'Colormap',mat0, ...
h0 = figure('Units','points', ...
	'Color',[0.8 0.8 0.8], ...
	'Position',[500 301 512 384], ...
	'Tag','Fig1');
	
%	'ColorOrder',mat1, ...
h1 = axes('Parent',h0, ...
	'Units','pixels', ...
	'CameraUpVector',[0 1 0], ...
	'Color',[1 .9 .8], ...
	'Position',[145 55 345 340], ...
	'Tag','Axes1', ...
	'XColor',[0 0 0], ...
	'YColor',[0 0 0], ...
	'ZColor',[0 0 0]);
h2 = text('Parent',h1, ...
	'Color',[0 0 0], ...
	'HandleVisibility','off', ...
	'HorizontalAlignment','center', ...
	'Position',[0.4968750000000001 -0.05704697986577179 9.160254037844386], ...
	'Tag','Axes1Text4', ...
	'VerticalAlignment','cap');
set(get(h2,'Parent'),'XLabel',h2);
h2 = text('Parent',h1, ...
	'Color',[0 0 0], ...
	'HandleVisibility','off', ...
	'HorizontalAlignment','center', ...
	'Position',[-0.07187499999999997 0.4966442953020134 9.160254037844386], ...
	'Rotation',90, ...
	'Tag','Axes1Text3', ...
	'VerticalAlignment','baseline');
set(get(h2,'Parent'),'YLabel',h2);
h2 = text('Parent',h1, ...
	'Color',[0 0 0], ...
	'HandleVisibility','off', ...
	'HorizontalAlignment','right', ...
	'Position',[-0.3375 1.10738255033557 9.160254037844386], ...
	'Tag','Axes1Text2');
set(get(h2,'Parent'),'ZLabel',h2);
h2 = text('Parent',h1, ...
	'Color',[0 0 0], ...
	'HandleVisibility','off', ...
	'HorizontalAlignment','center', ...
	'Position',[0.4968750000000001 1.013422818791946 9.160254037844386], ...
	'Tag','Axes1Text1', ...
	'VerticalAlignment','bottom');
set(get(h2,'Parent'),'Title',h2);

%%%%%%%%%
% Start setup of UI controls (buttons)
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'BackgroundColor',[1 1 1], ...
	'Position',[5 48 85 306], ...
	'String',sites, ...
	'Style','listbox', ...
	'Tag','Listbox1', ...
	'Value',1, ...
	'UserData',sites) ;
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'Callback','gpsguio(''Load'')', ...
	'Position',[450 320 56 25], ...
	'String','Load', ...
	'Tag','Pushbutton1', ...
	'TooltipString','Load Selected Data');
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'Callback','gpsguio(''Append'')', ...
	'Position',[450 280 56 25], ...
	'String','Append', ...
	'Tag','Pushbutton2', ...
	'TooltipString','Append data to current');
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'Position',[450 240 56 25], ...
	'Callback','gpsguio(''Detrend'')', ...
	'String','Detrend', ...
	'Tag','Pushbutton3', ...
	'TooltipString','Show detrended data');
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'Callback','gpsguio(''Edit'')', ...
	'Position',[450 200 56 25], ...
	'String','Edit', ...
	'Tag','Pushbutton4', ...
	'TooltipString','Edit data, \nRight mouse button allows repeated selection');

h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'Callback','gpsguio(''BlockEdit'')', ...
	'Position',[450 160 56 25], ...
	'String','Block Edit', ...
	'Tag','Pushbutton6', ...
	'TooltipString','Select region to edit');
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'Callback','gpsguio(''Break'')', ...
	'Position',[450 120 56 25], ...
	'String','Break', ...
	'Tag','Pushbutton5',...
	'TooltipString','Insert breaks data, Right mouse button allows repeated selection');
h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'Callback','zoom on', ...
	'Position',[450 80 56 25], ...
	'String','Zoom', ...
	'Tag','ZoomButton', ...
	'TooltipString','Turn Zoom on');

% Get the version on Matlab since Popup's have trouble in 7.0 version
aver = ver('MATLAB') ; mver = str2num(aver.Version(1:3));
if mver < 7 
   fprintf('Less than 7 verion\n')
   h1 = uicontrol('Parent',h0, ...
	'Units','points', ...
	'Position',[13 16 69 21], ...
	'String',['North';'East ';'Up   '], ...
	'Style','popupmenu', ...
	'Tag','PopupMenu1', ...
	'TooltipString','Select North. East or Up', ...
	'Value',1);
else
   fprintf('Post 7 verion\n')
   pos = [0,0, 10,10 ];
   hlp = uipanel('Parent',h0, 'Units','Pixels', 'Position',pos);
   h1 = uicontrol('Parent',hlp, ...
	'Units','points', ...
	'Position',[13 16 69 21], ...
	'String',['North';'East ';'Up   '], ...
	'Style','popupmenu', ...
	'Tag','PopupMenu1', ...
	'TooltipString','Select North. East or Up', ...
	'Value',1);
end

if nargout > 0, fig = h0; end


