Snap!
I appear to have had the same problem as you on my old iMac G5! The problem was solved by replacing the logic board.
I suggest, if possible, get your machine your local Approved Apple Service Provider (details on the Apple website).They'll carry out diagnostic tests in order to confirm the problem and then give you a free quotation. Any work carried out is eligible to an Apple 90 day warranty.