/**
 * /public_html/javascript/functions.js
 *
 * @author    Ahmed Chafik (admin@achafik.com)
 * @copyright aChafik 2007
 * @version   Define("Id: functions.js,v 1.00 2007/10/07 16:36:56 Ahmed")
 * <script>
 */

function _gel( id ) {
  return document.getElementById(id);
}

Number.prototype.format_number = function() {
  var s = this.toString();
  var formatted = '';

    for (var i = s.length-1; i >= 0; i -=3) {
        if (i-3 >= 0) formatted = ',' + s.substr(i-2, 3) + formatted;
        else formatted = s.substring(0, i+1) + formatted;
    }

  return formatted;
}

// List how many people have perished today
function perishedToday(id) {
  this.perished = 0;
  this.id = id;
  this.update();
}

perishedToday.prototype.update = function() {
  this.perished++;

    _gel(this.id).innerHTML = this.perished.format_number();

  this.setTimeout();
}

perishedToday.prototype.setTimeout = function() {
    window.setTimeout('perishedToday.update();', 576); // (24 * 60 * 60) / 150,000 = 0.576
}