<inp2:adm_SetPopupSize width="870" height="600"/>

<inp2:m_include t="incs/header"/>
<inp2:m_RenderElement name="combined_header" prefix="coup" section="in-commerce:coupons" title_preset="coupons_edit" tab_preset="Default"/>

<!-- ToolBar -->
<table class="toolbar" height="30" cellspacing="0" cellpadding="0" width="100%" border="0">
<tbody>
	<tr>
  	<td>
  		<script type="text/javascript">
				a_toolbar = new ToolBar();
				a_toolbar.AddButton( new ToolBarButton('select', '<inp2:m_phrase label="la_ToolTip_Save" escape="1"/>', function() {
							submit_event('coup','<inp2:coup_SaveEvent/>');
						}
					) );
				a_toolbar.AddButton( new ToolBarButton('cancel', '<inp2:m_phrase label="la_ToolTip_Cancel" escape="1"/>', function() {
							submit_event('coup','OnCancel');
						}
				 ) );

				a_toolbar.AddButton( new ToolBarSeparator('sep1') );

				a_toolbar.AddButton( new ToolBarButton('prev', '<inp2:m_phrase label="la_ToolTip_Prev" escape="1"/>', function() {
							go_to_id('coup', '<inp2:coup_PrevId/>');
						}
				 ) );
				a_toolbar.AddButton( new ToolBarButton('next', '<inp2:m_phrase label="la_ToolTip_Next" escape="1"/>', function() {
							go_to_id('coup', '<inp2:coup_NextId/>');
						}
				 ) );

				//a_toolbar.AddButton( new ToolBarSeparator('sep2') );

				a_toolbar.Render();

				<inp2:m_if check="coup_IsSingle" >
					a_toolbar.HideButton('prev');
					a_toolbar.HideButton('next');
					a_toolbar.HideButton('sep1');
					//a_toolbar.HideButton('sep2');
				<inp2:m_else/>
					<inp2:m_if check="coup_IsLast" >
						a_toolbar.DisableButton('next');
					</inp2:m_if>
					<inp2:m_if check="coup_IsFirst" >
						a_toolbar.DisableButton('prev');
					</inp2:m_if>
				</inp2:m_if>
			</script>
		</td>
	</tr>
</tbody>
</table>

<script language="JavaScript">
function Random(N) {
    return Math.floor(N * (Math.random() % 1));
}

function generateRandomCode(elementId){
    var j, S = "", d;
    for (j = 0; j < 10; j++) {
    	d=Random(2);
    	if (d==1)
        	S += String.fromCharCode(65 + Random(26));
        else
        	S += String(Random(9));
    }
    document.getElementById(elementId).value=S;
}
</script>

<inp2:coup_SaveWarning name="grid_save_warning"/>
<inp2:coup_ErrorWarning name="form_error_warning"/>

<div id="scroll_container">
	<table class="edit-form">
		<inp2:m_RenderElement name="subsection" title="la_section_General"/>
			<inp2:m_RenderElement name="inp_label" prefix="coup" field="CouponId" title="la_fld_Id"/>
			<inp2:m_RenderElement name="inp_edit_radio" prefix="coup" field="Status" title="la_fld_Status"/>
			<inp2:m_RenderElement name="inp_edit_box" prefix="coup" field="Name" title="la_fld_Name" size="35"/>

			<inp2:m_RenderElement design="form_row" prefix="coup" field="Code" title="la_fld_CouponCode" size="35">
				<td class="control-cell">
					<input type="text" name="<inp2:{$prefix}_InputName field='$field'/>" id="<inp2:{$prefix}_InputName field='$field'/>" value="<inp2:{$prefix}_Field field='$field'/>" tabindex="<inp2:m_get param='tab_index'/>" size="<inp2:m_param name='size'/>">
					<input type="button" class="button" onClick="generateRandomCode('<inp2:{$prefix}_InputName field='$field'/>')" value="<inp2:m_Phrase label='la_GenerateCode' />" />
				</td>
			</inp2:m_RenderElement>

			<inp2:m_RenderElement name="inp_edit_date_time" prefix="coup" field="Expiration" title="la_fld_Expiration" size="10"/>

			<inp2:m_RenderElement name="inp_edit_options" prefix="coup" field="Type" title="la_fld_Type"/>
			<inp2:m_RenderElement name="inp_edit_box" prefix="coup" field="Amount" title="la_fld_Amount" size="4"/>

			<inp2:m_RenderElement name="inp_label" prefix="coup" field="LastUsedBy" title="la_fld_LastUsedBy" size="15"/>
			<inp2:m_RenderElement name="inp_label" prefix="coup" field="LastUsedOn" title="la_fld_LastUsedOn" size="10"/>

			<inp2:m_RenderElement design="form_row" prefix="coup" field="NumberOfUses" title="la_fld_NumberOfUses" size="4">
				<td class="control-cell">
					<input type="text" name="<inp2:{$prefix}_InputName field='$field'/>" id="<inp2:{$prefix}_InputName field='$field'/>" value="<inp2:{$prefix}_Field field='$field'/>" tabindex="<inp2:m_get param='tab_index'/>" size="<inp2:m_param name='size'/>">
					<inp2:m_Phrase label="la_comment_LeaveBlank" />
				</td>
			</inp2:m_RenderElement>

		<inp2:m_RenderElement name="inp_edit_filler"/>
	</table>
</div>

<inp2:m_include t="incs/footer"/>