{{ 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">
                    <label for="name">Nome:</label>
                    <input type="text" name="name" class="form-control title" value="{{ old('name') }}">
                </div>                
            </div>
            <div class="col-md-6">
                <div class="form-group">
                    <label for="slug">Slug:</label>
                    <input type="text" name="slug" class="form-control slug" value="{{ old('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">
                        <label for="layout">Layout:</label>
                        <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">
                        <label for="type">Tipologia:</label>
                        {{-- TODO: Convert Form::select for type manually --}}
<select name="type" class="form-control">
    {{-- Add options manually --}}
</select>
                    </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">
                    <label for="type">Tipologia:</label>
                    {{-- TODO: Convert Form::select for type manually --}}
<select name="type" class="form-control">
    {{-- Add options manually --}}
</select>
                </div>                
            </div>
            <div class="col-md-3">
                <div class="form-group">
                    <label for="show_social">Mostra box Facebook:</label><br>
                    <input type="checkbox" name="show_social" value="on" {{ old('show_social') ? 'checked' : '' }}>
                </div>                
            </div>
            <div class="col-md-3">
                <div class="form-group">
                    <label for="show_social_twitter">Mostra box Twitter:</label><br>
                    <input type="checkbox" name="show_social_twitter" value="on" {{ old('show_social_twitter') ? 'checked' : '' }}>
                </div>                
            </div>
        </div>
    </div>

    <div class="box-footer">
        @if(Auth::user()->only_read == false)
            <button type="submit" class="btn btn-success">{{ $submit_text }}</button>
        @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