﻿var uyeInfo;
var messageNotReadCount = 0;
var reminderCount = 0;
var htmlStr;
var newFacebookContentIndex;
var newTwitterContentIndex;
var aktifSayfa;
var aktifMiddleIcerik = 0;

var currDate = new Date();
var aylar = Array("", "Ocak", "Şubat", "Mart", "Nisan", "Mayıs", "Haziran", "Temmuz", "Ağustos", "Eylül", "Ekim", "Kasım", "Aralık");
function haftaninGunu(dayOfWeek) {
    switch (dayOfWeek) {
        case "Mon": return "Pazartesi"
            break;
        case "Tue": return "Salı"
            break;
        case "Wed": return "Çarşamba"
            break;
        case "Thu": return "Perşembe"
            break;
        case "Fri": return "Cuma"
            break;
        case "Sat": return "Cumartesi"
            break;
        case "Sun": return "Pazar"
            break;
    }
}

var gosteriTurleri = [];
var iletisimKanallari = [];

$(document).ready(function () {
    $("#top-banner-close").click(function () {
        $("#top-banner").slideUp();
    });

    /*$("#main-top-menu a:eq(6)").click(function () {
    window.open("http://www.cokguzelhareketlerbunlar.com/mPlayer.asp", "musicPlayer", "menubar=0,resizable=0,width=560,height=650");
    });*/

    $("#middle-bar .reklam a").click(function () {
        if ($("#middle-bar.active").length == 0) {
            $("#middle-bar").addClass("active");
            $("#middle-bar #middle-bar-bottom").slideDown();
        }
        else {
            $("#middle-bar #middle-bar-bottom").slideUp(function () {
                $("#middle-bar").removeClass("active");
            });
        }
    });

    $("#main-top-menu li a").bind("mouseenter", function () {
        $("#top-menu").css("z-index", "42");
        $(".open-tab").hide();
        $(".open-tab #tab ul").hide();
        if ($(this).parent().index() == 0 || $(this).parent().index() == 1) {
            $(".open-tab").show();
            $(".open-tab #tab ul#top-hover-menu-" + $(this).parent().index()).fadeIn(250);
        }
    });

    $(".open-tab").bind("mouseleave", function () {
        $(".open-tab").hide();
        $("#top-menu").css("z-index", "8");
    });

    $("#middle-bar-bottom #reklam:eq(0)").fadeIn(250);

    $(".reklam-list ul li a, #middle-bar-content ul").click(function () {
        //$("#middle-bar-bottom .middle-reklam").hide();
        //$("#middle-bar-bottom .middle-reklam:eq(" + $(this).parent().index() + ")").fadeIn(250);
        AjaxService.Tanitim(parseInt(this.id.substr(8)), function (_tanitim) {
            $("#reklam").attr("class", _tanitim.BolgeAd);
            $("#reklam .reklam-resim img").attr("src", "/bitmap/170/170?src=" + _tanitim.ResimURL);
            $("#reklam .reklam-resim img").attr("alt", _tanitim.Baslik);
            $("#reklam .reklam-info .reklam-baslik").html(_tanitim.Baslik);
            $("#reklam .reklam-info .reklam-aciklama").html(_tanitim.Detay);
            $("#reklam .reklam-info .reklam-button").attr("class", "reklam-button Izle");
            $("#reklam .reklam-info .reklam-button").empty();
            $(_tanitim.Dugme).each(function () {
                $("#reklam .reklam-info .reklam-button").append("<a href=\"" + this.URL + "\" target=\"" + this.Target + "\">" + this.Ad + "</a>");
            });
            $("#reklam").fadeIn(250);
        }, ajaxServiceErrHandler);
    });

    $(".login-buton a").click(function () {
        $("#membership").css("z-index", "42");
        memberLoginWindow();
    });

    $(".sign-up a").click(function () {
        $("#membership").css("z-index", "42");
        memberSignWindow();
    });

    function memberLoginWindow() {
        $("#member-remind-pass-form").hide();
        $("#member-login-form").show();
        $("#new-member").slideUp();
        $("html, body").animate({ scrollTop: 0 }, function () { $("#member-login").slideDown(); });
    }

    function memberSignWindow() {
        $("#member-remind-pass-form").hide();
        $("#member-login-form").show();
        $("#member-login").slideUp();
        $("html, body").animate({ scrollTop: 0 }, function () { $("#new-member").slideDown(); });
    }

    $("#btn-login-tab").click(function () {
        $("#member-login-form").show();
        $("#member-remind-pass-form").hide();
    });

    $("#btn-remind-pass").click(function () {
        $("#member-login-form").hide();
        $("#member-remind-pass-form").show();
    });
    $("#member-remind-pass-form").bind("keypress", function (e) { if (e.keyCode == 13) { remindPassword(); } });
    $("#member-remind-pass-form .button a").click(function () {
        remindPassword();
    });

    $("#new-member-description-button a").click(function () {
        $("#member-login").slideUp("fast", function () { $("#new-member").slideDown(); });
    });

    $(".membership-close a").click(function () {
        $("#member-login").slideUp();
        $("#new-member").slideUp();
        $("#member-window").slideUp();
        formTemizle();
        //$("#membership").css({ "z-index": "0" });
    });

    $("#member-login-form").bind("keypress", function (e) { if (e.keyCode == 13) { memberLogin(); } });
    $("#LoginImageButton").click(function () {
        memberLogin();
    });
    for (var gun = 1; gun <= 31; gun++) {
        $("#ddlDogumGun").append("<option value=\"" + gun + "\">" + gun + "</option>");
        $("#ddlEditDogumGun").append("<option value=\"" + gun + "\">" + gun + "</option>");
    }
    for (var ay = 1; ay <= 12; ay++) {
        $("#ddlDogumAy").append("<option value=\"" + ay + "\">" + aylar[ay] + "</option>");
        $("#ddlEditDogumAy").append("<option value=\"" + ay + "\">" + aylar[ay] + "</option>");
    }
    for (var yil = currDate.getFullYear(); yil >= (currDate.getFullYear() - 80); yil--) {
        $("#ddlDogumYil").append("<option value=\"" + yil + "\">" + yil + "</option>");
        $("#ddlEditDogumYil").append("<option value=\"" + yil + "\">" + yil + "</option>");
    }

    $("#new-member").bind("keypress", function (e) { if (e.keyCode == 13) { submitNewMember(); } })
    $("#new-member .submit a").click(function () {
        submitNewMember();
    });

    $(".button-light, .isik").click(function () {
        $("#member-login").slideUp();
        $("#new-member").slideUp();
        $("#member-window").slideUp();
        openDarkBg();
    });
    $("#dark-bg").click(function () {
        closeDarkBg();
    });

    $(".score").bind("mouseover", function () {
        if ($(this).attr("class").indexOf("pointer") != -1) {
            for (var counter = 1; counter <= 5; counter++) {
                $(this).parent().parent().children("li:eq(" + (counter - 1) + ")").children("img").attr("src", counter <= ($(this).parent().index() + 1) ? "/images/icon/star-hover.png" : "/images/icon/star-empty.png");
            }
        }
    });
    $(".score").click(function () {
        if ($(this).attr("class").indexOf("pointer") != -1) {
            var sender = this;
            AjaxService.PuanVer($(this).attr("class").split(" ")[2].split("-")[0], $(this).attr("class").split(" ")[2].split("-")[1], $(this).attr("class").split(" ")[2].split("-")[2], function (_puan) {
                puanGeriCevir(sender, _puan);
                $(sender).parent().parent().children("li").children("img").removeClass("pointer");
            }, ajaxServiceErrHandler);
        }
    });
    $(".score").bind("mouseleave", function () {
        if ($(this).attr("class").indexOf("pointer") != -1) {
            puanGeriCevir(this);
        }
    });

    $(".share-icon:eq(1) a").click(function () {
        $("#twitter-popup").css("left", ($(".share-icon:eq(1) a").offset().left - 340) + "px");
        $("#twitter-popup").css("top", ($(".share-icon:eq(1) a").offset().top - 370) + "px");
        $("#twitter-popup").fadeIn(250);
        $("#twitter-popup-tabs a").removeClass("selected");
        $("#twitter-popup-tabs a:eq(0)").addClass("selected");
        $(".twitter-popup-content-list").hide();
        $(".twitter-popup-content").hide();
        $(".twitter-popup-content-list:eq(0)").show();
        $(".twitter-popup-content-list:eq(0)").show();
        $(".twitter-popup-content-list:eq(0) .twitter-popup-content:eq(0)").show();
        $("#twitter-popup .content-nav a:eq(0)").addClass("selected");
        newTwitterContentIndex = 0;
        getTwitterFollow($(".twitter-popup-content-list:eq(0) .twitter-popup-content:eq(0) .twitter-btn span").html());
    });

    $(".share-icon:eq(0) a").click(function () {
        $("#facebook-popup").css("left", ($(".share-icon:eq(0) a").offset().left - 310) + "px");
        $("#facebook-popup").css("top", ($(".share-icon:eq(0) a").offset().top - 360) + "px");
        $("#facebook-popup").fadeIn(250);
        $("#facebook-popup-tabs a").removeClass("selected");
        $("#facebook-popup-tabs a:eq(0)").addClass("selected");
        $(".facebook-popup-content-list").hide();
        $(".facebook-popup-content").hide();
        $(".facebook-popup-content-list:eq(0)").show();
        $(".facebook-popup-content-list:eq(0)").show();
        $(".facebook-popup-content-list:eq(0) .facebook-popup-content:eq(0)").show();
        $("#facebook-popup .content-nav a:eq(0)").addClass("selected");
        newFacebookContentIndex = 0;
        getFacebookLike($(".facebook-popup-content-list:eq(0) .facebook-popup-content:eq(0) .facebook-btn span").html());
    });

    $("#twitter-popup-tabs a").click(function () {
        $("#twitter-popup-tabs a").removeClass("selected");
        $(this).addClass("selected");
        $(".twitter-popup-content-list").hide();
        $(".twitter-popup-content-list:eq(" + $(this).index() + ")").fadeIn(250);
        $("#twitter-popup .content-nav a").removeClass("selected");
        $("#twitter-popup .content-nav a:eq(" + $(this).index() + ")").addClass("selected");
        $(".twitter-popup-content-list .twitter-popup-content").hide();
        $(".twitter-popup-content-list:eq(" + $(this).index() + ") .twitter-popup-content:eq(0)").show();
        newTwitterContentIndex = 0;
        getTwitterFollow($(".twitter-popup-content-list:eq(" + $(this).index() + ") .twitter-popup-content:eq(0) .twitter-btn span").html());
    });

    $("#facebook-popup-tabs a").click(function () {
        $("#facebook-popup-tabs a").removeClass("selected");
        $(this).addClass("selected");
        $(".facebook-popup-content-list").hide();
        $(".facebook-popup-content-list:eq(" + $(this).index() + ")").fadeIn(250);
        $("#facebook-popup .content-nav a").removeClass("selected");
        $("#facebook-popup .content-nav a:eq(" + $(this).index() + ")").addClass("selected");
        $(".facebook-popup-content-list .facebook-popup-content").hide();
        $(".facebook-popup-content-list:eq(" + $(this).index() + ") .facebook-popup-content:eq(0)").show();
        newFacebookContentIndex = 0;
        getFacebookLike($(".facebook-popup-content-list:eq(" + $(this).index() + ") .facebook-popup-content:eq(0) .facebook-btn span").html());
    });
    //tweet
    $(".twitter-popup-content-list .content-list-nav a.prev").click(function () {
        if (newTwitterContentIndex == 0)
            return;

        newTwitterContentIndex -= 1;

        $(".twitter-popup-content").hide();
        $(this).parent().parent().children(".twitter-popup-content:eq(" + newTwitterContentIndex + ")").fadeIn(250);

        $(".twitter-popup-content-list .content-nav a").removeClass("selected");
        $(this).parent().next().children("a:eq(" + newTwitterContentIndex + ")").addClass("selected");
        getTwitterFollow($(this).parent().parent().children(".twitter-popup-content:eq(" + newTwitterContentIndex + ")").children(".twitter-btn").children("span").html());
    });
    $(".twitter-popup-content-list .content-list-nav a.next").click(function () {
        if ((newTwitterContentIndex + 1) >= $(this).parent().parent().children(".twitter-popup-content").length)
            return;

        newTwitterContentIndex += 1;

        $(".twitter-popup-content").hide();
        $(this).parent().parent().children(".twitter-popup-content:eq(" + newTwitterContentIndex + ")").fadeIn(250);

        $(".twitter-popup-content-list .content-nav a").removeClass("selected");
        $(this).parent().next().children("a:eq(" + newTwitterContentIndex + ")").addClass("selected");
        getTwitterFollow($(this).parent().parent().children(".twitter-popup-content:eq(" + newTwitterContentIndex + ")").children(".twitter-btn").children("span").html());
    });
    $("#twitter-popup .content-nav a").click(function () {
        $("#twitter-popup .content-nav a").removeClass("selected");
        $(this).addClass("selected");

        newTwitterContentIndex = 0;
        $("#twitter-popup-tabs a").removeClass("selected");
        $("#twitter-popup-tabs a:eq(" + $(this).index() + ")").addClass("selected");
        $(".twitter-popup-content-list").hide();
        $(".twitter-popup-content-list:eq(" + $(this).index() + ")").fadeIn(250);

        $(".twitter-popup-content-list .twitter-popup-content").hide();
        $(".twitter-popup-content-list:eq(" + $(this).index() + ") .twitter-popup-content:eq(0)").show();
        getTwitterFollow($(".twitter-popup-content-list:eq(" + $(this).index() + ") .twitter-popup-content:eq(0) .twitter-btn span").html());
    });
    // feys
    $(".facebook-popup-content-list .content-list-nav a.prev").click(function () {
        if (newFacebookContentIndex == 0)
            return;

        newFacebookContentIndex -= 1;

        $(".facebook-popup-content").hide();
        $(this).parent().parent().children(".facebook-popup-content:eq(" + newFacebookContentIndex + ")").fadeIn(250);

        $(".facebook-popup-content-list .content-nav a").removeClass("selected");
        $(this).parent().next().children("a:eq(" + newFacebookContentIndex + ")").addClass("selected");

        getFacebookLike($(this).parent().parent().children(".facebook-popup-content:eq(" + newFacebookContentIndex + ")").children(".facebook-btn").children("span").html());
    });
    $(".facebook-popup-content-list .content-list-nav a.next").click(function () {
        if ((newFacebookContentIndex + 1) >= $(this).parent().parent().children(".facebook-popup-content").length)
            return;

        newFacebookContentIndex += 1;

        $(".facebook-popup-content").hide();
        $(this).parent().parent().children(".facebook-popup-content:eq(" + newFacebookContentIndex + ")").fadeIn(250);

        $(".facebook-popup-content-list .content-nav a").removeClass("selected");
        $(this).parent().next().children("a:eq(" + newFacebookContentIndex + ")").addClass("selected");
        getFacebookLike($(this).parent().parent().children(".facebook-popup-content:eq(" + newFacebookContentIndex + ")").children(".facebook-btn").children("span").html());
    });
    $("#facebook-popup .content-nav a").click(function () {
        $("#facebook-popup .content-nav a").removeClass("selected");
        $(this).addClass("selected");

        newFacebookContentIndex = 0;
        $("#facebook-popup-tabs a").removeClass("selected");
        $("#facebook-popup-tabs a:eq(" + $(this).index() + ")").addClass("selected");
        $(".facebook-popup-content-list").hide();
        $(".facebook-popup-content-list:eq(" + $(this).index() + ")").fadeIn(250);

        $(".facebook-popup-content-list .facebook-popup-content").hide();
        $(".facebook-popup-content-list:eq(" + $(this).index() + ") .facebook-popup-content:eq(0)").show();
        getFacebookLike($(".facebook-popup-content-list:eq(" + $(this).index() + ") .facebook-popup-content:eq(0) .facebook-btn span").html());
    });

    $("#facebook-popup-close").click(function () {
        $("#facebook-popup").fadeOut(250);
    });
    $("#twitter-popup-close").click(function () {
        $("#twitter-popup").fadeOut(250);
    });
    // member-window-binds

    $(".login-name a").click(function () {
        $("#edit-profile, #updates, #messages, #messages, #favorites, #reminders, #music-list").hide();
        $("#member-window").slideDown();

        $("#member-menu ul li a").removeClass("selected");
        $("#member-menu ul li:eq(0) a").addClass("selected");

        $("#updates").hide();
        $("#messages").hide();
        $("#favorites").hide();
        $("#reminders").hide();
        $("#music-list").hide();

        updateListIndex = 0;
        $("#updates").fadeIn();
        $("#update-list-container").html("<div class=\"loading\"></div>");
        $("#update-list-container .loading").fadeIn(250);
        memberUpdates();
    });

    $("#header-tab li.mesaj").click(function () {
        $("#edit-profile, #updates, #messages, #messages, #favorites, #reminders, #music-list").hide();
        $("#member-menu li a").removeClass("selected");
        memberMessages();
        $("#messages").show();
        $("#member-window").slideDown();
        $("#member-menu li:eq(1) a").addClass("selected");
    });

    $("#header-tab li.yorum").click(function () {
        $("#edit-profile, #updates, #messages, #favorites, #reminders, #music-list").hide();
        $("#member-menu li a").removeClass("selected");
        memberReminders();
        $("#member-window").slideDown();
        $("#member-menu li:eq(3) a").addClass("selected");
        $("#reminders").fadeIn(250);
        $("#reminders .item-list").fadeIn(250);
    });

    $(".logout a").click(function () {
        AjaxService.Logout(function () {
            $("#member-login").hide();
            $("#new-member").hide();
            $("#member-window").hide();

            $(".uye-ozel").hide();
            $(".login-buton").show();
            $(".btn-uye-ol").show();

            $("#member-menu ul li a").removeClass("selected");
            $(this).addClass("selected");

            $("#updates").hide();
            $("#messages").hide();
            $("#favorites").hide();
            $("#reminders").hide();
            $("#music-list").hide();
        });
    });

    var counter = 0;

    var updateListIndex;
    var musicPlaylistListIndex;
    var musicListIndex;
    var playlistId;
    var favoriListIndex;
    var reminderListIndex;
    var messageListIndex;
    var uyeMesajList;

    $("#member-menu-edit-profile a").click(function () {
        $("#member-menu ul li a").removeClass("selected");
        $("#member-menu-edit-profile a").addClass("selected");

        $("#edit-profile, #updates, #messages, #favorites, #reminders, #music-list").hide();

        $("#edit-profile").prepend("<div class=\"loading\"></div>");
        $(".loading").fadeIn(250);
        AjaxService.UyeInfo(function (_uye) {
            uyeInfo = _uye;

            $(".line-1 li:eq(1)").html(uyeInfo.UserName);
            $(".line-1 li:eq(3)").html(uyeInfo.Email);
            $("#txtEditAdSoyad").val(uyeInfo.AdSoyad);
            $("#ddlEditDogumGun").val(parseInt(new Date(uyeInfo.DogumTarihi).format("dd")));
            $("#ddlEditDogumAy").val(parseInt(new Date(uyeInfo.DogumTarihi).format("MM")));
            $("#ddlEditDogumYil").val(parseInt(new Date(uyeInfo.DogumTarihi).format("yyyy")));
            $("#CepTelefonuTextBox").val(uyeInfo.CepTelefonu.length == 10 ? uyeInfo.CepTelefonu.substring(3,10) : "");
            $("#MedeniHalRadioButtonList").val(uyeInfo.MedeniHal);
            $("#CalismaSekliDropDownList").val(uyeInfo.CalismaSekli);
            $("#SehirDropDownList").val(uyeInfo.SehirId);
            $("#YenilikOnayRadioButtonList").val(uyeInfo.YenilikOnay);
            $("#IletisimOnayRadioButtonList").val(uyeInfo.IletisimOnay);

            $(uyeInfo.GosteriTuruList).each(function () {
                //$("#GosteriTuruListCheckBoxList_" + this.GosteriId).attr("checked", "checked");
            });

            $(uyeInfo.IletisimKanallariList).each(function () {
                //$("#IletisimKanallariCheckBoxList_" + this.IletisimKanalId).attr("checked", "checked");
            });

            $("#rblEditCinsiyet li:eq(" + (uyeInfo.Cinsiyet == 1 ? 1 : 0) + ") input").attr("checked", "checked");
            $(".loading").remove();
            $("#edit-profile").fadeIn(250);
        });
    });

    $("#member-menu ul li a").click(function () {
        $("#member-menu ul li a").removeClass("selected");
        $("#member-menu-edit-profile a").removeClass("selected");
        $(this).addClass("selected");

        $("#edit-profile").hide();
        $("#updates").hide();
        $("#messages").hide();
        $("#favorites").hide();
        $("#reminders").hide();
        $("#music-list").hide();

        switch ($(this).parent().index()) {
            case 0:
                updateListIndex = 0;
                $("#updates").fadeIn();
                $("#update-list-container").html("<div class=\"loading\"></div>");
                $("#update-list-container .loading").fadeIn(250);
                memberUpdates();
                break;
            case 1:
                messageListIndex = 0;
                $("#messages").fadeIn();
                $("#message-list-container").animate({ scrollTop: 0 });
                $("#message-list-container").html("<div class=\"loading\"></div>");
                $("#message-list-container .loading").fadeIn(250);
                memberMessages();
                break;
            case 2:
                favoriListIndex = 0;
                $("#favorites").fadeIn();
                $("#favorites .item-list").animate({ scrollTop: 0 });
                $("#favorites .item-list").html("<div class=\"loading\"></div>");
                $("#favorites .item-list .loading").fadeIn(250);
                memberFavorites();
                break;
            case 3:
                reminderListIndex = 0;
                $("#reminders").fadeIn();
                $("#reminders .item-list").animate({ scrollTop: 0 });
                $("#reminders .item-list").html("<div class=\"loading\"></div>");
                $("#reminders .item-list .loading").fadeIn(250);
                memberReminders();
                break;
            case 4:
                musicPlaylistListIndex = 0;
                $("#music-playlist-list").animate({ scrollTop: 0 });
                $("#music-playlist-list").html("<div class=\"loading\"></div>");
                $("#music-playlist-list .loading").fadeIn(250);
                $("#music-playlist-detail").hide();
                memberPlaylists();
                break;
        }
    });



    $("#updates .prev").click(function () {
        if (updateListIndex == 0) return;
        updateListIndex -= 1;
        $("#update-list-container").animate({ scrollTop: (updateListIndex * $("#update-list-container div").height()) });
    });
    $("#updates .next").click(function () {
        if ((updateListIndex + 1) == $("#update-list-container div").length) return;
        updateListIndex += 1;
        $("#update-list-container").animate({ scrollTop: (updateListIndex * ($("#update-list-container div").height())) });
    });

    $("#music-playlist .prev").click(function () {
        if (musicPlaylistListIndex == 0) return;
        musicPlaylistListIndex -= 1;
        $("#music-playlist-list").animate({ scrollTop: (musicPlaylistListIndex * $("#music-playlist-list div").height()) });
    });
    $("#music-playlist .next").click(function () {
        if ((musicPlaylistListIndex + 1) == $("#music-playlist-list div").length) return;
        musicPlaylistListIndex += 1;
        $("#music-playlist-list").animate({ scrollTop: (musicPlaylistListIndex * ($("#music-playlist-list div").height())) });
    });

    $("#music-playlist-detail .prev").click(function () {
        if (musicListIndex == 0) return;
        musicListIndex -= 1;
        $("#music-playlist-detail-list").animate({ scrollTop: (musicListIndex * $("#music-playlist-detail-list div").height()) });
    });
    $("#music-playlist-detail .next").click(function () {
        if ((musicListIndex + 1) == $("#music-playlist-detail-list div").length) return;
        musicListIndex += 1;
        $("#music-playlist-detail-list").animate({ scrollTop: (musicListIndex * ($("#music-playlist-detail-list div").height())) });
    });

    $("#favorites .prev").click(function () {
        if (favoriListIndex == 0) return;
        favoriListIndex -= 1;
        $("#favorites .item-list").animate({ scrollTop: (favoriListIndex * $("#favorites .item-list div").height()) });
    });
    $("#favorites .next").click(function () {
        if ((favoriListIndex + 1) == $("#favorites .item-list div").length) return;
        favoriListIndex += 1;
        $("#favorites .item-list").animate({ scrollTop: (favoriListIndex * ($("#favorites .item-list div").height())) });
    });

    $("#reminders .prev").click(function () {
        if (reminderListIndex == 0) return;
        reminderListIndex -= 1;
        $("#reminders .item-list").animate({ scrollTop: (reminderListIndex * $("#favorites .item-list div").height()) });
    });
    $("#reminders .next").click(function () {
        if ((reminderListIndex + 1) == $("#reminders .item-list div").length) return;
        reminderListIndex += 1;
        $("#reminders .item-list").animate({ scrollTop: (reminderListIndex * ($("#reminders .item-list div").height())) });
    });

    $("#message-list .prev").click(function () {
        if (messageListIndex == 0) return;
        messageListIndex -= 1;
        $("#message-list #message-list-container").animate({ scrollTop: (messageListIndex * $("#message-list #message-list-container div").height()) });
    });
    $("#message-list .next").click(function () {
        if ((messageListIndex + 1) == $("#message-list #message-list-container div").length) return;
        messageListIndex += 1;
        $("#message-list #message-list-container").animate({ scrollTop: (messageListIndex * ($("#message-list #message-list-container div").height())) });
    });
    // end

    if ($("#fb-root").length == 0)
        $("body").append("<div id=\"fb-root\"></div>");

    /*FB.init({
    appId: '157687594278175',
    status: false, // check login status
    cookie: false, // enable cookies to allow the server to access the session
    xfbml: false // parse XFBML
    });*/
});

function submitNewMember() {
    $("#new-member ul li.err").hide();
    var kontrol = true;
    if ($("#txtName").val() == "") {
        $("#new-member-form ul:eq(" + $("#txtName").parent().parent().index() + ") li.err").html("Ad giriniz !");
        $("#new-member-form ul:eq(" + $("#txtName").parent().parent().index() + ") li.err").fadeIn();
        kontrol = false;
    }
    if ($("#txtSurname").val() == "") {
        $("#new-member-form ul:eq(" + $("#txtSurname").parent().parent().index() + ") li.err").html("Soyad giriniz !");
        $("#new-member-form ul:eq(" + $("#txtSurname").parent().parent().index() + ") li.err").fadeIn();
        kontrol = false;
    }
    if ($("#txtUserName").val().length < 4) {
        $("#new-member-form ul:eq(" + $("#txtUserName").parent().parent().index() + ") li.err").html("Username (en az 4) giriniz !");
        $("#new-member-form ul:eq(" + $("#txtUserName").parent().parent().index() + ") li.err").fadeIn();
        kontrol = false;
    }
    if ($("#txtPassword").val().length < 6) {
        $("#new-member-form ul:eq(" + $("#txtPassword").parent().parent().index() + ") li.err").html("Şifre (en az 6) giriniz !");
        $("#new-member-form ul:eq(" + $("#txtPassword").parent().parent().index() + ") li.err").fadeIn();
        kontrol = false;
    }
    if ($("#txtPassword2").val() != $("#txtPassword").val()) {
        $("#new-member-form ul:eq(" + $("#txtPassword2").parent().parent().index() + ") li.err").html("Şifre uyuşmuyor !");
        $("#new-member-form ul:eq(" + $("#txtPassword2").parent().parent().index() + ") li.err").fadeIn();
        kontrol = false;
    }
    if (!isValidEmailAddress($("#txtEmail").val())) {
        $("#new-member-form ul:eq(" + $("#txtEmail").parent().parent().index() + ") li.err").html("E-posta giriniz !");
        $("#new-member-form ul:eq(" + $("#txtEmail").parent().parent().index() + ") li.err").fadeIn();
        kontrol = false;
    }
    if ($("#ddlDogumGun").val() == "" || $("#ddlDogumAy").val() == "" || $("#ddlDogumYil").val() == "") {
        $("#new-member-form #new-member-left ul:eq(" + $("#ddlDogumGun").parent().parent().index() + ") li.err").html("Doğum tarihi giriniz !");
        $("#new-member-form #new-member-left ul:eq(" + $("#ddlDogumGun").parent().parent().index() + ") li.err").fadeIn();
        kontrol = false;
    }
    if ($("#cbAgreement:checked").length == 0) {
        $("#new-member-form #new-member-right .agreement li.err").html("Anlaşma zorunlu !");
        $("#new-member-form #new-member-right .agreement li.err").fadeIn();
        kontrol = false;
    }
    //if ($("#rbCinsiyetBay:checked").val() == null || $("#rbCinsiyetBayan:checked").val() == null) {
    if ($("input[name='rbCinsiyet']:checked").val() == null) {
        $("#new-member-form #cinsiyet li.err").html("Cinsiyet seçiniz !");
        $("#new-member-form #cinsiyet li.err").fadeIn();
        kontrol = false;
    } else {
        kontrol = true;
    }
    if ($("input[name='ctl00$MedeniHalNewRadioButtonList']:checked").val() == null) {
        $("#new-member-form #MedeniHal li.err").html("Medeni hal seçiniz !");
        $("#new-member-form #MedeniHal li.err").fadeIn();
        kontrol = false;
    } else {
        kontrol = true;
    }
    if ($("input[name='IletisimKanallariNewLiteral']:checked").val() == null) {
        $("#new-member-form #kanallar li.err").html("İletişim kanalları seçiniz !");
        $("#new-member-form #kanallar li.err").fadeIn();
        kontrol = false;
    } else {
        kontrol = true;
    }

    if (kontrol) {
        gosteriTurleri = [];
        iletisimKanallari = [];

        $("input:checkbox[name=GosteriTuruNewCheckBoxList]:checked").each(function (index) { gosteriTurleri.push($(this).val()); });
        $("input:checkbox[name=IletisimKanallariNewLiteral]:checked").each(function (index) { iletisimKanallari.push($(this).val()); });

        $("li.submit").hide();
        $("li.loader").show();

        AjaxService.YeniUye($("#txtName").val() + " " + $("#txtSurname").val(), $("#txtUserName").val(), $("#txtPassword").val(), $("#txtEmail").val(), $("input[name='rbCinsiyet']:checked").val(), $("#ddlDogumGun").val() + "." + $("#ddlDogumAy").val() + "." + $("#ddlDogumYil").val(), $("#CepTelKodNewDropDownList").val() + $("#CepTelefonuNewTextBox").val(), $("#SehirNewDropDownList").val(), $("input[name='ctl00$MedeniHalNewRadioButtonList']:checked").val(), $("#CalismaSekliNewDropDownList").val(), $("input[name='ctl00$YenilikOnayNewRadioButtonList']:checked").val(), $("input[name='ctl00$IletisimOnayNewRadioButtonList']:checked").val(), iletisimKanallari, gosteriTurleri, function () {
            $("#new-member").slideUp();
            formTemizle();
            alert("Üyelik işleminiz tamamlanmıştır. Kullanıcı adınız ve şifreniz ile sisteme giriş yapabilirsiniz.");
        }, function (_err) {
            var obj = _err._message == "Kullanıcı adı kullanımda !" ? "#txtUserName" : "#txtEmail";
            $("#new-member-form ul:eq(" + $(obj).parent().parent().index() + ") li.err").html(_err._message);
            $("#new-member-form ul:eq(" + $(obj).parent().parent().index() + ") li.err").fadeIn();

            $("li.submit").show();
            $("li.loader").hide();
        });
    }
}

function getFacebookLike(_facebookUrl) {
    $(".facebook-popup-content-list:eq(" + $("#facebook-popup-tabs a.selected").index() + ") .facebook-popup-content:eq(" + newFacebookContentIndex + ") .like-description").hide();
    FB.api(
        {
            method: 'fql.query',
            query: "SELECT like_count FROM link_stat WHERE url='" + _facebookUrl + "'"
        },
        function (response) {
            $(".facebook-popup-content-list:eq(" + $("#facebook-popup-tabs a.selected").index() + ") .facebook-popup-content:eq(" + newFacebookContentIndex + ") .like-description span").html(response[0].like_count);
            $(".facebook-popup-content-list:eq(" + $("#facebook-popup-tabs a.selected").index() + ") .facebook-popup-content:eq(" + newFacebookContentIndex + ") .like-description").fadeIn(250);
        }
    );
}

function getTwitterFollow(_twitterDisplayName) {
    $(".twitter-popup-content-list:eq(" + $("#twitter-popup-tabs a.selected").index() + ") .twitter-popup-content:eq(" + newTwitterContentIndex + ") .follow-description").hide();
    $.getJSON("http://api.twitter.com/1/users/show.json?callback=?&screen_name=" + _twitterDisplayName, function (json) {
        $(".twitter-popup-content-list:eq(" + $("#twitter-popup-tabs a.selected").index() + ") .twitter-popup-content:eq(" + newTwitterContentIndex + ") .follow-description span").html(json.followers_count);
        $(".twitter-popup-content-list:eq(" + $("#twitter-popup-tabs a.selected").index() + ") .twitter-popup-content:eq(" + newTwitterContentIndex + ") .follow-description").fadeIn(250);

    });
}

function puanGeriCevir(_sender, _puan) {
    for (var counter = 1; counter <= 5; counter++) {
        if (counter <= _puan)
            $(_sender).parent().parent().children("li:eq(" + (counter - 1) + ")").children("img").attr("src", "/images/icon/star.gif");
        else if ((counter - _puan) <= 0.5)
            $(_sender).parent().parent().children("li:eq(" + (counter - 1) + ")").children("img").attr("src", "/images/icon/star-half.gif");
        else
            $(_sender).parent().parent().children("li:eq(" + (counter - 1) + ")").children("img").attr("src", "/images/icon/star-empty.gif");
    }
}

function openDarkBg() {
    $("#dark-bg").width($(document).width());
    $("#dark-bg").height($(window).height());
    $("#dark-bg").css('filter', 'alpha(opacity=90)').fadeIn(200);
}

function memberActivationWindow() {
    alert("Aktivasyon yapıldı!");
}

function closeDarkBg() {
    $(".video-player-container").css("z-index", "41");
    $("#dark-bg").fadeOut(200);
    if ($("#hata-ekrani").length > 0) $("#hata-ekrani").hide();
    if ($("#yazi-ekle-form").length > 0) $("#yazi-ekle-form").hide();
    if ($("#album-ekle-form").length > 0) $("#album-ekle-form").hide();
    if ($("#album-resim-ekle-form").length > 0) $("#album-resim-ekle-form").hide();
    if ($("#video-ekle-form").length > 0) $("#video-ekle-form").hide();
    if ($("#konu-ekle-form").length > 0) $("#konu-ekle-form").hide();
    if ($("#genel-duzenle-form").length > 0) $("#genel-duzenle-form").hide();
}

function karakterYaz(_s, _karakter) {
    return _s.length > _karakter ? _s.substr(0, _karakter) + "..." : _s;
}

function formTemizle() {
    $("#txtLoginUserName").val("");
    $("#txtLoginPassword").val("");
    $("#txtName").val("");
    $("#txtSurname").val("");
    $("#txtUserName").val("");
    $("#txtPassword").val("");
    $("#txtPassword2").val("");
    $("#txtEmail").val("");
    $("#rbCinsiyetBay").attr("checked", "checked");
    $("#ddlDogumGun").val("");
    $("#ddlDogumAy").val("");
    $("#ddlDogumYil").val("");
    $("#cbAgreement").attr("checked", "");
    $("input:checkbox[name=GosteriTuruNewCheckBoxList]").each(function () { $(this).attr("checked",""); });
    $("input:checkbox[name=IletisimKanallariNewLiteral]").each(function () { $(this).attr("checked", ""); });
    $("input:checkbox[name=GosteriTuruCheckBoxList]").each(function () { $(this).attr("checked", ""); });
    $("input:checkbox[name=IletisimKanallariLiteral]").each(function () { $(this).attr("checked", ""); });
}

function memberLogin() {
    $("#member-login-form ul li.err").hide();
    kontrol = true;
    if ($("#txtLoginUserName").val() == "") {
        $("#member-login-form ul:eq(" + ($("#txtLoginUserName").parent().parent().index() - 1) + ") li.err").html("Kullanıcı adı giriniz !");
        $("#member-login-form ul:eq(" + ($("#txtLoginUserName").parent().parent().index() - 1) + ") li.err").fadeIn();
        return false;
        //kontrol = false;
    }
    if ($("#txtLoginPassword").val() == "") {
        $("#member-login-form ul:eq(" + ($("#txtLoginPassword").parent().parent().index() - 1) + ") li.err").html("Şifre giriniz !");
        $("#member-login-form ul:eq(" + ($("#txtLoginPassword").parent().parent().index() - 1) + ") li.err").fadeIn();
        return false;
        //kontrol = false;
    }

    /*if (kontrol) {
        AjaxService.Login($("#txtLoginUserName").val(), $("#txtLoginPassword").val(), $("#cbRemindMember:checked").length, function (_uye) {
            uyeInfo = _uye;

            $("#member-login").slideUp();
            $(".login-buton, .btn-uye-ol").hide();
            $(".uye-ozel").show();
            formTemizle();

            if (typeof ekipUyeId != "undefined") {
                if (uyeInfo.UyeID == ekipUyeId) {
                    location.href = window.location.pathname;
                }
            }

            $(".login-name a").html(uyeInfo.AdSoyad);
            $(".mesaj").html(uyeInfo.ToplamMesaj);
            $(".yorum").html(uyeInfo.ToplamHatirlatma);
            $("#member-window #member-avatar img").attr("src", "/bitmap-crop/118/92?src=" + uyeInfo.AvatarURL);
            $("#member-window #member-name").html(uyeInfo.AdSoyad);
            memberIcons(uyeInfo);
            formTemizle();
        }, function (_err) {
            $("#member-login-form ul:eq(" + ($("#txtLoginUserName").parent().parent().index() - 1) + ") li.err").html(_err._message);
            $("#member-login-form ul:eq(" + ($("#txtLoginUserName").parent().parent().index() - 1) + ") li.err").fadeIn();
        });
    }*/
}

function remindPassword() {
    $("#member-remind-pass-form ul li.err").hide();
    kontrol = true;
    if (!isValidEmailAddress($("#txtRemindEmail").val())) {
        $("#member-remind-pass-form ul:eq(" + ($("#txtRemindEmail").parent().parent().index() - 1) + ") li.err").html("Geçerli email giriniz !");
        $("#member-remind-pass-form ul:eq(" + ($("#txtRemindEmail").parent().parent().index() - 1) + ") li.err").fadeIn();
        kontrol = false;
    }

    if (kontrol) {
        $("#member-remind-pass-form ul:eq(1) li").empty();
        AjaxService.SifreHatirlat($("#txtRemindEmail").val(), function (_uye) {
            $("#member-remind-pass-form ul:eq(1) li.remind-password").html("Şifreniz email adresinize iletilmiştir.");

        }, function (_err) {
            if (_err._exceptionType == "System.ServiceModel.AddressAccessDeniedException") {
                $("#member-remind-pass-form ul:eq(" + ($("#txtRemindEmail").parent().parent().index() - 1) + ") li.err").html(_err._message);
                $("#member-remind-pass-form ul:eq(" + ($("#txtRemindEmail").parent().parent().index() - 1) + ") li.err").fadeIn();
            } else if (_err._exceptionType == "System.InvalidOperationException") {
                $("#member-remind-pass-form ul:eq(1) li").html(_err._message);
            }
        });
    }
}

function ajaxServiceErrHandler(err) {

}

function isValidEmailAddress(emailAddress) {
    var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
    return pattern.test(emailAddress);
}

function puanGoster(_puan) {
    var puan = "<ul>";
    for (var counter = 1; counter <= 5; counter++)
    {
        if (counter <= _puan)
            puan += "<li><img src=\"/images/icon/star.gif\" alt=\"" + _puan + "\" /></li>";
        else if ((counter - _puan) <= 0.5)
            puan += "<li><img src=\"/images/icon/star-half.gif\" alt=\"" + _puan + "\" /></li>";
        else
            puan += "<li><img src=\"/images/icon/star-empty.gif\" alt=\"" + _puan + "\" /></li>";
    }
    puan += "</ul>";
    return puan;
}

function tarihFormat(_tarih) {
    return _tarih.format("dd") + " " + aylar[parseInt(_tarih.format("MM"))] + " " + _tarih.format("yyyy") + " " + haftaninGunu(_tarih.format("ddd")) + " " + _tarih.format("HH") + ":" + _tarih.format("mm") + ":" + _tarih.format("ss");
}

function hataEkrani(_hataMesaji) {
    switch (_hataMesaji) {
        case "":
            $("#hata-ekrani").hide();
            $("#hata-ekrani li.metin").html("");
            break;
        default:
            $(".video-player-container").css("z-index","5");
            openDarkBg();
            $("#hata-ekrani").fadeIn(500);
            $("#hata-ekrani li.metin").html(_hataMesaji);
            break;
    }
}

function memberIcons(_uye) {
    if (_uye == null) {
        AjaxService.UyeInfo(function (_uye) {
            uyeInfo = _uye;
            displayMemberIcons();
        });
    } else {
        displayMemberIcons();
    }
}

function displayMemberIcons() {
    messageNotReadCount = 0;

    $(uyeInfo.Mesaj).each(function () {
        if (this.Okunma == false)
            messageNotReadCount += 1;
    });

    reminderCount = $(uyeInfo.Hatirlatma).length;

    if (messageNotReadCount > 0) {
        $(".messages-icon .red-numb").fadeIn(500);
        $(".messages-icon .red-numb").html(messageNotReadCount);
    } else {
        $(".messages-icon .red-numb").hide();
    }
    if (reminderCount > 0) {
        $(".reminders-icon .red-numb").fadeIn(500);
        $(".reminders-icon .red-numb").html(reminderCount);
    } else {
        $(".reminders-icon .red-numb").hide();
    }
}

function memberFavorites() {
    AjaxService.UyeFavori(function (_favori) {
        $("#favorites .item-list").empty();
        htmlStr = "<div>";

        counter = 0;
        $(_favori).each(function () {
            htmlStr += "<ul>" +
                        "<li class=\"item-remove\"><a id=\"item_" + counter + "\" href=\"javascript:void(0)\"></a></li>" +
                        "<li class=\"item-pic\"><a href=\"" + this.LinkURL + "\"><img src=\"/bitmap-crop/154/75?src=" + this.ResimURL + "\" alt=\"\" /></a></li>" +
                        "<li class=\"item-name\"><a href=\"" + this.LinkURL + "\">" + this.Baslik + "</a></li>" +
                        "<li class=\"item-add-date\">" + new Date(this.EklenmeTarihi).format("dd.MM.yyyy") + "</li>" +
                    "</ul>";
            if ((counter + 1) % 6 == 0 && (counter + 1) < _favori.length) htmlStr += "</div><div>";
            counter++;
        });

        if (counter == 0)
            htmlStr = "Hiç favori video eklememişsiniz.";

        htmlStr += "</div>";
        $("#favorites .item-list").html(htmlStr);

        $("#favorites .item-list .item-remove a").click(function () {
            $("#favorites .item-list").html("<div class=\"loading\"></div>");
            $("#favorites .item-list .loading").fadeIn(250);
            AjaxService.UyeFavoriSil($(this).attr("id").substr(5), function () {
                memberFavorites();
            });
        });
    });
}

function memberReminders() {
    AjaxService.UyeHatirlatma(function (_hatirlatma) {
        $("#reminders .item-list").empty();
        htmlStr = "<div>";
        counter = 0;
        $(_hatirlatma).each(function () {
            htmlStr += "<ul>" +
                        "<li class=\"item-remove\"><a id=\"item_" + counter + "\" href=\"javascript:void(0)\"></a></li>" +
                        "<li class=\"item-pic\"><a href=\"" + this.LinkURL + "\"><img src=\"/bitmap-crop/154/75?src=" + this.ResimURL + "\" alt=\"\" /></a></li>" +
                        "<li class=\"item-name\"><a href=\"" + this.LinkURL + "\">" + this.Baslik + "</a></li>" +
                        "<li class=\"item-add-date\">" + new Date(this.HatirlatmaTarihi).format("dd.MM.yyyy") + "</li>" +
                    "</ul>";
            if ((counter + 1) % 6 == 0 && (counter + 1) < _hatirlatma.length) htmlStr += "</div><div>";
            counter++;
        });

        if (counter == 0)
            htmlStr = "Herhangi bir etkinlik için hatırlatma kurmamışsınız.";

        htmlStr += "</div>";
        $("#reminders .item-list").html(htmlStr);

        $("#reminders .item-list .item-remove a").click(function () {
            $("#reminders .item-list").html("<div class=\"loading\"></div>");
            $("#reminders .item-list .loading").fadeIn(250);
            AjaxService.UyeHatirlatmaSil($(this).attr("id").substr(5), function () {
                memberReminders();
                memberIcons(null);
            });
        });
    });
}

function memberMessages() {
    AjaxService.UyeMesaj(function (_mesaj) {
        $("#message-detail").hide();
        $("#message-list-container").empty();
        htmlStr = "<div>";
        uyeMesajList = _mesaj;
        counter = 0;
        $(uyeMesajList).each(function () {
            var messageRead = "";
            if (this.Okunma == false) messageRead = " class=\"not-read\""
            htmlStr += "<ul" + messageRead + ">" +
                        "<li class=\"message-remove\"><a id=\"item_" + counter + "\" href=\"javascript:void(0)\"></a></li>" +
                        "<li class=\"message-from\"><a id=\"message_" + counter + "\" href=\"javascript:void(0)\">BKM Online</a></li>" +
                        "<li class=\"message-date\">" + new Date(this.MesajTarihi).format("dd.MM.yy") + "</li>" +
                        "<li class=\"message-short-text\">" + this._Mesaj.substr(0, 50) + "</li>" +
                    "</ul>";
            if ((counter + 1) % 6 == 0 && (counter + 1) < uyeMesajList.length) htmlStr += "</div><div>";
            counter++;
        });

        if (counter == 0)
            htmlStr = "Mesaj bulunamadı.";

        htmlStr += "</div>";
        $("#message-list-container").html(htmlStr);

        $("#message-list-container .message-from a").click(function () {
            $("#message-list-container ul").removeClass("selected");
            $(this).parent().parent().addClass("selected");
            $(this).parent().parent().removeClass("not-read");
            var mesajIndex = $(this).attr("id").substr(8);
            $("#message-detail").fadeIn(250);
            $("#message-text").html("<div class=\"loading\"></div>");
            $("#message-text .loading").fadeIn(250);

            $("span.message-time").empty();
            $("span.message-date").empty();
            $("span#message-subject").empty();

            AjaxService.UyeMesajOkundu(mesajIndex, function () {
                $("#message-text .loading").remove();
                $("span.message-time").html(new Date(uyeMesajList[mesajIndex].MesajTarihi).format("MM:hh"));
                $("span.message-date").html(new Date(uyeMesajList[mesajIndex].MesajTarihi).format("dd.MM.yyyy"));
                $("span#message-subject").html("Konu: " + uyeMesajList[mesajIndex].Konu);
                $("div#message-text").html(uyeMesajList[mesajIndex]._Mesaj);
                memberIcons();
            });
        });

        $("#message-list-container .message-remove a").click(function () {
            $("#message-list-container").html("<div class=\"loading\"></div>");
            $("#message-list-container .loading").fadeIn(250);
            AjaxService.UyeMesajSil($(this).attr("id").substr(5), function () {
                memberMessages();
                memberIcons();
            });
        });
    });
}

function memberUpdates() {
    AjaxService.Guncellemeler(function (_guncelleme) {
        $("#update-list-container").empty();
        htmlStr = "<div>";
        counter = 0;
        $(_guncelleme).each(function () {
            htmlStr += "<ul>" +
                        "<li class=\"pic\"><a href=\"" + this.LinkURL + "\"><img src=\"/bitmap-crop/46/45?src=" + this.ResimURL + "\" alt=\"\" /></a></li>" +
                        "<li class=\"top-header " + this.Bolge + "\">" + new Date(this.Tarih).format("dd.MM.yyyy") + "</li>" +
                        "<li class=\"text\"><a href=\"" + this.LinkURL + "\">" + this.Aciklama + "</a></li>" +
                    "</ul>";
            if ((counter + 1) % 6 == 0 && (counter + 1) < _guncelleme.length) htmlStr += "</div><div>";
            counter++;
        });

        if (counter == 0)
            htmlStr = "Herhangi bir güncelleme bulunamadı.";

        htmlStr += "</div>";
        $("#update-list-container").html(htmlStr);
    });
}

function memberPlaylists() {
    AjaxService.UyePlaylist(function (_playlist) {
        musicListIndex = 0;
        $("#music-playlist-list").empty();
        htmlStr = "<div><ul>";
        counter = 0;
        $(_playlist).each(function () {
            htmlStr += "<li><a class=\"playlist-remove\" id=\"playlist_" + counter + "\" href=\"javascript:void(0)\"></a>" +
                                                                "<a class=\"lnk-playlist\" id=\"playlist_" + this.PlaylistID + "\" href=\"javascript:void(0)\">" + this.Ad + "</a></li>";
            if ((counter + 1) % 6 == 0 && (counter + 1) < _playlist.length) htmlStr += "</ul></div><div><ul>";
            counter++;
        });

        if (counter == 0)
            htmlStr = "<li>Herhangi bir güncelleme bulunamadı.</li>";

        htmlStr += "</ul></div>";
        $("#music-playlist-list").html(htmlStr);

        $("#music-playlist-list ul li a.playlist-remove").click(function () {
            $("#music-playlist-list").html("<div class=\"loading\"></div>");
            $("#music-playlist-list .loading").fadeIn(250);
            AjaxService.UyeMuzikPlaylistSil($(this).attr("id").substr(9), function () {
                memberPlaylists();
            }, ajaxServiceErrHandler);
        });


        $("#music-playlist-list li a.lnk-playlist").click(function () {
            $("#music-playlist-detail").hide();
            playlistId = $(this).attr("id").substr(9);
            $("#music-playlist-detail-list").animate({ scrollTop: 0 });
            musicListIndex = 0;

            AjaxService.UyeMuzikListesi(playlistId, function (_muzikList) {
                musicListIndex = 0;
                $("#music-playlist-detail-list").empty();
                htmlStr = "<div><ul>";
                counter = 0;
                $(_muzikList).each(function () {
                    htmlStr += "<li class=\"playlist-name\"><a id=\"music_" + playlistId + "-" + counter + "\" href=\"javascript:void(0)\">" + this.Ad + "</a></li>";
                    if ((counter + 1) % 6 == 0 && (counter + 1) < _muzikList.length) htmlStr += "</ul></div><div><ul>";
                    counter++;
                });
                htmlStr += "</ul></div>";
                $("#music-playlist-detail-list").html(htmlStr);

                if (_muzikList.length > 0) {
                    $("#music-playlist-detail").fadeIn();
                    $("#music-playlist-detail-list a").click(function () {
                        //window.open("/_ProfilMuzikPlayer.htm?playlistId=" + $(this).attr("id").substr(6).split("-")[0] + "&playIndex=" + $(this).attr("id").substr(6).split("-")[1], "BKM Player", "width=563px,height=593px");
                    });
                }
            });
        });
    });
    $("#music-list").fadeIn();
}
