function [wind_neg, wind_pos, ok] = set_ts_windows

wind_neg = 1/24;
wind_pos = 1/24;
wind_neg_h = wind_neg*24; 
wind_pos_h = wind_pos*24;

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 extended thunderstorm windows','WindowStyle','modal');

set( h, 'Units', 'character');
Size = get( h, 'Position');
Xc = Size(1);
Yc = Size(2);
X0 = 60; % 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 lengths of time to extend thunderstorm windows before and after ' ...
    'the recorded beginning and ending times, for classification of thunderstorm winds:'];

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','Length of Time (h)');

uicontrol('Parent',h,'BackgroundColor',clr,'Units','character','Position',[2 edit_y+2 30 1.5],...
    'HorizontalAlignment','left','Style','text','String','Before recorded beginning:');

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

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

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

%changed wind_pos_h to wind_neg_h and vice versa on 3/7

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 )
    wind_neg_str = get(neg_edit,'String');
    if ~isempty(str2num(wind_neg_str))
        wind_neg_h = abs(str2num(wind_neg_str));
    end
    set(neg_edit,'String',num2str(wind_neg_h));
 
    wind_pos_str = get(pos_edit,'String');
    if ~isempty(str2num(wind_pos_str))
        wind_pos_h = abs(str2num(wind_pos_str));
    end
    set(pos_edit,'String',num2str(wind_pos_h));
end

function OKCallback(src, eventdata)
    wind_neg = wind_neg_h/24;
    wind_pos = wind_pos_h/24;
    ok = 1;
    close(h);
end
function CancelCallback(src, eventdata)
    close(h);
end


end