<script type="text/javascript">
    function toggleType()
    {
        form = document.coupon_form;
        symbolElement = document.getElementById('symbol');
        if (form.discount_type.value == 'amount') {
            symbolElement.innerHTML = "{currencySymbol}";
            $('trApplyTo').style.display = 'none';
        } else {
            symbolElement.innerHTML = '%';
            $('trApplyTo').style.display = '';
        }
    }

    function validateForm(form)
    {
            check(form, form.elements.length);
    }
    
    function toggleRecurring()
    {
        if($('recurring').value == 0){
            $('recurringtimefield').style.display = 'none';
        }else{
            $('recurringtimefield').style.display = 'inline';
        }
    }
</script>
<form name="coupon_form" method="POST" action="index.php?fuse=admin&action=SaveCoupon">
<input type="hidden" name="couponid" value="{couponId}" />
<table border=0>
    <tr>
      <td class="formlabel" align="right">&nbsp;&nbsp;&nbsp;[l]Name[/l]:</td>
      <td class="formfield">
        <input class="required" type="text" name="name" value="{couponName}" />
        <input type="hidden" name="r_name" value="Name" />
      </td>
    </tr>
    <tr>
      <td class="formlabel" align="right">&nbsp;&nbsp;&nbsp;[l]Description[/l]:</td>
      <td class="formfield">
        <textarea name="description">{couponDescription}</textarea>
      </td>
    </tr>
    <tr>
      <td class="formlabel" align="right">&nbsp;&nbsp;&nbsp;[l]Code[/l]:</td>
      <td class="formfield"><input class="body" type="text" name="code" value="{couponCode}" />&nbsp;&nbsp;{codePopup}</td>
    </tr>
    <tr>
      <td class="formlabel" align="right">&nbsp;&nbsp;&nbsp;[l]Quantity[/l]:</td>
      <td class="formfield"><input class="body" type="text" name="quantity" value="{couponQuantity}" />&nbsp;&nbsp;{quantityPopup}</td>
    </tr>
    <tr>
      <td class="formlabel" align="right">&nbsp;&nbsp;&nbsp;[l]Discount type[/l]:</td>
      <td class="formfield">
        <select name="discount_type" onchange="toggleType();return true;">
            <option value="amount" {amountSelected}>[l]Amount[/l]</option>
            <option value="percentage" {percentageSelected}>[l]Percentage[/l]</option>
        </select>
      </td>
    </tr>
    <tr id="trApplyTo" style="display:{displayApplyTo}">
      <td class="formlabel" valign="top" align="right">&nbsp;&nbsp;&nbsp;[l]Apply coupon to[/l]:</td>
      <td class="formfield">
        <select name="applyTo[]" multiple="true">
            <option value="domainRegistration" {applyToDomainRegistrationSelected}>[l]Domain Name Registration[/l]</option>
            <option value="domainTransfer" {applyToDomainTransferSelected}>[l]Domain Name Transfer[/l]</option>
            <option value="package" {applyToPackageSelected}>[l]Package[/l]</option>
            <option value="packageSetup" {applyToPackageSetupSelected}>[l]Package Setup[/l]</option>
            <option value="addons" {applyToAddonsSelected}>[l]Package Add-ons[/l]</option>
            <option value="addonsSetup" {applyToAddonsSetupSelected}>[l]Package Add-ons Setup[/l]</option>
            <option value="other" {applyToOtherSelected}>[l]Other invoice items[/l]</option>
        </select>
      </td>
    </tr>
    <tr>
      <td class="formlabel" align="right">&nbsp;&nbsp;&nbsp;[l]Discount[/l]:</td>
      <td class="formfield">
        <input class="required" type="text" name="discount" value="{couponDiscount}" />&nbsp;<span id="symbol">{discountSymbol}</span>
        <input type="hidden" name="r_discount" value="Discount" />
        <input type="hidden" name="i_discount" value="Discount" />
      </td>
    </tr>
    <tr>
      <td class="formlabel" align="right">&nbsp;&nbsp;&nbsp;[l]Start Date[/l]:</td>
      <td class="formfield">
        <input class="required" type="text" name="start_date" id="start_date" value="{couponStart}" />&nbsp;
        <input type="hidden" name="r_start_date" value="Start Date" />
        <img id="calButton" src="images/dynCalendar.gif" style="cursor:pointer"/>
        <link rel="stylesheet" type="text/css" href="newedge/javascript/jscalendar/calendar-win2k-cold-1.css" />
        <script type="text/javascript">
            Calendar.setup({
                inputField      : 'start_date',
                ifFormat        : '{dateFormat}',
                showsTime       : false,
                button          : 'calButton',
                weekNumbers     : false,
                step            : 1
            });
        </script>
      </td>
    </tr>
    <tr>
      <td class="formlabel" align="right">&nbsp;&nbsp;&nbsp;[l]Expiration Date[/l]:</td>
      <td class="formfield">
        <input class="body" type="text" name="expires" id="expires" value="{couponExpires}" />&nbsp;
        <img id="calButton2" src="images/dynCalendar.gif" style="cursor:pointer"/>
        <link rel="stylesheet" type="text/css" href="newedge/javascript/jscalendar/calendar-win2k-cold-1.css" />
        <script type="text/javascript">
            Calendar.setup({
                inputField      : 'expires',
                ifFormat        : '{dateFormat}',
                showsTime       : false,
                button          : 'calButton2',
                weekNumbers     : false,
                step            : 1
            });
        </script>
        &nbsp;&nbsp;{expirationPopup}
      </td>
    </tr>
    <tr>
      <td class="formlabel" align="right">&nbsp;&nbsp;&nbsp;[l]Recurring[/l]:</td>
      <td class="formfield">
        <select id="recurring" name="recurring" onchange="toggleRecurring();">
            <option value="1" {recurringYesSelected}>[l]Yes[/l]</option>
            <option value="0" {recurringNoSelected}>[l]No[/l]</option>
        </select>
        &nbsp;&nbsp;{recurringPopup}
        <span id="recurringtimefield" style="display:{displayRecurringTimeField};">
            &nbsp;&nbsp;&nbsp;[l]Duration[/l]:
            <input class="body" type="text" size=2 id="recurringmonths" name="recurringmonths" value="{couponRecurringTime}" />
            [l]month(s)[/l]&nbsp;&nbsp;{recurringTimePopup}
        </span>
      </td>
    </tr>
    <tr>
      <td class="formlabel" align="right">&nbsp;&nbsp;&nbsp;[l]Apply coupon before or after taxes[/l]:</td>
      <td class="formfield">
        <select id="taxable" name="taxable">
            <option value="1" {taxableYesSelected}>[l]Before[/l]</option>
            <option value="0" {taxableNoSelected}>[l]After[/l]</option>
        </select>
      </td>
    </tr>
    <tr>
      <td class="formlabel" valign="top" align="right">&nbsp;&nbsp;&nbsp;[l]Packages[/l]:</td>
      <td class="formfield">
        <select multiple name="applies_to[]">
            <!-- BEGIN DYNAMIC BLOCK: package -->
                <option value="{applies_toValue}" {packageSelected}>{applies_toText}</option>
            <!-- END DYNAMIC BLOCK: package -->
        </select>
      </td>
    </tr>
    <tr>
      <td class="formlabel" valign="top" align="right">&nbsp;&nbsp;&nbsp;[l]Billing Cycles[/l]:</td>
      <td class="formfield">
        <input type="checkbox" name="bcycle_all" {bcycle_all_checked}/>&nbsp;&nbsp;[l]All[/l]<br />
        <input type="checkbox" name="bcycle_1" {bcycle_1_checked}/>&nbsp;&nbsp;[l]Monthly[/l]<br />
        <input type="checkbox" name="bcycle_4" {bcycle_4_checked}/>&nbsp;&nbsp;[l]Quarterly[/l]<br />
        <input type="checkbox" name="bcycle_6" {bcycle_6_checked}/>&nbsp;&nbsp;[l]Semiannually[/l]<br />
        <input type="checkbox" name="bcycle_12" {bcycle_12_checked}/>&nbsp;&nbsp;[l]Yearly[/l]<br />
        <input type="checkbox" name="bcycle_24" {bcycle_24_checked}/>&nbsp;&nbsp;[l]Every 2 Years[/l]<br />
        <input type="checkbox" name="bcycle_0" {bcycle_0_checked}/>&nbsp;&nbsp;[l]Setup Fee Only (No Recurring Fee)[/l]
      </td>
    </tr>
    
    <input type="hidden" name="archive" value="0" />
    
</table>
<input type="submit" class="button_large" name="add_coupon" value="{submitBtnValue}" onclick="validateForm(this.form);return false;" />
</form>
