// Use this code however you want. Attribution is appreciated.

const kShastaStartTime = (new Date("September 18, 2009")).getTime();
const kShastaEndTime = (new Date("September 21, 2009")).getTime();

// Fills a shasta div with a text string explaining the current time in 
// relation to Houseboat 2009 (or 2010).
function fillDaysTilShastaDiv(div_id) {
  var display_text = "";
  var days_til_shasta = getDaysTilShasta();
  if (days_til_shasta > 0) {
    display_text = days_til_shasta + " days 'til Shasta";
  } else if (days_til_shasta == 0) {
    display_text = "Cruisin' on the Lake...";
  } else {
    display_text = "Houseboat 2010!!!!"
  }
  var daystilshasta_div = document.getElementById(div_id);
  while (daystilshasta_div.hasChildNodes())
    daystilshasta_div.removeChild(daystilshasta_div.firstChild);
  daystilshasta_div.appendChild(document.createTextNode(display_text));
}

// Returns number of days until Lake Shasta, 0 during the start and end
// of the trip, and -1 after.    
function getDaysTilShasta() {
  var current_time = (new Date()).getTime();
  if (current_time < kShastaStartTime) {
    var delta_time = kShastaStartTime - current_time;
    return Math.floor(((((delta_time / 1000) / 60) / 60) / 24));
  } else if (current_time < kShastaEndTime) {
    return 0;
  } else {
    return -1;
  }
}
