function eMailValidationModule(Received_Email_To_Test)
{
/////////////////////
// BUILD 007 ////////
/////////////////////

//Convert the email address to lowercase.
	Received_Email_To_Test=Received_Email_To_Test.toLowerCase()






//The 'MainCharacters' Array contains the characters which make up the bulk of the email address.
	MainCharacters=new Array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","1","2","3","4","5","6","7","8","9","0","-","_")






//The 'SpecialCharacters' Array contains the characters which can (and must) exist within an email address but ONLY in specific locations.
	SpecialCharacters=new Array("@",".")






//The 'DomainExtensionCharacters' Array contains the characters which are acceptable in the Domain Extension.
	DomainExtensionCharacters=new Array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z")






//Set the variable 'Final_Return_Result'. If this becomes '0' at any time then the email address has failed a test and even if it passes all other tests, the overall result will be a fail.
	Final_Return_Result=1






//An email address must be at least 6 characters in length. The smallest possible email address is in the form 'x@y.zz' where 'x' is the alias, 'y' is the domain name and 'zz' is the Domain Extension.
	if(Received_Email_To_Test.length<6)
	{
		Final_Return_Result=0
	}






//Here the whole of the email address is checked to see if it contains any invalid characters such as '£' or '$' etc. etc.
//This test is only performed if the email address has passed all previous tests. This is to prevent 'Dependency Errors' and to speed-up execution.
	if(Final_Return_Result!=0)
	{
		for(a=0;a<Received_Email_To_Test.length;a++)
		{
			IsThisCharacterValid=0

			for(b=0;b<MainCharacters.length;b++)
			{
				if(Received_Email_To_Test.charAt(a)==MainCharacters[b])
				{
					IsThisCharacterValid=1
				}
			}

			for(b=0;b<SpecialCharacters.length;b++)
			{
				if(Received_Email_To_Test.charAt(a)==SpecialCharacters[b])
				{
					IsThisCharacterValid=1
				}
			}

			if(IsThisCharacterValid==0)
			{
				Final_Return_Result=0
			}
		}
	}






//An email address must contain one (and ONLY one) Arroba (@) symbol. If an Arroba symbol is located and it is subsequently found to be the only one, then its location is marked for future reference.
//This test is only performed if the email address has passed all previous tests. This is to prevent 'Dependency Errors' and to speed-up execution.
	if(Final_Return_Result!=0)
	{
		ArrobaCount=0

		for(a=0;a<Received_Email_To_Test.length;a++)
		{
			if(Received_Email_To_Test.charAt(a)=='@')
			{
				ArrobaCount++
			}
		}

		if(ArrobaCount==1)
		{
			for(a=0;a<Received_Email_To_Test.length;a++)
			{
				if(Received_Email_To_Test.charAt(a)=='@')
				{
					ArrobaSymbolPosition=a
				}
			}
		}
		else
		{
			Final_Return_Result=0
		}
	}






//There are constraints on exactly where an Arroba (@) symbol can exist within an email address. The first character of the email address must not be an Arroba.
//This test is only performed if the email address has passed all previous tests. This is to prevent 'Dependency Errors' and to speed-up execution.
	if(Final_Return_Result!=0)
	{
		if(Received_Email_To_Test.charAt(0)=='@')
		{
			Final_Return_Result=0
		}
	}






//There are constraints on exactly where an Arroba (@) symbol can exist within an email address. The last character of the email address must not be an Arroba.
//This test is only performed if the email address has passed all previous tests. This is to prevent 'Dependency Errors' and to speed-up execution.
	if(Final_Return_Result!=0)
	{
		if(Received_Email_To_Test.charAt(Received_Email_To_Test.length-1)=='@')
		{
			Final_Return_Result=0
		}
	}






//An email address must contain at least one Period (.) symbol.
//This test is only performed if the email address has passed all previous tests. This is to prevent 'Dependency Errors' and to speed-up execution.
	if(Final_Return_Result!=0)
	{
		PeriodCount=0

		for(a=0;a<Received_Email_To_Test.length;a++)
		{
			if(Received_Email_To_Test.charAt(a)=='.')
			{
				PeriodCount++
			}
		}

		if(PeriodCount==0)
		{
			Final_Return_Result=0
		}
	}






//There are constraints on exactly where a Period (.) symbol can exist within an email address. The first character of the email address must not be a Period.
//This test is only performed if the email address has passed all previous tests. This is to prevent 'Dependency Errors' and to speed-up execution.
	if(Final_Return_Result!=0)
	{
		if(Received_Email_To_Test.charAt(0)=='.')
		{
			Final_Return_Result=0
		}
	}






//There are constraints on exactly where a Period (.) symbol can exist within an email address. The last character of the email address must not be a Period.
//This test is only performed if the email address has passed all previous tests. This is to prevent 'Dependency Errors' and to speed-up execution.
	if(Final_Return_Result!=0)
	{
		if(Received_Email_To_Test.charAt(Received_Email_To_Test.length-1)=='.')
		{
			Final_Return_Result=0
		}
	}






//There are constraints on exactly where a Period (.) symbol can exist within an email address. A Period character can not exist immediatly before an Arroba character.
//This test is only performed if the email address has passed all previous tests. This is to prevent 'Dependency Errors' and to speed-up execution.
	if(Final_Return_Result!=0)
	{
		if(Received_Email_To_Test.charAt(ArrobaSymbolPosition-1)=='.')
		{
			Final_Return_Result=0
		}
	}






//There are constraints on exactly where a Period (.) symbol can exist within an email address. A Period character can not exist immediatly after an Arroba character.
//This test is only performed if the email address has passed all previous tests. This is to prevent 'Dependency Errors' and to speed-up execution.
	if(Final_Return_Result!=0)
	{
		if(Received_Email_To_Test.charAt(ArrobaSymbolPosition+1)=='.')
		{
			Final_Return_Result=0
		}
	}






//There are constraints on exactly where a Period (.) symbol can exist within an email address. No two Period characters can exist immediatly adjacent to each other.
//This test is only performed if the email address has passed all previous tests. This is to prevent 'Dependency Errors' and to speed-up execution.
	if(Final_Return_Result!=0)
	{
		for(a=0;a<Received_Email_To_Test.length;a++)
		{
			if(Received_Email_To_Test.substring(a,(a+2))=='..')
			{
				Final_Return_Result=0
			}
		}
	}






//There are constraints on exactly where a Period (.) symbol can exist within an email address. At least one Period character must exist after the Arroba character.
//This test is only performed if the email address has passed all previous tests. This is to prevent 'Dependency Errors' and to speed-up execution.
	if(Final_Return_Result!=0)
	{
		PeriodCount=0

		for(a=ArrobaSymbolPosition;a<Received_Email_To_Test.length;a++)
		{
			if(Received_Email_To_Test.charAt(a)=='.')
			{
				PeriodCount++
			}
		}

		if(PeriodCount==0)
		{
			Final_Return_Result=0
		}
	}






//The 'Domain Extension' is the section of the email address from the last Period character to the end of the email address.
//The 'Domain Extension' must be at least 2 Characters in length.
//This test is only performed if the email address has passed all previous tests. This is to prevent 'Dependency Errors' and to speed-up execution.
	if(Final_Return_Result!=0)
	{
		StartOfDomainExtension=(Received_Email_To_Test.lastIndexOf('.')+1)

		if((Received_Email_To_Test.length-StartOfDomainExtension)<2)
		{
			Final_Return_Result=0
		}
	}






//There are constraints on the characters that the 'Domain Extension' can contain. It can exist of letters only and therefore numbers or Special characters are not allowed.
//Here the whole 'Domain Extension' is checked to see if it contains any invalid characters such as '£','$' or '3' etc. etc.
//This test is only performed if the email address has passed all previous tests. This is to prevent 'Dependency Errors' and to speed-up execution.
	if(Final_Return_Result!=0)
	{
		for(a=StartOfDomainExtension;a<Received_Email_To_Test.length;a++)
		{
			IsThisCharacterValid=0

			for(b=0;b<DomainExtensionCharacters.length;b++)
			{
				if(Received_Email_To_Test.charAt(a)==DomainExtensionCharacters[b])
				{
					IsThisCharacterValid=1
				}
			}

			if(IsThisCharacterValid==0)
			{
				Final_Return_Result=0
			}
		}
	}

return Final_Return_Result
}
