// Ensure that the object contains an email address in the format we require
// a blank field is considered okay

function validEmail(emailAddress)
{
	var emailFormat = /^\w(\.?[\w-])*@\w(\.?[\w-])*\.[a-zA-Z]{2,6}(\.[a-zA-Z]{2})?$/;
	
	var tmp = '';
	if (typeof(emailAddress) == 'object')
		tmp = String(emailAddress.value);
	else
		tmp = String(emailAddress);
	tmp = tmp.replace(/\s+$/, ''); // remove trailing spaces as they confuse things
	
	if (tmp.length != 0) // do we have input ?
	{
		if (tmp.search(emailFormat) == -1) // yes, is it valid ?
			return (false); // nope
	}
	return (true);
}