var will_be_age_check_shown = 0; // priznak, jestli budu zobrazovat AgeCheck, pokud ano, vypnu TV

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(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;
}
function checkTrue(){
	createCookie("GambrinusAgeCheck","true",1);
	// document.getElementById("age_check").style.display= "none";
	// document.getElementById("age_check_tab").style.display= "none";
	// document.getElementById("age_check_tab").innerHTML= "";
	window.location.reload(); // refresh stranky
}
function checkFalse(){
	createCookie("GambrinusAgeCheck","false",1);
}
function eraseCookie(name) {
	createCookie(name,"",-1);
}
function resizeLayer(){
	var winH = document.documentElement.scrollHeight;
	document.getElementById("age_check").style.height= winH+"px";
}
function checkTvQualityRadio() {
	var tv_quality = getTvQuality();
	if ( tv_quality == 0 ) document.getElementById("quality0").checked = true;
	if ( tv_quality == 1 ) document.getElementById("quality1").checked = true;
	if ( tv_quality == 2 ) document.getElementById("quality2").checked = true;
}
function startAgeCheck(){
	var server = getServer();
	var checked = readCookie("GambrinusAgeCheck");

	if(checked == null || checked == "false"){

	  document.write('<div id="age_check"></div><div id="age_check_tab"><div class="container">');
	  document.write("&nbsp;");
		flash("/_swf/agecheck.swf","360","250","","transparent","ac_video","","",0);
		document.write('<div class="ac-content"><p><a href="" onclick="checkTrue(); return false;" title="Vstoupit"><img src="/_clip/btn-enter.gif" alt="Vstoupit" class="btn" /></a><strong>Jsem starší 18 let</strong><br />nebo jsem osoba podléhající právu USA starší 21 let.</p><p><a href="'+server+'/opustit-stranky.php" onclick="checkFalse();" title="Opustit stránky"><img src="/_clip/btn-leave.gif" alt="Opustit stránky" class="btn" /></a><strong>Jsem mladší 18 let</strong><br />nebo jsem osoba podléhající právu USA mladší 21 let.</p>');
    document.write('<div class="ac-login-box"><h3>Členové našeho G-klubu se mohou rovnou přihlásit.</h3><div id="err_code"></div><div id="ac-login-form" class="ac-login-form"><span>Login: </span><input name="ach_login" id="ach_login" type="text" value=""/><span> Heslo:</span><input name="ach_pswd" id="ach_pswd" type="password" /> <input type="image" src="/_clip/btn-login.gif" value="PŘIHLÁSIT" title="Přihlásit se do G-klubu" class="ac-btn-login" onclick="login();" /></div></div>');
		document.write('<div class="ac-quality-box"><h3>Kvalita video animací</h3><form action=""><input type="radio" name="quality" id="quality0" onclick="javascript:setTvQuality(0);" /><label for="quality0">&nbsp;vysoká (700 Kb/s)</label> <input type="radio"  name="quality" id="quality1" onclick="javascript:setTvQuality(1);" /><label for="quality1">&nbsp;střední (250 Kb/s)</label> <input type="radio" id="quality2"  name="quality" onclick="javascript:setTvQuality(2);" /><label for="quality2">&nbsp; nízká (100 Kb/s)</label></form></div>');
		document.write('<br /><p><em>Pro správné zobrazení stránek musíte mít zapnutou podporu cookies ve svém prohlížeči.</em></p></div></div></div>');

    will_be_age_check_shown = 1;

		window.onresize=resizeLayer;
		window.onload=resizeLayer;
		window.onload=checkTvQualityRadio;
	}else{
	    will_be_age_check_shown = 0;
	}
}
function getServer(){
	var host = window.location.toString();
	host = host.split('://');
	var protocol = host[0];
	host = window.location.host;

	return protocol+"://"+host;
}

startAgeCheck();