<style>
    .second-level, .third-level
    {
        position: absolute !important;
        left: 182px !important;
        top: -2px !important;
    }
</style>
<header class="clearfix second-style">


    <!-- Bootstrap navbar -->
    <nav class="navbar navbar-default navbar-static-top" role="navigation">

        <div class="logo-advertisement">
            <div class="container">

                <!-- Brand and toggle get grouped for better mobile display -->
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                        <span class="sr-only">Toggle navigation</span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <a class="navbar-brand" href="/"><img src="/images/logo.jpg" alt=""></a>
                </div>

                <div class="advertisement carousel slide" data-ride="carousel">
                    <div class="desktop-advert carousel-inner">

                        @if($home->banner_top_google != '')
                            <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
                            <ins class="adsbygoogle"
                                style="display:block"
                                data-ad-client="ca-pub-0209495346002620"
                                data-ad-slot="{{$home->banner_top_google}}"
                                data-ad-format="auto"
                                data-full-width-responsive="true"></ins>
                            <script>
                                (adsbygoogle = window.adsbygoogle || []).push({});
                            </script>
                        @else
                            @php
                            $found = false;
                            $count = 0;
                            @endphp
                            @if(isset($home->banner_top) && $home->banner_top != '')
                                <div class="item {{$count == 0 ? 'active' : ''}}">
                                    <a href="{{$home->banner_top_url}}"><img src="/files/{{$home->banner_top}}"  width="728" alt="" style="border:1px solid gray;"></a>
                                </div>
                                @php
                                $count += 1;
                                $found = true;
                                @endphp
                            @endif
                            @if(isset($home->banner_top_2) && $home->banner_top_2 != '')
                                <div class="item {{$count == 0 ? 'active' : ''}}">
                                    <a href="{{$home->banner_top_url_2}}"><img src="/files/{{$home->banner_top_2}}"  width="728" alt="" style="border:1px solid gray;"></a>
                                </div>
                                @php
                                $found = true;
                                @endphp
                            @endif
                            @if(isset($home->banner_top_3) && $home->banner_top_3 != '')
                                <div class="item {{$count == 0 ? 'active' : ''}}">
                                    <a href="{{$home->banner_top_url_3}}"><img src="/files/{{$home->banner_top_3}}"  width="728" alt="" style="border:1px solid gray;"></a>
                                </div>
                                @php
                                $found = true;
                                @endphp
                            @endif
                            @if(isset($home->banner_top_4) && $home->banner_top_4 != '')
                                <div class="item {{$count == 0 ? 'active' : ''}}">
                                    <a href="{{$home->banner_top_url_4}}"><img src="/files/{{$home->banner_top_4}}"  width="728" alt="" style="border:1px solid gray;"></a>
                                </div>
                                @php
                                $found = true;
                                @endphp
                            @endif
                            @if(isset($home->banner_top_5) && $home->banner_top_5 != '')
                                <div class="item {{$count == 0 ? 'active' : ''}}">
                                    <a href="{{$home->banner_top_url_5}}"><img src="/files/{{$home->banner_top_5}}"  width="728" alt="" style="border:1px solid gray;"></a>
                                </div>
                                @php
                                $found = true;
                                @endphp
                            @endif
                            @if(!$found)
                                <div class="widget" style="width:728px;height:90px;border:1px solid gray;">
                            @endif
                        @endif

                    </div>
                    <div class="tablet-advert carousel-inner">
                        @if($home->banner_top_google != '')
                            <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
                            <ins class="adsbygoogle"
                                style="display:block"
                                data-ad-client="ca-pub-0209495346002620"
                                data-ad-slot="{{$home->banner_top_google}}"
                                data-ad-format="auto"
                                data-full-width-responsive="true"></ins>
                            <script>
                                (adsbygoogle = window.adsbygoogle || []).push({});
                            </script>
                        @else
                            @php
                            $found = false;
                            $count = 0;
                            @endphp
                            @if(isset($home->banner_top) && $home->banner_top != '')
                                <div class="item {{$count == 0 ? 'active' : ''}}">
                                    <a href="{{$home->banner_top_url}}"><img src="/files/{{$home->banner_top}}"  width="728" alt="" style="border:1px solid gray;"></a>
                                </div>
                                @php
                                $count += 1;
                                $found = true;
                                @endphp
                            @endif
                            @if(isset($home->banner_top_2) && $home->banner_top_2 != '')
                                <div class="item {{$count == 0 ? 'active' : ''}}">
                                    <a href="{{$home->banner_top_url_2}}"><img src="/files/{{$home->banner_top_2}}"  width="728" alt="" style="border:1px solid gray;"></a>
                                </div>
                                @php
                                $found = true;
                                @endphp
                            @endif
                            @if(isset($home->banner_top_3) && $home->banner_top_3 != '')
                                <div class="item {{$count == 0 ? 'active' : ''}}">
                                    <a href="{{$home->banner_top_url_3}}"><img src="/files/{{$home->banner_top_3}}"  width="728" alt="" style="border:1px solid gray;"></a>
                                </div>
                                @php
                                $found = true;
                                @endphp
                            @endif
                            @if(isset($home->banner_top_4) && $home->banner_top_4 != '')
                                <div class="item {{$count == 0 ? 'active' : ''}}">
                                    <a href="{{$home->banner_top_url_4}}"><img src="/files/{{$home->banner_top_4}}"  width="728" alt="" style="border:1px solid gray;"></a>
                                </div>
                                @php
                                $found = true;
                                @endphp
                            @endif
                            @if(isset($home->banner_top_5) && $home->banner_top_5 != '')
                                <div class="item {{$count == 0 ? 'active' : ''}}">
                                    <a href="{{$home->banner_top_url_5}}"><img src="/files/{{$home->banner_top_5}}"  width="728" alt="" style="border:1px solid gray;"></a>
                                </div>
                                @php
                                $found = true;
                                @endphp
                            @endif
                            @if(!$found)
                                <div class="widget" style="width:728px;height:90px;border:1px solid gray;">
                            @endif
                        @endif
                    </div>
                </div>
            </div>
        </div>
        <!-- End Logo & advertisement -->

        <!-- navbar list container -->
        <div class="nav-list-container">
            <div class="container">

                <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                    <ul class="nav navbar-nav navbar-left">
                        <li><a href="/">Home</a></li>
                        @foreach($sections_menu as $section)
                            <li>
                                @if($section->layout != '')
                                    <a href="#" onclick="scroll_to('{{$section->slug}}')">{{$section->name}}</a>
                                @else
                                    <a href="/{{$section->slug}}">{{$section->name}}</a>
                                @endif
                            </li>
                        @endforeach
                        <li class="dropdown" id="calendarMobile">
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Calendari e risultati <span class="caret"></span></a>
                            <ul class="dropdown-menu">
                                @foreach($calendars as $type => $categories)
                                    <li class="dropdown">
                                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{$type}} </a>
                                        <ul class="dropdown-submenu">
                                            @foreach($categories as $category => $groups)
                                                @if(is_array($groups))
                                                    <li class="dropdown">
                                                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{$category}} </a>
                                                        <ul class="dropdown-submenu">
                                                            @foreach($groups as $group => $cal)
                                                                <li><a href="/calendario/{{Str::slug($category)}}-{{Str::slug($group)}}/{{$cal}}">{{$group}}</a></li>
                                                            @endforeach
                                                        </ul>
                                                    </li>
                                                @else
                                                    <li>
                                                        <a href="/calendario/{{Str::slug($category)}}/{{$groups}}">{{$category}}</a>
                                                    </li>
                                                @endif
                                            @endforeach
                                        </ul>
                                    </li>
                                @endforeach
                            </ul>
                          </li>
                        <li class="drop" id="calendar"><a class="home" href="#">Calendari e risultati</a>
                            <ul class="dropdown">
                                @foreach($calendars as $type => $categories)
                                    <li class="drop">
                                        <a href="#">{{$type}}</a>
                                        <ul class="dropdown second-level">
                                            @foreach($categories as $category => $groups)
                                                @if(is_array($groups))
                                                    <li class="drop">
                                                        <a href="#">{{$category}}</a>
                                                        <ul class="dropdown third-level">
                                                            @foreach($groups as $group => $cal)
                                                                <li><a href="/calendario/{{Str::slug($category)}}-{{Str::slug($group)}}/{{$cal}}">{{$group}}</a></li>
                                                            @endforeach
                                                        </ul>
                                                    </li>
                                                @else
                                                    <li>
                                                        <a href="/calendario/{{Str::slug($category)}}/{{$groups}}">{{$category}}</a>
                                                    </li>
                                                @endif
                                            @endforeach
                                        </ul>
                                    </li>
                                @endforeach

                            </ul>
                        </li>
                        <li class="drop"><a class="home" href="#">Eventi</a>
                            <ul class="dropdown">
                                @foreach($events as $event)
                                    <li><a href="/{{$event->slug}}">{{$event->title}}</a></li>
                                @endforeach
                            </ul>
                        </li>
                        <li class="drop"><a class="home" href="#">Pagine WEB</a>
                            <ul class="dropdown">
                                @foreach($pages as $page)
                                    <li><a href="/{{$page->slug}}">{{$page->title}}</a></li>
                                @endforeach
                            </ul>
                        </li>
                        <li><a><i class="fa fa-search" aria-hidden="true"></i></a></li>
                        <div class="togglesearch">
                            <form class="navbar-form  form-inline my-2 my-lg-0" role="search" autocomplete="off" action="/ricerca" method="POST">
                                {{ csrf_field() }}
                                <input type="text" id="search" name="search" placeholder="Cerca qui" style="width:100%;border:1px;">
                                <button type="submit" id="search-submit"><i class="fa fa-search"></i></button>
                            </form>
                        </div>

                    </ul>
                    <!--
                    <form class="navbar-form navbar-right form-inline my-2 my-lg-0" role="search" autocomplete="off" action="/ricerca" method="POST">
                        {{ csrf_field() }}
                        <input type="text" id="search" name="search" placeholder="Cerca qui" style="width:100%">
                        <button type="submit" id="search-submit"><i class="fa fa-search"></i></button>
                    </form>
                -->
                </div>
                <!-- /.navbar-collapse -->
            </div>

            <div class="container">
                <div class="col-sm-2 no-padding">
                    <div class="center-button-reg blu-box" style="text-align:left">
                        Pagine regionali
                    </div>
                </div>
                <div class="col-sm-10">
                    <nav id="menu-container" class="arrow">
                        <div id="btn-nav-previous">
                            <img src="/images/prev.png" width="25">
                        </div>
                        <div id="btn-nav-next">
                            <img src="/images/next.png" width="25">
                        </div>
                        <div class="menu-inner-box">
                            <div class="menu center-button-reg">
                                @foreach($regions as $region)
                                    @if($region->layout != '')
                                        <a class="menu-item region" href="#" onclick="scroll_to('{{$region->slug}}')">{{$region->name}}</a>
                                    @else
                                        <a class="menu-item region" href="/{{$region->slug}}">{{$region->name}}</a>
                                    @endif
                                @endforeach
                            </div>
                        </div>
                    </nav>
                </div>
            </div>

        </div>
        <!-- End navbar list container -->

    </nav>
    <!-- End Bootstrap navbar -->

</header>

<section class="ticker-news">
    <div class="container">
        <div class="ticker-news-box">
            <span class="breaking-news">breaking news</span>
            <span class="new-news">New</span>
            <ul id="js-news">
                @foreach($breaking_news as $news)
                    <li class="news-item"><span class="time-news">{{date("d/m/Y H:i", strtotime($news->date))}}</span>  {{$news->title}}</li>
                @endforeach
            </ul>
        </div>

    </div>
</section>
