var bSeitenPfadAbsolut = "http://www.bibelpraxis.de/";   /* muss mit Slash ("/") enden */
var ttbMX = 0;
var ttbMY = 0;
var ttb_a = null;
var ttb_read = null;
var ttb_ref = null;
var ttb_vis = false;
var ttb_newcount = "";

/* Bibel-Popup */
function showbible(bible_ref) {
  window_bible = window.open(bSeitenPfadAbsolut+"biblepopup.php?ref=" + bible_ref ,"window_bible", "width=300,height=450,left=0,right=0,resizable=yes,scrollbars=yes,status=no,location=no,menubar=no,toolbar=no,");
  if (window.window_bible) {
    window.window_bible.focus();
  }
}
function showbibleN(bible_ref) {
  window_bible = window.open(bSeitenPfadAbsolut+"biblepopup.php?ref="+bible_ref+"&count=new","window_bible", "width=300,height=450,left=0,right=0,resizable=yes,scrollbars=yes,status=no,location=no,menubar=no,toolbar=no,");
  if (window.window_bible) {
    window.window_bible.focus();
  }
}

/* Bibel-Tooltips */
function ttb_createElements(bible_ref) {
  if(!document.getElementById('ttb_loadtext')) {
    ttb_a = document.createElement("div");
    ttb_a.id = "ttb_loadtext";
    ttb_a.style.position = "absolute";
    ttb_a.top = "0px";
    ttb_a.left = "0px";
    ttb_a.visibility = "hidden";
    ttb_a.display = "none";
    ttb_a.className = "ttb_loaddiv";
    document.body.appendChild(ttb_a);
  }
  if(!document.getElementById('ttb_ref')) {
    ttb_ref = document.createElement("div");
    ttb_ref.id = "ttb_ref";
    ttb_ref.style.position = "absolute";
    ttb_ref.style.top = "0px";
    ttb_ref.style.left = "0px";
    ttb_ref.style.visibility = "hidden";
    ttb_ref.style.display = "none";
    document.body.appendChild(ttb_ref);
  }
  if(!document.getElementById('ttb_read')) {
	ttb_read = document.createElement("iframe");
    ttb_read.id = 'ttb_read';
    ttb_read.style.position = "absolute";
    ttb_read.style.border = "1px solid #000000";
    ttb_read.style.visibility = "hidden";
    ttb_read.style.display = "none";
    ttb_read.src = bSeitenPfadAbsolut+'bibletooltip.php?&ref='+bible_ref+ttb_newcount;
	document.body.appendChild(ttb_read);
  }
}

function ttBibleShow(bible_ref) {
  
  ttb_newcount = "";
  if(!ttb_a || !ttb_read || !ttb_ref) ttb_createElements(bible_ref);
  
  if(!ttb_vis) {
	ttb_a.innerHTML = '<span class="ttb_loadtext">[Bibeltext wird geladen...]</span>';
    ttb_a.style.visibility = "";
    ttb_a.style.display = "";
	ttb_read.style.height = "50px";
    ttb_read.style.width = "400px";
    ttb_ref.innerHTML = bible_ref;
	ttb_read.src = bSeitenPfadAbsolut+'bibletooltip.php?&ref='+bible_ref;
    ttb_vis = true;
	document.onmousemove = ttbMouseMove;
  }
  
}

function ttBibleShowN(bible_ref) {
  
  ttb_newcount = "&count=new";
  if(!ttb_a || !ttb_read || !ttb_ref) ttb_createElements(bible_ref);
  
  if(!ttb_vis) {
	ttb_a.innerHTML = '<span class="ttb_loadtext">[Bibeltext wird geladen...]</span>';
    ttb_a.style.visibility = "";
    ttb_a.style.display = "";
	ttb_read.style.height = "50px";
    ttb_read.style.width = "400px";
    ttb_ref.innerHTML = bible_ref;
	ttb_read.src = bSeitenPfadAbsolut+'bibletooltip.php?&ref='+bible_ref+ttb_newcount;
    ttb_vis = true;
	document.onmousemove = ttbMouseMove;
  }
  
}

function ttBibleHide() {
  if(ttb_vis) {
	ttb_read.style.visibility = "hidden";
	ttb_read.style.display = "none";
	ttb_a.style.visibility = "hidden";
	ttb_a.style.display = "none";
	ttb_read.style.top = "-1000px";
	ttb_read.style.left = "0px";
	ttb_vis = false;
  }
  document.onmousemove = null;
}

function ttbSetPos() {
  wt = ttb_read.style.width;
  wt = wt.substr(0, wt.length-2);
  w = parseInt(wt);
  var a = 15;
  var b = w / 2;
  var nX = 0;
  var nY = 0;
  if(window.Event) { // Netscape
    nY = ttbMY+a;
    nX = ttbMX-b;
    aX = 0;
  } else { // Internet Explorer
    nY = ttbMY + document.body.scrollTop + a;
    nX = ttbMX + document.body.scrollLeft - b;
    aX = 40;
  }
  if((nX+w+aX)>document.body.offsetWidth) nX = document.body.offsetWidth - w - aX;
  if(nX<20) nX = 20;
  ttb_read.style.top = nY;
  ttb_read.style.left = nX;
  ttb_a.style.top = nY;
  ttb_a.style.left = nX;
}

function ttbMouseMove(e) {
  if(window.Event) { //Netscape
    ttbMX = e.pageX;
    ttbMY = e.pageY;
  } else { // Internet Explorer
    ttbMX = window.event.clientX;
    ttbMY = window.event.clientY;
  }
  if (ttb_read) ttbSetPos();
}