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

				a_toolbar.Render();

				<inp2:m_if check="curr_IsSingle" >
					a_toolbar.HideButton('prev');
					a_toolbar.HideButton('next');
					a_toolbar.HideButton('sep1');
					a_toolbar.HideButton('sep2');
				<inp2:m_else/>
					<inp2:m_if check="curr_IsLast" >
						a_toolbar.DisableButton('next');
					</inp2:m_if>
					<inp2:m_if check="curr_IsFirst" >
						a_toolbar.DisableButton('prev');
					</inp2:m_if>
				</inp2:m_if>

			</script>
		</td>
	</tr>
</tbody>
</table>

<inp2:curr_SaveWarning name="grid_save_warning"/>
<inp2:curr_ErrorWarning name="form_error_warning"/>

<div id="scroll_container">
	<table class="edit-form">
		<inp2:m_RenderElement name="subsection" title="!la_section_Currency!"/>
			<inp2:m_RenderElement name="inp_label" prefix="curr" field="CurrencyId" title="!la_fld_Id!"/>
			<inp2:m_RenderElement name="inp_label" prefix="curr" field="ISO" title="!la_fld_ISOCode!"/>

			<inp2:m_if check="curr_FieldVisible" field="RateToPrimary">
				<tr class="<inp2:m_odd_even odd='edit-form-odd' even='edit-form-even'/>">
					<inp2:m_RenderElement name="inp_edit_field_caption" prefix="curr" field="RateToPrimary" title="!la_fld_RateToPrimary!" />
					<td class="control-cell">
						<input type="text" name="<inp2:curr_InputName field='RateToPrimary'/>" id="<inp2:curr_InputName field='RateToPrimary'/>" value="<inp2:curr_Field field='RateToPrimary'/>" size="10">
						<input type="button" class="button" onclick="submit_event('curr', 'OnUpdateRate')" value="<inp2:m_phrase label='la_UpdateRate'/>">
						<span class="small">1 <inp2:curr_Field field="ISO"/> = ? <inp2:curr_PrimaryCurrencyISO /></span>
					</td>
					<inp2:m_RenderElement name="inp_edit_error" prefix="curr" field="RateToPrimary"/>
				</tr>
			</inp2:m_if>

			<inp2:m_if check="curr_FieldVisible" field="Symbol">
				<tr class="<inp2:m_odd_even odd='edit-form-odd' even='edit-form-even'/>">
					<inp2:m_RenderElement name="inp_edit_field_caption" prefix="curr" field="Symbol" title="!la_fld_CurrencySymbol!"/>
					<td class="control-cell">
						<input type="text" name="<inp2:curr_InputName field='Symbol'/>" id="<inp2:curr_InputName field='Symbol'/>" value="<inp2:curr_Field field='Symbol'/>" tabindex="<inp2:m_get param='tab_index'/>" size="10">
						<span class="small"><inp2:m_phrase label="la_ISOUsedIfBlank" /></span>
						<inp2:curr_Error field="Symbol"/>
					</td>
					<inp2:m_RenderElement name="inp_edit_error" prefix="curr" field="Symbol"/>
				</tr>
			</inp2:m_if>

			<inp2:m_RenderElement name="inp_edit_radio" prefix="curr" field="SymbolPosition" title="!la_fld_CurrencySymbolPosition!"/>

			<inp2:m_RenderElement name="inp_edit_box" prefix="curr" field="Name" title="!la_fld_CurrencyName!" size="40"/>
			<inp2:m_RenderElement name="inp_edit_checkbox" prefix="curr" field="IsPrimary" title="!la_fld_Primary!" onchange="check_status()"/>
			<inp2:m_RenderElement name="inp_edit_checkbox" prefix="curr" field="Status" title="!la_fld_Enabled!" onchange="check_primary()"/>
			<inp2:m_RenderElement name="inp_edit_box" prefix="curr" field="Priority" title="!la_fld_Priority!" size="5"/>
		<inp2:m_RenderElement name="inp_edit_filler"/>
	</table>
</div>

<script type="text/javascript">
	if(document.getElementById('_cb_curr[<inp2:curr_field field="CurrencyId" />][IsPrimary]').checked)
	{
		document.getElementById('_cb_curr[<inp2:curr_field field="CurrencyId" />][IsPrimary]').disabled = true;
		document.getElementById('_cb_curr[<inp2:curr_field field="CurrencyId" />][Status]').disabled = true;
	}

	function check_status()
	{
		if(document.getElementById('_cb_curr[<inp2:curr_field field="CurrencyId" />][IsPrimary]').checked)
		{
			document.getElementById('_cb_curr[<inp2:curr_field field="CurrencyId" />][Status]').checked = true;
			document.getElementById('<inp2:curr_InputName field="Status"/>').value = 1;
		}
	}

	function check_primary()
	{
		if(!document.getElementById('_cb_curr[<inp2:curr_field field="CurrencyId" />][Status]').checked)
		{
			document.getElementById('_cb_curr[<inp2:curr_field field="CurrencyId" />][IsPrimary]').checked = false;
			document.getElementById('<inp2:curr_InputName field="IsPrimary"/>').value = 0;
		}
	}
</script>

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