var whitespace = " \t\n\r";

function isEmpty(s)
{
	return ((s == null) || (s.length == 0))
}

function isWhitespace (s)
{
	var i;
	if (isEmpty(s)) return true;
	for (i = 0; i < s.length; i++)
	{   
		var c = s.charAt(i);
		if (whitespace.indexOf(c) == -1) return false;
	}
	return true;
}

function isEmail (s)
{
	if (isEmpty(s)) return false;
	if (isWhitespace(s)) return false;
 	var i = 2;
	var sLength = s.length;
	while ((i < sLength) && (s.charAt(i) != "@"))
	{ i++
	}
	if ((i >= sLength) || (s.charAt(i) != "@")) return false;
	else i += 3;
  while ((i < sLength) && (s.charAt(i) != "."))
	{ i++
	}
	if ((i >= sLength - 2) || (s.charAt(i) != ".")) return false;
	else return true;
}

function Validator(contactus)
{

	if (isEmpty(contactus.name.value) || isWhitespace(contactus.name.value))
  {
    alert("Prosíme, vpíšte vaše meno!");
    contactus.name.focus();
		contactus.name.select();
    return (false);
  }
	
	  if (!isEmail(contactus.from.value))  
  {
    alert("Prosíme, vpíšte korektnú emailovú adresu!");
    contactus.from.focus();
		contactus.from.select();
    return (false);
  }
	
if (isEmpty(contactus.message.value) || isWhitespace(contactus.message.value))  
  {
    alert("Prosíme, vpíšte vašu požiadavku, komentár alebo dotaz!");
    contactus.message.focus();
		contactus.message.select();
    return (false);
  }
  
  if (!confirm("Ste si istý odoslaním tohto emailu? Pred odoslaním ešte raz skontrolujte overovací kód! ")) {
		form1.name.focus();
	   form1.name.select();
		return (false);
		 }
		 
  return (true);
}
