

var globalGtagPerms = {
	'ad_storage': 'denied',
	'analytics_storage': 'denied',
	'functional_storage': 'denied',
	'personalization_storage': 'denied',
	'security_storage': 'granted'
};
	
function updateCookies(cookie) {
	globalGtagPerms.analytics_storage = cookie.level.indexOf('analytics') >= 0 ? 'granted' : 'denied';
	globalGtagPerms.ad_storage = cookie.level.indexOf('targeting') >= 0 ? 'granted' : 'denied';
	globalGtagPerms.functional_storage = cookie.level.indexOf('necessary') >= 0 ? 'granted' : 'denied';
	globalGtagPerms.personalization_storage = cookie.level.indexOf('preference') >= 0 ? 'granted' : 'denied';
	
	if (typeof gtag !== 'undefined') {
		gtag('consent', 'update', globalGtagPerms);
		gtag('event', 'cookie_consent_update');
	}
}

// obtain plugin
	var cc = initCookieConsent();


	// run plugin with your configuration
	cc.run({
		current_lang: "cs",
		autoclear_cookies: true, // default: false
		theme_css: "" + '/plugins/cookieconsent/dist/cookieconsent.css', // 🚨 replace with a valid path
		page_scripts: true, // default: false
		revision: 0,
		
		// delay: 0,                               // default: 0
		// auto_language: null                     // default: null; could also be 'browser' or 'document'
		// autorun: true,                          // default: true
		force_consent: true,                   // default: false
		// hide_from_bots: false,                  // default: false
		// remove_cookie_tables: false             // default: false
		// cookie_name: 'cc_cookie',               // default: 'cc_cookie'
		// cookie_expiration: 182,                 // default: 182 (days)
		// cookie_domain: location.hostname,       // default: current domain
		// cookie_path: '/',                       // default: root
		// cookie_same_site: 'Lax',                // default: 'Lax'
		// use_rfc_cookie: false,                  // default: false
		// revision: 0,                            // default: 0

		gui_options: {
			consent_modal: {
				layout: 'box',
				position: 'middle center'
			}
		},
		
		onAccept: function (cookie) {
			updateCookies(cookie);
		},

		onChange: function (cookie, changed_preferences) {
			ccInitButton();
			updateCookies(cookie);
		},

		languages: {
			"cs": {
				consent_modal: {
					title: "Informace o cookies na této stránce",
					description: "Tato webová stránka používá nezbytné soubory cookies k zajištění správného fungování a další kategorie souborů cookies. Vše kromě nezbytných cookies bude použito až po vašem souhlasu." +  '<br><button type="button" data-cc="c-settings" class="cc-link">' + "Zobrazit nastavení" + '</button>',
					primary_btn: {
						text: "Přijmout vše",
						role: 'accept_all'              // 'accept_selected' or 'accept_all'
					},
					secondary_btn: {
						text: "Zamítnout vše",
						role: 'accept_necessary'        // 'settings' or 'accept_necessary'
					}
				},
				settings_modal: {
					title: "Nastavení cookies",
					save_settings_btn: "Uložit nastavení",
					accept_all_btn: "Přijmout vše",
					reject_all_btn: "Zamítnout vše",
					close_btn_label: "Zavřít",
					cookie_table_headers: [
						{
							col1: 'Name'
						},
						{
							col2: 'Domain'
						},
						{
							col3: 'Expiration'
						},
						{
							col4: 'Description'
						}
					],
					blocks: [
						{
							title: "Použití cookies",
							description: "Cookie soubory, které jsou použité na těchto stránkách jsou rozděleny do kategorií a níže můžete povolit nebo zamítnout některé nebo všechny z nich. Jakmile zakážete kategorie, které byly předtím povoleny, budou z vašeho prohlížeče odstraněny všechny soubory cookie přiřazené do této kategorie. <a href=\"https:\/\/www.cookiehub.com\/about-cookies\" target=\"_blank\">Zjistit více<\/a>.",
						}, 
												{
							title: "Nutné soubory cookie",
							description: "Některé soubory cookie jsou vyžadovány, aby byla zajištěna základní funkčnost. Bez těchto cookies nebude web fungovat správně. Ve výchozím nastavení jsou povoleny a nelze je zakázat.",
							toggle: {
								value: "necessary",
								enabled: true,
								readonly: true          // cookie categories with readonly=true are all treated as "necessary cookies"
							}, 
							cookie_table: [
									{
										col1: "PHPSESSID", // match all cookies starting with "_ga"
										col2: "prazdnedomy.cz",
										col3: "30 d",
										col4: "This cookie is native to PHP applications. The cookie is used to store and identify a users' unique session ID for the purpose of managing user session on the website. The cookie is a session cookies and is deleted when all the browser windows are closed.",
										//is_regex: true
									},
									{
										col1: "cc_cookie", // match all cookies starting with "_ga"
										col2: "prazdnedomy.cz",
										col3: "6 month",
										col4: "",
										//is_regex: true
									}
							]
						},
						{
							title: "Analytické soubory cookie",
							description: "Analytické soubory cookie nám pomáhají vylepšovat naše webové stránky shromažďováním informací a podáváním zpráv o jeho používání.",
							toggle: {
								value: "analytics",
								enabled: true,
								readonly: false          // cookie categories with readonly=true are all treated as "necessary cookies"
							}, 
							cookie_table: [
									{
										col1: "_ga", // match all cookies starting with "_ga"
										col2: ".prazdnedomy.cz",
										col3: "730 d",
										col4: "Contains a unique identifier used by Google Analytics to determine that two distinct hits belong to the same user across browsing sessions.",
										//is_regex: true
									},
									{
										col1: "_gat", // match all cookies starting with "_ga"
										col2: ".prazdnedomy.cz",
										col3: "?",
										col4: "Used by Google Analytics to throttle request rate (limit the collection of data on high traffic sites)",
										//is_regex: true
									},
									{
										col1: "_gid", // match all cookies starting with "_ga"
										col2: ".prazdnedomy.cz",
										col3: "24 h",
										col4: "Contains a unique identifier used by Google Analytics to determine that two distinct hits belong to the same user across browsing sessions.",
										//is_regex: true
									}
							]
						},
						{
							title: "Ostatní cookies",
							description: "Soubory cookie v této kategorii ještě nebyly zařazeny a jejich účel může být v tuto chvíli neznámý.",
							toggle: {
								value: "other",
								enabled: true,
								readonly: false          // cookie categories with readonly=true are all treated as "necessary cookies"
							}, 
							cookie_table: [
									{
										col1: "cookiesEnabled", // match all cookies starting with "_ga"
										col2: "prazdnedomy.cz",
										col3: "24 h",
										col4: "",
										//is_regex: true
									},
									{
										col1: "localeRedirected", // match all cookies starting with "_ga"
										col2: "prazdnedomy.cz",
										col3: "24 h",
										col4: "",
										//is_regex: true
									},
									{
										col1: "VISITOR_INFO1_LIVE", // match all cookies starting with "_ga"
										col2: ".youtube.com",
										col3: "180 d",
										col4: "",
										//is_regex: true
									},
									{
										col1: "YSC", // match all cookies starting with "_ga"
										col2: ".youtube.com",
										col3: "Session",
										col4: "",
										//is_regex: true
									},
									{
										col1: "AWSALBCORS", // match all cookies starting with "_ga"
										col2: "www.darujme.cz",
										col3: "7 d",
										col4: "",
										//is_regex: true
									}
							]
						}
					]
				}
			}
		}
	});

	$(function() {
		if (cc.get('level')) {
			ccInitButton();
		}
	});
	
	function ccInitButton() {
		if ($('.cookies-settings-button').length == 0) {
			$('body').append('<a href="javascript:void(0);" aria-label="View cookie settings" data-cc="c-settings" class="cookies-settings-button" onclick="cc.showSettings(0);return false;">Cookie Settings</a>');
		}
	}