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();
var sess = createRequestObject();

function check()
{
	var profile = document.getElementById('profile').value;
	var profilepassword = document.getElementById('profilepassword').value;
	var profileusername = document.getElementById('profileusername').value;
	var sessid = document.getElementById('sessid').value;
	var url = 'http://www.gayuserid.com/incs/' + profile + 'addprocess.php?profilepassword=' + profilepassword + '&profileusername=' + profileusername + '&sessid=' + sessid;
	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 == '0')
		{
			document.getElementById('boven').innerHTML = '<i>something wrong:</i>';

		}
		if(showcheck == '1')
		{
			document.getElementById('submit').disabled = 'true';
			document.getElementById('boven').innerHTML = '<i>thank you, your information is added</i>';
			document.getElementById('eerst').innerHTML = '';
			window.location.replace( 'http://www.gayuserid.com/logged.php' );

		}
		if(showcheck == '2')
		{
			document.getElementById('boven').innerHTML = '<i>something wrong with your username</i>';
			document.getElementById('profileusername').style.border = '1px solid #c24949';
			document.getElementById('profileusername').style.background = '#ffbcbc';
			document.getElementById('profilepassword').style.border = '1px solid #49c24f';
			document.getElementById('profilepassword').style.background = '#bcffbf';
			

		}
		if(showcheck == '3')
		{
			document.getElementById('boven').innerHTML = '<i>something wrong with your password</i>';
			document.getElementById('profilepassword').style.border = '1px solid #c24949';
			document.getElementById('profilepassword').style.background = '#ffbcbc';

		}
		
		if(showcheck == '4')
		{
			document.getElementById('boven').innerHTML = '<i>username and password doesnot match</i>';
			document.getElementById('profilepassword').style.border = '1px solid #c24949';
			document.getElementById('profilepassword').style.background = '#ffbcbc';

		}
		
	}
}

