$(function(){
   
   // задание значений фильтрам
   // var reg=/&?brand=(\d+)/;
   // var arr=reg.exec(location.search);
   // if( arr.length >= 2 && arr[1] ) {
      // $('#brandFilter').val( arr[1] );
   // }
   // var reg=/&?area=(\d+)/;
   // var arr=reg.exec(location.search);
   // if( arr.length >= 2 && arr[1] ) {
      // $('#productAreaFilter').val( arr[1] );
   // }
   
   // прячем кнопку, дальше все аяксом
   // $('#submitButton').hide();
   
   // изменение фильтров в списке товаров
   $('#catalog_filter select').change(function(){
      var filter_select = $('#catalog_filter select').index(this);
      if( $(this).val() != 0 ) {
      $.ajax({
        type: "POST",
        url: "/_indy/func/ajax_catalog.php",  
        data: 'action=get_subdirs&dir_id=' + $(this).val(),
        success: function( resp ) {
         eval( 'var data=' + resp );
         if( data && data.status == 'ok' ) {
            if( data.dirs && data.dirs.length ) {
               var opts = '<option value="0">Все виды</option>';
               $.each(data.dirs, function(i,item){
                  opts += '<option value="' + item.id + '">' + item.name + '</option>';
               });
               $("#catalog_filter select").eq( filter_select + 1 ).html( opts ).attr('disabled', false);
               // $("#catalog_filter").trigger('submit');
            }//if data.dirs
            
         } else {
            alert( 'При выполнении запроса возникла ошибка.' );
         }//if data.status
        },
        error: function( ) {
         alert( "Сервер не отвечает" );
        }
      });
      } else {//
         $('#catalog_filter select').each(function(i,item){
            if( $('#catalog_filter select').index(item) > filter_select ) {
               var opts = '<option value="0">Все виды</option>';
               $(item).html( opts ).attr('disabled', true);
            }
         });
         
      }//if val
      
   });
   
   
   $('.card-content').hide();
   $('.card-content:first').show();
   $('.card-links a').click(function(){
      $('.card-links a').removeClass('card-on');
      $(this).addClass('card-on');
      
      $('.card-content').slideUp();
      $('.card-content').eq($('.card-links a').index(this)).slideDown();
      return false;
   });
   
/*    $('.main-menu a').click(function(){
      if( $(this).next(':hidden').length ) {
         $(this).next().show();
         return false;
      } else {
         return true;
      }
   });
 */   
});