﻿

$(document).ready(function () {


//    $(".articleLink").click(function () {
//        var url = $(this).attr("lang");
//        window.open(url, '_blank');
//        return false;
//    });

//    $(".showFullText").click(function () {
//        var url = $(this).attr("lang");

//        //        if ($("." + url).is(":hidden")) {
//        $("." + url).show();
//        //        } else {
//        //            $("." + url).hide();
//        //        }

//        $(this).hide();
//        $("#hideFullText" + url).show();
//        return false;
//    });

//    $(".hideFullText").click(function () {
//        var url = $(this).attr("lang");

//        $("." + url).hide();
//        $(this).hide();
//        $("#showFullText" + url).show();
//        return false;
//    });




    $(".pdfLink").click(function () {

        var checkIfOpenAccess = $(this).attr("rel");
        var url = $(this).attr("lang");

        $.ajax({
            type: "POST",
            url: "table_of_content.aspx/CheckIfLoggedIn",
            data: "{ value : '" + checkIfOpenAccess + "' , file : '" + url + "'}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (msg) {
                // Do something interesting here.
                if (!msg.d["LoggedIn"] && msg.d["ValueBool"] == "false") {
                    $("#lblError").html(msg.d["Error"]);
                    $("#Errors").dialog('open');
                    return false;
                }
                else if (msg.d["ValueBool"] == "true")
                {
                    window.open(url, '_blank');
                }
                else {
                    window.open(url, '_blank');
                }
            }
        });
        return false;


    });

    $(function () {
        // a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
        $("#dialog:ui-dialog").dialog("destroy");

        $("#Errors").dialog({
            autoOpen: false,
            width: 540,
            modal: true
        });




    });



});


