if (window.opera && !document.createTextNode) document.write('<style type="text/css">div.br {clear: left;}</style>');

function insertOpenTable() {
	return "<div class=\"footnote\">";
}

function insertCloseTable() {
	return "</div>";
}

function getElementPosition(offsetTrail){
	var offsetLeft = 0;
        var offsetTop = 0;
        while(offsetTrail) {
        	offsetLeft += offsetTrail.offsetLeft;
                offsetTop += offsetTrail.offsetTop;
                offsetTrail = offsetTrail.offsetParent;
        }
        return { left:offsetLeft, top:offsetTop }
}

function hideFootnotes() {
	var div = document.getElementById('current_footnote');
        div.className = 'footnote_new';
        div.style.display = 'none';
		div.innerHTML = "";
        return false;
}

function showFootnote(evt, id) {

 if (document.getElementById(id+"x")) {
  
  hideFootnotes();
 }
 else {
	var winWidth = document.body.clientWidth;
       var evt = evt || window.event;
       var o = evt.target || evt.srcElement;
       var div = document.getElementById('current_footnote');
       var coords = getElementPosition(o);
       div.innerHTML = '<a href="#" id="'+id+'x" onclick="return hideFootnotes()"><img src="/files/images/close.jpg" height="13" width="13" border="0" id="x_image" alt="Закрыть" style="font-size: 8px;" /></a><div style="float: right; width: 17px; height: 17px"></div><div style="padding: 7px">' + document.getElementById(id).innerHTML + '</div>';
       div.className = 'footnote_new_active';
       div = document.getElementById('current_footnote');
       var w = 200;
       div.style.top = (coords.top + o.offsetHeight) + 'px';
       if((winWidth - coords.left) < w) 
       		div.style.left = (coords.left  - 10 - (w - (winWidth - coords.left)))+ 'px';
       else
	       div.style.left = coords.left + 'px';
       div.style.display = 'none';
       div.style.display = 'block';
       evt.cancelBubble = true;
       return false;
	   }
}
