$(document).ready(function(){

	$(".footer > div > ul > li:not(.footer > div > ul > li:last)").after(" <span class=\"separator\">|</span> ");
	
	$('.slideshow .images').cycle({
		fx: 'fade',
		pause: 0,
		speed: 1000,
		timeout: 5000,
		before: cycleBefore
	});
	
	
	$('.navigation > div > ul > li').each(function() {
        $(this).find("li").width($(this).find("> ul").innerWidth());
    });
	
	
	
	
	var scrollwidth = $(".scrollable-wrapper .post").size()*185;
	if (scrollwidth % 925 > 0) {
		scrollwidth = scrollwidth + (925-(scrollwidth % 925));
	}
	$(".scrollable-wrapper").width(scrollwidth);
	
	var currentPage = 1;
	var totalPage = scrollwidth / 925;
	
	$(".scrollable-wrapper").scrollTo({top:'0px', left:'0px'}, 1 );
	
	$("#prev").bind("click", function() {
		if (currentPage > 1) {
			$(".scrollable").scrollTo({top:'-=0px', left:'-=925px'}, 500 );
			currentPage--;
		} else {
			$(".scrollable").scrollTo({top:'-=0px', left: totalPage*925 }, 500 );
			currentPage = totalPage;
		}
	});
	$("#next").bind("click", function() {
		if (currentPage < totalPage) {
			$(".scrollable").scrollTo({top:'-=0px', left:'+=925px'}, 500 );
			currentPage++;
		} else {
			$(".scrollable").scrollTo({top:'-=0px', left:'0px'}, 500 );
			currentPage = 1;
		}
	});
	
});
function cycleBefore(currSlideElement, nextSlideElement, options, forwardFlag) {
	$(nextSlideElement).find(".sepia").animate({ opacity:1 }, 1);
	$(nextSlideElement).find(".sepia").delay(1500).animate({ opacity:0 }, 2000);
}
