Actually, it is possible that the power supply is the problem. I have dealt with this before...if the PSU is giving bad power, be it from a faulty source, or due the the PSU itself being faulty, it can cause weird behavior and even damage the motherboard, causing further problems. If you can get the PSU tested, I suggest doing so. It's easy for PCs...not so sure about iMacs.
If this were a standard PC, I'd say go out to your local electronics store and pick up a tester or a cheap replacement PSU (about the same price either way), but I'm pretty sure it's not that simple with an iMac. A search on eBay shows PSUs going for $40 and up. Again, be careful when buying!
The more likely culprit as Bernie said is the logic board. If the capacitors are swollen or ruptured (it's pretty obvious), and if you're not all that great with a soldering iron, you might consider replacement. Searching eBay again, used logic boards seem to go for $70 and up, where the new ones are about $200+. If you ARE ok with soldering, then there are plenty of places to sell pre-made repair kits with all the capacitors you'll need. Google and eBay should give you PLENTY of options.
I honestly hope, for your sake, that it IS the PSU (or something simpler that I overlooked). Motherboard (logic board) issues are a pain...especially if it's not physically obvious that something's wrong. At least you have the guides here to step you through the hard parts of getting at the parts you're replacing!
I hope this helps!