
function updateNLTime(){
  nl_mins++;
  if(nl_mins >= 60){
    nl_hours++;
    nl_mins = 0;
  }
  if(nl_hours > 12){
    nl_hours=1;
    switchPM();
  }
}

function switchPM(){
  if(nl_pm == 'PM'){
    nl_pm = 'AM';
  } else {
    ln_pm = 'PM';
  }
}

function getNLTime(){
  var minStr = '' + nl_mins;
  if(nl_mins < 10){
    minStr = '0' + minStr;
  }
  var hourStr = '' + nl_hours;
  if(nl_hours < 10){
    hourStr = '0' + hourStr;
  }
  return nl_date + ' ' + hourStr + ':' + minStr + ' ' + nl_pm + ' ' + nl_gmt;
}

function printNLTime(div_id){
  document.writeln('<div id="' + div_id + '">');
  document.writeln(getNLTime());
  document.writeln('</div>');
  setInterval('document.getElementById("' + div_id + '").innerHTML=getNLTime();', 60*1000);
}

function TimeCountdown(hours, minutes, divId, div_class){
  this.divId = divId;
  this.divClass = div_class;
  this.hours = hours;
  this.minutes = minutes;
  this.updateByMinute = function(){
    this.minutes -= 1;
    if (this.minutes < 0) {
      if (this.hours > 0){
        this.hours -= 1;
        this.minutes = 60;
      }
    }
    this.updateDiv();
  }
  this.updateDiv = function() {
    var html = '';
    if (this.hours ==1) html += "1 hour";
    else if(this.hours > 1) html+= this.hours + " hours";

    if (this.hours > 0 && this.minutes > 0) html+=', ';

    if (this.minutes == 1) html += '1 minute';
    else if(this.minutes > 1) html += this.minutes + ' minutes';

    if (this.hours < 1 && this.minutes < 1) html = ' **RIGHT NOW**'

    document.getElementById(this.divId).innerHTML = html;
  }
  this.printCountdown = function(){
    document.writeln('<div id="' + this.divId + '" class="' + this.divClass + '" ></div>');
    this.updateDiv();
  }
}




