Calculating distance between two points on map

How to calculate distance with javascript and Google Maps API
http://briancray.com/2009/04/01/how-to-calculate-the-distance-between-two-addresses-with-javascript-and-google-maps-api/

The Google Distance Matrix API
http://code.google.com/apis/maps/documentation/distancematrix/

Example
http://maps.googleapis.com/maps/api/distancematrix/xml?origins=Vancouver+BC|Seattle&destinations=San+Francisco|Vancouver+BC&mode=bicycling&language=fr-FR&sensor=false

http://maps.googleapis.com/maps/api/distancematrix/xml?origins=51.51392519285,-0.1344234978578&destinations=51.5132025698763,-0.130902022377279&mode=walking&language=en-GB&sensor=false&units=imperial