﻿// JScript File

    function onUpdating(){
        // get the update progress div
        var updateProgressDiv = $get('updateProgressDiv'); 
        // make it visible
        updateProgressDiv.style.display = '';

        //  get the gridview element        
        var gridView = $get('tbbe');
        
        // get the bounds of both the gridview and the progress div
	    var gridViewBounds = Sys.UI.DomElement.getBounds(gridView);
	    
        updateProgressDiv.style.width =Math.round(gridViewBounds.width) + 'px';
        updateProgressDiv.style.height = Math.round(gridViewBounds.height) + 'px';
        
	    var updateProgressDivBounds = Sys.UI.DomElement.getBounds(updateProgressDiv);
        
	    //	do the math to figure out where to position the element (the center of the gridview)
	    var x = gridViewBounds.x + Math.round(gridViewBounds.width / 2) - Math.round(updateProgressDivBounds.width / 2);
	    var y = gridViewBounds.y + Math.round(gridViewBounds.height / 2) - Math.round(updateProgressDivBounds.height / 2);
        
	    //	set the progress element to this position
	    Sys.UI.DomElement.setLocation (updateProgressDiv, x, y);
    }

    function onUpdated() {
        // get the update progress div
        var updateProgressDiv = $get('updateProgressDiv'); 
        // make it invisible
        updateProgressDiv.style.display = 'none';
    }
    
    function onAbort(){
        if(Sys.WebForms.PageRequestManager.getInstance().get_isInAsyncPostBack()){
            //  abort the postback
            Sys.WebForms.PageRequestManager.getInstance().abortPostBack();
            //  get the reference to the animation for the gridview
            var gvCustomersAnimation = $find('animation');
            //  simulate stopping by replaying the animation
            gvCustomersAnimation._postBackPending = false;
            gvCustomersAnimation.get_OnUpdatingBehavior().quit();
            gvCustomersAnimation.get_OnUpdatedBehavior().play();
        }
    }
