If you decide to use IP-based redirection, you should do it through whatever server side technology you are using, and not through client-side technology. We've got other forums here for many of the common server-side languages.
A personal note: I travel a lot, and I find automated IP redirection to be a major problem - and one that many sites have decided to drop in recent times. It's better to have one static landing page that allow users to make their own choice, I think. You can even offer to give them a cookie to remember their choice, but don't force it. I've had some trips in the UK where the hotel was using a German ISP and I wanted to access some US materials. Insanity!