﻿// Find both positions at once
function findBothPos(obj)
{
    var curleft = curtop =  0;
    if (obj.offsetParent)
    {
        curleft = obj.offsetLeft;
        curtop = obj.offsetTop;
        while (obj = obj.offsetParent)
        {
            curleft += obj.offsetLeft;
            curtop += obj.offsetTop;
        }
    }
    return [curleft, curtop];
}

// source : client ID of the control that causes the event
// target : client ID of the targer UpdateProgress Control to display

function positionDiv(source, target, condition)
{
    var s = document.getElementById(source);
    var pos = findBothPos(s);
    var t = document.getElementById(target);

    t.style.top = pos[1] + "px";
    t.style.left = pos[0] + "px";
    t.style.width = s.offsetWidth + "px";
    t.style.height = s.offsetHeight + "px";
    t.style.position = "absolute";
}