race1 = "Cardiff Half Marathon - 16 Oct 11<br />"
dateFuture1 = new Date(2010,9,16,9,00,00);
race2 = "Edinburgh Marathon Team Relay - 22 May 11<br />"
dateFuture2 = new Date(2011,4,22,9,00,00);
race3 = "Cardiff Half Marathon - 17 Oct 10<br />"
dateFuture3 = new Date(2010,9,17,9,00,00);

function getCount() {
  var out;
  out =  'dasfa';
  document.getElementById('countbox1').innerHTML = out;
}

function getCount1() {
  race1 = "Cardiff Half Marathon - 16 Oct 11<br />"
  dateFuture1 = new Date(2010,9,16,9,00,00);
  dateNow = new Date();//grab current date

  amount = dateFuture1.getTime() - dateNow.getTime();//calc ms between dates

  var out = ''

  // time is already past
  if(amount < 0){
    out = race1 + 'NOT RUNNING!'
  }
  // date is still good
  else{
    days=0;hours=0;mins=0;secs=0;

    amount = Math.floor(amount/1000);//kill the "milliseconds" so just secs
    days=Math.floor(amount/86400);//days
    amount=amount%86400;
    hours=Math.floor(amount/3600);//hours
    amount=amount%3600;
    mins=Math.floor(amount/60);//minutes
    amount=amount%60;
    secs=Math.floor(amount);//seconds
    out = race1;

    if(days != 0){out += days +" day"+((days!=1)?"s":"")+", ";}
    if(days != 0 || hours != 0){out += hours +" hr"+((hours!=1)?"s":"")+", ";}
    if(days != 0 || hours != 0 || mins != 0)
      {out += mins +" min"+((mins!=1)?"s":"")+", ";}
    out += secs +" secs";
  }
  out = 'hello';
  document.getElementById('countbox1').innerHTML = out;
  return out;
}

