I think James answered well to the answer, however I've blogged which answer the same. Please take a look over it and let me know if you face any problem.
http://forceguru.blogspot.in/2011/12/fetching-sobject-type-from-record-id.html
Ankit Arora(Force.com MVP)