First of all, try to restore it through iTunes. If the problem is still there then you would probably have to troubleshoot it on a hard-ware level. As far as I know it's most likely something faulty on the motherboard when it comes to these wifi "sometimes" problems. If it had to do with the antenna the problem would most likely always be there.
Also, if you restore it through iTunes and it turns gray then its definitely something related to the wifi-chip.