﻿
$(document).ready(function () {



    window.onbeforeunload = closeit;

    function closeit() {
        var closeEvent = false;
        //    alert(event.clientY);
        if (event.clientY < 0)
            closeEvent = true;

        if ((closeEvent)) {
            //        alert("do you want to close the window");
            //your actions during closing comes here
            window.onbeforeunload = null;
            $.ajax({
                type: "POST",
                url: "table_of_content.aspx/LogOutAsyn",
                data: "{}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (msg) {
                    if (msg.d["Error"] == "") {
                        //                    alert("unload event detected!");
                        return false;

                    }
                }
            });
            return false;
        }
    }

});




