$(document).ready(function() {
	
	$('#yebab-shop-filter-form').submit(function(){
  //Drupal.t
    // Display warning if category is not selected 
    if($('#edit-shop-filter-category').val() == 0 &&  $("#edit-shop-filter-category").is(':hidden') ==  false) {
      $('#edit-shop-filter-category').css('border', '1px solid red');
        return false;
      }
  });

  // Hide fieldset if city is empty
  if ($('#edit-shop-filter-city').val() == 0) {
    $('#yebab-shop-filter-form fieldset').hide();
  }
  /*
  //When category change, restore the city to non-selected  
  $('#edit-shop-filter-category').change (function() {
    $('#edit-shop-filter-city').val(0);
  });
  
  $('#edit-shop-filter-city').change (function() {
    var c = $(this).val();
    var cat = $('#edit-shop-filter-category').val();
    var pa = $(location).attr('href');
    
    if (c == 0) {
      $('#yebab-shop-filter-form fieldset').hide();
    }

    $.post(Drupal.settings.basePath + 'yebab-shop-filter-write-city', {city: c, category: cat, path: pa}, function(output) {

      if (output != '' && output.length != 0 && output != null) {

        $('#yebab-shop-filter-form fieldset:first').html(output);
        $('#yebab-shop-filter-form fieldset:first').show();
        // Check if no districts or neighborhoods are returned, to hide the fieldset
        if ($('#yebab-shop-filter-form .fieldset-wrapper .form-checkbox').length == 0) {
          $('#yebab-shop-filter-form fieldset').hide();
        }
      }
    });
  });
  */
});

