var qn = null;
var qn_cur = "";
var qn_ininput = false;

var QNinL = false;
var QNinD = false;

function inQNLink(L) {
  //alert(qn_cur);
  if(qn_cur && qn_cur!=L) {
    hideQN(qn_cur);
  }
  QNinL = true;
  qn_cur = L;
  showQN(L);
}
function outQNLink(L) {
  QNinL = false;
  window.setTimeout("QNcheckMouse('"+L+"')", 333);
}
function inQN(L) {
  QNinD = true;
}
function outQN(L) {
  QNinD = false;
  window.setTimeout("QNcheckMouse('"+L+"')", 333);
}
function inQNInput(L) {
  qn_ininput = true;
}
function outQNInput(L) {
  qn_ininput = false;
//  alert(qn_ininput);
  window.setTimeout("QNcheckMouse('"+L+"')", 333);
}
function QNcheckMouse(L) {
  //if(qn_ininput==true) alert(qn_ininput);
  if(!qn_ininput==true) {
    if(qn_cur==L && !QNinL && !QNinD) hideQN(L);
  }
}

function showQN(L) {

  qn = window.document.getElementById('qn_'+L);
  qnt = window.document.getElementById('qnLink_'+L);
  
  // Hintergrundfarbe des Links ändern
  qnt.style.backgroundColor = "#752629";
  
  // Positionen bestimmen
  var t = 0;
  t = qnt.offsetTop;
  t += qnt.offsetParent.offsetTop;
  t += qnt.offsetParent.offsetParent.offsetTop;
  t += qnt.offsetParent.offsetParent.offsetParent.offsetTop;
  t += qnt.offsetParent.offsetParent.offsetParent.offsetParent.offsetTop;
  t += qnt.offsetParent.offsetParent.offsetParent.offsetParent.offsetParent.offsetTop;
  t += qnt.offsetParent.offsetParent.offsetParent.offsetParent.offsetParent.offsetParent.offsetTop;
  t += qnt.offsetParent.offsetParent.offsetParent.offsetParent.offsetParent.offsetParent.offsetParent.offsetTop;

  var l = 0;
  l = qnt.offsetLeft;
  l += qnt.offsetParent.offsetLeft;
  l += qnt.offsetParent.offsetParent.offsetLeft;
  l += qnt.offsetParent.offsetParent.offsetParent.offsetLeft;
  l += qnt.offsetParent.offsetParent.offsetParent.offsetParent.offsetLeft;
  l += qnt.offsetParent.offsetParent.offsetParent.offsetParent.offsetParent.offsetLeft;
  l += qnt.offsetParent.offsetParent.offsetParent.offsetParent.offsetParent.offsetParent.offsetLeft;
  l += qnt.offsetParent.offsetParent.offsetParent.offsetParent.offsetParent.offsetParent.offsetParent.offsetLeft;
    
  // Positionen festlegen und anzeigen
  qn.style.position = "absolute";
  qn.style.display = "block";
  t = t + qnt.offsetHeight;
  if(L=='chapter') {
    l = l + (qnt.offsetWidth-qn.offsetWidth);
  }
  if(L=='book') {
    l = l + (document.getElementById('qnLink_chapter').offsetWidth-qn.offsetWidth)+qnt.offsetWidth+4;
  }
  if(document.all) l = l + 1;
  qn.style.top = t;
  qn.style.left = l;
  qn.style.visibility = "";

}

function hideQN(L) {

  // Hintergrundfarbe des Links zurücksetzen
  qn = window.document.getElementById('qnLink_'+L);
  qn.style.backgroundColor = "#4E689C";
  // Weblinks verstecken
  qn = window.document.getElementById('qn_'+L);
  qn.style.visibility = "hidden";
  qn.style.display = "none";

}
