// kontrola emailů
function zkontroluj_email(adresa)
{
  re = /^[^.]+(\.[^.]+)*@([^.]+[.])+[a-z]{2,3}$/;
  return adresa.search(re) == 0;
}



//Kontrola vkládání znaků



function getkey(e)
{ 
  var code; 
  if (!e)
    var e = window.event; // nastaveni pro IE 
  if (e.keyCode)
    code = e.keyCode; // ie and mozilla/gecko 
  else
   if (e.which)
     code = e.which; // nn4
  return code; 
} 

function numeric(eX)
{
  test=getkey(eX);
  if (test<48 || test>57)
    return false;
}

function alfanumeric(eX,diacritic)
{
  test=getkey(eX);
  set1=(test>32 && test<48);
  set2=(test>57 && test<65);
  set3=(test>90 && test<97);
  if (diacritic == 1)
    set4=(test>122 && test<127);
  else
    set4=(test>122)
  if (set1 || set2 || set3 || set4)
    return false;
}

function safechars(eX)
{
  test=getkey(eX);
  if (test==34 || test==39)
    return false;
}



function objednavkaValidate(){
		if (document.objednavka.den.value=="") {
			alert("You have not filed the field 'DAY' !!!");
			document.objednavka.den.focus();			
			document.objednavka.den.style.background = "#ffffff";
			return false;
		}
		
		
		
		if (document.objednavka.mesic.value=="") {
			alert("You have not filed the field 'MONTH' !!!");
			document.objednavka.mesic.focus();			
			document.objednavka.mesic.style.background = "#ffffff";
			return false;
		}
		if (document.objednavka.rok.value=="") {
			alert("You have not filed the field 'YEAR' !!!");
			document.objednavka.rok.focus();			
			document.objednavka.rok.style.background = "#ffffff";
			return false;
		}
		if (document.objednavka.pocetnoci.value=="") {
			alert("You have not filed the field 'NUMBER OF NIGHTS' !!!");
			document.objednavka.pocetnoci.focus();			
			document.objednavka.pocetnoci.style.background = "#ffffff";
			return false;
		}
		if (document.objednavka.pocetosob.value=="") {
			alert("You have not filed the field 'NUMBER OF PEOPLE' !!!");
			document.objednavka.pocetosob.focus();			
			document.objednavka.pocetosob.style.background = "#ffffff";
			return false;
		}
		if (document.objednavka.druhpokoje.value=="") {
			alert("You have not filed the field 'TYPE OF ROOM' !!!");
			document.objednavka.druhpokoje.focus();			
			document.objednavka.druhpokoje.style.background = "#ffffff";
			return false;
		}
		if (document.objednavka.jmeno.value=="") {
			alert("You have not filed the field 'NAME' !!!");
			document.objednavka.jmeno.focus();			
			document.objednavka.jmeno.style.background = "#ffffff";
			return false;
		}
		if (document.objednavka.adresa.value=="") {
			alert("You have not filed the field 'ADDRESS' !!!");
			document.objednavka.adresa.focus();			
			document.objednavka.adresa.style.background = "#ffffff";
			return false;
		}
		if (document.objednavka.mesto.value=="") {
			alert("You have not filed the field 'CITY' !!!");
			document.objednavka.mesto.focus();			
			document.objednavka.mesto.style.background = "#ffffff";
			return false;
		}
		if (document.objednavka.stat.value=="") {
			alert("You have not filed the field 'COUNTRY' !!!");
			document.objednavka.stat.focus();			
			document.objednavka.stat.style.background = "#ffffff";
			return false;
		}
		if (document.objednavka.telefon.value=="") {
			alert("You have not filed the field 'TELEPHONE' !!");
			document.objednavka.telefon.focus();			
			document.objednavka.telefon.style.background = "#ffffff";
			return false;
		}
		if (!zkontroluj_email(self.document.forms.objednavka.email.value))
		  {
		    alert("You have not filed the field 'E-MAIL' correctly !!!");
			document.objednavka.email.focus();			
			document.objednavka.email.style.background = "#ffffff";
		    return false;
		  }
		
	msg = "Please, check the mentioned data: \n\n\n\n Date of arrival:                      "
	+ document.objednavka.den.value + document.objednavka.mesic.value +" "+ document.objednavka.rok.value + "\n Number of nights: 		"
	+ document.objednavka.pocetnoci.value + "\n Number of people: 		"
	+ document.objednavka.pocetosob.value + "\n Type of room: 		"
	+ document.objednavka.druhpokoje.value + "\n Name: 			"
	+ document.objednavka.jmeno.value + "\n Address: 		"
	+ document.objednavka.adresa.value + "\n City: 			"
	+ document.objednavka.mesto.value + "\n Country: 		"
	+ document.objednavka.stat.value + "\n Telephone: 		"
	+ document.objednavka.telefon.value + "\n E-mail: 			"
	+ document.objednavka.email.value + "";
	
	
		return confirm(msg);
	}
	
	function returnBgColor(obj){
			obj.style.background = "#ffffff";
	}
	function changeBgColor(obj){
			obj.style.background = "#ffffff";
	}
  
