{{function name="selectOptions" aOptions=0 mOption=0}}{{foreach from=$aOptions item=sOption}}<option value="{{$sOption@key}}" {{if ( is_array( $mOption ) && in_array( $sOption@key, $mOption ) ) || ( $sOption@key == $mOption )}}selected="selected"{{/if}}>{{$sOption}}</option>{{/foreach}}{{/function}}
<script type="text/javascript">
// <![CDATA[
$(function(){	
	$('#new_region').click(function(e){
		e.preventDefault();
		$('#regions_table').append('<tr><td class="name"><input type="text" name="aNewRegions[sRegion][]" value="" /></td><td class="name"><select name="aNewRegions[iCountry][]">{{selectOptions aOptions=$aCountries}}</select></td><td><input type="checkbox" name="aNewRegions[iDelete][]" value="1" /></td></tr>');
	});
	$('#regions_table').on('click', 'input[name="aNewRegions[iDelete][]"]', function(){
		$(this).closest('tr').remove();
	});
	
	{{if isset( $smarty.get.activeTabId )}}$('ul.tab-headers li a[href="#{{$smarty.get.activeTabId}}"]').trigger('click');{{/if}}
});
// ]]>
</script>
<form action="?p={{$_GET.p}}" method="post">
	<fieldset class="tabbed">
		<div class="clear"></div>
		<ul class="tab-headers">
			<li><a href="#countries">{{$lang.Countries}}</a></li>
			<li><a href="#regions">{{$lang.Regions}}</a></li>
		</ul>
		<h1>{{$lang.Countries_regions}}</h1>
		<div class="tab" id="countries">
			<h2>{{$lang.Countries}}</h2>
			<table class="list">
				<tr><th class="id">{{$lang.Id}}</th><th class="name">{{$lang.Name}}</th></tr>
				{{foreach from=$aCountries item=sCountry}}
					<tr><td>{{$sCountry@key}}</td><td class="name"><input type="text " name="aCountries[{{$sCountry@key}}]" value="{{$sCountry}}" />
				{{/foreach}}
			</table>
		</div>
		<div class="tab" id="regions">
			<h2>{{$lang.Regions}}</h2>
			<table id="regions_table" class="list">
				<tr><th class="name">{{$lang.Name}}</th><th class="name">{{$lang.Country}}</th><th class="del">{{$lang.Delete}}</th></tr>
				{{foreach from=$aRegions item=aRegion}}
					<tr><td class="name"><input type="text" name="aRegions[{{$aRegion@key}}][sRegion]" value="{{$aRegion.sRegion}}" /></td><td class="name"><select name="aRegions[{{$aRegion@key}}][iCountry]">{{selectOptions aOptions=$aCountries mOption=$aRegion.iCountry}}</select></td><td><input type="checkbox" name="aRegions[{{$aRegion@key}}][iDelete]" value="1" /></td></tr>
				{{/foreach}}
			</table>
			<a href="#new-region" id="new_region" class="new_element">{{$lang.New_region}}</a>
		</div>
		<div class="save float">
			<div class="save floatcontainer"><input type="submit" class="submit" value="{{$lang.Save}} &raquo;" name="sOption" /></div>
		</div>

	</fieldset> <!-- end div tabbed -->
</form>
<div class="clear"></div>