/* Minification failed. Returning unminified contents.
(15,34-35): run-time error JS1195: Expected expression: >
(17,9-10): run-time error JS1195: Expected expression: )
(22,7-8): run-time error JS1002: Syntax error: }
(26,34-35): run-time error JS1195: Expected expression: >
(28,8-9): run-time error JS1002: Syntax error: }
(30,14-15): run-time error JS1004: Expected ';': {
(34,8-12): run-time error JS1034: Unmatched 'else'; no 'if' defined: else
(37,8-9): run-time error JS1002: Syntax error: }
(38,34-35): run-time error JS1004: Expected ';': {
(41,7-8): run-time error JS1002: Syntax error: }
(44,21-22): run-time error JS1195: Expected expression: )
(44,23-24): run-time error JS1004: Expected ';': {
(63,6-7): run-time error JS1195: Expected expression: ,
(64,26-27): run-time error JS1195: Expected expression: )
(64,28-29): run-time error JS1004: Expected ';': {
(70,6-7): run-time error JS1195: Expected expression: ,
(71,29-30): run-time error JS1195: Expected expression: )
(71,30-31): run-time error JS1004: Expected ';': {
(77,56-57): run-time error JS1195: Expected expression: >
(83,8-9): run-time error JS1195: Expected expression: ,
(85,8-9): run-time error JS1195: Expected expression: )
(85,9-10): run-time error JS1197: Too many errors. The file might not be a JavaScript file: .
 */
window.didomiOnReady = window.didomiOnReady || [];

var layout = {
		menu : {
				isOpen : false,
				stickyOne : true,
				
				toggle : function(s) {
						if(!layout.menu.initialized) {
							layout.menu.ini();
						}
						const mnItems = document.querySelectorAll(".header-menu-hamburger__icon, .megamenu-wrapper");
						if(layout.menu.isOpen) {
							dataLayer.push({event: 'clickTo_navigation', menu: {type: 'menu'}, link: {text: 'close'}});
							mnItems.forEach((mnItem) => {
								mnItem.classList.remove("opened");
							});
							document.querySelector(".megamenu-backdrop").classList.remove("megamenu-backdrop--active");
							if(layout.menu.stickyOne) {
								layout.menu.onAfterStickyMenu();
							}
						}else{
							if(layout.menu.stickyOne) {
								layout.menu.onBeforeStickyMenu();
							}
							mnItems.forEach((mnItem) => {
								mnItem.classList.add("opened");
							});
							document.querySelector(".megamenu-backdrop").classList.add("megamenu-backdrop--active");
							if(s) {
								document.getElementById("searchInput").focus();
								dataLayer.push({event: 'clickTo_navigation', menu: {type: 'menu'}, link: {text: 'openSearch'}});
							}
							else
							{
								dataLayer.push({event: 'clickTo_navigation', menu: {type: 'menu'}, link: {text: 'open'}});
							}
							if(layout.menu.stickyOne) {
								window.scrollTo(0,0);
							}
						}
						layout.menu.isOpen = !layout.menu.isOpen;
				},
				ini 	: function() {
						layout.search.initialized = true;
						document.querySelector(".megamenu-search__submit").addEventListener("click", function() {
							layout.search.run();
						});
						document.querySelector(".megamenu-search__input").addEventListener("keydown", function(e) {
							if(e.keyCode == 13){
								e.preventDefault();
								e.stopPropagation();
								layout.search.run();
							}
						});
						document.addEventListener("keydown", function(e) {
							if(layout.menu.isOpen && e.keyCode == 27){
								e.stopPropagation();
								e.preventDefault();
								layout.menu.toggle();
							};
						});
				},
				setSticky : function() {
						if(layout.menu.stickyOne) {
							window.addEventListener("DOMContentLoaded", function(){
								layout.menu.handleSticky();
							});
						}
				},
				handleSticky : function(){
						const b = document.querySelector("body");
						const el = document.querySelector("header");
						const elSen = document.querySelector(".header-sensor");
						let mT = el.getBoundingClientRect().height + "px";
						elSen.style.top = mT;
						const observer = new IntersectionObserver( ([t])=>{
							b.classList.toggle("header-pinned", t.intersectionRatio < 1);
							el.classList.toggle("is-pinned", t.intersectionRatio < 1);
							setTimeout(function(){
								el.classList.toggle("anim", t.intersectionRatio < 1);
							}, 50);
						}, {
							threshold: 0
						}).observe(elSen);
				},
				onBeforeStickyMenu : function() {
							const el = document.querySelector("header");
							el.dataset.offsetX = window.scrollX;
							el.dataset.offsetY = window.scrollY;
				},
				onAfterStickyMenu : function() {
							const el = document.querySelector("header");
							window.scrollTo(parseInt(el.dataset.offsetX), parseInt(el.dataset.offsetY));
				},
				initialized : false
		},

		search : {
				url 	: "/vysledky-vyhledavani/sc-236/?search={0}",
				run 	: function() {
						var v = document.getElementById("searchInput").value;
						if(v!="") {
							dataLayer.push({event: 'clickTo_navigation', menu: {type: 'menu'}, link: {text: v}});
							document.location = layout.search.url.replace( "{0}", encodeURIComponent(v) );
						}
				}
		},

		pager : {
				enabled : true,
				page 	: 0,
				suffix 	: null,
				url 	: "/get.aspx?pgnum={0}{1}",
				nextPage : function(spot, fromHash) {
						layout.pager.page +=1;
						const url = layout.pager.url.replace("{0}", layout.pager.page).replace("{1}", layout.pager.suffix === null ? "" : layout.pager.suffix);
						let w = document.getElementById(spot + "_" + layout.pager.page).nextElementSibling;
						w.classList.add("pager-loading");
						try
						{
							var pg = JSON.parse(JSON.stringify(cncPage)); 
							pg.pagination.page=layout.pager.page+1;
							dataLayer.push({"event": "page_next", "pagination": JSON.parse(JSON.stringify(pg.pagination))});
						}catch(e){}
						layout.pager.getPage(url, spot, fromHash);
				},
				getPage	: async function(url, spot, fromHash) {
						let w = document.getElementById(spot + "_" + layout.pager.page).nextElementSibling;
						try {
							let response = await fetch(url);
							if(response.ok) {
								let pd = await response.text();
								const s = document.getElementById(spot + "_" + layout.pager.page);
								let np = "<span id='" + ( spot + "_" + (layout.pager.page+1) ) + "'></span>";
								s.insertAdjacentHTML("afterend", np);
								s.insertAdjacentHTML("afterend", pd.replace('xml version="1.0" encoding="UTF-8"', " "));
								try{
									gtmParse(false);
								}catch(e){}
								if(fromHash === true) {
									layout.pager.setPageFromHash(spot);
								}
							}
							w.classList.remove("pager-loading");
						}catch(e){
							w.classList.remove("pager-loading");
   						}
				},
				check : function() {
						if(!layout.pager.enabled) {
							let btn = document.querySelector(".load-more-wrapper");
							btn.style.display = "none";
						}
				},
				setPageFromHash : function(spot) {
							let pageFromHash = layout.utils.getHash("pgnum", true);
							if(pageFromHash!=null && pageFromHash>1) {
								if(layout.pager.page<pageFromHash-1) {
									layout.pager.nextPage(spot, true);
								}else{
									document.getElementById(spot + "_" + layout.pager.page).scrollIntoView();
								}
							}
				}
		},

		tab : {
				makeActive : function(o, tab, pane, i) {
					let t = document.querySelectorAll("." + tab);
					let p = document.querySelectorAll("." + pane);
					t.forEach(e => { e.classList.remove(tab + "--active") });
					p.forEach(e => { e.classList.remove(pane + "--active") });
					o.classList.add(tab + "--active");
					document.getElementById(pane + "__" + i).classList.add(pane + "--active");
				}
		},

		lazyLoad : {
				trigger : function() {

				}
		},

		smiley: {
				init : function() {
						$(".smiley-appender img").on("click", function(){
							var sm = $(this);
							var trg = sm.parent().parent().find("textarea");
							$("body").focus();
							trg.val(trg.val() + " " + sm.attr("title") + " ").focus();
						});
				}
		},

		template : {
				count : null,
				current : null,
				sheets : null,
				uwmode : true,
				article : null,
				ini : function(id) {
					layout.template.article = id;
					let n = document.getElementById("body-part-selector");
					if(n==null){
						layout.template.uwmode = false;
						n = document.querySelector(".body-part-switcher");
					}
					layout.template.sheets = document.querySelectorAll(".bodyPart");
					layout.template.current = parseInt(n.dataset.sheet);
					layout.template.count = layout.template.sheets.length;
					layout.template.bindKeyBoardEvents();
					const sheetFromHash = layout.utils.getHash("part", true);
					if(sheetFromHash!=null && sheetFromHash>0 && sheetFromHash<=layout.template.count) {
						layout.template.current = sheetFromHash-1;
						layout.template.sheets[0].classList.add("list-hidden");
						layout.template.show(1);
					}
				},
				bindKeyBoardEvents : function() {
					document.addEventListener("keyup", function(e){
						const key = e.keyCode;
						let v = false;
						v = layout.template.isInViewPort();
						if(v && key === 37) { //left
							layout.template.prev();
						}else if(v && key === 39) { //right
							layout.template.next();
						}
					});
				},
				next: function() {
					layout.template.sheets[layout.template.current].classList.add("list-hidden");
					layout.template.current+=1;
					if(layout.template.current==layout.template.count){
						layout.template.current = 0;
					}
					layout.template.show(1);
				},
				prev: function() {
					layout.template.sheets[layout.template.current].classList.add("list-hidden");
					layout.template.current-=1;
					if(layout.template.current==-1){
						layout.template.current = layout.template.count-1;
					}
					layout.template.show(-1);
				},
				first: function() {
					layout.template.sheets[layout.template.current].classList.add("list-hidden");
					layout.template.current=0;
					layout.template.show(1);
				},
				show : function(w){
					layout.template.sheets[layout.template.current].classList.remove("list-hidden");
					if( layout.template.uwmode ) {
						let nav = document.querySelectorAll("#body-part-selector li");
						for (i = 0; i < nav.length; i++) {
  							if(i==0 && layout.template.current==0){
								nav[i].classList.add("article-listed-navigation__item--visible");
							}else if(i==nav.length-1 && layout.template.current==layout.template.count-1){
								nav[i].classList.add("article-listed-navigation__item--visible");
							}else if( (i>0 && i<nav.length-1) && (layout.template.current>0 && layout.template.current<layout.template.count-1)){
								nav[i].classList.add("article-listed-navigation__item--visible");
							}else{
								nav[i].classList.remove("article-listed-navigation__item--visible");
							}
						}
					}else{
						Array.from(document.querySelectorAll(".body-part-switcher .button--outlined span:first-child"))
							.forEach(function(c) {
								c.innerHTML = layout.template.current+1;
								let s = document.querySelector("#bodyPart" + layout.template.current + ".bodyPart__with-title h3");
								if(s!=null) s.style.display = 'none';
						});
					}
					try {
						try{
							Array.from(document.querySelectorAll("div[class^='gtm-scrl']"))
								.forEach(function(val) {
									val.style.display = 'none';
							});
							Array.from(document.querySelectorAll("div[class='gtm-scrl" + layout.template.current + "']"))
								.forEach(function(val) {
									val.style.display = 'block';
							});
						}catch(e){}
						try{gemius_hit(pp_gemius_identifier.replace("USED_", ""));}catch(e){}
						try{adoR.reload();}catch(e){}
						try{gtmSetArticlePart(layout.template.current+1, w);}catch(e){}
						try { window.io({event: 'pageviews', config_page_url: window._io_config["0.2.0"][0].page_url,type_article:'Listy'}); } catch (e) { };
					}catch(e){}
					try { layout.template.setPartUrl(); }catch(e){console.log(e)};
					try { customTables.reBuild(); }catch(e){console.log(e)};
					try{document.getElementById("as").scrollIntoView();window.scrollTo(window.scrollX, window.scrollY - 80);}catch(e){}
				},
				setPartUrl : function() {
					const url = document.location.pathname + (layout.template.current>0 ? "#part=" + (layout.template.current+1) : "");
					if ('undefined' !== typeof history.replaceState) {
						history.replaceState({}, document.title, url);
					} else {
						window.location.assign(url);
					}
					try{sessionStorage.setItem(layout.template.article + "_last-url", document.location.href);}catch(e){}
				},
				isInViewPort : function() {
					const { top, left, bottom, right, height } = layout.template.sheets[layout.template.current].getBoundingClientRect();
  					const { innerHeight, innerWidth } = window;
					return ((top > 0 && top < innerHeight) || (top <= 0 && top+height > innerHeight) || (bottom > 0 && bottom < innerHeight)) && ((left > 0 && left < innerWidth) || (right > 0 && right < innerWidth));
				}
		},

		utils : {
				getQS : function(p, isInt) {
					if (window.location.search) {
        	    				const wls = new URLSearchParams(window.location.search);
						const qs = wls.get(p);
            					if ( qs!==null ) {
							if(!isInt) {
        	        					return qs;
							}else if ( isInt && !isNaN(parseInt(qs)) ) {
								return parseInt(qs);
							}else{
								return null;
							}
	            				}	
					}
					return null;
				},
				getHash : function(p, isInt) {
					if (window.location.hash) {
        	    				const wls = window.location.hash.split("=");
            					if ( wls.length===2 && ("#"+p == wls[0]) ) {
							if(!isInt) {
        	        					return wls[1];
							}else if ( isInt && !isNaN(parseInt(wls[1])) ) {
								return parseInt(wls[1]);
							}else{
								return null;
							}
	            				}	
					}
					return null;
				}
		},
		adHandler : {
				ini : function() {
					layout.adHandler.skyTarget = document.getElementById("halfpage-repeater-target");
					if( layout.adHandler.skyTarget !== null) {
						if(layout.adHandler.skyTarget.parentElement.classList.contains("main--first-content")) {
							layout.adHandler.skyDiff = 550;
						}
						resizeObserver.observe(layout.adHandler.skyTarget);
					}
				},
				lastHeight : 0,
				skyHeight : 1200,
				skyDiff	  : 0,
				skyTarget : null,
				lastSky : null,
				setSky : function(h) {
						if(layout.adHandler.checkTimeout !== null) {
							clearTimeout(layout.adHandler.checkTimeout);
						}
						if( layout.adHandler.skyTarget !== null) {
							let sideBlockCounter = parseInt(layout.adHandler.skyTarget.dataset.rendered);
							layout.adHandler.lastSky = layout.adHandler.getLastSky();
							const cH = layout.adHandler.getSkyHeight()+layout.adHandler.skyDiff;
							if(layout.adHandler.lastHeight === h) {
								resizeObserver.unobserve(layout.adHandler.skyTarget);
								layout.adHandler.lastSky.style.setProperty('height', (h - cH + layout.adHandler.skyHeight - 150) + "px", 'important');
								return
							}

							layout.adHandler.lastSky.style.height = layout.adHandler.skyHeight + "px";
							const sideBlockAd = document.getElementById("halfpage-repeater").innerHTML;
							let sideBlockHeight = h - cH;

							while(sideBlockHeight > layout.adHandler.skyHeight && sideBlockCounter<3) {
								sideBlockCounter++;
								layout.adHandler.skyTarget.insertAdjacentHTML('beforeEnd', sideBlockAd);
								layout.adHandler.lastSky = layout.adHandler.getLastSky();
								layout.adHandler.lastSky.id=	"halfpage_render_" + layout.adHandler.skyTarget.dataset.rendered;
								window.__cncAdsQueue = window.__cncAdsQueue || [];
								window.__cncAdsQueue.push(() => {
									window.__cncLazyLoad(layout.adHandler.lastSky.children[0]);
								});
								sideBlockHeight -= layout.adHandler.skyHeight;
							}
							layout.adHandler.skyTarget.dataset.rendered = sideBlockCounter;
							layout.adHandler.lastHeight = h;
							layout.adHandler.checkTimeout = setTimeout(function(){
								layout.adHandler.checkObserver(h);
							}, 1000);
						}
				},
				addSky : function() {
					if( layout.adHandler.skyTarget !== null) {
						layout.adHandler.lastSky = layout.adHandler.getLastSky();
						layout.adHandler.lastSky.style.height = layout.adHandler.skyHeight + "px";
						layout.adHandler.setSky(layout.adHandler.skyTarget.clientHeight);
					}
				},
				getSkyHeight : function() {
					let skyHeight = 0
					for(var i=layout.adHandler.skyTarget.children.length; i>0; i--) {
						skyHeight += layout.adHandler.skyTarget.children[i-1].clientHeight;
					}
					return skyHeight;
				},
				getLastSky : function() {
					return document.querySelector("#" + layout.adHandler.skyTarget.id + " > .sidebar-content--repeater:last-of-type");
				},
				checkObserver : function(h) {
					layout.adHandler.setSky(h)
				},
				checkTimeout : null
		},
		theme : {
				switch : function(e){
						document.cookie = "modedark=;expires=Thu, 01 Jan 1970 00:00:00 GMT";

						const isDark = e.classList.contains("dark");
						const d = new Date();
						d.setTime(d.getTime() + (90*24*60*60*1000));
						let expires = "expires="+ d.toUTCString();

						document.cookie = "modedark=" + (isDark ? 0 : 1) + ";" + expires + ";domain=.zive.cz;path=/";
						document.location.reload();
				}
		},
		premium : {
				lockModal : function(h,s) {
					var m = $(".subscription:first").clone();
						m.append("<a class='close' href='#' onclick='layout.premium.hideModal();return false'>×</a>");
						m.find(".subscription__description__full").empty();
						m.find(".subscription__headline").html(h);
						if(s!="") {
							m.find(".subscription__description").html(s);
						}else{
							m.find(".subscription__description").remove();
						}
						var mw = $("<div class='ar-sheet-concat base__modal-wrapper' onclick='layout.premium.hideModal();'><div class='base__modal-content'></div></div>");
						mw.find("div").append(m);
						$(document).on("keydown", function(event){
							if( (event.keyCode || event.which === 27) || (event.key === "Escape") ) {
  								layout.premium.hideModal();
								$(document).off('keydown');
  								event.preventDefault();
							};
						});
						$("body").append(mw);
						document.querySelector("form").classList.add("bg-blur");
						m.show();
				},
				hideModal : function() {
					$(".base__modal-wrapper:not(#footer-info-popup)").remove();
					document.querySelector("form").classList.remove("bg-blur");
				},
				ini : function() {
					window.addEventListener("DOMContentLoaded", function(){
						$(".pLockSheet").on("click", function(e){
							let h = "Tato funkce je součástí předplatného Živě Premium";
							let d = "Zobrazení všech listů najednou nabízíme pouze předplatitelům";
							const l = $(this).attr("data-lock");
							if( !(l == undefined) ) {
								h = l;
								const ld = $(this).attr("data-lock-description");
								if( ld == undefined) {
									d = "";
								}
							}	
							layout.premium.lockModal(h, d);
							e.preventDefault();
							e.stopPropagation();
						});
					});
				}
		},

		modal : {
				confirmLink : null,
				template : `<div class="subscription subscription--article subscription--chapters fade-out">
						<a class="close" href="#" onclick="layout.modal.cancel();return false">×</a>
						<div class="subscription__logo">
							<img alt="" src="/client.images/logo-zive-transparent.svg" />
						</div>
						<h2 class="subscription__headline">{0}</h2>
						<p class="subscription__description"{2}>{1}</p>
						<div class="subscription__buttons">
							<a class="subscription__type-order" class="confirm" href="#" onclick="layout.modal.confirm();return false">{3}</a>
							<a class="subscription__type-order" class="cancel" href="#" onclick="layout.modal.cancel();return false"{5}>{4}</a>
						</div>
					    </div>`,
				parseTemplate : function(o) {
							layout.modal.confirmLink = o.link;
							let pT = layout.modal.template.replace("{0}", o.headline);
							pT = pT.replace("{3}", o.confirm);
							if( o.desc == undefined) {
								pT = pT.replace("{2}", " style='display:none'");
							}else{
								pT = pT.replace("{2}", "");
								pT = pT.replace("{1}", o.desc);
							}
							if( o.cancel == undefined) {
								pT = pT.replace("{5}", " style='display:none'");
							}else{
								pT = pT.replace("{5}", "");
								pT = pT.replace("{4}", o.cancel);
							}
							return pT;
				},
				show : function(o) {
						layout.modal.confirmLink = null;
						var mw = $("<div class='ar-sheet-concat base__modal-wrapper modal-custom' onclick='layout.modal.cancel();'><div class='base__modal-content'></div></div>");
						mw.find("div").append(layout.modal.parseTemplate(o));
						$(document).on("keydown", function(event){
							if( (event.keyCode || event.which === 27) || (event.key === "Escape") ) {
  								layout.modal.cancel();
								$(document).off('keydown');
  								event.preventDefault();
							};
						});
						$("body").append(mw);
						document.querySelector("form").classList.add("bg-blur");
						return false;
				},
				hide : function() {
					$(".modal-custom").remove();
					document.querySelector("form").classList.remove("bg-blur");
				},
				confirm : function() {
					layout.modal.hide();
					document.location = layout.modal.confirmLink;
				},
				cancel : function() {
					layout.modal.hide();
				}
		}
}
layout.menu.setSticky();
layout.premium.ini();
let resizeObserver;
window.addEventListener("DOMContentLoaded", function(){
	layout.pager.check();
	resizeObserver = new ResizeObserver((entries) => {
		layout.adHandler.setSky(entries[0].target.clientHeight);
	});
	layout.adHandler.ini();
});
;
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        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;
    }
};

$.fn.enterKey = function (f) {
    return this.each(function () {
        $(this).on("keypress", function (e) {
            var keycode = (e.keyCode ? e.keyCode : e.which);
            if (keycode == '13') {
                e.preventDefault();
                e.stopPropagation();
                f.call(this);
            }
        })
    })
}
$.fn.isInViewport = function() {
	var eTop = $(this).offset().top;
	var eBottom = eTop + $(this).outerHeight();
	var vTop = $(window).scrollTop();
	var vBottom = vTop + $(window).height();
	return eBottom > vTop && eTop < vBottom;
};
;
	if ('IntersectionObserver' in window && 'IntersectionObserverEntry' in window && 'intersectionRatio' in window.IntersectionObserverEntry.prototype && !('isIntersecting' in IntersectionObserverEntry.prototype)) {
		Object.defineProperty(window.IntersectionObserverEntry.prototype, 'isIntersecting', {
			get: function () {
				return this.intersectionRatio > 0
			}
		})
	}

	var client = client || null;

	var recombeeRender = {
				serverPrefix : "zive",

				clearTemplate : function(i) {
					document.getElementById(i+"-more").style.display = "none";
				},
				getSrcSet : function(imageSrc) {
					let url = imageSrc.replace(/(?<=getthumbnail\.aspx\?crop=1&)(w=[\d]*&h=[\d]*)/, '{0}');
					if (url !== imageSrc){
						return recombeeRender.srcSets.map(s => `<source media="${s.media}" srcset="${url.replace('{0}', s.wh)}${(s.descriptor ? ' ' + s.descriptor : '')}">`).join('');
					} else {
						return "";
					}
				},
				getImageSrcSet : function(imageSrc) {
					let url = imageSrc.replace(/(?<=getthumbnail\.aspx\?crop=1&)(w=[\d]*&h=[\d]*)/, '{0}');
					if (url !== imageSrc){
						return url.replace('{0}', "w=416&h=234") + ' 2x';
					} else {
						return imageSrc;
					}
				},
				srcSets : [
						{
							media : "(max-width:768px)",
							wh : "w=800&h=450"
						}/*,
						{
							media: "(min-width: 768.1px)",
							wh: "w=1600&h=900",
							descriptor: "2x"
						}*/
				],
				getTemplate : function(i, res, ad, cnt) {
                			let template = document.getElementById(i).innerHTML;
					let isPrStandard = document.getElementById(i+"-standard")!=null;
					document.getElementById(i+"-more").dataset.recombee = res.recommId;
					res.recomms.forEach(function (item, idx) {
						let aVal = recombeeRender.getServerArticleId(String(item.id), item.values.magazine_name);
                    				item.values.url = recombeeRender.formatUrl(item.values.url, res.recommId, aVal[1], aVal[0]);
                    				item.values.date = new Date(item.values.published_at * 1000);
                    				item.values.premium = item.values.is_premium ? "ano" : "ne";
                    				item.values.premiumcls = item.values.is_premium ? "ar-premium" : "ar-premium-free";
                    				item.values.gtmcls = "gtm-list-i";
                    				item.values.articleId = aVal[1];
                    				item.values.srv = aVal[0];
                    				item.values.category = item.values.main_category_name ?  item.values.main_category_name : item.values.categories[0];
                    				item.values.customDomain = recombeeRender.formatCrumb(item.values.domain, item.values.magazine_name); 
                    				item.values.parsedDate = recombeeRender.formatDT({'day':'numeric'}, item.values.date, false)+" "+recombeeRender.formatDT({'month':'numeric'}, item.values.date, true)+" "+recombeeRender.formatDT({'year':'numeric'}, item.values.date, false);
						item.values.srcset = recombeeRender.getSrcSet(item.values.image);
						item.values.imgsrcset = recombeeRender.getImageSrcSet(item.values.image);
                    				var html = recombeeRender.formatTemplate(template, item);
						if(!item.values.author) {
							html = recombeeRender.formatNonAuthor(html)
						} 
                    				document.getElementById(i+"-more").insertAdjacentHTML('beforeBegin', html);

						if(ad==="position" && idx==1) {
                					let adtemplate = document.getElementById(i+"-ad").innerHTML;
                    					document.getElementById(i+"-more").insertAdjacentHTML('beforebegin', adtemplate );
							let adSpot = document.getElementById(i+"-more").previousElementSibling;
							window.__cncAdsQueue = window.__cncAdsQueue || [];
							window.__cncAdsQueue.push(() => {
								window.__cncLazyLoad(adSpot);
							});
						}else if(ad===true && idx==2 && !isPrStandard) {
               						let adtemplate = document.getElementById(i+"-pr").innerHTML;
                   					document.getElementById(i+"-more").insertAdjacentHTML('beforebegin', adtemplate );
							let adSpot = document.getElementById(i+"-more").previousElementSibling;
							window.__cncAdsQueue = window.__cncAdsQueue || [];
							window.__cncAdsQueue.push(() => {
								window.__cncLazyLoad(adSpot);
							});
						}else if(ad===true && idx==cnt-1 && isPrStandard) {
                					let adtemplate = document.getElementById(i+"-standard").innerHTML;
                    					document.getElementById(i+"-more").insertAdjacentHTML('beforebegin', adtemplate );
							let adSpot = document.getElementById(i+"-more").previousElementSibling;
							window.__cncAdsQueue = window.__cncAdsQueue || [];
							window.__cncAdsQueue.push(() => {
								window.__cncLazyLoad(adSpot);
							});
						}else if(ad==="custom" && typeof(recombeeRender.adTemplate[i])==="object") {
							if(typeof(recombeeRender.adTemplate[i][(idx).toString()]) === "string") {
                						let adtemplate = document.getElementById(i+"-" + recombeeRender.adTemplate[i][idx.toString()]).innerHTML;
                    						document.getElementById(i+"-more").insertAdjacentHTML('beforebegin', adtemplate );
								let adSpot = document.getElementById(i+"-more").previousElementSibling;
								window.__cncAdsQueue = window.__cncAdsQueue || [];
								window.__cncAdsQueue.push(() => {
									window.__cncLazyLoad(adSpot);
								});
							}
						}

						if(res.recomms.length<cnt) {
							recombeeRender.clearTemplate(i);
						};
                			});
					try{layout.adHandler.addSky();}catch(e){}
					try{gtmParse(false);}catch(e){}
				},
				formatTemplate : function (template, options) {
       						return template.replace(/\{\{\s?([\w.]+)\s?\}\}/g, (match, variable) => {
               						return variable.split('.').reduce((previous, current) => {
               							return previous[current]
              						}, options) || ''
       						})
        			},
				formatNonAuthor : function (html) {
       						return html.replace('list-article__authors"', 'list-article__authors"  style="display:none"');
        			},
				formatCrumb : function(d, m) {
						if(m!=null && String(m)!="") {
							return m.charAt(0).toUpperCase() + m.slice(1);
						}else{
							const dparse = d.replace("www.", "").split(".");
							if(dparse.length>1) {
								const wName = dparse[0].charAt(0).toUpperCase() + dparse[0].slice(1);
								return recombeeRender.formatCustomCrumb(wName) + "." + dparse[dparse.length-1];
							}else{
								return d;
							}
						}
        			},
				formatCustomCrumb : function(w) {
					return w.replace("Avmania", "AVmania").replace("Digiarena", "DIGIarena").replace("Vtm", "VTM").replace("Mobilmania", "MobilMania").replace("Samsungmania", "SamsungMania").replace("Autorevue", "AutoRevue").replace("Sportrevue", "SportRevue").replace("Abecedazahrady", "AbecedaZahrady").replace("Zive", "Živě");
				},
				formatDT : function (o, d, p) {
						let m = new Intl.DateTimeFormat('cs-CZ', o).format(d);
						return p ? recombeeRender.formatDTMonthNames[ parseInt(m) - 1 ] : m;
				},
				formatDTMonthNames : ["ledna","února","března","dubna","května","června","července","srpna","září","října","listopadu","prosince"],

				formatUrl : function(url, rec, aId, srv) {
						return url + (url.indexOf("?")!=-1 ? "&recombee_recomm_id=" : "?recombee_recomm_id=") + rec;
				},
				getServerArticleId : function(aId, mName) {
					if(aId.indexOf("_") > -1 ) {
						let p = aId.split("_");
						if(p.length == 2) {
							return p
						}
					}
					let o = new Array(mName, aId);
					return o;
				},
				getClient : function() {
        					client = client || new recombee.ApiClient(
            						'czech-news-center-prod',
            						'70U0WxdYzaEMPtAX0IfhiEhiMo6JcI1NtbHvH0nTn38eORv4PDkPTQ1ngsvCBuGf',
            						{
                						'baseUri': 'client-rapi-cnc.recombee.com'
            						}
						);
				},
				getMore : function(i, cnt, evt) {
					var page = parseInt(evt.srcElement.dataset.page);
					if (isNaN(page)){
						page = 1;
					}
					page++;
					evt.srcElement.dataset.page = page;
					var gaJson = evt.srcElement.dataset.ga;
					if (gaJson){
						gaJson = JSON.parse(gaJson);
						gaJson.pagination.page = page;
						dataLayer.push(gaJson);
					}
                			client.send(new recombee.RecommendNextItems(document.getElementById(i+"-more").dataset.recombee, cnt)).then(function (res) {
							recombeeRender.getTemplate(i, res, "position", cnt)
					}).catch(function (e) {
					});
				},
				setDetailView : function(rId, aId) {
					recombeeRender.getClient();
					if( localStorage.getItem("biskoId") != null ) {
						if( rId !== "" ) {
							client.send(new recombee.AddDetailView(localStorage.getItem("biskoId"), recombeeRender.serverPrefix+"_" + aId, {'cascadeCreate': true, 'recommId' : rId}));
						}else{
							client.send(new recombee.AddDetailView(localStorage.getItem("biskoId"), recombeeRender.serverPrefix+"_" + aId, {'cascadeCreate': true}));
						}
					}
				},
				ini : function(i, cnt, i2u, o, ad, onview) {
					if(/bot|google|baidu|bing|msn|teoma|slurp|yandex|crawl|spider/i.test(navigator.userAgent)) {
						return;
					}
					recombeeRender.getClient();
					let sp = cnt; 
					document.getElementById(i+"-more").addEventListener("click", function(evt){
						evt.stopPropagation();
						evt.preventDefault();
						recombeeRender.getMore(i, sp, evt);
					});
					let fp = parseInt(document.getElementById(i+"-more").dataset.firstPageSize);
					if(!isNaN(fp)) {
						cnt = fp;
						ad = "custom";
					}
					if(!onview) {
						if(i2u) {
	        					client.send(new recombee.RecommendItemsToUser(localStorage.getItem("biskoId"), cnt, o)).then(function (res) {
								recombeeRender.getTemplate(i, res, ad, cnt)
							}).catch(function (e) {recombeeRender.clearTemplate(i)});
						}else{
	        					client.send(new recombee.RecommendItemsToItem(recombeeRender.serverPrefix + "_" + recombeeRender.articleId, localStorage.getItem("biskoId"), cnt, o)).then(function (res) {
								recombeeRender.getTemplate(i, res, ad, cnt)
							}).catch(function (e) {recombeeRender.clearTemplate(i)});
						}
					}else{
						document.getElementById(i+"-more").style.display = "none";
						var recombeeObserver = new IntersectionObserver((entries, observer) => {
							entries.forEach(entry => {
								if (entry.isIntersecting) {
									observer.unobserve(entry.target)
									if(i2u) {
	        								client.send(new recombee.RecommendItemsToUser(localStorage.getItem("biskoId"), cnt, o)).then(function (res) {
											recombeeRender.getTemplate(i, res, ad, cnt);
											document.getElementById(i+"-more").style.display = "block";
										}).catch(function (e) {recombeeRender.clearTemplate(i)});
									}else{
	        								client.send(new recombee.RecommendItemsToItem(recombeeRender.serverPrefix + "_" + recombeeRender.articleId, localStorage.getItem("biskoId"), cnt, o)).then(function (res) {
											recombeeRender.getTemplate(i, res, ad, cnt)
											document.getElementById(i+"-more").style.display = "block";
										}).catch(function (e) {recombeeRender.clearTemplate(i)});
									}
								}
							})
						}, { rootMargin: "500px" });
						recombeeObserver.observe(document.getElementById(i+"-more").parentElement);
					}
				}
	}

;
var custom_hp_page = {
		pages : {
				skip : 19,
				count : [5, 5, 5, 5],
				current : 0,
				toAdd	: 2,
				goTo	: sessionStorage.getItem("hp_page_current")
		},
		set : function(o, compart) {
			if(custom_hp_page.pages.current == custom_hp_page.pages.count.length) {
				document.location = compart ? "/pocitace/?pg=4" : "/?pg=5";
			}else{
				let gUrl = "/get.aspx?pgnum=" + (custom_hp_page.pages.current+custom_hp_page.pages.toAdd) + "&skip=" + custom_hp_page.pages.skip + "&size=" + custom_hp_page.pages.count[custom_hp_page.pages.current] + (compart ? "&compartajax=1" : "");
				custom_hp_page.pages.skip += custom_hp_page.pages.count[custom_hp_page.pages.current];
				custom_hp_page.pages.current += 1;
				sessionStorage.setItem("hp_page_current", custom_hp_page.pages.current);
				o.dataset.page = custom_hp_page.pages.current;

				$.get(gUrl, function (data) {
					let p = o.parentElement;
					p.insertAdjacentHTML("beforebegin", data);
					try{
						window.__cncAdsQueue = window.__cncAdsQueue || [];
						window.__cncAdsQueue.push(() => {
							window.__cncLazyLoad( p.parentElement.querySelector(".cnc-ads:last-of-type") );
						});
					}catch(e){}
					if (custom_hp_page.pages.goTo && custom_hp_page.pages.current < custom_hp_page.pages.goTo) {
						o.click();
					}else{
						try
						{
							var pg = JSON.parse(JSON.stringify(cncPage)); 
							pg.pagination.page=custom_hp_page.pages.current;
							dataLayer.push({"event": "page_next", "pagination": JSON.parse(JSON.stringify(pg.pagination))});
						}catch(e){}
						try{layout.adHandler.addSky();}catch(e){}
						try { gtmParse(false); } catch (e) { }
					}
				});
			}
		}
}
document.addEventListener("DOMContentLoaded", function(){
        if (custom_hp_page.pages.goTo && custom_hp_page.pages.current < custom_hp_page.pages.goTo) {
		document.getElementById('btn_read_next').click();
        }
})

;
var dlEvts = [];
var gallery = {
		wrapper : null,
		slider : null,
		info : null,
		infoVisible : false,
		count : 0,
		current : 0,
		touch : {
				start : 0,
				end : 0
		},
		build : function() {
				gallery.wrapper = document.getElementById("article-gallery__wrapper");
				gallery.slider = document.querySelector("#article-gallery__wrapper > .article-gallery__spot");
				gallery.info = document.querySelectorAll("#article-gallery__wrapper > .article-gallery__spot .article__top-info-icon-wrapper");
				gallery.count = parseInt(gallery.wrapper.dataset.imageCount);
				gallery.current = parseInt(gallery.wrapper.dataset.imageCurrent);

				gallery.repos(-1);
				gallery.resize();
				gallery.bindEvents();
		},
		bindEvents : function() {
				document.addEventListener("DOMContentLoaded", function() {
					gallery.resize();
				});
				document.addEventListener("keyup", function(event){
					let v = gallery.isInViewPort();
					if(v && event.keyCode === 39) {
						gallery.move(1);
					}else if(v && event.keyCode === 37) {
						gallery.move(-1);
					}
				});
				document.addEventListener('touchstart', function(event) {
					gallery.touch.start = gallery.isInViewPort() ? event.changedTouches[0].screenX : 0;
					gallery.touch.startY = gallery.isInViewPort() ? event.changedTouches[0].screenY : 0;
				});
				document.addEventListener('touchend', function(event) {
					let v = gallery.isInViewPort();
					gallery.touch.end = v ? event.changedTouches[0].screenX : 0;
					gallery.touch.endY = v ? event.changedTouches[0].screenY : 0;
					let slideSide = Math.abs(gallery.touch.start - gallery.touch.end) > Math.abs(gallery.touch.startY - gallery.touch.endY);
					if(v && slideSide) {
						if( gallery.touch.start > gallery.touch.end ) {
							gallery.move(1);
						}else if( gallery.touch.start < gallery.touch.end ) {
							gallery.move(-1);
						}
					}
					gallery.touch.start = 0;
					gallery.touch.end = 0;
				});
				window.addEventListener("resize", function(){
					gallery.resize();
				});
				gallery.handleInfoMouseOver();
		},
		move : function(w) {
			gallery.current += w;
			if(gallery.current == 0){
				gallery.current = gallery.count;
			}else if(gallery.current > gallery.count){
				gallery.current = 1;
			}
			gallery.wrapper.dataset.imageCurrent = gallery.current;
			gallery.repos(w);
			gallery.log();
			var evt = {
				"event": (w == 1)? "gallery_next" : "gallery_previous",
				"gallery": {
					"position": this.current
		                }
		        };

			if (dlEvts != null){
				dlEvts.push(evt);
			}else{
				dataLayer.push(evt);
			}
		},
		toggleInfo : function(o) {
				if(gallery.info == null) {
					if(gallery.infoVisible) {
						o.classList.remove("article__top-info-icon-wrapper--active");
					}else{
						o.classList.add("article__top-info-icon-wrapper--active");
					}
				}else{
					gallery.info.forEach((info) => {
						if(gallery.infoVisible) {
							info.classList.remove("article__top-info-icon-wrapper--active");
						}else{
							info.classList.add("article__top-info-icon-wrapper--active");
						}
					});
				}
				gallery.infoVisible = !gallery.infoVisible;
		},
		handleInfoMouseOver : function(o) {
				if(o) {
					gallery.info = o;
				}
				if(gallery.info != null) {
					gallery.info.forEach((info) => {
						info.addEventListener("mouseenter", function(e){
							let o = e.target;
							e.stopPropagation();
							if(!gallery.infoVisible){
								o.classList.add("article__top-info-icon-wrapper--active");
							}
						});
						info.addEventListener("mouseleave", function(e){
							let o = e.target;
							e.stopPropagation();
							if(!gallery.infoVisible){
								o.classList.remove("article__top-info-icon-wrapper--active");
							}
						});
					});
				}
		},
		repos : function(w) {
			if(w>0) {
				gallery.slider.insertBefore(gallery.slider.firstElementChild, gallery.slider.lastElementChild.nextSibling);
			}else{
				gallery.slider.insertBefore(gallery.slider.lastElementChild, gallery.slider.firstElementChild);
			}
		},
		resize : function() {
			let w = gallery.wrapper.getBoundingClientRect()
			gallery.slider.style.width = w.width * gallery.count + "px";
			gallery.slider.style.left = w.width * -1 + "px";
		},
		log : function() {
				let f = gallery.slider.children[1].querySelector("source[media='(min-width:1080px)']").getAttribute("srcset");
				let d = window.location.origin;
				try{gemius_hit(pp_gemius_identifier.replace("USED_", ""));}catch(e){}
				try{adoR.reload();}catch(e){}
		        	try { window.io({event: 'pageviews', config_page_url: window._io_config["0.2.0"][0].page_url,type_article:'Galerie'}); } catch (e) { }; 
				try { window.io({event:'gallery_photo_viewed', gallery_id: window._io_gallery_config[0].gallery_id, img_src: d + '/' + f});}catch(e){};
				//try { gtmLogGallery(gallery.current-1, gallery.count);}catch(e){};
		},
		isInViewPort : function() {
				const { top, left, bottom, right } = gallery.wrapper.getBoundingClientRect();
  				const { innerHeight, innerWidth } = window;
				return ((top > 0 && top < innerHeight) || (bottom > 0 && bottom < innerHeight)) && ((left > 0 && left < innerWidth) || (right > 0 && right < innerWidth));
		}
}

function afterInit(){
	if (typeof cncGallery !== 'undefined' && cncGallery != null && typeof cncGallery === 'object'){
		//dataLayer.push({ event: 'gallery_open' });
	}
	if (dlEvts != null){
		for (let i = 0; i < dlEvts.length; i++) { 
			dataLayer.push(dlEvts[i]); 
		}
		dlEvts = null;
	}
}
;
var customTables = {
		currentView : null,
		build : function(firstTime) {
			let tList = document.querySelectorAll(".addOn_table > table");
			for (let i = 0; i < tList.length; i++) {
				const { width, height } = tList[i].querySelector("tr").getBoundingClientRect();
				const pEl = tList[i].parentElement.getBoundingClientRect();
				if(pEl.width < width) {
					const scale = (pEl.width / width);
					tList[i].style.scale = scale;
					tList[i].parentElement.dataset["scale"] = scale;
					tList[i].style.transformOrigin = "left top";
					tList[i].parentElement.dataset["originalHeight"] = pEl.height;
					tList[i].parentElement.style.height = pEl.height*scale + "px";
					tList[i].parentElement.dataset["originalWidth"] = width;
					tList[i].parentElement.addEventListener("click", function() {
						const { x, y } = document.body.getBoundingClientRect();
						customTables.enLarge(i, x, y);
					});
					tList[i].parentElement.insertAdjacentHTML("beforeEnd", "<div class='addOn_table-resizer'></div>");
					tList[i].parentElement.classList.add("full");
				} 
			}
		},
		reBuild : function() {
			let tList = document.querySelectorAll(".addOn_table > table");
			for (let i = 0; i < tList.length; i++) {
				tList[i].style.scale = 1;
				try {
					tList[i].parentElement.querySelector('.addOn_table-resizer').remove();
					tList[i].parentElement.classList.remove("full");
					tList[i].parentElement.style.height = "auto";
				}catch(e){}
			}
			customTables.build();
		},
		enLarge : function(i, x, y) {
			let t = document.querySelectorAll(".addOn_table")[i].querySelector("table");
			let p = t.parentElement;
			let nT = t.cloneNode(true);
			nT.style.width = p.dataset["originalWidth"] + "px";
			nT.style.scale = 1;
			let cT = "<div class='addOn_table-preview' data-scroll-x='" + x + "' data-scroll-y='" + y + "'>";
			    cT += "<div class='addOn_table-resizer'></div>";
			    cT += "<div class='article' style='width:" + p.dataset["originalWidth"] + "px;'>";
			    cT += "<div class='article__body'>";
			    cT += nT.outerHTML;
			    cT += "</div>";
			    cT += "</div>";
			document.body.insertAdjacentHTML("afterBegin", cT);
			document.querySelector(".addOn_table-preview, .addOn_table-preview .addOn_table-resizer").addEventListener("click", function(event){
				event.preventDefault();
				event.stopPropagation();
 				customTables.close(event);
			});
			document.querySelector(".addOn_table-preview .article").addEventListener("click", function(event){
				event.preventDefault();
				event.stopPropagation();
			});
			document.querySelector("form").style.display = "none";
			window.scrollTo(0,0);
		},
		close : function() {
				let t = document.querySelector(".addOn_table-preview");
				document.querySelector("form").style.display = "block";
				window.scrollTo(parseFloat(t.dataset["scrollX"])*-1,parseFloat(t.dataset["scrollY"])*-1);
				t.remove();
		},
		bindEvents : function() {
				document.addEventListener("DOMContentLoaded", function() {
					customTables.build();
				});
				document.addEventListener("keyup", function(event){
					let t = document.querySelector(".addOn_table-preview");
					if(document.querySelector(".addOn_table-preview") !== null && event.keyCode === 27) {
						customTables.close();
					}
				});

				window.addEventListener("resize", function(){
					customTables.reBuild();
				});
		}
}
customTables.bindEvents();

;
var video = {
		ini : function() {
			window.addEventListener("DOMContentLoaded", function(){
				video.iniFrames();
				video.iniCNC();
			});
			const firstvideo = document.querySelector(".addOn_video") || null;
			const topvideo = document.getElementById("video-preview") || null;
			if(topvideo != null && firstvideo != null) {
				topvideo.appendChild(firstvideo);
			}
		},
		iniFrames : function() {
			let videos = document.querySelectorAll(".addOn_video > div > iframe");
			videos.forEach(function (item, idx) {
				item.src = item.dataset.src;
			});
		},
		iniCNC : function() {
		}
}
;
var inquiries = {
			enabled		: navigator.cookieEnabled,
			voteUrl		: "/PubSystem.Controls.Run.Inquiry/inquiry.ashx",

			/* *********************************************************************** */
			//inquiries methods
			addOnFly	: function(inq, server, url, w){
						var o = $('#inquiry_' + inq);
						if(inq == null || !inquiries.enabled) {o.hide(); return;};
						$.post(url, { id: inq, s: server } ).done(function(data){

							if(!data) {o.hide(); return;}

							var d = o.find(".infobox-data");
							d.append(inquiries.getWrapperData(data));
							d.append("<div class='vote-list'></div>");
							let w = d.find(".vote-list");
							for(var i=0; i<data.items.length;i++)
							{
								w.append(inquiries.getRow(data.items[i], inq, server));
							}
							d.append(inquiries.getVotes(data.votes));
						}).fail(function(jqxhr, textStatus, error){
							console.log("Fail: " + textStatus + ", " + error);
							o.hide(); return;
						});
			},

			addDuel	: function(inq, server, url, w){
						if(inq == null || !inquiries.enabled) return;
						$.post(url, { id: inq, s: server } ).done(function(data){
							var o = $('#inquiry_' + data.id);
							o.attr("data-votes", data.votes);
							o.append('<div class="heading">' + data.question + '</div>');
							var w = $("#snippet-articleDetail-articleContent .article-text").width() - 5;
							var onStart = parseInt(data.items[0].proc)==0 && parseInt(data.items[1].proc)==0;

							for(var i=0; i<2;i++)
							{
								o.append( inquiries.getColumn(data.items[i], data.id, w, onStart, i, parseInt(data.votes)) );
							}

							o.append('<div class="clear"></div>');
							o.append('<div class="footer">' + ( parseInt(data.votes)<2 ? 2 : data.votes ) + ( parseInt(data.votes)<5 ? " hlasy" : " hlasů" ) + '</div>');
							$("#snippet-articleDetail-articleContent .article-text").prepend(o);
						}).fail(function(jqxhr, textStatus, error){
							console.log("Fail: " + textStatus + ", " + error);
						});
			},
			
			/* *********************************************************************** */
			//inquiries templates
			getRow		: function(inq, id, sid){
						var o = $("<div class='vote-wrapper'><p>" + inq.text + "</p><div class='vote'><span class='bar' style='width:" + (inq.proc*0.8) + "%'>&#160;</span><span class='count'>" + inq.proc + " %</span></div></div>");
						o.on("click", function(){
							inquiries.onVote(id, inq.id, sid);
						});			
						return o;
			},
			getWrapperData	: function(inq){
						return "<h3>" + inq.question + "</h3>";
			},
			getColumn	: function(inq, id, w, s, i, v){
						var c = $("<div data-answer='" + inq.id + "' data-votes='" + (v==0 ? 0 : Math.round(parseFloat(v/100*inq.proc)) ) + "' title='Hlasovat' class='inquiry-col col" + i + ( ( inq.proc>50 || (s && i==0) || (i==0 && inq.proc==50) ) ? " winner" : "" ) + "' style='width:" + Math.round( (w-2*125) * ( (s ? 50 : inq.proc) /100) + 125 )  + "px'><span style='background-image:url(/getthumbnail.aspx?w=160&h=160&id_file=" + inq.id_file + ")' title='Hlasovat'></span><div class='inquiry-votes' title='Hlasovat'>" + inq.proc + " %</div><div class='inquiry-tx' title='Hlasovat'>Hlasovat</div></div>");
						c.on("click", function(){
							inquiries.onVoteDuel(id, inq.id);
						});			
						return c;
			},
			getVotes	: function(cnt){
						var a,b = "";
						switch(cnt){
							case 1: a = "Celkem "; b=" hlas"; break;
							case 2:
							case 3:
							case 4: a = "Celkem  "; b=" hlasy"; break;
							default: a = "Celkem  "; b=" hlasů"; break;
						}
						return "<p class='vote-footer'>" + a + cnt + b + "</p>";
			},

			/* *********************************************************************** */
			//inquiries events
			onVote 		: function(inq, answ, sId){
						$.ajax({method:"POST", url: inquiries.voteUrl, data: { i: inq, ia: answ, s: sId}, headers: {"X-Csrf-Token": $.cookie("__AntiXsrfToken")}} ).done(function(data){
							if(!data) return;
							var d = $('#inquiry_' + data.params.i + " > .infobox-data");
							//d.find('.vote-wrapper').remove();
							d.find('.vote-info').remove();
                                                        $('#inquiry_' + data.params.i + " > .infobox-data .vote-list").append("<div class='vote-result'>" + data.message + "</div>"); 
						}).fail(function(jqxhr, textStatus, error){
							console.log("Fail: " + textStatus + ", " + error);
						});
			},
			onVoteDuel 		: function(inq, answ, sId){
						$.ajax({method:"POST", url: inquiries.voteUrl, data: { i: inq, ia: answ, s: sId}, headers: {"X-Csrf-Token": $.cookie("__AntiXsrfToken")}} ).done(function(data){
							if(!data) return;
							if(data.isOk) 
							{
								inquiries.onAfterVoteDuel(inq, answ, sId);
								alert(data.message);
							}
							else
							{
								alert(data.message);
							}
						}).fail(function(jqxhr, textStatus, error){
							console.log("Fail: " + textStatus + ", " + error);
						});
			},
			onAfterVoteDuel 	: function(inq, answ, sId){
						var w = $("#snippet-articleDetail-articleContent .article-text").width() - 5;
						var o = $('#inquiry_' + inq);
						var v = parseInt(o.attr("data-votes"));
						v++;
						o.attr("data-votes", v);
						var proc,f = 0;
						o.find(".inquiry-col").each(function(index,item){
							var i = $(this);
							var a = parseInt(i.attr("data-answer"));
							var c = parseInt(i.attr("data-votes"));
							if(a==answ)
							{
								c++;
								i.attr("data-votes", c);
							}
							if(index==0)
							{
								proc = parseInt(c/v*100);
								f = proc;
							}
							else
							{
								proc = 100-f;
							}
							i.removeClass("winner");
							if( proc>50 || (a==answ && proc==50) )
							{
								i.addClass("winner");
							}
							i.css({"width": Math.round( (w-2*125) * ( proc/100 ) + 125 ) });
							i.find('.inquiry-votes').html(proc + " %");
						});
			}
}
;
