/* Smooth Scroll */
function smoothTo(t) {
	var targetOffset = $(t).offset().top;
	$('html,body').animate({scrollTop: targetOffset}, 840);
	return false;
};

/* Folio Setup */
var folios = new Array();
function showTab(group, index) {
	$(folios[group]).parent().find("li").removeClass("current");
	$(folios[group]).parent().find("li:nth-child(" + (index+1) + ")").addClass("current");
	$(folios[group]).find(".images").animate({left: -670 * index},340);
};

$(function() {
	$(".folio").each(function(i){
		folios[i] = $(this);
		
		var folioTabs = "<ol class=\"folio-tabs\">"
		
		$(this).find("img").each(function(j){
			$(this).css({
				left: j*670,
				display: "block"
			});
			folioTabs += "<li><a onclick=\"showTab(" + i + "," + j + ")\">Image " + (j+1) + "</a></li>";
		});
		
		$(this).parent().find("h3").after(folioTabs);
		$(".folio-tabs").find("li:nth-child(1)").addClass("current");
	});
});
