Say if the visitors come from German I'd redirect them to German
website, if vistors from USA, I'd redirect them to USA websites.
Is there a way to do this with javascript?
It depends what you want to do with the "redirected" user:
if you want to redirect the user to a page relevant to the country
he's "visiting from" - lets say he's looging in through a US ISP,
then you want to redirect to a US subsidiary of the website,
then I would be careful redirecting without making sure there is
an escape from it to a different "country" page.
assume some soldier in Guantanamo visits your page, does he get
the Cuban or the US page? Same applies for other countries: where
do you send someone from Belize? Just curious here.
I would let the user choose the country manually, then save that
info in a "cookie" letting the user, if necessary, change the
country in case he travels (or moves).
If you want to do this, you can use the server side variables
REMOTE_HOST which isn't always filled,
and
REMOTE_ADDR which can contain a proxied address - used also for
anonymous surfing
so, as you see, the above doesn't give you a clear or sure address
where your customer comes from.
If you need to redirect them for the language, then keep in mind
that every user can set language specific entries on their
browsers, but there are also browsers used by more than one user
(internet cafe) where every user can use a different language.
In that case I would also let the user choose the desired language
from a list of supported languages.
my 2 cents (and comments)