Updated AppleScript part to make use of the new document object and updated to Automator 1.0.2 aka 10.8.x.