$(document).ready(function() {

        if($('.footercomm').hasClass('d-none')){
            $('.footer-block_grid > div').css({'width':'50%'});
        }

    let pictureHeight = $('.block-article__pictures_titles img').prop('naturalHeight');
    let pictureWidth = $('.block-article__pictures_titles img').prop('naturalWidth');

    if(pictureHeight == pictureWidth){
        if(pictureWidth > 600){
            $('.block-article__pictures_titles img').css({'width':'50%'});
        }
    }
    if(pictureHeight > pictureWidth){
        if(pictureHeight < 2000 && pictureHeight > 700){
            $('.block-article__pictures_titles img').css({'width':'25%'});
        }
        if(pictureHeight < 700 && pictureHeight > 500){
            $('.block-article__pictures_titles img').css({'width':'50%'});
        }
    }
    if(pictureHeight < pictureWidth){
        $('.block-article__pictures_titles img').css({'width':'100%'});
        if(pictureWidth < 600){
            $('.block-article__pictures_titles img').css({'width':'500px'});
        }
    }

    function whatColor(){
        let mainColor = $('.header-content-block__top').css('background-color');
        if(tinycolor(mainColor).isLight()){
            $('.header-content-block__top').css({'color':'#333'});
            $('.header-content-block__top a').css({'color':'#333'});
            $('.if-not_comments_block').css({'color':'#333'});
            $('footer').css({'color':'#333'});
            $('.footer-block_grid ul li a').css({'color':'#333'});
        }else{
            $('.header-content-block__top').css({'color':'#fff'});
            $('.header-content-block__top a').css({'color':'#fff'});
            $('.if-not_comments_block').css({'color':'#fff'});
            $('footer').css({'color':'#fff'});
            $('.footer-block_grid ul li a').css({'color':'#fff'});
        }

    }

    if($('.header-content-block__center h1').css('text-align') == 'center'){
        $('.navigation-block').css({'justify-content':'center'});
    }

    if($('.header-content-block__bottom .navigation-block').css('display') == 'none'){
        $('.bread-block-new').show();
    }

    if($('.header-content-block__top').css('display') == 'none'){
        $('.block-article__pictures_titles .shareBlock').show();
    }

    if($('.block-article__pictures_titles').hasClass('flex-column') || $('.block-article__pictures_titles').hasClass('flex-column-reverse')){
        $('.block-article__pictures_titles > div').css({'width':'100%'});
    }

    let br = $('.related-box_wrapper-item_images img').css('border-radius');
    if($('.container-box').width() > 1180){
        $('.related-box_wrapper').css({'display':'flex','flex-direction':'row','gap':'20px'});
        $('.related-box_wrapper > div').css({'width':'33%'});
        $('.related-box_wrapper-item').css({'flex-direction':'column','border-radius':br});
        $('.related-box_wrapper-item > div').css({'width':'100%'});
        $('.related-box_wrapper-item_content > p a').css({'font-size':'22px'});
        if($('.block-article__pictures_titles .shareBlock').css('display') == 'none'){
            $('.related-box_wrapper-item_content').css({'position':'absolute','bottom':'0px','height':'100%', 'color':'#fff','display':'flex','flex-direction':'column', 'border-radius':br,'justify-content':'end','background':newRgba('#000000',20)});
            $('.linkRelated').css({'color':'#fff','text-shadow':'0px 0px 3px #4b4b4b','font-size':'20px'});
            $('.dateLatestBlock').css({'opacity':'0.9'});
            $('.related-box_wrapper-item_images').css({'height':'350px'});
            $('.related-box_wrapper-item').css({'padding':'0px'});
        }
    }

    let colorBlock = $('#colorBlock').attr('class');
    $('.comments_main-item').css({'background':newRgba(colorBlock,10)});

    if($('.author_latest_articles img').css('border-radius') == '50%'){
        $('.comments-a-block').css({'padding-bottom':'8px','border-bottom':'1px solid '+newRgba(colorBlock,20)});
    }

    if($('.block-comments_main').hasClass('flex-row')){
        $('.comments_main-item').css({'width':'33%'})
        $('footer').css({'background':colorBlock});
    }else{
        $('.footer-block').css({'background':colorBlock,'border-top-left-radius':br,'border-top-right-radius':br});
    }

    if($('.subscribe_block').css('text-align') == 'center'){
        $('.subscribe_block-item').css({'justify-content':'center'});
    }




    $('.linkRelated').each(function() {
        $(this).attr('href', $(this).parents('.related-box_wrapper-item').children('.related-box_wrapper-item_images').children('img').attr('src'));
    });




    $('.color-background').css({'background':newRgba('#000000',20)})


    function newRgba(hex,opacity){
        hex = hex.replace('#','');
        r = parseInt(hex.substring(0,2), 16);
        g = parseInt(hex.substring(2,4), 16);
        b = parseInt(hex.substring(4,6), 16);

        result = 'rgba('+r+','+g+','+b+','+opacity/100+')';
        return result;
    }

        whatColor();


});
