<inp2:adm_SetPopupSize width="750" height="400"/>

<inp2:m_include t="incs/header"/>
<inp2:m_RenderElement name="combined_header" prefix="ap" section="in-commerce:affiliate_plans" title_preset="affiliate_plans_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('ap','<inp2:ap_SaveEvent/>');
						}
					) );
				a_toolbar.AddButton( new ToolBarButton('cancel', '<inp2:m_phrase label="la_ToolTip_Cancel" escape="1"/>', function() {
						submit_event('ap','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('ap', '<inp2:ap_PrevId/>');
						}
				 ) );
				a_toolbar.AddButton( new ToolBarButton('next', '<inp2:m_phrase label="la_ToolTip_Next" escape="1"/>', function() {
							go_to_id('ap', '<inp2:ap_NextId/>');
						}
				 ) );

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

				a_toolbar.Render();

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

<inp2:ap_SaveWarning name="grid_save_warning"/>
<inp2:ap_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="ap" field="AffiliatePlanId" title="la_fld_Id"/>
			<inp2:m_RenderElement name="inp_edit_box" prefix="ap" field="Name" title="la_fld_Name" size="40"/>
			<inp2:m_RenderElement name="inp_edit_radio" prefix="ap" field="PlanType" title="la_fld_PlanType"/>
			<inp2:m_RenderElement name="inp_edit_options" prefix="ap" field="ResetInterval" title="la_fld_Period"/>
			<inp2:m_RenderElement name="inp_edit_checkbox" prefix="ap" field="IsPrimary" title="la_fld_Primary" onchange="check_status()" />
			<inp2:m_RenderElement name="inp_edit_checkbox" prefix="ap" field="Enabled" title="la_fld_Enabled" onchange="check_primary()"/>

			<inp2:m_RenderElement design="form_row" prefix="ap" field="MinPaymentAmount" title="la_fld_MinimumPaymentAmount">
				<td class="control-cell">
					<input type="text" name="<inp2:$prefix_InputName field='$field' />" id="<inp2:$prefix_InputName field='$field' />" value="<inp2:$prefix_Field name='$field' />" tabindex="<inp2:m_get param='tab_index'/>" size="8"/>
					<span class="small">(<inp2:curr_PrimaryCurrencyISO />)</span>
				</td>
			</inp2:m_RenderElement>
		<inp2:m_RenderElement name="inp_edit_filler"/>
	</table>
</div>

<script type="text/javascript">
	if(document.getElementById('_cb_<inp2:ap_InputName field="IsPrimary"/>').checked)
	{
		document.getElementById('_cb_<inp2:ap_InputName field="IsPrimary"/>').disabled = true;
		document.getElementById('_cb_<inp2:ap_InputName field="Enabled"/>').disabled = true;
	}

	function check_status()
	{
		if(document.getElementById('_cb_<inp2:ap_InputName field="IsPrimary"/>').checked)
		{
			document.getElementById('_cb_<inp2:ap_InputName field="Enabled"/>').checked = true;
			document.getElementById('<inp2:ap_InputName field="Enabled"/>').value = 1;
		}
	}

	function check_primary()
	{
		if(!document.getElementById('_cb_<inp2:ap_InputName field="Enabled"/>').checked)
		{
			document.getElementById('_cb_<inp2:ap_InputName field="IsPrimary"/>').checked = false;
			document.getElementById('<inp2:ap_InputName field="IsPrimary"/>').value = 0;
		}
	}
</script>

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