var HoveredTabMenu;
function ClickTabMenu (id) {
  //$(id).className = ($(id).className == 'tab' ? 'tab active' : 'tab');
  // Kijk of deze tab al "geopend" was. Zo ja, dan kunnen we direct door naar de link van de anchor.
  if (!ItsIE6 && ($(id).className == 'tab active' || HoveredTabMenu == id)) {
    return true;
    }
  else {
    $(id).className = 'tab active';
    return false;
    }
}

function HoverTabMenu (id) {
  clearTabMenus();
  if (ItsIE6) {
    $(id).className = 'tab active';
  }
  HoveredTabMenu = id;
}

//onclick outside dropdown menu  hide all
function containerClick(event) {
  var element = event.element();
  //element.addClassName('active');
  var debug = element.className;
  // Als het element of een parent er van "tab active" heeft, niets doen.
  var KeepAlive;
  while (element) {
    debug += " / " + element.className;
    if (element.className == "tab active") KeepAlive = element;
    element = element.parentNode;
    }
  //alert('clicked ' + debug);
  // Anders, alle tabs "tab" geven
  clearTabMenus(KeepAlive);
}

function clearTabMenus (KeepAlive) {
  var tabs = $$('.tab');
  for (var i = 0; i < tabs.length; i++) {
    if (!KeepAlive || KeepAlive !== tabs[i]) tabs[i].className = "tab";
    }
}

Event.observe(window, 'load', function() {
  Event.observe('container', 'click', containerClick);
});

/* Script TBV Home home page */

var CurrentShownBtn = '';
var IdArray = ['wezo','clienten','organisaties','ondernemers'];
var IdHash = {'wezo':0,'clienten':1,'organisaties':2,'ondernemers':3};

function HoverMainBtn (id) {
  // Alle andere clearen:
  if (id != 'wezo')                 HoutMainBtn('wezo');
  if (id != 'clienten')             HoutMainBtn('clienten');
  if (id != 'organisaties')         HoutMainBtn('organisaties');
  if (id != 'ondernemers')          HoutMainBtn('ondernemers');
  if (id != CurrentShownBtn) {
    $('main_button_' + id).className = id + "_active";
    //$('home_button_' + id).appear({duration:0.4,queue:'before'});//blindDown({duration:0.2});
    $('home_button_' + id).show();//blindDown({duration:0.1,queue:'before'});//blindDown({duration:0.2});
    SetSubTxtLogo(id);
    try {
      $("flashcontent").openItem(IdHash[id]);
      }
    catch (error) {
      // ...
      }
    CurrentShownBtn = id;
    }
}

function HoutMainBtn (id) {
  $('main_button_' + id).className = id;
  //$('home_button_' + id).fade({duration:0,queue:'after'});//blindUp({duration:0.2});hide();//
  $('home_button_' + id).hide();//blindUp({duration:0.1,queue:'after'});//blindUp({duration:0.2});hide();//
}
  
function SetSubTxtLogo (id) {
  $('subtxtlogo').className = "txt_" + id;
}
      
function CheckForm (frm) {
  var velden = ['naam','emailadres','adres','postcode','woonplaats','telefoon','geboortedatum','nationaliteit'];
  for (var i = 0; i < velden.length; i++) {
    if (frm[velden[i]].value == "") {
      alert("Wilt u a.u.b. alle velden volledig invullen?");
      return false;
      }
    }
  return true;
}
