this is your machine
sounds like an overheating issue...when you've got the back off the machine you'll be able to see how much dirt and grime is in the fans and vent. Get the vacuum out see if you can clean the vents and fan. When you plug in the mains and turn the machine on (either bridge the 2 pins bottom left with a screw driver or use the reset button (has a power circle symbol next to it)) which LEDs light up on the motherboard? the 4th lights up red when it overheats. Take a good look at the capacitors and see if any are bulging... it's a common occurence with these machines.
After almost 10 years the thermal paste should be good and dry and it's always a good idea to replace it when you've opened up the Mac...(1 lot is under the G5 heat sink(need to unscrew it from the rear of the board), the other is located on the rear of the motherboard.