function result_html(fp,exp)

% if (nargin==2)
%     width = 500;
% end

fprintf(fp,'<table border=1>\n');

% fprintf(fp,'<tr align=center>\n');
% 
% for i=1:length(exp)
%     if (isempty(exp(i).title) || isempty(exp(i).img) || exp(i).display == 0)
%         continue;
%     end
%     if (isfield(exp(i),'compare'))
%         fprintf(fp,'<td>\n');
%         fprintf(fp,'<b>%d</b>',i);
%         fprintf(fp,'</td>\n');
%     end
% end
% 
% fprintf(fp,'</tr>\n');

fprintf(fp,'<tr align=center valign=middle>\n');

for i=1:length(exp)
    if (isempty(exp(i).title) || isempty(exp(i).img) || exp(i).display == 0)
        continue;
    end
    
%     if (isfield(exp(i).blank))
%         fprintf(fp,'<td>\n');
%         fprintf(fp,'&nbsp',i);
%         fprintf(fp,'</td>\n');
%         continue;
%     end       
    
    fprintf(fp,'<td>\n');
    if (isfield(exp(i),'width'))
        if (~isempty(exp(i).width))
            fprintf(fp,'<img width=%d src=%s name=%s>\n', exp(i).width, exp(i).img, exp(i).id);
     
        else
            fprintf(fp,'<img src=%s name=%s>\n',exp(i).img, exp(i).id);
        end
    else
        fprintf(fp,'<img src=%s name=%s>\n',exp(i).img, exp(i).id);
    end
    fprintf(fp,'</td>\n');
end

fprintf(fp,'</tr>\n');

fprintf(fp,'<tr align=center>\n');

for i=1:length(exp)
    if (isempty(exp(i).title) || isempty(exp(i).img) || exp(i).display == 0)
        continue;
    end
    
    if (isfield(exp(i),'compare'))
        if (~isempty(exp(i).compare))
            fprintf(fp,'<td>\nCompare %s to: <br>\n',exp(i).title);
%             fprintf(fp,'<td>\nMouse over links below to see the deblurred image: <br>\n');
            
            for j=1:length(exp(i).compare)
                k = find_key(exp,exp(i).compare{j});
                fprintf(fp,'<a href="#"\nonmouseover="document.%s.src=''%s''"\nonmouseout="document.%s.src=''%s''">%s</a><br>\n', exp(i).id, exp(k).img, exp(i).id, exp(i).img, exp(k).title);
            end
            fprintf(fp,'</td>\n');
        else
            fprintf(fp,'<td>\n');
            fprintf(fp,'%s',exp(i).title);
            fprintf(fp,'</td>\n');            
        end
    else
        fprintf(fp,'<td>\n');
        fprintf(fp,'%s',exp(i).title);
        fprintf(fp,'</td>\n');
    end
end

fprintf(fp,'</tr>\n');
fprintf(fp,'</table><br><br>\n\n\n');

function i = find_key(exp,key)
for i=1:length(exp)
    if (strcmp(exp(i).id,key) == 1)
        break;
    end
end


