it sounds like you have a simple and common problem.
computers are designed to shut down when they get too hot inside. the reason it comes back on after being off for a while is because it has cooled down. the main cause of this, is dust inside. if you can, take the covers off and check for dust, especially where the fans are and around the CPU (main chip) and power supply.
remove all the dust with a small brush or cotton bud and vacuum cleaner.
hope this helps...
craig, April 2010