@using System
@using MrCMS.Helpers
@model MrCMS.Web.Apps.Ecommerce.Models.FeaturedProductsViewModel
@if (Model != null)
{
    ViewData["cart"] = Model.Cart;
    if (!String.IsNullOrEmpty(Model.Title))
    {
        <div class="margin-top-70-bottom-30 grey-border-top featured-products-widget">
            <div class="container">
                <div class="margin-top-bottom-10">
                    <div class="row">
                        <div class="col-md-12">
                            <span class="title">
                                @if (!String.IsNullOrEmpty(Model.Title))
                                {
                                    @Model.Title
                                }
                            </span>
                        </div>
                    </div>
                </div>
                @ShowItems()
            </div>
        </div>
    }
    else
    {
        <div class="margin-top-bottom-10 featured-products-widget">
            <div class="container">
                <div class="padding-top-bottom-20">
                    @ShowItems()
                </div>
            </div>
        </div>
    }
}
@helper ShowItems()
{
    foreach (var itemRow in Model.Products.Chunk(4))
    {
        var i = 0;
        <div class="row text-center">
            @foreach (var item in itemRow)
            {
                i++;
                <div class="col-md-3 col-sm-3 col-xs-6">
                    @{Html.RenderPartial("ProductCardFeatured", item);}
                </div>
                if (i % 2 == 0)
                {
                    <div class="clearfix visible-xs"></div>
                }
            }
        </div>
    }
}