// universal function to obtain the object where the occured event took place
thePassword = 'unset';

function eventObj(e) {
  var targ;
  if (!e) var e = window.event;
  if (e.target) targ = e.target;
  else if (e.srcElement) targ = e.srcElement; // for IE
  if (targ.nodeType == 3) targ = targ.parentNode; // fix for safari bug
  return targ;
}

function showGBForm() {
  var theForm = document.getElementById('gbformid');
  if (theForm.style.display == 'none') {
    theForm.style.display = 'block';
  }
  else {
    theForm.style.display = 'none';
  }
  return false;
}

function deleteGBEntry(e) {
  var confirmed = confirm('Weet je zeker dat je dit bericht wilt verwijderen?');
  if (confirmed) {
    var theForm = document.getElementById('gb-del');
    var theEntry = eventObj(e).parentNode.getAttribute('title');
    theForm.getElementsByTagName('input')[0].value = theEntry;
    theForm.getElementsByTagName('input')[1].value = thePassword;
    theForm.submit();
  }

}

function enableGBAdmin() {
  var theBook = document.getElementById('gastenboekv2');
  thePassword = prompt("Wachtwoord:", "");


  var theEntries = theBook.getElementsByTagName('dt');

  for (var i = 0; i < theEntries.length; i++) {
    theEntries[i].style.color = 'red';
    theEntries[i].onclick = deleteGBEntry;
  }

  return false;
}