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

    function validateForm(form)
    {
        if (form.discount_type.value == 'percentage' && form.recurring.value == '1') {
            alert(lang("You can't set percentage recurring discount coupons."));
            return false;
        } else {
            check(form, form.elements.length);
        }
    }
</script>
<form name="coupon_form" method="POST" action="index.php">
<input type="hidden" name="fuse" value="{fuse}" />
<input type="hidden" name="action" value="{action}" />
<input type="hidden" name="couponid" value="{couponId}" />
<table border=0>
    <tr class="{trClassOdd}">
      <td width=150>&nbsp;&nbsp;&nbsp;[l]Name[/l]:</td>
      <td>
        <input class="required" type="text" name="name" value="{couponName}" />
        <input type="hidden" name="r_name" value="Name" />
      </td>
    </tr>
    <tr class="{trClassEven}">
      <td width=150>&nbsp;&nbsp;&nbsp;[l]Description[/l]:</td>
      <td>
        <textarea name="description">{couponDescription}</textarea>
      </td>
    </tr>
    <tr class="{trClassOdd}">
      <td width=150>&nbsp;&nbsp;&nbsp;[l]Code[/l]:</td>
      <td><input class="body" type="text" name="code" value="{couponCode}" />&nbsp;&nbsp;{codePopup}</td>
    </tr>
    <tr class="{trClassEven}">
      <td width=150>&nbsp;&nbsp;&nbsp;[l]Quantity[/l]:</td>
      <td><input class="body" type="text" name="quantity" value="{couponQuantity}" />&nbsp;&nbsp;{quantityPopup}</td>
    </tr>
    <tr class="{trClassOdd}">
      <td width=150>&nbsp;&nbsp;&nbsp;[l]Discount type[/l]:</td>
      <td>
        <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 class="{trClassEven}">
      <td width=150>&nbsp;&nbsp;&nbsp;[l]Discount[/l]:</td>
      <td>
        <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 class="{trClassOdd}">
      <td width=150>&nbsp;&nbsp;&nbsp;[l]Start Date[/l]:</td>
      <td>
        <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="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 class="{trClassEven}">
      <td width=150>&nbsp;&nbsp;&nbsp;[l]Expiration Date[/l]:</td>
      <td>
        <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="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 class="{trClassOdd}">
      <td width=150>&nbsp;&nbsp;&nbsp;[l]Recurring[/l]:</td>
      <td>
        <select name="recurring"><option value="1" {recurringYesSelected}>[l]Yes[/l]</option><option value="0" {recurringNoSelected}>[l]No[/l]</option></select>
        &nbsp;&nbsp;{recurringPopup}
    </td>
    </tr>
    <tr class="{trClassEven}">
      <td width=150>&nbsp;&nbsp;&nbsp;[l]Packages[/l]:</td>
      <td>
        <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 class="{trClassOdd}">
      <td width=150>&nbsp;&nbsp;&nbsp;[l]Billing Cycles[/l]:</td>
      <td>
        <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_0" {bcycle_0_checked}/>&nbsp;&nbsp;[l]Setup Fee Only (No Recurring Fee)[/l]
      </td>
    </tr>
</table>
<input type="submit" class="button_large" name="add_coupon" value="{submitBtnValue}" onclick="validateForm(this.form);return false;" />
</form>
