﻿// Get a reference to the PageRequestManager.
var _prm = Sys.WebForms.PageRequestManager.getInstance();
var _origin = null;

// Using that prm reference, hook _initializeRequest
// and _endRequest, to run our code at the begin and end
// of any async postbacks that occur.
_prm.add_initializeRequest(InitializeRequest);
_prm.add_endRequest(EndRequest);

function InitializeRequest(sender, args) 
{
  // Change the Container div's CSS class to .Progress.
  //$get('_pageRequestWait').style.display = 'block';
  
  // Save an object reference to the button that caused the postback
  _origin = document.getElementById(args._postBackElement.id)
  // Disable that button.
  _origin.disabled = true;
  
  var prw = document.getElementById("_pageRequestWait");
  modalPopup("_pageRequestWait", null, null, null, null, "inline");
 
}

function EndRequest(sender, args) 
{
  // Check the Container div's class back to .Normal.
  //$get('Container').className = 'Normal';
  
  modalPopup();
  
  // Re-enable the button.
  _origin.disabled = false;
}

