function InfoForm(formular)
{
	if (formular.Jmeno){
		if (formular.Jmeno.value == ""){
			alert('Prosím zadejte Vaše jméno');
			formular.Jmeno.focus();
			return false;	
		}
	}
	if (formular.Prijmeni){
		if (formular.Prijmeni.value == ""){
			alert('Prosím zadejte Vaše příjmení');
			formular.Prijmeni.focus();
			return false;	
		}
	}
	if ((formular.Email.value == "")){
		alert('Prosím zadejte Váš email');
		formular.Email.focus();
		return false;	
	}
	if (formular.Telefon){
		if ((formular.Telefon.value == "")){
			alert('Prosím zadejte Váš telefon');
			formular.Telefon.focus();
			return false;	
		}
	}
	if (formular.Mesto){
		if ((formular.Mesto.value == "")){
			alert('Prosím zadejte město');
			formular.Mesto.focus();
			return false;	
		}
	}
	if (formular.Text){ 
		if(formular.Text.value == ""){
			alert('Prosím zadejte zprávu');
			formular.Text.focus();
			return false;
		}
	}
	
	return SendForm(formular);

}
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 SendForm(x){
	CaptchaCode = readCookie('Captcha');
	if(x.Captcha.value!=CaptchaCode){
		alert("Zadali jste nesprávný ověřovací kód");
		RefreshCaptcha();
		x.Captcha.value = "";
		x.Captcha.focus();
		return false;
	}
	eraseCookie('Captcha');
	return true;
}

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 eraseCookie(name) {
	createCookie(name,"",-7);
}

function RefreshCaptcha(){
	eraseCookie('Captcha');
	document.getElementById("Captcha").src = "/captcha/CaptchaSecurityImages.php?width=90&amp;height=27&amp;characters=5&"+ Math.random();
	
}
function $(id) {
	return document.getElementById(id);
}
var test;
function ShowError(Text,RefreshAfter){
	var Body = Text;
	var w = 415;
	var h = 199;
	var scrollTop = document.body.scrollTop ? document.body.scrollTop:document.documentElement.scrollTop;
	var scrollLeft = document.body.scrollLeft ? document.body.scrollLeft:document.documentElement.scrollLeft;
	var top = ((winH()/2)-(h/2)) + scrollTop;
	var left = ((winW()/2)-(w/2)) + scrollLeft;
	test = document.createElement("div");
	test.style.position = 'absolute';
	test.style.width = w;
	test.style.top = top + 'px';
	test.style.left = left + 'px';
	//test.setAttribute('id','Informer');
	test.innerHTML = Body;
	document.getElementById("informer").style.display = 'block';
	document.getElementById("informer").appendChild(test);
	//document.getElementsByTagName("header").appendChild(test); 
	
	setTimeout('Destroy()',5000);
	if(RefreshAfter==1){
		setTimeout('SetLocation()',1000);
	}
}
function ShowDialogText(Text){
	if($('Modal'))HideModal();
	var w = 180;
	var h = 60;
	var scrollTop = document.body.scrollTop ? document.body.scrollTop:document.documentElement.scrollTop;
	var scrollLeft = document.body.scrollLeft ? document.body.scrollLeft:document.documentElement.scrollLeft;
	var top = ((winH()/2)-(h/2)) + scrollTop;
	var left = ((winW()/2)-(w/2)) + scrollLeft;
	var body = document.getElementsByTagName("body")[0];
	var div = document.createElement("div");
	var divSheet = document.createElement("div");
	divSheet.className  = 'Modal-dialog-bg';
	divSheet.setAttribute('id','Modal-bg');
	div.innerHTML = Text + '<br><br><br><button onclick="HideModal();">ok</button>';
	div.setAttribute('id','Modal');
	div.className  = 'Modal';
	div.style.position = 'absolute';
	div.style.width = w;
	div.style.top = top + 'px';
	div.style.left = left + 'px';
	body.appendChild(divSheet);
	body.appendChild(div);
	//document.body.style.overflow='hidden';
	//document.body.scroll='no';
}
function winW() {
	if (window.innerWidth)
	   return window.innerWidth;
	 else if(document.documentElement &&  document.documentElement.clientWidth)
	    return document.documentElement.clientWidth;
	 else if(document.body && document.body.clientWidth)
	    return document.body.clientWidth;
	 else
	    return null;
}
function winH() {
	if (window.innerHeight)
		return window.innerHeight;
	else if(document.documentElement && document.documentElement.clientHeight)
		return document.documentElement.clientHeight;
	else if(document.body && document.body.clientHeight)
		return document.body.clientHeight;
	else
		return null;
}

function HideModal(){
	var body = document.getElementsByTagName('Body')[0];
	body.removeChild($('Modal-bg'));
	body.removeChild($('Modal'));
	/*document.body.style.overflow='auto';
	document.body.scroll='yes';*/
}

function SetLocation(){
  	top.location.reload(true);
  }
function SetLocationURL(Url){
  	top.location = Url;
  }
function Destroy(){
	//document.removeChild($('document'));
	test.innerHTML = "";
	document.getElementById("informer").style.display = 'none';
}
function Texty(e){
	if(e.value !=''){
		e.value = '';
	}
}