{{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}}

{{function name="selectTrueFalse" mOption=0}}
	<option value="true" {{if $mOption}}selected="selected"{{/if}}>{{$lang.yes}}</option>
	<option value="false" {{if !$mOption}}selected="selected"{{/if}}>{{$lang.no}}</option>
{{/function}}

<script type="text/javascript">
	$(document).ready(function(){
		{{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" id="tabbed" name="form" >
	<fieldset class="tabbed">
		<div class="clear"></div>
		<ul class="tab-headers">
			<li><a href="#link-stores">{{$lang.Stores}}</a></li>
			<li><a href="#link-stock">{{$lang.Stock_level_admin}}</a></li>
			<li><a href="#link-visual-stock">{{$lang.VisualStock_level_admin}}</a></li>
			<li><a href="#link-available">{{$lang.Available}}</a></li>
		</ul>
		<h1>{{$lang.Stores}}</h1>
		<div class="tab" id="link-stores">
			<h2>{{$lang.Stores}}</h2>
			<a href="?p=stores-form" class="new_element">{{$lang.New_store}}</a>
			<table class="list">
				<thead>
					<tr><th class="id">{{$lang.Id}}</th><th class="name">{{$lang.Name}}</th><th class="position">{{$lang.Priority}}</th><th>{{$lang.AvailableOnStock}}</th><th>{{$lang.AvailableOutOfStock}}</th><th class="actions">{{$lang.Actions}}</th></tr>
				</thead>
				<tbody>
				{{foreach from=$aStores item=aStore}}
					<tr>
						<td class="id">{{$aStore.iStore}}</td>
						<td class="name"><a href="?p=stores-form&amp;iStore={{$aStore.iStore}}">{{$aStore.sName}}</a></td>
						<td class="position">{{$aStore.iPriority}}</td>
						<td>{{if !empty( $aStore.iAvailableOnStock )}}{{$aAvailabilities[$aStore.iAvailableOnStock]}}{{else}}{{$lang.Default}}{{/if}}</td>
						<td>{{if !empty( $aStore.iAvailableOutOfStock )}}{{$aAvailabilities[$aStore.iAvailableOutOfStock]}}{{else}}{{$lang.Default}}{{/if}}</td>
						<td class="actions">
							<a href="?p=stores-form&amp;iStore={{$aStore.iStore}}"><img title="{{$lang.Edit}}" alt="{{$lang.Edit}}" src="{{$config.dir_templates}}admin/images/ico/edit.png"></a>
							{{if count( $aStores ) > 1}}
								<a href="?p=stores-delete&amp;iStore={{$aStore.iStore}}" class="delete" onclick="return del( );"><img title="{{$lang.Delete}}" alt="{{$lang.Delete}}" src="{{$config.dir_templates}}admin/images/ico/delete.png"></a>
							{{/if}}
						</td>
					</tr>
				{{/foreach}}
				</tbody>
			</table>
		</div>
		<div class="tab" id="link-stock">
			<table class="details">
				<tr>
					<th colspan="3"><h2>{{$lang.Stock_level_admin}}</h2></th>
				</tr><tr>
					<th class="name">{{$lang.Hide_unavailable_products}}</th><td class="value"><select name="hide_unavailable_products">{{selectTrueFalse mOption=$config.hide_unavailable_products}}</select></td><td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_settings_stock_hide_unavailable}}" /></td>
				</tr><tr class="l0">
					<th class="name">{{$lang.Stock_show_level_for_client}}</th><td class="value"><select name="stock_show_level_for_client">{{selectTrueFalse mOption=$config.stock_show_level_for_client}}</select></td><td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_settings_stock_show}}" /></td>
				</tr><tr>
					<th class="name">{{$lang.Send_admin_min_level}}</th><td class="value"><input type="text" name="stock_send_admin_min" value="{{$config.stock_send_admin_min}}" maxlength="10" class="input" /></td><td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_settings_stock_min}}" /></td>
				</tr><tr>
					<th class="name">{{$lang.Default_on_stock}}</th><td class="value"><select name="default_onstock">{{selectOptions aOptions=$aAvailabilitiesOnStock mOption=$config.default_onstock}}</select></td><td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_settings_default_on_stock}}" /></td>
				</tr><tr>
					<th class="name">{{$lang.Default_out_of_stock}}</th><td class="value"><select name="default_outofstock">{{selectOptions aOptions=$aAvailabilities mOption=$config.default_outofstock}}</select></td><td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_settings_default_out_of_stock}}" /></td>
				</tr>
			</table>
		</div>
		<div class="tab" id="link-visual-stock">
			<table class="details">    
				<tr>
				<th colspan="3"><h2>{{$lang.VisualStock_level_admin}}</h2></th>
				</tr><tr>
					<th class="name">{{$lang.Show_stock_visual}}</th>
					<td class="value"><select name="stock_visual">{{selectTrueFalse mOption=$config.stock_visual}}</select></td>
					<td class="help"><img class="tTip info" src="templates/images/info.png" title="{{$lang.help_settings_stock_visual}}" /></td>
				</tr><tr>
					<th class="name"><img src="{{$config.dir_templates}}images/0_{{$config.language}}.png" alt="0"> {{$lang.stock_0}}</th>
					<td class="value">
						{{$lang.From}}: <input type="text" value="0" disabled="disabled" class="input" />
						{{$lang.To}}: <input type="text" value="0" disabled="disabled" class="input" />
					</td>
					<td class="help"></td>
				</tr><tr>
					<th class="name"><img src="{{$config.dir_templates}}images/1_{{$config.language}}.png" alt="1"> {{$lang.stock_1}}</th>
					<td class="value">
						{{$lang.From}}: <input type="text" value="1" disabled="disabled" class="input" />
						{{$lang.To}}: <input type="text" id="stock1max" value="{{$config.visualstock1max}}" name="visualstock1max" class="input" />
					</td>
					<td class="help"></td>
				</tr><tr>
					<th class="name"><img src="{{$config.dir_templates}}images/2_{{$config.language}}.png" alt="2"> {{$lang.stock_2}}</th>
					<td class="value">
						{{$lang.From}}: <input type="text" id="stock2min" value="{{$config.visualstock2min}}" name="visualstock2min" class="input" />
						{{$lang.To}}: <input type="text" id="stock2max" value="{{$config.visualstock2max}}" name="visualstock2max" class="input" />
					</td>
					<td class="help"></td>
				</tr><tr>
					<th class="name"><img src="{{$config.dir_templates}}images/3_{{$config.language}}.png" alt="3"> {{$lang.stock_3}}</th>
					<td class="value">
						{{$lang.From}}: <input type="text" id="stock3min" value="{{$config.visualstock3min}}" name="visualstock3min" class="input" />
						{{$lang.To}}: <input type="text" id="stock3max" value="{{$config.visualstock3max}}" name="visualstock3max" class="input" />
					</td>
					<td class="help"></td>
				</tr><tr>
					<th class="name"><img src="{{$config.dir_templates}}images/4_{{$config.language}}.png" alt="4"> {{$lang.stock_4}}</th>
					<td class="value">
						{{$lang.From}}: <input type="text" id="stock4min" value="{{$config.visualstock4min}}" name="visualstock4min" class="input" />
						{{$lang.To}}: <input type="text" value="-" disabled="disabled" class="input" />
					</td>
					<td class="help"></td>
				</tr>
			</table>
		</div>
		<div class="tab" id="link-available">
			<h2>{{$lang.Available}}</h2>
			<table class="list">
				<thead>
					<tr>
						<td class="help" colspan="3" style="color: red; font-size: 12px;">{{$lang.help_settings_stock_available}}</td>
					</tr>
					<tr>
						<th class="id">{{$lang.Id}}</th><th class="name">{{$lang.Name}}</th><th>{{$lang.CanBuy}}</th>
					</tr>
				</thead>
				<tfoot>
				</tfoot>
				<tbody>
					{{foreach from=$aAvailabilitiesFull item=aAvail}}
						<tr>
							<td class="id">{{$aAvail.iAvailable}}</td>
							<td class="name"><input type="text" name="aAvailabilities[{{$aAvail.iAvailable}}]" value="{{$aAvail.sText}}" /></td>
							<td>{{if $aAvail.iCanBuy}}{{$lang.yes}}{{else}}{{$lang.no}}{{/if}}</td>
						</tr>
					{{/foreach}}
				</tbody>
			</table>
		</div>
		
		<div class="save float"><div class="save floatcontainer">
		<input type="submit" class="submit" value="{{$lang.Save}} &raquo;" name="sOption" />
		</div></div>
	</fieldset>
</form>