I assume that they just buy a zip database, convert zips to longitude and latitude, then plug in the appropriate formula.
Oh, and the US Postal Service sells software for turning addresses into zips. I highly recommend using that rather than trying to roll your own solution. (Even if it does cost money.)
Comment on Re (tilly) 1: Determining the distance from one zip code to another