/*Функция обработчик включения стилей*/
function CecutientOn(){
    $('#CecutientOn').css("display","none");
    $('#CecutientOff').css("display","inline-block");

    $.cookie("CecutientCookie", "on");
    return false;
}

/*Функции изменения размера шрифта*/
function SmallFonts(){
    if ($.cookie("CecutientCookie")=="on"){
        $('#wrap, .container p, p, a, #wrap *, p, button').removeClass("MediumFonts BigFonts SuperBigFonts").addClass("SmallFonts");
        $.cookie("fonts", "small");
        return false;
    }
}

function MediumFonts(){
    if ($.cookie("CecutientCookie")=="on"){
        $('#wrap, .container p, p, a, #wrap *, p, button').removeClass("SmallFonts BigFonts SuperBigFonts").addClass("MediumFonts");
        $.cookie("fonts", "medium");
        return false;
    }
}

function BigFonts(){
    if ($.cookie("CecutientCookie")=="on"){
        $('#wrap, .container p, p, a, #wrap *, p, button').removeClass("SmallFonts MediumFonts SuperBigFonts").addClass("BigFonts");
        $.cookie("fonts", "big");
        return false;
    }
}

function SuperBigFonts(){
    if ($.cookie("CecutientCookie")=="on"){
        $('#wrap, .container p, p, a, #wrap *, p, button').removeClass("SmallFonts MediumFonts BigFonts").addClass("SuperBigFonts");
        $.cookie("fonts", "superbig");
        return false;
    }
}

/*Функции обработчик отображения изображений*/
function ImageOn(){
    if ($.cookie("CecutientCookie")=="on"){
        $('img').css("display","inline-block");
        $('#ImageOff').css("display","inline-block");
        $('#ImageOn').css("display","none");
        $.cookie("image", "on");
        return false;
    }
}

function ImageOff(){
    if ($.cookie("CecutientCookie")=="on"){
        $('img').css("display","none");
        $('#ImageOff').css("display","none");
        $('#ImageOn').css("display","inline-block");
        $('#CecutientBtn img').css("display","inline-block");
        $.cookie("image", "off");
        return false;
    }
}

/*Функции изменения цветовой схемы*/
function WhiteStyle(){
    if ($.cookie("CecutientCookie")=="on"){
        $('body, html, #wrap *, .header, .navbar, .phone_next, .departments, .departments-block, .medical-examination, .time-block, .btn, .bg-feedback, .feedback-form, .footer').removeClass("BlackStyle BlueStyle GreenStyle").addClass("WhiteStyle");
        $('body, html, .header, .navbar, .phone_next, .departments, .departments-block, .medical-examination, .time-block, .btn, .bg-feedback, .feedback-form, .footer').css("background","#fff");
        $('p, a, button, span, h1, h2, h3, h4, h5, h6, label').css("color","#000");
        $('.navbar-default .navbar-toggle .icon-bar').attr('style', 'background: #000 !important');
        $('.form-check-input').attr('style', 'border:1px solid #000 !important');
        $.cookie("style", "white");
        return false;
    }
}

function BlackStyle(){
    if ($.cookie("CecutientCookie")=="on"){
        $('body, html, #wrap *, .header, .navbar, .phone_next, .departments, .departments-block, .medical-examination, .time-block, .btn, .bg-feedback, .feedback-form, .footer').removeClass("WhiteStyle BlueStyle GreenStyle").addClass("BlackStyle");
        $('body, html, .header, .navbar, .phone_next, .departments, .departments-block, .medical-examination, .time-block, .btn, .bg-feedback, .feedback-form, .footer').css("background","#000");
        $('p, a, button, span, h1, h2, h3, h4, h5, h6, label').css("color","#fff");
        $('.navbar-default .navbar-toggle .icon-bar, .form-control').attr('style', 'background: #fff !important');
        $('.form-check-input').attr('style', 'border:1px solid #fff !important');
        
        // Меняем цвет шрифта h5 и p внутри .card на чёрный
        $('.card h5, .card p').css('color', '#000');
        
        $.cookie("style", "black");
        return false;
    }
}

function BlueStyle(){
    if ($.cookie("CecutientCookie")=="on"){
        $('body, html, #wrap *, p, a, button, span, h1, h2, h3, h4, h5, h6, label, .header, .navbar, .phone_next, .departments, .departments-block, .medical-examination, .time-block, .btn, .bg-feedback, .slogan, .feedback-form, .footer, p, h').removeClass("WhiteStyle BlackStyle GreenStyle").addClass("BlueStyle");
        $('body, html, .header, .navbar, .phone_next, .departments, .departments-block, .medical-examination, .time-block, .btn, .bg-feedback, .feedback-form, .footer').css("background","#9DD1FF");
        $('p, a, button, span, h1, h2, h3, h4, h5, h6, label').css("color","#063462");
        $('.navbar-default .navbar-toggle .icon-bar, .form-control').attr('style', 'background: #063462 !important');
        $('.form-check-input').attr('style', 'border:1px solid #063462 !important');
        $.cookie("style", "blue");
        return false;
    }
}

function GreenStyle(){
    if ($.cookie("CecutientCookie")=="on"){
        $('body, html, #wrap *, .header, .navbar, .phone_next, .departments, .departments-block, .medical-examination, .time-block, .btn, .bg-feedback, .feedback-form, .footer').removeClass("WhiteStyle BlackStyle BlueStyle").addClass("GreenStyle");
        $('body, html, .header, .navbar, .phone_next, .departments, .departments-block, .medical-examination, .time-block, .btn, .bg-feedback, .feedback-form, .footer').css("background","#3B2716");
        $('p, a, button, span, h1, h2, h3, h4, h5, h6, label').css("color","#A9E44D");
        $('.navbar-default .navbar-toggle .icon-bar, .form-control').attr('style', 'background: #A9E44D !important');
        $('.form-check-input').attr('style', 'border:1px solid #A9E44D !important');
        $.cookie("style", "green");
        return false;
    }
}

$(document).ready(function(){

    var CecutientMenuShow = 0;

    $.cookie.defaults = { path: '/', expires: 365 };

    $('#CecutientBtn').on('click', function(){
        CecutientOn();
        WhiteStyle();
        if(CecutientMenuShow === 0){
            if ($(window).width() > 768) {
                $('#CecutientWrapper').slideDown(500);
                $('#wrap').animate({"top":"40px"}, 500);
            } else {
                $('#CecutientWrapper').slideDown(500);
                $('#wrap').animate({"top":"180px"}, 500);
            }
            CecutientMenuShow = 1;
        } else {
            $('#CecutientWrapper').slideUp(500);
            $('#wrap').animate({"top":"0px"}, 500);
            CecutientMenuShow = 0;
        }
        return false;
    });

    if ($.cookie("CecutientCookie")=="on"){
        CecutientOn();
        if ($.cookie("fonts")=="small"){SmallFonts();}
        if ($.cookie("fonts")=="medium"){MediumFonts();}
        if ($.cookie("fonts")=="big"){BigFonts();}
        if ($.cookie("fonts")=="superbig"){SuperBigFonts();}
        if ($.cookie("image")=="on"){ImageOn();}
        if ($.cookie("image")=="off"){ImageOff();}
        if ($.cookie("style")=="white"){WhiteStyle();}
        if ($.cookie("style")=="black"){BlackStyle();}
        if ($.cookie("style")=="blue"){BlueStyle();}
        if ($.cookie("style")=="green"){GreenStyle();}
    }

    /*alert($.cookie("fonts")+'&'+$.cookie("CecutientCookie"));*/
    /*Включение стилей для слабовидящих*/
    $('#CecutientOn').on('click',function(){CecutientOn(); WhiteStyle();});
    /*Включение выключение изображений*/
    $('#ImageOn').on('click',function(){ImageOn();});
    $('#ImageOff').on('click',function(){ImageOff();});
    /*Размер шрифта*/
    $('#SmallFonts').on('click',function(){SmallFonts();});
    $('#MediumFonts').on('click',function(){MediumFonts();});
    $('#BigFonts').on('click',function(){BigFonts();});
    $('#SuperBigFonts').on('click',function(){SuperBigFonts();});
    /*Цветовая схема*/
    $('#WhiteStyle').on('click',function(){WhiteStyle();});
    $('#BlackStyle').on('click',function(){BlackStyle();});
    $('#BlueStyle').on('click',function(){BlueStyle();});
    $('#GreenStyle').on('click',function(){GreenStyle();});
    
    /*Отключение версии для слабовидящих*/
    $('#CecutientOff').on('click',function(){
        $.removeCookie("CecutientCookie", { path: '/'});
        $.removeCookie("style", { path: '/'});
        $.removeCookie("image", { path: '/'});
        $.removeCookie("fonts", { path: '/'});
        window.location.reload();
        return false;
    });
});
