function mover(target)
{
target.style.borderColor='#FF0000'; target.border=2;
}
function mout(target)
{
target.style.borderColor='#999999';target.border=1;
}
function setCookie (name, value, expires, path, domain, secure) {
      document.cookie = name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}
function getCookie(name) {
	var cookie = " " + document.cookie;
	var search = " " + name + "=";
	var setStr = null;
	var offset = 0;
	var end = 0;
	if (cookie.length > 0) {
		offset = cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			end = cookie.indexOf(";", offset)
			if (end == -1) {
				end = cookie.length;
			}
			setStr = unescape(cookie.substring(offset, end));
		}
	}
	return(setStr);
}

function setCat(category)
{
	tempstr = getCookie("cat");
	if(tempstr==null)tempstr = 'c';
	tempstr = tempstr + ";" + category + ";";
	setCookie("cat",tempstr);
}

function resetCat(category)
{
	tempstr = getCookie("cat");
	i=tempstr.indexOf(";"+category+";");
	str=";"+category+";";
	j=i+str.length;
	str = tempstr.substring(0,i) + tempstr.substring(j,tempstr.length);
	setCookie("cat",str);
}
function check_fields()
{
	error=false;
	mail=/^([a-z0-9]([\._-]?[a-z0-9])*@[a-z0-9]([\._-]?[a-z0-9])*([\.][a-z]{2,4}))?$/;
	fio=/^([А-Я]{1})(([а-я])*)$/;
	otch=/(^([А-Я]{1})(([а-я])*)$)?/;
	index=/[0-9]{6}/;
	flat=/^([1-9]([0-9]{0,3}))?$/;
	house=/^[1-9][0-9]{0,2}(([\/][1-9])||([а-я]))?$/;
	home_phone=/^[0-9\(\)-]*$/;
	contact_phone=/^[0-9\(\)-]+$/;
	ul_town=/^[А-яа-я\.-]+$/;
	if(!mail.test(document.all.mail.value))
	{
		document.all.mail.style.backgroundColor="#FF0000";
		error=true;
	}
	else
		document.all.mail.style.backgroundColor="#CCCCCC";
		
	if(!fio.test(document.all.first_name.value))
	{
		document.all.first_name.style.backgroundColor="#FF0000";
		error=true;
	}
	else
		document.all.first_name.style.backgroundColor="#CCCCCC";
		
	if(!otch.test(document.all.second_name.value))
	{
		document.all.second_name.style.backgroundColor="#FF0000";
		error=true;
	}
	else
		document.all.second_name.style.backgroundColor="#CCCCCC";
		
	if(!fio.test(document.all.surname.value))
	{
		document.all.surname.style.backgroundColor="#FF0000";
		error=true;
	}
	else
		document.all.surname.style.backgroundColor="#CCCCCC";
		
	if(!index.test(document.all.index.value))
	{
		document.all.index.style.backgroundColor="#FF0000";
		error=true;
	}
	else
		document.all.index.style.backgroundColor="#CCCCCC";
		
	if(!flat.test(document.all.flat.value))
	{
		document.all.flat.style.backgroundColor="#FF0000";
		error=true;
	}
	else
		document.all.flat.style.backgroundColor="#CCCCCC";
	
	if(!house.test(document.all.house.value))
	{
		document.all.house.style.backgroundColor="#FF0000";
		error=true;
	}
	else
		document.all.house.style.backgroundColor="#CCCCCC";
		
	if(!home_phone.test(document.all.home_phone.value))
	{
		document.all.home_phone.style.backgroundColor="#FF0000";
		error=true;
	}
	else
		document.all.home_phone.style.backgroundColor="#CCCCCC";
		
	if(!contact_phone.test(document.all.contact_phone.value))
	{
		document.all.contact_phone.style.backgroundColor="#FF0000";
		error=true;
	}
	else
		document.all.contact_phone.style.backgroundColor="#CCCCCC";
		
	if(!ul_town.test(document.all.nas_punkt.value))
	{
		document.all.nas_punkt.style.backgroundColor="#FF0000";
		error=true;
	}
	else
		document.all.nas_punkt.style.backgroundColor="#CCCCCC";
		
	if(!ul_town.test(document.all.street.value))
	{
		document.all.street.style.backgroundColor="#FF0000";
		error=true;
	}
	else
		document.all.street.style.backgroundColor="#CCCCCC";
		
	if(error)
		alert("При вводе формы вы допустили ошибки. Поля введенные с ошибками отображены красным цветом.");
	else
		document.all.send_form.submit();
	
}