/** This code hides/displays different options of the "What would you like help with?" field based on the I'm looking for" field value. */

document.querySelector('.company-sector-field').addEventListener('change', function () {
    const val = this.value;
    const possibleValues = ["Hospitality", "Retail", "Partners"];
    const hospitalityValues = ["Property Management Solutions", "Networking solutions", "Accept Payments"];
    const retailValues = ["Tax Free Solutions", "Order Management Systems", "Accept Payments"];

    if (possibleValues.includes(val)) {
        const companySectorDeep = document.querySelector(".company-sector-deep-field");
        const options = companySectorDeep.querySelectorAll('option');

        options.forEach(option => {
            option.style.display = "none";
        });

        switch (val) {
            case 'Hospitality':
                hospitalityValues.forEach(option => {
                    const targetOption = companySectorDeep.querySelector('option[value="' + option + '"]');
                    if (targetOption) {
                        targetOption.style.display = "block";
                    }
                });
                break;
            case 'Retail':
                retailValues.forEach(option => {
                    const targetOption = companySectorDeep.querySelector('option[value="' + option + '"]');
                    if (targetOption) {
                        targetOption.style.display = "block";
                    }
                });
                break;
            default:
                // no action!
        }
    }
});