<?php
// Copyright 1999-2021. Plesk International GmbH. All rights reserved.
?>
<?php echo $this->partial('partials/forms/radio-controls.phtml', null, $this); ?>
<script type="text/javascript">
//<![CDATA[
(function () {
    var updateControlsState = function () {
        var bounce = document.getElementById('<?php echo $this->element->getElement('mailToNonExistentUser')->getId() ?>-bounce');
        var bounceText = document.getElementById('<?php echo $this->element->getElement('bounceText')->getId() ?>');
        if (bounce.checked) {
            bounceText.disabled = false;
        } else {
            bounceText.disabled = true;
        }

        var redirect = document.getElementById('<?php echo $this->element->getElement('mailToNonExistentUser')->getId() ?>-catch');
        var forwardToAddress = document.getElementById('<?php echo $this->element->getElement('forwardToAddress')->getId() ?>');
        if (redirect.checked) {
            forwardToAddress.disabled = false;
        } else {
            forwardToAddress.disabled = true;
        }

        <?php if ($this->redirectToIpOption):?>
        var externalMailServer = document.getElementById('<?php echo $this->element->getElement('mailToNonExistentUser')->getId() ?>-catch_ip');
        var redirectToIp = document.getElementById('<?php echo $this->element->getElement('redirectToIp')->getId() ?>');
        if (externalMailServer.checked) {
            redirectToIp.disabled = false;
        } else {
            redirectToIp.disabled = true;
        }
        <?php endif?>
    }

    document.getElementById('<?php echo $this->element->getElement('mailToNonExistentUser')->getId() ?>-bounce').addEventListener('click', updateControlsState);
    document.getElementById('<?php echo $this->element->getElement('mailToNonExistentUser')->getId() ?>-catch').addEventListener('click', updateControlsState);
    document.getElementById('<?php echo $this->element->getElement('mailToNonExistentUser')->getId() ?>-reject').addEventListener('click', updateControlsState);
    <?php if ($this->redirectToIpOption): ?>
        document.getElementById('<?php echo $this->element->getElement('mailToNonExistentUser')->getId() ?>-catch_ip').addEventListener('click', updateControlsState);
    <?php endif ?>
    updateControlsState();
})();
//]]>
</script>
