function pic2htmltable(filename,filepath,targetfilename,targetfilepath)
%   This software is protected by german copyright and international treaties.             
%   Copyright 2004 Markus Junghöfer & Peter Peyk. All Rights Reserved.                     
%                                                                                          
%   THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE        
%   NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO,    
%   WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE    
%   OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS,
%   TRADEMARKS OR OTHER RIGHTS. COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT,       
%   INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE      
%   OR DOCUMENTATION.                                                                      
if nargin<2;filepath=[];end
file=[filepath,filename];
targetfile=[targetfilepath,targetfilename];
filesepvec = findstr(filename,filesep);
filenameonly=filename(filesepvec(end)+1:end);


fid=fopen(targetfile,'at');

fprintf(fid,'<td><a href="');
fprintf(fid,'%s',strrep(filenameonly,'.JPG','.htm'));
fprintf(fid,'%s',['"><img src="picconvert/',filenameonly,'" width="220" height="170" border="0" alt=""></a></td>']);
fprintf(fid,'\n\n');
fclose(fid);

return
