function validovat(formular, txtfield, type, povinne)
{
	var neplatnymail = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/;
	var platnymail = /^.+@[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,6}|[0-9]{1,3})$/;

	policko = formular[txtfield];
	
	if (policko == null)
	return true;
	
	var val = policko.value;
	var chyba = '';
	
	if (val == '' && povinne == 1)
	{
		chyba = 'Field marked with * are mandatory.';
	}
	else
	{
		if (val == '')
		{
			return true;
		}
		else
		{
			switch (type) {
			case 'email':
				if (val.match(neplatnymail) || !val.match(platnymail))
				chyba = 'Not valid email!';
			break;

			case 'cvc':
				if (!val.match (/[0-9]{3}/))
				chyba = 'Not valid CVC2 or CVV2 code!';
			break;
			
			}
		}
	}
	
	if (chyba != '')
	{
		alert(chyba);
		policko.focus();
		return false;
	}
	else
	{
		return true;
	}
}

function val_request()
{
	var formular = document.personal;
	
	if (validovat(formular,'nights','text',1) && validovat(formular,'den','text',1) && validovat(formular,'mesic','text',1) &&  validovat(formular,'persons','text',1) && validovat(formular,'jmeno','text',1) && validovat(formular,'prijmeni','text',1) && validovat(formular,'zeme','text',1) && validovat(formular,'email','email',1) && validovat(formular,'telefon','text',1) )
	{
		return true;
	}
	else
	{
		return false;
	}
}

