function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Niepoprawny adres email. Popraw błąd i spróbuj ponownie!")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Niepoprawny adres email. Popraw błąd i spróbuj ponownie!")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Niepoprawny adres email. Popraw błąd i spróbuj ponownie!")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Niepoprawny adres email. Popraw błąd i spróbuj ponownie!")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Niepoprawny adres email. Popraw błąd i spróbuj ponownie!")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Niepoprawny adres email. Popraw błąd i spróbuj ponownie!")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Niepoprawny adres email. Popraw błąd i spróbuj ponownie!")
		    return false
		 }
		 
		

 		 return true					
	}

function ValidateForm(){
	var emailID=document.frmSample.email
	var emailID2=document.frmSample.email2
	var firstnameID=document.frmSample.firstname
	var lastnameID=document.frmSample.lastname
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Wpisz swój adres email (na niego otrzymasz odpowiedź od nas).")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	
	 if (emailID.value != emailID2.value)
{
alert('Adresy email w obu okienkach muszą być takie same. Popraw błąd i spróbuj ponownie!');
return false;
} 

if (firstnameID.value == "") {
alert("Musisz podać Twoje Imię.");
return false;
}

if (lastnameID.value == "") {
alert("Musisz podać Twoje Nazwisko.");
return false;
}

	
	return true
 }
 
 
