Unfortunately it looks like your 3GS' battery has expanded so much that it cracked the whole case wide open. If you have AppleCare on your device then you're all set, just take it to your local Apple Store.
If not, then still take it to the store. Complain about the battery bursting, and make sure to tell them that it's for sure a defect (you'd think it's obvious, but sometimes you just need to drive the point in), and that it potentially could have been and still be a hazard.
Remind them that the phone has not been in any adverse conditions, extreme temperatures, or abused in any way but that you just merely used it normally. (I'm assuming that's the truth?)
If they're good about it they should replace the broken phone for you; but unfortunately there's little chance of repairing your current device.