Need some help with Illustrator AS

Hi, peoples!

I have little AS for convert images to JPEG.
But after execute this script Illustrator have some bugs “ i cant open a files with drag&drop and with clicked on it.
If i relaunch Illustrator all work well.


on open droppeditems
	my setList(droppeditems)
end open

on setList(droppeditems)
	-- path to input files
	tell application "Finder"
		set inputFolder to (container of item 1 of droppeditems) as text
	end tell
	set outputFolder to (choose folder with prompt "Choose folder for save:") as alias
	my exportFilesAsJPEG(droppeditems, inputFolder, outputFolder)
end setList

on exportFilesAsJPEG(droppeditems, inputFolder, outputFolder)
	set previewSizeValue to 1200 as integer
	set destinationPath to outputFolder as string
	repeat with aFile in droppeditems
		set {name:fileName, name extension:fileExtension} to info for aFile
		try
			tell application "Finder"
				set theFile to aFile as alias -- for Illustrator
				set theFileName to theFile as text -- for Photoshop
				set fileExtension to name extension of aFile
			end tell
		on error the error_message number the error_number
			display dialog "Error in exportFilesAsJPEG Finder Step: " & the error_number & ". " & the error_message ¬
				buttons {"OK"} default button 1 with icon stop
		end try
		
		if fileExtension is "tif" or fileExtension is "psd" then -- if filetype is PSD or TIFF		
			try
				tell application "Adobe Photoshop CS5"
					activate
					set display dialogs to never
					with timeout of 600 seconds
						open file theFileName
					end timeout
					
					set docRef to the current document
					set docName to name of docRef
					set docHeight to height of docRef
					set docWidth to width of docRef
					flatten docRef
					
					if (mode of docRef is not RGB) then
						change mode docRef to RGB
					end if
					
					with timeout of 600 seconds
						if docHeight > docWidth then
							resize image current document resolution 72 as pixels height previewSizeValue as pixels
						else
							resize image current document resolution 72 as pixels width previewSizeValue as pixels
						end if
					end timeout
					set newFileName to (destinationPath as string) & docName
					with timeout of 600 seconds
						save docRef in file newFileName as JPEG with options {class:JPEG save options, embed color profile:true, format options:progressive, quality:10, scans:3}
					end timeout
					close document 1 saving no -- закрытие документа
				end tell
			on error the error_message number the error_number
				display dialog "Error in exportFilesAsJPEG Photoshop Step: " & the error_number & ". " & the error_message ¬
					buttons {"OK"} default button 1 with icon stop
			end try
		else if fileExtension is "ai" or fileExtension is "pdf" or fileExtension is "eps" then
			try
				tell application "Adobe Illustrator"
					set user interaction level to never interact
					with timeout of 180 seconds
						open theFile with options {create artboard with artwork bounding box:true} without dialogs
					end timeout
					
					set docRef to the current document
					set docName to name of docRef
					set docWidth to (width of document 1)
					set docHeight to (height of document 1)
					
					if docWidth > docHeight then
						set scaleValue to (previewSizeValue * 100) / docWidth as integer
					else
						set scaleValue to (previewSizeValue * 100) / docHeight as integer
					end if
					
					set newFileName to (destinationPath as string) & docName
					with timeout of 180 seconds
						export current document to file newFileName as JPEG with options ¬
							{class:JPEG export options, quality:100, horizontal scaling:scaleValue, vertical scaling:scaleValue, matte:false, artboard clipping:true}
						close current document saving no
					end timeout
					
				end tell
			on error the error_message number the error_number
				display dialog "Error in exportFilesAsJPEG Illustrator Step: " & the error_number & ". " & the error_message ¬
					buttons {"OK"} default button 1 with icon stop
			end try
		end if
	end repeat
end exportFilesAsJPEG


P.S. MAC OSX 10.6.8