Did you do the actual coding in Acrobat or is there a less painful way to write embedded JS in a PDF?