Listen very carefully as you plug the iMac in (on the back of the mac, not at the wall plug), if you can here a clicking noise, that's the power unit earthing. If you can't hear a click then the power supply has gone. It's not hard to replace on a G5 iMac.