//Start load and active sound
const activeSoundImg = "/assets/football-vn/images/volumn-loud.svg";
const unActiveSoundImg = "/assets/images/volume-off.svg";
const idTagSound = "#choose-tool-sound";

$(document).ready(function () {
    $('#breadcrumbs').text($('#breadcrumbs').text().replace('Chi tiếc', 'Chi tiết'))
    loadInitSound();
    function loadInitSound() {
        let sound = localStorage.getItem("sound");
        sound = sound ? JSON.parse(sound) : null;
        if (!sound) {
            sound = { active: true };
            localStorage.setItem("sound", JSON.stringify(sound));
        }
        toggleAllSounds(sound)
        setTimeout(() => {
            $(idTagSound).attr(
                "src",
                sound.active ? activeSoundImg : unActiveSoundImg
            );
        }, 200);
    }
});

function toggleAllSounds(sound) {
    if (!sound) {
        sound = JSON.parse(localStorage.getItem("sound"));
        sound.active = !sound.active;
        localStorage.setItem("sound", JSON.stringify(sound));
    }
    $("audio, video").each(function () {
        $(this).prop("muted", !sound.active);
    });
    $(idTagSound).attr("src", sound.active ? activeSoundImg : unActiveSoundImg);
}

//End load and active sound

//View passwork
function eyePasswork(isShow) {
    let type = isShow ? "text" : "password";
    $("#Password_head").attr("type", type);
    if (isShow) {
        $("#img-password-eye").removeClass("hide");
        $("#img-password-hide").addClass("hide");
    } else {
        $("#img-password-hide").removeClass("hide");
        $("#img-password-eye").addClass("hide");
    }
}
//----------END LOGIN---------------
