//Sprawdzenie czy pole zostało wypełnione

function Req(MyField, MyLabel)
	{
	 var result = true;
	 if(MyField.value == "")
		{
		 alert('Proszę wypełnić pole ' + MyLabel);
		 MyField.focus();
		 result = false;
		}
	 return result;
	}

//Sprawdzanie poprawności adresu E-mail (czy zawiera @ i przynajmniej jedną ".")

function ValidEmail(MyField)
	{
	 var result = false;
	 var tempstr = new String(MyField.value);
	 var aindex = tempstr.indexOf("@");
	 if (aindex > 0)
		{
		 var pindex = tempstr.indexOf(".", aindex);
		 if ((pindex > aindex+1) && (tempstr.length > pindex+1))
			{
			 result = true;
			}
		}
	 if (result == false)
		{
		 alert("Proszę podać poprawny adres e-mail");
		 MyField.focus();
		}
	 return result;
	}
	
//Zabezpieczenie anty-robotowe, czy wpisana została poprawna wartość

function AntyRobotCheck(MyField)
	{
	 var result = true;
	 if (MyField.value != 15)
		{
		 alert("Źle, popraw");
		 MyField.focus();
		 result = false;
		}
	 return result;
	}
	
//Sprawdzanie poprawności wypełnienia formularza

function ValidateForm(MyForm)
	{
	 //czy podane zostało imie?
	 if (!Req(MyForm.autor, "Autor: "))
		{
		 return false;
		}
	//czy podany został e-mail?
	 if (!Req(MyForm.adres, "Twój e-mail: "))
		{
		 return false;
		}
	//czy prawidłowy e-mail? (czy zawiera @ i przynajmniej jedną ".")
	 if (!ValidEmail(MyForm.adres))
		{
		 return false;
		}	
/*	//Czy podany został tytuł?
	 if (!Req(MyForm.tytul, "Tytuł: "))
		{
		 return false;
		}
*/	//czy wpisana została treść wiadomości
	 if (!Req(MyForm.tresc, "Treść: "))
		{
		 return false;
		}
	//Czy uzupełnione zostało pole anty-robotowe
	 if (!Req(MyForm.captcha, "sześć + dziewięć = "))
		{
		 return false;
		}
	//Czy podano poprawną wartość?
	 if (!AntyRobotCheck(MyForm.captcha))
		{
		 return false;
		}
	 return true;
	}