﻿/// <reference name="MicrosoftAjax.js"/>
function BindFunctionsOnAjaxRequest(beginRequestFunc, endRequestFunc) {
    var prm = Sys.WebForms.PageRequestManager.getInstance();
    
    if (beginRequestFunc != null)
        prm.add_beginRequest(beginRequestFunc);
    if (endRequestFunc != null)
        prm.add_endRequest(endRequestFunc);
}

function BindAsyncTriggersOnProgress(triggerControlIds, progressControlId) {
    function __beginRequest(sender, args) {
        prm._scrollPosition = null;
        var found = false;
        for (var i = 0; !found && i < triggerControlIds.length; i++) {
            if (args.get_postBackElement().id == triggerControlIds[i]) {
                $("#" + progressControlId).show();
                found = true;
            }
        }
    }

    // Don't get it to work to use BindFunctionsOnAjaxRequest... 
    // Maybe because we use the data passed and its lost when the function is called?
    var prm = Sys.WebForms.PageRequestManager.getInstance();
    prm.add_beginRequest(__beginRequest);


}
