
Sys.Application.add_load(application_Load);
var isAjaxMsgShowed = false;
var ajaxMsgTimer = 0;

function application_Load() {
    var prmInstance = Sys.WebForms.PageRequestManager.getInstance();
    prmInstance.add_beginRequest(onBeginAjaxRequest);
    prmInstance.add_endRequest(onEndAjaxRequest);
}

function onBeginAjaxRequest() {
    if (isAjaxMsgShowed) {
        if (ajaxMsgTimer != 0) window.clearTimeout(ajaxMsgTimer);
        ajaxMsgTimer = 0;
    } else {
    var dd = document.getElementById('ajax-message');
        var ps = getScrollXY();
        var sz = getInnerSize();
        dd.style.top = (ps[1] + (sz[1] / 2) - 20) + "px";
        var lf = (ps[0] + (sz[0] / 2) - 100);
        if (!document.all) lf -= 20;
        dd.style.left = lf + "px";
        dd.style.display = 'block';
        isAjaxMsgShowed = true;
    }
}

function onEndAjaxRequest() {
    ajaxMsgTimer = window.setTimeout('doHideMsgAjax()', 500);
}

function doHideMsgAjax() {
	var dd = document.getElementById('ajax-message');
    if (dd != null) dd.style.display = 'none';
    isAjaxMsgShowed = false;
}
