<script type="text/javascript">
    var productsCountVar = '{$prodsMaxCount|default:0}';
    var lastCatkey       = "{$resProducts[$resProducts|count-1]['catKey']}|default:''";
   
</script>

{if $toAppend|default:'' neq Yes}
<ul class="cateListing list-unstyled m-0 gridBg row p-0" id="prodListingUl">
    {/if} 
    {assign var="categoryKey" value=""}
    {foreach $resProducts|default:array() as $resProduct key="key" name="highlt"} 
    {assign var="productID" value=$resProduct.productID} 
    {assign var="productOptionsCount" value=$resProduct['productOptionCount']|default:''} 
    {assign var="offerPrice" value=$resProduct['offerPrice']} 
    {assign var="productOptionRegularPrice" value=$resProduct['productOptionRegularPrice']} 
    {assign var="productOptionCashBack" value=$resProduct['productOptionCashBack']|default:''} 
    {assign var="productOptionOfferDiscount" value=$resProduct['productOptionOfferDiscount']|round} 
    {assign var="productOptionQuantitySum" value=$resProduct.productOptionQuantitySum} 
    {assign var="item.freeProductsCount" value=$resProduct.freeProductsCount} 
    {assign var="productCurrency" value=$resProduct.productDefaultCurrency} 
    {assign var="uniqueID" value=$uniqueID|default:''}

		 <li class="col-12 col-sm-6 col-md-4 col-lg-6 col-xl-4 p-0" rel="product_{$productID}" uniqueID="{$uniqueID}">
        <div class="imageBox bg-white mb-sm-0 mb-3 text-left h-100 d-flex flex-column position-relative">
            <div class="image-thumb position-relative px-3 py-2">
                <figure class="position-relative mb-0">
                    {if $listLevel|default:'' eq '3'}
                        {assign var="urlValue" value="{$resProduct.productID|sef_path:'product':$originCatalogID|default:0}"}
                        {html->anchor href="{$resProduct.productID|sef_path:'product':$originCatalogID|default:0}" class="d-inline-block w-100" title=$language.lblViewDetails content="{if $resProduct.catKey|default:'' neq $categoryKey}<div class='category_icon position-absolute font-weight-bold'>{$resProduct.catBgName}</div>{/if}<img class='lazy img-fluid' data-original='{$view_public_path}/uploads/catalog/vehicles/thumb/{$resProduct.productImage}' src='{$view_images}/loader-small.gif' alt='{$resProduct.productTitle}'>"}
                   {else}
                      
                       {if $listLevel|default:'' eq '1'}
                           {if $resProduct.bodyStyle|lower|default:'' neq 'off road'}
                                {assign var="showTitle" value=$resProduct.catName|cat:" "|cat:$resProduct.bodyStyle}
                           {else}
                               {assign var="showTitle" value=$resProduct.catName}
                            {/if}
                       {else}
                            {assign var="showTitle" value="{$resProduct.productShortDescription}"}
                       {/if}
                       {if $showTitle|default:'' eq ''}
                           {assign var="showTitle" value="{$resProduct.productTitle}"}                           
                        {/if}
                        {if $resProduct.bodyStyle|lower|default:'' neq 'off road'}
                             {assign var="urlValue" value="/series/{$resProduct.catKey}/{$resProduct.bodyStyle}/"}
                        {else}
                             {assign var="urlValue" value="/series/{$resProduct.catKey}/"}                             
                        {/if}
                        {assign var="bodystyleparam" value="{$resProduct.bodyStyle}"}
                        {if $listLevel|default:'' eq '2'}
                            {assign var="catparam" value="{$resProduct.catKey}"}
                            {if $bodystyleparam|lower|default:'' neq 'off road'}
                                 {assign var="urlValue" value="/series/{$catparam}/{$bodystyleparam}/code/{$resProduct.bmwCode}/"}
                           {else}
                                 {assign var="urlValue" value="/series/{$catparam}/code/{$resProduct.bmwCode}/"}                     
                           {/if}
                        {else}
                            {if $bodystyleparam|lower|default:'' neq 'off road'}
                                {assign var="urlValue" value="/series/{$resProduct.catKey}/{$bodystyleparam}/"}
                           {else}
                                {assign var="urlValue" value="/series/{$resProduct.catKey}/"}                            
                           {/if}
                        {/if}
                      {html->anchor href="{$urlValue}" class="d-inline-block w-100" title=$language.lblViewDetails content="{if $resProduct.catKey|default:'' neq $categoryKey}<div class='category_icon position-absolute font-weight-bold'>{$resProduct.catBgName}</div>{/if}<img class='lazy img-fluid' data-original='{$view_public_path}/uploads/catalog/vehicles/thumb/{$resProduct.productImage}' src='{$view_images}/loader-small.gif' alt='{$showTitle}'>"}
                   {/if}
               </figure>
               {assign var="categoryKey" value="{$resProduct.catKey}"}
                <!-- days left ends -->
			 </div>
            <div class="deatils product-info-block px-md-4 px-3 pb-3"> 
                {if $resProduct.financeDesc|default:'' neq ''}
                    <div class="advantage-label bg-primary text-white font-xsmall px-lg-4 px-3 py-1 mb-3 text-center">
                    <span class="font-family-secondary">{$resProduct.financeDesc}</span> {if $listLevel|default:'' eq '3'}{if $resProduct.financeDetailedDesc|default:'' neq ''} <i class="icon-info" data-toggle="tooltip" data-placement="top" data-html="true" title="{$resProduct.financeDetailedDesc|unescape:'html'|escape:'html'}"></i>{/if}{/if}</div>
                   {else}
                   
                    <div class="advantage-label bg-primary text-white font-xsmall px-lg-4 px-3 py-1 mb-3 text-center opacity-0">
                    <span class="font-family-secondary">offer</span></div>
                {/if}
			    <h6 class="productTitle font-weight-bold f15 mb-1">
                    {if $listLevel|default:'' eq '3'}
                        {html->anchor href="{$resProduct.productID|sef_path:'product':$originCatalogID|default:0}" content="{$brandName} {$resProduct.productTitle|truncate:45}" class="text-secondary"}
                    {else}
                        {html->anchor href="{$urlValue}" content="{$brandName} {$showTitle|truncate:45}" class="text-secondary"}
                    {/if}
                </h6>
                {if $resProduct.monthlyInstallment|default:''>=0}
            <div class="font-small">
                {$language.lblFinanceEMI} <span class="font-weight-bold">{$resProduct.monthlyInstallment|price}</span></div>
                {/if}
                <div class="row m-0 pt-1 link-block align-items-center">
                    <div class="col-6 p-0 text-left">
                        {html->anchor href="{$urlValue}" class="font-weight-bold font-small viewDetail d-flex align-items-center py-1" title=$language.lblViewDetails content="{if $languageDirection=='rtl'}<i class='icon-arrow-left font-weight-bold font-xsmall mr-1'></i>{else}<i class='icon-arrow-right font-weight-bold font-xsmall mr-1'></i>{/if}{$language.lblViewDetails}"}
                    </div>
                </div>
            </div>
        </div>
    </li>
	{/foreach}
{if $toAppend|default:'' neq Yes}</ul>{/if}
{if $toAppend|default:'' neq Yes && $resProducts|default:array()|count ==0}
{include file='IndexNoProduct.tpl'}
{/if}