function getElementById(id) {
  if (document.all)
    return document.all[id];
  return document.getElementById(id);
}

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function'){
    window.onload = func;
  } else {
    window.onload = function(){
      oldonload();
      func();
    }
  }
}


var actualevent = false;
var actualanchor = false;
function calendar_init() {
  var hash = '';
  document_title = document.title;
  if (location.hash && location.hash != '')
    hash = location.hash.substr(1);
  var allanchors = document.getElementsByTagName('a');
//  var alldivs = document.getElementsByTagName('div');
  if (allanchors) {
    for (i=0; i<allanchors.length; i++)
      if (allanchors[i].className && (allanchors[i].className=='calendar')) {
        if (allanchors[i].href.substr(allanchors[i].href.lastIndexOf('#')+1) != hash) {
//					 alert('calendar_'+allanchors[i].href.substr(allanchors[i].href.lastIndexOf('#')+1));
           getElementById('calendar_'+allanchors[i].href.substr(allanchors[i].href.lastIndexOf('#')+1)).style.display='none';
        } else {
          actualevent = getElementById('_'+hash);
          actualanchor = allanchors[i];
          actualanchor.className = 'tabbermenu_active';
//          document.title = actualanchor.innerHTML + ' - ' + document_title;
        }
        allanchors[i].onclick = function () {
//          alert(actualanchor.href);
          if (actualanchor)
            actualanchor.className = 'calendar';
          actualanchor = this;
          actualanchor.className = 'calendar current'
          if (actualevent)
            actualevent.style.display='none';
          actualevent = getElementById('calendar_'+this.href.substr(this.href.lastIndexOf('#')+1));
          actualevent.style.display = 'block';
//          document.title = actualanchor.innerHTML + ' - ' + document_title;
//					document.location = this.href;
          return false;
        }
      }
  }
  if (hash != '') {
//    document.location = document.location;
  }
}

addLoadEvent(calendar_init);

