$(document).ready(function () {
    var windowWidth = $(window).width();
    var windowHeight = $(window).height();
    var layers
    layui.use(['layer'], function () {
        layers = layui.layer;
    });
    if(windowWidth <= 1024){
        // lrconCreate  
        if ($('.lrconCreate').length) {
            var lrconCreateTop = $('.lrconCreate').offset().top
            var lrconCreateHeight = $('.lrconCreate').height()
            var marginTop = $('.lrCons').css('margin-top').substring(0,$('.lrCons').css('margin-top').length -2 )
            var tops = (lrconCreateTop + lrconCreateHeight - marginTop) / 2
            // pwduploading  showUpload
            $('.pwduploading').css('top', tops+'px')
        }
    }
    setTimeout(function () {
        if($('.profileBody').length > 0){
            $('.idInput input').parent().find('span').text($('.idInput input').val().length+"/50");
        }
        $('.topTips').mouseover(function () {
            layers.tips("<font color=\"black\">提示1</font>", '#' + $(this).attr('id'), { tips: [1, '#fff'], time: 0 });
        })
        $('.topTips').mouseleave(function () {
            layers.closeAll('tips');
        })

        if (windowWidth <= 1024) {
            $('.sggbCap').click(function () {
                if ($(this).find('.sggbCapTipsd').is(':visible')) {
                    $(this).find('.sggbCapTipsd').hide()
                } else {
                    $(this).find('.sggbCapTipsd').show()
                }

            })
            $('.sggbCap10').click(function () {
                if ($(this).find('.sggbCap7Tips').is(':visible')) {
                    $(this).find('.sggbCap7Tips').hide()
                } else {
                    $(this).find('.sggbCap7Tips').show()
                }
            })

            $('.sggbCap8').click(function () {
                if ($(this).parent().find('.sggbCap8Tips').is(':visible')) {
                    $(this).parent().find('.sggbCap8Tips').hide()
                } else {
                    $(this).parent().find('.sggbCap8Tips').show()
                }
            })

            $('.sggbCap9').click(function () {
                if ($(this).parent().find('.sggbCap9Tips').is(':visible')) {
                    $(this).parent().find('.sggbCap9Tips').hide()
                } else {
                    $(this).parent().find('.sggbCap9Tips').show()
                }
            })
            $('.pricetip').click(function () {
                if ($(this).parent().find('.pricetipTips').is(':visible')) {
                    $(this).parent().find('.pricetipTips').hide()
                } else {
                    $(this).parent().find('.pricetipTips').show()
                }
            })
            $('.webshowpermenu').click(function () {
                $('.getmenuPersonal').show()
            })
            $('.accountpwdD input').focus(function () {
                $(this).parent().addClass('clickNowinput')
            })
            $('.accountpwdD input').blur(function () {
                $(this).parent().removeClass('clickNowinput')
            })

        } else {
            $('.webDownup')

            $('.sggbCap').mouseover(function () {
                $(this).find('.sggbCapTipsd').show()
            })
            $('.sggbCap').mouseleave(function () {
                $(this).find('.sggbCapTipsd').hide()
            })


            $('.sggbCap10').mouseover(function () {
                $(this).parent().find('.sggbCap7Tips').show()
            })
            $('.sggbCap10').mouseleave(function () {
                $(this).parent().find('.sggbCap7Tips').hide()
            })

            $('.sggbCap8').mouseover(function () {
                $(this).parent().find('.sggbCap8Tips').show()
            })
            $('.sggbCap8').mouseleave(function () {
                $(this).parent().find('.sggbCap8Tips').hide()
            })
            $('.sggbCap9').mouseover(function () {
                $(this).parent().find('.sggbCap9Tips').show()
            })
            $('.sggbCap9').mouseleave(function () {
                $(this).parent().find('.sggbCap9Tips').hide()
            })
            $('.pricetip').mouseover(function () {
                $(this).parent().find('.pricetipTips').show()
            })
            $('.pricetip').mouseleave(function () {
                $(this).parent().find('.pricetipTips').hide()
            })
        }

        $('.muconUlTitle').click(function () {
            if ($(this).parent().find('.muconUllidList').css('display') == 'none') {
                $(this).parent().find('.muconUllidList').show()
            } else {
                $(this).parent().find('.muconUllidList').hide()
            }
        })

    }, 100)


    $('.headLang').mouseover(function () {
        $(this).find('.dggbYuyanSub').show()
    })
    $('.headLang').mouseleave(function () {
        $(this).find('.dggbYuyanSub').hide()
    })

    $('.avaselConA').mouseover(function () {
        $(this).parent().find('.avaselConA').removeClass('checked')
        $(this).addClass('checked')
    })
    $('.avaselConA').mouseout(function () {
        $(this).removeClass('checked')
    })

    $('.avatarDiv').mouseover(function () {
        $('.avaSelect').show()
    })
    $('.avatarDiv').mouseout(function () {
        $('.avaSelect').hide()
    })


    $('.coloridiv').mouseover(function () {
        $('.coloridivnod').show()
    })
    $('.coloridiv').mouseout(function () {
        $('.coloridivnod').hide()
    })

    $('.width1').mouseover(function () {
        $('.width1').find('.coloridivnod').show()
    })
    $('.width1').mouseout(function () {
        $('.width1').find('.coloridivnod').hide()
    })

    $('.pagesels a').mouseover(function (e) {
        $(this).parent().find('a').removeClass('checked')
        $(this).addClass('checked')
        if ($(this).index() == 0) {
            $('.pagesels').addClass('change')
        } else {
            $('.pagesels').removeClass('change')
        }
    })
    $('.pagesels a').mouseout(function () {
        $(this).removeClass('checked')
        $('.pagesels').removeClass('change')
    })
    var layerIndex


    $('.dggbShowSelect').click(function () {
        if (windowWidth > 750) {
            if ($('.pagesels').css('display') == 'block') {
                $('.pagesels').hide()
            } else {
                $('.pagesels').show()
            }
        }
    })
    $('.dggbShowSelectpage').click(function () {
        var heights = windowHeight
        if (windowWidth <= 430) {
            heights = windowHeight
        } else if (windowWidth <= 750) {
            heights = Math.round(windowHeight)
        }
        if (windowWidth <= 750) {
            layerIndex = layer.open({
                type: 1,
                title: false,
                closeBtn: false,
                shadeClose: true,
                area: [windowWidth + 'px'],
                // maxHeight:heights + 'px',
                offset: 'b',
                scrollbar: true,
                content: $('#weblayuiPage') //这里content是一个DOM，注意：最好该元素要存放在body最外层，否则可能被其它的相对元素所影响
            });
            layer.style(layerIndex, {
                'border-radius': '16px 16px 0px 0px',
            });
        }

        if (windowWidth > 750) {
            if ($('.pagesels').css('display') == 'block') {
                $('.pagesels').hide()
            } else {
                $('.pagesels').show()
            }
        }
    })
    $('.btRightweb').click(function () {
        var heights = windowHeight
        if (windowWidth <= 430) {
            heights = windowHeight
        } else if (windowWidth <= 750) {
            heights = Math.round(windowHeight)
        }
        if (windowWidth <= 750) {
            layerIndex = layer.open({
                type: 1,
                title: false,
                closeBtn: false,
                shadeClose: true,
                area: [windowWidth + 'px'],
                // maxHeight:heights + 'px',
                offset: 'b',
                scrollbar: true,
                content: $('#weblayui') //这里content是一个DOM，注意：最好该元素要存放在body最外层，否则可能被其它的相对元素所影响
            });
            layer.style(layerIndex, {
                'border-radius': '16px 16px 0px 0px',
            });
        }

        if (windowWidth > 750) {
            if ($('.pagesels').css('display') == 'block') {
                $('.pagesels').hide()
            } else {
                $('.pagesels').show()
            }
        }
    })

    $('.dggbUsdtType').click(function () {
        layerIndex = layer.open({
            type: 1,
            title: false,
            closeBtn: false,
            shadeClose: true,
            content: $('#layuiDiv') //这里content是一个DOM，注意：最好该元素要存放在body最外层，否则可能被其它的相对元素所影响
        });
    })

    $('.laydTop b').click(function () {
        layer.close(layerIndex)
    })
    $('.closea').click(function () {
        layer.close(layerIndex)
    })

    $('.webheaderMenubtn').click(function () {
        $('.getMenu').show()
        $('.ngbbodybg').css('overflow', 'hidden')
        if($('.getMenu').hasClass('getmenuPersonal')){
            $('.getMenu.getmenuPersonal').hide()
        }
    })
  
    $('.getMenuTop b').on('click',function(){
        $('.getMenu').hide()
        $('.ngbbodybg').css('overflow', 'auto')
        $('.cookieSets').hide();
    })


    $('.choseiconlan.languages').click(function () {
        if (windowWidth > 750) {
            if ($('.dggbYuyanSubweb').css('display') == 'none') {
                $('.dggbYuyanSubweb').show()
            } else {
                $('.dggbYuyanSubweb').hide()
            }
        } else {
            $('.getMenu').hide()
            $('.webLang').show()
            $('.webLang .dggbYuyanSubweb').show()

        }

    })
    $('.webLangTop b').click(function () {
        $('.getMenu').show()
        $('.webLang').hide()
        $('.webLang .dggbYuyanSubweb').hide()
    })
    $('.webUsdTop b').click(function () {
        $('.getMenu').show()
        $('.webUsd').hide()
    })

    $('.choseiconlan.bitcoin').click(function () {
        if (windowWidth > 750) {
            $('.layuiDiv').addClass('ipadlayuidiv')
            layerIndex = layer.open({
                type: 1,
                title: false,
                closeBtn: false,
                shadeClose: true,
                width: '100%',
                content: $('#layuiDiv') //这里content是一个DOM，注意：最好该元素要存放在body最外层，否则可能被其它的相对元素所影响
            });
        } else {
            $('.getMenu').hide()
            $('.webUsd').show()
            $('.webUsd').show()
        }

    })

    $('.searchLists li').mouseover(function () {
        $(this).addClass('checked')
    })
    $('.searchLists li').mouseout(function () {
        $(this).removeClass('checked')
    })

    $('.cardTr').mouseover(function () {
        $(this).addClass('checked')
    })
    $('.cardTr').mouseout(function () {
        $(this).removeClass('checked')
    })

    $('.tplicard').mouseover(function () {
        $(this).find('.tplicardCoindowna').addClass('checked')
    })
    $('.tplicard').mouseout(function () {
        $(this).find('.tplicardCoindowna').removeClass('checked')
    })




    $(document).on('mouseover','.sercontopUl li',function(){
        $(this).addClass('checked')
    })
    $(document).on('mouseout','.sercontopUl li',function(){
        $(this).removeClass('checked')
    })

    $('.searchinputop .text1').on('input', function () {
        if (!$(this).val()) { // 检查输入框是否为空
            $('.serconTitleRight').hide()
            $(this).parent().parent().addClass('dggbDengSerTitlemouse')
            $('.searchLine').show()
            $('.searchinputop').css('z-index', '10')
        } else {
            $('.serconTitleRight').show()
            if($(this).parent().parent().parent().parent().find('.bkTop').length <= 0){
                $(this).parent().parent().removeClass('dggbDengSerTitlemouse')
            }
            $(this).parent().parent().removeClass('dggbDengSerTitlemouse')
            $('.searchLine').hide()
            $('.searchinputop').css('z-index', '1003')
        }

    });

    $(document).on('click','.cookieSet b',function(){
        $('.cookieSet').hide()
    })

    $('.cokieAaccpet').click(function(){
        setCookie('accpect_cookie', 1, 30);
        layers.closeAll();
        $('.cookieSet').hide()
        $('.cookieSets').hide();
    })

    $('.cokieAreject').click(function(){
        setCookie('accpect_cookie', 0, 1);
        $('.cookieSets').hide();
        $('.cookieSet').hide()
    })

    $('.cokieAsetting').on('click',function(){
        if (windowWidth > 750) {
            layerIndex = layer.open({
                type: 1,
                title: false,
                closeBtn: false,
                shadeClose: false,
                content: $('#layuiDivcokie') //这里content是一个DOM，注意：最好该元素要存放在body最外层，否则可能被其它的相对元素所影响
            });
        }else{
            // layerIndex = layer.open({
            //     type: 1,
            //     title: false,
            //     closeBtn: false,
            //     shadeClose: true,
            //     area: [windowWidth + 'px','auto'],
            //     // maxHeight:654,
            //     offset: 'b',
            //     scrollbar: true,
            //     content: $('#weblayuiCookie') //这里content是一个DOM，注意：最好该元素要存放在body最外层，否则可能被其它的相对元素所影响
            // });
            
        }
        
    })
    if($('.weblayuiCookie').length > 0){
        if (windowWidth < 750) {

            layerIndex = layer.open({
                type: 1,
                title: false,
                closeBtn: false,
                shadeClose: true,
                area: [windowWidth + 'px','auto'],
                // maxHeight:654,
                offset: 'b',
                scrollbar: true,
                content: $('#weblayuiCookie') //这里content是一个DOM，注意：最好该元素要存放在body最外层，否则可能被其它的相对元素所影响
            });
        }
    }
        // cookie 
        $('.ckdLeft').on('click',function(){
            if($(this).parent().parent().find('.ckdDowns').css('display') == 'none'){
                $(this).parent().parent().find('.ckdDowns').show()
                $('.cokidownli').css('padding','30px 0 0 0')
                $(this).find('.ckdliImgleft').attr('src','/assets/pc/images/png95.png')
                $(this).find('.ckdliImgleft').css('height','4px')
            }else{
                $(this).parent().parent().find('.ckdDowns').hide()
                $('.cokidownli').css('padding','30px 0 25px 0')
                $(this).find('.ckdliImgleft').attr('src','/assets/pc/images/png94.png')
                $(this).find('.ckdliImgleft').css('height','24px')
            }
        })
        $('.ckdliImgright').on('click',function(){
            if($(this).attr('src') == '/assets/pc/images/png97.png'){
                $(this).attr('src','/assets/pc/images/png96.png') 
            }else{
                $(this).attr('src','/assets/pc/images/png97.png') 
            }
        })
    $('.webcoka').click(function(){
        layers.closeAll();
    })
    $('.webcokaSet').click(function(){
        $('.cookieSets').show();
    })
    $('.cokielayTop b').on('click', function() {
        layers.closeAll();
    })
    $('.cklydmiddleA').on('click', function() {
        $.each($('.ckdliImgright'), function (index, value) {
            $(this).attr('src','/assets/pc/images/png96.png') 
        });
    })
    $('.cklyBtnaright').click(function(){
        $.each($('.ckdliImgright'), function (index, value) {
            $(this).attr('src','/assets/pc/images/png96.png') 
        });
    })
    if($('.nameInput').length > 0){
        $('#username').parent().find('span').text($('#username').val().length+"/50");
    }   
    $('#username').on('input', function() {
        var valueLength = $(this).val().length;
        $(this).parent().find('span').text(valueLength+"/50");
    });
    if($('.nameInput').length > 0){
        $('#surname').parent().find('span').text($('#surname').val().length+"/50");
    }   
    $('#surname').on('input', function() {
        var valueLength = $(this).val().length;
        $(this).parent().find('span').text(valueLength+"/50");
    });
    if($('.Bioinput').length > 0){
        $('.Bioinput textarea').parent().find('span').text($('.Bioinput textarea').val().length+"/250");
    }
    $('.Bioinput textarea').on('input', function() {
        var valueLength = $(this).val().length;
        $(this).parent().find('span').text(valueLength+"/250");
    });
    if($('.Websiteinput').length > 0){
        $('.Websiteinput input').parent().find('span').text($('.Websiteinput input').val().length+"/100");
    }
    $('.Websiteinput input').on('input', function() {
        var valueLength = $(this).val().length;
        $(this).parent().find('span').text(valueLength+"/100");
    });
    
    
     // 首页 sggbTable tab 切换 
     $('.tblchoaall').on('click', function(e){
        $('.dggbShowMsg').css('display','flex')
        $('.fyxxPage').css('display','flex')
        $('.dggbShowRow').css('display','flex')
        $('.tblchoaall').hide()
        $('.allShows').show()
        $('.collectShows').hide()
        if($(this).hasClass('chooseallchoose')){
            $('.chooseall').css('display','none')
            $('.chooseallchoose').css('display','flex')
            $('.choosewatchlists').css('display','flex')
            $('.choosewatchlistschoose').css('display','none')
        }else{
            $('.chooseall').css('display','none')
            $('.chooseallchoose').css('display','flex')
            $('.choosewatchlists').css('display','flex')
            $('.choosewatchlistschoose').css('display','none')
        }
    })
    $('.tblchoacollect').on('click', function(e){
        $('.dggbShowMsg').css('display','none')
        $('.fyxxPage').css('display','none')
        $('.dggbShowRow').css('display','none')
        $('.tblchoacollect').hide()
        $('.allShows').hide()
        $('.collectShows').show()
        if($(this).hasClass('choosewatchlistschoose')){
            $('.choosewatchlistschoose').css('display','flex')
            $('.choosewatchlists').css('display','none')
            $('.chooseallchoose').css('display','none')
            $('.chooseall').css('display','flex')
        }else{
            $('.choosewatchlistschoose').css('display','flex')
            $('.choosewatchlists').css('display','none')
            $('.chooseallchoose').css('display','none')
            $('.chooseall').css('display','flex')
        }
    })

})

