Dmajor / E minor / F#minor / G major / A major / B minor / C# dim.
Now take the chords that exist in E minor.
Eminor / F#dim / G major / A minor / B minor / Cmajor / D major.
Now to move from the first key to the second is done by taking a common chord that exists within both keys and use that as a pivot point to go from the first key to the second key. Looking at the chords that exist between both keys, you would see 4.
D major, E minor, G major, and B minor.
Since when you write something in a particular key you should always end with the tonic. In this case starting in the of D major, it's D major. So what they did was just end a part on D major and then slide right up to any of the the 4 chords meantioned above and start the new key with that chord. Most likely E minor or B minor.
If you study this with all the keys, you can see that you can get from one key to a good number of keys using this process of modulation. The others that don't work out would be a dramatic move, which sometimes thats what you want.
When using modulation, it's best to end the first key by playing the iv-v (IV-V) chord progression that exists in the new key. It's not a rule but it often gives the best results of being smooth. Try using the harmonic minor or harmonic major scale to change the V chord to minor or major.
Hope that helps.
"My whole life is a dark room...ONE BIG DARK ROOM" - a.f.i.