function ToggleStatus(toggle,fighandle)
% ToggleStatus(TOGGLE,FIGHANDLE)
% 
% This function is to indicate in the redAnTS window whether it is
% busy working or whether it is waiting for user interaction. 
% TOGGLE is either 1 to indicate that the GUI is busy, or 0 to indicate
% that the GUI is finished working and is waiting for user interaction. 
% FIGHANDLE is the handle to the redAnTS figure handle: handles.mainguifig


% get the handles structure from the main GUI
handles=guidata(fighandle);

% set the busy/waiting text and the pointer style depending on the value of
% the toggle variable
switch toggle
    case 1% busy% if toggle
    tic
    set(handles.status_text, 'String', 'BUSY', 'ForegroundColor','red');
    set(handles.mainguifig,'Pointer','watch');
    case 0% operation complete% else
    darkgreen=[0 0.6 0];
    set(handles.status_text,'String',['READY (',num2str(toc),' sec)']...
        ,'ForegroundColor',darkgreen);
    set(handles.mainguifig,'Pointer','arrow');
    case 2% non-timed operation (error? help?)
    darkgreen=[0 0.6 0];
    set(handles.status_text,'String','READY','ForegroundColor',darkgreen);
    set(handles.mainguifig,'Pointer','arrow');
end
drawnow
% Update handles structure
guidata(fighandle, handles);
