{{ csrf_field() }}
<div class="box box-primary">
    <div class="box-header with-border">
        <h3 class="box-title"></h3>
    </div>

    <div class="box-body">
        <div class="row">
            <div class="col-md-6">
                <div class="form-group">
                    {!! Form::label('name', 'Nome:') !!}
                    {!! Form::text('name', null, array('class' => 'form-control title')) !!}
                </div>                
            </div>
            <div class="col-md-6">
                <div class="form-group">
                    {!! Form::label('slug', 'Slug:') !!}
                    {!! Form::text('slug', null, array('class' => 'form-control slug')) !!}
                </div>                
            </div>
            
        </div>
        <input name="layout" type="hidden" value="{{isset($section) ? $section->layout : ''}}" id="layout">
        @if(false)
            <div class="row">
                <div class="col-md-6">
                    <div class="form-group">
                        {!! Form::label('layout', 'Layout:') !!}
                        <br>
                        @for($x=1;$x<=6;$x++)
                            <div style="padding:10px;float:left;{{(isset($section) && $section->layout == 'layout_' . $x) ? 'background-color:red;' : ''}} " class="selImg" data-id="layout_{{$x}}">
                                <img src="/images/layout_{{$x}}.png" style="width:150px;">
                            </div>
                        @endfor
                        
                        <input name="layout" type="hidden" value="{{isset($section) ? $section->layout : ''}}" id="layout">
                        
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="form-group">
                        {!! Form::label('type', 'Tipologia:') !!}
                        {!! Form::select('type', ['section' => 'Nazionale', 'region' => 'Regionale'] , null, array('class' => 'form-control')) !!}
                    </div>                
                </div>
            </div>
        @endif
        <input name="position" type="hidden" value="{{isset($section) ? $section->position : '0'}}">
        <div class="row">
            <div class="col-md-6">
                <div class="form-group">
                    {!! Form::label('type', 'Tipologia:') !!}
                    {!! Form::select('type', ['section' => 'Nazionale', 'region' => 'Regionale'] , null, array('class' => 'form-control')) !!}
                </div>                
            </div>
            <div class="col-md-3">
                <div class="form-group">
                    {!! Form::label('show_social', 'Mostra box Facebook:') !!}<br>
                    {!! Form::checkbox('show_social', 'on', null) !!}
                </div>                
            </div>
            <div class="col-md-3">
                <div class="form-group">
                    {!! Form::label('show_social_twitter', 'Mostra box Twitter:') !!}<br>
                    {!! Form::checkbox('show_social_twitter', 'on', null) !!}
                </div>                
            </div>
        </div>
    </div>

    <div class="box-footer">
        @if(Auth::user()->only_read == false)
            {!! Form::submit($submit_text, ['class'=>'btn btn-success']) !!}
        @endif
        {!! link_to_route('sections.index', 'Annulla', null, array('class' => 'btn btn-info')) !!}
    </div>
</div>

@section('extra_js')

    <script>
        
        $(function () {

            $(".title").keyup(function(){
                var Text = $(this).val();
                Text = Text.toLowerCase();
                Text = Text.replace(/[^a-zA-Z0-9]+/g,'-');
                $(".slug").val(Text);        
            });

            $(".selImg").click(function(){
                $(".selImg").css("background-color", "white");  
                $(this).css("background-color", "red");  
                var id = $(this).attr("data-id");
                $("#layout").val(id);
            });
            
        });

    </script>
@stop