function HTTPClient()
{};
HTTPClient.prototype = {
    xmlhttp: null,
    callback: null,
    loadRemoteContent: function(url, callbackFunction) 
    {
        this.callback = function(self) {
            eval(callbackFunction + '(self.xmlhttp);');
        }
        var self = this;
        if (window.XMLHttpRequest) {
            this.xmlhttp = new XMLHttpRequest();
            this.xmlhttp.onreadystatechange = function() {
                self.processReqChange(self);
            }
            this.xmlhttp.open("GET", url, true);
            this.xmlhttp.send(null);
        } else if (window.ActiveXObject) {
            this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            if (this.xmlhttp) {
                this.xmlhttp.onreadystatechange = function() {
                    self.processReqChange(self);
                };
				//alert(url);
                this.xmlhttp.open("GET", url, true);
                this.xmlhttp.send();
            }
        }
    },
    processReqChange: function(self) 
    {
        if (this.xmlhttp.readyState == 4) {
           if (this.xmlhttp.status == 200) {
              self.callback(self);
            } else {
                alert("There was a problem retrieving the data:\n" + this.xmlhttp.statusText);
            }
        }
    }
}
var expanding = false;
function call_country( country_id )
{
		
		var r = Math.random();
        var httpClient = new HTTPClient();
		httpClient.loadRemoteContent("get_state.php?country_id="+country_id+"&t2="+r, 'handleCountry');
}

/* Function for the zoomox registeration*/
function call_zoomox_country( continentID, countryID )
{
		var r = Math.random();
        var httpClient = new HTTPClient();
		httpClient.loadRemoteContent("get_zoomox_country.php?continentID="+continentID+"&country="+ countryID +"&t2="+r, 'handlezoomoxCountry');
}

function handlezoomoxCountry(response)
{
    var message = response.responseText;
    var temp;
	Countrydiv.innerHTML = message;
}

/* for the state function*/
function call_zoomox_state( countryID, stateID )
{
		var r = Math.random();
        var httpClient = new HTTPClient();
		httpClient.loadRemoteContent("get_zoomox_state.php?countryID="+countryID+"&state="+stateID+"&t2="+r, 'handlezoomoxstate');
}

function handlezoomoxstate(response)
{
    var message = response.responseText;
    var temp;
	Statediv.innerHTML = message;
}
/* closing for the state function*/


/* for the county function*/
function call_zoomox_county( stateID, countryID, countyID, cityID )
{		
		var r = Math.random();
        var httpClient = new HTTPClient();
		httpClient.loadRemoteContent("get_zoomox_county.php?stateID="+stateID+"&countryID="+ countryID +"&countyID="+ countyID +"&cityID="+ cityID +"&t2="+r, 'handlezoomoxcounty');
}

function handlezoomoxcounty(response)
{
    var message = response.responseText;
    var temp;
	temp = message.split("#");
	Countydiv.innerHTML = temp[0];

	if(temp[1] <= 0){
		call_zoomox_city( '', temp[2], temp[3], temp[4] );
	} else
		call_zoomox_city( temp[5], temp[2], temp[3], temp[4] );
	}

/* closing for the county function*/

/* for the city function*/
function call_zoomox_city( countyID, stateID, countryID, cityID )
{
		var r3 = Math.random();
        
		//alert(countyID+ ' '+stateID+' '+countryID+ cityID)
		var httpClient = new HTTPClient();
		//alert("includes/lib/get_zoomox_city.php?countyID="+countyID+"&stateID="+ stateID +"&countryID="+ countryID +"&n="+r3)
		httpClient.loadRemoteContent("get_zoomox_city.php?countyID="+countyID+"&stateID="+ stateID +"&countryID="+ countryID +"&cityID="+ cityID +"&n="+r3, 'handlezoomoxcity');
}

function handlezoomoxcity(response)
{
    var message = response.responseText;
    var temp;
	CityDiv.innerHTML = message;
}
/* closing for the state function*/



/*  closing of the all zoomox function */





function handleCountry(response)
{
   
    var message = response.responseText;
    var temp;
	//temp = message.split("#");
	statediv.innerHTML = message;
}

function call_state( state_id )
{
		var r = Math.random();
        var httpClient = new HTTPClient();
		httpClient.loadRemoteContent("get_county.php?state_id="+state_id+"&t2="+r, 'handleState');
}

function handleState(response)
{
   
    var message = response.responseText;
    var temp;
	temp = message.split("#");
	countydiv.innerHTML = temp[0];
	
	if(temp[1] <= 0){
		call_county( '', temp[2] );
	}
}

function call_county( county_id, state_id )
{
		
		var r = Math.random();
        var httpClient = new HTTPClient();
		httpClient.loadRemoteContent("lib/get_city.php?county_id="+county_id+"&state_id="+state_id+"&t2="+r, 'handleCounty');
}

function handleCounty(response)
{
   
    var message = response.responseText;
	citydiv.innerHTML = message;
}

