var Window = {
    /* gets offset from the top of the viewable area */
    getScrollTop : function(target) {
        target = target || window;
        if (target.document || target.contentDocument) {
            _window = target;
            _document = _window.contentDocument || _window.document;
            target = null;
        }
        if (target) {
            return target.scrollTop;
        } else if (_document.documentElement && _document.documentElement.scrollTop) {
            return _document.documentElement.scrollTop;
        } else if (_document.body && _document.body.scrollTop) {
            return _document.body.scrollTop;
        } else if (_window.pageYOffset) {
            return _window.pageYOffset;
        } else if (_window.scrollY) {
            return _window.scrollY;
        }
        return 0;
    },

    setScrollTop : function(target, amount) {
        target = target || window;
        if (target.document || target.contentDocument) {
            _window = target;
            _document = _window.contentDocument || _window.document;
            target = null;
        }
        if (target) {
            target.scrollTop += amount;
        } else if (_document.body && _document.body.scrollTop != undefined) {
            _document.body.scrollTop += amount;
        } else if (_document.documentElement && _document.documentElement.scrollTop != undefined) {
            _document.documentElement.scrollTop += amount;
        } else if (_window.pageYOffset != undefined) {
            _window.pageYOffset += amount;
        } else if (_window.scrollY != undefined) {
            _window.scrollY += amount;
        }
        return 0;
    },

    /* gets offset from the left of the viewable area */
    getScrollLeft: function() {
        if (document.documentElement && document.documentElement.scrollLeft) {
            return document.documentElement.scrollLeft;
        } else if (document.body && document.body.scrollLeft) {
            return document.body.scrollLeft;
        } else if (window.pageXOffset) {
            return window.pageXOffset;
        } else if (window.scrollX) {
            return window.scrollX;
        }
        return 0;
    },

    /* gets the width of the whole page */
    getPageWidth: function() {
        return document.documentElement.scrollWidth;
    },

    /* gets the height of the whole page */
    getPageHeight: function(target) {
        target = target || window;
        if (target.document || target.contentDocument) {
            _window = target;
            _document = _window.contentDocument || _window.document;
        }
        return _document.scrollHeight || _document.body.scrollHeight;
    },

    /* gets the width of the viewalbe area on the clients computer */
    getClientWidth: function() {
        if (self.innerWidth) {
            return parseFloat(self.innerWidth);
        } else if (document.documentElement && document.documentElement.clientWidth) {
            return parseFloat(document.documentElement.clientWidth);
        } else if (document.body) {
            return parseFloat(document.body.clientWidth);
        }
        return 0.0;
    },

    /* gets the height of the viewalbe area on the clients computer */
    getClientHeight: function() {
        if (self.innerHeight) {
            return parseFloat(self.innerHeight);
        } else if (document.documentElement && document.documentElement.clientHeight) {
            return parseFloat(document.documentElement.clientHeight);
        } else if (document.body) {
            return parseFloat(document.body.clientHeight);
        }
        return 0.0;
    },

    /* gets the number of pixels from the left side of a page for an element */
    getX: function(element) {
        var x = 0;
        if (element.offsetParent) {
            while (element.offsetParent) {
                x += element.offsetLeft
                element = element.offsetParent;
            }
        } else if (element.x) {
            x += element.x;
        }
        return x;
    },

    /* gets the number of pixels from the top of a page for an element */
    getY: function(element) {
        var y = 0;

        if (element.offsetParent) {
            while (element.offsetParent) {
                y += element.offsetTop
                element = element.offsetParent;
            }
        } else if (element.y) {
            y += element.y;
        }
        return y;
    },

    refresh: function() {
        window.location = window.location;
    }
}