var fields = ['country','region','city'];
function hideSelect(field){
    var index_hide = fields.length;
    for(var i=0;i<fields.length;i++){
        if(fields[i] == field){
            index_hide = i;
        }
        if(index_hide<i){
            $("#"+fields[i]).hide();
        }
    }
}
function showSelect(field){
    var index = fields.length;
    for(var i=0;i<fields.length;i++){
        if(fields[i] == field){
            index = i;
        }
    }
    $("#"+fields[index]).show();
}
function getCountry(selectId,lastSelectId){
    var select = $('#'+selectId).val();
    $.ajax({
        type :"GET",
        dataType: "json",
        url:'/filters/ajax/autocomplete/get/'+selectId+'/country/'+select+'/rand/' + Math.random(),
        success: function(data){
            showSelect(lastSelectId);
            if($('#'+lastSelectId)[0].length > 0){
                $('#'+lastSelectId+'>option').remove();
            }
            $.each(data.items,function(i){
                var option = new Option(data.items[i].name,data.items[i].id);
                var dropdownList = $('#'+lastSelectId)[0];
                if ($.browser.msie) {
                    dropdownList.add(option);
                } else {
                    dropdownList.add(option, null);
                }
            });
        }
    });
}