I had same problem with my HTC Senasation XL, everything worked fine on mobile network, but when i turned off mobile network and turned on WiFi, some apps like facebook or gmail did not work correctly, mostly they did not show pictures or i couldn't access some sites in web browser(with message Web page was not found). My solution for this problem was:
1. long touch on connected wifi network and press Edit (or something similar)
2. change DHCP to Static
3. write some IP address - default IP for my network was 192.168.0.156 so i changed it to 192.168.0.154
4. i thing this is the most important thing: set DNS servers to free Google DNS servers - 8.8.8.8 for DNS1 and 8.8.4.4 for DNS2
Since then everything works fine
EDIT
My router is D-Link DI-524