<inp2:adm_SetPopupSize width="780" height="640"/>

<inp2:m_include t="incs/header"/>
<inp2:m_RenderElement name="combined_header" prefix="gc" section="in-commerce:gift-certificates" title_preset="gift_certificates_edit"/>

<!-- 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('gc','<inp2:gc_SaveEvent/>');
						}
					) );


				a_toolbar.AddButton( new ToolBarButton('in-commerce:save_and_print', '<inp2:m_phrase label="la_ToolTip_SaveAndPrint" escape="1"/>', function() {
								set_hidden_field('print_certificate', 1);
								submit_event('gc','<inp2:gc_SaveEvent/>');
							}
						) );


				a_toolbar.AddButton( new ToolBarButton('cancel', '<inp2:m_phrase label="la_ToolTip_Cancel" escape="1"/>', function() {
							submit_event('gc','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('gc', '<inp2:gc_PrevId/>');
						}
				 ) );
				a_toolbar.AddButton( new ToolBarButton('next', '<inp2:m_phrase label="la_ToolTip_Next" escape="1"/>', function() {
							go_to_id('gc', '<inp2:gc_NextId/>');
						}
				 ) );

				a_toolbar.Render();

				<inp2:m_if check="gc_IsSingle" >
					a_toolbar.HideButton('prev');
					a_toolbar.HideButton('next');
					a_toolbar.HideButton('sep1');
				<inp2:m_else/>
					<inp2:m_if check="gc_IsLast" >
						a_toolbar.DisableButton('next');
					</inp2:m_if>
					<inp2:m_if check="gc_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:gc_SaveWarning name="grid_save_warning"/>
<inp2:gc_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_id_label" prefix="gc" field="GiftCertificateId" title="la_fld_Id"/>

			<inp2:m_if check="gc_HasOrder">
				<inp2:m_RenderElement name="inp_label" prefix="gc" field="Purchaser" title="la_fld_SenderName" size="35"/>
				<inp2:m_RenderElement name="inp_label" prefix="gc" field="Recipient" title="la_fld_RecipientName" size="35"/>
				<inp2:m_RenderElement name="inp_label" prefix="gc" field="Message" title="la_fld_MessageText" cols="35" rows="7"/>
				<inp2:m_RenderElement name="inp_label" prefix="gc" field="Amount" title="la_fld_Amount" size="7"/>

				<inp2:m_RenderElement name="inp_label" prefix="gc" field="SendVia" title="la_fld_DeliveryMethod"/>
			<inp2:m_else/>
				<inp2:m_RenderElement name="inp_edit_box" prefix="gc" field="Purchaser" title="la_fld_SenderName" size="35"/>
				<inp2:m_RenderElement name="inp_edit_box" prefix="gc" field="Recipient" title="la_fld_RecipientName" size="35"/>
				<inp2:m_RenderElement name="inp_edit_textarea" prefix="gc" field="Message" title="la_fld_MessageText" cols="35" rows="7"/>
				<inp2:m_RenderElement name="inp_edit_box" prefix="gc" field="Amount" title="la_fld_Amount" size="7"/>

				<inp2:m_RenderElement name="inp_edit_radio" prefix="gc" field="SendVia" title="la_fld_DeliveryMethod"/>
			</inp2:m_if>

		<inp2:m_RenderElement name="subsection" title="la_section_EmailDelivery"/>
			<inp2:m_if check="gc_HasOrder">
				<inp2:m_RenderElement name="inp_label" prefix="gc" field="RecipientEmail" title="la_fld_Email" size="35"/>
			<inp2:m_else/>
				<inp2:m_RenderElement name="inp_edit_box" prefix="gc" field="RecipientEmail" title="la_fld_Email" size="35"/>
			</inp2:m_if>

		<inp2:m_RenderElement name="subsection" title="la_section_PostalDelivery"/>
			<inp2:m_if check="gc_HasOrder">
				<inp2:m_RenderElement name="inp_label" prefix="gc" field="RecipientFirstname" title="la_fld_FirstName" size="35"/>
				<inp2:m_RenderElement name="inp_label" prefix="gc" field="RecipientLastname" title="la_fld_LastName" size="35"/>
				<inp2:m_RenderElement name="inp_label" prefix="gc" field="RecipientAddress1" title="la_fld_AddressLine1"/>
				<inp2:m_RenderElement name="inp_label" prefix="gc" field="RecipientAddress2" title="la_fld_AddressLine2"/>
				<inp2:m_RenderElement name="inp_label" prefix="gc" field="RecipientCity" title="la_fld_City"/>
				<inp2:m_RenderElement name="inp_label" prefix="gc" field="RecipientZipcode" title="la_fld_Zip"/>
				<inp2:m_RenderElement name="inp_label" prefix="gc" field="RecipientState" title="la_fld_State"/>
				<inp2:m_RenderElement name="inp_label" prefix="gc" field="RecipientCountry" title="la_fld_Country"/>
				<inp2:m_RenderElement name="inp_label" prefix="gc" field="RecipientPhone" title="la_fld_Phone"/>
			<inp2:m_else/>
				<inp2:m_RenderElement name="inp_edit_box" prefix="gc" field="RecipientFirstname" title="la_fld_FirstName" size="35"/>
				<inp2:m_RenderElement name="inp_edit_box" prefix="gc" field="RecipientLastname" title="la_fld_LastName" size="35"/>
				<inp2:m_RenderElement name="inp_edit_box" prefix="gc" field="RecipientAddress1" title="la_fld_AddressLine1"/>
				<inp2:m_RenderElement name="inp_edit_box" prefix="gc" field="RecipientAddress2" title="la_fld_AddressLine2"/>
				<inp2:m_RenderElement name="inp_edit_box" prefix="gc" field="RecipientCity" title="la_fld_City"/>
				<inp2:m_RenderElement name="inp_edit_box" prefix="gc" field="RecipientZipcode" title="la_fld_Zip"/>
				<inp2:m_RenderElement name="inp_edit_box" prefix="gc" field="RecipientState" title="la_fld_State"/>
				<inp2:m_RenderElement name="inp_edit_options" prefix="gc" field="RecipientCountry" title="la_fld_Country" has_empty="1"/>
				<inp2:m_RenderElement name="inp_edit_box" prefix="gc" field="RecipientPhone" title="la_fld_Phone"/>
			</inp2:m_if>

		<inp2:m_RenderElement name="subsection" title="la_section_Properties"/>
			<inp2:m_RenderElement name="inp_edit_radio" prefix="gc" field="Status" title="la_fld_Status"/>

			<inp2:m_if check="gc_HasOrder">
				<inp2:m_RenderElement name="inp_label" prefix="gc" field="AddDate" title="la_fld_CreatedOn"/>
				<inp2:m_RenderElement name="inp_label" prefix="gc" field="Code" title="la_fld_Code" size="35"/>
			<inp2:m_else/>
				<inp2:m_RenderElement name="inp_edit_date_time" prefix="gc" field="AddDate" title="la_fld_CreatedOn"/>

				<inp2:m_RenderElement design="form_row" prefix="gc" field="Code" title="la_fld_Code" 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_if>

			<inp2:m_if check="gc_IsNewItem" inverse="inverse">
				<inp2:m_RenderElement name="inp_label" prefix="gc" field="Debit" title="la_fld_RemainingAmount" size="7"/>
			</inp2:m_if>

			<inp2:m_if check="gc_HasOrder">
				<inp2:m_RenderElement name="inp_label" prefix="gc" field="Expiration" title="la_fld_Expiration" size="10"/>
			<inp2:m_else/>
				<inp2:m_RenderElement name="inp_edit_date_time" prefix="gc" field="Expiration" title="la_fld_Expiration" size="10"/>
			</inp2:m_if>
		<inp2:m_RenderElement name="inp_edit_filler"/>
	</table>
</div>

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