﻿$(document).ready(function() {
    //  IniLinks();

    //    $("a[id^='category_']").click(function() {
    //        var categoryID = $(this).attr("id").substring(9);

    //        $(this).attr("href", "/Details/Details?moduleType=1&categoryID=" + categoryID + "&type=1");
    //    });


    //    $("a[id^='case_']").click(function() {
    //        var categoryID = $(this).attr("id").substring(5);

    //        $(this).attr("href", "/Details/Details?moduleType=2&categoryID=" + categoryID + "&type=1");
    //    });

    $("a[id^='title_']").click(function() {
        var titleID = $(this).attr("id").substring(6);

        var categoryID = $(this).attr("class");

        $(this).attr("href", "/Details/DetailsbyTitle?moduleType=1&categoryID=" + categoryID + "&titleID=" + titleID);

    });

//    $("a[id^='title_']").each(function() {
//        $(this).click(function() {
//            var titleID = $(this).attr("id").substring(6);

//            var categoryID = $(this).attr("class");

//            $(this).attr("href", "/Details/DetailsbyTitle?moduleType=1&categoryID=" + categoryID + "&titleID=" + titleID);
//        });
//    });


    function IniLinks() {

        $.ajax({
            url: "/Index/GetAllLiks",
            type: 'POST',
            dataType: 'json',
            data: null,
            contentType: 'application/json; charset=utf-8',
            success: function(data) {

                while (data.indexOf("\r") >= 0) {
                    data = data.replace("\r", "\\r");
                    data = data.replace("\n", "\\n");

                }

                var json = eval('(' + data + ')');


                if (json.length > 0) {

                    for (var i = 0; i < json.length; i++) {

                        $("#linkTr").append("<td><a href=" + json[i].articleDetail + " target='_blank'><img  src=" + json[i].articleTitle + " class='i_link_margin'/></a></td>");

                    }




                }
            }
        });

    }


});


