// CREATING THE REQUEST

function createRequestObject()
{
	try
	{
		xmlhttp = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
	}
	catch(e)
	{
		alert('Sorry, but your browser doesn\'t support XMLHttpRequest.');
	}
	return xmlhttp;
}

var http = createRequestObject();
function registercheck()
{
	var submission = document.getElementById('cptc').value;
	var url = 'testcaptcha.asp?val1=' + submission ;
	docheck(url, displayregistercheck);
}

function docheck(url, callback)
{
	http.open('GET', url, true);
	http.onreadystatechange = displayregistercheck;
	http.send(null);
}

function displayregistercheck()
{
	if(http.readyState == 4)
	{
	
		var showcheck = http.responseText;
		if(showcheck == '1')
		{
			document.getElementById('cptc').style.border = '1px solid #49c24f';
			document.getElementById('cptc').style.background = '#bcffbf';
			validate();
		}
		if(showcheck == '0')
		{
			document.getElementById('cptc').style.border = '1px solid #c24949';
			document.getElementById('cptc').style.background = '#ffbcbc';
			alert("Wrong Validation Code");
			document.newpost.cptc.focus();
			document.newpost.validCaptcha.value= 0;
			return 0;
		}
	}
}


