﻿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("Érvénytelen E-Mail")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Érvénytelen E-Mail")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Érvénytelen E-Mail")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Érvénytelen E-Mail")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Érvénytelen E-Mail")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Érvénytelen E-Mail")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Érvénytelen E-Mail")
		    return false
		 }

 		 return true					
	}

function ValidateForm_email(){
	var emailID=document.irjon.email
    if(document.irjon.text.value<5){
    alert("Ön még nem írt üzenetet!");
    document.irjon.text.focus();
    return false
    }
	if(document.irjon.name.value<1){
    alert("Kérjük adja meg nevét!");
    document.irjon.name.focus();
    return false
    }
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Kérjük adjon meg egy érvényes e-mail címet!")
        emailID.focus();
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
 }
 function ValidateForm_reservation(){
	var emailID=document.reservation.email
    if(document.reservation.nev.value.length<3){
		alert("Kérjük adja meg nevét!");
		document.reservation.nev.focus();
		return false
    }
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Kérjük adjon meg egy érvényes e-mail címet!")
        emailID.focus();
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	 if(document.reservation.telefon.value.length<6){
		alert("Kérjük adja meg telefonszámát!");
		document.reservation.telefon.focus();
		return false
    }
	if(document.reservation.fo.value<1){
		alert("Kérjük adja meg hány fő részére szeretne foglalni!");
		document.reservation.fo.focus();
		return false
    }
	if(document.reservation.dohanyzo){
		if(document.reservation.dohanyzo[1].checked==false && document.reservation.dohanyzo[0].checked==false){;
		alert("Kérjük adja meg dohányzó, vagy nem dohányzó asztalt szeretne foglalni!");
		return false
		}
		
    }
	return true
 }

 
 
