var xmlHttp=createXmlHttpRequestObject();

function createXmlHttpRequestObject()
{
	var xmlHttp;
	if (window.ActiveXObject)
	{
		try
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(e)
		{
			xmlHttp=false;
		}
	}
	else
	{
		try
		{
			xmlHttp=new XMLHttpRequest();
		}
		catch(e)
		{
			xmlHttp=false;
		}
	}
	if (!xmlHttp)
		alert("Ошибка создания объекта XMLHttpRequest.");
	else
		return xmlHttp;
}



function checker()
{

	if (xmlHttp.readyState==4||xmlHttp.readyState==0)
	{
		login=encodeURIComponent(document.getElementById("login").value);
		password=encodeURIComponent(document.getElementById("password").value);
		password1=encodeURIComponent(document.getElementById("password1").value);
		name=encodeURIComponent(document.getElementById("name").value);
		mail=encodeURIComponent(document.getElementById("mail").value);
		xmlHttp.open("GET","do/querreg.php?l="+login+"&p="+password+"&p1="+password1+"&m="+mail+"&n="+name,true);
		xmlHttp.onreadystatechange=handleServerResponse;
		xmlHttp.send(null);
	}
	else
		setTimeout('checker()',1000);
}

function handleServerResponse()
{
	if (xmlHttp.readyState==4)
	{
		if (xmlHttp.status==200)
		{
			response=xmlHttp.responseText;
			document.getElementById("mess").innerHTML=response;
			if(response=='okregistry')
			{
document.getElementById("mess").innerHTML='<input type="submit" value="Зарегистрироваться" style="width:90; font-size:10">'
			}
			setTimeout('checker()',1000);
		}
		else
		{
			alert("При обращении к серверу возникла проблема: "+xmlHttp.statusText);
		}
	}
}

function getRadioValue(radioGroupObj)
{
  for (var i=0; i < radioGroupObj.length; i++)
    if (radioGroupObj[i].checked) return radioGroupObj[i].value;
}

function updaterec()
{
var v = getRadioValue(document.getElementById("oprosform").opros);
	if (xmlHttp.readyState==4||xmlHttp.readyState==0)
	{
		xmlHttp.open("GET","do/oprosnik.php?opros="+v,true);
		xmlHttp.onreadystatechange=retriv;
		xmlHttp.send(null);
	}
	else
	setTimeout('updaterec()',1000);
}

function retriv()
{
if (xmlHttp.readyState==4)
	{
		if (xmlHttp.status==200)
		{
			response=xmlHttp.responseText;
			document.getElementById('opros1').innerHTML=response;
		}
		else
		{
			alert("При обращении к серверу возникла проблема: "+xmlHttp.statusText);
		}
}}


