This is just a possibilty:
I think your PRAM battery needs replaced. When you turn off the computer the PRAM battery dies. When you turn the computer on and leave it for forty minutes, it trickle charges the PRAM, and builds enough temporary power to launch the startup.
Depending on your iMac model, you may or may not be able to replace it yourself. I see G5 is marked as a tag. If you have a G5 iSight model, you can't do the replacement yourself. All other G5 models the install is very easy.
Here is a link to the PRAM battery for the G5 iMac:
Here's a link to installing RAM in a G5 (it shows how to open the back of the iMac to get to the PRAM battery):