// Author  Raivis Rampāns
// Created 29.02.2024
// Editor Raivis
// Modified 29.02.2024

document.addEventListener('DOMContentLoaded', function() { // Pareizo pogu padara zaļu, nepareizos sarkanus
        const correctButton = document.getElementById('correctbutton');
        const incorrectButtons = document.querySelectorAll('.incorrectbutton');
    
        correctButton.addEventListener('click', function() {
            correctButton.style.backgroundColor = 'green';
            incorrectButtons.forEach(button => {
                button.style.backgroundColor = 'red';
            });
        });
    
        incorrectButtons.forEach(button => {
            button.addEventListener('click', function() {
                button.style.backgroundColor = 'red';
            });
        });
    });
    
    var correctAnswers = 0;
    
    function checkAnswer(button) {
        const buttons = document.querySelectorAll('button');
        buttons.forEach(button => {
            if (button.textContent === document.getElementById('correctTitleValue').value) {
                button.style.backgroundColor = 'green';
                button.disabled = true;
                correctAnswers++;
            } else {
                button.style.backgroundColor = 'red';
                button.disabled = true;
            }
        });
    
        // Parāda pareizo atbildi virs plakāta/poster
        document.getElementById('correctTitle').textContent = document.getElementById('correctTitleValue').value;
    
        // Pēc 3 sekundēm aizsūta uz nākamo jautājumu
        setTimeout(function() {
            // Redirect to the next level
            const nextAnimeId = document.getElementById('nextAnimeId').value;
            if (nextAnimeId) {
                window.location.href = "minigame.php?id=" + nextAnimeId; // Aizsūta uz nākamo jautājumu
            } else {
                // Aizsūta uz nobeiguma lapu
                window.location.href = "minigameend.php";
            }
        }, 3000);
    }
    
    