<inp2:adm_SetPopupSize width="790" height="520"/>

<inp2:m_include t="incs/header"/>
<inp2:m_RenderElement name="combined_header" prefix="pt" section="in-commerce:payment_types" title_preset="gateway" tab_preset="Default"/>

<inp2:m_DefineElement name="GatewayFieldsDiv">
	<inp2:m_RenderElement name="grid_data_td" />
</inp2:m_DefineElement>

<inp2:m_DefineElement name="dummy">
</inp2:m_DefineElement>

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

				a_toolbar.Render();

				<inp2:m_if check="pt_IsSingle" >
					a_toolbar.HideButton('prev');
					a_toolbar.HideButton('next');
					a_toolbar.HideButton('sep1');
				<inp2:m_else/>
					<inp2:m_if check="pt_IsLast" >
						a_toolbar.DisableButton('next');
					</inp2:m_if>
					<inp2:m_if check="pt_IsFirst" >
						a_toolbar.DisableButton('prev');
					</inp2:m_if>
				</inp2:m_if>
			</script>
		</td>
	</tr>
</tbody>
</table>

<script type="text/javascript">

function refresh_fields() {
	var $dropdown=document.getElementById('pt[<inp2:m_get name="pt_id" />][GatewayId]');
	var $table=document.getElementById('gateway_fields');
	var $display_style='';
	var $i=0;


	if (is.gecko || !is.ie) {
		on_style = 'table-row';
	}
	else {
		on_style = 'block';
	}

	while($i<$table.rows.length)
	{
		$row=$table.rows[$i];
		if( isset($row.getAttribute('GatewayId')) )
		{
			$display_style=($row.getAttribute('GatewayId') == $dropdown.options[$dropdown.selectedIndex].value) ? on_style : 'none';
//			alert('current display is '+$row.style.display+' setting it to '+$display_style);
			$row.style.display = $display_style;
//			alert('set');
		}
		$i++;
	}
}

</script>

<inp2:m_DefineElement name="gw_input_text">
	<input type="text" name="<inp2:gwf_InputName field="Value"/>" id="<inp2:gwf_InputName field="Value"/>" value="<inp2:gwf_gwConfigValue/>" tabindex="<inp2:m_get param="tab_index"/>" style="width:80%">
</inp2:m_DefineElement>

<inp2:m_DefineElement name="gw_input_select">
	<select tabindex="<inp2:m_get param="tab_index"/>" name="<inp2:gwf_InputName field="Value"/>" id="<inp2:gwf_InputName field="Value"/>">
		<inp2:PredefinedOptions field="Value" block="inp_option_phrase" selected="selected"/>
	</select>
</inp2:m_DefineElement>

<inp2:m_DefineElement name="gw_input_checkbox">
	<input type="hidden" id="<inp2:gwf_InputName field="Value"/>" name="<inp2:gwf_InputName field="Value"/>" value="<inp2:gwf_gwConfigValue/>">
	<input tabindex="<inp2:m_get param="tab_index"/>" type="checkbox" id="_cb_<inp2:gwf_InputName field="Value"/>" name="_cb_<inp2:gwf_InputName field="Value"/>" <inp2:gwf_gwConfigValue checked="checked"/> class="<inp2:m_param name="class"/>" onchange="update_checkbox(this, document.getElementById('<inp2:gwf_InputName field="Value"/>'));">
</inp2:m_DefineElement>

<inp2:m_DefineElement name="gateway_field">
	<tr class="<inp2:m_odd_even odd='edit-form-odd' even='edit-form-even'/>" GatewayId="<inp2:m_param name="gateway_id"/>" style="display: <inp2:m_param name="display"/>;">
		<inp2:m_inc param="tab_index" by="1"/>
		<td class="label-cell">
			<inp2:gwf_Field field="FieldName"/>:
		</td>
		<td class="control-mid">&nbsp;</td>
		<td class="control-cell">
			<inp2:m_RenderElement name="$input_block" pass_params="true"/>
		</td>
	</tr>
</inp2:m_DefineElement>

<inp2:gwf_initGWConfigValues/>

<inp2:pt_SaveWarning name="grid_save_warning"/>
<inp2:pt_ErrorWarning name="form_error_warning"/>

<div id="scroll_container">
	<table class="edit-form" id="gateway_fields">
		<inp2:m_RenderElement name="inp_edit_options" prefix="pt" field="GatewayId" title="la_fld_Gateway" onchange="refresh_fields()"/>
		<inp2:gwf_PrintList block="gateway_field" input_block_prefix="gw_input_" per_page="-1"/>
		<inp2:m_RenderElement name="inp_edit_filler"/>
	</table>
</div>

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