/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

function include_once(filename) {
    var cur_file = {};
    var result = {};
    cur_file[window.location.href] = 1;
    
    if (!window.php_js)
        window.php_js = {};
    if (!window.php_js.includes)
        window.php_js.includes = cur_file;
    if (!window.php_js.includes[filename]) {
        result = this.include(filename);
    } else {
        result = window.php_js.includes[filename];
    }
    return result;
}

function include( filename ) {
    
	var js = document.createElement('script');
	js.setAttribute('type', 'text/javascript');
	js.setAttribute('src', filename);
	js.setAttribute('defer', 'defer');
	document.getElementsByTagName('HEAD')[0].appendChild(js);

	// save include state for reference by include_once
	var cur_file = {};
	cur_file[window.location.href] = 1;

	if (!window.php_js) window.php_js = {};
	if (!window.php_js.includes) window.php_js.includes = cur_file;
	if (!window.php_js.includes[filename]) {
		window.php_js.includes[filename] = 1;
	} else {
		window.php_js.includes[filename]++;
	}

	return window.php_js.includes[filename];
}


function getNavbar(aNav) {
    navLi = $(aNav).parent();
    navQuery = $.trim($(aNav).text());
    $(navLi).html('<a>' + navQuery + ' <span class="glyphicon glyphicon-cloud-download"></span></a>');
    $.ajax({
        url: "/cache/" + navQuery + '.html',
        dataType: "html",
        success: function (data) {
            $(navLi).html(data);
            navStart();
            $($(navLi).children("a")).click();
        }
    });
}



//<!-- Matomo -->



//<!-- End Matomo Code -->


function navStart() {
    $('.dropdown-submenu a.test').on("click", function (e) {
        $(this).next('ul').toggle();
        e.stopPropagation();
        e.preventDefault();
    });
}
;

$(document).ready(function () {
    navStart();
    //при нажатию на любую кнопку, имеющую класс .btn
    $("a." + classShowModal).click(function (event) {

        event.preventDefault(); // отключает переход по href                

        var srcImg = $(this).attr("href");
        srcImg = srcImg.replace("-smoll-", "-big-");
        $("#" + idShowModal).attr({
            alt: event.target.alt,
            title: event.target.title,
            src: srcImg
        });
        $("#" + idShowModalSnapshot).text(event.target.title);

        //открыть модальное окно с id="myModal"
        $("#" + idShowModalDiv).modal('show');
    });
});

var stopError = 5;
function errorImg(img) {
    c = $(img).attr('c');
    if (c < stopError) {
        $(img).attr('c', ++c);
        $(img).attr('src', $(img).attr('src') + '&r=' + Math.random());
    } else
        $(img).attr('onerror', '');
}

console.log(include_once('https://www.googletagmanager.com/gtag/js?id=UA-141178346-1'));

window.dataLayer = window.dataLayer || [];
function gtag() {
    dataLayer.push(arguments);
}
gtag('js', new Date());

gtag('config', 'UA-122156797-1');
