/* <![CDATA[ */


//ADJUST THIS TO YOUR LAUNCH DATE
var launch = new Date("October 24, 2008");

//ADJUST THIS TO YOUR LAUNCHED MESSAGE (WE CAN UPDATE THE SCRIPT TO REFLECT TIME LEFT BEFORE CLOSE ONCE THIS MESSAGE APPEARS)
var launchedMessage = 'Open enrollment has officially started.';



//NO TOUCHY :)
function getCountdown()
{
  var now = new Date();
  var countdown = Math.floor( (launch.getTime() - now.getTime()) / 1000);
  
  if (countdown <= 0) return launchedMessage;
  
  var d = Math.floor(countdown/86400); 
  countdown = countdown % 86400;

  h = Math.floor(countdown / 3600);
  countdown = countdown % 3600;

  m = Math.floor(countdown / 60);
  countdown = countdown % 60;

  s = Math.floor(countdown);

  m = formatTime(m);
  s = formatTime(s);
  
  return d + " days, " + h + " hours, " + m + " minutes, " + s + " seconds"; 
}


function writeCountdown(parentElem)
{
  var newSpan = document.createElement('span'); 
  newSpan.id = 'countdownSpan'; 
  newSpan.appendChild(document.createTextNode(getCountdown()));
  var el = document.getElementById(parentElem);
  removeChildNodes(el);
  el.appendChild(newSpan);
  t = setTimeout('writeCountdown()', 500);  
}


function removeChildNodes(ctrl)
{
  while (ctrl.childNodes[0])
  {
    ctrl.removeChild(ctrl.childNodes[0]);
  }
}


function formatTime(i)
{
  if (i < 10)
  {
    i = "0" + i;
  }
  return i;
}

// ]]> 