var countdown_target = 1304107200;
var countdown_now = countdown_target - Math.floor((new Date()).getTime() / 1000) + 3600;
var countdown_animate = true;

function teaser_load() {

  countdown_tick();      
}

function countdown_tick() {
  
  var secs = (countdown_now % 60).toString();
  var mins = (Math.floor(countdown_now / 60) % 60).toString();
  var hours = (Math.floor(countdown_now / 3600) % 24).toString();
  var days = Math.floor(countdown_now / 86400).toString();
  
  countdown_show_number('secs', secs);
  countdown_show_number('mins', mins);
  countdown_show_number('hours', hours);
  countdown_show_number('days', days);
       
  if(countdown_animate) {
    countdown_animate = false;
    $('#countdown').show();//'fade', null, 1000);
  }
               
  countdown_now--;
  
  setTimeout('countdown_tick()', 1000);
}

function countdown_show_number(name, valuestr) {
    
  //used for position calibration
  //valuestr = '0';
  
  $('#' + name + '-1', '#countdown').attr('src', 'teaser-images/' + (valuestr.length > 1 ? valuestr.charAt(0) : '0') + '.png');
  
  $('#' + name + '-2', '#countdown').attr('src', 'teaser-images/' + (valuestr.length > 1 ? valuestr.charAt(1) : valuestr.charAt(0)) + '.png');    
}
