Sounds like the exact problem I've just had fixed, luckily for me my 20" iMac G5 2ghz (pre isight) was still under warrenty.
My iMac just kept switching itself off, at first I thought I was going mad, I'd wake up in the morning and go to my Mac and it would be off, I couldn't remember if id turned it off or not (I normally dont), eventually though it started doing it while I was using it, totally randomly, sometimes straight after boot, sometimes after hours but steadily getting worse. Its not going to sleep its like someones just pulled the plug, no warning just off. I found switching it to reduced processor made it stable enough for me to get a full backup.
Contacted Apple who told me to clean install Mac OS X, clear PRAM, NVRAM etc etc... at first this worked and for a couple of days it seemed to be fixed, then it came back even worse. Contacted them again, I mentioned that my iMac fell within the serial range for the issue that Eidorian links to above but Apple wouldnt have it because my Mac wasnt a first generation 1.6GHz or 1.8GHz G5 iMac.
After a few weeks it just totally died, I contacted Apple and they thought I needed a new logic board, they sent that and I had an onsite fix which did nothing. It was the power unit not the board, 4 weeks without my work computer later, after sending the wrong part again and then being out of stock of the power unit, I finally got my iMac back up and running.
Now I've been waiting about 8 weeks for my "voucher to apologise for the delay", I've spoken to 3 people from Apple Australia Customer Relations who have promised but failed to call me back. Overall the experience has left a bad taste in my mouth.
I was lucky though, my friends iMac is doing the exact same thing (it died 3 times duing a 45 iChat session recently) but hes just out of his warrenty and its going to cost him.