Just bought an S4 two days ago and this problem has stumped me until today!
Go to settings, click on wifi, click the bottom left button next to the home button (one of the light up buttons) to bring up another menu, click Advanced, "check for Internet service" should be checked. This allows for...