Well you and/or the dealer accepting the trade will have to pay off the balance owed (the "payoff"). If you owe more than the dealer gives you in trade, then you'll be kicking that amount into the new car loan. So if the dealer gives you X dollars in trade, and you owe $5000 more than X, then the $5000 is added onto the new car price...so you'll pay it one way or the other.
doing a trade in like this is not a great idea if you are "upside down" in your loan, because once you fold what you owe on the old car into the new car, you'll be even MORE upside down on the new car loan.
Also keep in mind that you should have gap insurance...if you total the new car, you get market value, not the value of your loan.