<inp2:adm_SetPopupSize width="820" height="570"/>

<inp2:m_include t="incs/header"/>
<inp2:m_RenderElement name="combined_header" prefix="ord" section="in-commerce:orders" title_preset="orders_edit_billing" 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('ord','<inp2:ord_SaveEvent/>');
						}
					) );
				a_toolbar.AddButton( new ToolBarButton('cancel', '<inp2:m_phrase label="la_ToolTip_Cancel" escape="1"/>', function() {
							submit_event('ord','OnCancelEdit');
						}
				 ) );

				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('ord', '<inp2:ord_PrevId/>');
						}
				 ) );
				a_toolbar.AddButton( new ToolBarButton('next', '<inp2:m_phrase label="la_ToolTip_Next" escape="1"/>', function() {
							go_to_id('ord', '<inp2:ord_NextId/>');
						}
				 ) );

				<inp2:m_if check="ord_OrderEditable">
					a_toolbar.AddButton( new ToolBarSeparator('sep2') );

					a_toolbar.AddButton( new ToolBarButton('reset_to_user', '<inp2:m_phrase label="la_ToolTip_ResetToUser" escape="1"/>', function() {
								submit_event('ord','OnResetToUser');
							}
					 ) );

					a_toolbar.AddButton( new ToolBarButton('in-commerce:reset_to_shipping', '<inp2:m_phrase label="la_ToolTip_ResetToShipping" escape="1"/>', function() {
								submit_event('ord','OnResetToShipping');
							}
					 ) );
				</inp2:m_if>

				a_toolbar.Render();

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

<script type="text/javascript">
	function OpenGWResults(field) {
		openSelector('ord', '<inp2:m_Link template="in-commerce/orders/gw_results" pass="m,ord" no_amp="1" js_escape="1"/>&field=' + field, '', '500x400');
	}
</script>

<inp2:m_DefineElement name="inp_gwresults" is_last="" as_label="" currency="" is_last="">
	<inp2:m_RenderElement design="form_row" pass_params="1">
		<td class="control-cell">
			<inp2:m_if check="m_Param" name="display_field"><inp2:m_Param name="display_field"/>: <inp2:Field name="$field" format="$display_field"/></inp2:m_if>
			<a href="javascript:OpenGWResults('<inp2:m_param name="field"/>')"><inp2:m_Phrase label="la_Details"/></a>
		</td>
	</inp2:m_RenderElement>
</inp2:m_DefineElement>

<inp2:m_RenderElement name="inp_edit_hidden" prefix="ord" field="Status" db="db"/>

<inp2:ord_SaveWarning name="grid_save_warning"/>
<inp2:ord_ErrorWarning name="form_error_warning"/>

<div id="scroll_container">
	<table class="edit-form">
		<inp2:m_RenderElement name="subsection" title="la_section_OrderBilling"/>
			<inp2:m_if check="ord_OrderEditable">
				<inp2:m_RenderElement name="inp_edit_box" prefix="ord" field="BillingTo" title="la_fld_BillingTo" size="40"/>
				<inp2:m_RenderElement name="inp_edit_box" prefix="ord" field="BillingCompany" title="la_fld_BillingCompany" size="40"/>
				<inp2:m_RenderElement name="inp_edit_box" prefix="ord" field="BillingPhone" title="la_fld_BillingPhone" size="20"/>
				<inp2:m_RenderElement name="inp_edit_box" prefix="ord" field="BillingFax" title="la_fld_BillingFax" size="20"/>
				<inp2:m_RenderElement name="inp_edit_box" prefix="ord" field="BillingEmail" title="la_fld_BillingEmail" size="20"/>
				<inp2:m_RenderElement name="inp_edit_box" prefix="ord" field="BillingAddress1" title="la_fld_BillingAddress1" size="40"/>
				<inp2:m_RenderElement name="inp_edit_box" prefix="ord" field="BillingAddress2" title="la_fld_BillingAddress2" size="40"/>
				<inp2:m_RenderElement name="inp_edit_box" prefix="ord" field="BillingCity" title="la_fld_BillingCity" size="20"/>
				<inp2:m_RenderElement name="inp_edit_box" prefix="ord" field="BillingState" title="la_fld_BillingState" size="20"/>
				<inp2:m_RenderElement name="inp_edit_box" prefix="ord" field="BillingZip" title="la_fld_BillingZip" size="10"/>
				<inp2:m_RenderElement name="inp_edit_options" prefix="ord" field="BillingCountry" title="la_fld_BillingCountry" size="20"/>
				<inp2:m_RenderElement name="inp_edit_options" prefix="ord" field="PaymentType" title="la_fld_PaymentType" onchange="submit_event('ord','OnPreSave');"/>

				<inp2:m_RenderElement name="inp_edit_checkbox" prefix="ord" field="IsRecurringBilling" title="la_fld_IsRecurringBilling"/>
				<inp2:m_RenderElement name="inp_edit_date_time" prefix="ord" field="NextCharge" title="la_fld_NextCharge"/>
				<inp2:m_RenderElement name="inp_edit_checkbox" prefix="ord" field="VATIncluded"/>

				<inp2:m_if check="ord_UsingCreditCard">
					<inp2:m_RenderElement name="subsection" title="la_section_CreditCard"/>
					<inp2:m_RenderElement name="inp_edit_options" prefix="ord" field="PaymentCardType" title="la_fld_PaymentCardType"/>
					<inp2:m_RenderElement name="inp_edit_box" prefix="ord" field="PaymentAccount" title="la_fld_CreditCardNumber" size="20"/>
					<inp2:m_RenderElement name="inp_edit_box" prefix="ord" field="PaymentNameOnCard" title="la_fld_PaymentNameOnCard" size="20"/>

					<inp2:m_RenderElement design="form_row" prefix="ord" field="PaymentCCExpDate" title="la_fld_PaymentCCExpDate">
						<td class="control-cell">
							<input type="text" size="3" maxlength="2" name="<inp2:ord_InputName field="PaymentCCExpMonth"/>" id="<inp2:ord_InputName field="PaymentCCExpMonth"/>" value="<inp2:ord_Field field="PaymentCCExpMonth"/>">
							/
							<input type="text" size="3" maxlength="2" name="<inp2:ord_InputName field="PaymentCCExpYear"/>" id="<inp2:ord_InputName field="PaymentCCExpYear"/>" value="<inp2:ord_Field field="PaymentCCExpYear"/>">
						</td>
					</inp2:m_RenderElement>

					<inp2:m_RenderElement name="inp_edit_box" prefix="ord" field="PaymentCVV2" title="la_fld_PaymentCVV2" size="5" maxlength="5"/>
					<inp2:m_RenderElement name="inp_edit_date_time" prefix="ord" field="PaymentExpires" title="la_fld_PaymentExpires" size="16"/>
					<inp2:m_RenderElement name="inp_edit_checkbox" prefix="ord" field="ChargeOnNextApprove" title="la_fld_ChargeOnNextApprove"/>
				<inp2:m_else/>
					<inp2:m_RenderElement name="inp_edit_box" prefix="ord" field="PaymentAccount" title="la_fld_PaymentAccount" size="20"/>
					<inp2:m_RenderElement name="inp_edit_date_time" prefix="ord" field="PaymentExpires" title="la_fld_PaymentDate" size="16"/>
				</inp2:m_if>

				<inp2:m_if check="ord_Field" name="GWResult1" db="db">
					<inp2:m_RenderElement name="inp_gwresults" prefix="ord" field="GWResult1" title="la_fld_AuthorizationResult" />
				</inp2:m_if>

				<inp2:m_if check="ord_Field" name="GWResult2" db="db">
					<inp2:m_RenderElement name="inp_gwresults" prefix="ord" field="GWResult2" title="la_fld_CaptureResult" />
				</inp2:m_if>
			<inp2:m_else/>
				<inp2:m_RenderElement name="inp_label" prefix="ord" field="BillingTo" title="la_fld_BillingTo" size="40"/>
				<inp2:m_RenderElement name="inp_label" prefix="ord" field="BillingCompany" title="la_fld_BillingCompany" size="40"/>
				<inp2:m_RenderElement name="inp_label" prefix="ord" field="BillingPhone" title="la_fld_BillingPhone" size="20"/>
				<inp2:m_RenderElement name="inp_label" prefix="ord" field="BillingFax" title="la_fld_BillingFax" size="20"/>
				<inp2:m_RenderElement name="inp_label" prefix="ord" field="BillingEmail" title="la_fld_BillingEmail" size="20"/>
				<inp2:m_RenderElement name="inp_label" prefix="ord" field="BillingAddress1" title="la_fld_BillingAddress1" size="40"/>
				<inp2:m_RenderElement name="inp_label" prefix="ord" field="BillingAddress2" title="la_fld_BillingAddress2" size="40"/>
				<inp2:m_RenderElement name="inp_label" prefix="ord" field="BillingCity" title="la_fld_BillingCity" size="20"/>
				<inp2:m_RenderElement name="inp_label" prefix="ord" field="BillingState" title="la_fld_BillingState" size="20"/>
				<inp2:m_RenderElement name="inp_label" prefix="ord" field="BillingZip" title="la_fld_BillingZip" size="10"/>
				<inp2:m_RenderElement name="inp_label" prefix="ord" field="BillingCountry" title="la_fld_BillingCountry" size="20"/>
				<inp2:m_RenderElement name="inp_label" prefix="ord" field="PaymentType" title="la_fld_PaymentType"/>

				<inp2:m_RenderElement name="inp_edit_checkbox" prefix="ord" field="IsRecurringBilling" title="la_fld_IsRecurringBilling"/>
				<inp2:m_RenderElement name="inp_edit_date_time" prefix="ord" field="NextCharge" title="la_fld_NextCharge"/>
				<inp2:m_RenderElement name="inp_label" prefix="ord" field="VATIncluded"/>

				<inp2:m_if check="ord_UsingCreditCard">
					<inp2:m_RenderElement name="subsection" title="la_section_CreditCard"/>
					<inp2:m_RenderElement name="inp_label" prefix="ord" field="PaymentCardType" title="la_fld_PaymentCardType"/>
					<inp2:m_RenderElement name="inp_label" prefix="ord" field="PaymentAccount" title="la_fld_CreditCardNumber"/>
					<inp2:m_RenderElement name="inp_label" prefix="ord" field="PaymentNameOnCard" title="la_fld_PaymentNameOnCard"/>

					<inp2:m_RenderElement design="form_row" prefix="ord" field="PaymentCCExpDate" title="la_fld_PaymentCCExpDate">
						<td class="control-cell">
							<inp2:ord_Field field="PaymentCCExpMonth"/> / <inp2:ord_Field field="PaymentCCExpYear"/>
						</td>
					</inp2:m_RenderElement>

					<inp2:m_RenderElement name="inp_label" prefix="ord" field="PaymentCVV2" title="la_fld_PaymentCVV2"/>
					<inp2:m_RenderElement name="inp_label" prefix="ord" field="PaymentExpires" title="la_fld_PaymentExpires"/>
				<inp2:m_else/>
					<inp2:m_RenderElement name="inp_label" prefix="ord" field="PaymentAccount" title="la_fld_PaymentAccount"/>
					<inp2:m_RenderElement name="inp_label" prefix="ord" field="PaymentExpires" title="la_fld_PaymentDate"/>
				</inp2:m_if>

				<inp2:m_if check="ord_Field" name="GWResult1" db="db">
					<inp2:m_RenderElement name="inp_gwresults" prefix="ord" field="GWResult1" title="la_fld_AuthorizationResult" />
				</inp2:m_if>

				<inp2:m_if check="ord_Field" name="GWResult2" db="db">
					<inp2:m_RenderElement name="inp_gwresults" prefix="ord" field="GWResult2" title="la_fld_CaptureResult" />
				</inp2:m_if>
			</inp2:m_if>

			<inp2:m_if check="ord_Field" name="CouponId">
				<inp2:m_RenderElement name="inp_label" prefix="ord" field="CouponCode" title="la_fld_CouponCode" />
			</inp2:m_if>
			<inp2:m_RenderElement name="inp_label" prefix="ord" field="DiscountTotal" title="la_fld_TotalSavings" />
			<inp2:m_RenderElement name="inp_label" prefix="ord" field="ReturnTotal" title="la_fld_TotalReturns" />

			<inp2:m_if check="ord_FieldEquals" name="VAT" value="0.00">
			<inp2:m_else />
				<inp2:m_RenderElement name="inp_label" prefix="ord" field="AmountWithoutVAT" title="la_fld_SubTotal" />
				<inp2:m_RenderElement name="inp_label" prefix="ord" field="VAT" title="la_fld_VAT" />
			</inp2:m_if>

			<inp2:m_if check="ord_Field" name="GiftCertificateId">
				<inp2:m_RenderElement name="inp_label" prefix="ord" field="GiftCertificateCode" title="la_fld_GiftCertificateNumber" />
				<inp2:m_RenderElement name="inp_label" prefix="ord" field="GiftCertificateDiscount" title="la_fld_GiftCertificateAmountApplied" />
			</inp2:m_if>


			<inp2:m_RenderElement name="inp_label" prefix="ord" field="TotalAmount" title="la_fld_TotalAmount" />
			<inp2:m_if check="ord_HasOriginalAmount" >
				<inp2:m_RenderElement name="inp_label" prefix="ord" field="OriginalAmount" title="la_fld_OriginalAmount" />
			</inp2:m_if>
		<inp2:m_RenderElement name="inp_edit_filler"/>
	</table>
</div>

<input type="hidden" name="to_tab" value="Billing">
<input type="hidden" name="check_billing_address" value="true" />
<inp2:m_if check="ord_UsingCreditCard">
	<input type="hidden" name="check_credit_card" value="true" />
</inp2:m_if>

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