Among the additional details that will make solving this easier, the script your using as well clear specs about what should (and should not) happen will be part of.
You'll have to do this regardless whom you're working with in the end, but I'd be glad to help. :)
Please don't forget that iptables uses a sort of 'wholistic' approach; i.e. not only the proper rules are important, but equally important is where and how they fit into your existing rule sets.
Thank you!