this.LibScreen = function () {};
this.LibScreen.prototype.screen = this.document.getElementsByTagName('HEAD')[0].parentNode;

this.LibScreen.prototype.dim = function (element, zIndex, callback) {
    var parent = element || document.body,
        ovAttributes;
    element = element || document.getElementsByTagName('head')[0].parentNode;
    if (this.ov) {
        this.ov.remove('fade');
        this.ov = undefined;
    } else {
        ovAttributes = {
            setDim:function () {
                this.style.width = '1px';
                this.style.height = '1px';
                this.style.width = element.scrollWidth+'px';
                this.style.height = element.scrollHeight+'px';
            },
            style:{
                position:'absolute',
                top:0,
                left:0,
                background:'black',
                zIndex:zIndex || 65536
            },
            oncreate:function() {
                this.setDim();
                eventHandler.addEvent(window, 'resize', this.resizeListener = function () {
                    this.setDim();
                }.bindTo(this));
            },
            onremove:function () {
                eventHandler.removeEvent(window, 'resize', this.resizeListener);
            }
        };
        this.ov = renderer.createElement('div',ovAttributes);
        cssHandler.setOpacity(this.ov, 0);
        var c;
        eventHandler.addEvent(this.ov, 'fadeready', c = function () {
            if (callback) {
                callback();
            }
            var x = function () {
                this.removeCallback(c);
            }.call(this);
        }.bindTo(this));
        
        this.ov.renderIn(parent, 'fade', {"stopOpacity":{'in':0.7}});
    }
};
this.LibScreen.prototype.removeCallback = function (c) {
    eventHandler.removeEvent(this.ov, 'fadeready', c);
};
this.LibScreen.prototype.getScollSize = function () {
    return {"x":this.screen.scrollWidth,"y":this.screen.scrollHeight};
};
this.LibScreen.prototype.getOffsetSize = function () {
    return {"x":this.screen.offsetWidth,"y":this.screen.offsetHeight};
};
this.LibScreen.prototype.getClientSize = function () {
    return {"x":this.screen.clientWidth,"y":this.screen.clientHeight};
};
this.LibScreen.prototype.getScrollOffset = function () {
    var scrOfX = 0, scrOfY = 0;
    if (typeof window.pageYOffset == "number") {
        scrOfY = window.pageYOffset;
        scrOfX = window.pageXOffset;
    } else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
        scrOfY = document.body.scrollTop;
        scrOfX = document.body.scrollLeft;
    } else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
        scrOfY = document.documentElement.scrollTop;
        scrOfX = document.documentElement.scrollLeft;
    }
    return {"x":scrOfX,"y":scrOfY};
};
this.libScreen = new this.LibScreen();