﻿function validator(action)
{
	//check the validation of the e-mail address
	var mail
	mail=submission.mm_newemail.value
						
	//if we have the default its ok
						
	if (mail=="")
	{
		alert("Please insert Email")
		submission.mm_newemail.focus()
		return false
	}
	else
	{
						
		//check if we have the @ sign
						
		if (mail.indexOf("@")==-1)
		{
			alert("Please use a leagel Email Address")
			submission.mm_newemail.focus()
			return false
		}	
		else
		{
							
			//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")
				submission.mm_newemail.focus()
				return false
			}
			else
			{
								
				//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")
					submission.mm_newemail.focus()
					return false
				}
				else
				{
					//document.forms[0].action = action
					submission.submit()
					return true;
				}
			}
		}
	}
}
