var activeTab = '1';
var lock = 0;
var anchorMap = Array();

var init = function (id) {
  anchorMap[1] = '#openslx';
  anchorMap[2] = '#dnbd';
  anchorMap[3] = '#dnbd2';
  anchorMap[4] = '#other';
  activeTab = id;
  $$('a.nonjslink').each (function (e) {e.href="#"+e.id});
  if (window.location.pathname != '/')
    window.location.href = '/#' + window.location.pathname.substring(4);
  checkanchor();
  setInterval("checkanchor()",300);
};

var checkanchor = function () {
  if (lock) return false;
  switch (window.location.hash.substring(1)) {
    case "dnbd":
      if (activeTab != 2) goTab(2);
      break;
    case "dnbd2":
      if (activeTab != 3) goTab(3);
      break;
    case "other":
      if (activeTab != 4) goTab(4);
      break;
    default:
      if (activeTab != 1) goTab(1);
      break;
  }
}

var goTab = function (tabID) {
  if (lock) return false;
  lock = 1;
  window.location.hash=anchorMap[tabID];
  oldTab = activeTab;
  activeTab = tabID;
  $('tab_' + oldTab).hide();
  $('li_' + oldTab).toggleClassName('selected');
  $('tab_' + tabID).show();
  $('li_' + tabID).toggleClassName('selected');
  lock = 0;
  return false;
};

