var dist = [
['Johannesburg', [], []],
['Durban', [598], ["5:25"]],
['Cape Town', [1405,1660], ["12:46","15:05"]],
['Kruger NP Malelane Gate', [463,778,1833], ["4:12","7:04","17:06"]],
['Kgalagadi NP Twee Rivieren Gate', [902,1577,1155,1319], ["8:12","14:20","10:30","12:00"]],
['Pilanesberg GR Manyane Gate', [190,756,1498,537,1057], ["1:42","6:52","13:36","4:52","9:36"]],
['Ithala GR Mvunyane Gate', [503,430,1634,396,1469,643], ["4:34","3:54","14:51","3:36","13:21","5:50"]],
['Mkuze GR Mshopi Gate', [500,300,1772,354,1527,672,137], ["4:32","2:43","16:06","3:12","13:52","6:06","1:14"]],
['Hluhluwe-Imfolozi GR Memorial Gate', [556,250,1921,422,1596,739,197,67], ["5:03","2:16","17:27","3:49","14:30","6:42","1:47","0:36"]]
];

// Distance Calculator with Times at average speed of 110km/h
// copyright 27th April 2006, by Stephen Chapman
// permission to use this Javascript on your web page is granted
// provided that all of the code below in this script (including these
// comments) is used without any alteration
function reverse(a, b){if (a>b) return -1;if (a <b) return 1;return 0;}function setOptions(id) {var selbox = document.getElementById(id);selbox.options.length = 0;var ct = []; for (var i = dist.length - 1; i >= 0; i--) {ct[i] = dist[i][0]+','+i;} ct.sort(reverse); for (var i = dist.length - 1; i >= 0; i--) {var c = ct[i].split(','); selbox.options[selbox.options.length] = new Option(c[0],c[1]);}}function calc() {var v1 = document.getElementById('ca').value;var v2 =  document.getElementById('cb').value;var dst = 0;if (v1 != v2) {dst =dist[Math.max(v1,v2)][1][Math.min(v1,v2)];tme = dist[Math.max(v1,v2)][2][Math.min(v1,v2)];}
// change the following line to allow both miles and km if required
document.getElementById('m').value = dst/1.6;
document.getElementById('k').value = dst;
document.getElementById('t').value = tme;}function start() {setOptions('ca');setOptions('cb');}window.onload=start;
                  