<?php
// Copyright 1999-2025. WebPros International GmbH. All rights reserved.
?>
<?php
$domainSelect = $this->element->getView()->form->getElement($this->elementName);
$elementIds = array();
foreach ($this->element->getElements() as $element) {
    $elementIds[] = $element->getId();
    echo $element;
}
?>
<script type="text/javascript">
//<![CDATA[
Jsw.onReady(function () {
    var updateState = function () {
        var elementIds = <?php echo Zend_Json::encode($elementIds); ?>;
        var noHostingDomains = <?php echo Zend_Json::encode($this->noHostingDomains); ?>;
        if (noHostingDomains.indexOf(Jsw.getComponent('<?php echo $domainSelect->getId(); ?>').getValue()) === -1) {
            elementIds.forEach(function (item) {
                document.getElementById(item).parentNode.style.display = '';
            });
        } else {
            elementIds.forEach(function (item) {
                document.getElementById(item).parentNode.style.display = 'none';
            });
        }
    }

    updateState();
    Jsw.getComponent('<?php echo $domainSelect->getId(); ?>').addEventObserver('component:change', updateState);
});
//]]>
</script>
