Your basis in the new vehicle is $37527.09. The adjusted basis of your old vehicle $22,538 ($34,823 - $12,285) plus the cash paid for the new vehicle $16,989.09 ($29,989.09 - $13,000). I have provided links to Form 8824 & instructions and IRS Publications 551 & 544.
See page 7: http://www.irs.gov/pub/irs-pdf/p551.pdf
See page 11: http://www.irs.gov/pub/irs-pdf/p544.pdf
Sorry, wasn't quite awake yet. Yes, it should be $39,527.09.