// MENU DESPLAZAMIENTO


  var 
  speed = 1000,   // animation speed
  $wall = $('#contenido_tiendas').find('.socios_comerciales'),

  masonryOptions = { // initial masonry options
  itemSelector: '.box:not(.invis)',
  animate: true,
  animationOptions: {
  duration: speed,
  queue: false
    }
  };

// run on window.load so we can capture any incoming hashes
  $(window).load(function(){
  // run masonry on start-up to capture all the boxes we'll need
  $wall.masonry(masonryOptions);
  if ( window.location.hash ) {
    // get rid of the '#' from the hash
    var possibleFilterClass = window.location.hash.replace('#', '');
    switch (possibleFilterClass) {
    // if the hash matches the following words
    case 'uno' : case 'dos' : case 'tres' : 
      // set masonry options animate to false
      masonryOptions.animate = false;
      // hide boxes that don't match the filter class
      $wall.children().not('.'+possibleFilterClass)
        .toggleClass('invis').hide();
      // run masonry again, this time with the necessary stuff hidden
      $wall.masonry(masonryOptions);
      break;
    }
  }
});

$('#menu_tiendas a').click(function(){
  var 
    color = $(this).attr('class'),
    filterClass = '.' + color;
  ;

  if (filterClass == '.all') {
	  
// show all hidden boxes
	
    $wall.children('.invis')
      .toggleClass('invis').fadeIn(speed);
  } else {
	  
// hide visible boxes 

    $wall.children().not(filterClass).not('.invis')
      .toggleClass('invis').fadeOut(speed);
	  
// show hidden boxes

    $wall.children(filterClass+'.invis')
      .toggleClass('invis').fadeIn(speed);
  }
  $wall.masonry({ animate: true });
  
// set hash in URL
  window.location.hash = color;
  return false;
});




