
function startTimer(duration, display) {
    var timer = duration, minutes, seconds;
    setInterval(function () {
        minutes = parseInt(timer / 60, 10);
        seconds = parseInt(timer % 60, 10);

        minutes = minutes < 10 ? "0" + minutes : minutes;
        seconds = seconds < 10 ? "0" + seconds : seconds;

        display.textContent = minutes + ":" + seconds;

        if (--timer < 0) {
            timer = duration;
        }
    }, 1000);
}

window.onload = function () {
    var thirteenMinutes = 60 * 32,
        display = document.querySelector('.js-timer');
    startTimer(thirteenMinutes, display);
    startTimer(thirteenMinutes, document.querySelector('.js-timer2'));
};




window.addEventListener('DOMContentLoaded', function () {

    var excludedLink = document.getElementById('toque1');

    var exclLink = document.getElementById('link_offer');

    var linken = document.getElementById('link_offer2')

    var links = document.getElementsByTagName('a');



    for (var i = 0; i < links.length; i++) {

        var link = links[i];

        if (link !== excludedLink && link !== exclLink && link !== linken) {

            link.href = '#toscroll';

        }

    }



});


const today = new Date();
const day = String(today.getDate()).padStart(2, '0');
const month = String(today.getMonth() + 1).padStart(2, '0'); // Январь - 0
const year = today.getFullYear();

// Форматируем дату в нужном формате
const formattedDate = `${day}.${month}.${year}`;

// Находим все элементы с классом js-date и присваиваем им сегодняшнюю дату
const dateElements = document.querySelectorAll('.js-date');
dateElements.forEach(element => {
    element.textContent = formattedDate;
});



function setAvaComs(avatars) {
    avatars = document.querySelectorAll(avatars);
    let i = 1;
    avatars.forEach(item => {
        item.setAttribute('src', `img/ava/${i}.png`);
        i++;
    });
}

setAvaComs('.comment-item img[alt="User Avatar"]');
