/*---------------------------------------- Header Js--------------------------------------------------*/

function iasOpenMenu(){
    document.getElementById("iasMobileMenu").classList.toggle("ias-open");
}

function iasToggleDropdown(element){
    let dropdown = element.nextElementSibling;
    dropdown.style.display = dropdown.style.display === "block" ? "none" : "block";
}

/*---------------------------------------- contact cpatcha--------------------------------------------------*/

let iasCaptchaText = "";

function iasGenerateCaptcha() {
    let chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    iasCaptchaText = "";

    for (let i = 0; i < 5; i++) {
        iasCaptchaText += chars.charAt(Math.floor(Math.random() * chars.length));
    }

    document.getElementById("iasCaptchaCode").innerText = iasCaptchaText;
}

function iasValidateCaptcha() {
    let userInput = document.getElementById("iasCaptchaInput").value;

    if (userInput !== iasCaptchaText) {
        alert("Invalid Captcha! Please try again.");
        iasGenerateCaptcha();
        return false;
    }

    return true;
}

window.onload = function () {
    iasGenerateCaptcha();
};


/* FAQ Script */

function iasToggleFaq(element) {
    let card = element.parentElement;

    card.classList.toggle("ias-active");

    let icon = element.querySelector("i");

    if (card.classList.contains("ias-active")) {
        icon.classList.remove("fa-plus");
        icon.classList.add("fa-minus");
    } else {
        icon.classList.remove("fa-minus");
        icon.classList.add("fa-plus");
    }
}