var dist = [
  ['Saldahna',[]],
  ['Vredenburg',[13]],
  ['Louville',[1,1]],
  ['George Curry',[1,1,1]],
  ['Langeenheid',[1,1,1,1]],
  ['Langebaanweg',[18,24,1,1,1]],
  ['Hopefield - Mission Church',[44,44,1,1,1,37]],
  ['Koperfontein',[1,1,1,1,1,1,1]],
  ['Skoolbult',[1,1,1,1,1,1,1,1]],
  ['Malmesbury',[105,107,1,1,1,89,63,1,1]],
  ['Cape Town',[142,147,1,1,1,123,114,1,1,70]]
];

// Distance Calculator
// copyright 23rd 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);
  selbox.options[selbox.options.length] = new Option("Please Select","Please Select");
  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 km = 0;
if (v1 != v2)
  km = dist[Math.max(v1,v2)][1][Math.min(v1,v2)];
document.getElementById('k').value = km + ' km';
}

function start() {
setOptions('ca');
setOptions('cb');
document.getElementById('k').value = '';
}



// Copyright 2002 Bontrager Connection, LLC
// See http://willmaster.com/possibilities/archives/ for more info
//
// Specify the spelling of month names. They can be abbreviated 
//    or completely spelled out, and can be in any written language.

Month1  = 'January';
Month2  = 'February';
Month3  = 'March';
Month4  = 'April';
Month5  = 'May';
Month6  = 'June';
Month7  = 'July';
Month8  = 'August';
Month9  = 'September';
Month10 = 'October';
Month11 = 'November';
Month12 = 'December';

//
// Specify the spelling of month names. They can be abbreviated 
//    or completely spelled out, and can be in any written language.

Weekday1  = 'Sun';
Weekday2  = 'Mon';
Weekday3  = 'Tue';
Weekday4  = 'Wed';
Weekday5  = 'Thu';
Weekday6  = 'Fri';
Weekday7  = 'Sat';


// Specify the format you want for your date/time display. Whatever 
//    you type between the quotes will be printed, except the 
//    following placeholders will be replaced with live data --
//
// Note 1: All placeholders are case sensitive.
//
//       YEAR -- The 4-digit year.
//         YR -- The 2-digit year.
//
//      MONTH -- The month name.
//         MT -- The month number.
//        0MT -- The month number, with a zero leading single digits.
// Note 2: The first character of 0MT is a zero, not a capital letter Oh.
//
//    WEEKDAY -- The day of the week.
//
//        DAY -- The day of the month.
//       0DAY -- The day of the month, with a zero leading single digits.
// Note 3: The first character of 0DAY is a zero, not a capital letter Oh.
//
//        H12 -- replaced with the hour (12-hour clock).
//       0H12 -- replaced with the hour (12-hour clock), with a zero leading single digits.
//        H24 -- replaced with the hour (12-hour clock).
//       0H24 -- replaced with the hour (12-hour clock), with a zero leading single digits.
//         MM -- replaced with the minute.
//         0M -- replaced with the minute, with a zero leading single digits.
//         SS -- replaced with the second.
//         0S -- replaced with the second, with a zero leading single digits.
//       AMPM -- replaced with "AM" if the time is before noon, "PM" otherwise.
// Note 4: The first character of 0H12, 0H24, 0M, and 0S is a zero, not a capital letter Oh.
//
// Here, specify the format:

DateTimeFormat = "WEEKDAY - 0H24:0M AMPM";



//
// No customizations are required below this point of 
//    this JavaScript code section.
//

function FormatDateTimeString(fixedtime) {
	var currentYear     = fixedtime.getFullYear();
	var currentMonth    = fixedtime.getMonth();
	var currentWeekDay  = fixedtime.getDay();
	var currentMonthDay = fixedtime.getDate();
	var currentHour     = fixedtime.getHours();
	var currentMinute   = fixedtime.getMinutes();
	var currentSecond   = fixedtime.getSeconds();
	var re = '';
	var datetimeString = DateTimeFormat;
	re = /YEAR/g;
	datetimeString = datetimeString.replace(re,currentYear);
	var st = new String(currentYear);
	var shortYear = st.charAt(2) + st.charAt(3);
	re = /YR/g;
	datetimeString = datetimeString.replace(re,shortYear);
	currentMonth = currentMonth + 1;
	st = String('st2 = Month' + currentMonth);
	var st2 = '';
	eval(st);
	re = /MONTH/g;
	datetimeString = datetimeString.replace(re,st2);
	var si = '';
	if(currentMonth < 10){ 
		si = '0' + currentMonth; 
	}
	else{ 
		si = currentMonth; 
	}
	re = /0MT/g;
	datetimeString = datetimeString.replace(re,si);
	re = /MT/g;
	datetimeString = datetimeString.replace(re,currentMonth);
	currentWeekDay = currentWeekDay + 1;
	st = String('st2 = Weekday' + currentWeekDay);
	eval(st);
	re = /WEEKDAY/g;
	datetimeString = datetimeString.replace(re,st2);
	si = '';
	if(currentMonthDay < 10) { 
		si = '0' + currentMonthDay; 
	}
	else{ 
		si = currentMonthDay; 
	}
	re = /0DAY/g;
	datetimeString = datetimeString.replace(re,si);
	re = /DAY/g;
	datetimeString = datetimeString.replace(re,currentMonthDay);
	var AmPm = 'pm';
	if(currentHour < 12) { 
		AmPm = 'am';
	}
	var twelveHour = currentHour;
	if(currentHour > 12) { 
		twelveHour = currentHour - 12; 
	}
	var zeroCurrentHour = currentHour;
	if(currentHour < 10) { 
		zeroCurrentHour = '0' + currentHour; 
	}
	var zeroCurrentMinute = currentMinute;
	if(currentMinute < 10) { 
		zeroCurrentMinute = '0' + currentMinute; 
	}
	var zeroCurrentSecond = currentSecond;
	if(currentSecond < 10) { 
		zeroCurrentSecond = '0' + currentSecond; 
	}
	var zeroTwelveHour = twelveHour;
	if(twelveHour < 10) {
		zeroTwelveHour = '0' + twelveHour; 
	}
	re = /AMPM/g;
	datetimeString = datetimeString.replace(re,AmPm);
	re = /0H12/g;
	datetimeString = datetimeString.replace(re,zeroTwelveHour);
	re = /H12/g;
	datetimeString = datetimeString.replace(re,twelveHour);
	re = /0H24/g;
	datetimeString = datetimeString.replace(re,zeroCurrentHour);
	re = /H24/g;
	datetimeString = datetimeString.replace(re,currentHour);
	re = /0M/g;
	datetimeString = datetimeString.replace(re,zeroCurrentMinute);
	re = /MM/g;
	datetimeString = datetimeString.replace(re,currentMinute);
	re = /0S/g;
	datetimeString = datetimeString.replace(re,zeroCurrentSecond);
	re = /SS/g;
	datetimeString = datetimeString.replace(re,currentSecond);
	re = /am/g;
	datetimeString = datetimeString.replace(re,'AM');
	re = /pm/g;
	datetimeString = datetimeString.replace(re,'PM');
	return datetimeString;
} // end of function FormatDateTimeString()

function GetAndRelayCurrentDateTime() {
	var mytime = new Date();
	return FormatDateTimeString(mytime);
} // end of function GetAndRelayCurrentDateTime()

function UpdateDateTime() {
	var t = GetAndRelayCurrentDateTime();
	document.datetimeform.timespot.value = t;
	setTimeout('UpdateDateTime()',1000);
} // end of function UpdateDateTime()
//-->

// Copyright 2002 Bontrager Connection, LLC
// The data and functions in this section assume that 
//    the data and functions developed for the article, 
//    "JavaScript Clocks and Calendars, Part II, Custom Date/Time Display,"
//    are available in this web page's source code above this section. 
//    See http://willmaster.com/possibilities/archives/ for more info.

//
// Leave the following three lines as is:
	ItemName = new Array();
	ItemTime = new Array();
	HowMany = 0;
// Leave the above three lines as is.


//
// In the space below, specify the particulars of each time zone you 
//    want displayed on your page.
// For each time zone, you must specify a name and the adjustment 
//    plus or minus Universal Time. [Universal Time (UT) is the same 
//    as Greenwich Mean Time (GMT).]
// The name of the time zone can be anything you wish it to be. If 
//    the name contains quotation marks, they must be preceeded with 
//    a backslash, like: \"
// The adjustment can be specified in hours or minutes. Hours may 
//    be whole or decimal numbers, like +2 or -2.5 but minutes must 
//    be whole numbers only, like +120 or -150. If the number is 
//    over 12 or less than -12 it's deemed to be minutes, otherwise, 
//    it is assumed to represent hours. To indicate a time zone West 
//    of Greenwich, England, which is time zone 0 or UT, preceed the 
//    number with a minus sign (hyphen). To indicate a time zone East 
//    of 0, preceeding the number with a plus sign is optional.
// (Because this program does not have a database of individual world 
//    regions' Daylight Savings Time rules, separate Daylight Savings 
//    Time entries need to be added to the list for those you want 
//    displayed.)
// To specify the particulars of each time zone for display, follow 
//    this format, one line per time zone:
//       AddTimeZoneToList("Time Zone Name",0);
//    Replace "Time Zone Name" with the name of your time zone. And 
//    replace 0 with the number of hours or minutes, minus or plus, 
//    that the time zone differs from UT.
// The order you specify the time zones in the lines below is the order 
//    they will be displayed on your page.

	AddTimeZoneToList("Cape Town",2);

//
// Between the quotes, type the characters (if any) that you want displayed 
//    at the beginning of the list of time zones display. If your characters 
//    contain quotation marks, they must be preceeded with a backslash, 
//    like: \"

	var BeginListWith = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><th>Time Zone</th><th>Actual Time</th></tr>";


//
// Between the quotes, type the characters that you want displayed wherever 
//    a list time zone is displayed. Use TIMEZONENAME and TIMEZONETIME 
//    where you want the name of the time zone and the time of the time 
//    zone displayed, respectively. If your characters contain quotation 
//    marks, they must be preceeded with a backslash, like: \"

	var ListItemDisplay = "TIMEZONENAME - TIMEZONETIME";


//
// Between the quotes, type the characters (if any) that you want displayed 
//    at the end of the list of time zones display. If your characters 
//    contain quotation marks, they must be preceeded with a backslash, 
//    like: \"

	var EndListWith = "</table>";

//
// No customizations are required below this point of 
//    this JavaScript code section.
//

var globalCount=0;

function DisplayListOfTimeZones() {
	toWriteTo=document.getElementById('timeDisplayer');
	var centertime = new Date();
	var centerdigits = centertime.getTime() + (centertime.getTimezoneOffset() * 60 * 1000);
	centertime.setTime(centerdigits);
	var re = '';
	var myStr='';
//myStr=(BeginListWith);
	/*for(var i = 0; i < HowMany; i++) {*/
		var i= globalCount;
		var s = ListItemDisplay;
		re = /TIMEZONENAME/g;
		s = s.replace(re,ItemName[i]);
		centertime.setTime(centerdigits + (ItemTime[i] * 60 * 1000));
		var t = FormatDateTimeString(centertime);
		re = /TIMEZONETIME/g;
		s = s.replace(re,t);
		myStr+=(s);
	/*}*/
	//myStr+=(EndListWith);
	toWriteTo.innerHTML=myStr;
	globalCount++;
	if (globalCount==HowMany){
		globalCount=0;
	}
} // DisplayListOfTimeZones()

function AddTimeZoneToList(s,t) {
	ItemName[HowMany] = s;
	if((t <= 12) && (t >= -12)) { t = t * 60; }
	ItemTime[HowMany] = t;
	HowMany = HowMany + 1;
} // AddTimeZoneToList()

//Calls the display function repeatedly, bring up the next item in the time list in a loop
function Update(){
	DisplayListOfTimeZones();
	myClock=setInterval('DisplayListOfTimeZones()',5000);
}


/*
Dynamic Calendar II (By Jason Moon at http://www.jasonmoon.net)
Permission granted to Dynamicdrive.com to include script in archive
For this and 100's more DHTML scripts, visit http://dynamicdrive.com
*/

var ns6=document.getElementById&&!document.all
var ie4=document.all

var Selected_Month;
var Selected_Year;
var Current_Date = new Date();
var Current_Month = Current_Date.getMonth();

var Days_in_Month = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
var Month_Label = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');

var Current_Year = Current_Date.getYear();
if (Current_Year < 1000)
Current_Year+=1900


var Today = Current_Date.getDate();

function Header(Year, Month) {

   if (Month == 1) {
   Days_in_Month[1] = ((Year % 400 == 0) || ((Year % 4 == 0) && (Year % 100 !=0))) ? 29 : 28;
   }
   var Header_String = Month_Label[Month] + ' ' + Year;
   return Header_String;
}



function Make_Calendar(Year, Month) {
   var First_Date = new Date(Year, Month, 1);
   var Heading = Header(Year, Month);
   var First_Day = First_Date.getDay() + 1;
   if (((Days_in_Month[Month] == 31) && (First_Day >= 6)) ||
       ((Days_in_Month[Month] == 30) && (First_Day == 7))) {
      var Rows = 6;
   }
   else if ((Days_in_Month[Month] == 28) && (First_Day == 1)) {
      var Rows = 4;
   }
   else {
      var Rows = 5;
   }

   var HTML_String = '<table border=0 cellspacing=0 cellpadding=0 width="170">';

   HTML_String += '<tr height="18" class="month"><th colspan=7>' + Heading + '</th></tr>';

   HTML_String += '<tr class="heading"><td align="center">S</td><td align="center">M</td><td ALIGN="center">T</td><td ALIGN="center">W</td>';

   HTML_String += '<td align="center">T</td><td align="center">F</td><td align="center">S</td></tr>';

   var Day_Counter = 1;
   var Loop_Counter = 1;
   for (var j = 1; j <= Rows; j++) {
      HTML_String += '<tr align="center">';
      for (var i = 1; i < 8; i++) {
         if ((Loop_Counter >= First_Day) && (Day_Counter <= Days_in_Month[Month])) {
            if ((Day_Counter == Today) && (Year == Current_Year) && (Month == Current_Month)) {
               HTML_String += '<td><span class="current">' + Day_Counter + '</span></td>';
            }
            else {
               HTML_String += '<td>' + Day_Counter + '</td>';
            }
            Day_Counter++;    
         }
         else {
            HTML_String += '<td> </td>';
         }
         Loop_Counter++;
      }
      HTML_String += '</tr>';
   }
   HTML_String += '</table>';
   cross_el=ns6? document.getElementById("display") : document.all.display
   cross_el.innerHTML = HTML_String;
}

function Check_Nums() {
   if ((event.keyCode < 48) || (event.keyCode > 57)) {
      return false;
   }
}



function On_Year() {
   var Year = document.when.year.value;
   if (Year.length == 4) {
      Selected_Month = document.when.month.selectedIndex;
      Selected_Year = Year;
      Make_Calendar(Selected_Year, Selected_Month);
   }
}

function On_Month() {
   var Year = document.when.year.value;
   if (Year.length == 4) {
      Selected_Month = document.when.month.selectedIndex;
      Selected_Year = Year;
      Make_Calendar(Selected_Year, Selected_Month);
   }
   else {
      alert('Please enter a valid year.');
      document.when.year.focus();
   }
}


function Defaults() {
   if (!ie4&&!ns6)
   return
   var Mid_Screen = Math.round(document.body.clientWidth / 2);
   document.when.month.selectedIndex = Current_Month;
   document.when.year.value = Current_Year;
   Selected_Month = Current_Month;
   Selected_Year = Current_Year;
   Make_Calendar(Current_Year, Current_Month);
}


function Skip(Direction) {
   if (Direction == '+') {
      if (Selected_Month == 11) {
         Selected_Month = 0;
         Selected_Year++;
      }
      else {
         Selected_Month++;
      }
   }
   else {
      if (Selected_Month == 0) {
         Selected_Month = 11;
         Selected_Year--;
      }
      else {
         Selected_Month--;
      }
   }
   Make_Calendar(Selected_Year, Selected_Month);
   document.when.month.selectedIndex = Selected_Month;
   document.when.year.value = Selected_Year;
}

var displaystate = 'none';

function showhide(layer_ref) {

if (displaystate == 'block') {
displaystate = 'none';
}
else {
displaystate = 'block';
}
if (document.all) { //IS IE 4 or 5 (or 6 beta)
eval( "document.all." + layer_ref + ".style.display = displaystate");
}
if (document.layers) { //IS NETSCAPE 4 or below
document.layers[layer_ref].display = displaystate;
}
if (document.getElementById &&!document.all) {
hza = document.getElementById(layer_ref);
hza.style.display = displaystate;
}
}

function popitup() {
	newwindow=window.open('terms-and-conditions.html','name','height=400,width=700,scrollbars=yes');
	if (window.focus) {newwindow.focus()}
	return false;
}

function award() {
	newwindow=window.open('awards.html','name','height=305,width=588,scrollbars=no');
	if (window.focus) {newwindow.focus()}
	return false;
}


function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

addLoadEvent(Defaults);
addLoadEvent(Update);
