I recently stumbled across a console application that sorts all the wireless configuration hell out. You can also use this tool to configure the LAN interface.
sudo apt-get install wicd-curses
It will install quite a few other packages but it runs its own daemon in the background. This manages the networks and makes sure you connect to the ones you want. Run it with:
sudo wicd-curses

If you get a message saying no networks detected press P
(must be capital so use [SHIFT]p) and type in wlan0 in the wireless interface field and press F10 to save.
R
to refresh the list.
- Use the cursors on the keyboard to navigate up and down the list
- Press right to configure the wireless connection
- Press down a few times and check "Automatically connect to this network"
- Press down a few times again and type in your password in the key field
- Press F10 to save
- Start from 1 to do this again for any other networks

You might have to press C
to connect to the access point. If you were connected via cable, that will most likely kill the LAN interface and bring up wireless.
It is also manages the connection so it will reconnect to any configured wireless access points if it drops out for whatever reason but it will also try to connect to any available networks, just like in Windows, Macintosh or Linux Desktops.
Hope it helps!