When you say your iMac goes to sleep, what happens exactly? In other words, when it goes to sleep by itself, what is different from when you tell it to go to sleep?
For example, when I tell my PowerMac G5 to go to sleep, I get a pulsating power light. What does your Mac do?
Or try seeing what happens if you boot the iMac off of the OS X install DVD. Will it go to sleep then? Try removing the hard drive (if you can) for this.
Have you tried running the Apple Hardware Test on the OS X install DVD that came with the iMac?
I had to bring my G5 into the Apple Store this weekend due to it not booting up anymore. The Concierge at the Genius Bar told me that Apple only makes replacement parts for up to 5 years (if I understood him correctly). So, Apple couldn't help me on parts (as they suspect it's a motherboard issue). The closest Apple Authorized repair facility (which I called up today) said they probably couldn't get a motherboard either.
My G5 is a first generation machine from 2004, and is considered "vintage", so I'm kinda on my own now. My point is - you could be stuck like me, with no real support options besides outside help. Great, now I'm just depressing myself...