<?php if($this->domainError) { ?>
<!-- Show any domain errors -->
    <div id="error">
        <table class="ts2" cellspacing="0">
          <tr>
            <td colspan="6" style="font-size:16px; font-weight:bold; color:red;"><?php echo $this->domainError;?></td>
          </tr>
        </table>
    </div>

    <input class="submit" id="submitButton" type="submit" disabled value="<?php echo $this->lang('Continue');?> &raquo;" />
<?php } else { ?>

    <script type="text/javascript">

    // Whilst we usually handle the hides / unhides in the template, in some situations
    // we need to do it in the template
    function processAction(action) {

        // Process the radio button clicks
        if(action == 'transferDomain') {
            // Transfer Domain
            document.getElementById('submitButton').disabled = false;
            document.getElementById('transferOptions').style.visibility = 'visible';
            document.getElementById('transferOptions').style.display = '';
            document.getElementById('defaultNameservers').style.visibility = 'hidden';
            document.getElementById('defaultNameservers').style.display = 'none';
            if(document.getElementById('noCheckRegisterOptions')) {
                document.getElementById('noCheckRegisterOptions').style.visibility = 'hidden';
                document.getElementById('noCheckRegisterOptions').style.display = 'none';
            }
        } else if(action == 'manageDomain') {
            // Manage Domain
            document.getElementById('submitButton').disabled = false;
            document.getElementById('transferOptions').style.visibility = 'hidden';
            document.getElementById('transferOptions').style.display = 'none';
            document.getElementById('defaultNameservers').style.visibility = 'visible';
            document.getElementById('defaultNameservers').style.display = '';
            if(document.getElementById('noCheckRegisterOptions')) {
                document.getElementById('noCheckRegisterOptions').style.visibility = 'hidden';
                document.getElementById('noCheckRegisterOptions').style.display = 'none';
            }
        } else if(action == 'registerDomain') {
            // Transfer Domain
            document.getElementById('submitButton').disabled = false;
            document.getElementById('transferOptions').style.visibility = 'hidden';
            document.getElementById('transferOptions').style.display = 'none';
            document.getElementById('defaultNameservers').style.visibility = 'hidden';
            document.getElementById('defaultNameservers').style.display = 'none';
            document.getElementById('noCheckRegisterOptions').style.visibility = 'visible';
            document.getElementById('noCheckRegisterOptions').style.display = '';
        }
    }

    // Function to show / hide additional attribute areas for namesuggested domains
    function handleNameSuggestAttributes(index,tld) {
        if(document.getElementById('extraAttributes-' + tld)) {
            if(index != -1) {
                document.getElementById('extraAttributes-' + tld).style.visibility = 'visible';
                document.getElementById('extraAttributes-' + tld).style.display = '';
            } else {
                document.getElementById('extraAttributes-' + tld).style.visibility = 'hidden';
                document.getElementById('extraAttributes-' + tld).style.display = 'none';
            }
        }
        return null;
    }
    </script>


    <?php if($this->checkingAvailablility) { ?>


        <?php if($this->domainStatus == 1 && !$this->domainNameSuggest) { ?>
            <!-- Registered Domain options -->
            <div id="domainRegistered">
                <table class="ts2" cellspacing="0">
                  <tr>
                    <td colspan="6" style="font-size:16px; font-weight:bold; color:red;" id="textAlreadyRegistered"><?php echo $this->domainName." ".$this->lang('is not currently available!');?></td>
                  </tr>
                  <?php if(@$this->allowTransfer) { ?>
                    <tr>
                        <td><input name="domainAction" type="radio" value="transfer" onclick="processAction('transferDomain');" /> <?php echo $this->lang("Transfer domain to us");?></td>
                    </tr>
                  <?php } ?>
                  <?php if(@$this->allowManage) { ?>
                    <tr>
                        <td><input name="domainAction" type="radio" value="manage" onclick="processAction('manageDomain');" /> <?php echo $this->lang("Manage domain yourself");?></td>
                    </tr>
                  <?php } ?>
                </table>
            </div>
        <?php } ?>




        <?php if($this->domainStatus == 0 || $this->domainNameSuggest) { ?>
            <!-- Available Domain options -->
            <div id="domainAvailable">
                <table class="ts2" border="0" cellspacing="0">
                    <?php if($this->domainStatus == 0) { ?>
                      <tr>
                        <td colspan="6" style="font-size:16px; font-weight:bold; color:#090;" id="textAvailable"><?php echo $this->domainName." ".$this->lang('is available to register!');?></td>
                      </tr>
                    <?php } else { ?>
                      <tr>
                        <td colspan="6" style="font-size:16px; font-weight:bold; color:red;" id="textAlreadyRegistered"><?php echo $this->domainName." ".$this->lang('is not currently available!');?></td>
                      </tr>
                    <?php } ?>
              <?php if($this->domainNameSuggest) { ?>
                  <tr>
                      <?php foreach($this->nameSuggestReturn AS $key) { ?>
                        <?php if($key['status'] == 1) { ?>
                            <td align="center" >
                                <strong>.<?php echo $key['tld'];?></strong>
                                <br /><?php echo $this->lang('from')." ".$key['fromPrice'];?><br /><br />
                                <select name="<?php echo $key['tld'];?>-registrationTerm" disabled>
                                    <option value="-1"><?php echo $this->lang('Not Available'); ?> &nbsp;</option>
                                </select>
                            </td>
                        <?php } elseif($key['status'] == 0) { ?>
                            <td align="center" style="background:#E9F2F7;">
                                <strong>.<?php echo $key['tld'];?></strong>
                                <br /><?php echo $this->lang('from')." ".$key['fromPrice'];?><br /><br />
                                <select name="<?php echo $key['tld'];?>-registrationTerm" onchange="handleNameSuggestAttributes(this.options[this.selectedIndex].value, '<?php echo $key['tld'];?>');">
                                    <?php if($key['searchedFor'] != true) { ?>
                                        <option value="-1" selected>Select a term</option>
                                    <?php } ?>
                                    <?php foreach($key['price'] AS $price) { ?>
                                        <?php if($price['price'] !== ''){?>
                                            <option value="<?php echo $price['period'];?>"><?php echo $price['period'];?> <?php if($price['period'] == 1) { echo $this->lang("Year"); } else { echo $this->lang("Years"); } ?> - <?php echo $price['price'];?></option>
                                        <?php } ?>
                                    <?php } ?>
                                </select>
                            </td>
                        <?php } ?>
                      <?php } ?>
                  </tr>
              <?php } else { ?>
                  <tr>
                    <td class="label"><?php echo $this->lang("Registration Term");?>:</td>
                    <td><select name="<?php echo $this->requestTld;?>-registrationTerm">
                            <?php foreach($this->domainPricing AS $key) { ?>
                                <?php if($key['price'] !== ''){?>
                                    <option value="<?php echo $key['period'];?>"><?php echo $key['period'];?> <?php if($key['period'] == 1) { echo $this->lang("Year"); } else { echo $this->lang("Years"); } ?> - <?php echo $key['price'];?></option>
                                <?php } ?>
                            <?php } ?>
                        </select>
                        <br /><span style="font-size:11px; color:#666;"><?php echo $this->lang("Select the Registration Term for this domain name.");?></span>
                    </td>
                   </tr>
              <?php } ?>
                </table>
            </div>
        <?php } ?>




        <?php if($this->transferOptions) { ?>
            <!-- Domain transfer options -->
            <div id="transferOptions" <?php if(@$this->allowTransfer && @$this->allowManage) {?> style="visibility:hidden; display:none;" <?php } ?>>
                <h3><?php echo $this->lang("Transfer Options");?></h3>
                <table class="ts2" cellspacing="0" style="margin-top:20px;">
                    <tr>
                        <td class="label"><?php echo $this->lang("Transfer Term");?>:</td>
                        <td><select name="transferTerm">
                                <?php foreach($this->domainPricing AS $key) { ?>
                                    <?php if($key['transfer'] !== ''){?>
                                        <option value="<?php echo $key['period'];?>"><?php echo $key['period'];?> <?php if($key['period'] == 1) { echo $this->lang("Year"); } else { echo $this->lang("Years"); } ?> - <?php echo $key['transfer'];?></option>
                                    <?php } ?>
                                <?php } ?>
                            </select>
                            <br /><span style="font-size:11px; color:#666;"><?php echo $this->lang("Select the transfer term for this domain.");?></span></td>
                    </tr>
                        <tr>
                        <td class="label"><?php echo $this->lang("EPP Code");?>:</td>
                        <td><input type="text" name="eepCode"><br /><span style="font-size:11px; color:#666;"><?php echo $this->lang("Enter the EPP transfer code from your existing registrar here.");?></span></td>
                    </tr>
                </table>
            </div>
        <?php } ?>

        <?php if(isset($this->defaultNameservers)) { ?>
            <!-- Domain transfer options -->
            <div id="defaultNameservers" <?php if(@$this->allowTransfer && @$this->allowManage) {?> style="visibility:hidden; display:none;" <?php } ?>>
                <h3><?php echo $this->lang("Our Nameservers");?></h3>
                <?php echo $this->lang('In order to use your Domain with our services you will need to configure the domain to point to the following DNS Nameservers');?>:
                <table class="ts2" cellspacing="0" style="margin-top:20px;">
                    <?php foreach($this->defaultNameservers AS $nameserver) { ?>
                        <tr>
                            <td><strong><?php echo $nameserver['hostname'];?></strong></td>
                         </tr>
                    <?php } ?>
                </table>
            </div>
        <?php } ?>

        <?php if($this->extraAttributes) { ?>
            <?php foreach($this->extraAttributesReturn AS $key) { ?>
                <!-- Domain Extra Attributes options <?php echo $key['tld'];?> -->
                <div id="extraAttributes-<?php echo $key['tld'];?>" <?php if(!$key['visible']) {?> style="visibility:hidden; display:none;" <?php } ?>>
                    <h3><?php echo $this->lang("Additional Information Required for .".$key['tld']." Domains");?></h3>
                    <table class="ts2" cellspacing="0" style="margin-top:20px;">
                        <?php foreach($key['attributes'] AS $attribute => $value) { ?>
                            <tr>
                                <td class="label"><?php echo @$value['name'];?>:</td>
                              <td>
                                  <?php if(@count($value['options']) == 0) { ?>
                                  <input type="text" name="<?php echo $key['tld'];?>-EA-<?php echo $attribute;?>" size="40">
                                  <?php } else { ?>
                                      <select name="<?php echo $key['tld'];?>-EA-<?php echo $attribute;?>">
                                        <?php foreach($value['options'] AS $option => $optionValue) { ?>
                                            <option value="<?php echo $optionValue['value'];?>"><?php echo $option;?> </option>
                                        <?php } ?>
                                      </select>
                                  <?php } ?>
                                  <br /><span style="font-size:11px; color:#666;"><?php echo $value['description']; ?></span>
                              </td>
                            </tr>
                        <?php } ?>
                    </table>
                </div>
            <?php } ?>
        <?php } ?>


        <?php if($this->domainHasAddons && ($this->domainStatus == 0 || $this->domainNameSuggest)) { ?>
            <!-- Domain Addons options -->
            <div id="domainAddons">
                <h3><?php echo $this->lang("Domain Addons");?></h3>
                <table class="ts2" cellspacing="0" style="margin-top:20px;">
                    <?php foreach ( $this->domainAddons as $addon ) { ?>
                    <tr>
                        <td class="label"><?php echo $this->lang($addon['name']);?>:</td>
                        <td>
                            <?php if ( @$addon['radio_buttons'] == '0' ) { ?>
                            <select name="addonSelect_<?php echo $addon['id']; ?>" class="dropdown">
                                <?php foreach ( $addon['prices'] as $price ) { ?>
                                <option value="addon_<?php echo $addon['id']; ?>_<?php echo $price['price_id']; ?>_<?php echo $price['recurringprice_cyle']; ?>" <?php echo $price['price_selected']; ?>><?php echo $price['price']; ?></option>
                                <?php } ?>
                            </select>
                            <?php } else { ?>
                                <?php foreach ( $addon['prices'] as $price ) { ?>
                            <span>
                                <input type="radio" name="addonSelect_<?php echo $addon['id']; ?>" class="dropdown" id="addon_<?php echo $addon['id']; ?>_<?php echo $price['price_id']; ?>_<?php echo $price['recurringprice_cyle']; ?>" value="addon_<?php echo $addon['id']; ?>_<?php echo $price['price_id']; ?>_<?php echo $price['recurringprice_cyle']; ?>" style="background:none; border:0px;" <?php echo $price['price_selected']; ?>/>
                                <?php echo $price['price']; ?>
                            </span>
                            <br/>
                                <?php } ?>
                            <?php } ?>
                            <?php if ( strlen($addon['desc']) > 0 ) { ?>
                            <br />
                            <span style="font-size:11px; color:#666;"><?php echo $this->lang($addon['desc']);?></span>
                            <?php } ?>
                        </td>
                    </tr>
            <?php } ?>
                </table>
            </div>
        <?php } ?>

    <?php } else { ?>

            <!-- Registered Domain options -->
            <div id="domainAvailable">
                <table class="ts2" cellspacing="0">
                  <tr>
                    <td colspan="6" style="font-size:16px; font-weight:bold; color:#090;" id="textAvailable"><?php echo $this->domainName." ".$this->lang('is available to register!');?></td>
                  </tr>
                  <tr>
                        <td><input name="domainAction" type="radio" value="register" onclick="processAction('registerDomain');" /> <?php echo $this->lang("Register this domain with us");?></td>
                    </tr>
                  <?php if(@$this->allowTransfer) { ?>
                    <tr>
                        <td><input name="domainAction" type="radio" value="transfer" onclick="processAction('transferDomain');" /> <?php echo $this->lang("Transfer domain to us");?></td>
                    </tr>
                  <?php } ?>
                  <?php if(@$this->allowManage) { ?>
                    <tr>
                        <td><input name="domainAction" type="radio" value="manage" onclick="processAction('manageDomain');" /> <?php echo $this->lang("Manage domain yourself");?></td>
                    </tr>
                  <?php } ?>
                </table>
            </div>

            <div id="noCheckRegisterOptions" style="visibility:hidden; display:none;">
                <table class="ts2" border="0" cellspacing="0">
                   <tr>
                    <td class="label"><?php echo $this->lang("Registration Term");?>:</td>
                    <td><select name="<?php echo $this->requestTld;?>-registrationTerm">
                            <?php foreach($this->domainPricing AS $key) { ?>
                                <?php if($key['price'] !== ''){?>
                                    <option value="<?php echo $key['period'];?>"><?php echo $key['period'];?> <?php if($key['period'] == 1) { echo $this->lang("Year"); } else { echo $this->lang("Years"); } ?> - <?php echo $key['price'];?></option>
                                <?php } ?>
                            <?php } ?>
                        </select>
                        <br /><span style="font-size:11px; color:#666;"><?php echo $this->lang("Select the Registration Term for this domain name.");?></span>
                    </td>
                </table>
                <?php if($this->domainHasAddons && ($this->domainStatus == 0 || $this->domainNameSuggest)) { ?>
                    <!-- Domain Addons options -->
                    <div id="domainAddons">
                        <h3><?php echo $this->lang("Domain Addons");?></h3>
                        <table class="ts2" cellspacing="0" style="margin-top:20px;">
                            <?php foreach ( $this->domainAddons as $addon ) { ?>
                            <tr>
                                <td class="label"><?php echo $this->lang($addon['name']);?>:</td>
                                <td>
                                    <?php if ( @$addon['radio_buttons'] == '0' ) { ?>
                                    <select name="addonSelect_<?php echo $addon['id']; ?>" class="dropdown">
                                        <?php foreach ( $addon['prices'] as $price ) { ?>
                                        <option value="addon_<?php echo $addon['id']; ?>_<?php echo $price['price_id']; ?>_<?php echo $price['recurringprice_cyle']; ?>" <?php echo $price['price_selected']; ?>><?php echo $price['price']; ?></option>
                                        <?php } ?>
                                    </select>
                                    <?php } else { ?>
                                        <?php foreach ( $addon['prices'] as $price ) { ?>
                                    <span>
                                        <input type="radio" name="addonSelect_<?php echo $addon['id']; ?>" class="dropdown" id="addon_<?php echo $addon['id']; ?>_<?php echo $price['price_id']; ?>_<?php echo $price['recurringprice_cyle']; ?>" value="addon_<?php echo $addon['id']; ?>_<?php echo $price['price_id']; ?>_<?php echo $price['recurringprice_cyle']; ?>" style="background:none; border:0px;" <?php echo $price['price_selected']; ?>/>
                                        <?php echo $price['price']; ?>
                                    </span>
                                    <br/>
                                        <?php } ?>
                                    <?php } ?>
                                    <?php if ( strlen($addon['desc']) > 0 ) { ?>
                                    <br />
                                    <span style="font-size:11px; color:#666;"><?php echo $this->lang($addon['desc']);?></span>
                                    <?php } ?>
                                </td>
                            </tr>
                    <?php } ?>
                        </table>
                    </div>
                <?php } ?>

            </div>

            <!-- Domain transfer options -->
            <div id="transferOptions" <?php if(@$this->allowTransfer && @$this->allowManage) {?> style="visibility:hidden; display:none;" <?php } ?>>
                <h3><?php echo $this->lang("Transfer Options");?></h3>
                <table class="ts2" cellspacing="0" style="margin-top:20px;">
                    <tr>
                        <td class="label"><?php echo $this->lang("Transfer Term");?>:</td>
                        <td><select name="transferTerm">
                                <?php foreach($this->domainPricing AS $key) { ?>
                                    <?php if($key['transfer'] !== ''){?>
                                        <option value="<?php echo $key['period'];?>"><?php echo $key['period'];?> <?php if($key['period'] == 1) { echo $this->lang("Year"); } else { echo $this->lang("Years"); } ?> - <?php echo $key['transfer'];?></option>
                                    <?php } ?>
                                <?php } ?>
                            </select>
                            <br /><span style="font-size:11px; color:#666;"><?php echo $this->lang("Select the transfer term for this domain.");?></span></td>
                    </tr>
                        <tr>
                        <td class="label"><?php echo $this->lang("EPP Code");?>:</td>
                        <td><input type="text"><br /><span style="font-size:11px; color:#666;"><?php echo $this->lang("Enter the EPP transfer code from your existing registrar here.");?></span></td>
                    </tr>
                </table>
            </div>

            <!-- Domain transfer options -->
            <div id="defaultNameservers" <?php if(@$this->allowTransfer && @$this->allowManage) {?> style="visibility:hidden; display:none;" <?php } ?>>
                <h3><?php echo $this->lang("Our Nameservers");?></h3>
                <?php echo $this->lang('In order to use your Domain with our services you will need to configure the domain to point to the following DNS Nameservers');?>:
                <table class="ts2" cellspacing="0" style="margin-top:20px;">
                    <?php foreach($this->defaultNameservers AS $nameserver) { ?>
                        <tr>
                            <td><strong><?php echo $nameserver['hostname'];?></strong></td>
                         </tr>
                    <?php } ?>
                </table>
            </div>

    <?php } ?>
    <input class="submit" id="submitButton" type="submit" <?php echo $this->submitButton;?> value="<?php echo $this->lang('Continue');?> &raquo;" />

<?php } ?>