
var DHTML = 0, DOM = 0, MS = 0, NS = 0, OP = 0;

if (window.opera) {
	OP = 1;
}
if(document.getElementById) {
	DHTML = 1;
	DOM = 1;
}
if(document.all && !OP) {
	DHTML = 1;
	MS = 1;
}
if(document.layers && !OP) {
	DHTML = 1;
	NS = 1;
}

var ib, ibt, ibb, sp = 0.1;
var margintop = 4.0;
var marginbottom = 8.0;

function updateInfoBox()
{
	h = ib.offsetHeight;
	st = document.body.scrollTop;
	sb = st + document.body.scrollHeight;
	pt = st - h;
	pb = sb;
	p0 = parseInt(ib.style.top);
	if(typeof(p0) == "undefined" || typeof(p0) == "string" || isNaN(p0)) p0 = 0;
	if (p0 < pt) p0 = pt;
	if (p0 > pb) p0 = pb;
	t0 = ibt.offsetTop;
	p1 = Math.max(t0, st + margintop);
	p1 = Math.min(p1, ibb.offsetTop - h - marginbottom);

	if (p1 != p0) {
		pd = p1 - p0;
		pn = p0 + sp * pd;
		if (p0 < t0) pn = t0;
		ib.style.top = pn;
	}

//	ib.innerText = "p0:" + p0 + " p1:" + p1 + " pn:" + pn;
//	ib.innerText = p1 + "<"  + (ibt.offsetTop + margintop) + "||" + p1 + ">" + (ibb.offsetTop - h - marginbottom);

//	m = h + marginbottom + margintop;
//	hide = (st > (ibb.offsetTop - m)) ||
//		(sb < (ibt.offsetTop + m));

//	hide = (p0 < (ibt.offsetTop));
//	ib.style.visibility = hide ? 'hidden' : 'visible';
	
	window.setTimeout('updateInfoBox();', 50);
}

function initInfoBox()
{
	if (!document) return;
	if (!document.getElementById) return;
	ib = document.getElementById('infobox');
	if (!ib) return;
	ibt = document.getElementById('infoboxtop');
	if (!ibt) return;
	ibb = document.getElementById('infoboxbottom');
	if (!ibb) return;
	ibt.style.position = 'absolute';
	ibb.style.position = 'absolute';
	d = ibb.offsetTop - ibt.offsetTop;
	if (d < 2*ib.offsetHeight) return;
	
	ib.style.position = 'absolute';
	updateInfoBox();
}

if (1 || MS) {
	window.setTimeout('initInfoBox();', 2000);
}

