$(document).ready(function() {
	
	setup_blog_scroller();
	
});

function setup_blog_scroller() {

	var current_blog_post = 1;
	var max_blog_posts = $(".post_scroller > div").size();

	$('#prev_blog_post').click(function() {
		if(current_blog_post > 1 && !scroll_disabled) {
			swap_blog_post(current_blog_post, --current_blog_post);
		}
		return false
	});
	
	$('#next_blog_post').click(function() {
		if(current_blog_post < max_blog_posts && !scroll_disabled) {
			swap_blog_post(current_blog_post, ++current_blog_post);
		}
		return false
	});
}

var scroll_disabled = false;
var fade_speed = 1000;
function swap_blog_post(first_id, next_id) {
	scroll_disabled = true;
	$('#blog_post_'+first_id).fadeOut(fade_speed, function() {
		$('#blog_post_'+next_id).fadeIn(fade_speed, function() {
			scroll_disabled = false;
			
		});
	});
	return false
}
