function ttel()
{
var inpt=document.forms[1].Telefon.value;
tel=/^[0-9]{9}$/;
	{
	if (tel.test(inpt)==false)
	return false;
	else
	return true;
	}
}

function tmail()
{
var inpe=document.forms[1].Mail.value;
emal=/^.+@.+\..{2,4}$/;
	{
	if (emal.test(inpe)==false)
	return false;
	else
	return true;
	}
}

function isblank(s)
{	for(var i = 0; i<s.length; i++)
	{	var c = s.charAt(i);
		if ((c != '') && (c != '\n') && (c != '\t'))
		{	return false;
		}
	}
	return true;
}

function verify(f,language)
{	var msg;
	var empty_fields = "";
	var errors = "";

	for(var i = 0; i<f.length; i++)
	{	var e = f.elements[i];
		if (((e.type == "text") || (e.type == "textarea")) && (!e.optional))
		{	if (((e.value == null) || (e.value == "") || isblank(e.value)) && (e.name!="Telefon" && e.name!="Mail"))
			{	
				empty_fields += e.name+":	Nevyplněno!\n";
				continue;
			}
			if ( e.numeric || (e.min != null) || (e.max != null) )
			{	var v = parseFloat(e.value);
				if ( isNaN(v) || ((e.min != null) && (v < e.min)) ||
				   (( e.max != null ) && (v > e.max)))
				{	errors += (language == "CZ") ? ("- Políčko " + e.name + " musí být číslo,") : ("The field " + e.name + " must be a number");
					if (e.min != null)
						errors += (language == "CZ") ? (" které musí být větší než " + e.min) : (" that is greater than " + e.min);
					if (e.max != null && e.min != null)
						errors += (language == "CZ") ? (" a menší než " + e.max) : (" and less than " + e.max);
					else if (e.max != null)
						errors += (language == "CZ") ? (" které je menší než " + e.max) : (" that is less then " + e.max);
					errors += ".\n";
				}
			}
		}
	}
	if (!empty_fields && !errors && ttel()==true && tmail()==true) return true;
	msg = "_______________________________________________________  \n\n";
	msg += (language == "CZ") ? ("Formulář nebyl odeslán, poněvadž byly shledány následující chyby.\n") : ("The form was not submitted because of the following error(s).\n");
	msg += (language == "CZ") ? ("     Prosím, chyby opravte a formulář odešlete znovu. Děkujeme.\n") : ("Please correct these error(s) and re-submit.\n");
	msg += "_______________________________________________________  \n\n";
	if (empty_fields==true || ttel()==false || tmail()==false)
	{	msg += (language == "CZ") ? (empty_fields) : (empty_fields);
		if (errors)
			msg += "\n";
	if (ttel()==false)
	msg += ("Telefon:	Nevyplněno nebo chybný formát! Prosím, zadejte 9 čísel\n	bez mezer. Mezinárodní číslo můžete uvést v komentáři.\n");
	if (tmail()==false)
	msg += ("E-mail:	Nevyplněno nebo chybný formát! Prosím, zadejte ve formátu\n	např. jan_novak@novak.cz, novak@novak.cz apod..\n");
	}
	msg += errors;
	alert(msg);
	return false;
}

function tpsc()
{
inpt=document.forms[1].PSČ.value;
pcsc=/^[0-9]{5}$/;
{
if (pscc.test(inpt)==false) 
window.alert("             Špatný formát PSČ!\n\nProsím, zadejte pětimístné číslo bez mezery.");
}
}
