Nice script apart from the UK resolving problem.
I've been monitoring my site most of the evening, and know most of the users that have been online, using the site are from the UK. Yet not once as their been any sign of a UK flag.
I have seen similar scripts to this before, and even they put me in the US. lol I wouldn't mind being in San Francisco with the current horrid weather here in the UK!