jQuery(document).ready(function($) {
	var postPaginatiorActive = false;
		
	if($('.singlePost').length < 1) {
		$(window).scroll(function () {
			if($('#contentFrame').height() < (250+window.pageYOffset+window.innerHeight)) {
				if(!postPaginatiorActive) {
					postPaginatiorActive = true;
					postPaginatorCurrentPage++;
	
					$('<span></span>').load(currentUrl+'page/'+postPaginatorCurrentPage+'/?ajaxPaginator=1 #content', function(response, status, xhr) {
						  if (status != "error" && $.trim($(this).children('#content').html()) != 'finished') {
							    $('#content').append($(this).children('#content').html());
							    postPaginatiorActive = false;
							  }
						});
				}
			}
		});
	}
	
	$('div.post_social').click(function(e) {
		var more = $(this).children('span.post_more_social').get(0);
		var overlay = $(this).children('div.post_more_social_overlay');
		if(more == e.target && !overlay.hasClass('visible')) {
			overlay.addClass('visible');
			overlay.stop().fadeIn(200, function() { $(this).css('opacity', 1); });
		} else if(overlay.hasClass('visible')) {
			overlay.removeClass('visible');
			overlay.stop().fadeOut(200, function() { $(this).css('opacity', 1).hide(); });
		}
	});
	
	
	$('li.widget_avance_authors div.showAll').click(function() {
		$(this).hide();
		$('div.moreAuthors').stop().slideDown(200, function() {
			$('li.widget_avance_authors div.hideAll').show();
		});
	});
	$('li.widget_avance_authors div.hideAll').click(function() {
		$(this).hide();
		$('div.moreAuthors').stop().slideUp(200, function() {
			$(this).css('height', 'auto');
			$('li.widget_avance_authors div.showAll').show();
		});
	});
});
