function changeRegion(prefix)
{
    $('#'+prefix+'_city').html('<option value="">Загрузка...</option>');
    $.jNice.SelectUpdate($('#'+prefix+'_city').get(0));
    $.getJSON(atm_json, {'region_id': $('#'+prefix+'_region').val(), 'act':'show_region'}, function(data){
        var html = '';
        if (data.atm_cities.length > 1 || data.atm_cities.length == 0)
        {
            html = '<option value="">Все города</option>';
        }
        for (var i=0; i < data.atm_cities.length; i++)
        {
            html += '<option value="'+data.atm_cities[i].id+'">'+data.atm_cities[i].name+'</option>';
        }
        $('#'+prefix+'_city').html(html);
        $.jNice.SelectUpdate($('#'+prefix+'_city').get(0));
        if (data.atm_cities.length == 1)
        {
            changeCity(prefix);
        }
        else
        {
            $('#'+prefix+'_district').html('<option value="">Все районы</option>');
            $.jNice.SelectUpdate($('#'+prefix+'_district').get(0));
        }
    });
}

function changeCity(prefix)
{
    $('#'+prefix+'_district').html('<option value="">Загрузка...</option>');
    $.jNice.SelectUpdate($('#'+prefix+'_district').get(0));
    $.getJSON(atm_json, {'city_id': $('#'+prefix+'_city').val(), 'act':'show_city'}, function(data){
        var html = '<option value="">Все районы</option>';
        for (var i=0; i < data.atm_districts.length; i++)
        {
            html += '<option value="'+data.atm_districts[i].id+'">'+data.atm_districts[i].name+'</option>';
        }
        $('#'+prefix+'_district').html(html);
        $.jNice.SelectUpdate($('#'+prefix+'_district').get(0));
    });
}

if ($.browser.msie)
{
    $(document).ready(function() {
        $('.h-section table th:last-child').addClass('last-child');
        $('.h-section table tr:first-child').addClass('first-child');
        $('.h-section table td:first-child').addClass('first-child');
    });
}
