<script>
    function CollapseShowTLDs(intID){
        $(intID+'_tlds').style.display="";
        $(intID+'_collapse').style.display="";
        $(intID+'_expand').style.display="none";
        return false;
    }
    function ExpandShowTLDs(intID){
        $(intID+'_tlds').style.display="none";
        $(intID+'_collapse').style.display="none";
        $(intID+'_expand').style.display="";
        return false;
    }
    function AddNewTLDEntry(intID,strName){
        $(intID+'new').style.display="";
    }
    function CancelNewTLDEntry(intID){
        $(intID+'new').style.display="none";
    }
    function SaveNewTLD(intID,strName){
        document.forms['tlds'].elements['action'].value='AddTld';
        document.forms['tlds'].elements['fuse'].value='admin';
        //if intID = '' then new TLD is passed not just new period
        if (intID==''){
                //need to check name
                //check to see if name is blank
                 if (isEmpty(trim(document.forms['tlds'].elements['newname'].value))){
                        alert('[lj]WARNING: You cannot leave the TLD extension name blank[/lj]');
                        return false;
                 }
                 //check to see that . is entered in front
                 if(document.forms['tlds'].elements['newname'].value.substring(0, 1)=='.'){
                        alert('[lj]ERROR: Your TLD extension does not need to start with a . symbol[/lj]');
                        return false;
                 }
                 //check to see if name already exists
                 intCount = document.forms['tlds'].elements.length;
                 bolShowMessage=true;
                 bolUsedAlready=false;
                 for(x=1;x<=intCount;x++){
                         tempString = document.forms['tlds'].elements[x-1].name;
                         if(tempString.substring(0, 4)=='name'){
                            tempId = tempString.substring(4);
                            if((document.forms['tlds'].elements[x-1].value==document.forms['tlds'].elements['newname'].value)){
                                  bolUsedAlready = true;
                            }
                         }
                 }
                 if(bolUsedAlready){
                          alert('WARNING: The TLD \''+document.forms['tlds'].elements['newname'].value+'\' has already been used');
                          document.forms['tlds'].elements['newname'].value=''; //set back to what it was
                          return false;
                 }
        }
        document.forms['tlds'].elements['tldname'].value=strName;
        document.forms['tlds'].elements['id'].value=intID;
        //check for valid prices
        if(!isFloat(document.forms['tlds'].elements[intID+'newprice'].value)){
                alert('[lj]WARNING: Your price is not in the proper format[/lj]');
                return false;
        }

        //check for valid transfer price
        if(!isFloat(document.forms['tlds'].elements[intID+'newtransfer'].value)){
                alert('[lj]WARNING: Your transfer setup is not in the proper format[/lj]');
                return false;
        }
        document.forms['tlds'].submit();
    }
    function UpdateTLD(intID,strName,bolTopTier){
        //only for TOP TIER
        if (bolTopTier) {
             //check to see if name is blank
             if (isEmpty(trim(document.forms['tlds'].elements['name'+intID].value))) {
                alert('[lj]WARNING: You cannot leave the TLD extension name blank[/lj]');
                document.forms['tlds'].elements['name'+intID].value=strName;
                return false;
             }
             //check to see that . is entered in front
             if (document.forms['tlds'].elements['name'+intID].value.substring(0, 1)=='.') {
                alert('[lj]ERROR: Your TLD extension does not need to start with a . symbol[/lj]');
                return false;
             }
             //check to see if name already exists
             intCount = document.forms['tlds'].elements.length;
             bolShowMessage=true;
             bolUsedAlready=false;
             for (x=1; x<=intCount; x++) {
                     tempString = document.forms['tlds'].elements[x-1].name;
                     if(tempString.substring(0, 4)=='name'){
                        tempId = tempString.substring(4);
                        if((tempId!=intID)&&(document.forms['tlds'].elements[x-1].value==document.forms['tlds'].elements['name'+intID].value)){
                              bolUsedAlready = true;
                        }
                     }
             }
             if (bolUsedAlready) {
                      alert('WARNING: The TLD \''+document.forms['tlds'].elements['name'+intID].value+'\' has already been used');
                      document.forms['tlds'].elements['name'+intID].value=strName; //set back to what it was
                      return false;
             } else {
                  document.forms['tlds'].elements['oldtldname'].value=strName;
                  strName=document.forms['tlds'].elements['name'+intID].value;
             }

        }

        //check for valid prices
        if (!isFloat(document.forms['tlds'].elements[intID+'price'].value)) {
            alert('[lj]WARNING: Your price is not in the proper format[/lj]');
            return false;
        }

        //check for valid transfer price
        if(!isFloat(document.forms['tlds'].elements[intID+'transfer'].value)){
            alert('[lj]WARNING: Your transfer setup is not in the proper format[/lj]');
            return false;
        }
        document.forms['tlds'].elements['action'].value='UpdateTld';
        document.forms['tlds'].elements['fuse'].value='admin';
        document.forms['tlds'].elements['tldname'].value=strName;
        document.forms['tlds'].elements['id'].value=intID;
        if (bolTopTier) {
            document.forms['tlds'].elements['bolTopTier'].value = '1';
        }
        document.forms['tlds'].submit();
    }
    
    function DeleteAllTLD(intID,strName) {
        bolSubmit=true;
        var answer=confirm('[lj]Clicking "OK" will delete all entries for TLD[/lj] "'+strName+'"');
        if (answer){
            document.forms['tlds'].elements['action'].value='DeleteAllTld';
            document.forms['tlds'].elements['fuse'].value='admin';
            document.forms['tlds'].elements['id'].value=intID;
            document.forms['tlds'].elements['tldname'].value=strName;
            document.forms['tlds'].submit();
        } else {
            return false;
        }
    }
    
    function DeleteTLD(intID,strName) {
        bolSubmit=true;
        var answer=confirm('[lj]Delete Entry? (OK = Yes  CANCEL = No)[/lj]');
        if (answer){
            document.forms['tlds'].elements['action'].value='DeleteTld';
            document.forms['tlds'].elements['fuse'].value='admin';
            document.forms['tlds'].elements['id'].value=intID;
            document.forms['tlds'].elements['tldname'].value=strName;
            document.forms['tlds'].submit();
        }else return false;
    }
</script>

<table bgcolor=white cellpadding=0 cellspacing=0 border=0 width=700>
  <tr>
    <td>
       <table border="0" cellpadding="0" cellspacing="0" width="100%">
         <tr>
           <td class="snapshot-header-left"></td>
           <td class="snapshot-header" nowrap="nowrap">
             <font class="snapshot-header-text">
               [l]Please enter the new TLD extension you want to support[/l]
             </font>
           </td>
           <td class="snapshot-header" align="right"></td>
           <td class="snapshot-header-right"></td>
         </tr>
       </table>
       <table width=100% cellpadding=4 cellspacing=1 border=0>
         <tr class=header>
           <td width=50 class='headerSelected'>[l]Name[/l]</td>
           <td width=90 align=left>&nbsp;&nbsp;[l]Period[/l]&nbsp;&nbsp;</td>
           <td width=60 align=left>[l]Price[/l]</td>
           <td width=60 align=left>[l]Renewal[/l]</td>
           <td width=80 align=left>[l]Transfer Setup[/l]</td>
           <td width=90 align=left>[l]Registrar Plugin[/l]</td>
           <td align=center>[l]Actions[/l]</td>
         </tr>
       </table>
       <form name=tlds method=post action=index.php?fuse=admin&action=TldManager>
       <input type=hidden name=action value=''>
       <input type=hidden name=fuse value=''>
       <input type=hidden name=tldname value=''>
       <input type=hidden name=oldtldname value=''>
       <input type=hidden name=bolTopTier value='0'>
       <input type=hidden name=id value=''>
       <table width=100% cellpadding=4 cellspacing=1 border=0>
         <tr>
           <td width=50 nowrap><b>.</b><input type=text name='newname' value='' size=6></td>
           <td width=90 align=left>
             <select name='newperiod'>
             <!-- BEGIN DYNAMIC BLOCK: new_tld_years -->
               <option value={YEAR_VALUE} {YEAR_SELECTED}>{YEAR_TEXT}&nbsp;&nbsp;</option>
             <!-- END DYNAMIC BLOCK: new_tld_years -->
             </select>
           </td>
           <td width=60 nowrap align=left><input type=text name='newprice' value='{ZERO}' size=6></td>
           <td width=60 nowrap align=left><input type=text name='newrenewal' value='{ZERO}' size=6></td>
           <td width=80 nowrap align=left><input type=text name='newtransfer' value='{ZERO}' size=6></td>
           <td width=90 nowrap align=left>
             <select name='newregistrar'>
             <!-- BEGIN DYNAMIC BLOCK: new_tld_registrars -->
               <option value="{PLUGIN_VALUE}" {PLUGIN_SEL}>{PLUGIN_NAME}&nbsp;&nbsp;</option>
             <!-- END DYNAMIC BLOCK: new_tld_registrars -->
             </select>
           </td>
           <td align=left>
             <input type=button class=button_large value = "[lh]Add New TLD[/lh]" onClick="SaveNewTLD('','');return false;">
           </td>
         </tr>
       </table>
       <br><br>
     </td>
   </tr>
   <tr>
     <td>
       <table border="0" cellpadding="0" cellspacing="0" width="100%">
         <tr>
           <td class="snapshot-header-left"></td>
           <td class="snapshot-header" nowrap="nowrap">
             <font class="snapshot-header-text">
               [l]Existing TLD Extensions[/l]
             </font>
           </td>
           <td class="snapshot-header" align="right"></td>
           <td class="snapshot-header-right"></td>
         </tr>
       </table>
     </td>
   </tr>
   <tr>
     <td>
       <table width=100% cellpadding=4 cellspacing=1 border=0>
         <tr class=header>
           <td width=15></td>
           <td width=50 class='headerSelected'>[l]Name[/l]</td>
           <td width=90 align=left>&nbsp;&nbsp;[l]Period[/l]&nbsp;&nbsp;</td>
           <td width=60 align=left>[l]Price[/l]</td>
           <td width=60 align=left>[l]Renewal[/l]</td>
           <td width=80 align=left>[l]Transfer Setup[/l]</td>
           <td width=90 align=left>[l]Registrar Plugin[/l]</td>
           <td  align=center>[l]Actions[/l]</td>
         </tr>
       </table>
       
       
       <!-- BEGIN DYNAMIC BLOCK: existing_tld -->
       <table width=100% cellpadding=4 cellspacing=1 border=0>
         <tr class=inner_odd>
           <td width=15 align=center>
             <div id='{TLD_ID}_expand' style="display:"><{IMGINPUT} src="../images/{EXPAND_IMG}" {EXPAND_JS}></div>
             <div id='{TLD_ID}_collapse' style="display:none"><{IMGINPUT} src="../images/collapse.jpg" {COLLAPSE_JS}></div>
           </td>
           <td width=50 nowrap><b>.</b>
             <input type=text name='name{TLD_ID}' value='{TLD_VALUE}' size=6>
           </td>
           <td width=90 align=left>
             <select name='{TLD_ID}period'>
             <!-- BEGIN DYNAMIC BLOCK: existing_tld_years -->
               <option value={YEAR_VALUE} {YEAR_SELECTED}>{YEAR_TEXT}&nbsp;&nbsp;</option>
             <!-- END DYNAMIC BLOCK: existing_tld_years -->
             </select>
           </td>
           <td width=60 nowrap align=left>
             <input type=text name='{TLD_ID}price' value='{TLD_REG_PRICE}' size=6>
           </td>
           <td width=60 nowrap align=left>
             <input type=text name='{TLD_ID}renewal' value='{TLD_REG_RENEWAL}' size=6>
           </td>
           <td width=80 nowrap align=left>
             <input type=text name='{TLD_ID}transfer' value='{TLD_TRANS_PRICE}' size=6>
           </td>
           <td width=90 nowrap align=left>
             <select name='{TLD_ID}registrar'>
             <!-- BEGIN DYNAMIC BLOCK: existing_tld_registrars -->
               <option value="{PLUGIN_VALUE}" {PLUGIN_SEL}>{PLUGIN_NAME}&nbsp;&nbsp;</option>
             <!-- END DYNAMIC BLOCK: existing_tld_registrars -->
             </select>
           </td>
           <td align=left>
             <input type=button class=button_medium value = "[lh]update[/lh]" onClick="UpdateTLD('{TLD_ID}','{TLD_VALUE}',true); return false;">
             <input type=button class=button_medium value = "[lh]delete[/lh]" onClick="DeleteTLD('{TLD_ID}','{TLD_VALUE}'); return false;">
             <!-- BEGIN DYNAMIC BLOCK: deleteall -->
             <input type=button class=button_large value = "[lh]Delete All[/lh]" onClick="DeleteAllTLD('{TLD_ID}','{TLD_VALUE}'); return false;">
             <!-- END DYNAMIC BLOCK: deleteall -->
             <input type=button class=button_small value = "[lh]Add[/lh]" onClick="AddNewTLDEntry('{TLD_ID}','{TLD_VALUE}'); return false;">
           </td>
         </tr>
       </table>
       <!-- BEGIN DYNAMIC BLOCK: sub_script -->
       <script>
         $('{TLD_ID}_collapse').style.display="";
         $('{TLD_ID}_expand').style.display="none";
       </script>
       <!-- END DYNAMIC BLOCK: sub_script -->
       <!-- BEGIN DYNAMIC BLOCK: sub_existing_tlds -->
       <div id='{TLD_ID}_tlds' style="display:{SUB_TLD_ID_DISP}">
         <!-- BEGIN DYNAMIC BLOCK: sub_existing_tld -->
         <table width=100% cellpadding=4 cellspacing=1 border=0>
           <tr class=inner_odd>
             <td width=15 align=center></td>
             <td width=50 nowrap></td>
             <td width=90 align=left>
               <select name='{SUB_TLD_ID}period'>
               <!-- BEGIN DYNAMIC BLOCK: sub_existing_tld_years -->
                 <option value={YEAR_VALUE} {YEAR_SELECTED}>{YEAR_TEXT}&nbsp;&nbsp;</option>
               <!-- END DYNAMIC BLOCK: sub_existing_tld_years -->
               </select>
             </td>
             <td width=60 nowrap align=left><input type=text name='{SUB_TLD_ID}price' value='{SUB_TLD_REG}' size=6></td>
             <td width=60 nowrap align=left><input type=text name='{SUB_TLD_ID}renewal' value='{SUB_TLD_RENEW}' size=6></td>
             <td width=80 nowrap align=left><input type=text name='{SUB_TLD_ID}transfer' value='{SUB_TLD_TRANS}' size=6></td>
             <td width=90><input type="hidden" name='{SUB_TLD_ID}registrar' value='{TLD_PLUGIN}'></td>
             <td align=left>
               <input type=button class=button_medium value = "update" onClick="UpdateTLD('{SUB_TLD_ID}','{TLD_VALUE}',false); return false;">
               <input type=button class=button_medium value = "delete" onClick="DeleteTLD('{SUB_TLD_ID}','{TLD_VALUE}'); return false;">
             </td>
           </tr>
         </table>
         <!-- END DYNAMIC BLOCK: sub_existing_tld -->
       </div>
       <!-- END DYNAMIC BLOCK: sub_existing_tlds -->

       <div id='{TLD_ID}new' style="display:none">
         <table width=100% cellpadding=4 cellspacing=1 border=0>
           <tr class=inner_odd>
             <td width=15 align=center></td>
             <td width=50 align=left><font color=red><b>New<br>{TLD_VALUE}</b></font></td>
             <td width=90 align=left>
               <select name='{TLD_ID}newperiod'>
               <!-- BEGIN DYNAMIC BLOCK: new_existing_tld_years -->
                 <option value={YEAR_VALUE} {YEAR_SELECTED}>{YEAR_TEXT}&nbsp;&nbsp;</option>
               <!-- END DYNAMIC BLOCK: new_existing_tld_years -->
               </select>
             </td>
             <td width=60 nowrap align=left><input type=text name='{TLD_ID}newprice' value='{ZERO}' size=6></td>
             <td width=60 nowrap align=left><input type=text name='{TLD_ID}newrenewal' value='{ZERO}' size=6></td>
             <td width=80 nowrap align=left><input type=text name='{TLD_ID}newtransfer' value='{ZERO}' size=6></td>
             <td width=90><input type="hidden" name='{TLD_ID}newregistrar' value='{TLD_PLUGIN}'></td>
             <td align=left>
               <input type="button" class="button_medium" value="[lh]Save[/lh]" onClick="SaveNewTLD('{TLD_ID}','{TLD_VALUE}'); return false;">
               <input type="button" class="button_medium" value="[lh]Cancel[/lh]" onClick="CancelNewTLDEntry('{TLD_ID}'); return false;">
             </td>
           </tr>
         </table>
       </div>
       <!-- END DYNAMIC BLOCK: existing_tld -->
       </form><br><br>
    </td>
  </tr>
  <tr>
    <td>
       <table border="0" cellpadding="0" cellspacing="0" width="100%">
         <tr>
           <td class="snapshot-header-left"></td>
           <td class="snapshot-header" nowrap="nowrap">
             <font class="snapshot-header-text">
               [l]TLD Options[/l]
             </font>
           </td>
           <td class="snapshot-header" align="right"></td>
           <td class="snapshot-header-right"></td>
         </tr>
       </table>
       <form name=options method=post action=index.php?fuse=admin&action=TldManager>
       <input type=hidden name=options value='1'>
       <table width=100% cellpadding=4 cellspacing=1 border=0>
         <tr class='primarycolor'>
           <td width=200>
             &nbsp;<img src="../images/sub_dot.gif">&nbsp;&nbsp;<span style="font-weight: bold">[l]Domains Taxable[/l]:</span><br /><br />
             <div class="smalltext">[l]When set to 'Yes', tax will be charged for domain purchases[/l].</div>
           </td>
           <td width=90 align=right><input type=radio name='taxable' value='1' {TAXABLE_YES}> [l]Yes[/l] <input type=radio name='taxable' value='0' {TAXABLE_NO}> [l]No[/l]</td>
         </tr>
         <tr class='secondarycolor'>
           <td width=200>
             &nbsp;<img src="../images/sub_dot.gif">&nbsp;&nbsp;<span style="font-weight: bold">[l]Default TLD[/l]:</span><br /><br />
             <div class="smalltext">[l]Select the TLD that should be preselected in the sign up form.[/l]</div>
           </td>
           <td width=90 align=right>
             <select name='defaultTLD'>
                <!-- BEGIN DYNAMIC BLOCK: default_tld -->
                <option value="{TLD_VALUE}" {TLD_SELECTED}>{TLD_VALUE}&nbsp;&nbsp;&nbsp;</option>
                <!-- END DYNAMIC BLOCK: default_tld -->
             </select>
           </td>
         </tr>
         <tr>
           <td></td>
           <td align=right>
             <input type=button class=button_large value = "[lh]Save[/lh]" onClick="document.forms['options'].submit();">
           </td>
         </tr>
         <tr>
           <td>
             <div class="yellowbox">
               <h2>[l]TLD Extension Setup Description[/l]</h2>
               <b>[l]NOTE:</b>  A period of "One Time" will not create a recurring transaction for domain registration.[/l]
             </div>
           </td>
         </tr>
       </table>
       <br><br>
     </td>
   </tr>
</table>
