// declare new variables for each new div that you add, and link to the div by ID
// var region_div = document.getElementById("region_div");
var doc = null;

function ajax() {
	// Make a new XMLHttp object
	if (typeof window.ActiveXObject != 'undefined' ) doc = new ActiveXObject("Microsoft.XMLHTTP");
	else doc = new XMLHttpRequest();
}

function SelectCountry(section, destination){
    	ajax();
		// Load the result from the response page
		// ** As far a I know firefox will only load a document on the SAME domain!!	
	    if (doc){
	       destination.innerHTML = "Loading data...";
	       doc.open("GET", "location.php?sec=" + section + "&sel=country", false);
	       doc.send(null);
	    	// Write the response to the div	    	
	       destination.innerHTML = doc.responseText;
	    }
	    else{
	      
	       destination.innerHTML = 'Browser unable to create XMLHttp Object';
	    }        
}

function SelectRegion(section, id_country, destination, destination2){
    if (id_country != '') {
		ajax();
		// Load the result from the response page
		// ** As far a I know firefox will only load a document on the SAME domain!!	
	    if (doc){
	       destination.innerHTML = "Loading data...";
	       doc.open("GET", "location.php?sec=" + section + "&sel=region&id_country=" + id_country, false);
	       doc.send(null);
	    	// Write the response to the div	    	
	       destination.innerHTML = doc.responseText;
	    }
	    else{
	      
	       destination.innerHTML = 'Browser unable to create XMLHttp Object';
	    }        
    }
    else {
    	destination.innerHTML = "Country is not selected";
    }
    destination2.innerHTML = "";
}

function SelectCity(section, id_region, destination){
    if (id_region != '') {
		ajax();
		// Load the result from the response page
		// ** As far a I know firefox will only load a document on the SAME domain!!	
	    if (doc){
	       destination.innerHTML = "Loading data...";	
	       doc.open("GET", "location.php?sec=" + section + "&sel=city&id_region=" + id_region, false);
	       doc.send(null);
	    	// Write the response to the div	    	
	       destination.innerHTML = doc.responseText;
	    }
	    else{
	      
	       destination.innerHTML = 'Browser unable to create XMLHttp Object';
	    }        
    }
    else {
    	destination.innerHTML = "Region is not selected";
    }
	    
}

function CheckLogin(section, login, destination){
    if (login != '') {
		ajax();
		// Load the result from the response page
		// ** As far a I know firefox will only load a document on the SAME domain!!	
	    if (doc){
	       destination.innerHTML = "Loading data...";	
	       doc.open("GET", "location.php?sec=" + section + "&sel=login&login=" + login, false);
	       doc.send(null);
	    	// Write the response to the div	    	
	       destination.innerHTML = doc.responseText;
	    }
	    else{
	      
	       destination.innerHTML = 'Browser unable to create XMLHttp Object';
	    }        
    }
    else {
    	destination.innerHTML = "Nick is empty";
    }

}

