<?php
// Copyright 1999-2024. WebPros International GmbH. All rights reserved.
?>
<script type="text/javascript">
//<![CDATA[
Jsw.onReady(function () {
    var servicePlanElement = document.getElementById('subscription-subscriptionInfo-servicePlan');
    var createSubscriptionElement = document.getElementById('subscription-domainInfo-createSubscription');
    var updatePlanControlsState = function () {
        var addonPlanSelector = document.getElementById('subscription-subscriptionInfo-addonPlanSelector');
        if ('0' == servicePlanElement.value) {
            if (addonPlanSelector) {
                addonPlanSelector.closest('.form-row').style.display = 'none';
            }
            document.getElementById('subscription-subscriptionInfo-customize').checked = true;
        } else {
            if (addonPlanSelector) {
                addonPlanSelector.closest('.form-row').style.display = '';
            }
            document.getElementById('subscription-subscriptionInfo-customize').checked = false;
        }
    };

    var updateAllControlsState = function () {
        var visible = createSubscriptionElement.checked;
        var formRow = createSubscriptionElement.closest('.form-row');
        while ((formRow = formRow.nextElementSibling)) {
            formRow.style.display = visible ? '' : 'none';
        }
        document.getElementById('subscription-subscriptionInfo').style.display = visible ? '' : 'none';
        document.getElementById('subscription-adminInfo').style.display = visible ? '' : 'none';
    };
    if (servicePlanElement) {
        updatePlanControlsState();
        servicePlanElement.addEventListener('change', updatePlanControlsState);
    }

    if (createSubscriptionElement) {
        createSubscriptionElement.addEventListener('click', updateAllControlsState);
    }
});
//]]>
</script>
