/*
	Разработано Смолянским О.В.
	Дата последнего обновления: 20.09.2006
	--------------------------------------------------------------------
	Функции для работы со строками
*/
//вырезаем пробелы слева, справа или с обеих сторон
function trim_spaces ( from_where )
{
	var temp_string = this

	if ( arguments.length == 0 )
	{
	  	from_where = "BOTH"
	}

	if ( from_where.toUpperCase () == "LEFT" || from_where == "BOTH" )
	{
  		while ( temp_string.left ( 1 ) == " ")
		{
	  		temp_string = temp_string.substring ( 1 );
	  	}
	}
  
	if ( from_where.toUpperCase () == "RIGHT" || from_where == "BOTH" )
	{
  		while ( temp_string.right ( 1 ) == " " )
		{
  			temp_string = temp_string.substring ( 0, temp_string.length - 1 )
	  	}
	}

	return temp_string
}

//вырезаем сколько-то символов слева
function extract_left ( total_chars )
{
	return this.substring ( 0, total_chars )
}

//вырезаем сколько-то символов справа
function extract_right ( total_chars )
{
	return this.substring ( this.length - total_chars )
}

//задаем прототипы функций для строк
String.prototype.right = extract_right;
String.prototype.left = extract_left;
String.prototype.trim = trim_spaces;

//проверяем адрем эл. почты на допустимость
function check_email ( email_address )
{
	var reg_mail = /^[a-z][\w\-\.]*@[\w\-\.]+\.[a-z]{2,3}/i
	return reg_mail.test ( email_address ) 
}