var dist = [
['Etosha NP Anderssons Gate', [], []],
['Windhoek', [421], ["3:49"]],
['Swakopmund', [553,363], ["5:01","3:18"]],
['Otjiwarongo', [173,248,380], ["1:34","2:15","3:27"]],
['Gobabis', [624,203,566,451], ["5:40","1:50","5:08","4:06"]],
['Keetmanshoop', [916,495,858,743,541], ["8:19","4:30","7:48","6:45","4:54"]],
['Luderitz', [1257,836,807,1084,795,341], ["11:25","7:36","7:20","9:51","7:13","3:06"]]
];


// 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;
                  