﻿function validator(action)
{

	//check if we have the name
	if(submission.Name.value=="")
	{
		alert("נא להזין שם מלא")
		document.all.Name.focus()
		return false
	}
	
	//check if we have the phone number
	/*if(submission.Phone.value=="")
	{
		alert("נא להזין מספר טלפון")
		document.all.Phone.focus()
		return false
	}*/
	
	//check the validation of the e-mail address
	var mail = new String();
	mail=submission.Email.value

	//if we have the default its ok
	if (mail=="")
	{
		alert("נא להזין כתובת אי-מייל")
		document.all.Email.focus()
		return false
	}

	//check if we have the @ sign
	if (mail.indexOf("@")==-1)
	{
		alert("כתובת אי-מייל לא תקנית")
		document.all.Email.focus()
		return false
	}	

	//check if we have dot in the second part of the form
	var dot
	dot=mail.split("@")[1]	
	if (dot.indexOf(".")==-1)
	{
		alert("כתובת אי-מייל לא תקנית .בדוק להמצאות סימן .")
		//document.all.Email.focus()
		return false
	}

	//check if the address ends with 2 or 3 letters
		
	var end
	end=dot.split(".")[1]
	if (end.length<2 || end.length>3)
	{
		alert("כתובת אי-מייל לא תקנית. בדוק את החלק השני של הכתובת")
		//document.all.Email.focus()
		return false
	}
	
	//check if we have the comments
	if(submission.Comments.value=="")
	{
		alert("נא להזין טקסט חופשי")
		document.all.Comments.focus()
		return false
	}

	//submission.action = action
	submission.submit()
	return true;
}

