function toggleTab(idName) {
  var tab = document.getElementById(idName);
  document.cookie = "active_tab=" + tab.id + "; path=/;";
  tab.id = 'current';
  var head = document.getElementById('head');
  head.className = 'head_' + idName;
}

cookie = document.cookie.split('; ');

found = false;
for (i = 0; i < cookie.length; i++) {
  crumb = cookie[i].split('=');
  if (crumb[0] == 'active_tab') {
    found = true;
    toggleTab(crumb[1]);
  }
}

if (!found) toggleTab('home');
