/* From Daniel Glazman
Glazblog */

function langs_toggle(aAnchor)
{
  var parent = aAnchor.parentNode;
  var anchor = parent.firstChild;
  var allLangs = [];
  while (anchor)
  {
    // iterate all tabs
    if (anchor.nodeType == 1)
    {
      // a real element, not pcdata; let's clear class
      anchor.className = "";
      // and store its language
      allLangs.push( anchor.getAttribute("lang") );
    }
    // next...
    anchor = anchor.nextSibling;
  }

  // the tab that triggered the event handler becomes selected
  aAnchor.className = "selected";
  // what's the target language again ?
  var targetLang = aAnchor.getAttribute("lang");
  // find all tabpanels
  var tabpanel = parent.nextSibling;
  while (tabpanel)
  {
    if (tabpanel.nodeType == 1)
    {
      var l = tabpanel.getAttribute("lang");
      tabpanel.className = "langs_tabpanel";
      if (l == targetLang)
        tabpanel.className = "selected " + tabpanel.className;
    }
    tabpanel = tabpanel.nextSibling;
  }
}