function addEvent(elm, evType, fn, useCapture) {
  // cross-browser event handling for IE5+, NS6 and Mozilla
  // By Scott Andrew
  if (elm.addEventListener) {
    elm.addEventListener(evType, fn, useCapture);
    return true;
  } else if (elm.attachEvent) {
    var r = elm.attachEvent('on' + evType, fn);
    EventCache.add(elm, evType, fn);
    return r;
  } else {
    elm['on' + evType] = fn;
  }
}

addEvent(window, 'unload', EventCache.flush, false);

function init() {
  // Eventhandler für Javascript-Menu definieren
  setStyle(null, true)
}

addEvent(window, 'load', init, false);

function getClickFor(node) {
  return function(e) { mclick(e, node); };
}

function mclick(e, targetElement) {
  var el = window.event ? targetElement : e ? e.currentTarget : null;
  if (!el) return;
  setStyle(el, false)
}


function setStyle(currEl, withEvent)
{
  var tabContainer = document.getElementById('divTabs');
  if (!tabContainer) return
  var lis = tabContainer.getElementsByTagName('li');
  if (!lis) return
  for (var i = 0; i < lis.length; i++) {
    var li = lis[i]
    var a = lis[i].firstChild
    
    // Wenn currEl nicht übergeben -> 1. Element nehmen
    if(currEl == null && i == 0) currEl = a;
    
    var content = document.getElementById('divTabContent'+(i+1));
    //Titel ausblenden (wenn JS aktiviert)
    content.firstChild.style.display = 'none';
    //Content ein-/ausblenden
    content.style.display = (a.id == currEl.id ? 'block' : 'none');
	//Ausgewähltes Element hervorheben
    a.className = (a.id == currEl.id ? 'cTabSel' : 'cTab');
	
    if(withEvent) addEvent(a, 'click', getClickFor(a), false);
  }  

}
