function checkEmailAddress(email)
{

	for (var i = 0; i < email.length; i++)
	{
		var chr = email.charAt(i);

		if (!(((chr >= 'a') && (chr <= 'z')) || ((chr >= 'A') && (chr <= 'Z')) ||
			(chr == '.') || (chr == '@') || (chr == '_') || (chr == '-') ||
			((chr >= '0') && (chr <= '9'))))
		{
			alert("Invalid Email address '" + email + "'.");
			return false;
		}
	}
	if ((email == "") || (email.indexOf('@', 0) == -1) ||
		(email.indexOf('@', 0) == 0) || (email.indexOf('.', 0) == -1) ||
		(email.indexOf('.', 0) == (email.length - 1)) ||
		(email.indexOf('@', 0) == (email.length - 2)) ||
		(email.charAt(0) == '.') || (email.charAt(email.length - 1) == '.'))
	{
		alert("Invalid Email address  " + email + " .");
		return false;
	}
	// Added by Riz... 241201 checking for invalid emails due to '.' placement
	var temp = email.substring(email.indexOf('@', 0) + 1, email.length);

	if (temp.length > 2)
	{
		if (temp.indexOf('.', 1) == -1)
		{
			alert("Invalid Email address " + email + " .");
			return false;
		}
		else
		{
			if (temp.indexOf('.', 1) == temp.length - 1)
			{
				alert("Invalid Email address " + email + " .");
				return false;
			}
		}
	}
	else
	{
		alert("Invalid Email address " + email + " .");
		return false;
	}

	var charIndex = email.indexOf('@', 0);
	if (email.indexOf('@', charIndex + 1) != -1)
	{
		alert("Invalid Email address '" + email + "'.");
		return false;
	}
	else
	{
		charIndex = email.indexOf('@', 0);
		if (email.charAt(charIndex - 1) == '.')
		{
			alert("Invalid Email address '" + email + "'.");
			return false;
		}
	}
	// This case checks that 2 dots can't be consective
	var previousChar;
	var currentChar;

	for (var i = 0; i < email.length; i++)
	{
		currentChar = email.charAt(i);
		if (currentChar == '.')
		{
			if (currentChar == previousChar)
			{
				alert("Invalid Email address " + email + " .");
				return false;
			}
		}
		previousChar = currentChar;
	}
	return true;
}

function charsCheck(e, goods)
{
	
	if(goods=='a...z' || goods=='A...Z')
		goods='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
	if(goods=='a...z,0...9')
		goods='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
	
	if(goods=='0.9')
		goods='0123456789';
	if(goods=='1.9')
		goods='123456789';
	if(goods=='0...9')
		goods='0123456789';
	if(goods=='0...9:')
		goods=':0123456789';
	if(goods=='0...9.')
		goods='.0123456789';
	if(goods=='0...9-')
		goods='-0123456789';
	
	var key, keychar;
	key = getkey(e);
	//alert(key);
	if (key == null) return true;
	
	// get character
	keychar = String.fromCharCode(key);
	keychar = keychar.toLowerCase();
	goods = goods.toLowerCase();
	
	// check goodkeys
	if (goods.indexOf(keychar) != -1)
		return true;
	
	//alert(goods.indexOf(keychar));
	
	// control keys
	if ( key==null || key==8 || key==9 || key==13 || key==27 || key == 0  )
	   return true;	
	   
	// else return false
	return false;
}

function getkey(e)
{
if (window.event)
   return window.event.keyCode;
else if (e)
   return e.which;
else
   return null;
}

function dotAndSpace(txtBoxValue)
{
	 
	 
	if (txtBoxValue)
	{
		for (var i=0; i<txtBoxValue.length; i++) {
		//spaces don't count as "existence"
		if (txtBoxValue.charAt(i) == " ")
		{
		 alert("spaces are not allowed");
         return true;
		}
	}
return false;
} 
}
