I just stumbled across this topic and figured I'd share the script I use for my own site.
It works a little differently than the one posted at the beginning of this thread, in that it doesn't redirect your visitors, but displays a custom index page, depending on the domain being used by the visitor.
I took my script, removed my personal values and added some documentation. It can be downloaded here:
http://zionmatrix.com/scripts/
Regards,
Trinity