﻿
var userAgent = navigator.userAgent.toLowerCase();

function selectValue() {
    try {
        if (document.getElementById('sepet'))
            return "Sepet";
        select = "ddlMECRA";
        if (typeof (select) == "string")
            select = document.getElementById(select);
        return select.options[select.selectedIndex].value;
    }
    catch (err) { }
}

function addnews(id) {
    try {
        var listes = selectedlist();
        var sonuc;
        for (izz = 0; izz < listes.length; izz++) {
            if (listes[izz] == id)
                sonuc = "var";
        }
        if (sonuc != "var") {
            listes[listes.length] = id;
        }
        selectedlistadd(listes);
    }
    catch (err) {
    }
}
function selectedlistadd(newlist) {
    try {

        if ($("#hdmecra").val() == "BASIN") {
            if (yazarselect == "") {

                newsSelectedId = newlist;
            }
            else {
                yazarSelectedId = newlist;
            }
        }
        else if ($("#hdmecra").val() == "INTERNET") {
            internetSelectedId = newlist;
        }
        else if ($("#hdmecra").val() == "SOCIALMEDIA") {
            socialmediaSelectedId = newlist; ;
        }
        else if ($("#hdmecra").val() == "HABERAJANS") {
            ajansSelectedId = newlist;
        }
        else if ($("#hdmecra").val() == "RADYO") {
            tvSelectedId = newlist;
        }
        else if ($("#hdmecra").val() == "TELEVIZYON") {
            tvSelectedId = newlist;
        }
        else if ($("#hdmecra").val() == "Sepet") {
            sepetSelectId = newlist;
        }
        else {

        }
    }
    catch (err) {
    }
}
function selectedlist() {

    if ($("#hdmecra").val() == "BASIN") {
        if (yazarselect == "") {

            return newsSelectedId;

        }
        else {
            return yazarSelectedId;

        }
    }
    else if ($("#hdmecra").val() == "INTERNET") {
        return internetSelectedId;
    } else if ($("#hdmecra").val() == "SOCIALMEDIA") {
        return socialmediaSelectedId;
    }
    else if ($("#hdmecra").val() == "HABERAJANS") {
        return ajansSelectedId;
    }
    else if ($("#hdmecra").val() == "RADYO") {
        return tvSelectedId;

    }
    else if ($("#hdmecra").val() == "TELEVIZYON") {
        return tvSelectedId;
    }
    else if ($("#hdmecra").val() == "Sepet") {
        return sepetSelectId;
    }
    else if ($("#hdmecra").val() == "Yazar") {
        return yazarSelectedId;
    }
    else if ($("#hdmecra").val() == "CEVIRI") {
        return yazarSelectedId;
    }
    else {
        return null;
    }

}
function deletenews(id) {
    try {
        var sonuc;
        var yeniDizi2 = [];
        var yenliste = selectedlist();
        for (iz = 0; iz < yenliste.length; iz++) {
            if (yenliste[iz] == id)
                sonuc = "var";
            if (sonuc == "var") {

            }
            else {
                yeniDizi2[yeniDizi2.length] = yenliste[iz];
            }
        }
        selectedlistadd(yeniDizi2);
    }
    catch (err) {
    }
}


function secilileriIsaretle(id) {
    var secliliste = selectedlist();
    for (ex = 0; ex < secliliste.length; ex++) {
        if (secliliste[ex] == id) {
            var inputTitle = $get("t" + id);
            inputTitle.getElementsByTagName("input")[0].checked = true;
            toogleRowSelection(inputTitle.getElementsByTagName("input")[0]);
        }
    }
}

function ortala() {


    try {
        //			        alert(autocompeteload);
        //autocompeteload.abort();
        var size = windowSize();

        $('#DIVProgress').height(size["height"]);

        $('#DIVProgress').show();
        $('#DIVProgress').vCenter();
    }
    catch (err) {
    }
}

this.tooltip = function () {
    xOffset = 10;
    yOffset = 20;
    $("span.tooltip").hover(function (e) {
        this.t = this.title;
        this.title = "";
        $("body").append("<p id='tooltip'>" + this.t + "</p>");
        $("#tooltip")
						.css("top", (e.pageY - xOffset) + "px")
						.css("left", (e.pageX + yOffset) + "px")
						.fadeIn("fast");
    },
				function () {
				    this.title = this.t;
				    $("#tooltip").remove();
				});
    $("span.tooltip").mousemove(function (e) {
        $("#tooltip")
						.css("top", (e.pageY - xOffset) + "px")
						.css("left", (e.pageX + yOffset) + "px");
    });
};
function yukseklik() {
    $("#DIVProgress").height(100);
}
function addList() {
    try {
        $("#ImageButtonSonrakiSayfa").click(function () {
            Get_Haber_ID_List();

        });
        $("#ImageButtonOncekiSayfa").click(function () {
            Get_Haber_ID_List();
        });

        $("#ddlSayfalama").change(function () {
            Get_Haber_ID_List();
        });
    }
    catch (err) {
    }
}

function Paging() {
    //var ddlsayfalamam = $("#ddlSayfalama"); 
    kayitSayisi = $("#hdTotalCount").val();
    pageViewCount = $("#hdPageView").val();
    selectedvalueindex = $("#hdSelectCount").val();
    newpaging();

}
function newpaging() {
   
    var k = Totalpage(kayitSayisi, pageViewCount);
    // var ddlsayfalamam = $("#ddlSayfalama"); 
    //     ddlsayfalamam.find('option').remove();
    if (totalcountofnews != kayitSayisi) {
        var addString = [];
        ddlPagingData = "";
        var z = 0;
        var bir = 1;
        selectedvalueindex = parseInt(selectedvalueindex, 10) + bir;
        // if(k<1000)
        //{
        //    for (var i = 0; i < k;i++)
        //  {
        //    var iint=parseInt(i,10);
        //  ddlsayfalamam.append($("<option></option>").attr("value",iint+1).text(iint+1)); 
        //}
        // $("#ddlSayfalama").val(selectedvalueindex); 
        // $("#lblToplamSayfa").html(" / "+k);   
        //}
        //else{
        //$("#ddlSayfalama").remove();
             $("#txtSayfayaGit").val(selectedvalueindex); 
        $("#lblToplamSayfa").html(" / " + k);
   
        //}
    }
}

function ResetUpsMenustyle() {
    $("#ceviri>a").css("color", "#fff");
    $("#ceviri").removeClass('menuclick2');
    $("#kose>a").css("color", "#fff");
    $("#kose").removeClass('menuclick');
    $("#gundem>a").css("color", "#fff");
    $("#gundem").removeClass('menuclick2');
    $("#Divsepet>a").css("color", "#fff");
    $("#Divsepet").removeClass('menuclick2');
}


function EditSiraNo(selector) {
    var reg = new RegExp('[^0-9]');
    var siraid = $(selector).attr("id").split("_")[1];
    if (reg.exec($(selector).val())) {
        alert("Lütfen Sayısal Değerler Giriniz...");
        $(selector).parent(".RowEdit").html(siraid);
    }
    else {
        //$("#tr_" + siraid).fadeOut()
        if (siraid != $(selector).val()) {


            $(selector).parent().parent().parent().fadeOut(function () {

                var gidecekno = $(selector).val();

                if (gidecekno > $('.RowEdit').length)
                    gidecekno = $('.RowEdit').length;
                var clonedata = $("#tr_" + siraid).clone();

                $("#tr_" + siraid).remove();
                if (gidecekno > siraid)
                    $("#tr_" + gidecekno).after(clonedata);
                else
                    $("#tr_" + gidecekno).before(clonedata);
                $("#tr_" + siraid).fadeIn();

                $("#tr_" + siraid + ">.RowEdit").html($(selector).val());
                Sirala(selector);
            });
        }
        else {
            $(selector).parent(".RowEdit").html($(selector).val());
        }
    }
}
function Sirala(selector) {
    var siraid = $(selector).attr("id").split("_")[1];
    var i = siraid;
    var x = 1;
    

          var sepetno= 0;
                      if(hidsepetno)
                        sepetno=hidsepetno;
                      var idlist = Get_Haber_All_ID_List();
                      

                    $.ajax({
                        type: "POST",
                        url: "WebServicesLayer/DefaultServices.asmx/SepetCustomSort",
                        data: "{sepetno:'"+sepetno+"',idList:'"+idlist+"'}",
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function(msg) {
                          
                        }
                    });

    $('.RowEdit').each(function () {

        $(this).html(x);
        $(this).attr("id", "sira_" + x);
        $(this).parent().parent().attr("id", "tr_" + x);
        x++;
    });


}

function redy() {
    SepetSortItem();
    $(".ui-autocomplete").hide();
   if( $("#hdmecra").val() == "Sepet"){

                  $('.RowEdit').click(function () {
                    var siraid = $(this).attr("id").split("_")[1];
                      var html = "<input onblur='EditSiraNo(this)' style='width:22px;height:22px;border:solid 1px gray;' id='txt_" + $(this).html() + "' name='" + $(this).html() + "' type='text' value='" + siraid + "' />";
                      if ($(this).attr("id") == "sira_" + $(this).html()) {
                          $(this).html(html)
                          $("#txt_" + siraid).focus();
                      }
                  });


                  $('#tablo1').tableDnD({
                      onDrop: function (table, row) {
                          Sirala(row);
                          $(row).css("background-color", "")
                          //  alert($('#tablo1').tableDnDSerialize());
                      },
                      onDragStart:function(table,row){
                          $(row).parent().css("background-color", "#fff0a5")
                      },
                      dragHandle: "rowSirala"
                  });
               

               }
               
    if (MusteriId == 3095 || MusteriId == 2076 || MusteriId == 3704 || MusteriId == 3875 || MusteriId == 1491 || MusteriId == 681 || MusteriId == 1604 || MusteriId == 1008) {
        $("#LoadJsFile").html('<script src="Script/jquery-qtip-1.0.0-rc3155617/jquery.qtip-1.0.0-rc3.js" type="text/javascript"></script>');
        QuickView();
    }

    ResimliMail();
    CheckCategoryViewText();
    LoadAutocomplete();
    $("div#DIVProgress").hide();
    BetaOrtala();
    CropChars();
    SortedEvent();
 
    CategoryView();


    $("#mainUserDiv").css("width", widthh);

    var kidgorunum = $("#htmlBtnAnaSayfa").css("display");
    if (kidgorunum == 'block') {

    }
    else {

        widthh = 940;
    }
    $("#SayfalamaUstCountainer").css("width", widthh);
    updatelist();
    checkMenuVisible();
    $('#bntAra').focus();
    $('#bntAra').select();
    $('#bntAra').TabIndex = 1;
    $('#ImageButtonOncekiSayfa').TabIndex = 2;
    $('#ImageButtonSonrakiSayfa').TabIndex = 3;
    $('#txtTarihBaslangic').attr('title', 'Başlangıç Tarihi')
    $('#txtTarihBitis').attr('title', 'Bitiş Tarihi')
    addList();
    tooltip();
    DurumKontrol();
    Get_Haber_ID_List_news();
    deneme();
    // $("#ddlSayfalama").change(function() {
    //$("#hdPageChange").val($("#ddlSayfalama").val());
    //    $("#hdPageNum").val($("#ddlSayfalama").val());
    //   <%=fethi %>;
    //   });
    $("#ddlMECRA").change(function () {
        toogleAllRemove();
        CategoryView("");
        ClearCache();
        ResetUpsMenustyle();
        createCookie("menu", "acik", 30);
        sortType = 1;

    });
    $('#bntAra').click(function () {
        ClearCache();
    });

    $('#ddlKayitGostermeSayisi').change(function () {
        ClearCache();
    });

    $('#ddlGosterim').change(function () {
        ClearCache();
    });

    $('#ddlAlan').change(function () {
        ortala();

        var selectedmecra = $("#hdmecra").val();
        if (selectedmecra == "BASIN" || selectedmecra == "TELEVIZYON" || selectedmecra == "INTERNET" || selectedmecra == "RADYO" || selectedmecra == "HABERAJANS") {


            var divhtml = $("#Category-nav-data-layer").html();
            if (divhtml != "") {
                //alert("oldu");
                var alanselected = $('#ddlAlan');
                var index = alanselected.attr("selectedIndex");
                index = parseInt(index, 10) - 1;
                if (index != -1) {
                    ToggleeAlanClick(index, alanselected.val());
                }
                else {
                    toogleAllRemove();
                }
            }
        }
        ClearCache();
    });

    $('#ddlMarka').change(function () {

        ortala();
        ClearCache();
    });
    Paging();

}

function CheckCategoryViewText() {

    var status = $('#Category-nav-data-layer').css('display');
    if (status != 'none') {
        $(".divbaslik").each(function () {
            var htmltext = $(this).attr('lang');
            if (htmltext.length > 50) {
                CropChar = 50;
                $(this).html(crop(htmltext, 50));
            }
        });
        $(".divMediaName").each(function () {
            var htmltext = $(this).attr('title');
            if (htmltext.length > 15) {

                $(this).html(crop(htmltext, 15));
            }
        });
    }
}
function ClearCache() {
    totalcountofnews = 0;
    kayitSayisi = 0;
    pageViewCount = 0;
    selectedvalueindex = 0;
    ddlPagingData = "";
    newsSelectedId = [];
    tvSelectedId = [];
    internetSelectedId = [];
    socialmediaSelectedId = [];

    ajansSelectedId = [];
    radyoSelectedId = [];
    yazarSelectedId = [];
    sepetSelectedId = [];
    yazarselect;
}
function BetaOrtala() {
    var myWidth = 0, myHeight = 0;
    if (typeof (window.innerWidth) == 'number') {
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
    } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
        myWidth = document.documentElement.clientWidth;
        myHeight = document.documentElement.clientHeight;
    } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;
    }
    //            var divbeta = document.getElementById("div_beta");
    //            if (divbeta) {
    //                imgwidth = document.getElementById("img_beta").offsetWidth;
    //                divbeta.style.top = "50px";
    //                divbeta.style.left = (((myWidth - imgwidth) / 2)) + "px";
    //            }
}
function crop(str, len) {
    var res = str;
    if (str.length > len && len >= 0) {
        res = res.substr(0, len);
        if (res.lastIndexOf(' ') > 0)
            res = res.substr(0, res.lastIndexOf(' '));
        res += "...";
    }
    return res;
}

function RemoveSession() {
    try {
        var firefox = navigator.userAgent.toLowerCase().indexOf("firefox") >= 0;
        if (!firefox) {
            if (window.event.clientY < 0 && (window.event.clientX > (document.documentElement.clientWidth - 5) || window.event.clientX < 15)) {
                $.ajax({
                    type: "POST",
                    url: "WebServicesLayer/DefaultServices.asmx/DeleteSession",
                    data: "{gelen:'sil'}",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (msg) {
                    }
                });
            }
        }
    }
    catch (err) {
        alert(err);
    }
}

function toggleDiv() {

    var status = $('#Category-nav-data-layer').css('display');
    if (status == 'block') {
        createCookie("categoryview", "kapali", 30);
        $(".divbaslik").each(function () {
            var htmltext = $(this).attr('lang');
            if (htmltext.length > 50) {
                $(this).html(crop(htmltext, 75));
            }
        });

        $(".divMediaName").each(function () {
            var htmltext = $(this).attr('title');
            if (htmltext.length > 15) {
                $(this).html(crop(htmltext, 18));
            }
        });

        CropChar = 75;

        hideCategoryView();
    }
    else {
        createCookie("categoryview", "acik", 30);
        $(".divbaslik").each(function () {
            var htmltext = $(this).attr('lang');
            if (htmltext.length > 50) {
                CropChar = 50;
                $(this).html(crop(htmltext, 50));
            }
        });
        $(".divMediaName").each(function () {
            var htmltext = $(this).attr('title');
            if (htmltext.length > 15) {

                $(this).html(crop(htmltext, 15));
            }
        });
        showCategoryView();
    }


    loadCategoryView();
}
function toogleAllRemove() {
    $(".divKategori").removeClass("Bold");
    $(".divMarka").removeClass("Bold");
}

function haberIdOlustur(listIdler, mecraa) {
    Get_Haber_ID_List();
    listIdler = selectedlist();
    var idlistem = "";
    var newliste = "";
    var i = 0;
    for (zez = 0; zez < listIdler.length; zez++) {
        idlistem += "," + listIdler[zez];
        if (i < 135) {
            newliste += "," + listIdler[zez];

        }
        i++;
    }
    $.ajax({
        type: "POST",
        url: "WebServicesLayer/DefaultServices.asmx/AddSelectedId",
        data: "{gelen:'" + idlistem.substring(1) + "' , mecra:'" + mecraa + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {

        }
    });

    return newliste;
}
function haberIdOlustur2(listIdler, mecraa) {
    Get_Haber_ID_List();
    listIdler = selectedlist();
    return listIdler;
}
function Get_Rss() {
    rssOpen("Rss/Rss.aspx");
}
function openBasindaBizWindow(durum) {
    url = "BASINDABIZ/CreateBasindaBiz2.aspx?mecra=" + durum;
    self.open(url, "sdf", "scrollbars=yes,resizable=1,width=750,height=700");
}
function SepeteEkle() {


    var haberids = selectedlist();
    if (haberids.length > 0) {
        $.ajax({
            type: "POST",
            url: "WebServicesLayer/DefaultServices.asmx/SepeteEkle",
            data: "{haberid:1}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (msg) {
                alert("Seçmiş olduğunuz haberler sepetinize eklenmiştir.");
            },
            error: function (xhr, desc, exceptionobj) {
                alert("Hata oluştu. Lütfen daha sonra tekrar deneyiniz.");
            }
        });
    }
    else {
        alert("Sepete haber eklemek için en az bir haber seçmelisiniz...");
    }
}
function showDuyurular() {
    if ($("#duyurular").html()) {
        $("#duyurular").slideToggle('slow');
        return;
    }

    $.ajax({
        type: "GET",
        url: "WebServicesLayer/GetDuyurular.ashx",
        contentType: "text/html; charset=utf-8",
        success: function (msg) {
            var html = '<div id="duyurular"><div style="padding:0px 8px 0px 8px">' + msg + '</div><div class="footer" onclick="$(\'#duyurular\').slideUp(\'slow\');"><img src="/theme/images/kapat.png"/></div></div>';
            if ($("#duyurular").html())
                $("#duyurular").replaceWith(html);
            else {
                $("body").append(html);
                var pos = $("#duyuru").offset();
                var width = $("#duyuru").width(), height = $("#duyuru").height();
                $("#duyurular").css('left', (pos.left - 100 + width / 2) + 'px');
                $("#duyurular").css('top', height + 2);
            }
            $("#duyurular").slideDown('slow');
        },
        error: function (xhr, desc, exceptionobj) {
            alert("Hata oluştu. Lütfen daha sonra tekrar deneyiniz.");
        }
    });
}
$(window).resize(function () {
    if ($("#duyurular").html()) {
        var pos = $("#duyuru").offset();
        var width = $("#duyuru").width(), height = $("#duyuru").height();
        $("#duyurular").css('left', (pos.left - 100 + width / 2) + 'px');
        $("#duyurular").css('top', height + 2);
    }
    if ($("#duyuruDisplay").html()) {
        var width = $(document).width();
        $('#duyuruDisplay').css('left', (width / 2 - 300) + 'px');
        $('#duyuruDisplay').css('top', '200px');
    }
});


function showDuyuru(elm) {
    var id = elm.parentNode.id.split('_')[1];
    $.ajax({
        type: "GET",
        url: "WebServicesLayer/GetDuyurular.ashx?id=" + id,
        contentType: "text/html; charset=utf-8",
        success: function (msg) {
            if ($("#duyuru_" + id).hasClass("unread"))
                $("#duyuru_" + id).removeClass("unread");

            var baslik = $("#duyuru_" + id + " span.baslik").html();
            if ($('#duyuruDisplay').html()) {
                $('#duyuruDisplay div.baslik').replaceWith('<div class="baslik">' + baslik + '</div>');
                $('#duyuruDisplay div.metin').replaceWith('<div class="metin">' + msg + '</div>');
                $('#duyuruDisplay').show('fast');
            }
            else {
                $('body').append('<div id="duyuruDisplay"><div class="header">Duyuru<img onclick="closeDuyuru();" src="/theme/images/kapat.png"/></div><div class="baslik">' + baslik + '</div><div class="metin">' + msg + '</div></div>');
                var width = $(document).width();
                $('#duyuruDisplay').css('left', (width / 2 - 300) + 'px');
                $('#duyuruDisplay').css('top', '200px');
                $('#duyuruDisplay').show('fast');
            }
            $('#ddlKayitGostermeSayisi').hide('fast');
        },
        error: function (xhr, desc, exceptionobj) {
            alert("Hata oluştu. Lütfen daha sonra tekrar deneyiniz.");
        }
    });
}
function closeDuyuru() {
    $('#duyuruDisplay').hide('fast');
    $('#ddlKayitGostermeSayisi').show('fast');
}


function showSepetler(tip, haberid, mecra, ust_dizin_say, xoffset) {
    if (!tip) tip = "";
    if (!haberid) haberid = "1";
    if (!mecra) mecra = "Basin";
    if (!ust_dizin_say) ust_dizin_say = 0;
    if (!xoffset) xoffset = 0;

    var ust_klasor = "";
    for (var i = 0; i < ust_dizin_say; i++)
        ust_klasor += "../";


    $.ajax({
        type: "GET",
        url: ust_klasor + "WebServicesLayer/GetSepetler.ashx?tip=" + tip + "&haberid=" + haberid + "&mecra=" + mecra + "&ust_dizin_say=" + ust_dizin_say,
        contentType: "text/html; charset=utf-8",
        success: function (msg) {
            //alert ('<%=GetSource("anasayfa") %>');

            html = " <div id=\"sepetler\" style=\"z-index:9999;display:block;\">   <div style=\"padding:0px 8px 0px 8px;\" >" + msg + "</div> ";
            if (tip == "")
                html += "<div class=\"footer\" ><a id=\"a_ana_sayfa\" href=\"javascript:__doPostBack('htmlBtnAnaSayfa', '')\" class=\"link_ana_sayfa\">Ana Sayfa</a></div></div>";

            if ($("#sepetler").html())
                $("#sepetler").replaceWith(html);
            else {
                $("body").append(html);
            }
            var pos = $("#Divsepet").offset();
            var width = $("#Divsepet").width(), height = $("#Divsepet").height();
            $("#sepetler").css('left', (pos.left - 100 + width / 2 + xoffset) + 'px');
            $("#sepetler").css('top', height + 2);

            $("#sepetler").slideDown('fast');
            $("#sepetler").css('z-index', 999);

            //alert(userAgent + " : 2");
            if (userAgent.indexOf("msie 6") > 0) {
                //try{ document.getElementById("ddlAlan").style.visibility = "hidden";}catch(err){}
                $("#ddlAlan").hide();

            }

            $(document).click(function () {
                $('#sepetler').slideUp('fast');
                //try{document.getElementById("ddlAlan").style.visibility = "visible";}catch(err){} 
                $("#ddlAlan").show();
            });
            //document.getElementById("a_ana_sayfa").innerHTML = str_anasayfa;

        },
        error: function (xhr, desc, exceptionobj) {
            alert("Hata oluştu showSepetler. Lütfen daha sonra tekrar deneyiniz.");
        }
    });
}

function SepeteEkle2(sepetno, haberid, mecra, ust_dizin_say) {
    if (!haberid) haberid = 1;
    if (!mecra) mecra = "Basin";

    var ust_klasor = "";
    for (var i = 0; i < ust_dizin_say; i++)
        ust_klasor += "../";

    try { $("#div_waiting").show(); } catch (ex) { }

    $.ajax({
        type: "POST",
        url: ust_klasor + "WebServicesLayer/DefaultServices.asmx/SepeteEkle2",
        data: "{haberid:" + haberid + ",sepetno:" + sepetno + ",mecra:'" + mecra + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            try { $("#div_waiting").hide(); } catch (ex) { }
            alert(msg.d);
            if (typeof SepetOlusturGetir == 'function') SepetOlusturGetir('');
        },
        error: function (xhr, desc, exceptionobj) {
            try { $("#div_waiting").hide(); } catch (ex) { }
            alert("Hata oluştu sepete ekle 2. Lütfen daha sonra tekrar deneyiniz.");
        }
    });
}

function SepeteEkle3(sepetno, haberids, mecra, ust_dizin_say) {
    if (!mecra) mecra = "Basin";

    var ust_klasor = "";
    for (var i = 0; i < ust_dizin_say; i++)
        ust_klasor += "../";

    if (!haberids) {
        haberids = selectedlist();
        haberids = haberids.toString().replace(" ", "");
    }

    if (sepetno < 0) {
        var sepet_bilgisi = SeciliSepetGetir();
        sepetno = sepet_bilgisi["sepetno"];
    }

    if (haberids.length > 0) {
        try { $("#div_waiting").show(); } catch (ex) { }

        $.ajax({
            type: "POST",
            url: ust_klasor + "WebServicesLayer/DefaultServices.asmx/SepeteEkle3",
            data: "{haberids:'" + haberids + "',sepetno:" + sepetno + ",mecra:'" + mecra + "'}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (msg) {
                try { $("#div_waiting").hide(); } catch (ex) { }
                alert(msg.d);
                if (typeof SepetOlusturGetir == 'function') SepetOlusturGetir('');
            },
            error: function (xhr, desc, exceptionobj) {
                try { $("#div_waiting").hide(); } catch (ex) { }
                alert("Hata oluştu sepete ekle 3. Lütfen daha sonra tekrar deneyiniz.");
            }
        });
    }
    else {
        alert("Sepete eklemek için en az bir haber seçmelisiniz.");
    }

}

function HaberDetayGoster(haberID, mecrax, sepette) {

    $("#span_" + haberID).addClass("visitedLink");
    window.open("BasinAyrintiGoster.aspx?IDS=" + haberID + "&kayit_sayisi=" + document.getElementById("ertpolgtfmbtopdgdfgdflkeflkjhh_lbl_habersayisi").innerHTML + "&mecra=" + mecrax + "&sepette=" + sepette);
}

function HaberMedyaKunyeGoster(haberID) {
    window.open("BasinAyrintiGoster.aspx?IDS=" + haberID + "&kayit_sayisi=1&mecra=basin&kunye_goster=225");
}
function windowSize() {
    var myWidth = 0, myHeight = 0;
    if (typeof (window.innerWidth) == 'number') {
        //Non-IE
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
    } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth;
        myHeight = document.documentElement.clientHeight;
    } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;
    }

    var result = [];
    result["width"] = myWidth;
    result["height"] = myHeight;
    return result;

}

function DurumKontrol() {
    var menu = readCookie("menu", "kapali");
    if (menu == "acik") {
        menuVisible2();
    }
    else {
        menuVisible1();
    }
}

$('#txtTarihBaslangic').attr('title', 'Başlangıç Tarihi')
$('#txtTarihBitis').attr('title', 'Bitiş Tarihi')

function CropChars() {
    $(".divbaslik").each(function () {
        var htmltext = $(this).attr('title');
        if (htmltext.length > CropChar) {
            $(this).html(crop(htmltext, CropChar));
        }
    });
}

function CategoryView() {
    var selectedmecra = $("#hdmecra").val();
    if (selectedmecra == "BASIN" || selectedmecra == "TELEVIZYON" || selectedmecra == "INTERNET" || selectedmecra == "RADYO" || selectedmecra == "HABERAJANS" || selectedmecra == "SOCIALMEDIA") {

        var divhtml = $("#Category-nav-data-layer").html();
        var divchanced = $("#hdChange").val();
        if (divhtml != "" && divchanced != "") {
            $("#Category-nav-data-layer").append("<div style='position: absolute;' ><img  src='theme/images/loading.gif'/></div>");
            $.ajax({
                type: "GET",
                url: "WebServicesLayer/GetCategoryHtml.ashx?guid=" + getUniqueId(),
                contentType: "text/html; charset=utf-8",
                success: function (msg) {
                    $("#Category-nav-data-layer").html(msg);
                }
            });
        }
        var statusdatacategory = $('#Category-nav-data-layer').css('display');
        if (statusdatacategory == "none") {
            widthh = 940;
        }
        else if (statusdatacategory == "block") {
            widthh = 720;
        }
        else {
            widthh = 965;
        }

        $("#mainUserDiv").css("width", widthh);
        $("#SayfalamaUstCountainer").css("width", widthh);
        $("#DivKategorikGorunumMain").attr("style", "display:block;");
    }
    else {
        $("#DivKategorikGorunumMain").css("display", "none");
        widthh = 965;
    }

}
function Totalpage(count, pageRecordCount) {
    var deger = 0;
    deger = count / pageRecordCount;
    return Math.ceil(deger);

}


function gettvalan() {
    $.ajax({
        type: "POST",
        url: "WebServicesLayer/DefaultServices.asmx/SetTvalan",
        data: "{islem:'sil'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            getinternetalan();
        }
    });
}

               
