var centered_div;

var offset_for = function(o) {
	return (($(window).width()-o.outerWidth())/2);
};

var slide_to = function(o,cb) {
	if (o.size()>0) {
		var $panel = $('#scrollable-panel');
		var offset = o.offset().left + $panel.scrollLeft() - offset_for(o);
		$panel.animate({ scrollLeft: offset+'px' }, 'fast', cb);
		centered_div = o;
	}
};

$(window).load(function() {
	
	// Frise offset
	var $frise = $("#frise");
	var left_margin;
	var frise_left_margin = function() {
		var first = $frise.children(":first");
		left_margin = offset_for(first)-16;
		$frise.css({marginLeft: left_margin+'px'});
	};
	frise_left_margin();
	$(window).resize(frise_left_margin);
	centered_div = $frise.children(":first");
	
	// Frise width
	var frise_width = 0;
	$frise.children().each(function() {
		frise_width += ($(this).outerWidth()+16);
	});
	$frise.css({width: frise_width-$('#credits').width()+'px'});
	$('#legs').width($('#frise').width()+left_margin);
	
	//$('#scrollable-panel').strokebars();
	
});

