var http = createRequestObject();

function checkUsername()
{
	http.open('GET', 'index.php?action=ajaxreg_checkusername&xml=true&username=' + document.creator.user.value);
	http.onreadystatechange = handleResult; 
	http.send(null);
}

function checkEmail()
{
	http.open('GET', 'index.php?action=ajaxreg_checkemail&xml=true&email=' + document.creator.email.value);
	http.onreadystatechange = handleResult; 
	http.send(null);
}

function checkPasswrd1()
{
	http.open('GET', 'index.php?action=ajaxreg_checkpasswrd1&xml=true&passwrd1=' + document.creator.passwrd1.value + '&username=' + document.creator.user.value);
	http.onreadystatechange = handleResult; 
	http.send(null);
}

function checkPasswrd2()
{
	http.open('GET', 'index.php?action=ajaxreg_checkpasswrd2&xml=true&passwrd1=' + document.creator.passwrd1.value + '&passwrd2=' + document.creator.passwrd2.value);
	http.onreadystatechange = handleResult; 
	http.send(null);
}


function handleResult()
{
	if (http.readyState == 4)
	{ 
		var response = http.responseXML;
		var root = response.getElementsByTagName('result')[0];
		var status = root.getElementsByTagName('status')[0];
		var css = root.getElementsByTagName('css')[0];
		var field = root.getElementsByTagName('field')[0];
		var message = root.getElementsByTagName('message')[0];
		document.getElementById(field.firstChild.nodeValue).style.cssText = css.firstChild.nodeValue
		document.getElementById(field.firstChild.nodeValue).innerHTML = '&nbsp;' + message.firstChild.nodeValue + '&nbsp;';
	}
}

function createRequestObject()
{
	var request_o; //declare the variable to hold the object.
	var browser = navigator.appName; //find the browser name
	
	if (browser == "Microsoft Internet Explorer")
	{
		/* Create the object using MSIE's method */
		request_o = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else
	{
		/* Create the object using other browser's method */
		request_o = new XMLHttpRequest();
	}
	
	return request_o; //return the object
}