
    var _backgroundElement = document.createElement("div");  

    function pageLoad()
    {

    // pageContent is the parent of the new DIV
        $get("content").appendChild(_backgroundElement);
        
    }

    function OnBeginRequest(sender, args) 
    {
        EnableUI(false);
    }

    function OnEndRequest(sender, args) 
    {
        EnableUI(true);
    }

    function EnableUI(state) 
    {
                       
        if (!state)
        {
     
            _backgroundElement.style.display = 'inline';
            /*_backgroundElement.style.position = 'fixed';
            _backgroundElement.style.left = '0px';
            _backgroundElement.style.top = '0px';*/
            _backgroundElement.className = "backgroundElement transparant";
            var clientBounds = this._getClientBounds();
            var clientWidth = clientBounds.width;
            var clientHeight = clientBounds.height;
            _backgroundElement.style.width = 
               Math.max(Math.max(document.documentElement.scrollWidth, 
               document.body.scrollWidth), clientWidth)+'px';
            _backgroundElement.style.height = 
               Math.max(Math.max(document.documentElement.scrollHeight, 
               document.body.scrollHeight), clientHeight)+'px';
            /*_backgroundElement.style.zIndex = 10000;
            _backgroundElement.style.background = "#AAAAAA";
            _backgroundElement.style.filter = "alpha(opacity=70)";
            _backgroundElement.style.opacity = "0.7";*/

        }
        else
        {
            _backgroundElement.style.display = 'none';
        }
    }

    function _getClientBounds() 
    {
        var clientWidth;
        var clientHeight;
        switch(Sys.Browser.agent) {
            case Sys.Browser.InternetExplorer:
                clientWidth = document.documentElement.clientWidth;
                clientHeight = document.documentElement.clientHeight;
                break;
            case Sys.Browser.Safari:
                clientWidth = window.innerWidth;
                clientHeight = window.innerHeight;
                break;
            case Sys.Browser.Opera:
                clientWidth = Math.min(window.innerWidth, 
                              document.body.clientWidth);
                clientHeight = Math.min(window.innerHeight, 
                               document.body.clientHeight);
                break;
            default:  // Sys.Browser.Firefox, etc.
                clientWidth = Math.min(window.innerWidth, 
                              document.documentElement.clientWidth);
                clientHeight = Math.min(window.innerHeight, 
                               document.documentElement.clientHeight);
                break;
        }
        return new Sys.UI.Bounds(0, 0, clientWidth, clientHeight);
    }    

