function regCountDown() {
	minutes = 3;
	timeout = minutes * 60;
	cdid = setInterval("regCountDownTimeout()", 1000);
}

function regCountDownTimeout() {
	if (timeout >= 0) {
		document.getElementById("counter").value = timeout;
		timeout = timeout - 1;
		}
	else {
		document.getElementById("counter").value = "0";
		clearInterval(cdid);
		}
}

function CreateWebLink(data) {
	document.form.adresa.value = 'www.webpoint.cz/' +data+'/index.php';
}

function CheckForm(x) {
	if(x.username.value.length < 3 || x.username.value.length > 20) {
		alert("Uživatelské jméno musí mít délku 3 - 20 znaků.");
		x.username.select();
		x.username.focus();
		return false;
	}
	var objRegex = new RegExp("^[a-z0-9_\.\-]{2,19}$");
	if(!objRegex.test(x.username.value)) {
		alert("Uživatelské jméno může obsahovat pouze\nmalá písmena a-z\nčíslice 0-9\ntečku .\npodtržítko _\npomlčku -\n\nUživatelské jméno zároveň nesmí obsahovat žádné mezery a musí začínat písmenem.");
		x.username.select();
		x.username.focus();
		return false;
	}
	if(!x.passwd.value) {
		alert('Chybí heslo!');
		x.passwd.select();
		x.passwd.focus();
		return false;
	}
	
	if(x.passwd.value.length < 6 || x.passwd.value.length > 15) {
		alert("Uživatelské heslo musí mít délku 6 - 15 znaků.");
		x.username.select();
		x.username.focus();
		return false;
	}
	
	if(x.passwd.value != x.passwdcontrol.value) {
		alert('Potvrzení hesla nesouhlasí!');
		x.passwdcontrol.value = '';
		x.passwdcontrol.focus();
		return false;
	}
	if(x.passwd.value == x.username.value) {
		alert('Heslo by nemělo být stejné jako uživatelské jméno!');
		x.passwdcontrol.value = '';
		x.passwd.value = '';
		x.passwd.focus();
		return false;
	}

	
	var objRegex1 = new RegExp("^[^.@]+(\.[^.@]+)*@([^.@]+[.])+[a-z]{2,3}$");
	if(!objRegex1.test(x.email.value)) {
		alert("Zadali jste nesprávnou emailovou adresu!");
		x.email.select();
		x.email.focus();
		return false;
	}

	if(!x.agree.checked) {
		alert('Chybí souhlas se smluvními podmínkami!');
		x.agree.focus();
		return false;
	}

	return true;
}
function openUnfinishedWin() {
//	alert(document.cookie);
	value = getCookie("finished");
	if (value == -1) {
		window.open("http://gfx.volny.cz/ads/popunder2.html", "anonym", "toolbar=0,location=0,directories=0,status=0,menubar=no,scrollbars=no,resizable=no,width=534,height=366");
	} else if (value == 2) {
		window.open('http://kolostesti.volny.cz/popup.php','foo','width=250,height=250');
	}
	return;
}
var bikky = document.cookie;
function getCookie(name) { // use: getCookie("name");
	var index = bikky.indexOf(name + "=");
	if (index == -1) return null;
	index = bikky.indexOf("=", index) + 1;
	var endstr = bikky.indexOf(";", index);
	if (endstr == -1) endstr = bikky.length;
	return unescape(bikky.substring(index, endstr));
}
function setCookie(name, value) { // use: setCookie("name", value);
	if (value != null && value != "") {
		document.cookie=name + "=" + escape(value) + ";";
	}
	bikky = document.cookie; // update bikky
}
function doTooltip(e, msg) {
  if ( typeof Tooltip == "undefined" || !Tooltip.ready ) return;
  Tooltip.show(e, msg);
}
function hideTip() {
  if ( typeof Tooltip == "undefined" || !Tooltip.ready ) return;
  Tooltip.hide();
}
