{{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 ) ) || ( isset( $mOption ) && $sOption@key == $mOption )}}selected="selected"{{/if}}>{{$sOption}}</option>
	{{/foreach}}
{{/function}}

{{function name="selectMainPageOptions" aPages=0 aOptions=0 mOption=0}}
	{{foreach from=$aPages item=sOption}}
		{{if $sOption@key !== 0 && in_array( $sOption@key, $aOptions ) }}
			<option value="{{$sOption@key}}"{{if ( is_array( $mOption ) && in_array( $sOption@key, $mOption ) ) || ( $sOption@key == $mOption )}} selected="selected"{{/if}}>{{$sOption}}</option>
		{{/if}}
	{{/foreach}}
{{/function}}

<script type="text/javascript">
	var tags = {{$json_tags}};
	var aVats = {{$aGeneralInfo.sVatsJSON}};

	$(document).ready(function(){
		$("form#product-form").validate();
		$("form#product-form #product-name").rules("add", {required: true});
		$("form#product-form #fPrice").rules("add", {number: true, required: true});
		$("form#product-form #fPriceOld").rules("add", {number: true});
		$("form#product-form textarea[name='sDescriptionShort']").rules('add', {maxbytes: 65535});
		$("form#product-form textarea[name='sDescriptionFull']").rules('add', {maxbytes: 65535});
		$("form#product-form .product-variant .variant-stores .stock input").each(function(){ $(this).rules("add", {required: true, number: true}); });
		$("form#product-form input.weight" ).each( function(){ $(this).rules( "add", {pattern: '^[0-9]+\\.?[0-9]*$' }); });
		
		
		{{if isset( $smarty.get.activeTabId )}}$('ul.tab-headers li a[href="#{{$smarty.get.activeTabId}}"]').trigger('click');{{/if}}
	});
</script>
<form action="?p={{$_GET.p}}&amp;iProduct={{$aProduct.iProduct}}" enctype="multipart/form-data" method="post" id="product-form">
	<fieldset class="tabbed">
		<input type="hidden" name="iProduct" value="{{$aProduct.iProduct}}" />
		<div class="clear"></div>
		
		<ul class="tab-headers">
			<li><a href="#product-basic">{{$lang.Name_price}}</a></li>
			<li><a href="#product-variants">{{$lang.Variants}}</a></li>
			<li><a href="#product-description">{{$lang.Description}}</a></li>
			{{if $config.additional_tabs > 0}}<li><a href="#product-tabs">{{$lang.Additional_tabs}}</a></li>{{/if}}
			<li><a href="#product-attributes">{{$lang.Products_attributes}}</a></li>
		
			{{if $config.related_boxes > 0}}<li><a href="#product-related">{{$lang.Related}}</a></li>{{/if}}
		
			<li><a href="#product-advsearcher">{{$lang.Adv_searcher}}</a></li>
			<li><a href="#product-delivery_discounts">{{$lang.Products_carriers_prices}}, {{$lang.Products_discounts}}</a></li>
			<li><a href="#product-files">{{$lang.Files_and_images}}</a></li>
			<li><a href="#product-seo">{{$lang.SEO}}</a></li>
			{{if !empty( $aProduct.iProduct )}}
				<li><a href="#product-avail_newsletter">{{$lang.Avail_newsletter}}</a></li>
			
				<li><a href="#product-stats">{{$lang.Product_stats}}</a></li>
				<li><a href="#product-referers">{{$lang.Product_referers}}</a></li>
			{{/if}}
		</ul>
		
		<h1>{{if isset( $aProduct.sLinkName )}}<a href="{{$aProduct.sLinkName}}" target="_blank"><img src="{{$config.dir_templates}}admin/images/ico/view.png" alt="{{$lang.Preview}}" title="{{$lang.Preview}}"></a>{{/if}} {{$lang.Products_form}} - <span class="autochange">{{$aProduct.sName}}</span></h1>
		
		<div class="tab" id="product-basic">
			<div class="block50">
				<h2>{{$lang.Name_category}}</h2>
				<table class="details">
					<tbody>
						<tr>
							<th class="name">{{$lang.Name}}</th>
							<td class="value"><input type="text" name="sName" value="{{$aProduct.sName}}" class="input" id="product-name" maxlength="200" /></td>
							<td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_product_name}}" /></td>
						</tr><tr>
							<th class="name">{{$lang.Name_compare}}</th>
							<td class="value"><input type="text" name="sNameCompare" value="{{$aProduct.sNameCompare}}" class="input" id="product-name-compare" maxlength="200" /></td>
							<td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_product_name_compare}}" /></td>
						</tr><tr>
							<th class="name">{{$lang.Active}}</th><td class="value"><input type="checkbox" name="iStatus" {{if $aProduct.iStatus}}checked="checked"{{/if}} value="1" /></td><td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_product_status}}" /></td>
						</tr><tr>
							<th class="name">{{$lang.Producer}}</th>
							<td class="value">
								<select name="iProducer" id="producer-select"><option value="">{{$lang.none}}</option>{{selectOptions aOptions=$aGeneralInfo.aProducers mOption=$aProduct.iProducer}}</select>
								<div id="producer_quick_add" class="dialog" title="{{$lang.New_producer}}">
									<label>{{$lang.Producer}}: <input type="text" name="sNewProducer" /></label> <input type="hidden" class="rel" value="#producer-select" /> <input type="hidden" class="action" value="admin.php?p=producers-ajax&sName=" />
								</div>
								<a href="#producer_quick_add" class="dialog"><img src="{{$config.dir_templates}}admin/images/ico/add.png" alt="{{$lang.New_producer}}" /></a>
							</td>
							<td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_product_producer}}" /></td>
						</tr><tr>
							<th class="name">{{$lang.Position}}</th><td class="value"><input type="text" name="iPosition" value="{{$aProduct.iPosition}}" maxlength="5" /></td><td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_product_position}}" /></td>
						</tr>
						<tr>
							<th class="name">{{$lang.Pages}}</th>
							<td class="value" colspan="2">
								<p class="help">{{$lang.help_product_pages}}</p>
								<table id="pages-multiselect">
									<thead>
										<tr>
											<th class="id">{{$lang.Id}}</th><th class="name">{{$lang.Name}}</th><th class="del">{{$lang.Delete}}</th>
										</tr>
										<tr class="item" style="display: none">
											<td class="id">%iId%</td>
											<td class="name">%sName%</td>
											<td class="del"><a class="page-delete" href="#" ><img src="{{$config.dir_templates}}admin/images/ico/delete.png" alt="{{$lang.Delete}}" title="{{$lang.Delete}}"/></a></td>
											<td class="value" style="display: none"><input type="hidden" value="%iId%" name="aPages[]" /></td>
										</tr>
									</thead>
									<tfoot>
										<tr>
											<td></td>
											<td colspan="3"><a href="admin.php?p=p-multiselect&amp;request_type=pages-multiselect&amp;iProducts=1&amp;getFull=1" class="pages-select new_element">{{$lang.Add_related_pages}}</a></td>
										</tr>
									</tfoot>
									<tbody>
										{{foreach from=$aProduct.aCategories item=iCategory}}
											<tr>
												<td class="id">{{$iCategory}}</td>
												<td class="name">{{$aGeneralInfo.aPagesFull[$iCategory]}}</td>
												<td class="del"><a class="page-delete" href="#" ><img src="{{$config.dir_templates}}admin/images/ico/delete.png" alt="{{$lang.Delete}}" title="{{$lang.Delete}}"/></a></td>
												<td class="value" style="display: none"><input type="hidden" value="{{$iCategory}}" name="aPages[]" /></td>
											</tr>
										{{/foreach}}
									</tbody>
								</table>
							</td>
						</tr>
						<tr>
							<th class="name">{{$lang.Main_category}}</th>
							<td class="value"><select id="product-main-category" name="iMainCategory">{{if !empty( $aProduct.aCategories )}}{{selectMainPageOptions aPages=$aGeneralInfo.aPagesFull aOptions=$aProduct.aCategories mOption=$aProduct.iMainCategory}}{{/if}}</select></td>
							<td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_product_main_category}}" /></td>
						</tr>
					</tbody>
				</table>
			</div>
			<div class="block50">
				<h2>{{$lang.Price}}</h2>
				<table class="details">
					<tbody>
						<tr>
							<th class="name">{{$lang.Admin_info}}</th>
							<td class="value" colspan="2"><textarea name="sAdminInfo">{{$aProduct.sAdminInfo}}</textarea></td>
							<td class="help"></td>
						</tr>
						<tr>
							<th class="name">{{$lang.Vat}}</th>
							<td class="value" colspan="2"><select name="iVat" id="vat">{{selectOptions aOptions=$aGeneralInfo.aVatsForSelect mOption=$aProduct.iVat}}</select></td>
							<td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_product_vat}}" /></td>
						</tr>
						<tr><th class="name"></th><th class="value gross">{{$lang.Gross}}</th><th class="value netto">{{$lang.Netto}}</th><td></td></tr>
						<tr class="price">
							<th class="name">{{$lang.Buy_price}}</th>
							<td class="value gross"><input type="text" name="fBuyPrice" value="{{$aProduct.fBuyPrice}}" id="fBuyPrice" /> {{$config.currency_symbol}}</td>
							<td class="value netto"><input type="text" id="fBuyPriceN" /> {{$config.currency_symbol}}</td>
							<td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_product_fBuyPrice}}" /></td>
						</tr>
						<tr>
							<th class="name">{{$lang.Margin}}</th>
							<td class="value" colspan="2">
								<input type="text" name="sMargin" value="{{$aProduct.sMargin}}" id="sMargin" />
								<a href="#" id="margin-count"><img src="{{$config.dir_templates}}admin/images/ico/margin-product.png" alt="product" title="{{$lang.Margin_product}}" /></a>
								<a href="#" id="margin-count-producer"><img src="{{$config.dir_templates}}admin/images/ico/margin-producer.png" alt="producer" title="{{$lang.Margin_producer}}" /></a>
								<a href="#" id="margin-count-category"><img src="{{$config.dir_templates}}admin/images/ico/margin-category.png" alt="category" title="{{$lang.Margin_category}}" /></a>
							</td>
							<td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_product_sMargin}}" /></td>
						</tr>
						<tr class="price">
							<th class="name">{{$lang.Price}}</th>
							<td class="value gross"><input type="text" name="fPrice" id="fPrice" value="{{$aProduct.fPrice}}"/> {{$config.currency_symbol}}</td>
							<td class="value netto"><input type="text" id="fPriceN" /> {{$config.currency_symbol}}</td>
							<td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_product_fPrice}}" /></td>
						</tr>
						<tr class="price">
							<th class="name">{{$lang.Price_old}}</th>
							<td class="value gross"><input type="text" name="fPriceOld" value="{{$aProduct.fPriceOld}}" id="fPriceOld" /> {{$config.currency_symbol}}</td>
							<td class="value netto"><input type="text" id="fPriceOldN" /> {{$config.currency_symbol}}</td>
							<td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_product_fPriceOld}}" /></td>
						</tr>
						<tr class="price">
							<th class="name">{{$lang.Price_time_value}}</th>
							<td class="value gross"><input type="text" name="fPriceTimeValue" value="{{$aProduct.fPriceTimeValue}}" id="fPriceTimeValue" /> {{$config.currency_symbol}}</td>
							<td class="value netto"><input type="text" id="fPriceTimeValueN" /> {{$config.currency_symbol}}</td>
							<td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_prodcut_fPriceTimeValue}}" /></td>
						</tr>
						<tr>
							<th class="name">{{$lang.Price_time_from}}</th>
							<td class="value" colspan="2"><input class="datetime" type="text" name="sPriceTimeFrom" value="{{$aProduct.sPriceTimeFrom}}" /></td>
							<td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_prodcut_fPriceTimeFrom}}" /></td>
						</tr>
						<tr>
							<th class="name">{{$lang.Price_time_to}}</th>
							<td class="value" colspan="2"><input class="datetime" type="text" name="sPriceTimeTo" value="{{$aProduct.sPriceTimeTo}}" /></td>
							<td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_prodcut_fPriceTimeTo}}" /></td>
						</tr>
						<tr>
							<th class="name">{{$lang.Price_currency_dependent}}</th>
							<td class="value" colspan="2"><input type="checkbox" value="1" name="iCurrencyDependent" {{if $aProduct.iCurrencyDependent}}checked="checked"{{/if}} /></td>
							<td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_prodcut_iCurrencyDependent}}" /></td>
						</tr>
					</tbody>
				</table>
			</div>
			<div class="block30">
				<h2>{{$lang.Options}}</h2>
				<table class="details">
					<tr>
						<th class="name">{{$lang.Date}}</th><td class="value"><input class="datetime" type="text" name="sDate" value="{{$aProduct.sDate}}" size="20" maxlength="20" class="input" /></td><td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_product_date}}" /></td>
					</tr><tr>
						<th class="name">{{$lang.ActiveDiscount}}</th><td class="value"><input type="checkbox" value="1" name="iActiveDiscount" {{if $aProduct.iActiveDiscount}}checked="checked"{{/if}} /></td><td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_product_activeDiscount}}" /></td>
					</tr><tr>
						<th class="name">{{$lang.Products_compare}}</th><td class="value"><input type="checkbox" value="1" name="iCompare" {{if $aProduct.iCompare}}checked="checked"{{/if}} /></td><td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_product_compare}}" /></td>
					</tr><tr>
						<th class="name">{{$lang.Products_comment}}</th><td class="value"><input type="checkbox" value="1" name="iComments" {{if $aProduct.iComments}}checked="checked"{{/if}} /></td><td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_product_comments}}" /></td>
					</tr><tr>
						<th class="name">{{$lang.Weight}}</th><td class="value"><input type="text" id="product-weight" name="sWeight" value="{{$aProduct.sWeight}}" class="input weight" /></td><td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_product_weight}}" /></td>
					</tr><tr>
						<th class="name">{{$lang.WeightDisplayed}}</th><td class="value"><input type="text" id="product-display-weight" name="sWeightDisplayed" value="{{$aProduct.sWeightDisplayed}}" class="input weight" /></td><td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_product_clientWeight}}" /></td>
					</tr><tr>
						<th class="name">{{$lang.Product_measure}}</th><td class="value"><input type="text" name="sMeasure" value="{{$aProduct.sMeasure}}" /></td><td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_product_measure}}" /></td>
					</tr><tr>
						<th class="name">{{$lang.CatalogNumber}}</th><td class="value"><input type="text" name="sCatalogNumber" value="{{$aProduct.sCatalogNumber}}" /></td><td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_product_catalogNumber}}" /></td>
					</tr><tr>
						<th class="name">{{$lang.ProductIndex}}</th><td class="value"><input type="text" name="sProductIndex" value="{{$aProduct.sProductIndex}}" class="input" size="10" /></td><td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_product_productIndex}}" /></td>
					</tr>
				</table>
			</div>
			<div class="block30">
				<h2>&nbsp;</h2>
				<table class="details">
					<tr>
						<th class="name">{{$lang.Products_fotolia}}</th><td class="value"><input type="checkbox" value="1" name="iFotolia" {{if $aProduct.iFotolia}}checked="checked"{{/if}} /></td><td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_product_fotolia}}" /></td>
					</tr><tr>
						<th class="name">{{$lang.StockSendAdminMin}}</th><td class="value"><input type="text" name="iStockSendAdminMin" value="{{$aProduct.iStockSendAdminMin}}" /></td><td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_product_minStock}}" /></td>
					</tr><tr>
						<th class="name">{{$lang.Author}}</th><td class="value"><select name="iAdmin"><option value="">{{$lang.none}}</option>{{selectOptions aOptions=$aGeneralInfo.aAdmins mOption=$aProduct.iAdmin}}</select></td><td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_product_author}}" /></td>
					</tr><tr>
						<th class="name">{{$lang.Search_words}}</th><td class="value"><input type="text" name="sSearchWords" value="{{$aProduct.sSearchWords}}" class="input" maxlength="255" /></td><td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_product_keywords}}" /></td>
					</tr><tr>
						<th class="name">{{$lang.NewUsed}}</th><td class="value"><select name="iNewUsed" size="1">{{selectOptions aOptions=$aGeneralInfo.aNewUsed mOption=$aProduct.iNewUsed}}</select></td><td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_product_newUsed}}" /></td>
					</tr><tr>
						<th class="name">{{$lang.NotForSale}}</th><td class="value"><input type="checkbox" value="1" name="iNotForSale" {{if $aProduct.iNotForSale}}checked="checked"{{/if}} /></td><td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_product_notForSale}}" /></td>
					</tr><tr>
						<th class="name">{{$lang.SizeXYZ}}</th><td class="value"><input type="text" name="sSizeXYZ" value="{{$aProduct.sSizeXYZ}}" class="input" /></td><td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_product_size}}" /></td>
					</tr><tr>
						<th class="name">{{$lang.ProducerURL}}</th><td class="value"><input type="text" name="sProducerURL" value="{{$aProduct.sProducerURL}}" /></td><td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_product_producerUrl}}" /></td>
					</tr><tr>
						<th class="name">{{$lang.ReviewURL}}</th><td class="value"><input type="text" name="sReviewURL" value="{{$aProduct.sReviewURL}}" /></td><td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_product_reviewUrl}}" /></td>
					</tr>
				</table>
			</div>
			<div class="block30">
				<h2>{{$lang.option_products_promotion}}</h2>
				<table class="details">
					{{for $iPromoted=1 to $config.promoted_types}}
						<tr>
							<th class="name">{{$config["promoted{{$iPromoted}}_name"]}}</th><td class="value"><input type="checkbox" value="1" name="aPromoted[{{$iPromoted}}]" {{if $aProduct.aPromoted[$iPromoted]}}checked="checked"{{/if}} /> {{$lang.Valid_until}} <input type="text" name="aPromotedTimes[{{$iPromoted}}]" value="{{$aProduct.aPromotedTimes[$iPromoted]}}" class="datetime" /></td><td class="help"></td>
						</tr>
					{{/for}}
				</table>
			</div>
		</div>
		
		<div class="tab" id="product-variants">
			<table class="details" id="product-variant-container">
				<thead>
					<tr>
						<th colspan="3"><h2>{{$lang.Variants}}</h2></th>
					</tr>
					<tr>
						<th class="name">{{$lang.Attributes}}</th>
						<td class="help">{{$lang.help_product_variants}}</td>
						<td><a id="attributes-show" href="#"><span>{{$lang.Show_attributes}}</span></a></td>
					</tr>
					{{if !empty( $aGeneralInfo.aAttributesGroups )}}
						<tr>
							<th class="name">
								{{$lang.Attributes_group}}:
							</th>
							<td colspan="2">
								<select id="attributes-groups">
									<option value="">{{$lang.Attributes_group_choose}}</option>
									{{foreach from=$aGeneralInfo.aAttributesGroups item=aAttributesGroup}}
										<option value="{{$aAttributesGroup.aAttributesJSON}}">{{$aAttributesGroup.sName}}</option>
									{{/foreach}}
								</select>
							</td>
						</tr>
					{{/if}}
					<tr>
						<td class="value" colspan="3">
							<ul id="AttributesList">
								{{foreach from=$aGeneralInfo.aAttributes item=sAttribute}}
									<li><label><input value="{{$sAttribute@key}}" type="checkbox" {{if in_array( $sAttribute@key, $aProduct.aAttributesSelected )}}checked="checked"{{/if}} />{{$sAttribute}}</label></li>
								{{/foreach}}
							</ul>
							<div style="display: none;" id="variantAttributeNew">
								{{foreach from=$aGeneralInfo.aAttributesAndValues item=aAttribute key=iAttribute}}
									<div class="product-variant-attribute" id="variant-%VariantId%-attribute-{{$iAttribute}}">
										<div id="attribute_quick_add-%VariantId%-attribute-{{$iAttribute}}" class="dialog" title="{{$lang.New_attribute_value}}: {{$aAttribute.sName}}">
											<label>{{$lang.Attribute_value}}: <input type="text" name="sNewValue" /></label> <input type="hidden" class="rel_additional" value=".variant-attribute-{{$iAttribute}}" /> <input type="hidden" class="rel" value="#variant-%VariantId%-attribute-{{$iAttribute}}-select" /> <input type="hidden" class="action" value="admin.php?p=attributes-ajax_value&iAttribute={{$iAttribute}}&sValue=" />
										</div>
										<span>{{$aAttribute.sName}}</span>
										<span>
											<select id="variant-%VariantId%-attribute-{{$iAttribute}}-select" name="aVariants[%VariantId%][aAttributes][{{$iAttribute}}]" class="variant-attribute-{{$iAttribute}}">
												{{foreach from=$aAttribute.aAValues key=iValue item=sValue}}
													<option value="{{$iValue}}" selected="selected">{{$sValue}}</option>
												{{/foreach}}
											</select>
											<a href="#attribute_quick_add-%VariantId%-attribute-{{$iAttribute}}" class="dialog"><img src="{{$config.dir_templates}}admin/images/ico/add.png" alt="{{$lang.New_attribute_value}}" /></a>
										</span>
									</div>
								{{/foreach}}
							</div>
						</td>
					</tr>
					<tr>
						<td class="name">{{$lang.New_variant}}</td>
						<td class="value"><input type="button" value="{{$lang.New_variant}}" id="product-varaiant-new" class="submit"/></td>
						<td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_product_variants_new}}" /></td>
					</tr>
					<tr>
						<td colspan="3" class="help">{{$lang.help_product_variants_description}}</td>
					</tr>
					<tr class="product-variant">
						<td colspan="3">
							<!-- header on variant list -->
							<table class="list product-variant-item-head">
								<thead>
									<tr>
										<td class="active">{{$lang.Active}}</td>
										<td class="buy-price">{{$lang.Buy_price}}</td>
										<td class="margin">{{$lang.Margin}}</td>
										<td class="price">{{$lang.Price}}</td>
										<td class="price-old">{{$lang.Price_old}}</td>
										<td class="price-time">{{$lang.Price_time}}</td>
										<td class="stock">{{$lang.Stock_level}}</td>
										<td class="del">{{$lang.Delete}}</td>
									</tr>
								</thead>
							</table>
							<a id="variant-additional" href="#"><span>{{$lang.Info_addtional}}</span></a>
						</td>
					</tr>
				</thead>
				<tbody id="product-variant-list">
					{{include file='products_variant.tpl' aVariant=[ 'bNewVariant' => 1, 'iProductVariant' => '%VariantId%', 'iStock' => 0, 'iStatus' => 1 ]}}
					{{foreach from=$aProduct.aVariants item=aVariant}}
						{{include file='products_variant.tpl' aVariant=$aVariant}}
					{{/foreach}}
				</tbody>
			</table>
		</div>
		<div class="tab" id="product-description">
			<div class="block50">
				<h2>{{$lang.Full_description}} <img class="tTip info" src="templates/images/info.png" title="{{$lang.help_product_description}}" /></h2>
				<div id="description-long" class="description">{{htmlEditor sName='sDescriptionFull' iH='480px' iW='100%' sContent=$aProduct.sDescriptionFull}}</div>
			</div>
			<div class="block50">
				<h2>{{$lang.Short_description}} <img class="tTip info" src="templates/images/info.png" title="{{$lang.help_product_descriptionShort}}" /></h2>
				<div id="description-short" class="description">{{htmlEditor sName='sDescriptionShort' iH='280px' iW='100%' sContent=$aProduct.sDescriptionShort}}</div>
			</div>
		</div>

		{{if $config.additional_tabs > 0}}
			<div class="tab" id="product-tabs">
				{{section name=additionalTabs start=1 loop=$config.additional_tabs+1 step=1}}
					<div class="block50">
						<h2>{{$config["tab`$smarty.section.additionalTabs.index`_name"]}}</h2>
						{{htmlEditor sName="aTabs[`$smarty.section.additionalTabs.index`]" iH='280px' iW='100%' sContent=$aProduct.aTabs[$smarty.section.additionalTabs.index]}}
					</div>
				{{/section}}
			</div>
		{{/if}}

		{{if $config.related_boxes > 0}}
			<div class="tab" id="product-related">
				{{section name=related start=1 loop=$config.related_boxes+1 step=1}}
					<div class="block30">
						<h2>{{$config["related`$smarty.section.related.index`_name"]}}</h2>
						<p class="help">{{$lang.help_product_related}}</p>
						<table id="related-{{$smarty.section.related.index}}" class="related">
							<thead>
								<tr><th class="id">{{$lang.Id}}</th><th class="name">{{$lang.Name}}</th><th class="del">{{$lang.Delete}}</th></tr>
								<tr class="item" style="display: none"><td class="id">%iId%</td><td class="name">%sName%</td><td class="del"><a class="related-delete" href="#" ><img src="{{$config.dir_templates}}admin/images/ico/delete.png" alt="{{$lang.Delete}}" title="{{$lang.Delete}}"/></a></td><td class="value" style="display: none"><input type="hidden" value="%iId%" name="aRelated[{{$smarty.section.related.index}}][]" /></td></tr>
							</thead>
							<tfoot>
								<tr><td></td><td colspan="2"><a href="admin.php?p=products-multiselect&request_type=related-{{$smarty.section.related.index}}" class="related-select new_element">{{$lang.Add_related_products}}</a></td></tr>
							</tfoot>
							<tbody>
								{{foreach from=$aProduct.aRelatedProducts[$smarty.section.related.index] item=aRelatedProduct}}
									<tr class="item"><td class="id">{{$aRelatedProduct.iProduct}}</td><td class="name"> {{$aRelatedProduct.sName}}</td><td class="del"><a class="related-delete" href="#" ><img src="{{$config.dir_templates}}admin/images/ico/delete.png" alt="{{$lang.Delete}}" title="{{$lang.Delete}}"/></a></td><td class="value" style="display: none"><input type="hidden" value="{{$aRelatedProduct.iProduct}}" name="aRelated[{{$smarty.section.related.index}}][]" /></td></tr>
								{{/foreach}}
							</tbody>
						</table>
					</div>
				{{/section}}
			</div>
		{{/if}}

		<div class="tab" id="product-advsearcher">
			<h2>{{$lang.Adv_searcher}}</h2>
			<p class="help">{{$lang.help_product_advsearcher}}</p>
			<table class="list">
				{{foreach from=$aProduct.aAdvsearcherValues item=sAdvsearcherValue}}
					<tr class="item item_{{$sAdvsearcherValue@key}}">
						<td class="id">
							{{$sAdvsearcherValue@key}}
						</td>
						<td class="name">
							{{$sAdvsearcherValue}}
						</td>
						<td class="del">
							<a class="advsearcher-delete" href="#">
								<img src="{{$config.dir_templates}}admin/images/ico/delete.png" alt="{{$lang.Delete}}" title="{{$lang.Delete}}"/>
							</a>
						</td>
						<td class="value" style="display: none">
							<input type="hidden" value="{{$sAdvsearcherValue@key}}" name="aAdvsearcherValues[]" />
						</td>
					</tr>
				{{/foreach}}
				<tr>
					<td colspan="3">
						{{foreach from=$aGeneralInfo.aAdvsearcherColumns item=sColumn}}
							<div class="advsearcher_column_container">
								<div id="advsearcher_quick_add-{{$sColumn@key}}" class="dialog" title="{{$lang.New_advsearcher_value}}: {{$sColumn}}">
									<label>{{$lang.Advsearcher_value}}: <input type="text" name="sNewValue" /></label> <input type="hidden" class="rel_additional" value=".advsearcher-column-{{$sColumn@key}}" /> <input type="hidden" class="rel" value="#advsearcher_add_{{$sColumn@key}}" /> <input type="hidden" class="action" value="admin.php?p=advsearcher-ajax_value&amp;iColumn={{$sColumn@key}}&amp;{{if !$sColumn@first}}iParentValue=&amp;{{/if}}sValue=" />
								</div>
								<label class="advsearcher_column" for="advsearcher_add_{{$sColumn@key}}">
									{{$sColumn}}
								</label>
								<span class="advsearcher_column">
									<select id="advsearcher_add_{{$sColumn@key}}" class="advsearcher-column-{{$sColumn@key}} {{if $sColumn@last}}advsearcher_add_last{{/if}}" {{if !$sColumn@first}}disabled="disabled"{{/if}}>
										<option value="">{{$lang.Select}}</option>
										{{if $sColumn@first}}{{foreach from=$aGeneralInfo.aAdvsearcherValues item=sValue}}<option value="{{$sValue@key}}">{{$sValue}}</option>{{/foreach}}{{/if}}
									</select>
								</span>
								<span><a href="#advsearcher_quick_add-{{$sColumn@key}}" class="dialog"><img src="{{$config.dir_templates}}admin/images/ico/add.png" alt="{{$lang.New_advsearcher_value}}" /></a></span>
							</div>
						{{/foreach}}
						<a href="#" class="add new_element">{{$lang.Add}}</a>
					</td>
				</tr>
			</table>
		</div>

		<div class="tab" id="product-delivery_discounts">
			<div class="block50">
				<h2>{{$lang.Products_carriers_prices}}</h2>
				<table class="details">
					<tr><td colspan="3" class="help">{{$lang.help_product_deliveryPrices}}</td></tr>
					<tr><td colspan="3" class="help">{{$lang.help_product_deliveryPrices2}}</td></tr>
					{{foreach from=$aGeneralInfo.aCarriers item=aCarrier}}
						<tr>
							<td class="name"><label for="fCarrierPrice_{{$aCarrier.iCarrier}}">{{$aCarrier.sName}}</label></td>
							<td class="value"><input name="aCarrierPrice[{{$aCarrier.iCarrier}}]" id="fCarrierPrice_{{$aCarrier.iCarrier}}" value="{{$aProduct.aCarriersPrices[$aCarrier.iCarrier]}}" /></td>
							<td class="help"></td>
						</tr>
					{{/foreach}}
				</table>
			</div>

			<div class="block50">
				<h2>{{$lang.Products_discounts}}</h2>
				<table class="details">
					<tr><td colspan="4" class="help">{{$lang.help_product_discounts}}</td></tr>
					<tr>
						<th>{{$lang.Group_name}}</th><th>{{$lang.Discount}}</th><th>{{$lang.Can_see}}</th><th>{{$lang.Can_see_price}}</th><th>{{$lang.Can_buy}}</th>
					</tr>
					<tr>
						<td colspan="2">{{$lang.Not_logged_in}}</td>
						<td><input type="hidden" name="iVisibleAll" value="0" /><input type="checkbox" name="iVisibleAll" value="1" {{if $aProduct.iVisibleAll}}checked="checked"{{/if}} /></td>
						<td><input type="hidden" name="iVisiblePriceAll" value="0" /><input type="checkbox" name="iVisiblePriceAll" value="1" {{if $aProduct.iVisiblePriceAll}}checked="checked"{{/if}} /></td>
						<td><input type="hidden" name="iCanBuyAll" value="0" /><input type="checkbox" name="iCanBuyAll" value="1" {{if $aProduct.iCanBuyAll}}checked="checked"{{/if}} /></td>
					</tr>
					{{foreach from=$aGeneralInfo.aUsersGroups item=aGroup}}
						<tr>
							<td class="name"><label for="fDiscount_{{$aGroup.iGroup}}">{{$aGroup.sName}}</label></td>
							<td class="value"><input name="aDiscounts[{{$aGroup.iGroup}}]" id="fDiscount_{{$aGroup.iGroup}}" value="{{$aProduct.aDiscounts[$aGroup.iGroup]}}" /></td>
							<td><input type="hidden" name="aGroupsInfo[{{$aGroup.iGroup}}][iVisible]" value="0" /><input type="checkbox" name="aGroupsInfo[{{$aGroup.iGroup}}][iVisible]" value="1" {{if $aProduct.aGroupsInfo[$aGroup.iGroup]['iVisible']}}checked="checked"{{/if}} /></td>
							<td><input type="hidden" name="aGroupsInfo[{{$aGroup.iGroup}}][iVisiblePrice]" value="0" /><input type="checkbox" name="aGroupsInfo[{{$aGroup.iGroup}}][iVisiblePrice]" value="1" {{if $aProduct.aGroupsInfo[$aGroup.iGroup]['iVisiblePrice']}}checked="checked"{{/if}} /></td>
							<td><input type="hidden" name="aGroupsInfo[{{$aGroup.iGroup}}][iCanBuy]" value="0" /><input type="checkbox" name="aGroupsInfo[{{$aGroup.iGroup}}][iCanBuy]" value="1" {{if $aProduct.aGroupsInfo[$aGroup.iGroup]['iCanBuy']}}checked="checked"{{/if}} /></td>
						</tr>
					{{/foreach}}
				</table>
			</div>
			
			<div class="block50">
				<h2>{{$lang.Payment_block}}</h2>
				<table class="details">
					<thead>
						<tr><th>{{$lang.Payment}}</th><th>{{$lang.Block}}</th></tr>
					</thead>
					<tbody>
					{{foreach from = $aGeneralInfo.aPayments item = aPayment}}
						<tr>
							<td>{{$aPayment.sName}}</td>
							<td><input type="checkbox" name="aPaymentBlock[]" value="{{$aPayment.iPayment}}" {{if in_array( $aPayment.iPayment, $aProduct.aPaymentBlock )}}checked="checked"{{/if}}/></td>
						</tr>
					{{/foreach}}
					</tbody>
				</table>
			</div>
		</div>

		<div class="tab" id="product-files">
			{{include file='files_form_list.tpl' aFiles=$aProduct.aFiles}}
		</div>

					
		<div class="tab" id="product-seo">
			<table class="details">
				<thead>
					<tr>
						<th colspan="3"><h2>{{$lang.SEO}}</h2></th>
					</tr>
				</thead>
				<tbody>
					<tr>
						<th class="name">{{$lang.Tags}}</th>
						<td class="value"><input type="text" name="Tags" value="{{foreach from=$aProduct.aTags item=sTag}}{{$sTag}}, {{/foreach}}" class="input" id="tagit-tags" /></td>
						<td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_product_tags}}" /></td>
					</tr><tr>
						<th class="name">{{$lang.Page_title}}</th>
						<td class="value"><textarea name="sNameTitle">{{$aProduct.sNameTitle}}</textarea><br/>{{$lang.AutoSEO}}: {{$aMetaProduct.sTitle}}</td>
						<td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.Page_title_description}}" /></td>
					</tr><tr>
						<th class="name">{{$lang.Meta_description}}</th>
						<td class="value"><textarea name="sMetaDescription">{{$aProduct.sMetaDescription}}</textarea><br/>{{$lang.AutoSEO}}: {{$aMetaProduct.sDescription}}</td>
						<td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.Meta_description_description}}" /></td>
					</tr><tr>
						<th class="name">{{$lang.Key_words}}</th>
						<td class="value"><textarea name="sMetaKeywords">{{$aProduct.sMetaKeywords}}</textarea><br/>{{$lang.AutoSEO}}: {{$aMetaProduct.sKeywords}}</td>
						<td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.Key_words_description}}" /></td>
					</tr><tr>
						<th class="name">{{$lang.Page_Topic}}</th>
						<td class="value"><textarea name="sMetaPageTopic">{{$aProduct.sMetaPageTopic}}</textarea><br/>{{$lang.AutoSEO}}: {{$config.page_topic}}</td>
						<td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.Page_Topic_description}}" /></td>
					</tr><tr>
						<th class="name">{{$lang.Abstract}}</th>
						<td class="value"><textarea name="sMetaAbstract">{{$aProduct.sMetaAbstract}}</textarea><br/>{{$lang.AutoSEO}}: {{$config.abstract}}</td>
						<td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.Abstract_description}}" /></td>
					</tr><tr>
						<th class="name">{{$lang.GoogleAdWords_conversion_label}}</th><td class="value"><input type="text" name="sConversionLabel" value="{{$aProduct.sConversionLabel}}" /></td><td class="help"><img class="tTip info" src="templates/images/info.png"  title="{{$lang.help_product_ConversionLabel}}" /></td>
					</tr>
				</tbody>
			</table>
		</div>

		{{if !empty( $aProduct.iProduct )}}
			<div class="tab" id="product-avail_newsletter">
				<table class="details">
					<thead>
						<tr>
							<th colspan="3"><h2>{{$lang.Avail_newsletter}}</h2></th>
						</tr>
						<tr>
							<th><h2>{{$lang.Email}}</h2></th>
							<th><h2>{{$lang.Phone}}</h2></th>
							<th><h2>{{$lang.Date}}</h2></th>
						</tr>
					</thead>
					<tbody>
						{{foreach from=$aProduct.aAvailNewsletter item=aAvailNewsletter }}
							<tr><td>{{$aAvailNewsletter.sEmail}}</td><td>{{$aAvailNewsletter.sPhone}}</td><td>{{date( 'Y-m-d H:i:s', $aAvailNewsletter.iTime )}}</td></tr>
						{{/foreach}}
						
						{{foreach from=$aProduct.aVariants item=aVariant}}
							{{if !empty( $aVariant.aAvailNewsletter )}}
								<tr>
									<th colspan="3"><h2>Wariant [{{$aVariant.iProductVariant}}]: {{$aVariant.sName}}</h2></th>
								</tr>
								{{foreach from=$aVariant.aAvailNewsletter item=aAvailNewsletter}}
									<tr><td>{{$aAvailNewsletter.sEmail}}</td><td>{{$aAvailNewsletter.sPhone}}</td><td>{{date( 'Y-m-d H:i:s', $aAvailNewsletter.iTime )}}</td></tr>
								{{/foreach}}
							{{/if}}
						{{/foreach}}
					
					</tbody>
				</table>
			</div>

			<div class="tab smartoffer" id="product-stats">
				<a class="loader" href="?p=products-form&amp;iProduct={{$aProduct.iProduct}}&amp;tab=product-stats">{{$lang.Loading}}</a>
			</div>
			
			<div class="tab smartoffer" id="product-referers">
				<a class="loader" href="?p=products-form&amp;iProduct={{$aProduct.iProduct}}&amp;tab=product-referers">{{$lang.Loading}}</a>
			</div>
		{{/if}}

		<div class="tab" id="product-attributes">
			<table class="details" id="product-attributes-container">
				<thead>
					<tr>
						<th class="name">{{$lang.Attributes}}</th>
						<td class="help">{{$lang.help_product_variants_products}}</td>
						<td><a id="attributes-show" href="#"><span>{{$lang.Show_attributes}}</span></a></td>
					</tr>
					<tr>
						<td class="value" colspan="3">
							<ul id="AttributesProductList">
								{{foreach from=$aGeneralInfo.aAttributes item=sAttribute}}
									<li><label><input class="checkbox" value="{{$sAttribute@key}}" type="checkbox" {{if in_array( $sAttribute@key, $aProduct.aProductAttributesList )}}checked="checked"{{/if}} />{{$sAttribute}}</label></li>
								{{/foreach}}
							</ul>
						</td>
					</tr>
				</thead>
				<tbody id="product-attributes-list">
					<tr>
						<th>{{$lang.Attributes_choosen}}</th>
					</tr>
					<tr>
						<td colspan="3">
							<div id="attributes">
								<ul id="productAttributesChoosen">
									{{foreach from = $aGeneralInfo.aAttributesAndValues key = iAttribute item = aAttribute}}
										<li id="attribute-product-{{$iAttribute}}" {{if !isset( $aProduct.aProductAttributes.$iAttribute ) }}style="display: none;" disabled="disabled"{{/if}}>
											<label>{{$aAttribute.sName}}</label>
											<select id="attribute-{{$iAttribute}}-select" name="aProductAttributes[{{$iAttribute}}][]" multiple="multiple">
												{{foreach from = $aGeneralInfo.aAttributesAndValues.$iAttribute.aAValues key = iValue item = sValue}}
													<option value="{{$iValue}}" {{if in_array( $iValue, $aProduct.aProductAttributes.$iAttribute )}}selected="selected"{{/if}}>{{$sValue}}</option>
												{{/foreach}}
											</select>
											<div id="attribute_quick_add-attribute-{{$iAttribute}}" class="dialog" title="{{$lang.New_attribute_value}}">
												<label>{{$lang.Attribute_values}}: <input type="text" name="sValue" /></label> <input type="hidden" class="rel" value="#attribute-{{$iAttribute}}-select" /> <input type="hidden" class="action" value="admin.php?p=attributes-ajax_value&iAttribute={{$iAttribute}}&sValue=" />
											</div>
											<a href="#attribute_quick_add-attribute-{{$iAttribute}}" class="dialog"><img src="{{$config.dir_templates}}admin/images/ico/add.png" alt="{{$lang.New_attribute_value}}" /></a>
										</li>
									{{/foreach}}
								</ul>
							</div>
						</td>
					</tr>
				</tbody>
			</table>
		</div>
		<div class="save float">
			<div class="save floatcontainer"><input type="submit" class="submit" value="{{$lang.Save}}" name="sOption" /></div>
		</div>

	</fieldset>
</form>
