Automatic Location (proxy) switcher

I have several locations that I use. Does anyone have a script that will detect the proxy and choose the appropriate location according to the proxy?