function addOnloadEvent(fnc) {
    var hasSys = true;
    try
    {
       Sys.Application.add_load(fnc);
       return;
    }
    catch(e)
    {
        hasSys = false;
    }
       
    if (typeof window.addEventListener != "undefined")
        window.addEventListener("load", fnc, false);
    else if (typeof window.attachEvent != "undefined") {
        window.attachEvent("onload", fnc);
    }
    else {
        if (window.onload != null) {
            var oldOnload = window.onload;
            window.onload = function(e) {
                oldOnload(e);
                window[fnc]();
            };
        }
        else
            window.onload = fnc;
    }
}

var PS;
addOnloadEvent(function() { PS = new PayScale(); });

//internal documentation located at http://wiki/JavascriptArchitecture
function PayScale() {
    this.toString = function() { return 'PayScale object';}

    this.findElement = function(elementOrId, levels) {
        var elem = elementOrId;
        var result = new PayScaleDOMElement();
        if (typeof (elementOrId) == "string") {
            elem = document.getElementById(elementOrId);
        }
        if (elem) {
            result.initialize(elem);
            var o = elem;
            if (o.offsetParent) {

                while (o) {
                    if (levels && levels-- > 0)
                        break;
                    result.x += o.offsetLeft;
                    result.y += o.offsetTop;
                    o = o.offsetParent;
                }
            }
            else if (o.x) {
                result.x = o.x;
                result.y = o.y;
            }
        }
        if (result.element)
            return result;
        else
            return null;
    }
}

function PayScaleDOMElement() {
    this.initialize = function(elem) {
        this.element = elem;
        this.x = 0;
        this.y = 0;
    }
    var x;
    var y;
    var element;
    this.setRelativePosition = function(relativeToId, offsetX, offsetY) {
        var positionto = PS.findElement(relativeToId);
        if (positionto) {
            this.element.style.top = (+positionto.element.offsetHeight + positionto.y + offsetY) + 'px';
            this.element.style.left = (positionto.x + offsetX) + 'px';
        }
    }
}function addOnloadEvent(fnc) {
    var hasSys = true;
    try
    {
       Sys.Application.add_load(fnc);
       return;
    }
    catch(e)
    {
        hasSys = false;
    }
       
    if (typeof window.addEventListener != "undefined")
        window.addEventListener("load", fnc, false);
    else if (typeof window.attachEvent != "undefined") {
        window.attachEvent("onload", fnc);
    }
    else {
        if (window.onload != null) {
            var oldOnload = window.onload;
            window.onload = function(e) {
                oldOnload(e);
                window[fnc]();
            };
        }
        else
            window.onload = fnc;
    }
}

var PS;
addOnloadEvent(function() { PS = new PayScale(); });

//internal documentation located at http://wiki/JavascriptArchitecture
function PayScale() {
    this.toString = function() { return 'PayScale object';}

    this.findElement = function(elementOrId, levels) {
        var elem = elementOrId;
        var result = new PayScaleDOMElement();
        if (typeof (elementOrId) == "string") {
            elem = document.getElementById(elementOrId);
        }
        if (elem) {
            result.initialize(elem);
            var o = elem;
            if (o.offsetParent) {

                while (o) {
                    if (levels && levels-- > 0)
                        break;
                    result.x += o.offsetLeft;
                    result.y += o.offsetTop;
                    o = o.offsetParent;
                }
            }
            else if (o.x) {
                result.x = o.x;
                result.y = o.y;
            }
        }
        if (result.element)
            return result;
        else
            return null;
    }
}

function PayScaleDOMElement() {
    this.initialize = function(elem) {
        this.element = elem;
        this.x = 0;
        this.y = 0;
    }
    var x;
    var y;
    var element;
    this.setRelativePosition = function(relativeToId, offsetX, offsetY) {
        var positionto = PS.findElement(relativeToId);
        if (positionto) {
            this.element.style.top = (+positionto.element.offsetHeight + positionto.y + offsetY) + 'px';
            this.element.style.left = (positionto.x + offsetX) + 'px';
        }
    }
}