<script type="text/javascript">

    // 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->domainError || (isset($this->domainStatus) && $this->domainStatus == -2)) { ?>
<!-- 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)?$this->domainError:$this->lang("An unknown error has occurred.");?></td>
          </tr>
        </table>
    </div>
<?php } else { ?>
	<?php if($this->searchType == 'register') { ?>
		<!-- Handle registrations -->
        <?php if($this->domainStatus == 1 && !$this->domainNameSuggest) { ?>
            <!-- Domain is NOT available & we are NOT doing NameSuggest so nothing further to do. -->
            <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>
                </table>
            </div>
        <?php } ?>

            <?php if($this->domainStatus == 0 || $this->domainNameSuggest) { ?>
            <!-- Domain IS availalbe OR we are doing NameSuggest so we have something to show -->
            <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 if(isset($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 qtip="<?php echo $optionValue['description']; ?>" 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(isset($this->domainAddons) && is_array($this->domainAddons)) { ?>
				<!-- 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 } ?>	
			
			<input class="submit" id="submitButton" type="submit" value="<?php echo $this->lang('Continue');?> &raquo;" />
			
        <?php } ?>
	<?php } elseif($this->searchType == 'transfer') { ?>
		<!-- Handle transfers -->
		<div id="domainRegistered">
			<table class="ts2" cellspacing="0">
			  <tr>
				<td colspan="6" style="font-size:16px; font-weight:bold; color:#090;" id="textAlreadyRegistered"><?php echo $this->domainName." ".$this->lang('is available to transfer!');?></td>
			  </tr>
			</table>
		</div>
		<div id="transferOptions">
			<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="eppCode"><br /><span style="font-size:11px; color:#666;"><?php echo $this->lang("Enter the EPP transfer code from your existing registrar here (if you have one).");?></span></td>
				</tr>
                                
                                <?php if ( $this->transferCheckList ) { ?>
                                <tr>
                                    <td class="label"><?php echo $this->lang("Is the domain unlocked?");?></td>
                                    <td><input type="checkbox" name="domain_unlocked" class="required"><br /><span style="font-size:11px; color:#666;"><?php echo $this->lang("Please ensure your domain is not locked.");?></span></td>
                                </tr>
                                <tr>
                                    <td class="label"><?php echo $this->lang("Is private registration turned off?");?></td>
                                    <td><input type="checkbox" name="private_registration" class="required"><br /><span style="font-size:11px; color:#666;"><?php echo $this->lang("Please ensure private registration is not turned on for your domain.");?></span></td>
                                </tr>
                                 <tr>
                                    <td class="label"><?php echo $this->lang("Do you have access to the e-mail address listed as the registrant?");?></td>
                                    <td><input type="checkbox" name="email_address" class="required"><br /><span style="font-size:11px; color:#666;"><?php echo $this->lang("Please ensure that you have access to the e-mail address that is listed as the registrant.");?></span></td>
                                </tr>
                                <?php } ?>
			</table>
		</div>

		<input class="submit" id="submitButton" type="submit" value="<?php echo $this->lang('Continue');?> &raquo;" />
    
    <?php } elseif($this->searchType == 'selfmanage') { ?>
    	<!-- Handle SelfManage Nameservers -->
		<div id="defaultNameservers">
			<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 } ?>

<?php if ( $this->searchType == 'transfer' && $this->transferCheckList ) { ?>
<style type="text/css">
    span.invalid { color: red; padding-left: 10px;}
</style>
<script type="text/javascript" src="javascript/jquery.validate.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
    $("#domainForm").validate({
       errorClass: "invalid",
       errorElement: "span"
    });
});
</script>
<?php } ?>