{

function enlevespace(champ)
{
if (champ.charAt(0) == " ")
	{
	do {champ=champ.substr(1)}
	while (champ.charAt(0) == " ")
	}
return champ;
}



function requestaddform(theForm)
{

theForm.name.style.backgroundColor='#fff';
theForm.phone.style.backgroundColor='#fff';
theForm.email.style.backgroundColor='#fff';
theForm.city.style.backgroundColor='#fff';
theForm.code.style.backgroundColor='#fff';

	theForm.name.value = enlevespace(theForm.name.value);
	if (theForm.name.value == "") 
	{	alert("Пожалуйста введите ФИО.");
        theForm.name.style.backgroundColor='#ffcccc';
		theForm.name.focus();
		return (false);
	}

	theForm.phone.value = enlevespace(theForm.phone.value);
	if (theForm.phone.value == "") 
	{	alert("Пожалуйста введите номер телефона для связи с Вами.");
        theForm.phone.style.backgroundColor='#ffcccc';
		theForm.phone.focus();
		return (false);
	}

	
	theForm.email.value = enlevespace(theForm.email.value);
	if (theForm.email.value == "") {alert("Пожалуйста введите email"); theForm.email.style.backgroundColor='#ffcccc'; theForm.email.focus(); return (false); }
	else {
		var str=theForm.email.value
 		var expregmail=/^.+@.+\..{2,3}$/
 		if (expregmail.test(str))
 		{}
 		else { alert("email не соответствует формату."); theForm.email.style.backgroundColor='#ffcccc'; theForm.email.focus(); return false;}
 		if (theForm.email.value.indexOf("'") !== -1) { alert("Пожалуйста не пишите посторонние символы в поле \"электронная почта\"."); theForm.email.style.backgroundColor='#ffcccc'; theForm.email.focus(); return (false); }
	}


	theForm.city.value = enlevespace(theForm.city.value);
	if (theForm.city.value == "") 
	{	alert("Пожалуйста введите название Вашего города");
        theForm.city.style.backgroundColor='#ffcccc';
		theForm.city.focus();
		return (false);
	}


	theForm.code.value = enlevespace(theForm.code.value);
	if (theForm.code.value == "") 
	{	alert("Пожалуйста введите защитный код, проверьте на соответствие введенного кода и кода на картинке.");
        theForm.code.style.backgroundColor='#ffcccc';
		theForm.code.focus();
		return (false);
	}

	theForm.focus();
	return(true);
}

}