Routing 1 LAN + 2 WLANs + 2 WANs (failover) with DD-WRT on WRT54G2

Multiple WANs on DD-WRT look here and maybe this will help as well.

Dual WAN fallover: here

The tutorials look very detailed and documented. Using them or slight variances should get you what you want. I use DD-WRT myself and it has been a great router for me.