function nove_okno(adresa, jmeno, vzhled){
  secondWindow=window.open(adresa, jmeno, vzhled)
}

function isDate(theField)   {
		var theInput = theField.value;
		var theLength = theInput.length; 
		var date = true;
		if (theLength == 10)   {
				for (var i = 0; i < 2; i++)   {
						var theChar = theInput.substring(i,i+1);
						if (theChar < "0" || theChar >"9")   {
									date = false;
						}
				}
				for (var i = 3; i < 5; i++)   {
						var theChar = theInput.substring(i,i+1);
						if (theChar < "0" || theChar >"9")   {
									date = false;
						}
				}
				for (var i = 6; i < 10; i++)   {
						var theChar = theInput.substring(i,i+1);
						if (theChar < "0" || theChar >"9")   {
									date = false;
						}
				}
		}
		else   {
				date = false;
		}
		if (date == true)   {
				return true;
				}
		else   {
				return false;
				}		
}

function isCas(theField)   {
		var theInput = theField.value;
		var theLength = theInput.length; 
		var cas = true;
		if (theLength == 5)   {
				var theChar = theInput.substring(2,3);
				if (theChar != ":")   {
							cas = false;
				}				
				for (var i = 0; i < 2; i++)   {
						var theChar = theInput.substring(i,i+1);
						if (theChar < "0" || theChar >"9")   {
									cas = false;
						}
				}
				for (var i = 3; i < 5; i++)   {
						var theChar = theInput.substring(i,i+1);
						if (theChar < "0" || theChar >"9")   {
									cas = false;
						}
				}
		}
		else   {
				cas = false;
		}
		if (cas == true)   {
				return true;
				}
		else   {
				return false;
				}		
}

function isText(theField)   {
		var theInput = theField.value;
		var theLength = theInput.length; 
		var text = true;
		for (var i = 0; i < theLength; i++)   {
				var theChar = theInput.substring(i,i+1);
				if (theChar =="$" || theChar == "{" || theChar == "}" || theChar == "[" || theChar == "]")   {
							text = false;
				}
		}
		if (text == true)   {
				return true;
				}
		else   {
				return false;
				}
}

function validRezerv(form) {
	if (isText(form.Pilot) == false)   { 
			alert ("Do pole Pilot nepište složené a hranaté závorky a $!");
    		return false;
	}
	if(form.Datum_odletu.value != "")  {
		if (isDate(form.Datum_odletu) == false)   {
			alert ("Datum odletu nemá správný formát. \n Datum zapište ve formátu DD-MM-RRRR.");
			return false;
		}
	}
	if(form.Cas_odletu.value != "")  {
		if (isCas(form.Cas_odletu) == false)   {
			alert ("Čas odletu nemá správný formát. \n Čas zapište ve formátu HH:MM.");
			return false;
		}
	}
	if(form.Datum_priletu.value != "")  {
		if (isDate(form.Datum_priletu) == false)   {
			alert ("Datum příletu nemá správný formát. \n Datum zapište ve formátu DD-MM-RRRR.");
			return false;
		}
	}
	if(form.Cas_priletu.value != "")  {
		if (isCas(form.Cas_priletu) == false)   {
			alert ("Čas příletu nemá správný formát. \n Čas zapište ve formátu HH:MM.");
			return false;
		}
	}
	if (isText(form.Destinace) == false)   { 
			alert ("Do pole Destinace nepište složené a hranaté závorky a $!");
    		return false;
	}
	return true;
}	

function potvrzeniPolRez(Id){
     var msg = "Opravdu chcete rezervaci odstranit?";
     if (confirm(msg))
        location.replace("smazat_rez.php?Id=" + Id);
     else
        location.replace("rezervace.php");
   }
/*;<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2">*/
