var clocktimerID = null;
var pics = "../counter/bilder/";
var lastsecond = -1;
var x;
var digits = new Array(10); // pre-load images;
for (x=0; x<10; x++) {
	digits[x] = new Image;
	digits[x].src = pics +	x + ".gif";
}

function startclock(){
  showtime();
}

function changedigits(h, m, s){
  var digita = h%10;
  var digitb = Math.floor((h-digita)/10);
  document.clockdigit1.src = digits[digitb].src;
  document.clockdigit2.src = digits[digita].src;
  digita = m%10;
  digitb = Math.floor((m-digita)/10);
  document.clockdigit3.src = digits[digitb].src;
  document.clockdigit4.src = digits[digita].src;
}

function showtime(){
  var now = new Date();
  var hours = now.getHours();
  var minutes = now.getMinutes();
  var seconds = now.getSeconds();
  if (lastsecond != seconds) {
    changedigits(hours, minutes, seconds);
    lastsecond = seconds;
    clocktimerID = setTimeout("showtime()",1000);
  }
}

