$(document).ready(function() {
    $('td.by-class a').click( function(){
        var bid = $(this).attr('id').split('_')[1];
        if ($(this).hasClass('active') ){
            $(this).removeClass('active');    
            $(this).parent().find('input[type=checkbox]#klassbox_'+ bid).removeAttr('checked');
        }else{ 
            $(this).addClass('active');
            $(this).parent().find('input[type=checkbox]#klassbox_'+ bid).attr('checked', 'checked');
        }
        return false;
    });
    $('a.button-search-accounts').click( function(){
        $('form#filters-form').submit();
        return false;
    });
    
    $('a.button-reset-filter').click( function(){
        // сбрасываем сервер
        $('select#id_server').val('');
        // сбрасываем расу
        $('td.by-race input[type=checkbox]').removeAttr('checked');
        
        // сброс фильтра по цене
        $('td.by-price input[type=radio][value=""]').attr('checked', 'checked');
        
        // сбрасываем класс
        $('td.by-class a').removeClass('active');
        $('td.by-class input[type=checkbox]').removeAttr('checked');
        return false;
    });
    
});
