on mouseUp
  answer folder "Choose a folder of images:"
  if it is "" then exit mouseUp
  put it into tfolder
  
  put Dir (tfolder,false,true) into tfileList

  repeat with x =  the number of lines in tfilelist down to 1
    if not isGraphicFile(line x of tFileList) then delete line x of tfilelist
  end repeat
  set the itemDel to colon
  repeat with x = 1 to the number of lines in tFilelist
    put last item of line x of tfileList into line x of tfileNames
  end repeat
  if the number of lines in cd fld "imagelist" = 0
  then
    put tfileNames into cd fld "imageList"
    set the uImagePaths of cd fld "imageList" to tfileList
  else
    put CR& tfileNames after cd fld "imageList" 
    set the uImagePaths of cd fld "imageList" to the uImagePaths of cd fld "imageList"&CR& tfileList
  end if 

end mouseUp


function isGraphicFile pfilePath
  put empty into tAppleScript
  put "tell application " & quote & "Finder" & quote & return after tAppleScript
  put "     set x to kind of alias " & quote & "[[pfilePath]]" & quote & return after tAppleScript
  put "end tell" & return after tAppleScript
  Get value(Script(do, Applescript, merge(tAppleScript)))
  return it is in "JPEG Image,JPEG Image,JPEG Image,Windows Bitmap Image,JPEG 2000 Image,JPEG Image,PDF Document,Apple PICT Document,Portable Network Graphics Image,Apple MacPaint Image,Adobe Photoshop Image,Apple QuickTime Image,Silicon Graphics Image,Targa Image,TIFF Document,Graphics Interchange Format Image"
end isGraphicFile