function h = arithdlg(tsparentnode,manager,varargin)

%% Arithmatic dialog constructor. Optional args is the name of selected
%% time series

persistent dlg;

%% If necessary build the arithmatic dialog
if isempty(dlg) || ~ishandle(dlg) || dlg.SrcNode~=tsparentnode
    dlg = tsguis.arithdlg;
    dlg.Srcnode = tsparentnode;
    dlg.initialize(manager,varargin{:});
end

%% If specified - select the defined time series
if nargin>=3 && ~isempty(varargin{1})
    dlg.update(get(tsparentnode.getChildren,{'Label'}),varargin{1});
end
    
%% Show the dialog
dlg.Visible = 'on';
centerfig(dlg.Figure,0);
set(dlg.Handles.TXTexp,'String','')
figure(double(dlg.Figure))

%% Return the handle
h = dlg;