I have written an AppleScript to solve your problem. Download here from my iDisk, source code is included. If the link breaks, find it in my Public Folder.
This AppleScript application requires that you use the default keystroke to hide/show the Dock (Command-Option-D) as set in Exposé and/or the Keyboard System Preference pane. It will also require that you have "Enable access for assistive devices" enabled in the Universal Access section of System Preferences.
When you launch the application, it will ask what applications you want the Dock hidden during. Hold Command to select multiple items from the list. Click Okay. Then, every second, it will check to see the state of the Dock and then perform the keystroke if needed. Click the icon for the AppleScript to change the list of apps to hide the dock for.
Also, two suggestions for hiding all non-active apps:
From Freeverse software, Think (free) blacks out your screen except for one application that you choose.
Spirited Away (free) checks each running application's activity, and if an application isn't active for a certain fixed time, Spirited Away hides the application automatically.