You can use ExternalInterface.addCallback to create a bridge for Javascript to talk with ActionScript. There are a few more steps to make sure this is set up properly.
1) Make sure the id and name are the same in each AC_FL_RunContent function. Just changing one won't work. This way document.getElementById should always find the object on the page.
2) Make sure allowScriptAccess is set to always in each AC_FL_RunContent function. This updates the security setting so Javascript can access the Flash object.
3) If you're doing local development make sure to check Always allow in Global Security Settings Panel.
I found step 3 after wasting an entire morning looking around the internet. Without this I kept getting this warning.
*** Security Sandbox Violation ***
SecurityDomain 'null' tried to access incompatible context 'file:///foo/bar/project.swf'
Once you're project is finished you might want to change this back. Not sure what thing on the web wants to break your computer.