@if(!empty($scrollad))
<div style="position:relative;display:inline-block;text-align:left;width:100%;z-index:1000000;overflow:visible;">
    <div id="scrolladsbanners" style="position: fixed; display: none; right: 10px; bottom: 0px; width: 310px; height: 260px;border: 1px solid rgb(240, 240, 240); z-index: 999;">
        <a class="closebtn" onclick="closeScroll()" href="javascript:;" onmouseover="this.style.backgroundColor='#f01626';" onmouseout="this.style.backgroundColor='#d2d2d2';"
           style="display: block;position:absolute;left:-10px;top:-10px;line-height: 20px;height: 20px;width: 20px;text-align: center;border-radius: 50%;margin: 3px;box-sizing: border-box;background: #d2d2d2 url(./images/close-icon.svg) center center no-repeat;z-index:5;"></a>
        @if($scrollad->tip == 1)
            <div style="position: relative; width: 300px; height: 250px; padding: 5px;overflow: hidden; cursor: pointer;">
                <a target="_blank" href="{{ $scrollad->link }}">
                    <img src="{{url('images/reklamlar/'.$scrollad->resim)}}" alt="{{ $scrollad->baslik }}">
                </a>
            </div>
        @else
            <div style="position: relative; width: 300px; height: 250px; padding: 5px;overflow: hidden; cursor: pointer;">
                {!! $scrollad->metin !!}
            </div>
        @endif
    </div>
</div>
    <script type="text/javascript">
        var runonce = 0, closeClick = 0;
        function setCookie(key, value) {
            var expires = new Date();
            expires.setTime(expires.getTime() + ({{ config('ayarlar.popup_reklam_cache') }}  * 60 * 1000));
            document.cookie = key + '=' + value + ';expires=' + expires.toUTCString();
        }
        function getCookie(key) {
            var keyValue = document.cookie.match('(^|;) ?' + key + '=([^;]*)(;|$)');
            return keyValue ? keyValue[2] : null;
        }
        function closeScroll() {
            $("#scrolladsbanners").fadeOut();
            closeClick = 1;
            setCookie("scroll_reklam", '{{ config('ayarlar.siteadresi') }}')
        }
        if (getCookie("scroll_reklam") == '{{ config('ayarlar.siteadresi') }}'){
            $("#scrolladsbanners").fadeOut();
        }else {
            $(window).scroll(function () {
                if (closeClick == 0) {
                    if (runonce == 0 && $(window).scrollTop() > 400) {
                        $("#scrolladsbanners").fadeIn("slow");
                        runonce = 1;
                    } else if (runonce == 1 && $(window).scrollTop() < 400) {
                        $("#scrolladsbanners").fadeOut("slow");
                        runonce = 0;
                    }
                }else {
                    $("#scrolladsbanners").fadeOut();
                }
            });
            setCookie("scroll_reklam", '{{ config('ayarlar.siteadresi') }}')
        }
    </script>
@endif