function zkontroluj_email(adresa) {
  re = /^[^.]+(\.[^.]+)*@([^.]+[.])+[a-z]{2,3}$/;
  return adresa.search(re) == 0;
}

function zkontroluj_telefon(cislo) {
  re = /^[+]? ?\d{3,14} ?\d{2,9} ?\d{2,6} ?\d{2,3} ?\d{0,2}$/;
  return cislo.search(re) == 0;
}

function Form_Validatore(theForm) {// jeden nebo druhy
	
	if (!zkontroluj_email(theForm.textfield11.value)) {
  		theForm.textfield11.style.backgroundColor = "#c00";
			theForm.textfield11.style.color = "#fff";
			
			alert("Nevyplnili jste správně e-mail! Vyplňte jej a akci opakujte.");

			return (false);
		}

	return (true);
}

// validace formulářů s tel. nebo emailem
function Form_Validatore_tmail(theForm) {
	if ((!zkontroluj_telefon(theForm.textfield2.value) && !zkontroluj_email(theForm.textfield6.value))) {			
  		theForm.textfield2.style.backgroundColor = "#c00";
			theForm.textfield2.style.color = "#fff";  
			
			theForm.textfield6.style.backgroundColor = "#c00";
			theForm.textfield6.style.color = "#fff";
			
			alert("Nevyplnili jste správně Váš telefon nebo email. Prosím vyplňte tyto údaje a akci opakujte.");

			return (false);
		}

	return (true);
}

// validace formulářů a adresou (Majetkové pojištění :domácnosti)
function Form_Validatore2(theForm) {
	if ((!zkontroluj_telefon(theForm.textfield11.value) && !zkontroluj_email(theForm.textfield11.value)) || (theForm.ul_cp.value.length <3) || (theForm.obec.value.length <3) || (theForm.psc.value.length <3) || (theForm.jmeno.value.length <3) || (theForm.prijmeni.value.length <3) || (theForm.adresa.value.length <3)) {			
  		theForm.textfield11.style.backgroundColor = "#c00";
			theForm.textfield11.style.color = "#fff";  
			
			theForm.ul_cp.style.backgroundColor = "#c00";
			theForm.ul_cp.style.color = "#fff"; 		  
			
			theForm.obec.style.backgroundColor = "#c00";
			theForm.obec.style.color = "#fff"; 		  
			
			theForm.psc.style.backgroundColor = "#c00";
			theForm.psc.style.color = "#fff"; 		  
			
			theForm.jmeno.style.backgroundColor = "#c00";
			theForm.jmeno.style.color = "#fff"; 		  
			
			theForm.prijmeni.style.backgroundColor = "#c00";
			theForm.prijmeni.style.color = "#fff"; 		
  		
  		theForm.adresa.style.backgroundColor = "#c00";
			theForm.adresa.style.color = "#fff";
			
			alert("Nevyplnili jste správně některý z povinných údajů. Prosím vyplňte tyto údaje a akci opakujte.");

			return (false);
		}

	return (true);
}

// validace formulářů a adresou (Majetkové pojištění :nemovitostí)
function Form_Validatore3(theForm) {
	if ((!zkontroluj_telefon(theForm.kontakt.value) && !zkontroluj_email(theForm.kontakt.value)) || (theForm.ul_cp.value.length <3) || (theForm.obec.value.length <3) || (theForm.psc.value.length <3) || (theForm.pc_hnem.value.length <3) || (theForm.jmeno.value.length <3) || (theForm.prijmeni.value.length <3) || (theForm.adresa.value.length <3)) {			
  		theForm.kontakt.style.backgroundColor = "#c00";
			theForm.kontakt.style.color = "#fff";  
			
			theForm.ul_cp.style.backgroundColor = "#c00";
			theForm.ul_cp.style.color = "#fff"; 		  
			
			theForm.obec.style.backgroundColor = "#c00";
			theForm.obec.style.color = "#fff"; 		  
			
			theForm.psc.style.backgroundColor = "#c00";
			theForm.psc.style.color = "#fff"; 		  
			
			theForm.pc_hnem.style.backgroundColor = "#c00";
			theForm.pc_hnem.style.color = "#fff"; 		  
			
			theForm.jmeno.style.backgroundColor = "#c00";
			theForm.jmeno.style.color = "#fff"; 		
  		
  		theForm.prijmeni.style.backgroundColor = "#c00";
			theForm.prijmeni.style.color = "#fff";
  		
  		theForm.adresa.style.backgroundColor = "#c00";
			theForm.adresa.style.color = "#fff";			
			
			alert("Nevyplnili jste správně některý z povinných údajů. Prosím vyplňte tyto údaje a akci opakujte.");

			return (false);
		}

	return (true);
}

// validace formulářů s adresou (Pojištění vozidel)
function Form_Validatore4(theForm) {
	if ((!zkontroluj_telefon(theForm.textfield2.value) && !zkontroluj_email(theForm.textfield6.value)) || (theForm.textfield8.value.length <3) || (theForm.textfield9.value.length <3) || (theForm.jmeno.value.length <3) || (theForm.textfield7.value.length <3)) {			
  		theForm.textfield2.style.backgroundColor = "#c00";
			theForm.textfield2.style.color = "#fff";  
			
  		theForm.textfield6.style.backgroundColor = "#c00";
			theForm.textfield6.style.color = "#fff"; 			
			
			theForm.textfield8.style.backgroundColor = "#c00";
			theForm.textfield8.style.color = "#fff"; 		  
			
			theForm.textfield9.style.backgroundColor = "#c00";
			theForm.textfield9.style.color = "#fff"; 		  
			
			theForm.jmeno.style.backgroundColor = "#c00";
			theForm.jmeno.style.color = "#fff"; 		
  		
  		theForm.textfield7.style.backgroundColor = "#c00";
			theForm.textfield7.style.color = "#fff";
			
			alert("Nevyplnili jste správně některý z povinných údajů. Prosím vyplňte tyto údaje a akci opakujte.");

			return (false);
		}

	return (true);
}

function openwin(url,name) {
  var height = 600;
  var width = 800;
  var str = "height=" + height + ",innerHeight=" + height;
  str += ",width=" + width + ",innerWidth=" + width;
  if (window.screen) {
    var ah = screen.availHeight - 30;
    var aw = screen.availWidth - 10;
    var xc = Math.floor((aw - width) / 2);
    var yc = Math.floor((ah - height) / 2);
    str += ",left=" + xc + ",screenX=" + xc;
    str += ",top=" + yc + ",screenY=" + yc;
  }
  str += ",directories=0,location=0,menubar=1,personalbar=1,scrollbars=1,status=1,toolbar=1";
  return window.open(url,name,str);
}


