﻿$(document).ready(function () {
    $(window).scroll(function () {
        if ($(document).scrollTop() > 229) {
            $('#menu1').addClass('menusabit');
            $('#menu2').addClass('menubosluk');
        }
        else {
            $('#menu1').removeClass('menusabit');
            $('#menu2').removeClass('menubosluk');
        }
    });
    $(function () {
        $('#yukari').click(function () {
            $('html,body').stop().animate({ scrollTop: '0' }, 2000);
        });
    });
    $(window).scroll(function () {
        var uzunluk = $(document).scrollTop();
        if (uzunluk > 500) {
            $('#yukari').fadeIn(1000);
        }
        else {
            $('#yukari').fadeOut(1000);
        }
    });
    $('#barim').click(function () {
        if ($.cookie('altbar') == null) {
            $.cookie('altbar', 'kapat', { expires: 1, path: '/' });
            $('#canlikayit').html('');
            $('#barim').addClass('gizle');
            $('#barim').removeClass('goste');
        }
        else {
            $.cookie('altbar', null, { expires: -1, path: '/' });
            $('#barim').addClass('goste');
            $('#barim').removeClass('gizle');
            kayit();
        }
    });
    if ($.cookie('altbar') == null) {
        kayit();
        setInterval(kayit, 30000);
        $('#barim').addClass('goste');
    }
    else {
        $('#barim').addClass('gizle');
    }
    function kayit() {
        if ($.cookie('altbar') == null) {
            $.ajax({
                type: 'GET',
                url: '/CanliKayit/Index/',
                dataType: 'html',
                success: function (data) {
                    $('#canlikayit').html(data);
                },
                error: function () {
                }
            });
        }
    }
    $('#hsohbet').click(function () {
        if ($.cookie('sohbet') == null) {
            $.cookie('sohbet', 'acik', { expires: 1, path: '/' });
            $('#hgoster').addClass('hgoster');
            sohbet();
        }
        else {
            $.cookie('sohbet', null, { expires: -1, path: '/' });
            $('#hgoster').removeClass('hgoster');
            $('#hgoster').html('');
        }
    });
    if ($.cookie('sohbet') != null) {
        $('#hgoster').addClass('hgoster');
        sohbet();
    }
    function sohbet() {
        $.ajax({
            url: '/Sohbet/HizliSohbet',
            type: 'GET',
            cache: false,
            dataType: 'html',
            success: function (data) {
                $('#hgoster').html(data);
            },
            error: function () {
            }
        });
    }
});
