You can either catch a taxi, train or coach into Madrid from the airport. In September last year, it was 30 euros via taxi to central Madrid - we had flown from Australia, so after 24 hours of travel, just wanted to reach our destination quickly. After staying a few days in Madrid to help us over our jet lag and enjoy Madrid, we caught a train from Atocha Station (a very large station in Madrid) at approx. 7:30am. Upon reaching Pamplona, we caught a local bus after only a short wait (from right outside the train station - the local bus driver spoke only a little English, but, he was helpful in recognising where we needed to go as was an older gentlemen already on the bus), to the main coach departure station. We had adequate time to board the coach to SJPDP for its departure time of 12 noon (the only bus of the day) and arriving in SJPDP at about 1:45pm. You will not be able to pre-purchase your train or coach tickets more than about a month or so out online, as schedules are not available until close to departure dates - don't stress about this, there was plenty of room on both the train (Renfe) and coach (Alsa) - both were very reasonably priced from memory. It will likely be easier for you and not so confusing to see booking information when the schedules are released, as you will no doubt be hitting brick walls at present due to not being able to access the dates you need. Try again when you are four or five weeks out from arriving in Madrid, I'm sure it will all make more sense then. Buen Camino!