function status = videogetdemodata(file_name)
% VIDEOGETDEMODATA Fetches video data for Computer Vision System Toolbox MATLAB demos.
% VIDEOGETDEMODATA(FNAME) takes in a file name FNAME and opens up a dialog
% asking if it should be downloaded from a MathWorks website.

% Copyright 2006 The MathWorks, Inc.

%% only ask if file is not on the path
status = false;
if exist(file_name,'file') ~= 2
    button_name = questdlg(sprintf(['This demo requires that you download a video file ',...
                        ' from The MathWorks Web site.  Would you like to connect' ,...
                        ' to this Web site?']),...
                           'Download demo files','Yes','No','Help','Yes');
    
    if strcmpi(button_name,'No') || isempty(button_name)
        %% simply return
        return;
    elseif strcmpi(button_name,'Yes')
        lastwarn('');
        try
            web('http://www.mathworks.com/vipdemos','-browser');
        catch browserException
            errordlg(browserException.message);
        end
        
        if (lastwarn)
            errordlg(lastwarn);
        end
        return;
    else
        try
            helpview(fullfile(docroot, 'toolbox', 'vision', 'vision.map'), 'missing_video_file','CSHelpWindow');
        catch %#ok
            eid = 'vipblks:videogetdemodata:invalidDocroot';
            msg = 'Help not found.  Verify that your docroot is set to a valid location.';
            error(eid,'%s', msg);
        end
        return;
    end
else
    status = true;
end
