///<reference name="MicrosoftAjax.js">
Sys.Application.add_load(ApplicationLoadHandler)
Sys.Application.add_init(Init);
var isPopupVisible;
var prm = null;
var rightTreescrollTop;
function Init(sender)
{
      prm = Sys.WebForms.PageRequestManager.getInstance();
      //Ensure EnablePartialRendering isn't false which will prevent
      //accessing an instance of the PageRequestManager
      if (prm)
      {
          if (!prm.get_isInAsyncPostBack())
          {
              prm.add_initializeRequest(InitRequest);
          }
      }
}
function InitRequest(sender,args)
{
      if (prm.get_isInAsyncPostBack()) { 
         //& args.get_postBackElement().id ==  'btnRefresh'        
         //alert(args.get_postBackElement().id);
         //Could abort current request by using:  prm.abortPostBack();   
         //Cancel most recent request so that previous request will complete 
         //and display
         args.set_cancel(true);
         //alert("A request is currently being processed.  Please wait.");
      }
}
function ApplicationLoadHandler(sender, args)
{
     Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(beginRequest);
     Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequest);     
}
function beginRequest(sender, args)
{    
    var divProgress = $get('divProgress');
    
    //Note: This variable is used in Document Center, to fade the folder on the right side
    // Reset the right side fade folder, this is done here since it was giving error if we put reset it in pageLoad
    fadeRightFolderElementID = null;
    fadeRightDocumentElementIDs = null;
    
    if(divProgress !=null && isPopupVisible != true)
    {
        divProgress.style.display = '';
    }
    
    // Maintain scroll position in Document Center Right Pop-up div
    var elem = document.getElementById('divRightTreeDiv');
    if(elem != null)
    {   
        rightTreescrollTop = elem.scrollTop;
    }
}
function endRequest(visString, msg)
{
    var divProgress = $get('divProgress');
    var divRequestInProgress = $get('divRequestInProgress');
    
    if(divProgress !=null)
    {
        divProgress.style.display = 'none';
    }
    if(divRequestInProgress !=null)
    {
        divRequestInProgress.style.display = 'none';
    }
    
    // Maintain scroll position in Document Center Right Pop-up div
    var elem = document.getElementById('divRightTreeDiv');
    if(elem != null)
    {
        elem.scrollTop = rightTreescrollTop;
    }
}
function IsRequestInProgress()
{    
    return prm.get_isInAsyncPostBack();
}
if(typeof(Sys) !== "undefined") Sys.Application.notifyScriptLoaded();

