$(document).ready(function(){
  var body = $('html, body');


  $('a.btn-up').click(function() {
    $(body).animate({scrollTop : 0},600);
  });

  $('.slide-here').scrollable();

  $('#show-map').click( function(event){
    $('.tabset a').removeClass('active');
    $('.extra a').removeClass('active');
    $('#link-tab-map').addClass('active');
    $('.tab-content').hide();
    $('#tab-map').show();
  });

  $('.tabset a.tab').click(dofix);
  $('.extra a.tab').click(dofix);
  
  function dofix(event){
    $('.tabarea .tabset .active').removeClass('active');
    $('.tabarea2 .extra .active').removeClass('active');
    $(this).addClass('active');

    var id = $(this).attr('id');
    var substart = 'link-'; 
    id = id.substr(substart.length);

    $('.tabarea .tab-content').hide();
    $('.tabarea #'+id).show();
    $('.tabarea2 .tab-content').hide();
    $('.tabarea2 #'+id).show();

  }
  
  $('#btn-more').click(function(event){
    $('#content .posts li.hidden:lt(6)').each(function(el){
      $(this).removeClass('hidden');
      $(this).addClass('todisplay');
    });
    if(!$('#content .posts li.hidden').length){
      removeButton($(this));
    }
    $('#content .posts li.todisplay').slideDown('slow', function(){
      removeEmptyPictures();
    });

  });

  
});//document.ready
function removeButton(el){
  el.parent().fadeOut('slow'); 
}//removeButton

function removeEmptyPictures(){
  /*$('.facebook-attachment img').each( function(){
    if ( $(this).width() < 2 && $(this).parent('.posts li').attr('class') != 'hidden' ){
      console.log( $(this).width() )
      $(this).parent('.facebook-link').hide() ;
    }//if

  });
  */
}
