There are two big issues:
1. There are errors in your script and that is why you are getting the message.
2. Even if you fix the errors it still will not work. Acrobat/Reader security will stop you from dynamically setting an image field. You will have to have the user select the image if you want to change the image on the fly.
Paul