﻿function showFrontPageNews() {

    var evalue = "";
    //var etype = 'ordered';
    var divToBeWorkedOn = '#Div_News';
    var webMethod = 'WebServices/FrontPage_News.asmx/GetFrontPage_News';
    //var parameters = "{'evalue':'" + evalue + "','etype':'" + etype + "'}";
    //var parameters = "{'newsType':'" + newsType + " '}";
    //alert('lkj');
    $.ajax({
        type: "POST",
        url: webMethod,
        //    data: parameters,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            //alert(msg.d);
            //alert('truetrue');
            var FrontPageNewsItems = msg.d;
            $.each(FrontPageNewsItems, function (idx, item) {
                var href = "/News/Pages/News.aspx?type=selected&id=" + item.NWS_id;
                var imageUrl = "";
                if (item.NWS_Image_Name.length == 0) {
                    imageUrl = "defaultnews.jpg";
                }
                else {
                    imageUrl = item.NWS_id + ".jpg";
                }
                //(item.NWS_Description.length > 150 ? item.NWS_Description = item.NWS_Description.substring(0, 150)+"..." : item.NWS_Description);
                try {//////////////////Section Down==Top_Left///////////////////////////////////
                    if (idx == 0) {

                        $("#TD_News_Title_Top_Left a").html(item.NWS_Title);
                        $("#TD_News_Title_Top_Left a").attr("href", href);
                        $("#TD_News_Date_Top_Left").html(item.PersianDateInfo);
                        $("#TD_News_Descrition_Top_Left").html(item.NWS_Description);
                        $("#img_FrontPage_News_Top_Left").attr("src", "/Images/News/" + imageUrl);

                    }
                }
                catch (e) {
                }

                try {//////////////////Section Down==Top_Right///////////////////////////////////
                    if (idx == 1) {
                        $("#TD_News_Title_Top_Right a").html(item.NWS_Title);
                        $("#TD_News_Title_Top_Right a").attr("href", href);
                        $("#TD_News_Date_Top_Right").html(item.PersianDateInfo);
                        $("#TD_News_Descrition_Top_Right").html(item.NWS_Description);
                        $("#img_FrontPage_News_Top_Right").attr("src", "/Images/News/" + imageUrl);
                    }
                }
                catch (e)
                { }

                try {//////////////////Section Down==Buttom_Left///////////////////////////////////
                    if (idx == 2) {
                        $("#TD_News_Title_Buttom_Left a").html(item.NWS_Title);
                        $("#TD_News_Title_Buttom_Left a").attr("href", href);
                        $("#TD_News_Date_Buttom_Left").html(item.PersianDateInfo);
                        $("#TD_News_Descrition_Buttom_Left").html(item.NWS_Description);
                        $("#img_FrontPage_News_Buttom_Left").attr("src", "/Images/News/" + imageUrl);

                    }
                }
                catch (e) {
                }

                try {//////////////////Section Down==Buttom_Right///////////////////////////////////
                    if (idx == 3) {
                        $("#TD_News_Title_Buttom_Right a").html(item.NWS_Title);
                        $("#TD_News_Title_Buttom_Right a").attr("href", href);
                         $("#TD_News_Date_Buttom_Right").html(item.PersianDateInfo);
                   $("#TD_News_Descrition_Buttom_Right").html(item.NWS_Description);
                   $("#img_FrontPage_News_Buttom_Right").attr("src", "/Images/News/" + imageUrl);
                        //$("#img_FrontPage_News_Buttom_Right").attr("src", "/Images/News/000003.jpg");

                    }
                }
                catch (e)
                { }
            });

        },
        error: function (e) {
            alert(e);
            $(divToBeWorkedOn).html("Unavailable");

        }
    });

    $('#Div_News').animate({
        opacity: 0.8,
        left: '+=0',
        height: '450'
    }, 3000, function () {

        // Animation complete.

    });

}


