
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(onEndRequest);

function onEndRequest(sender, args) {
    var error = args.get_error();
    if (error != null) {
       // Set the error handled flag to avoid a runtime error
       // reaching the user.
       args.set_errorHandled(true);
    }
}

function sleep(milliseconds) {
    var now = new Date();
    var exitTime = now.getTime() + milliseconds;
    while (true) {
        now = new Date();
        if (now.getTime() > exitTime)
            return;
    }
}
