Sounds like your battery is just about toast. Many have had an issue similar to this, where when the power adapter is removed, the computer shuts off unexpectedly, though it runs fine on AC. I had that problem on my mbp. I developed out of no where one day and I had to call apple and they replaced my battery for me. no problems since.
You may also want to search the forum here. There are many a thread about this and they all result in the same thing: Calling apple.