var numElem = 3; //numero elementi visualizzati contemporaneamente
var numeroLi = $("div.box_home", ".scrollable").length;
$(".items", ".scrollable").width(((numeroLi * 325) + numeroLi - 1)); // numeroLi moltiplicato per il reale ingombro misurato come width + margin + border (ci andrebbe un caso particolare per IE6 che calcola il padding esternamente a width)

$.easing.custom = function(x, t, b, c, d) {
    var s = 1.70158;
    if ((t /= d / 2) < 1) return c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b;
    return c / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2) + b;
}
$(".scrollable").scrollable({ easing: 'custom', speed: 2000, circular: false });

var whatWasClicked = "";
var stopped = false;
var api = $(".scrollable").data("scrollable");
$("a.next").click(function() { whatWasClicked = "right"; });
$("a.left").click(function() {
	whatWasClicked = "left";
	if (stopped == true && whatWasClicked == "left") { api.prev(); }
});
api.onBeforeSeek(function(event) { 
	if (parseInt(api.getIndex()) > parseInt(numeroLi - (numElem + 2))) { $("a.next").hide(); }
    else { $("a.next").show(); }
	
	if (whatWasClicked == "right" && stopped == true) { 
		event.preventDefault(); 
	}
});
api.onSeek(function(event) {
    if (parseInt(api.getIndex()) > parseInt(numeroLi - (numElem + 1))) { stopped = true; $("a.next").hide(); }
    else { stopped = false; $("a.next").show(); }
});

