function CrozzGame(home, date, opponent)
{
  this.home = home;
  this.date = new Date(date);
  this.opponent = opponent;
}

function CrozzCountdown(endDate, callback) 
{
  var _self = this;
  this.endDate = endDate;
  this.decrement = function()
  {
    window.setTimeout(_self.decrement, 500);
    var now = new Date();
    callback(new CrozzTimeTo(_self.endDate-now));
  }
  this.decrement();
}

function CrozzTimeTo(difference)
{
  var _self = this;
  this.difference = difference;
  this.milliseconds=factorOut(1000);
  this.seconds=zeroFill(factorOut(60), 2);
  this.minutes=zeroFill(factorOut(60), 2);
  this.hours=zeroFill(factorOut(24), 2);
  this.days=zeroFill(Math.floor(_self.difference), 2);
  function factorOut(divisor)
  {
    var ret = Math.floor(_self.difference%divisor);
    _self.difference = _self.difference/divisor;
    return ret;
  }
  function zeroFill(num, digits)
  {
    num = String(num);
    while(num.length < digits) { 
      num = '0' + num;
    }
    return num;
  }
}
