// CREATING THE REQUEST

var xmlHttp

function checkForm(str, id)
	{ 
	xmlHttp=GetXmlHttpObject()
	if(xmlHttp==null)
		{
 		alert ("Browser does not support HTTP Request")
 		return
 		}
	var url="plugins/contactus/inc/ajax.php?q="+encodeURI(str)+"&id="+id
	xmlHttp.onreadystatechange = function()
		{
	    	if(xmlHttp.readyState==4)
			{
			text = xmlHttp.responseText
 			document.getElementById(id).style.borderColor = text.substring(0,7);
			document.getElementById(id+"v").innerHTML = text.substring(8)
			}
		}
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	}

function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
 	{ 
		xmlHttp=new XMLHttpRequest();
 	}
	catch (e)
 	{
 		try
  		{
  			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  		}
 		catch (e)
  		{
  			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  		}
	 }
	return xmlHttp;
}

var http = GetXmlHttpObject();
var sess = GetXmlHttpObject();

// SUBMISSION

function check2()
	{
	var submission = document.getElementById('captcha').value;
	var url = 'plugins/contactus/inc/process.php?captcha=' + submission;
	docheck(url, displaycheck);
	}


function docheck(url, callback)
	{
	http.open('GET', url, true);
	http.onreadystatechange = displaycheck;
	http.send(null);
	}

function displaycheck()
	{	
	if(http.readyState == 4)
		{
		var showcheck = http.responseText;
		if(showcheck == '1')
		{	
			//document.getElementById('captcha').style.border = '1px solid #8f5f2c';
			//document.getElementById('captcha').style.background = '#eef5e3';
			document.getElementById('captcha').form.submit();
		}
		if(showcheck == '0')
		{
			//document.getElementById('captcha').style.border = '1px solid #e87a35';
			document.getElementById('captcha').style.background = '#e87a35';
			document.getElementById('captchav').innerHTML = "<img src='plugins/contactus/inc/images/bad.gif' style='margin:0 5px 0 10px' align='absmiddle' /> Ошибка в коде.";
		}
	}
}
