@using System.Drawing
@using System.Linq
@model MrCMS.Web.Apps.Core.Widgets.Slider
@if (Model.Sliders.Any())
{
    var sliders = Model.Sliders.ToList();
    
    <div id="carousel-@Model.Name" class="carousel slide" data-ride="carousel">
        <ol class="carousel-indicators">
            @for (int i = 0; i < Model.Sliders.Count(); i++)
            {
                <li data-target="#carousel-@Model.Name" data-slide-to="@i" class="@(i == 0 ? "active" : "")"></li>
            }
        </ol>
        <div class="carousel-inner">
            @foreach (var slider in sliders)
            {
                var image = RenderImage(slider.Image);
                <div class="item @(slider == sliders.First() ? "active" : "")">
                    @if (string.IsNullOrWhiteSpace(slider.Link))
                    {
                        @image
                    }
                    else
                    {
                        <a href="@slider.Link">@image</a>
                    }
                    @if (!string.IsNullOrWhiteSpace(slider.Description))
                    {
                        <div class="carousel-caption">
                            @slider.Description
                        </div>
                    }
                </div>
            }
        </div>
        <a class="left carousel-control" href="#carousel-@Model.Name" data-slide="prev">
            <span class="glyphicon glyphicon-chevron-left"></span>
        </a>
        <a class="right carousel-control" href="#carousel-@Model.Name" data-slide="next">
            <span class="glyphicon glyphicon-chevron-right"></span>
        </a>
    </div>
}

