{{assign var=ColectionID value=130}}
{{assign var=ProductsColectionID value=129}} 
{{assign var=PricesColectionID value=131}} 
{{assign var=CatProdXref value=132}} 
{{getCollectionByCategory ColumnID='5' Value=$smarty.get.category CollectionID=$ColectionID Collection_130_6='on' OrderColumn='ID' var=Category}} 
{{if $Category|@count eq 0}} 
     {{getcontent id=4}} 
{{else}} 
	
	{{assign var=CategoryData value=$Category[0]}} 
	{{assign var=ColectionPrefix value='Collection_'}} 
	{{assign var=ColectionPrefix value=$ColectionPrefix|concat:$ColectionID|concat:'_'}} 
	{{assign var=CategoryID value=$ColectionPrefix|concat:'ID'}} 
	{{assign var=CategoryName value=$ColectionPrefix|concat:'8'}} 
	{{assign var=CategoryAbbrev value=$ColectionPrefix|concat:'5'}} 
	{{assign var=CategoryImage1 value=$ColectionPrefix|concat:'2'}} 
	{{assign var=CategoryImage2 value=$ColectionPrefix|concat:'3'}} 
	{{assign var=CategoryDesc value=$ColectionPrefix|concat:'4'}} 
	{{assign var=CategoryVisible value=$ColectionPrefix|concat:'6'}} 
	{{setPage var='Collection_17_2' value=$CategoryData.$CategoryName|concat:' Products'}}
	
	
{{assign var=ProductCategoryID value=$CategoryData.$CategoryID}}
<script type="text/javascript" src="/js/store.js"></script>
<script type="text/javascript">

function getOptions(prodid)
{
	var optionsText = '';
    var tags = document.getElementsByTagName('input');
	for (var j=0;j<tags.length;j++) {
			if (tags[j].className == 'op_'+ prodid && tags[j].checked == true)
			{
				
				if (document.getElementById('op_p_'+ tags[j].value))
				{
					var opObj = document.getElementById('op_p_'+ tags[j].value);
					if (opObj.value)
					{
						opValue = opObj.value;
					}
					else
					{
						opValue = opObj.options[opObj.selectedIndex].value;
					}
					
					optionsText += '&opt%5B%5D=' + tags[j].value + '&optv%5B%5D=' + opValue;
					
				}
				
				
			}
						
	}
	
	return optionsText;
}

function addToCart(prodid)
{
var qty = document.getElementById('q_'+prodid).value;
var pid = document.getElementById('p_'+prodid).options[document.getElementById('p_'+prodid).selectedIndex].value;
var optionsText = getOptions(prodid);
window.location='/addproduct.html?prodid='+prodid+'&quantity='+qty+'&price='+pid+'&page=shopping-cart.html' + optionsText;
}

function addToCart2(prodid, priceid)
{
var optionsText = getOptions(prodid );
window.location='/addproduct.html?prodid='+prodid+'&quantity='+document.getElementById('q_'+ prodid).value+'&price='+priceid+'&page=shopping-cart.html'+ optionsText;
}
</script>

<div id="submenu">
<div id="smarty_plugin">{{getcontent id=40}}</div>
</div>
<div id="middle2">

<h1>{{$CategoryData.$CategoryName}}</h1>



	{{if $CategoryData.$CategoryDesc neq ''}}
		<p>{{$CategoryData.$CategoryDesc}}</p>
	{{/if}}
	
	
	{{getTreeChildNumberAdmin var=SubCategories CategoryID=$ProductCategoryID OrderCol=9 OrderWay=0  CID=$ColectionID noDisplay=1 Level=0 }}
	{{if $SubCategories|@count gt 0}}
			{{foreach from=$SubCategories item=v key=k}}{{if $v.$CategoryVisible eq 'on'}}
			<h3><a href="/store/{{$v.$CategoryAbbrev}}.html">{{$v.$CategoryName}}</a></h3>
			{{if $v.$CategoryDesc neq ''}}<p>{{$v.$CategoryDesc}}</p>{{/if}}{{/if}}
			{{/foreach}}
			<p> </p>
	{{/if}}
	
	{{getCollectionByXRef CollectionID=$ProductsColectionID FilterColumnID=8 FilterValue='on' CollectionJoin=$ColectionID CollectionJoinValues=$ProductCategoryID Var=Products}} 
	{{if $Products|@count eq 0}}
            {{if $SubCategories|@count eq 0}}
			<p>There are no products in this category. </p>
			{{/if}}
    {{else}} 
			
			<h2>Products</h2>
		{{assign var=ProdPrefix value='Collection_'}} 
		{{assign var=ProdPrefix value=$ProdPrefix|concat:$ProductsColectionID|concat:'_'}}
		{{assign var='ProductID' value=$ProdPrefix|concat:'ID'}}
		{{assign var='ProductName' value=$ProdPrefix|concat:'1'}} 
		{{assign var='ProductItem' value=$ProdPrefix|concat:'13'}} 
		{{assign var='ProductSample' value=$ProdPrefix|concat:'14'}} 
		{{assign var='ShortDesc' value=$ProdPrefix|concat:'2'}} 
		{{assign var='SmallImage' value=$ProdPrefix|concat:'5'}} 
		{{assign var=PricePrefix value='Collection_'}} 
		{{assign var=PricePrefix value=$PricePrefix|concat:$PricesColectionID|concat:'_'}} 
		{{assign var='PriceID' value=$PricePrefix|concat:'ID'}} 
		{{assign var='PriceName' value=$PricePrefix|concat:'2'}} 
		{{assign var='Price' value=$PricePrefix|concat:'3'}} 
		{{assign var='ItemDesc' value=$PricePrefix|concat:'4'}} 
		{{assign var='PriceImage' value=$PricePrefix|concat:'5'}} 
			
			<table cellpadding="2" cellspacing="2" border="0" width="480">
			<tr valign="top">
			{{foreach from=$Products item=v key=k name=plist}}
			{{if $smarty.foreach.plist.index % 1 eq 0 and $smarty.foreach.plist.index neq 0}}</tr><tr valign="top">{{/if}}
			<td>
			
            		<div class="product">
					<table cellpadding="4" cellspacing="4" border="0" width="100%">
					<tr valign="middle">
						<td>
						<a href="/store-products/{{$v.$ProductID}}.html"><img id="image_{{$v.$ProductID}}" alt="{{$v.$ProductName}}" src="{{if $v.$SmallImage neq ''}}{{$v.$SmallImage}}{{else}}/images/contentimages/image_20_4_54.gif {{/if}}" border="0" /></a>
						</td>
						<td>
						{{if $v.$ProductItem neq ''}}<p><strong>Item #:</strong> {{$v.$ProductItem}}</p>{{/if}}
						<h5><a href="/store-products/{{$v.$ProductID}}.html">{{$v.$ProductName}}</a></h5>
						<p>{{$v.$ShortDesc|nl2br}}</p>
						{{if $v.$ProductSample neq ''}}{{assign var=tmp value=$v.$ProductSample}}<p><a target="_blank" href="{{$Documents.$tmp}}">View Sample Pages</a></p>{{/if}}
						</td>
					</tr>
					<tr>
						<td colspan="2" align="right">
						
						{{getCollectionByCategory ColumnID='1' Value=$v.$ProductID CollectionID=$PricesColectionID OrderColumn='ID' var=Prices}}
									{{if $Prices|@count gt 1}}
										<select name="p_{{$v.$ProductID}}" id="p_{{$v.$ProductID}}" class="selectbox" onChange="makeChanges(this , {{$v.$ProductID}})">
										{{foreach from=$Prices item=vv key=kk}}
										<option value="{{$vv.$PriceID}}" img="{{if $vv.$PriceImage neq ''}}{{$vv.$PriceImage}}{{/if}}">{{$vv.$PriceName}}  ${{$vv.$Price|string_format:'%.2f'}}</option>
										{{/foreach}}
										</select>   
										<input size="2" name="q_{{$v.$ProductID}}" id="q_{{$v.$ProductID}}" value="1" />
										 
										<a href="javascript: addToCart({{$v.$ProductID}});">Add To Cart</a>
									{{else}}
										{{assign var=vv value=$Prices[0]}}
										<strong>${{$vv.$Price|string_format:'%.2f'}} </strong>
									<input size="2" name="q_{{$v.$ProductID}}" id="q_{{$v.$ProductID}}" value="1" /> 
									<a onclick="javascript: void(0);" href="javascript: addToCart2({{$v.$ProductID}}, {{$vv.$PriceID}});">Add To Cart</a>
									{{/if}}		
						
						</td>
					</tr>
					<tr>
					<td colspan="2">
					{{assign var=ProductIDForOptions value=$v.$ProductID}}		
						{{getcontent id=107}}
					</td>
					</tr>
					</table>
					<hr width="70%" align="center">
					</div>
            
			</td>
			{{/foreach}} 
			</tr>
			</table>
			
	{{/if}}

</div>	
{{/if}}