﻿        var _backgroundDiv;
       
        var test=1;
        var brs=-1;
        
        function Load(_updateProgressDiv,_table){         
            brs=navigator.userAgent.indexOf('Safari');            
            Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(beginRequest);
            Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequest);          
            if (document.getElementById("divDisabler") == null)
            {
                _backgroundDiv = document.createElement('div');
                _backgroundDiv.style.display = 'none';
                _backgroundDiv.style.zIndex = 10000;
                _backgroundDiv.className = 'backgroundDiv';
                _backgroundDiv.id = 'divDisabler';
                _table.parentNode.appendChild(_backgroundDiv); 
            }           
        }        
        
        function beginRequest(sender, args)
        {        
            if(test%2 == 1)
            {
                _updateProgressDiv.style.display = '';
                _backgroundDiv.style.display = '';
	            var tableBounds = Sys.UI.DomElement.getBounds(_table);
	            var updateProgressDivBounds = Sys.UI.DomElement.getBounds(_updateProgressDiv);
	            var x = tableBounds.x + Math.round(tableBounds.width / 2) - Math.round(updateProgressDivBounds.width / 2);    
                var y=document.documentElement.scrollTop;
                if(brs>0)
                {
                    y=document.body.scrollTop;
                }
                y=y+300;               
                _backgroundDiv.style.width = tableBounds.width + 'px';
                _backgroundDiv.style.height = tableBounds.height + 'px';
	            Sys.UI.DomElement.setLocation(_updateProgressDiv, x, y);  
	            Sys.UI.DomElement.setLocation(_backgroundDiv, tableBounds.x, tableBounds.y);	            
	            if(brs>0)
	            {
	                test=test+1;
	            }
	        }          
        }

        function endRequest(sender, args) {           
            _updateProgressDiv.style.display = 'none';
            _backgroundDiv.style.display = 'none';            
            if(brs>0)
            {
                if(test%2 == 1)test=0;else test=1;
            }
        }
