function loc_sel_country(sel_ctry, type) {
	
	if (typeof(type) == 'undefined') {
	    type = 0;
	}

	AjaxRequest.get({
		'url':'/ajax_locations/country.php'
		,'sel': sel_ctry
		,'type': type
		,'onLoading': function(req)	{ /*divs.innerHTML = 'Loading';*/ }
		,'onSuccess': function(req)	{ div1.innerHTML = req.responseText; }
		,'onError':   function(req)	{ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
	});
}

function loc_sel_region(sel_reg, sel_ctry, type) {
    
	if (typeof(type) == 'undefined') {
	    type = 0;
	}
	
	AjaxRequest.get({
		'url':'/ajax_locations/region.php'
		,'par': sel_ctry
		,'sel': sel_reg
		,'type': type
		,'onLoading': function(req)	{ /*divs.innerHTML = 'Loading';*/ }
		,'onSuccess': function(req)	{ 
		    if (req.responseText=='&nbsp;') {
		        div2.style.display = 'none';
                div2.innerHTML = ''; 
		    } else {
		        div2.style.display = 'block';
                div2.innerHTML = req.responseText; 
		    }
		}
		,'onError':   function(req)	{ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
	});
}

function loc_sel_city(sel_city, sel_reg, type) {
    
	if (typeof(type) == 'undefined') {
	    type = 0;
	}
	
	AjaxRequest.get({
		'url':'/ajax_locations/city.php'
		,'par': sel_reg
		,'sel': sel_city
		,'type': type
		,'onLoading': function(req)	{ /*divs.innerHTML = 'Loading';*/ }
		,'onSuccess': function(req)	{ 
		    if (req.responseText=='&nbsp;') {
		        div3.style.display = 'none';
                div3.innerHTML = ''; 
		    } else {
		        div3.style.display = 'block';
                div3.innerHTML = req.responseText; 
		    }
		}
		,'onError':   function(req)	{ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
	});
}

function loc_sel_init(sel_ctry, sel_reg, sel_city, type) {
    div1 = document.getElementById("sel_country");
    div2 = document.getElementById("sel_region");
    div3 = document.getElementById("sel_city");
    
    loc_sel_country(sel_ctry, type);
    loc_sel_region(sel_reg, sel_ctry, type);
    loc_sel_city(sel_city, sel_reg, type);
}

function loc_zip_init(type, sel_ctry) {
    if ( type == -1 ) { // in search
        // show/hide nothing
    } else if ( type == 1 ) { // in admin
        if ( sel_ctry == 'BE' || sel_ctry == 'FR' || sel_ctry == '-1' ) {
            showRow('zip_row');
        } else {
            hideRow('zip_row');
        }
    } else { // not in admin
        if ( sel_ctry == 'BE' || sel_ctry == 'FR' || sel_ctry == '-1' ) {
            hideRow('zip_row');
        } else {
            showRow('zip_row');
        }
    }
}
