function toggleTools() {
  $('tools').toggle();
}

function lightsOff() {
  darkStylesheet().disabled = false;
};

function lightsOn() {
  darkStylesheet().disabled = true;
};

function darkStylesheet() {
  return $('lightsoff-stylesheet');
}

function respondToClick(event) {
   //Which tag are we working with?
  var tgt = event.target || evt.srcElement;
  tagClass = tgt.id;

   //Get events
  var allEvents = $$('#filter div.cencalEvent');

   //Iterate and show events only if they match the tag
  allEvents.each(function(evtDiv){
    if (evtDiv.hasClassName(tagClass) || tagClass == "all") {
      evtDiv.show();
      $$('#tags a').each(function(a) {
        a.removeClassName("current");
      });
      tgt.addClassName("current");
    } else {
      evtDiv.hide();
    }
  });

  var allDays = $$('.eventsForDay');

  allDays.each(function(day) {
    day.hide();
    day.select('div.cencalEvent').each(function(evt) {
      if (evt.visible()) {
        day.show();
      }
    });
  });

  Event.stop(event);
}

function showConcertina() {
  //init cookie
  var cookie = new Cookie('concertinaState2', Cookie.days(14));
  var conState = cookie.get();

  if (conState == "hidden") {
    // Nothing to do.
  } else if (conState == "shown") {
    // Immediately show the concertina.
    $('concertina').show();
  } else {
    // Unfold the concertina after two seconds.
    setTimeout(function() { Effect.SlideDown('concertina', {duration: 0.3}); }, 2000);
    setTimeout(function() { cookie.set("shown"); }, 3500);
  }
}


function closeConcertina() {
  // Fold up the concertina.
  Effect.SlideUp('concertina', {duration: 0.3});
  dismissConcertina();
}


function dismissConcertina() {
  // Update cookie state.
  var cookie = new Cookie('concertinaState2', Cookie.days(14));
  cookie.set("hidden");
}

