function setCookie(cname, cvalue, exdays) {
	var d = new Date();
	d.setTime(d.getTime() + (exdays*24*60*60*1000));
	var expires = "expires="+d.toUTCString();
	document.cookie = cname + "=" + cvalue + "; " + expires + ";path=/;domain=.hdfilmek.net;secure;";
}
function getCookie(cname) {
	var name = cname + "=";
	var decodedCookie = decodeURIComponent(document.cookie);
	var ca = decodedCookie.split(';');
	for(var i = 0; i <ca.length; i++) {
		var c = ca[i];
		while (c.charAt(0) == ' ') {
			c = c.substring(1);
		}
		if (c.indexOf(name) == 0) {
			return c.substring(name.length, c.length);
		}
	}
	return "";
}
function checkCookie() {
	var username = getCookie("username");
	if (username != "") {
		console.log("Welcome again " + username);
	} else {
		username = prompt("Please enter your name:", "");
		if (username != "" && username != null) {
			setCookie("username", username, 7200);
		}
	}
}
const bc = new BroadcastChannel("hdfilmeknet");
bc.onmessage = (event) => {
	if (event.data === "Am I the first?") {
		bc.postMessage("No you're not.");
		console.log("A webhelynek egy másik lapja most nyílt meg!");
	}
	if (event.data === "No you're not.") {
		console.log("AntiCheat aktív!");
		setCookie("anticheat", "true", 7200);
	}
};
bc.postMessage("Am I the first?");
window.addEventListener('unload', function() {
	console.log("AntiCheat OFF");
	setCookie("anticheat", "false", 7200);
})
window.addEventListener('onbeforeunload', function() {
	console.log("AntiCheat OFF");
	setCookie("anticheat", "false", 7200);
})

document.onkeydown = function(e) {
	if (e.ctrlKey && 
		(e.keyCode === 85 )) {
		return false;
	}
};
document.onkeydown = function(e) {
	if (e.keyCode === 123) {
		return false;
	}
};
document.onkeydown = function(e) {
	if (e.keyCode === 116) {
		return false;
	}
};

// $("body").on("contextmenu",function(e){
	// return false;
// });

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

// gtag('config', 'G-GJGCRM15MM');

function blink_text() {
    $('.flashtext').fadeOut(500);
    $('.flashtext').fadeIn(500);
}
setInterval(blink_text, 1000);
