jQuery(function ($) {
  var years = ['2008', '2009', '2011'].reverse(),
      match = re = /^\/(\d{4})/.exec(document.location.pathname),
      year  = match[1];
      
  var bar = $('<ul>').attr('id', 'year-selector');

  if (year === '2011') {
    bar.css({
      position: 'absolute',
      left: 0,
      top: 0
    });
  }

  bar.append('<li>Kultur vom Rande im Jahr</li>');

  $.each(years, function () {
    var klass = year == this ? 'active' : null;
    $('<li>').addClass(klass).append($('<a>', {
      href: '/' + this,
      text: this.toString()
    })).appendTo(bar);
  });

  var url = '/static/past-events.css';
  if (document.createStyleSheet) {
    document.createStyleSheet(url);
  } else {
    $('head').append($('<link>', {
      rel:  'stylesheet',
      type: 'text/css',
      href: url
    }));
  }

  $('body').prepend(bar);
});


