When you take Airtrain from the terminals and exit at HB or JS you will purchase your $5 "exit" fare there. When you arrive at HS or JS going to the terminals you will pay your $5 "entry" fare there as well. If you have a pay-per-ride Metrocard you should be able to swipe that for your Airtrain fare.
When you take Airtrain from