/*
    Copyright (C) A. Bram Neijt <bneijt@gmail.com>
    
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
var b_correction = (new Date()) - (new Date("Tue, 07 Feb 2012 06:04:54"));

function b_update_time()
{
  //Calculate time
  var time = new Date();
  time.setTime(time.getTime() - b_correction);
  
  //Create display strings
  var sec = time.getSeconds();
  var min = time.getMinutes();
  if(sec < 10)
  {  sec = '0'+sec; }
  if(min < 10)
  {  min = '0'+min; }
  var hour = time.getHours();
  var str = hour + ':' + min;
  if(window.innerWidth >= 770)
    str += ':' + sec;
  $('time').update(str);
  
  var y = time.getFullYear();
  var m = time.getMonth() + 1;
  var month = [
      'januari',
      'februari',
      'maart',
      'april',
      'mei',
      'juni',
      'juli',
      'augustus',
      'september',
      'oktober',
      'november',
      'december',
    ][time.getMonth()]
  var d = time.getDate();
  $('date').update(d + ' ' + month + '<sup>' + m + '</sup> ' + y);
  
  //Special days
  var special_days = {m10d4:'Dierendag',m12d15:'Koninkrijksdag',m12d25:'Kerstmis',m12d26:'Kerstmis',m12d31:'Oudejaarsdag',m12d5:'Sinterklaasavond',m1d1:'Nieuwjaarsdag',m2d14:'Valentijnsdag',m4d17:'Secretaressedag',m4d30:'Koninginnedag',m5d1:'Dag van de arbeid',m5d11:'Moederdag',m5d4:'Nationale herdenking',m5d5:'Bevrijdingsdag',m6d15:'Vaderdag',m6d29:'Nederlandse veteranendag',m8d15:'Herdenking gevallenen Zuid-oost Azië',m9d16:'Prinsjesdag',m9d9:'Nationale ziekendag'};
  $('annotation').update(special_days['m'+m+'d'+d]);
  $('clock').writeAttribute('src', 'http://chart.apis.google.com/chart?cht=rs&chs=150x150&chd=t:90,90,90,90|60,60,60,60&chco=ffffff&chm=v,000000,0,' + (3.0 * (time.getMinutes()/60.0)) + ',3.0|v,000000,1,' + (3.0 * (hour % 12 + time.getMinutes()/60.0)/12.0 ) + ',4.0|h,000000,0,1,2.0');
}



