Why is the top button on my iPhone 3Gs not working consistently?
I'm afraid you've busted your iPhone. There's no easy solution.

That power button is known to be a weak spot, and submitting the phone to excess humidity (or direct moisture) is never a good idea, even if you weren't planning to be in that storm. 

From your description it sounds like the switch is slowly corroding. It will not get better, only worse over time. I'd suggest to have the phone serviced as long as it's otherwise still in good condition, or give up and replace it sooner than planned.

You could also try to repair it yourself by opening it up and cleaning that switch, but it might not even be possible, and worse: you risk breaking your phone. Have it serviced instead.