// Scrolla il div 'contentDivId' di 'pixel' pixel e rende visibile o meno i div che contengono le freccettine next e previous 
function scrollDiv(contentDivId, pixel, previousDivId, nextDivId) {
	var contentDiv = $(contentDivId);
	var previousDiv = $(previousDivId);
	var nextDiv = $(nextDivId);

	//alert(contentDiv.getProperties());
	var numOfPages = contentDiv.getProperty('numOfPages');
	var currentPage = contentDiv.getProperty('currentPage');

	// Sposto il contentDiv
	var currentLeft = contentDiv.getStyle('left').toInt();
	//currentLeft = currentLeft + pixel;
	//contentDiv.setStyle('left', currentLeft);
	var myEffect = new Fx.Morph(contentDivId, {duration: 250, transition: Fx.Transitions.Quad.easeIn});
	myEffect.start({
		'left': [currentLeft,currentLeft + pixel]
	});
	
	myEffect.onComplete=function(){
		// Aggiorno il numero di pagina
		if (pixel > 0)
			currentPage--;
		if (pixel < 0)
			currentPage++;
		contentDiv.setProperty('currentPage', currentPage);
		
		// Mostro o nascondo le frecce
		if (currentPage == 1)
			previousDiv.setStyle('display', 'none');
		else
			previousDiv.setStyle('display', 'block');

		if (currentPage < numOfPages)
			nextDiv.setStyle('display', 'block');
		else
			nextDiv.setStyle('display', 'none');
	}

	return false;
}

// Inizializza lo scroll: effettua una finta traslazione di 0 pixel, solamente per sistemare la visibilità delle freccie
// Questo metodo può essere chiamato sull'onload del body delle pagine
function initScroll() {
	scrollDiv('boxAffini_content', 0, 'boxAffini_previous', 'boxAffini_next');
}