If the computer shuts off and won't turn back on for a while it sounds like a power supply or heat problem. But it can be worse, it can be the motherboard.
I guess the first thing to do, simply because its the easiest and free, is to open up the side and take a look inside. There should be a heatsink and fan mounted on the CPU. When the computer is on that fan should be spinning, probably all the time. Also make sure the heatsink is firmly attached to the motherboard so there is good contact between it and the CPU. Now while inside the case see if it needs a cleaning. Compressed air seems to do a good job at blowing out any dust; vacuums should be avoided as the plastics wands can deliver static charges.
And still while inside the computer take a look at the capacitors on the motherboard. These are those small cone things sticking up from the mobo. If the tops are bulged up or appear to be leaking something then you mobo is failing. You cna leave the side cover off the computer case to see whats happening when you run it.
This could also be a sign or result of a failing power supply. It could be tripping and powering off. No sure 100% way to test this without trying another known goo or new powersupply.
You cna monitor temps and voltages from within the BIOS setup, pressing DEL or F2 on system startup usually gets you in, or monitoring it from Windows with the likes of something like Speedfan:
http://www.almico.com/speedfan.php
And you will need to enter the BIOS to load the setup defaults everytime this happens. Use the arrow keys to navigate and Enter to select. Read the on-screen help for other keys to use.
If the setttings are lost everytime the computer is powered-off then you need a new CMOS battery. These are regular 3V coind shped batteries like they use in older watches that you can buy almost anywhere for like $3.