﻿function validator(action)
{

	//check if we have the name
	if(submission.clientName.value=="")
	{
		alert("Please insert Name")
		document.all.clientName.focus()
		return false
	}
	
	//check if we have the phone number
	if(submission.phone.value=="")
	{
		alert("Please insert Phone Number")
		document.all.phone.focus()
		return false
	}
	
	//check the validation of the e-mail address
	var mail
	mail=submission.Email.value

	//if we have the default its ok
	if (mail=="")
	{
		alert("Please insert Email")
		document.all.Email.focus()
		return false
	}

	//check if we have the @ sign
	if (mail.indexOf("@")==-1)
	{
		alert("Please use a leagel Email Address")
		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("Please use a leagel Email Address")
		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("Please use a leagel Email Address")
		document.all.Email.focus()
		return false
	}

	//submission.action = action
	submission.submit()
	return true;
}
