function chkemail( obj )
{
	valor = obj.value.toLowerCase();
	retorno = '';
	x = 0;
	arr = 0;
	for( c = 0; c < valor.length; c++ )
	{
		letra = asc( valor.substr( c, 1 ) );
		if( x == 0 )
		{
			if( ( letra >= 48 && letra <= 57 ) || ( letra >= 97 && letra <= 122 ) )
			{
				retorno = retorno + valor.substr( c, 1 );
				x = 1;
			}
		} else {
			if( ( letra >= 48 && letra <= 57 ) || ( letra >= 97 && letra <= 122 ) || ( letra == 46 ) || ( letra == 95 ) || ( letra == 64 ) )
			{
				if( ( letra == 64 ) && arr == 0 )
				{
					retorno = retorno + valor.substr( c, 1 );
					arr = 1;
				} else {
					if( !( letra == 46 && last == 46 ) && !( letra == 95 && last == 95 ) && !( letra == 46 && last == 64 ) )
					{
						if( x >= 1 ) retorno = retorno + valor.substr( c, 1 );
						x = x + 1;
					}
				}
			}
		}
		last = letra;
	}
	valor = retorno;
	retorno = '';  
	x = 0;
	pto = 0;
	for( c = ( valor.length - 1 ); c >= 0; c-- )
	{
		letra = asc( valor.substr( c, 1 ) );
		if( letra == 46 ) pto = 1;
		if( x == 0 )
		{
			if( ( letra >= 48 && letra <= 57 ) || ( letra >= 97 && letra <= 122 ) )
			{
				retorno = valor.substr( c, 1 ) + retorno;
				x = 1;
			}
		} else {
			if( ( letra >= 48 && letra <= 57 ) || ( letra >= 97 && letra <= 122 ) || ( letra == 46 ) || ( letra == 95 ) || ( letra == 64 ) )
			{
				if( x >= 1 ) retorno = valor.substr( c, 1 ) + retorno;
				x = x + 1;
			}
		}
	}
   	
	if( arr == 0 || pto == 0 ) retorno = '';
  	
	obj.value = retorno;
	return;

}

function sonumero( valor )
{
	retorno = '';
	for( c = 0; c < valor.length; c++ )
	{
		letra = asc( valor.substr( c, 1 ) );
		if( letra >= 48 && letra <= 57 ) retorno = retorno + valor.substr( c, 1 );
	}
	return retorno;
}

function asc(each_char)
{
	var n = 0;
	var char_str = ' !"#$%&' + "'" + '()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~';
	for (i = 0; i < char_str.length; i++)
	{
		if (each_char == char_str.substring(i, i+1)) break;
	}
	return i + 32;
}

function textmax( obj, max )
{
	str = obj.value;
	if( str.length > max ) obj.value = str.substring( 0, max );
}