function go_to_tag(tag) {
  setCookie('select-tag', tag, null, '/', 'catseye.tc');
  if (getCookie('select-tag') === null)
    window.location.replace('/projects/?tag=' + tag);
  else
    window.location.replace('/projects/');
}

$(window).load(function() {
  // rewrite all links to tag pages to go to project space w/qs or cookie
  $("a.taglink").each(function() {
    var page = $(this).attr("href").split("/").pop();
    var tag = page.split(".", 1)[0];
    $(this).attr("href", "#");
    $(this).attr("onclick", 'go_to_tag("' + tag + '")');
  });
});

