Since it may still be alive when the GUI freezes, enabling SSH and logging into it remotely will be one of the quicker ways to find out what is going on. To do so, open System Preferences, go to Sharing, and check Remote Login.
Next time it does this, ssh in, and try to do "sudo dmesg" to get the kernel log. The last lines may reveal something useful. You can also do "ps aux" to list all running processes, and try to find if something is hung. Once rebooted, in the Utilities folder is an application called Console. You can use that to look at system logs, and see if anything relevant is being saved out to the logs on disk.
Also, if you want to give the hardware a test, the system should have a set of restore discs. Put in the first one (if there are multiples), and reboot holding the alt/option key. A boot menu should appear, and one of the options should be a hardware test.