Use vi to edit the /etc/config/network file. The only change here is to comment out (put a # mark in at the start of the line) any Ethernet interfaces attached to the wan network, since you will not be using Ethernet for the wan.
Then edit the /etc/config/wireless file. Comment out the "disabled" line in the first section (wifi-device) to enable the wifi system globally. Don't change anything else in that section. Make a new section like this:
config wifi-iface
option network 'wan'
option device radio0
option mode 'sta'
option ssid 'WIFINETWORKNAME'
option encryption psk2
option key 'WIFIPASSWORD'
Replace the name and password with your actual name of course.
Execute /etc/init.d/network restart
or simply reboot and the router should connect to the Internet. (If the IP range of the network you connected to is 192.168.1.X you will need to edit /etc/config/network and change the lan IP to something like 192.168.2.1).