
function position_update( t )
{
    var q = t.popup.style;
    var x = 0;
    var y = 0; // t.offsetHeight;
    while (t)
    {
	x += t.offsetLeft;
	y += t.offsetTop;
	t = t.offsetParent;
    }
    q.left = x + 'px';
    q.top  = y + 'px';
}

function show_popup() {
    var q = this.popup.style;
    if ( q.visibility != 'visible' )
    {
	position_update( this );
        q.visibility = 'visible';
    } 
    else 
    {
	q.visibility = 'hidden';
    }
}

function popup_init() 
{
    var i, j, e, t, p;
    e = document.getElementsByTagName('DIV');
    for (i = 0; e.length > i; i++)
    {
	t = e[i];
	if (t.className == 'popup')
	{
	    for (j = 0; t.childNodes.length > j; j++)
	    {
		p = t.childNodes[j];
		if (p.className == 'popup_data')
		{
		    t.onclick = show_popup;
		    t.popup = p;
		    break;
		}
	    }
	}
    }
}
