    function setOpacity(opacity)
    {
        var pageSize = getPageSize();
       
        initialize();

        var objOverlay = document.getElementById("overlay").style;
       
        objOverlay.height = pageSize[1] + "px";
        objOverlay.display = '';
       
        objOverlay.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=" + opacity + ")";
        objOverlay.opacity = opacity / 100;
        objOverlay.MozOpacity = opacity / 100;
        objOverlay.KhtmlOpacity = opacity / 100;
       
        return true;
    }

    function initialize()
    {
        var objBody = document.getElementsByTagName("body");
        var objBody = objBody[0];   
        if (document.getElementById('overlay')) {
            objBody.removeChild(document.getElementById("overlay"));
        }
        var objOverlay = document.createElement("div");
            objOverlay.setAttribute('id','overlay');
            objOverlay.style.display = 'none';
            objBody.appendChild(objOverlay);
           
        return true;
    }

    function end()
    {
        var objBody = document.getElementsByTagName("body");
        var objBody = objBody[0];   
        if (document.getElementById('overlay')) {
            objBody.removeChild(document.getElementById("overlay"));
        }
    }

    function getPageSize() {   
        var xScroll, yScroll, windowWidth, windowHeight;
        if (window.innerHeight && window.scrollMaxY) {
            xScroll = document.scrollWidth;
            yScroll = (document.isFrame ? parent.innerHeight : self.innerHeight) + (document.isFrame ? parent.scrollMaxY : self.scrollMaxY);
        } else if (document.body.scrollHeight > document.body.offsetHeight){
            xScroll = document.body.scrollWidth;
            yScroll = document.body.scrollHeight;
        } else {
            xScroll = document.getElementsByTagName("html").item(0).offsetWidth;
            yScroll = document.getElementsByTagName("html").item(0).offsetHeight;
            xScroll = (xScroll < document.body.offsetWidth) ? document.body.offsetWidth : xScroll;
            yScroll = (yScroll < document.body.offsetHeight) ? document.body.offsetHeight : yScroll;
        }
        if (self.innerHeight) {
            windowWidth = (this.isFrame) ? parent.innerWidth : self.innerWidth;
            windowHeight = (this.isFrame) ? parent.innerHeight : self.innerHeight;
        } else if (document.documentElement && document.documentElement.clientHeight) {
            windowWidth = document.documentElement.clientWidth;
            windowHeight = document.documentElement.clientHeight;
        } else if (document.body) {
            windowWidth = document.getElementsByTagName("html").item(0).clientWidth;
            windowHeight = document.getElementsByTagName("html").item(0).clientHeight;
            windowWidth = (windowWidth == 0) ? document.body.clientWidth : windowWidth;
            windowHeight = (windowHeight == 0) ? document.body.clientHeight : windowHeight;
        }
        var pageHeight = (yScroll < windowHeight) ? windowHeight : yScroll;
        var pageWidth = (xScroll < windowWidth) ? windowWidth : xScroll;
        return new Array(pageWidth, pageHeight, windowWidth, windowHeight);
    };
