<script>
function toggledisablestate(){
    if (document.forms['addrule'].elements['state'].disabled)
    {
        document.forms['addrule'].elements['state'].disabled=false;
        document.forms['addrule'].elements['state'].value='';
    }else{
        document.forms['addrule'].elements['state'].disabled=true;
        document.forms['addrule'].elements['state'].value=lang('All States');
    }

    return false;
}

function toggledisableall(check_checkbox, default_country_code){
    if(check_checkbox){
        document.forms['addrule'].elements['allcountries'].checked=true;
    }

    if (document.forms['addrule'].elements['allcountries'].checked)
    {
        document.forms['addrule'].elements['state'].disabled=true;
        document.forms['addrule'].elements['state'].value=lang('All States');
    }else{
        document.forms['addrule'].elements['state'].disabled=false;
        document.forms['addrule'].elements['state'].value='';
    }
    
    if (document.forms['addrule'].elements['countrycode'].disabled)
    {
        document.forms['addrule'].elements['countrycode'].disabled=false;
        document.forms['addrule'].elements['countrycode'].value=default_country_code;
    }else{
        document.forms['addrule'].elements['countrycode'].disabled=true;
        document.forms['addrule'].elements['countrycode'].value='_ALL';
    }
    
    if (document.forms['addrule'].elements['all'].disabled)
    {
        document.forms['addrule'].elements['all'].disabled=false;
        document.forms['addrule'].elements['all'].checked=false;
    }else{
        document.forms['addrule'].elements['all'].disabled=true;
        document.forms['addrule'].elements['all'].checked=true;
    }
    

    return false;
}
</script>

  <form name="addrule" action="index.php?fuse=admin&action=AddTaxRules" method="POST">
    <table>
      <tr>
        <td>[l]Country[/l]:&nbsp;&nbsp;</td>
        <td>
          <select name=countrycode onChange="if (this.value == '_ALL') toggledisableall(true, '{defaultCountry}');">
            <option value="_ALL">[l]ALL COUNTRIES[/l]</option>
            <!-- BEGIN DYNAMIC BLOCK: country -->
            <option value="{countryCode}" {countrySelected}>{countryName}</option>
            <!-- END DYNAMIC BLOCK: country -->
          </select>&nbsp;&nbsp;<input type="checkbox" style="position:relative; left:2px; top:5px" name="allcountries" onClick="toggledisableall(false, '{defaultCountry}');"\>&nbsp;&nbsp;[l]All[/l]
        </td>
      </tr>
      <tr>
        <td>[l]State[/l]:</td>
        <td><input type=text name=state>&nbsp;&nbsp;<input type="checkbox" style="position:relative; left:2px; top:5px" name="all" onClick='toggledisablestate();';>&nbsp;&nbsp;[l]All[/l]</td>
      </tr>
      <input type="hidden" name="r_state" value='[l]State must be added[/l]'>
      <tr>
        <td>[l]Use VAT[/l]:&nbsp;</td>
        <td>
          <select name="vat">
            <option value="0">[l]No[/l]&nbsp;&nbsp;&nbsp;</option>
            <option value="1">[l]Yes[/l]&nbsp;&nbsp;&nbsp;</option>
          </select>
        </td>
      </tr>
      <tr>
        <td>[l]Tax[/l]:&nbsp;</td>
        <td><input type="text" name="tax" size="6" />&nbsp;<strong>%</strong></td>
      </tr>
      <input type="hidden" name="r_tax" value='[l]Tax rate must be added[/l]' />
      <input type="hidden" name="i_tax" value='[l]Tax rate must be a valid number[/l]'>
      <tr>
        <td colspan="2" align="right"><input type="submit" class="button_large" value="[l]Add Tax Rule[/l]" onClick='check(form,form.elements.length);return false;'></td>
      </tr>
      <tr>
        <td colspan="2" align="right">&nbsp;&nbsp;[l]Insert more[/l]<input type="checkbox" name="addanother" style="position:relative; left:2px; top:5px"></td>
      </tr>
    </table>
  </form>
