/* ---------------------------- */
/* XMLHTTPRequest Enable 	*/
/* ---------------------------- */
function createObject() {
	var request_type;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer"){
	request_type = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		request_type = new XMLHttpRequest();
	}
		return request_type;
}

var http = createObject();

/* -------------------------- */
/* SEARCH		      */
/* -------------------------- */
function autoname() {
q = document.getElementById('username').value;
// Set the random number to add to URL request
nocache = Math.random();
http.open('get', 'searchusername.cfm?q='+q+'&nocache = '+nocache);
http.onreadystatechange = autonameReply;
http.send(null);
}
function autonameReply() {
if(http.readyState == 4){
	var response = http.responseText;
	if(response!=""){
		document.getElementById('checkusername').innerHTML=response;
		document.getElementById('checkusername').style.display="block";
	} else {
		document.getElementById('checkusername').style.display="none";
	}
}
}

function checkpassword() {
q1 = document.getElementById('password1').value;
q2 = document.getElementById('password2').value;
// Set the random number to add to URL request
nocache = Math.random();
http.open('get', 'checkpassword.cfm?p1='+q1+ '&p2='+q2+ '&nocache = '+nocache);
http.onreadystatechange = checkpasswordReply;
http.send(null);
}
function checkpasswordReply() {
if(http.readyState == 4){
	var response = http.responseText;
	if(response!=""){
		document.getElementById('checkpassword').innerHTML=response;
		document.getElementById('checkpassword').style.display="block";
	} else {
		document.getElementById('checkpassword').style.display="none";
	}
}
}

function checkemail() {
q1 = document.getElementById('emailaddress1').value;
q2 = document.getElementById('emailaddress2').value;
// Set the random number to add to URL request
nocache = Math.random();
http.open('get', 'checkemail.cfm?e1='+q1+ '&e2='+q2+ '&nocache = '+nocache);
http.onreadystatechange = checkemailReply;
http.send(null);
}
function checkemailReply() {
if(http.readyState == 4){
	var response = http.responseText;
	if(response!=""){
		document.getElementById('checkemailaddress').innerHTML=response;
		document.getElementById('checkemailaddress').style.display="block";
	} else {
		document.getElementById('checkemailaddress').style.display="none";
	}
}
}
