function instant_footnotes() {
 var fnp=null;

 function hide_fn() {
     if (fnp != null) {
         fnp.parentNode.removeChild(fnp);
         fnp = null;
         return false;
     }
 }
 function show_fn(el, event) {
     if (fnp != null) {
         fnp.parentNode.removeChild(fnp);
         fnp = null;
         return false;
     }
     // create fnp node
     fnp = document.createElement('div');
     fnp.setAttribute('id','footnote-popup');
     fnp.style.top = (event.pageY + 20) + 'px';
     var fn=document.getElementsByName(el.getAttribute('href').substr(1))[0];
     // close button
     var closebtn=document.createElement('div');
     closebtn.setAttribute('id','footnote-popup-close');
     closebtn.innerHTML="<span>[Fenster schließen]</span>";
     closebtn.onclick=function (event) {
         hide_fn();
     }
     var fntext=document.createElement('div');
     fntext.setAttribute('id','footnote-popup-text');
     var num=document.createElement('div');
     num.setAttribute('class', 'fnnum');
     num.innerHTML=el.innerHTML;
     fntext.appendChild(num);
     var text=document.createElement('div');
     text.setAttribute('class', 'fntext');
     text.innerHTML = fn.nextSibling.nextSibling.innerHTML;
     fntext.appendChild(text);
     // insert footnote text
     fnp.appendChild(fntext);
     fnp.appendChild(closebtn);
     el.parentNode.appendChild(fnp);
 }

 var a=document.getElementsByTagName("a");
 for ( var i = 0, l = a.length; i < l; i++ ) {
     var aname=a[i].getAttribute('name')
     if (aname != null && aname.substr(0, 5) == 'fnanc') {
         a[i].onclick=function(event){show_fn(this, event); return false;};
     }
 }
}

window.onload=instant_footnotes;

