// Upper Case first symbol
function ucfirst(obj)
{
    text = trim(obj.value);
    first = text.substr(0, 1);
    obj.value = first.toUpperCase() + text.substr(1);
}

// Trim string (left and right) and delete double spaces 
function trim(text)
{
	if ( typeof(text) == 'object' )
		text.value = trim(text.value);
	else
	{
		text = text.replace(/^\ +/, '');
		text = text.replace(/\ +$/, '');
		text = text.replace(/[\ ]{2,}/, ' ');

		return text;
	}
}

//
function trim_url(obj)
{
	obj.value = obj.value.replace(/[\/]+$/, '').toLowerCase();
}

// Check URL
function check_url(obj)
{
	pattern = /^http:\/\/(www\.)?[0-9a-z_\-\.]{2,}\.[a-z]{2,4}$/i;
	if ( !pattern.test(obj.value) )
	{
		alert('Неправильно указан URL сайта!');
		obj.focus();
		return false;
	}

	return true;
}