﻿function AbsPosition(obj) {
    var x = y = 0;
    while (obj) {
        x += obj.offsetLeft;
        y += obj.offsetTop;
        obj = obj.offsetParent;
    }
    return { x: x, y: y };
}

function getScrollY() {
    scrollY = 0;
    if (typeof window.pageYOffset == "number") {
        scrollY = window.pageYOffset;
    } else if (document.documentElement && document.documentElement.scrollTop) {
        scrollY = document.documentElement.scrollTop;
    } else if (document.body && document.body.scrollTop) {
        scrollY = document.body.scrollTop;
    } else if (window.scrollY) {
        scrollY = window.scrollY;
    }
    return scrollY;
}

function SetElementCenterPosition(elId) {
    var elObj = document.getElementById(elId);
    if (elObj != null) {
        var PointX = Math.round((document.body.clientWidth / 2) - (elObj.clientWidth * 2));
        var PointY = Math.round((document.body.clientHeight / 2) - (elObj.clientHeight * 2));

        elObj.style.position = "absolute";
        elObj.style.left = PointX + "px";
        elObj.style.top = PointY + "px";
        elObj.style.zIndex = "10";
    }
}
