function check_form_fields()
{
	var i;
	var a = new Array(8);
	var validator;
	
	a[0] = "name";
	a[1] = "email";
	a[2] = "phone";
	a[3] = "motivation";
	
	
	for (i=0;i<=3;i++)
	{
		if (check_field(a[i]) == "") 
		{
			validator = false;
			break;
		}
	}
	
	if (validator === false)
	{
		return false;
	}
	else
	{
		return true;		
	}
}

function check_field(id)
{
	if (document.getElementById(id))
	{
		if (!document.getElementById(id).value)
		{
			switch(id)
			{
				case "name":
				alert("Neivestas vardas,imones pavadinimas");
				return false;
				break;
								
				case "email":
				alert("Neivestas el. paštas");
				return false;
				break;
				
				case "phone":
				alert("Neivestas telefonas");
				return false;
				break;
				
				case "motivation":
				alert("Neivestas tekstas");
				return false;
				break;
				
			}
			return true;
		}
	}
}
