function [interval_nts, interval_ts, ok] = set_sep_intervals

interval_nts = 4;
interval_ts = 0.25;
interval_nts_h = interval_nts;
interval_ts_h = interval_ts;


ok = 0;


scrsz = get(0,'ScreenSize');
Xc = scrsz(3)*.4;
Yc = scrsz(4)*.4;
X0 = scrsz(3)*.25;
Y0 = scrsz(4)*.25;
clr = get(0,'DefaultUicontrolBackgroundColor');

h = dialog('Color',clr,'Position',[Xc Yc X0 Y0],'Name','Specify separation intervals','WindowStyle','modal');

set( h, 'Units', 'character');
Size = get( h, 'Position');
Xc = Size(1);
Yc = Size(2);
X0 = 55; % width of dialog box
Y0 = 13; % height of dialog box
set(h,'Position',[Xc Yc X0 Y0]);

edit_x = 32; % horizontal position of left edge of edit boxes;
edit_y = 4; % vertical position of bottom edge of edit boxes;
edit_w = 20; % width of edit boxes;
edit_h = 1.5; % height of edit boxes;

h_header = uicontrol('Parent',h,'BackgroundColor',clr,'Units','character','Position',[1 Y0-5 X0-2 4.5],...
    'HorizontalAlignment','left','Style','text');

header_string = ['Enter minimum time interval by which non-thunderstorm and thunderstorm '...
                 'peak winds must be separated to ensure statistical independence:'];

set(h_header,'String',header_string);





uicontrol('Parent',h,'BackgroundColor',clr,'Units','character','Position',[edit_x edit_y+3.5 edit_w 1.5],...
    'HorizontalAlignment','left','Style','text','String','Time Interval (d)');

uicontrol('Parent',h,'BackgroundColor',clr,'Units','character','Position',[4 edit_y+2 30 1.5],...
    'HorizontalAlignment','left','Style','text','String','Non-Thunderstorm:');

nts_edit = uicontrol('Parent',h,'BackgroundColor','w','Units','character','Position',[edit_x edit_y+2 edit_w edit_h],...
    'HorizontalAlignment','center','Style','edit','String',num2str(interval_nts_h), 'Callback', @EditCallback);

uicontrol('Parent',h,'BackgroundColor',clr,'Units','character','Position',[4 edit_y X0-4 1.5],...
    'HorizontalAlignment','left','Style','text','String','Thunderstorm:');

ts_edit = uicontrol('Parent',h,'BackgroundColor','w','Units','character','Position',[edit_x edit_y edit_w edit_h],...
    'HorizontalAlignment','center','Style','edit','String',num2str(interval_ts_h), 'Callback', @EditCallback);

button_w = 20;

OK_button = uicontrol(h, 'Style','pushbutton','String','OK','Units','character','Position',[X0*.5-button_w-4 1 button_w 2],...
    'Callback',@OKCallback);
cancel_button = uicontrol(h, 'Style','pushbutton','String','Cancel','Units','character','Position',[X0*.5+4 1 button_w 2],...
    'Callback',@CancelCallback);


uiwait(h);


function EditCallback( src, event )
    nts_intvl_str = get(nts_edit,'String');
    if ~isempty(str2num(nts_intvl_str))
        interval_nts_h = abs(str2num(nts_intvl_str));
    end
    set(nts_edit,'String',num2str(interval_nts_h));
    
    ts_intvl_str = get(ts_edit,'String');
    if ~isempty(str2num(ts_intvl_str))
        interval_ts_h = abs(str2num(ts_intvl_str));
    end
    set(ts_edit,'String',num2str(interval_ts_h));
 
end

function OKCallback(src, eventdata)
    interval_nts = interval_nts_h;
    interval_ts = interval_ts_h;
    ok = 1;
    close(h);
end
function CancelCallback(src, eventdata)
    close(h);
end


end