function vote()
{
	var o=document.getElementById("val").value;
	var id=document.getElementById("id").value;
	var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
 try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp = false;
  }
 }
@end @*/
	if (!xmlhttp && typeof XMLHttpRequest!='undefined')
	{
		xmlhttp = new XMLHttpRequest();
	}
	xmlhttp.open("GET", "vote.php?value="+o+"&id="+id,true);
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4)
		{
			if(xmlhttp.responseText=="-1")
				alert("Возникла ошибка. Повторите голосование.");
			else
				if(xmlhttp.responseText=="-2")
					alert("Вы или кто-то другой с Вашего IP-адреса уже оценил эту позицию.")
				else
				{
					alert("Спасибо! Ваш голос учтён.");
				}
		}
	}
	xmlhttp.send(null);
}
function requestpassword()
{
	var id=document.getElementById("email").value;
	var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
 try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp = false;
  }
 }
@end @*/
	if (!xmlhttp && typeof XMLHttpRequest!='undefined')
	{
		xmlhttp = new XMLHttpRequest();
	}
	xmlhttp.open("GET", "requestpassword.php?email="+id,true);
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4)
		{
			alert(xmlhttp.responseText);
		}
	}
	xmlhttp.send(null);
}
function showhide_regtype()
{
	document.getElementById("fizl").style.display=document.reg.typ[0].checked?"block":"none";
	document.getElementById("yurl").style.display=document.reg.typ[1].checked?"block":"none";
}
function isNotEmpty(elem)
{		
	var str=elem.value;
	var re=/.+/;
	return !str.match(re);
}
function isEmail(elem)
{
	var str=elem.value;
	var re=/^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
	return !str.match(re);
}

function validate_reg_form()
{
	if(!document.reg.typ[0].checked&&!document.reg.typ[1].checked)
	{
		alert("Выберите тип пользователя");
		return;
	}
	if(document.reg.typ[0].checked)
	{
		if(isNotEmpty(document.reg.fsurname))
		{
			alert("Укажите фамилию");
			document.reg.fsurname.focus();
			return;
		}
		if(isNotEmpty(document.reg.fname))
		{
			alert("Укажите имя");
			document.reg.fname.focus();
			return;
		}
		if(isEmail(document.reg.femail))
		{
			alert("Укажите e-mail");
			document.reg.femail.focus();
			return;
		}
		if(isNotEmpty(document.reg.fhometelephone))
		{
			alert("Укажите домашний телефон");
			document.reg.fhometelephone.focus();
			return;
		}
	}
	if(document.reg.typ[1].checked)
	{
		if(document.reg.uopf.selectedIndex==0)
		{
			alert("Укажите ОПФ");
			document.reg.fopf.focus();
			return;
		}
		if(isNotEmpty(document.reg.ucompanyname))
		{
			alert("Укажите название компании");
			document.reg.ucompanyname.focus();
			return;
		}
		if(isNotEmpty(document.reg.usurname))
		{
			alert("Укажите фамилию");
			document.reg.usurname.focus();
			return;
		}
		if(isNotEmpty(document.reg.uname))
		{
			alert("Укажите имя");
			document.reg.uname.focus();
			return;
		}
		if(isEmail(document.reg.uemail))
		{
			alert("Укажите e-mail");
			document.reg.uemail.focus();
			return;
		}
		if(isNotEmpty(document.reg.uworkphone))
		{
			alert("Укажите рабочий телефон");
			document.reg.uworkphone.focus();
			return;
		}
	}
	if(isNotEmpty(document.reg.login))
	{
		alert("Укажите логин");
		document.reg.login.focus();
		return;
	}
	if(isNotEmpty(document.reg.password))
	{
		alert("Укажите пароль");
		document.reg.password.focus();
		return;
	}
	if(document.reg.password.value!=document.reg.password2.value)
	{
		alert("Пароли не совпадают");
		document.reg.password2.focus();
		return;
	}
	document.reg.submit();

}

function validate_infochange_form()
{		
	if(document.reg.typ.value==0)
	{		
		if(isNotEmpty(document.reg.fsurname))
		{
			alert("Укажите фамилию");
			document.reg.fsurname.focus();
			return;
		}		
		if(isNotEmpty(document.reg.fname))
		{
			alert("Укажите имя");
			document.reg.fname.focus();
			return;
		}		
		if(isEmail(document.reg.femail))
		{
			alert("Укажите e-mail");
			document.reg.femail.focus();
			return;
		}		
		if(isNotEmpty(document.reg.fhometelephone))
		{
			alert("Укажите домашний телефон");
			document.reg.fhometelephone.focus();
			return;
		}		
	}
	else
	{		
		if(isNotEmpty(document.reg.ucompanyname))
		{
			alert("Укажите название компании");
			document.reg.ucompanyname.focus();
			return;
		}			
		if(isNotEmpty(document.reg.usurname))
		{
			alert("Укажите фамилию");
			document.reg.usurname.focus();
			return;
		}		
		if(isNotEmpty(document.reg.uname))
		{
			alert("Укажите имя");
			document.reg.uname.focus();
			return;
		}		
		if(isEmail(document.reg.uemail))
		{
			alert("Укажите e-mail");
			document.reg.uemail.focus();
			return;
		}		
		if(isNotEmpty(document.reg.uworkphone))
		{
			alert("Укажите рабочий телефон");
			document.reg.uworkphone.focus();
			return;
		}		
	}
	if(isNotEmpty(document.reg.password))
	{
		alert("Укажите пароль");
		document.reg.password.focus();
		return;
	}
	if(document.reg.password.value!=document.reg.password2.value)
	{
		alert("Пароли не соврадают");
		document.reg.password2.focus();
		return;
	}
	document.reg.submit();

}
