
function Logout()
{
    var data = new FormData();
    data.append("request", "logout");
    $.ajax
    ({
        type: "POST",
        enctype: 'multipart/form-data',
        url: "../../controllers/logout.php",
        data: data,
        processData: false,
        contentType: false,
        cache: false,
        timeout: 600000,
        async: false,
        success: function (response) 
        {
            response    =   JSON.parse(response);
            if((response["R_URL"]))
            {
                window.location.href    =   response["R_URL"];
            }

        },
        error: function (e) 
        {
            console.log("ERROR : ", e);
        }
    });

}

function LoginCheck()
{
    var data = new FormData();
    data.append("request", "login_check");
    $.ajax
    ({
        type: "POST",
        enctype: 'multipart/form-data',
        url: "../../controllers/login_check.php",
        data: data,
        processData: false,
        contentType: false,
        cache: false,
        timeout: 600000,
        async: false,
        success: function (response) 
        {
            response    =   JSON.parse(response);
            if((response["error"] == false))
            {
                if((response["sidebar"]))
                {
                    $("#SideMenu").html(response["sidebar"]);
                }
                
                if((response["topbar"]))
                {
                    $("#Topbar").html(response["topbar"]);
                }

                $(".logout").on("click", function()
                {
                    Logout();
                });
            }

        },
        error: function (e) 
        {
            $("#result").text(e.responseText);
            console.log("ERROR : ", e);
            $("#btnSubmit").prop("disabled", false);
        }
    });
}



$(document).ready(function()
{


    

    LoginCheck();




    

});