It is easy.
function deliveryFee(origin,destination)
{
var u = 'http://maps.googleapis.com/maps/api/distancematrix/json?origins='+origin+'.&destinations='+destination+'.&mode=driving&language=en-US&sensor=false&units=metric';
var alldata = web.Download(u);
var json = JSON.parse(alldata);
var distance = json.rows[0].elements[0].distance.value;
if (distance < 100) {
var fee = 0;
}
if (distance >= 100 && distance < 1600) {
var fee = 5;
}
if (distance >= 1600 && distance < 3100) {
var fee = 6;
}
if (distance >= 3100 && distance < 6100) {
var fee = 7;
}
if (distance >= 6100 && distance < 8100) {
var fee = 8;
}
if (distance >= 8100) {
var fee = -1;
}
return fee;
}