$(document).ready(function () {
(function (global, undefined) {
    var toHide = true, tooltip1, tooltip2;

    function beginRequest(sender, args) {
        toHide = false;
        if (args.get_postBackElement().id.indexOf("Button1") > -1) {
            tooltip1.show();
        }
        else if (args.get_postBackElement().id.indexOf("Button2") > -1) {
            tooltip2.show();
        }
    }

    function endRequest(sender, args) {
        toHide = true;

        var tooltip = GetActiveToolTip();
        if (tooltip != null && tooltip.get_id().indexOf("RadToolTip1") > -1) {
            tooltip.hide();
        }
    }

    function GetActiveToolTip() {
        return Telerik.Web.UI.RadToolTip.getCurrent();
    }

    var telerikDemo = global.telerikDemo = {
        onClientBeforeHide: function (sender, args) {
            args.set_cancel(!toHide);
        },
        GetActiveToolTip: GetActiveToolTip
    };

    Sys.Application.add_load(function () {
        tooltip1 = $find(tooltip1ID);
        tooltip2 = $find(tooltip2ID);
    });

    var pageRequestManager = Sys.WebForms.PageRequestManager.getInstance();
    //Attach to event that will indicate when ajax request begins
    pageRequestManager.add_beginRequest(beginRequest);
    //Attach to event that will indicate when ajax request is complete
    pageRequestManager.add_endRequest(endRequest);
})(window);
});