{if $body.product.variations.labels[$cfg.cyklospeciality_tpl.variation_helmet_labels_id]}
   {include "product/product.variations.size-convertion.tpl" id_convertor=$cfg.cyklospeciality_tpl.helmet_convertor_id}
{else}
   {$precheck_single = true}

   <div data-variations="variations-ajax">
      {if $body.product.param[18]}
         {$imgType = 20}
      {else}
         {$imgType = 3}
      {/if}
      {function sizeTableBtn}
         {if $body.returnNav[0][1].ID == 22}
            <div class="size-table-link-wrapper">
               <a class="size-table-link" href="" data-focus-opener="focus-sizetable"><span>{t}Velikostní tabulka{/t}</span><span class="fc icons_height"></span></a>
            </div>
         {/if}
      {/function}

      {foreach $body.product.variations.labels as $label}
         <div class="product-variations-header"{if $label.id == $cfg.cyklospeciality_tpl.bv_variations_id} style="display: none;"{/if}>
            <p class="h5" data-variation-error="title">
               {$label.label}
            </p>
            {*todo sizetable link*}
         </div>

         {if $label.id == {$cfg.cyklospeciality_tpl.variation_color_labels_id}}
            <div class="product-colors product-variations" data-color-variations>
               {foreach $label.values as $id => $value}
                  {$allowedVars = []}
                  {$labelValue = $value|lower}
                  {foreach $body.product.variations.variations as $variation}
                     {if ($variation.title|lower)|strstr:$labelValue}
                        {$variationPhoto = $variation.photos[0]}
                        {$inStore = $variation.in_store}
                        {if !$variation.in_store && $variation.in_store_suppliers > 0}
                           {$inStore = true}
                        {/if}
                        {$allowedVars[$variation.combinations[1].id_value] = $variation.combinations[1].id_value}
                     {/if}
                  {/foreach}
                  <input name="IDLabel_{$label.id}" type="radio" value="{$id}" data-color-control id="lab_{$label.id}_{$id}" data-allowed-vars="{foreach $allowedVars as $v}{$v},{/foreach}">
                  <label for="lab_{$label.id}_{$id}" class="product-variation product-variation-color {if !$inStore}soldout{/if}"
                         data-variation-color>
                     <span class="color" title="{$value}" style="background-color: {$label.data[$id].colorCode};"></span>
                  </label>
               {/foreach}

            </div>
         {else}
            <div class="product-variations"
                 data-other-variations{if $label.id == $cfg.cyklospeciality_tpl.bv_variations_id} style="display: none;"{/if}>
               {foreach $label.values as $id => $value}
                  {$labelValue = $value}
                  {foreach $body.product.variations.variations as $variation}
                     {$var_title=": "|explode:$variation.title}
                     {if $var_title[1] == $labelValue}
                        {$inStore = $variation.in_store}
                        {if $variation.delivery_time_index == 0}
                           {$inStore = true}
                        {elseif $variation.in_store_suppliers > 0}
                           {$inStore = $variation.in_store_suppliers}
                        {/if}

                     {/if}
                  {/foreach}

                  <input name="IDLabel_{$label.id}" type="radio" value="{$id}" id="lab_{$label.id}_{$id}" >
                  <label for="lab_{$label.id}_{$id}"
                         class="product-variation{if $label.id == {$cfg.cyklospeciality_tpl.variation_handlebar_labels_id}} variation-handlebar{/if} {if !$inStore} soldout{if !findModule('watchdog')} disabled{/if}{/if}"
                         data-id="{$id}">
                     {if $label.id == {$cfg.cyklospeciality_tpl.variation_handlebar_labels_id}}
                        <span class="fc icons_handlebar-{$value|lower}"></span>
                     {/if}
                     <span class="variation-title">{$value}</span>
                  </label>
               {/foreach}
            </div>
         {/if}

      {/foreach}

      <script>
         wpj.variations = {ldelim}{rdelim};
      </script>

      <div class="product-variations" style="display: none;">
         {foreach $body.product.variations.variations as $variation}
            {* varianta je vyprodana a v adminu je vypnute zobrazovani vyprodanych produktu *}
            {if $variation.delivery_time_index != 0 and $dbcfg.prod_show_not_in_store == "N"}
               {continue}
            {/if}

            {* varianta je vyprodana a v adminu je vypnute zobrazovani vyprodanych produktu *}
            {if $variation.delivery_time_index != 0 and $dbcfg.prod_show_not_in_store == "N"}
               {continue}
            {/if}

            {$soldout = true}

            {if $variation.delivery_time_index == 0}
               {* varianta je skladem *}
               {$soldout = false}
            {elseif $variation.in_store_suppliers > 0}
               {$soldout = false}
            {elseif $dbcfg.order_not_in_store == 'N' }
               {* varianta není skladem a je zakázáno kupování vyprodaných prod. v adminu *}
               {* $soldout je true *}
            {elseif $cfg.Products.allowSoldoutToCart[$variation.delivery_time_index] or
            ($cfg.Products.allowSoldoutToCart[1] and $variation.delivery_time_index > 0)}
               {* delivery_time_index varianty je povoleny v configu *}
               {$soldout = false}
            {/if}
            <script>{* @formatter:off *}
               wpj.variations[{$variation.id}] = {
                  soldout: "{$soldout}",
                  {ifmodule WATCHDOG}
                  {get_product_info type='is_watchdog' id_variation=$variation.id product=$body.product assign='is_watchdog'}
                  watchdog: {if $soldout}true{else}false{/if},
                  deleteWatchdog: "/launch.php?s=watchdog&IDp={$body.product.id}&IDv={$variation.id}&acn=delete", {* todo jak to generovat neescapovane? *}
                  {if $is_watchdog}
                  watchdogActive: true,
                  {/if}
                  {/ifmodule}
                  combinations: {
               {foreach $variation.combinations as $comb}
               {$comb.id_label}: {$comb.id_value},
               {/foreach}
               },
               }
               {* @formatter:on *}
            </script>
            <input name="IDvariation" type="radio" value="{$variation.id}" id="var_{$variation.id}"{if $soldout} class="soldout"{/if}
                    {if $soldout and !findModule('watchdog')} disabled
                    {elseif $precheck_single and $body.product.variations.variations|count == 1}checked{/if}
                    {if $body.product.variations.labels[{$cfg.cyklospeciality_tpl.variation_color_labels_id}]}
                       {foreach $variation.photos as $photo}
                          {if $photo.id_photo == $body.product.image.id and !$soldout}
                             checked
                             {break}
                          {/if}
                       {/foreach}
                    {/if}

            >
            <label for="var_{$variation.id}"
                   class="product-variation {if $soldout}soldout {if findModule('watchdog')}watchdog{else}disable{/if}{/if}">
                  <span class="variation-title">
                     {foreach $variation.combinations as $index => $comb}
                        {$body.product.variations.labels[$comb.id_label].values[$comb.id_value]}
                     {/foreach}
                  </span>
            </label>
         {/foreach}
      </div>
   </div>
{/if}
