var hBox = 0;
var ch = 0
var speed = 500;
var hTop = new Array();
var top = 0;
var nBox = 0;
$(document).ready(function(){
	hBox = $("#elencoDocumenti").height();

	margin = $(".singoloDocumento").css( 'margin-bottom' );
	margin = parseInt( margin );	
	for( i = 0; i < nBox; i++ )
	{
		hTop[i] = $(".singoloDocumento:eq("+i+")").height() + margin;
	}	
});
function scrollDocumenti( d )
{
	if( top == 0 )
		top = $("#elencoDocumenti").position().top;

	//top = $("#elencoDocumenti").position().top;
	gap = hTop[ch];
	//alert( gap );
	if( d == 'up' && top < 0 )
	{
		ch--;	
		top = top + hTop[ch];
		$("#elencoDocumenti").animate({top: top},speed, function() {});
	} else if ( d == 'down' && ch < ( nBox - 1 ) )
	{
		top = top - gap;
		//alert( top );
		$("#elencoDocumenti").animate({top: top},speed, function() {});
		ch++;
	}
}
function caricaDocumento( i )
{
	$.getJSON("/public/caricaDocumento.php", { i : i },
		function( ris ){
			$(".abstract_news_fade").hide();
			$("#title_abstract_news_home").html( ris.documento_titolo );
			$("#txt_abstract_news_home").html( ris.documento_abstract );
			l = '/'+lang+'/news/'+ris.id_documento+'/'+ris.documento_url+'.php';
			$("#link_abstract_news_home").attr( 'href', l );
			$(".abstract_news_fade").fadeIn( "slow" );
			
			
	});
}
