I was hoping to see more replies to your posting. I don’t know javascript but it appears to be something that I should learn. I think I read something that said you can call a javascript for InDesign with Applescript. The only reason I remember this is because there was a reference to “ExtendScript Toolkit”. Unfortunately, I can’t find the reference I think I remember. I may have been upgrade information when I went from CS to CS2.
“ExtendScript Toolkit” appears to be a javascript development application that gets installed in your Utilities directory. But as I mentioned above, I don’t know javascript. I wish I could be more help.