var LayerWindow = function(){
    var getViewPort = function(){
        var viewPortWidth;
        var viewPortHeight;
        var vYscroll;
        if (window.innerWidth) {
            viewPortWidth = window.innerWidth;
            viewPortHeight = window.innerHeight;
            vYscroll = window.pageYOffset;
        } else if (document.documentElement && document.documentElement.clientWidth) {
                viewPortWidth = document.documentElement.clientWidth;
                viewPortHeight = document.documentElement.clientHeight;
                vYscroll = document.documentElement.scrollTop;
            } else {
				var bodyTag = document.getElementsByTagName('body')[0];
                viewPortWidth = bodyTag.clientWidth;
                viewPortHeight = bodyTag.clientHeight;
                vYscroll = document.body.scrollTop;
            }
        return {
            w: viewPortWidth,
            h: viewPortHeight,
            yScroll: vYscroll
        };
    };
    
    return {
        open: function(id, options){
            var vp = getViewPort();
            if (document.getElementById(id)) {
                overlayer = document.getElementById(id);
                overlayer.style.width = options.w + 'px';
                overlayer.style.height = options.h + 'px';
                overlayer.style.top = (vp.yScroll + parseInt(vp.h / 2, 10) - parseInt(options.h / 2, 10)) + 'px';
                overlayer.style.left = (parseInt(vp.w / 2, 10) - parseInt(options.w / 2, 10)) + 'px';
                overlayer.style.display = 'block';
            }
            return false;
        },
		close: function(id) {
			document.getElementById(id).style.display = 'none';
		}
    };
}();

