It sounds to me like it could be a lot of things;
1) could be a heat problem, you say the fan works but that is not really a good indication. Take off the cover and blow out all dust, pay particular attention to CPU heatsink you may need to remove the fan to get in all the corners.
2) make sure the CPU fan is working
3) blow out the PSU and check the fan
4) make sure the vents are not blocked (front and back).
Then post again with details of O/S and configuration.