﻿var heute = new Date();
var Stunden = heute.getHours();
var Endjahr = heute.getFullYear(); 
var Endmonat = heute.getMonth();
if (Stunden >= 9) {
var Endtag = heute.getDate()+1;
}
else
{
var Endtag = heute.getDate();
}
var Endstunde = 8;
var Endminute = 59;
var Endsekunde = 59;

var end = new Date(Endjahr, Endmonat, Endtag, Endstunde, Endminute, Endsekunde);

function toSt2(n) {
  s = '';
  if (n < 10) s += '0';
  return (s + n).toString();
}
function toSt3(n) {
  s = '';
  if (n < 10) s += '00';
  else if (n < 100) s += '0';
  return (s + n).toString();
}
function countdown() {
  d = new Date();
  count = Math.floor(end.getTime() - d.getTime());
  if(count > 0) {
    miliseconds = toSt3(count%1000); count = Math.floor(count/1000);
    seconds = toSt2(count%60); count = Math.floor(count/60);
    minutes = toSt2(count%60); count = Math.floor(count/60);
    hours = toSt2(count%24); count = Math.floor(count/24);
    days = count;
    document.getElementById('dd').innerHTML = hours + ':' + minutes + ':' + seconds
    setTimeout('countdown()', 100);
  }
}
countdown();
