// 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;
var clientPC = navigator.userAgent.toLowerCase(); // Get client info
	var clientVer = parseInt(navigator.appVersion); // Get browser version
	var is_ie = ((clientPC.indexOf("msie") != -1) && (clientPC.indexOf("opera") == -1));
	var is_op = ( (clientPC.indexOf("opera") != -1));
	var is_nav = ((clientPC.indexOf('mozilla')!=-1) && (clientPC.indexOf('firefox')!=-1));

function ajax() {
	// Make a new XMLHttp object
	if (typeof window.ActiveXObject != 'undefined' ) doc = new ActiveXObject("Microsoft.XMLHTTP");
	else doc = new XMLHttpRequest();
}
var destination3 = null;
var destination4 = null;
function SelectCountry(section, destination){destination.innerHTML = "Loading data...";
    	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.onreadystatechange = 'load1';
	       doc.open("GET", "include/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, str){
    if (id_country != '') {
    	destination3 = destination;
    	destination.innerHTML = "Loading data...";	
//    	alert(destination.innerHTML);
		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){
	    	function load1() {
				if (doc.readyState == 4) {
				if (doc.status == 200) {
					if (doc.responseText!='') destination3.innerHTML = doc.responseText;
					
				}}
			}
	    	
	       destination.innerHTML = "Loading data...";
//	       alert(destination.innerHTML);
			
		   
//		   alert("include/location.php?sec=" + section + "&sel=region&id_country=" + id_country);
	       doc.open("GET", "include/location.php?sec=" + section + "&sel=region&id_country=" + id_country);
	       doc.onreadystatechange = load1;
	       doc.send("");
//	       alert("include/location.php?sec=" + section + "&sel=region&id_country=" + id_country);
	    	// 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";
    }
    if(section=='ip') {widths = 'width:160px'; }else widths = '';
    
    destination2.innerHTML = '<select name="city" disabled class="reg_user_login" style="' + widths + '">' +
						'<option value="0"> '+ str +' </option>' +
					'</select>';
}




function SelectCity(section, id_region, destination){
    if (id_region != '') {destination.innerHTML = "Loading data...";
		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...";	
	       destination4 = destination;
	       doc.onreadystatechange = load2;
	       doc.open("GET", "include/location.php?sec=" + section + "&sel=city&id_region=" + id_region);
	       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 load2() {
        if (doc.readyState == 4) {
        if (doc.status == 200) {
                if (doc.responseText!='') destination4.innerHTML = doc.responseText;
//				alert(destination3.innerHTML);
        }}
}


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", "include/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 = "<div class='my_warning'>Nick is empty</div>";
    }

}

function CheckMail(section, email, destination){
    if (email != '') {
		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", "include/location.php?sec=" + section + "&sel=email_partner&email=" + email, 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 = "<div class='my_warning'>Email is empty</div>";
    }

}

//возвращает элемент с ид 
function ID(id_block){
	return document.getElementById(id_block);
}

//делает блок видимым
function show(id_block){
	ID(id_block).style.display = 'block';
}

//делает блок невидимым
function hid(id_block){
	ID(id_block).style.display = 'none';
}


function toggle_visibility(id) {
var e = document.getElementById(id);
if(e.style.display == 'none')
e.style.display = 'block';
else
e.style.display = 'none';
}

function cl_qhelp(){
	document.getElementById('quick_help').style.display='none';
	document.cookie = "noqhelp=1;path=/";
}

function cl_qhelp1(){
	document.getElementById('quick_help').style.display='none';
	}



