﻿var wait_timer1;
var wait_timer2;

function startWait() {
    var prm = Sys.WebForms.PageRequestManager.getInstance();
    prm.add_beginRequest(beginRequest);
    prm.add_endRequest(endRequest);
}

function beginRequest(sender, args) {
    var p = $find('pleaseWaitEE');
    
    p.set_BackgroundCssClass('pleaseWaitMBG1');
    p._backgroundElement.className = 'pleaseWaitMBG1';
    p._backgroundElement.style.zIndex = 2097151;
    p.show();
    p._popupElement.style.zIndex = 2097152;
    
    wait_timer1 = setTimeout('displayWait1()', 500);
    wait_timer2 = setTimeout('displayWait2()', 2000); 
}
function endRequest(sender, args) {
    clearTimeout(wait_timer1);
    clearTimeout(wait_timer2);    
    $find('pleaseWaitEE').hide();
    $get('imgWait').style.display = 'none';
}
function displayWait1() {
    $get('imgWait').style.display = 'block';
}
function displayWait2() {
    var p = $find('pleaseWaitEE'); 
    var zindex = p._backgroundElement.style.zIndex        
           
    p.set_BackgroundCssClass('pleaseWaitMBG2');
    p._backgroundElement.className = 'pleaseWaitMBG2';
    p._backgroundElement.style.zIndex = zindex;
}

if(typeof(Sys) !== "undefined") Sys.Application.notifyScriptLoaded();