﻿/***************************************************************************
@doc           /includes/global/incValidation.js
@desc          Common validation functions
****************************************************************************
NO NEED TO INCLUDE THIS FILE DIRECTLY
****************************************************************************
|       isEmailAddress(email)
***************************************************************************/

function isEmailAddress(email) {
	// Get rid of any leading and trailing whitespace
	email = trim(email);
	
	// Check for empty string or whitespace
	if (email == "" || email.indexOf(" ") != -1)
	{
		return false;
	}
	else
	{
		var posAt = -1, posDot = -1;
		posAt = email.indexOf("@");
		if (posAt != -1) posDot = email.indexOf(".", posAt);

		/**
		*	Check for:
		*		No '@',
		*		No '.',
		*		Nothing before '@',
		*		Nothing between '@' & '.' or
		*		Nothing after '.'
		*/
		if (posAt == -1 || posDot == -1 || posAt == 0 || posDot == posAt + 1 || posDot == email.length)
		{
			return false;
		}
	}
	
	return true;
}