$(window).load(function() {
	var originalFontSize = 16;
	var sectionWidth = $('.box').width();

	$('.box span').each(function(){
		var spanWidth = $(this).width();
		var newFontSize = (sectionWidth/spanWidth) * originalFontSize;
		$(this).css({"font-size" : newFontSize, "line-height" : newFontSize/1.100 + "px", "font-family" : "Impact, Charcoal, sans-serif", "margin" : "0", "padding" : "0", "letter-spacing" : "-2px", "font-weight" : "normal", "text-transform" : "uppercase", "color" : "#8b6a56" });
	
});

	//Masonry
    var $container = $('#mason');
  
    $container.imagesLoaded(function(){
      $container.masonry({
        itemSelector: '.box',
		gutterWidth: 10,
		columnWidth: 180,
		singleMode: true,	
      });
	  
	 //Infinite Scroll
	 $container.infinitescroll({
	loading			: {
	msgText		: "<div class='mason-msg'>Cargando...</div>",
	finishedMsg	: "<div class='mason-msg no-more'>No, mentira.</div>"
	},
	state			: {
	currPage	: "1"
	},
	nextSelector    : ".post-previous a",
	navSelector     : "#post-nav",
	itemSelector    : ".box",
	pathParse		: ["/page/", "/"]
	}, function( newElements ) { 
	var $newElems = $( newElements ).css({ opacity: 0 });
	$newElems.imagesLoaded(function(){
          $newElems.animate({ opacity: 1 });
          $container.masonry( 'appended', $newElems, true ); 
        });
	
	$('.box').hover(function(){  
        $(".cover", this).stop().animate({bottom:'0px'},{queue:false,duration:300});  
    }, function() {  
        $(".cover", this).stop().animate({bottom:'-260px'},{queue:false,duration:300});  
    });
	
	} );
	  
    });
  });

$(window).load(function() {
//Captions
$('.box').hover(function(){  
        $(".cover", this).stop().animate({bottom:'0px'},{queue:false,duration:300});  
    }, function() {  
        $(".cover", this).stop().animate({bottom:'-260px'},{queue:false,duration:300});  
    });
});
	//Scrolling
$('a[href*=#]').click(function() {
 if (location.pathname.replace(/^\//,'')
        == this.pathname.replace(/^\//,'')
        && location.hostname == this.hostname) {
    var $target = $(this.hash);
    $target = $target.length && $target
            || $('[name=' + this.hash.slice(1) +']');
    if ($target.length) {
      var targetOffset = $target.offset().top;
      $('html,body').animate({scrollTop: targetOffset}, 1000);
      return false;
    }
  }
});

addEventListener("load", function() { setTimeout(
hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); }
