Have a look through some of the threads in our Security forum to see if you can find any helpful suggestions; there are some nasty viruses/trojans/malware programs out there which can cause this behaviour. The fact that you say that it happens when you're online makes me suspicious of this.
Did you add any new hardware or change drivers before having this problem? Sometimes conflicts will cause that behavior. Once I added a network card and everytime I would go online my PC would restart. Just a thought.
I might not be a hardware problem, because Windows is shutting down, not just a spontaneous reboot. Before it starts to shut down does it give you any kind of error? I would definitely check that your system is clean from malware.