<html lang="ru">
<head>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <link rel="shortcut icon" type="image/png" href="/media/favicon.ico"/>
    <title>{% block title %}Лунапарк{% endblock %}</title>

    <script nonce='{{ common.CSP_SCRIPT_NONCE }}' type="text/javascript" src="//yandex.st/jquery/1.9.1/jquery.min.js"></script>

    {% if pagename == 'taskpage'%}
        <script nonce='{{ common.CSP_SCRIPT_NONCE }}' type="text/javascript" src="/media/js/vendor/bootstrap.js"></script>
        <link href="/media/css/styles/bootstrap.css" type="text/css" rel="stylesheet" />
        <script nonce='{{ common.CSP_SCRIPT_NONCE }}' type="text/javascript" src="/media/js/vendor/selectpicker.js"></script>
        <link href="/media/css/styles/selectpicker.css" type="text/css" rel="stylesheet" />
    {% else %}
        <script nonce='{{ common.CSP_SCRIPT_NONCE }}' type="text/javascript" src="/media/js/vendor/tether.min.js"></script>
        <script nonce='{{ common.CSP_SCRIPT_NONCE }}' type="text/javascript" src="/media/js/vendor/bootstrap4.js"></script>
        <link href="/media/css/styles/bootstrap4.css" type="text/css" rel="stylesheet" />
        <script nonce='{{ common.CSP_SCRIPT_NONCE }}' type="text/javascript" src="/media/js/vendor/selectpicker4.js"></script>
        <link href="/media/css/styles/selectpicker4.css" type="text/css" rel="stylesheet" />
    {% endif %}
    <script nonce='{{ common.CSP_SCRIPT_NONCE }}' type="text/javascript" src="/media/js/vendor/highcharts/highstock.js"></script>
    <script nonce='{{ common.CSP_SCRIPT_NONCE }}' type="text/javascript" src="/media/js/vendor/highcharts/highcharts-more.js"></script>
	<!-- <script nonce='{{ common.CSP_SCRIPT_NONCE }}' type="text/javascript" src="/media/js/vendor/highcharts/annotations.js"></script> -->
	<script nonce='{{ common.CSP_SCRIPT_NONCE }}' type="text/javascript" src="/media/js/vendor/underscore.js"></script>
	<script nonce='{{ common.CSP_SCRIPT_NONCE }}' type="text/javascript" src="/media/js/vendor/moment.js"></script>
	<script nonce='{{ common.CSP_SCRIPT_NONCE }}' type="text/javascript" src="/media/js/vendor/ionSlider.js"></script>
    <script nonce='{{ common.CSP_SCRIPT_NONCE }}' type="text/javascript" src="/media/js/vendor/bootstrap-toggle.min.js"></script>
    <script nonce='{{ common.CSP_SCRIPT_NONCE }}' type="text/javascript" src="/media/js/vendor/yaml.min.js"></script>

	<link href="/media/css/header.css?version=43.4" type="text/css" rel="stylesheet" />
    <link href="/media/css/styles/ionSlider.css" type="text/css" rel="stylesheet" />
    <link href="/media/css/styles/bootstrap-toggle.min.css" type="text/css" rel="stylesheet" />
    <link href="/media/css/styles/bootstrap-sortable.css?version=43.4" type="text/css" rel="stylesheet" />
    <link href="/media/css/common.css?version=43.4" type="text/css" rel="stylesheet" />


    <style nonce='{{ common.CSP_STYLE_NONCE }}'>
        a {
           outline: 0 !important;
        }
    </style>

    {% block head %}{% endblock %}
    
    {% csrf_token %}
    
    <!-- http://stackoverflow.com/questions/5100539/django-csrf-check-failing-with-an-ajax-post-request -->
    <script nonce='{{ common.CSP_SCRIPT_NONCE }}'>
	    $.ajaxSetup({ 
		     beforeSend: function(xhr, settings) {
		         function getCookie(name) {
		             var cookieValue = null;
		             if (document.cookie && document.cookie !== '') {
		                 var cookies = document.cookie.split(';');
		                 for (var i = 0; i < cookies.length; i++) {
		                     var cookie = jQuery.trim(cookies[i]);
		                     // Does this cookie string begin with the name we want?
		                     if (cookie.substring(0, name.length + 1) === (name + '=')) {
		                         cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
		                         break;
		                     }
		                 }
		             }
		             return cookieValue;
		         }
		         if (!(/^http:.*/.test(settings.url) || /^https:.*/.test(settings.url))) {
		             // Only send the token to relative URLs i.e. locally.
		             xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken'));
		         }
		     } 
		});
    </script>
    
</head>

<script nonce='{{ common.CSP_SCRIPT_NONCE }}'>

      $(document).ready( function()
      {
            $("body").show();

      });
</script>

{% if request.yauser.login == 'direvius' %}
    <body style="display:none; background: url('/media/img/149442342912056106.jpg');">
{% else %}
    <body style="display:none;">
{% endif %}
{% if common.production_env %}
    <!-- Yandex.Metrika counter -->
    <script nonce='{{ common.CSP_SCRIPT_NONCE }}' type="text/javascript">
    (function (d, w, c) {
        (w[c] = w[c] || []).push(function() {
            try {
                w.yaCounter21376513 = new Ya.Metrika({id:21376513,
                        webvisor:true,
                        clickmap:true,
                        trackLinks:true,
                        accurateTrackBounce:true});
            } catch(e) { }
        });

        var n = d.getElementsByTagName("script")[0],
            s = d.createElement("script"),
            f = function () { n.parentNode.insertBefore(s, n); };
        s.type = "text/javascript";
        s.async = true;
        s.src = (d.location.protocol === "https:" ? "https:" : "http:") + "//mc.yandex.ru/metrika/watch.js";

        if (w.opera === "[object Opera]") {
            d.addEventListener("DOMContentLoaded", f, false);
        } else { f(); }
    })(document, window, "yandex_metrika_callbacks");
    </script>
    <noscript><div><img src="//mc.yandex.ru/watch/21376513" style="position:absolute; left:-9999px;" alt="" /></div></noscript>
    <!-- /Yandex.Metrika counter -->
{% endif %}

<span id="global-login" style="display:none;" data-login="{{ request.yauser.login }}"></span>

<!-- НОВЫЙ ХЕДЕР -->
{% if common.maintenance %}
    <div id="maintenance">
        <div style="width:100%; background-color:red; padding:1em;">
            <span style="color:white; font-weight: bold; font-size: 120%;">ЛУНАПАРК НА MAINTENANCE. ЗАПУСК НОВЫХ СТРЕЛЬБ ПОКА НЕВОЗМОЖЕН :(</span>
        </div>
    </div>
{% endif %}
{% if common.notify_user and common.notification_text %}
	<div id="notification">
		<div style="width:100%; background-color: Orange; padding:0.4em;">
			<span id="notification_text" style="font-weight: bold; font-size: 120%;">
				{{ common.notification_text }}
			</span>
			<a style="cursor:pointer; float: right; margin-right:1em;" id="do_not_notify">
				<span class="fa fa-times-circle-o" aria-hidden="true" style="font-size: 24px;" title="Закрыть"></span>
			</a>
		</div>
	</div>
	<script nonce='{{ common.CSP_SCRIPT_NONCE }}'>
		$("a#do_not_notify").bind('click',
		function(event) {
			$.ajax({
				url : "/api/hide_notification.json",
				type : 'GET',
				dataType : 'json'
			}).always(function(data) {
				console.log('notification hidden', data);
				$("div#notification").remove();
			});
		});
		var notification_text = $("span#notification_text").text().replace(
	            /((http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?)/g,
	            '<a href="$1" target="_blank" class="b_link">$1</a>'
	        );
		$("span#notification_text").html(notification_text)
	</script>
{% endif %}

<header class="m-head m-head_type_at mi-bem" style="border-bottom: 1px solid #eee; box-shadow: 0px 0px 2px rgba(0, 0, 0, 0.05);" id="lunapark_header">
	<div class="m-head-arrow m-head__min mi-bem m-head-arrow_js_inited">
		<a href="/" class="b_header_link">
			<span class="m-head-arrow__home" style="font-weight: 500">Лунапарк&nbsp;</span>
		</a>
		<div class="popup popup_theme_head popup_autoclosable_yes popup_adaptive_yes popup_animate_yes mi-bem popup_js_inited">
			<div class="popup__content"></div>
		</div>
	</div>
	<div class="m-head__main">
		<menu class="m-head-menu m-head-menu_type_main mi-bem m-head-menu_js_inited">
			<div class="m-head-menu__list">
				<div id="comparepage_menu_link" class="m-head-menu__item">
                     <a href="/compare/" class="mlink">Сравнение:&nbsp;
                        <span class="b_compare_count">{{ common.compare_count }}</span>
                     </a>
					<span class="fa fa-times-circle-o b_compare_count__delete text-muted"
						aria-hidden="true"
						style="font-size: 12pt; {% if common.compare_count == 0 %}display:none;{% endif %}">
					</span>
				</div>
				<div id="firestarter_menu_link" class="m-head-menu__item">
					<a href="/firestarter/" class="mlink">Пострелять</a>
				</div>
                <div id="firestarter_menu_link" class="m-head-menu__item">
					<a href="https://forms.yandex-team.ru/surveys/11286/" target="blank" class="mlink">Сообщить о проблеме</a>
				</div>
                <div id="mobilefirestarter_menu_link" class="m-head-menu__item">
					<a href="https://forms.yandex-team.ru/surveys/18792/" target="blank" class="mlink">Задать вопрос</a>
				</div>
				<div id="firestarter_menu_link" class="m-head-menu__item">
					<a href="https://forms.yandex-team.ru/surveys/17511/" target="blank" class="mlink">Запросить консультацию</a>
				</div>
				<div id="permalink_menu_link" class="m-head-menu__item">
					<span style="cursor: pointer" id="nda-url" class="mlink" title="Короткая ссылка на эту страницу">Ссылка для друга</span>
				</div>
			</div>
		</menu>
	</div>
	<script nonce='{{ common.CSP_SCRIPT_NONCE }}'>
		$('.b_compare_count__delete').on('click', function clearCompare() {
            var url = '/clear_compare/';
            $.get(url).success(function(data) {
				if (data.success === 1) {
					$('.b_compare_count').text('0');
				}
			});
		});
		$('.b_mobilecompare_count__delete').on('click', function clearMobileCompare() {
            var url = '/clear_compare/?type=mobile';
            $.get(url).success(function(data) {
				if (data.success === 1) {
					$('.b_mobilecompare_count').text('0');
				}
			});
		});
	</script>
	<div class="m-head-user mi-bem">
		<span class="m-userpic __icon">
			<img src="//center.yandex-team.ru/user/avatar/{{ request.yauser.login }}/100/square" height="50" width="50" class="m-userpic__img">
		</span>
	</div>
	
</header>

<script nonce='{{ common.CSP_SCRIPT_NONCE }}'>
		
	$('span#nda-url').bind('click', function(){
		$.ajax({
			url : 'https://nda.ya.ru/--?url='+escape(window.location.href),
			type : 'GET',
			dataType : 'text'
		}).success(function(data) {
			console.log(data);
		  	window.prompt("Копировать ссылку: Ctrl+C, Enter", data);
		})
	})
		
</script>

<div class='header-bottom-padding'>
</div>
<!-- конец блока -->

<!-- навигационный блок-->
<div style="margin-left: 171px; margin-bottom: 10px;">
{% block navigation %}{% endblock %}
</div>
<!-- конец блока -->

<!-- блок сортировки -->
{% block sort %}{% endblock %}
<!-- конец блока -->

<div class="b-body">
{% block body %}{% endblock %}
</div>

<div class="b_modal_dialog" style="display:none;">
      
      <table border="0" cellspacing="0" cellpadding="0">
            <tr>
                  <td id="up_left_corner"></td>
                  <td class="b_up"></td>
                  <td id="up_right_corner"></td>
            </tr>
            <tr>
                  <td id="left_mid"></td>
                  <td bgcolor="white">
                  <div class="b_modal_comment">
                  </div>
                  </td>
                  <td id="right_mid"></td>
            </tr>
            <tr>
                  <td id="down_left_corner"></td>
                  <td class="b_down"></td>
                  <td id="down_right_corner"></td>
            </tr>
      </table>
</div>

</body>
</html>
