
var http;
var username;
//var requestUsername_waiting=false;


//instantiate the XMLHttpRequest object
function getHTTPObject() {
    if (typeof XMLHttpRequest != 'undefined') {
        return new XMLHttpRequest();
    }
    try {
        return new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
        try {
            return new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {}
    }
    return false;
}

//initialize the XMLHttpObject.
//Call this near the beginning of your php file.
function initializeHTTPObject()
{
	http = getHTTPObject();
}

//This is the tool. Use this function to request a username from the server script given a u_id
function requestUsername(u_id,object)
{	
	var y=document.getElementById(object);

	//the name of the php script to run
	var requestusername_url = "http://www.itsanetwork.com/members/requestusername.php?u_id="; 

	//calling the php script
	http.open("GET", requestusername_url + escape(u_id), true);

	//when we receive a response call this function
	http.onreadystatechange = function()
	{
	    //if the request is complete
	    if(http.readyState==4)
	    {
		//we are no longer waiting on the request
		//requestUsername_waiting=false;
	
		//read the response into a global variable
		//In this case, we have received our information as simple text via
		//the responseText property of our XMLHTTPRequest object.  Information
		//can, however, be returned as XML or as properties of a predefined javascript object. 
		username = http.responseText;
	
		y.innerHTML = username;
	    }
	}

	http.send(null);

} 




