var HighchartsColors = ['#36a2eb', '#ff9f40', '#ED561B', '#DDDF00', '#24CBE5', '#64E572',
	'#FF9655', '#FFF263', '#6AF9C4'];

var u = 'undefined';
function setDocPath(urlPath){
	console.log(urlPath);

	_this.pathData = urlPath;

	if (typeof(urlPath) == 'undefined') urlPath = [];
	var data = {};
	var url = [];
	$.each(urlPath, function (k,v) {
		if (v != '' && v != 0 && k != 'page') {
			data[k] = v;
		}
		if (v.length > 0) {
			url.push(k+'-'+v);
		} else {
			url.push(k);
		}
	});
	//urlPath = '?'+(new URLSearchParams(data)).toString();
	urlPath = url.join('/');
	console.log(urlPath);
	if (urlPath == '') {
		if (typeof(eCity.queries[PARTITION]) != 'undefined') {
			urlPath = eCity.queries[PARTITION];
		} else {
			urlPath = '/';
		}
	} else {
		urlPath = '/'+PARTITION+'/'+urlPath+'/';
	}
	console.log(urlPath);
    window.history.pushState({"html":document.body.innerHtml,"pageTitle":document.title},"", urlPath);
}
function getCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}

var eCity = {
	data : {},
	queries : {
		quiz: '/quiz',
	},
	onError : false,
	query : function (method, postData, callback) {
		if (typeof(postData) == 'function') callback = postData;
		if (typeof(callback) == u) callback = function () {};
		if (typeof(postData) == u) postData = {};
		var jqxhr = $.ajax({
			type: "POST",
			url: "/api.php?method="+method,
			data: postData,
			dataType: 'JSON',
			success: function (data) {
				if (method != 'auth.login') {
					//setDocPath(postData);
				}
				callback(data);
			}
		})
		.fail(function(data) {

			if (typeof(_this.onError) == 'function') {
				_this.onError();
			}

			console.log(data);
			if (typeof(data.responseJSON) == u) {
				data.responseJSON = {
					error_code : data.status,
					error_message : data.statusText,
				};
			}

			data.responseJSON.error_message = data.responseJSON.error_message.split('~');
			if (data.responseJSON.error_message.length == 2) {

				var html = '\
					<div class="modal fade" id="error_modal" tabindex="-1" role="dialog" aria-hidden="true">\
					  <div class="modal-dialog" role="document">\
						<div class="modal-content">\
						  <div class="modal-header">\
							<h5 class="modal-title" id="exampleModalCenterTitle">Увага</h5>\
							<button type="button" class="close" data-dismiss="modal" aria-label="Close">\
							  <span aria-hidden="true">&times;</span>\
							</button>\
						  </div>\
						  <div class="modal-body">\
							  <h5>'+data.responseJSON.error_message[1]+'</h5>\
							  <hr>\
						  </div>\
						</div>\
					  </div>\
					</div>\
				';
				$("body").append(html);
				$('#error_modal').modal({});
				$("#error_modal").modal('show');

			} else {
				var toast = '\
				<div class="position-fixed top-0 end-0 p-3" style="z-index: 500000">\
				  <div id="liveToast" class="toast show" role="alert" aria-live="assertive" aria-atomic="true">\
				    <div class="toast-header" style="width: 300px;">\
				      <strong class="me-auto mr-3"><i class="bi bi-x-circle-fill text-danger"></i> ERROR</strong>\
				      <small>code <b>'+data.responseJSON.error_code+'</b></small>\
				    </div>\
				    <div class="toast-body">\
				      '+data.responseJSON.error_message[0]+'\
				    </div>\
				  </div>\
				</div>\
			';
				$("body").append(toast);
				setTimeout(function () {
					$("#liveToast").parent().fadeOut(500);
					setTimeout(function () {
						$("#liveToast").parent().remove();
					}, 500);
				}, 1000);
			}

		});
	},
	listenReload: 0,
	mh : 0,
	init : function (data) {
		_this.data = data;

		setCookie('back_url', document.location.href);

		//$("#main_row").css('padding-bottom', $("footer").height()+15);

		if (IS_MOBILE == 1) {
			$("body").addClass('mobile');
			$("#photo-by").remove();
			$("#container-main").css('padding-bottom', $("footer").height());
			$("#header .navbar .col-4").html('\
				<button class="navbar-toggler collapsed" onclick="go(\'/\');" type="button" data-toggle="collapse" data-target="#navbarTogglerDemo03" aria-controls="navbarTogglerDemo03" aria-expanded="false" aria-label="Toggle navigation">\
					<span class="navbar-toggler-icon"></span>\
			  	</button>\
			');
		} else {
			$(".for-header").css('padding-top', $("#header").height() );
		}

		_this.makeManagers(data.managers);
		
		const resizeObserver = new ResizeObserver(entries => {
			for (const entry of entries) {
				
				var body = document.body,
			    html = document.documentElement;

				var height = Math.max( body.scrollHeight, body.offsetHeight, 
				                       html.clientHeight, html.scrollHeight, html.offsetHeight );

				console.log('entry.contentRect.height', entry.contentRect.height);
				console.log('entries[0].target.clientHeight', entries[0].target.clientHeight);
				console.log('height', height);


				if (entry.contentRect.height < entries[0].target.clientHeight) height = entries[0].target.clientHeight;
				if (entry.contentRect.height < height) height = entry.contentRect.height;

				if (IS_MOBILE == 1 && height < window.visualViewport.height) {
					//height = window.visualViewport.height;
				}

				console.log('window.visualViewport.height', window.visualViewport.height);
				console.log('height', height);

				_this.mh = height;

				console.log('Body height changed:', entries[0].target.clientHeight);
				if (IS_MOBILE == 0) {
					//$("footer").css('top', height-$("footer").height());
				} else {
					//$("footer").css('top', (entry.contentRect.height)+$("footer").height());
				}
				console.log(entry.contentRect.height);
				console.log(height);
				
				if (height > entries[0].target.clientHeight) {
					$("body").removeClass("no-scroll");
				} else {
					$("body").addClass("no-scroll");
					$("body").css('min-height', entries[0].target.clientHeight+'px');
					if (IS_MOBILE == 1 && height < window.visualViewport.height) {
						height = window.visualViewport.height;
						$("body").css('min-height', height+'px');
					}
				}

				console.log('$("#header").height()',$("#header").height());
				if (IS_MOBILE == 0) {
					$("#main_row").css('min-height', $("body").height() - $("#header").height() - $("footer").height());
				}


			}
		});
		resizeObserver.observe(document.body);
		
		window.addEventListener('focus', function(e){
		    if (_this.listenReload > 0) {
		    	_this.listenReload++;
		    }
		    if (_this.listenReload == 3) {
		    	document.location.reload();
		    }
		});

		$("[data-type=login]").click(function () {
			_this.showLoginModal();
		});
		
		if (typeof(data.auth.id) != u) {
			_this.auth(data.auth);
		}
		
		window.onpopstate = function(event) {
			_this.loadHistory(document.location.pathname);
		};
		
		
		_this.onLoad();

		//$("#questions-create").click();

	},
	loadHistory : function (pathname) {
		pathname = pathname.split('/');
		var path = {};
		var method = false;
		$.each(pathname, function (k,v) {
			if (v.length > 0) {
				if (method === false) {
					method = v;
				} else {
					v = v.split('-');
					path[v[0]] = v[1];
				}
			}
		});
		$.each(path, function (k,v) {
			if (typeof(v) === u) path[k] = true;
		});
		if (method == 'questions') {
			if (typeof(path.show) != u) {
				_this.manager_id = path.id;
				_this.questionGetById(path.show);
			} else if (typeof(path.id) != u) {
				_this.manager_id = path.id;
				_this.questionsGetByManager(_this.manager_id, 1);
			}
		} else if (method == 'account') {
			if (typeof(path.settings) != u) {
				_this.showEditSettings();
			}
		}
	},
	pathData : {},
	onLoad : function () {

		Highcharts.theme = {
			colors: HighchartsColors,
			chart: {
				backgroundColor: {
					linearGradient: [0, 0, 0, 500],
					stops: [
						[0, 'rgb(255, 255, 255)'],
						[1, 'rgb(240, 240, 255)']
					]
				},
			},
			title: {
				style: {
					color: '#000',
					font: 'bold 16px "Open Sans", sans-serif'
				}
			},
			subtitle: {
				style: {
					color: '#666666',
					font: 'bold 12px "Open Sans", sans-serif'
				}
			},
			legend: {
				itemStyle: {
					font: '9pt "Open Sans", sans-serif',
					color: 'black'
				},
				itemHoverStyle:{
					color: 'gray'
				}
			}
		};
		// Apply the theme
		Highcharts.setOptions(Highcharts.theme);

		pathname = document.location.pathname.split('/');
		var path = {};
		var method = false;
		$.each(pathname, function (k,v) {
			if (v.length > 0) {
				if (method === false) {
					method = v;
				} else {
					v = v.split('-');
					path[v[0]] = v[1];
				}
			}
		});
		$.each(path, function (k,v) {
			if (typeof(v) === u) path[k] = true;
		});

		console.log(method);
		console.log(path);

		_this.pathData = path;

		if (method === false) {
			_this.loadMainPage();
		} else {
			PARTITION = method;
			$("#main_row").css('background', '#fff');
			if (method == 'quiz') {
				if (typeof(path.cat) != u) {
					_this.loadQuizPageSubInit(path.cat);
				} else {
					_this.loadQuizPage();
				}
			} else if (method == 'questions') {
				if (typeof (path.show) != u) {
					_this.manager_id = path.id;
					_this.questionsGetByManager(_this.manager_id, 1, function () {
						_this.questionGetById(path.show);
					});
				} else if (typeof (path.id) != u) {
					_this.manager_id = path.id;
					_this.questionsGetByManager(_this.manager_id, 1);
				}
			} else if (method == 'account') {
				if (typeof (path.settings) != u) {
					_this.showEditSettings();
				}
			} else if (method == 'docs') {
				if (typeof (path.broken) != u) {
					_this.query("docs.getBroken", function (data) {
						_this.docsBroken(data);
					});
				} else {
					_this.showDocsSearchPage();
				}
			} else if (method == 'maps') {
				if (typeof (path.heat) != u) {
					_this.query("maps.getHeat", function (data) {
						_this.mapsHeat(data);
					});
				} else {
					//_this.showDocsSearchPage();
				}
			} else if (method == 'deputy') {
				if (typeof (path.info) != u) {
					_this.query("deputy.getDeputyFullInfo", {id: path.info}, function (data) {
						_this.showDeputyFullInfo(data);
					});
				} else if (typeof (path.decision) != u) {
					_this.query("deputy.getDecisionFullInfo", {id: path.decision}, function (data) {
						_this.showDecisionFullInfo(data);
					});
				} else {
					_this.query("deputy.getSessionsInfo", function (data) {
						_this.showSessionsInfo(data);
					});
				}
			} else if (method == 'hromada') {
				_this.query("ictv.get", function (data) {
					_this.showHromada(data);
				});
			}
		}
		Listener.start();
	},

	showHromada : function (data) {
		console.log(data);


		var html = ['<div class="p-3 py-5 hromada">'];

		//var w = (100*parseFloat(data.riven))

		var max = parseFloat(data.first[1].riven);
		var r = 100 * parseFloat(data.riven) / max;

		var min = parseFloat(data.first[13].riven);
		var m = 100 * min / max;
		var mp = m - r;

		var w = 100 - 100*data.nizhyn/data.all;

		var r_html = [];

		$.each(data.first, function (k,v) {

			if (k > 20) return false;

			var bg = '';
			if (k == data.nizhyn) {
				bg = 'bg-success';
			}

			r_html.push('\
				<div class="progress mb-3">\
				  <div style="width: 30px;">'+(k)+'.</div>\
				  <div class="progress-bar '+bg+'" role="progressbar" style="width: '+(100 * parseFloat(v.riven) / max)+'%">'+parseFloat(v.riven).toFixed(4)+'% ['+number_format(v.votes)+']</div>\
				</div>\
			');

		});


		if (data.nizhyn > 13) {
			r_html.push('\
				<div class="progress mb-3">\
				  <div style="width: 30px;">' + data.nizhyn + '.</div>\
				  <div class="progress-bar bg-success" role="progressbar" style="width: ' + r + '%;" aria-valuemin="0" aria-valuemax="100">' + parseFloat(data.riven).toFixed(4) + '% ['+number_format(data.votes)+']</div>\
				</div>\
			');
		}

		html.push('\
			<h4 class="mb-5" style="text-align: center;">Всього голосів: <b>'+data.votes+'</b></h4>\
			<h5>Рівень підтримки громади: <b>'+data.riven+'</b></h5>\
			<div class="progress mb-5">\
			  <div class="progress-bar bg-success" role="progressbar" style="width: '+r+'%;" aria-valuemin="0" aria-valuemax="100">'+parseFloat(data.riven).toFixed(4)+'%</div>\
			</div>\
			<h5>Місце серед учасників: <b>'+data.nizhyn+'</b> із <b>'+data.all+'</b></h5>\
			<div class="progress mb-5">\
				<div class="progress-bar bg-info" role="progressbar" style="width: '+w+'%;" aria-valuemin="0" aria-valuemax="100"></div>\
			</div>\
			<h5>Лідируючі позиції</h5>\
			'+r_html.join('')+'\
			<h5 style="text-align: center;" class="mb-5">\
				Посилання на конкурс:\
				<div class="mb-4"></div>\
				<a href="https://otg.fakty.com.ua/communities/nizhynska-hromada" target="_blank">https://otg.fakty.com.ua/communities/nizhynska-hromada</a> \
			</h5>\
		');

		html.push('</div>');

		$("#main_row").html(html.join("\n"));

	},

	showDecisionFullInfo : function (data) {
		console.log(data);

		var html = [];

		var  alert_type = '';
		if (data.info.vote_type == 0) {
			alert_type = 'success';
		} else if (v.vote_type == 1) {
			alert_type = 'danger';
		} else if (v.vote_type == 2) {
			alert_type = 'warning';
		} else if (v.vote_type == 3) {
			alert_type = 'secondary';
		} else if (v.vote_type == 4) {
			alert_type = 'secondary';
		} else if (v.vote_type == 5) {
			alert_type = 'info';
		}

		var result_type = '';
		if (data.info.result == 1) {
			result_type = '\
				<div class="alert question-result alert-success" role="alert">\
					Рішення прийнято\
				</div>\
			';
		} else if (data.info.result == 0) {
			result_type = '\
				<div class="alert question-result alert-danger" role="alert">\
					Рішення не прийнято\
				</div>\
			';
		} else {
			result_type = '\
				<div class="alert question-result alert-warning" role="alert">\
					Невідомий результат\
				</div>\
			';
		}

		/*
		html.push('\
			<div class="row mb-3 px-3">\
				<h5><a href="/deputy/decision-'+v.id+'/">'+v.question_name+'</a></h5>\
				<div class="w-100">\
					'+result_type+'\
					<div class="alert vote-result alert-'+alert_type+' '+fr+'" role="alert">\
						'+sessionsVotesTypes[v.vote_type]+'\
					</div>\
				</div>\
			</div>\
			<hr>\
		');
		*/
		html.push('\
			<div class="d-flex" id="search-results-page">\
				<div class="w-100">\
					<h4>'+data.info.question_name+'</h4>\
					<hr>\
					<div class="alert alert-primary" role="alert">\
						Скликання VIII\
					</div>\
					<div class="alert alert-primary" role="alert">\
						Сесія №'+data.info.session_id+'\
					</div>\
					'+result_type+'\
					</div>\
			</div>\
		');

		var vote_0;
		var vote_1;
		var vote_2;
		var vote_3;
		var alert_type;
		var box;
		var sessionsVotesTypes = [
			'За',
			'Проти',
			'Утримався',
			'Не голосував',
			'Відсутній',
			'Конфлікт інтересів',
		];

		if (IS_MOBILE == 1) {
			sessionsVotesTypes = [
				'За',
				'Пр.',
				'Утр.',
				'Н/г',
				'Н/г',
				'Конфл.',
			];
		}

		var w = 350;

		if (IS_MOBILE == 1) {
			w = 160;
		}

		var votes = [
			'<table id="personal-votes" class="mb-3 table-bordered" cellpadding="0" cellspacing="0">\
				<thead class="thead-light">\
					<tr>\
						<td width="'+w+'" nowrap>&nbsp;</td>\
						<th>'+sessionsVotesTypes[0]+'</th>\
						<th>'+sessionsVotesTypes[1]+'</th>\
						<th>'+sessionsVotesTypes[2]+'</th>\
						<th>'+sessionsVotesTypes[5]+'</th>\
					</tr>\
				</thead>\
			',
		];


		if (IS_MOBILE == 1) {
			sessionsVotesTypes = [
				'+',
				'-',
				'&nbsp;',
				'',
				'',
				'!',
			];
		}

		$.each(data.votes, function (k,v) {
			alert_type = '';

			if (v.vote_type == 0) {
				alert_type = 'success';
			} else if (v.vote_type == 1) {
				alert_type = 'danger';
			} else if (v.vote_type == 2) {
				alert_type = 'warning';
			} else if (v.vote_type == 3) {
				alert_type = 'secondary';
			} else if (v.vote_type == 4) {
				alert_type = 'secondary';
			} else if (v.vote_type == 5) {
				alert_type = 'info';
			}


			vote_0 = '';
			vote_1 = '';
			vote_2 = '';
			vote_3 = '';

			box = '\
				<div class="alert vote-result alert-'+alert_type+'" role="alert">\
					'+sessionsVotesTypes[v.vote_type]+'\
				</div>\
			';

			var tr = '';

			if (v.vote_type == 0) {
				vote_0 = box;
			} else if (v.vote_type == 1) {
				vote_1 = box;
			} else if (v.vote_type == 2) {
				vote_2 = box;
			} else if (v.vote_type == 5) {
				vote_3 = box;
			} else {
				box = '\
					<div class="alert vote-result alert-'+alert_type+'" role="alert">\
						'+sessionsVotesTypes[v.vote_type]+'\
					</div>\
				';
				vote_0 = '';
				vote_1 = '';
				vote_2 = '';
				vote_3 = '';
				tr = 'table-active';
			}

			votes.push('\
				<tr class="'+tr+'">\
					<td>\
						<h6>'+v.fio+'</h6>\
						<small>'+v.faction+'</small>\
					</td>\
					<td valign="middle">\
						'+vote_0+'\
					</td>\
					<td>\
						'+vote_1+'\
					</td>\
					<td>\
						'+vote_2+'\
					</td>\
					<td>\
						'+vote_3+'\
					</td>\
				</tr>\
			');
		});

		votes.push('\
			<tr>\
				<th>Всього:</th>\
				<th style="padding: 10px;">\
					<div class="alert vote-result alert-success" role="alert">\
						'+data.info.answers_0+'\
					</div>\
				</th>\
				<th style="padding: 10px;">\
					<div class="alert vote-result alert-danger" role="alert">\
						'+data.info.answers_1+'\
					</div>\
				</th>\
				<th style="padding: 10px;">\
					<div class="alert vote-result alert-warning" role="alert">\
						'+data.info.answers_2+'\
					</div>\
				</th>\
				<th style="padding: 10px;">\
					<div class="alert vote-result alert-info" role="alert">\
						'+data.info.answers_5+'\
					</div>\
				</th>\
			</tr>\
		');

		votes.push('</table><br>');

		html.push(votes.join("\n"));


		$("#main_row").html(html.join("\n"));

	},
	showDeputyFullInfo : function (data) {

		console.log(data);
		var html = [];
		var info = data.sessionsDeputyVotes;

		var sessions_visits = [];
		var sessions_options = [];
		var visit;

		var miss = 0;
		var presence = 0;

		$.each(info.sessions, function (k, v) {
			if (v.reduce((a, b) => a + b) == v[4]) {
				visit = 0;
				miss++;
			} else {
				presence++;
				visit = 1;
				v[3] += v[4];
				v[4] = 0;
				info.sessions[k] = v;
			}
			sessions_visits.push('\
				<div class="session-visit session-visit-' + visit + '">' + k + '</div>\
			');
			sessions_options.push('<option value="8-'+k+'">'+k+' сесія VIII скликання</option>');
		});

		if (info.district == -1) {
			info.district = 'Мер міста';
		} else if (info.district == 0) {
			info.district = 'Перший кандидат у списку';
		} else {
			info.district = 'Виборчий округ №'+info.district;
		}

		var ava_w = '';
		var is_flex = 'd-flex';
		if (IS_MOBILE == 1) {
			ava_w = 'w-100';
			is_flex = '';
		}

		html.push('\
			<div class="'+is_flex+' pt-3 deputy-info-page">\
				<div class="deputy-avatar '+ava_w+'">\
					<img src="'+info.photo+'" class="mb-3" height="250">\
					<hr>\
					<h4>'+info.fio+'</h4>\
				</div>\
				<div class="w-100 px-3">\
					<h5>Загальна інформація:</h5>\
					'+info.district+'<br>\
					'+data.factionsData[info.faction].name+'<br>\
					<hr>\
					<h5>Відвідування сесій: ('+presence+' із '+(presence+miss)+', '+Math.round(100*presence/(presence+miss))+'%) </h5>\
					'+sessions_visits.join("\n")+'\
					<hr>\
					<h5>Результати голосувань:</h5>\
					<form class="form-inline" id="find-form">\
						<div class="d-flex w-100 mb-3"> \
							<div class="input-group w-100">\
								<select name="session" class="custom-select w-100">\
									<option value="0">Всі сесії</option>\
									'+sessions_options.join("\n")+'\
								</select>\
							</div>\
							<div class="">\
								<button type="button" id="find-votes" class="btn btn-primary">Шукати результати</button>\
							</div>\
						</div>\
						<div class="custom-control custom-checkbox mr-2 mb-2">\
							<input type="checkbox" checked class="custom-control-input" id="vote_0">\
							<label class="custom-control-label" for="vote_0">За</label>\
						</div>\
						<div class="custom-control custom-checkbox mr-2 mb-2">\
							<input type="checkbox" checked class="custom-control-input" id="vote_1">\
							<label class="custom-control-label" for="vote_1">Проти</label>\
						</div>\
						<div class="custom-control custom-checkbox mr-2 mb-2">\
							<input type="checkbox" checked class="custom-control-input" id="vote_2">\
							<label class="custom-control-label" for="vote_2">Утримався</label>\
						</div>\
						<div class="custom-control custom-checkbox mr-2 mb-2">\
							<input type="checkbox" checked class="custom-control-input" id="vote_3">\
							<label class="custom-control-label" for="vote_3">Не голосував</label>\
						</div>\
						<div class="custom-control custom-checkbox mr-2 mb-2">\
							<input type="checkbox" checked class="custom-control-input" id="vote_4">\
							<label class="custom-control-label" for="vote_4">Не гол. через відсутність</label>\
						</div>\
						<div class="custom-control custom-checkbox mr-2 mb-2">\
							<input type="checkbox" checked class="custom-control-input" id="vote_5">\
							<label class="custom-control-label" for="vote_5">Конфлікт інтересів</label>\
						</div>\
					</form>\
				</div>\
			</div>\
			<hr>\
			<div class="pt-3" id="search-results-page"></div>\
		');

		$("#main_row").html(html.join(''));

		var sessionsVotesTypes = [
			'За',
			'Проти',
			'Утримався',
			'Не голосував',
			'Відсутній',
			'Конфлікт інтересів',
		];

		$("#find-votes").click(function () {
			var postData = _this.getFormData("#find-form");
			postData.id = data.id;
			_this.query("deputy.findVotes", postData, function (data) {
				console.log(data);
				var html = [];
				$.each(data, function (k,v) {
					var  alert_type = '';
					if (v.vote_type == 0) {
						alert_type = 'success';
					} else if (v.vote_type == 1) {
						alert_type = 'danger';
					} else if (v.vote_type == 2) {
						alert_type = 'warning';
					} else if (v.vote_type == 3) {
						alert_type = 'secondary';
					} else if (v.vote_type == 4) {
						alert_type = 'secondary';
					} else if (v.vote_type == 5) {
						alert_type = 'info';
					}

					var result_type = '';
					if (v.result == 1) {
						result_type = '\
							<div class="alert question-result alert-success" role="alert">\
								Рішення прийнято\
							</div>\
						';
					} else if (v.result == 0) {
						result_type = '\
							<div class="alert question-result alert-danger" role="alert">\
								Рішення не прийнято\
							</div>\
						';
					} else {
						result_type = '\
							<div class="alert question-result alert-warning" role="alert">\
								Невідомий результат\
							</div>\
						';
					}

					var fr = 'float-right';
					if (IS_MOBILE == 1) fr = '';

					html.push('\
						<div class="row mb-3 px-3">\
							<h5><a href="/deputy/decision-'+v.id+'/">'+v.question_name+'</a></h5>\
							<div class="w-100">\
								<div class="alert alert-primary" role="alert">\
									Скликання VIII\
								</div>\
								<div class="alert alert-primary" role="alert">\
									Сесія №'+v.session_id+'\
								</div>\
								'+result_type+'\
								<div class="alert vote-result alert-'+alert_type+' '+fr+'" role="alert">\
									'+sessionsVotesTypes[v.vote_type]+'\
								</div>\
							</div>\
						</div>\
						<hr>\
					');
				});
				$("#search-results-page").html(html.join("\n"));
			});
		});
	},
	showSessionsInfo : function (data) {
		console.log(data);

		var html = [];

		if (IS_MOBILE == 0) {

			html.push('\
				<div class="row">\
					<div class="col-8">\
						<div id="sessionsResults"></div>\
					</div>\
					<div class="col-4">\
						<div id="sessionsVotes"></div>\
					</div>\
				</div>\
				<div class="" id="sessionsDeputiesVotes"></div> \
			');

		} else {
			html.push('\
				<div id="sessionsResults" class="pt-3"></div>\
				<div id="sessionsVotes"></div>\
				<div class="" id="sessionsDeputiesVotes"></div> \
			');
		}


		$("#main_row").html(html.join("\n"));

		var categories = [];
		var series = [
			{
				name: 'Прийняті рішення',
				data: [],
			},
			{
				name: 'Не прийняті рішення',
				data: [],
			},
			{
				name: 'Помилки',
				data: [],
			}
		];
		var id;
		$.each(data.sessionsResults, function (k,v) {
			categories.push(k);
			$.each(v, function (kk,vv) {
				if (kk == 0) id = 1;
				else if (kk == 1) id = 0;
				else id = 2;
				series[id].data.push(vv);
			});
		});

		var sessionsVotesTypes = [
			'За',
			'Проти',
			'Утримався',
			'Не голосував',
			'Відсутній',
			'Конфлікт інтересів',
		];
		var sessionsVotesSeriesData = [];
		var sessionsVotesCategories = [];
		$.each(data.sessionsVotes, function (k,v) {
			sessionsVotesSeriesData.push({
				name: sessionsVotesTypes[k],
				y: v,
				color: HighchartsColors[k],
				id: k,
			});
		});

		function compareByY(a, b) {
			return b.y - a.y;
		}
		sessionsVotesSeriesData.sort(compareByY);

		$.each(sessionsVotesSeriesData, function (k,v) {
			sessionsVotesCategories.push(sessionsVotesTypes[v.id].split(" ").join("<br>"));
		});

		console.log(categories);
		console.log(series);

		Highcharts.chart('sessionsResults', {
			chart: {
				type: 'areaspline'
			},
			title: {
				text: 'Динаміка розгляду рішень'
			},
			navigation: {
				buttonOptions: {
					enabled: false
				}
			},
			legend: {
				layout: 'horizontal',
				align: 'center',
				verticalAlign: 'top',
				x: 0,
				y: 31,
				floating: true,
				borderWidth: 1,
				backgroundColor:
					Highcharts.defaultOptions.legend.backgroundColor || '#FFFFFF'
			},
			xAxis: {
				categories: categories,
				/*
				plotBands: [{ // visualize the weekend
					from: 4.5,
					to: 6.5,
					color: 'rgba(68, 170, 213, .2)'
				}]
				*/
			},
			yAxis: {
				title: {
					text: ''
				}
			},
			tooltip: {
				shared: true,
				valueSuffix: ' '
			},
			credits: {
				enabled: false
			},
			plotOptions: {
				areaspline: {
					fillOpacity: 0.2
				}
			},
			series: series
		});

		Highcharts.chart('sessionsVotes', {
			chart: {
				type: 'bar'
			},
			navigation: {
				buttonOptions: {
					enabled: false
				}
			},
			title: {
				text: 'Динаміка голосувань'
			},
			xAxis: {
				categories: sessionsVotesCategories
			},
			yAxis: {
				min: 0,
				title: {
					text: ''
				}
			},
			legend: {
				reversed: false,
				enabled: false
			},
			plotOptions: {
				series: {
					stacking: 'normal'
				}
			},
			credits: {
				enabled: false
			},
			series: [{
				data: sessionsVotesSeriesData,
				dataLabels: {
					enabled: true,
					rotation: 0,
					color: '#000',
					align: 'right',
					format: '{point.y:.0f}', // one decimal
					y: -2, // 10 pixels down from the top
					style: {
						fontSize: '13px',
						fontFamily: '"Open Sans", sans-serif'
					}
				}
			}]
		});

		html = [
			'<h4 class="p-3">Активність депутатів</h4>',
		];

		var deputies = [];
		$.each(data.sessionsDeputiesVotes, function (k,v) {
			$.each(v.sessions, function (kk,vv) {
				if (typeof(deputies[k]) == u) {
					deputies[k] = {
						id: k,
						miss : 0,
						presence : 0,
						vote_0 : 0,
						vote_1 : 0,
						vote_2 : 0,
						vote_3 : 0,
						vote_4 : 0,
						vote_5 : 0,
						info : v,
					};
				}
				if (vv.reduce((a,b) => a + b) == vv[4]) {
					deputies[k].miss++;
				} else {
					deputies[k].presence++;
					vv[3] += vv[4];
					vv[4] = 0;
				}
				$.each(vv, function (kkk,vvv) {
					deputies[k]['vote_'+kkk] += vvv;
				});
			});
		});


		deputies.sort(function (a,b) {
			return b.vote_0 - a.vote_0;
		});
		deputies.sort(function (a,b) {
			return a.miss - b.miss;
		});

		console.log(deputies);

		$.each(deputies, function (k,v) {

			if (typeof(v) == u) return false;

			if (v.info.photo == '') v.info.photo = '/img/no_photo.png';

			var presence_perc = Math.floor(100 * v.presence / (v.presence + v.miss));

			var votes_all = v.vote_0 +
							v.vote_1 +
							v.vote_2 +
							v.vote_3 +
							v.vote_4 +
							v.vote_5;

			var vote_0_p = Math.round(100 * v.vote_0 / votes_all);
			var vote_1_p = Math.round(100 * v.vote_1 / votes_all);
			var vote_2_p = Math.round(100 * v.vote_2 / votes_all);
			var vote_3_p = Math.round(100 * v.vote_3 / votes_all);
			var vote_4_p = Math.round(100 * v.vote_4 / votes_all);
			var vote_5_p = Math.round(100 * v.vote_5 / votes_all);

			var c = 6;
			var p = '';
			if (IS_MOBILE == 1) {
				c = 12;
				p = 'p-3';
			}


			html.push('\
				<div class="row '+p+'">\
					<div class="col-'+c+' p-2">\
						<div class="d-flex w-100">\
							<div class="sessions-avatar">\
								<a href="/deputy/info-'+v.id+'/"><img src="'+v.info.photo+'"></a>\
							</div>\
							<div class="w-100 pl-3">\
								<a href="/deputy/info-'+v.id+'/"><b>'+v.info.fio+'</b></a>\
								<br>\
								'+data.factionsData[v.info.faction].name+'\
								<div class="progress mt-1">\
									<div class="progress-bar" role="progressbar" style="width: '+presence_perc+'%;" >\
										Відвідуваність: '+presence_perc+'% ['+v.presence+' із '+(v.presence+v.miss)+']\
									</div>\
								</div>\
							</div>\
						</div>\
					</div>\
					<div class="col-'+c+' p-2">\
						<div class="row">\
							<div class="col-'+c+'">\
								<div class="mb-1">\
									<div class="in-round" style="background: '+HighchartsColors[0]+';"></div>\
									За\
									<div class="in-right">'+v.vote_0+' ('+vote_0_p+'%)</div> \
									<br>\
									<div class="progress in-line mt-1">\
										<div class="progress-bar" role="progressbar" style="background: '+HighchartsColors[0]+';width: '+vote_0_p+'%;" ></div>\
									</div>\
								</div>\
								<div class="mb-1">\
									<div class="in-round" style="background: '+HighchartsColors[3]+';"></div>\
									Не голосував\
									<div class="in-right">'+v.vote_3+' ('+vote_3_p+'%)</div> \
									<br>\
									<div class="progress in-line mt-1">\
										<div class="progress-bar" role="progressbar" style="background: '+HighchartsColors[3]+';width: '+vote_3_p+'%;" ></div>\
									</div>\
								</div>\
								<div class="mb-1">\
									<div class="in-round" style="background: '+HighchartsColors[2]+';"></div>\
									Утримався\
									<div class="in-right">'+v.vote_2+' ('+vote_2_p+'%)</div> \
									<br>\
									<div class="progress in-line mt-1">\
										<div class="progress-bar" role="progressbar" style="background: '+HighchartsColors[2]+';width: '+vote_2_p+'%;" ></div>\
									</div>\
								</div>\
							</div>\
							<div class="col-'+c+'">\
								<div class="mb-1">\
									<div class="in-round" style="background: '+HighchartsColors[1]+';"></div>\
									Проти\
									<div class="in-right">'+v.vote_1+' ('+vote_1_p+'%)</div> \
									<br>\
									<div class="progress in-line mt-1">\
										<div class="progress-bar" role="progressbar" style="background: '+HighchartsColors[1]+';width: '+vote_1_p+'%;" ></div>\
									</div>\
								</div>\
								<div class="mb-1">\
									<div class="in-round" style="background: '+HighchartsColors[5]+';"></div>\
									Конфлік інтересів\
									<div class="in-right">'+v.vote_5+' ('+vote_5_p+'%)</div> \
									<br>\
									<div class="progress in-line mt-1">\
										<div class="progress-bar" role="progressbar" style="background: '+HighchartsColors[5]+';width: '+vote_5_p+'%;" ></div>\
									</div>\
								</div>\
								<div class="mb-1">\
									<div class="in-round" style="background: '+HighchartsColors[4]+';"></div>\
									Не гол. через відсутність\
									<div class="in-right">'+v.vote_4+' ('+vote_4_p+'%)</div> \
									<br>\
									<div class="progress in-line mt-1">\
										<div class="progress-bar" role="progressbar" style="background: '+HighchartsColors[4]+';width: '+vote_4_p+'%;" ></div>\
									</div>\
								</div>\
							</div>\
						</div>\
					</div>\
				</div>\
				<hr>\
			');
		});

		$("#sessionsDeputiesVotes").html(html);
	},
	mapsHeat : function (data) {
		console.log(data);
		$("#main_row").html('<div id="map" style="width: 100vw;"></div>');

		if ($("#container-main").hasClass('maps') === false) {
			$("#main_row").height(_this.mh - $("footer").height() - $("#header").height() - 20);
			$("#container-main").addClass('maps');
			$("#map").height('100%');
			$("#map").width(document.body.clientWidth+'px');
		}

		var map = L.map('map').setView([51.046702, 31.879793], 12);

		var tiles = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
			attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors',
		}).addTo(map);

		var markers = new L.MarkerClusterGroup();

		var addressPoints = [];

		$.each(data.items, function (k,v) {
			addressPoints.push([v.lat, v.lng, 25*(v.amount/data.sum)]);
			var marker = new L.Marker(new L.LatLng(v.lat, v.lng), { title: v.title });
			marker.bindPopup("["+v.id+"] "+v.title+"<hr>Витрати: <b>"+nf(v.amount)+" грн</b>");
			markers.addLayer(marker);
		});

		//addressPoints = addressPoints.map(function (p) { return [p[0], p[1]]; });

		var heat = L.heatLayer(addressPoints, {radius: 50}).addTo(map);
		map.addLayer(markers);

		var years = [];
		var selected = '';
		$.each(data.years, function (k,v) {
			if (k == data.year) selected = 'selected'; else selected = '';
			years.push('<option value="'+k+'" '+selected+'>'+k+' ('+v+' транзакцій)</option>');
		});

		if (IS_MOBILE == 1) {
			$("#years").remove();
			$("#main_row").append('<div id="years" onclick="event.cancelBubble = true;">\
				<form>\
				  <div class="form-row align-items-center">\
					<div class="col-auto">\
					  <select class="custom-select" id="map-year">\
						<option value="0">Всі роки</option>\
						' + years.join("\n") + '\
					  </select>\
					</div>\
				  </div>\
				</form>\
			</div>');
		} else {

			$("#map").append('<div id="years">\
				<form>\
				  <div class="form-row align-items-center">\
					<div class="col-auto">\
					  <select class="custom-select" id="map-year">\
						<option value="0">Всі роки</option>\
						' + years.join("\n") + '\
					  </select>\
					</div>\
				  </div>\
				</form>\
			</div>');

			$("#years").click(function () {
				console.log('test');
			})
		}

		$("#map-year").change(function () {
			_this.query("maps.getHeat", {year: $(this).val()}, function (data) {
				_this.mapsHeat(data);
			});
		});

	},
	showDocsSearchPage : function () {
		var html = '\
			<div class="p-3" style="min-height: 100%;position: relative;">\
				<form onSubmit="$(\'#doc_search\').click();return false;">\
					 <div class="input-group">\
					    <input type="text" class="form-control" id="doc_text" placeholder="Введіть текст для пошуку..." style="outline: none !important;box-shadow:initial;">\
						<div class="input-group-append">\
						   <button class="btn btn-primary px-5" type="button" id="doc_search">Пошук</button>\
						</div>\
					  </div>\
				</form>\
				<div id="docs_results"></div>\
			</div>\
		';
		$("#main_row").html(html);
		$("#doc_search").click(function () {

			if ($(this).prop('disabled')) return false;

			$(this).prepend('<span class="button-loader spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>');
			$(this).prop('disabled',true);

			_this.query('docs.search', {
				q: $("#doc_text").val(),
			}, function (data) {
				_this.docsSearchDraw(data);
			});
		});
	},
	docsSearchDraw : function (data) {
		var html = [];
		var founds = [];
		var hidden = '';
		console.log(data);

		$.each(data.items, function (k,v) {

			founds = [];

			$.each(v.substrings, function(kk,vv) {
				if (kk < 3) {
					hidden = '';
				} else {
					hidden = 'd-none';
				}
				founds.push('<div class="substrings px-3 mb-3 '+hidden+'" data-doc-id="'+v.doc_id+'">...'+vv+'...</div>');
			});

			if (v.substrings.length > 3) {
				founds.push('<div class="docs-show-all alert mx-3 alert-secondary text-center" role="alert">\
					Показати всі входження пошукового запиту ('+(v.substrings.length-3)+')\
				</div>');
			}

			html.push('\
				<div class="card mb-3">\
					<div class="card-title p-3 mb-0 border-bottom">\
						'+v.info.doc_title+'\
					</div>\
					<div class="card-body">\
						<b>'+v.info.category+'</b><br><br>\
						<a href="'+v.info.page+'" target="_blank">Сторінка з документом</a> | <a href="https://nizhynrada.gov.ua/'+v.info.doc_url+'" target="_blank">Посилання на документ</a> | <a href="https://nizhyn.online/'+v.info.local_doc+'" target="_blank">Дзеркало посилання</a><br>\
					</div>\
					'+founds.join("\n")+'\
				</div>\
			');
		});

		$(".docs-show-more").remove();

		html.push('<div class="docs-show-more alert mx-3 alert-primary text-center" role="alert">\
			Завантажити більше документів\
		</div>');

		if (data.page == 1) {
			$("#docs_results").html(html.join(''));
		} else {
			$("#docs_results").append(html.join(''));
		}

		$(".docs-show-all").off();
		$(".docs-show-all").click(function () {
			$(this).parent().find('.d-none').removeClass('d-none');
			$(this).hide();
		});
		$(".docs-show-more").click(function () {
			$(this).html('<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>');
			_this.query('docs.search', {
				q: $("#doc_text").val(),
				page: data.next_page,
			}, function (data) {
				_this.docsSearchDraw(data);
			});
		});

		$("#doc_search").removeAttr('disabled');
		$(".button-loader").remove();

	},
	docsBroken : function (data) {
		var html = [];

		$.each(data, function (k,v) {
			html.push('\
				<div class="card mb-3">\
					<div class="card-title p-3 mb-0 border-bottom">\
						'+v.category+'\
					</div>\
					<div class="card-body">\
						<b>'+v.doc_title+'</b><br><br>\
						Сторінка з документом - <a href="'+v.page+'" target="_blank">'+v.page+'</a><br>\
					</div>\
				</div>\
			');
		});

		$("#main_row").html(html.join(''));
	},
	loadQuizPage : function () {

		PARTITION = 'quiz';
		setDocPath({});

		_this.query('quiz.getActiveCategories', function (data) {
			console.log(data);

			var html = [
				'<div class="row">'
			];

			var col = '';
			if (IS_MOBILE == 0) {
				col = 'col-6';
			}

			$.each(data, function (k,v) {
				if (v.questions_count > 0) {
					html.push('\
						<div class="'+col+' px-3">\
							<div class="card mb-3">\
							  <img src="'+v.img+'" class="card-img-top">\
							  <div class="card-body">\
								<h5 class="card-title">' + v.name + '</h5>\
								<div class="description-text">\
									'+v.description+'\
								</div>\
								<p class="card-text">Кількість питань: ' + v.questions_count + '</p>\
							  </div>\
							  <div class="card-body text-end">\
								<a href="#" onclick="return false;" data-id="' + v.id + '" class="btn btn-primary quiz-open">Перейти до опитування</a>\
							  </div>\
							</div>\
						</div>\
					');
				}
			});

			html.push('</div>');

			$("#main_row").html(html.join(''));

			$(".quiz-open").click(function () {
				var id = $(this).attr('data-id');
				_this.loadQuizPageSubInit(id);
			});

		});

	},
	loadQuizPageSubInit : function (id) {


		PARTITION = 'quiz';
		setDocPath({cat:id});

		_this.query('quiz.get', {cat: id},function (data) {
			console.log(data);
			var html = ['\
				<nav aria-label="breadcrumb my-3">\
				  <ol class="breadcrumb">\
					<li class="breadcrumb-item"><a href="#" onclick="_this.loadQuizPage();return false;">Опитування</a></li>\
					<li class="breadcrumb-item active" aria-current="page">'+data[0].cat_name+'</li>\
				  </ol>\
				</nav>\
				<div class="row quiz">\
			'];

			var items = [];
			var item;
			$.each(data, function (k,v) {
				item = [];
				item.push('<div class="col-12 mb-3" id="quiz-'+v.id+'">');
				item.push(_this.drawQuiz(v));
				item.push('</div>');
				html.push(item.join(''));
			});

			html.push('</div>');
			$("#main_row").html(html.join(''));

			$.each($("label"), function (k,v) {
				$(this).width($(this).parent().width()-$(this).parent().find('input').width()-20);
			});

			_this.quizBind();

		});
	},
	quizBind : function () {
		$(".revote").off();
		$(".revote").click(function () {
			var id = $(this).attr('data-id');
			_this.query("quiz.revote", {id: id}, function (data) {
				_this.redrawQuiz(data);
			});
		});

		$(".card-img-top img").attr('width', $(".card-img-top").width());
		$(".card-img-top img").attr('height', $(".card-img-top").width()/1.5);

		$(".img-vote").off();
		$(".img-vote.btn-primary").click(function () {
			var id = $(this).attr('data-id');
			var ans_id = $(this).attr('data-ans-id');
			console.log(id);
			console.log(ans_id);
			var answers = [ans_id];
			if (_this.authed === true) {
				_this.query("quiz.vote", {id: id, answers: answers.join(',')}, function (data) {
					_this.redrawQuiz(data);
				});
			} else {
				setCookie('back_url', document.location.href);

				var url = 'https://id.gov.ua/?response_type=code&' +
					'client_id=3c42d413ceee86a5a04d1efd444d4d3e&' +
					'auth_type=dig_sign,bank_id,mobile_id&' +
					'state='+Math.random().toString().split('.').join('')+'&' +
					'redirect_uri=https://nizhyn.online/auth/';

				var html = '\
					<div class="modal fade" id="login_modal" tabindex="-1" role="dialog" aria-hidden="true">\
					  <div class="modal-dialog" role="document">\
						<div class="modal-content">\
						  <div class="modal-header">\
							<h5 class="modal-title" id="exampleModalCenterTitle">Увага</h5>\
							<button type="button" class="close" data-dismiss="modal" aria-label="Close">\
							  <span aria-hidden="true">&times;</span>\
							</button>\
						  </div>\
						  <div class="modal-body">\
							  Для участі в опитуванні необхідно авторизуватись на сайті!\
							  <hr>\
							  Для цього натисність кнопку нижче, та оберіть зручний для вас варіант!<br>\
							  Якщо у вас немає Електронного цифрового підпису (ЕЦП) - оберіть на сторінці авторизації <b>"Увійти за допомогою"</b> варіант <b>Bank ID НБУ</b>, а потім оберіть зі списку зручний для вас банк для атворизації!\
							  <hr>\
							  <div class="form-group text-center">\
								<button type="button" class="btn btn-primary" id="auth-enter">Авторизуватись!</button>\
							  </div>\
							  <hr>\
						  </div>\
						</div>\
					  </div>\
					</div>\
				';
				$("body").append(html);
				$('#login_modal').modal({});
				$("#login_modal").modal('show');
				$("#auth-enter").click(function () {
					document.location.href = url;
				});
			}
		});

		$(".vote").off();
		$(".vote").click(function () {
			var id = $(this).attr('data-id');
			var answers = [];
			$.each($("#quiz-"+id+" input:checked"), function (k,v) {
				answers.push($(this).attr('id').split('ans-')[1]);
			});

			if (_this.authed === true) {
				_this.query("quiz.vote", {id: id, answers: answers.join(',')}, function (data) {
					_this.redrawQuiz(data);
				});
			} else {
				setCookie('back_url', document.location.href);

				var url = 'https://id.gov.ua/?response_type=code&' +
					'client_id=3c42d413ceee86a5a04d1efd444d4d3e&' +
					'auth_type=dig_sign,bank_id,mobile_id&' +
					'state='+Math.random().toString().split('.').join('')+'&' +
					'redirect_uri=https://nizhyn.online/auth/';

				var html = '\
					<div class="modal fade" id="login_modal" tabindex="-1" role="dialog" aria-hidden="true">\
					  <div class="modal-dialog" role="document">\
						<div class="modal-content">\
						  <div class="modal-header">\
							<h5 class="modal-title" id="exampleModalCenterTitle">Увага</h5>\
							<button type="button" class="close" data-dismiss="modal" aria-label="Close">\
							  <span aria-hidden="true">&times;</span>\
							</button>\
						  </div>\
						  <div class="modal-body">\
							  Для участі в опитуванні необхідно авторизуватись на сайті!\
							  <hr>\
							  Для цього натисність кнопку нижче, та оберіть зручний для вас варіант!<br>\
							  Якщо у вас немає Електронного цифрового підпису (ЕЦП) - оберіть на сторінці авторизації <b>"Увійти за допомогою"</b> варіант <b>Bank ID НБУ</b>, а потім оберіть зі списку зручний для вас банк для атворизації!\
							  <hr>\
							  <div class="form-group text-center">\
								<button type="button" class="btn btn-primary" id="auth-enter">Авторизуватись!</button>\
							  </div>\
							  <hr>\
						  </div>\
						</div>\
					  </div>\
					</div>\
				';
				$("body").append(html);
				$('#login_modal').modal({});
				$("#login_modal").modal('show');
				$("#auth-enter").click(function () {
					document.location.href = url;
				});
			}
		});

	},
	redrawQuiz : function (data) {
		$.each(data, function (k,v) {
			$("#quiz-"+v.id).html(_this.drawQuiz(v));
		})
		_this.quizBind();
	},
	quizUpdate : function (data) {
		$.each(data, function (k,v) {
			$.each(v.answers, function (kk,vv) {
				if (v.is_visible_answers == 1) {
					var p = 0;
					if (vv.votes_count > 0) {
						p = Math.round(100 * vv.votes_count / v.votes_count);
					}
					$("#progress-"+vv.id+" .progress-bar").html(p+'% ('+vv.votes_count+')');
					$("#progress-"+vv.id+" .progress-bar").width(p+'%');
				}
			})
			$("#quiz-votes-"+v.id).html(nf(v.votes_count));
		});
	},
	getQuizInfo : function (v) {
		var quiz_info = '';

		var time_end = '';
		if (v.time_end > 0) {
			moment.locale('uk')
			v.time_start = v.time_start * 1000;
			v.time_end = v.time_end * 1000;
			time_end = 'Прийняти участь в опитуванні можна з <b>';
			time_end += moment(v.time_start).format('LT') + " ";
			time_end += moment(v.time_start).format('LL') + "</b> по <b>";
			time_end += moment(v.time_end).format('LT') + " ";
			time_end += moment(v.time_end).format('LL')+"</b>!";

			quiz_info += '<i class="bi bi-calendar-week mr-3"></i>' + time_end + '<div class="br"></div>';
		}

		if (v.city_access > 0) {
			quiz_info += '<i class="bi bi-geo-alt mr-3"></i>Опитування доступне лише для жителів Ніжинської ТГ!<div class="br"></div>';
		}

		if (v.is_anon > 0) {
			quiz_info += '<i class="bi bi-eye-slash mr-3"></i>Анонімне опитування!<div class="br"></div>';
		}

		if (v.visible_answers == 1) {
			quiz_info += '<i class="bi bi-check2-circle mr-3"></i>Відповіді доступні лише після голосування!<div class="br"></div>';
		}
		if (v.visible_answers == 2) {
			quiz_info += '<i class="bi bi-hourglass-split mr-3"></i>Відповіді доступні після закінчення опитування!<div class="br"></div>';
		}

		if (quiz_info != '') {
			quiz_info = '\
				<div class="alert alert-info">\
					'+quiz_info+'\
				</div>\
			';
		}
		return quiz_info;
	},
	drawQuiz : function (v) {
		console.log(v);

		if (v.image_type == 1) return _this.drawQuizImage(v);

		var item = [];
		var mb = '';
		if (IS_MOBILE == 1) mb = 'mb-3';



		item.push('\
			<div class="card '+mb+'">\
				<div class="card-body">\
					<div class="row card-title">\
						<div class="col">\
							<div class="">'+v.name+'</div>\
						</div>\
						<div class="col-4 text-muted text-right">\
							Відповідей: <span id="quiz-votes-'+v.id+'">'+nf(v.votes_count)+'</span>\
						</div>\
					</div>\
					<hr>\
					'+_this.getQuizInfo(v)+'\
		');
		var i = 0;
		$.each(v.answers, function (kk,vv) {
			var id = 'quiz-ans-'+vv.id;

			var disabled = '';
			var checked = '';
			var bolded = '';

			if (v.voted == 1 || v.is_closed == 1) {
				disabled = 'disabled';
			}
			if (vv.voted == 1) {
				checked = 'checked';
				bolded = 'bolded';
			}

			if (v.type == 1) {
				item.push('\
					<div class="form-check mb-3 '+bolded+'">\
						<div class="custom-radio custom-control">\
							<input type="radio" class="custom-control-input" name="quiz-radio-'+v.id+'" class="" id="'+id+'" '+disabled+' '+checked+'>\
							<label class="custom-control-label" for="'+id+'">'+vv.name+'</label>\
					</div>\
				');
			} else {
				item.push('\
					<div class="form-check mb-2 '+bolded+'">\
						<div class="custom-control custom-checkbox">\
							<input type="checkbox" class="custom-control-input" id="'+id+'" '+disabled+' '+checked+'>\
							<label class="custom-control-label" for="'+id+'">'+vv.name+'</label>\
						</div>\
				');
			}

			if (v.is_visible_answers == 1) {
				var p = 0;
				if (vv.votes_count > 0) {
					p = Math.round(100 * vv.votes_count / v.votes_count);
				}
				item.push('\
					<div class="progress" id="progress-'+vv.id+'">\
						<div class="progress-bar" role="progressbar" style="background-color: '+Colors.get(i)+'; width: '+p+'%;" aria-valuenow="25">'+p+'% ('+vv.votes_count+')</div>\
					</div>\
				');
			}

			item.push('</div>');
			i++;
		});

		item.push('<hr>');

		if (v.voted == 1) {
			item.push('\
				<div class="alert-light">\
					Ви вже прийняли участь у цьому опитуванні!\
			');
			if (v.revote == 0) {
				item.push('<a href="#" onclick="return false;" class="revote" data-id="'+v.id+'">Переголосувати</a>');
			}
			item.push('</div>');
		} else {
			item.push('<a href="#" onclick="return false;" class="btn btn-primary vote" data-id="'+v.id+'">Проголосувати</a>');
		}

		item.push('\
				</div>\
			</div>\
		');

		return item.join('');
	},

	drawQuizImage : function (v) {

		var item = [];
		var mb = '';
		if (IS_MOBILE == 1) mb = 'mb-3';

		item.push('\
			<div class="card '+mb+'">\
				<div class="card-body">\
					<div class="row card-title">\
						<div class="col">\
							<div class="">'+v.name+'</div>\
						</div>\
						<div class="col-4 text-muted text-right">\
							Відповідей: <span id="quiz-votes-'+v.id+'">'+nf(v.votes_count)+'</span>\
						</div>\
					</div>\
					<hr>\
					'+_this.getQuizInfo(v)+'\
					<div class="row">\
		');
		var i = 0;
		var sep = '';
		if (IS_MOBILE == 1) {
			sep = '<div class="clearfix mb-3"></div>';
		}
		$.each(v.answers, function (kk,vv) {
			var id = 'quiz-ans-'+vv.id;

			var btn = '';
			var btn_txt = 'Проголосувати';

			if (v.voted == 1 || v.is_closed == 1) {
				btn = 'btn-secondary disabled';
			} else {
				btn = 'btn-primary';
			}
			if (vv.voted == 1) {
				btn = 'btn-success disabled';
				btn_txt = 'Проголосовано!';
			}

			vv.link.match(/http\S*/g).forEach(l => {
				var ll = l.substr(0, 50) + '...';
				vv.link = vv.link.replace(l, ' <a href="' + l + '" target="_blank">'+ll+'</a>');
			});

			var col_size = '-6';
			if (IS_MOBILE == 1) col_size = '';

			item.push('<div class="col'+col_size+' mb-4"><div class="card">');

			if (vv.img == '') vv.img = '/img/ebb6803b.png';
				item.push('\
					<div class="card-img-top" style="background-image: url('+vv.img+');">\
						<img src="/img/pixel.png" width="508" >\
					</div>\
				');

				item.push('<div class="card-body">');

					item.push('<h5 class="card-title">'+vv.name+'</h5>');

					item.push('<p class="card-text">'+vv.link+'</p>');

					item.push('<hr>');

					if (v.is_visible_answers == 1) {

						var p = 0;
						if (v.votes_count > 0) {
							p = Math.round(100 * vv.votes_count / v.votes_count);
						}
						var sdo = 301.635 - 301.635 * p / 100;
						sdo = sdo.toFixed(3);

						item.push('\
							<div class="circle-progress-block" style="float: left;">\
								<div id="circleProgress1" class="progressbar-js-circle rounded">\
									<svg viewBox="-2 -2 104 104" style="display: block; width: 100%;">\
										<path d="M 50,50 m 0,-48 a 48,48 0 1 1 0,96 a 48,48 0 1 1 0,-96" stroke="#eee" stroke-width="8" fill-opacity="0"></path>\
										<path d="M 50,50 m 0,-48 a 48,48 0 1 1 0,96 a 48,48 0 1 1 0,-96" stroke="rgb(75, 192, 192)" stroke-width="8" fill-opacity="0" style="stroke-dasharray: 301.635, 301.635; stroke-dashoffset: ' + sdo + ';"></path>\
									</svg>\
									<div class="progressbar-text">\
										' + p + '%\
									</div>\
								</div>\
							</div>\
							<div class="votes-round-count ml-3">\
								Голосів: <b>' + vv.votes_count + '</b>\
							</div>\
							' + sep + '\
						');

					}

					item.push('<a href="#" data-id="'+v.id+'" data-ans-id="'+vv.id+'" onclick="return false;" class="img-vote btn '+btn+'" style="float: right;">'+btn_txt+'</a>');

				item.push('</div>');

			item.push('</div></div>');

			/*
			if (v.type == 1) {
				item.push('\
					<div class="form-check mb-3 '+bolded+'">\
						<div class="custom-radio custom-control">\
							<input type="radio" class="custom-control-input" name="quiz-radio-'+v.id+'" class="" id="'+id+'" '+disabled+' '+checked+'>\
							<label class="custom-control-label" for="'+id+'">'+vv.name+'</label>\
					</div>\
				');
			} else {
				item.push('\
					<div class="form-check mb-2 '+bolded+'">\
						<div class="custom-control custom-checkbox">\
							<input type="checkbox" class="custom-control-input" id="'+id+'" '+disabled+' '+checked+'>\
							<label class="custom-control-label" for="'+id+'">'+vv.name+'</label>\
						</div>\
				');
			}

			if (v.is_visible_answers == 1 || v.voted == 1) {
				var p = 0;
				if (vv.votes_count > 0) {
					p = Math.round(100 * vv.votes_count / v.votes_count);
				}
				item.push('\
					<div class="progress" id="progress-'+vv.id+'">\
						<div class="progress-bar" role="progressbar" style="background-color: '+Colors.get(i)+'; width: '+p+'%;" aria-valuenow="25">'+p+'% ('+vv.votes_count+')</div>\
					</div>\
				');
			}
			item.push('</div>');

			 */
			i++;
		});

		item.push('<hr>');

		/*
		if (v.voted == 1) {
			item.push('\
				<div class="alert-light">\
					Ви вже прийняли участь у цьому опитуванні!\
			');
			if (v.revote == 0) {
				item.push('<a href="#" onclick="return false;" class="revote" data-id="'+v.id+'">Переголосувати</a>');
			}
			item.push('</div>');
		} else {
			item.push('<a href="#" onclick="return false;" class="btn btn-primary vote" data-id="'+v.id+'">Проголосувати</a>');
		}
		*/
		item.push('\
					</div>\
				</div>\
			</div>\
		');

		return item.join('');

	},

	loadMainPage : function () {
		var html = '';
		if (IS_MOBILE == 0) {
			html = '\
			<div class="row mt-3">\
				<a class="col-3" href="https://nizhyn.money/" onclick="go(\'https://nizhyn.money/\');">\
					<div class="index-block p-3 m-3 text-center">\
						<div class="p-3">\
							'+Icons.get('budget', '40%', 'white', '0 0 60 60')+'\
						</div>\
						<hr>\
						<h3 class="py-3">Відкритий<br>бюджет</h3>\
					</div>\
				</a>\
				<a class="col-3" onclick="go(\'https://nizhyn.money/tenders/\');">\
					<div class="index-block p-3 m-3 text-center">\
						<div class="p-3">\
							'+Icons.get('prozorro', '40%', 'white', '0 0 60 60')+'\
						</div>\
						<hr>\
						<h3 class="py-3">Закупівлі<br>на Prozorro</h3>\
					</div>\
				</a>\
				<a class="col-3" onclick="go(\'https://nizhyn.online/docs/\');">\
					<div class="index-block p-3 m-3 text-center">\
						<div class="p-3">\
							'+Icons.get('docs', '40%', 'white', '-3 0 480 480')+'\
						</div>\
						<hr>\
						<h3 class="py-3">Пошук<br>документів</h3>\
					</div>\
				</a>\
				<a class="col-3" onclick="go(\'/quiz\');">\
					<div class="index-block p-3 m-3 text-center">\
						<div class="p-3">\
							'+Icons.get('quiz', '40%', 'white', '0 0 512 512')+'\
						</div>\
						<hr>\
						<h3 class="py-3">onLine<br>опитування</h3>\
					</div>\
				</a>\
			</div>\
			<br>\
			<br>\
			<hr class="sep">\
			<br>\
			<div class="row" style="text-shadow: 1px 1px 6px #000;">\
				<div class="col">\
					<div class="index-blockline p-3 m-3 text-center ">\
						<h1 class="display-4">'+nf(INT_TRANS_CNT)+'</h1>\
						<div class="display-5">платежів</div>\
					</div>\
				</div>\
				<div class="col">\
					<div class="index-blockline p-3 m-3 text-center">\
						<div class="display-5">витрати</div>\
						<h1 class="display-4">'+INT_TRANS_SUM+' млрд</h1>\
					</div>\
				</div>\
				<div class="col">\
					<div class="index-blockline p-3 m-3 text-center">\
						<h1 class="display-4">'+nf(INT_DOCS_CNT)+'</h1>\
						<div class="display-5">документів</div>\
					</div>\
				</div>\
			</div>';

			$("#container-main").removeClass('container');
			$("#container-main").addClass('container-fluid');

			html += '\
			<br>\
			<br>\
			<hr class="sep">\
			<br>\
			<br>\
			<a class="row mb-3 index-full-line" style="max-height: 260px;cursor: pointer;" href="https://nizhyn.online/deputy/" ">\
				<div class="col-7">\
					<div class="row">\
						<div class="px-5 col-2>">\
							'+Icons.get('votes', '64px', 'white', '0 0 512.089 512.089')+'\
						</div>\
						<div class="col-10>">\
							<div class="display-5 text-white">Деталізація сесій</div>\
						</div>\
					</div>\
					<div class="row">\
						<div class="col-12 px-5">\
							<div class="text-white mt-3 description">Деталізація голосувань на сесіях міської ради! Дізнайтесь, як депутати ходять на сесії, та як вони голосують!</div>\
						</div>\
					</div>\
				</div>\
				<div class="col-5 pr-5">\
					<img src="/img/deputy.jpg" class="index-full-line-right-image"> \
				</div>\
			</a>\
			<br>\
			<br>\
			<hr class="sep">\
			<br>\
			<br>\
			<a class="row mb-3 index-full-line" style="max-height: 260px;cursor: pointer;" href="https://nizhynrada.gov.ua/news/novini/ecity-nizhin-operativna-dopomoga/">\
				<div class="col-5">\
					<img src="/img/iphone1.png" class="ml-4 index-full-line-left-duo-image">\
					<img src="/img/iphone2.png" class="ml-4 index-full-line-left-duo-image">\
				</div>\
				<div class="col-7">\
					<div class="row">\
						<div class="px-5 col-2>">\
							'+Icons.get('anon_bot', '64px', 'white', '0 0 512 512')+'\
						</div>\
						<div class="col-10>">\
							<div class="display-5 text-white">Анонімний чат-бот</div>\
						</div>\
					</div>\
					<div class="row">\
						<div class="col-12 px-5">\
							<div class="text-white mt-3 description">Тепер ви можете надсилати анонімні повідомлення про будь-які правопорушення національній поліції Ніжина та муніципальній Варті!</div>\
						</div>\
					</div>\
				</div>\
			</a>\
			<br>\
			<br>\
			<hr class="sep">\
			<br>\
			<br>\
			<a class="row mb-3 index-full-line" style="max-height: 260px;cursor: pointer;" href="https://nizhyn.online/maps/heat/" ">\
				<div class="col-7">\
					<div class="row">\
						<div class="px-5 col-2>">\
							'+Icons.get('money_map', '64px', 'white', '0 0 64 64')+'\
						</div>\
						<div class="col-10>">\
							<div class="display-5 text-white">Видадки на мапі</div>\
						</div>\
					</div>\
					<div class="row">\
						<div class="col-12 px-5">\
							<div class="text-white mt-3 description">За допомогою цього розділу ви можете відслідковувати витрати грошей на різні райони нашого міста!</div>\
						</div>\
					</div>\
				</div>\
				<div class="col-5 pr-5">\
					<img src="/img/map.jpg" class="index-full-line-right-image"> \
				</div>\
			</a>\
			<br>\
			<br>\
			<hr class="sep">\
			<br>\
			<br>\
			<div class="row index-full-line-nohover">\
				<div class="col text-center">\
					<h1 class="display-5 text-white p-3 text-center">Слідкуйте за нами</h1>\
					<hr>\
					<a class="href-icons" href="https://t.me/nwasted" target="_blank">'+Icons.get('msg_telegram', '96px', 'white', '0 0 512 512')+'</a>\
					<a class="ml-5 href-icons" href="https://www.facebook.com/nizhyn.online" target="_blank">'+Icons.get('msg_facebook', '96px', 'white', '0 0 512 512')+'</a>\
				</div>\
			</div>\
			<hr class="sep">\
			<br>\
			<br>\
			';

		} else {
			$("#container-main").removeClass('container');
			$("#container-main").addClass('container-fluid');

			w = '100%';

			html = '\
			<div class="row mt-3">\
				<div class="col-12" onclick="go(\'quiz\');">\
					<div class="row index-block p-3 m-3 clearfix">\
						<div class="col-3 pl-3">\
							'+Icons.get('quiz', w, 'white', '0 0 512 512')+'\
						</div>\
						<div class="col-9 pt-2">\
							<div class="display-4 ml-3">onLine<br>опитування</div>\
						</div>\
					</div>\
				</div>\
				<div class="col-12" onclick="go(\'https://nizhyn.money/\');">\
					<div class="row index-block p-3 m-3 clearfix">\
						<div class="col-3 pl-3">\
							'+Icons.get('budget', w, 'white', '0 0 60 60')+'\
						</div>\
						<div class="col-9 pt-2">\
							<div class="display-4 ml-3">Відкритий <br>бюджет</div>\
						</div>\
					</div>\
				</div>\
				<div class="col-12" onclick="go(\'https://nizhyn.money/tenders/\');">\
					<div class="row index-block p-3 m-3 clearfix">\
						<div class="col-3 pl-3">\
							'+Icons.get('prozorro', w, 'white', '0 0 60 60')+'\
						</div>\
						<div class="col-9 pt-2">\
							<div class="display-4 ml-3">Закупівлі <br>на Prozorro</div>\
						</div>\
					</div>\
				</div>\
				<div class="col-12" onclick="go(\'https://nizhyn.online/docs/\');">\
					<div class="row index-block p-3 m-3 clearfix">\
						<div class="col-3 pl-3">\
							'+Icons.get('docs', w, 'white', '-3 0 480 480')+'\
						</div>\
						<div class="col-9 pt-2">\
							<div class="display-4 ml-3">Пошук <br>документів</div>\
						</div>\
					</div>\
				</div>\
				<div class="col-12" onclick="go(\'https://nizhyn.online/deputy/\');">\
					<div class="row index-block p-3 m-3 clearfix">\
						<div class="col-3 pl-3">\
							'+Icons.get('votes', w, 'white', '0 0 512.089 512.089')+'\
						</div>\
						<div class="col-9 pt-2">\
							<div class="display-4 ml-3">Деталізація<br>сесій</div>\
						</div>\
					</div>\
				</div>\
				<div class="col-12" onclick="go(\'https://nizhyn.online/maps/heat/\');">\
					<div class="row index-block p-3 m-3 clearfix">\
						<div class="col-3 pl-3">\
							'+Icons.get('money_map', w, 'white', '0 0 64 64')+'\
						</div>\
						<div class="col-9 pt-2">\
							<div class="display-4 ml-3">Видатки <br>на мапі</div>\
						</div>\
					</div>\
				</div>\
				<div class="col-12" onclick="go(\'https://nizhynrada.gov.ua/news/novini/ecity-nizhin-operativna-dopomoga/\');">\
					<div class="row index-block p-3 m-3 clearfix">\
						<div class="col-3 pl-3">\
							'+Icons.get('anon_bot', w, 'white', '0 0 512 512')+'\
						</div>\
						<div class="col-9 pt-2">\
							<div class="display-4 ml-3">Сповіщай <br>про порушення</div>\
						</div>\
					</div>\
				</div>\
				<div class="col-12" onclick="go(\'https://t.me/nwasted/\');">\
					<div class="row index-block p-3 m-3 clearfix">\
						<div class="col-3 pl-3">\
							'+Icons.get('msg_telegram', w, 'white', '0 0 512 512')+'\
						</div>\
						<div class="col-9 pt-2">\
							<div class="display-4 ml-3">Все важливе <br>в Telegram</div>\
						</div>\
					</div>\
				</div>\
				<div class="col-12" onclick="go(\'https://t.me/nwasted/\');">\
					<div class="row index-block p-3 m-3 clearfix">\
						<div class="col-3 pl-3">\
							'+Icons.get('msg_facebook', w, 'white', '0 0 512 512')+'\
						</div>\
						<div class="col-9 pt-2">\
							<div class="display-4 ml-3">Слідкуйте за оновленнями в Facebook</div>\
						</div>\
					</div>\
				</div>\
			</div>\
			<br>\
			<br>\
			<hr>\
			<br>\
			<br>\
			<br>\
			';
		}
		$("#main_row").html(html);
	},
	makeManagers : function (data) {
		var html = [];
		$.each(data, function (k,v) {
			html.push('<li class="menu-li-sep menu-li-sep-f"><a class="dropdown-item" href="#">'+v.name+'</a></li>');
			html.push('<li><hr class="dropdown-divider"></li>');
			$.each(v.items, function (kk,vv) {
				html.push('<li data-type="questions-'+vv.id+'"><a class="dropdown-item" href="#" onclick="return false;">'+vv.name+'</a></li>');
			});
			html.push('<li><hr class="dropdown-divider"></li>');
		});
		$("#main-menu").html(html.join(''));
		
		$("#main-menu li[data-type]").click(function () {
			var type = $(this).attr('data-type');
			id = type.split('-')[1];
			_this.questionsGetByManager(id);
		});
		
		$("#a-questions-self").click(_this.questionsGetSelf);
		
	},
	showLoginModal : function () {

		setCookie('back_url', document.location.href);

		var url = 'https://id.gov.ua/?response_type=code&' +
			'client_id=3c42d413ceee86a5a04d1efd444d4d3e&' +
			'auth_type=dig_sign,bank_id,mobile_id&' +
			'state='+Math.random().toString().split('.').join('')+'&' +
			'redirect_uri=https://nizhyn.online/auth/';
		document.location.href = url;

		return false;

		var html = '\
			<div class="modal fade" id="login_modal" tabindex="-1" role="dialog" aria-hidden="true">\
			  <div class="modal-dialog" role="document">\
			    <div class="modal-content">\
			      <div class="modal-header">\
			        <h5 class="modal-title" id="exampleModalCenterTitle">Авторизація</h5>\
			        <button type="button" class="close" data-dismiss="modal" aria-label="Close">\
			          <span aria-hidden="true">&times;</span>\
			        </button>\
			      </div>\
			      <div class="modal-body">\
					<form>\
					  <div class="form-group">\
						<label for="auth-login" class="col-form-label">Логін:</label>\
						<input type="text" class="form-control" id="auth-login">\
					  </div>\
					  <div class="form-group">\
						<label for="auth-pass" class="col-form-label">Пароль:</label>\
						<input type="password" class="form-control" id="auth-pass">\
					  </div>\
					  <div class="form-group text-center">\
						<button type="button" class="btn btn-primary" id="auth-enter">Увійти</button>\
					  </div>\
					  <hr>\
					  <div class="form-group text-center" id="register">\
						<label for="auth-pass" class="col-form-label">Авторизація через Bank ID</label>\
						<br>\
						<img width=250 src="https://bank.gov.ua/admin_uploads/article/BankID-logo-2_1.png">\
					  </div>\
					</form>\
			      </div>\
			    </div>\
			  </div>\
			</div>\
		';
		$("body").append(html);
		$('#login_modal').modal({});
		$("#login_modal").modal('show');
		$("#auth-enter").click(function () {
			_this.query('auth.login', {
				login : $("#auth-login").val(),
				pass : $("#auth-pass").val(),
			}, function () {
				window.location.reload();
			});
		});
		$("#register").click(function () {

			setCookie('back_url', document.location.href);

			var url = 'https://id.gov.ua/?response_type=code&' +
				'client_id=3c42d413ceee86a5a04d1efd444d4d3e&' +
				'auth_type=dig_sign,bank_id,mobile_id&' +
				'state='+Math.random().toString().split('.').join('')+'&' +
				'redirect_uri=https://nizhyn.online/auth/';
			document.location.href = url;
		});
	},
	authed : false,
	auth : function (data) {
		_this.authed = true;
		$("#login_modal").modal('hide');
		$("[data-type=login]").remove();
		$("#header .nav").prepend('\
			<div class="ml-3 mr-1 user-profile header-notification row">\
				<div class="header-notification mr-3 d-flex align-items-center" style="display: none!important;;">\
	                <div class="dropdown-primary dropdown">\
	                    <div class="align-middle dropdown-toggle mx-3" data-toggle="dropdown" aria-expanded="false">\
	                        <i class="align-middle bi bi-bell text-white">\
								<span class="badge bg-c-pink">5</span>\
							</i>\
	                    </div>\
	                    <ul class="show-notification notification-view dropdown-menu" data-dropdown-in="fadeIn" data-dropdown-out="fadeOut">\
	                        <li>\
	                            <h6>Notifications</h6>\
	                            <label class="label label-danger">New</label>\
	                        </li>\
	                        <li>\
	                            <div class="media">\
	                                <img class="d-flex align-self-center img-radius" src="./files/assets/images/avatar-4.jpg" alt="Generic placeholder image">\
	                                <div class="media-body">\
	                                    <h5 class="notification-user">John Doe</h5>\
	                                    <p class="notification-msg">Lorem ipsum dolor sit amet, consectetuer\
	                                        elit.</p>\
	                                    <span class="notification-time">30 minutes ago</span>\
	                                </div>\
	                            </div>\
	                        </li>\
	                    </ul>\
	                </div>\
	            </div>\
                <div class="dropdown-primary dropdown">\
                    <div class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false">\
                        <img src="'+data.photo+'" class="avatar img-radius mr-3">\
                        <span class="text-white">'+data.firstName+' '+data.lastName+'</span>\
                        <i class="feather icon-chevron-down"></i>\
                    </div>\
                    <ul class=" show-notification profile-notification dropdown-menu" data-dropdown-in="fadeIn" data-dropdown-out="fadeOut">\
                        <!--<li class="px-3 py-1" id="auth-settings">\
                            <a href="#" onclick="return false;">\
                                <i class="feather icon-settings"></i> Налаштування\
                            </a>\
                        </li>\
                        <li class="px-3 py-1" id="auth-account">\
                            <a href="#" onclick="return false;">\
                                <i class="feather icon-user"></i> Профіль\
                            </a>\
                        </li>-->\
                        <li class="px-3 py-1" id="auth-logout">\
                            <a href="#" onclick="return false;">\
                                <i class="feather icon-log-out"></i> Вийти\
                            </a>\
                        </li>\
                    </ul>\
                </div>\
            </div>\
		');
		$("#auth-logout").click(function () {
			_this.query('auth.logout', function () {
				window.location.reload();
			});
		});
		$("#auth-account").click(function () {
			_this.showEditAccount();
		});
		$("#auth-settings").click(function () {
			_this.showEditSettings();
		});
	},
	showEditSettings : function () {
		PARTITION = 'account';
		setDocPath({settings:''});
		_this.query('auth.getSettings', {}, function (data) {
			var tg = 'Підключити';
			var tg_style = 'btn-primary';
			var vb = 'Підключити';
			var vb_style = 'btn-primary';
			var vb_user = '';
			var tg_user = '';
			if (typeof(data.notify[1]) != u) {
				vb = 'Відключити';
				vb_style = 'btn-success';
				vb_user = data.notify[1].messanger_username;
			}
			if (typeof(data.notify[2]) != u) {
				tg = 'Відключити';
				tg_style = 'btn-success';
				tg_user = data.notify[2].messanger_username;
			}
			var html = '\
				<div class="container mt-3">\
				  <div class="row justify-content-center">\
				    <div class="col-auto w-50">\
						<form>\
				 			<div class="row mb-3 vertical-align">\
							  <div class="col-4">\
							    <label for="staticEmail2">Email</label>\
							  </div>\
							  <div class="col-8">\
								<div class="input-group">\
									<input type="text" value="'+data.email+'" id="user-email" class="form-control" placeholder="email" aria-label="email">\
									<button class="btn btn-primary" type="button" id="email-change">Зберегти</button>\
								</div>\
							  </div>\
							</div>\
							<hr>\
							<div class="row mb-3 vertical-align">\
							  <div class="col-8">\
							    <div><label for="viber">Сповіщення в Viber <b>'+vb_user+'</b></label></div>\
							  </div>\
							  <div class="col-4">\
								<div class="text-right">\
									<button type="button" id="viber" class="pull-right btn '+vb_style+'">\
										<svg class="mx-1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" focusable="false" width="1em" height="1em" style="-ms-transform: rotate(360deg); -webkit-transform: rotate(360deg); transform: rotate(360deg);" preserveAspectRatio="xMidYMid meet" viewBox="0 0 512 512"><path d="M444 49.9C431.3 38.2 379.9.9 265.3.4c0 0-135.1-8.1-200.9 52.3C27.8 89.3 14.9 143 13.5 209.5c-1.4 66.5-3.1 191.1 117 224.9h.1l-.1 51.6s-.8 20.9 13 25.1c16.6 5.2 26.4-10.7 42.3-27.8c8.7-9.4 20.7-23.2 29.8-33.7c82.2 6.9 145.3-8.9 152.5-11.2c16.6-5.4 110.5-17.4 125.7-142c15.8-128.6-7.6-209.8-49.8-246.5zM457.9 287c-12.9 104-89 110.6-103 115.1c-6 1.9-61.5 15.7-131.2 11.2c0 0-52 62.7-68.2 79c-5.3 5.3-11.1 4.8-11-5.7c0-6.9.4-85.7.4-85.7c-.1 0-.1 0 0 0c-101.8-28.2-95.8-134.3-94.7-189.8c1.1-55.5 11.6-101 42.6-131.6c55.7-50.5 170.4-43 170.4-43c96.9.4 143.3 29.6 154.1 39.4c35.7 30.6 53.9 103.8 40.6 211.1zm-139-80.8c.4 8.6-12.5 9.2-12.9.6c-1.1-22-11.4-32.7-32.6-33.9c-8.6-.5-7.8-13.4.7-12.9c27.9 1.5 43.4 17.5 44.8 46.2zm20.3 11.3c1-42.4-25.5-75.6-75.8-79.3c-8.5-.6-7.6-13.5.9-12.9c58 4.2 88.9 44.1 87.8 92.5c-.1 8.6-13.1 8.2-12.9-.3zm47 13.4c.1 8.6-12.9 8.7-12.9.1c-.6-81.5-54.9-125.9-120.8-126.4c-8.5-.1-8.5-12.9 0-12.9c73.7.5 133 51.4 133.7 139.2zM374.9 329v.2c-10.8 19-31 40-51.8 33.3l-.2-.3c-21.1-5.9-70.8-31.5-102.2-56.5c-16.2-12.8-31-27.9-42.4-42.4c-10.3-12.9-20.7-28.2-30.8-46.6c-21.3-38.5-26-55.7-26-55.7c-6.7-20.8 14.2-41 33.3-51.8h.2c9.2-4.8 18-3.2 23.9 3.9c0 0 12.4 14.8 17.7 22.1c5 6.8 11.7 17.7 15.2 23.8c6.1 10.9 2.3 22-3.7 26.6l-12 9.6c-6.1 4.9-5.3 14-5.3 14s17.8 67.3 84.3 84.3c0 0 9.1.8 14-5.3l9.6-12c4.6-6 15.7-9.8 26.6-3.7c14.7 8.3 33.4 21.2 45.8 32.9c7 5.7 8.6 14.4 3.8 23.6z" fill="#FFF"/></svg></i>\
										<span>'+vb+'</span>\
									</button>\
								</div>\
							  </div>\
							</div>\
							<hr>\
							<div class="row mb-3 vertical-align">\
							  <div class="col-8">\
							    <div><label for="telegram">Сповіщення в Telegram <b>'+tg_user+'</b></label></div>\
							  </div>\
							  <div class="col-4">\
								<div class="text-right">\
									<button type="button" id="telegram" class="pull-right btn '+tg_style+'">\
										<i class="bi mx-1 bi-telegram"></i>\
										<span>'+tg+'</span>\
									</button>\
								</div>\
							  </div>\
							</div>\
						</form>\
				    </div>\
				  </div>\
				</div>\
			';
			$("#main_row").html(html);
			$("#viber").click(_this.showViberModal);
			$("#telegram").click(_this.showTelegramModal);
			$("#email-change").click(function () {
				var el = $(this);
				_this.query('auth.changeEmail', {
					email: $("#user-email").val(),
				}, function () {
					el.parent().append('<i class="bi bi-check2-circle bi-ok"></i>');
					el.parent().find('.bi-ok').fadeOut(2000);
					setTimeout(function () {el.parent().find('.bi-ok').remove();}, 2000);
				});
			});
		});
	},
	manager_id : 0,
	questionsGetByManager : function (id, from_history, cb) {
		PARTITION = 'questions';
		if (typeof(from_history) == u) {
			setDocPath({id: id});
		}
		if (typeof(cb) == u) cb = function () {$("#questions-list").show();};
		_this.manager_id = id;
		_this.query('managers.getInfoById', {
			id: id,
		}, function (data) {_this.questionsShowMainPage(data);cb();});
	},
	questionsGetSelf : function (id, from_history, cb) {
		PARTITION = 'questions';
		setDocPath({self: true});
		if (typeof(cb) == u) cb = function () {$("#questions-list").show();};
		_this.query('questions.getQuestionsSelf', {

		}, function (data) {_this.questionsShowMainPage(data);cb();});
	},
	questionsShowQuestion : function (data) {
		var category;
		var answer;
		var bg;
		var questions = [];
		$.each(data.questions.items, function (k,v) {
			category = _this.data.categories.main[v.category_main];
			console.log(v);
			if (v.official_answer_id > 0) {
				answer = '\
					<div class="card-footer bg-success-01">\
				    	Офіційна відповідь\
						<div class="float-end">'+v.time+'</div>\
				  	</div>\
				  	<div class="card-body d-flex">\
						<div class="p-2">\
							<img width=60 class="rounded-circle" src="'+v.answer.user_info.photo+'">\
						</div>\
						<div class="p-2 w-100">\
				    		<h6 class="card-title"><b>'+v.answer.user_info.firstName+' '+v.answer.user_info.lastName+'</b>:</h6>\
						    '+v.answer.message+'\
				    	</div>\
					</div>\
				';
			} else {
				answer = '';
			}
			
			var open_question = '\
				<div class="card-footer d-flex justify-content-end">\
					<button type="button" data-id="'+v.id+'" class="btn ml-2 btn-sm btn-info question-button-reply"><i class="bi mx-1 bi-info-circle"></i> Детальніше</button>\
				</div>';

			if (typeof(v.single_page) != u) {
				open_question = '';
			}
			
			var auth = getCookie('AUTHORIZATION');
			if (auth === null) {
				answer += open_question; 
			} else {
				if (_this.perm(v.access_level, 8) === true) {
					answer += '\
						<div class="card-footer d-flex justify-content-end">\
							<button type="button" data-id="'+v.id+'" class="btn ml-2 btn-sm btn-info question-button-priority"><i class="bi mx-1 bi-patch-exclamation"></i> Пріорітет</button>\
							<button type="button" data-id="'+v.id+'" class="btn ml-2 btn-sm btn-info question-button-add-person"><i class="bi mx-1 bi-share"></i> Додати помічника</button>\
							<button type="button" data-id="'+v.id+'" class="btn ml-2 btn-sm btn-success question-button-reply"><i class="bi mx-1 bi-chat-left-text"></i> Відповісти</button>\
							<button type="button" data-id="'+v.id+'" class="btn ml-2 btn-sm btn-danger question-button-close"><i class="bi mx-1 bi-lock"></i> Відхилити</button>\
					  	</div>\
					';
				} else {
					answer += open_question;
				}
			}
			
			bg = 'secondary';
			if (v.priority == 1) {
				bg = 'warning';
			} else if (v.priority == 2) {
				bg = 'danger';
			}
			
			var user = '<font class="text-info">Анонім</font>';
			var photo = '\
					<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" fill="currentColor" class="bi bi-person-circle text-info float-start mr-3" viewBox="0 0 16 16">\
				  	  <path d="M11 6a3 3 0 1 1-6 0 3 3 0 0 1 6 0z"/>\
					  <path fill-rule="evenodd" d="M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8zm8-7a7 7 0 0 0-5.468 11.37C3.242 11.226 4.805 10 8 10s4.757 1.225 5.468 2.37A7 7 0 0 0 8 1z"/>\
					</svg>\
			';
			if (v.account_id > 0) {
				user = v.user_info.firstName + ' ' + v.user_info.lastName;
				photo = '<img src="'+v.user_info.photo+'" class="rounded-circle float-start mr-3 " width=50 >';
			}
			
			questions.push('\
				<div class="card text-dark bg-light mb-3" data-id="'+v.id+'">\
					<div class="card-header text-dark alert-'+bg+'">\
						<b>'+category+'</b>\
						<div class="float-end">'+v.time+'</div>\
				  	</div>\
					<div class="card-body">\
						'+photo+'\
						<div class="mb-1"><b>'+user+'</b></div>\
				    	<h5 class="card-title">'+v.title+'</h5>\
				    	'+v.msg+'\
			  		</div>\
			    	'+answer+'\
				</div>\
			');
			
			if (typeof(v.recipts) != u) {
				questions.push('<h5 class="ml-1 mb-0">Задіяні особи:</h5>');
				questions.push('<div class="row p-3">');
				var hidden = '';
				var i = 0;
				var persons = {};
				var persons_ids = [];
				var show_more_persons = 0;
				
				$.each(v.managers, function (kk,vv) {
					persons[vv.id] = 1;
					persons_ids.push(vv.id);
				});
				$.each(v.recipts, function (kk,vv) {
					if (typeof(persons[vv.id]) == u) {
						persons[vv.id] = 1;
						persons_ids.push(vv.id);
					}
				});
				
				console.log(v.managers);
				console.log(v.recipts);
				console.log(persons);
				console.log(persons_ids);
				
				$.each(v.managers, function (kk,vv) {
					i++;
					persons[vv.id] = 1;
					questions.push('\
						<div class="col-4 mb-1 p-1 '+hidden+'">\
							<div class="py-3 px-1 align-middle border border-1 rounded-3">\
								<img src="'+vv.photo+'" class="rounded-circle float-start mx-3" width=50>\
								<h5 class="mb-0">'+vv.firstName+'\
								<br>\
								'+vv.lastName+'</h5>\
							</div>\
						</div>\
					');
					if (i == 2 && persons_ids.length > 3) {
						show_more_persons = 1;
						questions.push('\
							<div class="col-4 mb-1 p-1" id="show-more-persons">\
								<div class="py-3 px-1 align-middle border border-1 rounded-3">\
									<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" fill="currentColor" class="float-start bi bi-chevron-double-down mx-3" viewBox="0 0 16 16">\
									  <path fill-rule="evenodd" d="M1.646 6.646a.5.5 0 0 1 .708 0L8 12.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z"/>\
									  <path fill-rule="evenodd" d="M1.646 2.646a.5.5 0 0 1 .708 0L8 8.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z"/>\
									</svg>\
									<h5 class="mb-0">Показати\
									<br>\
									всіх осіб</h5>\
								</div>\
							</div>\
						');
						hidden = 'd-none';
					}
				});
				$.each(v.recipts, function (kk,vv) {
					//if (typeof(persons[vv.id]) != u) return true;
					i++;
					questions.push('\
						<div class="col-4 mb-1 p-1 '+hidden+'">\
							<div class="py-3 px-1 align-middle border border-1 rounded-3">\
								<img src="'+vv.photo+'" class="rounded-circle float-start mx-3" width=50>\
								<h5 class="mb-0">'+vv.firstName+'\
								<br>\
								'+vv.lastName+'</h5>\
							</div>\
						</div>\
					');
					if (i == 2 && persons_ids.length > 3 && show_more_persons == 0) {
						show_more_persons = 1;
						questions.push('\
							<div class="col-4 mb-1 p-1" id="show-more-persons">\
								<div class="py-3 px-1 align-middle border border-1 rounded-3">\
									<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" fill="currentColor" class="float-start bi bi-chevron-double-down mx-3" viewBox="0 0 16 16">\
									  <path fill-rule="evenodd" d="M1.646 6.646a.5.5 0 0 1 .708 0L8 12.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z"/>\
									  <path fill-rule="evenodd" d="M1.646 2.646a.5.5 0 0 1 .708 0L8 8.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z"/>\
									</svg>\
									<h5 class="mb-0">Показати\
									<br>\
									всіх осіб</h5>\
								</div>\
							</div>\
						');
						hidden = 'd-none';
					}
				});
				questions.push('</div>');
			}
			
		});
		return questions;
	},
	questionsShowMainPage : function (data) {
		var html = [];
		
		var questions = _this.questionsShowQuestion(data);
		
		var photo, name;
		if (typeof(data.person) != u) {
			photo = data.person.photo;
			name = '\
				'+data.person.lastName+'\
				'+data.person.firstName+'\
				'+data.person.middleName+'\
			';
		} else {
			photo = data.info.photo;
			name = data.info.name;
		}
		
		html.push('\
			<div class="col-md-3 p-3 text-center">\
				<img class="rounded-circle img-fluid" src="'+photo+'">\
				<hr>\
				<div class="h4">\
					'+name+'\
				</div>\
				<hr>\
				<button type="button" class="btn btn-danger" id="questions-create">\
					<i class="bi bi-chat-left-text mx-1"></i>\
					Створити звернення\
				</button>\
				<hr>\
				<div class="row px-3 statistic">\
					<div class="col-md-7 mb-3 text-left"><b>Всього звернень:</b></div>\
					<div class="col-md-5 mb-3 text-right"><span class="badge bg-secondary p-1 px-2 text-white">12 125</span></div>\
					\
					<div class="col-md-7 mb-3 text-left"><b>Опрацьовано:</b></div>\
					<div class="col-md-5 mb-3 text-right"><span class="badge bg-info p-1 px-2 text-white">10 125</span></div>\
					\
					<div class="col-md-7 mb-3 text-left"><b>Зараз на розгляді:</b></div>\
					<div class="col-md-5 mb-3 text-right"><span class="badge bg-primary p-1 px-2 text-white">1 125</span></div>\
					\
					<div class="col-md-7 mb-3 text-left"><b>Вирішено:</b></div>\
					<div class="col-md-5 mb-3 text-right"><span class="badge bg-success p-1 px-2 text-white">10 125</span></div>\
					\
					<div class="col-md-7 mb-3 text-left"><b>Відхилено:</b></div>\
					<div class="col-md-5 mb-3 text-right"><span class="badge bg-danger p-1 px-2 text-white">1 125</span></div>\
				</div>\
			</div>\
			<div class="col-md-9 p-3 border-left" id="questions">\
				<div id="questions-add" style="display: none;" class="questions-blocks">\
				</div>\
			    <div id="questions-on-add" class="questions-blocks">\
			      	<div class="alert alert-success" role="alert">\
				      	Дякуємо! Ваше звернення зареєстровано!\
			      	</div>\
		      	</div>\
				<div id="questions-list" class="questions-blocks">\
					'+questions.join('')+'\
					<br>\
					<nav aria-label="pagination" class="justify-content-center" id="questions-pagination" class="mt-1"></nav>\
				</div>\
			</div>\
		');
		
		$("#main_row").html(html.join(''));
		
		_this.questionsPageBind();
		
		$("#questions-pagination").html('');
		//http://josecebe.github.io/twbs-pagination/
		if (Math.ceil(data.questions.items_count/20) > 1) {
			$("#questions-pagination").twbsPagination({
				totalPages: Math.ceil(data.questions.items_count/20),
				visiblePages: 7,
				startPage : data.questions.cur_page,
				first: false,
				prev: 'Попередня',
				next: 'Наступна',
				last: false,
				paginationClass: 'pagination justify-content-center',
				onPageClick: function (event, page) {
					$('#page-content').text('Page ' + page);
				}
			});
		}

		
		$("#questions-create").click(function () {
			$(".questions-blocks").hide();
			_this.questionCreateNew(data);
			$("#questions-add").show();
		});
		
		
	},
	questionsPageBind : function () {
		//question-button-priority
		//question-button-add-person
		//question-button-reply
		//question-button-close
		
		$(".question-button-close").click(_this.showCancelModal);
		$(".question-button-priority").click(_this.showPriorityModal);
		$(".question-button-reply").click(_this.questionGetById);
		$("[data-bs-toggle=tooltip]").tooltip();
	},
	questionGetById : function (id) {
		console.log(id);
		if (typeof(id) == 'object') {
			var id = $(this).attr('data-id');
			PARTITION = 'questions';
			setDocPath({id:_this.manager_id, show: id});
		}
		_this.query('questions.getQuestionById', {
			id:id
		}, _this.questionsSingleShow);
	},
	questionsSingleShow : function (data) {
		var html = [];
		var questions = _this.questionsShowQuestion(data);
		
		html.push(questions.join(''));

		var display = 'none';
		if (typeof(data.answers.items) != 'undefined' && data.answers.items.length > 0) {
			display = 'block';
		}
		
		html.push('<div id="history-block" style="display: '+display+'"><hr>');
		html.push('<h5 class="ml-1 mb-0">Історія обговорення:</h5>');
		html.push('<div class="row p-3 mb-3" id="comments-list"></div>');
		html.push('</div>');
		
		var managers_buttons = '';
		if (_this.perm(data.questions.items[0].access_level, 8) === true) {
			managers_buttons = '\
				<div class="float-start ml-3 p-1 px-3">\
					<input type="checkbox" class="form-check-input" id="question-is-official">\
				    <label class="form-check-label mr-3" for="question-is-official">Офіційна відповідь</label>\
				</div>\
				<div class="float-start ml-3 p-1 px-3">\
					<input type="checkbox" class="form-check-input" id="question-close">\
				    <label class="form-check-label" for="question-close">Закрити звернення</label>\
				</div>\
			';
		}
		
		if (data.questions.items[0].status >= 0) {
			if (_this.perm(data.questions.items[0].access_level, [2,4,8]) === true) {
				html.push('\
					<hr>\
					<div class="mb-3">\
						<form id="questions-add-comment">\
							<input type="hidden" name="id" value="'+data.questions.items[0].id+'">\
							<div class="form-group">\
								<label for="message" class="form-label">Додати коментар</label>\
								<textarea class="form-control" name="message" rows="5"></textarea>\
							</div>\
							<div class="clearfix">\
								'+managers_buttons+'\
								<div class="float-end">\
							  		<button type="button" class="btn btn-primary align-right" id="question-reply-button">Відповісти</button>\
								</div>\
							  </div>\
						</form>\
					</div>\
				');
			} else {
				
			}
		}
		
		$("#questions-list").html(html.join(''));
		
		$.each(data.answers.items, function (k,v) {
			_this.questionsAddComment(v);
		});
		
		_this.questionsPageBind();
		
		$("#question-reply-button").click(function () {
			_this.query('questions.reply', _this.getFormData("#questions-add-comment"), function (data) {
				_this.questionsAddComment(data.items[0]);
				_this.clearFormData("#questions-add-comment", {save: {id:1}});
			});
		});
		
		$("#questions-list").show();
		
	},
	questionsAddComment : function (data) {
		var user = 'Анонім';
		var photo = '';
		var bg = '';
		var official_msg = '';
		if (data.account_id > 0) {
			user = data.user_info.firstName + ' ' + data.user_info.lastName;
			photo = '<img src="'+data.user_info.photo+'" class="rounded-circle float-start mr-3 " width=50 >';
			if (data.is_official_answer === true) {
				bg = 'alert-success';
				official_msg = '(Офіційна відповідь)';
			}
		}
		var html = '\
			<div class="card text-dark w-100 bg-light mb-3" data-id="'+data.id+'">\
				<div class="card-header text-dark '+bg+'">\
					<b>'+user+'</b> '+official_msg+'\
					<div class="float-end">'+data.time+'</div>\
			  	</div>\
				<div class="card-body clearfix">\
					'+photo+'\
			    	'+data.message+'\
		  		</div>\
			</div>\
		';
		
		$("#comments-list").append(html);
		$("#history-block").show();
	},
	questionCreateNew : function (data) {
		var categories = [];
		$.each(_this.data.categories.main, function (k,v) {
			categories.push('<option value="'+k+'">'+v+'</option>');
		});
		
		var id;
		if (typeof(data.info) != u) {
			id = data.info.id;
		} else {
			id = data.person.id;
		}
		
		$("#questions-add").html('\
			<h4>Створення нового запиту</h4>\
			<hr>\
			<form id="questions-add-form">\
			  <input type="hidden" id="question-recipts-ids" value="'+id+'">\
			  <div class="form-group">\
			    <label for="question-name">Введіть назву:</label>\
			    <input type="text" class="form-control" id="question-name" placeholder="Введіть назву">\
			  </div>\
			  <div class="form-group">\
			    <label for="question-category">Виберіть категоію</label>\
			    <select class="form-control" id="question-category">\
			      '+categories.join('')+'\
			    </select>\
			  </div>\
			  <div class="form-group">\
			    <label for="question-message">Введіть суть вашого звернення</label>\
			    <textarea style="height: 250px;" class="form-control" id="question-message" rows="3"></textarea>\
			  </div>\
			  <div class="clearfix">\
				<div class="float-start ml-3 p-1 px-3">\
					<input type="checkbox" class="form-check-input" id="question-is-anon">\
				    <label class="form-check-label mr-3" for="question-is-anon">Анонімне питання*</label>\
				</div>\
				<div class="float-start ml-3 p-1 px-3">\
					<input type="checkbox" class="form-check-input" id="question-is-public">\
				    <label class="form-check-label" for="question-is-public">Публічне питання**</label>\
				</div>\
				<div class="float-end">\
			  		<button type="button" class="btn btn-primary align-right" id="question-add-button">Задати питання</button>\
				</div>\
			  </div>\
			</form>\
			<div class="">\
				<p><b>Анонімне питання*</b> - ніхто не буде бачити ваше ім\'я</p>\
				<p><b>Публічне питання**</b> - інші користувачі зможуть бачити ваше запитання та історію його розгляду, враховуючи налаштування анонімності.</p>\
			</div>\
        ');
		_this.questionsAddLoading = 0;
		$("#question-add-button").off();
		$("#question-add-button").click(function () {
			$(this).addClass("disabled");
			if (_this.questionsAddLoading == 0) {
				_this.questionsAddLoading = 1;
			} else {
				return false;
			}
			var postData = _this.getFormData("#questions-add-form");
			_this.query('questions.create', postData, _this.questionsOnCreate);
		});
	},
	questionsClosed : 0,
	showCancelModal : function () {
		var id = $(this).attr('data-id');
		var reasons = [];
		$.each(_this.data.questions_close, function (k,v) {
			reasons.push('<option value="'+k+'">'+v+'</option>');
		});
		var html = '\
			<div class="modal fade" id="cancel_modal" tabindex="-1" role="dialog" aria-hidden="true">\
			  <div class="modal-dialog" role="document">\
			    <div class="modal-content">\
			      <div class="modal-header">\
			        <h5 class="modal-title" id="exampleModalCenterTitle">Відхилити звернення</h5>\
			        <button type="button" class="close" data-dismiss="modal" aria-label="Close">\
			          <span aria-hidden="true">&times;</span>\
			        </button>\
			      </div>\
			      <div class="modal-body">\
					<form id="cancel_modal_form">\
					  <input type="hidden" name="id" value="'+id+'">\
					  <div class="form-group">\
						<label for="auth-login" class="col-form-label">Причина:</label>\
						<select name="category" class="form-control">\
							<option>Оберіть причину</option>\
							'+reasons.join('')+'\
						</select>\
					  </div>\
					  <div class="form-group">\
						<label for="auth-pass" class="col-form-label">Коментар:</label>\
							<textarea name="message" rows=6 class="form-control"></textarea>\
					  </div>\
					  <div class="form-group text-center">\
						<button type="button" class="btn mr-2 btn-danger" id="question-button-close"><i class="bi mx-1 bi-lock"></i> Відхилити</button>\
						<button type="button" class="btn btn-secondary" data-bs-dismiss="modal"><i class="bi mx-1 bi-x-circle"></i> Закрити</button>\
					  </div>\
					</form>\
			      </div>\
			    </div>\
			  </div>\
			</div>\
		';
		$('#cancel_modal').remove();
		$("body").append(html);
		$('#cancel_modal').modal({});
		$("#cancel_modal").modal('show');
		$("[data-bs-dismiss=modal]").click(function () {$("#cancel_modal").modal('hide');});
		$("#question-button-close").click(function () {
			_this.query('questions.close', _this.getFormData('#cancel_modal'), function (data) {
				$("#cancel_modal").modal('hide');
				$(".card[data-id="+id+"]").remove();
				_this.questionsClosed++;
			});
		});
	},
	showPriorityModal : function () {
		var id = $(this).attr('data-id');
		var priority = [];
		$.each(_this.data.priority, function (k,v) {
			priority.push('<option value="'+k+'">'+v+'</option>');
		});
		var html = '\
			<div class="modal fade" id="priority_modal" tabindex="-1" role="dialog" aria-hidden="true">\
			  <div class="modal-dialog" role="document">\
			    <div class="modal-content">\
			      <div class="modal-header">\
			        <h5 class="modal-title" id="exampleModalCenterTitle">Зміна пріорітету</h5>\
			        <button type="button" class="close" data-dismiss="modal" aria-label="Close">\
			          <span aria-hidden="true">&times;</span>\
			        </button>\
			      </div>\
			      <div class="modal-body">\
					<form id="cancel_modal_form">\
					  <input type="hidden" name="id" value="'+id+'">\
					  <br>\
					  <div class="form-group">\
						<label for="auth-login" class="col-form-label">Оберіть пріорітет:</label>\
						<select name="priority" class="form-control">\
							<option>Оберіть пріорітет</option>\
							'+priority.join('')+'\
						</select>\
					  </div>\
					  <br>\
					  <hr class="my-3">\
					  <br>\
					  <div class="form-group text-center">\
						<button type="button" class="btn mr-2 btn-success" id="question-button-save"><i class="bi mx-1 bi-check2-square"></i> Зберегти</button>\
						<button type="button" class="btn btn-secondary" data-bs-dismiss="modal"><i class="bi mx-1 bi-x-circle"></i> Закрити</button>\
					  </div>\
					</form>\
			      </div>\
			    </div>\
			  </div>\
			</div>\
		';
		$('#priority_modal').remove();
		$("body").append(html);
		$('#priority_modal').modal({});
		$("#priority_modal").modal('show');
		$("[data-bs-dismiss=modal]").click(function () {$("#priority_modal").modal('hide');});
		$("#question-button-save").click(function () {
			var postData = _this.getFormData('#priority_modal');
			_this.query('questions.changePriority', postData, function (data) {
				$("#priority_modal").modal('hide');
				$(".card[data-id="+id+"] .card-header").removeClass('alert-danger');
				$(".card[data-id="+id+"] .card-header").removeClass('alert-warning');
				if (postData.priority == 1) {
					$(".card[data-id="+id+"] .card-header").addClass('alert-warning');
				} else if (postData.priority == 2) {
					$(".card[data-id="+id+"] .card-header").addClass('alert-danger');
				}
			});
		});
	},
	showViberModal : function () {
		var el = $(this);
		if (el.hasClass('btn-success')) {
			_this.query('notify.delMessanger', {type:1}, function (data) {
				el.removeClass('btn-success');
				el.addClass('btn-primary');
				el.find('span').html('Підключити');
			});
		} else {
			_this.query('notify.getUrl', {type:1}, function (data) {
				_this.openMessengerModal(1, 'Viber', data);
			});
		}
	},
	showTelegramModal : function () {
		var el = $(this);
		if (el.hasClass('btn-success')) {
			_this.query('notify.delMessanger', {type:2}, function (data) {
				el.removeClass('btn-success');
				el.addClass('btn-primary');
				el.find('span').html('Підключити');
			});
		} else {
			_this.query('notify.getUrl', {type:2}, function (data) {
				_this.openMessengerModal(2, 'Telegram', data);
			});
		}
	},
	openMessengerModal : function (mtype, type, data) {
		var url = 'https://nizhyn.online/m/'+data.code;
		var html = '\
			<div class="modal fade" id="modal" tabindex="-1" role="dialog" aria-hidden="true">\
			  <div class="modal-dialog modal-lg" role="document">\
			    <div class="modal-content">\
			      <div class="modal-header">\
			        <h5 class="modal-title" id="exampleModalCenterTitle">Підключення сповіщень '+type+'</h5>\
			        <button type="button" class="close" data-dismiss="modal" aria-label="Close">\
			          <span aria-hidden="true">&times;</span>\
			        </button>\
			      </div>\
			      <div class="modal-body">\
					<div class="text-center fs-3 mb-3">\
						<a href="'+url+'" target=_blank>'+url+'</a>\
					</div>\
					<p class="px-3">\
						Відкрийте це посилання на тому пристрої, де у вас встановлено <b>'+type+'</b>!\
					</p>\
					<p class="px-3">\
						Якщо <b>'+type+'</b> встановлено на мобільному пристрої - скопіюйте це посилання, відкрийте на вашому пристрої браузер, вставте в нього це посилання, та перейдіть по ньому!\
					</p>\
			      </div>\
			    </div>\
			  </div>\
			</div>\
		';
		$('#modal').remove();
		$("body").append(html);
		$('#modal').modal({});
		$("#modal").modal('show');
		$("[data-dismiss=modal]").click(function () {$("#modal").modal('hide');});
		$("#modal a").click(function () {
			_this.listenReload = mtype;
		});
	},
	questionsAddLoading : 0,
	questionsOnCreate : function (data) {
		_this.questionsAddLoading = 0;
		$("#question-add-button").removeClass('disabled');
		$(".questions-blocks").hide();
		$("#questions-on-add").show();
	},
	getFormData : function (form) {
		var data = {};
		var key = false;
		$(form).find('input, textarea, select').each(function() {
			key = this.id.split('-').join('_');
			if (key.length == 0) key = this.name.split('-').join('_');
			if (this.type == 'checkbox') {
				data[key] = $(this).is(':checked');
			} else if (this.type == 'file') {
				data[key] = $(this).attr('data-img');
			} else {
				data[key] = $(this).val();
			}
		});
		return data;
	},
	clearFormData : function (form, data) {
		$(form).find('input, textarea, select').each(function() {
			key = this.id.split('-').join('_');
			if (key.length == 0) key = this.name.split('-').join('_');
			if (typeof(data.save[key]) == 'undefined') {
				if (this.type == 'checkbox') {
					$(this).prop('checked', false);
				} else {
					data[key] = $(this).val('');
				}
			}
		});
	},
	perm : function (mask, role) {
		var found = false;
		if (typeof(role) == 'object') {
			$.each(role, function (k,v) {
				console.log(mask, v, (!!(mask & v)));
				if ((!!(mask & v)) === true) {
					found = true;
				}
			})
			return found;
		} else {
			return !!(mask & role);
		}
	},
};

var _this = eCity;


var Icons = {
	get : function (type, width, fill, viewBox) {
		var icon = this.icons[type];
		if (icon.split('viewBox').length == 1) {
			icon = icon.split('{settings}').join('class="mt-3 mb-3 bi" width="' + width + '" fill="' + fill + '" viewBox="' + viewBox + '"');
		} else {
			icon = icon.split('{settings}').join('class="mt-3 mb-3 bi" width="' + width + '" fill="' + fill + '" ');
		}
		return icon;
	},
	icons : {
		//1 0 60 60
		telegram : '<svg {settings} xmlns="http://www.w3.org/2000/svg"><path id="Shape" d="m39.293 20.293-3.578 3.578c-.2599566.2510745-.3642126.6228779-.2726972.9725073.0915155.3496295.3645604.6226744.7141899.7141899.3496294.0915154.7214328-.0127406.9725073-.2726972l3.578-3.578c.3789722-.3923789.3735524-1.0160848-.0121814-1.4018186s-1.0094397-.3911536-1.4018186-.0121814z"/><path id="Shape" d="m32.887 26.7-6.365 6.364c-.2527654.2527654-.3514815.621179-.258963.966463.0925186.3452839.3622161.6149814.7075.7075.345284.0925185.7136976-.0061976.966463-.258963l6.363-6.366c.2701457-.2486399.3823146-.6253227.2921953-.9812426s-.3680328-.6338334-.7239527-.7239527-.7326027.0220496-.9812426.2921953z"/><path id="Shape" d="m50 0c-3.2238225-.02278836-6.2930525 1.37973071-8.3858632 3.8320142s-2.9954179 5.70382665-2.4661368 8.8839858l-36.792 12.258c-.76920452.2594071-1.30531125.9580262-1.35684906 1.7681567-.05153781.8101306.39171771 1.5710535 1.12184906 1.9258433l20.311 9.9 9.9 20.31c.33404.6869371 1.0311513 1.1226802 1.795 1.122h.127c.8131264-.0497304 1.5148327-.5876788 1.774-1.36l12.256-36.788c4.0844527.6484769 8.1872823-1.0500508 10.6181652-4.395807 2.4308829-3.3457563 2.778519-7.77264637.8996858-11.4568372-1.8788333-3.68419083-5.6662413-6.00232528-9.801851-5.9993558zm-15.871 58-9.887-20.279c-.1872768-.4181258-.5183236-.7552046-.933-.95l-20.309-9.902 36.64-12.208c1.1118089 3.1274596 3.5725404 5.5881911 6.7 6.7zm15.871-38c-4.9705627 0-9-4.0294373-9-9 0-4.97056275 4.0294373-9 9-9s9 4.02943725 9 9c-.0055111 4.9682782-4.0317218 8.9944889-9 9z"/><path id="Shape" d="m11.891 41.69c-.8754446-1.2913037-2.21181826-2.1986782-3.735-2.536-1.53263544-.3402571-3.13665118-.1135989-4.515.638-1.52982846.7719748-2.53517864 2.2977012-2.641 4.008.08835015 1.6080902.83176719 3.109742 2.057 4.155 1.53510325 1.5638259 3.44669691 2.706443 5.551 3.318-.96299673 1.3784355-2.0505649 2.6655084-3.249 3.845-1.14537631 1.1594944-2.42705369 2.1759045-3.817 3.027-.30996049.1831191-.49756579.5187152-.49119514.8786701.00637064.3599549.20573379.6887022.52197999.8607384.31624619.1720363.70055636.1608041 1.00621515-.0294085 1.52942687-.9358019 2.93972216-2.0536288 4.2-3.329 1.50535265-1.4722483 2.83856853-3.1107552 3.974-4.884.8359781.0596089 1.6761485.0118872 2.5-.142 5.1-.968 7.98-6.154 7.73-10.4-.0209-.3572656-.2308114-.6762426-.5506625-.8367754-.3198511-.1605329-.7010489-.1382328-1 .0585-.2989511.1967327-.4702376.5380098-.4493375.8952754.2 3.406-2.078 7.556-6.107 8.321-.3521161.0674568-.7087711.1085707-1.067.123.4643199-1.0151469.7915235-2.0875543.973-3.189.3087054-1.6493379-.0090099-3.3545169-.891-4.782zm-1.079 4.464c-.1975988 1.1607439-.5783439 2.2827268-1.128 3.324-.169-.037-.336-.078-.5-.124-1.78714287-.5154724-3.40999938-1.4857407-4.71-2.816-.83004963-.6714149-1.36009787-1.6444885-1.474-2.706.10387249-.990063.71201905-1.8561424 1.608-2.29.66182394-.3577325 1.4026841-.5440648 2.155-.542.32005837-.0020442.63935225.0314951.952.1 1.01768924.2267304 1.91251225.8287542 2.506 1.686.6079125 1.0105071.8185498 2.2108902.591 3.368z"/><path id="Shape" d="m50 4c-.5522847 0-1 .44771525-1 1v7c0 .5522847.4477153 1 1 1s1-.4477153 1-1v-7c0-.55228475-.4477153-1-1-1z"/><path id="Shape" d="m50 15c-.5522847 0-1 .4477153-1 1v1c0 .5522847.4477153 1 1 1s1-.4477153 1-1v-1c0-.5522847-.4477153-1-1-1z"/></svg>',
		quiz : '<svg  {settings} ><g><path d="M476,208H424V72a8.008,8.008,0,0,0-2.34-5.66l-48-48A8.008,8.008,0,0,0,368,16H96a8,8,0,0,0-8,8V208H36A28.031,28.031,0,0,0,8,236V468a28.031,28.031,0,0,0,28,28H476a28.031,28.031,0,0,0,28-28V236A28.031,28.031,0,0,0,476,208ZM376,43.31,396.69,64H376ZM104,32H360V72a8,8,0,0,0,8,8h40V448H104ZM24,306.25l16,4v83.5l-16,4ZM488,468a12.01,12.01,0,0,1-12,12H36a12.01,12.01,0,0,1-12-12V414.25l25.94-6.49A8,8,0,0,0,56,400V304a8,8,0,0,0-6.06-7.76L24,289.75V236a12.01,12.01,0,0,1,12-12H88V448H72a8,8,0,0,0,0,16H440a8,8,0,0,0,0-16H424V224h52a12.01,12.01,0,0,1,12,12Z"/><path d="M472,304a8,8,0,0,0-8,8v80a8,8,0,0,0,16,0V312A8,8,0,0,0,472,304Z"/><path d="M128,176h48a8,8,0,0,0,8-8V120a8,8,0,0,0-8-8H128a8,8,0,0,0-8,8v48A8,8,0,0,0,128,176Zm8-48h32v32H136Z"/><path d="M208,128H384a8,8,0,0,0,0-16H208a8,8,0,0,0,0,16Z"/><path d="M208,152H384a8,8,0,0,0,0-16H208a8,8,0,0,0,0,16Z"/><path d="M208,176H384a8,8,0,0,0,0-16H208a8,8,0,0,0,0,16Z"/><path d="M128,272h48a8,8,0,0,0,8-8V216a8,8,0,0,0-8-8H128a8,8,0,0,0-8,8v48A8,8,0,0,0,128,272Zm8-48h32v32H136Z"/><path d="M208,224H384a8,8,0,0,0,0-16H208a8,8,0,0,0,0,16Z"/><path d="M208,248H384a8,8,0,0,0,0-16H208a8,8,0,0,0,0,16Z"/><path d="M208,272H384a8,8,0,0,0,0-16H208a8,8,0,0,0,0,16Z"/><path d="M128,368h48a8,8,0,0,0,8-8V312a8,8,0,0,0-8-8H128a8,8,0,0,0-8,8v48A8,8,0,0,0,128,368Zm8-48h32v32H136Z"/><path d="M208,320H384a8,8,0,0,0,0-16H208a8,8,0,0,0,0,16Z"/><path d="M208,344H384a8,8,0,0,0,0-16H208a8,8,0,0,0,0,16Z"/><path d="M208,368H384a8,8,0,0,0,0-16H208a8,8,0,0,0,0,16Z"/></g></svg>',
		budget : '<svg  {settings} xmlns="http://www.w3.org/2000/svg"><path id="Shape" d="m27 34.5c0 .5522847.4477153 1 1 1s1-.4477153 1-1c0-3.308-3.06-6.042-7-6.444v-1.056c0-.5522847-.4477153-1-1-1s-1 .4477153-1 1v1.056c-3.94.4-7 3.136-7 6.444s3.06 6.042 7 6.444v8.988c-2.833-.358-5-2.207-5-4.432 0-.5522847-.4477153-1-1-1s-1 .4477153-1 1c0 3.308 3.06 6.042 7 6.444v1.056c0 .5522847.4477153 1 1 1s1-.4477153 1-1v-1.056c3.94-.4 7-3.136 7-6.444s-3.06-6.042-7-6.444v-8.988c2.833.358 5 2.207 5 4.432zm-12 0c0-2.225 2.167-4.074 5-4.432v8.864c-2.833-.358-5-2.207-5-4.432zm12 11c0 2.225-2.167 4.074-5 4.432v-8.864c2.833.358 5 2.207 5 4.432z"/><path id="Shape" d="m3.6 30.173c-.50092364-.232479-1.09546587-.0148981-1.328.486-1.5050802 3.2391608-2.28067026 6.7692562-2.272 10.341 0 12.607 7.065 19 21 19 2.8157147.0442533 5.625148-.2794853 8.357-.963.5337832-.1419372.8514371-.6897168.7095-1.2235-.1419372-.5337832-.6897168-.8514371-1.2235-.7095-2.5651413.6334934-5.2010742.9346277-7.843.896-12.785 0-19-5.561-19-17-.01799209-3.2823093.69491672-6.527462 2.087-9.5.23167576-.5009339.01371332-1.094848-.487-1.327z"/><path id="Shape" d="m57 25h-22c-1.6568542 0-3 1.3431458-3 3v29c0 1.6568542 1.3431458 3 3 3h22c1.6568542 0 3-1.3431458 3-3v-29c0-1.6568542-1.3431458-3-3-3zm1 32c0 .5522847-.4477153 1-1 1h-22c-.5522847 0-1-.4477153-1-1v-29c0-.5522847.4477153-1 1-1h22c.5522847 0 1 .4477153 1 1z"/><path id="Shape" d="m39 38h14c1.1045695 0 2-.8954305 2-2v-4c0-1.1045695-.8954305-2-2-2h-14c-1.1045695 0-2 .8954305-2 2v4c0 1.1045695.8954305 2 2 2zm0-6h14v4h-14z"/><path id="Shape" d="m41 41h-3c-.5522847 0-1 .4477153-1 1s.4477153 1 1 1h3c.5522847 0 1-.4477153 1-1s-.4477153-1-1-1z"/><path id="Shape" d="m41 45h-3c-.5522847 0-1 .4477153-1 1s.4477153 1 1 1h3c.5522847 0 1-.4477153 1-1s-.4477153-1-1-1z"/><path id="Shape" d="m41 49h-3c-.5522847 0-1 .4477153-1 1s.4477153 1 1 1h3c.5522847 0 1-.4477153 1-1s-.4477153-1-1-1z"/><path id="Shape" d="m41 53h-3c-.5522847 0-1 .4477153-1 1s.4477153 1 1 1h3c.5522847 0 1-.4477153 1-1s-.4477153-1-1-1z"/><path id="Shape" d="m48 41h-3c-.5522847 0-1 .4477153-1 1s.4477153 1 1 1h3c.5522847 0 1-.4477153 1-1s-.4477153-1-1-1z"/><path id="Shape" d="m48 45h-3c-.5522847 0-1 .4477153-1 1s.4477153 1 1 1h3c.5522847 0 1-.4477153 1-1s-.4477153-1-1-1z"/><path id="Shape" d="m48 49h-3c-.5522847 0-1 .4477153-1 1s.4477153 1 1 1h3c.5522847 0 1-.4477153 1-1s-.4477153-1-1-1z"/><path id="Shape" d="m48 53h-3c-.5522847 0-1 .4477153-1 1s.4477153 1 1 1h3c.5522847 0 1-.4477153 1-1s-.4477153-1-1-1z"/><path id="Shape" d="m55 41h-3c-.5522847 0-1 .4477153-1 1s.4477153 1 1 1h3c.5522847 0 1-.4477153 1-1s-.4477153-1-1-1z"/><path id="Shape" d="m55 45h-3c-.5522847 0-1 .4477153-1 1s.4477153 1 1 1h3c.5522847 0 1-.4477153 1-1s-.4477153-1-1-1z"/><path id="Shape" d="m55 49h-3c-.5522847 0-1 .4477153-1 1s.4477153 1 1 1h3c.5522847 0 1-.4477153 1-1s-.4477153-1-1-1z"/><path id="Shape" d="m55 53h-3c-.5522847 0-1 .4477153-1 1s.4477153 1 1 1h3c.5522847 0 1-.4477153 1-1s-.4477153-1-1-1z"/><path id="Shape" d="m6.325 1.263c-2.633 2.412 1.993 9.852 4.719 13.737h-.544c-.9289377-.0033847-1.82071613.3645594-2.477 1.022-.65404808.6590332-1.02166441 1.5495056-1.023 2.478.00429999 1.246115.67287021 2.3953392 1.754 3.015-1.16726953 1.2346386-2.26687698 2.5315345-3.294 3.885-.33137083.4418278-.24182778 1.0686291.20000002 1.4.44182779.3313708 1.06862912.2418278 1.39999998-.2 1.23519803-1.6159851 2.5711887-3.1523743 4-4.6h20.44c1.2504296 0 2.4058742-.6670962 3.031089-1.75s.6252148-2.4170962 0-3.5-1.7806594-1.75-3.031089-1.75h-.544c2.725-3.885 7.351-11.324 4.72-13.737-1.21-1.108-2.62-.3-3.863.407-1.1303266.77409964-2.4464379 1.2331681-3.813 1.33-1.0848335-.00229137-2.1190042-.45934329-2.851-1.26-1.094289-1.11255768-2.5894703-1.73914491-4.15-1.73914491s-3.055711.62658723-4.15 1.73914491c-.7331714.80193841-1.7694252 1.25910923-2.856 1.26-1.3658416-.09582787-2.6812414-.55500942-3.81-1.33-1.242-.709-2.651-1.514-3.858-.407zm26.238 16.175c.4302609.4291709.5590582 1.0755404.3261637 1.6368534-.2328945.5613131-.7814549.9266399-1.3891637.9251466h-21c-.82842712 0-1.5-.6715729-1.5-1.5s.67157288-1.5 1.5-1.5h21c.3982269.0001175.7802853.1575413 1.063.438zm-18.57-12.438c1.5611462-.00022096 3.0567762-.62751363 4.151-1.741.7303517-.80231155 1.7650496-1.25961838 2.85-1.25961838s2.1196483.45730683 2.85 1.25961838c1.0956967 1.11434336 2.5932102 1.74167037 4.156 1.741 1.7169875-.09020951 3.3780633-.64079278 4.809-1.594.45655-.32224884.9730545-.54972842 1.519-.669 1.026.94-1.686 6.609-5.832 12.263h-2.496v-5c0-.55228475-.4477153-1-1-1s-1 .44771525-1 1v5h-6v-5c0-.55228475-.4477153-1-1-1s-1 .44771525-1 1v5h-2.492c-4.146-5.654-6.858-11.323-5.818-12.278.53463002.14279843 1.04162028.37398599 1.5.684 1.4287716.953081 3.0878912 1.50370283 4.803 1.594z"/></g></g></svg>',
		prozorro : '<svg  {settings} xmlns="http://www.w3.org/2000/svg"><path id="Shape" d="m57 0h-54c-1.65685425 0-3 1.34314575-3 3v41c0 1.6568542 1.34314575 3 3 3h17v4c-3.8641657.0044086-6.9955914 3.1358343-7 7 0 1.1045695.8954305 2 2 2h30c1.1045695 0 2-.8954305 2-2-.0044086-3.8641657-3.1358343-6.9955914-7-7v-4h17c1.6568542 0 3-1.3431458 3-3v-41c0-1.65685425-1.3431458-3-3-3zm-12 58h-30c.0033061-2.7600532 2.2399468-4.9966939 5-5h20c2.7598251.0038557 4.9961443 2.2401749 5 5zm-7-7h-16v-4h16zm19-6h-54c-.55228475 0-1-.4477153-1-1v-5h34c.5522847 0 1-.4477153 1-1s-.4477153-1-1-1h-34v-34c0-.55228475.44771525-1 1-1h54c.5522847 0 1 .44771525 1 1v34h-2c-.5522847 0-1 .4477153-1 1s.4477153 1 1 1h2v5c0 .5522847-.4477153 1-1 1z"/><path id="Shape" d="m34.332 20.056-3-1.686-9.7-9.7-1.72-3.06c-.3920665-.60611833-1.0340624-1.00576172-1.751-1.09-.5928072-.06767506-1.1846474.13462267-1.612.551l-7 7c-.41825989.4261938-.62087306 1.0189568-.551 1.612.09136036.7383331.51338735 1.3951057 1.147 1.785l3 1.686 2.023 2.023-8.994 9c-1.56213741 1.5621374-1.56213741 4.0948626 0 5.657s4.0948626 1.5621374 5.657 0l8.994-8.995 2.024 2.024 1.72 3.06c.3916487.6060722 1.0333314 1.0057488 1.75 1.09.075.007.148.011.221.011.5200982.0048404 1.0206859-.1977698 1.391-.563l7-7c.4183498-.4257287.6210036-1.0182429.551-1.611-.0897228-.7420718-.5131648-1.4026412-1.15-1.794zm-7.854 1.944-2.829 2.829-8.485-8.486 5.657-5.657 8.485 8.485zm-15.521-8.517 6.962-6.977h.016c.1026077.00780363.1972609.05821279.261.139l1.382 2.455-6 6-2.405-1.347c-.0953018-.06859-.1700029-.1619663-.216-.27zm-.544 18.93c-.78120678.7812068-2.04779322.7812068-2.829 0s-.78120678-2.0477932 0-2.829l8.994-9 2.829 2.829zm16.138-3.4c-.1087959-.0003098-.2112238-.0513389-.277-.138l-1.382-2.461 3-3 3-3 2.4 1.347c.0961043.0701944.171711.164789.219.274z"/><path id="Shape" d="m48.856 33.2.944-.754c.5455625-.4370997.8233078-1.1273333.7325503-1.8204839-.0907576-.6931505-.5368448-1.2886093-1.1765503-1.5705161l-10.548-4.655c-.7085074-.3119903-1.5334352-.1870729-2.117808.3206959s-.8232231 1.3071815-.613192 2.0523041l3.014 10.677c.1820062.6452435.6751983 1.1563752 1.3135301 1.3613091s1.3368838.0764068 1.8604699-.3423091l1.888-1.511 3.856 4.365c.3650003.4143684.8850796.6593883 1.437.677h.061c.53054-.0008328 1.039212-.2114913 1.415-.586l1.415-1.414c.7421565-.7465364.7810138-1.9397599.089-2.733zm.652 6.8-4.486-5.079c-.3530164-.3996609-.9575275-.4520167-1.374-.119l-2.632 2.106-3.016-10.677 10.549 4.65-1.759 1.407c-.213281.1704492-.3475964.4206916-.3717699.6926427-.0241734.271951.0638974.5419611.2437699.7473573l4.259 4.858z"/><path id="Shape" d="m39 21c.5522847 0 1-.4477153 1-1v-3c0-.5522847-.4477153-1-1-1s-1 .4477153-1 1v3c0 .5522847.4477153 1 1 1z"/><path id="Shape" d="m43.707 22.707 2.5-2.5c.3789722-.3923789.3735524-1.0160848-.0121814-1.4018186s-1.0094397-.3911536-1.4018186-.0121814l-2.5 2.5c-.2599566.2510745-.3642126.6228779-.2726972.9725073.0915155.3496295.3645604.6226744.7141899.7141899.3496294.0915154.7214328-.0127406.9725073-.2726972z"/><path id="Shape" d="m30 7h2c.5522847 0 1-.44771525 1-1s-.4477153-1-1-1h-2c-.5522847 0-1 .44771525-1 1s.4477153 1 1 1z"/><path id="Shape" d="m54 5h-18c-.5522847 0-1 .44771525-1 1s.4477153 1 1 1h18c.5522847 0 1-.44771525 1-1s-.4477153-1-1-1z"/><path id="Shape" d="m32 41h-4c-.5522847 0-1 .4477153-1 1s.4477153 1 1 1h4c.5522847 0 1-.4477153 1-1s-.4477153-1-1-1z"/></g></g></svg>',
		docs : '<svg  {settings} xmlns="http://www.w3.org/2000/svg"><path d="m474.386719 103.496094c-.042969-.699219-.179688-1.394532-.410157-2.054688-.085937-.257812-.152343-.503906-.261718-.753906-.390625-.871094-.933594-1.664062-1.601563-2.34375l-96-96c-.679687-.671875-1.476562-1.214844-2.351562-1.601562-.238281-.109376-.480469-.175782-.726563-.261719-.679687-.234375-1.382812-.375-2.097656-.417969-.136719.0273438-.28125-.0625-.449219-.0625h-240c-22.078125.0273438-39.972656 17.917969-40 40v58.878906c-54.996093 24.253906-90.488281 78.691406-90.488281 138.800782 0 60.109374 35.492188 114.546874 90.488281 138.800781v63.519531c.027344 22.082031 17.921875 39.972656 40 40h304c22.082031-.027344 39.976563-17.917969 40-40v-336c0-.175781-.085937-.328125-.101562-.503906zm-27.210938-7.496094h-60.6875c-4.417969 0-8-3.582031-8-8v-60.6875zm-431.007812 141.679688c-.046875-36.085938 14.265625-70.703126 39.78125-96.21875 25.515625-25.515626 60.136719-39.828126 96.21875-39.78125 4.546875 0 9.058593.222656 13.511719.65625 61.859374 6.113281 111.644531 53.496093 120.808593 114.976562 1.0625 6.738281 1.621094 13.546875 1.671875 20.367188.058594 25.621093-7.183594 50.726562-20.871094 72.382812-10.855468 17.304688-25.484374 31.929688-42.792968 42.777344-41.910156 26.320312-94.808594 27.796875-138.121094 3.851562-43.3125-23.941406-70.199219-69.523437-70.207031-119.011718zm228.914062 120.175781c1.09375-.847657 2.175781-1.6875 3.246094-2.558594 3.949219-3.179687 7.730469-6.558594 11.335937-10.121094 3.5625-3.605469 6.941407-7.382812 10.121094-11.328125.871094-1.070312 1.710938-2.160156 2.558594-3.253906.96875-1.265625 2.019531-2.464844 2.945312-3.753906l68.199219 68.28125c4.515625 4.472656 7.058594 10.566406 7.058594 16.921875 0 6.359375-2.542969 12.449219-7.058594 16.925781-9.445312 9.128906-24.425781 9.128906-33.871093 0l-68.289063-68.167969c1.289063-.9375 2.496094-1.976562 3.753906-2.945312zm189.40625 106.144531h-304c-13.253906 0-24-10.746094-24-24v-57.273438c.496094.160157 1.015625.265626 1.519531.417969 1.28125.390625 2.578126.703125 3.875 1.0625 2.992188.800781 6.007813 1.601563 9.054688 2.199219 1.496094.3125 2.992188.601562 4.503906.867188 3.046875.535156 6.121094.957031 9.207032 1.3125 1.378906.15625 2.738281.351562 4.121093.46875 4.433594.378906 8.894531.625 13.398438.625 26.445312.019531 52.429687-6.902344 75.355469-20.078126l70.734374 70.664063c9.925782 10.863281 25.019532 15.402344 39.289063 11.808594 14.273437-3.589844 25.421875-14.726563 29.023437-28.996094 3.605469-14.269531-.917968-29.367187-11.777343-39.300781l-70.703125-70.746094c13.175781-22.925781 20.101562-48.910156 20.078125-75.351562 0-5.066407-.242188-10.09375-.734375-15.078126-3.414063-34.953124-18.886719-67.625-43.761719-92.410156-28.449219-28.601562-67.160156-44.628906-107.503906-44.511718-4.503907 0-8.964844.25-13.398438.625-1.382812.121093-2.753906.3125-4.128906.472656-3.078125.34375-6.136719.78125-9.183594 1.3125-1.519531.265625-3.035156.554687-4.542969.871094-3.007812.625-5.992187 1.359374-8.953124 2.175781-1.328126.359375-2.65625.679687-4 1.078125-.496094.152344-1 .257812-1.496094.417968v-52.632812c0-13.253906 10.746094-24 24-24h232.023437v72c0 13.253906 10.746094 24 24 24h72v328c0 13.253906-10.742187 24-24 24zm0 0"/><path d="m330.488281 56c0-4.417969-3.582031-8-8-8h-176c-4.417969 0-8 3.582031-8 8s3.582031 8 8 8h176c4.417969 0 8-3.582031 8-8zm0 0"/><path d="m418.488281 192h-96c-4.417969 0-8 3.582031-8 8s3.582031 8 8 8h96c4.417969 0 8-3.582031 8-8s-3.582031-8-8-8zm0 0"/><path d="m418.488281 240h-96c-4.417969 0-8 3.582031-8 8s3.582031 8 8 8h96c4.417969 0 8-3.582031 8-8s-3.582031-8-8-8zm0 0"/><path d="m426.488281 296c0-4.417969-3.582031-8-8-8h-104c-4.417969 0-8 3.582031-8 8s3.582031 8 8 8h104c4.417969 0 8-3.582031 8-8zm0 0"/><path d="m426.488281 344c0-4.417969-3.582031-8-8-8h-72c-4.417969 0-8 3.582031-8 8s3.582031 8 8 8h72c4.417969 0 8-3.582031 8-8zm0 0"/><path d="m330.488281 104c0-4.417969-3.582031-8-8-8h-64c-4.417969 0-8 3.582031-8 8s3.582031 8 8 8h64c4.417969 0 8-3.582031 8-8zm0 0"/><path d="m426.488281 152c0-4.417969-3.582031-8-8-8h-120c-4.417969 0-8 3.582031-8 8s3.582031 8 8 8h120c4.417969 0 8-3.582031 8-8zm0 0"/><path d="m122.488281 200h56c4.417969 0 8-3.582031 8-8s-3.582031-8-8-8h-56c-4.417969 0-8 3.582031-8 8s3.582031 8 8 8zm0 0"/><path d="m218.488281 240c0-4.417969-3.582031-8-8-8h-120c-4.417969 0-8 3.582031-8 8s3.582031 8 8 8h120c4.417969 0 8-3.582031 8-8zm0 0"/><path d="m178.488281 280h-56c-4.417969 0-8 3.582031-8 8s3.582031 8 8 8h56c4.417969 0 8-3.582031 8-8s-3.582031-8-8-8zm0 0"/><path d="m209.113281 343.199219c19.511719-10.390625 35.691407-26.085938 46.671875-45.269531.632813-1.105469 1.320313-2.175782 1.914063-3.296876.308593-.578124.550781-1.175781.847656-1.753906 1.214844-2.335937 2.398437-4.671875 3.445313-7.0625 1.050781-2.390625 1.875-4.664062 2.730468-7.015625.246094-.679687.558594-1.34375.800782-2.03125 20.34375-59.160156-8.171876-124.027343-65.515626-149.03125-57.347656-25.003906-124.28125-1.753906-153.78125 53.414063-9.285156 17.378906-14.121093 36.789062-14.074218 56.496094-.074219 42.28125 22.132812 81.472656 58.441406 103.136718 36.308594 21.667969 81.34375 22.601563 118.519531 2.460938zm-106.800781-14.253907c-8.707031-4.746093-16.683594-10.722656-23.6875-17.746093-4.859375-4.855469-9.230469-10.171875-13.054688-15.878907-1.890624-2.828124-3.628906-5.730468-5.226562-8.710937-24.078125-45.464844-11.320312-101.703125 30.019531-132.324219 41.339844-30.621094 98.855469-26.433594 135.328125 9.851563 32.300782 32.605469 39.566406 82.464843 17.917969 122.933593v.066407c-9.539063 17.847656-24.164063 32.460937-42.015625 41.992187-30.96875 16.824219-68.363281 16.765625-99.28125-.152344zm0 0"/><path d="m434.488281 384c-4.417969 0-8 3.582031-8 8v32c0 4.417969-3.582031 8-8 8h-32c-4.417969 0-8 3.582031-8 8s3.582031 8 8 8h32c13.257813 0 24-10.746094 24-24v-32c0-4.417969-3.582031-8-8-8zm0 0"/></svg>',
		money_map : '<svg  {settings} xmlns="http://www.w3.org/2000/svg" ><path d="M39.89,50.567C46.42,43.571,55,32.882,55,25A23,23,0,0,0,9,25c0,7.882,8.58,18.571,15.11,25.567C20.314,51.151,14,52.628,14,56c0,3.939,9.055,6,18,6s18-2.061,18-6C50,52.628,43.686,51.151,39.89,50.567ZM32,4A21.024,21.024,0,0,1,53,25c0,10.4-17.343,27.209-21,30.637C28.343,52.209,11,35.4,11,25A21.024,21.024,0,0,1,32,4Zm0,56c-10.5,0-16-2.6-16-4,0-1.023,3.128-2.856,9.808-3.646,2.98,3.08,5.239,5.133,5.522,5.389a1,1,0,0,0,1.34,0c.283-.256,2.542-2.309,5.522-5.389C44.872,53.144,48,54.977,48,56,48,57.4,42.505,60,32,60Z"/><path d="M33,37H30a1,1,0,0,1-1-1V34.2A6.025,6.025,0,0,1,26,29a1,1,0,0,1,1-1h3a1,1,0,0,1,1,1,1,1,0,1,0,1-1,6,6,0,0,1-2-11.659V15a1,1,0,0,1,1-1h3a1,1,0,0,1,1,1v1.8A6.025,6.025,0,0,1,38,22a1,1,0,0,1-1,1H34a1,1,0,0,1-1-1,1,1,0,1,0-1,1,6.033,6.033,0,0,1,4.287,1.793l.008.008A6.01,6.01,0,0,1,34,34.659V36A1,1,0,0,1,33,37Zm-2-2h1V33.9a1,1,0,0,1,.8-.981A4.008,4.008,0,0,0,34.869,26.2,4.045,4.045,0,0,0,32,25a3,3,0,1,1,2.829-4h1.043A4.046,4.046,0,0,0,33.6,18.324,1,1,0,0,1,33,17.41V16H32v1.1a1,1,0,0,1-.8.981A4,4,0,0,0,32,26a3,3,0,1,1-2.829,4H28.128a4.046,4.046,0,0,0,2.277,2.676A1,1,0,0,1,31,33.59Z"/><path d="M32,41A16,16,0,1,1,48,25,16.019,16.019,0,0,1,32,41Zm0-30A14,14,0,1,0,46,25,14.015,14.015,0,0,0,32,11Z"/></svg>',
		anon_bot : '<svg  {settings} xmlns="http://www.w3.org/2000/svg"><path d="m434.983 78h-238.954a45.847 45.847 0 0 0 -46.029 45.729v13.271h-72.983a46.268 46.268 0 0 0 -46.017 46.235v245.036a6.014 6.014 0 0 0 6.011 6 6.069 6.069 0 0 0 3.5-1.184l74.007-53.087h201.453a45.975 45.975 0 0 0 46.029-45.88v-13.12h35.482l74.006 52.835a5.9 5.9 0 0 0 3.5 1.026 6.137 6.137 0 0 0 6.016-6.1v-245.032a45.836 45.836 0 0 0 -46.021-45.729zm-84.983 256.12a33.961 33.961 0 0 1 -34.029 33.88h-203.381a6.092 6.092 0 0 0 -3.5 1.183l-66.09 47.407v-233.355a34.254 34.254 0 0 1 34.017-34.235h72.983v125.613c0 25.365 20.665 46.387 46.029 46.387h153.971zm119 22.964-66.086-47.154a5.858 5.858 0 0 0 -3.5-.93h-203.385c-18.748 0-34.029-15.639-34.029-34.387v-150.884a33.832 33.832 0 0 1 34.029-33.729h238.954a33.822 33.822 0 0 1 34.017 33.729z"/><path d="m379.6 153.494-1.8-33.086a17.252 17.252 0 0 0 -21.316-15.82l-19.572 4.778a50.418 50.418 0 0 1 -23.835 0l-19.571-4.778a17.252 17.252 0 0 0 -21.316 15.82l-1.79 32.9c-29.445 6.543-46.277 18.008-46.277 31.624 0 24.215 52.03 37.281 100.986 37.281 25.9 0 50.357-3.34 68.856-9.4 26.367-8.643 31.9-19.806 31.9-27.65.007-13.663-16.803-25.126-46.265-31.669zm-93.313-36.363a5.164 5.164 0 0 1 4.374-.885l19.57 4.778a62.541 62.541 0 0 0 29.529 0l19.571-4.778a5.25 5.25 0 0 1 6.487 4.815l2.666 48.939-10.184 3.168a107.2 107.2 0 0 1 -66.663-.019l-10.121-3.149 2.662-48.935a5.175 5.175 0 0 1 2.113-3.934zm38.823 93.08c-24.635 0-47.8-3.167-65.22-8.917-17.542-5.788-23.766-12.433-23.766-16.364 0-5.63 11.52-13.725 33.6-19.142l-.448 8.221a6 6 0 0 0 4.207 6.054l14.507 4.519a118.875 118.875 0 0 0 36.932 5.9 120.268 120.268 0 0 0 37-5.874l14.584-4.543a6 6 0 0 0 4.207-6.054l-.438-8.037c23.019 5.6 33.589 13.661 33.589 19.186.008 10.213-34.564 25.051-88.75 25.051z"/><path d="m362.343 222.711a35.468 35.468 0 0 0 -24.761 10.058c-8.61-5.434-16.321-5.473-24.918-.123a35.563 35.563 0 1 0 7.155 9.667c3.808-2.17 6.82-2.128 10.663.143a35.59 35.59 0 1 0 31.861-19.745zm-74.311 59.2a23.6 23.6 0 1 1 23.6-23.6 23.625 23.625 0 0 1 -23.6 23.597zm74.311 0a23.6 23.6 0 1 1 23.6-23.6 23.625 23.625 0 0 1 -23.6 23.597z"/></svg>',
		msg_telegram: '<svg  {settings} xmlns="http://www.w3.org/2000/svg"><path d="M437.019,74.981C388.667,26.628,324.379,0,256,0S123.333,26.628,74.981,74.981C26.628,123.333,0,187.621,0,256 s26.628,132.667,74.981,181.019C123.333,485.372,187.621,512,256,512s132.667-26.628,181.019-74.981S512,324.379,512,256 S485.372,123.333,437.019,74.981z M256,495.832C123.756,495.832,16.168,388.244,16.168,256S123.756,16.168,256,16.168 S495.832,123.756,495.832,256S388.244,495.832,256,495.832z"/><path d="M400.989,98.637c-2.482-1.87-5.817-2.15-8.577-0.722L79.822,259.599c-2.702,1.397-4.391,4.194-4.371,7.236 c0.02,3.042,1.747,5.815,4.469,7.176l81.764,40.88v81.006c0,2.12,0.721,4.218,2.18,5.757c1.614,1.703,3.759,2.557,5.905,2.557 c1.352,0,2.704-0.338,3.927-1.018l93.544-51.969l71.597,30.684c1.523,0.653,3.209,0.923,4.839,0.619 c3.355-0.627,5.849-3.197,6.485-6.372l18.115-90.577c1-5.003-2.826-9.67-7.928-9.67c-3.854-0.002-7.171,2.718-7.927,6.496 l-16.162,80.808l-66.295-28.412c-2.297-0.985-4.923-0.85-7.111,0.363l-85,47.223v-72.492c0-3.062-1.73-5.86-4.469-7.231 l-72.015-36.007l283.53-146.654l-24.605,123.023c-1,5.003,2.826,9.67,7.928,9.67c3.853,0,7.171-2.721,7.928-6.499l27.903-139.517 C404.662,103.633,403.471,100.506,400.989,98.637z"/><path d="M348.576,164.757c-2.541-3.216-7.089-4.024-10.581-1.873l-140.126,86.232c-2.391,1.471-3.847,4.078-3.847,6.885v86.232 c-0.001,3.75,2.577,7.006,6.225,7.868c0.621,0.147,1.244,0.218,1.86,0.218c3.007,0,5.837-1.686,7.228-4.47l31.75-63.5 l106.863-106.863C350.847,172.586,351.117,167.975,348.576,164.757z M228.725,271.842c-0.613,0.614-1.125,1.324-1.513,2.101 l-17.022,34.043v-47.468l77.636-47.777L228.725,271.842z"/></svg>',
		msg_facebook : '<svg  {settings} xmlns="http://www.w3.org/2000/svg"><g><path d="m437.02 74.98c-48.353-48.351-112.64-74.98-181.02-74.98s-132.667 26.629-181.02 74.98c-48.351 48.353-74.98 112.64-74.98 181.02s26.629 132.667 74.98 181.02c48.353 48.351 112.64 74.98 181.02 74.98s132.667-26.629 181.02-74.98c48.351-48.353 74.98-112.64 74.98-181.02s-26.629-132.667-74.98-181.02zm-10.607 351.433c-34.091 34.091-76.596 56.708-122.832 65.917v-164.701h34.338c7.133 0 13.323-4.833 15.053-11.753l12.025-48.097c1.167-4.668.137-9.52-2.824-13.312s-7.418-5.967-12.229-5.967h-53.862c-4.142 0-7.5 3.358-7.5 7.5s3.358 7.5 7.5 7.5h53.862c.075 0 .251 0 .407.199.155.198.112.37.094.443l-12.024 48.097c-.058.23-.264.391-.501.391h-41.838c-4.142 0-7.5 3.358-7.5 7.5v174.684c-10.714 1.437-21.59 2.186-32.582 2.186-64.374 0-124.894-25.068-170.413-70.587s-70.587-106.039-70.587-170.413 25.068-124.894 70.587-170.413 106.039-70.587 170.413-70.587 124.894 25.068 170.413 70.587 70.587 106.039 70.587 170.413-25.068 124.894-70.587 170.413z"/><path d="m352.193 96.193h-48.097c-52.757 0-95.677 42.921-95.677 95.678v56.629h-48.613c-8.556 0-15.516 6.96-15.516 15.516v48.097c0 8.556 6.96 15.516 15.516 15.516h48.613v136.791c0 4.142 3.358 7.5 7.5 7.5s7.5-3.358 7.5-7.5v-144.291c0-4.142-3.358-7.5-7.5-7.5h-56.113c-.285 0-.516-.231-.516-.516v-48.097c0-.285.231-.516.516-.516h56.113c4.142 0 7.5-3.358 7.5-7.5v-64.129c0-44.486 36.192-80.678 80.677-80.678h48.097c.285 0 .516.231.516.516v48.097c0 .285-.231.516-.516.516h-32.064c-17.396 0-31.548 14.152-31.548 31.548v32.064c0 4.142 3.358 7.5 7.5 7.5s7.5-3.358 7.5-7.5v-32.064c0-9.125 7.423-16.548 16.548-16.548h32.064c8.556 0 15.516-6.96 15.516-15.516v-48.097c0-8.555-6.96-15.516-15.516-15.516z"/></g></svg>',
		votes : '<svg  {settings} xmlns="http://www.w3.org/2000/svg"><g><path d="m8.306 333.042h43.444c1.436 0 2.842-.413 4.051-1.188l27.587-17.706c3.486-2.237 4.499-6.877 2.261-10.363s-6.877-4.497-10.363-2.261l-25.736 16.518h-41.244c-4.142 0-7.5 3.358-7.5 7.5s3.358 7.5 7.5 7.5z"/><path d="m249.495 340.195c0-14.756-12.005-26.761-26.761-26.761h-14.987v-5.6c0-18.834-14.488-34.34-32.903-35.979v-78.677c11.979-3.258 23.266-8.78 33.395-16.452 3.302-2.501 3.951-7.205 1.45-10.507-2.5-3.301-7.205-3.952-10.507-1.45-14.563 11.03-31.939 16.86-50.251 16.86-45.94 0-83.315-37.375-83.315-83.315s37.375-83.315 83.315-83.315 83.315 37.375 83.315 83.315c0 15.943-4.516 31.436-13.061 44.804-2.231 3.49-1.21 8.128 2.28 10.358 3.491 2.23 8.128 1.209 10.358-2.28 10.089-15.785 15.422-34.071 15.422-52.882-.001-54.21-44.105-98.314-98.316-98.314s-98.315 44.104-98.315 98.315c0 44.906 30.263 82.876 71.464 94.588v80.852c-4.353 1.302-8.526 3.21-12.399 5.696l-7.384 4.739c-3.486 2.237-4.499 6.877-2.261 10.363 2.238 3.488 6.879 4.499 10.363 2.261l7.384-4.739c5.476-3.514 11.808-5.372 18.313-5.372h35.522c11.651 0 21.13 9.479 21.13 21.13v70.041c0 6.866-5.586 12.453-12.452 12.453s-12.452-5.586-12.452-12.453v-29.453c0-3.516-2.442-6.56-5.875-7.322-3.433-.764-6.934.963-8.421 4.149-8.504 18.215-27.625 28.833-47.583 26.417l-11.825-1.43c-4.113-.501-7.849 2.434-8.346 6.545s2.433 7.849 6.545 8.346l11.825 1.43c6.085.735 12.107.535 17.916-.472v75.063h-31.097c-6.079 0-12.109-1.545-17.44-4.467l-35.966-19.718c-1.105-.606-2.345-.923-3.605-.923h-25.664c-4.142 0-7.5 3.358-7.5 7.5s3.358 7.5 7.5 7.5h23.742l34.282 18.795c7.534 4.13 16.059 6.314 24.651 6.314h31.098v28.44c0 4.142 3.358 7.5 7.5 7.5s7.5-3.358 7.5-7.5v-123.138c5.743-2.627 11.068-6.123 15.764-10.401v6.826c0 7.353 2.917 14.029 7.642 18.961-5.794 4.912-9.486 12.23-9.486 20.403 0 7.559 3.16 14.385 8.218 19.255-5.06 4.871-8.218 11.705-8.218 19.267 0 7.871 3.417 14.958 8.845 19.859v28.969c0 4.142 3.358 7.5 7.5 7.5s7.5-3.358 7.5-7.5v-22.229c.958.104 1.931.162 2.917.162h33c14.756 0 26.761-12.005 26.761-26.761 0-6.542-2.367-12.536-6.281-17.189 6.456-4.888 10.638-12.629 10.638-21.333 0-6.334-2.221-12.153-5.914-16.741 6.801-4.855 11.245-12.806 11.245-21.781 0-7.013-2.715-13.401-7.144-18.177 5.758-4.91 9.429-12.2 9.429-20.345zm-112.417-68.491v-75.79c3.886.469 7.84.716 11.851.716 3.674 0 7.314-.215 10.914-.609v75.683zm40.682 133.774h37.357c6.485 0 11.761 5.276 11.761 11.761s-5.276 11.761-11.761 11.761h-37.357c-6.485 0-11.761-5.276-11.761-11.761-.001-6.485 5.275-11.761 11.761-11.761zm32.999 62.044h-33c-6.485 0-11.761-5.276-11.761-11.761s5.276-11.761 11.761-11.761h33c6.485 0 11.761 5.276 11.761 11.761s-5.276 11.761-11.761 11.761zm9.688-77.044h-15.781c1.965-3.776 3.08-8.06 3.08-12.603v-10.919h12.701c6.485 0 11.761 5.276 11.761 11.761s-5.276 11.761-11.761 11.761zm2.287-38.522h-14.987v-23.522h14.987c6.485 0 11.761 5.276 11.761 11.761s-5.276 11.761-11.761 11.761z"/><path d="m503.783 436.041h-24.663c-1.26 0-2.5.317-3.605.923l-35.966 19.718c-5.331 2.922-11.361 4.467-17.44 4.467h-31.098v-75.062c5.81 1.007 11.832 1.207 17.916.47l11.825-1.43c4.112-.498 7.042-4.234 6.545-8.346-.498-4.112-4.23-7.042-8.346-6.545l-11.825 1.43c-19.96 2.41-39.079-8.203-47.583-26.417-1.488-3.186-4.988-4.91-8.421-4.149-3.433.762-5.875 3.806-5.875 7.322v29.453c0 6.866-5.586 12.453-12.452 12.453s-12.452-5.586-12.452-12.453v-70.041c0-11.651 9.479-21.13 21.13-21.13h35.522c6.505 0 12.838 1.857 18.313 5.372l61.98 39.778c1.208.775 2.615 1.188 4.051 1.188h42.444c4.142 0 7.5-3.358 7.5-7.5s-3.358-7.5-7.5-7.5h-40.244l-60.128-38.59c-3.874-2.486-8.047-4.394-12.4-5.696v-20.852c41.202-11.712 71.464-49.682 71.464-94.588 0-19.004-5.437-37.451-15.724-53.347-2.25-3.477-6.893-4.471-10.371-2.222-3.478 2.25-4.472 6.894-2.222 10.371 8.711 13.462 13.316 29.091 13.316 45.197 0 45.94-37.375 83.315-83.315 83.315s-83.315-37.375-83.315-83.315 37.375-83.315 83.315-83.315c18.196 0 35.48 5.76 49.987 16.657 3.311 2.487 8.013 1.819 10.501-1.492 2.488-3.312 1.82-8.014-1.492-10.501-17.124-12.865-37.524-19.664-58.995-19.664-54.211 0-98.315 44.104-98.315 98.315 0 45.245 30.724 83.442 72.401 94.843v18.698c-18.415 1.639-32.903 17.145-32.903 35.979v5.6h-14.987c-14.756 0-26.761 12.005-26.761 26.761 0 8.147 3.672 15.44 9.434 20.35-4.429 4.776-7.147 11.16-7.147 18.172 0 8.972 4.441 16.921 11.238 21.778-3.691 4.588-5.907 10.411-5.907 16.744 0 8.709 4.187 16.451 10.649 21.339-3.915 4.652-6.291 10.64-6.291 17.183 0 14.756 12.005 26.761 26.761 26.761h33c.986 0 1.958-.058 2.917-.162v22.229c0 4.142 3.358 7.5 7.5 7.5s7.5-3.358 7.5-7.5v-28.969c5.427-4.901 8.845-11.988 8.845-19.859 0-7.559-3.161-14.385-8.218-19.257 5.06-4.871 8.218-11.704 8.218-19.265 0-8.169-3.683-15.49-9.471-20.403 4.721-4.931 7.628-11.612 7.628-18.961v-6.825c4.695 4.276 10.021 7.773 15.764 10.4v123.139c0 4.142 3.358 7.5 7.5 7.5s7.5-3.358 7.5-7.5v-28.44h31.098c8.592 0 17.117-2.184 24.651-6.314l34.282-18.795h22.742c4.142 0 7.5-3.358 7.5-7.5s-3.362-7.5-7.505-7.5zm-139.623-179.411c4.011 0 7.965-.247 11.851-.716v15.79h-22.765v-15.683c3.585.398 7.225.609 10.914.609zm-28.83 172.37h-37.357c-6.485 0-11.761-5.276-11.761-11.761s5.276-11.761 11.761-11.761h37.357c6.485 0 11.761 5.276 11.761 11.761s-5.276 11.761-11.761 11.761zm-42.688-38.522c-6.485 0-11.761-5.276-11.761-11.761s5.276-11.761 11.761-11.761h12.701v10.919c0 4.543 1.118 8.826 3.08 12.603h-10.451zm-2.286-62.044h14.987v23.522h-14.987c-6.485 0-11.761-5.276-11.761-11.761-.001-6.485 5.275-11.761 11.761-11.761zm11.974 139.088c-6.485 0-11.761-5.276-11.761-11.761s5.276-11.761 11.761-11.761h33c6.485 0 11.761 5.276 11.761 11.761s-5.276 11.761-11.761 11.761z"/><path d="m309.401 196.225 16.85 16.85c5.133 5.132 13.485 5.132 18.617 0l19.293-19.293 19.293 19.293c2.566 2.566 5.938 3.85 9.309 3.85s6.742-1.283 9.308-3.85l16.85-16.85c5.133-5.133 5.133-13.484 0-18.617l-19.293-19.293 19.294-19.293c5.132-5.133 5.132-13.484 0-18.617l-16.849-16.849c-2.486-2.487-5.792-3.856-9.309-3.856s-6.823 1.37-9.309 3.856l-19.293 19.293-19.292-19.292c-2.486-2.487-5.792-3.856-9.309-3.856-3.516 0-6.822 1.369-9.309 3.856l-16.849 16.849c-5.132 5.132-5.133 13.483 0 18.617l19.293 19.293-19.293 19.293c-5.135 5.132-5.135 13.483-.002 18.616zm35.202-32.607c2.929-2.929 2.929-7.678 0-10.606l-23.298-23.298 14.253-14.253 23.298 23.298c2.928 2.929 7.677 2.929 10.606 0l23.299-23.298 14.253 14.253-23.299 23.298c-1.407 1.406-2.197 3.314-2.197 5.303s.79 3.897 2.197 5.303l23.298 23.298-14.253 14.253-23.298-23.298c-1.406-1.407-3.314-2.197-5.303-2.197s-3.897.79-5.303 2.197l-23.298 23.299-14.253-14.253z"/><path d="m185.826 45.087c-2.786-.033-5.475 1.048-7.474 3.04l-47.381 47.207-8.153-10.27c-2.956-3.721-8.427-4.396-12.192-1.501l-24.979 19.169c-1.846 1.417-3.07 3.554-3.358 5.863s.372 4.682 1.813 6.509l25.327 32.13c.539.69 1.133 1.364 1.817 2.062 1.41 1.438 3.34 2.249 5.355 2.249h24.279c1.984 0 3.888-.787 5.293-2.187l66.397-66.153c3.999-3.983 4.071-10.536.162-14.608l-19.501-20.305c-1.954-2.036-4.584-3.174-7.405-3.205zm-48.045 91.457h-17.679l-20.307-25.762 15.094-11.583 9.555 12.036c1.328 1.672 3.306 2.7 5.438 2.824 2.135.123 4.216-.667 5.729-2.174l50.028-49.844 13.163 13.706z"/></g></svg>',
		office : '<svg viewBox="0 0 64 64" {settings} xmlns="http://www.w3.org/2000/svg"><g><path d="m12 37h-4c-.553 0-1 .447-1 1v4c0 .553.447 1 1 1h4c.553 0 1-.447 1-1v-4c0-.553-.447-1-1-1zm-1 4h-2v-2h2z"/><path d="m12 45h-4c-.553 0-1 .447-1 1v4c0 .553.447 1 1 1h4c.553 0 1-.447 1-1v-4c0-.553-.447-1-1-1zm-1 4h-2v-2h2z"/><path d="m12 53h-4c-.553 0-1 .447-1 1v4c0 .553.447 1 1 1h4c.553 0 1-.447 1-1v-4c0-.553-.447-1-1-1zm-1 4h-2v-2h2z"/><path d="m56 37h-4c-.553 0-1 .447-1 1v4c0 .553.447 1 1 1h4c.553 0 1-.447 1-1v-4c0-.553-.447-1-1-1zm-1 4h-2v-2h2z"/><path d="m12 29h-4c-.553 0-1 .447-1 1v4c0 .553.447 1 1 1h4c.553 0 1-.447 1-1v-4c0-.553-.447-1-1-1zm-1 4h-2v-2h2z"/><path d="m56 29h-4c-.553 0-1 .447-1 1v4c0 .553.447 1 1 1h4c.553 0 1-.447 1-1v-4c0-.553-.447-1-1-1zm-1 4h-2v-2h2z"/><path d="m56 45h-4c-.553 0-1 .447-1 1v4c0 .553.447 1 1 1h4c.553 0 1-.447 1-1v-4c0-.553-.447-1-1-1zm-1 4h-2v-2h2z"/><path d="m42 45h-4c-.553 0-1 .447-1 1v4c0 .553.447 1 1 1h4c.553 0 1-.447 1-1v-4c0-.553-.447-1-1-1zm-1 4h-2v-2h2z"/><path d="m34 45h-4c-.553 0-1 .447-1 1v4c0 .553.447 1 1 1h4c.553 0 1-.447 1-1v-4c0-.553-.447-1-1-1zm-1 4h-2v-2h2z"/><path d="m26 45h-4c-.553 0-1 .447-1 1v4c0 .553.447 1 1 1h4c.553 0 1-.447 1-1v-4c0-.553-.447-1-1-1zm-1 4h-2v-2h2z"/><path d="m43 30c0-.553-.447-1-1-1h-4c-.553 0-1 .447-1 1v4c0 .553.447 1 1 1h4c.553 0 1-.447 1-1zm-2 3h-2v-2h2z"/><path d="m35 30c0-.553-.447-1-1-1h-4c-.553 0-1 .447-1 1v4c0 .553.447 1 1 1h4c.553 0 1-.447 1-1zm-2 3h-2v-2h2z"/><path d="m27 30c0-.553-.447-1-1-1h-4c-.553 0-1 .447-1 1v4c0 .553.447 1 1 1h4c.553 0 1-.447 1-1zm-2 3h-2v-2h2z"/><path d="m43 38c0-.553-.447-1-1-1h-4c-.553 0-1 .447-1 1v4c0 .553.447 1 1 1h4c.553 0 1-.447 1-1zm-2 3h-2v-2h2z"/><path d="m35 38c0-.553-.447-1-1-1h-4c-.553 0-1 .447-1 1v4c0 .553.447 1 1 1h4c.553 0 1-.447 1-1zm-2 3h-2v-2h2z"/><path d="m27 38c0-.553-.447-1-1-1h-4c-.553 0-1 .447-1 1v4c0 .553.447 1 1 1h4c.553 0 1-.447 1-1zm-2 3h-2v-2h2z"/><path d="m56 53h-4c-.553 0-1 .447-1 1v4c0 .553.447 1 1 1h4c.553 0 1-.447 1-1v-4c0-.553-.447-1-1-1zm-1 4h-2v-2h2z"/><path d="m61 61v-35c0-.553-.447-1-1-1h-1v-3c0-.553-.447-1-1-1h-11v-3c0-.553-.447-1-1-1h-4v2h3v42h-8v-7c0-.553-.447-1-1-1h-8c-.553 0-1 .447-1 1v7h-8v-42h3v-2h-4c-.553 0-1 .447-1 1v3h-11c-.553 0-1 .447-1 1v3h-1c-.553 0-1 .447-1 1v35h-2v2h62v-2zm-4-38v2h-10v-2zm-10 4h12v34h-12zm-18 28h6v6h-6zm-22-32h10v2h-10zm-2 4h12v34h-12z"/><path d="m29.138 20.575 1.914 5.741c.136.409.517.684.948.684s.812-.275.948-.684l1.914-5.741c4.231-1.257 7.138-5.116 7.138-9.575 0-5.514-4.486-10-10-10s-10 4.486-10 10c0 4.459 2.907 8.318 7.138 9.575zm2.862-17.575c4.411 0 8 3.589 8 8 0 3.719-2.527 6.916-6.147 7.775-.336.08-.607.328-.717.656l-1.136 3.407-1.136-3.406c-.109-.328-.381-.576-.717-.656-3.62-.86-6.147-4.057-6.147-7.776 0-4.411 3.589-8 8-8z"/><path d="m32 17c3.309 0 6-2.691 6-6s-2.691-6-6-6-6 2.691-6 6 2.691 6 6 6zm0-10c2.206 0 4 1.794 4 4s-1.794 4-4 4-4-1.794-4-4 1.794-4 4-4z"/></g></svg>',
		request: '<svg viewBox="0 0 512 512" {settings} xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><g id="D_-_25_x2C__chat_x2C__message_x2C__popup_x2C__man_x2C__conversation"><g><polygon points="126.994,302.544 149.92,343.164 163.452,334.819 166.019,333.237 138.13,291.455   "/><path d="M195.454,171.498l-73.91,0.076c-2.558,0-5.021-0.266-7.368-0.756c-0.165,2.506-0.169,5.135-0.169,8.137    c0,31.558,21.114,92.982,59.82,92.982c15.685,0,27.609-10.195,34.849-18.748c16.96-20.033,26.978-52.616,23.853-76.869    l-21.415-11.097C207.324,169.344,201.991,171.498,195.454,171.498z M194.56,241.311c-7.666,5.325-15.253,7.233-22.029,7.233    c-9.847,0-17.981-4.028-22.165-7.458c-2.001-1.641-2.294-4.593-0.653-6.594c1.635-1.996,4.575-2.292,6.577-0.667    c0.635,0.51,15.347,11.998,32.924-0.21c2.126-1.478,5.045-0.95,6.521,1.175C197.212,236.916,196.686,239.835,194.56,241.311z"/><path d="M111.515,160.205c0.326,0.094,0.633,0.217,0.922,0.373c2.722,1.042,5.784,1.625,9.102,1.625l73.91-0.076    c4.984,0,8.13-1.615,10.208-5.235c0.864-1.504,2.441-2.354,4.068-2.354c0.728,0,1.464,0.17,2.152,0.526l20.251,10.494v-15.383    l-27.494-16.693c-0.982-0.596-1.71-1.531-2.047-2.628c-0.143-0.462-0.397-0.966-0.72-1.604l-0.151-0.3l-0.522-0.928    c-3.215-5.732-4.778-7.898-8.471-7.898h-92.527v23.317C100.195,151.061,104.616,157.204,111.515,160.205z"/><path d="M198.748,352.637c-0.171,0.214-0.363,0.403-0.562,0.58c-0.037,0.032-0.073,0.065-0.111,0.098    c-0.197,0.163-0.403,0.309-0.621,0.436c-0.04,0.022-0.08,0.043-0.121,0.064c-0.22,0.12-0.446,0.227-0.68,0.309    c-0.01,0.004-0.02,0.01-0.03,0.013c-0.241,0.084-0.488,0.141-0.738,0.184c-0.049,0.009-0.098,0.019-0.147,0.024    c-0.216,0.03-0.434,0.052-0.652,0.052c-0.024,0-0.05-0.006-0.076-0.006c-0.071-0.001-0.143-0.011-0.215-0.016    c-0.19-0.012-0.379-0.033-0.567-0.068c-0.087-0.016-0.173-0.036-0.259-0.057c-0.181-0.045-0.36-0.102-0.536-0.17    c-0.077-0.028-0.154-0.054-0.229-0.087c-0.247-0.108-0.489-0.233-0.719-0.388l-19.976-13.36l-21.815,13.453    c-0.241,0.148-0.495,0.265-0.754,0.366c-0.073,0.028-0.145,0.055-0.218,0.079c-0.223,0.074-0.45,0.134-0.682,0.174    c-0.046,0.008-0.089,0.021-0.136,0.028c-0.221,0.032-0.445,0.051-0.67,0.051c-0.048,0-0.097-0.008-0.146-0.01    c-0.067-0.002-0.132-0.007-0.198-0.012c-0.276-0.021-0.553-0.057-0.825-0.127c-1.234-0.317-2.285-1.125-2.912-2.234l-25.35-44.914    l-78.335,18.219v94.675h46.855v-51.541c0-2.588,2.098-4.686,4.686-4.686c2.588,0,4.686,2.098,4.686,4.686v51.541h149.935v-51.541    c0-2.588,2.099-4.686,4.686-4.686c2.588,0,4.686,2.098,4.686,4.686v51.541h46.855v-89.133l-68.655-22.538L198.748,352.637z"/><polygon points="194.118,343.423 213.118,319.674 226.294,303.202 214.186,291.094 179.498,333.645   "/><path d="M274.742,92.008v103.081h31.168c2.588,0,4.686,2.098,4.686,4.686v38.196l64.459-42.118    c0.763-0.498,1.653-0.763,2.563-0.763h93.914V92.008H274.742z M382.508,166.976H307.54c-2.588,0-4.685-2.098-4.685-4.686    c0-2.587,2.097-4.686,4.685-4.686h74.968c2.588,0,4.686,2.098,4.686,4.686C387.193,164.878,385.096,166.976,382.508,166.976z     M448.104,129.492H307.54c-2.588,0-4.685-2.098-4.685-4.686c0-2.587,2.097-4.686,4.685-4.686h140.564    c2.589,0,4.686,2.098,4.686,4.686C452.79,127.395,450.693,129.492,448.104,129.492z"/></g></g><g id="Layer_1"/></svg>',
	},
};

var Colors = {
	get : function (i) {
		if (typeof (Colors.items[i]) == u) {
			i = (i % Colors.items.length) - 1;
		}
		return Colors.items[i];
	},
	items : [
		"rgb(54, 162, 235)",			//blue
		"rgb(75, 192, 192)",			//green
		"rgb(255, 159, 64)",			//orange
		"rgb(153, 102, 255)",			//purple
		"rgb(255, 99, 132)",			//red
		"rgb(255, 205, 86)",			//yellow
	]
};

function nf (val, dig) {
	if (typeof(dig) == u) dig = 0;
	return val.toLocaleString('uk-UA', {minimumFractionDigits: dig, maximumFractionDigits:dig}).split(' ').join('&nbsp;');
};

var Listener = {
	start : function () {
		if (IS_MOBILE == 0) {
			setInterval(Listener.makeQuery, 1000);
		}
	},
	makeQuery : function () {
		if (PARTITION == 'quiz' && typeof(_this.pathData.cat) != u) {
			_this.query("quiz.get", {cat: _this.pathData.cat}, function (data) {
				_this.quizUpdate(data);
			});
		}
	}
};

function number_format( number, decimals, dec_point, thousands_sep ) {	// Format a number with grouped thousands
	//
	// +   original by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
	// +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	// +	 bugfix by: Michael White (http://crestidg.com)

	var i, j, kw, kd, km;

	if (typeof(decimals) == u) decimals = 0;

	// input sanitation & defaults
	if( isNaN(decimals = Math.abs(decimals)) ){
		decimals = 2;
	}
	if( dec_point == undefined ){
		dec_point = ",";
	}
	if( thousands_sep == undefined ){
		thousands_sep = " ";
	}

	i = parseInt(number = (+number || 0).toFixed(decimals)) + "";

	if( (j = i.length) > 3 ){
		j = j % 3;
	} else{
		j = 0;
	}

	km = (j ? i.substr(0, j) + thousands_sep : "");
	kw = i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousands_sep);
	//kd = (decimals ? dec_point + Math.abs(number - i).toFixed(decimals).slice(2) : "");
	kd = (decimals ? dec_point + Math.abs(number - i).toFixed(decimals).replace(/-/, 0).slice(2) : "");


	return km + kw + kd;
}


function go (url) {
	document.location.href = url;
	return false;
}


function setCookie(name, value, options = {}) {

	options = {
		path: '/',
		'max-age': 3600,
	};

	if (options.expires instanceof Date) {
		options.expires = options.expires.toUTCString();
	}

	let updatedCookie = encodeURIComponent(name) + "=" + encodeURIComponent(value);

	for (let optionKey in options) {
		updatedCookie += "; " + optionKey;
		let optionValue = options[optionKey];
		if (optionValue !== true) {
			updatedCookie += "=" + optionValue;
		}
	}

	document.cookie = updatedCookie;
}